@sixb/core 0.2.0 → 0.2.2
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 +30 -30
- package/dist/agents/cancel.d.ts.map +1 -1
- package/dist/agents/index.d.ts +5 -3
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +39 -33
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/run-plan.d.ts +15 -1
- package/dist/agents/run-plan.d.ts.map +1 -1
- package/dist/agents/run-session-http.d.ts.map +1 -1
- package/dist/agents/run-session-serve.d.ts.map +1 -1
- package/dist/agents/run-session.d.ts +14 -2
- package/dist/agents/run-session.d.ts.map +1 -1
- package/dist/agents/skills.d.ts +3 -0
- package/dist/agents/skills.d.ts.map +1 -1
- package/dist/agents/step-limits.d.ts +6 -0
- package/dist/agents/step-limits.d.ts.map +1 -1
- package/dist/agents/streams/index.js +1 -1
- package/dist/agents/streams/internal.js +1 -1
- package/dist/agents/streams/protocol.d.ts +8 -2
- package/dist/agents/streams/protocol.d.ts.map +1 -1
- package/dist/agents/tool-files.d.ts +3 -1
- package/dist/agents/tool-files.d.ts.map +1 -1
- package/dist/agents/validation.d.ts +1 -1
- package/dist/agents/validation.d.ts.map +1 -1
- package/dist/agents/web.d.ts +47 -0
- package/dist/agents/web.d.ts.map +1 -0
- package/dist/artifacts/publish/index.js +17 -17
- package/dist/auth/index.js +3 -3
- package/dist/authorization/index.js +2 -2
- package/dist/authorization/resolve.d.ts +4 -3
- package/dist/authorization/resolve.d.ts.map +1 -1
- package/dist/authorization/types.d.ts +5 -5
- package/dist/authorization/types.d.ts.map +1 -1
- package/dist/bootstrap/index.js +38 -38
- package/dist/{chunk-neftrg0n.js → chunk-0j3crh1w.js} +2 -2
- package/dist/{chunk-8dcfj58k.js → chunk-2ajw5rz0.js} +14 -10
- package/dist/chunk-2ajw5rz0.js.map +18 -0
- package/dist/{chunk-23s66j86.js → chunk-31kcqmhf.js} +1 -1
- package/dist/{chunk-nghc7eq0.js → chunk-3723kgba.js} +1 -1
- package/dist/{chunk-fdkpkkpw.js → chunk-3sqqhpr7.js} +5 -5
- package/dist/{chunk-m3qe54bb.js → chunk-4bm0caep.js} +1 -1
- package/dist/{chunk-ztf5vtmp.js → chunk-4s753g3k.js} +41 -10
- package/dist/chunk-4s753g3k.js.map +12 -0
- package/dist/{chunk-fntqb7qy.js → chunk-57g0215c.js} +1 -1
- package/dist/{chunk-8wsjr52f.js → chunk-5wtnmpze.js} +1 -1
- package/dist/{chunk-edx8xcsm.js → chunk-7z5rkf0m.js} +29 -6
- package/dist/chunk-7z5rkf0m.js.map +13 -0
- package/dist/{chunk-2pk5hjj9.js → chunk-80gym75n.js} +1 -1
- package/dist/{chunk-qbrmpgvv.js → chunk-9whfmsfk.js} +1 -1
- package/dist/{chunk-qya541bk.js → chunk-a5v4gjdx.js} +31 -28
- package/dist/{chunk-qya541bk.js.map → chunk-a5v4gjdx.js.map} +4 -4
- package/dist/{chunk-he7g39e5.js → chunk-a7aa0nzj.js} +7 -7
- package/dist/{chunk-tvefbgvw.js → chunk-az95tsh3.js} +4 -2
- package/dist/chunk-az95tsh3.js.map +11 -0
- package/dist/{chunk-7hd2ez3q.js → chunk-c4nrycdy.js} +1 -1
- package/dist/{chunk-ekkpzcka.js → chunk-c706qvyc.js} +36 -9
- package/dist/chunk-c706qvyc.js.map +11 -0
- package/dist/{chunk-n54k068r.js → chunk-c7cfe31p.js} +7 -7
- package/dist/{chunk-qsg8rw04.js → chunk-d04g36fw.js} +1 -1
- package/dist/{chunk-hjy3dsws.js → chunk-dsv783c3.js} +305 -32
- package/dist/{chunk-hjy3dsws.js.map → chunk-dsv783c3.js.map} +12 -10
- package/dist/{chunk-peggaard.js → chunk-e6xgz4h4.js} +20 -2
- package/dist/{chunk-peggaard.js.map → chunk-e6xgz4h4.js.map} +5 -3
- package/dist/{chunk-e99kp9jh.js → chunk-eqgr6nsa.js} +86 -30
- package/dist/{chunk-e99kp9jh.js.map → chunk-eqgr6nsa.js.map} +10 -9
- package/dist/{chunk-f2w6328x.js → chunk-f1h34y3r.js} +6 -6
- package/dist/{chunk-9rh8ncs5.js → chunk-fwsvshr5.js} +1 -1
- package/dist/{chunk-c78jjzhy.js → chunk-ga63a3dz.js} +6 -6
- package/dist/{chunk-c78jjzhy.js.map → chunk-ga63a3dz.js.map} +2 -2
- package/dist/{chunk-cgznz22f.js → chunk-gkv8r794.js} +2 -2
- package/dist/{chunk-d3t26vah.js → chunk-j1ny5fwh.js} +35 -11
- package/dist/chunk-j1ny5fwh.js.map +15 -0
- package/dist/{chunk-8hvfs0fr.js → chunk-j8thxj7w.js} +4 -4
- package/dist/{chunk-855n80en.js → chunk-jjmggm9a.js} +1 -1
- package/dist/{chunk-31khg3g0.js → chunk-kkjfve0t.js} +73 -2
- package/dist/{chunk-31khg3g0.js.map → chunk-kkjfve0t.js.map} +3 -3
- package/dist/{chunk-fb3m4sa1.js → chunk-m2vh8gh0.js} +8 -14
- package/dist/{chunk-fb3m4sa1.js.map → chunk-m2vh8gh0.js.map} +3 -3
- package/dist/{chunk-vkweppkw.js → chunk-mbc5hvnj.js} +3 -3
- package/dist/{chunk-jk97v21j.js → chunk-n4zzaf6q.js} +3 -2
- package/dist/chunk-n4zzaf6q.js.map +10 -0
- package/dist/{chunk-y2x2935j.js → chunk-nh26e7c5.js} +2 -2
- package/dist/{chunk-jhbk10wf.js → chunk-q9nkpr8k.js} +1 -1
- package/dist/{chunk-47e09r7z.js → chunk-qttqe1ah.js} +86 -6
- package/dist/{chunk-47e09r7z.js.map → chunk-qttqe1ah.js.map} +5 -4
- package/dist/{chunk-9mab3dvg.js → chunk-s038wa5v.js} +9 -1
- package/dist/{chunk-9mab3dvg.js.map → chunk-s038wa5v.js.map} +3 -3
- package/dist/{chunk-3x3bebz7.js → chunk-s7j8ewqv.js} +161 -62
- package/dist/{chunk-3x3bebz7.js.map → chunk-s7j8ewqv.js.map} +7 -6
- package/dist/{chunk-dz7a4t3a.js → chunk-twfreyxr.js} +5 -10
- package/dist/{chunk-dz7a4t3a.js.map → chunk-twfreyxr.js.map} +4 -4
- package/dist/{chunk-semf1yqn.js → chunk-w1btn96n.js} +51 -26
- package/dist/{chunk-semf1yqn.js.map → chunk-w1btn96n.js.map} +6 -6
- package/dist/{chunk-fg1db9xx.js → chunk-wkq3kvzd.js} +5 -5
- package/dist/chunk-wkq3kvzd.js.map +10 -0
- package/dist/{chunk-xj97s5js.js → chunk-wrjx1fqz.js} +6 -6
- package/dist/{chunk-agn8d8ys.js → chunk-xtztwpkh.js} +1 -1
- package/dist/{chunk-0g5nyx0k.js → chunk-zeykm8my.js} +2 -2
- package/dist/connectors/connections/runs.d.ts +7 -0
- package/dist/connectors/connections/runs.d.ts.map +1 -1
- package/dist/datasets/execution.d.ts.map +1 -1
- package/dist/events/index.js +1 -1
- package/dist/events/selectors/index.js +1 -1
- package/dist/events/selectors/predicate.d.ts.map +1 -1
- package/dist/events/types/datasets.d.ts +6 -0
- package/dist/events/types/datasets.d.ts.map +1 -1
- package/dist/execution/agent.js +30 -30
- package/dist/execution/object-reader-security.d.ts.map +1 -1
- package/dist/execution/primitive.js +30 -30
- package/dist/execution/request.js +31 -31
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +42 -42
- package/dist/lake-storage/in-memory.d.ts.map +1 -1
- package/dist/lake-storage/index.d.ts +2 -2
- package/dist/lake-storage/index.d.ts.map +1 -1
- package/dist/lake-storage/index.js +6 -2
- package/dist/lake-storage/index.js.map +1 -1
- package/dist/lake-storage/source-ordering.d.ts +7 -0
- package/dist/lake-storage/source-ordering.d.ts.map +1 -1
- package/dist/lake-storage/types.d.ts +18 -0
- package/dist/lake-storage/types.d.ts.map +1 -1
- package/dist/lake-storage/version-inputs.d.ts +11 -3
- package/dist/lake-storage/version-inputs.d.ts.map +1 -1
- package/dist/materializer/index.js +16 -16
- package/dist/models/catalog.d.ts +16 -0
- package/dist/models/catalog.d.ts.map +1 -1
- package/dist/models/definitions.d.ts +1 -1
- package/dist/models/definitions.d.ts.map +1 -1
- package/dist/models/execution/index.js +18 -18
- package/dist/models/execution/model-call-recorder.d.ts +1 -1
- package/dist/models/execution/model-call-recorder.d.ts.map +1 -1
- package/dist/models/execution/web-search.d.ts +7 -0
- package/dist/models/execution/web-search.d.ts.map +1 -0
- package/dist/models/index.d.ts +3 -1
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/index.js +5 -3
- package/dist/models/index.js.map +1 -1
- package/dist/models/language-model.d.ts +12 -0
- package/dist/models/language-model.d.ts.map +1 -1
- package/dist/models/web-search-model.d.ts +66 -0
- package/dist/models/web-search-model.d.ts.map +1 -0
- package/dist/objects/index.js +30 -30
- package/dist/objects/query/executor.d.ts.map +1 -1
- package/dist/objects/query/index.d.ts +1 -0
- package/dist/objects/query/index.d.ts.map +1 -1
- package/dist/objects/query/index.js +19 -16
- package/dist/objects/query/index.js.map +1 -1
- package/dist/objects/query/sort-ties.d.ts +11 -0
- package/dist/objects/query/sort-ties.d.ts.map +1 -0
- package/dist/pipelines/index.js +19 -19
- package/dist/pipelines/run-dispatch.d.ts +2 -0
- package/dist/pipelines/run-dispatch.d.ts.map +1 -1
- package/dist/projections/internal.js +16 -16
- package/dist/runtime/create.d.ts +1 -1
- package/dist/runtime/create.d.ts.map +1 -1
- package/dist/runtime/internal.js +22 -22
- package/dist/runtime/resolve-definitions.d.ts.map +1 -1
- package/dist/schedules/index.js +2 -2
- package/dist/security/index.d.ts +1 -0
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/registry.d.ts +2 -0
- package/dist/security/registry.d.ts.map +1 -1
- package/dist/security/view-conditions.d.ts.map +1 -1
- package/dist/security/visibility-keys.d.ts +19 -0
- package/dist/security/visibility-keys.d.ts.map +1 -0
- package/dist/shares/internal.js +16 -16
- package/dist/storage/agents/in-memory.d.ts +8 -2
- 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 +8 -2
- package/dist/storage/agents/provider.d.ts.map +1 -1
- package/dist/storage/agents/provider.js +12 -6
- package/dist/storage/agents/provider.js.map +1 -1
- package/dist/storage/agents/types.d.ts +42 -2
- package/dist/storage/agents/types.d.ts.map +1 -1
- package/dist/storage/ai-cost/provider.js +4 -4
- package/dist/storage/ai-limits/enforcement.js +3 -3
- package/dist/storage/ai-limits/provider.js +2 -2
- package/dist/storage/connector-connections/provider.js +3 -3
- package/dist/storage/connector-connections/provider.js.map +3 -3
- package/dist/storage/file-upload-sessions/provider.js +4 -4
- package/dist/storage/index.d.ts +2 -2
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +15 -15
- package/dist/storage/internal.d.ts +2 -0
- package/dist/storage/internal.d.ts.map +1 -1
- package/dist/storage/internal.js +8 -4
- package/dist/storage/internal.js.map +1 -1
- package/dist/storage/migrations/types.d.ts +6 -0
- package/dist/storage/migrations/types.d.ts.map +1 -1
- package/dist/storage/objects/in-memory/query.d.ts.map +1 -1
- package/dist/storage/objects/index.d.ts +1 -1
- package/dist/storage/objects/index.d.ts.map +1 -1
- package/dist/storage/objects/query-preparation.d.ts +13 -0
- package/dist/storage/objects/query-preparation.d.ts.map +1 -1
- package/dist/storage/objects/read-scope.d.ts.map +1 -1
- package/dist/storage/objects/types.d.ts +52 -0
- package/dist/storage/objects/types.d.ts.map +1 -1
- package/dist/storage/pipeline-runs/in-memory.d.ts.map +1 -1
- package/dist/storage/pipeline-runs/transitions.d.ts +7 -0
- package/dist/storage/pipeline-runs/transitions.d.ts.map +1 -0
- package/dist/storage/share-grants/provider.js +2 -2
- package/dist/storage/sync-runs/in-memory.d.ts.map +1 -1
- package/dist/storage/sync-runs/transitions.d.ts +7 -0
- package/dist/storage/sync-runs/transitions.d.ts.map +1 -0
- package/dist/storage/workflow-runs/provider.js +4 -4
- package/dist/syncs/index.js +20 -20
- package/dist/syncs/run-dispatch.d.ts +2 -0
- package/dist/syncs/run-dispatch.d.ts.map +1 -1
- package/dist/testing/agent-storage-contract.d.ts.map +1 -1
- package/dist/testing/ai-limit-storage-contract.d.ts.map +1 -1
- package/dist/testing/ai-usage-storage-contract.d.ts.map +1 -1
- package/dist/testing/connector-connection-storage-contract.d.ts.map +1 -1
- package/dist/testing/dataset-sequence-contract.d.ts.map +1 -1
- package/dist/testing/index.js +552 -61
- package/dist/testing/index.js.map +11 -11
- package/dist/testing/lake-changes-contract.d.ts.map +1 -1
- package/dist/testing/lake-storage-contract.d.ts.map +1 -1
- package/dist/testing/object-conditional-read-scope-contract.d.ts.map +1 -1
- package/dist/testing/object-query-contract.d.ts.map +1 -1
- package/dist/webhooks/internal.js +16 -16
- package/dist/workers/index.d.ts +1 -0
- package/dist/workers/index.d.ts.map +1 -1
- package/dist/workers/index.js +12 -2
- package/dist/workers/index.js.map +5 -4
- package/dist/workers/unstarted-run.d.ts +10 -0
- package/dist/workers/unstarted-run.d.ts.map +1 -0
- package/dist/workflows/index.js +34 -34
- package/package.json +1 -1
- package/src/agents/README.md +2 -1
- package/src/agents/cancel.ts +7 -1
- package/src/agents/index.ts +9 -1
- package/src/agents/run-plan.ts +31 -0
- package/src/agents/run-session-http.ts +15 -12
- package/src/agents/run-session-serve.ts +8 -2
- package/src/agents/run-session.ts +31 -11
- package/src/agents/skills.ts +3 -0
- package/src/agents/step-limits.ts +6 -0
- package/src/agents/streams/protocol.ts +9 -4
- package/src/agents/tool-files.ts +11 -3
- package/src/agents/validation.ts +9 -0
- package/src/agents/web.ts +218 -0
- package/src/authorization/resolve.ts +9 -11
- package/src/authorization/types.ts +5 -5
- package/src/connectors/connections/runs.ts +42 -5
- package/src/datasets/execution.ts +2 -0
- package/src/events/selectors/predicate.ts +15 -0
- package/src/events/types/datasets.ts +6 -0
- package/src/execution/object-reader-security.ts +4 -9
- package/src/index.ts +2 -0
- package/src/lake-storage/in-memory.ts +30 -20
- package/src/lake-storage/index.ts +2 -1
- package/src/lake-storage/source-ordering.ts +31 -4
- package/src/lake-storage/types.ts +18 -0
- package/src/lake-storage/version-inputs.ts +21 -5
- package/src/models/catalog.ts +52 -3
- package/src/models/definitions.ts +2 -0
- package/src/models/execution/README.md +22 -2
- package/src/models/execution/model-call-recorder.ts +1 -1
- package/src/models/execution/web-search.ts +186 -0
- package/src/models/index.ts +12 -0
- package/src/models/language-model.ts +12 -0
- package/src/models/web-search-model.ts +152 -0
- package/src/objects/query/executor.ts +7 -3
- package/src/objects/query/index.ts +1 -0
- package/src/objects/query/sort-ties.ts +16 -0
- package/src/pipelines/run-dispatch.ts +53 -6
- package/src/runtime/create.ts +3 -2
- package/src/runtime/resolve-definitions.ts +4 -0
- package/src/security/index.ts +1 -0
- package/src/security/registry.ts +2 -0
- package/src/security/view-conditions.ts +4 -3
- package/src/security/visibility-keys.ts +144 -0
- package/src/storage/agents/in-memory.ts +29 -2
- package/src/storage/agents/index.ts +2 -0
- package/src/storage/agents/provider.ts +57 -1
- package/src/storage/agents/types.ts +45 -2
- package/src/storage/connector-connections/in-memory.ts +2 -2
- package/src/storage/connector-connections/provider/connections.ts +2 -2
- package/src/storage/index.ts +4 -0
- package/src/storage/internal.ts +2 -0
- package/src/storage/migrations/types.ts +6 -0
- package/src/storage/objects/in-memory/query.ts +5 -2
- package/src/storage/objects/index.ts +2 -0
- package/src/storage/objects/query-preparation.ts +59 -1
- package/src/storage/objects/read-scope.ts +108 -2
- package/src/storage/objects/types.ts +43 -0
- package/src/storage/pipeline-runs/in-memory.ts +2 -5
- package/src/storage/pipeline-runs/transitions.ts +14 -0
- package/src/storage/sync-runs/in-memory.ts +2 -5
- package/src/storage/sync-runs/transitions.ts +11 -0
- package/src/syncs/run-dispatch.ts +68 -13
- package/src/testing/agent-storage-contract.ts +70 -0
- package/src/testing/ai-limit-storage-contract.ts +11 -1
- package/src/testing/ai-usage-storage-contract.ts +15 -2
- package/src/testing/connector-connection-storage-contract.ts +23 -0
- package/src/testing/dataset-sequence-contract.ts +81 -0
- package/src/testing/lake-changes-contract.ts +2 -1
- package/src/testing/lake-storage-contract.ts +112 -0
- package/src/testing/object-conditional-read-scope-contract.ts +267 -5
- package/src/testing/object-query-contract.ts +75 -0
- package/src/workers/index.ts +1 -0
- package/src/workers/unstarted-run.ts +18 -0
- package/dist/chunk-8dcfj58k.js.map +0 -18
- package/dist/chunk-d3t26vah.js.map +0 -15
- package/dist/chunk-edx8xcsm.js.map +0 -13
- package/dist/chunk-ekkpzcka.js.map +0 -11
- package/dist/chunk-fg1db9xx.js.map +0 -10
- package/dist/chunk-jk97v21j.js.map +0 -10
- package/dist/chunk-tvefbgvw.js.map +0 -11
- package/dist/chunk-ztf5vtmp.js.map +0 -12
- /package/dist/{chunk-neftrg0n.js.map → chunk-0j3crh1w.js.map} +0 -0
- /package/dist/{chunk-23s66j86.js.map → chunk-31kcqmhf.js.map} +0 -0
- /package/dist/{chunk-nghc7eq0.js.map → chunk-3723kgba.js.map} +0 -0
- /package/dist/{chunk-fdkpkkpw.js.map → chunk-3sqqhpr7.js.map} +0 -0
- /package/dist/{chunk-m3qe54bb.js.map → chunk-4bm0caep.js.map} +0 -0
- /package/dist/{chunk-fntqb7qy.js.map → chunk-57g0215c.js.map} +0 -0
- /package/dist/{chunk-8wsjr52f.js.map → chunk-5wtnmpze.js.map} +0 -0
- /package/dist/{chunk-2pk5hjj9.js.map → chunk-80gym75n.js.map} +0 -0
- /package/dist/{chunk-qbrmpgvv.js.map → chunk-9whfmsfk.js.map} +0 -0
- /package/dist/{chunk-he7g39e5.js.map → chunk-a7aa0nzj.js.map} +0 -0
- /package/dist/{chunk-7hd2ez3q.js.map → chunk-c4nrycdy.js.map} +0 -0
- /package/dist/{chunk-n54k068r.js.map → chunk-c7cfe31p.js.map} +0 -0
- /package/dist/{chunk-qsg8rw04.js.map → chunk-d04g36fw.js.map} +0 -0
- /package/dist/{chunk-f2w6328x.js.map → chunk-f1h34y3r.js.map} +0 -0
- /package/dist/{chunk-9rh8ncs5.js.map → chunk-fwsvshr5.js.map} +0 -0
- /package/dist/{chunk-cgznz22f.js.map → chunk-gkv8r794.js.map} +0 -0
- /package/dist/{chunk-8hvfs0fr.js.map → chunk-j8thxj7w.js.map} +0 -0
- /package/dist/{chunk-855n80en.js.map → chunk-jjmggm9a.js.map} +0 -0
- /package/dist/{chunk-vkweppkw.js.map → chunk-mbc5hvnj.js.map} +0 -0
- /package/dist/{chunk-y2x2935j.js.map → chunk-nh26e7c5.js.map} +0 -0
- /package/dist/{chunk-jhbk10wf.js.map → chunk-q9nkpr8k.js.map} +0 -0
- /package/dist/{chunk-xj97s5js.js.map → chunk-wrjx1fqz.js.map} +0 -0
- /package/dist/{chunk-agn8d8ys.js.map → chunk-xtztwpkh.js.map} +0 -0
- /package/dist/{chunk-0g5nyx0k.js.map → chunk-zeykm8my.js.map} +0 -0
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { bindCurrentUserPredicate } from "../objects/query/current-user"
|
|
2
1
|
import { ObjectQueryValidationError } from "../objects/query/errors"
|
|
3
2
|
import type { ObjectQueryPredicate } from "../objects/query/ir"
|
|
4
3
|
import {
|
|
@@ -10,6 +9,7 @@ import { compileConditionalObjectReadScope } from "../storage/objects/read-scope
|
|
|
10
9
|
import type { ObjectReadScopeFactory } from "../storage/objects/types"
|
|
11
10
|
import { SecurityValidationError } from "./errors"
|
|
12
11
|
import type { GrantDefinition, Selection } from "./types"
|
|
12
|
+
import { viewConditionReadCondition } from "./visibility-keys"
|
|
13
13
|
|
|
14
14
|
/** A role's `can.view(Type).where(...)`, validated against the ontology at startup. */
|
|
15
15
|
export interface ViewCondition {
|
|
@@ -103,7 +103,6 @@ export function assertViewConditionsReadable(input: {
|
|
|
103
103
|
readonly getSubTypes: (objectTypeId: string) => readonly string[]
|
|
104
104
|
}): void {
|
|
105
105
|
for (const condition of input.conditions) {
|
|
106
|
-
const predicate = bindCurrentUserPredicate(condition.predicate, STARTUP_CHECK_USER)
|
|
107
106
|
const objectTypeIds = [condition.objectTypeId, ...input.getSubTypes(condition.objectTypeId)]
|
|
108
107
|
|
|
109
108
|
try {
|
|
@@ -111,7 +110,9 @@ export function assertViewConditionsReadable(input: {
|
|
|
111
110
|
projectId: input.projectId,
|
|
112
111
|
scope: compileConditionalObjectReadScope({
|
|
113
112
|
kind: "conditional",
|
|
114
|
-
conditions: objectTypeIds.map((objectTypeId) =>
|
|
113
|
+
conditions: objectTypeIds.map((objectTypeId) =>
|
|
114
|
+
viewConditionReadCondition(objectTypeId, [condition.predicate], STARTUP_CHECK_USER)
|
|
115
|
+
),
|
|
115
116
|
}),
|
|
116
117
|
})
|
|
117
118
|
} catch (error) {
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { bindCurrentUserPredicate } from "../objects/query/current-user"
|
|
2
|
+
import type { ObjectQueryPredicate } from "../objects/query/ir"
|
|
3
|
+
import { isCurrentUser, type UserRef } from "../ontology/user-ref"
|
|
4
|
+
import type { ObjectReadCondition, ObjectVisibilityKeys } from "../storage/objects/types"
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The keys of a view condition, or undefined when it has none.
|
|
8
|
+
*
|
|
9
|
+
* A part that never reads `currentUser()` shows an object to everyone holding the condition while
|
|
10
|
+
* it matches. `eq` and `contains` with `currentUser()` show it to the users the property names, and
|
|
11
|
+
* `in` to those and to everyone when another value matches. Two kinds of conditions keep their
|
|
12
|
+
* predicate: negating a comparison with `currentUser()` shows an object to every user but some,
|
|
13
|
+
* and requiring two of them at once, to the users two properties share.
|
|
14
|
+
*/
|
|
15
|
+
export function viewConditionKeys(
|
|
16
|
+
predicate: ObjectQueryPredicate
|
|
17
|
+
): ObjectVisibilityKeys | undefined {
|
|
18
|
+
const part = keyedPart(predicate)
|
|
19
|
+
if (part === undefined) return undefined
|
|
20
|
+
|
|
21
|
+
return part === EVERYONE ? { kind: "everyone", when: predicate } : part
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* What a reader holding these conditions on one concrete type reads it through: their predicates
|
|
26
|
+
* bound to its user, and, for the conditions that have keys, the same condition as keys.
|
|
27
|
+
*/
|
|
28
|
+
export function viewConditionReadCondition(
|
|
29
|
+
objectTypeId: string,
|
|
30
|
+
predicates: readonly ObjectQueryPredicate[],
|
|
31
|
+
user: UserRef | undefined
|
|
32
|
+
): ObjectReadCondition {
|
|
33
|
+
const keys: ObjectVisibilityKeys[] = []
|
|
34
|
+
const remainder: ObjectQueryPredicate[] = []
|
|
35
|
+
|
|
36
|
+
for (const predicate of predicates) {
|
|
37
|
+
const conditionKeys = viewConditionKeys(predicate)
|
|
38
|
+
if (conditionKeys) keys.push(conditionKeys)
|
|
39
|
+
else remainder.push(bindCurrentUserPredicate(predicate, user))
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const bound = bindCurrentUserPredicate(anyOf(predicates), user)
|
|
43
|
+
if (keys.length === 0) return { objectTypeId, predicate: bound }
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
objectTypeId,
|
|
47
|
+
predicate: bound,
|
|
48
|
+
visibility: {
|
|
49
|
+
keys,
|
|
50
|
+
...(user ? { user } : {}),
|
|
51
|
+
...(remainder.length > 0 ? { remainder: anyOf(remainder) } : {}),
|
|
52
|
+
},
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** A part that reads no `currentUser()`: it shows an object to everyone while it matches. */
|
|
57
|
+
const EVERYONE = "everyone"
|
|
58
|
+
|
|
59
|
+
function keyedPart(
|
|
60
|
+
predicate: ObjectQueryPredicate
|
|
61
|
+
): typeof EVERYONE | ObjectVisibilityKeys | undefined {
|
|
62
|
+
if (!readsCurrentUser(predicate)) return EVERYONE
|
|
63
|
+
|
|
64
|
+
switch (predicate.op) {
|
|
65
|
+
case "and": {
|
|
66
|
+
const parts = predicate.items.map(keyedPart)
|
|
67
|
+
if (parts.includes(undefined)) return undefined
|
|
68
|
+
|
|
69
|
+
const everyone = predicate.items.filter((_, index) => parts[index] === EVERYONE)
|
|
70
|
+
const keyed = parts.filter(isKeys)
|
|
71
|
+
|
|
72
|
+
// Each keyed part names its own users: only the users they share would hold all of them.
|
|
73
|
+
if (keyed.length !== 1) return undefined
|
|
74
|
+
|
|
75
|
+
return everyone.length === 0
|
|
76
|
+
? keyed[0]
|
|
77
|
+
: { kind: "when", when: allOf(everyone), keys: keyed[0]! }
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
case "or": {
|
|
81
|
+
const parts = predicate.items.map(keyedPart)
|
|
82
|
+
if (parts.includes(undefined)) return undefined
|
|
83
|
+
|
|
84
|
+
const everyone = predicate.items.filter((_, index) => parts[index] === EVERYONE)
|
|
85
|
+
const items = [
|
|
86
|
+
...(everyone.length > 0 ? [{ kind: "everyone" as const, when: anyOf(everyone) }] : []),
|
|
87
|
+
...parts.filter(isKeys),
|
|
88
|
+
]
|
|
89
|
+
return items.length === 1 ? items[0] : { kind: "union", items }
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
case "eq":
|
|
93
|
+
return { kind: "user", propertyId: predicate.propertyId }
|
|
94
|
+
|
|
95
|
+
case "contains":
|
|
96
|
+
return { kind: "users", propertyId: predicate.propertyId }
|
|
97
|
+
|
|
98
|
+
case "in": {
|
|
99
|
+
const values = predicate.values.filter((value) => !isCurrentUser(value))
|
|
100
|
+
const user: ObjectVisibilityKeys = { kind: "user", propertyId: predicate.propertyId }
|
|
101
|
+
if (values.length === 0) return user
|
|
102
|
+
|
|
103
|
+
return {
|
|
104
|
+
kind: "union",
|
|
105
|
+
items: [{ kind: "everyone", when: { ...predicate, values } }, user],
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
default:
|
|
110
|
+
// `not` and `neq` around `currentUser()`.
|
|
111
|
+
return undefined
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function readsCurrentUser(predicate: ObjectQueryPredicate): boolean {
|
|
116
|
+
switch (predicate.op) {
|
|
117
|
+
case "and":
|
|
118
|
+
case "or":
|
|
119
|
+
return predicate.items.some(readsCurrentUser)
|
|
120
|
+
case "not":
|
|
121
|
+
return readsCurrentUser(predicate.item)
|
|
122
|
+
case "in":
|
|
123
|
+
return predicate.values.some(isCurrentUser)
|
|
124
|
+
case "exists":
|
|
125
|
+
case "constant":
|
|
126
|
+
return false
|
|
127
|
+
default:
|
|
128
|
+
return isCurrentUser(predicate.value)
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function isKeys(
|
|
133
|
+
part: typeof EVERYONE | ObjectVisibilityKeys | undefined
|
|
134
|
+
): part is ObjectVisibilityKeys {
|
|
135
|
+
return typeof part === "object"
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function allOf(predicates: readonly ObjectQueryPredicate[]): ObjectQueryPredicate {
|
|
139
|
+
return predicates.length === 1 ? predicates[0]! : { op: "and", items: predicates }
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function anyOf(predicates: readonly ObjectQueryPredicate[]): ObjectQueryPredicate {
|
|
143
|
+
return predicates.length === 1 ? predicates[0]! : { op: "or", items: predicates }
|
|
144
|
+
}
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
agentRunMayHoldCalls,
|
|
18
18
|
assertAgentApprovalCaller,
|
|
19
19
|
assertAgentApprovalModeInput,
|
|
20
|
+
assertAgentBackgroundCommandRef,
|
|
20
21
|
assertAgentComputerSession,
|
|
21
22
|
assertAgentContextCheckpointAnchors,
|
|
22
23
|
assertAgentContextCheckpointAuthority,
|
|
@@ -52,6 +53,7 @@ import {
|
|
|
52
53
|
snapshotAgentThreadSandboxParams,
|
|
53
54
|
subagentRunMatchesCreateInput,
|
|
54
55
|
transitionAgentThreadSandbox,
|
|
56
|
+
withStopRequest,
|
|
55
57
|
} from "./provider"
|
|
56
58
|
import type {
|
|
57
59
|
AddAgentThreadParticipantsInput,
|
|
@@ -61,6 +63,7 @@ import type {
|
|
|
61
63
|
AgentApprovalOutcome,
|
|
62
64
|
AgentApprovalRecord,
|
|
63
65
|
AgentApprovalStore,
|
|
66
|
+
AgentBackgroundCommandRef,
|
|
64
67
|
AgentComputerSessionRecord,
|
|
65
68
|
AgentComputerSessionStore,
|
|
66
69
|
AgentContextCheckpointRecord,
|
|
@@ -1595,9 +1598,33 @@ function compareApprovals(left: AgentApprovalRecord, right: AgentApprovalRecord)
|
|
|
1595
1598
|
class InMemoryAgentComputerSessionStore implements AgentComputerSessionStore {
|
|
1596
1599
|
private readonly sessions = new Map<string, AgentComputerSessionRecord>()
|
|
1597
1600
|
|
|
1598
|
-
async hold(input: AgentComputerSessionRecord): Promise<void> {
|
|
1601
|
+
async hold(input: Omit<AgentComputerSessionRecord, "stopRequests">): Promise<void> {
|
|
1599
1602
|
assertAgentComputerSession(input)
|
|
1600
|
-
|
|
1603
|
+
const { backgroundCommands, ...session } = input
|
|
1604
|
+
const stopRequests = this.sessions.get(sessionKey(input))?.stopRequests
|
|
1605
|
+
this.sessions.set(
|
|
1606
|
+
sessionKey(input),
|
|
1607
|
+
clone({
|
|
1608
|
+
...session,
|
|
1609
|
+
...(backgroundCommands?.length ? { backgroundCommands } : {}),
|
|
1610
|
+
...(stopRequests?.length ? { stopRequests } : {}),
|
|
1611
|
+
})
|
|
1612
|
+
)
|
|
1613
|
+
}
|
|
1614
|
+
|
|
1615
|
+
async requestStop(input: {
|
|
1616
|
+
readonly projectId: string
|
|
1617
|
+
readonly id: string
|
|
1618
|
+
readonly ownerPrincipal: Principal
|
|
1619
|
+
readonly command: AgentBackgroundCommandRef
|
|
1620
|
+
}): Promise<AgentComputerSessionRecord | null> {
|
|
1621
|
+
assertAgentBackgroundCommandRef(input.command)
|
|
1622
|
+
const held = this.sessions.get(sessionKey(input))
|
|
1623
|
+
if (!held) return null
|
|
1624
|
+
|
|
1625
|
+
const next = { ...held, stopRequests: withStopRequest(held.stopRequests ?? [], input.command) }
|
|
1626
|
+
this.sessions.set(sessionKey(input), clone(next))
|
|
1627
|
+
return clone(next)
|
|
1601
1628
|
}
|
|
1602
1629
|
|
|
1603
1630
|
async release(input: {
|
|
@@ -9,12 +9,17 @@ import { isModelReasoning } from "../../models/language-model"
|
|
|
9
9
|
import type { ExecutionRecord, ExecutionStorage } from "../executions"
|
|
10
10
|
import { findAgentRunExecution } from "../executions/run-link"
|
|
11
11
|
import { AgentStorageError } from "./errors"
|
|
12
|
+
import { AGENT_COMPUTER_BACKGROUND_COMMANDS_MAX } from "./types"
|
|
13
|
+
|
|
14
|
+
export { AGENT_COMPUTER_BACKGROUND_COMMANDS_MAX }
|
|
15
|
+
|
|
12
16
|
import type {
|
|
13
17
|
AddAgentThreadParticipantsInput,
|
|
14
18
|
AgentApprovalCall,
|
|
15
19
|
AgentApprovalMode,
|
|
16
20
|
AgentApprovalRecord,
|
|
17
21
|
AgentApprovalStatus,
|
|
22
|
+
AgentBackgroundCommandRef,
|
|
18
23
|
AgentComputerSessionRecord,
|
|
19
24
|
AgentContextCheckpointRecord,
|
|
20
25
|
AgentMemoryChange,
|
|
@@ -490,7 +495,7 @@ export function assertComputerPlace(runsOn: unknown, computer: unknown, prefix =
|
|
|
490
495
|
|
|
491
496
|
/** Validate a computer session before a store keeps it. */
|
|
492
497
|
export function assertAgentComputerSession(
|
|
493
|
-
session: AgentComputerSessionRecord,
|
|
498
|
+
session: Omit<AgentComputerSessionRecord, "stopRequests">,
|
|
494
499
|
prefix = "Sixb"
|
|
495
500
|
): void {
|
|
496
501
|
if (typeof session.id !== "string" || session.id.trim() === "" || session.id.length > 200) {
|
|
@@ -506,6 +511,57 @@ export function assertAgentComputerSession(
|
|
|
506
511
|
)
|
|
507
512
|
}
|
|
508
513
|
assertAgentThreadComputer(session.computer, prefix)
|
|
514
|
+
|
|
515
|
+
const commands = session.backgroundCommands ?? []
|
|
516
|
+
if (!Array.isArray(commands) || commands.length > AGENT_COMPUTER_BACKGROUND_COMMANDS_MAX) {
|
|
517
|
+
throw new AgentStorageError(
|
|
518
|
+
"invalid_input",
|
|
519
|
+
`[${prefix}] A computer session reports at most ${AGENT_COMPUTER_BACKGROUND_COMMANDS_MAX} background commands.`
|
|
520
|
+
)
|
|
521
|
+
}
|
|
522
|
+
for (const command of commands) {
|
|
523
|
+
assertAgentBackgroundCommandRef(command, prefix)
|
|
524
|
+
if (
|
|
525
|
+
typeof command.command !== "string" ||
|
|
526
|
+
!["running", "exited", "stopped"].includes(command.status) ||
|
|
527
|
+
(command.exitCode !== undefined && !Number.isInteger(command.exitCode)) ||
|
|
528
|
+
(command.endedAt !== undefined && typeof command.endedAt !== "string")
|
|
529
|
+
) {
|
|
530
|
+
throw new AgentStorageError(
|
|
531
|
+
"invalid_input",
|
|
532
|
+
`[${prefix}] A background command names its command, its status (running, exited or stopped), and an integer exit code once it ended.`
|
|
533
|
+
)
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
/** Validate which background command a stop names. */
|
|
539
|
+
export function assertAgentBackgroundCommandRef(
|
|
540
|
+
ref: AgentBackgroundCommandRef,
|
|
541
|
+
prefix = "Sixb"
|
|
542
|
+
): void {
|
|
543
|
+
const fields = [ref?.threadId, ref?.id, ref?.startedAt]
|
|
544
|
+
if (fields.some((field) => typeof field !== "string" || field === "" || field.length > 200)) {
|
|
545
|
+
throw new AgentStorageError(
|
|
546
|
+
"invalid_input",
|
|
547
|
+
`[${prefix}] A background command is named by its thread, its id and its start, each a non-empty string of at most 200 characters.`
|
|
548
|
+
)
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
/** The stop requests a session keeps with `command` added: once, the newest ones. */
|
|
553
|
+
export function withStopRequest(
|
|
554
|
+
requests: readonly AgentBackgroundCommandRef[],
|
|
555
|
+
command: AgentBackgroundCommandRef
|
|
556
|
+
): AgentBackgroundCommandRef[] {
|
|
557
|
+
const same = (other: AgentBackgroundCommandRef) =>
|
|
558
|
+
other.threadId === command.threadId &&
|
|
559
|
+
other.id === command.id &&
|
|
560
|
+
other.startedAt === command.startedAt
|
|
561
|
+
if (requests.some(same)) return [...requests]
|
|
562
|
+
|
|
563
|
+
const ref = { threadId: command.threadId, id: command.id, startedAt: command.startedAt }
|
|
564
|
+
return [...requests, ref].slice(-AGENT_COMPUTER_BACKGROUND_COMMANDS_MAX)
|
|
509
565
|
}
|
|
510
566
|
|
|
511
567
|
/** C0 and C1 controls, DEL, and the marks that reorder text where a terminal or page shows it. */
|
|
@@ -258,6 +258,36 @@ export interface AgentComputerSessionRecord {
|
|
|
258
258
|
readonly ownerPrincipal: Principal
|
|
259
259
|
readonly computer: AgentThreadComputer
|
|
260
260
|
readonly expiresAt: Date
|
|
261
|
+
/** Its threads' background commands, as its latest renewal reported them. */
|
|
262
|
+
readonly backgroundCommands?: readonly AgentComputerBackgroundCommand[]
|
|
263
|
+
/** The commands someone asked to stop: each renewal hands back those still running. */
|
|
264
|
+
readonly stopRequests?: readonly AgentBackgroundCommandRef[]
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/** How many background commands a computer session reports, and keeps stop requests for. */
|
|
268
|
+
export const AGENT_COMPUTER_BACKGROUND_COMMANDS_MAX = 64
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* A background command an open `sixb` runs for one of its threads, which outlives the turn that
|
|
272
|
+
* started it: the web shows how it stands between turns.
|
|
273
|
+
*/
|
|
274
|
+
export interface AgentComputerBackgroundCommand {
|
|
275
|
+
readonly threadId: string
|
|
276
|
+
/** `bg_<hex>`, as the agent's tools name it. */
|
|
277
|
+
readonly id: string
|
|
278
|
+
readonly command: string
|
|
279
|
+
readonly status: "running" | "exited" | "stopped"
|
|
280
|
+
readonly exitCode?: number
|
|
281
|
+
/** ISO timestamps. */
|
|
282
|
+
readonly startedAt: string
|
|
283
|
+
readonly endedAt?: string
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/** A background command by its start: its id comes again once `sixb` restarts. */
|
|
287
|
+
export interface AgentBackgroundCommandRef {
|
|
288
|
+
readonly threadId: string
|
|
289
|
+
readonly id: string
|
|
290
|
+
readonly startedAt: string
|
|
261
291
|
}
|
|
262
292
|
|
|
263
293
|
export interface RemoveAgentThreadParticipantInput {
|
|
@@ -1252,8 +1282,21 @@ export const AGENT_MEMORY_HISTORY_DAYS = 90
|
|
|
1252
1282
|
|
|
1253
1283
|
/** Each open `sixb` on its owner's computers, as a lease it renews. */
|
|
1254
1284
|
export interface AgentComputerSessionStore {
|
|
1255
|
-
/**
|
|
1256
|
-
|
|
1285
|
+
/**
|
|
1286
|
+
* Open the session, or renew it until `expiresAt`; its computer, folder and background commands
|
|
1287
|
+
* are kept as given, and its stop requests as they are.
|
|
1288
|
+
*/
|
|
1289
|
+
hold(input: Omit<AgentComputerSessionRecord, "stopRequests">): Promise<void>
|
|
1290
|
+
/**
|
|
1291
|
+
* Record that someone asked to stop one of its commands, once, keeping the newest
|
|
1292
|
+
* {@link AGENT_COMPUTER_BACKGROUND_COMMANDS_MAX}. Null when the owner holds no such session.
|
|
1293
|
+
*/
|
|
1294
|
+
requestStop(input: {
|
|
1295
|
+
readonly projectId: string
|
|
1296
|
+
readonly id: string
|
|
1297
|
+
readonly ownerPrincipal: Principal
|
|
1298
|
+
readonly command: AgentBackgroundCommandRef
|
|
1299
|
+
}): Promise<AgentComputerSessionRecord | null>
|
|
1257
1300
|
/** End the owner's session; null when it is not open. */
|
|
1258
1301
|
release(input: {
|
|
1259
1302
|
readonly projectId: string
|
|
@@ -886,7 +886,7 @@ export class InMemoryConnectorConnectionStorage implements ConnectorConnectionSt
|
|
|
886
886
|
}
|
|
887
887
|
const existing = this.findConnectionRecord(input)
|
|
888
888
|
const sameAccount = existing?.account.id === account.id
|
|
889
|
-
if (existing && !sameAccount && !input.replace) {
|
|
889
|
+
if (existing?.status === "connected" && !sameAccount && !input.replace) {
|
|
890
890
|
throw new ConnectorConnectionStorageError(
|
|
891
891
|
"connection_conflict",
|
|
892
892
|
`[Sixb] Connector slot '${input.slot}' is already connected to another account; explicit replacement is required.`
|
|
@@ -965,7 +965,7 @@ export class InMemoryConnectorConnectionStorage implements ConnectorConnectionSt
|
|
|
965
965
|
? {}
|
|
966
966
|
: { revocationPendingAuthorizationId }),
|
|
967
967
|
created: existing === undefined,
|
|
968
|
-
replaced: existing
|
|
968
|
+
replaced: existing?.status === "connected" && !sameAccount,
|
|
969
969
|
}
|
|
970
970
|
}
|
|
971
971
|
|
|
@@ -182,7 +182,7 @@ export class DurableConnectorConnections extends ConnectorConnectionOperations {
|
|
|
182
182
|
}
|
|
183
183
|
const existing = await persistence.getConnectionBySelector(input)
|
|
184
184
|
const sameAccount = existing?.account.id === account.id
|
|
185
|
-
if (existing && !sameAccount && !input.replace) {
|
|
185
|
+
if (existing?.status === "connected" && !sameAccount && !input.replace) {
|
|
186
186
|
throw new ConnectorConnectionStorageError(
|
|
187
187
|
"connection_conflict",
|
|
188
188
|
`[Sixb] Connector slot '${input.slot}' is already connected to another account; explicit replacement is required.`
|
|
@@ -267,7 +267,7 @@ export class DurableConnectorConnections extends ConnectorConnectionOperations {
|
|
|
267
267
|
? {}
|
|
268
268
|
: { revocationPendingAuthorizationId }),
|
|
269
269
|
created: existing === null,
|
|
270
|
-
replaced: existing
|
|
270
|
+
replaced: existing?.status === "connected" && !sameAccount,
|
|
271
271
|
}
|
|
272
272
|
}
|
|
273
273
|
}
|
package/src/storage/index.ts
CHANGED
|
@@ -89,6 +89,8 @@ export type {
|
|
|
89
89
|
AgentApprovalSettledStatus,
|
|
90
90
|
AgentApprovalStatus,
|
|
91
91
|
AgentApprovalStore,
|
|
92
|
+
AgentBackgroundCommandRef,
|
|
93
|
+
AgentComputerBackgroundCommand,
|
|
92
94
|
AgentComputerSessionRecord,
|
|
93
95
|
AgentComputerSessionStore,
|
|
94
96
|
AgentContextCheckpointReason,
|
|
@@ -566,10 +568,12 @@ export type {
|
|
|
566
568
|
ObjectReadRoot,
|
|
567
569
|
ObjectReadScopeFactory,
|
|
568
570
|
ObjectReadStorage,
|
|
571
|
+
ObjectReadVisibility,
|
|
569
572
|
ObjectRow,
|
|
570
573
|
ObjectRowLinks,
|
|
571
574
|
ObjectRowUsers,
|
|
572
575
|
ObjectStorage,
|
|
576
|
+
ObjectVisibilityKeys,
|
|
573
577
|
QueryObjectLinksInput,
|
|
574
578
|
QueryObjectLinksResult,
|
|
575
579
|
QueryObjectsInput,
|
package/src/storage/internal.ts
CHANGED
|
@@ -44,8 +44,10 @@ export {
|
|
|
44
44
|
export { parseFileDownloadGrantRow } from "./file-download-grants/record"
|
|
45
45
|
export { createFileUploadId, createUploadExpiresAt } from "./file-upload-sessions/utils"
|
|
46
46
|
export { canRequeuePipelineRunAfterEnqueueFailure } from "./pipeline-runs/idempotency"
|
|
47
|
+
export { canFinishPipelineRun } from "./pipeline-runs/transitions"
|
|
47
48
|
export { projectionRunObjectTypesVisible, zeroProjectionRunProgress } from "./projection-runs/types"
|
|
48
49
|
export { canRequeueSyncRunAfterEnqueueFailure } from "./sync-runs/idempotency"
|
|
50
|
+
export { canFinishSyncRun } from "./sync-runs/transitions"
|
|
49
51
|
export {
|
|
50
52
|
assertTransactionActive,
|
|
51
53
|
createTransactionStorageProxy,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { OntologyDefinitionCatalog } from "../../ontology/registry"
|
|
2
|
+
import type { SecurityDefinitionCatalog } from "../../security/registry"
|
|
2
3
|
import type { ObjectQueryPreparationResult } from "../objects/query-preparation"
|
|
3
4
|
import type { Storage } from "../types"
|
|
4
5
|
|
|
@@ -128,6 +129,11 @@ export interface MigrationCapableStorage extends Storage {
|
|
|
128
129
|
export interface StorageMigrationOptions {
|
|
129
130
|
readonly projectId: string
|
|
130
131
|
readonly ontology: OntologyDefinitionCatalog
|
|
132
|
+
/**
|
|
133
|
+
* The roles' view conditions, whose keys member reads filter on. Without them, what was prepared
|
|
134
|
+
* for them is left as it is.
|
|
135
|
+
*/
|
|
136
|
+
readonly security?: Pick<SecurityDefinitionCatalog, "listViewConditions">
|
|
131
137
|
}
|
|
132
138
|
|
|
133
139
|
export interface StorageMigrationResult {
|
|
@@ -2,6 +2,7 @@ import type { ObjectQuery, ObjectQuerySortField } from "../../../objects/query"
|
|
|
2
2
|
import { linkEndpointObjectTypeIds } from "../../../objects/query/link-endpoints"
|
|
3
3
|
import { matchesPredicate } from "../../../objects/query/matches-predicate"
|
|
4
4
|
import { compareQueryScalarValues } from "../../../objects/query/scalar-values"
|
|
5
|
+
import { sortTieDirection } from "../../../objects/query/sort-ties"
|
|
5
6
|
import { vectorSources } from "../../../objects/vectors/profile"
|
|
6
7
|
import type { LinkBatchKey } from "../keys"
|
|
7
8
|
import {
|
|
@@ -443,14 +444,16 @@ function sortEntries(
|
|
|
443
444
|
entries: readonly QueryEntry[],
|
|
444
445
|
fields: readonly ObjectQuerySortField[]
|
|
445
446
|
): QueryEntry[] {
|
|
447
|
+
const ties = sortTieDirection(fields)
|
|
446
448
|
return [...entries].sort((left, right) => {
|
|
447
449
|
for (const field of fields) {
|
|
448
450
|
const comparison = compareSortField(left, right, field)
|
|
449
451
|
if (comparison !== 0) return comparison
|
|
450
452
|
}
|
|
451
|
-
|
|
453
|
+
|
|
454
|
+
const tie =
|
|
452
455
|
left.order - right.order || rowIdentityKey(left.row).localeCompare(rowIdentityKey(right.row))
|
|
453
|
-
|
|
456
|
+
return ties === "desc" ? -tie : tie
|
|
454
457
|
})
|
|
455
458
|
}
|
|
456
459
|
|
|
@@ -50,10 +50,12 @@ export type {
|
|
|
50
50
|
ObjectReadRoot,
|
|
51
51
|
ObjectReadScopeFactory,
|
|
52
52
|
ObjectReadStorage,
|
|
53
|
+
ObjectReadVisibility,
|
|
53
54
|
ObjectRow,
|
|
54
55
|
ObjectRowLinks,
|
|
55
56
|
ObjectRowUsers,
|
|
56
57
|
ObjectStorage,
|
|
58
|
+
ObjectVisibilityKeys,
|
|
57
59
|
QueryObjectLinksInput,
|
|
58
60
|
QueryObjectLinksResult,
|
|
59
61
|
QueryObjectsInput,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { compareStrings } from "../../json"
|
|
1
2
|
import type { QueryScalarKind } from "../../objects/query/ir"
|
|
2
3
|
import { linkTargetObjectTypeIds } from "../../objects/query/link-endpoints"
|
|
3
4
|
import {
|
|
@@ -7,7 +8,10 @@ import {
|
|
|
7
8
|
} from "../../ontology/query-capabilities"
|
|
8
9
|
import type { OntologyDefinitionCatalog } from "../../ontology/registry"
|
|
9
10
|
import type { ObjectQueryIndexDefinition } from "../../ontology/types"
|
|
11
|
+
import type { SecurityDefinitionCatalog } from "../../security/registry"
|
|
12
|
+
import { viewConditionKeys } from "../../security/visibility-keys"
|
|
10
13
|
import type { Storage } from "../types"
|
|
14
|
+
import type { ObjectVisibilityKeys } from "./types"
|
|
11
15
|
|
|
12
16
|
export interface ObjectQueryPreparationPlan {
|
|
13
17
|
readonly projectId: string
|
|
@@ -26,6 +30,12 @@ export interface ObjectQueryPreparationPlan {
|
|
|
26
30
|
readonly linkId: string
|
|
27
31
|
readonly targetObjectTypeIds: readonly string[] | undefined
|
|
28
32
|
}[]
|
|
33
|
+
/**
|
|
34
|
+
* The keys of every view condition a role puts on the type or a supertype, each once: a
|
|
35
|
+
* member's reads of the type filter on them. Absent when preparation was not given the view
|
|
36
|
+
* conditions, and a provider then leaves what it prepared for them as it is.
|
|
37
|
+
*/
|
|
38
|
+
readonly visibility?: readonly ObjectVisibilityKeys[]
|
|
29
39
|
}[]
|
|
30
40
|
}
|
|
31
41
|
|
|
@@ -54,6 +64,11 @@ export function isQueryPreparationCapableStorage(
|
|
|
54
64
|
export async function prepareObjectQueries(input: {
|
|
55
65
|
projectId: string
|
|
56
66
|
ontology: OntologyDefinitionCatalog
|
|
67
|
+
/**
|
|
68
|
+
* The roles' view conditions, whose keys member reads filter on. Without them, what was prepared
|
|
69
|
+
* for them is left as it is.
|
|
70
|
+
*/
|
|
71
|
+
security?: Pick<SecurityDefinitionCatalog, "listViewConditions">
|
|
57
72
|
storage: Storage
|
|
58
73
|
}): Promise<ObjectQueryPreparationResult> {
|
|
59
74
|
if (!isQueryPreparationCapableStorage(input.storage)) {
|
|
@@ -61,6 +76,7 @@ export async function prepareObjectQueries(input: {
|
|
|
61
76
|
}
|
|
62
77
|
|
|
63
78
|
const values = input.ontology.getValueTypesById()
|
|
79
|
+
const visibility = viewConditionKeysByType(input.security, input.ontology)
|
|
64
80
|
const objectTypes = input.ontology.listObjectTypes().map((type) => ({
|
|
65
81
|
objectTypeId: type.id,
|
|
66
82
|
properties: type.properties
|
|
@@ -82,6 +98,48 @@ export async function prepareObjectQueries(input: {
|
|
|
82
98
|
linkId: link.id,
|
|
83
99
|
targetObjectTypeIds: linkTargetObjectTypeIds(link.targetObjectTypeId, input.ontology),
|
|
84
100
|
})),
|
|
101
|
+
...(visibility ? { visibility: visibility.get(type.id) ?? [] } : {}),
|
|
85
102
|
}))
|
|
86
|
-
|
|
103
|
+
const result = await input.storage.prepareObjectQueries({
|
|
104
|
+
projectId: input.projectId,
|
|
105
|
+
objectTypes,
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
const unindexed = (input.security?.listViewConditions() ?? [])
|
|
109
|
+
.filter((condition) => !viewConditionKeys(condition.predicate))
|
|
110
|
+
.map(
|
|
111
|
+
(condition) =>
|
|
112
|
+
`Role '${condition.roleId}': can.view(${condition.objectTypeId}).where(...) negates currentUser() or needs it twice at once, so members' reads check every object.`
|
|
113
|
+
)
|
|
114
|
+
return unindexed.length > 0 ? { ...result, warnings: [...result.warnings, ...unindexed] } : result
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** Each concrete type's distinct condition keys, in a stable order. */
|
|
118
|
+
function viewConditionKeysByType(
|
|
119
|
+
security: Pick<SecurityDefinitionCatalog, "listViewConditions"> | undefined,
|
|
120
|
+
ontology: OntologyDefinitionCatalog
|
|
121
|
+
): ReadonlyMap<string, readonly ObjectVisibilityKeys[]> | undefined {
|
|
122
|
+
if (!security) return undefined
|
|
123
|
+
|
|
124
|
+
const keysByType = new Map<string, Map<string, ObjectVisibilityKeys>>()
|
|
125
|
+
for (const condition of security.listViewConditions()) {
|
|
126
|
+
const keys = viewConditionKeys(condition.predicate)
|
|
127
|
+
if (!keys) continue
|
|
128
|
+
|
|
129
|
+
for (const objectTypeId of [
|
|
130
|
+
condition.objectTypeId,
|
|
131
|
+
...ontology.listSubTypes(condition.objectTypeId),
|
|
132
|
+
]) {
|
|
133
|
+
const typeKeys = keysByType.get(objectTypeId) ?? new Map<string, ObjectVisibilityKeys>()
|
|
134
|
+
typeKeys.set(JSON.stringify(keys), keys)
|
|
135
|
+
keysByType.set(objectTypeId, typeKeys)
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return new Map(
|
|
140
|
+
[...keysByType].map(([objectTypeId, keys]) => [
|
|
141
|
+
objectTypeId,
|
|
142
|
+
[...keys].sort(([left], [right]) => compareStrings(left, right)).map(([, value]) => value),
|
|
143
|
+
])
|
|
144
|
+
)
|
|
87
145
|
}
|