@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
package/src/calendar.ts
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calendar arithmetic in an IANA time zone.
|
|
3
|
+
*
|
|
4
|
+
* A period of a zone's calendar is not a fixed number of milliseconds: where a zone changes its
|
|
5
|
+
* clocks a day lasts 23 or 25 hours, and a zone such as Asia/Kolkata starts its hours half past a
|
|
6
|
+
* UTC hour. Usage buckets are whole periods of the reader's calendar, so the queried range, the
|
|
7
|
+
* bars and the calls in them all go through these functions.
|
|
8
|
+
*
|
|
9
|
+
* It is `@sixb/core/calendar` rather than `internal/*` because `@sixb/app` draws the bars with it,
|
|
10
|
+
* and the app installs core by a compatible range, which `internal/*` refuses. It is not part of
|
|
11
|
+
* the documented API: export only what the app calls.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { DEFAULT_PROJECT_TIME_ZONE } from "./runtime/locale"
|
|
15
|
+
|
|
16
|
+
/** An hour, a day, or a week starting Monday: the periods a usage chart is drawn in. */
|
|
17
|
+
export type CalendarPeriod = "hour" | "day" | "week"
|
|
18
|
+
|
|
19
|
+
/** A period of the calendar: a start and the start of the one after it. */
|
|
20
|
+
export interface CalendarPeriodRange {
|
|
21
|
+
readonly start: Date
|
|
22
|
+
readonly end: Date
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** A period wider than this many is a caller's mistake, not a chart. */
|
|
26
|
+
const MAX_PERIODS = 10_000
|
|
27
|
+
|
|
28
|
+
const hourMs = 60 * 60 * 1000
|
|
29
|
+
const dayMs = 24 * hourMs
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The canonical IANA name of a time zone (`europe/paris` → `Europe/Paris`), or `undefined`.
|
|
33
|
+
*
|
|
34
|
+
* A UTC offset such as `+05:30` is refused even where `Intl` takes it: it names no zone, and
|
|
35
|
+
* PostgreSQL reads it the POSIX way, five and a half hours west of UTC.
|
|
36
|
+
*/
|
|
37
|
+
export function canonicalTimeZone(value: unknown): string | undefined {
|
|
38
|
+
if (typeof value !== "string" || value.trim() !== value || value === "") return undefined
|
|
39
|
+
let timeZone: string
|
|
40
|
+
try {
|
|
41
|
+
timeZone = new Intl.DateTimeFormat("en-US", { timeZone: value }).resolvedOptions().timeZone
|
|
42
|
+
} catch {
|
|
43
|
+
return undefined
|
|
44
|
+
}
|
|
45
|
+
return /^[+-]/.test(timeZone) ? undefined : timeZone
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Buckets are formatted for every call and every period of a range, so one formatter per zone is
|
|
49
|
+
// built once: constructing one costs more than reading several of them.
|
|
50
|
+
const formatters = new Map<string, Intl.DateTimeFormat>()
|
|
51
|
+
|
|
52
|
+
function formatterFor(timeZone: string): Intl.DateTimeFormat {
|
|
53
|
+
let formatter = formatters.get(timeZone)
|
|
54
|
+
if (!formatter) {
|
|
55
|
+
formatter = new Intl.DateTimeFormat("en-US", {
|
|
56
|
+
timeZone,
|
|
57
|
+
year: "numeric",
|
|
58
|
+
month: "numeric",
|
|
59
|
+
day: "numeric",
|
|
60
|
+
hour: "numeric",
|
|
61
|
+
minute: "numeric",
|
|
62
|
+
second: "numeric",
|
|
63
|
+
hourCycle: "h23",
|
|
64
|
+
})
|
|
65
|
+
formatters.set(timeZone, formatter)
|
|
66
|
+
}
|
|
67
|
+
return formatter
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** The zone's wall clock at an instant, as the milliseconds `Date.UTC` gives for its fields. */
|
|
71
|
+
function wallClockOf(at: Date, timeZone: string): number {
|
|
72
|
+
const parts = formatterFor(timeZone).formatToParts(at)
|
|
73
|
+
const field = (type: Intl.DateTimeFormatPartTypes) => {
|
|
74
|
+
const part = parts.find((candidate) => candidate.type === type)
|
|
75
|
+
if (!part) throw new TypeError(`[Sixb] ${timeZone} did not read back a ${type}.`)
|
|
76
|
+
return Number(part.value)
|
|
77
|
+
}
|
|
78
|
+
return Date.UTC(
|
|
79
|
+
field("year"),
|
|
80
|
+
field("month") - 1,
|
|
81
|
+
field("day"),
|
|
82
|
+
field("hour"),
|
|
83
|
+
field("minute"),
|
|
84
|
+
field("second")
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** How far the zone's wall clock runs ahead of UTC at an instant. */
|
|
89
|
+
function offsetOf(at: Date, timeZone: string): number {
|
|
90
|
+
return wallClockOf(at, timeZone) - Math.floor(at.getTime() / 1000) * 1000
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* The instant a zone's wall clock reads `wallClock`.
|
|
95
|
+
*
|
|
96
|
+
* A wall clock the zone skips is met at the jump that skipped it, and one it reads twice starts the
|
|
97
|
+
* period at its first reading, so periods stay in order and whole.
|
|
98
|
+
*/
|
|
99
|
+
function instantOf(wallClock: number, timeZone: string): Date {
|
|
100
|
+
const before = offsetOf(new Date(wallClock - dayMs), timeZone)
|
|
101
|
+
const after = offsetOf(new Date(wallClock + dayMs), timeZone)
|
|
102
|
+
if (before === after) return new Date(wallClock - before)
|
|
103
|
+
const candidates = [wallClock - before, wallClock - after].sort((left, right) => left - right)
|
|
104
|
+
const found = candidates.find((instant) => wallClockOf(new Date(instant), timeZone) >= wallClock)
|
|
105
|
+
return new Date(found ?? candidates[candidates.length - 1]!)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* The zone's wall clock at an instant, spelled as `wallClockInstant` reads it back:
|
|
110
|
+
* `2026-11-14T05:00:00.000Z` in America/New_York is `2026-11-14T00:00:00.000Z`.
|
|
111
|
+
*/
|
|
112
|
+
export function wallClockAt(at: Date, timeZone = DEFAULT_PROJECT_TIME_ZONE): string {
|
|
113
|
+
return new Date(wallClockOf(at, timeZone)).toISOString()
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* The instant a zone's wall clock names.
|
|
118
|
+
*
|
|
119
|
+
* `wallClock` is an ISO 8601 string whose `Z` marks the wall clock rather than UTC, as a provider
|
|
120
|
+
* reads it out of a query without a time zone: `2026-11-14T00:00:00Z` is midnight in the zone.
|
|
121
|
+
*/
|
|
122
|
+
export function wallClockInstant(wallClock: string, timeZone = DEFAULT_PROJECT_TIME_ZONE): Date {
|
|
123
|
+
const wall = Date.parse(wallClock)
|
|
124
|
+
if (Number.isNaN(wall)) {
|
|
125
|
+
throw new TypeError(`[Sixb] ${JSON.stringify(wallClock)} is not a wall clock time.`)
|
|
126
|
+
}
|
|
127
|
+
return instantOf(wall, timeZone)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* The wall clock a period of the calendar is named by: its hour, its midnight, or its Monday's.
|
|
132
|
+
*
|
|
133
|
+
* It is the name even where the zone skips it, so a period that began at the jump still steps to
|
|
134
|
+
* the next midnight rather than to the next 1 am.
|
|
135
|
+
*/
|
|
136
|
+
function periodWallClock(wallClock: number, period: CalendarPeriod): number {
|
|
137
|
+
if (period === "hour") return wallClock - (wallClock % hourMs)
|
|
138
|
+
const midnight = wallClock - (wallClock % dayMs)
|
|
139
|
+
if (period === "day") return midnight
|
|
140
|
+
|
|
141
|
+
// Weeks begin on Monday, which is what a date truncated to its week gives everywhere else.
|
|
142
|
+
const mondayOffset = (new Date(midnight).getUTCDay() + 6) % 7
|
|
143
|
+
return midnight - mondayOffset * dayMs
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** The start of the period an instant falls in, on the zone's calendar. */
|
|
147
|
+
export function calendarPeriodStart(
|
|
148
|
+
at: Date,
|
|
149
|
+
period: CalendarPeriod,
|
|
150
|
+
timeZone = DEFAULT_PROJECT_TIME_ZONE
|
|
151
|
+
): Date {
|
|
152
|
+
return instantOf(periodWallClock(wallClockOf(at, timeZone), period), timeZone)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* The start of the period `count` periods away from the one `at` falls in.
|
|
157
|
+
*
|
|
158
|
+
* Stepping the zone's wall clock keeps every period whole across a change of clocks, where adding
|
|
159
|
+
* milliseconds would land an hour off a boundary.
|
|
160
|
+
*/
|
|
161
|
+
export function addCalendarPeriods(
|
|
162
|
+
at: Date,
|
|
163
|
+
period: CalendarPeriod,
|
|
164
|
+
count: number,
|
|
165
|
+
timeZone = DEFAULT_PROJECT_TIME_ZONE
|
|
166
|
+
): Date {
|
|
167
|
+
const step = period === "hour" ? hourMs : period === "week" ? 7 * dayMs : dayMs
|
|
168
|
+
const start = periodWallClock(wallClockOf(at, timeZone), period)
|
|
169
|
+
return instantOf(start + count * step, timeZone)
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Every period of [from, to), starting with the one `from` falls in.
|
|
174
|
+
*
|
|
175
|
+
* A wall clock the zone skips begins its period where the clocks jump, which keeps the periods
|
|
176
|
+
* contiguous through the hour the zone never had.
|
|
177
|
+
*/
|
|
178
|
+
export function calendarPeriods(
|
|
179
|
+
from: Date,
|
|
180
|
+
to: Date,
|
|
181
|
+
period: CalendarPeriod,
|
|
182
|
+
timeZone = DEFAULT_PROJECT_TIME_ZONE
|
|
183
|
+
): readonly CalendarPeriodRange[] {
|
|
184
|
+
const periods: CalendarPeriodRange[] = []
|
|
185
|
+
let start = calendarPeriodStart(from, period, timeZone)
|
|
186
|
+
while (start.getTime() < to.getTime()) {
|
|
187
|
+
if (periods.length >= MAX_PERIODS) {
|
|
188
|
+
throw new RangeError(`[Sixb] The range holds more than ${MAX_PERIODS} ${period} periods.`)
|
|
189
|
+
}
|
|
190
|
+
const end = addCalendarPeriods(start, period, 1, timeZone)
|
|
191
|
+
periods.push({ start, end })
|
|
192
|
+
start = end
|
|
193
|
+
}
|
|
194
|
+
return periods
|
|
195
|
+
}
|
|
@@ -1,8 +1,22 @@
|
|
|
1
|
+
import type { AuthorizablePrincipal } from "../../execution/types"
|
|
2
|
+
import type { SandboxOAuthConnector } from "../../sandboxes/auth"
|
|
3
|
+
import type { ConnectorConnectionSelector, ConnectorTokenSource } from "../types"
|
|
1
4
|
import type { ConnectorConnectionCallbackProcess } from "./contracts"
|
|
2
5
|
import type { ConnectorConnectionsRuntime } from "./execution"
|
|
3
6
|
|
|
7
|
+
export interface SandboxConnectionTokenAccessInput {
|
|
8
|
+
readonly connector: SandboxOAuthConnector
|
|
9
|
+
readonly selector: ConnectorConnectionSelector
|
|
10
|
+
readonly requestedBy?: AuthorizablePrincipal
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type SandboxConnectionTokenAccess = (
|
|
14
|
+
input: SandboxConnectionTokenAccessInput
|
|
15
|
+
) => ConnectorTokenSource
|
|
16
|
+
|
|
4
17
|
const connectorConnectionsRuntimeKey: unique symbol = Symbol("sixb.connectorConnectionsRuntime")
|
|
5
18
|
const connectorConnectionCallbackKey: unique symbol = Symbol("sixb.connectorConnectionCallback")
|
|
19
|
+
const sandboxConnectionTokenAccessKey: unique symbol = Symbol("sixb.sandboxConnectionTokenAccess")
|
|
6
20
|
|
|
7
21
|
interface ConnectorConnectionsRuntimeOwner {
|
|
8
22
|
readonly [connectorConnectionsRuntimeKey]?: ConnectorConnectionsRuntime
|
|
@@ -12,6 +26,10 @@ interface ConnectorConnectionCallbackOwner {
|
|
|
12
26
|
readonly [connectorConnectionCallbackKey]?: ConnectorConnectionCallbackProcess
|
|
13
27
|
}
|
|
14
28
|
|
|
29
|
+
interface SandboxConnectionTokenAccessOwner {
|
|
30
|
+
readonly [sandboxConnectionTokenAccessKey]?: SandboxConnectionTokenAccess
|
|
31
|
+
}
|
|
32
|
+
|
|
15
33
|
export function registerConnectorConnectionsRuntime(
|
|
16
34
|
owner: object,
|
|
17
35
|
runtime: ConnectorConnectionsRuntime
|
|
@@ -57,3 +75,25 @@ export function getConnectorConnectionCallbackProcess(
|
|
|
57
75
|
if (process) return process
|
|
58
76
|
throw new Error("[Sixb] Connector callback process is not registered for this host.")
|
|
59
77
|
}
|
|
78
|
+
|
|
79
|
+
export function registerSandboxConnectionTokenAccess(
|
|
80
|
+
owner: object,
|
|
81
|
+
access: SandboxConnectionTokenAccess
|
|
82
|
+
): void {
|
|
83
|
+
const registered = (owner as SandboxConnectionTokenAccessOwner)[sandboxConnectionTokenAccessKey]
|
|
84
|
+
if (registered && registered !== access) {
|
|
85
|
+
throw new Error("[Sixb] Sandbox connection token access is already registered for this host.")
|
|
86
|
+
}
|
|
87
|
+
Object.defineProperty(owner, sandboxConnectionTokenAccessKey, {
|
|
88
|
+
configurable: false,
|
|
89
|
+
enumerable: false,
|
|
90
|
+
value: access,
|
|
91
|
+
writable: false,
|
|
92
|
+
})
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function getSandboxConnectionTokenAccess(
|
|
96
|
+
owner: object
|
|
97
|
+
): SandboxConnectionTokenAccess | undefined {
|
|
98
|
+
return (owner as SandboxConnectionTokenAccessOwner)[sandboxConnectionTokenAccessKey]
|
|
99
|
+
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
export { isOAuthConnectorDefinition } from "../types"
|
|
2
|
+
export type { SandboxConnectionTokenAccess, SandboxConnectionTokenAccessInput } from "./capability"
|
|
2
3
|
export {
|
|
3
4
|
getConnectorConnectionCallbackProcess,
|
|
4
5
|
getConnectorConnectionsRuntime,
|
|
6
|
+
getSandboxConnectionTokenAccess,
|
|
7
|
+
registerSandboxConnectionTokenAccess,
|
|
5
8
|
} from "./capability"
|
|
6
9
|
export type {
|
|
7
10
|
AddConnectorConnectionInput,
|
|
@@ -23,6 +23,7 @@ import type {
|
|
|
23
23
|
ConnectorClient,
|
|
24
24
|
ConnectorConnectionSelector,
|
|
25
25
|
ConnectorDefinition,
|
|
26
|
+
ConnectorTokenSource,
|
|
26
27
|
OAuthConnectorAdapter,
|
|
27
28
|
} from "../types"
|
|
28
29
|
import {
|
|
@@ -172,6 +173,68 @@ export class ConnectorConnectionService implements ConnectorConnectionProcess {
|
|
|
172
173
|
definition: ConnectorDefinition<string, TAdapter>,
|
|
173
174
|
selector: ConnectorConnectionSelector
|
|
174
175
|
): Promise<ConnectorClient<TAdapter>> {
|
|
176
|
+
const readable = await this.requireReadableConnection(definition, selector)
|
|
177
|
+
return this.connectExecutionConnection(definition, readable)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Live token source for one connected account, re-checking connection status and member
|
|
182
|
+
* suspension on each read while keeping revision invalidation across calls.
|
|
183
|
+
*/
|
|
184
|
+
createConnectionTokenSource<TAdapter extends OAuthConnectorAdapter>(
|
|
185
|
+
definition: ConnectorDefinition<string, TAdapter>,
|
|
186
|
+
selector: ConnectorConnectionSelector
|
|
187
|
+
): ConnectorTokenSource {
|
|
188
|
+
this.assertOAuthRegistered(definition)
|
|
189
|
+
assertConnectorConnectionSelector(selector)
|
|
190
|
+
let current:
|
|
191
|
+
| {
|
|
192
|
+
readonly authorizationId: string
|
|
193
|
+
readonly accountId: string
|
|
194
|
+
readonly source: ConnectorTokenSource
|
|
195
|
+
}
|
|
196
|
+
| undefined
|
|
197
|
+
|
|
198
|
+
return Object.freeze({
|
|
199
|
+
get: async () => {
|
|
200
|
+
const readable = await this.requireReadableConnection(definition, selector)
|
|
201
|
+
if (
|
|
202
|
+
readable.projectId !== this.projectId ||
|
|
203
|
+
readable.connectorId !== definition.id ||
|
|
204
|
+
readable.status !== "connected"
|
|
205
|
+
) {
|
|
206
|
+
throw createConnectorCodedError(
|
|
207
|
+
"connector.not_found",
|
|
208
|
+
`Connector '${definition.id}' connection '${readable.id}' is not active in this project.`
|
|
209
|
+
)
|
|
210
|
+
}
|
|
211
|
+
const authorization = await this.authorizations.requireStableActiveAuthorization(
|
|
212
|
+
definition,
|
|
213
|
+
readable.authorizationId
|
|
214
|
+
)
|
|
215
|
+
if (
|
|
216
|
+
current?.authorizationId !== authorization.id ||
|
|
217
|
+
current.accountId !== readable.account.id
|
|
218
|
+
) {
|
|
219
|
+
current = {
|
|
220
|
+
authorizationId: authorization.id,
|
|
221
|
+
accountId: readable.account.id,
|
|
222
|
+
source: this.authorizations.createTokenSource(
|
|
223
|
+
definition,
|
|
224
|
+
authorization.id,
|
|
225
|
+
readable.account
|
|
226
|
+
),
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return current.source.get()
|
|
230
|
+
},
|
|
231
|
+
})
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
private async requireReadableConnection<TAdapter extends OAuthConnectorAdapter>(
|
|
235
|
+
definition: ConnectorDefinition<string, TAdapter>,
|
|
236
|
+
selector: ConnectorConnectionSelector
|
|
237
|
+
): Promise<ConnectorConnectionRecord> {
|
|
175
238
|
this.assertOAuthRegistered(definition)
|
|
176
239
|
assertConnectorConnectionSelector(selector)
|
|
177
240
|
const connection = await withConnectorStorageBoundary(
|
|
@@ -199,13 +262,21 @@ export class ConnectorConnectionService implements ConnectorConnectionProcess {
|
|
|
199
262
|
`Connector '${definition.id}' does not open the connections of a suspended member.`
|
|
200
263
|
)
|
|
201
264
|
}
|
|
202
|
-
|
|
203
|
-
return this.connectExecutionConnection(definition, readable)
|
|
265
|
+
return readable
|
|
204
266
|
}
|
|
205
267
|
|
|
206
268
|
/** Snapshot the connected records that one trusted primitive execution may consume. */
|
|
207
269
|
async listExecutionConnections<TAdapter extends OAuthConnectorAdapter>(
|
|
208
270
|
definition: ConnectorDefinition<string, TAdapter>
|
|
271
|
+
): Promise<readonly ConnectorConnectionRecord[]> {
|
|
272
|
+
const connections = await this.listAllConnections(definition)
|
|
273
|
+
const connected = connections.filter((connection) => connection.status === "connected")
|
|
274
|
+
return this.withoutSuspendedOwners(connected)
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/** Every connection of the connector, whatever its status: none is ever deleted. */
|
|
278
|
+
async listAllConnections<TAdapter extends OAuthConnectorAdapter>(
|
|
279
|
+
definition: ConnectorDefinition<string, TAdapter>
|
|
209
280
|
): Promise<readonly ConnectorConnectionRecord[]> {
|
|
210
281
|
this.assertOAuthRegistered(definition)
|
|
211
282
|
const connections = await withConnectorStorageBoundary(
|
|
@@ -216,9 +287,7 @@ export class ConnectorConnectionService implements ConnectorConnectionProcess {
|
|
|
216
287
|
connectorId: definition.id,
|
|
217
288
|
})
|
|
218
289
|
)
|
|
219
|
-
|
|
220
|
-
const readable = await this.withoutSuspendedOwners(connected)
|
|
221
|
-
return [...readable].sort((left, right) => left.id.localeCompare(right.id))
|
|
290
|
+
return [...connections].sort((left, right) => left.id.localeCompare(right.id))
|
|
222
291
|
}
|
|
223
292
|
|
|
224
293
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AuthorizationError, assertProviderAccess } from "../authorization"
|
|
2
|
-
import type { ExecutionContext } from "../execution"
|
|
2
|
+
import type { AuthorizablePrincipal, ExecutionContext } from "../execution"
|
|
3
3
|
import { resolveExecutionScopeAuthorization } from "../execution/authorization"
|
|
4
4
|
import type { SixbRuntimeContext } from "../runtime/types"
|
|
5
5
|
import { createConnectorConnections } from "./connection-handles"
|
|
@@ -65,7 +65,7 @@ export function createConnectorRuntime(
|
|
|
65
65
|
`[Sixb] Connector '${definition.id}' uses persistent connections and requires an explicit owner and slot.`
|
|
66
66
|
)
|
|
67
67
|
}
|
|
68
|
-
assertPersonalConnectionRequester(definition, execution, selector)
|
|
68
|
+
assertPersonalConnectionRequester(definition, execution.requestedBy, selector)
|
|
69
69
|
return service.connectConnection(definition, selector)
|
|
70
70
|
}
|
|
71
71
|
if (selector) {
|
|
@@ -178,13 +178,12 @@ export function getConnectorExecutionSourceResolver(
|
|
|
178
178
|
* person's account by calling an action, even with can.manage. A run no one requested, such as one
|
|
179
179
|
* an event or a schedule started, picks the owner from its data, as syncs and webhooks do.
|
|
180
180
|
*/
|
|
181
|
-
function assertPersonalConnectionRequester(
|
|
182
|
-
definition: ConnectorDefinition,
|
|
183
|
-
|
|
181
|
+
export function assertPersonalConnectionRequester(
|
|
182
|
+
definition: Pick<ConnectorDefinition, "id">,
|
|
183
|
+
requester: AuthorizablePrincipal | undefined,
|
|
184
184
|
selector: ConnectorConnectionSelector
|
|
185
185
|
): void {
|
|
186
186
|
const owner = selector.owner
|
|
187
|
-
const requester = execution.requestedBy
|
|
188
187
|
if (owner?.type !== "user" || requester === undefined) return
|
|
189
188
|
if (requester.type === "user" && requester.id === owner.id) return
|
|
190
189
|
throw new AuthorizationError(
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SandboxOAuthConnector } from "../sandboxes/auth"
|
|
1
2
|
import type { ConnectorConnectionRecord } from "../storage"
|
|
2
3
|
import type { ConnectorConnectionProcess } from "./connections/contracts"
|
|
3
4
|
import {
|
|
@@ -10,6 +11,7 @@ import type {
|
|
|
10
11
|
ConnectorClient,
|
|
11
12
|
ConnectorConnectionSelector,
|
|
12
13
|
ConnectorDefinition,
|
|
14
|
+
ConnectorTokenSource,
|
|
13
15
|
OAuthConnectorAdapter,
|
|
14
16
|
} from "./types"
|
|
15
17
|
import { isOAuthConnectorDefinition } from "./types"
|
|
@@ -77,12 +79,33 @@ export class ConnectorService {
|
|
|
77
79
|
return this.requireConnections().connectConnection(definition, selector)
|
|
78
80
|
}
|
|
79
81
|
|
|
82
|
+
createConnectionTokenSource(
|
|
83
|
+
connector: SandboxOAuthConnector,
|
|
84
|
+
selector: ConnectorConnectionSelector
|
|
85
|
+
): ConnectorTokenSource {
|
|
86
|
+
const definition = connector as unknown as ConnectorDefinition
|
|
87
|
+
if (!isOAuthConnectorDefinition(definition)) {
|
|
88
|
+
throw createConnectorCodedError(
|
|
89
|
+
"connector.configuration_invalid",
|
|
90
|
+
`[Sixb] Connector '${connector.id}' does not use persistent OAuth connections.`
|
|
91
|
+
)
|
|
92
|
+
}
|
|
93
|
+
return this.requireConnections().createConnectionTokenSource(definition, selector)
|
|
94
|
+
}
|
|
95
|
+
|
|
80
96
|
listExecutionConnections<TAdapter extends OAuthConnectorAdapter>(
|
|
81
97
|
definition: ConnectorDefinition<string, TAdapter>
|
|
82
98
|
): Promise<readonly ConnectorConnectionRecord[]> {
|
|
83
99
|
return this.requireConnections().listExecutionConnections(definition)
|
|
84
100
|
}
|
|
85
101
|
|
|
102
|
+
/** Every connection of the connector, whatever its status: none is ever deleted. */
|
|
103
|
+
listAllConnections<TAdapter extends OAuthConnectorAdapter>(
|
|
104
|
+
definition: ConnectorDefinition<string, TAdapter>
|
|
105
|
+
): Promise<readonly ConnectorConnectionRecord[]> {
|
|
106
|
+
return this.requireConnections().listAllConnections(definition)
|
|
107
|
+
}
|
|
108
|
+
|
|
86
109
|
/** Revokes every connection one person owns. Nothing to do without OAuth connectors. */
|
|
87
110
|
async revokeUserConnections(userId: string): Promise<void> {
|
|
88
111
|
await this.connections?.revokeUserConnections(userId)
|
package/src/deploy/index.ts
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
export { defineDeploy } from "./define"
|
|
2
2
|
export type {
|
|
3
|
-
DeployAccess,
|
|
4
|
-
DeployAccessKey,
|
|
5
3
|
DeployCheck,
|
|
6
4
|
DeployCheckContext,
|
|
7
|
-
DeployCi,
|
|
8
|
-
DeployCiCredential,
|
|
9
5
|
DeployCommand,
|
|
10
6
|
DeployConfig,
|
|
11
7
|
DeployContext,
|
|
@@ -29,7 +25,6 @@ export type {
|
|
|
29
25
|
DeployScript,
|
|
30
26
|
DeployServiceName,
|
|
31
27
|
DeployServicesConfig,
|
|
32
|
-
DeploySetupContext,
|
|
33
28
|
DeploySingletonServiceConfig,
|
|
34
29
|
DeploySingletonServiceName,
|
|
35
30
|
DeploySource,
|
package/src/deploy/types.ts
CHANGED
|
@@ -134,89 +134,34 @@ export interface DeployTarget {
|
|
|
134
134
|
): Promise<void>
|
|
135
135
|
/** What stands between the target and a working deploy of the release, changing nothing. */
|
|
136
136
|
check(release: DeployRelease, context: DeployCheckContext): Promise<readonly DeployCheck[]>
|
|
137
|
-
/** Prepares the target for the release, fixing what `check` reports as fixable. */
|
|
138
|
-
setup?(release: DeployRelease, context: DeploySetupContext): Promise<void>
|
|
139
137
|
/**
|
|
140
138
|
* Runs a script against the deployed project, as `sixb run` would there, with the environment the
|
|
141
139
|
* deployment's services start from and the script's output on this terminal. Resolves with its
|
|
142
140
|
* exit code; rejects only when the target cannot run it.
|
|
143
141
|
*/
|
|
144
142
|
run?(script: DeployScript, context: DeployOperationContext): Promise<number>
|
|
145
|
-
/** Who may deploy and operate the deployment, for a target reached with keys. */
|
|
146
|
-
readonly access?: DeployAccess
|
|
147
|
-
/** Credentials for a CI job that deploys, for a target reached with keys. */
|
|
148
|
-
readonly ci?: DeployCi
|
|
149
143
|
}
|
|
150
144
|
|
|
151
145
|
export interface DeployCheck {
|
|
152
146
|
readonly id: string
|
|
153
147
|
/** What was checked, such as `"SSH"` or `"api DNS"`. */
|
|
154
148
|
readonly label: string
|
|
155
|
-
/**
|
|
156
|
-
|
|
157
|
-
* a deploy; a `warning` does not.
|
|
158
|
-
*/
|
|
159
|
-
readonly status: "ok" | "fixable" | "manual" | "warning"
|
|
149
|
+
/** `fail` stops a deploy until `remedy` is done; a `warning` does not. */
|
|
150
|
+
readonly status: "ok" | "fail" | "warning"
|
|
160
151
|
readonly detail: string
|
|
161
152
|
/** What to do about it, when the status is not `ok`. */
|
|
162
153
|
readonly remedy?: string
|
|
154
|
+
/** Shell commands that fix it, for someone with administrator rights on the target to run once. */
|
|
155
|
+
readonly commands?: readonly string[]
|
|
163
156
|
}
|
|
164
157
|
|
|
165
158
|
export interface DeployCheckContext extends DeployOperationContext {
|
|
166
159
|
/** The project's directory inside its repository: `.` at the root. */
|
|
167
160
|
readonly projectPath: string
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
readonly admin?: string
|
|
173
|
-
/** A public key file to authorize for deploys, instead of the one the target would pick. */
|
|
174
|
-
readonly key?: string
|
|
175
|
-
/** Creates the token `steps.env` reads with, for a target that doesn't have one yet. */
|
|
176
|
-
readonly createEnvToken?: () => Promise<string>
|
|
177
|
-
/** A line of progress for the person running setup. */
|
|
178
|
-
write(line: string): void
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
export interface DeployAccess {
|
|
182
|
-
list(context: DeployOperationContext): Promise<readonly DeployAccessKey[]>
|
|
183
|
-
/** Authorizes a public key, given as its text (`ssh-ed25519 AAAA… comment`). */
|
|
184
|
-
add(key: string, context: DeployOperationContext): Promise<DeployAccessKey>
|
|
185
|
-
/** Revokes the keys whose fingerprint or comment matches, and returns them. */
|
|
186
|
-
remove(match: string, context: DeployOperationContext): Promise<readonly DeployAccessKey[]>
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
export interface DeployAccessKey {
|
|
190
|
-
readonly type: string
|
|
191
|
-
readonly fingerprint: string
|
|
192
|
-
readonly comment: string
|
|
193
|
-
/** Whether the key is limited to running commands: no forwarding, no terminal. */
|
|
194
|
-
readonly restricted: boolean
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Lets a CI job deploy. `sixb deploy ci` stores what `create` returns as the CI system's secrets and
|
|
199
|
-
* writes the workflow around it.
|
|
200
|
-
*/
|
|
201
|
-
export interface DeployCi {
|
|
202
|
-
/**
|
|
203
|
-
* Creates a credential for one CI job, such as `"github:acme/shop"`, and authorizes it on the
|
|
204
|
-
* target next to the job's earlier ones. Running it again for the same job rotates the credential.
|
|
205
|
-
*/
|
|
206
|
-
create(job: string, context: DeployOperationContext): Promise<DeployCiCredential>
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
export interface DeployCiCredential {
|
|
210
|
-
/** Describes the credential, such as its key's fingerprint. */
|
|
211
|
-
readonly description: string
|
|
212
|
-
/** What the CI job needs, by environment variable name. CI stores them as secrets. */
|
|
213
|
-
readonly secrets: Readonly<Record<string, string>>
|
|
214
|
-
/** Shell lines that install the credential on the CI runner, with `secrets` in the environment. */
|
|
215
|
-
readonly install: readonly string[]
|
|
216
|
-
/** Revokes the job's earlier credentials once CI holds this one, and returns them. */
|
|
217
|
-
retireOthers(): Promise<readonly DeployAccessKey[]>
|
|
218
|
-
/** Revokes this credential, when CI could not store it. */
|
|
219
|
-
revoke(): Promise<void>
|
|
161
|
+
/** The project prints with Chromium through Playwright, so the target needs its libraries. */
|
|
162
|
+
readonly chromium: boolean
|
|
163
|
+
/** The project's env source reads on the server with a token file, not an identity of its own. */
|
|
164
|
+
readonly envToken: boolean
|
|
220
165
|
}
|
|
221
166
|
|
|
222
167
|
export interface DeployListenAddress {
|
|
@@ -244,7 +189,10 @@ export interface DeployRelease {
|
|
|
244
189
|
readonly env?: DeployCommand
|
|
245
190
|
/** Runs while the previous release still serves. */
|
|
246
191
|
readonly build: readonly DeployCommand[]
|
|
247
|
-
/**
|
|
192
|
+
/**
|
|
193
|
+
* Runs before the new release starts. The SSH target keeps the previous release serving
|
|
194
|
+
* meanwhile, unless storage migrations are pending: then the services stop first.
|
|
195
|
+
*/
|
|
248
196
|
readonly beforeStart: readonly DeployCommand[]
|
|
249
197
|
}
|
|
250
198
|
readonly services: readonly DeployReleaseService[]
|
package/src/deploy/validation.ts
CHANGED
|
@@ -68,7 +68,7 @@ function services(value: unknown): void {
|
|
|
68
68
|
|
|
69
69
|
if (isDeployHttpService(service)) {
|
|
70
70
|
knownKeys(options, ["domain", "env", "process"], path, {
|
|
71
|
-
port: "
|
|
71
|
+
port: "The target picks the ports; remove the setting.",
|
|
72
72
|
})
|
|
73
73
|
if (options.domain !== undefined) domain(options.domain, `${path}.domain`)
|
|
74
74
|
if (options.process !== undefined) {
|
package/src/env/index.ts
CHANGED
|
@@ -14,15 +14,21 @@ export type EnvVarRule = "required" | "prod" | "optional"
|
|
|
14
14
|
export interface EnvSource {
|
|
15
15
|
/** The names `env` has values for, without reading the values. */
|
|
16
16
|
names(env: EnvName): Promise<readonly string[]>
|
|
17
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* Every value `env` has. `server` reads as a server does, never signing a person in, with
|
|
19
|
+
* `token`, the credential from its token file, when the source needs one.
|
|
20
|
+
*/
|
|
18
21
|
read(
|
|
19
22
|
env: EnvName,
|
|
20
|
-
options?: { readonly token?: string }
|
|
23
|
+
options?: { readonly server?: boolean; readonly token?: string }
|
|
21
24
|
): Promise<Readonly<Record<string, string>>>
|
|
22
25
|
/** Creates or updates these values, and leaves the rest alone. */
|
|
23
26
|
write(env: EnvName, values: Readonly<Record<string, string>>): Promise<void>
|
|
24
|
-
/**
|
|
25
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Whether a server reads with a credential in its token file. False for a source that reads
|
|
29
|
+
* with the server's own identity, such as an Azure managed identity. Defaults to true.
|
|
30
|
+
*/
|
|
31
|
+
readonly serverNeedsToken?: boolean
|
|
26
32
|
}
|
|
27
33
|
|
|
28
34
|
/** The source could not answer: an outage, not a refusal. A retry may succeed unchanged. */
|