@sixb/core 0.1.21 → 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 +63 -59
- 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 +14 -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/timeline.d.ts +8 -1
- package/dist/activity/timeline.d.ts.map +1 -1
- 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 +19 -8
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +159 -86
- 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/streams/index.d.ts +3 -2
- package/dist/agents/streams/index.d.ts.map +1 -1
- package/dist/agents/streams/index.js +7 -3
- 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 +5 -3
- 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 +23 -4
- 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/canvas.d.ts +92 -0
- package/dist/artifacts/canvas.d.ts.map +1 -0
- package/dist/artifacts/csv.d.ts +5 -0
- package/dist/artifacts/csv.d.ts.map +1 -1
- package/dist/artifacts/errors.d.ts +7 -2
- package/dist/artifacts/errors.d.ts.map +1 -1
- package/dist/artifacts/execution.d.ts +102 -7
- package/dist/artifacts/execution.d.ts.map +1 -1
- 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 +11 -9
- package/dist/artifacts/frames/assets.d.ts.map +1 -1
- 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 +6 -6
- package/dist/artifacts/frames/grants.d.ts.map +1 -1
- package/dist/artifacts/frames/index.d.ts +4 -2
- package/dist/artifacts/frames/index.d.ts.map +1 -1
- package/dist/artifacts/frames/index.js +444 -51
- package/dist/artifacts/frames/index.js.map +10 -8
- package/dist/artifacts/frames/kit.d.ts +10 -5
- package/dist/artifacts/frames/kit.d.ts.map +1 -1
- package/dist/artifacts/frames/probe.d.ts +16 -12
- package/dist/artifacts/frames/probe.d.ts.map +1 -1
- package/dist/artifacts/frames/protocol.d.ts +79 -10
- package/dist/artifacts/frames/protocol.d.ts.map +1 -1
- package/dist/artifacts/frames/runtime.d.ts +27 -9
- package/dist/artifacts/frames/runtime.d.ts.map +1 -1
- package/dist/artifacts/index.d.ts +11 -5
- package/dist/artifacts/index.d.ts.map +1 -1
- package/dist/artifacts/index.js +128 -6
- package/dist/artifacts/index.js.map +3 -3
- package/dist/artifacts/kinds.d.ts +1 -1
- package/dist/artifacts/kinds.d.ts.map +1 -1
- package/dist/artifacts/limits.d.ts +30 -0
- package/dist/artifacts/limits.d.ts.map +1 -1
- 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 +27 -1
- package/dist/artifacts/outline.d.ts.map +1 -1
- package/dist/artifacts/publish/index.d.ts +2 -0
- package/dist/artifacts/publish/index.d.ts.map +1 -1
- package/dist/artifacts/publish/index.js +59 -19
- package/dist/artifacts/publish/index.js.map +1 -1
- package/dist/artifacts/publish/publish.d.ts +43 -11
- package/dist/artifacts/publish/publish.d.ts.map +1 -1
- 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 +6 -3
- package/dist/artifacts/publish/references.d.ts.map +1 -1
- 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/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 +11 -3
- package/dist/artifacts/publish/validate/sheet.d.ts.map +1 -1
- package/dist/artifacts/publish/validate/slides.d.ts +1 -7
- package/dist/artifacts/publish/validate/slides.d.ts.map +1 -1
- package/dist/artifacts/queries.d.ts +95 -0
- package/dist/artifacts/queries.d.ts.map +1 -0
- package/dist/artifacts/resolve.d.ts +6 -0
- package/dist/artifacts/resolve.d.ts.map +1 -1
- 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/tones.d.ts +8 -0
- package/dist/artifacts/tones.d.ts.map +1 -0
- package/dist/artifacts/workbook.d.ts +76 -5
- package/dist/artifacts/workbook.d.ts.map +1 -1
- package/dist/auth/index.d.ts +1 -1
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +14 -11
- 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 +15 -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 +12 -7
- 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/bootstrap/index.js +69 -65
- package/dist/bootstrap/index.js.map +2 -2
- package/dist/{chunk-ky3j490c.js → chunk-02bzjgnt.js} +6 -6
- package/dist/{chunk-ky3j490c.js.map → chunk-02bzjgnt.js.map} +1 -1
- package/dist/{chunk-mfs23znk.js → chunk-07kkp2e1.js} +1 -1
- package/dist/{chunk-c1rxbz5y.js → chunk-098anw4f.js} +21 -19
- package/dist/chunk-098anw4f.js.map +12 -0
- package/dist/{chunk-z58tm0hm.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-18sk89cg.js +47 -0
- package/dist/chunk-18sk89cg.js.map +10 -0
- package/dist/{chunk-e17zdm62.js → chunk-1t6k1avb.js} +1 -1
- 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-kge7k6ey.js → chunk-2fn60nvs.js} +2 -2
- 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-mjddfa7k.js → chunk-3fqxbn31.js} +2 -24
- package/dist/{chunk-mjddfa7k.js.map → chunk-3fqxbn31.js.map} +3 -4
- package/dist/{chunk-y0c4e6ex.js → chunk-3gbefjg5.js} +1 -1
- package/dist/{chunk-5hx48dnn.js → chunk-45ngkxkp.js} +52 -31
- package/dist/chunk-45ngkxkp.js.map +13 -0
- package/dist/{chunk-cy4mbddw.js → chunk-48jezz3j.js} +1 -1
- package/dist/{chunk-561r0yc9.js → chunk-4b26qwbg.js} +13 -13
- package/dist/{chunk-561r0yc9.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-8frc8a4j.js → chunk-65pyhyas.js} +90 -83
- package/dist/chunk-65pyhyas.js.map +20 -0
- package/dist/{chunk-hwksyjks.js → chunk-661ezhks.js} +182 -6
- package/dist/chunk-661ezhks.js.map +11 -0
- package/dist/{chunk-447a5c0p.js → chunk-6n69k945.js} +2 -2
- package/dist/{chunk-0bphap9y.js → chunk-6p0pastb.js} +5 -5
- package/dist/{chunk-9j4jw7as.js → chunk-6rrtzea3.js} +18 -5
- package/dist/chunk-6rrtzea3.js.map +14 -0
- package/dist/{chunk-431pyp2c.js → chunk-6y0mkhex.js} +2 -2
- package/dist/{chunk-f4pamkt9.js → chunk-73v685wb.js} +10 -10
- package/dist/{chunk-f4pamkt9.js.map → chunk-73v685wb.js.map} +3 -3
- package/dist/{chunk-akzryx9h.js → chunk-7gr4j2eq.js} +7836 -5047
- package/dist/chunk-7gr4j2eq.js.map +120 -0
- package/dist/{chunk-bk9svbcq.js → chunk-7mc2wkre.js} +386 -86
- package/dist/chunk-7mc2wkre.js.map +50 -0
- package/dist/{chunk-6rqgmkde.js → chunk-7z5p905k.js} +335 -703
- package/dist/chunk-7z5p905k.js.map +22 -0
- 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-az47zep4.js +41 -0
- package/dist/chunk-az47zep4.js.map +10 -0
- package/dist/{chunk-s7jg7pmn.js → chunk-bab05bhg.js} +1 -1
- package/dist/{chunk-858emn8m.js → chunk-bktev1ds.js} +14 -11
- package/dist/{chunk-858emn8m.js.map → chunk-bktev1ds.js.map} +3 -3
- package/dist/{chunk-dhcv7yxc.js → chunk-c0vk1djt.js} +5 -3
- package/dist/chunk-c0vk1djt.js.map +11 -0
- package/dist/chunk-c69nj7se.js +3 -0
- package/dist/{chunk-7n30ybym.js.map → chunk-c69nj7se.js.map} +1 -1
- package/dist/{chunk-q5e5tv4b.js → chunk-c844dkwd.js} +1 -1
- package/dist/{chunk-g257jwnc.js → chunk-cdk3egjj.js} +17 -4
- 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-cfj9dfbb.js → chunk-d2m879s4.js} +2 -2
- package/dist/{chunk-arns890k.js → chunk-d7vyc7k6.js} +2 -2
- package/dist/chunk-d7vyc7k6.js.map +10 -0
- package/dist/{chunk-q7gn29y3.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-cn0fwwhy.js → chunk-efmm01gj.js} +108 -1045
- package/dist/chunk-efmm01gj.js.map +18 -0
- package/dist/{chunk-918wwnaa.js → chunk-ezne9wc9.js} +1224 -430
- package/dist/chunk-ezne9wc9.js.map +71 -0
- package/dist/{chunk-tbc1ngpd.js → chunk-fe8zwt8b.js} +58 -12
- package/dist/{chunk-tbc1ngpd.js.map → chunk-fe8zwt8b.js.map} +5 -4
- 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-1cc1xaf3.js → chunk-fp2kq35z.js} +26 -10
- package/dist/{chunk-1cc1xaf3.js.map → chunk-fp2kq35z.js.map} +5 -5
- package/dist/{chunk-vvxtn22d.js → chunk-g663fahq.js} +2 -2
- package/dist/{chunk-k43ct2ke.js → chunk-gvj5cd3b.js} +16 -9
- package/dist/chunk-gvj5cd3b.js.map +12 -0
- package/dist/{chunk-rmakanzx.js → chunk-h33shhq6.js} +5 -5
- package/dist/{chunk-nn5xnx3s.js → chunk-h3pbv7n8.js} +1738 -38
- package/dist/chunk-h3pbv7n8.js.map +48 -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-d09e3rax.js → chunk-hwarjrgf.js} +1 -1
- package/dist/{chunk-vf57cr4t.js → chunk-hyesv9dv.js} +1 -1
- 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-kcqpk9w1.js +75 -0
- package/dist/chunk-kcqpk9w1.js.map +10 -0
- package/dist/{chunk-5vems3nx.js → chunk-m2nevja0.js} +2 -2
- 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-d7dnxdep.js → chunk-n9zpx9c6.js} +4 -4
- package/dist/{chunk-xvsc5m8n.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-y5tah2kf.js → chunk-q4pmvkg0.js} +1 -1
- package/dist/chunk-qhqgp4jf.js +1418 -0
- package/dist/chunk-qhqgp4jf.js.map +22 -0
- package/dist/{chunk-48qjhh6v.js → chunk-qx00vjrj.js} +19 -60
- package/dist/chunk-qx00vjrj.js.map +13 -0
- package/dist/{chunk-5948n82c.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-d5rjr8c0.js → chunk-vabga7fk.js} +1 -1
- package/dist/{chunk-dhdha526.js → chunk-vhbw5sqm.js} +26 -2
- package/dist/chunk-vhbw5sqm.js.map +10 -0
- package/dist/{chunk-e6k4thh5.js → chunk-vpgwq5nf.js} +98 -12
- package/dist/chunk-vpgwq5nf.js.map +21 -0
- package/dist/{chunk-61y5xs4p.js → chunk-vyt322b6.js} +69 -50
- package/dist/{chunk-61y5xs4p.js.map → chunk-vyt322b6.js.map} +4 -4
- package/dist/chunk-waqk73p1.js +2380 -0
- package/dist/chunk-waqk73p1.js.map +23 -0
- package/dist/chunk-wsc1brye.js +27 -0
- package/dist/chunk-wsc1brye.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-6vb4st8k.js → chunk-yc9ners4.js} +120 -19
- package/dist/{chunk-6vb4st8k.js.map → chunk-yc9ners4.js.map} +8 -8
- package/dist/{chunk-dvd2fp9q.js → chunk-zbc929zg.js} +28 -4
- 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/write.js +5 -5
- package/dist/error-reporting/internal.js +3 -3
- package/dist/errors/catalog.d.ts +26 -0
- package/dist/errors/catalog.d.ts.map +1 -1
- package/dist/errors/internal.d.ts.map +1 -1
- package/dist/errors/internal.js +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.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 +8 -10
- 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 +63 -57
- 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 +51 -2
- 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-ontology.d.ts +2 -2
- package/dist/execution/object-reader-ontology.d.ts.map +1 -1
- package/dist/execution/object-reader-security.d.ts +24 -3
- package/dist/execution/object-reader-security.d.ts.map +1 -1
- 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 +61 -57
- 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 +64 -56
- 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 +32 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +137 -126
- package/dist/index.js.map +1 -1
- package/dist/lake-storage/index.js +5 -5
- 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 +45 -41
- 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 +44 -34
- 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/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 +68 -58
- package/dist/objects/index.js.map +1 -1
- package/dist/objects/link/authorization.d.ts +3 -0
- 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/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 +49 -44
- 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/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/index.d.ts +2 -2
- package/dist/ontology/index.d.ts.map +1 -1
- package/dist/ontology/index.js +11 -7
- package/dist/ontology/index.js.map +1 -1
- package/dist/ontology/internal.js +7 -5
- 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.js +43 -40
- package/dist/pipelines/index.js.map +1 -1
- package/dist/projections/internal.js +36 -33
- 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/host.d.ts.map +1 -1
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/internal.js +42 -38
- package/dist/runtime/internal.js.map +1 -1
- package/dist/runtime/resolve-definitions.d.ts.map +1 -1
- package/dist/runtime/sixb.d.ts +2 -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/index.js +7 -6
- package/dist/sandboxes/index.js.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/grants.d.ts +12 -4
- package/dist/security/grants.d.ts.map +1 -1
- package/dist/security/index.d.ts +1 -1
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/internal.js +1 -1
- package/dist/security/project.d.ts +4 -1
- package/dist/security/project.d.ts.map +1 -1
- package/dist/security/public.js +2 -2
- package/dist/security/registry.d.ts +6 -0
- package/dist/security/registry.d.ts.map +1 -1
- package/dist/security/types.d.ts +47 -9
- 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 +34 -31
- package/dist/shares/internal.js.map +2 -2
- package/dist/storage/action-runs/failure.js +2 -2
- package/dist/storage/action-runs/provider.js +1 -1
- package/dist/storage/action-runs/types.d.ts +1 -1
- package/dist/storage/action-runs/types.d.ts.map +1 -1
- 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 +120 -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 -5
- package/dist/storage/agents/provider.js.map +1 -1
- package/dist/storage/agents/types.d.ts +565 -13
- 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 +5 -4
- 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 +12 -2
- package/dist/storage/artifacts/errors.d.ts.map +1 -1
- package/dist/storage/artifacts/in-memory.d.ts +23 -2
- package/dist/storage/artifacts/in-memory.d.ts.map +1 -1
- package/dist/storage/artifacts/index.d.ts +2 -2
- package/dist/storage/artifacts/index.d.ts.map +1 -1
- package/dist/storage/artifacts/record.d.ts +19 -2
- package/dist/storage/artifacts/record.d.ts.map +1 -1
- package/dist/storage/artifacts/types.d.ts +87 -8
- package/dist/storage/artifacts/types.d.ts.map +1 -1
- 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/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 +40 -9
- package/dist/storage/auth/types.d.ts.map +1 -1
- package/dist/storage/connector-connections/provider.js +1 -1
- package/dist/storage/executions/in-memory.d.ts +2 -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/types.d.ts +15 -0
- package/dist/storage/executions/types.d.ts.map +1 -1
- package/dist/storage/file-upload-sessions/provider.js +15 -12
- package/dist/storage/file-upload-sessions/provider.js.map +1 -1
- package/dist/storage/index.d.ts +13 -11
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +50 -39
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/internal.d.ts +2 -2
- package/dist/storage/internal.d.ts.map +1 -1
- package/dist/storage/internal.js +19 -8
- 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/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 +4 -1
- 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/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 +2 -2
- package/dist/storage/share-grants/provider.js +4 -3
- package/dist/storage/share-grants/provider.js.map +1 -1
- package/dist/storage/types.d.ts +2 -2
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/storage/workflow-runs/provider.js +15 -12
- package/dist/storage/workflow-runs/provider.js.map +1 -1
- package/dist/syncs/index.js +42 -39
- package/dist/syncs/index.js.map +1 -1
- 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.map +1 -1
- 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 +9 -5
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +7938 -3743
- package/dist/testing/index.js.map +29 -25
- 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 +34 -31
- package/dist/webhooks/internal.js.map +2 -2
- package/dist/workers/index.js +4 -6
- 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 +67 -63
- 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 +6 -2
- package/dist/workflows/types.d.ts.map +1 -1
- package/dist/workflows/validation.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/actions/commit-edits.ts +6 -1
- package/src/actions/execution.ts +42 -15
- package/src/actions/read-facade.ts +33 -0
- package/src/actions/request.ts +224 -71
- 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 +72 -0
- package/src/actions/types/context.ts +20 -3
- package/src/actions/validators.ts +19 -8
- package/src/activity/README.md +5 -2
- package/src/activity/timeline.ts +39 -78
- 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 +55 -0
- 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 -69
- package/src/agents/run-scope.ts +134 -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 +35 -10
- package/src/agents/validation.ts +2 -0
- package/src/artifacts/access.ts +125 -0
- package/src/artifacts/canvas.ts +369 -0
- package/src/artifacts/csv.ts +10 -0
- package/src/artifacts/errors.ts +12 -1
- package/src/artifacts/execution.ts +436 -36
- 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 +35 -19
- package/src/artifacts/frames/entries.ts +35 -0
- package/src/artifacts/frames/grants.ts +10 -9
- package/src/artifacts/frames/index.ts +8 -2
- package/src/artifacts/frames/kit.ts +191 -14
- package/src/artifacts/frames/probe.ts +66 -18
- package/src/artifacts/frames/protocol.ts +164 -10
- package/src/artifacts/frames/runtime.ts +273 -28
- package/src/artifacts/index.ts +66 -2
- package/src/artifacts/kinds.ts +1 -1
- package/src/artifacts/limits.ts +31 -0
- package/src/artifacts/live-sheet.ts +345 -0
- package/src/artifacts/outline.ts +34 -1
- package/src/artifacts/publish/index.ts +2 -0
- package/src/artifacts/publish/publish.ts +120 -34
- package/src/artifacts/publish/queries.ts +336 -0
- package/src/artifacts/publish/references.ts +18 -13
- package/src/artifacts/publish/validate/canvas.ts +118 -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 +115 -69
- package/src/artifacts/publish/validate/slides.ts +11 -63
- package/src/artifacts/queries.ts +512 -0
- package/src/artifacts/resolve.ts +20 -5
- 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/tones.ts +20 -0
- package/src/artifacts/workbook.ts +374 -15
- 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 +47 -0
- package/src/authorization/event-visibility.ts +17 -16
- package/src/authorization/grant-kinds.ts +32 -0
- 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/errors/catalog.ts +26 -1
- package/src/errors/internal.ts +17 -8
- package/src/events/definitions.ts +26 -0
- package/src/events/execution.ts +43 -6
- 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 +238 -32
- package/src/execution/lineage.ts +14 -0
- package/src/execution/object-reader-ontology.ts +11 -14
- package/src/execution/object-reader-security.ts +134 -10
- 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 +206 -7
- package/src/index.ts +99 -2
- 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/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 +12 -3
- package/src/objects/link/endpoints.ts +42 -11
- package/src/objects/link/remove.ts +25 -10
- package/src/objects/link/upsert-batch.ts +2 -0
- package/src/objects/link/upsert.ts +18 -12
- package/src/objects/materializer-adapter.ts +55 -18
- package/src/objects/object/delete.ts +24 -7
- package/src/objects/object/upsert-batch.ts +44 -14
- package/src/objects/object/upsert.ts +23 -5
- 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/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 +3 -0
- package/src/ontology/docs-markdown.ts +1 -0
- 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/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/host.ts +18 -1
- package/src/runtime/index.ts +2 -0
- package/src/runtime/resolve-definitions.ts +3 -0
- package/src/runtime/sixb.ts +35 -8
- package/src/runtime/types.ts +99 -9
- 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/grants.ts +155 -10
- package/src/security/index.ts +3 -1
- package/src/security/project.ts +6 -1
- package/src/security/registry.ts +32 -7
- package/src/security/types.ts +54 -9
- package/src/security/validation.ts +27 -11
- package/src/security/view-conditions.ts +215 -0
- package/src/shares/execution.ts +43 -10
- package/src/storage/action-runs/types.ts +2 -0
- package/src/storage/agents/errors.ts +3 -0
- package/src/storage/agents/in-memory.ts +779 -32
- package/src/storage/agents/index.ts +42 -0
- package/src/storage/agents/provider.ts +733 -8
- package/src/storage/agents/types.ts +620 -12
- 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 +13 -1
- package/src/storage/artifacts/in-memory.ts +156 -8
- package/src/storage/artifacts/index.ts +6 -1
- package/src/storage/artifacts/record.ts +61 -1
- package/src/storage/artifacts/types.ts +92 -8
- package/src/storage/auth/in-memory/auth-storage.ts +27 -2
- package/src/storage/auth/in-memory/users.ts +40 -6
- package/src/storage/auth/index.ts +1 -0
- package/src/storage/auth/types.ts +43 -7
- package/src/storage/executions/in-memory.ts +32 -0
- package/src/storage/executions/index.ts +2 -0
- package/src/storage/executions/types.ts +17 -0
- package/src/storage/index.ts +69 -1
- package/src/storage/internal.ts +9 -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/unique-values.ts +62 -0
- package/src/storage/ontology/index.ts +10 -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/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/types.ts +2 -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 +1188 -33
- 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 +338 -4
- package/src/testing/auth-storage-contract.ts +550 -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 +53 -0
- package/src/testing/file-upload-session-storage-contract.ts +12 -24
- package/src/testing/index.ts +17 -4
- package/src/testing/lake-storage-contract.ts +22 -28
- package/src/testing/materializer-storage-contract.ts +36 -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 +230 -21
- 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 +13 -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 +6 -0
- package/src/workflows/request.ts +46 -8
- package/src/workflows/types.ts +6 -2
- package/src/workflows/validation.ts +23 -9
- package/dist/chunk-29yx306f.js.map +0 -22
- package/dist/chunk-3jms7je7.js +0 -14
- package/dist/chunk-3jms7je7.js.map +0 -10
- package/dist/chunk-3qct2mdc.js +0 -297
- package/dist/chunk-3qct2mdc.js.map +0 -12
- package/dist/chunk-48qjhh6v.js.map +0 -13
- package/dist/chunk-4as3wt1c.js.map +0 -12
- package/dist/chunk-5948n82c.js.map +0 -10
- package/dist/chunk-5hx48dnn.js.map +0 -14
- package/dist/chunk-6rqgmkde.js.map +0 -29
- 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-7q8t23v4.js +0 -467
- package/dist/chunk-7q8t23v4.js.map +0 -14
- package/dist/chunk-8frc8a4j.js.map +0 -20
- package/dist/chunk-918wwnaa.js.map +0 -68
- package/dist/chunk-91mg3nj9.js.map +0 -12
- package/dist/chunk-96yw3pwd.js.map +0 -10
- package/dist/chunk-9j4jw7as.js.map +0 -14
- package/dist/chunk-9k93ah50.js.map +0 -11
- package/dist/chunk-9kgkfg6v.js +0 -502
- package/dist/chunk-9kgkfg6v.js.map +0 -14
- package/dist/chunk-akzryx9h.js.map +0 -100
- package/dist/chunk-arns890k.js.map +0 -10
- package/dist/chunk-bk9svbcq.js.map +0 -49
- package/dist/chunk-c06hmxyy.js +0 -31
- package/dist/chunk-c06hmxyy.js.map +0 -10
- package/dist/chunk-c1rxbz5y.js.map +0 -12
- package/dist/chunk-cn0fwwhy.js.map +0 -19
- package/dist/chunk-dhcv7yxc.js.map +0 -11
- package/dist/chunk-dhdha526.js.map +0 -10
- package/dist/chunk-dvd2fp9q.js.map +0 -13
- package/dist/chunk-e6k4thh5.js.map +0 -19
- package/dist/chunk-ere85b8y.js.map +0 -15
- package/dist/chunk-g257jwnc.js.map +0 -12
- package/dist/chunk-hwksyjks.js.map +0 -11
- package/dist/chunk-k43ct2ke.js.map +0 -12
- package/dist/chunk-nn5xnx3s.js.map +0 -40
- 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-v4jbb3rs.js.map +0 -10
- package/dist/chunk-yxd3nnqt.js.map +0 -11
- 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-z58tm0hm.js.map → chunk-0phpbbvm.js.map} +0 -0
- /package/dist/{chunk-e17zdm62.js.map → chunk-1t6k1avb.js.map} +0 -0
- /package/dist/{chunk-kge7k6ey.js.map → chunk-2fn60nvs.js.map} +0 -0
- /package/dist/{chunk-y0c4e6ex.js.map → chunk-3gbefjg5.js.map} +0 -0
- /package/dist/{chunk-cy4mbddw.js.map → chunk-48jezz3j.js.map} +0 -0
- /package/dist/{chunk-twe4dx8p.js → chunk-5tfev0fv.js} +0 -0
- /package/dist/{chunk-twe4dx8p.js.map → chunk-5tfev0fv.js.map} +0 -0
- /package/dist/{chunk-447a5c0p.js.map → chunk-6n69k945.js.map} +0 -0
- /package/dist/{chunk-0bphap9y.js.map → chunk-6p0pastb.js.map} +0 -0
- /package/dist/{chunk-431pyp2c.js.map → chunk-6y0mkhex.js.map} +0 -0
- /package/dist/{chunk-s7jg7pmn.js.map → chunk-bab05bhg.js.map} +0 -0
- /package/dist/{chunk-q5e5tv4b.js.map → chunk-c844dkwd.js.map} +0 -0
- /package/dist/{chunk-cfj9dfbb.js.map → chunk-d2m879s4.js.map} +0 -0
- /package/dist/{chunk-q7gn29y3.js.map → chunk-dp0cdtj2.js.map} +0 -0
- /package/dist/{chunk-br3k6qbf.js.map → chunk-fm62y49k.js.map} +0 -0
- /package/dist/{chunk-vvxtn22d.js.map → chunk-g663fahq.js.map} +0 -0
- /package/dist/{chunk-rmakanzx.js.map → chunk-h33shhq6.js.map} +0 -0
- /package/dist/{chunk-d09e3rax.js.map → chunk-hwarjrgf.js.map} +0 -0
- /package/dist/{chunk-vf57cr4t.js.map → chunk-hyesv9dv.js.map} +0 -0
- /package/dist/{chunk-5vems3nx.js.map → chunk-m2nevja0.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-d7dnxdep.js.map → chunk-n9zpx9c6.js.map} +0 -0
- /package/dist/{chunk-xvsc5m8n.js.map → chunk-npcr0228.js.map} +0 -0
- /package/dist/{chunk-y5tah2kf.js.map → chunk-q4pmvkg0.js.map} +0 -0
- /package/dist/{chunk-d5rjr8c0.js.map → chunk-vabga7fk.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,31 +108,34 @@ 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";
|
|
86
119
|
import {
|
|
87
120
|
actionSubjectsEqual,
|
|
88
121
|
normalizeRecordActionRunInput2,
|
|
89
122
|
resolveActionRunEffects2,
|
|
90
123
|
StorageTransactionError2,
|
|
124
|
+
isStorageSerializationFailure2,
|
|
91
125
|
ACTIVITY_MAX_VISIT_MS2,
|
|
92
126
|
validateActivityAppend2,
|
|
93
127
|
planActivityAppend2,
|
|
94
128
|
activityCalendarDays2,
|
|
95
129
|
activityDay,
|
|
130
|
+
artifactStateBytes2,
|
|
131
|
+
checkArtifactStateWrite2,
|
|
96
132
|
artifactStorageErrors2,
|
|
97
133
|
cloneFileDownloadGrantRecord,
|
|
98
134
|
canRequeuePipelineRunAfterEnqueueFailure2,
|
|
99
135
|
canRequeueSyncRunAfterEnqueueFailure2,
|
|
100
136
|
createTransactionStorageProxy2,
|
|
101
137
|
throwNestedStorageTransaction2
|
|
102
|
-
} from "./chunk-
|
|
138
|
+
} from "./chunk-fe8zwt8b.js";
|
|
103
139
|
import {
|
|
104
140
|
ExecutionStorageError2,
|
|
105
141
|
prepareExecutionRecord2,
|
|
@@ -107,8 +143,6 @@ import {
|
|
|
107
143
|
compareExecutionCreation2
|
|
108
144
|
} from "./chunk-eptrvnby.js";
|
|
109
145
|
import {
|
|
110
|
-
sha256Canonical2,
|
|
111
|
-
createEventId2,
|
|
112
146
|
objectRefKey2,
|
|
113
147
|
linkRefKey2,
|
|
114
148
|
projectionEntityKey2,
|
|
@@ -118,7 +152,7 @@ import {
|
|
|
118
152
|
linkScopeKey,
|
|
119
153
|
linkScopeSortKey2,
|
|
120
154
|
telemetryPointSortKey2
|
|
121
|
-
} from "./chunk-
|
|
155
|
+
} from "./chunk-cswhawa2.js";
|
|
122
156
|
import {
|
|
123
157
|
assertNonblank2,
|
|
124
158
|
assertPositiveInteger2,
|
|
@@ -134,6 +168,7 @@ import {
|
|
|
134
168
|
prepareReplacementIdentities2,
|
|
135
169
|
projectionChangeCounts,
|
|
136
170
|
createCardinalityValidator2,
|
|
171
|
+
uniqueValueViolation2,
|
|
137
172
|
workUniquenessKey2,
|
|
138
173
|
comparePlanWork2,
|
|
139
174
|
compareCardinalityWork2,
|
|
@@ -160,7 +195,7 @@ import {
|
|
|
160
195
|
assertSourceStagedRow2,
|
|
161
196
|
isExactStagingManifest2,
|
|
162
197
|
sourceConflict2
|
|
163
|
-
} from "./chunk-
|
|
198
|
+
} from "./chunk-hqsp2sx4.js";
|
|
164
199
|
import {
|
|
165
200
|
createStorageOperationScope2,
|
|
166
201
|
createOperationScopedFacade2,
|
|
@@ -169,7 +204,7 @@ import {
|
|
|
169
204
|
createOntologyOperationScope2,
|
|
170
205
|
createObjectOperationScope2,
|
|
171
206
|
createWorkflowRunOperationScope2
|
|
172
|
-
} from "./chunk-
|
|
207
|
+
} from "./chunk-2adz0h75.js";
|
|
173
208
|
import {
|
|
174
209
|
PipelineRunError2,
|
|
175
210
|
assertPipelineRunExecution2
|
|
@@ -204,7 +239,7 @@ import {
|
|
|
204
239
|
assertProjectionMissingTarget2,
|
|
205
240
|
requireTelemetryProjectionRun2,
|
|
206
241
|
assertProjectionRunDurableExecution2
|
|
207
|
-
} from "./chunk-
|
|
242
|
+
} from "./chunk-g663fahq.js";
|
|
208
243
|
import {
|
|
209
244
|
SyncRunError2,
|
|
210
245
|
assertSyncRunExecution2
|
|
@@ -217,7 +252,7 @@ import {
|
|
|
217
252
|
WorkflowRunError2,
|
|
218
253
|
assertWorkflowRunExecution2,
|
|
219
254
|
assertWorkflowAgentNodeRunExecution2
|
|
220
|
-
} from "./chunk-
|
|
255
|
+
} from "./chunk-6rrtzea3.js";
|
|
221
256
|
import {
|
|
222
257
|
ShareGrantStorageError2,
|
|
223
258
|
normalizeShareGrantCreate2,
|
|
@@ -226,7 +261,7 @@ import {
|
|
|
226
261
|
normalizeListShareGrantsInput2,
|
|
227
262
|
normalizeRevokeShareGrantInput2,
|
|
228
263
|
cloneShareGrantRecord2
|
|
229
|
-
} from "./chunk-
|
|
264
|
+
} from "./chunk-fm62y49k.js";
|
|
230
265
|
import {
|
|
231
266
|
ShareSessionStorageError2,
|
|
232
267
|
normalizeShareSessionCreate2,
|
|
@@ -242,20 +277,21 @@ import {
|
|
|
242
277
|
} from "./chunk-2c4j899j.js";
|
|
243
278
|
import {
|
|
244
279
|
ActionRunError2
|
|
245
|
-
} from "./chunk-
|
|
280
|
+
} from "./chunk-3gbefjg5.js";
|
|
246
281
|
import {
|
|
247
282
|
assertPinnedDatasetWatermark2
|
|
248
|
-
} from "./chunk-
|
|
283
|
+
} from "./chunk-n8q5j6y5.js";
|
|
249
284
|
import {
|
|
250
285
|
MaterializationValidationError2,
|
|
286
|
+
UniqueValueViolationError2,
|
|
251
287
|
MaterializationConflictError2
|
|
252
|
-
} from "./chunk-
|
|
253
|
-
import {
|
|
254
|
-
AGENT_RUN_FAILURE_CODES2
|
|
255
|
-
} from "./chunk-c06hmxyy.js";
|
|
288
|
+
} from "./chunk-y7dbmaqh.js";
|
|
256
289
|
import {
|
|
257
290
|
compareDecimalValues2
|
|
258
291
|
} from "./chunk-3bh94gbw.js";
|
|
292
|
+
import {
|
|
293
|
+
AGENT_RUN_FAILURE_CODES2
|
|
294
|
+
} from "./chunk-18sk89cg.js";
|
|
259
295
|
import {
|
|
260
296
|
cloneJsonValue2,
|
|
261
297
|
stableJsonStringify2
|
|
@@ -416,6 +452,7 @@ class InMemoryAgentThreadStore {
|
|
|
416
452
|
const record = {
|
|
417
453
|
id: input.id,
|
|
418
454
|
projectId: input.projectId,
|
|
455
|
+
kind: "conversation",
|
|
419
456
|
ownerPrincipal: clone(input.ownerPrincipal),
|
|
420
457
|
...sandboxParams === undefined ? {} : { sandboxParams },
|
|
421
458
|
...input.title === undefined ? {} : { title: input.title },
|
|
@@ -428,6 +465,41 @@ class InMemoryAgentThreadStore {
|
|
|
428
465
|
this.state.threads.set(threadKey, clone(record));
|
|
429
466
|
return clone(record);
|
|
430
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
|
+
}
|
|
431
503
|
async getById(params) {
|
|
432
504
|
const record = this.state.threads.get(key(params.projectId, params.id));
|
|
433
505
|
return record ? clone(record) : null;
|
|
@@ -438,13 +510,57 @@ class InMemoryAgentThreadStore {
|
|
|
438
510
|
return record ? [clone(record)] : [];
|
|
439
511
|
});
|
|
440
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
|
+
}
|
|
441
517
|
async list(input) {
|
|
442
518
|
const order = input.order ?? "desc";
|
|
443
519
|
const statuses = input.statuses ? new Set(input.statuses) : null;
|
|
444
|
-
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));
|
|
445
526
|
const { page, hasMore, total } = applyWindow(filtered, input.offset, input.limit);
|
|
446
527
|
return { threads: page.map(clone), hasMore, total };
|
|
447
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
|
+
}
|
|
448
564
|
}
|
|
449
565
|
|
|
450
566
|
class InMemoryAgentRunStore {
|
|
@@ -467,6 +583,7 @@ class InMemoryAgentRunStore {
|
|
|
467
583
|
if (!thread) {
|
|
468
584
|
throw new AgentStorageError2("thread_not_found", `[Sixb] Agent thread '${input.threadId}' not found for project '${input.projectId}'.`);
|
|
469
585
|
}
|
|
586
|
+
assertConversationThreadRow2(thread, "takes turns");
|
|
470
587
|
if (thread.activeRunId !== null) {
|
|
471
588
|
throw new AgentStorageError2("active_run_exists", `[Sixb] Agent thread '${input.threadId}' already has an active run '${thread.activeRunId}'.`);
|
|
472
589
|
}
|
|
@@ -534,18 +651,60 @@ class InMemoryAgentRunStore {
|
|
|
534
651
|
if ([...this.state.runs.values()].some((run) => run.projectId === input.projectId && run.executionId === input.executionId)) {
|
|
535
652
|
throw new AgentStorageError2("duplicate_id", `[Sixb] Execution '${input.executionId}' already belongs to another Agent run.`);
|
|
536
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
|
+
}
|
|
537
677
|
const run = {
|
|
538
678
|
kind: "subagent",
|
|
539
679
|
id: input.id,
|
|
540
680
|
projectId: input.projectId,
|
|
541
681
|
executionId: input.executionId,
|
|
682
|
+
threadId: input.thread.id,
|
|
683
|
+
triggerMessageId: input.trigger.id,
|
|
542
684
|
parentRunId: input.parentRunId,
|
|
543
685
|
spawnKey: input.spawnKey,
|
|
544
686
|
spec: clone(input.spec),
|
|
545
687
|
status: "queued",
|
|
546
688
|
attempt: 0,
|
|
547
|
-
createdAt
|
|
689
|
+
createdAt
|
|
548
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
|
|
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));
|
|
549
708
|
this.state.runs.set(runKey, clone(run));
|
|
550
709
|
return clone(run);
|
|
551
710
|
}
|
|
@@ -606,11 +765,13 @@ class InMemoryAgentRunStore {
|
|
|
606
765
|
if (!run.execution || run.execution.token !== input.executionToken) {
|
|
607
766
|
throw new AgentStorageError2("execution_lost", `[Sixb] Execution token is no longer current on agent run '${input.id}'.`);
|
|
608
767
|
}
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
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
|
+
});
|
|
614
775
|
}
|
|
615
776
|
const completedAt = new Date(input.completedAt ?? new Date);
|
|
616
777
|
const next = {
|
|
@@ -626,6 +787,7 @@ class InMemoryAgentRunStore {
|
|
|
626
787
|
};
|
|
627
788
|
this.state.runs.set(key(input.projectId, input.id), clone(next));
|
|
628
789
|
this.releaseThread(run, completedAt);
|
|
790
|
+
this.settleApprovals(run, input, completedAt);
|
|
629
791
|
return clone(next);
|
|
630
792
|
}
|
|
631
793
|
async getById(params) {
|
|
@@ -635,11 +797,20 @@ class InMemoryAgentRunStore {
|
|
|
635
797
|
async getByIds(params) {
|
|
636
798
|
return [...new Set(params.ids)].map((id) => this.state.runs.get(key(params.projectId, id))).filter((record) => record !== undefined).map(clone);
|
|
637
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
|
+
}
|
|
638
809
|
async list(input) {
|
|
639
810
|
const order = input.order ?? "desc";
|
|
640
811
|
const statuses = input.statuses ? new Set(input.statuses) : null;
|
|
641
812
|
const kinds = input.kinds ? new Set(input.kinds) : null;
|
|
642
|
-
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));
|
|
643
814
|
const { page, hasMore, total } = applyWindow(filtered, input.offset, input.limit);
|
|
644
815
|
return { runs: page.map(clone), hasMore, total };
|
|
645
816
|
}
|
|
@@ -656,9 +827,28 @@ class InMemoryAgentRunStore {
|
|
|
656
827
|
}
|
|
657
828
|
return run;
|
|
658
829
|
}
|
|
659
|
-
|
|
660
|
-
if (
|
|
830
|
+
settleApprovals(run, input, at) {
|
|
831
|
+
if (input.finishReason === "awaiting_approval" || !agentRunMayHoldCalls2(run))
|
|
661
832
|
return;
|
|
833
|
+
const turn = run.kind === "conversation";
|
|
834
|
+
if (!turn && input.status === "succeeded")
|
|
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) {
|
|
662
852
|
const threadKey = key(run.projectId, run.threadId);
|
|
663
853
|
const thread = this.state.threads.get(threadKey);
|
|
664
854
|
if (thread && thread.activeRunId === run.id) {
|
|
@@ -686,7 +876,7 @@ class InMemoryAgentMessageStore {
|
|
|
686
876
|
throw new AgentStorageError2("run_not_found", `[Sixb] Agent run '${input.runId}' not found for project '${input.projectId}'.`);
|
|
687
877
|
}
|
|
688
878
|
const createdAt = new Date(input.createdAt ?? new Date);
|
|
689
|
-
const seq = this.
|
|
879
|
+
const seq = nextMessageSeq(this.state, input.projectId, input.threadId);
|
|
690
880
|
const message = {
|
|
691
881
|
id: input.id,
|
|
692
882
|
projectId: input.projectId,
|
|
@@ -704,7 +894,7 @@ class InMemoryAgentMessageStore {
|
|
|
704
894
|
this.state.messages.set(messageKey, clone(message));
|
|
705
895
|
this.state.threads.set(threadKey, clone({
|
|
706
896
|
...thread,
|
|
707
|
-
messageCount: thread.messageCount + 1,
|
|
897
|
+
messageCount: thread.messageCount + (countsAsThreadMessage2(input) ? 1 : 0),
|
|
708
898
|
lastMessageAt: createdAt,
|
|
709
899
|
updatedAt: createdAt
|
|
710
900
|
}));
|
|
@@ -728,7 +918,7 @@ class InMemoryAgentMessageStore {
|
|
|
728
918
|
const updatedAt = new Date;
|
|
729
919
|
this.state.threads.set(threadKey, clone({
|
|
730
920
|
...thread,
|
|
731
|
-
messageCount: remainingMessages.length,
|
|
921
|
+
messageCount: remainingMessages.filter(countsAsThreadMessage2).length,
|
|
732
922
|
lastMessageAt: latestMessage?.createdAt,
|
|
733
923
|
updatedAt
|
|
734
924
|
}));
|
|
@@ -745,15 +935,15 @@ class InMemoryAgentMessageStore {
|
|
|
745
935
|
const { page, hasMore, total } = applyWindow(filtered, input.offset, input.limit);
|
|
746
936
|
return { messages: page.map(clone), hasMore, total };
|
|
747
937
|
}
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
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;
|
|
754
944
|
}
|
|
755
|
-
return max + 1;
|
|
756
945
|
}
|
|
946
|
+
return max + 1;
|
|
757
947
|
}
|
|
758
948
|
|
|
759
949
|
class InMemoryAgentContextCheckpointStore {
|
|
@@ -769,7 +959,7 @@ class InMemoryAgentContextCheckpointStore {
|
|
|
769
959
|
const messages = [...this.state.messages.values()].filter((message) => message.projectId === input.projectId && message.threadId === input.threadId);
|
|
770
960
|
const headSeq = messages.reduce((head, message) => Math.max(head, message.seq), 0);
|
|
771
961
|
const latest = this.findLatest(input.projectId, input.threadId);
|
|
772
|
-
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);
|
|
773
963
|
if (existingForRun) {
|
|
774
964
|
if (agentContextCheckpointMatchesCreateInput2(existingForRun, input)) {
|
|
775
965
|
assertAgentContextCheckpointReplayState2({
|
|
@@ -816,47 +1006,320 @@ class InMemoryAgentContextCheckpointStore {
|
|
|
816
1006
|
return record ? clone(record) : null;
|
|
817
1007
|
}
|
|
818
1008
|
async getByRunIds(input) {
|
|
819
|
-
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]));
|
|
820
1010
|
return [...new Set(input.runIds)].flatMap((runId) => {
|
|
821
1011
|
const checkpoint = byRunId.get(runId);
|
|
822
1012
|
return checkpoint ? [clone(checkpoint)] : [];
|
|
823
1013
|
});
|
|
824
1014
|
}
|
|
825
1015
|
findLatest(projectId, threadId) {
|
|
826
|
-
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);
|
|
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 };
|
|
827
1231
|
}
|
|
828
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]);
|
|
1273
|
+
}
|
|
829
1274
|
|
|
830
1275
|
class InMemoryAgentStorage2 {
|
|
831
1276
|
state = {
|
|
832
1277
|
threads: new Map,
|
|
1278
|
+
participants: new Map,
|
|
833
1279
|
runs: new Map,
|
|
834
1280
|
messages: new Map,
|
|
835
|
-
checkpoints: new Map
|
|
1281
|
+
checkpoints: new Map,
|
|
1282
|
+
memory: new Map,
|
|
1283
|
+
approvals: new Map,
|
|
1284
|
+
approvalModes: new Map
|
|
836
1285
|
};
|
|
837
1286
|
threads;
|
|
838
1287
|
runs;
|
|
839
1288
|
messages;
|
|
840
1289
|
checkpoints;
|
|
1290
|
+
memory;
|
|
1291
|
+
approvals;
|
|
1292
|
+
approvalModes;
|
|
841
1293
|
constructor(executions) {
|
|
842
1294
|
this.threads = new InMemoryAgentThreadStore(this.state);
|
|
843
1295
|
this.runs = new InMemoryAgentRunStore(this.state, executions);
|
|
844
1296
|
this.messages = new InMemoryAgentMessageStore(this.state);
|
|
845
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);
|
|
846
1301
|
}
|
|
847
1302
|
snapshot() {
|
|
848
1303
|
return {
|
|
849
1304
|
threads: structuredClone(this.state.threads),
|
|
1305
|
+
participants: structuredClone(this.state.participants),
|
|
850
1306
|
runs: structuredClone(this.state.runs),
|
|
851
1307
|
messages: structuredClone(this.state.messages),
|
|
852
|
-
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)
|
|
853
1312
|
};
|
|
854
1313
|
}
|
|
855
1314
|
restore(snapshot) {
|
|
856
1315
|
replace(this.state.threads, snapshot.threads);
|
|
1316
|
+
replace(this.state.participants, snapshot.participants);
|
|
857
1317
|
replace(this.state.runs, snapshot.runs);
|
|
858
1318
|
replace(this.state.messages, snapshot.messages);
|
|
859
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);
|
|
860
1323
|
}
|
|
861
1324
|
}
|
|
862
1325
|
function replace(target, source) {
|
|
@@ -2584,6 +3047,7 @@ function byLastSeenDescending(id) {
|
|
|
2584
3047
|
class InMemoryArtifactStorage {
|
|
2585
3048
|
artifacts = new Map;
|
|
2586
3049
|
frameGrants = new Map;
|
|
3050
|
+
state = new Map;
|
|
2587
3051
|
async create(input) {
|
|
2588
3052
|
const key = artifactKey(input.projectId, input.id);
|
|
2589
3053
|
if (this.artifacts.has(key))
|
|
@@ -2599,7 +3063,12 @@ class InMemoryArtifactStorage {
|
|
|
2599
3063
|
createdAt: new Date(version.createdAt),
|
|
2600
3064
|
updatedAt: new Date(version.createdAt)
|
|
2601
3065
|
};
|
|
2602
|
-
this.artifacts.set(key, {
|
|
3066
|
+
this.artifacts.set(key, {
|
|
3067
|
+
record,
|
|
3068
|
+
versions: [version],
|
|
3069
|
+
nextVersion: 2,
|
|
3070
|
+
threads: sharedIn(new Map, version)
|
|
3071
|
+
});
|
|
2603
3072
|
return published(record, version);
|
|
2604
3073
|
}
|
|
2605
3074
|
async publish(input) {
|
|
@@ -2610,6 +3079,13 @@ class InMemoryArtifactStorage {
|
|
|
2610
3079
|
if (stored.record.kind !== input.kind) {
|
|
2611
3080
|
throw artifactStorageErrors2.kindMismatch(input.artifactId, stored.record.kind, input.kind);
|
|
2612
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
|
+
}
|
|
2613
3089
|
const version = versionRecord(input.projectId, input.artifactId, stored.nextVersion, input.version);
|
|
2614
3090
|
const record = {
|
|
2615
3091
|
...stored.record,
|
|
@@ -2620,7 +3096,8 @@ class InMemoryArtifactStorage {
|
|
|
2620
3096
|
this.artifacts.set(key, {
|
|
2621
3097
|
record,
|
|
2622
3098
|
versions: [...stored.versions, version],
|
|
2623
|
-
nextVersion: stored.nextVersion + 1
|
|
3099
|
+
nextVersion: stored.nextVersion + 1,
|
|
3100
|
+
threads: sharedIn(stored.threads, version)
|
|
2624
3101
|
});
|
|
2625
3102
|
return published(record, version);
|
|
2626
3103
|
}
|
|
@@ -2629,7 +3106,7 @@ class InMemoryArtifactStorage {
|
|
|
2629
3106
|
return stored ? structuredClone(stored.record) : null;
|
|
2630
3107
|
}
|
|
2631
3108
|
async list(input) {
|
|
2632
|
-
const matching = [...this.artifacts.values()].filter(({ record,
|
|
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));
|
|
2633
3110
|
const { page, hasMore, total } = paginate(matching, input);
|
|
2634
3111
|
return { artifacts: structuredClone(page), hasMore, total };
|
|
2635
3112
|
}
|
|
@@ -2644,6 +3121,28 @@ class InMemoryArtifactStorage {
|
|
|
2644
3121
|
const { page, hasMore, total } = paginate(newestFirst, input);
|
|
2645
3122
|
return { versions: structuredClone(page), hasMore, total };
|
|
2646
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
|
+
}
|
|
2647
3146
|
async listReferencingVersions(input) {
|
|
2648
3147
|
const prefix = `artifact:${input.artifactId}`;
|
|
2649
3148
|
const referencing = [];
|
|
@@ -2679,6 +3178,45 @@ class InMemoryArtifactStorage {
|
|
|
2679
3178
|
}
|
|
2680
3179
|
return deleted;
|
|
2681
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
|
+
}
|
|
2682
3220
|
async delete(input) {
|
|
2683
3221
|
return this.deleteArtifact(artifactKey(input.projectId, input.id));
|
|
2684
3222
|
}
|
|
@@ -2696,6 +3234,11 @@ class InMemoryArtifactStorage {
|
|
|
2696
3234
|
this.deleteArtifact(key);
|
|
2697
3235
|
continue;
|
|
2698
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
|
+
}
|
|
2699
3242
|
this.artifacts.set(key, {
|
|
2700
3243
|
...stored,
|
|
2701
3244
|
record: {
|
|
@@ -2704,36 +3247,55 @@ class InMemoryArtifactStorage {
|
|
|
2704
3247
|
latestVersion: latest.version,
|
|
2705
3248
|
updatedAt: new Date(latest.createdAt)
|
|
2706
3249
|
},
|
|
2707
|
-
versions: remaining
|
|
3250
|
+
versions: remaining,
|
|
3251
|
+
threads
|
|
2708
3252
|
});
|
|
2709
3253
|
}
|
|
2710
3254
|
return deleted;
|
|
2711
3255
|
}
|
|
2712
3256
|
snapshot() {
|
|
2713
|
-
return structuredClone({
|
|
3257
|
+
return structuredClone({
|
|
3258
|
+
artifacts: this.artifacts,
|
|
3259
|
+
frameGrants: this.frameGrants,
|
|
3260
|
+
state: this.state
|
|
3261
|
+
});
|
|
2714
3262
|
}
|
|
2715
3263
|
restore(snapshot) {
|
|
2716
3264
|
const restored = structuredClone(snapshot);
|
|
2717
3265
|
this.artifacts = new Map(restored.artifacts);
|
|
2718
3266
|
this.frameGrants = new Map(restored.frameGrants);
|
|
3267
|
+
this.state = new Map([...restored.state].map(([key, kept]) => [key, new Map(kept)]));
|
|
2719
3268
|
}
|
|
2720
3269
|
deleteArtifact(key) {
|
|
2721
3270
|
for (const [grantKey, grant] of this.frameGrants) {
|
|
2722
3271
|
if (artifactKey(grant.projectId, grant.artifactId) === key)
|
|
2723
3272
|
this.frameGrants.delete(grantKey);
|
|
2724
3273
|
}
|
|
3274
|
+
for (const kept of this.state.keys()) {
|
|
3275
|
+
if (kept.startsWith(`${key}\x00`))
|
|
3276
|
+
this.state.delete(kept);
|
|
3277
|
+
}
|
|
2725
3278
|
return this.artifacts.delete(key);
|
|
2726
3279
|
}
|
|
2727
3280
|
}
|
|
2728
3281
|
function versionRecord(projectId, artifactId, version, input) {
|
|
2729
3282
|
return structuredClone({ ...input, projectId, artifactId, version });
|
|
2730
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
|
+
}
|
|
2731
3290
|
function published(record, version) {
|
|
2732
3291
|
return structuredClone({ artifact: record, version });
|
|
2733
3292
|
}
|
|
2734
3293
|
function artifactKey(projectId, id) {
|
|
2735
3294
|
return `${projectId}\x00${id}`;
|
|
2736
3295
|
}
|
|
3296
|
+
function stateKey(scope) {
|
|
3297
|
+
return `${artifactKey(scope.projectId, scope.artifactId)}\x00${scope.principal.type}\x00${scope.principal.id}`;
|
|
3298
|
+
}
|
|
2737
3299
|
function refersTo(address, prefix) {
|
|
2738
3300
|
return address.startsWith(prefix) && /^(?:$|[@/#])/.test(address.slice(prefix.length));
|
|
2739
3301
|
}
|
|
@@ -2803,6 +3365,22 @@ class InMemoryExecutionStorage {
|
|
|
2803
3365
|
};
|
|
2804
3366
|
});
|
|
2805
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
|
+
}
|
|
2806
3384
|
}
|
|
2807
3385
|
function isFromSession(row, session) {
|
|
2808
3386
|
const ref = row.authorizationRef;
|
|
@@ -2856,40 +3434,6 @@ class InMemoryFileDownloadGrantStorage {
|
|
|
2856
3434
|
function rowKey(projectId, id) {
|
|
2857
3435
|
return `${projectId}\x00${id}`;
|
|
2858
3436
|
}
|
|
2859
|
-
// src/objects/vectors/query.ts
|
|
2860
|
-
function hasVectorProfile2(query) {
|
|
2861
|
-
if (query.kind === "vector")
|
|
2862
|
-
return true;
|
|
2863
|
-
if (query.kind === "set")
|
|
2864
|
-
return query.inputs.some(hasVectorProfile2);
|
|
2865
|
-
return "input" in query && hasVectorProfile2(query.input);
|
|
2866
|
-
}
|
|
2867
|
-
function isVectorProfileQuery2(query) {
|
|
2868
|
-
if (query.kind === "limit" || query.kind === "project")
|
|
2869
|
-
return isVectorProfileQuery2(query.input);
|
|
2870
|
-
if (query.kind === "rerank") {
|
|
2871
|
-
return query.input.kind === "vector" && isVectorProfileQuery2(query.input);
|
|
2872
|
-
}
|
|
2873
|
-
if (query.kind !== "vector" || !query.profile)
|
|
2874
|
-
return false;
|
|
2875
|
-
return isVectorCandidateQuery(query.input);
|
|
2876
|
-
}
|
|
2877
|
-
function isVectorCandidateQuery(query) {
|
|
2878
|
-
switch (query.kind) {
|
|
2879
|
-
case "start":
|
|
2880
|
-
return !query.includeSubtypes;
|
|
2881
|
-
case "refs":
|
|
2882
|
-
return true;
|
|
2883
|
-
case "filter":
|
|
2884
|
-
case "traverse":
|
|
2885
|
-
return isVectorCandidateQuery(query.input);
|
|
2886
|
-
case "set":
|
|
2887
|
-
return query.inputs.every(isVectorCandidateQuery);
|
|
2888
|
-
default:
|
|
2889
|
-
return false;
|
|
2890
|
-
}
|
|
2891
|
-
}
|
|
2892
|
-
|
|
2893
3437
|
// src/storage/objects/keys.ts
|
|
2894
3438
|
function objectBatchKey2(objectTypeId, primaryId) {
|
|
2895
3439
|
return JSON.stringify([objectTypeId, primaryId]);
|
|
@@ -2913,42 +3457,6 @@ function compareObjectLinks(left, right) {
|
|
|
2913
3457
|
return compareObjectLinkCursors(objectLinkCursor2(left), objectLinkCursor2(right));
|
|
2914
3458
|
}
|
|
2915
3459
|
|
|
2916
|
-
// src/storage/objects/in-memory/keys.ts
|
|
2917
|
-
function objectRowKey(projectId, objectTypeId) {
|
|
2918
|
-
return JSON.stringify([projectId, objectTypeId]);
|
|
2919
|
-
}
|
|
2920
|
-
function objectRowProjectPrefix(projectId) {
|
|
2921
|
-
return `[${JSON.stringify(projectId)},`;
|
|
2922
|
-
}
|
|
2923
|
-
function compareStrings(left, right) {
|
|
2924
|
-
if (left < right)
|
|
2925
|
-
return -1;
|
|
2926
|
-
if (left > right)
|
|
2927
|
-
return 1;
|
|
2928
|
-
return 0;
|
|
2929
|
-
}
|
|
2930
|
-
function sourceLinkBucketKey(projectId, sourceTypeId, sourceId) {
|
|
2931
|
-
return JSON.stringify([projectId, sourceTypeId, sourceId]);
|
|
2932
|
-
}
|
|
2933
|
-
function linkRowKey(linkId, targetTypeId, targetId) {
|
|
2934
|
-
return JSON.stringify([linkId, targetTypeId, targetId]);
|
|
2935
|
-
}
|
|
2936
|
-
function fullLinkRowKey(row) {
|
|
2937
|
-
return JSON.stringify([
|
|
2938
|
-
row.sourceTypeId,
|
|
2939
|
-
row.sourceId,
|
|
2940
|
-
row.linkId,
|
|
2941
|
-
row.targetTypeId,
|
|
2942
|
-
row.targetId
|
|
2943
|
-
]);
|
|
2944
|
-
}
|
|
2945
|
-
function rowIdentityKey(row) {
|
|
2946
|
-
return rowIdentityKeyParts(row.objectTypeId, row.primaryId);
|
|
2947
|
-
}
|
|
2948
|
-
function rowIdentityKeyParts(objectTypeId, primaryId) {
|
|
2949
|
-
return objectBatchKey2(objectTypeId, primaryId);
|
|
2950
|
-
}
|
|
2951
|
-
|
|
2952
3460
|
// src/objects/query/scalar-values.ts
|
|
2953
3461
|
function compareQueryScalarValues(left, right, scalarKind) {
|
|
2954
3462
|
if (left === undefined || right === undefined || left === null || right === null) {
|
|
@@ -2959,7 +3467,7 @@ function compareQueryScalarValues(left, right, scalarKind) {
|
|
|
2959
3467
|
switch (scalarKind) {
|
|
2960
3468
|
case "string":
|
|
2961
3469
|
case "uuid":
|
|
2962
|
-
return typeof left === "string" && typeof right === "string" ?
|
|
3470
|
+
return typeof left === "string" && typeof right === "string" ? compareStrings(left, right) : Number.NaN;
|
|
2963
3471
|
case "boolean":
|
|
2964
3472
|
return typeof left === "boolean" && typeof right === "boolean" ? Number(left) - Number(right) : Number.NaN;
|
|
2965
3473
|
case "integer":
|
|
@@ -3001,7 +3509,7 @@ function compareRuntimeValues(left, right) {
|
|
|
3001
3509
|
if (typeof left === "number" && typeof right === "number")
|
|
3002
3510
|
return left - right;
|
|
3003
3511
|
if (typeof left === "string" && typeof right === "string")
|
|
3004
|
-
return
|
|
3512
|
+
return compareStrings(left, right);
|
|
3005
3513
|
if (typeof left === "boolean" && typeof right === "boolean") {
|
|
3006
3514
|
return Number(left) - Number(right);
|
|
3007
3515
|
}
|
|
@@ -3034,6 +3542,81 @@ function dateTime(value) {
|
|
|
3034
3542
|
}
|
|
3035
3543
|
return null;
|
|
3036
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
|
+
}
|
|
3037
3620
|
function compareStrings2(left, right) {
|
|
3038
3621
|
if (left < right)
|
|
3039
3622
|
return -1;
|
|
@@ -3041,55 +3624,26 @@ function compareStrings2(left, right) {
|
|
|
3041
3624
|
return 1;
|
|
3042
3625
|
return 0;
|
|
3043
3626
|
}
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
var MAX_VECTOR_K = 1000;
|
|
3047
|
-
var VECTOR_INPUT_VERSION = 1;
|
|
3048
|
-
var INDEXING_EMBEDDING_TIMEOUT_MS = 5 * 60000;
|
|
3049
|
-
function vectorConfiguration(profile) {
|
|
3050
|
-
return sha256Canonical2({
|
|
3051
|
-
format: VECTOR_INPUT_VERSION,
|
|
3052
|
-
sources: [...profile.source],
|
|
3053
|
-
provider: profile.model.providerId,
|
|
3054
|
-
model: profile.model.modelId,
|
|
3055
|
-
representation: profile.model.definition.representation ?? { name: profile.model.modelId },
|
|
3056
|
-
dimensions: profile.model.definition.dimensions,
|
|
3057
|
-
...profile.model.definition.inputMode === "asymmetric" ? { inputMode: "asymmetric" } : {},
|
|
3058
|
-
metric: "cosine",
|
|
3059
|
-
precision: "float32",
|
|
3060
|
-
normalization: "l2-v1"
|
|
3061
|
-
});
|
|
3627
|
+
function sourceLinkBucketKey(projectId, sourceTypeId, sourceId) {
|
|
3628
|
+
return JSON.stringify([projectId, sourceTypeId, sourceId]);
|
|
3062
3629
|
}
|
|
3063
|
-
function
|
|
3064
|
-
|
|
3065
|
-
for (const key of source) {
|
|
3066
|
-
const value = properties[key];
|
|
3067
|
-
if (value !== undefined && value !== null && typeof value !== "string") {
|
|
3068
|
-
throw new MaterializationValidationError2(`Vector source must be text: ${key}`);
|
|
3069
|
-
}
|
|
3070
|
-
values[key] = typeof value === "string" ? value : null;
|
|
3071
|
-
}
|
|
3072
|
-
const text = JSON.stringify(source.map((key) => [key, values[key]]));
|
|
3073
|
-
return { text, sourceFingerprint: sha256Canonical2(text) };
|
|
3630
|
+
function linkRowKey(linkId, targetTypeId, targetId) {
|
|
3631
|
+
return JSON.stringify([linkId, targetTypeId, targetId]);
|
|
3074
3632
|
}
|
|
3075
|
-
function
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
return Math.fround(value);
|
|
3084
|
-
});
|
|
3085
|
-
if (!normalized.some((value) => value !== 0)) {
|
|
3086
|
-
throw new MaterializationValidationError2("Cosine search requires a nonzero vector.");
|
|
3087
|
-
}
|
|
3088
|
-
const norm = Math.hypot(...normalized);
|
|
3089
|
-
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
|
+
]);
|
|
3090
3641
|
}
|
|
3091
|
-
function
|
|
3092
|
-
return
|
|
3642
|
+
function rowIdentityKey(row) {
|
|
3643
|
+
return rowIdentityKeyParts(row.objectTypeId, row.primaryId);
|
|
3644
|
+
}
|
|
3645
|
+
function rowIdentityKeyParts(objectTypeId, primaryId) {
|
|
3646
|
+
return objectBatchKey2(objectTypeId, primaryId);
|
|
3093
3647
|
}
|
|
3094
3648
|
|
|
3095
3649
|
// src/storage/objects/in-memory/query.ts
|
|
@@ -3123,7 +3677,8 @@ var IN_MEMORY_OBJECT_QUERY_CAPABILITIES = {
|
|
|
3123
3677
|
gte: true,
|
|
3124
3678
|
in: true,
|
|
3125
3679
|
exists: true,
|
|
3126
|
-
contains: true
|
|
3680
|
+
contains: true,
|
|
3681
|
+
constant: true
|
|
3127
3682
|
},
|
|
3128
3683
|
sortKinds: {
|
|
3129
3684
|
property: true,
|
|
@@ -3272,7 +3827,7 @@ function evaluateRefs(refs, source) {
|
|
|
3272
3827
|
seen.add(key);
|
|
3273
3828
|
const row = source.getObject(ref.objectTypeId, ref.primaryId);
|
|
3274
3829
|
return row ? [row] : [];
|
|
3275
|
-
}).sort((left, right) =>
|
|
3830
|
+
}).sort((left, right) => compareStrings2(left.objectTypeId, right.objectTypeId) || compareStrings2(left.primaryId, right.primaryId)).map((row, order) => ({ row, score: 0, order }));
|
|
3276
3831
|
return completeEvaluation(entries);
|
|
3277
3832
|
}
|
|
3278
3833
|
function evaluateSet(op, inputs, source) {
|
|
@@ -3349,48 +3904,6 @@ function completeEvaluation(entries) {
|
|
|
3349
3904
|
hasMore: false
|
|
3350
3905
|
};
|
|
3351
3906
|
}
|
|
3352
|
-
function matchesPredicate(row, predicate) {
|
|
3353
|
-
switch (predicate.op) {
|
|
3354
|
-
case "and":
|
|
3355
|
-
return predicate.items.every((item) => matchesPredicate(row, item));
|
|
3356
|
-
case "or":
|
|
3357
|
-
return predicate.items.some((item) => matchesPredicate(row, item));
|
|
3358
|
-
case "not":
|
|
3359
|
-
return !matchesPredicate(row, predicate.item);
|
|
3360
|
-
case "eq":
|
|
3361
|
-
return queryScalarValuesEqual(row.properties[predicate.propertyId], predicate.value, predicate.scalarKind);
|
|
3362
|
-
case "neq":
|
|
3363
|
-
return !queryScalarValuesEqual(row.properties[predicate.propertyId], predicate.value, predicate.scalarKind);
|
|
3364
|
-
case "lt":
|
|
3365
|
-
return compareQueryScalarValues(row.properties[predicate.propertyId], predicate.value, predicate.scalarKind) < 0;
|
|
3366
|
-
case "lte":
|
|
3367
|
-
return compareQueryScalarValues(row.properties[predicate.propertyId], predicate.value, predicate.scalarKind) <= 0;
|
|
3368
|
-
case "gt":
|
|
3369
|
-
return compareQueryScalarValues(row.properties[predicate.propertyId], predicate.value, predicate.scalarKind) > 0;
|
|
3370
|
-
case "gte":
|
|
3371
|
-
return compareQueryScalarValues(row.properties[predicate.propertyId], predicate.value, predicate.scalarKind) >= 0;
|
|
3372
|
-
case "in":
|
|
3373
|
-
return predicate.values.some((value) => queryScalarValuesEqual(row.properties[predicate.propertyId], value, predicate.scalarKind));
|
|
3374
|
-
case "exists": {
|
|
3375
|
-
const exists = Object.hasOwn(row.properties, predicate.propertyId) && row.properties[predicate.propertyId] !== undefined;
|
|
3376
|
-
return predicate.value ? exists : !exists;
|
|
3377
|
-
}
|
|
3378
|
-
case "contains":
|
|
3379
|
-
return containsValue(row.properties[predicate.propertyId], predicate.value, predicate.scalarKind);
|
|
3380
|
-
}
|
|
3381
|
-
}
|
|
3382
|
-
function containsValue(actual, expected, itemScalarKind) {
|
|
3383
|
-
if (typeof actual === "string" && typeof expected === "string") {
|
|
3384
|
-
return actual.includes(expected);
|
|
3385
|
-
}
|
|
3386
|
-
if (Array.isArray(actual)) {
|
|
3387
|
-
return actual.some((item) => queryScalarValuesEqual(item, expected, itemScalarKind));
|
|
3388
|
-
}
|
|
3389
|
-
if (isPlainObject(actual) && typeof expected === "string") {
|
|
3390
|
-
return Object.hasOwn(actual, expected);
|
|
3391
|
-
}
|
|
3392
|
-
return false;
|
|
3393
|
-
}
|
|
3394
3907
|
function textScore(row, query, fields, fieldsByObjectType) {
|
|
3395
3908
|
const terms = tokenize(query);
|
|
3396
3909
|
if (terms.length === 0)
|
|
@@ -3598,37 +4111,215 @@ function collectLinksBatch(source, params, cloneRows) {
|
|
|
3598
4111
|
];
|
|
3599
4112
|
}));
|
|
3600
4113
|
}
|
|
3601
|
-
function upsertEntry(entriesByKey, entry) {
|
|
3602
|
-
const key = rowIdentityKey(entry.row);
|
|
3603
|
-
const existing = entriesByKey.get(key);
|
|
3604
|
-
if (!existing) {
|
|
3605
|
-
entriesByKey.set(key, entry);
|
|
3606
|
-
return;
|
|
4114
|
+
function upsertEntry(entriesByKey, entry) {
|
|
4115
|
+
const key = rowIdentityKey(entry.row);
|
|
4116
|
+
const existing = entriesByKey.get(key);
|
|
4117
|
+
if (!existing) {
|
|
4118
|
+
entriesByKey.set(key, entry);
|
|
4119
|
+
return;
|
|
4120
|
+
}
|
|
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
|
+
}
|
|
3607
4256
|
}
|
|
3608
|
-
if (
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
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
|
+
}
|
|
3613
4263
|
}
|
|
4264
|
+
if (direction !== "both")
|
|
4265
|
+
return rows;
|
|
4266
|
+
return [...new Map(rows.map((row) => [fullLinkRowKey(row), row])).values()];
|
|
3614
4267
|
}
|
|
3615
|
-
function
|
|
3616
|
-
|
|
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
|
+
};
|
|
3617
4289
|
}
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
}
|
|
3628
|
-
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
|
+
});
|
|
3629
4299
|
}
|
|
3630
|
-
function
|
|
3631
|
-
|
|
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
|
+
};
|
|
3632
4323
|
}
|
|
3633
4324
|
|
|
3634
4325
|
// src/storage/objects/in-memory/read-scope.ts
|
|
@@ -3732,10 +4423,7 @@ function createReadUniverse(source, objects, links, objectProperties) {
|
|
|
3732
4423
|
}
|
|
3733
4424
|
return {
|
|
3734
4425
|
projectId,
|
|
3735
|
-
|
|
3736
|
-
links,
|
|
3737
|
-
linksBySource,
|
|
3738
|
-
objectProperties,
|
|
4426
|
+
selectsProperty: (objectTypeId, primaryId, propertyId) => objectProperties.get(rowIdentityKeyParts(objectTypeId, primaryId))?.has(propertyId) ?? false,
|
|
3739
4427
|
getVector: (ref, profile) => {
|
|
3740
4428
|
const key = rowIdentityKeyParts(ref.objectTypeId, ref.primaryId);
|
|
3741
4429
|
if (!objects.has(key))
|
|
@@ -3743,10 +4431,18 @@ function createReadUniverse(source, objects, links, objectProperties) {
|
|
|
3743
4431
|
const value = source.getVector?.(ref, profile);
|
|
3744
4432
|
return value?.source.every((id) => objectProperties.get(key)?.has(id)) ? value : undefined;
|
|
3745
4433
|
},
|
|
4434
|
+
allObjects: () => objects.values(),
|
|
3746
4435
|
objectsOfType: (objectTypeId) => [...objects.values()].filter((row) => row.objectTypeId === objectTypeId),
|
|
3747
4436
|
getObject: (objectTypeId, primaryId) => objects.get(rowIdentityKeyParts(objectTypeId, primaryId)),
|
|
3748
4437
|
outgoingLinks: (objectTypeId, primaryId) => linksBySource.get(sourceLinkBucketKey(projectId, objectTypeId, primaryId)) ?? [],
|
|
3749
|
-
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
|
+
}
|
|
3750
4446
|
};
|
|
3751
4447
|
}
|
|
3752
4448
|
function unionInto(target, key, values) {
|
|
@@ -3777,153 +4473,14 @@ function redactProperties(properties, propertyIds) {
|
|
|
3777
4473
|
|
|
3778
4474
|
// src/storage/objects/in-memory/selected-reader.ts
|
|
3779
4475
|
function createInMemorySelectedReader(source, params, queryCapabilities) {
|
|
3780
|
-
const projectId = source.projectId;
|
|
3781
4476
|
const plan = prepareReadPlan(params.scope);
|
|
3782
4477
|
const limits = snapshotObjectReadExecutionLimits2(params.limits);
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
const visibleMap = (value) => {
|
|
3789
|
-
assertObjectReadOutputWithinLimit2([...value.entries()], limits);
|
|
3790
|
-
return value;
|
|
3791
|
-
};
|
|
3792
|
-
const selectsObjectProperties = async (input) => {
|
|
3793
|
-
assertProject(input.projectId);
|
|
3794
|
-
const universe = resolveSelectedReadUniverse(source, plan, limits);
|
|
3795
|
-
return visible(input.items.map((item) => {
|
|
3796
|
-
const key = rowIdentityKeyParts(item.objectTypeId, item.primaryId);
|
|
3797
|
-
if (!universe.objects.has(key))
|
|
3798
|
-
return false;
|
|
3799
|
-
return universe.objectProperties.get(key)?.has(item.propertyId) ?? false;
|
|
3800
|
-
}));
|
|
3801
|
-
};
|
|
3802
|
-
return Object.freeze({
|
|
3803
|
-
queryCapabilities,
|
|
3804
|
-
queryObjects: async (input) => {
|
|
3805
|
-
assertProject(input.projectId);
|
|
3806
|
-
const universe = resolveSelectedReadUniverse(source, plan, limits);
|
|
3807
|
-
const result = evaluateObjectQuery(input.query, universe);
|
|
3808
|
-
return visible({
|
|
3809
|
-
objects: result.entries.map((entry) => ({
|
|
3810
|
-
...structuredClone(entry.row),
|
|
3811
|
-
...hasVectorProfile2(input.query) ? { score: entry.score } : {}
|
|
3812
|
-
})),
|
|
3813
|
-
hasMore: result.hasMore,
|
|
3814
|
-
nextPageToken: result.nextPageToken,
|
|
3815
|
-
...input.includeTotal === false ? {} : { total: result.total }
|
|
3816
|
-
});
|
|
3817
|
-
},
|
|
3818
|
-
countObjects: async (input) => {
|
|
3819
|
-
assertProject(input.projectId);
|
|
3820
|
-
const universe = resolveSelectedReadUniverse(source, plan, limits);
|
|
3821
|
-
return visible({
|
|
3822
|
-
count: evaluateObjectQuery(stripOuterRowShape(input.query), universe).total
|
|
3823
|
-
});
|
|
3824
|
-
},
|
|
3825
|
-
existsObjects: async (input) => {
|
|
3826
|
-
assertProject(input.projectId);
|
|
3827
|
-
const universe = resolveSelectedReadUniverse(source, plan, limits);
|
|
3828
|
-
return visible({
|
|
3829
|
-
exists: evaluateObjectQuery(stripOuterRowShape(input.query), universe).total > 0
|
|
3830
|
-
});
|
|
3831
|
-
},
|
|
3832
|
-
facetObjects: async (input) => {
|
|
3833
|
-
assertProject(input.projectId);
|
|
3834
|
-
assertObjectReadFacetCount2(input.facets.length);
|
|
3835
|
-
const universe = resolveSelectedReadUniverse(source, plan, limits);
|
|
3836
|
-
const result = evaluateObjectQuery(stripOuterRowShape(input.query), universe);
|
|
3837
|
-
return visible(structuredClone({
|
|
3838
|
-
total: result.entries.length,
|
|
3839
|
-
facets: buildFacetResults(result.entries.map((entry) => entry.row), input.facets)
|
|
3840
|
-
}));
|
|
3841
|
-
},
|
|
3842
|
-
getByPrimaryId: async (input) => {
|
|
3843
|
-
assertProject(input.projectId);
|
|
3844
|
-
const universe = resolveSelectedReadUniverse(source, plan, limits);
|
|
3845
|
-
const row = universe.objects.get(rowIdentityKeyParts(input.objectTypeId, input.primaryId));
|
|
3846
|
-
return visible(row ? structuredClone(row) : null);
|
|
3847
|
-
},
|
|
3848
|
-
selectsObjectProperties,
|
|
3849
|
-
listLinks: async (input) => {
|
|
3850
|
-
assertProject(input.projectId);
|
|
3851
|
-
const universe = resolveSelectedReadUniverse(source, plan, limits);
|
|
3852
|
-
return visible(listUniverseLinks(universe, input).map((row) => structuredClone(row)));
|
|
3853
|
-
},
|
|
3854
|
-
getByPrimaryIdBatch: async (input) => {
|
|
3855
|
-
assertProject(input.projectId);
|
|
3856
|
-
const universe = resolveSelectedReadUniverse(source, plan, limits);
|
|
3857
|
-
const rows = new Map;
|
|
3858
|
-
for (const item of input.items) {
|
|
3859
|
-
const row = universe.objects.get(rowIdentityKeyParts(item.objectTypeId, item.primaryId));
|
|
3860
|
-
if (row) {
|
|
3861
|
-
rows.set(objectBatchKey2(item.objectTypeId, item.primaryId), structuredClone(row));
|
|
3862
|
-
}
|
|
3863
|
-
}
|
|
3864
|
-
return visibleMap(rows);
|
|
3865
|
-
},
|
|
3866
|
-
listLinksBatch: async (input) => {
|
|
3867
|
-
assertProject(input.projectId);
|
|
3868
|
-
const universe = resolveSelectedReadUniverse(source, plan, limits);
|
|
3869
|
-
return visibleMap(collectLinksBatch({
|
|
3870
|
-
all: () => universe.links.values(),
|
|
3871
|
-
outgoing: (item) => universe.linksBySource.get(sourceLinkBucketKey(projectId, item.objectTypeId, item.objectId)) ?? []
|
|
3872
|
-
}, input, true));
|
|
3873
|
-
},
|
|
3874
|
-
queryLinks: async (input) => {
|
|
3875
|
-
assertProject(input.projectId);
|
|
3876
|
-
const universe = resolveSelectedReadUniverse(source, plan, limits);
|
|
3877
|
-
return visible(structuredClone(await queryLinksFrom(input, (item) => listUniverseLinks(universe, item))));
|
|
3878
|
-
},
|
|
3879
|
-
list: async (input) => {
|
|
3880
|
-
assertProject(input.projectId);
|
|
3881
|
-
const universe = resolveSelectedReadUniverse(source, plan, limits);
|
|
3882
|
-
return visible(listRows(input, [...universe.objects.values()]));
|
|
3883
|
-
}
|
|
3884
|
-
});
|
|
3885
|
-
}
|
|
3886
|
-
function listUniverseLinks(universe, params) {
|
|
3887
|
-
const direction = params.direction ?? "outgoing";
|
|
3888
|
-
const matches = (row) => !params.linkId || row.linkId === params.linkId;
|
|
3889
|
-
const rows = [];
|
|
3890
|
-
if (direction === "outgoing" || direction === "both") {
|
|
3891
|
-
const outgoing = universe.linksBySource.get(sourceLinkBucketKey(params.projectId, params.objectTypeId, params.objectId));
|
|
3892
|
-
if (outgoing)
|
|
3893
|
-
rows.push(...outgoing.filter(matches));
|
|
3894
|
-
}
|
|
3895
|
-
if (direction === "incoming" || direction === "both") {
|
|
3896
|
-
for (const row of universe.links.values()) {
|
|
3897
|
-
if (row.targetTypeId === params.objectTypeId && row.targetId === params.objectId && matches(row)) {
|
|
3898
|
-
rows.push(row);
|
|
3899
|
-
}
|
|
3900
|
-
}
|
|
3901
|
-
}
|
|
3902
|
-
if (direction !== "both")
|
|
3903
|
-
return rows;
|
|
3904
|
-
return [...new Map(rows.map((row) => [fullLinkRowKey(row), row])).values()];
|
|
3905
|
-
}
|
|
3906
|
-
function listRows(params, candidates) {
|
|
3907
|
-
const requestedTypes = params.objectTypeId === undefined ? undefined : new Set(typeof params.objectTypeId === "string" ? [params.objectTypeId] : params.objectTypeId);
|
|
3908
|
-
let rows = candidates.filter((row) => row.projectId === params.projectId && (!requestedTypes || requestedTypes.has(row.objectTypeId)));
|
|
3909
|
-
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));
|
|
3910
|
-
const total = rows.length;
|
|
3911
|
-
const offset = params.offset ?? 0;
|
|
3912
|
-
const limit = params.limit ?? 50;
|
|
3913
|
-
if (limit === 0)
|
|
3914
|
-
return { objects: [], hasMore: offset < total, total };
|
|
3915
|
-
const orderBy = params.orderBy ?? "updatedAt";
|
|
3916
|
-
const order = params.order ?? "desc";
|
|
3917
|
-
rows.sort((left, right) => {
|
|
3918
|
-
const comparison = orderBy === "primaryId" ? left.primaryId.localeCompare(right.primaryId) : orderBy === "createdAt" ? left.createdAt.getTime() - right.createdAt.getTime() : left.updatedAt.getTime() - right.updatedAt.getTime();
|
|
3919
|
-
return order === "desc" ? -comparison : comparison;
|
|
4478
|
+
return createInMemoryScopedReader({
|
|
4479
|
+
projectId: source.projectId,
|
|
4480
|
+
resolve: () => resolveSelectedReadUniverse(source, plan, limits),
|
|
4481
|
+
limits,
|
|
4482
|
+
queryCapabilities
|
|
3920
4483
|
});
|
|
3921
|
-
const objects = rows.slice(offset, offset + limit).map((row) => structuredClone(row));
|
|
3922
|
-
return {
|
|
3923
|
-
objects,
|
|
3924
|
-
hasMore: offset + limit < total,
|
|
3925
|
-
total
|
|
3926
|
-
};
|
|
3927
4484
|
}
|
|
3928
4485
|
|
|
3929
4486
|
// src/storage/objects/in-memory/storage.ts
|
|
@@ -3938,6 +4495,8 @@ function getInMemoryObjectMaterializerAdapter(storage) {
|
|
|
3938
4495
|
class InMemoryObjectStorage {
|
|
3939
4496
|
rows = new Map;
|
|
3940
4497
|
links = new Map;
|
|
4498
|
+
uniqueValues = new Map;
|
|
4499
|
+
uniqueProperties = new Map;
|
|
3941
4500
|
vectorReader;
|
|
3942
4501
|
constructor() {
|
|
3943
4502
|
materializerAdapters.set(this, {
|
|
@@ -3966,13 +4525,37 @@ class InMemoryObjectStorage {
|
|
|
3966
4525
|
if (row.linkId === linkId)
|
|
3967
4526
|
visit(structuredClone(row));
|
|
3968
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 });
|
|
3969
4550
|
}
|
|
3970
4551
|
});
|
|
3971
4552
|
}
|
|
3972
4553
|
snapshot() {
|
|
3973
4554
|
return {
|
|
3974
4555
|
rows: cloneObjectBuckets(this.rows),
|
|
3975
|
-
links: cloneLinkBuckets(this.links)
|
|
4556
|
+
links: cloneLinkBuckets(this.links),
|
|
4557
|
+
uniqueValues: cloneUniqueValues(this.uniqueValues),
|
|
4558
|
+
uniqueProperties: new Map(this.uniqueProperties)
|
|
3976
4559
|
};
|
|
3977
4560
|
}
|
|
3978
4561
|
restore(snapshot) {
|
|
@@ -3984,6 +4567,58 @@ class InMemoryObjectStorage {
|
|
|
3984
4567
|
for (const [key, bucket] of cloneLinkBuckets(snapshot.links)) {
|
|
3985
4568
|
this.links.set(key, bucket);
|
|
3986
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);
|
|
3987
4622
|
}
|
|
3988
4623
|
getExactObjectRow(projectId, objectTypeId, primaryId) {
|
|
3989
4624
|
const row = this.rows.get(objectRowKey(projectId, objectTypeId))?.get(primaryId);
|
|
@@ -4037,16 +4672,21 @@ class InMemoryObjectStorage {
|
|
|
4037
4672
|
createSelectedReadScope(params) {
|
|
4038
4673
|
return createInMemorySelectedReader(this.readSource(params.projectId), params, () => this.queryCapabilities());
|
|
4039
4674
|
}
|
|
4675
|
+
createConditionalReadScope(params) {
|
|
4676
|
+
return createInMemoryConditionalReader(this.readSource(params.projectId), params.scope, () => this.queryCapabilities());
|
|
4677
|
+
}
|
|
4040
4678
|
readSource(projectId) {
|
|
4041
4679
|
return {
|
|
4042
4680
|
projectId,
|
|
4043
4681
|
getVector: (ref, profile) => this.vectorReader?.(projectId, ref, profile),
|
|
4682
|
+
allObjects: () => projectObjectRows(this.rows, projectId),
|
|
4044
4683
|
objectsOfType: (objectTypeId) => [
|
|
4045
4684
|
...this.rows.get(objectRowKey(projectId, objectTypeId))?.values() ?? []
|
|
4046
4685
|
],
|
|
4047
4686
|
getObject: (objectTypeId, primaryId) => this.rows.get(objectRowKey(projectId, objectTypeId))?.get(primaryId),
|
|
4048
4687
|
outgoingLinks: (objectTypeId, primaryId) => this.links.get(sourceLinkBucketKey(projectId, objectTypeId, primaryId))?.values() ?? [],
|
|
4049
|
-
allLinks: () =>
|
|
4688
|
+
allLinks: () => projectLinkRows(this.links, projectId),
|
|
4689
|
+
uniqueHolder: (value) => this.uniqueHolder(projectId, value)
|
|
4050
4690
|
};
|
|
4051
4691
|
}
|
|
4052
4692
|
async queryObjects(params) {
|
|
@@ -4084,6 +4724,12 @@ class InMemoryObjectStorage {
|
|
|
4084
4724
|
return null;
|
|
4085
4725
|
return bucket.get(params.primaryId) ?? null;
|
|
4086
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
|
+
}
|
|
4087
4733
|
async selectsObjectProperties(params) {
|
|
4088
4734
|
return params.items.map((item) => this.rows.get(objectRowKey(params.projectId, item.objectTypeId))?.has(item.primaryId) ?? false);
|
|
4089
4735
|
}
|
|
@@ -4150,7 +4796,7 @@ class InMemoryObjectStorage {
|
|
|
4150
4796
|
async listByPrimaryIdPage(params) {
|
|
4151
4797
|
assertReconciliationPageLimit(params.limit);
|
|
4152
4798
|
const bucket = this.rows.get(objectRowKey(params.projectId, params.objectTypeId));
|
|
4153
|
-
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);
|
|
4154
4800
|
const hasMore = rows.length > params.limit;
|
|
4155
4801
|
const objects = rows.slice(0, params.limit).map((row) => structuredClone(row));
|
|
4156
4802
|
const last = objects.at(-1);
|
|
@@ -4234,6 +4880,12 @@ function cloneObjectBuckets(rows) {
|
|
|
4234
4880
|
}
|
|
4235
4881
|
return clone;
|
|
4236
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
|
+
}
|
|
4237
4889
|
function cloneLinkBuckets(links) {
|
|
4238
4890
|
const clone = new Map;
|
|
4239
4891
|
for (const [key, bucket] of links) {
|
|
@@ -4241,6 +4893,20 @@ function cloneLinkBuckets(links) {
|
|
|
4241
4893
|
}
|
|
4242
4894
|
return clone;
|
|
4243
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
|
+
}
|
|
4244
4910
|
function* allLinkRows(buckets) {
|
|
4245
4911
|
for (const bucket of buckets.values())
|
|
4246
4912
|
yield* bucket.values();
|
|
@@ -5006,6 +5672,9 @@ function touchPlanItem(touches, item) {
|
|
|
5006
5672
|
case "link-slot-override-delete":
|
|
5007
5673
|
touches.scopes.add(linkScopeKey(item.value.ref.source, item.value.ref.linkId));
|
|
5008
5674
|
return;
|
|
5675
|
+
case "unique-value-release":
|
|
5676
|
+
case "unique-value-claim":
|
|
5677
|
+
return;
|
|
5009
5678
|
}
|
|
5010
5679
|
}
|
|
5011
5680
|
function replacementPlanKey(input) {
|
|
@@ -5634,6 +6303,17 @@ class InMemoryOntologyMaterializationStorage {
|
|
|
5634
6303
|
const value = this.linkSlotState(session, scope.source, scope.linkId);
|
|
5635
6304
|
yield { objects: [], links: [], linkScopes: [value], points: [] };
|
|
5636
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
|
+
}
|
|
5637
6317
|
const requestedPoints = uniqueSorted2(request.points, (point) => telemetryPointKey2(point.series, point.at), (point) => telemetryPointSortKey2(point.series, point.at));
|
|
5638
6318
|
for (let offset = 0;offset < requestedPoints.length; offset += input.pageRows) {
|
|
5639
6319
|
this.requireSession(input.session);
|
|
@@ -5801,6 +6481,14 @@ class InMemoryOntologyMaterializationStorage {
|
|
|
5801
6481
|
this.assertLinkSync(item.expected, projectId);
|
|
5802
6482
|
getInMemoryObjectMaterializerAdapter(this.objects).applyExactLink(item.row, projectId);
|
|
5803
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
|
+
});
|
|
5804
6492
|
for (const item of chunk.timeseries.pointUpserts)
|
|
5805
6493
|
write("timeseries.point.upsert", () => {
|
|
5806
6494
|
this.assertPoint(item.expected, projectId);
|
|
@@ -5971,6 +6659,16 @@ class InMemoryOntologyMaterializationStorage {
|
|
|
5971
6659
|
throw new MaterializationConflictError2("timeseries-point", `Telemetry point ${telemetryPointKey2(expected.series, expected.at)} changed.`);
|
|
5972
6660
|
}
|
|
5973
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
|
+
}
|
|
5974
6672
|
linkSlotState(session, source, linkId) {
|
|
5975
6673
|
session.linkSlotStates ??= new Map;
|
|
5976
6674
|
const key = linkScopeSortKey2(source, linkId);
|
|
@@ -6721,6 +7419,32 @@ function registerInMemoryOntologyStorageTestingAdapter(storage, adapter) {
|
|
|
6721
7419
|
testingAdapters.set(storage, adapter);
|
|
6722
7420
|
}
|
|
6723
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
|
+
|
|
6724
7448
|
// src/storage/ontology/in-memory/vector-indexing.ts
|
|
6725
7449
|
class InMemoryVectorIndexingStorage {
|
|
6726
7450
|
state;
|
|
@@ -6853,6 +7577,7 @@ class InMemoryOntologyStorage {
|
|
|
6853
7577
|
materializations;
|
|
6854
7578
|
replacementPlans;
|
|
6855
7579
|
outbox;
|
|
7580
|
+
uniqueValues;
|
|
6856
7581
|
testHooks = {};
|
|
6857
7582
|
testingAdapter = {
|
|
6858
7583
|
setTestHooks: (hooks) => this.setTestHooks(hooks),
|
|
@@ -6865,6 +7590,7 @@ class InMemoryOntologyStorage {
|
|
|
6865
7590
|
this.commits = new InMemoryOntologyCommitStorage(this.state, options.runRootOperation);
|
|
6866
7591
|
this.sources = new InMemoryOntologySourceStorage(this.state, options.runRootOperation, options.assertSourceMaterializationExecution);
|
|
6867
7592
|
this.outbox = new InMemoryOntologyOutboxStorage(this.state, options.runRootOperation, options.readExecution);
|
|
7593
|
+
this.uniqueValues = new InMemoryOntologyUniqueValueStorage(objects, options.runRootOperation);
|
|
6868
7594
|
const hooks = {
|
|
6869
7595
|
beforeRead: (boundary) => this.testHooks.beforeRead?.(boundary),
|
|
6870
7596
|
beforeWrite: (boundary, ordinal) => this.testHooks.beforeWrite?.(boundary, ordinal),
|
|
@@ -7224,29 +7950,19 @@ function compareRuns2(a, b, order) {
|
|
|
7224
7950
|
|
|
7225
7951
|
class InMemoryProjectionRunStorage2 {
|
|
7226
7952
|
rows = new Map;
|
|
7227
|
-
executionTokensByRun = new Map;
|
|
7228
7953
|
runRootOperation;
|
|
7229
|
-
createExecutionToken;
|
|
7230
7954
|
constructor(input) {
|
|
7231
7955
|
this.executions = input.executions;
|
|
7232
7956
|
this.runRootOperation = input.runRootOperation ?? runDirectly3;
|
|
7233
|
-
this.createExecutionToken = input.executionToken ?? randomUUID;
|
|
7234
7957
|
}
|
|
7235
7958
|
executions;
|
|
7236
7959
|
snapshot() {
|
|
7237
|
-
return structuredClone({
|
|
7238
|
-
rows: this.rows,
|
|
7239
|
-
executionTokensByRun: this.executionTokensByRun
|
|
7240
|
-
});
|
|
7960
|
+
return structuredClone({ rows: this.rows });
|
|
7241
7961
|
}
|
|
7242
7962
|
restore(snapshot) {
|
|
7243
7963
|
this.rows.clear();
|
|
7244
|
-
this.executionTokensByRun.clear();
|
|
7245
7964
|
for (const [key, record] of structuredClone(snapshot.rows))
|
|
7246
7965
|
this.rows.set(key, record);
|
|
7247
|
-
for (const [key, tokens] of structuredClone(snapshot.executionTokensByRun)) {
|
|
7248
|
-
this.executionTokensByRun.set(key, tokens);
|
|
7249
|
-
}
|
|
7250
7966
|
}
|
|
7251
7967
|
async queue(input) {
|
|
7252
7968
|
return this.runRootOperation(async () => {
|
|
@@ -7282,12 +7998,11 @@ class InMemoryProjectionRunStorage2 {
|
|
|
7282
7998
|
if (!existing)
|
|
7283
7999
|
throw projectionRunNotFound2(input.projectId, input.id);
|
|
7284
8000
|
const attempt = planProjectionRunReclaim2(existing, input).attempt;
|
|
7285
|
-
const executionToken = this.issueExecutionToken(key, input.id, existing.executionToken);
|
|
7286
8001
|
const record = {
|
|
7287
8002
|
...existing,
|
|
7288
8003
|
status: "running",
|
|
7289
8004
|
attempt,
|
|
7290
|
-
executionToken,
|
|
8005
|
+
executionToken: randomUUID(),
|
|
7291
8006
|
startedAt: existing.startedAt ?? new Date(input.startedAt ?? new Date),
|
|
7292
8007
|
finishedAt: undefined
|
|
7293
8008
|
};
|
|
@@ -7431,19 +8146,6 @@ class InMemoryProjectionRunStorage2 {
|
|
|
7431
8146
|
}
|
|
7432
8147
|
}
|
|
7433
8148
|
}
|
|
7434
|
-
issueExecutionToken(key, runId, currentToken) {
|
|
7435
|
-
const executionToken = this.createExecutionToken();
|
|
7436
|
-
assertProjectionRunNonEmpty2(executionToken, "executionToken");
|
|
7437
|
-
const usedTokens = this.executionTokensByRun.get(key) ?? new Set;
|
|
7438
|
-
if (currentToken)
|
|
7439
|
-
usedTokens.add(currentToken);
|
|
7440
|
-
if (usedTokens.has(executionToken)) {
|
|
7441
|
-
throw new ProjectionRunError2(`[Sixb] Projection run '${runId}' execution token was already used.`);
|
|
7442
|
-
}
|
|
7443
|
-
usedTokens.add(executionToken);
|
|
7444
|
-
this.executionTokensByRun.set(key, usedTokens);
|
|
7445
|
-
return executionToken;
|
|
7446
|
-
}
|
|
7447
8149
|
requireExecution(input) {
|
|
7448
8150
|
const record = this.requireRunning(input.projectId, input.id);
|
|
7449
8151
|
assertProjectionRunAttempt2(record, input);
|
|
@@ -7465,7 +8167,7 @@ class InMemoryProjectionRunStorage2 {
|
|
|
7465
8167
|
}
|
|
7466
8168
|
}
|
|
7467
8169
|
// src/storage/rules/in-memory.ts
|
|
7468
|
-
function
|
|
8170
|
+
function stateKey2(params) {
|
|
7469
8171
|
return JSON.stringify([
|
|
7470
8172
|
params.projectId,
|
|
7471
8173
|
params.ruleId,
|
|
@@ -7511,12 +8213,12 @@ class InMemoryRulesStorage2 {
|
|
|
7511
8213
|
}
|
|
7512
8214
|
}
|
|
7513
8215
|
async getActive(params) {
|
|
7514
|
-
const record = this.active.get(
|
|
8216
|
+
const record = this.active.get(stateKey2(params));
|
|
7515
8217
|
return record ? cloneRuleStateRecord(record) : null;
|
|
7516
8218
|
}
|
|
7517
8219
|
async getActiveBatch(params) {
|
|
7518
8220
|
return params.items.flatMap((item) => {
|
|
7519
|
-
const record = this.active.get(
|
|
8221
|
+
const record = this.active.get(stateKey2({ projectId: params.projectId, ...item }));
|
|
7520
8222
|
return record ? [cloneRuleStateRecord(record)] : [];
|
|
7521
8223
|
});
|
|
7522
8224
|
}
|
|
@@ -7559,10 +8261,10 @@ class InMemoryRulesStorage2 {
|
|
|
7559
8261
|
subject: structuredClone(event.payload.subject),
|
|
7560
8262
|
triggeredAt: event.payload.triggeredAt
|
|
7561
8263
|
};
|
|
7562
|
-
this.active.set(
|
|
8264
|
+
this.active.set(stateKey2(record), cloneRuleStateRecord(record));
|
|
7563
8265
|
}
|
|
7564
8266
|
async applyResolved(event) {
|
|
7565
|
-
this.active.delete(
|
|
8267
|
+
this.active.delete(stateKey2({
|
|
7566
8268
|
projectId: event.projectId,
|
|
7567
8269
|
ruleId: event.payload.ruleId,
|
|
7568
8270
|
subject: event.payload.subject
|
|
@@ -9042,6 +9744,96 @@ async function prepareObjectQueries2(input) {
|
|
|
9042
9744
|
return input.storage.prepareObjectQueries({ projectId: input.projectId, objectTypes });
|
|
9043
9745
|
}
|
|
9044
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
|
+
|
|
9045
9837
|
// src/storage/migrations/migrate-storage.ts
|
|
9046
9838
|
function isMigrationCapableStorage2(storage) {
|
|
9047
9839
|
return Array.isArray(storage.migrators);
|
|
@@ -9060,6 +9852,8 @@ async function migrateStorage2(storage, options) {
|
|
|
9060
9852
|
console.warn(`[Sixb] ${warning}`);
|
|
9061
9853
|
}
|
|
9062
9854
|
}
|
|
9855
|
+
if (options)
|
|
9856
|
+
await prepareUniqueProperties({ ...options, storage });
|
|
9063
9857
|
let status = "skipped";
|
|
9064
9858
|
if (reports.length > 0 || queries) {
|
|
9065
9859
|
status = "current";
|
|
@@ -9270,6 +10064,6 @@ var VECTOR_INDEXING_FAILURE_CODES2 = [
|
|
|
9270
10064
|
"vector.outcome_unknown",
|
|
9271
10065
|
"internal.unexpected"
|
|
9272
10066
|
];
|
|
9273
|
-
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 };
|
|
9274
10068
|
|
|
9275
|
-
//# debugId=
|
|
10069
|
+
//# debugId=80206110A1AC9B8564756E2164756E21
|