@sixb/core 0.1.20 → 0.1.22
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/commit-edits.d.ts +3 -1
- package/dist/actions/commit-edits.d.ts.map +1 -1
- package/dist/actions/execution.d.ts.map +1 -1
- package/dist/actions/index.js +71 -60
- package/dist/actions/index.js.map +1 -1
- package/dist/actions/read-facade.d.ts +9 -1
- package/dist/actions/read-facade.d.ts.map +1 -1
- package/dist/actions/request.d.ts +15 -1
- package/dist/actions/request.d.ts.map +1 -1
- package/dist/actions/run/context.d.ts +1 -0
- package/dist/actions/run/context.d.ts.map +1 -1
- package/dist/actions/run/execute.d.ts +2 -3
- package/dist/actions/run/execute.d.ts.map +1 -1
- package/dist/actions/run/executor.d.ts +3 -0
- package/dist/actions/run/executor.d.ts.map +1 -1
- package/dist/actions/run/normalize.d.ts +2 -1
- package/dist/actions/run/normalize.d.ts.map +1 -1
- package/dist/actions/run/signals.d.ts +1 -3
- package/dist/actions/run/signals.d.ts.map +1 -1
- package/dist/actions/run/types.d.ts +16 -1
- package/dist/actions/run/types.d.ts.map +1 -1
- package/dist/actions/run-authorization.d.ts +23 -0
- package/dist/actions/run-authorization.d.ts.map +1 -1
- package/dist/actions/types/context.d.ts +17 -1
- package/dist/actions/types/context.d.ts.map +1 -1
- package/dist/actions/validators.d.ts.map +1 -1
- package/dist/activity/connection.d.ts +62 -0
- package/dist/activity/connection.d.ts.map +1 -0
- package/dist/activity/device.d.ts +8 -0
- package/dist/activity/device.d.ts.map +1 -0
- package/dist/activity/execution.d.ts +48 -0
- package/dist/activity/execution.d.ts.map +1 -0
- package/dist/activity/service.d.ts +79 -0
- package/dist/activity/service.d.ts.map +1 -0
- package/dist/activity/shares.d.ts +24 -0
- package/dist/activity/shares.d.ts.map +1 -0
- package/dist/activity/timeline.d.ts +103 -0
- package/dist/activity/timeline.d.ts.map +1 -0
- package/dist/agents/accounting.d.ts +15 -0
- package/dist/agents/accounting.d.ts.map +1 -0
- package/dist/agents/adapters.d.ts.map +1 -1
- package/dist/agents/agent-mail.d.ts +9 -0
- package/dist/agents/agent-mail.d.ts.map +1 -0
- package/dist/agents/api-gateway.d.ts +5 -0
- package/dist/agents/api-gateway.d.ts.map +1 -1
- package/dist/agents/approval-continuation.d.ts +23 -0
- package/dist/agents/approval-continuation.d.ts.map +1 -0
- package/dist/agents/approval-executor.d.ts +56 -0
- package/dist/agents/approval-executor.d.ts.map +1 -0
- package/dist/agents/approval-outcome.d.ts +8 -0
- package/dist/agents/approval-outcome.d.ts.map +1 -0
- package/dist/agents/approvals.d.ts +210 -0
- package/dist/agents/approvals.d.ts.map +1 -0
- package/dist/agents/authority.d.ts +10 -0
- package/dist/agents/authority.d.ts.map +1 -1
- package/dist/agents/builders.d.ts.map +1 -1
- package/dist/agents/cancel.d.ts +23 -0
- package/dist/agents/cancel.d.ts.map +1 -0
- package/dist/agents/child-question.d.ts +18 -0
- package/dist/agents/child-question.d.ts.map +1 -0
- package/dist/agents/children.d.ts +99 -0
- package/dist/agents/children.d.ts.map +1 -0
- package/dist/agents/context/index.js +1 -1
- package/dist/agents/context-compaction.d.ts.map +1 -1
- package/dist/agents/errors.d.ts +13 -1
- package/dist/agents/errors.d.ts.map +1 -1
- package/dist/agents/execution.d.ts +180 -14
- package/dist/agents/execution.d.ts.map +1 -1
- package/dist/agents/fork.d.ts +16 -0
- package/dist/agents/fork.d.ts.map +1 -0
- package/dist/agents/ids.d.ts +7 -0
- package/dist/agents/ids.d.ts.map +1 -1
- package/dist/agents/index.d.ts +20 -8
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +170 -84
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/memory-execution.d.ts +57 -0
- package/dist/agents/memory-execution.d.ts.map +1 -0
- package/dist/agents/memory.d.ts +49 -0
- package/dist/agents/memory.d.ts.map +1 -0
- package/dist/agents/message.d.ts +50 -1
- package/dist/agents/message.d.ts.map +1 -1
- package/dist/agents/model-loop.d.ts +19 -0
- package/dist/agents/model-loop.d.ts.map +1 -1
- package/dist/agents/model-routing.d.ts +19 -0
- package/dist/agents/model-routing.d.ts.map +1 -0
- package/dist/agents/participants.d.ts +18 -0
- package/dist/agents/participants.d.ts.map +1 -0
- package/dist/agents/reference.d.ts.map +1 -1
- package/dist/agents/request.d.ts +36 -2
- package/dist/agents/request.d.ts.map +1 -1
- package/dist/agents/run-scope.d.ts +51 -0
- package/dist/agents/run-scope.d.ts.map +1 -0
- package/dist/agents/skills.d.ts.map +1 -1
- package/dist/agents/streams/index.d.ts +3 -2
- package/dist/agents/streams/index.d.ts.map +1 -1
- package/dist/agents/streams/index.js +8 -4
- package/dist/agents/streams/index.js.map +1 -1
- package/dist/agents/streams/internal.d.ts +1 -1
- package/dist/agents/streams/internal.d.ts.map +1 -1
- package/dist/agents/streams/internal.js +6 -4
- package/dist/agents/streams/internal.js.map +1 -1
- package/dist/agents/streams/protocol.d.ts +122 -3
- package/dist/agents/streams/protocol.d.ts.map +1 -1
- package/dist/agents/subagent-runs.d.ts +12 -0
- package/dist/agents/subagent-runs.d.ts.map +1 -0
- package/dist/agents/thread-access.d.ts +53 -0
- package/dist/agents/thread-access.d.ts.map +1 -0
- package/dist/agents/tool-definition.d.ts +5 -4
- package/dist/agents/tool-definition.d.ts.map +1 -1
- package/dist/agents/types.d.ts +31 -12
- package/dist/agents/types.d.ts.map +1 -1
- package/dist/agents/validation.d.ts +1 -1
- package/dist/agents/validation.d.ts.map +1 -1
- package/dist/artifacts/access.d.ts +52 -0
- package/dist/artifacts/access.d.ts.map +1 -0
- package/dist/artifacts/address.d.ts +48 -0
- package/dist/artifacts/address.d.ts.map +1 -0
- package/dist/artifacts/canvas.d.ts +92 -0
- package/dist/artifacts/canvas.d.ts.map +1 -0
- package/dist/artifacts/csv.d.ts +27 -0
- package/dist/artifacts/csv.d.ts.map +1 -0
- package/dist/artifacts/errors.d.ts +16 -0
- package/dist/artifacts/errors.d.ts.map +1 -0
- package/dist/artifacts/execution.d.ts +138 -0
- package/dist/artifacts/execution.d.ts.map +1 -0
- package/dist/artifacts/formula/check.d.ts +24 -0
- package/dist/artifacts/formula/check.d.ts.map +1 -0
- package/dist/artifacts/formula/evaluate.d.ts +32 -0
- package/dist/artifacts/formula/evaluate.d.ts.map +1 -0
- package/dist/artifacts/formula/index.d.ts +38 -0
- package/dist/artifacts/formula/index.d.ts.map +1 -0
- package/dist/artifacts/formula/parser.d.ts +67 -0
- package/dist/artifacts/formula/parser.d.ts.map +1 -0
- package/dist/artifacts/frames/assets.d.ts +30 -0
- package/dist/artifacts/frames/assets.d.ts.map +1 -0
- package/dist/artifacts/frames/entries.d.ts +19 -0
- package/dist/artifacts/frames/entries.d.ts.map +1 -0
- package/dist/artifacts/frames/grants.d.ts +37 -0
- package/dist/artifacts/frames/grants.d.ts.map +1 -0
- package/dist/artifacts/frames/index.d.ts +12 -0
- package/dist/artifacts/frames/index.d.ts.map +1 -0
- package/dist/artifacts/frames/index.js +1285 -0
- package/dist/artifacts/frames/index.js.map +16 -0
- package/dist/artifacts/frames/kit.d.ts +71 -0
- package/dist/artifacts/frames/kit.d.ts.map +1 -0
- package/dist/artifacts/frames/probe.d.ts +45 -0
- package/dist/artifacts/frames/probe.d.ts.map +1 -0
- package/dist/artifacts/frames/protocol.d.ts +167 -0
- package/dist/artifacts/frames/protocol.d.ts.map +1 -0
- package/dist/artifacts/frames/runtime.d.ts +31 -0
- package/dist/artifacts/frames/runtime.d.ts.map +1 -0
- package/dist/artifacts/html.d.ts +6 -0
- package/dist/artifacts/html.d.ts.map +1 -0
- package/dist/artifacts/ids.d.ts +5 -0
- package/dist/artifacts/ids.d.ts.map +1 -0
- package/dist/artifacts/index.d.ts +22 -0
- package/dist/artifacts/index.d.ts.map +1 -0
- package/dist/artifacts/index.js +247 -0
- package/dist/artifacts/index.js.map +10 -0
- package/dist/artifacts/kinds.d.ts +5 -0
- package/dist/artifacts/kinds.d.ts.map +1 -0
- package/dist/artifacts/limits.d.ts +58 -0
- package/dist/artifacts/limits.d.ts.map +1 -0
- package/dist/artifacts/live-sheet.d.ts +65 -0
- package/dist/artifacts/live-sheet.d.ts.map +1 -0
- package/dist/artifacts/outline.d.ts +70 -0
- package/dist/artifacts/outline.d.ts.map +1 -0
- package/dist/artifacts/publish/files.d.ts +15 -0
- package/dist/artifacts/publish/files.d.ts.map +1 -0
- package/dist/artifacts/publish/index.d.ts +7 -0
- package/dist/artifacts/publish/index.d.ts.map +1 -0
- package/dist/artifacts/publish/index.js +76 -0
- package/dist/{chunk-7n30ybym.js.map → artifacts/publish/index.js.map} +1 -1
- package/dist/artifacts/publish/publish.d.ts +84 -0
- package/dist/artifacts/publish/publish.d.ts.map +1 -0
- package/dist/artifacts/publish/queries.d.ts +33 -0
- package/dist/artifacts/publish/queries.d.ts.map +1 -0
- package/dist/artifacts/publish/references.d.ts +30 -0
- package/dist/artifacts/publish/references.d.ts.map +1 -0
- package/dist/artifacts/publish/validate/canvas.d.ts +18 -0
- package/dist/artifacts/publish/validate/canvas.d.ts.map +1 -0
- package/dist/artifacts/publish/validate/document.d.ts +17 -0
- package/dist/artifacts/publish/validate/document.d.ts.map +1 -0
- package/dist/artifacts/publish/validate/file.d.ts +8 -0
- package/dist/artifacts/publish/validate/file.d.ts.map +1 -0
- package/dist/artifacts/publish/validate/html.d.ts +20 -0
- package/dist/artifacts/publish/validate/html.d.ts.map +1 -0
- package/dist/artifacts/publish/validate/page.d.ts +15 -0
- package/dist/artifacts/publish/validate/page.d.ts.map +1 -0
- package/dist/artifacts/publish/validate/sheet.d.ts +23 -0
- package/dist/artifacts/publish/validate/sheet.d.ts.map +1 -0
- package/dist/artifacts/publish/validate/slides.d.ts +15 -0
- package/dist/artifacts/publish/validate/slides.d.ts.map +1 -0
- package/dist/artifacts/queries.d.ts +95 -0
- package/dist/artifacts/queries.d.ts.map +1 -0
- package/dist/artifacts/references.d.ts +12 -0
- package/dist/artifacts/references.d.ts.map +1 -0
- package/dist/artifacts/resolve.d.ts +47 -0
- package/dist/artifacts/resolve.d.ts.map +1 -0
- package/dist/artifacts/run-query.d.ts +26 -0
- package/dist/artifacts/run-query.d.ts.map +1 -0
- package/dist/artifacts/serialize-query.d.ts +12 -0
- package/dist/artifacts/serialize-query.d.ts.map +1 -0
- package/dist/artifacts/sheet-rules.d.ts +26 -0
- package/dist/artifacts/sheet-rules.d.ts.map +1 -0
- package/dist/artifacts/theme.d.ts +19 -0
- package/dist/artifacts/theme.d.ts.map +1 -0
- package/dist/artifacts/tones.d.ts +8 -0
- package/dist/artifacts/tones.d.ts.map +1 -0
- package/dist/artifacts/warnings.d.ts +11 -0
- package/dist/artifacts/warnings.d.ts.map +1 -0
- package/dist/artifacts/workbook.d.ts +135 -0
- package/dist/artifacts/workbook.d.ts.map +1 -0
- package/dist/auth/index.d.ts +1 -1
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +16 -13
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/member-events.d.ts +13 -0
- package/dist/auth/member-events.d.ts.map +1 -0
- package/dist/auth/profile.d.ts +11 -0
- package/dist/auth/profile.d.ts.map +1 -0
- package/dist/auth/runtime.d.ts +31 -3
- package/dist/auth/runtime.d.ts.map +1 -1
- package/dist/auth/strategy.d.ts +3 -1
- package/dist/auth/strategy.d.ts.map +1 -1
- package/dist/auth/strategy.js +7 -3
- package/dist/auth/strategy.js.map +1 -1
- package/dist/auth/types.d.ts +30 -1
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/authorization/decision.d.ts +17 -0
- package/dist/authorization/decision.d.ts.map +1 -1
- package/dist/authorization/event-visibility.d.ts +5 -1
- package/dist/authorization/event-visibility.d.ts.map +1 -1
- package/dist/authorization/grant-kinds.d.ts +2 -2
- package/dist/authorization/grant-kinds.d.ts.map +1 -1
- package/dist/authorization/index.d.ts +2 -2
- package/dist/authorization/index.d.ts.map +1 -1
- package/dist/authorization/index.js +14 -9
- package/dist/authorization/index.js.map +1 -1
- package/dist/authorization/resolve.d.ts +19 -1
- package/dist/authorization/resolve.d.ts.map +1 -1
- package/dist/authorization/run-visibility.d.ts +8 -1
- package/dist/authorization/run-visibility.d.ts.map +1 -1
- package/dist/authorization/types.d.ts +14 -0
- package/dist/authorization/types.d.ts.map +1 -1
- package/dist/blob-storage/browser.js +1 -1
- package/dist/blob-storage/index.js +2 -2
- package/dist/blob-storage/internal.d.ts +1 -1
- package/dist/blob-storage/internal.d.ts.map +1 -1
- package/dist/blob-storage/internal.js +11 -5
- package/dist/blob-storage/internal.js.map +1 -1
- package/dist/blob-storage/media-type.d.ts +12 -0
- package/dist/blob-storage/media-type.d.ts.map +1 -1
- package/dist/bootstrap/index.js +76 -66
- package/dist/bootstrap/index.js.map +2 -2
- package/dist/{chunk-tg2cw67r.js → chunk-02bzjgnt.js} +6 -6
- package/dist/{chunk-tg2cw67r.js.map → chunk-02bzjgnt.js.map} +1 -1
- package/dist/{chunk-mfs23znk.js → chunk-07kkp2e1.js} +1 -1
- package/dist/{chunk-6p49a5cq.js → chunk-098anw4f.js} +21 -19
- package/dist/chunk-098anw4f.js.map +12 -0
- package/dist/{chunk-fkgc1wt8.js → chunk-0phpbbvm.js} +3 -3
- package/dist/{chunk-ere85b8y.js → chunk-0xmt5p5y.js} +116 -27
- package/dist/chunk-0xmt5p5y.js.map +14 -0
- package/dist/{chunk-t6f3tdnr.js → chunk-16a9dmfy.js} +33 -2
- package/dist/{chunk-t6f3tdnr.js.map → chunk-16a9dmfy.js.map} +5 -4
- package/dist/{chunk-hkc3jct7.js → chunk-18sk89cg.js} +18 -10
- package/dist/chunk-18sk89cg.js.map +10 -0
- package/dist/{chunk-way52z4h.js → chunk-1t6k1avb.js} +6 -12
- package/dist/{chunk-way52z4h.js.map → chunk-1t6k1avb.js.map} +3 -4
- package/dist/chunk-2626mh4m.js +693 -0
- package/dist/chunk-2626mh4m.js.map +19 -0
- package/dist/{chunk-qczk96d9.js → chunk-2adz0h75.js} +13 -4
- package/dist/chunk-2adz0h75.js.map +11 -0
- package/dist/{chunk-3t2hgbgd.js → chunk-2fn60nvs.js} +40 -8
- package/dist/chunk-2fn60nvs.js.map +15 -0
- package/dist/{chunk-99nd4rc1.js → chunk-2gjj5dx3.js} +5 -4
- package/dist/{chunk-99nd4rc1.js.map → chunk-2gjj5dx3.js.map} +3 -3
- package/dist/chunk-3fqxbn31.js +107 -0
- package/dist/chunk-3fqxbn31.js.map +11 -0
- package/dist/{chunk-y0c4e6ex.js → chunk-3gbefjg5.js} +1 -1
- package/dist/{chunk-yzwja0mj.js → chunk-45ngkxkp.js} +52 -31
- package/dist/chunk-45ngkxkp.js.map +13 -0
- package/dist/{chunk-fa02jy15.js → chunk-48jezz3j.js} +1 -1
- package/dist/{chunk-ren4kg2j.js → chunk-4b26qwbg.js} +13 -13
- package/dist/{chunk-ren4kg2j.js.map → chunk-4b26qwbg.js.map} +1 -1
- package/dist/{chunk-9k93ah50.js → chunk-4f3ydv7t.js} +33 -69
- package/dist/chunk-4f3ydv7t.js.map +10 -0
- package/dist/chunk-4y26vs3v.js +97 -0
- package/dist/chunk-4y26vs3v.js.map +10 -0
- package/dist/{chunk-4as3wt1c.js → chunk-4ymrcdbm.js} +7 -3
- package/dist/chunk-4ymrcdbm.js.map +12 -0
- package/dist/{chunk-hcbyfxbe.js → chunk-5grk14e5.js} +76 -2
- package/dist/{chunk-hcbyfxbe.js.map → chunk-5grk14e5.js.map} +4 -3
- package/dist/chunk-5tfev0fv.js +676 -0
- package/dist/chunk-5tfev0fv.js.map +15 -0
- package/dist/chunk-65abf64x.js +13 -0
- package/dist/chunk-65abf64x.js.map +10 -0
- package/dist/{chunk-hvsb78a1.js → chunk-65pyhyas.js} +114 -107
- package/dist/chunk-65pyhyas.js.map +20 -0
- package/dist/{chunk-1sr8ryzk.js → chunk-661ezhks.js} +303 -6
- package/dist/chunk-661ezhks.js.map +11 -0
- package/dist/{chunk-z3y5kg1x.js → chunk-6eqsgvxk.js} +3 -3
- package/dist/{chunk-z3y5kg1x.js.map → chunk-6eqsgvxk.js.map} +2 -2
- package/dist/{chunk-c85m1hyj.js → chunk-6n69k945.js} +2 -2
- package/dist/{chunk-xfs8x8m9.js → chunk-6p0pastb.js} +5 -5
- package/dist/{chunk-rrzt8jdy.js → chunk-6rrtzea3.js} +116 -110
- package/dist/chunk-6rrtzea3.js.map +14 -0
- package/dist/{chunk-t7x8dmn0.js → chunk-6y0mkhex.js} +3 -3
- package/dist/{chunk-es1gxsbf.js → chunk-73v685wb.js} +14 -16
- package/dist/chunk-73v685wb.js.map +12 -0
- package/dist/{chunk-6c6sn0bh.js → chunk-7gr4j2eq.js} +7930 -5973
- package/dist/chunk-7gr4j2eq.js.map +120 -0
- package/dist/{chunk-hjzdd750.js → chunk-7mc2wkre.js} +391 -91
- package/dist/chunk-7mc2wkre.js.map +50 -0
- package/dist/chunk-7z5p905k.js +1660 -0
- package/dist/chunk-7z5p905k.js.map +22 -0
- package/dist/{chunk-3zxk45er.js → chunk-8ncg20rd.js} +3 -68
- package/dist/{chunk-3zxk45er.js.map → chunk-8ncg20rd.js.map} +4 -5
- package/dist/{chunk-yxd3nnqt.js → chunk-9mab3dvg.js} +26 -2
- package/dist/chunk-9mab3dvg.js.map +11 -0
- package/dist/chunk-9wr3yajk.js +42 -0
- package/dist/chunk-9wr3yajk.js.map +10 -0
- package/dist/chunk-a3faa34j.js +74 -0
- package/dist/chunk-a3faa34j.js.map +10 -0
- package/dist/chunk-az47zep4.js +41 -0
- package/dist/chunk-az47zep4.js.map +10 -0
- package/dist/{chunk-v9xd5wzd.js → chunk-bab05bhg.js} +1 -1
- package/dist/{chunk-5j58wjct.js → chunk-bktev1ds.js} +14 -11
- package/dist/{chunk-5j58wjct.js.map → chunk-bktev1ds.js.map} +3 -3
- package/dist/{chunk-b38szspf.js → chunk-c0vk1djt.js} +5 -3
- package/dist/chunk-c0vk1djt.js.map +11 -0
- package/dist/chunk-c69nj7se.js +3 -0
- package/dist/chunk-c69nj7se.js.map +9 -0
- package/dist/{chunk-0yh890a4.js → chunk-c844dkwd.js} +35 -7
- package/dist/{chunk-0yh890a4.js.map → chunk-c844dkwd.js.map} +3 -3
- package/dist/{chunk-d09tj99x.js → chunk-cdk3egjj.js} +24 -5
- package/dist/chunk-cdk3egjj.js.map +12 -0
- package/dist/chunk-cswhawa2.js +113 -0
- package/dist/chunk-cswhawa2.js.map +10 -0
- package/dist/{chunk-gc4ntf7d.js → chunk-cwdzcv37.js} +1 -1
- package/dist/chunk-d2m879s4.js +288 -0
- package/dist/chunk-d2m879s4.js.map +12 -0
- package/dist/chunk-d7vyc7k6.js +10 -0
- package/dist/chunk-d7vyc7k6.js.map +10 -0
- package/dist/{chunk-vyf9kfqf.js → chunk-dp0cdtj2.js} +2 -2
- package/dist/{chunk-6x0pqh32.js → chunk-e5wf5vz0.js} +3 -1
- package/dist/chunk-e5wf5vz0.js.map +10 -0
- package/dist/{chunk-bx9q3cwv.js → chunk-efmm01gj.js} +108 -1045
- package/dist/chunk-efmm01gj.js.map +18 -0
- package/dist/{chunk-tw03bsmb.js → chunk-eptrvnby.js} +224 -3
- package/dist/chunk-eptrvnby.js.map +12 -0
- package/dist/{chunk-n33z5bjw.js → chunk-ezne9wc9.js} +1762 -502
- package/dist/chunk-ezne9wc9.js.map +71 -0
- package/dist/chunk-fe8zwt8b.js +688 -0
- package/dist/chunk-fe8zwt8b.js.map +19 -0
- package/dist/chunk-ff5xkv0p.js +211 -0
- package/dist/chunk-ff5xkv0p.js.map +10 -0
- package/dist/{chunk-br3k6qbf.js → chunk-fm62y49k.js} +1 -1
- package/dist/{chunk-nq6gpjt7.js → chunk-fntqb7qy.js} +30 -4
- package/dist/{chunk-nq6gpjt7.js.map → chunk-fntqb7qy.js.map} +5 -5
- package/dist/{chunk-1zq2p6g0.js → chunk-fp2kq35z.js} +26 -10
- package/dist/{chunk-1zq2p6g0.js.map → chunk-fp2kq35z.js.map} +5 -5
- package/dist/chunk-g5bvzyyr.js +32 -0
- package/dist/chunk-g5bvzyyr.js.map +10 -0
- package/dist/{chunk-9ybhtmg4.js → chunk-g663fahq.js} +2 -2
- package/dist/{chunk-k6q3n2sc.js → chunk-gvj5cd3b.js} +29 -13
- package/dist/chunk-gvj5cd3b.js.map +12 -0
- package/dist/{chunk-yevzdx4y.js → chunk-h33shhq6.js} +10 -12
- package/dist/{chunk-yevzdx4y.js.map → chunk-h33shhq6.js.map} +3 -4
- package/dist/{chunk-vpq4shxz.js → chunk-h3pbv7n8.js} +1771 -36
- package/dist/chunk-h3pbv7n8.js.map +48 -0
- package/dist/chunk-hke9aeen.js +9 -0
- package/dist/chunk-hke9aeen.js.map +10 -0
- package/dist/chunk-hn2r7z41.js.map +1 -1
- package/dist/{chunk-pbcbn83d.js → chunk-hqsp2sx4.js} +54 -8
- package/dist/chunk-hqsp2sx4.js.map +14 -0
- package/dist/{chunk-9w055r5b.js → chunk-hwarjrgf.js} +1 -1
- package/dist/{chunk-9dmt152s.js → chunk-hyesv9dv.js} +2 -2
- package/dist/chunk-hz5d43gn.js +45 -0
- package/dist/chunk-hz5d43gn.js.map +10 -0
- package/dist/{chunk-91mg3nj9.js → chunk-j936th07.js} +86 -41
- package/dist/chunk-j936th07.js.map +12 -0
- package/dist/chunk-jcfw4h7m.js +9 -0
- package/dist/chunk-jcfw4h7m.js.map +10 -0
- package/dist/chunk-kcqpk9w1.js +75 -0
- package/dist/chunk-kcqpk9w1.js.map +10 -0
- package/dist/{chunk-x6m907x7.js → chunk-m2nevja0.js} +6 -7
- package/dist/{chunk-x6m907x7.js.map → chunk-m2nevja0.js.map} +3 -3
- package/dist/{chunk-x9v4cx1d.js → chunk-m36fw8ft.js} +1 -1
- package/dist/{chunk-a40ad1ft.js → chunk-mbsbxarb.js} +1 -1
- package/dist/chunk-mzx71snp.js +129 -0
- package/dist/chunk-mzx71snp.js.map +10 -0
- package/dist/{chunk-6aawea28.js → chunk-n8q5j6y5.js} +1 -1
- package/dist/{chunk-dk8tkk5f.js → chunk-n9zpx9c6.js} +4 -4
- package/dist/{chunk-7t429e3f.js → chunk-npcr0228.js} +1 -1
- package/dist/chunk-nydf3dbe.js +663 -0
- package/dist/chunk-nydf3dbe.js.map +13 -0
- package/dist/chunk-pdt5cw8z.js +233 -0
- package/dist/chunk-pdt5cw8z.js.map +11 -0
- package/dist/{chunk-rj69qcrd.js → chunk-pgrf64hp.js} +55 -7
- package/dist/chunk-pgrf64hp.js.map +12 -0
- package/dist/{chunk-z4m0yz8c.js → chunk-q4pmvkg0.js} +1 -1
- package/dist/chunk-qhqgp4jf.js +1418 -0
- package/dist/chunk-qhqgp4jf.js.map +22 -0
- package/dist/chunk-qx00vjrj.js +144 -0
- package/dist/chunk-qx00vjrj.js.map +13 -0
- package/dist/{chunk-5e43w60z.js → chunk-r6szek0x.js} +184 -7
- package/dist/chunk-r6szek0x.js.map +10 -0
- package/dist/{chunk-v4jbb3rs.js → chunk-rap5w0x0.js} +156 -2
- package/dist/chunk-rap5w0x0.js.map +10 -0
- package/dist/{chunk-pfp1txq2.js → chunk-sgx82nnt.js} +5 -31
- package/dist/{chunk-pfp1txq2.js.map → chunk-sgx82nnt.js.map} +3 -4
- package/dist/{chunk-bkpke1sg.js → chunk-t5608tkq.js} +3 -1
- package/dist/{chunk-bkpke1sg.js.map → chunk-t5608tkq.js.map} +3 -3
- package/dist/{chunk-29yx306f.js → chunk-tdxfsg1c.js} +507 -265
- package/dist/chunk-tdxfsg1c.js.map +23 -0
- package/dist/chunk-vabga7fk.js +176 -0
- package/dist/chunk-vabga7fk.js.map +12 -0
- package/dist/{chunk-gsjm1wms.js → chunk-vhbw5sqm.js} +33 -3
- package/dist/chunk-vhbw5sqm.js.map +10 -0
- package/dist/{chunk-tpn40322.js → chunk-vpgwq5nf.js} +104 -17
- package/dist/chunk-vpgwq5nf.js.map +21 -0
- package/dist/{chunk-0rbyz4qy.js → chunk-vyt322b6.js} +586 -171
- package/dist/{chunk-0rbyz4qy.js.map → chunk-vyt322b6.js.map} +12 -9
- package/dist/chunk-waqk73p1.js +2380 -0
- package/dist/chunk-waqk73p1.js.map +23 -0
- package/dist/{chunk-jhm3zsa7.js → chunk-wkv3h3q7.js} +64 -2
- package/dist/{chunk-jhm3zsa7.js.map → chunk-wkv3h3q7.js.map} +3 -3
- package/dist/chunk-wsc1brye.js +27 -0
- package/dist/chunk-wsc1brye.js.map +10 -0
- package/dist/chunk-x0v3jd47.js +124 -0
- package/dist/chunk-x0v3jd47.js.map +10 -0
- package/dist/{chunk-96yw3pwd.js → chunk-y7dbmaqh.js} +28 -2
- package/dist/chunk-y7dbmaqh.js.map +10 -0
- package/dist/{chunk-d0bqz29d.js → chunk-yc9ners4.js} +124 -19
- package/dist/{chunk-d0bqz29d.js.map → chunk-yc9ners4.js.map} +8 -8
- package/dist/{chunk-8mx7qw3y.js → chunk-zbc929zg.js} +29 -5
- package/dist/chunk-zbc929zg.js.map +13 -0
- package/dist/chunk-zrvhsq7f.js +37 -0
- package/dist/chunk-zrvhsq7f.js.map +10 -0
- package/dist/datasets/builders.d.ts +15 -2
- package/dist/datasets/builders.d.ts.map +1 -1
- package/dist/datasets/column-index.d.ts +7 -0
- package/dist/datasets/column-index.d.ts.map +1 -0
- package/dist/datasets/execution.d.ts +3 -2
- package/dist/datasets/execution.d.ts.map +1 -1
- package/dist/datasets/write.js +8 -8
- package/dist/error-reporting/internal.js +4 -4
- package/dist/errors/catalog.d.ts +26 -0
- package/dist/errors/catalog.d.ts.map +1 -1
- package/dist/errors/internal.d.ts +1 -0
- package/dist/errors/internal.d.ts.map +1 -1
- package/dist/errors/internal.js +7 -4
- package/dist/errors/internal.js.map +1 -1
- package/dist/events/definitions.d.ts +7 -0
- package/dist/events/definitions.d.ts.map +1 -1
- package/dist/events/execution.d.ts +12 -2
- package/dist/events/execution.d.ts.map +1 -1
- package/dist/events/index.d.ts +2 -3
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +9 -11
- package/dist/events/index.js.map +1 -1
- package/dist/events/scope.d.ts.map +1 -1
- package/dist/events/scope.js +1 -1
- package/dist/events/selectors/builder.d.ts +12 -1
- package/dist/events/selectors/builder.d.ts.map +1 -1
- package/dist/events/selectors/index.d.ts +2 -2
- package/dist/events/selectors/index.d.ts.map +1 -1
- package/dist/events/selectors/index.js +2 -2
- package/dist/events/selectors/types.d.ts +19 -3
- package/dist/events/selectors/types.d.ts.map +1 -1
- package/dist/events/service.d.ts +17 -2
- package/dist/events/service.d.ts.map +1 -1
- package/dist/events/types/index.d.ts +3 -1
- package/dist/events/types/index.d.ts.map +1 -1
- package/dist/events/types/users.d.ts +63 -0
- package/dist/events/types/users.d.ts.map +1 -0
- package/dist/events/view-conditions.d.ts +34 -0
- package/dist/events/view-conditions.d.ts.map +1 -0
- package/dist/execution/agent.d.ts +15 -0
- package/dist/execution/agent.d.ts.map +1 -1
- package/dist/execution/agent.js +72 -59
- package/dist/execution/agent.js.map +1 -1
- package/dist/execution/authorization.d.ts.map +1 -1
- package/dist/execution/authorized-object-reader.d.ts +102 -12
- package/dist/execution/authorized-object-reader.d.ts.map +1 -1
- package/dist/execution/lineage.d.ts +7 -0
- package/dist/execution/lineage.d.ts.map +1 -0
- package/dist/execution/object-reader-clearance.d.ts +41 -0
- package/dist/execution/object-reader-clearance.d.ts.map +1 -0
- package/dist/execution/object-reader-ontology.d.ts +12 -0
- package/dist/execution/object-reader-ontology.d.ts.map +1 -0
- package/dist/execution/object-reader-security.d.ts +66 -0
- package/dist/execution/object-reader-security.d.ts.map +1 -0
- package/dist/execution/object-reader-users.d.ts +20 -0
- package/dist/execution/object-reader-users.d.ts.map +1 -0
- package/dist/execution/preparation.d.ts +23 -0
- package/dist/execution/preparation.d.ts.map +1 -0
- package/dist/execution/primitive.js +70 -59
- package/dist/execution/primitive.js.map +1 -1
- package/dist/execution/request.d.ts +2 -1
- package/dist/execution/request.d.ts.map +1 -1
- package/dist/execution/request.js +72 -57
- package/dist/execution/request.js.map +3 -3
- package/dist/execution/unique-lookup.d.ts +14 -0
- package/dist/execution/unique-lookup.d.ts.map +1 -0
- package/dist/execution/visible-objects.d.ts +12 -0
- package/dist/execution/visible-objects.d.ts.map +1 -0
- package/dist/http/api-routes.d.ts +17 -0
- package/dist/http/api-routes.d.ts.map +1 -1
- package/dist/http/index.js +1 -1
- package/dist/index.d.ts +49 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +168 -142
- package/dist/index.js.map +1 -1
- package/dist/lake-storage/in-memory.d.ts +1 -0
- package/dist/lake-storage/in-memory.d.ts.map +1 -1
- package/dist/lake-storage/index.d.ts +6 -3
- package/dist/lake-storage/index.d.ts.map +1 -1
- package/dist/lake-storage/index.js +21 -13
- package/dist/lake-storage/index.js.map +1 -1
- package/dist/lake-storage/lineage.d.ts +94 -0
- package/dist/lake-storage/lineage.d.ts.map +1 -0
- package/dist/lake-storage/sql-transforms.d.ts +45 -0
- package/dist/lake-storage/sql-transforms.d.ts.map +1 -1
- package/dist/lake-storage/types.d.ts +55 -1
- package/dist/lake-storage/types.d.ts.map +1 -1
- package/dist/lake-storage/version-inputs.d.ts +14 -3
- package/dist/lake-storage/version-inputs.d.ts.map +1 -1
- package/dist/maintenance/ontology-maintenance.d.ts.map +1 -1
- package/dist/materialization/errors.d.ts +25 -0
- package/dist/materialization/errors.d.ts.map +1 -1
- package/dist/materialization/event-envelopes.d.ts +5 -0
- package/dist/materialization/event-envelopes.d.ts.map +1 -1
- package/dist/materialization/index.d.ts +1 -1
- package/dist/materialization/index.d.ts.map +1 -1
- package/dist/materialization/index.js +14 -8
- package/dist/materialization/index.js.map +1 -1
- package/dist/materialization/model.d.ts +20 -2
- package/dist/materialization/model.d.ts.map +1 -1
- package/dist/materializer/edits/commit.d.ts.map +1 -1
- package/dist/materializer/edits/load-state.d.ts +5 -1
- package/dist/materializer/edits/load-state.d.ts.map +1 -1
- package/dist/materializer/edits/plan.d.ts.map +1 -1
- package/dist/materializer/edits/unique-values.d.ts +47 -0
- package/dist/materializer/edits/unique-values.d.ts.map +1 -0
- package/dist/materializer/edits/working-state.d.ts +6 -1
- package/dist/materializer/edits/working-state.d.ts.map +1 -1
- package/dist/materializer/execution/work-records.d.ts +7 -1
- package/dist/materializer/execution/work-records.d.ts.map +1 -1
- package/dist/materializer/index.js +51 -46
- package/dist/materializer/index.js.map +1 -1
- package/dist/materializer/projections/replacement-plan.d.ts.map +1 -1
- package/dist/materializer/projections/source-materialization.d.ts +1 -0
- package/dist/materializer/projections/source-materialization.d.ts.map +1 -1
- package/dist/materializer/shared/normalize.d.ts.map +1 -1
- package/dist/materializer/shared/projection-run.d.ts +0 -1
- package/dist/materializer/shared/projection-run.d.ts.map +1 -1
- package/dist/materializer/telemetry/plan.d.ts.map +1 -1
- package/dist/models/audio/catalog.d.ts +13 -1
- package/dist/models/audio/catalog.d.ts.map +1 -1
- package/dist/models/audio/errors.d.ts +6 -1
- package/dist/models/audio/errors.d.ts.map +1 -1
- package/dist/models/audio/runtime.d.ts.map +1 -1
- package/dist/models/audio/speech.d.ts +8 -0
- package/dist/models/audio/speech.d.ts.map +1 -0
- package/dist/models/audio/types.d.ts +93 -0
- package/dist/models/audio/types.d.ts.map +1 -1
- package/dist/models/calls.d.ts +27 -0
- package/dist/models/calls.d.ts.map +1 -0
- package/dist/models/catalog-index.d.ts +7 -4
- package/dist/models/catalog-index.d.ts.map +1 -1
- package/dist/models/catalog.d.ts +55 -3
- package/dist/models/catalog.d.ts.map +1 -1
- package/dist/models/decision/runtime.d.ts +6 -1
- package/dist/models/decision/runtime.d.ts.map +1 -1
- package/dist/models/decision/validation.d.ts +4 -1
- package/dist/models/decision/validation.d.ts.map +1 -1
- package/dist/models/definitions.d.ts +23 -1
- package/dist/models/definitions.d.ts.map +1 -1
- package/dist/models/events.d.ts +12 -1
- package/dist/models/events.d.ts.map +1 -1
- package/dist/models/execution/binding.d.ts +3 -1
- package/dist/models/execution/binding.d.ts.map +1 -1
- package/dist/models/execution/index.d.ts +1 -0
- package/dist/models/execution/index.d.ts.map +1 -1
- package/dist/models/execution/index.js +50 -39
- package/dist/models/execution/index.js.map +1 -1
- package/dist/models/execution/model-call-accounting.d.ts.map +1 -1
- package/dist/models/execution/model-call-recorder.d.ts +3 -0
- package/dist/models/execution/model-call-recorder.d.ts.map +1 -1
- package/dist/models/execution/usage.d.ts.map +1 -1
- package/dist/models/execution.d.ts +4 -2
- package/dist/models/execution.d.ts.map +1 -1
- package/dist/models/generation-types.d.ts +8 -1
- package/dist/models/generation-types.d.ts.map +1 -1
- package/dist/models/image/catalog.d.ts +13 -0
- package/dist/models/image/catalog.d.ts.map +1 -0
- package/dist/models/image/errors.d.ts +8 -0
- package/dist/models/image/errors.d.ts.map +1 -0
- package/dist/models/image/runtime.d.ts +8 -0
- package/dist/models/image/runtime.d.ts.map +1 -0
- package/dist/models/image/types.d.ts +103 -0
- package/dist/models/image/types.d.ts.map +1 -0
- package/dist/models/index.d.ts +12 -8
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/index.js +17 -7
- package/dist/models/index.js.map +1 -1
- package/dist/models/input-file.d.ts +9 -0
- package/dist/models/input-file.d.ts.map +1 -0
- package/dist/models/language-model.d.ts +13 -0
- package/dist/models/language-model.d.ts.map +1 -1
- package/dist/models/pricing.d.ts +25 -10
- package/dist/models/pricing.d.ts.map +1 -1
- package/dist/models/rate-card.d.ts +44 -6
- package/dist/models/rate-card.d.ts.map +1 -1
- package/dist/objects/clearance-redaction.d.ts +27 -0
- package/dist/objects/clearance-redaction.d.ts.map +1 -0
- package/dist/objects/conditional-writes.d.ts +37 -0
- package/dist/objects/conditional-writes.d.ts.map +1 -0
- package/dist/objects/execution.d.ts +2 -0
- package/dist/objects/execution.d.ts.map +1 -1
- package/dist/objects/index.d.ts +1 -0
- package/dist/objects/index.d.ts.map +1 -1
- package/dist/objects/index.js +77 -60
- package/dist/objects/index.js.map +1 -1
- package/dist/objects/link/authorization.d.ts +11 -5
- package/dist/objects/link/authorization.d.ts.map +1 -1
- package/dist/objects/link/endpoints.d.ts +21 -2
- package/dist/objects/link/endpoints.d.ts.map +1 -1
- package/dist/objects/link/remove.d.ts.map +1 -1
- package/dist/objects/link/upsert-batch.d.ts.map +1 -1
- package/dist/objects/link/upsert.d.ts.map +1 -1
- package/dist/objects/materializer-adapter.d.ts +13 -4
- package/dist/objects/materializer-adapter.d.ts.map +1 -1
- package/dist/objects/object/delete.d.ts +3 -0
- package/dist/objects/object/delete.d.ts.map +1 -1
- package/dist/objects/object/upsert-batch.d.ts.map +1 -1
- package/dist/objects/object/upsert.d.ts.map +1 -1
- package/dist/objects/property-clearance.d.ts +47 -24
- package/dist/objects/property-clearance.d.ts.map +1 -1
- package/dist/objects/query/clearance-admission.d.ts +10 -0
- package/dist/objects/query/clearance-admission.d.ts.map +1 -0
- package/dist/objects/query/current-user.d.ts +17 -0
- package/dist/objects/query/current-user.d.ts.map +1 -0
- package/dist/objects/query/executor.d.ts +14 -0
- package/dist/objects/query/executor.d.ts.map +1 -1
- package/dist/objects/query/index.d.ts +2 -2
- package/dist/objects/query/index.d.ts.map +1 -1
- package/dist/objects/query/index.js +55 -49
- package/dist/objects/query/index.js.map +1 -1
- package/dist/objects/query/ir.d.ts +19 -1
- package/dist/objects/query/ir.d.ts.map +1 -1
- package/dist/objects/query/link-query-clearance.d.ts +21 -0
- package/dist/objects/query/link-query-clearance.d.ts.map +1 -0
- package/dist/objects/query/matches-predicate.d.ts +9 -0
- package/dist/objects/query/matches-predicate.d.ts.map +1 -0
- package/dist/objects/query/normalize.d.ts.map +1 -1
- package/dist/objects/query/user-expansions.d.ts +27 -0
- package/dist/objects/query/user-expansions.d.ts.map +1 -0
- package/dist/objects/query/validate.d.ts.map +1 -1
- package/dist/objects/runtime-batch.d.ts +3 -1
- package/dist/objects/runtime-batch.d.ts.map +1 -1
- package/dist/objects/sdk/object-set.d.ts.map +1 -1
- package/dist/objects/sdk/query-executor.d.ts +6 -0
- package/dist/objects/sdk/query-executor.d.ts.map +1 -1
- package/dist/objects/serialize.d.ts +39 -0
- package/dist/objects/serialize.d.ts.map +1 -0
- package/dist/objects/unique-violation.d.ts +22 -0
- package/dist/objects/unique-violation.d.ts.map +1 -0
- package/dist/ontology/builders.d.ts +3 -1
- package/dist/ontology/builders.d.ts.map +1 -1
- package/dist/ontology/docs-markdown.d.ts +1 -1
- package/dist/ontology/docs-markdown.d.ts.map +1 -1
- package/dist/ontology/index.d.ts +2 -2
- package/dist/ontology/index.d.ts.map +1 -1
- package/dist/ontology/index.js +13 -9
- package/dist/ontology/index.js.map +1 -1
- package/dist/ontology/internal.js +9 -7
- package/dist/ontology/internal.js.map +3 -3
- package/dist/ontology/json-schema.d.ts.map +1 -1
- package/dist/ontology/primitives.d.ts +3 -0
- package/dist/ontology/primitives.d.ts.map +1 -1
- package/dist/ontology/registry.d.ts +6 -0
- package/dist/ontology/registry.d.ts.map +1 -1
- package/dist/ontology/types.d.ts +9 -0
- package/dist/ontology/types.d.ts.map +1 -1
- package/dist/ontology/unique-values.d.ts +26 -0
- package/dist/ontology/unique-values.d.ts.map +1 -0
- package/dist/ontology/user-ref.d.ts +23 -0
- package/dist/ontology/user-ref.d.ts.map +1 -1
- package/dist/ontology/validation/properties.d.ts.map +1 -1
- package/dist/ontology/validation/schema.d.ts.map +1 -1
- package/dist/pipelines/index.d.ts +2 -0
- package/dist/pipelines/index.d.ts.map +1 -1
- package/dist/pipelines/index.js +61 -46
- package/dist/pipelines/index.js.map +1 -1
- package/dist/pipelines/lineage.d.ts +17 -0
- package/dist/pipelines/lineage.d.ts.map +1 -0
- package/dist/projections/internal.d.ts +2 -2
- package/dist/projections/internal.js +42 -38
- package/dist/projections/internal.js.map +1 -1
- package/dist/projections/registry.d.ts +4 -0
- package/dist/projections/registry.d.ts.map +1 -1
- package/dist/projections/revision.d.ts +15 -0
- package/dist/projections/revision.d.ts.map +1 -1
- package/dist/projections/run-dispatch.d.ts.map +1 -1
- package/dist/projections/types.d.ts +2 -0
- package/dist/projections/types.d.ts.map +1 -1
- package/dist/query.d.ts +4 -2
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +2 -2
- package/dist/rules/execution.d.ts.map +1 -1
- package/dist/runtime/ai-cost.d.ts +2 -0
- package/dist/runtime/ai-cost.d.ts.map +1 -1
- package/dist/runtime/ai-usage.d.ts +7 -0
- package/dist/runtime/ai-usage.d.ts.map +1 -1
- package/dist/runtime/create.d.ts +3 -0
- package/dist/runtime/create.d.ts.map +1 -1
- package/dist/runtime/host.d.ts +6 -0
- package/dist/runtime/host.d.ts.map +1 -1
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/internal.d.ts +2 -0
- package/dist/runtime/internal.d.ts.map +1 -1
- package/dist/runtime/internal.js +58 -50
- package/dist/runtime/internal.js.map +1 -1
- package/dist/runtime/ontology-mutations.d.ts +2 -0
- package/dist/runtime/ontology-mutations.d.ts.map +1 -1
- package/dist/runtime/resolve-definitions.d.ts.map +1 -1
- package/dist/runtime/sixb.d.ts +10 -0
- package/dist/runtime/sixb.d.ts.map +1 -1
- package/dist/runtime/types.d.ts +66 -8
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/sandboxes/auth.d.ts +16 -0
- package/dist/sandboxes/auth.d.ts.map +1 -1
- package/dist/sandboxes/config.d.ts.map +1 -1
- package/dist/sandboxes/configuration.d.ts +26 -0
- package/dist/sandboxes/configuration.d.ts.map +1 -1
- package/dist/sandboxes/index.d.ts +1 -1
- package/dist/sandboxes/index.d.ts.map +1 -1
- package/dist/sandboxes/index.js +15 -13
- package/dist/sandboxes/index.js.map +1 -1
- package/dist/sandboxes/sandbox.d.ts +28 -5
- package/dist/sandboxes/sandbox.d.ts.map +1 -1
- package/dist/schedules/builders.d.ts.map +1 -1
- package/dist/schedules/index.js +3 -3
- package/dist/schedules/runtime.d.ts.map +1 -1
- package/dist/schedules/validation.d.ts.map +1 -1
- package/dist/security/applied-markings-contribution.d.ts +58 -0
- package/dist/security/applied-markings-contribution.d.ts.map +1 -0
- package/dist/security/applied-markings-host.d.ts +10 -0
- package/dist/security/applied-markings-host.d.ts.map +1 -0
- package/dist/security/applied-markings-snapshot.d.ts +67 -0
- package/dist/security/applied-markings-snapshot.d.ts.map +1 -0
- package/dist/security/applied-markings.d.ts +73 -0
- package/dist/security/applied-markings.d.ts.map +1 -0
- package/dist/security/dataset-version-markings.d.ts +47 -0
- package/dist/security/dataset-version-markings.d.ts.map +1 -0
- package/dist/security/grants.d.ts +13 -4
- package/dist/security/grants.d.ts.map +1 -1
- package/dist/security/index.d.ts +2 -1
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/internal.d.ts +15 -0
- package/dist/security/internal.d.ts.map +1 -0
- package/dist/security/internal.js +135 -0
- package/dist/security/internal.js.map +10 -0
- package/dist/security/marking-propagation.d.ts +62 -0
- package/dist/security/marking-propagation.d.ts.map +1 -0
- package/dist/security/marking-sets.d.ts +14 -0
- package/dist/security/marking-sets.d.ts.map +1 -0
- package/dist/security/markings.d.ts +6 -3
- package/dist/security/markings.d.ts.map +1 -1
- package/dist/security/pipeline-markings.d.ts +20 -0
- package/dist/security/pipeline-markings.d.ts.map +1 -0
- package/dist/security/project.d.ts +7 -0
- package/dist/security/project.d.ts.map +1 -0
- package/dist/security/projection-markings.d.ts +71 -0
- package/dist/security/projection-markings.d.ts.map +1 -0
- package/dist/security/public.js +2 -2
- package/dist/security/redactions.d.ts +4 -1
- package/dist/security/redactions.d.ts.map +1 -1
- package/dist/security/registry.d.ts +6 -0
- package/dist/security/registry.d.ts.map +1 -1
- package/dist/security/types.d.ts +64 -6
- package/dist/security/types.d.ts.map +1 -1
- package/dist/security/validation.d.ts.map +1 -1
- package/dist/security/view-conditions.d.ts +37 -0
- package/dist/security/view-conditions.d.ts.map +1 -0
- package/dist/shares/execution.d.ts.map +1 -1
- package/dist/shares/internal.js +40 -36
- package/dist/shares/internal.js.map +2 -2
- package/dist/storage/action-runs/failure.js +3 -3
- package/dist/storage/action-runs/in-memory.d.ts +4 -0
- package/dist/storage/action-runs/in-memory.d.ts.map +1 -1
- package/dist/storage/action-runs/provider.js +1 -1
- package/dist/storage/action-runs/types.d.ts +9 -1
- package/dist/storage/action-runs/types.d.ts.map +1 -1
- package/dist/storage/activity/in-memory.d.ts +55 -0
- package/dist/storage/activity/in-memory.d.ts.map +1 -0
- package/dist/storage/activity/index.d.ts +3 -0
- package/dist/storage/activity/index.d.ts.map +1 -0
- package/dist/storage/activity/policy.d.ts +96 -0
- package/dist/storage/activity/policy.d.ts.map +1 -0
- package/dist/storage/activity/types.d.ts +191 -0
- package/dist/storage/activity/types.d.ts.map +1 -0
- package/dist/storage/agents/errors.d.ts +3 -1
- package/dist/storage/agents/errors.d.ts.map +1 -1
- package/dist/storage/agents/in-memory.d.ts +124 -3
- package/dist/storage/agents/in-memory.d.ts.map +1 -1
- package/dist/storage/agents/index.d.ts +2 -2
- package/dist/storage/agents/index.d.ts.map +1 -1
- package/dist/storage/agents/provider.d.ts +154 -4
- package/dist/storage/agents/provider.d.ts.map +1 -1
- package/dist/storage/agents/provider.js +60 -8
- package/dist/storage/agents/provider.js.map +1 -1
- package/dist/storage/agents/types.d.ts +573 -20
- package/dist/storage/agents/types.d.ts.map +1 -1
- package/dist/storage/ai-cost/analytics.d.ts +10 -1
- package/dist/storage/ai-cost/analytics.d.ts.map +1 -1
- package/dist/storage/ai-cost/groups.d.ts +9 -0
- package/dist/storage/ai-cost/groups.d.ts.map +1 -1
- package/dist/storage/ai-cost/index.d.ts +1 -1
- package/dist/storage/ai-cost/index.d.ts.map +1 -1
- package/dist/storage/ai-cost/provider.d.ts +2 -1
- package/dist/storage/ai-cost/provider.d.ts.map +1 -1
- package/dist/storage/ai-cost/provider.js +11 -5
- package/dist/storage/ai-cost/provider.js.map +1 -1
- package/dist/storage/ai-cost/types.d.ts +14 -2
- package/dist/storage/ai-cost/types.d.ts.map +1 -1
- package/dist/storage/ai-cost/validation.d.ts.map +1 -1
- package/dist/storage/ai-limits/enforcement.js +6 -5
- package/dist/storage/ai-limits/enforcement.js.map +1 -1
- package/dist/storage/ai-limits/provider.d.ts +1 -1
- package/dist/storage/ai-limits/provider.d.ts.map +1 -1
- package/dist/storage/ai-limits/provider.js +3 -2
- package/dist/storage/ai-limits/provider.js.map +1 -1
- package/dist/storage/ai-usage/in-memory.d.ts +5 -1
- package/dist/storage/ai-usage/in-memory.d.ts.map +1 -1
- package/dist/storage/ai-usage/index.d.ts +2 -2
- package/dist/storage/ai-usage/index.d.ts.map +1 -1
- package/dist/storage/ai-usage/record.d.ts +5 -1
- package/dist/storage/ai-usage/record.d.ts.map +1 -1
- package/dist/storage/ai-usage/types.d.ts +33 -0
- package/dist/storage/ai-usage/types.d.ts.map +1 -1
- package/dist/storage/ai-usage/usage.d.ts +2 -0
- package/dist/storage/ai-usage/usage.d.ts.map +1 -1
- package/dist/storage/artifacts/errors.d.ts +18 -0
- package/dist/storage/artifacts/errors.d.ts.map +1 -0
- package/dist/storage/artifacts/in-memory.d.ts +55 -0
- package/dist/storage/artifacts/in-memory.d.ts.map +1 -0
- package/dist/storage/artifacts/index.d.ts +5 -0
- package/dist/storage/artifacts/index.d.ts.map +1 -0
- package/dist/storage/artifacts/record.d.ts +34 -0
- package/dist/storage/artifacts/record.d.ts.map +1 -0
- package/dist/storage/artifacts/types.d.ts +263 -0
- package/dist/storage/artifacts/types.d.ts.map +1 -0
- package/dist/storage/auth/in-memory/auth-storage.d.ts +3 -2
- package/dist/storage/auth/in-memory/auth-storage.d.ts.map +1 -1
- package/dist/storage/auth/in-memory/sessions.d.ts +2 -1
- package/dist/storage/auth/in-memory/sessions.d.ts.map +1 -1
- package/dist/storage/auth/in-memory/users.d.ts +7 -3
- package/dist/storage/auth/in-memory/users.d.ts.map +1 -1
- package/dist/storage/auth/index.d.ts +1 -1
- package/dist/storage/auth/index.d.ts.map +1 -1
- package/dist/storage/auth/types.d.ts +59 -9
- package/dist/storage/auth/types.d.ts.map +1 -1
- package/dist/storage/connector-connections/provider.js +2 -2
- package/dist/storage/executions/in-memory.d.ts +3 -1
- package/dist/storage/executions/in-memory.d.ts.map +1 -1
- package/dist/storage/executions/index.d.ts +1 -1
- package/dist/storage/executions/index.d.ts.map +1 -1
- package/dist/storage/executions/provider.d.ts +2 -0
- package/dist/storage/executions/provider.d.ts.map +1 -1
- package/dist/storage/executions/provider.js +9 -223
- package/dist/storage/executions/provider.js.map +3 -4
- package/dist/storage/executions/types.d.ts +46 -0
- package/dist/storage/executions/types.d.ts.map +1 -1
- package/dist/storage/file-upload-sessions/provider.js +17 -14
- package/dist/storage/file-upload-sessions/provider.js.map +1 -1
- package/dist/storage/in-memory/index.d.ts +8 -0
- package/dist/storage/in-memory/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +15 -11
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +78 -66
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/internal.d.ts +4 -1
- package/dist/storage/internal.d.ts.map +1 -1
- package/dist/storage/internal.js +80 -19
- package/dist/storage/internal.js.map +1 -1
- package/dist/storage/migrations/migrate-storage.d.ts +4 -1
- package/dist/storage/migrations/migrate-storage.d.ts.map +1 -1
- package/dist/storage/migrations/prepare-unique-properties.d.ts +18 -0
- package/dist/storage/migrations/prepare-unique-properties.d.ts.map +1 -0
- package/dist/storage/objects/guard.d.ts +1 -1
- package/dist/storage/objects/guard.d.ts.map +1 -1
- package/dist/storage/objects/in-memory/conditional-reader.d.ts +5 -0
- package/dist/storage/objects/in-memory/conditional-reader.d.ts.map +1 -0
- package/dist/storage/objects/in-memory/query.d.ts.map +1 -1
- package/dist/storage/objects/in-memory/read-scope.d.ts +3 -9
- package/dist/storage/objects/in-memory/read-scope.d.ts.map +1 -1
- package/dist/storage/objects/in-memory/read-source.d.ts +10 -1
- package/dist/storage/objects/in-memory/read-source.d.ts.map +1 -1
- package/dist/storage/objects/in-memory/scoped-reader.d.ts +14 -0
- package/dist/storage/objects/in-memory/scoped-reader.d.ts.map +1 -0
- package/dist/storage/objects/in-memory/selected-reader.d.ts.map +1 -1
- package/dist/storage/objects/in-memory/storage.d.ts +36 -1
- package/dist/storage/objects/in-memory/storage.d.ts.map +1 -1
- package/dist/storage/objects/index.d.ts +2 -2
- package/dist/storage/objects/index.d.ts.map +1 -1
- package/dist/storage/objects/read-scope.d.ts +9 -1
- package/dist/storage/objects/read-scope.d.ts.map +1 -1
- package/dist/storage/objects/types.d.ts +64 -1
- package/dist/storage/objects/types.d.ts.map +1 -1
- package/dist/storage/ontology/in-memory/index.d.ts +2 -0
- package/dist/storage/ontology/in-memory/index.d.ts.map +1 -1
- package/dist/storage/ontology/in-memory/materializations.d.ts +1 -0
- package/dist/storage/ontology/in-memory/materializations.d.ts.map +1 -1
- package/dist/storage/ontology/in-memory/replacement-plans.d.ts.map +1 -1
- package/dist/storage/ontology/in-memory/sources.d.ts +2 -1
- package/dist/storage/ontology/in-memory/sources.d.ts.map +1 -1
- package/dist/storage/ontology/in-memory/unique-values.d.ts +32 -0
- package/dist/storage/ontology/in-memory/unique-values.d.ts.map +1 -0
- package/dist/storage/ontology/index.d.ts +5 -2
- package/dist/storage/ontology/index.d.ts.map +1 -1
- package/dist/storage/ontology/materializations.d.ts +34 -1
- package/dist/storage/ontology/materializations.d.ts.map +1 -1
- package/dist/storage/ontology/provider-work.d.ts +15 -2
- package/dist/storage/ontology/provider-work.d.ts.map +1 -1
- package/dist/storage/ontology/provider.d.ts +1 -1
- package/dist/storage/ontology/provider.d.ts.map +1 -1
- package/dist/storage/ontology/provider.js +9 -4
- package/dist/storage/ontology/provider.js.map +1 -1
- package/dist/storage/ontology/sources.d.ts +15 -0
- package/dist/storage/ontology/sources.d.ts.map +1 -1
- package/dist/storage/ontology/unique-values.d.ts +54 -0
- package/dist/storage/ontology/unique-values.d.ts.map +1 -0
- package/dist/storage/operation-scope.d.ts +1 -1
- package/dist/storage/operation-scope.d.ts.map +1 -1
- package/dist/storage/operation-scope.js +1 -1
- package/dist/storage/projection-runs/in-memory.d.ts +0 -6
- package/dist/storage/projection-runs/in-memory.d.ts.map +1 -1
- package/dist/storage/projection-runs/provider.js +3 -3
- package/dist/storage/share-grants/in-memory.d.ts +2 -1
- package/dist/storage/share-grants/in-memory.d.ts.map +1 -1
- package/dist/storage/share-grants/index.d.ts +1 -1
- package/dist/storage/share-grants/index.d.ts.map +1 -1
- package/dist/storage/share-grants/provider.js +4 -3
- package/dist/storage/share-grants/provider.js.map +1 -1
- package/dist/storage/share-grants/types.d.ts +6 -0
- package/dist/storage/share-grants/types.d.ts.map +1 -1
- package/dist/storage/types.d.ts +6 -2
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/storage/workflow-runs/in-memory.d.ts +4 -0
- package/dist/storage/workflow-runs/in-memory.d.ts.map +1 -1
- package/dist/storage/workflow-runs/provider.js +18 -14
- package/dist/storage/workflow-runs/provider.js.map +1 -1
- package/dist/storage/workflow-runs/types.d.ts +5 -0
- package/dist/storage/workflow-runs/types.d.ts.map +1 -1
- package/dist/syncs/index.js +49 -45
- package/dist/syncs/index.js.map +1 -1
- package/dist/testing/action-run-storage-contract.d.ts.map +1 -1
- package/dist/testing/activity-storage-contract.d.ts +14 -0
- package/dist/testing/activity-storage-contract.d.ts.map +1 -0
- package/dist/testing/agent-approval-storage-contract.d.ts +17 -0
- package/dist/testing/agent-approval-storage-contract.d.ts.map +1 -0
- package/dist/testing/agent-memory-storage-contract.d.ts +12 -0
- package/dist/testing/agent-memory-storage-contract.d.ts.map +1 -0
- package/dist/testing/agent-storage-contract.d.ts.map +1 -1
- package/dist/testing/ai-cost-storage-contract.d.ts.map +1 -1
- package/dist/testing/ai-limit-storage-contract.d.ts +0 -1
- package/dist/testing/ai-limit-storage-contract.d.ts.map +1 -1
- package/dist/testing/ai-model-call-groups-contract.d.ts.map +1 -1
- package/dist/testing/ai-usage-storage-contract.d.ts.map +1 -1
- package/dist/testing/artifact-storage-contract.d.ts +13 -0
- package/dist/testing/artifact-storage-contract.d.ts.map +1 -0
- package/dist/testing/auth-storage-contract.d.ts +13 -0
- package/dist/testing/auth-storage-contract.d.ts.map +1 -1
- package/dist/testing/broker-contract.d.ts +5 -0
- package/dist/testing/broker-contract.d.ts.map +1 -1
- package/dist/testing/effective-storage-contract.d.ts.map +1 -1
- package/dist/testing/execution-storage-contract.d.ts.map +1 -1
- package/dist/testing/file-upload-session-storage-contract.d.ts.map +1 -1
- package/dist/testing/index.d.ts +11 -5
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +9340 -3794
- package/dist/testing/index.js.map +32 -26
- package/dist/testing/lake-merge-storage-contract.d.ts.map +1 -1
- package/dist/testing/lake-storage-contract.d.ts +2 -0
- package/dist/testing/lake-storage-contract.d.ts.map +1 -1
- package/dist/testing/materializer-storage-contract.d.ts.map +1 -1
- package/dist/testing/object-conditional-read-scope-contract.d.ts +11 -0
- package/dist/testing/object-conditional-read-scope-contract.d.ts.map +1 -0
- package/dist/testing/object-query-contract.d.ts +0 -2
- package/dist/testing/object-query-contract.d.ts.map +1 -1
- package/dist/testing/ontology-storage-contract.d.ts.map +1 -1
- package/dist/testing/projection-run-storage-contract.d.ts.map +1 -1
- package/dist/testing/queues-contract.d.ts +5 -0
- package/dist/testing/queues-contract.d.ts.map +1 -1
- package/dist/testing/sandboxes-contract.d.ts.map +1 -1
- package/dist/testing/share-grant-storage-contract.d.ts.map +1 -1
- package/dist/testing/share-session-storage-contract.d.ts.map +1 -1
- package/dist/testing/unique-values-contract.d.ts +21 -0
- package/dist/testing/unique-values-contract.d.ts.map +1 -0
- package/dist/testing/webhook-execution.d.ts +0 -8
- package/dist/testing/webhook-execution.d.ts.map +1 -1
- package/dist/testing/webhook-run-storage-contract.d.ts.map +1 -1
- package/dist/users/execution.d.ts +40 -0
- package/dist/users/execution.d.ts.map +1 -0
- package/dist/users/index.d.ts +3 -0
- package/dist/users/index.d.ts.map +1 -0
- package/dist/webhooks/internal.js +42 -38
- package/dist/webhooks/internal.js.map +2 -2
- package/dist/workers/index.js +5 -7
- package/dist/workers/index.js.map +4 -4
- package/dist/workers/queue-worker.d.ts +0 -2
- package/dist/workers/queue-worker.d.ts.map +1 -1
- package/dist/workers/worker.d.ts +0 -2
- package/dist/workers/worker.d.ts.map +1 -1
- package/dist/workflows/builders.d.ts.map +1 -1
- package/dist/workflows/index.js +76 -66
- package/dist/workflows/index.js.map +1 -1
- package/dist/workflows/request.d.ts +12 -1
- package/dist/workflows/request.d.ts.map +1 -1
- package/dist/workflows/types.d.ts +15 -2
- package/dist/workflows/types.d.ts.map +1 -1
- package/dist/workflows/validation.d.ts +7 -0
- package/dist/workflows/validation.d.ts.map +1 -1
- package/package.json +25 -1
- package/src/actions/commit-edits.ts +6 -1
- package/src/actions/execution.ts +55 -23
- package/src/actions/read-facade.ts +33 -0
- package/src/actions/request.ts +234 -66
- package/src/actions/run/context.ts +47 -1
- package/src/actions/run/execute.ts +13 -6
- package/src/actions/run/executor.ts +11 -2
- package/src/actions/run/normalize.ts +12 -2
- package/src/actions/run/phases.ts +2 -0
- package/src/actions/run/run-action.ts +12 -3
- package/src/actions/run/signals.ts +3 -9
- package/src/actions/run/types.ts +17 -1
- package/src/actions/run-authorization.ts +95 -0
- package/src/actions/types/context.ts +20 -3
- package/src/actions/validators.ts +19 -8
- package/src/activity/README.md +158 -0
- package/src/activity/connection.ts +217 -0
- package/src/activity/device.ts +41 -0
- package/src/activity/execution.ts +210 -0
- package/src/activity/service.ts +274 -0
- package/src/activity/shares.ts +62 -0
- package/src/activity/timeline.ts +385 -0
- package/src/agents/accounting.ts +59 -0
- package/src/agents/adapters.ts +10 -0
- package/src/agents/agent-mail.ts +29 -0
- package/src/agents/api-gateway.ts +14 -3
- package/src/agents/approval-continuation.ts +48 -0
- package/src/agents/approval-executor.ts +318 -0
- package/src/agents/approval-outcome.ts +59 -0
- package/src/agents/approvals.ts +566 -0
- package/src/agents/authority.ts +24 -1
- package/src/agents/builders.ts +5 -3
- package/src/agents/cancel.ts +103 -0
- package/src/agents/child-question.ts +46 -0
- package/src/agents/children.ts +404 -0
- package/src/agents/context-compaction.ts +12 -0
- package/src/agents/errors.ts +31 -0
- package/src/agents/execution.ts +788 -90
- package/src/agents/fork.ts +158 -0
- package/src/agents/ids.ts +18 -6
- package/src/agents/index.ts +63 -3
- package/src/agents/memory-execution.ts +186 -0
- package/src/agents/memory.ts +178 -0
- package/src/agents/message.ts +57 -0
- package/src/agents/model-loop.ts +93 -6
- package/src/agents/model-routing.ts +193 -0
- package/src/agents/participants.ts +213 -0
- package/src/agents/reference.ts +2 -0
- package/src/agents/request.ts +398 -64
- package/src/agents/run-scope.ts +134 -0
- package/src/agents/skills.ts +6 -0
- package/src/agents/streams/index.ts +5 -0
- package/src/agents/streams/internal.ts +1 -0
- package/src/agents/streams/protocol.ts +385 -7
- package/src/agents/subagent-runs.ts +41 -0
- package/src/agents/thread-access.ts +137 -0
- package/src/agents/tool-definition.ts +5 -3
- package/src/agents/types.ts +43 -18
- package/src/agents/validation.ts +4 -0
- package/src/artifacts/access.ts +125 -0
- package/src/artifacts/address.ts +132 -0
- package/src/artifacts/canvas.ts +369 -0
- package/src/artifacts/csv.ts +118 -0
- package/src/artifacts/errors.ts +32 -0
- package/src/artifacts/execution.ts +553 -0
- package/src/artifacts/formula/check.ts +171 -0
- package/src/artifacts/formula/evaluate.ts +288 -0
- package/src/artifacts/formula/index.ts +199 -0
- package/src/artifacts/formula/parser.ts +357 -0
- package/src/artifacts/frames/assets.ts +104 -0
- package/src/artifacts/frames/entries.ts +35 -0
- package/src/artifacts/frames/grants.ts +125 -0
- package/src/artifacts/frames/index.ts +21 -0
- package/src/artifacts/frames/kit.ts +569 -0
- package/src/artifacts/frames/probe.ts +357 -0
- package/src/artifacts/frames/protocol.ts +328 -0
- package/src/artifacts/frames/runtime.ts +458 -0
- package/src/artifacts/html.ts +25 -0
- package/src/artifacts/ids.ts +18 -0
- package/src/artifacts/index.ts +125 -0
- package/src/artifacts/kinds.ts +8 -0
- package/src/artifacts/limits.ts +58 -0
- package/src/artifacts/live-sheet.ts +345 -0
- package/src/artifacts/outline.ts +95 -0
- package/src/artifacts/publish/files.ts +87 -0
- package/src/artifacts/publish/index.ts +14 -0
- package/src/artifacts/publish/publish.ts +336 -0
- package/src/artifacts/publish/queries.ts +336 -0
- package/src/artifacts/publish/references.ts +135 -0
- package/src/artifacts/publish/validate/canvas.ts +118 -0
- package/src/artifacts/publish/validate/document.ts +114 -0
- package/src/artifacts/publish/validate/file.ts +19 -0
- package/src/artifacts/publish/validate/html.ts +78 -0
- package/src/artifacts/publish/validate/page.ts +65 -0
- package/src/artifacts/publish/validate/sheet.ts +297 -0
- package/src/artifacts/publish/validate/slides.ts +82 -0
- package/src/artifacts/queries.ts +512 -0
- package/src/artifacts/references.ts +11 -0
- package/src/artifacts/resolve.ts +112 -0
- package/src/artifacts/run-query.ts +212 -0
- package/src/artifacts/serialize-query.ts +25 -0
- package/src/artifacts/sheet-rules.ts +180 -0
- package/src/artifacts/theme.ts +116 -0
- package/src/artifacts/tones.ts +20 -0
- package/src/artifacts/warnings.ts +10 -0
- package/src/artifacts/workbook.ts +674 -0
- package/src/auth/index.ts +4 -0
- package/src/auth/member-events.ts +114 -0
- package/src/auth/profile.ts +118 -0
- package/src/auth/runtime.ts +190 -9
- package/src/auth/strategy.ts +3 -0
- package/src/auth/types.ts +32 -0
- package/src/authorization/decision.ts +52 -0
- package/src/authorization/event-visibility.ts +17 -16
- package/src/authorization/grant-kinds.ts +46 -2
- package/src/authorization/index.ts +6 -1
- package/src/authorization/resolve.ts +58 -1
- package/src/authorization/run-visibility.ts +8 -1
- package/src/authorization/types.ts +14 -0
- package/src/blob-storage/internal.ts +1 -1
- package/src/blob-storage/media-type.ts +69 -0
- package/src/datasets/builders.ts +66 -2
- package/src/datasets/column-index.ts +19 -0
- package/src/datasets/execution.ts +23 -9
- package/src/errors/catalog.ts +26 -1
- package/src/errors/internal.ts +18 -8
- package/src/events/definitions.ts +26 -0
- package/src/events/execution.ts +171 -21
- package/src/events/index.ts +10 -1
- package/src/events/scope.ts +2 -0
- package/src/events/selectors/builder.ts +50 -0
- package/src/events/selectors/index.ts +4 -0
- package/src/events/selectors/types.ts +32 -1
- package/src/events/service.ts +55 -2
- package/src/events/types/index.ts +10 -0
- package/src/events/types/users.ts +73 -0
- package/src/events/view-conditions.ts +241 -0
- package/src/execution/agent.ts +25 -0
- package/src/execution/authorization.ts +70 -0
- package/src/execution/authorized-object-reader.ts +486 -266
- package/src/execution/lineage.ts +14 -0
- package/src/execution/object-reader-clearance.ts +91 -0
- package/src/execution/object-reader-ontology.ts +60 -0
- package/src/execution/object-reader-security.ts +270 -0
- package/src/execution/object-reader-users.ts +122 -0
- package/src/execution/preparation.ts +78 -0
- package/src/execution/request.ts +2 -0
- package/src/execution/unique-lookup.ts +55 -0
- package/src/execution/visible-objects.ts +26 -0
- package/src/http/api-routes.ts +331 -7
- package/src/index.ts +169 -4
- package/src/lake-storage/in-memory.ts +26 -3
- package/src/lake-storage/index.ts +13 -1
- package/src/lake-storage/lineage.ts +385 -0
- package/src/lake-storage/sql-transforms.ts +45 -0
- package/src/lake-storage/types.ts +59 -1
- package/src/lake-storage/version-inputs.ts +35 -6
- package/src/maintenance/ontology-maintenance.ts +15 -0
- package/src/materialization/errors.ts +37 -0
- package/src/materialization/event-envelopes.ts +11 -3
- package/src/materialization/index.ts +1 -0
- package/src/materialization/model.ts +24 -4
- package/src/materializer/README.md +7 -1
- package/src/materializer/edits/commit.ts +56 -12
- package/src/materializer/edits/load-state.ts +15 -7
- package/src/materializer/edits/operations.ts +12 -0
- package/src/materializer/edits/plan.ts +2 -0
- package/src/materializer/edits/unique-values.ts +255 -0
- package/src/materializer/edits/working-state.ts +8 -1
- package/src/materializer/execution/work-records.ts +47 -0
- package/src/materializer/projections/finish-run.ts +0 -1
- package/src/materializer/projections/replace.ts +1 -1
- package/src/materializer/projections/replacement-plan.ts +4 -1
- package/src/materializer/projections/source-materialization.ts +2 -1
- package/src/materializer/shared/normalize.ts +37 -6
- package/src/materializer/shared/projection-run.ts +1 -2
- package/src/materializer/telemetry/append.ts +14 -17
- package/src/materializer/telemetry/plan.ts +2 -0
- package/src/models/audio/catalog.ts +89 -10
- package/src/models/audio/errors.ts +18 -1
- package/src/models/audio/runtime.ts +10 -13
- package/src/models/audio/speech.ts +261 -0
- package/src/models/audio/types.ts +97 -0
- package/src/models/calls.ts +100 -0
- package/src/models/catalog-index.ts +21 -2
- package/src/models/catalog.ts +211 -35
- package/src/models/decision/runtime.ts +21 -22
- package/src/models/decision/validation.ts +4 -1
- package/src/models/definitions.ts +57 -8
- package/src/models/events.ts +72 -1
- package/src/models/execution/README.md +34 -5
- package/src/models/execution/binding.ts +3 -1
- package/src/models/execution/embedding.ts +1 -0
- package/src/models/execution/index.ts +5 -0
- package/src/models/execution/model-call-accounting.ts +3 -1
- package/src/models/execution/model-call-recorder.ts +29 -1
- package/src/models/execution/usage.ts +8 -0
- package/src/models/execution.ts +20 -22
- package/src/models/generation-types.ts +8 -1
- package/src/models/image/catalog.ts +89 -0
- package/src/models/image/errors.ts +19 -0
- package/src/models/image/runtime.ts +335 -0
- package/src/models/image/types.ts +111 -0
- package/src/models/index.ts +38 -4
- package/src/models/{audio/file.ts → input-file.ts} +22 -13
- package/src/models/language-model.ts +13 -0
- package/src/models/pricing.ts +263 -42
- package/src/models/rate-card.ts +161 -12
- package/src/objects/authorized-ontology-view.ts +1 -0
- package/src/objects/clearance-redaction.ts +138 -0
- package/src/objects/conditional-writes.ts +109 -0
- package/src/objects/execution.ts +4 -0
- package/src/objects/index.ts +8 -0
- package/src/objects/link/authorization.ts +37 -8
- package/src/objects/link/endpoints.ts +42 -11
- package/src/objects/link/remove.ts +27 -12
- package/src/objects/link/upsert-batch.ts +9 -5
- package/src/objects/link/upsert.ts +20 -14
- package/src/objects/materializer-adapter.ts +55 -18
- package/src/objects/object/delete.ts +26 -7
- package/src/objects/object/upsert-batch.ts +46 -18
- package/src/objects/object/upsert.ts +25 -8
- package/src/objects/property-clearance.ts +171 -152
- package/src/objects/query/clearance-admission.ts +112 -0
- package/src/objects/query/current-user.ts +76 -0
- package/src/objects/query/executor.ts +39 -103
- package/src/objects/query/explain.ts +20 -7
- package/src/objects/query/index.ts +2 -0
- package/src/objects/query/ir.ts +20 -0
- package/src/objects/query/link-query-clearance.ts +73 -0
- package/src/objects/query/links.ts +8 -0
- package/src/objects/query/matches-predicate.ts +108 -0
- package/src/objects/query/normalize.ts +50 -19
- package/src/objects/query/scalar-values.ts +19 -3
- package/src/objects/query/user-expansions.ts +65 -0
- package/src/objects/query/validate.ts +248 -10
- package/src/objects/runtime-batch.ts +8 -2
- package/src/objects/sdk/object-set.ts +12 -1
- package/src/objects/sdk/query-builder.ts +39 -8
- package/src/objects/sdk/query-executor.ts +6 -0
- package/src/objects/serialize.ts +79 -0
- package/src/objects/unique-violation.ts +59 -0
- package/src/objects/vectors/handle.ts +3 -3
- package/src/ontology/builders.ts +15 -1
- package/src/ontology/docs-markdown.ts +2 -1
- package/src/ontology/index.ts +2 -2
- package/src/ontology/json-schema.ts +4 -0
- package/src/ontology/primitives.ts +21 -8
- package/src/ontology/registry.ts +16 -0
- package/src/ontology/types.ts +9 -0
- package/src/ontology/unique-values.ts +84 -0
- package/src/ontology/user-ref.ts +39 -0
- package/src/ontology/validation/properties.ts +43 -0
- package/src/ontology/validation/schema.ts +9 -1
- package/src/pipelines/index.ts +2 -0
- package/src/pipelines/lineage.ts +45 -0
- package/src/projections/internal.ts +2 -2
- package/src/projections/registry.ts +16 -10
- package/src/projections/revision.ts +112 -45
- package/src/projections/run-dispatch.ts +38 -25
- package/src/projections/types.ts +2 -0
- package/src/query.ts +5 -0
- package/src/rules/execution.ts +43 -11
- package/src/runtime/ai-cost.ts +30 -0
- package/src/runtime/ai-usage.ts +32 -1
- package/src/runtime/create.ts +4 -0
- package/src/runtime/host.ts +73 -1
- package/src/runtime/index.ts +2 -0
- package/src/runtime/internal.ts +2 -0
- package/src/runtime/ontology-mutations.ts +19 -4
- package/src/runtime/resolve-definitions.ts +69 -3
- package/src/runtime/sixb.ts +53 -9
- package/src/runtime/types.ts +99 -9
- package/src/sandboxes/README.md +29 -7
- package/src/sandboxes/auth.ts +16 -0
- package/src/sandboxes/config.ts +2 -7
- package/src/sandboxes/configuration.ts +61 -7
- package/src/sandboxes/index.ts +1 -0
- package/src/sandboxes/sandbox.ts +27 -5
- package/src/schedules/builders.ts +3 -1
- package/src/schedules/runtime.ts +6 -0
- package/src/schedules/validation.ts +23 -1
- package/src/security/README.md +62 -0
- package/src/security/applied-markings-contribution.ts +277 -0
- package/src/security/applied-markings-host.ts +41 -0
- package/src/security/applied-markings-snapshot.ts +235 -0
- package/src/security/applied-markings.ts +405 -0
- package/src/security/dataset-version-markings.ts +163 -0
- package/src/security/grants.ts +191 -11
- package/src/security/index.ts +5 -0
- package/src/security/internal.ts +18 -0
- package/src/security/marking-propagation.ts +255 -0
- package/src/security/marking-sets.ts +42 -0
- package/src/security/markings.ts +29 -178
- package/src/security/pipeline-markings.ts +175 -0
- package/src/security/project.ts +13 -0
- package/src/security/projection-markings.ts +421 -0
- package/src/security/redactions.ts +7 -2
- package/src/security/registry.ts +32 -7
- package/src/security/types.ts +68 -5
- package/src/security/validation.ts +34 -11
- package/src/security/view-conditions.ts +215 -0
- package/src/shares/execution.ts +43 -10
- package/src/storage/action-runs/in-memory.ts +18 -0
- package/src/storage/action-runs/types.ts +10 -0
- package/src/storage/activity/in-memory.ts +374 -0
- package/src/storage/activity/index.ts +27 -0
- package/src/storage/activity/policy.ts +430 -0
- package/src/storage/activity/types.ts +211 -0
- package/src/storage/agents/errors.ts +3 -0
- package/src/storage/agents/in-memory.ts +789 -32
- package/src/storage/agents/index.ts +42 -0
- package/src/storage/agents/provider.ts +730 -16
- package/src/storage/agents/types.ts +628 -27
- package/src/storage/ai-cost/analytics.ts +60 -7
- package/src/storage/ai-cost/codec.ts +6 -1
- package/src/storage/ai-cost/groups.ts +44 -1
- package/src/storage/ai-cost/index.ts +1 -0
- package/src/storage/ai-cost/provider.ts +2 -0
- package/src/storage/ai-cost/types.ts +18 -1
- package/src/storage/ai-cost/validation.ts +39 -12
- package/src/storage/ai-limits/provider.ts +4 -7
- package/src/storage/ai-usage/in-memory.ts +28 -1
- package/src/storage/ai-usage/index.ts +9 -1
- package/src/storage/ai-usage/record.ts +44 -7
- package/src/storage/ai-usage/types.ts +38 -0
- package/src/storage/ai-usage/usage.ts +15 -1
- package/src/storage/artifacts/errors.ts +28 -0
- package/src/storage/artifacts/in-memory.ts +388 -0
- package/src/storage/artifacts/index.ts +35 -0
- package/src/storage/artifacts/record.ts +260 -0
- package/src/storage/artifacts/types.ts +293 -0
- package/src/storage/auth/in-memory/auth-storage.ts +27 -2
- package/src/storage/auth/in-memory/sessions.ts +21 -0
- package/src/storage/auth/in-memory/users.ts +40 -6
- package/src/storage/auth/index.ts +3 -0
- package/src/storage/auth/types.ts +61 -7
- package/src/storage/executions/in-memory.ts +93 -1
- package/src/storage/executions/index.ts +5 -0
- package/src/storage/executions/provider.ts +12 -0
- package/src/storage/executions/types.ts +47 -0
- package/src/storage/in-memory/index.ts +16 -0
- package/src/storage/index.ts +132 -1
- package/src/storage/internal.ts +39 -1
- package/src/storage/migrations/migrate-storage.ts +8 -1
- package/src/storage/migrations/prepare-unique-properties.ts +161 -0
- package/src/storage/objects/guard.ts +7 -3
- package/src/storage/objects/in-memory/conditional-reader.ts +72 -0
- package/src/storage/objects/in-memory/query.ts +4 -105
- package/src/storage/objects/in-memory/read-scope.ts +15 -14
- package/src/storage/objects/in-memory/read-source.ts +11 -1
- package/src/storage/objects/in-memory/scoped-reader.ts +243 -0
- package/src/storage/objects/in-memory/selected-reader.ts +6 -231
- package/src/storage/objects/in-memory/storage.ts +183 -1
- package/src/storage/objects/index.ts +9 -1
- package/src/storage/objects/read-scope.ts +191 -0
- package/src/storage/objects/types.ts +68 -1
- package/src/storage/ontology/in-memory/index.ts +3 -0
- package/src/storage/ontology/in-memory/materializations.ts +35 -0
- package/src/storage/ontology/in-memory/replacement-plans.ts +4 -0
- package/src/storage/ontology/in-memory/sources.ts +23 -0
- package/src/storage/ontology/in-memory/unique-values.ts +62 -0
- package/src/storage/ontology/index.ts +12 -0
- package/src/storage/ontology/materializations.ts +35 -1
- package/src/storage/ontology/provider-work.ts +76 -0
- package/src/storage/ontology/provider.ts +3 -0
- package/src/storage/ontology/sources.ts +17 -0
- package/src/storage/ontology/unique-values.ts +56 -0
- package/src/storage/operation-scope.ts +9 -1
- package/src/storage/projection-runs/in-memory.ts +3 -35
- package/src/storage/share-grants/in-memory.ts +8 -0
- package/src/storage/share-grants/index.ts +1 -0
- package/src/storage/share-grants/types.ts +8 -0
- package/src/storage/types.ts +6 -0
- package/src/storage/workflow-runs/in-memory.ts +16 -0
- package/src/storage/workflow-runs/types.ts +5 -0
- package/src/testing/action-run-storage-contract.ts +25 -0
- package/src/testing/activity-storage-contract.ts +840 -0
- package/src/testing/agent-approval-storage-contract.ts +1117 -0
- package/src/testing/agent-memory-storage-contract.ts +400 -0
- package/src/testing/agent-storage-contract.ts +1206 -50
- package/src/testing/ai-cost-storage-contract.ts +31 -1
- package/src/testing/ai-limit-storage-contract.ts +9 -7
- package/src/testing/ai-model-call-groups-contract.ts +76 -0
- package/src/testing/ai-usage-storage-contract.ts +120 -13
- package/src/testing/artifact-storage-contract.ts +851 -0
- package/src/testing/auth-storage-contract.ts +597 -73
- package/src/testing/broker-contract.ts +28 -23
- package/src/testing/effective-storage-contract.ts +3 -8
- package/src/testing/execution-storage-contract.ts +200 -1
- package/src/testing/file-upload-session-storage-contract.ts +12 -24
- package/src/testing/index.ts +26 -4
- package/src/testing/lake-merge-storage-contract.ts +38 -0
- package/src/testing/lake-storage-contract.ts +269 -30
- package/src/testing/materializer-storage-contract.ts +37 -9
- package/src/testing/object-conditional-read-scope-contract.ts +634 -0
- package/src/testing/object-query-contract.ts +386 -186
- package/src/testing/ontology-storage-contract.ts +286 -22
- package/src/testing/projection-run-storage-contract.ts +8 -18
- package/src/testing/queues-contract.ts +39 -70
- package/src/testing/sandboxes-contract.ts +3 -14
- package/src/testing/share-grant-storage-contract.ts +28 -16
- package/src/testing/share-session-storage-contract.ts +4 -14
- package/src/testing/unique-values-contract.ts +907 -0
- package/src/testing/webhook-execution.ts +1 -1
- package/src/testing/webhook-run-storage-contract.ts +6 -9
- package/src/users/execution.ts +131 -0
- package/src/users/index.ts +2 -0
- package/src/workers/queue-worker.ts +1 -3
- package/src/workers/worker.ts +1 -3
- package/src/workflows/builders.ts +20 -0
- package/src/workflows/request.ts +46 -8
- package/src/workflows/types.ts +15 -2
- package/src/workflows/validation.ts +95 -9
- package/dist/chunk-1k89ecfr.js +0 -85
- package/dist/chunk-1k89ecfr.js.map +0 -10
- package/dist/chunk-1sr8ryzk.js.map +0 -11
- package/dist/chunk-29yx306f.js.map +0 -22
- package/dist/chunk-3t2hgbgd.js.map +0 -15
- package/dist/chunk-4as3wt1c.js.map +0 -12
- package/dist/chunk-4vyr1j8f.js +0 -128
- package/dist/chunk-4vyr1j8f.js.map +0 -11
- package/dist/chunk-5e43w60z.js.map +0 -10
- package/dist/chunk-6c6sn0bh.js.map +0 -106
- package/dist/chunk-6p49a5cq.js.map +0 -12
- package/dist/chunk-6x0pqh32.js.map +0 -10
- package/dist/chunk-7n30ybym.js +0 -3
- package/dist/chunk-7n440zgt.js +0 -261
- package/dist/chunk-7n440zgt.js.map +0 -12
- package/dist/chunk-8mx7qw3y.js.map +0 -13
- package/dist/chunk-91mg3nj9.js.map +0 -12
- package/dist/chunk-96yw3pwd.js.map +0 -10
- package/dist/chunk-9gyp8hg1.js +0 -363
- package/dist/chunk-9gyp8hg1.js.map +0 -14
- package/dist/chunk-9k93ah50.js.map +0 -11
- package/dist/chunk-b38szspf.js.map +0 -11
- package/dist/chunk-bx9q3cwv.js.map +0 -19
- package/dist/chunk-d09tj99x.js.map +0 -12
- package/dist/chunk-ere85b8y.js.map +0 -15
- package/dist/chunk-es1gxsbf.js.map +0 -13
- package/dist/chunk-gsjm1wms.js.map +0 -10
- package/dist/chunk-hjzdd750.js.map +0 -49
- package/dist/chunk-hkc3jct7.js.map +0 -10
- package/dist/chunk-hvsb78a1.js.map +0 -20
- package/dist/chunk-k6q3n2sc.js.map +0 -12
- package/dist/chunk-n33z5bjw.js.map +0 -66
- package/dist/chunk-pbcbn83d.js.map +0 -14
- package/dist/chunk-pqajwytd.js +0 -68
- package/dist/chunk-pqajwytd.js.map +0 -11
- package/dist/chunk-qczk96d9.js.map +0 -11
- package/dist/chunk-rdghfsss.js +0 -39
- package/dist/chunk-rdghfsss.js.map +0 -10
- package/dist/chunk-rj69qcrd.js.map +0 -11
- package/dist/chunk-rrzt8jdy.js.map +0 -14
- package/dist/chunk-s16apyk9.js +0 -256
- package/dist/chunk-s16apyk9.js.map +0 -16
- package/dist/chunk-s54c868q.js +0 -307
- package/dist/chunk-s54c868q.js.map +0 -12
- package/dist/chunk-tpn40322.js.map +0 -19
- package/dist/chunk-tw03bsmb.js.map +0 -11
- package/dist/chunk-v4jbb3rs.js.map +0 -10
- package/dist/chunk-vpq4shxz.js.map +0 -39
- package/dist/chunk-yxd3nnqt.js.map +0 -11
- package/dist/chunk-yzwja0mj.js.map +0 -14
- package/dist/events/toStoredEvent.d.ts +0 -9
- package/dist/events/toStoredEvent.d.ts.map +0 -1
- package/dist/models/audio/file.d.ts +0 -9
- package/dist/models/audio/file.d.ts.map +0 -1
- package/src/events/toStoredEvent.ts +0 -33
- /package/dist/{chunk-mfs23znk.js.map → chunk-07kkp2e1.js.map} +0 -0
- /package/dist/{chunk-fkgc1wt8.js.map → chunk-0phpbbvm.js.map} +0 -0
- /package/dist/{chunk-y0c4e6ex.js.map → chunk-3gbefjg5.js.map} +0 -0
- /package/dist/{chunk-fa02jy15.js.map → chunk-48jezz3j.js.map} +0 -0
- /package/dist/{chunk-c85m1hyj.js.map → chunk-6n69k945.js.map} +0 -0
- /package/dist/{chunk-xfs8x8m9.js.map → chunk-6p0pastb.js.map} +0 -0
- /package/dist/{chunk-t7x8dmn0.js.map → chunk-6y0mkhex.js.map} +0 -0
- /package/dist/{chunk-v9xd5wzd.js.map → chunk-bab05bhg.js.map} +0 -0
- /package/dist/{chunk-gc4ntf7d.js.map → chunk-cwdzcv37.js.map} +0 -0
- /package/dist/{chunk-vyf9kfqf.js.map → chunk-dp0cdtj2.js.map} +0 -0
- /package/dist/{chunk-br3k6qbf.js.map → chunk-fm62y49k.js.map} +0 -0
- /package/dist/{chunk-9ybhtmg4.js.map → chunk-g663fahq.js.map} +0 -0
- /package/dist/{chunk-9w055r5b.js.map → chunk-hwarjrgf.js.map} +0 -0
- /package/dist/{chunk-9dmt152s.js.map → chunk-hyesv9dv.js.map} +0 -0
- /package/dist/{chunk-x9v4cx1d.js.map → chunk-m36fw8ft.js.map} +0 -0
- /package/dist/{chunk-a40ad1ft.js.map → chunk-mbsbxarb.js.map} +0 -0
- /package/dist/{chunk-6aawea28.js.map → chunk-n8q5j6y5.js.map} +0 -0
- /package/dist/{chunk-dk8tkk5f.js.map → chunk-n9zpx9c6.js.map} +0 -0
- /package/dist/{chunk-7t429e3f.js.map → chunk-npcr0228.js.map} +0 -0
- /package/dist/{chunk-z4m0yz8c.js.map → chunk-q4pmvkg0.js.map} +0 -0
|
@@ -1,46 +1,79 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
assertActionRunExecution2
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-mbsbxarb.js";
|
|
5
5
|
import {
|
|
6
6
|
createSixbError2,
|
|
7
7
|
toSixbFailure2,
|
|
8
8
|
parseSixbFailure2
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-zbc929zg.js";
|
|
10
10
|
import {
|
|
11
|
+
vectorSources,
|
|
12
|
+
hasVectorProfile2,
|
|
11
13
|
paginate,
|
|
12
14
|
InMemoryAuthStorage2,
|
|
13
15
|
principalsEqual2
|
|
14
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-h3pbv7n8.js";
|
|
15
17
|
import {
|
|
16
18
|
ObjectReadLimitExceededError2,
|
|
17
19
|
snapshotObjectReadExecutionLimits2,
|
|
18
20
|
assertObjectReadFacetCount2,
|
|
19
21
|
assertObjectReadOutputWithinLimit2
|
|
20
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-yc9ners4.js";
|
|
21
23
|
import {
|
|
22
24
|
assertObjectReaderProject2
|
|
23
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-rap5w0x0.js";
|
|
24
26
|
import {
|
|
27
|
+
UNIQUE_VALUE_KEY_VERSION,
|
|
28
|
+
uniquePropertiesOf,
|
|
29
|
+
uniqueValueKey,
|
|
25
30
|
queryScalarKindForSchema,
|
|
26
31
|
resolvePropertyQueryCapabilities2,
|
|
27
32
|
resolveQuerySchema
|
|
28
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-65pyhyas.js";
|
|
34
|
+
import {
|
|
35
|
+
createEventId2
|
|
36
|
+
} from "./chunk-zrvhsq7f.js";
|
|
29
37
|
import {
|
|
30
38
|
AgentStorageError2,
|
|
31
39
|
transitionAgentThreadSandbox2,
|
|
32
40
|
snapshotAgentThreadSandboxParams2,
|
|
41
|
+
participantsToAdd2,
|
|
42
|
+
compareAgentThreadParticipants2,
|
|
43
|
+
remapArtifactIds2,
|
|
44
|
+
countsAsThreadMessage2,
|
|
45
|
+
planAgentThreadFork2,
|
|
33
46
|
assertConversationAgentRunSpec2,
|
|
47
|
+
assertAgentApprovalModeInput2,
|
|
34
48
|
assertAgentRunExecution2,
|
|
35
49
|
assertCreateSubagentRunInput2,
|
|
36
50
|
subagentRunMatchesCreateInput2,
|
|
37
|
-
|
|
51
|
+
assertConversationThreadRow2,
|
|
52
|
+
newSubagentThreadRecord2,
|
|
53
|
+
assertSubagentThreadTakesRun2,
|
|
54
|
+
assertAgentRunFinishPayload2,
|
|
38
55
|
assertCreateAgentContextCheckpointInput2,
|
|
39
56
|
assertAgentContextCheckpointAuthority2,
|
|
40
57
|
assertAgentContextCheckpointAnchors2,
|
|
41
58
|
assertAgentContextCheckpointReplayState2,
|
|
42
|
-
agentContextCheckpointMatchesCreateInput2
|
|
43
|
-
|
|
59
|
+
agentContextCheckpointMatchesCreateInput2,
|
|
60
|
+
assertSaveAgentMemoryInput2,
|
|
61
|
+
agentMemoryConflicts2,
|
|
62
|
+
compareAgentMemoryPaths2,
|
|
63
|
+
agentMemoryHistoryCutoff2,
|
|
64
|
+
LIVE_AGENT_APPROVAL_STATUSES2,
|
|
65
|
+
agentApprovalHoldsRun2,
|
|
66
|
+
assertAwaitingApprovalFinish2,
|
|
67
|
+
agentRunMayHoldCalls2,
|
|
68
|
+
agentApprovalStops2,
|
|
69
|
+
agentApprovalRepairable2,
|
|
70
|
+
agentApprovalClaimable2,
|
|
71
|
+
agentApprovalCallKey2,
|
|
72
|
+
assertRequestAgentApprovalInput2,
|
|
73
|
+
assertAgentApprovalCaller2,
|
|
74
|
+
newAgentApprovalRecord2,
|
|
75
|
+
agentApprovalMatches2
|
|
76
|
+
} from "./chunk-nydf3dbe.js";
|
|
44
77
|
import {
|
|
45
78
|
InMemoryAiUsageStorage2,
|
|
46
79
|
buildAiAccountingOverview,
|
|
@@ -49,7 +82,7 @@ import {
|
|
|
49
82
|
buildAiModelCallGroups,
|
|
50
83
|
normalizeAiModelCallCostRecord2,
|
|
51
84
|
aiModelCallCostMatchesUsage2
|
|
52
|
-
} from "./chunk-
|
|
85
|
+
} from "./chunk-0xmt5p5y.js";
|
|
53
86
|
import {
|
|
54
87
|
AiLimitStorageError2,
|
|
55
88
|
aiLimitCalendarMonth2,
|
|
@@ -75,22 +108,41 @@ import {
|
|
|
75
108
|
cloneAiLimitPolicy2,
|
|
76
109
|
assertNonBlank2,
|
|
77
110
|
cloneValidDate2
|
|
78
|
-
} from "./chunk-
|
|
111
|
+
} from "./chunk-4ymrcdbm.js";
|
|
79
112
|
import {
|
|
80
113
|
isAbandonedFileUploadSession,
|
|
81
114
|
shouldDeleteFileUploadSession
|
|
82
115
|
} from "./chunk-h89wz928.js";
|
|
83
116
|
import {
|
|
84
117
|
DurableFileUploadSessions2
|
|
85
|
-
} from "./chunk-
|
|
118
|
+
} from "./chunk-hwarjrgf.js";
|
|
119
|
+
import {
|
|
120
|
+
actionSubjectsEqual,
|
|
121
|
+
normalizeRecordActionRunInput2,
|
|
122
|
+
resolveActionRunEffects2,
|
|
123
|
+
StorageTransactionError2,
|
|
124
|
+
isStorageSerializationFailure2,
|
|
125
|
+
ACTIVITY_MAX_VISIT_MS2,
|
|
126
|
+
validateActivityAppend2,
|
|
127
|
+
planActivityAppend2,
|
|
128
|
+
activityCalendarDays2,
|
|
129
|
+
activityDay,
|
|
130
|
+
artifactStateBytes2,
|
|
131
|
+
checkArtifactStateWrite2,
|
|
132
|
+
artifactStorageErrors2,
|
|
133
|
+
cloneFileDownloadGrantRecord,
|
|
134
|
+
canRequeuePipelineRunAfterEnqueueFailure2,
|
|
135
|
+
canRequeueSyncRunAfterEnqueueFailure2,
|
|
136
|
+
createTransactionStorageProxy2,
|
|
137
|
+
throwNestedStorageTransaction2
|
|
138
|
+
} from "./chunk-fe8zwt8b.js";
|
|
86
139
|
import {
|
|
87
140
|
ExecutionStorageError2,
|
|
88
141
|
prepareExecutionRecord2,
|
|
89
|
-
cloneExecutionRecord
|
|
90
|
-
|
|
142
|
+
cloneExecutionRecord,
|
|
143
|
+
compareExecutionCreation2
|
|
144
|
+
} from "./chunk-eptrvnby.js";
|
|
91
145
|
import {
|
|
92
|
-
sha256Canonical2,
|
|
93
|
-
createEventId2,
|
|
94
146
|
objectRefKey2,
|
|
95
147
|
linkRefKey2,
|
|
96
148
|
projectionEntityKey2,
|
|
@@ -100,7 +152,7 @@ import {
|
|
|
100
152
|
linkScopeKey,
|
|
101
153
|
linkScopeSortKey2,
|
|
102
154
|
telemetryPointSortKey2
|
|
103
|
-
} from "./chunk-
|
|
155
|
+
} from "./chunk-cswhawa2.js";
|
|
104
156
|
import {
|
|
105
157
|
assertNonblank2,
|
|
106
158
|
assertPositiveInteger2,
|
|
@@ -116,6 +168,7 @@ import {
|
|
|
116
168
|
prepareReplacementIdentities2,
|
|
117
169
|
projectionChangeCounts,
|
|
118
170
|
createCardinalityValidator2,
|
|
171
|
+
uniqueValueViolation2,
|
|
119
172
|
workUniquenessKey2,
|
|
120
173
|
comparePlanWork2,
|
|
121
174
|
compareCardinalityWork2,
|
|
@@ -142,7 +195,7 @@ import {
|
|
|
142
195
|
assertSourceStagedRow2,
|
|
143
196
|
isExactStagingManifest2,
|
|
144
197
|
sourceConflict2
|
|
145
|
-
} from "./chunk-
|
|
198
|
+
} from "./chunk-hqsp2sx4.js";
|
|
146
199
|
import {
|
|
147
200
|
createStorageOperationScope2,
|
|
148
201
|
createOperationScopedFacade2,
|
|
@@ -151,7 +204,7 @@ import {
|
|
|
151
204
|
createOntologyOperationScope2,
|
|
152
205
|
createObjectOperationScope2,
|
|
153
206
|
createWorkflowRunOperationScope2
|
|
154
|
-
} from "./chunk-
|
|
207
|
+
} from "./chunk-2adz0h75.js";
|
|
155
208
|
import {
|
|
156
209
|
PipelineRunError2,
|
|
157
210
|
assertPipelineRunExecution2
|
|
@@ -186,7 +239,7 @@ import {
|
|
|
186
239
|
assertProjectionMissingTarget2,
|
|
187
240
|
requireTelemetryProjectionRun2,
|
|
188
241
|
assertProjectionRunDurableExecution2
|
|
189
|
-
} from "./chunk-
|
|
242
|
+
} from "./chunk-g663fahq.js";
|
|
190
243
|
import {
|
|
191
244
|
SyncRunError2,
|
|
192
245
|
assertSyncRunExecution2
|
|
@@ -199,7 +252,7 @@ import {
|
|
|
199
252
|
WorkflowRunError2,
|
|
200
253
|
assertWorkflowRunExecution2,
|
|
201
254
|
assertWorkflowAgentNodeRunExecution2
|
|
202
|
-
} from "./chunk-
|
|
255
|
+
} from "./chunk-6rrtzea3.js";
|
|
203
256
|
import {
|
|
204
257
|
ShareGrantStorageError2,
|
|
205
258
|
normalizeShareGrantCreate2,
|
|
@@ -208,7 +261,7 @@ import {
|
|
|
208
261
|
normalizeListShareGrantsInput2,
|
|
209
262
|
normalizeRevokeShareGrantInput2,
|
|
210
263
|
cloneShareGrantRecord2
|
|
211
|
-
} from "./chunk-
|
|
264
|
+
} from "./chunk-fm62y49k.js";
|
|
212
265
|
import {
|
|
213
266
|
ShareSessionStorageError2,
|
|
214
267
|
normalizeShareSessionCreate2,
|
|
@@ -222,33 +275,23 @@ import {
|
|
|
222
275
|
ConnectorConnectionStorageError2,
|
|
223
276
|
CONNECTOR_CONNECTION_RUN_FAILURE_CODES2
|
|
224
277
|
} from "./chunk-2c4j899j.js";
|
|
225
|
-
import {
|
|
226
|
-
actionSubjectsEqual,
|
|
227
|
-
normalizeRecordActionRunInput2,
|
|
228
|
-
resolveActionRunEffects2,
|
|
229
|
-
StorageTransactionError2,
|
|
230
|
-
cloneFileDownloadGrantRecord,
|
|
231
|
-
canRequeuePipelineRunAfterEnqueueFailure2,
|
|
232
|
-
canRequeueSyncRunAfterEnqueueFailure2,
|
|
233
|
-
createTransactionStorageProxy2,
|
|
234
|
-
throwNestedStorageTransaction2
|
|
235
|
-
} from "./chunk-s16apyk9.js";
|
|
236
278
|
import {
|
|
237
279
|
ActionRunError2
|
|
238
|
-
} from "./chunk-
|
|
280
|
+
} from "./chunk-3gbefjg5.js";
|
|
239
281
|
import {
|
|
240
282
|
assertPinnedDatasetWatermark2
|
|
241
|
-
} from "./chunk-
|
|
283
|
+
} from "./chunk-n8q5j6y5.js";
|
|
242
284
|
import {
|
|
243
285
|
MaterializationValidationError2,
|
|
286
|
+
UniqueValueViolationError2,
|
|
244
287
|
MaterializationConflictError2
|
|
245
|
-
} from "./chunk-
|
|
246
|
-
import {
|
|
247
|
-
AGENT_RUN_FAILURE_CODES2
|
|
248
|
-
} from "./chunk-hkc3jct7.js";
|
|
288
|
+
} from "./chunk-y7dbmaqh.js";
|
|
249
289
|
import {
|
|
250
290
|
compareDecimalValues2
|
|
251
291
|
} from "./chunk-3bh94gbw.js";
|
|
292
|
+
import {
|
|
293
|
+
AGENT_RUN_FAILURE_CODES2
|
|
294
|
+
} from "./chunk-18sk89cg.js";
|
|
252
295
|
import {
|
|
253
296
|
cloneJsonValue2,
|
|
254
297
|
stableJsonStringify2
|
|
@@ -327,6 +370,15 @@ class InMemoryActionRunStorage2 {
|
|
|
327
370
|
return record ? cloneActionRunRecord(record) : null;
|
|
328
371
|
});
|
|
329
372
|
}
|
|
373
|
+
async getByExecutionIds(params) {
|
|
374
|
+
return this.runRootOperation(() => {
|
|
375
|
+
const byExecution = new Map([...this.rows.values()].filter((record) => record.projectId === params.projectId).map((record) => [record.executionId, record]));
|
|
376
|
+
return [...new Set(params.executionIds)].flatMap((executionId) => {
|
|
377
|
+
const record = byExecution.get(executionId);
|
|
378
|
+
return record ? [cloneActionRunRecord(record)] : [];
|
|
379
|
+
});
|
|
380
|
+
});
|
|
381
|
+
}
|
|
330
382
|
async list(input) {
|
|
331
383
|
return this.runRootOperation(() => {
|
|
332
384
|
if (input.actionIds?.length === 0) {
|
|
@@ -400,6 +452,7 @@ class InMemoryAgentThreadStore {
|
|
|
400
452
|
const record = {
|
|
401
453
|
id: input.id,
|
|
402
454
|
projectId: input.projectId,
|
|
455
|
+
kind: "conversation",
|
|
403
456
|
ownerPrincipal: clone(input.ownerPrincipal),
|
|
404
457
|
...sandboxParams === undefined ? {} : { sandboxParams },
|
|
405
458
|
...input.title === undefined ? {} : { title: input.title },
|
|
@@ -412,17 +465,102 @@ class InMemoryAgentThreadStore {
|
|
|
412
465
|
this.state.threads.set(threadKey, clone(record));
|
|
413
466
|
return clone(record);
|
|
414
467
|
}
|
|
468
|
+
async fork(input) {
|
|
469
|
+
const source = this.state.threads.get(key(input.projectId, input.sourceThreadId));
|
|
470
|
+
if (!source) {
|
|
471
|
+
throw new AgentStorageError2("thread_not_found", `[Sixb] Agent thread '${input.sourceThreadId}' not found for project '${input.projectId}'.`);
|
|
472
|
+
}
|
|
473
|
+
assertConversationThreadRow2(source, "can be forked");
|
|
474
|
+
const forkKey = key(input.projectId, input.id);
|
|
475
|
+
if (this.state.threads.has(forkKey)) {
|
|
476
|
+
throw new AgentStorageError2("duplicate_id", `[Sixb] Agent thread '${input.id}' already exists for project '${input.projectId}'.`);
|
|
477
|
+
}
|
|
478
|
+
const activeRun = source.activeRunId === null ? undefined : this.state.runs.get(key(input.projectId, source.activeRunId));
|
|
479
|
+
const messages = [...this.state.messages.values()].filter((message) => message.projectId === input.projectId).filter((message) => message.threadId === source.id).sort((left, right) => left.seq - right.seq);
|
|
480
|
+
const checkpoints = [...this.state.checkpoints.values()].filter((checkpoint) => checkpoint.projectId === input.projectId).filter((checkpoint) => checkpoint.threadId === source.id).sort(compareLatestCheckpoints);
|
|
481
|
+
const plan = planAgentThreadFork2(input, {
|
|
482
|
+
...activeRun?.kind === "conversation" ? { triggerMessageId: activeRun.triggerMessageId } : {},
|
|
483
|
+
messages: messages.map((message) => ({
|
|
484
|
+
...message,
|
|
485
|
+
counted: countsAsThreadMessage2(message)
|
|
486
|
+
})),
|
|
487
|
+
checkpoints
|
|
488
|
+
});
|
|
489
|
+
this.state.threads.set(forkKey, clone(plan.thread));
|
|
490
|
+
const copyIds = new Map(plan.messages.map((copy) => [copy.sourceId, copy.id]));
|
|
491
|
+
for (const message of messages) {
|
|
492
|
+
const id = copyIds.get(message.id);
|
|
493
|
+
if (id === undefined)
|
|
494
|
+
continue;
|
|
495
|
+
const parts = JSON.parse(remapArtifactIds2(JSON.stringify(message.parts), input.artifactCopies));
|
|
496
|
+
this.state.messages.set(key(input.projectId, id), clone({ ...message, id, threadId: input.id, parts }));
|
|
497
|
+
}
|
|
498
|
+
if (plan.checkpoint) {
|
|
499
|
+
this.state.checkpoints.set(key(input.projectId, plan.checkpoint.id), clone(plan.checkpoint));
|
|
500
|
+
}
|
|
501
|
+
return clone(plan.thread);
|
|
502
|
+
}
|
|
415
503
|
async getById(params) {
|
|
416
504
|
const record = this.state.threads.get(key(params.projectId, params.id));
|
|
417
505
|
return record ? clone(record) : null;
|
|
418
506
|
}
|
|
507
|
+
async getByIds(params) {
|
|
508
|
+
return [...new Set(params.ids)].flatMap((id) => {
|
|
509
|
+
const record = this.state.threads.get(key(params.projectId, id));
|
|
510
|
+
return record ? [clone(record)] : [];
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
async listChildren(input) {
|
|
514
|
+
const offset = input.offset ?? 0;
|
|
515
|
+
return [...this.state.threads.values()].filter((thread) => thread.projectId === input.projectId).filter((thread) => thread.parent?.threadId === input.parentThreadId).filter((thread) => input.parentRunId === undefined ? true : thread.parent?.spawnedBy === input.parentRunId).sort((a, b) => compareByDate(a.createdAt, b.createdAt, a.id, b.id, "asc")).slice(offset, offset + (input.limit ?? 100)).map(clone);
|
|
516
|
+
}
|
|
419
517
|
async list(input) {
|
|
420
518
|
const order = input.order ?? "desc";
|
|
421
519
|
const statuses = input.statuses ? new Set(input.statuses) : null;
|
|
422
|
-
const filtered = [...this.state.threads.values()].filter((thread) => thread.projectId === input.projectId).filter((thread) => statuses ? statuses.has(thread.status) : true).filter((thread) => input.ownerPrincipal ? principalsEqual2(thread.ownerPrincipal, input.ownerPrincipal) : true).
|
|
520
|
+
const filtered = [...this.state.threads.values()].filter((thread) => thread.projectId === input.projectId).filter((thread) => thread.kind === "conversation").filter((thread) => statuses ? statuses.has(thread.status) : true).filter((thread) => input.ownerPrincipal ? principalsEqual2(thread.ownerPrincipal, input.ownerPrincipal) : true).filter((thread) => {
|
|
521
|
+
const participant = input.participantPrincipal;
|
|
522
|
+
if (!participant)
|
|
523
|
+
return true;
|
|
524
|
+
return this.participantsOf(thread.projectId, thread.id).some((record) => record.principal.id === participant.id);
|
|
525
|
+
}).sort((a, b) => compareByDate(a.lastMessageAt ?? a.createdAt, b.lastMessageAt ?? b.createdAt, a.id, b.id, order));
|
|
423
526
|
const { page, hasMore, total } = applyWindow(filtered, input.offset, input.limit);
|
|
424
527
|
return { threads: page.map(clone), hasMore, total };
|
|
425
528
|
}
|
|
529
|
+
async addParticipants(input) {
|
|
530
|
+
const threadKey = key(input.projectId, input.threadId);
|
|
531
|
+
const thread = this.state.threads.get(threadKey);
|
|
532
|
+
if (!thread) {
|
|
533
|
+
throw new AgentStorageError2("thread_not_found", `[Sixb] Agent thread '${input.threadId}' not found for project '${input.projectId}'.`);
|
|
534
|
+
}
|
|
535
|
+
assertConversationThreadRow2(thread, "has participants");
|
|
536
|
+
const existing = this.participantsOf(input.projectId, input.threadId);
|
|
537
|
+
const addedAt = new Date(input.addedAt ?? new Date);
|
|
538
|
+
const added = participantsToAdd2(input, existing).map((principal) => ({
|
|
539
|
+
projectId: input.projectId,
|
|
540
|
+
threadId: input.threadId,
|
|
541
|
+
principal,
|
|
542
|
+
addedAt: new Date(addedAt),
|
|
543
|
+
addedBy: clone(input.addedBy)
|
|
544
|
+
}));
|
|
545
|
+
const participants = [...existing, ...added].sort(compareAgentThreadParticipants2);
|
|
546
|
+
this.state.participants.set(threadKey, participants);
|
|
547
|
+
return clone(participants);
|
|
548
|
+
}
|
|
549
|
+
async removeParticipant(input) {
|
|
550
|
+
const threadKey = key(input.projectId, input.threadId);
|
|
551
|
+
const existing = this.state.participants.get(threadKey);
|
|
552
|
+
const kept = existing?.filter((record) => record.principal.id !== input.principal.id);
|
|
553
|
+
if (!existing || !kept || kept.length === existing.length)
|
|
554
|
+
return false;
|
|
555
|
+
this.state.participants.set(threadKey, kept);
|
|
556
|
+
return true;
|
|
557
|
+
}
|
|
558
|
+
async listParticipants(input) {
|
|
559
|
+
return [...new Set(input.threadIds)].flatMap((threadId) => clone(this.participantsOf(input.projectId, threadId))).sort(compareAgentThreadParticipants2);
|
|
560
|
+
}
|
|
561
|
+
participantsOf(projectId, threadId) {
|
|
562
|
+
return this.state.participants.get(key(projectId, threadId)) ?? [];
|
|
563
|
+
}
|
|
426
564
|
}
|
|
427
565
|
|
|
428
566
|
class InMemoryAgentRunStore {
|
|
@@ -445,6 +583,7 @@ class InMemoryAgentRunStore {
|
|
|
445
583
|
if (!thread) {
|
|
446
584
|
throw new AgentStorageError2("thread_not_found", `[Sixb] Agent thread '${input.threadId}' not found for project '${input.projectId}'.`);
|
|
447
585
|
}
|
|
586
|
+
assertConversationThreadRow2(thread, "takes turns");
|
|
448
587
|
if (thread.activeRunId !== null) {
|
|
449
588
|
throw new AgentStorageError2("active_run_exists", `[Sixb] Agent thread '${input.threadId}' already has an active run '${thread.activeRunId}'.`);
|
|
450
589
|
}
|
|
@@ -512,18 +651,60 @@ class InMemoryAgentRunStore {
|
|
|
512
651
|
if ([...this.state.runs.values()].some((run) => run.projectId === input.projectId && run.executionId === input.executionId)) {
|
|
513
652
|
throw new AgentStorageError2("duplicate_id", `[Sixb] Execution '${input.executionId}' already belongs to another Agent run.`);
|
|
514
653
|
}
|
|
654
|
+
const createdAt = new Date(input.createdAt ?? new Date);
|
|
655
|
+
const threadKey = key(input.projectId, input.thread.id);
|
|
656
|
+
const existingThread = this.state.threads.get(threadKey) ?? null;
|
|
657
|
+
let thread;
|
|
658
|
+
if (input.thread.create) {
|
|
659
|
+
if (existingThread) {
|
|
660
|
+
throw new AgentStorageError2("duplicate_id", `[Sixb] Agent thread '${input.thread.id}' already exists for project '${input.projectId}'.`);
|
|
661
|
+
}
|
|
662
|
+
const conversation = this.state.threads.get(key(input.projectId, parent.threadId));
|
|
663
|
+
if (!conversation) {
|
|
664
|
+
throw new AgentStorageError2("thread_not_found", `[Sixb] Agent thread '${parent.threadId}' not found for project '${input.projectId}'.`);
|
|
665
|
+
}
|
|
666
|
+
thread = newSubagentThreadRecord2(input, conversation, createdAt);
|
|
667
|
+
} else {
|
|
668
|
+
assertSubagentThreadTakesRun2(existingThread, input, parent.threadId);
|
|
669
|
+
thread = {
|
|
670
|
+
...existingThread,
|
|
671
|
+
activeRunId: input.id,
|
|
672
|
+
messageCount: existingThread.messageCount + 1,
|
|
673
|
+
lastMessageAt: createdAt,
|
|
674
|
+
updatedAt: createdAt
|
|
675
|
+
};
|
|
676
|
+
}
|
|
515
677
|
const run = {
|
|
516
678
|
kind: "subagent",
|
|
517
679
|
id: input.id,
|
|
518
680
|
projectId: input.projectId,
|
|
519
681
|
executionId: input.executionId,
|
|
682
|
+
threadId: input.thread.id,
|
|
683
|
+
triggerMessageId: input.trigger.id,
|
|
520
684
|
parentRunId: input.parentRunId,
|
|
521
685
|
spawnKey: input.spawnKey,
|
|
522
686
|
spec: clone(input.spec),
|
|
523
687
|
status: "queued",
|
|
524
688
|
attempt: 0,
|
|
525
|
-
createdAt
|
|
689
|
+
createdAt
|
|
690
|
+
};
|
|
691
|
+
const trigger = {
|
|
692
|
+
id: input.trigger.id,
|
|
693
|
+
projectId: input.projectId,
|
|
694
|
+
threadId: input.thread.id,
|
|
695
|
+
runId: input.id,
|
|
696
|
+
role: "user",
|
|
697
|
+
seq: nextMessageSeq(this.state, input.projectId, input.thread.id),
|
|
698
|
+
parts: clone(input.trigger.parts),
|
|
699
|
+
...input.trigger.metadata === undefined ? {} : { metadata: clone(input.trigger.metadata) },
|
|
700
|
+
contentVersion: AGENT_MESSAGE_CONTENT_VERSION2,
|
|
701
|
+
createdAt
|
|
526
702
|
};
|
|
703
|
+
if (this.state.messages.has(key(input.projectId, trigger.id))) {
|
|
704
|
+
throw new AgentStorageError2("duplicate_id", `[Sixb] Agent message '${trigger.id}' already exists for project '${input.projectId}'.`);
|
|
705
|
+
}
|
|
706
|
+
this.state.threads.set(threadKey, clone(thread));
|
|
707
|
+
this.state.messages.set(key(input.projectId, trigger.id), clone(trigger));
|
|
527
708
|
this.state.runs.set(runKey, clone(run));
|
|
528
709
|
return clone(run);
|
|
529
710
|
}
|
|
@@ -584,11 +765,13 @@ class InMemoryAgentRunStore {
|
|
|
584
765
|
if (!run.execution || run.execution.token !== input.executionToken) {
|
|
585
766
|
throw new AgentStorageError2("execution_lost", `[Sixb] Execution token is no longer current on agent run '${input.id}'.`);
|
|
586
767
|
}
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
768
|
+
assertAgentRunFinishPayload2(run.kind, input, run.id, "Sixb");
|
|
769
|
+
if (input.finishReason === "awaiting_approval") {
|
|
770
|
+
assertAwaitingApprovalFinish2({
|
|
771
|
+
runId: run.id,
|
|
772
|
+
status: input.status,
|
|
773
|
+
holdsApproval: holdsRun(this.state, run.projectId, run.id)
|
|
774
|
+
});
|
|
592
775
|
}
|
|
593
776
|
const completedAt = new Date(input.completedAt ?? new Date);
|
|
594
777
|
const next = {
|
|
@@ -604,6 +787,7 @@ class InMemoryAgentRunStore {
|
|
|
604
787
|
};
|
|
605
788
|
this.state.runs.set(key(input.projectId, input.id), clone(next));
|
|
606
789
|
this.releaseThread(run, completedAt);
|
|
790
|
+
this.settleApprovals(run, input, completedAt);
|
|
607
791
|
return clone(next);
|
|
608
792
|
}
|
|
609
793
|
async getById(params) {
|
|
@@ -613,11 +797,20 @@ class InMemoryAgentRunStore {
|
|
|
613
797
|
async getByIds(params) {
|
|
614
798
|
return [...new Set(params.ids)].map((id) => this.state.runs.get(key(params.projectId, id))).filter((record) => record !== undefined).map(clone);
|
|
615
799
|
}
|
|
800
|
+
async listThreadSubagents(input) {
|
|
801
|
+
const runs = [...this.state.runs.values()].filter((run) => run.projectId === input.projectId);
|
|
802
|
+
const turns = new Map(runs.flatMap((run) => run.kind === "conversation" && run.threadId === input.threadId ? [[run.id, run]] : []));
|
|
803
|
+
const children = runs.filter((run) => run.kind === "subagent").filter((run) => turns.has(run.parentRunId)).filter((run) => input.spawnKey === undefined ? true : run.spawnKey === input.spawnKey).filter((run) => input.finishReason === undefined ? true : run.finishReason === input.finishReason).sort((left, right) => {
|
|
804
|
+
const [a, b] = [turns.get(left.parentRunId), turns.get(right.parentRunId)];
|
|
805
|
+
return compareByDate(a?.startedAt ?? a?.createdAt, b?.startedAt ?? b?.createdAt, left.parentRunId, right.parentRunId, "desc") || compareByDate(left.createdAt, right.createdAt, left.id, right.id, "desc");
|
|
806
|
+
});
|
|
807
|
+
return children.slice(0, input.limit ?? 100).map(clone);
|
|
808
|
+
}
|
|
616
809
|
async list(input) {
|
|
617
810
|
const order = input.order ?? "desc";
|
|
618
811
|
const statuses = input.statuses ? new Set(input.statuses) : null;
|
|
619
812
|
const kinds = input.kinds ? new Set(input.kinds) : null;
|
|
620
|
-
const filtered = [...this.state.runs.values()].filter((run) => run.projectId === input.projectId).filter((run) => kinds ? kinds.has(run.kind) : true).filter((run) => input.threadId ? run.
|
|
813
|
+
const filtered = [...this.state.runs.values()].filter((run) => run.projectId === input.projectId).filter((run) => kinds ? kinds.has(run.kind) : true).filter((run) => input.threadId ? run.threadId === input.threadId : true).filter((run) => input.parentRunId ? run.kind === "subagent" && run.parentRunId === input.parentRunId : true).filter((run) => statuses ? statuses.has(run.status) : true).filter((run) => input.startedAfter ? (run.startedAt ?? run.createdAt) >= input.startedAfter : true).filter((run) => input.startedBefore ? (run.startedAt ?? run.createdAt) <= input.startedBefore : true).sort((a, b) => compareByDate(a.startedAt ?? a.createdAt, b.startedAt ?? b.createdAt, a.id, b.id, order));
|
|
621
814
|
const { page, hasMore, total } = applyWindow(filtered, input.offset, input.limit);
|
|
622
815
|
return { runs: page.map(clone), hasMore, total };
|
|
623
816
|
}
|
|
@@ -634,9 +827,28 @@ class InMemoryAgentRunStore {
|
|
|
634
827
|
}
|
|
635
828
|
return run;
|
|
636
829
|
}
|
|
637
|
-
|
|
638
|
-
if (
|
|
830
|
+
settleApprovals(run, input, at) {
|
|
831
|
+
if (input.finishReason === "awaiting_approval" || !agentRunMayHoldCalls2(run))
|
|
832
|
+
return;
|
|
833
|
+
const turn = run.kind === "conversation";
|
|
834
|
+
if (!turn && input.status === "succeeded")
|
|
639
835
|
return;
|
|
836
|
+
for (const [approvalKey, approval] of this.state.approvals) {
|
|
837
|
+
if (approval.projectId !== run.projectId)
|
|
838
|
+
continue;
|
|
839
|
+
const ownCall = approval.runId === run.id || approval.callerRunId === run.id;
|
|
840
|
+
const cancel = approval.status === "pending" && ownCall;
|
|
841
|
+
const stop = turn && approval.runId === run.id && approval.reportedInMessageId === undefined && approval.turnStoppedAt === undefined;
|
|
842
|
+
if (!cancel && !stop)
|
|
843
|
+
continue;
|
|
844
|
+
this.state.approvals.set(approvalKey, {
|
|
845
|
+
...approval,
|
|
846
|
+
...cancel ? { status: "cancelled" } : {},
|
|
847
|
+
...stop ? { turnStoppedAt: new Date(at) } : {}
|
|
848
|
+
});
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
releaseThread(run, completedAt) {
|
|
640
852
|
const threadKey = key(run.projectId, run.threadId);
|
|
641
853
|
const thread = this.state.threads.get(threadKey);
|
|
642
854
|
if (thread && thread.activeRunId === run.id) {
|
|
@@ -664,7 +876,7 @@ class InMemoryAgentMessageStore {
|
|
|
664
876
|
throw new AgentStorageError2("run_not_found", `[Sixb] Agent run '${input.runId}' not found for project '${input.projectId}'.`);
|
|
665
877
|
}
|
|
666
878
|
const createdAt = new Date(input.createdAt ?? new Date);
|
|
667
|
-
const seq = this.
|
|
879
|
+
const seq = nextMessageSeq(this.state, input.projectId, input.threadId);
|
|
668
880
|
const message = {
|
|
669
881
|
id: input.id,
|
|
670
882
|
projectId: input.projectId,
|
|
@@ -682,7 +894,7 @@ class InMemoryAgentMessageStore {
|
|
|
682
894
|
this.state.messages.set(messageKey, clone(message));
|
|
683
895
|
this.state.threads.set(threadKey, clone({
|
|
684
896
|
...thread,
|
|
685
|
-
messageCount: thread.messageCount + 1,
|
|
897
|
+
messageCount: thread.messageCount + (countsAsThreadMessage2(input) ? 1 : 0),
|
|
686
898
|
lastMessageAt: createdAt,
|
|
687
899
|
updatedAt: createdAt
|
|
688
900
|
}));
|
|
@@ -706,7 +918,7 @@ class InMemoryAgentMessageStore {
|
|
|
706
918
|
const updatedAt = new Date;
|
|
707
919
|
this.state.threads.set(threadKey, clone({
|
|
708
920
|
...thread,
|
|
709
|
-
messageCount: remainingMessages.length,
|
|
921
|
+
messageCount: remainingMessages.filter(countsAsThreadMessage2).length,
|
|
710
922
|
lastMessageAt: latestMessage?.createdAt,
|
|
711
923
|
updatedAt
|
|
712
924
|
}));
|
|
@@ -723,15 +935,15 @@ class InMemoryAgentMessageStore {
|
|
|
723
935
|
const { page, hasMore, total } = applyWindow(filtered, input.offset, input.limit);
|
|
724
936
|
return { messages: page.map(clone), hasMore, total };
|
|
725
937
|
}
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
938
|
+
}
|
|
939
|
+
function nextMessageSeq(state, projectId, threadId) {
|
|
940
|
+
let max = 0;
|
|
941
|
+
for (const message of state.messages.values()) {
|
|
942
|
+
if (message.projectId === projectId && message.threadId === threadId && message.seq > max) {
|
|
943
|
+
max = message.seq;
|
|
732
944
|
}
|
|
733
|
-
return max + 1;
|
|
734
945
|
}
|
|
946
|
+
return max + 1;
|
|
735
947
|
}
|
|
736
948
|
|
|
737
949
|
class InMemoryAgentContextCheckpointStore {
|
|
@@ -747,7 +959,7 @@ class InMemoryAgentContextCheckpointStore {
|
|
|
747
959
|
const messages = [...this.state.messages.values()].filter((message) => message.projectId === input.projectId && message.threadId === input.threadId);
|
|
748
960
|
const headSeq = messages.reduce((head, message) => Math.max(head, message.seq), 0);
|
|
749
961
|
const latest = this.findLatest(input.projectId, input.threadId);
|
|
750
|
-
const existingForRun = [...this.state.checkpoints.values()].find((checkpoint) => checkpoint.projectId === input.projectId && checkpoint.createdByRunId === input.createdByRunId);
|
|
962
|
+
const existingForRun = [...this.state.checkpoints.values()].find((checkpoint) => checkpoint.projectId === input.projectId && checkpoint.threadId === input.threadId && checkpoint.createdByRunId === input.createdByRunId);
|
|
751
963
|
if (existingForRun) {
|
|
752
964
|
if (agentContextCheckpointMatchesCreateInput2(existingForRun, input)) {
|
|
753
965
|
assertAgentContextCheckpointReplayState2({
|
|
@@ -794,47 +1006,320 @@ class InMemoryAgentContextCheckpointStore {
|
|
|
794
1006
|
return record ? clone(record) : null;
|
|
795
1007
|
}
|
|
796
1008
|
async getByRunIds(input) {
|
|
797
|
-
const byRunId = new Map([...this.state.checkpoints.values()].filter((checkpoint) => checkpoint.projectId === input.projectId).map((checkpoint) => [checkpoint.createdByRunId, checkpoint]));
|
|
1009
|
+
const byRunId = new Map([...this.state.checkpoints.values()].filter((checkpoint) => checkpoint.projectId === input.projectId).filter((checkpoint) => checkpoint.threadId === input.threadId).map((checkpoint) => [checkpoint.createdByRunId, checkpoint]));
|
|
798
1010
|
return [...new Set(input.runIds)].flatMap((runId) => {
|
|
799
1011
|
const checkpoint = byRunId.get(runId);
|
|
800
1012
|
return checkpoint ? [clone(checkpoint)] : [];
|
|
801
1013
|
});
|
|
802
1014
|
}
|
|
803
1015
|
findLatest(projectId, threadId) {
|
|
804
|
-
return [...this.state.checkpoints.values()].filter((checkpoint) => checkpoint.projectId === projectId && checkpoint.threadId === threadId).sort(
|
|
1016
|
+
return [...this.state.checkpoints.values()].filter((checkpoint) => checkpoint.projectId === projectId && checkpoint.threadId === threadId).sort(compareLatestCheckpoints)[0] ?? null;
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
function compareLatestCheckpoints(left, right) {
|
|
1020
|
+
return right.summarizedThroughSeq - left.summarizedThroughSeq || right.createdAt.getTime() - left.createdAt.getTime() || right.id.localeCompare(left.id);
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
class InMemoryAgentMemoryStore {
|
|
1024
|
+
state;
|
|
1025
|
+
constructor(state) {
|
|
1026
|
+
this.state = state;
|
|
1027
|
+
}
|
|
1028
|
+
async get(input) {
|
|
1029
|
+
const repo = this.state.memory.get(key(input.projectId, input.repoId));
|
|
1030
|
+
const { asOf, revision: upTo } = input;
|
|
1031
|
+
const saved = repo?.revisions.filter((entry) => (!asOf || entry.createdAt.getTime() <= asOf.getTime()) && (upTo === undefined || entry.revision <= upTo));
|
|
1032
|
+
const revision = saved?.reduce((highest, entry) => Math.max(highest, entry.revision), 0) ?? 0;
|
|
1033
|
+
if (!repo || revision === 0)
|
|
1034
|
+
return { revision: 0, files: [] };
|
|
1035
|
+
const files = [
|
|
1036
|
+
...latestMemoryFiles({
|
|
1037
|
+
revisions: repo.revisions,
|
|
1038
|
+
files: repo.files.filter((file) => file.revision <= revision)
|
|
1039
|
+
}).values()
|
|
1040
|
+
].flatMap((file) => file.contents === null ? [] : [{ path: file.path, contents: file.contents }]).sort((left, right) => compareAgentMemoryPaths2(left.path, right.path));
|
|
1041
|
+
return { revision, files };
|
|
1042
|
+
}
|
|
1043
|
+
async save(input) {
|
|
1044
|
+
assertSaveAgentMemoryInput2(input);
|
|
1045
|
+
const repoKey = key(input.projectId, input.repoId);
|
|
1046
|
+
const repo = this.state.memory.get(repoKey) ?? { revisions: [], files: [] };
|
|
1047
|
+
const head = repo.revisions.at(-1)?.revision ?? 0;
|
|
1048
|
+
const conflicts = agentMemoryConflicts2(input, head, latestMemoryFiles(repo));
|
|
1049
|
+
if (conflicts.length > 0)
|
|
1050
|
+
return { saved: false, revision: head, conflicts };
|
|
1051
|
+
const revision = head + 1;
|
|
1052
|
+
const createdAt = input.createdAt ?? new Date;
|
|
1053
|
+
const revisions = [
|
|
1054
|
+
...repo.revisions,
|
|
1055
|
+
{
|
|
1056
|
+
revision,
|
|
1057
|
+
message: input.message,
|
|
1058
|
+
author: clone(input.author),
|
|
1059
|
+
...input.source === undefined ? {} : { source: input.source },
|
|
1060
|
+
createdAt: new Date(createdAt)
|
|
1061
|
+
}
|
|
1062
|
+
];
|
|
1063
|
+
const files = [...repo.files, ...input.changes.map((change) => ({ ...change, revision }))];
|
|
1064
|
+
const cutoff = agentMemoryHistoryCutoff2(createdAt).getTime();
|
|
1065
|
+
const savedAt = new Map(revisions.map((entry) => [entry.revision, entry.createdAt.getTime()]));
|
|
1066
|
+
const latest = latestMemoryFiles({ revisions, files });
|
|
1067
|
+
this.state.memory.set(repoKey, {
|
|
1068
|
+
revisions,
|
|
1069
|
+
files: files.filter((file) => latest.get(file.path) === file || (savedAt.get(file.revision) ?? 0) >= cutoff)
|
|
1070
|
+
});
|
|
1071
|
+
return { saved: true, revision };
|
|
1072
|
+
}
|
|
1073
|
+
async listRevisions(input) {
|
|
1074
|
+
const repo = this.state.memory.get(key(input.projectId, input.repoId));
|
|
1075
|
+
const newestFirst = [...repo?.revisions ?? []].reverse();
|
|
1076
|
+
const { page, hasMore, total } = applyWindow(newestFirst, input.offset, input.limit);
|
|
1077
|
+
const revisions = page.map((entry) => ({
|
|
1078
|
+
...clone(entry),
|
|
1079
|
+
changes: (repo?.files ?? []).filter((file) => file.revision === entry.revision).map((file) => ({ path: file.path, deleted: file.contents === null })).sort((left, right) => compareAgentMemoryPaths2(left.path, right.path))
|
|
1080
|
+
}));
|
|
1081
|
+
return { revisions, hasMore, total };
|
|
1082
|
+
}
|
|
1083
|
+
async delete(input) {
|
|
1084
|
+
this.state.memory.delete(key(input.projectId, input.repoId));
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
function latestMemoryFiles(repo) {
|
|
1088
|
+
const latest = new Map;
|
|
1089
|
+
for (const file of repo.files)
|
|
1090
|
+
latest.set(file.path, file);
|
|
1091
|
+
return latest;
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
class InMemoryAgentApprovalStore {
|
|
1095
|
+
state;
|
|
1096
|
+
constructor(state) {
|
|
1097
|
+
this.state = state;
|
|
1098
|
+
}
|
|
1099
|
+
async request(input) {
|
|
1100
|
+
assertRequestAgentApprovalInput2(input);
|
|
1101
|
+
const threadId = assertAgentApprovalCaller2({
|
|
1102
|
+
request: input,
|
|
1103
|
+
turn: this.state.runs.get(key(input.projectId, input.runId)) ?? null,
|
|
1104
|
+
caller: this.state.runs.get(key(input.projectId, input.callerRunId)) ?? null
|
|
1105
|
+
});
|
|
1106
|
+
const callKey = agentApprovalCallKey2(input.call);
|
|
1107
|
+
const live = [...this.state.approvals.values()].find((approval) => approval.projectId === input.projectId && approval.threadId === threadId && approval.callKey === callKey && LIVE_AGENT_APPROVAL_STATUSES2.includes(approval.status));
|
|
1108
|
+
if (live)
|
|
1109
|
+
return { approval: clone(live), created: false };
|
|
1110
|
+
if (this.state.approvals.has(key(input.projectId, input.id))) {
|
|
1111
|
+
throw new AgentStorageError2("duplicate_id", `[Sixb] Agent approval '${input.id}' already exists for project '${input.projectId}'.`);
|
|
1112
|
+
}
|
|
1113
|
+
const approval = newAgentApprovalRecord2(input, threadId);
|
|
1114
|
+
this.state.approvals.set(key(input.projectId, input.id), clone(approval));
|
|
1115
|
+
return { approval: clone(approval), created: true };
|
|
1116
|
+
}
|
|
1117
|
+
async decide(input) {
|
|
1118
|
+
const approvalKey = key(input.projectId, input.id);
|
|
1119
|
+
const approval = this.state.approvals.get(approvalKey);
|
|
1120
|
+
if (!approval)
|
|
1121
|
+
return null;
|
|
1122
|
+
if (approval.status !== "pending")
|
|
1123
|
+
return { approval: clone(approval), decided: false };
|
|
1124
|
+
const decidedAt = new Date(input.decidedAt ?? new Date);
|
|
1125
|
+
const next = approval.expiresAt <= decidedAt ? { ...approval, status: "expired" } : {
|
|
1126
|
+
...approval,
|
|
1127
|
+
status: input.decision,
|
|
1128
|
+
decidedAt,
|
|
1129
|
+
decidedBy: clone(input.decidedBy),
|
|
1130
|
+
...input.decision === "approved" && input.raisedMode !== undefined ? { raisedMode: input.raisedMode } : {}
|
|
1131
|
+
};
|
|
1132
|
+
this.state.approvals.set(approvalKey, clone(next));
|
|
1133
|
+
return { approval: clone(next), decided: next.status === input.decision };
|
|
1134
|
+
}
|
|
1135
|
+
async recordOutcome(input) {
|
|
1136
|
+
const approvalKey = key(input.projectId, input.id);
|
|
1137
|
+
const approval = this.state.approvals.get(approvalKey);
|
|
1138
|
+
if (!approval) {
|
|
1139
|
+
throw new AgentStorageError2("invalid_state", `[Sixb] Agent approval '${input.id}' not found for project '${input.projectId}'.`);
|
|
1140
|
+
}
|
|
1141
|
+
if (approval.status !== "approved") {
|
|
1142
|
+
throw new AgentStorageError2("invalid_state", `[Sixb] Agent approval '${input.id}' is not approved (status '${approval.status}').`);
|
|
1143
|
+
}
|
|
1144
|
+
if (approval.outcome)
|
|
1145
|
+
return clone(approval);
|
|
1146
|
+
const next = { ...approval, outcome: clone(input.outcome) };
|
|
1147
|
+
this.state.approvals.set(approvalKey, clone(next));
|
|
1148
|
+
return clone(next);
|
|
1149
|
+
}
|
|
1150
|
+
async settle(input) {
|
|
1151
|
+
const settled = [];
|
|
1152
|
+
for (const [approvalKey, approval] of this.state.approvals) {
|
|
1153
|
+
if (approval.projectId !== input.projectId || approval.threadId !== input.threadId || approval.status !== "pending") {
|
|
1154
|
+
continue;
|
|
1155
|
+
}
|
|
1156
|
+
const next = { ...approval, status: input.status };
|
|
1157
|
+
this.state.approvals.set(approvalKey, clone(next));
|
|
1158
|
+
settled.push(next);
|
|
1159
|
+
}
|
|
1160
|
+
return settled.sort(compareApprovals).map(clone);
|
|
1161
|
+
}
|
|
1162
|
+
async expireDue(input) {
|
|
1163
|
+
const due = [...this.state.approvals.values()].filter((approval) => approval.projectId === input.projectId && approval.status === "pending" && approval.expiresAt <= input.now).sort(compareApprovals).slice(0, input.limit);
|
|
1164
|
+
return due.map((approval) => {
|
|
1165
|
+
const next = { ...approval, status: "expired" };
|
|
1166
|
+
this.state.approvals.set(key(approval.projectId, approval.id), clone(next));
|
|
1167
|
+
return clone(next);
|
|
1168
|
+
});
|
|
1169
|
+
}
|
|
1170
|
+
async stop(input) {
|
|
1171
|
+
const stoppedAt = new Date(input.stoppedAt ?? new Date);
|
|
1172
|
+
const cancelled = [];
|
|
1173
|
+
let stopped = 0;
|
|
1174
|
+
for (const [approvalKey, approval] of this.state.approvals) {
|
|
1175
|
+
if (!agentApprovalStops2(approval, input))
|
|
1176
|
+
continue;
|
|
1177
|
+
const cancel = approval.status === "pending";
|
|
1178
|
+
const stop = approval.turnStoppedAt === undefined;
|
|
1179
|
+
if (!cancel && !stop)
|
|
1180
|
+
continue;
|
|
1181
|
+
const next = {
|
|
1182
|
+
...approval,
|
|
1183
|
+
...cancel ? { status: "cancelled" } : {},
|
|
1184
|
+
...stop ? { turnStoppedAt: stoppedAt } : {}
|
|
1185
|
+
};
|
|
1186
|
+
this.state.approvals.set(approvalKey, clone(next));
|
|
1187
|
+
if (cancel)
|
|
1188
|
+
cancelled.push(next);
|
|
1189
|
+
if (stop)
|
|
1190
|
+
stopped += 1;
|
|
1191
|
+
}
|
|
1192
|
+
return { cancelled: cancelled.sort(compareApprovals).map(clone), stopped };
|
|
1193
|
+
}
|
|
1194
|
+
async holdsRun(input) {
|
|
1195
|
+
return holdsRun(this.state, input.projectId, input.runId);
|
|
1196
|
+
}
|
|
1197
|
+
async claimExecution(input) {
|
|
1198
|
+
const approvalKey = key(input.projectId, input.id);
|
|
1199
|
+
const approval = this.state.approvals.get(approvalKey);
|
|
1200
|
+
if (!approval || !agentApprovalClaimable2(approval, input.staleBefore))
|
|
1201
|
+
return null;
|
|
1202
|
+
const next = { ...approval, executionClaimedAt: new Date(input.claimedAt) };
|
|
1203
|
+
this.state.approvals.set(approvalKey, clone(next));
|
|
1204
|
+
return clone(next);
|
|
805
1205
|
}
|
|
1206
|
+
async listRepairable(input) {
|
|
1207
|
+
const { after } = input;
|
|
1208
|
+
return [...this.state.approvals.values()].filter((approval) => approval.projectId === input.projectId && agentApprovalRepairable2(approval, input.claimableBefore) && (after === undefined || approval.createdAt > after.createdAt || approval.createdAt.getTime() === after.createdAt.getTime() && approval.id > after.id)).sort(compareApprovals).slice(0, input.limit).map(clone);
|
|
1209
|
+
}
|
|
1210
|
+
async markReported(input) {
|
|
1211
|
+
const marked = [];
|
|
1212
|
+
for (const id of new Set(input.ids)) {
|
|
1213
|
+
const approvalKey = key(input.projectId, id);
|
|
1214
|
+
const approval = this.state.approvals.get(approvalKey);
|
|
1215
|
+
if (!approval || approval.threadId !== input.threadId || approval.reportedInMessageId !== undefined || input.resuming === true && approval.turnStoppedAt !== undefined) {
|
|
1216
|
+
continue;
|
|
1217
|
+
}
|
|
1218
|
+
this.state.approvals.set(approvalKey, { ...approval, reportedInMessageId: input.messageId });
|
|
1219
|
+
marked.push(id);
|
|
1220
|
+
}
|
|
1221
|
+
return marked;
|
|
1222
|
+
}
|
|
1223
|
+
async getById(params) {
|
|
1224
|
+
const approval = this.state.approvals.get(key(params.projectId, params.id));
|
|
1225
|
+
return approval ? clone(approval) : null;
|
|
1226
|
+
}
|
|
1227
|
+
async list(input) {
|
|
1228
|
+
const matching = [...this.state.approvals.values()].filter((approval) => agentApprovalMatches2(approval, input)).sort(compareApprovals);
|
|
1229
|
+
const { page, hasMore, total } = applyWindow(matching, input.offset, input.limit);
|
|
1230
|
+
return { approvals: page.map(clone), hasMore, total };
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
function holdsRun(state, projectId, runId) {
|
|
1234
|
+
return [...state.approvals.values()].some((approval) => approval.projectId === projectId && agentApprovalHoldsRun2(approval, runId));
|
|
1235
|
+
}
|
|
1236
|
+
function compareApprovals(left, right) {
|
|
1237
|
+
return compareByDate(left.createdAt, right.createdAt, left.id, right.id, "asc");
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1240
|
+
class InMemoryAgentApprovalModeStore {
|
|
1241
|
+
state;
|
|
1242
|
+
constructor(state) {
|
|
1243
|
+
this.state = state;
|
|
1244
|
+
}
|
|
1245
|
+
async getDefault(input) {
|
|
1246
|
+
return this.state.approvalModes.get(defaultModeKey(input)) ?? null;
|
|
1247
|
+
}
|
|
1248
|
+
async setDefault(input) {
|
|
1249
|
+
assertAgentApprovalModeInput2(input.mode);
|
|
1250
|
+
this.state.approvalModes.set(defaultModeKey(input), input.mode);
|
|
1251
|
+
}
|
|
1252
|
+
async getForThread(input) {
|
|
1253
|
+
return this.state.approvalModes.get(threadModeKey(input)) ?? null;
|
|
1254
|
+
}
|
|
1255
|
+
async setForThread(input) {
|
|
1256
|
+
if (input.mode !== null)
|
|
1257
|
+
assertAgentApprovalModeInput2(input.mode);
|
|
1258
|
+
if (!this.state.threads.has(key(input.projectId, input.threadId))) {
|
|
1259
|
+
throw new AgentStorageError2("thread_not_found", `[Sixb] Agent thread '${input.threadId}' not found for project '${input.projectId}'.`);
|
|
1260
|
+
}
|
|
1261
|
+
if (input.mode === null) {
|
|
1262
|
+
this.state.approvalModes.delete(threadModeKey(input));
|
|
1263
|
+
return;
|
|
1264
|
+
}
|
|
1265
|
+
this.state.approvalModes.set(threadModeKey(input), input.mode);
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
function defaultModeKey(input) {
|
|
1269
|
+
return JSON.stringify([input.projectId, input.principal.type, input.principal.id]);
|
|
1270
|
+
}
|
|
1271
|
+
function threadModeKey(input) {
|
|
1272
|
+
return JSON.stringify([input.projectId, input.threadId, input.principal.type, input.principal.id]);
|
|
806
1273
|
}
|
|
807
1274
|
|
|
808
1275
|
class InMemoryAgentStorage2 {
|
|
809
1276
|
state = {
|
|
810
1277
|
threads: new Map,
|
|
1278
|
+
participants: new Map,
|
|
811
1279
|
runs: new Map,
|
|
812
1280
|
messages: new Map,
|
|
813
|
-
checkpoints: new Map
|
|
1281
|
+
checkpoints: new Map,
|
|
1282
|
+
memory: new Map,
|
|
1283
|
+
approvals: new Map,
|
|
1284
|
+
approvalModes: new Map
|
|
814
1285
|
};
|
|
815
1286
|
threads;
|
|
816
1287
|
runs;
|
|
817
1288
|
messages;
|
|
818
1289
|
checkpoints;
|
|
1290
|
+
memory;
|
|
1291
|
+
approvals;
|
|
1292
|
+
approvalModes;
|
|
819
1293
|
constructor(executions) {
|
|
820
1294
|
this.threads = new InMemoryAgentThreadStore(this.state);
|
|
821
1295
|
this.runs = new InMemoryAgentRunStore(this.state, executions);
|
|
822
1296
|
this.messages = new InMemoryAgentMessageStore(this.state);
|
|
823
1297
|
this.checkpoints = new InMemoryAgentContextCheckpointStore(this.state);
|
|
1298
|
+
this.memory = new InMemoryAgentMemoryStore(this.state);
|
|
1299
|
+
this.approvals = new InMemoryAgentApprovalStore(this.state);
|
|
1300
|
+
this.approvalModes = new InMemoryAgentApprovalModeStore(this.state);
|
|
824
1301
|
}
|
|
825
1302
|
snapshot() {
|
|
826
1303
|
return {
|
|
827
1304
|
threads: structuredClone(this.state.threads),
|
|
1305
|
+
participants: structuredClone(this.state.participants),
|
|
828
1306
|
runs: structuredClone(this.state.runs),
|
|
829
1307
|
messages: structuredClone(this.state.messages),
|
|
830
|
-
checkpoints: structuredClone(this.state.checkpoints)
|
|
1308
|
+
checkpoints: structuredClone(this.state.checkpoints),
|
|
1309
|
+
memory: structuredClone(this.state.memory),
|
|
1310
|
+
approvals: structuredClone(this.state.approvals),
|
|
1311
|
+
approvalModes: structuredClone(this.state.approvalModes)
|
|
831
1312
|
};
|
|
832
1313
|
}
|
|
833
1314
|
restore(snapshot) {
|
|
834
1315
|
replace(this.state.threads, snapshot.threads);
|
|
1316
|
+
replace(this.state.participants, snapshot.participants);
|
|
835
1317
|
replace(this.state.runs, snapshot.runs);
|
|
836
1318
|
replace(this.state.messages, snapshot.messages);
|
|
837
1319
|
replace(this.state.checkpoints, snapshot.checkpoints);
|
|
1320
|
+
replace(this.state.memory, snapshot.memory);
|
|
1321
|
+
replace(this.state.approvals, snapshot.approvals);
|
|
1322
|
+
replace(this.state.approvalModes, snapshot.approvalModes);
|
|
838
1323
|
}
|
|
839
1324
|
}
|
|
840
1325
|
function replace(target, source) {
|
|
@@ -2338,135 +2823,617 @@ class InMemoryFileUploadSessionPersistence {
|
|
|
2338
2823
|
// src/storage/in-memory/index.ts
|
|
2339
2824
|
import { AsyncLocalStorage } from "async_hooks";
|
|
2340
2825
|
|
|
2341
|
-
// src/storage/
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
restore(snapshot) {
|
|
2361
|
-
this.rows.clear();
|
|
2362
|
-
for (const [key, record] of structuredClone(snapshot)) {
|
|
2363
|
-
this.rows.set(key, record);
|
|
2364
|
-
}
|
|
2365
|
-
}
|
|
2366
|
-
async create(input) {
|
|
2367
|
-
return this.runRootOperation(async () => {
|
|
2368
|
-
const key = executionKey(input.projectId, input.id);
|
|
2369
|
-
if (this.rows.has(key)) {
|
|
2370
|
-
throw new ExecutionStorageError2("duplicate_execution", `[Sixb] Execution '${input.id}' already exists in project '${input.projectId}'.`);
|
|
2826
|
+
// src/storage/activity/in-memory.ts
|
|
2827
|
+
class InMemoryActivityStorage {
|
|
2828
|
+
sources = new Map;
|
|
2829
|
+
visits = new Map;
|
|
2830
|
+
pageViews = [];
|
|
2831
|
+
interactions = [];
|
|
2832
|
+
async append(input) {
|
|
2833
|
+
validateActivityAppend2(input);
|
|
2834
|
+
const sourceKey = JSON.stringify([input.projectId, input.actor.type, input.sessionId]);
|
|
2835
|
+
const stored = [...this.pageViews, ...this.interactions].filter((event) => event.projectId === input.projectId && this.isFromSession(event, input) && input.events.some((candidate) => candidate.id === event.id));
|
|
2836
|
+
const plan = planActivityAppend2(input, this.source(sourceKey, input.projectId), stored);
|
|
2837
|
+
if (plan.status !== "append") {
|
|
2838
|
+
return { status: plan.status === "duplicate" ? "accepted" : "throttled", accepted: 0 };
|
|
2839
|
+
}
|
|
2840
|
+
const visitKey = JSON.stringify([input.projectId, plan.state.visitId]);
|
|
2841
|
+
const lastSeenAt = new Date(plan.state.lastSeenAt);
|
|
2842
|
+
if (plan.newVisit) {
|
|
2843
|
+
if (this.visits.has(visitKey)) {
|
|
2844
|
+
throw new Error("[Sixb] Activity visit id already exists.");
|
|
2371
2845
|
}
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2846
|
+
this.visits.set(visitKey, {
|
|
2847
|
+
projectId: input.projectId,
|
|
2848
|
+
id: plan.state.visitId,
|
|
2849
|
+
actor: structuredClone(input.actor),
|
|
2850
|
+
sessionId: input.sessionId,
|
|
2851
|
+
attribution: plan.newVisit.attribution,
|
|
2852
|
+
startedAt: lastSeenAt,
|
|
2853
|
+
lastSeenAt,
|
|
2854
|
+
pageViews: plan.pageViews.length,
|
|
2855
|
+
interactions: plan.interactions.length
|
|
2379
2856
|
});
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2857
|
+
} else {
|
|
2858
|
+
const visit = this.requireVisit(input.projectId, plan.state.visitId);
|
|
2859
|
+
visit.lastSeenAt = lastSeenAt;
|
|
2860
|
+
visit.pageViews += plan.pageViews.length;
|
|
2861
|
+
visit.interactions += plan.interactions.length;
|
|
2862
|
+
}
|
|
2863
|
+
const { visitStartedAt: _startedAt, ...source } = plan.state;
|
|
2864
|
+
this.sources.set(sourceKey, source);
|
|
2865
|
+
for (const pageView of plan.pageViews) {
|
|
2866
|
+
this.pageViews.push({ ...pageView, projectId: input.projectId });
|
|
2867
|
+
}
|
|
2868
|
+
for (const interaction of plan.interactions) {
|
|
2869
|
+
this.interactions.push({ ...interaction, projectId: input.projectId });
|
|
2870
|
+
}
|
|
2871
|
+
return { status: "accepted", accepted: plan.accepted };
|
|
2383
2872
|
}
|
|
2384
|
-
async
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2873
|
+
async list(input) {
|
|
2874
|
+
const visits = this.overlapping(input).filter((visit) => isBefore(visit.lastSeenAt, visit.id, input.before)).sort(byLastSeenDescending((visit) => visit.id));
|
|
2875
|
+
return {
|
|
2876
|
+
visits: visits.slice(0, input.limit).map(toVisit),
|
|
2877
|
+
hasMore: visits.length > input.limit
|
|
2878
|
+
};
|
|
2389
2879
|
}
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2880
|
+
async users(input) {
|
|
2881
|
+
const byUser = new Map;
|
|
2882
|
+
for (const visit of this.overlapping(input)) {
|
|
2883
|
+
if (visit.actor.type !== "user") {
|
|
2884
|
+
continue;
|
|
2885
|
+
}
|
|
2886
|
+
const user = byUser.get(visit.actor.userId) ?? {
|
|
2887
|
+
lastSeenAt: visit.lastSeenAt,
|
|
2888
|
+
visits: 0,
|
|
2889
|
+
pageViews: 0
|
|
2890
|
+
};
|
|
2891
|
+
if (visit.lastSeenAt > user.lastSeenAt) {
|
|
2892
|
+
user.lastSeenAt = visit.lastSeenAt;
|
|
2893
|
+
}
|
|
2894
|
+
user.visits += 1;
|
|
2895
|
+
user.pageViews += this.pageViewsInPeriod(visit, input).length;
|
|
2896
|
+
byUser.set(visit.actor.userId, user);
|
|
2399
2897
|
}
|
|
2400
|
-
|
|
2898
|
+
const users = [...byUser].map(([userId, user]) => ({ userId, ...user })).filter((user) => isBefore(user.lastSeenAt, user.userId, input.before)).sort(byLastSeenDescending((user) => user.userId));
|
|
2899
|
+
return {
|
|
2900
|
+
users: users.slice(0, input.limit).map((user) => ({ ...user })),
|
|
2901
|
+
hasMore: users.length > input.limit
|
|
2902
|
+
};
|
|
2401
2903
|
}
|
|
2402
|
-
async
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2904
|
+
async summarize(input) {
|
|
2905
|
+
const visits = this.overlapping(input);
|
|
2906
|
+
const userIds = visits.flatMap((visit) => visit.actor.type === "user" ? [visit.actor.userId] : []);
|
|
2907
|
+
return {
|
|
2908
|
+
users: new Set(userIds).size,
|
|
2909
|
+
visits: visits.length,
|
|
2910
|
+
sharedVisits: visits.filter((visit) => visit.actor.type === "share").length,
|
|
2911
|
+
pageViews: visits.reduce((total, visit) => total + this.pageViewsInPeriod(visit, input).length, 0)
|
|
2912
|
+
};
|
|
2913
|
+
}
|
|
2914
|
+
async calendar(input) {
|
|
2915
|
+
const visits = this.overlapping(input);
|
|
2916
|
+
const pageViewsByDay = new Map;
|
|
2917
|
+
for (const visit of visits) {
|
|
2918
|
+
for (const pageView of this.pageViewsInPeriod(visit, input)) {
|
|
2919
|
+
const day = activityDay(pageView.receivedAt);
|
|
2920
|
+
pageViewsByDay.set(day, (pageViewsByDay.get(day) ?? 0) + 1);
|
|
2406
2921
|
}
|
|
2407
2922
|
}
|
|
2408
|
-
return
|
|
2923
|
+
return activityCalendarDays2(input, visits, pageViewsByDay);
|
|
2409
2924
|
}
|
|
2410
|
-
async
|
|
2411
|
-
const
|
|
2412
|
-
|
|
2413
|
-
if (!current)
|
|
2925
|
+
async read(input) {
|
|
2926
|
+
const visit = this.visits.get(JSON.stringify([input.projectId, input.id]));
|
|
2927
|
+
if (!visit) {
|
|
2414
2928
|
return null;
|
|
2415
|
-
if (!current.revokedAt) {
|
|
2416
|
-
this.rows.set(key, { ...current, revokedAt: new Date(input.revokedAt) });
|
|
2417
2929
|
}
|
|
2418
|
-
|
|
2930
|
+
const ofVisit = (event) => event.projectId === visit.projectId && event.visitId === visit.id;
|
|
2931
|
+
const events = [...this.pageViews.filter(ofVisit), ...this.interactions.filter(ofVisit)].sort((left, right) => left.sequence - right.sequence);
|
|
2932
|
+
const pageViews = [];
|
|
2933
|
+
const interactions = [];
|
|
2934
|
+
for (const event of events.slice(0, input.limit)) {
|
|
2935
|
+
const { id, visitId, sequence, route } = event;
|
|
2936
|
+
const pageView = { id, visitId, sequence, route, receivedAt: new Date(event.receivedAt) };
|
|
2937
|
+
if ("name" in event) {
|
|
2938
|
+
interactions.push({ ...pageView, name: event.name });
|
|
2939
|
+
} else {
|
|
2940
|
+
pageViews.push(pageView);
|
|
2941
|
+
}
|
|
2942
|
+
}
|
|
2943
|
+
return {
|
|
2944
|
+
visit: toVisit(visit),
|
|
2945
|
+
sessionId: visit.sessionId,
|
|
2946
|
+
pageViews,
|
|
2947
|
+
interactions,
|
|
2948
|
+
hasMore: events.length > input.limit
|
|
2949
|
+
};
|
|
2419
2950
|
}
|
|
2420
|
-
async
|
|
2421
|
-
const
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2951
|
+
async sessionVisits(input) {
|
|
2952
|
+
const sessionIds = new Set(input.sessionIds);
|
|
2953
|
+
const bySession = new Map;
|
|
2954
|
+
for (const visit of this.visits.values()) {
|
|
2955
|
+
if (visit.projectId !== input.projectId || visit.actor.type !== "user" || visit.actor.userId !== input.userId || !sessionIds.has(visit.sessionId)) {
|
|
2956
|
+
continue;
|
|
2957
|
+
}
|
|
2958
|
+
const visits = bySession.get(visit.sessionId) ?? [];
|
|
2959
|
+
visits.push(visit);
|
|
2960
|
+
bySession.set(visit.sessionId, visits);
|
|
2961
|
+
}
|
|
2962
|
+
return [...bySession].map(([sessionId, visits]) => ({
|
|
2963
|
+
sessionId,
|
|
2964
|
+
visits: visits.length,
|
|
2965
|
+
latest: visits.sort(byStartDescending).slice(0, input.limit).map(toVisit)
|
|
2966
|
+
}));
|
|
2425
2967
|
}
|
|
2426
2968
|
snapshot() {
|
|
2427
|
-
return
|
|
2428
|
-
|
|
2969
|
+
return structuredClone({
|
|
2970
|
+
sources: this.sources,
|
|
2971
|
+
visits: this.visits,
|
|
2972
|
+
pageViews: this.pageViews,
|
|
2973
|
+
interactions: this.interactions
|
|
2974
|
+
});
|
|
2975
|
+
}
|
|
2429
2976
|
restore(snapshot) {
|
|
2430
|
-
|
|
2977
|
+
const restored = structuredClone(snapshot);
|
|
2978
|
+
this.sources = restored.sources;
|
|
2979
|
+
this.visits = restored.visits;
|
|
2980
|
+
this.pageViews = restored.pageViews;
|
|
2981
|
+
this.interactions = restored.interactions;
|
|
2982
|
+
}
|
|
2983
|
+
source(key, projectId) {
|
|
2984
|
+
const source = this.sources.get(key);
|
|
2985
|
+
if (!source) {
|
|
2986
|
+
return;
|
|
2987
|
+
}
|
|
2988
|
+
const visit = this.visits.get(JSON.stringify([projectId, source.visitId]));
|
|
2989
|
+
return { ...source, visitStartedAt: visit ? visit.startedAt.getTime() : null };
|
|
2990
|
+
}
|
|
2991
|
+
overlapping(input) {
|
|
2992
|
+
const earliestStart = input.from.getTime() - ACTIVITY_MAX_VISIT_MS2;
|
|
2993
|
+
return [...this.visits.values()].filter((visit) => visit.projectId === input.projectId && visit.startedAt.getTime() >= earliestStart && visit.startedAt < input.to && visit.lastSeenAt >= input.from && (input.userId === undefined || visit.actor.type === "user" && visit.actor.userId === input.userId));
|
|
2994
|
+
}
|
|
2995
|
+
pageViewsOf(visit) {
|
|
2996
|
+
return this.pageViews.filter((pageView) => pageView.projectId === visit.projectId && pageView.visitId === visit.id);
|
|
2997
|
+
}
|
|
2998
|
+
pageViewsInPeriod(visit, period) {
|
|
2999
|
+
return this.pageViewsOf(visit).filter((pageView) => pageView.receivedAt >= period.from && pageView.receivedAt < period.to);
|
|
3000
|
+
}
|
|
3001
|
+
isFromSession(event, input) {
|
|
3002
|
+
const visit = this.visits.get(JSON.stringify([event.projectId, event.visitId]));
|
|
3003
|
+
return visit?.actor.type === input.actor.type && visit.sessionId === input.sessionId;
|
|
3004
|
+
}
|
|
3005
|
+
requireVisit(projectId, id) {
|
|
3006
|
+
const visit = this.visits.get(JSON.stringify([projectId, id]));
|
|
3007
|
+
if (!visit) {
|
|
3008
|
+
throw new Error("[Sixb] Activity visit is missing.");
|
|
3009
|
+
}
|
|
3010
|
+
return visit;
|
|
2431
3011
|
}
|
|
2432
3012
|
}
|
|
2433
|
-
function
|
|
2434
|
-
return
|
|
3013
|
+
function toVisit(visit) {
|
|
3014
|
+
return {
|
|
3015
|
+
id: visit.id,
|
|
3016
|
+
actor: structuredClone(visit.actor),
|
|
3017
|
+
attribution: structuredClone(visit.attribution),
|
|
3018
|
+
startedAt: new Date(visit.startedAt),
|
|
3019
|
+
lastSeenAt: new Date(visit.lastSeenAt),
|
|
3020
|
+
pageViews: visit.pageViews,
|
|
3021
|
+
interactions: visit.interactions
|
|
3022
|
+
};
|
|
2435
3023
|
}
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
if (query.kind === "vector")
|
|
3024
|
+
function isBefore(at, id, cursor) {
|
|
3025
|
+
if (!cursor) {
|
|
2439
3026
|
return true;
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
return "input" in query && hasVectorProfile2(query.input);
|
|
3027
|
+
}
|
|
3028
|
+
return at < cursor.at || at.getTime() === cursor.at.getTime() && id < cursor.id;
|
|
2443
3029
|
}
|
|
2444
|
-
function
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
return query.input.kind === "vector" && isVectorProfileQuery2(query.input);
|
|
3030
|
+
function byStartDescending(left, right) {
|
|
3031
|
+
const byTime = right.startedAt.getTime() - left.startedAt.getTime();
|
|
3032
|
+
if (byTime !== 0) {
|
|
3033
|
+
return byTime;
|
|
2449
3034
|
}
|
|
2450
|
-
|
|
2451
|
-
return false;
|
|
2452
|
-
return isVectorCandidateQuery(query.input);
|
|
3035
|
+
return left.id < right.id ? 1 : left.id > right.id ? -1 : 0;
|
|
2453
3036
|
}
|
|
2454
|
-
function
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
3037
|
+
function byLastSeenDescending(id) {
|
|
3038
|
+
return (left, right) => {
|
|
3039
|
+
const byTime = right.lastSeenAt.getTime() - left.lastSeenAt.getTime();
|
|
3040
|
+
if (byTime !== 0) {
|
|
3041
|
+
return byTime;
|
|
3042
|
+
}
|
|
3043
|
+
return id(left) < id(right) ? 1 : id(left) > id(right) ? -1 : 0;
|
|
3044
|
+
};
|
|
3045
|
+
}
|
|
3046
|
+
// src/storage/artifacts/in-memory.ts
|
|
3047
|
+
class InMemoryArtifactStorage {
|
|
3048
|
+
artifacts = new Map;
|
|
3049
|
+
frameGrants = new Map;
|
|
3050
|
+
state = new Map;
|
|
3051
|
+
async create(input) {
|
|
3052
|
+
const key = artifactKey(input.projectId, input.id);
|
|
3053
|
+
if (this.artifacts.has(key))
|
|
3054
|
+
throw artifactStorageErrors2.exists(input.id);
|
|
3055
|
+
const version = versionRecord(input.projectId, input.id, 1, input.version);
|
|
3056
|
+
const record = {
|
|
3057
|
+
projectId: input.projectId,
|
|
3058
|
+
id: input.id,
|
|
3059
|
+
kind: input.kind,
|
|
3060
|
+
title: version.title,
|
|
3061
|
+
owner: { ...input.owner },
|
|
3062
|
+
latestVersion: 1,
|
|
3063
|
+
createdAt: new Date(version.createdAt),
|
|
3064
|
+
updatedAt: new Date(version.createdAt)
|
|
3065
|
+
};
|
|
3066
|
+
this.artifacts.set(key, {
|
|
3067
|
+
record,
|
|
3068
|
+
versions: [version],
|
|
3069
|
+
nextVersion: 2,
|
|
3070
|
+
threads: sharedIn(new Map, version)
|
|
3071
|
+
});
|
|
3072
|
+
return published(record, version);
|
|
3073
|
+
}
|
|
3074
|
+
async publish(input) {
|
|
3075
|
+
const key = artifactKey(input.projectId, input.artifactId);
|
|
3076
|
+
const stored = this.artifacts.get(key);
|
|
3077
|
+
if (!stored)
|
|
3078
|
+
throw artifactStorageErrors2.notFound(input.artifactId);
|
|
3079
|
+
if (stored.record.kind !== input.kind) {
|
|
3080
|
+
throw artifactStorageErrors2.kindMismatch(input.artifactId, stored.record.kind, input.kind);
|
|
3081
|
+
}
|
|
3082
|
+
const latest = stored.versions.find((candidate) => candidate.version === stored.record.latestVersion);
|
|
3083
|
+
if (input.baseVersion !== undefined && latest && latest.version !== input.baseVersion) {
|
|
3084
|
+
throw artifactStorageErrors2.moved(input.artifactId, input.baseVersion, {
|
|
3085
|
+
version: latest.version,
|
|
3086
|
+
author: structuredClone(latest.author)
|
|
3087
|
+
});
|
|
3088
|
+
}
|
|
3089
|
+
const version = versionRecord(input.projectId, input.artifactId, stored.nextVersion, input.version);
|
|
3090
|
+
const record = {
|
|
3091
|
+
...stored.record,
|
|
3092
|
+
title: version.title,
|
|
3093
|
+
latestVersion: version.version,
|
|
3094
|
+
updatedAt: new Date(version.createdAt)
|
|
3095
|
+
};
|
|
3096
|
+
this.artifacts.set(key, {
|
|
3097
|
+
record,
|
|
3098
|
+
versions: [...stored.versions, version],
|
|
3099
|
+
nextVersion: stored.nextVersion + 1,
|
|
3100
|
+
threads: sharedIn(stored.threads, version)
|
|
3101
|
+
});
|
|
3102
|
+
return published(record, version);
|
|
3103
|
+
}
|
|
3104
|
+
async get(input) {
|
|
3105
|
+
const stored = this.artifacts.get(artifactKey(input.projectId, input.id));
|
|
3106
|
+
return stored ? structuredClone(stored.record) : null;
|
|
3107
|
+
}
|
|
3108
|
+
async list(input) {
|
|
3109
|
+
const matching = [...this.artifacts.values()].filter(({ record, threads }) => record.projectId === input.projectId && (!input.owner || principalsEqual2(record.owner, input.owner)) && (input.kind === undefined || record.kind === input.kind) && (input.threadId === undefined || threads.has(input.threadId))).map(({ record }) => record).sort((left, right) => right.updatedAt.getTime() - left.updatedAt.getTime() || left.id.localeCompare(right.id));
|
|
3110
|
+
const { page, hasMore, total } = paginate(matching, input);
|
|
3111
|
+
return { artifacts: structuredClone(page), hasMore, total };
|
|
3112
|
+
}
|
|
3113
|
+
async getVersion(input) {
|
|
3114
|
+
const stored = this.artifacts.get(artifactKey(input.projectId, input.artifactId));
|
|
3115
|
+
const version = stored?.versions.find((candidate) => candidate.version === input.version);
|
|
3116
|
+
return version ? structuredClone(version) : null;
|
|
3117
|
+
}
|
|
3118
|
+
async listVersions(input) {
|
|
3119
|
+
const stored = this.artifacts.get(artifactKey(input.projectId, input.artifactId));
|
|
3120
|
+
const newestFirst = [...stored?.versions ?? []].reverse();
|
|
3121
|
+
const { page, hasMore, total } = paginate(newestFirst, input);
|
|
3122
|
+
return { versions: structuredClone(page), hasMore, total };
|
|
3123
|
+
}
|
|
3124
|
+
async listThreadIds(input) {
|
|
3125
|
+
const stored = this.artifacts.get(artifactKey(input.projectId, input.id));
|
|
3126
|
+
return [...stored?.threads.keys() ?? []].sort((left, right) => left < right ? -1 : 1);
|
|
3127
|
+
}
|
|
3128
|
+
async copy(input) {
|
|
3129
|
+
const source = this.artifacts.get(artifactKey(input.projectId, input.sourceId));
|
|
3130
|
+
if (!source)
|
|
3131
|
+
throw artifactStorageErrors2.notFound(input.sourceId);
|
|
3132
|
+
const key = artifactKey(input.projectId, input.id);
|
|
3133
|
+
if (this.artifacts.has(key))
|
|
3134
|
+
throw artifactStorageErrors2.exists(input.id);
|
|
3135
|
+
const record = { ...source.record, id: input.id, owner: { ...input.owner } };
|
|
3136
|
+
const versions = source.versions.map(({ origin: _origin, ...version }) => structuredClone({ ...version, artifactId: input.id }));
|
|
3137
|
+
const sharedAt = new Date(input.copiedAt ?? new Date);
|
|
3138
|
+
this.artifacts.set(key, {
|
|
3139
|
+
record,
|
|
3140
|
+
versions,
|
|
3141
|
+
nextVersion: source.nextVersion,
|
|
3142
|
+
threads: new Map([[input.threadId, { sharedAt, copied: true }]])
|
|
3143
|
+
});
|
|
3144
|
+
return structuredClone(record);
|
|
3145
|
+
}
|
|
3146
|
+
async listReferencingVersions(input) {
|
|
3147
|
+
const prefix = `artifact:${input.artifactId}`;
|
|
3148
|
+
const referencing = [];
|
|
3149
|
+
for (const stored of this.artifacts.values()) {
|
|
3150
|
+
if (stored.record.projectId !== input.projectId)
|
|
3151
|
+
continue;
|
|
3152
|
+
const latest = stored.versions.find((candidate) => candidate.version === stored.record.latestVersion);
|
|
3153
|
+
if (latest?.references.some((reference) => refersTo(reference.address, prefix))) {
|
|
3154
|
+
referencing.push(structuredClone(latest));
|
|
3155
|
+
}
|
|
3156
|
+
}
|
|
3157
|
+
return referencing.sort((left, right) => left.artifactId < right.artifactId ? -1 : 1);
|
|
3158
|
+
}
|
|
3159
|
+
async createFrameGrant(record) {
|
|
3160
|
+
if (!this.artifacts.has(artifactKey(record.projectId, record.artifactId))) {
|
|
3161
|
+
throw artifactStorageErrors2.notFound(record.artifactId);
|
|
3162
|
+
}
|
|
3163
|
+
this.frameGrants.set(artifactKey(record.projectId, record.tokenHash), structuredClone(record));
|
|
3164
|
+
}
|
|
3165
|
+
async findFrameGrant(input) {
|
|
3166
|
+
const grant = this.frameGrants.get(artifactKey(input.projectId, input.tokenHash));
|
|
3167
|
+
return grant ? structuredClone(grant) : null;
|
|
3168
|
+
}
|
|
3169
|
+
async deleteExpiredFrameGrants(input) {
|
|
3170
|
+
let deleted = 0;
|
|
3171
|
+
for (const [key, grant] of this.frameGrants) {
|
|
3172
|
+
if (deleted >= input.limit)
|
|
3173
|
+
break;
|
|
3174
|
+
if (grant.projectId !== input.projectId || grant.expiresAt >= input.expiredBefore)
|
|
3175
|
+
continue;
|
|
3176
|
+
this.frameGrants.delete(key);
|
|
3177
|
+
deleted += 1;
|
|
3178
|
+
}
|
|
3179
|
+
return deleted;
|
|
2467
3180
|
}
|
|
3181
|
+
async getState(input) {
|
|
3182
|
+
const entry = this.state.get(stateKey(input))?.get(input.key);
|
|
3183
|
+
return entry ? structuredClone(entry) : null;
|
|
3184
|
+
}
|
|
3185
|
+
async setState(input) {
|
|
3186
|
+
if (!this.artifacts.has(artifactKey(input.projectId, input.artifactId))) {
|
|
3187
|
+
throw artifactStorageErrors2.notFound(input.artifactId);
|
|
3188
|
+
}
|
|
3189
|
+
const kept = this.state.get(stateKey(input)) ?? new Map;
|
|
3190
|
+
const others = [...kept.values()].filter((entry) => entry.key !== input.key);
|
|
3191
|
+
const sizeBytes = artifactStateBytes2(input.value);
|
|
3192
|
+
checkArtifactStateWrite2({
|
|
3193
|
+
key: input.key,
|
|
3194
|
+
valueBytes: sizeBytes,
|
|
3195
|
+
others: {
|
|
3196
|
+
keys: others.length,
|
|
3197
|
+
bytes: others.reduce((total, entry) => total + entry.sizeBytes, 0)
|
|
3198
|
+
}
|
|
3199
|
+
});
|
|
3200
|
+
kept.set(input.key, {
|
|
3201
|
+
key: input.key,
|
|
3202
|
+
value: input.value,
|
|
3203
|
+
sizeBytes,
|
|
3204
|
+
updatedAt: new Date(input.updatedAt)
|
|
3205
|
+
});
|
|
3206
|
+
this.state.set(stateKey(input), kept);
|
|
3207
|
+
}
|
|
3208
|
+
async deleteState(input) {
|
|
3209
|
+
return this.state.get(stateKey(input))?.delete(input.key) ?? false;
|
|
3210
|
+
}
|
|
3211
|
+
async listState(input) {
|
|
3212
|
+
const kept = [...this.state.get(stateKey(input))?.values() ?? []];
|
|
3213
|
+
return structuredClone(kept.sort((left, right) => left.key < right.key ? -1 : 1));
|
|
3214
|
+
}
|
|
3215
|
+
async clearState(input) {
|
|
3216
|
+
const count = this.state.get(stateKey(input))?.size ?? 0;
|
|
3217
|
+
this.state.delete(stateKey(input));
|
|
3218
|
+
return count;
|
|
3219
|
+
}
|
|
3220
|
+
async delete(input) {
|
|
3221
|
+
return this.deleteArtifact(artifactKey(input.projectId, input.id));
|
|
3222
|
+
}
|
|
3223
|
+
async deleteVersionsByOrigin(input) {
|
|
3224
|
+
let deleted = 0;
|
|
3225
|
+
for (const [key, stored] of this.artifacts) {
|
|
3226
|
+
if (stored.record.projectId !== input.projectId)
|
|
3227
|
+
continue;
|
|
3228
|
+
const remaining = stored.versions.filter((version) => version.origin?.runId !== input.runId);
|
|
3229
|
+
if (remaining.length === stored.versions.length)
|
|
3230
|
+
continue;
|
|
3231
|
+
deleted += stored.versions.length - remaining.length;
|
|
3232
|
+
const latest = remaining.at(-1);
|
|
3233
|
+
if (!latest) {
|
|
3234
|
+
this.deleteArtifact(key);
|
|
3235
|
+
continue;
|
|
3236
|
+
}
|
|
3237
|
+
const threadId = stored.versions.find((version) => version.origin?.runId === input.runId)?.origin?.threadId;
|
|
3238
|
+
const threads = new Map(stored.threads);
|
|
3239
|
+
if (threadId && !threads.get(threadId)?.copied && !remaining.some((version) => version.origin?.threadId === threadId)) {
|
|
3240
|
+
threads.delete(threadId);
|
|
3241
|
+
}
|
|
3242
|
+
this.artifacts.set(key, {
|
|
3243
|
+
...stored,
|
|
3244
|
+
record: {
|
|
3245
|
+
...stored.record,
|
|
3246
|
+
title: latest.title,
|
|
3247
|
+
latestVersion: latest.version,
|
|
3248
|
+
updatedAt: new Date(latest.createdAt)
|
|
3249
|
+
},
|
|
3250
|
+
versions: remaining,
|
|
3251
|
+
threads
|
|
3252
|
+
});
|
|
3253
|
+
}
|
|
3254
|
+
return deleted;
|
|
3255
|
+
}
|
|
3256
|
+
snapshot() {
|
|
3257
|
+
return structuredClone({
|
|
3258
|
+
artifacts: this.artifacts,
|
|
3259
|
+
frameGrants: this.frameGrants,
|
|
3260
|
+
state: this.state
|
|
3261
|
+
});
|
|
3262
|
+
}
|
|
3263
|
+
restore(snapshot) {
|
|
3264
|
+
const restored = structuredClone(snapshot);
|
|
3265
|
+
this.artifacts = new Map(restored.artifacts);
|
|
3266
|
+
this.frameGrants = new Map(restored.frameGrants);
|
|
3267
|
+
this.state = new Map([...restored.state].map(([key, kept]) => [key, new Map(kept)]));
|
|
3268
|
+
}
|
|
3269
|
+
deleteArtifact(key) {
|
|
3270
|
+
for (const [grantKey, grant] of this.frameGrants) {
|
|
3271
|
+
if (artifactKey(grant.projectId, grant.artifactId) === key)
|
|
3272
|
+
this.frameGrants.delete(grantKey);
|
|
3273
|
+
}
|
|
3274
|
+
for (const kept of this.state.keys()) {
|
|
3275
|
+
if (kept.startsWith(`${key}\x00`))
|
|
3276
|
+
this.state.delete(kept);
|
|
3277
|
+
}
|
|
3278
|
+
return this.artifacts.delete(key);
|
|
3279
|
+
}
|
|
3280
|
+
}
|
|
3281
|
+
function versionRecord(projectId, artifactId, version, input) {
|
|
3282
|
+
return structuredClone({ ...input, projectId, artifactId, version });
|
|
3283
|
+
}
|
|
3284
|
+
function sharedIn(threads, version) {
|
|
3285
|
+
const threadId = version.origin?.threadId;
|
|
3286
|
+
if (!threadId || threads.has(threadId))
|
|
3287
|
+
return threads;
|
|
3288
|
+
return new Map(threads).set(threadId, { sharedAt: new Date(version.createdAt), copied: false });
|
|
3289
|
+
}
|
|
3290
|
+
function published(record, version) {
|
|
3291
|
+
return structuredClone({ artifact: record, version });
|
|
3292
|
+
}
|
|
3293
|
+
function artifactKey(projectId, id) {
|
|
3294
|
+
return `${projectId}\x00${id}`;
|
|
3295
|
+
}
|
|
3296
|
+
function stateKey(scope) {
|
|
3297
|
+
return `${artifactKey(scope.projectId, scope.artifactId)}\x00${scope.principal.type}\x00${scope.principal.id}`;
|
|
3298
|
+
}
|
|
3299
|
+
function refersTo(address, prefix) {
|
|
3300
|
+
return address.startsWith(prefix) && /^(?:$|[@/#])/.test(address.slice(prefix.length));
|
|
3301
|
+
}
|
|
3302
|
+
// src/storage/executions/in-memory.ts
|
|
3303
|
+
var runDirectly2 = async (run) => run();
|
|
3304
|
+
function executionKey(projectId, id) {
|
|
3305
|
+
return JSON.stringify([projectId, id]);
|
|
2468
3306
|
}
|
|
2469
3307
|
|
|
3308
|
+
class InMemoryExecutionStorage {
|
|
3309
|
+
auth;
|
|
3310
|
+
rows = new Map;
|
|
3311
|
+
runRootOperation;
|
|
3312
|
+
shareSessions;
|
|
3313
|
+
constructor(auth, input = {}) {
|
|
3314
|
+
this.auth = auth;
|
|
3315
|
+
this.runRootOperation = input.runRootOperation ?? runDirectly2;
|
|
3316
|
+
this.shareSessions = input.shareSessions;
|
|
3317
|
+
}
|
|
3318
|
+
snapshot() {
|
|
3319
|
+
return structuredClone(this.rows);
|
|
3320
|
+
}
|
|
3321
|
+
restore(snapshot) {
|
|
3322
|
+
this.rows.clear();
|
|
3323
|
+
for (const [key, record] of structuredClone(snapshot)) {
|
|
3324
|
+
this.rows.set(key, record);
|
|
3325
|
+
}
|
|
3326
|
+
}
|
|
3327
|
+
async create(input) {
|
|
3328
|
+
return this.runRootOperation(async () => {
|
|
3329
|
+
const key = executionKey(input.projectId, input.id);
|
|
3330
|
+
if (this.rows.has(key)) {
|
|
3331
|
+
throw new ExecutionStorageError2("duplicate_execution", `[Sixb] Execution '${input.id}' already exists in project '${input.projectId}'.`);
|
|
3332
|
+
}
|
|
3333
|
+
const record = await prepareExecutionRecord2(input, {
|
|
3334
|
+
auth: this.auth,
|
|
3335
|
+
getExecution: async ({ projectId, id }) => {
|
|
3336
|
+
const existing = this.rows.get(executionKey(projectId, id));
|
|
3337
|
+
return existing ? cloneExecutionRecord(existing) : null;
|
|
3338
|
+
},
|
|
3339
|
+
getShareSession: async ({ projectId, id }) => await this.shareSessions?.getById({ projectId, id }) ?? null
|
|
3340
|
+
});
|
|
3341
|
+
this.rows.set(key, cloneExecutionRecord(record));
|
|
3342
|
+
return cloneExecutionRecord(record);
|
|
3343
|
+
});
|
|
3344
|
+
}
|
|
3345
|
+
async getById(params) {
|
|
3346
|
+
return this.runRootOperation(() => {
|
|
3347
|
+
const record = this.rows.get(executionKey(params.projectId, params.id));
|
|
3348
|
+
return record ? cloneExecutionRecord(record) : null;
|
|
3349
|
+
});
|
|
3350
|
+
}
|
|
3351
|
+
async listBySession(input) {
|
|
3352
|
+
return this.runRootOperation(() => {
|
|
3353
|
+
const rows = [...this.rows.values()].filter((row) => row.projectId === input.projectId);
|
|
3354
|
+
const roots = rows.filter((row) => row.source.type !== "execution" && row.createdAt >= input.from && row.createdAt < input.to && isFromSession(row, input.session)).sort(compareExecutionCreation2).slice(0, input.limit + 1);
|
|
3355
|
+
const found = [...roots];
|
|
3356
|
+
let level = roots;
|
|
3357
|
+
while (level.length > 0 && found.length <= input.limit) {
|
|
3358
|
+
const parents = new Set(level.map((row) => row.id));
|
|
3359
|
+
level = rows.filter((row) => row.source.type === "execution" && parents.has(row.source.executionId)).sort(compareExecutionCreation2);
|
|
3360
|
+
found.push(...level);
|
|
3361
|
+
}
|
|
3362
|
+
return {
|
|
3363
|
+
executions: found.slice(0, input.limit).sort(compareExecutionCreation2).map(cloneExecutionRecord),
|
|
3364
|
+
truncated: found.length > input.limit
|
|
3365
|
+
};
|
|
3366
|
+
});
|
|
3367
|
+
}
|
|
3368
|
+
async listDescendants(input) {
|
|
3369
|
+
return this.runRootOperation(() => {
|
|
3370
|
+
const rows = [...this.rows.values()].filter((row) => row.projectId === input.projectId);
|
|
3371
|
+
const seen = new Set(input.executionIds);
|
|
3372
|
+
const found = [];
|
|
3373
|
+
let parents = new Set(input.executionIds);
|
|
3374
|
+
while (parents.size > 0) {
|
|
3375
|
+
const level = rows.filter((row) => row.source.type === "execution" && parents.has(row.source.executionId) && !seen.has(row.id));
|
|
3376
|
+
for (const row of level)
|
|
3377
|
+
seen.add(row.id);
|
|
3378
|
+
found.push(...level);
|
|
3379
|
+
parents = new Set(level.map((row) => row.id));
|
|
3380
|
+
}
|
|
3381
|
+
return found.flatMap((row) => row.source.type === "execution" ? [{ id: row.id, parentId: row.source.executionId }] : []).sort((left, right) => left.id < right.id ? -1 : left.id > right.id ? 1 : 0);
|
|
3382
|
+
});
|
|
3383
|
+
}
|
|
3384
|
+
}
|
|
3385
|
+
function isFromSession(row, session) {
|
|
3386
|
+
const ref = row.authorizationRef;
|
|
3387
|
+
if (session.type === "user") {
|
|
3388
|
+
return ref.type === "principal" && ref.credential?.type === "session" && ref.credential.id === session.id;
|
|
3389
|
+
}
|
|
3390
|
+
return ref.type === "delegated" && ref.delegation.sessionId === session.id;
|
|
3391
|
+
}
|
|
3392
|
+
|
|
3393
|
+
// src/storage/file-download-grants/in-memory.ts
|
|
3394
|
+
class InMemoryFileDownloadGrantStorage {
|
|
3395
|
+
rows = new Map;
|
|
3396
|
+
async create(record) {
|
|
3397
|
+
const duplicate = [...this.rows.values()].some((current) => current.projectId === record.projectId && (current.id === record.id || current.tokenHash === record.tokenHash));
|
|
3398
|
+
if (duplicate) {
|
|
3399
|
+
throw new Error(`[Sixb] File download grant '${record.id}' conflicts with an existing one.`);
|
|
3400
|
+
}
|
|
3401
|
+
this.rows.set(rowKey(record.projectId, record.id), cloneFileDownloadGrantRecord(record));
|
|
3402
|
+
}
|
|
3403
|
+
async findByTokenHash(input) {
|
|
3404
|
+
for (const record of this.rows.values()) {
|
|
3405
|
+
if (record.projectId === input.projectId && record.tokenHash === input.tokenHash) {
|
|
3406
|
+
return cloneFileDownloadGrantRecord(record);
|
|
3407
|
+
}
|
|
3408
|
+
}
|
|
3409
|
+
return null;
|
|
3410
|
+
}
|
|
3411
|
+
async revoke(input) {
|
|
3412
|
+
const key = rowKey(input.projectId, input.id);
|
|
3413
|
+
const current = this.rows.get(key);
|
|
3414
|
+
if (!current)
|
|
3415
|
+
return null;
|
|
3416
|
+
if (!current.revokedAt) {
|
|
3417
|
+
this.rows.set(key, { ...current, revokedAt: new Date(input.revokedAt) });
|
|
3418
|
+
}
|
|
3419
|
+
return cloneFileDownloadGrantRecord(this.rows.get(key));
|
|
3420
|
+
}
|
|
3421
|
+
async deleteExpired(input) {
|
|
3422
|
+
const expired = [...this.rows.entries()].filter(([, record]) => record.projectId === input.projectId && record.expiresAt.getTime() < input.expiredBefore.getTime()).slice(0, input.limit);
|
|
3423
|
+
for (const [key] of expired)
|
|
3424
|
+
this.rows.delete(key);
|
|
3425
|
+
return expired.length;
|
|
3426
|
+
}
|
|
3427
|
+
snapshot() {
|
|
3428
|
+
return new Map([...this.rows].map(([key, record]) => [key, cloneFileDownloadGrantRecord(record)]));
|
|
3429
|
+
}
|
|
3430
|
+
restore(snapshot) {
|
|
3431
|
+
this.rows = new Map([...snapshot].map(([key, record]) => [key, cloneFileDownloadGrantRecord(record)]));
|
|
3432
|
+
}
|
|
3433
|
+
}
|
|
3434
|
+
function rowKey(projectId, id) {
|
|
3435
|
+
return `${projectId}\x00${id}`;
|
|
3436
|
+
}
|
|
2470
3437
|
// src/storage/objects/keys.ts
|
|
2471
3438
|
function objectBatchKey2(objectTypeId, primaryId) {
|
|
2472
3439
|
return JSON.stringify([objectTypeId, primaryId]);
|
|
@@ -2490,42 +3457,6 @@ function compareObjectLinks(left, right) {
|
|
|
2490
3457
|
return compareObjectLinkCursors(objectLinkCursor2(left), objectLinkCursor2(right));
|
|
2491
3458
|
}
|
|
2492
3459
|
|
|
2493
|
-
// src/storage/objects/in-memory/keys.ts
|
|
2494
|
-
function objectRowKey(projectId, objectTypeId) {
|
|
2495
|
-
return JSON.stringify([projectId, objectTypeId]);
|
|
2496
|
-
}
|
|
2497
|
-
function objectRowProjectPrefix(projectId) {
|
|
2498
|
-
return `[${JSON.stringify(projectId)},`;
|
|
2499
|
-
}
|
|
2500
|
-
function compareStrings(left, right) {
|
|
2501
|
-
if (left < right)
|
|
2502
|
-
return -1;
|
|
2503
|
-
if (left > right)
|
|
2504
|
-
return 1;
|
|
2505
|
-
return 0;
|
|
2506
|
-
}
|
|
2507
|
-
function sourceLinkBucketKey(projectId, sourceTypeId, sourceId) {
|
|
2508
|
-
return JSON.stringify([projectId, sourceTypeId, sourceId]);
|
|
2509
|
-
}
|
|
2510
|
-
function linkRowKey(linkId, targetTypeId, targetId) {
|
|
2511
|
-
return JSON.stringify([linkId, targetTypeId, targetId]);
|
|
2512
|
-
}
|
|
2513
|
-
function fullLinkRowKey(row) {
|
|
2514
|
-
return JSON.stringify([
|
|
2515
|
-
row.sourceTypeId,
|
|
2516
|
-
row.sourceId,
|
|
2517
|
-
row.linkId,
|
|
2518
|
-
row.targetTypeId,
|
|
2519
|
-
row.targetId
|
|
2520
|
-
]);
|
|
2521
|
-
}
|
|
2522
|
-
function rowIdentityKey(row) {
|
|
2523
|
-
return rowIdentityKeyParts(row.objectTypeId, row.primaryId);
|
|
2524
|
-
}
|
|
2525
|
-
function rowIdentityKeyParts(objectTypeId, primaryId) {
|
|
2526
|
-
return objectBatchKey2(objectTypeId, primaryId);
|
|
2527
|
-
}
|
|
2528
|
-
|
|
2529
3460
|
// src/objects/query/scalar-values.ts
|
|
2530
3461
|
function compareQueryScalarValues(left, right, scalarKind) {
|
|
2531
3462
|
if (left === undefined || right === undefined || left === null || right === null) {
|
|
@@ -2536,7 +3467,7 @@ function compareQueryScalarValues(left, right, scalarKind) {
|
|
|
2536
3467
|
switch (scalarKind) {
|
|
2537
3468
|
case "string":
|
|
2538
3469
|
case "uuid":
|
|
2539
|
-
return typeof left === "string" && typeof right === "string" ?
|
|
3470
|
+
return typeof left === "string" && typeof right === "string" ? compareStrings(left, right) : Number.NaN;
|
|
2540
3471
|
case "boolean":
|
|
2541
3472
|
return typeof left === "boolean" && typeof right === "boolean" ? Number(left) - Number(right) : Number.NaN;
|
|
2542
3473
|
case "integer":
|
|
@@ -2578,7 +3509,7 @@ function compareRuntimeValues(left, right) {
|
|
|
2578
3509
|
if (typeof left === "number" && typeof right === "number")
|
|
2579
3510
|
return left - right;
|
|
2580
3511
|
if (typeof left === "string" && typeof right === "string")
|
|
2581
|
-
return
|
|
3512
|
+
return compareStrings(left, right);
|
|
2582
3513
|
if (typeof left === "boolean" && typeof right === "boolean") {
|
|
2583
3514
|
return Number(left) - Number(right);
|
|
2584
3515
|
}
|
|
@@ -2611,6 +3542,81 @@ function dateTime(value) {
|
|
|
2611
3542
|
}
|
|
2612
3543
|
return null;
|
|
2613
3544
|
}
|
|
3545
|
+
function compareStrings(left, right) {
|
|
3546
|
+
if (left === right)
|
|
3547
|
+
return 0;
|
|
3548
|
+
const length = Math.min(left.length, right.length);
|
|
3549
|
+
let index = 0;
|
|
3550
|
+
while (index < length && left.charCodeAt(index) === right.charCodeAt(index))
|
|
3551
|
+
index++;
|
|
3552
|
+
if (index === length)
|
|
3553
|
+
return left.length - right.length;
|
|
3554
|
+
return codePointRank(left.charCodeAt(index)) - codePointRank(right.charCodeAt(index));
|
|
3555
|
+
}
|
|
3556
|
+
function codePointRank(unit) {
|
|
3557
|
+
if (unit >= 57344)
|
|
3558
|
+
return unit - 2048;
|
|
3559
|
+
if (unit >= 55296)
|
|
3560
|
+
return unit + 8192;
|
|
3561
|
+
return unit;
|
|
3562
|
+
}
|
|
3563
|
+
|
|
3564
|
+
// src/objects/query/matches-predicate.ts
|
|
3565
|
+
function matchesPredicate(row, predicate) {
|
|
3566
|
+
switch (predicate.op) {
|
|
3567
|
+
case "and":
|
|
3568
|
+
return predicate.items.every((item) => matchesPredicate(row, item));
|
|
3569
|
+
case "or":
|
|
3570
|
+
return predicate.items.some((item) => matchesPredicate(row, item));
|
|
3571
|
+
case "not":
|
|
3572
|
+
return !matchesPredicate(row, predicate.item);
|
|
3573
|
+
case "constant":
|
|
3574
|
+
return predicate.value;
|
|
3575
|
+
case "eq":
|
|
3576
|
+
return queryScalarValuesEqual(row.properties[predicate.propertyId], predicate.value, predicate.scalarKind);
|
|
3577
|
+
case "neq":
|
|
3578
|
+
return !queryScalarValuesEqual(row.properties[predicate.propertyId], predicate.value, predicate.scalarKind);
|
|
3579
|
+
case "lt":
|
|
3580
|
+
return compareQueryScalarValues(row.properties[predicate.propertyId], predicate.value, predicate.scalarKind) < 0;
|
|
3581
|
+
case "lte":
|
|
3582
|
+
return compareQueryScalarValues(row.properties[predicate.propertyId], predicate.value, predicate.scalarKind) <= 0;
|
|
3583
|
+
case "gt":
|
|
3584
|
+
return compareQueryScalarValues(row.properties[predicate.propertyId], predicate.value, predicate.scalarKind) > 0;
|
|
3585
|
+
case "gte":
|
|
3586
|
+
return compareQueryScalarValues(row.properties[predicate.propertyId], predicate.value, predicate.scalarKind) >= 0;
|
|
3587
|
+
case "in":
|
|
3588
|
+
return predicate.values.some((value) => queryScalarValuesEqual(row.properties[predicate.propertyId], value, predicate.scalarKind));
|
|
3589
|
+
case "exists": {
|
|
3590
|
+
const exists = Object.hasOwn(row.properties, predicate.propertyId) && row.properties[predicate.propertyId] !== undefined;
|
|
3591
|
+
return predicate.value ? exists : !exists;
|
|
3592
|
+
}
|
|
3593
|
+
case "contains":
|
|
3594
|
+
return containsValue(row.properties[predicate.propertyId], predicate.value, predicate.scalarKind);
|
|
3595
|
+
}
|
|
3596
|
+
}
|
|
3597
|
+
function containsValue(actual, expected, itemScalarKind) {
|
|
3598
|
+
if (typeof actual === "string" && typeof expected === "string") {
|
|
3599
|
+
return actual.includes(expected);
|
|
3600
|
+
}
|
|
3601
|
+
if (Array.isArray(actual)) {
|
|
3602
|
+
return actual.some((item) => queryScalarValuesEqual(item, expected, itemScalarKind));
|
|
3603
|
+
}
|
|
3604
|
+
if (isPlainObject(actual) && typeof expected === "string") {
|
|
3605
|
+
return Object.hasOwn(actual, expected);
|
|
3606
|
+
}
|
|
3607
|
+
return false;
|
|
3608
|
+
}
|
|
3609
|
+
function isPlainObject(value) {
|
|
3610
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3611
|
+
}
|
|
3612
|
+
|
|
3613
|
+
// src/storage/objects/in-memory/keys.ts
|
|
3614
|
+
function objectRowKey(projectId, objectTypeId) {
|
|
3615
|
+
return JSON.stringify([projectId, objectTypeId]);
|
|
3616
|
+
}
|
|
3617
|
+
function objectRowProjectPrefix(projectId) {
|
|
3618
|
+
return `[${JSON.stringify(projectId)},`;
|
|
3619
|
+
}
|
|
2614
3620
|
function compareStrings2(left, right) {
|
|
2615
3621
|
if (left < right)
|
|
2616
3622
|
return -1;
|
|
@@ -2618,55 +3624,26 @@ function compareStrings2(left, right) {
|
|
|
2618
3624
|
return 1;
|
|
2619
3625
|
return 0;
|
|
2620
3626
|
}
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
var MAX_VECTOR_K = 1000;
|
|
2624
|
-
var VECTOR_INPUT_VERSION = 1;
|
|
2625
|
-
var INDEXING_EMBEDDING_TIMEOUT_MS = 5 * 60000;
|
|
2626
|
-
function vectorConfiguration(profile) {
|
|
2627
|
-
return sha256Canonical2({
|
|
2628
|
-
format: VECTOR_INPUT_VERSION,
|
|
2629
|
-
sources: [...profile.source],
|
|
2630
|
-
provider: profile.model.providerId,
|
|
2631
|
-
model: profile.model.modelId,
|
|
2632
|
-
representation: profile.model.definition.representation ?? { name: profile.model.modelId },
|
|
2633
|
-
dimensions: profile.model.definition.dimensions,
|
|
2634
|
-
...profile.model.definition.inputMode === "asymmetric" ? { inputMode: "asymmetric" } : {},
|
|
2635
|
-
metric: "cosine",
|
|
2636
|
-
precision: "float32",
|
|
2637
|
-
normalization: "l2-v1"
|
|
2638
|
-
});
|
|
3627
|
+
function sourceLinkBucketKey(projectId, sourceTypeId, sourceId) {
|
|
3628
|
+
return JSON.stringify([projectId, sourceTypeId, sourceId]);
|
|
2639
3629
|
}
|
|
2640
|
-
function
|
|
2641
|
-
|
|
2642
|
-
for (const key of source) {
|
|
2643
|
-
const value = properties[key];
|
|
2644
|
-
if (value !== undefined && value !== null && typeof value !== "string") {
|
|
2645
|
-
throw new MaterializationValidationError2(`Vector source must be text: ${key}`);
|
|
2646
|
-
}
|
|
2647
|
-
values[key] = typeof value === "string" ? value : null;
|
|
2648
|
-
}
|
|
2649
|
-
const text = JSON.stringify(source.map((key) => [key, values[key]]));
|
|
2650
|
-
return { text, sourceFingerprint: sha256Canonical2(text) };
|
|
3630
|
+
function linkRowKey(linkId, targetTypeId, targetId) {
|
|
3631
|
+
return JSON.stringify([linkId, targetTypeId, targetId]);
|
|
2651
3632
|
}
|
|
2652
|
-
function
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
throw new MaterializationValidationError2("Cosine search requires a nonzero vector.");
|
|
2664
|
-
}
|
|
2665
|
-
const norm = Math.hypot(...normalized);
|
|
2666
|
-
return Object.freeze(normalized.map((value) => Math.fround(value / norm)));
|
|
3633
|
+
function fullLinkRowKey(row) {
|
|
3634
|
+
return JSON.stringify([
|
|
3635
|
+
row.sourceTypeId,
|
|
3636
|
+
row.sourceId,
|
|
3637
|
+
row.linkId,
|
|
3638
|
+
row.targetTypeId,
|
|
3639
|
+
row.targetId
|
|
3640
|
+
]);
|
|
3641
|
+
}
|
|
3642
|
+
function rowIdentityKey(row) {
|
|
3643
|
+
return rowIdentityKeyParts(row.objectTypeId, row.primaryId);
|
|
2667
3644
|
}
|
|
2668
|
-
function
|
|
2669
|
-
return
|
|
3645
|
+
function rowIdentityKeyParts(objectTypeId, primaryId) {
|
|
3646
|
+
return objectBatchKey2(objectTypeId, primaryId);
|
|
2670
3647
|
}
|
|
2671
3648
|
|
|
2672
3649
|
// src/storage/objects/in-memory/query.ts
|
|
@@ -2700,7 +3677,8 @@ var IN_MEMORY_OBJECT_QUERY_CAPABILITIES = {
|
|
|
2700
3677
|
gte: true,
|
|
2701
3678
|
in: true,
|
|
2702
3679
|
exists: true,
|
|
2703
|
-
contains: true
|
|
3680
|
+
contains: true,
|
|
3681
|
+
constant: true
|
|
2704
3682
|
},
|
|
2705
3683
|
sortKinds: {
|
|
2706
3684
|
property: true,
|
|
@@ -2849,7 +3827,7 @@ function evaluateRefs(refs, source) {
|
|
|
2849
3827
|
seen.add(key);
|
|
2850
3828
|
const row = source.getObject(ref.objectTypeId, ref.primaryId);
|
|
2851
3829
|
return row ? [row] : [];
|
|
2852
|
-
}).sort((left, right) =>
|
|
3830
|
+
}).sort((left, right) => compareStrings2(left.objectTypeId, right.objectTypeId) || compareStrings2(left.primaryId, right.primaryId)).map((row, order) => ({ row, score: 0, order }));
|
|
2853
3831
|
return completeEvaluation(entries);
|
|
2854
3832
|
}
|
|
2855
3833
|
function evaluateSet(op, inputs, source) {
|
|
@@ -2926,48 +3904,6 @@ function completeEvaluation(entries) {
|
|
|
2926
3904
|
hasMore: false
|
|
2927
3905
|
};
|
|
2928
3906
|
}
|
|
2929
|
-
function matchesPredicate(row, predicate) {
|
|
2930
|
-
switch (predicate.op) {
|
|
2931
|
-
case "and":
|
|
2932
|
-
return predicate.items.every((item) => matchesPredicate(row, item));
|
|
2933
|
-
case "or":
|
|
2934
|
-
return predicate.items.some((item) => matchesPredicate(row, item));
|
|
2935
|
-
case "not":
|
|
2936
|
-
return !matchesPredicate(row, predicate.item);
|
|
2937
|
-
case "eq":
|
|
2938
|
-
return queryScalarValuesEqual(row.properties[predicate.propertyId], predicate.value, predicate.scalarKind);
|
|
2939
|
-
case "neq":
|
|
2940
|
-
return !queryScalarValuesEqual(row.properties[predicate.propertyId], predicate.value, predicate.scalarKind);
|
|
2941
|
-
case "lt":
|
|
2942
|
-
return compareQueryScalarValues(row.properties[predicate.propertyId], predicate.value, predicate.scalarKind) < 0;
|
|
2943
|
-
case "lte":
|
|
2944
|
-
return compareQueryScalarValues(row.properties[predicate.propertyId], predicate.value, predicate.scalarKind) <= 0;
|
|
2945
|
-
case "gt":
|
|
2946
|
-
return compareQueryScalarValues(row.properties[predicate.propertyId], predicate.value, predicate.scalarKind) > 0;
|
|
2947
|
-
case "gte":
|
|
2948
|
-
return compareQueryScalarValues(row.properties[predicate.propertyId], predicate.value, predicate.scalarKind) >= 0;
|
|
2949
|
-
case "in":
|
|
2950
|
-
return predicate.values.some((value) => queryScalarValuesEqual(row.properties[predicate.propertyId], value, predicate.scalarKind));
|
|
2951
|
-
case "exists": {
|
|
2952
|
-
const exists = Object.hasOwn(row.properties, predicate.propertyId) && row.properties[predicate.propertyId] !== undefined;
|
|
2953
|
-
return predicate.value ? exists : !exists;
|
|
2954
|
-
}
|
|
2955
|
-
case "contains":
|
|
2956
|
-
return containsValue(row.properties[predicate.propertyId], predicate.value, predicate.scalarKind);
|
|
2957
|
-
}
|
|
2958
|
-
}
|
|
2959
|
-
function containsValue(actual, expected, itemScalarKind) {
|
|
2960
|
-
if (typeof actual === "string" && typeof expected === "string") {
|
|
2961
|
-
return actual.includes(expected);
|
|
2962
|
-
}
|
|
2963
|
-
if (Array.isArray(actual)) {
|
|
2964
|
-
return actual.some((item) => queryScalarValuesEqual(item, expected, itemScalarKind));
|
|
2965
|
-
}
|
|
2966
|
-
if (isPlainObject(actual) && typeof expected === "string") {
|
|
2967
|
-
return Object.hasOwn(actual, expected);
|
|
2968
|
-
}
|
|
2969
|
-
return false;
|
|
2970
|
-
}
|
|
2971
3907
|
function textScore(row, query, fields, fieldsByObjectType) {
|
|
2972
3908
|
const terms = tokenize(query);
|
|
2973
3909
|
if (terms.length === 0)
|
|
@@ -3182,30 +4118,208 @@ function upsertEntry(entriesByKey, entry) {
|
|
|
3182
4118
|
entriesByKey.set(key, entry);
|
|
3183
4119
|
return;
|
|
3184
4120
|
}
|
|
3185
|
-
if (entry.score > existing.score) {
|
|
3186
|
-
entriesByKey.set(key, {
|
|
3187
|
-
...existing,
|
|
3188
|
-
score: entry.score
|
|
3189
|
-
});
|
|
4121
|
+
if (entry.score > existing.score) {
|
|
4122
|
+
entriesByKey.set(key, {
|
|
4123
|
+
...existing,
|
|
4124
|
+
score: entry.score
|
|
4125
|
+
});
|
|
4126
|
+
}
|
|
4127
|
+
}
|
|
4128
|
+
function encodePageOffset(offset) {
|
|
4129
|
+
return `${PAGE_TOKEN_PREFIX}${offset}`;
|
|
4130
|
+
}
|
|
4131
|
+
function decodePageOffset(token) {
|
|
4132
|
+
if (!token)
|
|
4133
|
+
return 0;
|
|
4134
|
+
if (!token.startsWith(PAGE_TOKEN_PREFIX)) {
|
|
4135
|
+
throw new Error("[Sixb] Invalid object query page token");
|
|
4136
|
+
}
|
|
4137
|
+
const offset = Number(token.slice(PAGE_TOKEN_PREFIX.length));
|
|
4138
|
+
if (!Number.isInteger(offset) || offset < 0) {
|
|
4139
|
+
throw new Error("[Sixb] Invalid object query page token");
|
|
4140
|
+
}
|
|
4141
|
+
return offset;
|
|
4142
|
+
}
|
|
4143
|
+
|
|
4144
|
+
// src/storage/objects/in-memory/scoped-reader.ts
|
|
4145
|
+
function createInMemoryScopedReader(params) {
|
|
4146
|
+
const { projectId, resolve, limits, queryCapabilities } = params;
|
|
4147
|
+
const assertProject = (actualProjectId) => assertObjectReaderProject2(projectId, actualProjectId);
|
|
4148
|
+
const visible = (value) => {
|
|
4149
|
+
if (limits)
|
|
4150
|
+
assertObjectReadOutputWithinLimit2(value, limits);
|
|
4151
|
+
return value;
|
|
4152
|
+
};
|
|
4153
|
+
const visibleMap = (value) => {
|
|
4154
|
+
if (limits)
|
|
4155
|
+
assertObjectReadOutputWithinLimit2([...value.entries()], limits);
|
|
4156
|
+
return value;
|
|
4157
|
+
};
|
|
4158
|
+
const selectsObjectProperties = async (input) => {
|
|
4159
|
+
assertProject(input.projectId);
|
|
4160
|
+
const source = resolve();
|
|
4161
|
+
return visible(input.items.map((item) => source.selectsProperty(item.objectTypeId, item.primaryId, item.propertyId)));
|
|
4162
|
+
};
|
|
4163
|
+
return Object.freeze({
|
|
4164
|
+
queryCapabilities,
|
|
4165
|
+
queryObjects: async (input) => {
|
|
4166
|
+
assertProject(input.projectId);
|
|
4167
|
+
const result = evaluateObjectQuery(input.query, resolve());
|
|
4168
|
+
return visible({
|
|
4169
|
+
objects: result.entries.map((entry) => ({
|
|
4170
|
+
...structuredClone(entry.row),
|
|
4171
|
+
...hasVectorProfile2(input.query) ? { score: entry.score } : {}
|
|
4172
|
+
})),
|
|
4173
|
+
hasMore: result.hasMore,
|
|
4174
|
+
nextPageToken: result.nextPageToken,
|
|
4175
|
+
...input.includeTotal === false ? {} : { total: result.total }
|
|
4176
|
+
});
|
|
4177
|
+
},
|
|
4178
|
+
countObjects: async (input) => {
|
|
4179
|
+
assertProject(input.projectId);
|
|
4180
|
+
return visible({
|
|
4181
|
+
count: evaluateObjectQuery(stripOuterRowShape(input.query), resolve()).total
|
|
4182
|
+
});
|
|
4183
|
+
},
|
|
4184
|
+
existsObjects: async (input) => {
|
|
4185
|
+
assertProject(input.projectId);
|
|
4186
|
+
return visible({
|
|
4187
|
+
exists: evaluateObjectQuery(stripOuterRowShape(input.query), resolve()).total > 0
|
|
4188
|
+
});
|
|
4189
|
+
},
|
|
4190
|
+
facetObjects: async (input) => {
|
|
4191
|
+
assertProject(input.projectId);
|
|
4192
|
+
assertObjectReadFacetCount2(input.facets.length);
|
|
4193
|
+
const result = evaluateObjectQuery(stripOuterRowShape(input.query), resolve());
|
|
4194
|
+
return visible(structuredClone({
|
|
4195
|
+
total: result.entries.length,
|
|
4196
|
+
facets: buildFacetResults(result.entries.map((entry) => entry.row), input.facets)
|
|
4197
|
+
}));
|
|
4198
|
+
},
|
|
4199
|
+
getByPrimaryId: async (input) => {
|
|
4200
|
+
assertProject(input.projectId);
|
|
4201
|
+
const row = resolve().getObject(input.objectTypeId, input.primaryId);
|
|
4202
|
+
return visible(row ? structuredClone(row) : null);
|
|
4203
|
+
},
|
|
4204
|
+
getByUniqueValue: async (input) => {
|
|
4205
|
+
assertProject(input.projectId);
|
|
4206
|
+
const source = resolve();
|
|
4207
|
+
const holder = source.uniqueHolder(input);
|
|
4208
|
+
const row = holder === undefined ? undefined : source.getObject(input.objectTypeId, holder);
|
|
4209
|
+
return visible(row ? structuredClone(row) : null);
|
|
4210
|
+
},
|
|
4211
|
+
selectsObjectProperties,
|
|
4212
|
+
listLinks: async (input) => {
|
|
4213
|
+
assertProject(input.projectId);
|
|
4214
|
+
return visible(listScopedLinks(resolve(), input).map((row) => structuredClone(row)));
|
|
4215
|
+
},
|
|
4216
|
+
getByPrimaryIdBatch: async (input) => {
|
|
4217
|
+
assertProject(input.projectId);
|
|
4218
|
+
const source = resolve();
|
|
4219
|
+
const rows = new Map;
|
|
4220
|
+
for (const item of input.items) {
|
|
4221
|
+
const row = source.getObject(item.objectTypeId, item.primaryId);
|
|
4222
|
+
if (row) {
|
|
4223
|
+
rows.set(objectBatchKey2(item.objectTypeId, item.primaryId), structuredClone(row));
|
|
4224
|
+
}
|
|
4225
|
+
}
|
|
4226
|
+
return visibleMap(rows);
|
|
4227
|
+
},
|
|
4228
|
+
listLinksBatch: async (input) => {
|
|
4229
|
+
assertProject(input.projectId);
|
|
4230
|
+
const source = resolve();
|
|
4231
|
+
return visibleMap(collectLinksBatch({
|
|
4232
|
+
all: () => source.allLinks(),
|
|
4233
|
+
outgoing: (item) => source.outgoingLinks(item.objectTypeId, item.objectId)
|
|
4234
|
+
}, input, true));
|
|
4235
|
+
},
|
|
4236
|
+
queryLinks: async (input) => {
|
|
4237
|
+
assertProject(input.projectId);
|
|
4238
|
+
const source = resolve();
|
|
4239
|
+
return visible(structuredClone(await queryLinksFrom(input, (item) => listScopedLinks(source, item))));
|
|
4240
|
+
},
|
|
4241
|
+
list: async (input) => {
|
|
4242
|
+
assertProject(input.projectId);
|
|
4243
|
+
return visible(listRows(input, [...resolve().allObjects()]));
|
|
4244
|
+
}
|
|
4245
|
+
});
|
|
4246
|
+
}
|
|
4247
|
+
function listScopedLinks(source, params) {
|
|
4248
|
+
const direction = params.direction ?? "outgoing";
|
|
4249
|
+
const matches = (row) => !params.linkId || row.linkId === params.linkId;
|
|
4250
|
+
const rows = [];
|
|
4251
|
+
if (direction === "outgoing" || direction === "both") {
|
|
4252
|
+
for (const row of source.outgoingLinks(params.objectTypeId, params.objectId)) {
|
|
4253
|
+
if (matches(row))
|
|
4254
|
+
rows.push(row);
|
|
4255
|
+
}
|
|
4256
|
+
}
|
|
4257
|
+
if (direction === "incoming" || direction === "both") {
|
|
4258
|
+
for (const row of source.allLinks()) {
|
|
4259
|
+
if (row.targetTypeId === params.objectTypeId && row.targetId === params.objectId && matches(row)) {
|
|
4260
|
+
rows.push(row);
|
|
4261
|
+
}
|
|
4262
|
+
}
|
|
3190
4263
|
}
|
|
4264
|
+
if (direction !== "both")
|
|
4265
|
+
return rows;
|
|
4266
|
+
return [...new Map(rows.map((row) => [fullLinkRowKey(row), row])).values()];
|
|
3191
4267
|
}
|
|
3192
|
-
function
|
|
3193
|
-
|
|
4268
|
+
function listRows(params, candidates) {
|
|
4269
|
+
const requestedTypes = params.objectTypeId === undefined ? undefined : new Set(typeof params.objectTypeId === "string" ? [params.objectTypeId] : params.objectTypeId);
|
|
4270
|
+
let rows = candidates.filter((row) => row.projectId === params.projectId && (!requestedTypes || requestedTypes.has(row.objectTypeId)));
|
|
4271
|
+
rows = rows.filter((row) => (!params.primaryIdPrefix || row.primaryId.startsWith(params.primaryIdPrefix)) && (!params.primaryIdSuffix || row.primaryId.endsWith(params.primaryIdSuffix)) && (!params.updatedAfter || row.updatedAt >= params.updatedAfter) && (!params.updatedBefore || row.updatedAt <= params.updatedBefore) && (!params.createdAfter || row.createdAt >= params.createdAfter) && (!params.createdBefore || row.createdAt <= params.createdBefore));
|
|
4272
|
+
const total = rows.length;
|
|
4273
|
+
const offset = params.offset ?? 0;
|
|
4274
|
+
const limit = params.limit ?? 50;
|
|
4275
|
+
if (limit === 0)
|
|
4276
|
+
return { objects: [], hasMore: offset < total, total };
|
|
4277
|
+
const orderBy = params.orderBy ?? "updatedAt";
|
|
4278
|
+
const order = params.order ?? "desc";
|
|
4279
|
+
rows.sort((left, right) => {
|
|
4280
|
+
const comparison = orderBy === "primaryId" ? left.primaryId.localeCompare(right.primaryId) : orderBy === "createdAt" ? left.createdAt.getTime() - right.createdAt.getTime() : left.updatedAt.getTime() - right.updatedAt.getTime();
|
|
4281
|
+
return order === "desc" ? -comparison : comparison;
|
|
4282
|
+
});
|
|
4283
|
+
const objects = rows.slice(offset, offset + limit).map((row) => structuredClone(row));
|
|
4284
|
+
return {
|
|
4285
|
+
objects,
|
|
4286
|
+
hasMore: offset + limit < total,
|
|
4287
|
+
total
|
|
4288
|
+
};
|
|
3194
4289
|
}
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
}
|
|
3205
|
-
return offset;
|
|
4290
|
+
|
|
4291
|
+
// src/storage/objects/in-memory/conditional-reader.ts
|
|
4292
|
+
function createInMemoryConditionalReader(source, scope, queryCapabilities) {
|
|
4293
|
+
const conditional = createConditionalReadSource(source, scope);
|
|
4294
|
+
return createInMemoryScopedReader({
|
|
4295
|
+
projectId: source.projectId,
|
|
4296
|
+
resolve: () => conditional,
|
|
4297
|
+
queryCapabilities
|
|
4298
|
+
});
|
|
3206
4299
|
}
|
|
3207
|
-
function
|
|
3208
|
-
|
|
4300
|
+
function createConditionalReadSource(source, scope) {
|
|
4301
|
+
const predicates = new Map(scope.conditions.map((condition) => [condition.objectTypeId, condition.predicate]));
|
|
4302
|
+
const isVisible = (row) => {
|
|
4303
|
+
const predicate = predicates.get(row.objectTypeId);
|
|
4304
|
+
return predicate === undefined || matchesPredicate(row, predicate);
|
|
4305
|
+
};
|
|
4306
|
+
const getObject = (objectTypeId, primaryId) => {
|
|
4307
|
+
const row = source.getObject(objectTypeId, primaryId);
|
|
4308
|
+
return row && isVisible(row) ? row : undefined;
|
|
4309
|
+
};
|
|
4310
|
+
const isVisibleEndpoint = (objectTypeId, primaryId) => !predicates.has(objectTypeId) || getObject(objectTypeId, primaryId) !== undefined;
|
|
4311
|
+
const isVisibleLink = (link) => isVisibleEndpoint(link.sourceTypeId, link.sourceId) && isVisibleEndpoint(link.targetTypeId, link.targetId);
|
|
4312
|
+
return {
|
|
4313
|
+
projectId: source.projectId,
|
|
4314
|
+
selectsProperty: (objectTypeId, primaryId) => getObject(objectTypeId, primaryId) !== undefined,
|
|
4315
|
+
getVector: (ref, profile) => source.getVector?.(ref, profile),
|
|
4316
|
+
allObjects: () => [...source.allObjects()].filter(isVisible),
|
|
4317
|
+
objectsOfType: (objectTypeId) => source.objectsOfType(objectTypeId).filter(isVisible),
|
|
4318
|
+
getObject,
|
|
4319
|
+
outgoingLinks: (objectTypeId, primaryId) => [...source.outgoingLinks(objectTypeId, primaryId)].filter(isVisibleLink),
|
|
4320
|
+
allLinks: () => [...source.allLinks()].filter(isVisibleLink),
|
|
4321
|
+
uniqueHolder: (value) => source.uniqueHolder(value)
|
|
4322
|
+
};
|
|
3209
4323
|
}
|
|
3210
4324
|
|
|
3211
4325
|
// src/storage/objects/in-memory/read-scope.ts
|
|
@@ -3309,10 +4423,7 @@ function createReadUniverse(source, objects, links, objectProperties) {
|
|
|
3309
4423
|
}
|
|
3310
4424
|
return {
|
|
3311
4425
|
projectId,
|
|
3312
|
-
|
|
3313
|
-
links,
|
|
3314
|
-
linksBySource,
|
|
3315
|
-
objectProperties,
|
|
4426
|
+
selectsProperty: (objectTypeId, primaryId, propertyId) => objectProperties.get(rowIdentityKeyParts(objectTypeId, primaryId))?.has(propertyId) ?? false,
|
|
3316
4427
|
getVector: (ref, profile) => {
|
|
3317
4428
|
const key = rowIdentityKeyParts(ref.objectTypeId, ref.primaryId);
|
|
3318
4429
|
if (!objects.has(key))
|
|
@@ -3320,10 +4431,18 @@ function createReadUniverse(source, objects, links, objectProperties) {
|
|
|
3320
4431
|
const value = source.getVector?.(ref, profile);
|
|
3321
4432
|
return value?.source.every((id) => objectProperties.get(key)?.has(id)) ? value : undefined;
|
|
3322
4433
|
},
|
|
4434
|
+
allObjects: () => objects.values(),
|
|
3323
4435
|
objectsOfType: (objectTypeId) => [...objects.values()].filter((row) => row.objectTypeId === objectTypeId),
|
|
3324
4436
|
getObject: (objectTypeId, primaryId) => objects.get(rowIdentityKeyParts(objectTypeId, primaryId)),
|
|
3325
4437
|
outgoingLinks: (objectTypeId, primaryId) => linksBySource.get(sourceLinkBucketKey(projectId, objectTypeId, primaryId)) ?? [],
|
|
3326
|
-
allLinks: () => links.values()
|
|
4438
|
+
allLinks: () => links.values(),
|
|
4439
|
+
uniqueHolder: (value) => {
|
|
4440
|
+
const holder = source.uniqueHolder(value);
|
|
4441
|
+
if (holder === undefined)
|
|
4442
|
+
return;
|
|
4443
|
+
const key = rowIdentityKeyParts(value.objectTypeId, holder);
|
|
4444
|
+
return objects.has(key) && objectProperties.get(key)?.has(value.propertyId) ? holder : undefined;
|
|
4445
|
+
}
|
|
3327
4446
|
};
|
|
3328
4447
|
}
|
|
3329
4448
|
function unionInto(target, key, values) {
|
|
@@ -3354,153 +4473,14 @@ function redactProperties(properties, propertyIds) {
|
|
|
3354
4473
|
|
|
3355
4474
|
// src/storage/objects/in-memory/selected-reader.ts
|
|
3356
4475
|
function createInMemorySelectedReader(source, params, queryCapabilities) {
|
|
3357
|
-
const projectId = source.projectId;
|
|
3358
4476
|
const plan = prepareReadPlan(params.scope);
|
|
3359
4477
|
const limits = snapshotObjectReadExecutionLimits2(params.limits);
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
const visibleMap = (value) => {
|
|
3366
|
-
assertObjectReadOutputWithinLimit2([...value.entries()], limits);
|
|
3367
|
-
return value;
|
|
3368
|
-
};
|
|
3369
|
-
const selectsObjectProperties = async (input) => {
|
|
3370
|
-
assertProject(input.projectId);
|
|
3371
|
-
const universe = resolveSelectedReadUniverse(source, plan, limits);
|
|
3372
|
-
return visible(input.items.map((item) => {
|
|
3373
|
-
const key = rowIdentityKeyParts(item.objectTypeId, item.primaryId);
|
|
3374
|
-
if (!universe.objects.has(key))
|
|
3375
|
-
return false;
|
|
3376
|
-
return universe.objectProperties.get(key)?.has(item.propertyId) ?? false;
|
|
3377
|
-
}));
|
|
3378
|
-
};
|
|
3379
|
-
return Object.freeze({
|
|
3380
|
-
queryCapabilities,
|
|
3381
|
-
queryObjects: async (input) => {
|
|
3382
|
-
assertProject(input.projectId);
|
|
3383
|
-
const universe = resolveSelectedReadUniverse(source, plan, limits);
|
|
3384
|
-
const result = evaluateObjectQuery(input.query, universe);
|
|
3385
|
-
return visible({
|
|
3386
|
-
objects: result.entries.map((entry) => ({
|
|
3387
|
-
...structuredClone(entry.row),
|
|
3388
|
-
...hasVectorProfile2(input.query) ? { score: entry.score } : {}
|
|
3389
|
-
})),
|
|
3390
|
-
hasMore: result.hasMore,
|
|
3391
|
-
nextPageToken: result.nextPageToken,
|
|
3392
|
-
...input.includeTotal === false ? {} : { total: result.total }
|
|
3393
|
-
});
|
|
3394
|
-
},
|
|
3395
|
-
countObjects: async (input) => {
|
|
3396
|
-
assertProject(input.projectId);
|
|
3397
|
-
const universe = resolveSelectedReadUniverse(source, plan, limits);
|
|
3398
|
-
return visible({
|
|
3399
|
-
count: evaluateObjectQuery(stripOuterRowShape(input.query), universe).total
|
|
3400
|
-
});
|
|
3401
|
-
},
|
|
3402
|
-
existsObjects: async (input) => {
|
|
3403
|
-
assertProject(input.projectId);
|
|
3404
|
-
const universe = resolveSelectedReadUniverse(source, plan, limits);
|
|
3405
|
-
return visible({
|
|
3406
|
-
exists: evaluateObjectQuery(stripOuterRowShape(input.query), universe).total > 0
|
|
3407
|
-
});
|
|
3408
|
-
},
|
|
3409
|
-
facetObjects: async (input) => {
|
|
3410
|
-
assertProject(input.projectId);
|
|
3411
|
-
assertObjectReadFacetCount2(input.facets.length);
|
|
3412
|
-
const universe = resolveSelectedReadUniverse(source, plan, limits);
|
|
3413
|
-
const result = evaluateObjectQuery(stripOuterRowShape(input.query), universe);
|
|
3414
|
-
return visible(structuredClone({
|
|
3415
|
-
total: result.entries.length,
|
|
3416
|
-
facets: buildFacetResults(result.entries.map((entry) => entry.row), input.facets)
|
|
3417
|
-
}));
|
|
3418
|
-
},
|
|
3419
|
-
getByPrimaryId: async (input) => {
|
|
3420
|
-
assertProject(input.projectId);
|
|
3421
|
-
const universe = resolveSelectedReadUniverse(source, plan, limits);
|
|
3422
|
-
const row = universe.objects.get(rowIdentityKeyParts(input.objectTypeId, input.primaryId));
|
|
3423
|
-
return visible(row ? structuredClone(row) : null);
|
|
3424
|
-
},
|
|
3425
|
-
selectsObjectProperties,
|
|
3426
|
-
listLinks: async (input) => {
|
|
3427
|
-
assertProject(input.projectId);
|
|
3428
|
-
const universe = resolveSelectedReadUniverse(source, plan, limits);
|
|
3429
|
-
return visible(listUniverseLinks(universe, input).map((row) => structuredClone(row)));
|
|
3430
|
-
},
|
|
3431
|
-
getByPrimaryIdBatch: async (input) => {
|
|
3432
|
-
assertProject(input.projectId);
|
|
3433
|
-
const universe = resolveSelectedReadUniverse(source, plan, limits);
|
|
3434
|
-
const rows = new Map;
|
|
3435
|
-
for (const item of input.items) {
|
|
3436
|
-
const row = universe.objects.get(rowIdentityKeyParts(item.objectTypeId, item.primaryId));
|
|
3437
|
-
if (row) {
|
|
3438
|
-
rows.set(objectBatchKey2(item.objectTypeId, item.primaryId), structuredClone(row));
|
|
3439
|
-
}
|
|
3440
|
-
}
|
|
3441
|
-
return visibleMap(rows);
|
|
3442
|
-
},
|
|
3443
|
-
listLinksBatch: async (input) => {
|
|
3444
|
-
assertProject(input.projectId);
|
|
3445
|
-
const universe = resolveSelectedReadUniverse(source, plan, limits);
|
|
3446
|
-
return visibleMap(collectLinksBatch({
|
|
3447
|
-
all: () => universe.links.values(),
|
|
3448
|
-
outgoing: (item) => universe.linksBySource.get(sourceLinkBucketKey(projectId, item.objectTypeId, item.objectId)) ?? []
|
|
3449
|
-
}, input, true));
|
|
3450
|
-
},
|
|
3451
|
-
queryLinks: async (input) => {
|
|
3452
|
-
assertProject(input.projectId);
|
|
3453
|
-
const universe = resolveSelectedReadUniverse(source, plan, limits);
|
|
3454
|
-
return visible(structuredClone(await queryLinksFrom(input, (item) => listUniverseLinks(universe, item))));
|
|
3455
|
-
},
|
|
3456
|
-
list: async (input) => {
|
|
3457
|
-
assertProject(input.projectId);
|
|
3458
|
-
const universe = resolveSelectedReadUniverse(source, plan, limits);
|
|
3459
|
-
return visible(listRows(input, [...universe.objects.values()]));
|
|
3460
|
-
}
|
|
3461
|
-
});
|
|
3462
|
-
}
|
|
3463
|
-
function listUniverseLinks(universe, params) {
|
|
3464
|
-
const direction = params.direction ?? "outgoing";
|
|
3465
|
-
const matches = (row) => !params.linkId || row.linkId === params.linkId;
|
|
3466
|
-
const rows = [];
|
|
3467
|
-
if (direction === "outgoing" || direction === "both") {
|
|
3468
|
-
const outgoing = universe.linksBySource.get(sourceLinkBucketKey(params.projectId, params.objectTypeId, params.objectId));
|
|
3469
|
-
if (outgoing)
|
|
3470
|
-
rows.push(...outgoing.filter(matches));
|
|
3471
|
-
}
|
|
3472
|
-
if (direction === "incoming" || direction === "both") {
|
|
3473
|
-
for (const row of universe.links.values()) {
|
|
3474
|
-
if (row.targetTypeId === params.objectTypeId && row.targetId === params.objectId && matches(row)) {
|
|
3475
|
-
rows.push(row);
|
|
3476
|
-
}
|
|
3477
|
-
}
|
|
3478
|
-
}
|
|
3479
|
-
if (direction !== "both")
|
|
3480
|
-
return rows;
|
|
3481
|
-
return [...new Map(rows.map((row) => [fullLinkRowKey(row), row])).values()];
|
|
3482
|
-
}
|
|
3483
|
-
function listRows(params, candidates) {
|
|
3484
|
-
const requestedTypes = params.objectTypeId === undefined ? undefined : new Set(typeof params.objectTypeId === "string" ? [params.objectTypeId] : params.objectTypeId);
|
|
3485
|
-
let rows = candidates.filter((row) => row.projectId === params.projectId && (!requestedTypes || requestedTypes.has(row.objectTypeId)));
|
|
3486
|
-
rows = rows.filter((row) => (!params.primaryIdPrefix || row.primaryId.startsWith(params.primaryIdPrefix)) && (!params.primaryIdSuffix || row.primaryId.endsWith(params.primaryIdSuffix)) && (!params.updatedAfter || row.updatedAt >= params.updatedAfter) && (!params.updatedBefore || row.updatedAt <= params.updatedBefore) && (!params.createdAfter || row.createdAt >= params.createdAfter) && (!params.createdBefore || row.createdAt <= params.createdBefore));
|
|
3487
|
-
const total = rows.length;
|
|
3488
|
-
const offset = params.offset ?? 0;
|
|
3489
|
-
const limit = params.limit ?? 50;
|
|
3490
|
-
if (limit === 0)
|
|
3491
|
-
return { objects: [], hasMore: offset < total, total };
|
|
3492
|
-
const orderBy = params.orderBy ?? "updatedAt";
|
|
3493
|
-
const order = params.order ?? "desc";
|
|
3494
|
-
rows.sort((left, right) => {
|
|
3495
|
-
const comparison = orderBy === "primaryId" ? left.primaryId.localeCompare(right.primaryId) : orderBy === "createdAt" ? left.createdAt.getTime() - right.createdAt.getTime() : left.updatedAt.getTime() - right.updatedAt.getTime();
|
|
3496
|
-
return order === "desc" ? -comparison : comparison;
|
|
4478
|
+
return createInMemoryScopedReader({
|
|
4479
|
+
projectId: source.projectId,
|
|
4480
|
+
resolve: () => resolveSelectedReadUniverse(source, plan, limits),
|
|
4481
|
+
limits,
|
|
4482
|
+
queryCapabilities
|
|
3497
4483
|
});
|
|
3498
|
-
const objects = rows.slice(offset, offset + limit).map((row) => structuredClone(row));
|
|
3499
|
-
return {
|
|
3500
|
-
objects,
|
|
3501
|
-
hasMore: offset + limit < total,
|
|
3502
|
-
total
|
|
3503
|
-
};
|
|
3504
4484
|
}
|
|
3505
4485
|
|
|
3506
4486
|
// src/storage/objects/in-memory/storage.ts
|
|
@@ -3515,6 +4495,8 @@ function getInMemoryObjectMaterializerAdapter(storage) {
|
|
|
3515
4495
|
class InMemoryObjectStorage {
|
|
3516
4496
|
rows = new Map;
|
|
3517
4497
|
links = new Map;
|
|
4498
|
+
uniqueValues = new Map;
|
|
4499
|
+
uniqueProperties = new Map;
|
|
3518
4500
|
vectorReader;
|
|
3519
4501
|
constructor() {
|
|
3520
4502
|
materializerAdapters.set(this, {
|
|
@@ -3543,13 +4525,37 @@ class InMemoryObjectStorage {
|
|
|
3543
4525
|
if (row.linkId === linkId)
|
|
3544
4526
|
visit(structuredClone(row));
|
|
3545
4527
|
}
|
|
4528
|
+
},
|
|
4529
|
+
getUniqueHolder: (projectId, value) => this.uniqueHolder(projectId, value) ?? null,
|
|
4530
|
+
releaseUniqueValue: (projectId, value) => this.releaseUniqueValue(projectId, value),
|
|
4531
|
+
claimUniqueValue: (projectId, value) => this.claimUniqueValue(projectId, value),
|
|
4532
|
+
listPreparedUniqueProperties: (projectId) => [...this.uniqueProperties.values()].filter((prepared) => prepared.projectId === projectId).map(({ objectTypeId, propertyId, keyKind, keyVersion }) => ({
|
|
4533
|
+
objectTypeId,
|
|
4534
|
+
propertyId,
|
|
4535
|
+
keyKind,
|
|
4536
|
+
keyVersion
|
|
4537
|
+
})),
|
|
4538
|
+
clearUniqueProperty: (projectId, objectTypeId, propertyId) => {
|
|
4539
|
+
const key = uniquePropertyKey(projectId, objectTypeId, propertyId);
|
|
4540
|
+
this.uniqueValues.delete(key);
|
|
4541
|
+
this.uniqueProperties.delete(key);
|
|
4542
|
+
},
|
|
4543
|
+
insertUniqueValues: (projectId, objectTypeId, propertyId, entries) => {
|
|
4544
|
+
for (const { valueKey, primaryId } of entries) {
|
|
4545
|
+
this.holdUniqueValue(projectId, { objectTypeId, propertyId, valueKey, primaryId });
|
|
4546
|
+
}
|
|
4547
|
+
},
|
|
4548
|
+
markUniquePropertyPrepared: (input) => {
|
|
4549
|
+
this.uniqueProperties.set(uniquePropertyKey(input.projectId, input.objectTypeId, input.propertyId), { ...input });
|
|
3546
4550
|
}
|
|
3547
4551
|
});
|
|
3548
4552
|
}
|
|
3549
4553
|
snapshot() {
|
|
3550
4554
|
return {
|
|
3551
4555
|
rows: cloneObjectBuckets(this.rows),
|
|
3552
|
-
links: cloneLinkBuckets(this.links)
|
|
4556
|
+
links: cloneLinkBuckets(this.links),
|
|
4557
|
+
uniqueValues: cloneUniqueValues(this.uniqueValues),
|
|
4558
|
+
uniqueProperties: new Map(this.uniqueProperties)
|
|
3553
4559
|
};
|
|
3554
4560
|
}
|
|
3555
4561
|
restore(snapshot) {
|
|
@@ -3561,6 +4567,58 @@ class InMemoryObjectStorage {
|
|
|
3561
4567
|
for (const [key, bucket] of cloneLinkBuckets(snapshot.links)) {
|
|
3562
4568
|
this.links.set(key, bucket);
|
|
3563
4569
|
}
|
|
4570
|
+
this.uniqueValues.clear();
|
|
4571
|
+
for (const [key, holders] of cloneUniqueValues(snapshot.uniqueValues)) {
|
|
4572
|
+
this.uniqueValues.set(key, holders);
|
|
4573
|
+
}
|
|
4574
|
+
this.uniqueProperties.clear();
|
|
4575
|
+
for (const [key, prepared] of snapshot.uniqueProperties) {
|
|
4576
|
+
this.uniqueProperties.set(key, prepared);
|
|
4577
|
+
}
|
|
4578
|
+
}
|
|
4579
|
+
uniqueHolder(projectId, value) {
|
|
4580
|
+
return this.uniqueValues.get(uniquePropertyKey(projectId, value.objectTypeId, value.propertyId))?.get(value.valueKey);
|
|
4581
|
+
}
|
|
4582
|
+
releaseUniqueValue(projectId, value) {
|
|
4583
|
+
if (this.uniqueHolder(projectId, value) !== value.primaryId)
|
|
4584
|
+
return;
|
|
4585
|
+
this.uniqueValues.get(uniquePropertyKey(projectId, value.objectTypeId, value.propertyId))?.delete(value.valueKey);
|
|
4586
|
+
}
|
|
4587
|
+
claimUniqueValue(projectId, claim) {
|
|
4588
|
+
this.prepareUniqueProperty(projectId, claim);
|
|
4589
|
+
this.holdUniqueValue(projectId, claim);
|
|
4590
|
+
}
|
|
4591
|
+
prepareUniqueProperty(projectId, claim) {
|
|
4592
|
+
const key = uniquePropertyKey(projectId, claim.objectTypeId, claim.propertyId);
|
|
4593
|
+
const prepared = this.uniqueProperties.get(key);
|
|
4594
|
+
if (prepared?.keyKind === claim.keyKind && prepared.keyVersion === claim.keyVersion)
|
|
4595
|
+
return;
|
|
4596
|
+
this.uniqueValues.delete(key);
|
|
4597
|
+
const bucket = this.rows.get(objectRowKey(projectId, claim.objectTypeId));
|
|
4598
|
+
for (const row of bucket?.values() ?? []) {
|
|
4599
|
+
const valueKey = uniqueValueKey(claim.keyKind, row.properties[claim.propertyId]);
|
|
4600
|
+
if (valueKey === null)
|
|
4601
|
+
continue;
|
|
4602
|
+
this.holdUniqueValue(projectId, { ...claim, valueKey, primaryId: row.primaryId });
|
|
4603
|
+
}
|
|
4604
|
+
this.uniqueProperties.set(key, {
|
|
4605
|
+
projectId,
|
|
4606
|
+
objectTypeId: claim.objectTypeId,
|
|
4607
|
+
propertyId: claim.propertyId,
|
|
4608
|
+
keyKind: claim.keyKind,
|
|
4609
|
+
keyVersion: claim.keyVersion,
|
|
4610
|
+
preparedAt: new Date().toISOString()
|
|
4611
|
+
});
|
|
4612
|
+
}
|
|
4613
|
+
holdUniqueValue(projectId, value) {
|
|
4614
|
+
const holder = this.uniqueHolder(projectId, value);
|
|
4615
|
+
if (holder !== undefined && holder !== value.primaryId) {
|
|
4616
|
+
throw uniqueValueViolation2(value, holder, value.primaryId);
|
|
4617
|
+
}
|
|
4618
|
+
const key = uniquePropertyKey(projectId, value.objectTypeId, value.propertyId);
|
|
4619
|
+
const holders = this.uniqueValues.get(key) ?? new Map;
|
|
4620
|
+
this.uniqueValues.set(key, holders);
|
|
4621
|
+
holders.set(value.valueKey, value.primaryId);
|
|
3564
4622
|
}
|
|
3565
4623
|
getExactObjectRow(projectId, objectTypeId, primaryId) {
|
|
3566
4624
|
const row = this.rows.get(objectRowKey(projectId, objectTypeId))?.get(primaryId);
|
|
@@ -3614,16 +4672,21 @@ class InMemoryObjectStorage {
|
|
|
3614
4672
|
createSelectedReadScope(params) {
|
|
3615
4673
|
return createInMemorySelectedReader(this.readSource(params.projectId), params, () => this.queryCapabilities());
|
|
3616
4674
|
}
|
|
4675
|
+
createConditionalReadScope(params) {
|
|
4676
|
+
return createInMemoryConditionalReader(this.readSource(params.projectId), params.scope, () => this.queryCapabilities());
|
|
4677
|
+
}
|
|
3617
4678
|
readSource(projectId) {
|
|
3618
4679
|
return {
|
|
3619
4680
|
projectId,
|
|
3620
4681
|
getVector: (ref, profile) => this.vectorReader?.(projectId, ref, profile),
|
|
4682
|
+
allObjects: () => projectObjectRows(this.rows, projectId),
|
|
3621
4683
|
objectsOfType: (objectTypeId) => [
|
|
3622
4684
|
...this.rows.get(objectRowKey(projectId, objectTypeId))?.values() ?? []
|
|
3623
4685
|
],
|
|
3624
4686
|
getObject: (objectTypeId, primaryId) => this.rows.get(objectRowKey(projectId, objectTypeId))?.get(primaryId),
|
|
3625
4687
|
outgoingLinks: (objectTypeId, primaryId) => this.links.get(sourceLinkBucketKey(projectId, objectTypeId, primaryId))?.values() ?? [],
|
|
3626
|
-
allLinks: () =>
|
|
4688
|
+
allLinks: () => projectLinkRows(this.links, projectId),
|
|
4689
|
+
uniqueHolder: (value) => this.uniqueHolder(projectId, value)
|
|
3627
4690
|
};
|
|
3628
4691
|
}
|
|
3629
4692
|
async queryObjects(params) {
|
|
@@ -3661,6 +4724,12 @@ class InMemoryObjectStorage {
|
|
|
3661
4724
|
return null;
|
|
3662
4725
|
return bucket.get(params.primaryId) ?? null;
|
|
3663
4726
|
}
|
|
4727
|
+
async getByUniqueValue(params) {
|
|
4728
|
+
const holder = this.uniqueHolder(params.projectId, params);
|
|
4729
|
+
if (holder === undefined)
|
|
4730
|
+
return null;
|
|
4731
|
+
return this.getByPrimaryId({ ...params, primaryId: holder });
|
|
4732
|
+
}
|
|
3664
4733
|
async selectsObjectProperties(params) {
|
|
3665
4734
|
return params.items.map((item) => this.rows.get(objectRowKey(params.projectId, item.objectTypeId))?.has(item.primaryId) ?? false);
|
|
3666
4735
|
}
|
|
@@ -3727,7 +4796,7 @@ class InMemoryObjectStorage {
|
|
|
3727
4796
|
async listByPrimaryIdPage(params) {
|
|
3728
4797
|
assertReconciliationPageLimit(params.limit);
|
|
3729
4798
|
const bucket = this.rows.get(objectRowKey(params.projectId, params.objectTypeId));
|
|
3730
|
-
const rows = [...bucket?.values() ?? []].filter((row) => !params.afterPrimaryId ||
|
|
4799
|
+
const rows = [...bucket?.values() ?? []].filter((row) => !params.afterPrimaryId || compareStrings2(row.primaryId, params.afterPrimaryId) > 0).sort((left, right) => compareStrings2(left.primaryId, right.primaryId)).slice(0, params.limit + 1);
|
|
3731
4800
|
const hasMore = rows.length > params.limit;
|
|
3732
4801
|
const objects = rows.slice(0, params.limit).map((row) => structuredClone(row));
|
|
3733
4802
|
const last = objects.at(-1);
|
|
@@ -3811,6 +4880,12 @@ function cloneObjectBuckets(rows) {
|
|
|
3811
4880
|
}
|
|
3812
4881
|
return clone;
|
|
3813
4882
|
}
|
|
4883
|
+
function uniquePropertyKey(projectId, objectTypeId, propertyId) {
|
|
4884
|
+
return JSON.stringify([projectId, objectTypeId, propertyId]);
|
|
4885
|
+
}
|
|
4886
|
+
function cloneUniqueValues(values) {
|
|
4887
|
+
return new Map([...values].map(([key, holders]) => [key, new Map(holders)]));
|
|
4888
|
+
}
|
|
3814
4889
|
function cloneLinkBuckets(links) {
|
|
3815
4890
|
const clone = new Map;
|
|
3816
4891
|
for (const [key, bucket] of links) {
|
|
@@ -3818,6 +4893,20 @@ function cloneLinkBuckets(links) {
|
|
|
3818
4893
|
}
|
|
3819
4894
|
return clone;
|
|
3820
4895
|
}
|
|
4896
|
+
function* projectObjectRows(buckets, projectId) {
|
|
4897
|
+
const prefix = objectRowProjectPrefix(projectId);
|
|
4898
|
+
for (const [key, bucket] of buckets) {
|
|
4899
|
+
if (key.startsWith(prefix))
|
|
4900
|
+
yield* bucket.values();
|
|
4901
|
+
}
|
|
4902
|
+
}
|
|
4903
|
+
function* projectLinkRows(buckets, projectId) {
|
|
4904
|
+
const prefix = objectRowProjectPrefix(projectId);
|
|
4905
|
+
for (const [key, bucket] of buckets) {
|
|
4906
|
+
if (key.startsWith(prefix))
|
|
4907
|
+
yield* bucket.values();
|
|
4908
|
+
}
|
|
4909
|
+
}
|
|
3821
4910
|
function* allLinkRows(buckets) {
|
|
3822
4911
|
for (const bucket of buckets.values())
|
|
3823
4912
|
yield* bucket.values();
|
|
@@ -4583,6 +5672,9 @@ function touchPlanItem(touches, item) {
|
|
|
4583
5672
|
case "link-slot-override-delete":
|
|
4584
5673
|
touches.scopes.add(linkScopeKey(item.value.ref.source, item.value.ref.linkId));
|
|
4585
5674
|
return;
|
|
5675
|
+
case "unique-value-release":
|
|
5676
|
+
case "unique-value-claim":
|
|
5677
|
+
return;
|
|
4586
5678
|
}
|
|
4587
5679
|
}
|
|
4588
5680
|
function replacementPlanKey(input) {
|
|
@@ -5211,6 +6303,17 @@ class InMemoryOntologyMaterializationStorage {
|
|
|
5211
6303
|
const value = this.linkSlotState(session, scope.source, scope.linkId);
|
|
5212
6304
|
yield { objects: [], links: [], linkScopes: [value], points: [] };
|
|
5213
6305
|
}
|
|
6306
|
+
const uniqueHolders = this.uniqueHolders(session, request.uniqueValues ?? []);
|
|
6307
|
+
for (let offset = 0;offset < uniqueHolders.length; offset += input.pageRows) {
|
|
6308
|
+
this.requireSession(input.session);
|
|
6309
|
+
yield {
|
|
6310
|
+
objects: [],
|
|
6311
|
+
links: [],
|
|
6312
|
+
linkScopes: [],
|
|
6313
|
+
points: [],
|
|
6314
|
+
uniqueHolders: uniqueHolders.slice(offset, offset + input.pageRows)
|
|
6315
|
+
};
|
|
6316
|
+
}
|
|
5214
6317
|
const requestedPoints = uniqueSorted2(request.points, (point) => telemetryPointKey2(point.series, point.at), (point) => telemetryPointSortKey2(point.series, point.at));
|
|
5215
6318
|
for (let offset = 0;offset < requestedPoints.length; offset += input.pageRows) {
|
|
5216
6319
|
this.requireSession(input.session);
|
|
@@ -5378,6 +6481,14 @@ class InMemoryOntologyMaterializationStorage {
|
|
|
5378
6481
|
this.assertLinkSync(item.expected, projectId);
|
|
5379
6482
|
getInMemoryObjectMaterializerAdapter(this.objects).applyExactLink(item.row, projectId);
|
|
5380
6483
|
});
|
|
6484
|
+
for (const item of chunk.unique.releases)
|
|
6485
|
+
write("unique.release", () => {
|
|
6486
|
+
getInMemoryObjectMaterializerAdapter(this.objects).releaseUniqueValue(projectId, item);
|
|
6487
|
+
});
|
|
6488
|
+
for (const item of chunk.unique.claims)
|
|
6489
|
+
write("unique.claim", () => {
|
|
6490
|
+
getInMemoryObjectMaterializerAdapter(this.objects).claimUniqueValue(projectId, item);
|
|
6491
|
+
});
|
|
5381
6492
|
for (const item of chunk.timeseries.pointUpserts)
|
|
5382
6493
|
write("timeseries.point.upsert", () => {
|
|
5383
6494
|
this.assertPoint(item.expected, projectId);
|
|
@@ -5548,6 +6659,16 @@ class InMemoryOntologyMaterializationStorage {
|
|
|
5548
6659
|
throw new MaterializationConflictError2("timeseries-point", `Telemetry point ${telemetryPointKey2(expected.series, expected.at)} changed.`);
|
|
5549
6660
|
}
|
|
5550
6661
|
}
|
|
6662
|
+
uniqueHolders(session, values) {
|
|
6663
|
+
const adapter = getInMemoryObjectMaterializerAdapter(this.objects);
|
|
6664
|
+
const holders = [];
|
|
6665
|
+
for (const value of values) {
|
|
6666
|
+
const primaryId = adapter.getUniqueHolder(session.header.commit.projectId, value);
|
|
6667
|
+
if (primaryId !== null)
|
|
6668
|
+
holders.push({ ...value, primaryId });
|
|
6669
|
+
}
|
|
6670
|
+
return holders;
|
|
6671
|
+
}
|
|
5551
6672
|
linkSlotState(session, source, linkId) {
|
|
5552
6673
|
session.linkSlotStates ??= new Map;
|
|
5553
6674
|
const key = linkScopeSortKey2(source, linkId);
|
|
@@ -5843,6 +6964,24 @@ class InMemoryOntologySourceStorage {
|
|
|
5843
6964
|
return active ? sourceMaterializationRecord(active) : null;
|
|
5844
6965
|
});
|
|
5845
6966
|
}
|
|
6967
|
+
async listActive(input) {
|
|
6968
|
+
return this.runRootOperation(() => {
|
|
6969
|
+
assertNonblank(input.projectId, "Source project id");
|
|
6970
|
+
const active = [];
|
|
6971
|
+
for (const materialization of this.state.sourceMaterializations.values()) {
|
|
6972
|
+
if (materialization.projectId !== input.projectId)
|
|
6973
|
+
continue;
|
|
6974
|
+
if (materialization.status !== "active")
|
|
6975
|
+
continue;
|
|
6976
|
+
active.push({
|
|
6977
|
+
source: { projectionId: materialization.source.projectionId },
|
|
6978
|
+
datasetVersion: { ...materialization.datasetVersion },
|
|
6979
|
+
projectionRevision: materialization.projectionRevision
|
|
6980
|
+
});
|
|
6981
|
+
}
|
|
6982
|
+
return active;
|
|
6983
|
+
});
|
|
6984
|
+
}
|
|
5846
6985
|
async adopt(input) {
|
|
5847
6986
|
return this.runRootOperation(async () => {
|
|
5848
6987
|
assertSourceProject2(input);
|
|
@@ -6280,6 +7419,32 @@ function registerInMemoryOntologyStorageTestingAdapter(storage, adapter) {
|
|
|
6280
7419
|
testingAdapters.set(storage, adapter);
|
|
6281
7420
|
}
|
|
6282
7421
|
|
|
7422
|
+
// src/storage/ontology/in-memory/unique-values.ts
|
|
7423
|
+
class InMemoryOntologyUniqueValueStorage {
|
|
7424
|
+
objects;
|
|
7425
|
+
runRootOperation;
|
|
7426
|
+
constructor(objects, runRootOperation) {
|
|
7427
|
+
this.objects = objects;
|
|
7428
|
+
this.runRootOperation = runRootOperation;
|
|
7429
|
+
}
|
|
7430
|
+
async lockPreparation(_input) {}
|
|
7431
|
+
async listPrepared(input) {
|
|
7432
|
+
return this.runRootOperation(() => this.adapter().listPreparedUniqueProperties(input.projectId));
|
|
7433
|
+
}
|
|
7434
|
+
async clear(input) {
|
|
7435
|
+
await this.runRootOperation(() => this.adapter().clearUniqueProperty(input.projectId, input.objectTypeId, input.propertyId));
|
|
7436
|
+
}
|
|
7437
|
+
async insert(input) {
|
|
7438
|
+
await this.runRootOperation(() => this.adapter().insertUniqueValues(input.projectId, input.objectTypeId, input.propertyId, input.entries));
|
|
7439
|
+
}
|
|
7440
|
+
async markPrepared(input) {
|
|
7441
|
+
await this.runRootOperation(() => this.adapter().markUniquePropertyPrepared(input));
|
|
7442
|
+
}
|
|
7443
|
+
adapter() {
|
|
7444
|
+
return getInMemoryObjectMaterializerAdapter(this.objects);
|
|
7445
|
+
}
|
|
7446
|
+
}
|
|
7447
|
+
|
|
6283
7448
|
// src/storage/ontology/in-memory/vector-indexing.ts
|
|
6284
7449
|
class InMemoryVectorIndexingStorage {
|
|
6285
7450
|
state;
|
|
@@ -6412,6 +7577,7 @@ class InMemoryOntologyStorage {
|
|
|
6412
7577
|
materializations;
|
|
6413
7578
|
replacementPlans;
|
|
6414
7579
|
outbox;
|
|
7580
|
+
uniqueValues;
|
|
6415
7581
|
testHooks = {};
|
|
6416
7582
|
testingAdapter = {
|
|
6417
7583
|
setTestHooks: (hooks) => this.setTestHooks(hooks),
|
|
@@ -6424,6 +7590,7 @@ class InMemoryOntologyStorage {
|
|
|
6424
7590
|
this.commits = new InMemoryOntologyCommitStorage(this.state, options.runRootOperation);
|
|
6425
7591
|
this.sources = new InMemoryOntologySourceStorage(this.state, options.runRootOperation, options.assertSourceMaterializationExecution);
|
|
6426
7592
|
this.outbox = new InMemoryOntologyOutboxStorage(this.state, options.runRootOperation, options.readExecution);
|
|
7593
|
+
this.uniqueValues = new InMemoryOntologyUniqueValueStorage(objects, options.runRootOperation);
|
|
6427
7594
|
const hooks = {
|
|
6428
7595
|
beforeRead: (boundary) => this.testHooks.beforeRead?.(boundary),
|
|
6429
7596
|
beforeWrite: (boundary, ordinal) => this.testHooks.beforeWrite?.(boundary, ordinal),
|
|
@@ -6783,29 +7950,19 @@ function compareRuns2(a, b, order) {
|
|
|
6783
7950
|
|
|
6784
7951
|
class InMemoryProjectionRunStorage2 {
|
|
6785
7952
|
rows = new Map;
|
|
6786
|
-
executionTokensByRun = new Map;
|
|
6787
7953
|
runRootOperation;
|
|
6788
|
-
createExecutionToken;
|
|
6789
7954
|
constructor(input) {
|
|
6790
7955
|
this.executions = input.executions;
|
|
6791
7956
|
this.runRootOperation = input.runRootOperation ?? runDirectly3;
|
|
6792
|
-
this.createExecutionToken = input.executionToken ?? randomUUID;
|
|
6793
7957
|
}
|
|
6794
7958
|
executions;
|
|
6795
7959
|
snapshot() {
|
|
6796
|
-
return structuredClone({
|
|
6797
|
-
rows: this.rows,
|
|
6798
|
-
executionTokensByRun: this.executionTokensByRun
|
|
6799
|
-
});
|
|
7960
|
+
return structuredClone({ rows: this.rows });
|
|
6800
7961
|
}
|
|
6801
7962
|
restore(snapshot) {
|
|
6802
7963
|
this.rows.clear();
|
|
6803
|
-
this.executionTokensByRun.clear();
|
|
6804
7964
|
for (const [key, record] of structuredClone(snapshot.rows))
|
|
6805
7965
|
this.rows.set(key, record);
|
|
6806
|
-
for (const [key, tokens] of structuredClone(snapshot.executionTokensByRun)) {
|
|
6807
|
-
this.executionTokensByRun.set(key, tokens);
|
|
6808
|
-
}
|
|
6809
7966
|
}
|
|
6810
7967
|
async queue(input) {
|
|
6811
7968
|
return this.runRootOperation(async () => {
|
|
@@ -6841,12 +7998,11 @@ class InMemoryProjectionRunStorage2 {
|
|
|
6841
7998
|
if (!existing)
|
|
6842
7999
|
throw projectionRunNotFound2(input.projectId, input.id);
|
|
6843
8000
|
const attempt = planProjectionRunReclaim2(existing, input).attempt;
|
|
6844
|
-
const executionToken = this.issueExecutionToken(key, input.id, existing.executionToken);
|
|
6845
8001
|
const record = {
|
|
6846
8002
|
...existing,
|
|
6847
8003
|
status: "running",
|
|
6848
8004
|
attempt,
|
|
6849
|
-
executionToken,
|
|
8005
|
+
executionToken: randomUUID(),
|
|
6850
8006
|
startedAt: existing.startedAt ?? new Date(input.startedAt ?? new Date),
|
|
6851
8007
|
finishedAt: undefined
|
|
6852
8008
|
};
|
|
@@ -6990,19 +8146,6 @@ class InMemoryProjectionRunStorage2 {
|
|
|
6990
8146
|
}
|
|
6991
8147
|
}
|
|
6992
8148
|
}
|
|
6993
|
-
issueExecutionToken(key, runId, currentToken) {
|
|
6994
|
-
const executionToken = this.createExecutionToken();
|
|
6995
|
-
assertProjectionRunNonEmpty2(executionToken, "executionToken");
|
|
6996
|
-
const usedTokens = this.executionTokensByRun.get(key) ?? new Set;
|
|
6997
|
-
if (currentToken)
|
|
6998
|
-
usedTokens.add(currentToken);
|
|
6999
|
-
if (usedTokens.has(executionToken)) {
|
|
7000
|
-
throw new ProjectionRunError2(`[Sixb] Projection run '${runId}' execution token was already used.`);
|
|
7001
|
-
}
|
|
7002
|
-
usedTokens.add(executionToken);
|
|
7003
|
-
this.executionTokensByRun.set(key, usedTokens);
|
|
7004
|
-
return executionToken;
|
|
7005
|
-
}
|
|
7006
8149
|
requireExecution(input) {
|
|
7007
8150
|
const record = this.requireRunning(input.projectId, input.id);
|
|
7008
8151
|
assertProjectionRunAttempt2(record, input);
|
|
@@ -7024,7 +8167,7 @@ class InMemoryProjectionRunStorage2 {
|
|
|
7024
8167
|
}
|
|
7025
8168
|
}
|
|
7026
8169
|
// src/storage/rules/in-memory.ts
|
|
7027
|
-
function
|
|
8170
|
+
function stateKey2(params) {
|
|
7028
8171
|
return JSON.stringify([
|
|
7029
8172
|
params.projectId,
|
|
7030
8173
|
params.ruleId,
|
|
@@ -7070,12 +8213,12 @@ class InMemoryRulesStorage2 {
|
|
|
7070
8213
|
}
|
|
7071
8214
|
}
|
|
7072
8215
|
async getActive(params) {
|
|
7073
|
-
const record = this.active.get(
|
|
8216
|
+
const record = this.active.get(stateKey2(params));
|
|
7074
8217
|
return record ? cloneRuleStateRecord(record) : null;
|
|
7075
8218
|
}
|
|
7076
8219
|
async getActiveBatch(params) {
|
|
7077
8220
|
return params.items.flatMap((item) => {
|
|
7078
|
-
const record = this.active.get(
|
|
8221
|
+
const record = this.active.get(stateKey2({ projectId: params.projectId, ...item }));
|
|
7079
8222
|
return record ? [cloneRuleStateRecord(record)] : [];
|
|
7080
8223
|
});
|
|
7081
8224
|
}
|
|
@@ -7118,10 +8261,10 @@ class InMemoryRulesStorage2 {
|
|
|
7118
8261
|
subject: structuredClone(event.payload.subject),
|
|
7119
8262
|
triggeredAt: event.payload.triggeredAt
|
|
7120
8263
|
};
|
|
7121
|
-
this.active.set(
|
|
8264
|
+
this.active.set(stateKey2(record), cloneRuleStateRecord(record));
|
|
7122
8265
|
}
|
|
7123
8266
|
async applyResolved(event) {
|
|
7124
|
-
this.active.delete(
|
|
8267
|
+
this.active.delete(stateKey2({
|
|
7125
8268
|
projectId: event.projectId,
|
|
7126
8269
|
ruleId: event.payload.ruleId,
|
|
7127
8270
|
subject: event.payload.subject
|
|
@@ -7155,6 +8298,12 @@ class InMemoryShareGrantStorage2 {
|
|
|
7155
8298
|
const record = this.rows.get(rowKey2(normalized.projectId, normalized.id));
|
|
7156
8299
|
return record ? cloneShareGrantRecord2(record) : null;
|
|
7157
8300
|
}
|
|
8301
|
+
async getByIds(input) {
|
|
8302
|
+
return [...new Set(input.ids)].flatMap((id) => {
|
|
8303
|
+
const record = this.rows.get(rowKey2(input.projectId, id));
|
|
8304
|
+
return record ? [cloneShareGrantRecord2(record)] : [];
|
|
8305
|
+
});
|
|
8306
|
+
}
|
|
7158
8307
|
async list(input) {
|
|
7159
8308
|
const normalized = normalizeListShareGrantsInput2(input);
|
|
7160
8309
|
const matching = [...this.rows.values()].filter((record) => record.projectId === normalized.projectId && (normalized.definitionId === undefined || record.definitionId === normalized.definitionId) && (normalized.target === undefined || record.target.objectTypeId === normalized.target.objectTypeId && record.target.primaryId === normalized.target.primaryId) && (normalized.includeRevoked || record.revokedAt === undefined) && (normalized.includeExpired || record.expiresAt.getTime() > normalized.now.getTime())).sort(compareShareGrants);
|
|
@@ -7868,6 +9017,13 @@ class InMemoryWorkflowRunStorage2 {
|
|
|
7868
9017
|
const record = this.runs.get(storageKey(params.projectId, params.id));
|
|
7869
9018
|
return record ? cloneRecord(record) : null;
|
|
7870
9019
|
}
|
|
9020
|
+
async getByExecutionIds(params) {
|
|
9021
|
+
const byExecution = new Map([...this.runs.values()].filter((record) => record.projectId === params.projectId).map((record) => [record.executionId, record]));
|
|
9022
|
+
return [...new Set(params.executionIds)].flatMap((executionId) => {
|
|
9023
|
+
const record = byExecution.get(executionId);
|
|
9024
|
+
return record ? [cloneRecord(record)] : [];
|
|
9025
|
+
});
|
|
9026
|
+
}
|
|
7871
9027
|
async list(input) {
|
|
7872
9028
|
if (hasEmptyStatuses(input) || input.workflowIds?.length === 0) {
|
|
7873
9029
|
return {
|
|
@@ -8245,6 +9401,7 @@ class InMemoryStorage2 {
|
|
|
8245
9401
|
shareSessions: this.shareSessionStorage
|
|
8246
9402
|
});
|
|
8247
9403
|
agentStorage = new InMemoryAgentStorage2(this.executionStorage);
|
|
9404
|
+
artifactStorage = new InMemoryArtifactStorage;
|
|
8248
9405
|
aiUsageStorage = new InMemoryAiUsageStorage2(this.executionStorage);
|
|
8249
9406
|
aiCostStorage = new InMemoryAiCostStorage2(this.aiUsageStorage, {
|
|
8250
9407
|
resolve: (input) => this.resolveAiAccountingAttribution(input),
|
|
@@ -8286,9 +9443,11 @@ class InMemoryStorage2 {
|
|
|
8286
9443
|
fileUploadSessionStorage = new InMemoryFileUploadSessions2;
|
|
8287
9444
|
fileDownloadGrantStorage = new InMemoryFileDownloadGrantStorage;
|
|
8288
9445
|
connectorConnectionStorage;
|
|
9446
|
+
activityStorage = new InMemoryActivityStorage;
|
|
8289
9447
|
auth;
|
|
8290
9448
|
executions;
|
|
8291
9449
|
agents;
|
|
9450
|
+
artifacts;
|
|
8292
9451
|
aiUsage;
|
|
8293
9452
|
aiCosts;
|
|
8294
9453
|
aiLimits;
|
|
@@ -8305,6 +9464,7 @@ class InMemoryStorage2 {
|
|
|
8305
9464
|
fileUploadSessions;
|
|
8306
9465
|
fileDownloadGrants;
|
|
8307
9466
|
connectorConnections;
|
|
9467
|
+
activity;
|
|
8308
9468
|
constructor(options = {}) {
|
|
8309
9469
|
this.connectorConnectionStorage = new InMemoryConnectorConnectionStorage2(options.connectorConnections);
|
|
8310
9470
|
const scope = createStorageOperationScope2((run) => this.withStorageOperation(run), () => this.assertRootOperationAvailable());
|
|
@@ -8313,6 +9473,7 @@ class InMemoryStorage2 {
|
|
|
8313
9473
|
this.auth = createAuthOperationScope2(this.authStorage, scope);
|
|
8314
9474
|
this.executions = createOperationScopedFacade2(this.executionStorage, scope);
|
|
8315
9475
|
this.agents = createAgentOperationScope2(this.agentStorage, scope);
|
|
9476
|
+
this.artifacts = createOperationScopedFacade2(this.artifactStorage, scope);
|
|
8316
9477
|
this.aiUsage = createOperationScopedFacade2(this.aiUsageStorage, scope);
|
|
8317
9478
|
this.aiCosts = createOperationScopedFacade2(this.aiCostStorage, scope);
|
|
8318
9479
|
this.aiLimits = createOperationScopedFacade2(this.aiLimitStorage, scope);
|
|
@@ -8329,6 +9490,7 @@ class InMemoryStorage2 {
|
|
|
8329
9490
|
this.fileUploadSessions = createOperationScopedFacade2(this.fileUploadSessionStorage, scope);
|
|
8330
9491
|
this.fileDownloadGrants = createOperationScopedFacade2(this.fileDownloadGrantStorage, scope);
|
|
8331
9492
|
this.connectorConnections = createOperationScopedFacade2(this.connectorConnectionStorage, scope);
|
|
9493
|
+
this.activity = createOperationScopedFacade2(this.activityStorage, scope);
|
|
8332
9494
|
this.ontologyStorage = new InMemoryOntologyStorage(this.objectStorage, this.timeseriesStorage, {
|
|
8333
9495
|
runRootOperation: async (run) => run(),
|
|
8334
9496
|
getTransactionToken: () => this.getActiveTransactionToken(),
|
|
@@ -8474,6 +9636,7 @@ class InMemoryStorage2 {
|
|
|
8474
9636
|
auth: this.authStorage,
|
|
8475
9637
|
executions: this.executionStorage,
|
|
8476
9638
|
agents: this.agentStorage,
|
|
9639
|
+
artifacts: this.artifactStorage,
|
|
8477
9640
|
aiUsage: this.aiUsageStorage,
|
|
8478
9641
|
aiCosts: this.aiCostStorage,
|
|
8479
9642
|
aiLimits: this.aiLimitStorage,
|
|
@@ -8490,6 +9653,7 @@ class InMemoryStorage2 {
|
|
|
8490
9653
|
fileUploadSessions: this.fileUploadSessionStorage,
|
|
8491
9654
|
fileDownloadGrants: this.fileDownloadGrantStorage,
|
|
8492
9655
|
connectorConnections: this.connectorConnectionStorage,
|
|
9656
|
+
activity: this.activityStorage,
|
|
8493
9657
|
ping: async () => {
|
|
8494
9658
|
return;
|
|
8495
9659
|
},
|
|
@@ -8506,6 +9670,7 @@ class InMemoryStorage2 {
|
|
|
8506
9670
|
auth: this.authStorage.snapshot(),
|
|
8507
9671
|
executions: this.executionStorage.snapshot(),
|
|
8508
9672
|
agents: this.agentStorage.snapshot(),
|
|
9673
|
+
artifacts: this.artifactStorage.snapshot(),
|
|
8509
9674
|
aiUsage: this.aiUsageStorage.snapshot(),
|
|
8510
9675
|
aiCosts: this.aiCostStorage.snapshot(),
|
|
8511
9676
|
aiLimits: this.aiLimitStorage.snapshot(),
|
|
@@ -8521,7 +9686,8 @@ class InMemoryStorage2 {
|
|
|
8521
9686
|
shareSessions: this.shareSessionStorage.snapshot(),
|
|
8522
9687
|
fileUploadSessions: this.fileUploadSessionStorage.snapshot(),
|
|
8523
9688
|
fileDownloadGrants: this.fileDownloadGrantStorage.snapshot(),
|
|
8524
|
-
connectorConnections: this.connectorConnectionStorage.snapshot()
|
|
9689
|
+
connectorConnections: this.connectorConnectionStorage.snapshot(),
|
|
9690
|
+
activity: this.activityStorage.snapshot()
|
|
8525
9691
|
};
|
|
8526
9692
|
}
|
|
8527
9693
|
restore(snapshot) {
|
|
@@ -8531,6 +9697,7 @@ class InMemoryStorage2 {
|
|
|
8531
9697
|
this.authStorage.restore(snapshot.auth);
|
|
8532
9698
|
this.executionStorage.restore(snapshot.executions);
|
|
8533
9699
|
this.agentStorage.restore(snapshot.agents);
|
|
9700
|
+
this.artifactStorage.restore(snapshot.artifacts);
|
|
8534
9701
|
this.aiUsageStorage.restore(snapshot.aiUsage);
|
|
8535
9702
|
this.aiCostStorage.restore(snapshot.aiCosts);
|
|
8536
9703
|
this.aiLimitStorage.restore(snapshot.aiLimits);
|
|
@@ -8547,6 +9714,7 @@ class InMemoryStorage2 {
|
|
|
8547
9714
|
this.fileUploadSessionStorage.restore(snapshot.fileUploadSessions);
|
|
8548
9715
|
this.fileDownloadGrantStorage.restore(snapshot.fileDownloadGrants);
|
|
8549
9716
|
this.connectorConnectionStorage.restore(snapshot.connectorConnections);
|
|
9717
|
+
this.activityStorage.restore(snapshot.activity);
|
|
8550
9718
|
}
|
|
8551
9719
|
}
|
|
8552
9720
|
// src/storage/objects/query-preparation.ts
|
|
@@ -8576,6 +9744,96 @@ async function prepareObjectQueries2(input) {
|
|
|
8576
9744
|
return input.storage.prepareObjectQueries({ projectId: input.projectId, objectTypes });
|
|
8577
9745
|
}
|
|
8578
9746
|
|
|
9747
|
+
// src/storage/migrations/prepare-unique-properties.ts
|
|
9748
|
+
var BACKFILL_PAGE_ROWS = 1000;
|
|
9749
|
+
var MAX_PREPARATION_ATTEMPTS = 5;
|
|
9750
|
+
var FIRST_RETRY_DELAY_MS = 50;
|
|
9751
|
+
async function prepareUniqueProperties(input) {
|
|
9752
|
+
const { storage, projectId } = input;
|
|
9753
|
+
const declared = declaredUniqueProperties(input.ontology);
|
|
9754
|
+
const declaredKeys = new Set(declared.map(propertyKey));
|
|
9755
|
+
for (const property of declared) {
|
|
9756
|
+
await withRetries(property, () => storage.transaction((tx) => backfillProperty(tx, projectId, property), {
|
|
9757
|
+
isolation: "serializable"
|
|
9758
|
+
}));
|
|
9759
|
+
}
|
|
9760
|
+
const undeclared = (await storage.ontology.uniqueValues.listPrepared({ projectId })).filter((property) => !declaredKeys.has(propertyKey(property)));
|
|
9761
|
+
for (const { objectTypeId, propertyId } of undeclared) {
|
|
9762
|
+
await withRetries({ objectTypeId, propertyId }, () => storage.transaction(async (tx) => {
|
|
9763
|
+
await tx.ontology.uniqueValues.lockPreparation({ projectId });
|
|
9764
|
+
await tx.ontology.uniqueValues.clear({ projectId, objectTypeId, propertyId });
|
|
9765
|
+
}, { isolation: "serializable" }));
|
|
9766
|
+
}
|
|
9767
|
+
}
|
|
9768
|
+
function declaredUniqueProperties(ontology) {
|
|
9769
|
+
const valueTypesById = ontology.getValueTypesById();
|
|
9770
|
+
return ontology.listObjectTypes().flatMap((objectType) => uniquePropertiesOf(objectType, valueTypesById).map((property) => ({
|
|
9771
|
+
objectTypeId: objectType.id,
|
|
9772
|
+
...property
|
|
9773
|
+
})));
|
|
9774
|
+
}
|
|
9775
|
+
async function withRetries(property, run) {
|
|
9776
|
+
for (let attempt = 1;; attempt += 1) {
|
|
9777
|
+
try {
|
|
9778
|
+
return await run();
|
|
9779
|
+
} catch (error) {
|
|
9780
|
+
if (!isStorageSerializationFailure2(error) || attempt >= MAX_PREPARATION_ATTEMPTS) {
|
|
9781
|
+
throw preparationError(property, error);
|
|
9782
|
+
}
|
|
9783
|
+
await new Promise((resolve) => setTimeout(resolve, FIRST_RETRY_DELAY_MS * 2 ** (attempt - 1)));
|
|
9784
|
+
}
|
|
9785
|
+
}
|
|
9786
|
+
}
|
|
9787
|
+
async function backfillProperty(tx, projectId, property) {
|
|
9788
|
+
const { objectTypeId, propertyId } = property;
|
|
9789
|
+
const values = tx.ontology.uniqueValues;
|
|
9790
|
+
await values.lockPreparation({ projectId });
|
|
9791
|
+
const current = (await values.listPrepared({ projectId })).find((prepared) => propertyKey(prepared) === propertyKey(property));
|
|
9792
|
+
if (current && isCurrent(current, property))
|
|
9793
|
+
return;
|
|
9794
|
+
await values.clear({ projectId, objectTypeId, propertyId });
|
|
9795
|
+
let afterPrimaryId;
|
|
9796
|
+
do {
|
|
9797
|
+
const page = await tx.objects.listByPrimaryIdPage({
|
|
9798
|
+
projectId,
|
|
9799
|
+
objectTypeId,
|
|
9800
|
+
limit: BACKFILL_PAGE_ROWS,
|
|
9801
|
+
...afterPrimaryId === undefined ? {} : { afterPrimaryId }
|
|
9802
|
+
});
|
|
9803
|
+
if (afterPrimaryId === undefined && page.objects.length > 0) {
|
|
9804
|
+
console.info(`[Sixb] Preparing unique property '${objectTypeId}.${propertyId}'.`);
|
|
9805
|
+
}
|
|
9806
|
+
const entries = [];
|
|
9807
|
+
for (const object of page.objects) {
|
|
9808
|
+
const valueKey = uniqueValueKey(property.kind, object.properties[propertyId]);
|
|
9809
|
+
if (valueKey !== null)
|
|
9810
|
+
entries.push({ valueKey, primaryId: object.primaryId });
|
|
9811
|
+
}
|
|
9812
|
+
if (entries.length > 0)
|
|
9813
|
+
await values.insert({ projectId, objectTypeId, propertyId, entries });
|
|
9814
|
+
afterPrimaryId = page.nextPrimaryId;
|
|
9815
|
+
} while (afterPrimaryId !== undefined);
|
|
9816
|
+
await values.markPrepared({
|
|
9817
|
+
projectId,
|
|
9818
|
+
objectTypeId,
|
|
9819
|
+
propertyId,
|
|
9820
|
+
keyKind: property.kind,
|
|
9821
|
+
keyVersion: UNIQUE_VALUE_KEY_VERSION,
|
|
9822
|
+
preparedAt: new Date().toISOString()
|
|
9823
|
+
});
|
|
9824
|
+
}
|
|
9825
|
+
function isCurrent(prepared, property) {
|
|
9826
|
+
return prepared.keyKind === property.kind && prepared.keyVersion === UNIQUE_VALUE_KEY_VERSION;
|
|
9827
|
+
}
|
|
9828
|
+
function preparationError(property, error) {
|
|
9829
|
+
if (!(error instanceof UniqueValueViolationError2))
|
|
9830
|
+
return error;
|
|
9831
|
+
return new Error(`[Sixb] Cannot make '${property.objectTypeId}.${property.propertyId}' unique: objects ` + `'${error.holderPrimaryId}' and '${error.claimantPrimaryId}' share a value. ` + "Fix the data, then start again.", { cause: error });
|
|
9832
|
+
}
|
|
9833
|
+
function propertyKey(property) {
|
|
9834
|
+
return JSON.stringify([property.objectTypeId, property.propertyId]);
|
|
9835
|
+
}
|
|
9836
|
+
|
|
8579
9837
|
// src/storage/migrations/migrate-storage.ts
|
|
8580
9838
|
function isMigrationCapableStorage2(storage) {
|
|
8581
9839
|
return Array.isArray(storage.migrators);
|
|
@@ -8594,6 +9852,8 @@ async function migrateStorage2(storage, options) {
|
|
|
8594
9852
|
console.warn(`[Sixb] ${warning}`);
|
|
8595
9853
|
}
|
|
8596
9854
|
}
|
|
9855
|
+
if (options)
|
|
9856
|
+
await prepareUniqueProperties({ ...options, storage });
|
|
8597
9857
|
let status = "skipped";
|
|
8598
9858
|
if (reports.length > 0 || queries) {
|
|
8599
9859
|
status = "current";
|
|
@@ -8804,6 +10064,6 @@ var VECTOR_INDEXING_FAILURE_CODES2 = [
|
|
|
8804
10064
|
"vector.outcome_unknown",
|
|
8805
10065
|
"internal.unexpected"
|
|
8806
10066
|
];
|
|
8807
|
-
export {
|
|
10067
|
+
export { InMemoryActionRunStorage2, AGENT_MESSAGE_CONTENT_VERSION2, InMemoryAgentStorage2, AiCostStorageError2, InMemoryAiCostStorage2, InMemoryAiLimitStorage2, InMemoryConnectorConnectionStorage2, InMemoryFileUploadSessions2, objectBatchKey2, linkBatchKey2, objectLinkCursor2, compareQueryScalarValues, matchesPredicate, PIPELINE_RUN_FAILURE_CODES2, InMemoryPipelineRunStorage2, InMemoryProjectionRunStorage2, InMemoryRulesStorage2, InMemoryShareGrantStorage2, InMemoryShareSessionStorage2, SYNC_RUN_FAILURE_CODES2, InMemorySyncRunStorage2, WEBHOOK_RUN_FAILURE_CODES2, canRetryWebhookRun2, InMemoryWebhookRunStorage2, WorkflowInterventionError2, InMemoryWorkflowInterventionStorage2, WORKFLOW_RUN_FAILURE_CODES2, InMemoryWorkflowRunStorage2, InMemoryWorkflowNodeRunStorage2, InMemoryWorkflowAgentNodeRunStorage2, InMemoryStorage2, prepareObjectQueries2, isMigrationCapableStorage2, migrateStorage2, checkStorageSchema2, step2, defineMigrations2, runMigrationSet2, describeMigrationHistory2, VECTOR_INDEXING_FAILURE_CODES2 };
|
|
8808
10068
|
|
|
8809
|
-
//# debugId=
|
|
10069
|
+
//# debugId=80206110A1AC9B8564756E2164756E21
|