@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
|
@@ -120,6 +120,11 @@ const OPERATIONS: Readonly<Record<string, Operation>> = {
|
|
|
120
120
|
const { providerId, modelId, definition, rateCard, defaultReasoning, maxOutputTokens } = model
|
|
121
121
|
return { providerId, modelId, definition, rateCard, defaultReasoning, maxOutputTokens }
|
|
122
122
|
},
|
|
123
|
+
"models.webSearch": (session, [request], signal) =>
|
|
124
|
+
session.models.webSearch(
|
|
125
|
+
request as Parameters<AgentRunSession["models"]["webSearch"]>[0],
|
|
126
|
+
signal
|
|
127
|
+
),
|
|
123
128
|
"files.stat": (session, [blobId]) => session.files.stat(blobId as string),
|
|
124
129
|
}
|
|
125
130
|
|
|
@@ -428,11 +433,12 @@ function withSavedOutputChecked(part: AgentMessagePart): AgentMessagePart {
|
|
|
428
433
|
|
|
429
434
|
/** One model call, its events streamed back as lines of JSON as the provider sends them. */
|
|
430
435
|
async function streamModelCall(session: AgentRunSession, request: Request): Promise<Response> {
|
|
431
|
-
const { ref, call } = decodeWireValue(await readBodyText(request)) as {
|
|
436
|
+
const { ref, call, measures } = decodeWireValue(await readBodyText(request)) as {
|
|
432
437
|
ref: Parameters<AgentRunSession["models"]["language"]>[0]
|
|
433
438
|
call: Omit<LanguageModelRequest, "signal">
|
|
439
|
+
measures?: unknown
|
|
434
440
|
}
|
|
435
|
-
const model = await session.models.language(ref)
|
|
441
|
+
const model = await session.models.language(ref, { measures: measures !== false })
|
|
436
442
|
const opened = await model.stream({ ...call, signal: request.signal })
|
|
437
443
|
const encoder = new TextEncoder()
|
|
438
444
|
const iterator = opened.events[Symbol.asyncIterator]()
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
} from "../models/execution/index"
|
|
20
20
|
import type { LanguageModel } from "../models/language-model"
|
|
21
21
|
import { resolveLanguageModel } from "../models/resolve"
|
|
22
|
+
import type { WebSearchModelRequest, WebSearchModelResult } from "../models/web-search-model"
|
|
22
23
|
import type { Sixb } from "../runtime/sixb"
|
|
23
24
|
import type { SecurityDefinitionCatalog } from "../security"
|
|
24
25
|
import type { Storage } from "../storage"
|
|
@@ -90,6 +91,7 @@ import { subscribeAgentRunCancel } from "./streams/protocol"
|
|
|
90
91
|
import { subagentSandboxFiles } from "./subagent-runs"
|
|
91
92
|
import { conversationThreadId } from "./thread-access"
|
|
92
93
|
import type { AgentToolRunInfo } from "./types"
|
|
94
|
+
import { bindAgentWebSearch } from "./web"
|
|
93
95
|
|
|
94
96
|
/**
|
|
95
97
|
* A run's session: the one way its runner reads and writes shared state for it. Claiming the run
|
|
@@ -198,8 +200,20 @@ export interface AgentRunSession<TRun extends AgentRunRecord = AgentRunRecord> {
|
|
|
198
200
|
|
|
199
201
|
/** The models a run calls, by the ref its plan names. */
|
|
200
202
|
export interface AgentRunModels {
|
|
201
|
-
/**
|
|
202
|
-
|
|
203
|
+
/**
|
|
204
|
+
* A language model of the project, resolved once for the session. Each call is recorded, and
|
|
205
|
+
* measures the model's tokenizer for the run, unless `measures` is false: a tool's own call
|
|
206
|
+
* (`web_fetch`'s question) reads other text than the run's context, and must not stand for it.
|
|
207
|
+
*/
|
|
208
|
+
language(ref: LanguageModelRef, options?: { readonly measures?: boolean }): Promise<LanguageModel>
|
|
209
|
+
/**
|
|
210
|
+
* Search the web with the project's web search model, the one its plan's `web.search` names.
|
|
211
|
+
* It always runs where the project is: the provider's key never reaches the runner.
|
|
212
|
+
*/
|
|
213
|
+
webSearch(
|
|
214
|
+
request: Omit<WebSearchModelRequest, "signal">,
|
|
215
|
+
signal: AbortSignal
|
|
216
|
+
): Promise<WebSearchModelResult>
|
|
203
217
|
}
|
|
204
218
|
|
|
205
219
|
/** Where a run's files are stored: put one, open or stat one by its blob id. */
|
|
@@ -380,6 +394,11 @@ export async function openAgentRunSession<TRun extends AgentRunRecord>(
|
|
|
380
394
|
})
|
|
381
395
|
return toolsBound
|
|
382
396
|
}
|
|
397
|
+
// Its searches bill to the run too, and stop with it.
|
|
398
|
+
const webSearch = bindAgentWebSearch(host.definitions, {
|
|
399
|
+
signal: AbortSignal.any([cancelled, ended.signal, ...(stop ? [stop] : [])]),
|
|
400
|
+
accounting: openedModelCalls,
|
|
401
|
+
})
|
|
383
402
|
let logs: RunLogSession | undefined
|
|
384
403
|
// Labeled with the conversation its run works in: a child's is its parent's.
|
|
385
404
|
let toolLabels: Promise<LogFields> | undefined
|
|
@@ -437,7 +456,7 @@ export async function openAgentRunSession<TRun extends AgentRunRecord>(
|
|
|
437
456
|
pausesAfterStep: () => turnPausesOnHeldCalls(host.storage.agents, run),
|
|
438
457
|
},
|
|
439
458
|
models: {
|
|
440
|
-
async language(ref) {
|
|
459
|
+
async language(ref, options) {
|
|
441
460
|
const key = `${ref.provider}/${ref.modelId}`
|
|
442
461
|
let resolved = languageModels.get(key)
|
|
443
462
|
if (!resolved) {
|
|
@@ -453,15 +472,16 @@ export async function openAgentRunSession<TRun extends AgentRunRecord>(
|
|
|
453
472
|
resolved.catch(() => languageModels.delete(key))
|
|
454
473
|
}
|
|
455
474
|
// Each call records itself, and what it measured of the model's tokenizer.
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
)
|
|
475
|
+
const recorded = (await openedModelCalls()).wrapModel(await resolved)
|
|
476
|
+
if (options?.measures === false) return recorded
|
|
477
|
+
|
|
478
|
+
return measuringAgentContextTokenRates(recorded, {
|
|
479
|
+
tokenRates: agents.tokenRates,
|
|
480
|
+
projectId: host.projectId,
|
|
481
|
+
runId: run.id,
|
|
482
|
+
})
|
|
464
483
|
},
|
|
484
|
+
webSearch,
|
|
465
485
|
},
|
|
466
486
|
async renewLease(leaseExpiresAt) {
|
|
467
487
|
try {
|
package/src/agents/skills.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { OntologyDocsCatalog, OntologyDocsInput } from "../ontology/docs"
|
|
2
2
|
import { RuntimeError } from "../runtime/errors"
|
|
3
3
|
import type { AgentOptions } from "./step-limits"
|
|
4
|
+
import type { AgentWebOptions } from "./web"
|
|
4
5
|
|
|
5
6
|
/** A project file the Agent receives byte-for-byte in its sandbox. */
|
|
6
7
|
export interface AgentProjectFile {
|
|
@@ -48,6 +49,8 @@ export interface AgentDefinitions {
|
|
|
48
49
|
/** As the project set them, checked. Absent: a turn has no limit, a sub-agent the default. */
|
|
49
50
|
readonly maxSteps?: number
|
|
50
51
|
readonly subagentMaxSteps?: number
|
|
52
|
+
/** As the project set it, checked, its domains in canonical form. Absent: web tools are on. */
|
|
53
|
+
readonly web?: false | AgentWebOptions
|
|
51
54
|
}
|
|
52
55
|
|
|
53
56
|
/** Index skills by name. Discovery validates each skill; names must also be unique. */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { RuntimeError } from "../runtime/errors"
|
|
2
|
+
import type { AgentWebOptions } from "./web"
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* The most model calls a run nobody watches takes when nothing sets its own limit: a sub-agent's or
|
|
@@ -15,6 +16,11 @@ export interface AgentOptions {
|
|
|
15
16
|
readonly maxSteps?: number
|
|
16
17
|
/** At most this many steps in one run of a sub-agent. Defaults to 500. */
|
|
17
18
|
readonly subagentMaxSteps?: number
|
|
19
|
+
/**
|
|
20
|
+
* The web tools: `web_search` when the project has a web search model, and `web_fetch`. On by
|
|
21
|
+
* default; `false` turns both off, and domain lists narrow both.
|
|
22
|
+
*/
|
|
23
|
+
readonly web?: false | AgentWebOptions
|
|
18
24
|
}
|
|
19
25
|
|
|
20
26
|
/** Reject a step limit that is not a positive integer, naming where it was set. */
|
|
@@ -37,6 +37,8 @@ export interface AgentRunActivityEvent {
|
|
|
37
37
|
readonly attempt: number
|
|
38
38
|
/** Set on a computer's turn: a `sixb` hearing of any other has nothing to read about it. */
|
|
39
39
|
readonly runsOn?: "computer"
|
|
40
|
+
/** A stop was asked for: whatever runs it hears at its next lease renewal, or now, on this. */
|
|
41
|
+
readonly cancelRequested?: true
|
|
40
42
|
readonly occurredAt: string
|
|
41
43
|
}
|
|
42
44
|
|
|
@@ -100,7 +102,9 @@ export interface AgentApprovalActivityEvent {
|
|
|
100
102
|
|
|
101
103
|
/**
|
|
102
104
|
* An open `sixb` on its owner's computer came or went: the threads that run on that computer in
|
|
103
|
-
* that folder are reachable now, or not.
|
|
105
|
+
* that folder are reachable now, or not. Also said, `online`, as the background commands it runs
|
|
106
|
+
* start or end, and as its owner asks it to stop one, which it hears and renews its session for.
|
|
107
|
+
* Only its owner hears it.
|
|
104
108
|
*/
|
|
105
109
|
export interface AgentComputerActivityEvent {
|
|
106
110
|
readonly schemaVersion: typeof AGENT_ACTIVITY_STREAM_SCHEMA_VERSION
|
|
@@ -286,9 +290,10 @@ export async function publishAgentApprovalActivity(
|
|
|
286
290
|
|
|
287
291
|
export async function publishAgentRunActivity(
|
|
288
292
|
broker: Broker,
|
|
289
|
-
run: ConversationAgentRunRecord
|
|
293
|
+
run: ConversationAgentRunRecord,
|
|
294
|
+
options: { readonly cancelRequested?: true } = {}
|
|
290
295
|
): Promise<void> {
|
|
291
|
-
const event = agentRunActivityEvent(run)
|
|
296
|
+
const event = { ...agentRunActivityEvent(run), ...options }
|
|
292
297
|
await broker.ensureStream({
|
|
293
298
|
projectId: run.projectId,
|
|
294
299
|
stream: agentActivityStreamDefinition(),
|
|
@@ -302,7 +307,7 @@ export async function publishAgentRunActivity(
|
|
|
302
307
|
key: event.threadId,
|
|
303
308
|
// The event is composed only of validated JSON primitives.
|
|
304
309
|
payload: event as unknown as JsonValue,
|
|
305
|
-
idempotencyKey: `${event.runId}:${event.attempt}:${event.status}`,
|
|
310
|
+
idempotencyKey: `${event.runId}:${event.attempt}:${event.status}${options.cancelRequested ? ":cancel" : ""}`,
|
|
306
311
|
},
|
|
307
312
|
],
|
|
308
313
|
})
|
package/src/agents/tool-files.ts
CHANGED
|
@@ -224,23 +224,31 @@ export function agentToolFilePath(toolCallId: string, fileRef: FileRef, fileName
|
|
|
224
224
|
return posix.join("tool-files", callKey, `${digestKey}-${fileName}`)
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
+
/** What a saved output may be: text, a page as markdown, or a document or image as it came. */
|
|
228
|
+
export type AgentToolOutputExtension = "txt" | "md" | "pdf" | "png" | "jpg" | "gif" | "webp"
|
|
229
|
+
|
|
227
230
|
/**
|
|
228
231
|
* Where a call's output too large for the model's context is saved, relative to the context
|
|
229
232
|
* directory: the call, and the content's digest, so a call id a provider uses again names another
|
|
230
233
|
* file. `sha256` is the content's hex digest.
|
|
231
234
|
*/
|
|
232
|
-
export function agentToolOutputPath(
|
|
235
|
+
export function agentToolOutputPath(
|
|
236
|
+
toolCallId: string,
|
|
237
|
+
sha256: string,
|
|
238
|
+
extension: AgentToolOutputExtension = "txt"
|
|
239
|
+
): string {
|
|
233
240
|
const call = SAFE_CALL_ID.test(toolCallId)
|
|
234
241
|
? toolCallId
|
|
235
242
|
: createHash("sha256").update(toolCallId).digest("hex").slice(0, 16)
|
|
236
|
-
return `${AGENT_TOOL_OUTPUTS_DIRECTORY}/${call}-${sha256.slice(0, 12)}
|
|
243
|
+
return `${AGENT_TOOL_OUTPUTS_DIRECTORY}/${call}-${sha256.slice(0, 12)}.${extension}`
|
|
237
244
|
}
|
|
238
245
|
|
|
239
246
|
/** Where saved outputs go, in the context directory. */
|
|
240
247
|
export const AGENT_TOOL_OUTPUTS_DIRECTORY = "tool-outputs"
|
|
241
248
|
|
|
242
249
|
const SAFE_CALL_ID = /^[A-Za-z0-9_-]{1,128}$/
|
|
243
|
-
const TOOL_OUTPUT_PATH =
|
|
250
|
+
const TOOL_OUTPUT_PATH =
|
|
251
|
+
/^tool-outputs\/[A-Za-z0-9_-]{1,128}-([0-9a-f]{12})\.(?:txt|md|pdf|png|jpg|gif|webp)$/
|
|
244
252
|
|
|
245
253
|
/**
|
|
246
254
|
* Whether a tool-call part's `outputFile` is one {@link agentToolOutputPath} names: a stored file,
|
package/src/agents/validation.ts
CHANGED
|
@@ -5,10 +5,13 @@ import { normalizeSchemaValue } from "../ontology/validation/normalize"
|
|
|
5
5
|
import { validateSchemaValue } from "../ontology/validation/schema"
|
|
6
6
|
import { AgentDefinitionError } from "./errors"
|
|
7
7
|
import type { AgentToolDefinition, AgentToolInputSchema } from "./types"
|
|
8
|
+
import { AGENT_WEB_TOOL_NAMES } from "./web"
|
|
8
9
|
|
|
9
10
|
const AGENT_TOOL_NAME_PATTERN = /^[A-Za-z_][A-Za-z0-9_-]{0,63}$/
|
|
10
11
|
export const AGENT_RESERVED_TOOL_NAMES = [
|
|
11
12
|
"bash",
|
|
13
|
+
"bash_output",
|
|
14
|
+
"bash_stop",
|
|
12
15
|
"read",
|
|
13
16
|
"view_file",
|
|
14
17
|
"spawn_agent",
|
|
@@ -17,6 +20,7 @@ export const AGENT_RESERVED_TOOL_NAMES = [
|
|
|
17
20
|
"ask_parent",
|
|
18
21
|
"publish_artifact",
|
|
19
22
|
"publish_artifact_version",
|
|
23
|
+
...AGENT_WEB_TOOL_NAMES,
|
|
20
24
|
] as const
|
|
21
25
|
|
|
22
26
|
export function isAgentToolDefinition(value: unknown): value is AgentToolDefinition {
|
|
@@ -36,6 +40,11 @@ export function assertValidAgentToolName(name: unknown): asserts name is string
|
|
|
36
40
|
"[Sixb] Agent tool name must be 1-64 characters, start with a letter or underscore, and contain only letters, numbers, underscores, or hyphens."
|
|
37
41
|
)
|
|
38
42
|
}
|
|
43
|
+
if ((AGENT_WEB_TOOL_NAMES as readonly string[]).includes(name)) {
|
|
44
|
+
throw new AgentDefinitionError(
|
|
45
|
+
`[Sixb] Agent tool name '${name}' is reserved: Sixb gives the Agent its own ${name} tool. To search with Exa, set models.webSearch: [exaSearch(...)].`
|
|
46
|
+
)
|
|
47
|
+
}
|
|
39
48
|
if ((AGENT_RESERVED_TOOL_NAMES as readonly string[]).includes(name)) {
|
|
40
49
|
throw new AgentDefinitionError(`[Sixb] Agent tool name '${name}' is reserved by the framework.`)
|
|
41
50
|
}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { createSixbError } from "../errors/internal"
|
|
2
|
+
import type { ModelCatalog } from "../models/catalog"
|
|
3
|
+
import type { AiModelCallRecorder } from "../models/execution/model-call-recorder"
|
|
4
|
+
import { bindWebSearchModels } from "../models/execution/web-search"
|
|
5
|
+
import { RuntimeError } from "../runtime/errors"
|
|
6
|
+
import type { AgentRunModels } from "./run-session"
|
|
7
|
+
import type { AgentDefinitions } from "./skills"
|
|
8
|
+
|
|
9
|
+
// The Agent's web tools: the option that narrows or turns them off, the domain lists both tools
|
|
10
|
+
// apply, and the search a run's tool calls through its own accounting.
|
|
11
|
+
|
|
12
|
+
/** Narrows what the Agent's web tools reach. */
|
|
13
|
+
export interface AgentWebOptions {
|
|
14
|
+
/**
|
|
15
|
+
* Only these: `docs.example.com`, `*.example.com` (its subdomains, not itself) or a path prefix
|
|
16
|
+
* such as `example.com/guides`.
|
|
17
|
+
*/
|
|
18
|
+
readonly allowedDomains?: readonly string[]
|
|
19
|
+
/** Never these, in the same syntax; they win over `allowedDomains`. */
|
|
20
|
+
readonly blockedDomains?: readonly string[]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** The tool names Sixb gives the Agent for the web, offered unless `agent.web` is `false`. */
|
|
24
|
+
export const AGENT_WEB_TOOL_NAMES = ["web_search", "web_fetch"] as const
|
|
25
|
+
|
|
26
|
+
const MAX_DOMAINS = 1_200
|
|
27
|
+
const MAX_RULE_CHARACTERS = 4_096
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Check `agent.web` and return it with each domain rule in its canonical form: lowercase, without
|
|
31
|
+
* a trailing dot or slash, duplicates dropped.
|
|
32
|
+
*/
|
|
33
|
+
export function resolveAgentWebOptions(value: unknown): false | AgentWebOptions | undefined {
|
|
34
|
+
if (value === undefined || value === false) return value
|
|
35
|
+
|
|
36
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
37
|
+
throw new RuntimeError(
|
|
38
|
+
"[Sixb] agent.web must be false, or { allowedDomains?, blockedDomains? }."
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
for (const key of Object.keys(value)) {
|
|
43
|
+
if (key !== "allowedDomains" && key !== "blockedDomains") {
|
|
44
|
+
throw new RuntimeError(
|
|
45
|
+
`[Sixb] agent.web has an unknown option '${key}': use allowedDomains or blockedDomains.`
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const options = value as Record<string, unknown>
|
|
51
|
+
const allowedDomains = canonicalRules(options.allowedDomains, "allowedDomains")
|
|
52
|
+
const blockedDomains = canonicalRules(options.blockedDomains, "blockedDomains")
|
|
53
|
+
|
|
54
|
+
return Object.freeze({
|
|
55
|
+
...(allowedDomains ? { allowedDomains } : {}),
|
|
56
|
+
...(blockedDomains ? { blockedDomains } : {}),
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Refuse a language model whose provider runs a tool under a name the Agent's web tools take: a
|
|
62
|
+
* request would declare the name twice. Checked unless `agent.web` is `false`; `web_search` only
|
|
63
|
+
* when the project has a search backend, since the Agent offers none without one.
|
|
64
|
+
*/
|
|
65
|
+
export function assertNoProviderWebTools(models: ModelCatalog | undefined): void {
|
|
66
|
+
const offered: readonly string[] = models?.webSearch ? AGENT_WEB_TOOL_NAMES : ["web_fetch"]
|
|
67
|
+
|
|
68
|
+
for (const { provider, modelId, model } of models?.language?.list() ?? []) {
|
|
69
|
+
const name = model.providerToolNames?.find((tool) => offered.includes(tool))
|
|
70
|
+
if (name === undefined) continue
|
|
71
|
+
|
|
72
|
+
throw new RuntimeError(
|
|
73
|
+
`[Sixb] Language model '${provider}/${modelId}' declares the provider tool '${name}', a name Sixb gives the Agent's own web tool. Remove it from providerTools, or set agent.web: false to keep the provider's.`
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** What the domain lists say of a URL. */
|
|
79
|
+
export interface WebDomainPolicy {
|
|
80
|
+
/** Why the lists refuse the URL, or undefined when they allow it. */
|
|
81
|
+
refuses(url: URL): "blocked" | "not-allowed" | undefined
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Compile domain lists `resolveAgentWebOptions` already checked. */
|
|
85
|
+
export function webDomainPolicy(options: AgentWebOptions): WebDomainPolicy {
|
|
86
|
+
const allowed = options.allowedDomains?.map((rule) => parseRule(rule, "allowedDomains"))
|
|
87
|
+
const blocked = options.blockedDomains?.map((rule) => parseRule(rule, "blockedDomains"))
|
|
88
|
+
|
|
89
|
+
return {
|
|
90
|
+
refuses(url) {
|
|
91
|
+
if (blocked?.some((rule) => matchesRule(url, rule))) return "blocked"
|
|
92
|
+
if (allowed && !allowed.some((rule) => matchesRule(url, rule))) return "not-allowed"
|
|
93
|
+
return undefined
|
|
94
|
+
},
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* A run's web search, through the project's web search model: admitted, bounded and recorded with
|
|
100
|
+
* the run's other model calls.
|
|
101
|
+
*/
|
|
102
|
+
export function bindAgentWebSearch(
|
|
103
|
+
definitions: {
|
|
104
|
+
readonly agent: Pick<AgentDefinitions, "web">
|
|
105
|
+
readonly models?: Pick<ModelCatalog, "webSearch">
|
|
106
|
+
},
|
|
107
|
+
execution: {
|
|
108
|
+
/** Aborts once the run ends or is cancelled. */
|
|
109
|
+
readonly signal: AbortSignal
|
|
110
|
+
readonly accounting: () => Promise<AiModelCallRecorder>
|
|
111
|
+
}
|
|
112
|
+
): AgentRunModels["webSearch"] {
|
|
113
|
+
const bound = bindWebSearchModels(definitions.models?.webSearch, {
|
|
114
|
+
signal: (signal) => (signal ? AbortSignal.any([execution.signal, signal]) : execution.signal),
|
|
115
|
+
accounting: execution.accounting,
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
return async (request, signal) => {
|
|
119
|
+
// A runner asks for a search through its session: the project's options decide, not its plan.
|
|
120
|
+
if (definitions.agent.web === false) {
|
|
121
|
+
throw createSixbError(
|
|
122
|
+
"agent.execution_failed",
|
|
123
|
+
"[Sixb] The Agent's web tools are off: agent.web is false."
|
|
124
|
+
)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (!bound) {
|
|
128
|
+
throw createSixbError(
|
|
129
|
+
"agent.execution_failed",
|
|
130
|
+
"[Sixb] The project has no web search model: set models.webSearch, or use a language model that offers one."
|
|
131
|
+
)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return bound.default.model.search({ ...request, signal })
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
interface DomainRule {
|
|
139
|
+
readonly hostname: string
|
|
140
|
+
readonly wildcard: boolean
|
|
141
|
+
readonly pathPrefix?: string
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function canonicalRules(value: unknown, field: string): readonly string[] | undefined {
|
|
145
|
+
if (value === undefined) return undefined
|
|
146
|
+
|
|
147
|
+
if (!Array.isArray(value) || value.length < 1 || value.length > MAX_DOMAINS) {
|
|
148
|
+
throw new RuntimeError(`[Sixb] agent.web.${field} must list from 1 to ${MAX_DOMAINS} domains.`)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const rules = new Set<string>()
|
|
152
|
+
for (const entry of value) rules.add(canonicalRule(parseRule(entry, field)))
|
|
153
|
+
|
|
154
|
+
return Object.freeze([...rules])
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function parseRule(value: unknown, field: string): DomainRule {
|
|
158
|
+
if (typeof value !== "string") throw invalidRule(field, value)
|
|
159
|
+
|
|
160
|
+
const trimmed = value.trim()
|
|
161
|
+
if (!trimmed || trimmed.length > MAX_RULE_CHARACTERS || /[\\?#]/.test(trimmed)) {
|
|
162
|
+
throw invalidRule(field, value)
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const wildcard = trimmed.startsWith("*.")
|
|
166
|
+
const filter = wildcard ? trimmed.slice(2) : trimmed
|
|
167
|
+
const authority = filter.split("/", 1)[0] ?? ""
|
|
168
|
+
if (!authority || /[*:@]/.test(authority)) throw invalidRule(field, value)
|
|
169
|
+
|
|
170
|
+
let parsed: URL
|
|
171
|
+
try {
|
|
172
|
+
parsed = new URL(`https://${filter}`)
|
|
173
|
+
} catch {
|
|
174
|
+
throw invalidRule(field, value)
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const hostname = canonicalHostname(parsed.hostname)
|
|
178
|
+
if (!isValidHostname(hostname)) throw invalidRule(field, value)
|
|
179
|
+
|
|
180
|
+
const pathPrefix = parsed.pathname.replace(/\/+$/, "")
|
|
181
|
+
return { hostname, wildcard, ...(pathPrefix ? { pathPrefix } : {}) }
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function canonicalRule(rule: DomainRule): string {
|
|
185
|
+
return `${rule.wildcard ? "*." : ""}${rule.hostname}${rule.pathPrefix ?? ""}`
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function matchesRule(url: URL, rule: DomainRule): boolean {
|
|
189
|
+
const hostname = canonicalHostname(url.hostname)
|
|
190
|
+
const hostnameMatches = rule.wildcard
|
|
191
|
+
? hostname !== rule.hostname && hostname.endsWith(`.${rule.hostname}`)
|
|
192
|
+
: hostname === rule.hostname
|
|
193
|
+
if (!hostnameMatches) return false
|
|
194
|
+
|
|
195
|
+
if (!rule.pathPrefix) return true
|
|
196
|
+
return url.pathname === rule.pathPrefix || url.pathname.startsWith(`${rule.pathPrefix}/`)
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function canonicalHostname(value: string): string {
|
|
200
|
+
return value.toLowerCase().replace(/\.$/, "")
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function isValidHostname(hostname: string): boolean {
|
|
204
|
+
if (!hostname || hostname.length > 253) return false
|
|
205
|
+
|
|
206
|
+
return hostname
|
|
207
|
+
.split(".")
|
|
208
|
+
.every(
|
|
209
|
+
(label) =>
|
|
210
|
+
label.length >= 1 && label.length <= 63 && /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/.test(label)
|
|
211
|
+
)
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function invalidRule(field: string, value: unknown): RuntimeError {
|
|
215
|
+
return new RuntimeError(
|
|
216
|
+
`[Sixb] agent.web.${field} has an invalid entry ${JSON.stringify(value)}: write a domain such as 'example.com', '*.example.com' or 'example.com/docs', without a scheme, port, query or credentials.`
|
|
217
|
+
)
|
|
218
|
+
}
|
|
@@ -53,8 +53,9 @@ export function resolveRoleGrants(role: RoleDefinition, universe: GrantUniverse)
|
|
|
53
53
|
* Resolve a role's conditional view grants once at startup, from their validated conditions.
|
|
54
54
|
*
|
|
55
55
|
* A condition applies to the type its grant names and to each subtype, as a view grant does.
|
|
56
|
-
* Several conditions on one type
|
|
57
|
-
*
|
|
56
|
+
* Several conditions on one type stay apart: the role shows what any of them matches, and each
|
|
57
|
+
* keeps the index storage prepared for it. A type the role also views without a condition drops
|
|
58
|
+
* them: the role shows every object of it.
|
|
58
59
|
*/
|
|
59
60
|
export function resolveRoleViewConditions(
|
|
60
61
|
conditions: readonly {
|
|
@@ -63,7 +64,7 @@ export function resolveRoleViewConditions(
|
|
|
63
64
|
}[],
|
|
64
65
|
grants: GrantIndex,
|
|
65
66
|
universe: GrantUniverse
|
|
66
|
-
): ReadonlyMap<string, ObjectQueryPredicate> {
|
|
67
|
+
): ReadonlyMap<string, readonly ObjectQueryPredicate[]> {
|
|
67
68
|
const byType = new Map<string, ObjectQueryPredicate[]>()
|
|
68
69
|
|
|
69
70
|
for (const condition of conditions) {
|
|
@@ -79,15 +80,12 @@ export function resolveRoleViewConditions(
|
|
|
79
80
|
}
|
|
80
81
|
|
|
81
82
|
return new Map(
|
|
82
|
-
[...byType].map(
|
|
83
|
+
[...byType].map(
|
|
84
|
+
([objectTypeId, predicates]) => [objectTypeId, Object.freeze(predicates)] as const
|
|
85
|
+
)
|
|
83
86
|
)
|
|
84
87
|
}
|
|
85
88
|
|
|
86
|
-
function anyOf(predicates: readonly ObjectQueryPredicate[]): ObjectQueryPredicate {
|
|
87
|
-
if (predicates.length === 1) return predicates[0]!
|
|
88
|
-
return Object.freeze({ op: "or", items: Object.freeze([...predicates]) })
|
|
89
|
-
}
|
|
90
|
-
|
|
91
89
|
function expandSelection(
|
|
92
90
|
selection: Selection,
|
|
93
91
|
universe: ReadonlySet<string>,
|
|
@@ -153,8 +151,8 @@ export function resolveAuthorizationContext(input: {
|
|
|
153
151
|
for (const markingId of role.clearances ?? []) {
|
|
154
152
|
clearances.add(markingId)
|
|
155
153
|
}
|
|
156
|
-
for (const [objectTypeId,
|
|
157
|
-
viewConditions.set(objectTypeId, [...(viewConditions.get(objectTypeId) ?? []),
|
|
154
|
+
for (const [objectTypeId, predicates] of role.viewConditions ?? []) {
|
|
155
|
+
viewConditions.set(objectTypeId, [...(viewConditions.get(objectTypeId) ?? []), ...predicates])
|
|
158
156
|
}
|
|
159
157
|
}
|
|
160
158
|
|
|
@@ -45,10 +45,10 @@ export interface ResolvedRole {
|
|
|
45
45
|
readonly grants: GrantIndex
|
|
46
46
|
/**
|
|
47
47
|
* What the role's `can.view(Type).where(...)` grants show, per concrete type: the type's
|
|
48
|
-
* conditions,
|
|
49
|
-
* `grants["view:object"]` and not here. Absent means none.
|
|
48
|
+
* conditions, any of which shows an object. A type the role also views without a condition is
|
|
49
|
+
* in `grants["view:object"]` and not here. Absent means none.
|
|
50
50
|
*/
|
|
51
|
-
readonly viewConditions?: ReadonlyMap<string, ObjectQueryPredicate>
|
|
51
|
+
readonly viewConditions?: ReadonlyMap<string, readonly ObjectQueryPredicate[]>
|
|
52
52
|
/** Marking ids this role clears. Absent means none. */
|
|
53
53
|
readonly clearances?: ReadonlySet<string>
|
|
54
54
|
}
|
|
@@ -61,8 +61,8 @@ export interface AuthorizationContext {
|
|
|
61
61
|
readonly roleIds: readonly string[]
|
|
62
62
|
readonly grants: GrantIndex
|
|
63
63
|
/**
|
|
64
|
-
* The object types the principal views only where a condition matches, with
|
|
65
|
-
*
|
|
64
|
+
* The object types the principal views only where a condition matches, with every condition
|
|
65
|
+
* its roles put on each. A type in `grants["view:object"]` is never here, so a check on that grant
|
|
66
66
|
* denies these types; only the authorized object reader reads them, through these conditions.
|
|
67
67
|
* Absent means none.
|
|
68
68
|
*/
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
type Storage,
|
|
11
11
|
} from "../../storage"
|
|
12
12
|
import { createConnectorCodedError, isConnectorStorageError, storageBoundaryError } from "../errors"
|
|
13
|
+
import type { ConnectorAccountCandidate } from "../types"
|
|
13
14
|
import {
|
|
14
15
|
assertConnectorAuthorizationActor,
|
|
15
16
|
type DefaultConnectorAuthorizationLifecycle,
|
|
@@ -326,19 +327,28 @@ export class ConnectorConnectionRunService {
|
|
|
326
327
|
)
|
|
327
328
|
}
|
|
328
329
|
|
|
330
|
+
return this.view(await this.connectRunAccount(run, account, input.replace === true))
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/** Fills the run's slot with one of its authorization's accounts and finishes the run. */
|
|
334
|
+
private async connectRunAccount(
|
|
335
|
+
run: ConnectorConnectionRunRecord,
|
|
336
|
+
account: ConnectorAccountCandidate,
|
|
337
|
+
replace: boolean
|
|
338
|
+
): Promise<ConnectorConnectionRunRecord> {
|
|
329
339
|
let selected: Awaited<ReturnType<ConnectorConnectionStorage["putConnectionFromRun"]>>
|
|
330
340
|
try {
|
|
331
341
|
selected = await this.connectionStorage.putConnectionFromRun({
|
|
332
342
|
id: `ccn_${randomUUID()}`,
|
|
333
343
|
projectId: this.projectId,
|
|
334
|
-
connectorId:
|
|
344
|
+
connectorId: run.connectorId,
|
|
335
345
|
runId: run.id,
|
|
336
346
|
account,
|
|
337
|
-
replace
|
|
347
|
+
replace,
|
|
338
348
|
})
|
|
339
349
|
} catch (error) {
|
|
340
350
|
if (isConnectorStorageError(error, "run_invalid")) {
|
|
341
|
-
const latest = await this.readRun(
|
|
351
|
+
const latest = await this.readRun(run.connectorId, run.id)
|
|
342
352
|
if (latest) await this.continueRunCleanup(latest)
|
|
343
353
|
throw createConnectorCodedError(
|
|
344
354
|
"connector.operation_conflict",
|
|
@@ -364,7 +374,7 @@ export class ConnectorConnectionRunService {
|
|
|
364
374
|
}
|
|
365
375
|
const cleanupCompleted = selected.revocationPendingAuthorizationId
|
|
366
376
|
? await this.continuePendingRevocation(
|
|
367
|
-
|
|
377
|
+
run.connectorId,
|
|
368
378
|
selected.revocationPendingAuthorizationId
|
|
369
379
|
)
|
|
370
380
|
: true
|
|
@@ -373,7 +383,26 @@ export class ConnectorConnectionRunService {
|
|
|
373
383
|
} else {
|
|
374
384
|
this.scheduleRunMaintenance(selected.run, CLEANUP_RETRY_DELAY_MS)
|
|
375
385
|
}
|
|
376
|
-
return
|
|
386
|
+
return selected.run
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* A grant with one account leaves the user nothing to choose. The run is already waiting, so any
|
|
391
|
+
* failure here falls back to the picker with the grant intact.
|
|
392
|
+
*/
|
|
393
|
+
private async connectOnlyAccount(
|
|
394
|
+
run: ConnectorConnectionRunRecord,
|
|
395
|
+
account: ConnectorAccountCandidate
|
|
396
|
+
): Promise<void> {
|
|
397
|
+
try {
|
|
398
|
+
await this.connectRunAccount(run, account, false)
|
|
399
|
+
} catch (error) {
|
|
400
|
+
if (isSixbError(error) && error.code === "connector.replacement_required") return
|
|
401
|
+
console.warn(
|
|
402
|
+
"[Sixb] Connecting the only connector account failed; the user can still select it.",
|
|
403
|
+
error
|
|
404
|
+
)
|
|
405
|
+
}
|
|
377
406
|
}
|
|
378
407
|
|
|
379
408
|
private async claimCallback(state: string, callbackBinding: string, redirectUri: string) {
|
|
@@ -440,6 +469,12 @@ export class ConnectorConnectionRunService {
|
|
|
440
469
|
authorization: ConnectorAuthorizationRecord
|
|
441
470
|
): Promise<ConnectorConnectionRunRecord> {
|
|
442
471
|
if (run.kind === "connect") {
|
|
472
|
+
if (authorization.accounts.length === 0) {
|
|
473
|
+
throw createConnectorCodedError(
|
|
474
|
+
"connector.not_found",
|
|
475
|
+
"This authorization does not give access to any account. Sign in with one that has access."
|
|
476
|
+
)
|
|
477
|
+
}
|
|
443
478
|
if (!authorization.selectionExpiresAt) {
|
|
444
479
|
throw createConnectorCodedError(
|
|
445
480
|
"internal.unexpected",
|
|
@@ -461,6 +496,8 @@ export class ConnectorConnectionRunService {
|
|
|
461
496
|
)
|
|
462
497
|
if (waiting) {
|
|
463
498
|
this.scheduleRunMaintenance(waiting, this.selectionTtlMs + 1)
|
|
499
|
+
const [account, ...others] = authorization.accounts
|
|
500
|
+
if (account && others.length === 0) await this.connectOnlyAccount(waiting, account)
|
|
464
501
|
return waiting
|
|
465
502
|
}
|
|
466
503
|
} else {
|
|
@@ -222,6 +222,8 @@ export function createDatasetsRuntime(
|
|
|
222
222
|
versionId: result.version.versionId,
|
|
223
223
|
createdAt: result.version.createdAt.toISOString(),
|
|
224
224
|
producer,
|
|
225
|
+
rowsChanged: result.version.rowsChanged,
|
|
226
|
+
lineageChanged: result.version.lineageChanged,
|
|
225
227
|
},
|
|
226
228
|
},
|
|
227
229
|
],
|