@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
|
@@ -404,6 +404,65 @@ export function runAiCostStorageContractSuite<TStorage extends AiCostStorage>(
|
|
|
404
404
|
}
|
|
405
405
|
})
|
|
406
406
|
|
|
407
|
+
test("buckets a series on the calendar of the query's time zone", async () => {
|
|
408
|
+
// Removal proof: truncate in UTC again, in the providers and in the shared helpers; the call
|
|
409
|
+
// of August 3rd never leaves the first bar, and November 1st is not the 25-hour day it is in
|
|
410
|
+
// New York.
|
|
411
|
+
const storage = await fixture()
|
|
412
|
+
try {
|
|
413
|
+
const august = {
|
|
414
|
+
from: new Date("2026-08-03T00:00:00.000Z"),
|
|
415
|
+
to: new Date("2026-08-05T00:00:00.000Z"),
|
|
416
|
+
}
|
|
417
|
+
const callsIn = async (query: { readonly timeZone?: string }): Promise<readonly number[]> =>
|
|
418
|
+
(
|
|
419
|
+
await storage.queryProjectOverview({ projectId, ...august, bucket: "day", ...query })
|
|
420
|
+
).series.map((period) => period.modelCallCount)
|
|
421
|
+
|
|
422
|
+
expect(await callsIn({})).toEqual([1, 0])
|
|
423
|
+
// Fourteen hours ahead of UTC, the same call falls at 2 am on the 4th: the second bar.
|
|
424
|
+
expect(await callsIn({ timeZone: "Pacific/Kiritimati" })).toEqual([0, 1, 0])
|
|
425
|
+
|
|
426
|
+
const november = await storage.queryProjectOverview({
|
|
427
|
+
projectId,
|
|
428
|
+
from: new Date("2026-11-01T04:00:00.000Z"),
|
|
429
|
+
to: new Date("2026-11-03T05:00:00.000Z"),
|
|
430
|
+
bucket: "day",
|
|
431
|
+
timeZone: "America/New_York",
|
|
432
|
+
})
|
|
433
|
+
expect(
|
|
434
|
+
november.series.map((period) => [period.start.toISOString(), period.modelCallCount])
|
|
435
|
+
).toEqual([
|
|
436
|
+
["2026-11-01T04:00:00.000Z", 1],
|
|
437
|
+
["2026-11-02T05:00:00.000Z", 1],
|
|
438
|
+
])
|
|
439
|
+
|
|
440
|
+
// Removal proof: step each day from the one before it instead of from its midnight; after
|
|
441
|
+
// Chile skips midnight on September 6, the days start at 1 am, PostgreSQL refuses its own
|
|
442
|
+
// buckets, and the in-memory and SQLite bars lose or move the calls.
|
|
443
|
+
const santiago = await storage.queryProjectOverview({
|
|
444
|
+
projectId,
|
|
445
|
+
from: new Date("2026-09-05T04:00:00.000Z"),
|
|
446
|
+
to: new Date("2026-11-03T03:00:00.000Z"),
|
|
447
|
+
bucket: "day",
|
|
448
|
+
timeZone: "America/Santiago",
|
|
449
|
+
providerId: "gateway",
|
|
450
|
+
modelId: "clock/model",
|
|
451
|
+
})
|
|
452
|
+
expect(santiago.series).toHaveLength(59)
|
|
453
|
+
expect(
|
|
454
|
+
santiago.series
|
|
455
|
+
.filter((period) => period.modelCallCount > 0)
|
|
456
|
+
.map((period) => [period.start.toISOString(), period.modelCallCount])
|
|
457
|
+
).toEqual([
|
|
458
|
+
["2026-11-01T03:00:00.000Z", 1],
|
|
459
|
+
["2026-11-02T03:00:00.000Z", 1],
|
|
460
|
+
])
|
|
461
|
+
} finally {
|
|
462
|
+
await options.cleanup?.(storage)
|
|
463
|
+
}
|
|
464
|
+
})
|
|
465
|
+
|
|
407
466
|
test("rejects missing usage and mismatched billed quantities", async () => {
|
|
408
467
|
const storage = await fixture()
|
|
409
468
|
try {
|
|
@@ -530,6 +589,27 @@ export async function seedAiCostStorageContractUsage(
|
|
|
530
589
|
recordedAt: new Date("2026-08-03T12:00:00.100Z"),
|
|
531
590
|
})
|
|
532
591
|
|
|
592
|
+
// A call either side of a change of clocks, for the calendar a series buckets by.
|
|
593
|
+
for (const [index, occurredAt] of [
|
|
594
|
+
"2026-11-01T12:00:00.000Z",
|
|
595
|
+
"2026-11-02T12:00:00.000Z",
|
|
596
|
+
].entries()) {
|
|
597
|
+
await usage.recordModelCall({
|
|
598
|
+
id: `clock_${index}`,
|
|
599
|
+
projectId,
|
|
600
|
+
executionId: otherExecutionId,
|
|
601
|
+
attempt: 1,
|
|
602
|
+
callId: `clock_${index}`,
|
|
603
|
+
responseId: `response_clock_${index}`,
|
|
604
|
+
requesterGroupIds: [],
|
|
605
|
+
providerId: "gateway",
|
|
606
|
+
requestedModelId: "clock/model",
|
|
607
|
+
usage: { inputTokens: 1, outputTokens: 1 },
|
|
608
|
+
occurredAt: new Date(occurredAt),
|
|
609
|
+
recordedAt: new Date(occurredAt),
|
|
610
|
+
})
|
|
611
|
+
}
|
|
612
|
+
|
|
533
613
|
for (const [day, calls, complete, tokens] of [
|
|
534
614
|
[16, 87, 84, 4_013_782],
|
|
535
615
|
[18, 29, 28, 334_815],
|
|
@@ -1293,6 +1293,135 @@ export function runArtifactStorageContractSuite<TStorage extends ArtifactStorage
|
|
|
1293
1293
|
})
|
|
1294
1294
|
})
|
|
1295
1295
|
|
|
1296
|
+
// Regression proofs: in a provider's `undoTurnWrites`, count the turn's writes alone, as
|
|
1297
|
+
// providers once did; art_plan then stays at turn A's content and art_draft at turn A's
|
|
1298
|
+
// version. Count every later turn's comment as someone else's in `othersCommented`, and
|
|
1299
|
+
// art_draft stays for turn B's comment. Keep turn B's records on art_plan once it is undone,
|
|
1300
|
+
// and its restore point is left over.
|
|
1301
|
+
test("undoes later turns with a turn, back to before the first, as an edit takes them back", async () => {
|
|
1302
|
+
await withStorage(async (artifacts) => {
|
|
1303
|
+
const turnA = { threadId: "thr_a", runId: "run_a" }
|
|
1304
|
+
const turnB = { threadId: "thr_b", runId: "run_b" }
|
|
1305
|
+
const write = (artifactId: string, turn: typeof turnA, updatedAt: Date) =>
|
|
1306
|
+
artifacts.publish({
|
|
1307
|
+
...publishInput({ title: `Turn ${turn.runId}`, origin: turn, updatedAt }, artifactId),
|
|
1308
|
+
turnRunId: turn.runId,
|
|
1309
|
+
})
|
|
1310
|
+
|
|
1311
|
+
// Both turns changed an artifact someone else made.
|
|
1312
|
+
await artifacts.create(createInput({ id: "art_plan" }))
|
|
1313
|
+
await write("art_plan", turnA, at(1))
|
|
1314
|
+
await write("art_plan", turnB, at(2))
|
|
1315
|
+
|
|
1316
|
+
// Turn A created one, and turn B wrote it and commented on it for another participant.
|
|
1317
|
+
await artifacts.create({
|
|
1318
|
+
...createInput({ id: "art_draft", version: versionInput({ origin: turnA }) }),
|
|
1319
|
+
turnRunId: "run_a",
|
|
1320
|
+
})
|
|
1321
|
+
await write("art_draft", turnB, at(2))
|
|
1322
|
+
await artifacts.createComment({
|
|
1323
|
+
projectId,
|
|
1324
|
+
artifactId: "art_draft",
|
|
1325
|
+
id: "cmt_turn_b",
|
|
1326
|
+
anchor: { revision: 2 },
|
|
1327
|
+
body: "Turn B's note",
|
|
1328
|
+
author: otherOwner,
|
|
1329
|
+
origin: turnB,
|
|
1330
|
+
createdAt: at(3),
|
|
1331
|
+
})
|
|
1332
|
+
|
|
1333
|
+
const undone = await artifacts.undoTurnWrites({
|
|
1334
|
+
projectId,
|
|
1335
|
+
turnRunId: "run_a",
|
|
1336
|
+
laterTurnRunIds: ["run_b"],
|
|
1337
|
+
requester: owner,
|
|
1338
|
+
})
|
|
1339
|
+
|
|
1340
|
+
expect(undone.deleted).toEqual(["art_draft"])
|
|
1341
|
+
expect(undone.restored.map(({ artifact }) => artifact.id)).toEqual(["art_plan"])
|
|
1342
|
+
expect(await artifacts.get({ projectId, id: "art_draft" })).toBeNull()
|
|
1343
|
+
expect(await artifacts.get({ projectId, id: "art_plan" })).toMatchObject({
|
|
1344
|
+
title: "Q3 report",
|
|
1345
|
+
revision: 4,
|
|
1346
|
+
updatedAt: t0,
|
|
1347
|
+
})
|
|
1348
|
+
|
|
1349
|
+
// Turn B's records went with turn A's, and so did the threads they shared it in.
|
|
1350
|
+
expect(await artifacts.listRestorePoints({ projectId, id: "art_plan" })).toEqual([])
|
|
1351
|
+
expect(await artifacts.listTurnWrites({ projectId, turnRunId: "run_b" })).toEqual([])
|
|
1352
|
+
expect(await artifacts.listThreadIds({ projectId, id: "art_plan" })).toEqual(["thr_1"])
|
|
1353
|
+
expect(await artifacts.undoTurnWrites({ projectId, turnRunId: "run_b" })).toEqual({
|
|
1354
|
+
restored: [],
|
|
1355
|
+
deleted: [],
|
|
1356
|
+
})
|
|
1357
|
+
})
|
|
1358
|
+
})
|
|
1359
|
+
|
|
1360
|
+
// Regression proof: forget the later turns' records on an artifact kept in a provider's
|
|
1361
|
+
// `undoTurnWrites`; turn B's own undo then finds nothing, and its write stays.
|
|
1362
|
+
test("keeps what anyone wrote between turns undone together, and the later turn's own undo", async () => {
|
|
1363
|
+
await withStorage(async (artifacts) => {
|
|
1364
|
+
const write = (artifactId: string, runId: string, updatedAt: Date) =>
|
|
1365
|
+
artifacts.publish({
|
|
1366
|
+
...publishInput(
|
|
1367
|
+
{ title: `Turn ${runId}`, origin: { threadId: "thr_turn", runId }, updatedAt },
|
|
1368
|
+
artifactId
|
|
1369
|
+
),
|
|
1370
|
+
turnRunId: runId,
|
|
1371
|
+
})
|
|
1372
|
+
const person = (artifactId: string) =>
|
|
1373
|
+
artifacts.publish(
|
|
1374
|
+
publishInput({ title: "Person's", origin: undefined, updatedAt: at(2) }, artifactId)
|
|
1375
|
+
)
|
|
1376
|
+
|
|
1377
|
+
await artifacts.create(createInput({ id: "art_plan" }))
|
|
1378
|
+
await write("art_plan", "run_a", at(1))
|
|
1379
|
+
await person("art_plan")
|
|
1380
|
+
await write("art_plan", "run_b", at(3))
|
|
1381
|
+
|
|
1382
|
+
await artifacts.create({
|
|
1383
|
+
...createInput({
|
|
1384
|
+
id: "art_draft",
|
|
1385
|
+
version: versionInput({ origin: { threadId: "thr_turn", runId: "run_a" } }),
|
|
1386
|
+
}),
|
|
1387
|
+
turnRunId: "run_a",
|
|
1388
|
+
})
|
|
1389
|
+
await person("art_draft")
|
|
1390
|
+
await write("art_draft", "run_b", at(3))
|
|
1391
|
+
|
|
1392
|
+
expect(
|
|
1393
|
+
await artifacts.undoTurnWrites({
|
|
1394
|
+
projectId,
|
|
1395
|
+
turnRunId: "run_a",
|
|
1396
|
+
laterTurnRunIds: ["run_b"],
|
|
1397
|
+
})
|
|
1398
|
+
).toEqual({ restored: [], deleted: [] })
|
|
1399
|
+
expect(await artifacts.get({ projectId, id: "art_plan" })).toMatchObject({
|
|
1400
|
+
title: "Turn run_b",
|
|
1401
|
+
revision: 4,
|
|
1402
|
+
})
|
|
1403
|
+
expect(await artifacts.get({ projectId, id: "art_draft" })).toMatchObject({
|
|
1404
|
+
title: "Turn run_b",
|
|
1405
|
+
revision: 3,
|
|
1406
|
+
})
|
|
1407
|
+
|
|
1408
|
+
// Turn B alone is undone to what the person wrote.
|
|
1409
|
+
const undone = await artifacts.undoTurnWrites({ projectId, turnRunId: "run_b" })
|
|
1410
|
+
expect(undone.restored.map(({ artifact }) => artifact.id).sort()).toEqual([
|
|
1411
|
+
"art_draft",
|
|
1412
|
+
"art_plan",
|
|
1413
|
+
])
|
|
1414
|
+
expect(await artifacts.get({ projectId, id: "art_plan" })).toMatchObject({
|
|
1415
|
+
title: "Person's",
|
|
1416
|
+
revision: 5,
|
|
1417
|
+
})
|
|
1418
|
+
expect(await artifacts.get({ projectId, id: "art_draft" })).toMatchObject({
|
|
1419
|
+
title: "Person's",
|
|
1420
|
+
revision: 4,
|
|
1421
|
+
})
|
|
1422
|
+
})
|
|
1423
|
+
})
|
|
1424
|
+
|
|
1296
1425
|
test("keeps comments and their replies, oldest first, and resolves and deletes them", async () => {
|
|
1297
1426
|
await withStorage(async (artifacts) => {
|
|
1298
1427
|
await artifacts.create(createInput())
|
|
@@ -1730,6 +1859,16 @@ export function runArtifactStorageContractSuite<TStorage extends ArtifactStorage
|
|
|
1730
1859
|
})
|
|
1731
1860
|
})
|
|
1732
1861
|
|
|
1862
|
+
// A process's first query may ask for one board: Postgres refused one key sent through
|
|
1863
|
+
// postgres.js's `sql.array` before the client had read the server's array types.
|
|
1864
|
+
test("reads one board's pictures first", async () => {
|
|
1865
|
+
await withStorage(async (artifacts) => {
|
|
1866
|
+
expect(
|
|
1867
|
+
await artifacts.listBoardPreviews({ projectId, renderKeys: ["a".repeat(64)] })
|
|
1868
|
+
).toEqual([])
|
|
1869
|
+
})
|
|
1870
|
+
})
|
|
1871
|
+
|
|
1733
1872
|
test("keeps a PDF by render key, the first one kept staying", async () => {
|
|
1734
1873
|
await withStorage(async (artifacts) => {
|
|
1735
1874
|
const renderKey = "c".repeat(64)
|
|
@@ -256,6 +256,122 @@ export function runRunClaimStorageContractSuite<TStorage extends RunClaimStorage
|
|
|
256
256
|
})
|
|
257
257
|
})
|
|
258
258
|
|
|
259
|
+
// Reproduce: count only same-connection siblings; Grace's run then starts beside Ada's.
|
|
260
|
+
test("Sync: runs of every connection of one Sync run one at a time", async () => {
|
|
261
|
+
await withStorage(async (storage) => {
|
|
262
|
+
const runs = requireRuns(storage.syncRuns)
|
|
263
|
+
const queue = (id: string, connectionId?: string) =>
|
|
264
|
+
queueTestSyncRun(storage, {
|
|
265
|
+
id,
|
|
266
|
+
projectId,
|
|
267
|
+
syncId: "inbox",
|
|
268
|
+
...(connectionId === undefined ? {} : { connectionId }),
|
|
269
|
+
datasetId: "inbox",
|
|
270
|
+
mode: "merge",
|
|
271
|
+
})
|
|
272
|
+
await queue("ada-1", "conn_ada")
|
|
273
|
+
await queue("grace-1", "conn_grace")
|
|
274
|
+
await queue("whole-1")
|
|
275
|
+
|
|
276
|
+
await expect(
|
|
277
|
+
runs.startOrReclaim({ projectId, id: "ada-1", execution: held("ada-1"), claimedAt })
|
|
278
|
+
).resolves.toMatchObject({ outcome: "started", run: { connectionId: "conn_ada" } })
|
|
279
|
+
await expect(
|
|
280
|
+
runs.startOrReclaim({ projectId, id: "grace-1", execution: held("grace-1"), claimedAt })
|
|
281
|
+
).resolves.toMatchObject({ outcome: "waiting", sibling: { id: "ada-1" } })
|
|
282
|
+
|
|
283
|
+
const ada = await runs.list({ projectId, syncId: "inbox", connectionId: "conn_ada" })
|
|
284
|
+
expect(ada.runs.map((run) => run.id)).toEqual(["ada-1"])
|
|
285
|
+
const whole = await runs.list({ projectId, syncId: "inbox", connectionId: null })
|
|
286
|
+
expect(whole.runs.map((run) => run.id)).toEqual(["whole-1"])
|
|
287
|
+
expect(whole.runs[0]?.connectionId).toBeUndefined()
|
|
288
|
+
})
|
|
289
|
+
})
|
|
290
|
+
|
|
291
|
+
test("Sync: lists the latest run of each sync and connection", async () => {
|
|
292
|
+
await withStorage(async (storage) => {
|
|
293
|
+
const runs = requireRuns(storage.syncRuns)
|
|
294
|
+
const queue = (id: string, syncId: string, minute: number, connectionId?: string) =>
|
|
295
|
+
queueTestSyncRun(storage, {
|
|
296
|
+
id,
|
|
297
|
+
projectId,
|
|
298
|
+
syncId,
|
|
299
|
+
...(connectionId === undefined ? {} : { connectionId }),
|
|
300
|
+
datasetId: syncId,
|
|
301
|
+
mode: "merge",
|
|
302
|
+
queuedAt: new Date(`2100-06-01T12:0${minute}:00.000Z`),
|
|
303
|
+
})
|
|
304
|
+
await queue("inbox-ada-old", "inbox", 1, "conn_ada")
|
|
305
|
+
await queue("inbox-ada-new", "inbox", 2, "conn_ada")
|
|
306
|
+
await queue("inbox-grace", "inbox", 1, "conn_grace")
|
|
307
|
+
await queue("calendar-ada", "calendar", 3, "conn_ada")
|
|
308
|
+
await queue("inbox-whole", "inbox", 4)
|
|
309
|
+
await queue("other-ada", "other", 5, "conn_ada")
|
|
310
|
+
|
|
311
|
+
const ids = async (input: Parameters<typeof runs.listLatestByConnection>[0]) =>
|
|
312
|
+
(await runs.listLatestByConnection(input)).runs.map((run) => run.id).sort()
|
|
313
|
+
|
|
314
|
+
expect(await ids({ projectId, syncIds: ["inbox", "calendar"] })).toEqual([
|
|
315
|
+
"calendar-ada",
|
|
316
|
+
"inbox-ada-new",
|
|
317
|
+
"inbox-grace",
|
|
318
|
+
])
|
|
319
|
+
expect(
|
|
320
|
+
await ids({ projectId, syncIds: ["inbox", "calendar"], connectionIds: ["conn_ada"] })
|
|
321
|
+
).toEqual(["calendar-ada", "inbox-ada-new"])
|
|
322
|
+
expect(await ids({ projectId, syncIds: [] })).toEqual([])
|
|
323
|
+
})
|
|
324
|
+
})
|
|
325
|
+
|
|
326
|
+
// Reproduce: ignore `visibleConnectionIds` in the store; Grace's runs come back to Ada.
|
|
327
|
+
test("Sync: lists only the runs of visible connections, and every run that reads none", async () => {
|
|
328
|
+
await withStorage(async (storage) => {
|
|
329
|
+
const runs = requireRuns(storage.syncRuns)
|
|
330
|
+
const queue = (id: string, minute: number, connectionId?: string) =>
|
|
331
|
+
queueTestSyncRun(storage, {
|
|
332
|
+
id,
|
|
333
|
+
projectId,
|
|
334
|
+
syncId: "inbox",
|
|
335
|
+
...(connectionId === undefined ? {} : { connectionId }),
|
|
336
|
+
datasetId: "inbox",
|
|
337
|
+
mode: "merge",
|
|
338
|
+
queuedAt: new Date(`2100-06-01T12:0${minute}:00.000Z`),
|
|
339
|
+
})
|
|
340
|
+
await queue("whole", 1)
|
|
341
|
+
await queue("project", 2, "conn_project")
|
|
342
|
+
await queue("ada", 3, "conn_ada")
|
|
343
|
+
await queue("grace", 4, "conn_grace")
|
|
344
|
+
|
|
345
|
+
const listed = async (visibleConnectionIds: readonly string[]) => {
|
|
346
|
+
const page = await runs.list({
|
|
347
|
+
projectId,
|
|
348
|
+
syncId: "inbox",
|
|
349
|
+
visibleConnectionIds,
|
|
350
|
+
limit: 2,
|
|
351
|
+
})
|
|
352
|
+
return { ids: page.runs.map((run) => run.id), total: page.total, hasMore: page.hasMore }
|
|
353
|
+
}
|
|
354
|
+
const latest = async (visibleConnectionIds?: readonly string[]) => {
|
|
355
|
+
const { runs: found } = await runs.listLatestBySyncIds({
|
|
356
|
+
projectId,
|
|
357
|
+
syncIds: ["inbox"],
|
|
358
|
+
...(visibleConnectionIds === undefined ? {} : { visibleConnectionIds }),
|
|
359
|
+
})
|
|
360
|
+
return found.map((run) => run.id)
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
expect(await listed(["conn_project", "conn_ada"])).toEqual({
|
|
364
|
+
ids: ["ada", "project"],
|
|
365
|
+
total: 3,
|
|
366
|
+
hasMore: true,
|
|
367
|
+
})
|
|
368
|
+
expect(await listed([])).toEqual({ ids: ["whole"], total: 1, hasMore: false })
|
|
369
|
+
expect(await latest(["conn_project", "conn_ada"])).toEqual(["ada"])
|
|
370
|
+
expect(await latest([])).toEqual(["whole"])
|
|
371
|
+
expect(await latest()).toEqual(["grace"])
|
|
372
|
+
})
|
|
373
|
+
})
|
|
374
|
+
|
|
259
375
|
// Reproduce: count any running sibling in `planRunClaim`; the second run then waits for a day.
|
|
260
376
|
test("Sync: a run of an older version holds no later run back", async () => {
|
|
261
377
|
await withStorage(async (storage) => {
|
|
@@ -256,6 +256,22 @@ export function runSandboxesContractSuite(
|
|
|
256
256
|
}
|
|
257
257
|
})
|
|
258
258
|
|
|
259
|
+
// A timeout past a provider's limit was refused (Vercel's 400) or, past a timer's, fired at
|
|
260
|
+
// once. Removal proof: drop cappedCommandTimeout from a provider's runCommand.
|
|
261
|
+
test("declares its longest command timeout, and runs a command asked for longer", async () => {
|
|
262
|
+
const sandbox = await factory.create()
|
|
263
|
+
try {
|
|
264
|
+
expect(sandbox.maxCommandTimeout).toBeGreaterThan(0)
|
|
265
|
+
const result = await sandbox.runCommand("sh", ["-c", "sleep 0.2; echo ran"], {
|
|
266
|
+
timeout: Number.MAX_SAFE_INTEGER,
|
|
267
|
+
})
|
|
268
|
+
expect(result).toMatchObject({ exitCode: 0, stdout: "ran\n" })
|
|
269
|
+
expect(result.timedOut).toBeUndefined()
|
|
270
|
+
} finally {
|
|
271
|
+
await sandbox.destroy()
|
|
272
|
+
}
|
|
273
|
+
})
|
|
274
|
+
|
|
259
275
|
test("abort signal aborts an in-flight command", async () => {
|
|
260
276
|
const sandbox = await factory.create()
|
|
261
277
|
try {
|
|
@@ -354,6 +370,40 @@ export function runSandboxesContractSuite(
|
|
|
354
370
|
}
|
|
355
371
|
})
|
|
356
372
|
|
|
373
|
+
// An agent's run writes its skills and the sandbox's `sixb` in one call. Regression check:
|
|
374
|
+
// put every file's contents in one guest command's arguments again (smolvm once did); the
|
|
375
|
+
// kernel refuses an argument list this long, and the call fails.
|
|
376
|
+
test("writeFiles writes a large file and many files in one call", async () => {
|
|
377
|
+
const sandbox = await factory.create()
|
|
378
|
+
try {
|
|
379
|
+
const large = Uint8Array.from({ length: 2 * 1024 * 1024 }, (_, index) => index % 251)
|
|
380
|
+
const many = Array.from({ length: 200 }, (_, index) => ({
|
|
381
|
+
path: `many/${String(index).padStart(3, "0")}.txt`,
|
|
382
|
+
contents: `${index}\n`,
|
|
383
|
+
}))
|
|
384
|
+
await sandbox.writeFiles([{ path: "large.bin", contents: large }, ...many])
|
|
385
|
+
|
|
386
|
+
const size = await sandbox.runCommand("wc", ["-c", "large.bin"])
|
|
387
|
+
expect(size.exitCode).toBe(0)
|
|
388
|
+
expect(size.stdout.trim().split(/\s+/)[0]).toBe(String(large.length))
|
|
389
|
+
|
|
390
|
+
// The pattern's period is prime, so a dropped or shifted chunk changes the last bytes.
|
|
391
|
+
const tail = await sandbox.runCommand("/bin/sh", [
|
|
392
|
+
"-c",
|
|
393
|
+
"tail -c 4 large.bin | od -An -tu1",
|
|
394
|
+
])
|
|
395
|
+
expect(tail.stdout.trim().split(/\s+/)).toEqual(
|
|
396
|
+
[...large.subarray(-4)].map((byte) => String(byte))
|
|
397
|
+
)
|
|
398
|
+
|
|
399
|
+
const listed = await sandbox.runCommand("/bin/sh", ["-c", "cat many/*.txt"])
|
|
400
|
+
expect(listed.exitCode).toBe(0)
|
|
401
|
+
expect(listed.stdout).toBe(many.map((file) => file.contents).join(""))
|
|
402
|
+
} finally {
|
|
403
|
+
await sandbox.destroy()
|
|
404
|
+
}
|
|
405
|
+
})
|
|
406
|
+
|
|
357
407
|
test("writeFiles after stop rejects", async () => {
|
|
358
408
|
const sandbox = await factory.create()
|
|
359
409
|
await sandbox.stop()
|
package/src/workers/README.md
CHANGED
|
@@ -111,7 +111,10 @@ the run failed, and if the lake cannot say, the run stays open for the next deli
|
|
|
111
111
|
|
|
112
112
|
A checkpoint is one cursor, and two runs reading from it read the same rows. So a queued sync run
|
|
113
113
|
waits while another run of that sync is `running`, however that one is doing, and triggers that
|
|
114
|
-
arrive meanwhile join it, through one job per run.
|
|
114
|
+
arrive meanwhile join it, through one job per run. A sync of an OAuth connector runs once per
|
|
115
|
+
connection, with a checkpoint for each, and the rule still holds per sync: every connection's runs
|
|
116
|
+
commit to the one dataset, and a merge run's commit fails if anything committed since its read
|
|
117
|
+
began. A trigger joins only its own connection's queued run. The check holds in the transaction that claims the
|
|
115
118
|
run (an advisory lock on PostgreSQL). Datasets stay multi-writer, which is why this is a rule about
|
|
116
119
|
syncs and not about the dataset: guarding every sync from its start would fail it for any ingest that
|
|
117
120
|
landed while it read.
|
package/src/workers/lost-runs.ts
CHANGED
|
@@ -280,6 +280,7 @@ function syncLane({ projectId, storage, queues }: LaneInput) {
|
|
|
280
280
|
payload: {
|
|
281
281
|
syncId: run.syncId,
|
|
282
282
|
runId: run.id,
|
|
283
|
+
...(run.connectionId === undefined ? {} : { connectionId: run.connectionId }),
|
|
283
284
|
status: "cancelled",
|
|
284
285
|
datasetId: run.datasetId,
|
|
285
286
|
error: failure,
|
|
@@ -79,19 +79,30 @@ export abstract class QueueWorker<
|
|
|
79
79
|
return this.config.claimLimit
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
/**
|
|
83
|
+
* Stops claiming new jobs and waits for in-flight jobs to finish. When `timeoutMs` elapses
|
|
84
|
+
* first, aborts remaining jobs through `stop()` and returns `false`.
|
|
85
|
+
*/
|
|
86
|
+
async drain(timeoutMs?: number): Promise<boolean> {
|
|
87
|
+
if (timeoutMs !== undefined && (!Number.isFinite(timeoutMs) || timeoutMs < 0)) {
|
|
88
|
+
throw new Error("[SixbQueueWorker] Drain timeout must be a non-negative finite number.")
|
|
89
|
+
}
|
|
90
|
+
return this.drainRunning(timeoutMs)
|
|
91
|
+
}
|
|
92
|
+
|
|
82
93
|
protected async run(signal: AbortSignal): Promise<void> {
|
|
83
94
|
const inFlight = new Set<Promise<void>>()
|
|
84
95
|
let runError: unknown = null
|
|
85
|
-
// A claim waits for work, so a failed job must also end the wait it
|
|
96
|
+
// A claim waits for work, so a failed job or a drain must also end the wait it sits in.
|
|
86
97
|
const failed = new AbortController()
|
|
87
|
-
const claimSignal = AbortSignal.any([signal, failed.signal])
|
|
98
|
+
const claimSignal = AbortSignal.any([signal, this.drainSignal, failed.signal])
|
|
88
99
|
|
|
89
100
|
try {
|
|
90
|
-
while (!
|
|
91
|
-
while (!
|
|
101
|
+
while (!claimSignal.aborted && !runError) {
|
|
102
|
+
while (!claimSignal.aborted && !runError && inFlight.size >= this.config.claimLimit) {
|
|
92
103
|
await Promise.race(inFlight)
|
|
93
104
|
}
|
|
94
|
-
if (runError ||
|
|
105
|
+
if (runError || claimSignal.aborted) {
|
|
95
106
|
continue
|
|
96
107
|
}
|
|
97
108
|
|
package/src/workers/worker.ts
CHANGED
|
@@ -10,13 +10,17 @@ const STABLE_RUN_MS = 60_000
|
|
|
10
10
|
/** Base worker lifecycle with bounded restart supervision. */
|
|
11
11
|
export abstract class Worker {
|
|
12
12
|
private controller: AbortController | null = null
|
|
13
|
+
private drainController: AbortController | null = null
|
|
13
14
|
private running: Promise<void> | null = null
|
|
14
15
|
|
|
15
16
|
async start(): Promise<void> {
|
|
16
17
|
if (this.controller) return
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
const controller = new AbortController()
|
|
20
|
+
const drainController = new AbortController()
|
|
21
|
+
this.controller = controller
|
|
22
|
+
this.drainController = drainController
|
|
23
|
+
this.running = this.supervise(controller.signal, drainController.signal)
|
|
20
24
|
// `wait()` exposes terminal failure. Keep a handler attached for embedded callers that only use
|
|
21
25
|
// start/stop, so an exhausted restart budget does not become an unhandled rejection.
|
|
22
26
|
this.running.catch(() => {})
|
|
@@ -26,10 +30,12 @@ export abstract class Worker {
|
|
|
26
30
|
const controller = this.controller
|
|
27
31
|
if (!controller) return
|
|
28
32
|
|
|
33
|
+
this.drainController?.abort()
|
|
29
34
|
controller.abort()
|
|
30
35
|
await this.running?.catch(() => {})
|
|
31
36
|
if (this.controller === controller) {
|
|
32
37
|
this.controller = null
|
|
38
|
+
this.drainController = null
|
|
33
39
|
this.running = null
|
|
34
40
|
}
|
|
35
41
|
}
|
|
@@ -39,21 +45,75 @@ export abstract class Worker {
|
|
|
39
45
|
return this.running ?? Promise.resolve()
|
|
40
46
|
}
|
|
41
47
|
|
|
48
|
+
/** Aborts when `drainRunning` or `stop` begins, before `run`'s abort signal fires. */
|
|
49
|
+
protected get drainSignal(): AbortSignal {
|
|
50
|
+
return this.drainController?.signal ?? AbortSignal.abort()
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Stops new work through `drainSignal` and waits for `run` to finish, falling back to `stop()`
|
|
55
|
+
* when `timeoutMs` elapses first. Returns `true` when `run` finished without aborting `signal`.
|
|
56
|
+
*/
|
|
57
|
+
protected async drainRunning(timeoutMs?: number): Promise<boolean> {
|
|
58
|
+
const controller = this.controller
|
|
59
|
+
if (!controller) return true
|
|
60
|
+
|
|
61
|
+
this.drainController?.abort()
|
|
62
|
+
const running = (this.running ?? Promise.resolve()).then(
|
|
63
|
+
() => true,
|
|
64
|
+
() => true
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
if (timeoutMs !== undefined && timeoutMs <= 0) {
|
|
68
|
+
await this.stop()
|
|
69
|
+
return false
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
let finished = false
|
|
73
|
+
if (timeoutMs === undefined) {
|
|
74
|
+
finished = await running
|
|
75
|
+
} else {
|
|
76
|
+
let timer: ReturnType<typeof setTimeout> | undefined
|
|
77
|
+
try {
|
|
78
|
+
finished = await Promise.race([
|
|
79
|
+
running,
|
|
80
|
+
new Promise<boolean>((resolve) => {
|
|
81
|
+
timer = setTimeout(() => resolve(false), timeoutMs)
|
|
82
|
+
}),
|
|
83
|
+
])
|
|
84
|
+
} finally {
|
|
85
|
+
if (timer !== undefined) clearTimeout(timer)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (!finished) {
|
|
90
|
+
await this.stop()
|
|
91
|
+
return false
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (this.controller === controller) {
|
|
95
|
+
this.controller = null
|
|
96
|
+
this.drainController = null
|
|
97
|
+
this.running = null
|
|
98
|
+
}
|
|
99
|
+
return !controller.signal.aborted
|
|
100
|
+
}
|
|
101
|
+
|
|
42
102
|
protected abstract run(signal: AbortSignal): Promise<void>
|
|
43
103
|
|
|
44
|
-
private async supervise(signal: AbortSignal): Promise<void> {
|
|
104
|
+
private async supervise(signal: AbortSignal, drainSignal: AbortSignal): Promise<void> {
|
|
45
105
|
let restartCount = 0
|
|
46
106
|
|
|
47
|
-
while (!signal.aborted) {
|
|
107
|
+
while (!signal.aborted && !drainSignal.aborted) {
|
|
48
108
|
const startedAt = Date.now()
|
|
49
109
|
let failure: unknown
|
|
50
110
|
|
|
51
111
|
try {
|
|
52
112
|
await this.run(signal)
|
|
53
|
-
if (signal.aborted) return
|
|
113
|
+
if (signal.aborted || drainSignal.aborted) return
|
|
54
114
|
failure = new Error(`[SixbWorker] ${this.constructor.name} stopped unexpectedly.`)
|
|
55
115
|
} catch (error) {
|
|
56
|
-
if (signal.aborted) return
|
|
116
|
+
if (signal.aborted || drainSignal.aborted) return
|
|
57
117
|
failure = error
|
|
58
118
|
}
|
|
59
119
|
|
|
@@ -66,7 +126,7 @@ export abstract class Worker {
|
|
|
66
126
|
|
|
67
127
|
const delayMs = backoffDelay(restartCount, RESTART_BACKOFF)
|
|
68
128
|
restartCount += 1
|
|
69
|
-
await waitUnlessAborted(delayMs, signal)
|
|
129
|
+
await waitUnlessAborted(delayMs, AbortSignal.any([signal, drainSignal]))
|
|
70
130
|
}
|
|
71
131
|
}
|
|
72
132
|
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/connectors/connections/capability.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"import type { ConnectorConnectionCallbackProcess } from \"./contracts\"\nimport type { ConnectorConnectionsRuntime } from \"./execution\"\n\nconst connectorConnectionsRuntimeKey: unique symbol = Symbol(\"sixb.connectorConnectionsRuntime\")\nconst connectorConnectionCallbackKey: unique symbol = Symbol(\"sixb.connectorConnectionCallback\")\n\ninterface ConnectorConnectionsRuntimeOwner {\n readonly [connectorConnectionsRuntimeKey]?: ConnectorConnectionsRuntime\n}\n\ninterface ConnectorConnectionCallbackOwner {\n readonly [connectorConnectionCallbackKey]?: ConnectorConnectionCallbackProcess\n}\n\nexport function registerConnectorConnectionsRuntime(\n owner: object,\n runtime: ConnectorConnectionsRuntime\n): void {\n const registered = (owner as ConnectorConnectionsRuntimeOwner)[connectorConnectionsRuntimeKey]\n if (registered && registered !== runtime) {\n throw new Error(\"[Sixb] Connector connections runtime is already registered for this owner.\")\n }\n Object.defineProperty(owner, connectorConnectionsRuntimeKey, {\n configurable: false,\n enumerable: false,\n value: runtime,\n writable: false,\n })\n}\n\nexport function getConnectorConnectionsRuntime(owner: object): ConnectorConnectionsRuntime {\n const runtime = (owner as ConnectorConnectionsRuntimeOwner)[connectorConnectionsRuntimeKey]\n if (runtime) return runtime\n throw new Error(\"[Sixb] Connector connections runtime is not registered for this execution.\")\n}\n\nexport function registerConnectorConnectionCallbackProcess(\n owner: object,\n process: ConnectorConnectionCallbackProcess\n): void {\n const registered = (owner as ConnectorConnectionCallbackOwner)[connectorConnectionCallbackKey]\n if (registered && registered !== process) {\n throw new Error(\"[Sixb] Connector callback process is already registered for this host.\")\n }\n Object.defineProperty(owner, connectorConnectionCallbackKey, {\n configurable: false,\n enumerable: false,\n value: process,\n writable: false,\n })\n}\n\nexport function getConnectorConnectionCallbackProcess(\n owner: object\n): ConnectorConnectionCallbackProcess {\n const process = (owner as ConnectorConnectionCallbackOwner)[connectorConnectionCallbackKey]\n if (process) return process\n throw new Error(\"[Sixb] Connector callback process is not registered for this host.\")\n}\n"
|
|
6
|
-
],
|
|
7
|
-
"mappings": ";;AAGA,IAAM,iCAAgD,OAAO,kCAAkC;AAC/F,IAAM,iCAAgD,OAAO,kCAAkC;AAUxF,SAAS,mCAAmC,CACjD,OACA,SACM;AAAA,EACN,MAAM,aAAc,MAA2C;AAAA,EAC/D,IAAI,cAAc,eAAe,SAAS;AAAA,IACxC,MAAM,IAAI,MAAM,4EAA4E;AAAA,EAC9F;AAAA,EACA,OAAO,eAAe,OAAO,gCAAgC;AAAA,IAC3D,cAAc;AAAA,IACd,YAAY;AAAA,IACZ,OAAO;AAAA,IACP,UAAU;AAAA,EACZ,CAAC;AAAA;AAGI,SAAS,+BAA8B,CAAC,OAA4C;AAAA,EACzF,MAAM,UAAW,MAA2C;AAAA,EAC5D,IAAI;AAAA,IAAS,OAAO;AAAA,EACpB,MAAM,IAAI,MAAM,4EAA4E;AAAA;AAGvF,SAAS,0CAA0C,CACxD,OACA,SACM;AAAA,EACN,MAAM,aAAc,MAA2C;AAAA,EAC/D,IAAI,cAAc,eAAe,SAAS;AAAA,IACxC,MAAM,IAAI,MAAM,wEAAwE;AAAA,EAC1F;AAAA,EACA,OAAO,eAAe,OAAO,gCAAgC;AAAA,IAC3D,cAAc;AAAA,IACd,YAAY;AAAA,IACZ,OAAO;AAAA,IACP,UAAU;AAAA,EACZ,CAAC;AAAA;AAGI,SAAS,sCAAqC,CACnD,OACoC;AAAA,EACpC,MAAM,UAAW,MAA2C;AAAA,EAC5D,IAAI;AAAA,IAAS,OAAO;AAAA,EACpB,MAAM,IAAI,MAAM,oEAAoE;AAAA;",
|
|
8
|
-
"debugId": "AD5581E8A24D07E264756E2164756E21",
|
|
9
|
-
"names": []
|
|
10
|
-
}
|