@sixb/core 0.2.5 → 0.2.6
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 +2 -2
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +50 -44
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/model-routing.d.ts +5 -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-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/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-5a4a52tq.js → chunk-0pmpwn3g.js} +18 -2
- package/dist/chunk-0pmpwn3g.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-0mvjpgvm.js → chunk-425ydk65.js} +4 -4
- package/dist/{chunk-s5pj68fa.js → chunk-5sswe5ej.js} +2 -2
- package/dist/chunk-6hfbz4d0.js +98 -0
- package/dist/chunk-6hfbz4d0.js.map +10 -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-fpf57gca.js → chunk-7r9mqpva.js} +273 -66
- package/dist/{chunk-fpf57gca.js.map → chunk-7r9mqpva.js.map} +5 -5
- 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-90nqenq8.js +386 -0
- package/dist/chunk-90nqenq8.js.map +14 -0
- package/dist/{chunk-gjhrz66x.js → chunk-9c9yknwt.js} +247 -20
- package/dist/{chunk-gjhrz66x.js.map → chunk-9c9yknwt.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-z1njfqqs.js → chunk-ats8y3d9.js} +721 -156
- package/dist/{chunk-z1njfqqs.js.map → chunk-ats8y3d9.js.map} +13 -13
- package/dist/{chunk-68hm50qh.js → chunk-bcz9dxtf.js} +16 -46
- package/dist/chunk-bcz9dxtf.js.map +12 -0
- package/dist/{chunk-naxjka9v.js → chunk-brhp9d97.js} +2 -2
- package/dist/{chunk-8a8k38tz.js → chunk-brybqw5k.js} +1 -1
- package/dist/{chunk-s1mqyqmm.js → chunk-bs1sd0e0.js} +12 -8
- package/dist/chunk-bs1sd0e0.js.map +18 -0
- package/dist/{chunk-vehcr9eb.js → chunk-cg7cygfj.js} +1 -1
- package/dist/chunk-dq3t5sr3.js +114 -0
- package/dist/chunk-dq3t5sr3.js.map +11 -0
- package/dist/{chunk-r2psmn42.js → chunk-eg6xqef7.js} +1 -1
- package/dist/{chunk-zxhym8tr.js → chunk-f05994as.js} +1 -1
- package/dist/{chunk-5t9gm5tt.js → chunk-fmgf9h5e.js} +38 -14
- package/dist/chunk-fmgf9h5e.js.map +22 -0
- package/dist/{chunk-ey1p8w68.js → chunk-gaj8djsw.js} +80 -4
- package/dist/chunk-gaj8djsw.js.map +13 -0
- package/dist/{chunk-1yh6jgtz.js → chunk-grt2j5vp.js} +2 -2
- 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-rtdrm592.js → chunk-htdzx40w.js} +2 -2
- package/dist/{chunk-bc3y6gff.js → chunk-jka26v8c.js} +1 -1
- package/dist/{chunk-m3qx2pns.js → chunk-jt012fxq.js} +28 -12
- package/dist/{chunk-m3qx2pns.js.map → chunk-jt012fxq.js.map} +5 -5
- package/dist/{chunk-k3jh8gsg.js → chunk-kft7mp7z.js} +20 -3
- package/dist/chunk-kft7mp7z.js.map +10 -0
- package/dist/{chunk-qavwr628.js → chunk-n1hbwc6y.js} +5 -6
- package/dist/chunk-n1hbwc6y.js.map +12 -0
- package/dist/chunk-nxysqbt0.js.map +2 -2
- package/dist/{chunk-pqvvqc65.js → chunk-pqj8vff9.js} +3 -3
- 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-rg725hry.js → chunk-s8xxef60.js} +83 -33
- package/dist/{chunk-rg725hry.js.map → chunk-s8xxef60.js.map} +5 -5
- package/dist/{chunk-fzae1jpq.js → chunk-t19wjmnc.js} +5 -5
- 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-0hkdtwqk.js → chunk-xf76csps.js} +5 -5
- package/dist/{chunk-m9ketb51.js → chunk-ygvay56w.js} +1 -1
- package/dist/{chunk-b4escq4c.js → chunk-ykchk644.js} +6 -6
- package/dist/{chunk-k29n4176.js → chunk-ym1bqd98.js} +6 -6
- 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/types.d.ts +4 -1
- package/dist/deploy/types.d.ts.map +1 -1
- 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 +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +61 -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/host.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/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/index.d.ts +3 -1
- package/dist/sandboxes/index.d.ts.map +1 -1
- package/dist/sandboxes/index.js +5 -5
- 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 +18 -2
- package/dist/storage/agents/provider.js.map +1 -1
- package/dist/storage/agents/types.d.ts +136 -3
- 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 +22 -21
- 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 +1051 -58
- package/dist/testing/index.js.map +8 -8
- package/dist/testing/run-claim-storage-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 +4 -0
- package/src/agents/model-routing.ts +25 -9
- package/src/agents/request.ts +759 -40
- package/src/agents/run-events.ts +235 -38
- package/src/agents/run-session-children.ts +13 -2
- 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/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/types.ts +4 -1
- 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 +18 -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/host.ts +13 -7
- package/src/runtime/locale.ts +0 -10
- package/src/runtime/sixb.ts +12 -2
- package/src/sandboxes/README.md +3 -1
- package/src/sandboxes/auth.ts +32 -4
- package/src/sandboxes/index.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 +170 -13
- package/src/storage/agents/types.ts +148 -3
- 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 +767 -8
- package/src/testing/ai-cost-storage-contract.ts +80 -0
- package/src/testing/artifact-storage-contract.ts +129 -0
- package/src/testing/run-claim-storage-contract.ts +116 -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-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-0mvjpgvm.js.map → chunk-425ydk65.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-r2psmn42.js.map → chunk-eg6xqef7.js.map} +0 -0
- /package/dist/{chunk-zxhym8tr.js.map → chunk-f05994as.js.map} +0 -0
- /package/dist/{chunk-1yh6jgtz.js.map → chunk-grt2j5vp.js.map} +0 -0
- /package/dist/{chunk-rtdrm592.js.map → chunk-htdzx40w.js.map} +0 -0
- /package/dist/{chunk-bc3y6gff.js.map → chunk-jka26v8c.js.map} +0 -0
- /package/dist/{chunk-pqvvqc65.js.map → chunk-pqj8vff9.js.map} +0 -0
- /package/dist/{chunk-wqe9shx2.js.map → chunk-qbd282aa.js.map} +0 -0
- /package/dist/{chunk-fzae1jpq.js.map → chunk-t19wjmnc.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-0hkdtwqk.js.map → chunk-xf76csps.js.map} +0 -0
- /package/dist/{chunk-m9ketb51.js.map → chunk-ygvay56w.js.map} +0 -0
- /package/dist/{chunk-b4escq4c.js.map → chunk-ykchk644.js.map} +0 -0
- /package/dist/{chunk-k29n4176.js.map → chunk-ym1bqd98.js.map} +0 -0
|
@@ -261,15 +261,25 @@ export class InMemoryArtifactStorage implements ArtifactStorage {
|
|
|
261
261
|
}
|
|
262
262
|
|
|
263
263
|
async undoTurnWrites(input: UndoArtifactTurnInput): Promise<UndoneArtifactTurn> {
|
|
264
|
-
const { turnRunId } = input
|
|
264
|
+
const { turnRunId, laterTurnRunIds = [] } = input
|
|
265
265
|
const restored: PublishedArtifactVersion[] = []
|
|
266
266
|
const deleted: string[] = []
|
|
267
267
|
|
|
268
268
|
for (const [key, stored] of this.artifacts) {
|
|
269
269
|
if (stored.record.projectId !== input.projectId) continue
|
|
270
270
|
|
|
271
|
-
const
|
|
272
|
-
if (!
|
|
271
|
+
const own = stored.turnWrites.get(turnRunId)
|
|
272
|
+
if (!own) continue
|
|
273
|
+
|
|
274
|
+
// The later turns undone with this one wrote as this one did.
|
|
275
|
+
const later = laterTurnRunIds.filter((each) => stored.turnWrites.has(each))
|
|
276
|
+
const write = {
|
|
277
|
+
...own,
|
|
278
|
+
writes: later.reduce(
|
|
279
|
+
(sum, each) => sum + (stored.turnWrites.get(each)?.writes ?? 0),
|
|
280
|
+
own.writes
|
|
281
|
+
),
|
|
282
|
+
}
|
|
273
283
|
|
|
274
284
|
const revision = stored.record.revision
|
|
275
285
|
if (
|
|
@@ -296,8 +306,13 @@ export class InMemoryArtifactStorage implements ArtifactStorage {
|
|
|
296
306
|
untouched && point ? undo(stored, point, input.documents?.[stored.record.id]) : null
|
|
297
307
|
|
|
298
308
|
// Undone, the turn's restore point is what the artifact holds again, and the threads it
|
|
299
|
-
// alone shared the artifact in no longer do. Kept, the artifact stays where it was made
|
|
300
|
-
|
|
309
|
+
// alone shared the artifact in no longer do. Kept, the artifact stays where it was made, and
|
|
310
|
+
// the later turns keep their records for their own undo.
|
|
311
|
+
let next = forgetTurn(undone ?? stored, turnRunId, { undone: undone !== null })
|
|
312
|
+
if (undone) {
|
|
313
|
+
for (const each of later) next = forgetTurn(next, each, { undone: true })
|
|
314
|
+
}
|
|
315
|
+
|
|
301
316
|
this.artifacts.set(key, next)
|
|
302
317
|
if (undone) restored.push(published(next))
|
|
303
318
|
}
|
|
@@ -155,14 +155,20 @@ export function turnUndoable(input: {
|
|
|
155
155
|
/**
|
|
156
156
|
* Whether someone other than a retried turn and its requester commented on an artifact the turn
|
|
157
157
|
* created. Their words would go with it, so a retry keeps it, as it keeps one someone else wrote:
|
|
158
|
-
* a comment never moves the revision, which is all `turnUndoable` reads.
|
|
158
|
+
* a comment never moves the revision, which is all `turnUndoable` reads. The later turns undone
|
|
159
|
+
* with it are the turn's own.
|
|
159
160
|
*/
|
|
160
161
|
export function othersCommented(
|
|
161
162
|
comments: readonly Pick<ArtifactCommentRecord, "author" | "origin">[],
|
|
162
|
-
turn: {
|
|
163
|
+
turn: {
|
|
164
|
+
readonly turnRunId: string
|
|
165
|
+
readonly laterTurnRunIds?: readonly string[]
|
|
166
|
+
readonly requester?: Principal
|
|
167
|
+
}
|
|
163
168
|
): boolean {
|
|
164
169
|
return comments.some(({ author, origin }) => {
|
|
165
170
|
if (origin?.runId === turn.turnRunId) return false
|
|
171
|
+
if (origin && turn.laterTurnRunIds?.includes(origin.runId)) return false
|
|
166
172
|
return !turn.requester || author.type === "guest" || !principalsEqual(author, turn.requester)
|
|
167
173
|
})
|
|
168
174
|
}
|
|
@@ -225,6 +225,13 @@ export interface UndoArtifactTurnInput extends ArtifactTurnInput {
|
|
|
225
225
|
* bring up to the content.
|
|
226
226
|
*/
|
|
227
227
|
readonly documents?: Readonly<Record<string, FileRef>>
|
|
228
|
+
/**
|
|
229
|
+
* Later turns undone with this one, as an edit that takes several turns back undoes them, oldest
|
|
230
|
+
* first: their writes to an artifact this turn wrote count as this turn's, so the artifact goes
|
|
231
|
+
* back to before this turn when only these turns wrote it since. Undone, their records on it go
|
|
232
|
+
* too; kept, they stay for their own undo.
|
|
233
|
+
*/
|
|
234
|
+
readonly laterTurnRunIds?: readonly string[]
|
|
228
235
|
}
|
|
229
236
|
|
|
230
237
|
/** What undoing a turn's writes changed. */
|
package/src/storage/index.ts
CHANGED
|
@@ -130,6 +130,9 @@ export type {
|
|
|
130
130
|
AgentThreadParent,
|
|
131
131
|
AgentThreadParticipantRecord,
|
|
132
132
|
AgentThreadPlace,
|
|
133
|
+
AgentThreadReadRecord,
|
|
134
|
+
AgentThreadReadState,
|
|
135
|
+
AgentThreadReadStore,
|
|
133
136
|
AgentThreadRecord,
|
|
134
137
|
AgentThreadSandboxParams,
|
|
135
138
|
AgentThreadSandboxState,
|
|
@@ -149,7 +152,9 @@ export type {
|
|
|
149
152
|
CreateSubagentRunInput,
|
|
150
153
|
DecideAgentApprovalInput,
|
|
151
154
|
DecideAgentApprovalResult,
|
|
155
|
+
DeleteAgentContextCheckpointsAfterSeqInput,
|
|
152
156
|
DeleteAgentMessagesByRunInput,
|
|
157
|
+
DeleteAgentMessagesFromSeqInput,
|
|
153
158
|
EnqueueAgentInboxItemInput,
|
|
154
159
|
EnqueueAgentInboxItemResult,
|
|
155
160
|
FinishAgentRunInput,
|
|
@@ -166,11 +171,14 @@ export type {
|
|
|
166
171
|
ListAgentRunsResult,
|
|
167
172
|
ListAgentThreadChildrenInput,
|
|
168
173
|
ListAgentThreadParticipantsInput,
|
|
174
|
+
ListAgentThreadReadsInput,
|
|
169
175
|
ListAgentThreadsInput,
|
|
170
176
|
ListAgentThreadsResult,
|
|
177
|
+
ListLatestAgentRunsInput,
|
|
171
178
|
ListThreadSubagentsInput,
|
|
172
179
|
ListWaitingAgentInboxThreadsInput,
|
|
173
180
|
MarkAgentApprovalsReportedInput,
|
|
181
|
+
MarkAgentThreadReadInput,
|
|
174
182
|
MoveAgentThreadToCloudInput,
|
|
175
183
|
MoveAgentThreadToCloudResult,
|
|
176
184
|
ReclaimAgentRunInput,
|
|
@@ -179,6 +187,8 @@ export type {
|
|
|
179
187
|
RequestAgentApprovalInput,
|
|
180
188
|
RequestAgentApprovalResult,
|
|
181
189
|
RequestAgentRunCancelInput,
|
|
190
|
+
RewindAgentApprovalsInput,
|
|
191
|
+
RewindAgentApprovalsResult,
|
|
182
192
|
SaveAgentMemoryInput,
|
|
183
193
|
SaveAgentMemoryResult,
|
|
184
194
|
SettleAgentApprovalsInput,
|
|
@@ -910,6 +920,7 @@ export type {
|
|
|
910
920
|
export { InMemoryShareSessionStorage, ShareSessionStorageError } from "./share-sessions"
|
|
911
921
|
export type {
|
|
912
922
|
FinishSyncRunInput,
|
|
923
|
+
ListLatestSyncConnectionRunsInput,
|
|
913
924
|
ListLatestSyncRunsInput,
|
|
914
925
|
ListLatestSyncRunsResult,
|
|
915
926
|
ListSyncRunsInput,
|
|
@@ -286,6 +286,7 @@ export function createAgentOperationScope<T extends AgentStorage>(
|
|
|
286
286
|
): T {
|
|
287
287
|
return createOperationScopedFacade<AgentStorage>(target, scope, {
|
|
288
288
|
threads: createOperationScopedFacade(target.threads, scope),
|
|
289
|
+
reads: createOperationScopedFacade(target.reads, scope),
|
|
289
290
|
runs: createOperationScopedFacade(target.runs, scope),
|
|
290
291
|
messages: createOperationScopedFacade(target.messages, scope),
|
|
291
292
|
checkpoints: createOperationScopedFacade(target.checkpoints, scope),
|
|
@@ -10,6 +10,7 @@ export function canRequeueSyncRunAfterEnqueueFailure(
|
|
|
10
10
|
existing.error.retryable &&
|
|
11
11
|
existing.executionId === input.executionId &&
|
|
12
12
|
existing.syncId === input.syncId &&
|
|
13
|
+
existing.connectionId === input.connectionId &&
|
|
13
14
|
existing.datasetId === input.datasetId &&
|
|
14
15
|
existing.mode === input.mode &&
|
|
15
16
|
existing.expectedLatestVersionId === input.expectedLatestVersionId &&
|
|
@@ -27,6 +27,7 @@ import { assertSyncRunExecution } from "./provider"
|
|
|
27
27
|
import { canFinishSyncRun } from "./transitions"
|
|
28
28
|
import type {
|
|
29
29
|
FinishSyncRunInput,
|
|
30
|
+
ListLatestSyncConnectionRunsInput,
|
|
30
31
|
ListLatestSyncRunsInput,
|
|
31
32
|
ListLatestSyncRunsResult,
|
|
32
33
|
ListSyncRunsInput,
|
|
@@ -126,6 +127,7 @@ export class InMemorySyncRunStorage implements SyncRunStorage {
|
|
|
126
127
|
projectId: input.projectId,
|
|
127
128
|
executionId: input.executionId,
|
|
128
129
|
syncId: input.syncId,
|
|
130
|
+
...(input.connectionId === undefined ? {} : { connectionId: input.connectionId }),
|
|
129
131
|
datasetId: input.datasetId,
|
|
130
132
|
mode: input.mode,
|
|
131
133
|
status: "queued",
|
|
@@ -281,6 +283,12 @@ export class InMemorySyncRunStorage implements SyncRunStorage {
|
|
|
281
283
|
.filter((record) => record.projectId === input.projectId)
|
|
282
284
|
.filter((record) => (input.syncId ? record.syncId === input.syncId : true))
|
|
283
285
|
.filter((record) => (syncIds ? syncIds.has(record.syncId) : true))
|
|
286
|
+
.filter((record) =>
|
|
287
|
+
input.connectionId === undefined
|
|
288
|
+
? true
|
|
289
|
+
: (record.connectionId ?? null) === input.connectionId
|
|
290
|
+
)
|
|
291
|
+
.filter((record) => isVisibleRun(record, input.visibleConnectionIds))
|
|
284
292
|
.filter((record) => (input.datasetId ? record.datasetId === input.datasetId : true))
|
|
285
293
|
.filter((record) =>
|
|
286
294
|
matchesRunListDateFilters(record, {
|
|
@@ -302,7 +310,10 @@ export class InMemorySyncRunStorage implements SyncRunStorage {
|
|
|
302
310
|
|
|
303
311
|
async listLatestBySyncIds(input: ListLatestSyncRunsInput): Promise<ListLatestSyncRunsResult> {
|
|
304
312
|
const runs = latestStartedAtByOwnerId(
|
|
305
|
-
[...this.rows.values()].filter(
|
|
313
|
+
[...this.rows.values()].filter(
|
|
314
|
+
(record) =>
|
|
315
|
+
record.projectId === input.projectId && isVisibleRun(record, input.visibleConnectionIds)
|
|
316
|
+
),
|
|
306
317
|
input.syncIds,
|
|
307
318
|
(record) => record.syncId
|
|
308
319
|
)
|
|
@@ -312,6 +323,25 @@ export class InMemorySyncRunStorage implements SyncRunStorage {
|
|
|
312
323
|
}
|
|
313
324
|
}
|
|
314
325
|
|
|
326
|
+
async listLatestByConnection(
|
|
327
|
+
input: ListLatestSyncConnectionRunsInput
|
|
328
|
+
): Promise<ListLatestSyncRunsResult> {
|
|
329
|
+
const syncIds = new Set(input.syncIds)
|
|
330
|
+
const connectionIds = input.connectionIds ? new Set(input.connectionIds) : null
|
|
331
|
+
const latest = new Map<string, SyncRunRecord>()
|
|
332
|
+
for (const record of this.rows.values()) {
|
|
333
|
+
const { connectionId } = record
|
|
334
|
+
if (record.projectId !== input.projectId || connectionId === undefined) continue
|
|
335
|
+
if (!syncIds.has(record.syncId) || (connectionIds && !connectionIds.has(connectionId))) {
|
|
336
|
+
continue
|
|
337
|
+
}
|
|
338
|
+
const key = JSON.stringify([record.syncId, connectionId])
|
|
339
|
+
const current = latest.get(key)
|
|
340
|
+
if (!current || compareStartedAt(record, current, "desc") < 0) latest.set(key, record)
|
|
341
|
+
}
|
|
342
|
+
return { runs: [...latest.values()].map(cloneSyncRunRecord) }
|
|
343
|
+
}
|
|
344
|
+
|
|
315
345
|
private requireRun(projectId: string, id: string): SyncRunRecord {
|
|
316
346
|
const existing = this.rows.get(syncRunKey(projectId, id))
|
|
317
347
|
if (!existing) {
|
|
@@ -334,6 +364,18 @@ export class InMemorySyncRunStorage implements SyncRunStorage {
|
|
|
334
364
|
}
|
|
335
365
|
}
|
|
336
366
|
|
|
367
|
+
/** Whether `visibleConnectionIds` keeps this run, as `ListSyncRunsInput` describes. */
|
|
368
|
+
function isVisibleRun(
|
|
369
|
+
record: SyncRunRecord,
|
|
370
|
+
visibleConnectionIds: readonly string[] | undefined
|
|
371
|
+
): boolean {
|
|
372
|
+
return (
|
|
373
|
+
visibleConnectionIds === undefined ||
|
|
374
|
+
record.connectionId === undefined ||
|
|
375
|
+
visibleConnectionIds.includes(record.connectionId)
|
|
376
|
+
)
|
|
377
|
+
}
|
|
378
|
+
|
|
337
379
|
function staleExecution(id: string): SyncRunError {
|
|
338
380
|
return new SyncRunError(`[Sixb] Execution token is no longer current on sync run '${id}'.`)
|
|
339
381
|
}
|
|
@@ -3,6 +3,7 @@ export { canRequeueSyncRunAfterEnqueueFailure } from "./idempotency"
|
|
|
3
3
|
export { InMemorySyncRunStorage } from "./in-memory"
|
|
4
4
|
export type {
|
|
5
5
|
FinishSyncRunInput,
|
|
6
|
+
ListLatestSyncConnectionRunsInput,
|
|
6
7
|
ListLatestSyncRunsInput,
|
|
7
8
|
ListLatestSyncRunsResult,
|
|
8
9
|
ListSyncRunsInput,
|
|
@@ -19,6 +19,7 @@ export const SYNC_RUN_FAILURE_CODES = [
|
|
|
19
19
|
"runtime.cancelled",
|
|
20
20
|
"queue.enqueue_failed",
|
|
21
21
|
"sync.execution_failed",
|
|
22
|
+
"connector.authorization_required",
|
|
22
23
|
] as const satisfies readonly [SixbErrorCode, ...SixbErrorCode[]]
|
|
23
24
|
|
|
24
25
|
export type SyncRunFailureCode = (typeof SYNC_RUN_FAILURE_CODES)[number]
|
|
@@ -28,6 +29,8 @@ export interface SyncRunRecord {
|
|
|
28
29
|
readonly projectId: string
|
|
29
30
|
readonly executionId: string
|
|
30
31
|
readonly syncId: string
|
|
32
|
+
/** The one connection this run reads, on a sync of an OAuth connector. */
|
|
33
|
+
readonly connectionId?: string
|
|
31
34
|
readonly datasetId: string
|
|
32
35
|
readonly mode: SyncRunMode
|
|
33
36
|
readonly status: SyncRunStatus
|
|
@@ -55,6 +58,7 @@ export interface QueueSyncRunInput {
|
|
|
55
58
|
readonly projectId: string
|
|
56
59
|
readonly executionId: string
|
|
57
60
|
readonly syncId: string
|
|
61
|
+
readonly connectionId?: string
|
|
58
62
|
readonly datasetId: string
|
|
59
63
|
readonly mode: SyncRunMode
|
|
60
64
|
readonly queuedAt?: Date
|
|
@@ -111,6 +115,13 @@ export interface ListSyncRunsInput {
|
|
|
111
115
|
readonly projectId: string
|
|
112
116
|
readonly syncId?: string
|
|
113
117
|
readonly syncIds?: readonly string[]
|
|
118
|
+
/** Runs of this connection. `null` lists the runs that read no single connection. */
|
|
119
|
+
readonly connectionId?: string | null
|
|
120
|
+
/**
|
|
121
|
+
* The connections whose runs are listed. Runs of any other connection are left out; runs that
|
|
122
|
+
* read no single connection always stay. Omitted, nothing is left out.
|
|
123
|
+
*/
|
|
124
|
+
readonly visibleConnectionIds?: readonly string[]
|
|
114
125
|
readonly datasetId?: string
|
|
115
126
|
readonly statuses?: readonly SyncRunStatus[]
|
|
116
127
|
readonly startedAfter?: Date
|
|
@@ -129,17 +140,31 @@ export interface ListSyncRunsResult {
|
|
|
129
140
|
export interface ListLatestSyncRunsInput {
|
|
130
141
|
readonly projectId: string
|
|
131
142
|
readonly syncIds: readonly string[]
|
|
143
|
+
/**
|
|
144
|
+
* The connections whose runs are listed. Runs of any other connection are left out; runs that
|
|
145
|
+
* read no single connection always stay. Omitted, nothing is left out.
|
|
146
|
+
*/
|
|
147
|
+
readonly visibleConnectionIds?: readonly string[]
|
|
132
148
|
}
|
|
133
149
|
|
|
134
150
|
export interface ListLatestSyncRunsResult {
|
|
135
151
|
readonly runs: readonly SyncRunRecord[]
|
|
136
152
|
}
|
|
137
153
|
|
|
154
|
+
export interface ListLatestSyncConnectionRunsInput {
|
|
155
|
+
readonly projectId: string
|
|
156
|
+
readonly syncIds: readonly string[]
|
|
157
|
+
/** Only these connections. Omitted, every connection of the syncs. */
|
|
158
|
+
readonly connectionIds?: readonly string[]
|
|
159
|
+
}
|
|
160
|
+
|
|
138
161
|
export interface SyncRunStorage {
|
|
139
162
|
queue(input: QueueSyncRunInput): Promise<SyncRunRecord>
|
|
140
163
|
/**
|
|
141
164
|
* Takes the run for one execution, or says why this delivery cannot. One run of a Sync runs at a
|
|
142
|
-
* time: a checkpoint is one cursor, and two runs reading from it
|
|
165
|
+
* time, whichever connection it reads: a checkpoint is one cursor, and two runs reading from it
|
|
166
|
+
* would read the same rows. Runs of different connections also commit to one dataset, and a
|
|
167
|
+
* merge run's commit fails if anything committed since its read began.
|
|
143
168
|
*/
|
|
144
169
|
startOrReclaim(input: ClaimRunInput): Promise<RunClaim<SyncRunRecord>>
|
|
145
170
|
/** Projects a renewed queue lease onto the run. */
|
|
@@ -152,4 +177,8 @@ export interface SyncRunStorage {
|
|
|
152
177
|
getById(params: { projectId: string; id: string }): Promise<SyncRunRecord | null>
|
|
153
178
|
list(input: ListSyncRunsInput): Promise<ListSyncRunsResult>
|
|
154
179
|
listLatestBySyncIds(input: ListLatestSyncRunsInput): Promise<ListLatestSyncRunsResult>
|
|
180
|
+
/** The latest run of each sync and connection, among runs that read one connection. */
|
|
181
|
+
listLatestByConnection(
|
|
182
|
+
input: ListLatestSyncConnectionRunsInput
|
|
183
|
+
): Promise<ListLatestSyncRunsResult>
|
|
155
184
|
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { type ConnectorConnectionMetadata, isOAuthConnectorDefinition } from "../connectors"
|
|
2
|
+
import type { ExecutionContext } from "../execution"
|
|
3
|
+
import type { SixbRuntimeContext } from "../runtime/types"
|
|
4
|
+
import type { SyncRunRecord } from "../storage/sync-runs"
|
|
5
|
+
import { mayRunConnection, type SyncConnections, seesConnection } from "./connections"
|
|
6
|
+
import type { SyncDefinition } from "./types"
|
|
7
|
+
|
|
8
|
+
/** One connected account of an OAuth connector, and how each of its syncs last ran. */
|
|
9
|
+
export interface SyncAccount {
|
|
10
|
+
readonly connection: ConnectorConnectionMetadata
|
|
11
|
+
/** The latest run of each of the connector's syncs you may run. Empty before the first. */
|
|
12
|
+
readonly latestRuns: readonly SyncRunRecord[]
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Where each connected account stands, for the syncs that run once per account. */
|
|
16
|
+
export interface SyncAccountsRuntime {
|
|
17
|
+
/**
|
|
18
|
+
* The connected accounts of an OAuth connector, with the latest run of each sync you may run:
|
|
19
|
+
* the project's and your own, or everyone's with `can.manage` on the connector. Empty for a
|
|
20
|
+
* static connector, or when you may run none of its syncs.
|
|
21
|
+
*/
|
|
22
|
+
list(connectorId: string): Promise<readonly SyncAccount[]>
|
|
23
|
+
/**
|
|
24
|
+
* The latest run of each sync of one connection you see: your own, or anyone's with
|
|
25
|
+
* `can.manage` on its connector. Empty for a connection you don't see.
|
|
26
|
+
*/
|
|
27
|
+
latestRuns(connectorId: string, connectionId: string): Promise<readonly SyncRunRecord[]>
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function createSyncAccountsRuntime(input: {
|
|
31
|
+
readonly runtime: SixbRuntimeContext
|
|
32
|
+
readonly execution: ExecutionContext
|
|
33
|
+
/** Every sync definition, whether or not the caller may run it. */
|
|
34
|
+
readonly syncs: () => readonly SyncDefinition[]
|
|
35
|
+
/** The syncs the caller may run. */
|
|
36
|
+
readonly runnable: (syncId: string) => SyncDefinition | null
|
|
37
|
+
readonly connections?: SyncConnections
|
|
38
|
+
}): SyncAccountsRuntime {
|
|
39
|
+
const { runtime, execution, connections } = input
|
|
40
|
+
const latestByConnection = (syncIds: readonly string[], connectionIds?: readonly string[]) =>
|
|
41
|
+
runtime.storage.syncRuns
|
|
42
|
+
? runtime.storage.syncRuns
|
|
43
|
+
.listLatestByConnection({
|
|
44
|
+
projectId: runtime.projectId,
|
|
45
|
+
syncIds,
|
|
46
|
+
...(connectionIds === undefined ? {} : { connectionIds }),
|
|
47
|
+
})
|
|
48
|
+
.then(({ runs }) => runs)
|
|
49
|
+
: Promise.resolve([])
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
async list(connectorId) {
|
|
53
|
+
const syncs = input
|
|
54
|
+
.syncs()
|
|
55
|
+
.filter((sync) => sync.connector.id === connectorId && input.runnable(sync.id))
|
|
56
|
+
const connector = syncs[0]?.connector
|
|
57
|
+
if (!connections || !connector || !isOAuthConnectorDefinition(connector)) return []
|
|
58
|
+
|
|
59
|
+
const accounts = (await connections.list(connector)).filter((connection) =>
|
|
60
|
+
mayRunConnection(runtime, execution, connection)
|
|
61
|
+
)
|
|
62
|
+
const runs = await latestByConnection(
|
|
63
|
+
syncs.map(({ id }) => id),
|
|
64
|
+
accounts.map(({ id }) => id)
|
|
65
|
+
)
|
|
66
|
+
return accounts.map((connection) => ({
|
|
67
|
+
connection,
|
|
68
|
+
latestRuns: runs.filter((run) => run.connectionId === connection.id),
|
|
69
|
+
}))
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
async latestRuns(connectorId, connectionId) {
|
|
73
|
+
const syncs = input.syncs().filter((sync) => sync.connector.id === connectorId)
|
|
74
|
+
const connector = syncs[0]?.connector
|
|
75
|
+
if (!connections || !connector || !isOAuthConnectorDefinition(connector)) return []
|
|
76
|
+
|
|
77
|
+
const connection = (await connections.list(connector)).find(({ id }) => id === connectionId)
|
|
78
|
+
if (!connection || !seesConnection(runtime, execution, connection)) return []
|
|
79
|
+
return latestByConnection(
|
|
80
|
+
syncs.map(({ id }) => id),
|
|
81
|
+
[connection.id]
|
|
82
|
+
)
|
|
83
|
+
},
|
|
84
|
+
}
|
|
85
|
+
}
|
package/src/syncs/builders.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
type AnyConnectorAdapter,
|
|
3
|
+
type ConnectorDefinition,
|
|
4
|
+
isOAuthConnectorDefinition,
|
|
5
|
+
} from "../connectors"
|
|
2
6
|
import type { DatasetDefinition } from "../datasets"
|
|
3
7
|
import type { ScheduleDefinition, ScheduleReference } from "../schedules"
|
|
4
8
|
import { isScheduleDefinition } from "../schedules"
|
|
@@ -26,6 +30,17 @@ function assertDataset(dataset: DatasetDefinition, mode: SyncMode): void {
|
|
|
26
30
|
}
|
|
27
31
|
}
|
|
28
32
|
|
|
33
|
+
/**
|
|
34
|
+
* A sync on an OAuth connector runs once per connection, and a snapshot of one connection would
|
|
35
|
+
* replace every other connection's rows.
|
|
36
|
+
*/
|
|
37
|
+
function assertConnectorMode(syncId: string, connector: ConnectorDefinition, mode: SyncMode): void {
|
|
38
|
+
if (mode !== "snapshot" || !isOAuthConnectorDefinition(connector)) return
|
|
39
|
+
throw new SyncValidationError(
|
|
40
|
+
`[Sixb] Sync '${syncId}' reads OAuth connector '${connector.id}', which runs once per connection, so a snapshot of one connection would replace every other connection's rows. Use mode "merge" and return change.delete() for records the provider deleted, or mode "append".`
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
|
|
29
44
|
function normalizeBatchSyncConfig(options: BatchSyncConfig | undefined): BatchSyncDefinitionConfig {
|
|
30
45
|
const mode = options?.mode ?? "snapshot"
|
|
31
46
|
|
|
@@ -85,6 +100,8 @@ export function defineSync<TId extends string>(
|
|
|
85
100
|
from<TConnector extends ConnectorDefinition<string, AnyConnectorAdapter>>(
|
|
86
101
|
connector: TConnector
|
|
87
102
|
): SyncReadBuilder<TId, TConnector, TCheckpoint, SyncMode> {
|
|
103
|
+
assertConnectorMode(id, connector, config.mode)
|
|
104
|
+
|
|
88
105
|
return {
|
|
89
106
|
read(handler): SyncTargetBuilder<TId, TConnector, TCheckpoint, SyncMode> {
|
|
90
107
|
return {
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { isRuntimeAllowed } from "../authorization"
|
|
2
|
+
import {
|
|
3
|
+
type ConnectorConnectionMetadata,
|
|
4
|
+
type ConnectorDefinition,
|
|
5
|
+
isOAuthConnectorDefinition,
|
|
6
|
+
type OAuthConnectorAdapter,
|
|
7
|
+
} from "../connectors"
|
|
8
|
+
import type { ConnectorService } from "../connectors/service"
|
|
9
|
+
import type { ExecutionContext } from "../execution"
|
|
10
|
+
import { resolveRuntimeAuthorizationForProject } from "../execution/authorization"
|
|
11
|
+
import type { SixbRuntimeContext } from "../runtime/types"
|
|
12
|
+
import type { SyncDefinition } from "./types"
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The connections a sync of an OAuth connector runs for: every connected one whose owner isn't
|
|
16
|
+
* suspended. Dispatch reads them without an execution, so a host registers them on itself.
|
|
17
|
+
*/
|
|
18
|
+
export interface SyncConnections {
|
|
19
|
+
list(
|
|
20
|
+
definition: ConnectorDefinition<string, OAuthConnectorAdapter>
|
|
21
|
+
): Promise<readonly ConnectorConnectionMetadata[]>
|
|
22
|
+
/** Every connection of the connector, whatever its status: each one a run has read. */
|
|
23
|
+
listAll(
|
|
24
|
+
definition: ConnectorDefinition<string, OAuthConnectorAdapter>
|
|
25
|
+
): Promise<readonly ConnectorConnectionMetadata[]>
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const registered = new WeakMap<object, SyncConnections>()
|
|
29
|
+
|
|
30
|
+
export function registerSyncConnections(host: object, connections: SyncConnections): void {
|
|
31
|
+
registered.set(host, connections)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function findSyncConnections(host: object): SyncConnections | undefined {
|
|
35
|
+
return registered.get(host)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function createSyncConnections(
|
|
39
|
+
service: Pick<ConnectorService, "listExecutionConnections" | "listAllConnections">
|
|
40
|
+
): SyncConnections {
|
|
41
|
+
return {
|
|
42
|
+
async list(definition) {
|
|
43
|
+
return (await service.listExecutionConnections(definition)).map(toMetadata)
|
|
44
|
+
},
|
|
45
|
+
async listAll(definition) {
|
|
46
|
+
return (await service.listAllConnections(definition)).map(toMetadata)
|
|
47
|
+
},
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function toMetadata({
|
|
52
|
+
id,
|
|
53
|
+
connectorId,
|
|
54
|
+
owner,
|
|
55
|
+
slot,
|
|
56
|
+
account,
|
|
57
|
+
}: ConnectorConnectionMetadata): ConnectorConnectionMetadata {
|
|
58
|
+
return { id, connectorId, owner, slot, account }
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Whether a caller who may run a sync may run, and see, its runs of this connection. Anyone may
|
|
63
|
+
* run the project's. A person's own connection is theirs, and the connector's managers may act on
|
|
64
|
+
* anyone's: a sync reads into rows its owner owns, as the schedule would. A run no one requested
|
|
65
|
+
* may act on them all.
|
|
66
|
+
*/
|
|
67
|
+
export function mayRunConnection(
|
|
68
|
+
runtime: SixbRuntimeContext,
|
|
69
|
+
execution: ExecutionContext,
|
|
70
|
+
connection: ConnectorConnectionMetadata
|
|
71
|
+
): boolean {
|
|
72
|
+
return connection.owner.type === "project" || seesConnection(runtime, execution, connection)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The connections whose runs of these syncs the caller sees, as `mayRunConnection` decides: one
|
|
77
|
+
* listing per OAuth connector they read. Undefined when nothing is left out: no sync reads an
|
|
78
|
+
* OAuth connector, or the caller sees every run.
|
|
79
|
+
*/
|
|
80
|
+
export async function visibleSyncConnectionIds(
|
|
81
|
+
runtime: SixbRuntimeContext,
|
|
82
|
+
execution: ExecutionContext,
|
|
83
|
+
syncs: readonly (SyncDefinition | null)[],
|
|
84
|
+
connections: SyncConnections | undefined
|
|
85
|
+
): Promise<readonly string[] | undefined> {
|
|
86
|
+
const authority = resolveRuntimeAuthorizationForProject(runtime)
|
|
87
|
+
if (authority.type === "unrestricted" || execution.requestedBy === undefined) return undefined
|
|
88
|
+
|
|
89
|
+
const connectors = new Map<string, ConnectorDefinition<string, OAuthConnectorAdapter>>()
|
|
90
|
+
for (const sync of syncs) {
|
|
91
|
+
if (sync && isOAuthConnectorDefinition(sync.connector)) {
|
|
92
|
+
connectors.set(sync.connector.id, sync.connector)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (!connections || connectors.size === 0) return undefined
|
|
96
|
+
|
|
97
|
+
const all = await Promise.all(
|
|
98
|
+
[...connectors.values()].map((connector) => connections.listAll(connector))
|
|
99
|
+
)
|
|
100
|
+
return all
|
|
101
|
+
.flat()
|
|
102
|
+
.filter((connection) => mayRunConnection(runtime, execution, connection))
|
|
103
|
+
.map(({ id }) => id)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Whether the caller sees this connection itself, as the connector's connection views decide: the
|
|
108
|
+
* owner of a personal connection, the connector's managers, and runs no one requested.
|
|
109
|
+
*/
|
|
110
|
+
export function seesConnection(
|
|
111
|
+
runtime: SixbRuntimeContext,
|
|
112
|
+
execution: ExecutionContext,
|
|
113
|
+
connection: ConnectorConnectionMetadata
|
|
114
|
+
): boolean {
|
|
115
|
+
const { owner } = connection
|
|
116
|
+
const requester = execution.requestedBy
|
|
117
|
+
if (requester === undefined) return true
|
|
118
|
+
if (owner.type === "user" && requester.type === "user" && requester.id === owner.id) return true
|
|
119
|
+
return isRuntimeAllowed(runtime, {
|
|
120
|
+
kind: "connector.manage",
|
|
121
|
+
connectorId: connection.connectorId,
|
|
122
|
+
})
|
|
123
|
+
}
|