@sixb/core 0.2.5 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/index.js +36 -35
- package/dist/actions/index.js.map +1 -1
- package/dist/actions/validation.d.ts.map +1 -1
- package/dist/agents/errors.d.ts +1 -1
- package/dist/agents/errors.d.ts.map +1 -1
- package/dist/agents/execution.d.ts +17 -2
- package/dist/agents/execution.d.ts.map +1 -1
- package/dist/agents/index.d.ts +3 -3
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +53 -45
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/model-routing.d.ts +16 -2
- package/dist/agents/model-routing.d.ts.map +1 -1
- package/dist/agents/request.d.ts +45 -4
- package/dist/agents/request.d.ts.map +1 -1
- package/dist/agents/run-events.d.ts +4 -0
- package/dist/agents/run-events.d.ts.map +1 -1
- package/dist/agents/run-session-children.d.ts.map +1 -1
- package/dist/agents/run-token.d.ts +6 -0
- package/dist/agents/run-token.d.ts.map +1 -1
- package/dist/agents/run-turn.d.ts +9 -1
- package/dist/agents/run-turn.d.ts.map +1 -1
- package/dist/agents/streams/index.d.ts +1 -1
- package/dist/agents/streams/index.d.ts.map +1 -1
- package/dist/agents/streams/index.js +1 -1
- package/dist/agents/streams/internal.d.ts +2 -1
- package/dist/agents/streams/internal.d.ts.map +1 -1
- package/dist/agents/streams/internal.js +22 -2
- package/dist/agents/streams/internal.js.map +1 -1
- package/dist/agents/streams/protocol.d.ts +37 -0
- package/dist/agents/streams/protocol.d.ts.map +1 -1
- package/dist/agents/streams/steps.d.ts +24 -0
- package/dist/agents/streams/steps.d.ts.map +1 -0
- package/dist/agents/thread-access.d.ts +44 -2
- package/dist/agents/thread-access.d.ts.map +1 -1
- package/dist/artifacts/live/server.js +19 -18
- package/dist/artifacts/live/server.js.map +1 -1
- package/dist/artifacts/publish/index.js +18 -17
- package/dist/artifacts/publish/index.js.map +1 -1
- package/dist/artifacts/publish/merge.d.ts +2 -1
- package/dist/artifacts/publish/merge.d.ts.map +1 -1
- package/dist/artifacts/run-query.d.ts.map +1 -1
- package/dist/auth/index.js +6 -6
- package/dist/authorization/index.js +2 -2
- package/dist/bootstrap/discovery.d.ts +6 -0
- package/dist/bootstrap/discovery.d.ts.map +1 -1
- package/dist/bootstrap/index.js +40 -38
- package/dist/bootstrap/index.js.map +2 -2
- package/dist/calendar.d.ts +55 -0
- package/dist/calendar.d.ts.map +1 -0
- package/dist/calendar.js +19 -0
- package/dist/calendar.js.map +9 -0
- package/dist/chunk-04r2fdsd.js +386 -0
- package/dist/chunk-04r2fdsd.js.map +14 -0
- package/dist/{chunk-gjhrz66x.js → chunk-06kpaqg4.js} +248 -21
- package/dist/{chunk-gjhrz66x.js.map → chunk-06kpaqg4.js.map} +6 -6
- package/dist/{chunk-5a4a52tq.js → chunk-0pmpwn3g.js} +18 -2
- package/dist/chunk-0pmpwn3g.js.map +10 -0
- package/dist/{chunk-nxysqbt0.js → chunk-389ybvw9.js} +6 -2
- package/dist/chunk-389ybvw9.js.map +10 -0
- package/dist/{chunk-xcrnrpfh.js → chunk-394zjzjs.js} +20 -10
- package/dist/{chunk-xcrnrpfh.js.map → chunk-394zjzjs.js.map} +5 -5
- package/dist/{chunk-stmxh0hv.js → chunk-3neam1y5.js} +2 -2
- package/dist/{chunk-zeykm8my.js → chunk-3qtk0070.js} +16 -42
- package/dist/chunk-3qtk0070.js.map +14 -0
- package/dist/{chunk-0hkdtwqk.js → chunk-44hrfmbk.js} +5 -5
- package/dist/{chunk-ey1p8w68.js → chunk-5pz3htbe.js} +86 -5
- package/dist/chunk-5pz3htbe.js.map +13 -0
- package/dist/{chunk-s5pj68fa.js → chunk-5sswe5ej.js} +2 -2
- package/dist/{chunk-k3jh8gsg.js → chunk-5xkqasvn.js} +21 -4
- package/dist/chunk-5xkqasvn.js.map +10 -0
- package/dist/{chunk-5t9gm5tt.js → chunk-6md802cc.js} +38 -14
- package/dist/chunk-6md802cc.js.map +22 -0
- package/dist/{chunk-3zagkr6w.js → chunk-7mhbs9yy.js} +4 -4
- package/dist/{chunk-3zagkr6w.js.map → chunk-7mhbs9yy.js.map} +1 -1
- package/dist/{chunk-ewqn51gr.js → chunk-88xeh6zx.js} +6 -4
- package/dist/{chunk-ewqn51gr.js.map → chunk-88xeh6zx.js.map} +4 -4
- package/dist/{chunk-z1njfqqs.js → chunk-8qmp9fpa.js} +783 -171
- package/dist/{chunk-z1njfqqs.js.map → chunk-8qmp9fpa.js.map} +13 -13
- package/dist/{chunk-r2psmn42.js → chunk-95ps0k5q.js} +3 -3
- package/dist/{chunk-r2psmn42.js.map → chunk-95ps0k5q.js.map} +3 -3
- package/dist/{chunk-fpf57gca.js → chunk-9cyq87qa.js} +276 -68
- package/dist/{chunk-fpf57gca.js.map → chunk-9cyq87qa.js.map} +6 -6
- package/dist/{chunk-q9nkpr8k.js → chunk-9tpmfh3n.js} +1 -1
- package/dist/chunk-9wr3yajk.js.map +2 -2
- package/dist/{chunk-naxjka9v.js → chunk-brhp9d97.js} +2 -2
- package/dist/{chunk-8a8k38tz.js → chunk-brybqw5k.js} +1 -1
- package/dist/{chunk-vehcr9eb.js → chunk-cg7cygfj.js} +1 -1
- package/dist/{chunk-b4escq4c.js → chunk-cpy282b8.js} +6 -6
- package/dist/chunk-dq3t5sr3.js +114 -0
- package/dist/chunk-dq3t5sr3.js.map +11 -0
- package/dist/{chunk-68hm50qh.js → chunk-fdk0ks9p.js} +16 -46
- package/dist/chunk-fdk0ks9p.js.map +12 -0
- package/dist/{chunk-fzae1jpq.js → chunk-fycac8e9.js} +50 -16
- package/dist/{chunk-fzae1jpq.js.map → chunk-fycac8e9.js.map} +3 -3
- package/dist/{chunk-zft9bzbc.js → chunk-hkbks1xm.js} +2 -1
- package/dist/{chunk-zft9bzbc.js.map → chunk-hkbks1xm.js.map} +3 -3
- package/dist/{chunk-m3qx2pns.js → chunk-hvq8xs66.js} +28 -12
- package/dist/{chunk-m3qx2pns.js.map → chunk-hvq8xs66.js.map} +5 -5
- package/dist/{chunk-bc3y6gff.js → chunk-jka26v8c.js} +1 -1
- package/dist/{chunk-s1mqyqmm.js → chunk-js9e6487.js} +12 -8
- package/dist/chunk-js9e6487.js.map +18 -0
- package/dist/{chunk-zxhym8tr.js → chunk-k29rdc3h.js} +1 -1
- package/dist/{chunk-rg725hry.js → chunk-m1cwncee.js} +86 -34
- package/dist/{chunk-rg725hry.js.map → chunk-m1cwncee.js.map} +8 -8
- package/dist/{chunk-1yh6jgtz.js → chunk-mrs7jy17.js} +2 -2
- package/dist/{chunk-qavwr628.js → chunk-n1hbwc6y.js} +5 -6
- package/dist/chunk-n1hbwc6y.js.map +12 -0
- package/dist/{chunk-pqvvqc65.js → chunk-pfdq1ga6.js} +3 -3
- package/dist/{chunk-k29n4176.js → chunk-phs5fbff.js} +6 -6
- package/dist/{chunk-wqe9shx2.js → chunk-qbd282aa.js} +2 -2
- package/dist/{chunk-e91fmg6t.js → chunk-qsa7nw6f.js} +2 -1
- package/dist/{chunk-e91fmg6t.js.map → chunk-qsa7nw6f.js.map} +3 -3
- package/dist/chunk-r588h4ev.js +98 -0
- package/dist/chunk-r588h4ev.js.map +10 -0
- package/dist/{chunk-rtdrm592.js → chunk-t58sktr5.js} +12 -4
- package/dist/{chunk-rtdrm592.js.map → chunk-t58sktr5.js.map} +3 -3
- package/dist/{chunk-paxabbqd.js → chunk-tapdssb5.js} +1 -1
- package/dist/{chunk-dhkc9b23.js → chunk-v8a1qjzp.js} +1 -1
- package/dist/{chunk-q8d9p0tb.js → chunk-wzcjhv54.js} +8 -1
- package/dist/{chunk-q8d9p0tb.js.map → chunk-wzcjhv54.js.map} +3 -3
- package/dist/{chunk-pc7kra3k.js → chunk-xavet0qs.js} +1 -1
- package/dist/{chunk-m9ketb51.js → chunk-ygvay56w.js} +1 -1
- package/dist/{chunk-0mvjpgvm.js → chunk-yyj009tv.js} +4 -4
- package/dist/connectors/connections/capability.d.ts +11 -0
- package/dist/connectors/connections/capability.d.ts.map +1 -1
- package/dist/connectors/connections/internal.d.ts +2 -1
- package/dist/connectors/connections/internal.d.ts.map +1 -1
- package/dist/connectors/connections/internal.js +8 -4
- package/dist/connectors/connections/internal.js.map +1 -1
- package/dist/connectors/connections/service.d.ts +9 -1
- package/dist/connectors/connections/service.d.ts.map +1 -1
- package/dist/connectors/execution.d.ts +7 -1
- package/dist/connectors/execution.d.ts.map +1 -1
- package/dist/connectors/service.d.ts +5 -1
- package/dist/connectors/service.d.ts.map +1 -1
- package/dist/deploy/index.d.ts +1 -1
- package/dist/deploy/index.d.ts.map +1 -1
- package/dist/deploy/internal.js +2 -2
- package/dist/deploy/internal.js.map +2 -2
- package/dist/deploy/types.d.ts +12 -59
- package/dist/deploy/types.d.ts.map +1 -1
- package/dist/env/index.d.ts +10 -3
- package/dist/env/index.d.ts.map +1 -1
- package/dist/env/index.js.map +2 -2
- package/dist/events/execution.d.ts +8 -1
- package/dist/events/execution.d.ts.map +1 -1
- package/dist/events/types/syncs.d.ts +4 -0
- package/dist/events/types/syncs.d.ts.map +1 -1
- package/dist/execution/agent.js +37 -36
- package/dist/execution/agent.js.map +1 -1
- package/dist/execution/authorized-object-reader.d.ts +4 -0
- package/dist/execution/authorized-object-reader.d.ts.map +1 -1
- package/dist/execution/object-reader-ontology.d.ts +3 -0
- package/dist/execution/object-reader-ontology.d.ts.map +1 -1
- package/dist/execution/primitive.js +36 -35
- package/dist/execution/primitive.js.map +1 -1
- package/dist/execution/request.d.ts +1 -1
- package/dist/execution/request.d.ts.map +1 -1
- package/dist/execution/request.js +33 -32
- package/dist/execution/request.js.map +3 -3
- package/dist/http/api-routes.d.ts.map +1 -1
- package/dist/http/index.js +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +63 -59
- package/dist/index.js.map +1 -1
- package/dist/maintenance/index.js +1 -1
- package/dist/materializer/index.js +22 -21
- package/dist/materializer/index.js.map +1 -1
- package/dist/models/audio/runtime.d.ts.map +1 -1
- package/dist/models/audio/types.d.ts +19 -0
- package/dist/models/audio/types.d.ts.map +1 -1
- package/dist/models/execution/index.js +20 -19
- package/dist/models/execution/index.js.map +1 -1
- package/dist/models/index.d.ts +1 -1
- package/dist/models/index.d.ts.map +1 -1
- package/dist/objects/index.js +36 -35
- package/dist/objects/index.js.map +1 -1
- package/dist/objects/query/executor.d.ts +3 -1
- package/dist/objects/query/executor.d.ts.map +1 -1
- package/dist/objects/query/explain.d.ts +3 -1
- package/dist/objects/query/explain.d.ts.map +1 -1
- package/dist/objects/query/index.d.ts +1 -1
- package/dist/objects/query/index.d.ts.map +1 -1
- package/dist/objects/query/index.js +19 -18
- package/dist/objects/query/index.js.map +1 -1
- package/dist/objects/query/link-query-clearance.d.ts +3 -0
- package/dist/objects/query/link-query-clearance.d.ts.map +1 -1
- package/dist/objects/query/links.d.ts +1 -1
- package/dist/objects/query/links.d.ts.map +1 -1
- package/dist/objects/query/validate.d.ts +17 -0
- package/dist/objects/query/validate.d.ts.map +1 -1
- package/dist/objects/sdk/runtime-query-executor.d.ts +1 -1
- package/dist/objects/sdk/runtime-query-executor.d.ts.map +1 -1
- package/dist/ontology/index.js +3 -3
- package/dist/ontology/internal.js +3 -3
- package/dist/pipelines/index.js +21 -20
- package/dist/pipelines/index.js.map +1 -1
- package/dist/projections/internal.js +20 -19
- package/dist/projections/internal.js.map +1 -1
- package/dist/queues/in-memory.d.ts +1 -1
- package/dist/queues/in-memory.d.ts.map +1 -1
- package/dist/runtime/create.d.ts.map +1 -1
- package/dist/runtime/definitions.d.ts +14 -0
- package/dist/runtime/definitions.d.ts.map +1 -1
- package/dist/runtime/host.d.ts +3 -1
- package/dist/runtime/host.d.ts.map +1 -1
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/internal.js +24 -23
- package/dist/runtime/internal.js.map +2 -2
- package/dist/runtime/locale.d.ts +0 -2
- package/dist/runtime/locale.d.ts.map +1 -1
- package/dist/runtime/resolve-definitions.d.ts +2 -1
- package/dist/runtime/resolve-definitions.d.ts.map +1 -1
- package/dist/runtime/sixb.d.ts.map +1 -1
- package/dist/sandboxes/auth.d.ts +26 -4
- package/dist/sandboxes/auth.d.ts.map +1 -1
- package/dist/sandboxes/errors.d.ts +19 -0
- package/dist/sandboxes/errors.d.ts.map +1 -1
- package/dist/sandboxes/exec.d.ts +2 -0
- package/dist/sandboxes/exec.d.ts.map +1 -1
- package/dist/sandboxes/index.d.ts +4 -2
- package/dist/sandboxes/index.d.ts.map +1 -1
- package/dist/sandboxes/index.js +13 -7
- package/dist/sandboxes/index.js.map +1 -1
- package/dist/sandboxes/sandbox.d.ts +15 -1
- package/dist/sandboxes/sandbox.d.ts.map +1 -1
- package/dist/security/view-conditions.d.ts.map +1 -1
- package/dist/shares/internal.js +16 -15
- package/dist/shares/internal.js.map +2 -2
- package/dist/storage/agents/in-memory.d.ts +18 -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 +43 -9
- package/dist/storage/agents/provider.d.ts.map +1 -1
- package/dist/storage/agents/provider.js +19 -3
- package/dist/storage/agents/provider.js.map +1 -1
- package/dist/storage/agents/types.d.ts +150 -4
- package/dist/storage/agents/types.d.ts.map +1 -1
- package/dist/storage/ai-cost/analytics.d.ts +3 -2
- package/dist/storage/ai-cost/analytics.d.ts.map +1 -1
- package/dist/storage/ai-cost/provider.js +4 -3
- package/dist/storage/ai-cost/provider.js.map +1 -1
- package/dist/storage/ai-cost/types.d.ts +5 -1
- package/dist/storage/ai-cost/types.d.ts.map +1 -1
- package/dist/storage/artifacts/in-memory.d.ts.map +1 -1
- package/dist/storage/artifacts/record.d.ts +3 -1
- package/dist/storage/artifacts/record.d.ts.map +1 -1
- package/dist/storage/artifacts/types.d.ts +7 -0
- package/dist/storage/artifacts/types.d.ts.map +1 -1
- package/dist/storage/file-upload-sessions/provider.js +7 -7
- package/dist/storage/index.d.ts +2 -2
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +23 -22
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/internal.js +8 -8
- package/dist/storage/operation-scope.d.ts.map +1 -1
- package/dist/storage/operation-scope.js +1 -1
- package/dist/storage/sync-runs/idempotency.d.ts.map +1 -1
- package/dist/storage/sync-runs/in-memory.d.ts +2 -1
- package/dist/storage/sync-runs/in-memory.d.ts.map +1 -1
- package/dist/storage/sync-runs/index.d.ts +1 -1
- package/dist/storage/sync-runs/index.d.ts.map +1 -1
- package/dist/storage/sync-runs/types.d.ts +27 -2
- package/dist/storage/sync-runs/types.d.ts.map +1 -1
- package/dist/storage/workflow-runs/provider.js +7 -7
- package/dist/syncs/accounts.d.ts +36 -0
- package/dist/syncs/accounts.d.ts.map +1 -0
- package/dist/syncs/builders.d.ts.map +1 -1
- package/dist/syncs/connections.d.ts +36 -0
- package/dist/syncs/connections.d.ts.map +1 -0
- package/dist/syncs/execution.d.ts +14 -4
- package/dist/syncs/execution.d.ts.map +1 -1
- package/dist/syncs/index.d.ts +2 -1
- package/dist/syncs/index.d.ts.map +1 -1
- package/dist/syncs/index.js +22 -21
- package/dist/syncs/index.js.map +1 -1
- package/dist/syncs/request.d.ts +16 -2
- package/dist/syncs/request.d.ts.map +1 -1
- package/dist/syncs/run-dispatch.d.ts +14 -2
- package/dist/syncs/run-dispatch.d.ts.map +1 -1
- package/dist/testing/agent-approval-storage-contract.d.ts.map +1 -1
- package/dist/testing/agent-inbox-storage-contract.d.ts.map +1 -1
- package/dist/testing/agent-storage-contract.d.ts.map +1 -1
- package/dist/testing/ai-cost-storage-contract.d.ts.map +1 -1
- package/dist/testing/artifact-storage-contract.d.ts.map +1 -1
- package/dist/testing/index.js +1157 -100
- package/dist/testing/index.js.map +9 -9
- package/dist/testing/run-claim-storage-contract.d.ts.map +1 -1
- package/dist/testing/sandboxes-contract.d.ts.map +1 -1
- package/dist/webhooks/internal.js +17 -16
- package/dist/webhooks/internal.js.map +2 -2
- package/dist/workers/index.js +66 -13
- package/dist/workers/index.js.map +4 -4
- package/dist/workers/queue-worker.d.ts +5 -0
- package/dist/workers/queue-worker.d.ts.map +1 -1
- package/dist/workers/worker.d.ts +8 -0
- package/dist/workers/worker.d.ts.map +1 -1
- package/dist/workflows/index.js +42 -40
- package/dist/workflows/index.js.map +1 -1
- package/package.json +7 -1
- package/src/actions/validation.ts +3 -1
- package/src/agents/children.ts +6 -0
- package/src/agents/errors.ts +3 -0
- package/src/agents/execution.ts +170 -20
- package/src/agents/index.ts +5 -0
- package/src/agents/model-routing.ts +116 -34
- package/src/agents/request.ts +783 -38
- package/src/agents/run-events.ts +235 -38
- package/src/agents/run-session-children.ts +13 -2
- package/src/agents/run-token.ts +7 -0
- package/src/agents/run-turn.ts +140 -23
- package/src/agents/streams/index.ts +2 -0
- package/src/agents/streams/internal.ts +12 -0
- package/src/agents/streams/protocol.ts +69 -1
- package/src/agents/streams/steps.ts +131 -0
- package/src/agents/thread-access.ts +57 -2
- package/src/artifacts/publish/merge.ts +14 -3
- package/src/artifacts/run-query.ts +5 -2
- package/src/bootstrap/discovery.ts +61 -11
- package/src/calendar.ts +195 -0
- package/src/connectors/connections/capability.ts +40 -0
- package/src/connectors/connections/internal.ts +3 -0
- package/src/connectors/connections/service.ts +74 -5
- package/src/connectors/execution.ts +5 -6
- package/src/connectors/service.ts +23 -0
- package/src/deploy/index.ts +0 -5
- package/src/deploy/types.ts +12 -64
- package/src/deploy/validation.ts +1 -1
- package/src/env/index.ts +10 -4
- package/src/events/execution.ts +42 -2
- package/src/events/types/syncs.ts +4 -0
- package/src/execution/authorized-object-reader.ts +33 -5
- package/src/execution/object-reader-ontology.ts +6 -0
- package/src/execution/request.ts +1 -0
- package/src/http/api-routes.ts +8 -0
- package/src/index.ts +21 -2
- package/src/models/audio/runtime.ts +57 -14
- package/src/models/audio/types.ts +20 -0
- package/src/models/index.ts +1 -0
- package/src/objects/query/executor.ts +4 -0
- package/src/objects/query/explain.ts +5 -0
- package/src/objects/query/index.ts +1 -0
- package/src/objects/query/link-query-clearance.ts +4 -1
- package/src/objects/query/links.ts +5 -1
- package/src/objects/query/validate.ts +33 -1
- package/src/objects/sdk/runtime-query-executor.ts +7 -3
- package/src/runtime/create.ts +1 -0
- package/src/runtime/definitions.ts +25 -0
- package/src/runtime/host.ts +16 -8
- package/src/runtime/index.ts +6 -1
- package/src/runtime/locale.ts +0 -10
- package/src/runtime/resolve-definitions.ts +7 -1
- package/src/runtime/sixb.ts +12 -2
- package/src/sandboxes/README.md +12 -1
- package/src/sandboxes/auth.ts +32 -4
- package/src/sandboxes/errors.ts +27 -0
- package/src/sandboxes/exec.ts +3 -1
- package/src/sandboxes/index.ts +18 -1
- package/src/sandboxes/sandbox.ts +15 -1
- package/src/security/view-conditions.ts +2 -1
- package/src/storage/agents/in-memory.ts +271 -6
- package/src/storage/agents/index.ts +10 -0
- package/src/storage/agents/provider.ts +178 -13
- package/src/storage/agents/types.ts +166 -4
- package/src/storage/ai-cost/analytics.ts +22 -43
- package/src/storage/ai-cost/types.ts +5 -1
- package/src/storage/artifacts/in-memory.ts +20 -5
- package/src/storage/artifacts/record.ts +8 -2
- package/src/storage/artifacts/types.ts +7 -0
- package/src/storage/index.ts +11 -0
- package/src/storage/operation-scope.ts +1 -0
- package/src/storage/sync-runs/idempotency.ts +1 -0
- package/src/storage/sync-runs/in-memory.ts +43 -1
- package/src/storage/sync-runs/index.ts +1 -0
- package/src/storage/sync-runs/types.ts +30 -1
- package/src/syncs/accounts.ts +85 -0
- package/src/syncs/builders.ts +18 -1
- package/src/syncs/connections.ts +123 -0
- package/src/syncs/execution.ts +64 -22
- package/src/syncs/index.ts +3 -0
- package/src/syncs/request.ts +81 -23
- package/src/syncs/run-dispatch.ts +69 -7
- package/src/testing/agent-approval-storage-contract.ts +123 -0
- package/src/testing/agent-inbox-storage-contract.ts +59 -0
- package/src/testing/agent-storage-contract.ts +794 -8
- package/src/testing/ai-cost-storage-contract.ts +80 -0
- package/src/testing/artifact-storage-contract.ts +139 -0
- package/src/testing/run-claim-storage-contract.ts +116 -0
- package/src/testing/sandboxes-contract.ts +50 -0
- package/src/workers/README.md +4 -1
- package/src/workers/lost-runs.ts +1 -0
- package/src/workers/queue-worker.ts +16 -5
- package/src/workers/worker.ts +67 -7
- package/dist/chunk-5a4a52tq.js.map +0 -10
- package/dist/chunk-5t9gm5tt.js.map +0 -22
- package/dist/chunk-68hm50qh.js.map +0 -13
- package/dist/chunk-aw1z0gre.js +0 -234
- package/dist/chunk-aw1z0gre.js.map +0 -12
- package/dist/chunk-ey1p8w68.js.map +0 -13
- package/dist/chunk-k3jh8gsg.js.map +0 -10
- package/dist/chunk-nxysqbt0.js.map +0 -10
- package/dist/chunk-qavwr628.js.map +0 -12
- package/dist/chunk-s1mqyqmm.js.map +0 -18
- package/dist/chunk-zeykm8my.js.map +0 -14
- /package/dist/{chunk-stmxh0hv.js.map → chunk-3neam1y5.js.map} +0 -0
- /package/dist/{chunk-0hkdtwqk.js.map → chunk-44hrfmbk.js.map} +0 -0
- /package/dist/{chunk-s5pj68fa.js.map → chunk-5sswe5ej.js.map} +0 -0
- /package/dist/{chunk-q9nkpr8k.js.map → chunk-9tpmfh3n.js.map} +0 -0
- /package/dist/{chunk-naxjka9v.js.map → chunk-brhp9d97.js.map} +0 -0
- /package/dist/{chunk-8a8k38tz.js.map → chunk-brybqw5k.js.map} +0 -0
- /package/dist/{chunk-vehcr9eb.js.map → chunk-cg7cygfj.js.map} +0 -0
- /package/dist/{chunk-b4escq4c.js.map → chunk-cpy282b8.js.map} +0 -0
- /package/dist/{chunk-bc3y6gff.js.map → chunk-jka26v8c.js.map} +0 -0
- /package/dist/{chunk-zxhym8tr.js.map → chunk-k29rdc3h.js.map} +0 -0
- /package/dist/{chunk-1yh6jgtz.js.map → chunk-mrs7jy17.js.map} +0 -0
- /package/dist/{chunk-pqvvqc65.js.map → chunk-pfdq1ga6.js.map} +0 -0
- /package/dist/{chunk-k29n4176.js.map → chunk-phs5fbff.js.map} +0 -0
- /package/dist/{chunk-wqe9shx2.js.map → chunk-qbd282aa.js.map} +0 -0
- /package/dist/{chunk-paxabbqd.js.map → chunk-tapdssb5.js.map} +0 -0
- /package/dist/{chunk-dhkc9b23.js.map → chunk-v8a1qjzp.js.map} +0 -0
- /package/dist/{chunk-pc7kra3k.js.map → chunk-xavet0qs.js.map} +0 -0
- /package/dist/{chunk-m9ketb51.js.map → chunk-ygvay56w.js.map} +0 -0
- /package/dist/{chunk-0mvjpgvm.js.map → chunk-yyj009tv.js.map} +0 -0
|
@@ -6,11 +6,14 @@ export {
|
|
|
6
6
|
agentRunControlStreamDefinition,
|
|
7
7
|
agentRunControlStreamId,
|
|
8
8
|
agentRunFinishedEvent,
|
|
9
|
+
agentRunStepsStreamDefinition,
|
|
10
|
+
agentRunStepsStreamId,
|
|
9
11
|
agentRunStreamDefinition,
|
|
10
12
|
agentRunStreamEventBase,
|
|
11
13
|
agentRunStreamId,
|
|
12
14
|
agentRunStreamIdempotencyKey,
|
|
13
15
|
DEFAULT_AGENT_ACTIVITY_STREAM_RETENTION,
|
|
16
|
+
DEFAULT_AGENT_RUN_STEPS_RETENTION,
|
|
14
17
|
DEFAULT_AGENT_RUN_STREAM_RETENTION,
|
|
15
18
|
publishAgentComputerActivity,
|
|
16
19
|
publishAgentRunActivity,
|
|
@@ -19,3 +22,12 @@ export {
|
|
|
19
22
|
publishAgentThreadMoved,
|
|
20
23
|
subscribeAgentRunCancel,
|
|
21
24
|
} from "./protocol"
|
|
25
|
+
export {
|
|
26
|
+
appendCompacted,
|
|
27
|
+
continuesDelta,
|
|
28
|
+
coveredBySteps,
|
|
29
|
+
type DeltaChunk,
|
|
30
|
+
isDeltaChunk,
|
|
31
|
+
mergeDeltas,
|
|
32
|
+
readAgentRunSteps,
|
|
33
|
+
} from "./steps"
|
|
@@ -22,6 +22,16 @@ export const DEFAULT_AGENT_RUN_STREAM_RETENTION = {
|
|
|
22
22
|
maxRecords: 5_000,
|
|
23
23
|
} as const
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* A run's finished steps, kept apart from its live stream: the live stream drops its oldest records,
|
|
27
|
+
* and a long turn outgrows it, so whoever opens a turn late reads what it did here. Records last as
|
|
28
|
+
* long as the longest turn, and the run's whole answer fits well within the byte limit.
|
|
29
|
+
*/
|
|
30
|
+
export const DEFAULT_AGENT_RUN_STEPS_RETENTION = {
|
|
31
|
+
maxAgeMs: 24 * 60 * 60 * 1000, // 24 hours
|
|
32
|
+
maxBytes: 64 * 1024 * 1024,
|
|
33
|
+
} as const
|
|
34
|
+
|
|
25
35
|
export const AGENT_ACTIVITY_STREAM_SCHEMA_VERSION = 1 as const
|
|
26
36
|
export const AGENT_ACTIVITY_STREAM_ID = "agents.activity" as const
|
|
27
37
|
export const DEFAULT_AGENT_ACTIVITY_STREAM_RETENTION = {
|
|
@@ -323,6 +333,16 @@ export function agentRunStreamDefinition(runId: string): BrokerStreamDefinition
|
|
|
323
333
|
}
|
|
324
334
|
}
|
|
325
335
|
|
|
336
|
+
export type AgentRunStepsStreamId = `agents.runs.${string}.steps`
|
|
337
|
+
|
|
338
|
+
export function agentRunStepsStreamId(runId: string): AgentRunStepsStreamId {
|
|
339
|
+
return `agents.runs.${runId}.steps`
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
export function agentRunStepsStreamDefinition(runId: string): BrokerStreamDefinition {
|
|
343
|
+
return { id: agentRunStepsStreamId(runId), retention: DEFAULT_AGENT_RUN_STEPS_RETENTION }
|
|
344
|
+
}
|
|
345
|
+
|
|
326
346
|
type AgentRunStreamEventBase = {
|
|
327
347
|
readonly schemaVersion: typeof AGENT_RUN_STREAM_SCHEMA_VERSION
|
|
328
348
|
readonly projectId: string
|
|
@@ -436,6 +456,12 @@ export interface AgentInboxReadMessage {
|
|
|
436
456
|
readonly createdAt: string
|
|
437
457
|
}
|
|
438
458
|
|
|
459
|
+
/** Messages a turn read in its finished steps, after the first `at` of their chunks. */
|
|
460
|
+
export interface AgentRunStepsRead {
|
|
461
|
+
readonly at: number
|
|
462
|
+
readonly messages: readonly AgentInboxReadMessage[]
|
|
463
|
+
}
|
|
464
|
+
|
|
439
465
|
export type AgentRunStreamEvent =
|
|
440
466
|
| (AgentRunStreamEventBase & {
|
|
441
467
|
readonly type: "agent.run.started"
|
|
@@ -466,6 +492,24 @@ export type AgentRunStreamEvent =
|
|
|
466
492
|
| (AgentRunStreamEventBase & {
|
|
467
493
|
readonly type: "agent.inbox.read"
|
|
468
494
|
readonly messages: readonly AgentInboxReadMessage[]
|
|
495
|
+
/**
|
|
496
|
+
* The last live chunk published before the turn read them, absent before the first: the
|
|
497
|
+
* finished steps that cover it hold this read too, where it happened.
|
|
498
|
+
*/
|
|
499
|
+
readonly afterChunkIndex?: number
|
|
500
|
+
})
|
|
501
|
+
| (AgentRunStreamEventBase & {
|
|
502
|
+
/**
|
|
503
|
+
* The turn's finished steps, as the chunks that rebuild them. Never a live record: the server
|
|
504
|
+
* sends it first to a reader who opens the turn late, and that reader then skips the live
|
|
505
|
+
* records it covers. It replaces whatever the reader rebuilt before.
|
|
506
|
+
*/
|
|
507
|
+
readonly type: "agent.ui.steps"
|
|
508
|
+
/** The last live chunk it covers. */
|
|
509
|
+
readonly throughChunkIndex: number
|
|
510
|
+
readonly chunks: readonly ModelUiChunk[]
|
|
511
|
+
/** What the turn read from its inbox in those steps, each after the first `at` chunks. */
|
|
512
|
+
readonly reads?: readonly AgentRunStepsRead[]
|
|
469
513
|
})
|
|
470
514
|
| (AgentRunStreamEventBase & {
|
|
471
515
|
readonly type: "agent.message.finalized"
|
|
@@ -479,6 +523,7 @@ export type AgentRunStreamEvent =
|
|
|
479
523
|
})
|
|
480
524
|
|
|
481
525
|
export type AgentRunFinishedEvent = Extract<AgentRunStreamEvent, { type: "agent.run.finished" }>
|
|
526
|
+
export type AgentRunStepsEvent = Extract<AgentRunStreamEvent, { type: "agent.ui.steps" }>
|
|
482
527
|
|
|
483
528
|
// ── Record construction ──────────────────────────────────────────────────────────────────────────
|
|
484
529
|
//
|
|
@@ -568,7 +613,17 @@ export function isAgentRunStreamEvent(value: unknown): value is AgentRunStreamEv
|
|
|
568
613
|
return (
|
|
569
614
|
Array.isArray(value.messages) &&
|
|
570
615
|
value.messages.length > 0 &&
|
|
571
|
-
value.messages.every(isAgentInboxReadMessage)
|
|
616
|
+
value.messages.every(isAgentInboxReadMessage) &&
|
|
617
|
+
(value.afterChunkIndex === undefined || Number.isInteger(value.afterChunkIndex))
|
|
618
|
+
)
|
|
619
|
+
case "agent.ui.steps":
|
|
620
|
+
// As for one chunk: steps holding a chunk this reader does not know are skipped whole.
|
|
621
|
+
return (
|
|
622
|
+
Number.isInteger(value.throughChunkIndex) &&
|
|
623
|
+
Array.isArray(value.chunks) &&
|
|
624
|
+
value.chunks.every(isModelUiChunk) &&
|
|
625
|
+
(value.reads === undefined ||
|
|
626
|
+
(Array.isArray(value.reads) && value.reads.every(isAgentRunStepsRead)))
|
|
572
627
|
)
|
|
573
628
|
case "agent.message.finalized":
|
|
574
629
|
return typeof value.messageId === "string"
|
|
@@ -597,6 +652,17 @@ function isAgentInboxReadMessage(value: unknown): value is AgentInboxReadMessage
|
|
|
597
652
|
)
|
|
598
653
|
}
|
|
599
654
|
|
|
655
|
+
function isAgentRunStepsRead(value: unknown): value is AgentRunStepsRead {
|
|
656
|
+
return (
|
|
657
|
+
isPlainRecord(value) &&
|
|
658
|
+
Number.isInteger(value.at) &&
|
|
659
|
+
(value.at as number) >= 0 &&
|
|
660
|
+
Array.isArray(value.messages) &&
|
|
661
|
+
value.messages.length > 0 &&
|
|
662
|
+
value.messages.every(isAgentInboxReadMessage)
|
|
663
|
+
)
|
|
664
|
+
}
|
|
665
|
+
|
|
600
666
|
function isAgentContextCheckpointReason(value: unknown): value is AgentContextCheckpointReason {
|
|
601
667
|
return value === "threshold" || value === "overflow"
|
|
602
668
|
}
|
|
@@ -638,6 +704,8 @@ export function agentRunStreamIdempotencyKey(event: AgentRunStreamEvent): string
|
|
|
638
704
|
return `${event.runId}:${event.attempt}:chunk:${event.chunkIndex}`
|
|
639
705
|
case "agent.inbox.read":
|
|
640
706
|
return `${event.runId}:${event.attempt}:inbox:${event.messages.map((message) => message.id).join(",")}:read`
|
|
707
|
+
case "agent.ui.steps":
|
|
708
|
+
return `${event.runId}:${event.attempt}:steps:${event.throughChunkIndex}`
|
|
641
709
|
case "agent.message.finalized":
|
|
642
710
|
return `${event.runId}:${event.attempt}:message:${event.messageId}:finalized`
|
|
643
711
|
case "agent.run.finished":
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import type { Broker, BrokerRecord } from "../../broker"
|
|
2
|
+
import type { ModelUiChunk } from "../../models/events"
|
|
3
|
+
import {
|
|
4
|
+
type AgentRunStepsEvent,
|
|
5
|
+
type AgentRunStepsRead,
|
|
6
|
+
type AgentRunStreamEvent,
|
|
7
|
+
agentRunStepsStreamId,
|
|
8
|
+
isAgentRunStreamEvent,
|
|
9
|
+
} from "./protocol"
|
|
10
|
+
|
|
11
|
+
// A run's live stream carries one record per streamed delta, and drops its oldest past a limit: on
|
|
12
|
+
// its own it cannot rebuild a long turn. Its finished steps go to a stream of their own as well
|
|
13
|
+
// (see the stream sink), which a reader who opens the turn late reads first.
|
|
14
|
+
|
|
15
|
+
export type DeltaChunk = Extract<
|
|
16
|
+
ModelUiChunk,
|
|
17
|
+
{ readonly type: "text-delta" | "reasoning-delta" | "tool-input-delta" }
|
|
18
|
+
>
|
|
19
|
+
|
|
20
|
+
export function isDeltaChunk(chunk: ModelUiChunk): chunk is DeltaChunk {
|
|
21
|
+
return (
|
|
22
|
+
chunk.type === "text-delta" ||
|
|
23
|
+
chunk.type === "reasoning-delta" ||
|
|
24
|
+
chunk.type === "tool-input-delta"
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Whether `next` extends `delta`'s span, so the two read as one delta. */
|
|
29
|
+
export function continuesDelta(delta: DeltaChunk, next: ModelUiChunk): next is DeltaChunk {
|
|
30
|
+
if (next.type !== delta.type) return false
|
|
31
|
+
if (delta.type === "tool-input-delta") {
|
|
32
|
+
return next.type === "tool-input-delta" && next.toolCallId === delta.toolCallId
|
|
33
|
+
}
|
|
34
|
+
return (next as { readonly id?: string }).id === delta.id
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function mergeDeltas(delta: DeltaChunk, next: DeltaChunk): DeltaChunk {
|
|
38
|
+
if (delta.type === "tool-input-delta" && next.type === "tool-input-delta") {
|
|
39
|
+
return { ...delta, inputTextDelta: delta.inputTextDelta + next.inputTextDelta }
|
|
40
|
+
}
|
|
41
|
+
if (delta.type !== "tool-input-delta" && next.type !== "tool-input-delta") {
|
|
42
|
+
return { ...delta, delta: delta.delta + next.delta }
|
|
43
|
+
}
|
|
44
|
+
return delta
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Appends `chunk`, merged into the last chunk when it extends the same span. */
|
|
48
|
+
export function appendCompacted(chunks: ModelUiChunk[], chunk: ModelUiChunk): void {
|
|
49
|
+
const last = chunks.at(-1)
|
|
50
|
+
if (last && isDeltaChunk(last) && continuesDelta(last, chunk)) {
|
|
51
|
+
chunks[chunks.length - 1] = mergeDeltas(last, chunk)
|
|
52
|
+
return
|
|
53
|
+
}
|
|
54
|
+
chunks.push(chunk)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* A run's finished steps for one attempt, as one event, or null when none finished yet. Records of
|
|
59
|
+
* an earlier attempt are left out: that attempt's work was redone.
|
|
60
|
+
*/
|
|
61
|
+
export async function readAgentRunSteps(
|
|
62
|
+
broker: Broker,
|
|
63
|
+
params: { readonly projectId: string; readonly runId: string; readonly attempt: number }
|
|
64
|
+
): Promise<AgentRunStepsEvent | null> {
|
|
65
|
+
const streamId = agentRunStepsStreamId(params.runId)
|
|
66
|
+
const records: BrokerRecord[] = []
|
|
67
|
+
let afterCursor: string | undefined
|
|
68
|
+
for (;;) {
|
|
69
|
+
const page = await broker.read({
|
|
70
|
+
projectId: params.projectId,
|
|
71
|
+
streamId,
|
|
72
|
+
...(afterCursor === undefined ? {} : { afterCursor }),
|
|
73
|
+
limit: 1_000,
|
|
74
|
+
})
|
|
75
|
+
records.push(...page.records)
|
|
76
|
+
afterCursor = page.cursor ?? afterCursor
|
|
77
|
+
if (!page.hasMore || page.records.length === 0) break
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
let last: AgentRunStepsEvent | null = null
|
|
81
|
+
const chunks: ModelUiChunk[] = []
|
|
82
|
+
const reads: AgentRunStepsRead[] = []
|
|
83
|
+
for (const record of records) {
|
|
84
|
+
const event = record.payload as unknown
|
|
85
|
+
if (!isStepsEvent(event) || event.attempt !== params.attempt) continue
|
|
86
|
+
|
|
87
|
+
// Each step's reads keep their place among its chunks once the steps are joined.
|
|
88
|
+
const offset = chunks.length
|
|
89
|
+
const stepReads = event.reads ?? []
|
|
90
|
+
for (const read of stepReads) reads.push({ ...read, at: read.at + offset })
|
|
91
|
+
|
|
92
|
+
event.chunks.forEach((chunk, index) => {
|
|
93
|
+
// A chunk right after a read is not merged into the one before it: the read sits between.
|
|
94
|
+
const afterRead = reads.at(-1)?.at === offset + index
|
|
95
|
+
if (afterRead || index > 0) chunks.push(chunk)
|
|
96
|
+
else appendCompacted(chunks, chunk)
|
|
97
|
+
})
|
|
98
|
+
last = event
|
|
99
|
+
}
|
|
100
|
+
if (last === null) return null
|
|
101
|
+
|
|
102
|
+
const { reads: _lastReads, ...base } = last
|
|
103
|
+
return { ...base, chunks, ...(reads.length === 0 ? {} : { reads }) }
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function isStepsEvent(value: unknown): value is AgentRunStepsEvent {
|
|
107
|
+
return isAgentRunStreamEvent(value) && (value as AgentRunStreamEvent).type === "agent.ui.steps"
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Whether a live record is a chunk or a read that `steps` already holds. */
|
|
111
|
+
export function coveredBySteps(steps: AgentRunStepsEvent, payload: unknown): boolean {
|
|
112
|
+
if (typeof payload !== "object" || payload === null) return false
|
|
113
|
+
const event = payload as {
|
|
114
|
+
readonly type?: unknown
|
|
115
|
+
readonly attempt?: unknown
|
|
116
|
+
readonly chunkIndex?: unknown
|
|
117
|
+
readonly afterChunkIndex?: unknown
|
|
118
|
+
}
|
|
119
|
+
if (event.attempt !== steps.attempt) return false
|
|
120
|
+
|
|
121
|
+
if (event.type === "agent.ui.chunk") {
|
|
122
|
+
return typeof event.chunkIndex === "number" && event.chunkIndex <= steps.throughChunkIndex
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// A read before the turn's first chunk opens its first step, which every steps event holds.
|
|
126
|
+
if (event.type === "agent.inbox.read") {
|
|
127
|
+
const after = typeof event.afterChunkIndex === "number" ? event.afterChunkIndex : -1
|
|
128
|
+
return after <= steps.throughChunkIndex
|
|
129
|
+
}
|
|
130
|
+
return false
|
|
131
|
+
}
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { type Principal, principalsEqual, SYSTEM_PRINCIPAL, type UserPrincipal } from "../auth"
|
|
2
2
|
import { isRuntimeAllowed } from "../authorization"
|
|
3
3
|
import type { resolveRuntimeAuthorizationForProject } from "../execution/authorization"
|
|
4
|
+
import type { AuthorizablePrincipal } from "../execution/types"
|
|
4
5
|
import type { SixbRuntimeContext } from "../runtime/types"
|
|
5
|
-
import type {
|
|
6
|
+
import type {
|
|
7
|
+
AgentRunFailureCode,
|
|
8
|
+
AgentRunFinishReason,
|
|
9
|
+
AgentRunRecord,
|
|
10
|
+
AgentRunStatus,
|
|
11
|
+
AgentStorage,
|
|
12
|
+
AgentThreadRecord,
|
|
13
|
+
} from "../storage/agents"
|
|
6
14
|
import { AgentRequestError } from "./errors"
|
|
7
15
|
|
|
8
16
|
/** How the caller takes part in a conversation: its owner, or a user its owner added. */
|
|
@@ -15,9 +23,56 @@ export interface AgentThreadParticipant {
|
|
|
15
23
|
readonly addedBy: Principal
|
|
16
24
|
}
|
|
17
25
|
|
|
18
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* How far the caller's reading of a thread has reached, and what arrived past it. Reading on one
|
|
28
|
+
* device clears it on every other.
|
|
29
|
+
*/
|
|
30
|
+
export interface AgentThreadReadView {
|
|
31
|
+
readonly threadId: string
|
|
32
|
+
/** The seq of the last message their reading reached; 0 when it reached none. */
|
|
33
|
+
readonly throughSeq: number
|
|
34
|
+
/** The seq of the thread's newest message, 0 when it has none. */
|
|
35
|
+
readonly headSeq: number
|
|
36
|
+
/**
|
|
37
|
+
* Messages past `throughSeq` that someone else wrote: the Agent's answers and other people's
|
|
38
|
+
* messages. Their own messages are not new to them, nor is a message that only reports how
|
|
39
|
+
* approved calls ended.
|
|
40
|
+
*/
|
|
41
|
+
readonly unread: number
|
|
42
|
+
/** When they last marked the thread read, even where their place did not move. */
|
|
43
|
+
readonly readAt?: Date
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** The thread's newest run, enough for a client to offer Continue or Retry without reading it. */
|
|
47
|
+
export interface AgentThreadLastRunView {
|
|
48
|
+
readonly id: string
|
|
49
|
+
readonly status: AgentRunStatus
|
|
50
|
+
readonly finishReason?: AgentRunFinishReason
|
|
51
|
+
/** Why it failed, when it did. */
|
|
52
|
+
readonly errorCode?: AgentRunFailureCode
|
|
53
|
+
readonly completedAt?: Date
|
|
54
|
+
/**
|
|
55
|
+
* Who asked for it, when it ended short (failed, timed out or interrupted): only they can run it
|
|
56
|
+
* again, as it runs with their rights.
|
|
57
|
+
*/
|
|
58
|
+
readonly requestedBy?: AuthorizablePrincipal
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** A run that stopped before its answer: it failed, timed out, or its worker went away. */
|
|
62
|
+
export function agentRunEndedShort(run: Pick<AgentRunRecord, "status" | "finishReason">): boolean {
|
|
63
|
+
if (run.status === "failed") return true
|
|
64
|
+
return run.finishReason === "timeout" || run.finishReason === "interrupted"
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* A thread as the runtime returns it: the stored record with the users taking part in it, the
|
|
69
|
+
* caller's place in it, and its newest run. `read` is absent for an observer, and for system code,
|
|
70
|
+
* which is nobody's reading.
|
|
71
|
+
*/
|
|
19
72
|
export interface AgentThreadView extends AgentThreadRecord {
|
|
20
73
|
readonly participants: readonly AgentThreadParticipant[]
|
|
74
|
+
readonly read?: AgentThreadReadView
|
|
75
|
+
readonly lastRun?: AgentThreadLastRunView
|
|
21
76
|
}
|
|
22
77
|
|
|
23
78
|
/** A thread the caller can read, and how it takes part in it. */
|
|
@@ -215,16 +215,27 @@ export async function withDocumentHolding<T>(
|
|
|
215
215
|
* The documents of the artifacts a retry of a turn puts back, by id: each one the undo will put
|
|
216
216
|
* back, as the turn's restore point holds it. Made before the undo, at the revision it requires,
|
|
217
217
|
* so the undo can store them: one written meanwhile is not undone, and its document goes unused.
|
|
218
|
+
* The later turns undone with it count as it does, as `laterTurnRunIds` says.
|
|
218
219
|
*/
|
|
219
220
|
export async function undoneTurnDocuments(
|
|
220
221
|
context: MergeContext,
|
|
221
|
-
turnRunId: string
|
|
222
|
+
turnRunId: string,
|
|
223
|
+
laterTurnRunIds: readonly string[] = []
|
|
222
224
|
): Promise<Record<string, FileRef>> {
|
|
223
225
|
const { projectId, storage } = context
|
|
224
226
|
const documents: Record<string, FileRef> = {}
|
|
225
227
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
+
const laterWrites = new Map<string, number>()
|
|
229
|
+
for (const later of laterTurnRunIds) {
|
|
230
|
+
for (const write of await storage.listTurnWrites({ projectId, turnRunId: later })) {
|
|
231
|
+
laterWrites.set(write.artifactId, (laterWrites.get(write.artifactId) ?? 0) + write.writes)
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
for (const own of await storage.listTurnWrites({ projectId, turnRunId })) {
|
|
236
|
+
if (own.created) continue
|
|
237
|
+
const write = { ...own, writes: own.writes + (laterWrites.get(own.artifactId) ?? 0) }
|
|
238
|
+
|
|
228
239
|
const artifact = await storage.get({ projectId, id: write.artifactId })
|
|
229
240
|
if (!artifact || !keepsDocument(artifact.kind)) continue
|
|
230
241
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getAuthorizedOntologyView } from "../execution/authorized-object-reader"
|
|
1
|
+
import { getAuthorizedOntologyView, getQueryDiscovery } from "../execution/authorized-object-reader"
|
|
2
2
|
import type { AuthorizedOntologyView } from "../objects/authorized-ontology-view"
|
|
3
3
|
import { ObjectQueryPlanningError, ObjectQueryValidationError } from "../objects/query/errors"
|
|
4
4
|
import type { ObjectExpansion } from "../objects/query/ir"
|
|
@@ -57,7 +57,10 @@ export function describeArtifactQuery(
|
|
|
57
57
|
runtime: Pick<SixbRuntimeContext, "ontology" | "objectReader">,
|
|
58
58
|
query: ArtifactQuery
|
|
59
59
|
): ArtifactQueryShape {
|
|
60
|
-
const validated = validateObjectQuery(query.query, {
|
|
60
|
+
const validated = validateObjectQuery(query.query, {
|
|
61
|
+
ontology: runtime.ontology,
|
|
62
|
+
discovery: getQueryDiscovery(runtime.objectReader),
|
|
63
|
+
})
|
|
61
64
|
|
|
62
65
|
return {
|
|
63
66
|
resultObjectTypeIds: [...validated.result.objectTypeIds],
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
import { AsyncLocalStorage } from "node:async_hooks"
|
|
10
10
|
import { readdir } from "node:fs/promises"
|
|
11
|
-
import { join, relative, resolve, sep } from "node:path"
|
|
11
|
+
import { join, posix, relative, resolve, sep } from "node:path"
|
|
12
12
|
import { pathToFileURL } from "node:url"
|
|
13
13
|
import { isActionDefinition } from "../actions"
|
|
14
14
|
import { isConnectorDefinition } from "../connectors"
|
|
@@ -19,6 +19,7 @@ import type { ValueType } from "../ontology/types"
|
|
|
19
19
|
import { isPipelineDefinition } from "../pipelines"
|
|
20
20
|
import { isProjectionDefinition } from "../projections/builders"
|
|
21
21
|
import { isRuleDefinition } from "../rules"
|
|
22
|
+
import type { DefinitionFolderFamily, DefinitionFolderIndex } from "../runtime/definitions"
|
|
22
23
|
import { RuntimeError } from "../runtime/errors"
|
|
23
24
|
import { isScheduleDefinition } from "../schedules"
|
|
24
25
|
import {
|
|
@@ -44,6 +45,8 @@ export interface DiscoveredOntologyModule {
|
|
|
44
45
|
export interface DiscoveredOntology {
|
|
45
46
|
readonly sources: readonly OntologySource[]
|
|
46
47
|
readonly modules: readonly DiscoveredOntologyModule[]
|
|
48
|
+
/** Each object type's folder below `ontology/`; see {@link DefinitionFolderIndex}. */
|
|
49
|
+
readonly folders: ReadonlyMap<string, string>
|
|
47
50
|
}
|
|
48
51
|
|
|
49
52
|
export async function discoverOntologySources(projectRoot: string): Promise<DiscoveredOntology> {
|
|
@@ -53,6 +56,7 @@ export async function discoverOntologySources(projectRoot: string): Promise<Disc
|
|
|
53
56
|
const objectTypes: ObjectTypeWithPropertyTokens[] = []
|
|
54
57
|
const valueTypes: ValueType[] = []
|
|
55
58
|
const modules: DiscoveredOntologyModule[] = []
|
|
59
|
+
const folders = new DefinitionFolderCollector()
|
|
56
60
|
const seen = new Set<unknown>()
|
|
57
61
|
|
|
58
62
|
for (const loaded of loadedModules) {
|
|
@@ -77,10 +81,9 @@ export async function discoverOntologySources(projectRoot: string): Promise<Disc
|
|
|
77
81
|
valueTypes.push(candidate)
|
|
78
82
|
}
|
|
79
83
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
})
|
|
84
|
+
const path = toPosix(relative("ontology", loaded.path))
|
|
85
|
+
for (const id of objectTypeIds) folders.add(id, path)
|
|
86
|
+
modules.push({ path, objectTypeIds: [...new Set(objectTypeIds)] })
|
|
84
87
|
}
|
|
85
88
|
|
|
86
89
|
const discoveredSources: OntologySource[] = [...ontologyDocuments, ...objectTypes]
|
|
@@ -93,7 +96,7 @@ export async function discoverOntologySources(projectRoot: string): Promise<Disc
|
|
|
93
96
|
})
|
|
94
97
|
}
|
|
95
98
|
|
|
96
|
-
return { sources: discoveredSources, modules }
|
|
99
|
+
return { sources: discoveredSources, modules, folders: folders.index }
|
|
97
100
|
}
|
|
98
101
|
|
|
99
102
|
export type DiscoveryModuleKind =
|
|
@@ -217,31 +220,78 @@ export type DiscoveredProjectDefinitions = {
|
|
|
217
220
|
readonly [TKey in keyof typeof definitionDiscoveryRegistry]: readonly DefinitionFromFamily<
|
|
218
221
|
(typeof definitionDiscoveryRegistry)[TKey]
|
|
219
222
|
>[]
|
|
223
|
+
} & {
|
|
224
|
+
/** The folder each definition was found in; object types come from `discoverOntologySources`. */
|
|
225
|
+
readonly folders: Omit<DefinitionFolderIndex, "objectTypes">
|
|
220
226
|
}
|
|
221
227
|
|
|
228
|
+
/** The families whose folders the app shows; the rest are kept by id alone. */
|
|
229
|
+
const folderFamilies: ReadonlySet<string> = new Set<Exclude<DefinitionFolderFamily, "objectTypes">>(
|
|
230
|
+
["actions", "connectors", "datasets", "pipelines", "projections", "rules", "syncs", "workflows"]
|
|
231
|
+
)
|
|
232
|
+
|
|
222
233
|
export async function discoverProjectDefinitions(
|
|
223
234
|
projectRoot: string
|
|
224
235
|
): Promise<DiscoveredProjectDefinitions> {
|
|
225
236
|
const entries = await Promise.all(
|
|
226
237
|
Object.entries(definitionDiscoveryRegistry).map(async ([key, family]) => {
|
|
227
|
-
const
|
|
228
|
-
return [key,
|
|
238
|
+
const discovered = await discoverDefinitionFamily(projectRoot, family)
|
|
239
|
+
return [key, discovered] as const
|
|
229
240
|
})
|
|
230
241
|
)
|
|
231
242
|
|
|
243
|
+
const folders = Object.fromEntries(
|
|
244
|
+
entries.filter(([key]) => folderFamilies.has(key)).map(([key, { folders }]) => [key, folders])
|
|
245
|
+
)
|
|
232
246
|
// Object.fromEntries erases literal keys. Every entry above comes from the exact registry and its
|
|
233
247
|
// definitions have passed that entry's type guard, so restoring the mapped result type is safe.
|
|
234
|
-
return
|
|
248
|
+
return {
|
|
249
|
+
...Object.fromEntries(entries.map(([key, { definitions }]) => [key, definitions])),
|
|
250
|
+
folders,
|
|
251
|
+
} as DiscoveredProjectDefinitions
|
|
235
252
|
}
|
|
236
253
|
|
|
237
254
|
async function discoverDefinitionFamily(
|
|
238
255
|
projectRoot: string,
|
|
239
256
|
family: DefinitionDiscoveryFamily<unknown>
|
|
240
|
-
): Promise<readonly unknown[]> {
|
|
257
|
+
): Promise<{ definitions: readonly unknown[]; folders: ReadonlyMap<string, string> }> {
|
|
241
258
|
const loadedModules = await loadFamilyModules(projectRoot, family.kind, family.directory)
|
|
242
259
|
const exportedCandidates = new Set(loadedModules.flatMap((loaded) => loaded.exports))
|
|
260
|
+
const definitions = [...exportedCandidates].filter(family.isDefinition)
|
|
261
|
+
const isDefinition = new Set(definitions)
|
|
262
|
+
|
|
263
|
+
const directory = family.directory.join("/")
|
|
264
|
+
const folders = new DefinitionFolderCollector()
|
|
265
|
+
for (const loaded of loadedModules) {
|
|
266
|
+
const path = posix.relative(directory, toPosix(loaded.path))
|
|
267
|
+
for (const candidate of loaded.exports) {
|
|
268
|
+
if (isDefinition.has(candidate) && hasStringId(candidate)) folders.add(candidate.id, path)
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
return { definitions, folders: folders.index }
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Collects each definition's folder from the modules that export it. When several do, the deepest
|
|
277
|
+
* wins: a barrel such as `datasets/index.ts` re-exports what the files below it define.
|
|
278
|
+
*/
|
|
279
|
+
class DefinitionFolderCollector {
|
|
280
|
+
readonly index = new Map<string, string>()
|
|
281
|
+
private readonly depths = new Map<string, number>()
|
|
282
|
+
|
|
283
|
+
/** `path` is the module's POSIX path below the family's directory. */
|
|
284
|
+
add(id: string, path: string): void {
|
|
285
|
+
const folder = posix.dirname(path)
|
|
286
|
+
const depth = folder === "." ? 0 : folder.split("/").length
|
|
287
|
+
if ((this.depths.get(id) ?? -1) >= depth) return
|
|
288
|
+
this.depths.set(id, depth)
|
|
289
|
+
if (depth > 0) this.index.set(id, folder)
|
|
290
|
+
}
|
|
291
|
+
}
|
|
243
292
|
|
|
244
|
-
|
|
293
|
+
function hasStringId(value: unknown): value is { readonly id: string } {
|
|
294
|
+
return isRecord(value) && typeof value.id === "string"
|
|
245
295
|
}
|
|
246
296
|
|
|
247
297
|
/**
|