@camstack/server 1.2.928 → 1.2.929
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/CHANGELOG.md +6 -0
- package/package.json +10 -8
- package/system/dist/addon-id-CVg1_r5E.mjs +39 -0
- package/system/dist/addon-id-Di0lNJ89.js +50 -0
- package/system/dist/addon-pages.cap-Df9FQwN1.js +49 -0
- package/system/dist/addon-pages.cap-DksUlE8j.mjs +44 -0
- package/system/dist/addon-settings.cap-3-TIIMq_.mjs +592 -0
- package/system/dist/addon-settings.cap-DAiE0Nb0.js +651 -0
- package/system/dist/addon-utils.mjs +1 -1
- package/system/dist/addon-widgets.cap-C4jxflbF.js +200 -0
- package/system/dist/addon-widgets.cap-D9m48X78.mjs +183 -0
- package/system/dist/base-addon-DD5dIfcZ.js +4624 -0
- package/system/dist/base-addon-Md14i7pe.mjs +4505 -0
- package/system/dist/base-device-2sL1DMm1.js +1103 -0
- package/system/dist/base-device-IuM1AwXZ.mjs +1098 -0
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +8 -6
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +6 -4
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +8 -6
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +7 -5
- package/system/dist/builtins/alerts/alerts.addon.js +113 -56
- package/system/dist/builtins/alerts/alerts.addon.mjs +60 -3
- package/system/dist/builtins/autotrack/index.js +21 -17
- package/system/dist/builtins/autotrack/index.mjs +5 -1
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +14 -11
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +8 -5
- package/system/dist/builtins/calendars/calendars.addon.js +8 -6
- package/system/dist/builtins/calendars/calendars.addon.mjs +3 -1
- package/system/dist/builtins/camera-grid/index.js +615 -58
- package/system/dist/builtins/camera-grid/index.mjs +558 -1
- package/system/dist/builtins/composer/composer.addon.js +788 -209
- package/system/dist/builtins/composer/composer.addon.mjs +583 -4
- package/system/dist/builtins/console-logging/index.js +4 -3
- package/system/dist/builtins/console-logging/index.mjs +2 -1
- package/system/dist/builtins/core-blocks/core-blocks.addon.js +7887 -381
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +7511 -5
- package/system/dist/builtins/core-notifier/core-notifier.addon.js +731 -21
- package/system/dist/builtins/core-notifier/core-notifier.addon.mjs +711 -1
- package/system/dist/builtins/device-history/device-history.addon.js +110 -31
- package/system/dist/builtins/device-history/device-history.addon.mjs +81 -2
- package/system/dist/builtins/device-manager/device-manager.addon.js +12806 -227
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +12583 -5
- package/system/dist/builtins/hub-forwarder/index.js +4 -3
- package/system/dist/builtins/hub-forwarder/index.mjs +2 -1
- package/system/dist/builtins/keychain/index.js +31 -28
- package/system/dist/builtins/keychain/index.mjs +7 -4
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +15 -12
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +4 -1
- package/system/dist/builtins/local-auth/local-auth.addon.js +140 -39
- package/system/dist/builtins/local-auth/local-auth.addon.mjs +106 -6
- package/system/dist/builtins/local-network/local-network.addon.js +43 -39
- package/system/dist/builtins/local-network/local-network.addon.mjs +7 -3
- package/system/dist/builtins/loki-logging/index.js +23 -17
- package/system/dist/builtins/loki-logging/index.mjs +7 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.js +156 -15
- package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +151 -10
- package/system/dist/builtins/platform-probe/index.js +25 -23
- package/system/dist/builtins/platform-probe/index.mjs +12 -10
- package/system/dist/builtins/record-entries/index.js +9 -7
- package/system/dist/builtins/record-entries/index.mjs +3 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +4 -4
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/snapshot/index.js +97 -44
- package/system/dist/builtins/snapshot/index.mjs +54 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +5 -4
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +21 -20
- package/system/dist/builtins/sqlite-storage/index.js +1 -1
- package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +87 -61
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +29 -3
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +81 -72
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +10 -1
- package/system/dist/builtins/system-config/system-config.addon.js +17 -14
- package/system/dist/builtins/system-config/system-config.addon.mjs +118 -115
- package/system/dist/builtins/winston-logging/index.js +7 -5
- package/system/dist/builtins/winston-logging/index.mjs +3 -1
- package/system/dist/calendars.cap-CaFlShS9.js +155 -0
- package/system/dist/calendars.cap-_C4eD4fi.mjs +138 -0
- package/system/dist/camstack-error-DJ-TUAi1.js +23 -0
- package/system/dist/camstack-error-viZYfcj9.mjs +18 -0
- package/system/dist/cap-call-context-Bd76CbOW.js +95 -0
- package/system/dist/cap-call-context-DNwdgGSQ.mjs +78 -0
- package/system/dist/capability-definition-C2rJdVeX.mjs +177 -0
- package/system/dist/capability-definition-HCmTem8c.js +242 -0
- package/system/dist/{capture-engine-BcuwOSXv.js → capture-engine-DZ0LIUqA.js} +5 -4
- package/system/dist/{capture-engine-Bz7eXFjT.mjs → capture-engine-DiwbjoWp.mjs} +2 -1
- package/system/dist/command-origin-claim-Cief660O.js +35 -0
- package/system/dist/command-origin-claim-D1Wy7Qld.mjs +24 -0
- package/system/dist/composition-sources-Caqv7O7z.mjs +391 -0
- package/system/dist/composition-sources-CgnHjm8Q.js +408 -0
- package/system/dist/{constants-D2etJ02O.js → constants-Ba3FTIHl.js} +1 -1
- package/system/dist/constants-C860Y6U4.js +26 -0
- package/system/dist/{constants-BcUTQd1M.mjs → constants-DB4piTD5.mjs} +1 -1
- package/system/dist/constants-DCLpoF4L.mjs +21 -0
- package/system/dist/coral-accelerators-7o8hqvcN.js +564 -0
- package/system/dist/coral-accelerators-BKcXP59c.mjs +521 -0
- package/system/dist/core-blocks.cap-C6iKAZ-x.mjs +17986 -0
- package/system/dist/core-blocks.cap-LEMqVwxO.js +18705 -0
- package/system/dist/{custom-action-registry-N7flBDwT.mjs → custom-action-registry-B9zFBNVa.mjs} +37 -37
- package/system/dist/custom-actions-BFUSalC9.mjs +25 -0
- package/system/dist/custom-actions-D92NRi2c.js +36 -0
- package/system/dist/database-snapshot.cap-DF38e-0P.js +162 -0
- package/system/dist/database-snapshot.cap-dhrc9xnY.mjs +133 -0
- package/system/dist/declared-device-BWphj9WE.js +303 -0
- package/system/dist/declared-device-CKERA1Hi.mjs +286 -0
- package/system/dist/{device-ca-ExMN3xW3.mjs → device-ca-BLM6fccc.mjs} +2 -1
- package/system/dist/{device-ca-CU8zh9Pi.js → device-ca-C5kJE6mL.js} +7 -6
- package/system/dist/device-certificate-Cddm4Idn.mjs +91 -0
- package/system/dist/device-certificate-CguVACQO.js +162 -0
- package/system/dist/device-identifiers-BQg9EQi1.js +600 -0
- package/system/dist/device-identifiers-iSuQCKmK.mjs +529 -0
- package/system/dist/device-kind-BJ2pfsjw.mjs +78 -0
- package/system/dist/device-kind-CsSiv_YF.js +101 -0
- package/system/dist/device-manager.cap-2abwVLCM.js +2874 -0
- package/system/dist/device-manager.cap-CFZSPfUh.mjs +2749 -0
- package/system/dist/device-provider.cap-3Uvk6f5-.mjs +331 -0
- package/system/dist/device-provider.cap-D7TV2kVH.js +366 -0
- package/system/dist/{device-row-store-CeW_GWh9.mjs → device-row-store-YF3jtmkk.mjs} +4 -1
- package/system/dist/{device-row-store-BMIR-n3m.js → device-row-store-doTfMOqn.js} +12 -9
- package/system/dist/device-transitions.cap-B5w5PYU_.js +860 -0
- package/system/dist/device-transitions.cap-DojcwEuX.mjs +819 -0
- package/system/dist/device-type-CbQsnFdC.js +477 -0
- package/system/dist/device-type-DgEvK3ch.mjs +454 -0
- package/system/dist/entry-kind-D9MuVJCK.mjs +44 -0
- package/system/dist/entry-kind-cq90c--V.js +55 -0
- package/system/dist/error.cap-CSM_SRfR.mjs +3423 -0
- package/system/dist/error.cap-DBhgPeWK.js +3848 -0
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/history-catalog-BKRarIL_.js +831 -0
- package/system/dist/history-catalog-BwTeQ4Mr.mjs +802 -0
- package/system/dist/{hub-identity-Csxx2Q8k.js → hub-identity-BMdR3Mw9.js} +2 -2
- package/system/dist/{hub-identity-CYC1820R.mjs → hub-identity-DjMN9Ac2.mjs} +10 -10
- package/system/dist/{hub-mdns-ciao-By5577HM.js → hub-mdns-ciao--0v1TKME.js} +5 -5
- package/system/dist/{hub-mdns-ciao-CCDxM5qz.mjs → hub-mdns-ciao-DBrtHOcc.mjs} +2 -2
- package/system/dist/index.js +763 -151
- package/system/dist/index.mjs +832 -220
- package/system/dist/integration-instances.cap-Cl9O-k4h.mjs +538 -0
- package/system/dist/integration-instances.cap-dJIxg2_s.js +549 -0
- package/system/dist/keychain-admin.cap-Db_oFX4H.js +425 -0
- package/system/dist/keychain-admin.cap-GtM7gVGG.mjs +396 -0
- package/system/dist/l10n-Bu6aUvSY.mjs +10 -0
- package/system/dist/l10n-CGMvp7NF.js +15 -0
- package/system/dist/labels-DX5S8deC.js +81 -0
- package/system/dist/labels-DsBcU7md.mjs +64 -0
- package/system/dist/{legacy-integration-rows-door-CVwOo5aq.js → legacy-integration-rows-door-B1nzxxr5.js} +2 -2
- package/system/dist/{legacy-integration-rows-door-D9tQOUzh.mjs → legacy-integration-rows-door-nTvo_6jQ.mjs} +1 -1
- package/system/dist/log-destination.cap-CxZzAVaR.mjs +143 -0
- package/system/dist/log-destination.cap-DELPJkZ0.js +148 -0
- package/system/dist/low-power-sleep.cap-7lfVU41N.js +103 -0
- package/system/dist/low-power-sleep.cap-tGPmaZ_V.mjs +92 -0
- package/system/dist/mask-shape-Ci8Co9w0.mjs +57 -0
- package/system/dist/mask-shape-CmPA2fst.js +92 -0
- package/system/dist/metrics-provider.cap-BNmcHDkQ.mjs +405 -0
- package/system/dist/metrics-provider.cap-BcmQUt6l.js +410 -0
- package/system/dist/migration-BMjgkyG2.js +380 -0
- package/system/dist/migration-DRJAtdy7.mjs +321 -0
- package/system/dist/network-access.cap-B5TWLDCC.js +1099 -0
- package/system/dist/network-access.cap-BJnGbE6n.mjs +1004 -0
- package/system/dist/notification-rules.cap-B__YBgnG.js +3422 -0
- package/system/dist/notification-rules.cap-D9ArZlwx.mjs +3357 -0
- package/system/dist/ops-log-CB4pIdqi.mjs +64 -0
- package/system/dist/ops-log-pxt9176Z.js +81 -0
- package/system/dist/pinned-binary-BOhOSNff.js +28 -0
- package/system/dist/pinned-binary-CrIRAi4G.mjs +23 -0
- package/system/dist/platform-probe.cap-1WrMhWHx.js +250 -0
- package/system/dist/platform-probe.cap-BFeqFLtQ.mjs +233 -0
- package/system/dist/prefix-walk-B4b2-9aK.mjs +790 -0
- package/system/dist/prefix-walk-DC0ljmbB.js +843 -0
- package/system/dist/ptz-autotrack.cap-BW7w0zHD.js +229 -0
- package/system/dist/ptz-autotrack.cap-DT2GypXw.mjs +224 -0
- package/system/dist/quantity-D3g5SxsZ.mjs +114 -0
- package/system/dist/quantity-lY1KiTSZ.js +143 -0
- package/system/dist/raw-secret-migration-DxuBFtvi.js +50 -0
- package/system/dist/raw-secret-migration-iv88mLoc.mjs +39 -0
- package/system/dist/record-entries.cap-sMUhTvTU.mjs +75 -0
- package/system/dist/record-entries.cap-ti1C046R.js +80 -0
- package/system/dist/record-kind-DoBfYHCs.js +203 -0
- package/system/dist/record-kind-ub6NXqfh.mjs +162 -0
- package/system/dist/recording-archive.cap-7OrIn9e5.mjs +1299 -0
- package/system/dist/recording-archive.cap-D7bo-QSM.js +1328 -0
- package/system/dist/records.cap-ClcWV64i.js +329 -0
- package/system/dist/records.cap-CwLT2ByG.mjs +294 -0
- package/system/dist/relocate-CdVQAk-w.js +804 -0
- package/system/dist/relocate-CoZZTui1.mjs +661 -0
- package/system/dist/rename-composition-block-7WIICIDq.mjs +33525 -0
- package/system/dist/rename-composition-block-CcWLwVhG.js +34692 -0
- package/system/dist/{restore-archive-BJfyu0sG.mjs → restore-archive-CjAyKpgX.mjs} +96 -94
- package/system/dist/{restore-archive-CIFvqOze.js → restore-archive-CkTkv3Ss.js} +6 -4
- package/system/dist/scoped-settings-CylSSq_8.js +955 -0
- package/system/dist/scoped-settings-DVWUIP7Z.mjs +650 -0
- package/system/dist/server-name-BIhLuHvX.mjs +35 -0
- package/system/dist/server-name-OALNvpqC.js +52 -0
- package/system/dist/settings-store.cap-Ci4F2zul.mjs +569 -0
- package/system/dist/settings-store.cap-wlJhCspr.js +640 -0
- package/system/dist/snapshot.cap-3suPdBHV.js +250 -0
- package/system/dist/snapshot.cap-Bs8Oyaqh.mjs +245 -0
- package/system/dist/source-info-DGB7SdB_.mjs +190 -0
- package/system/dist/source-info-DtWf4k2j.js +225 -0
- package/system/dist/storage-admin.cap-BSv1NjKJ.mjs +883 -0
- package/system/dist/storage-admin.cap-he0OqvVM.js +906 -0
- package/system/dist/storage-location-CBT8GCD6.mjs +163 -0
- package/system/dist/storage-location-CTweDMZf.js +198 -0
- package/system/dist/storage-location-mode-B21UVRRX.mjs +167 -0
- package/system/dist/storage-location-mode-CS4sMzo-.js +232 -0
- package/system/dist/storage-migration.cap-CyyATY_p.js +330 -0
- package/system/dist/storage-migration.cap-D7QqGobp.mjs +313 -0
- package/system/dist/storage-occupancy.cap-2rmnS58Z.js +622 -0
- package/system/dist/storage-occupancy.cap-CqBztTl9.mjs +611 -0
- package/system/dist/storage-provider.cap-Bw0CfxVc.js +213 -0
- package/system/dist/storage-provider.cap-CMeck2w4.mjs +202 -0
- package/system/dist/stream-catalog.cap-Bp7SkgIf.mjs +6560 -0
- package/system/dist/stream-catalog.cap-D3uwePiA.js +6763 -0
- package/system/dist/streaming-shared-B8cXatuU.mjs +431 -0
- package/system/dist/streaming-shared-DQwFZOSi.js +526 -0
- package/system/dist/system-reasons-Be_k1W8g.js +25 -0
- package/system/dist/system-reasons-CYj4qwyS.mjs +20 -0
- package/system/dist/tag-BxLazvVb.js +2138 -0
- package/system/dist/tag-uZBAq6ox.mjs +2073 -0
- package/system/dist/user-management.cap-B9QDu8NE.js +825 -0
- package/system/dist/user-management.cap-DBIi77sB.mjs +766 -0
- package/system/dist/vector-store.cap-DnyfrYDn.js +330 -0
- package/system/dist/vector-store.cap-h2GHWQ1t.mjs +319 -0
- package/system/dist/{wal-maintenance-CTrCPzds.mjs → wal-maintenance-BG01rOn9.mjs} +0 -0
- package/system/dist/{wal-maintenance-dq7T3quB.js → wal-maintenance-DyrebYKF.js} +0 -0
- package/system/dist/zod-secret-DS7mj1bk.js +78 -0
- package/system/dist/zod-secret-zY4nM61M.mjs +73 -0
- package/system/package.json +1 -1
- package/system/dist/composition-sources-BI614LJx.mjs +0 -141
- package/system/dist/composition-sources-v_kkb8A9.js +0 -152
- package/system/dist/coral-accelerators-BSVsBVzt.js +0 -250
- package/system/dist/coral-accelerators-BW3OcrLD.mjs +0 -231
- package/system/dist/dist-BCHMSqzc.mjs +0 -143467
- package/system/dist/dist-BZfvhfS1.js +0 -146970
- package/system/dist/prefix-walk-DAOBSyH1.mjs +0 -88
- package/system/dist/prefix-walk-Dv6MLZlM.js +0 -99
- package/system/dist/rename-composition-block-C9HuBrKS.js +0 -112
- package/system/dist/rename-composition-block-DtaYmYAR.mjs +0 -101
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
const require_capability_definition = require("./capability-definition-HCmTem8c.js");
|
|
2
|
+
const require_system_reasons = require("./system-reasons-Be_k1W8g.js");
|
|
3
|
+
let zod = require("zod");
|
|
4
|
+
//#region ../types/dist/esm/capabilities/vector-store.cap.mjs
|
|
5
|
+
/**
|
|
6
|
+
* vector-store — the dedicated home for embedding vectors and similarity search.
|
|
7
|
+
*
|
|
8
|
+
* ## Why this is a capability and not a helper
|
|
9
|
+
*
|
|
10
|
+
* This capability was introduced with the claim that SIX stores in
|
|
11
|
+
* `addon-post-analysis` held vectors in a `JSON` settings-store column — object
|
|
12
|
+
* CLIP, face, plate, vehicle, identity, and the event store's derivatives. That
|
|
13
|
+
* claim was never true, and leaving it here made five stores look like pending
|
|
14
|
+
* work when three of them have no vector at all. Counted column by column on
|
|
15
|
+
* 2026-08-30, exactly THREE ever held one:
|
|
16
|
+
*
|
|
17
|
+
* - `object-clip` — 512-dim CLIP image embedding, migrated 2026-08-06.
|
|
18
|
+
* - `faces.embedding` — 512-dim ArcFace face embedding, migrated 2026-08-30.
|
|
19
|
+
* - `identity-samples.embedding` — the same ArcFace vector for an ENROLLED
|
|
20
|
+
* face, migrated 2026-08-30 into its OWN index (see below).
|
|
21
|
+
*
|
|
22
|
+
* `plates` and `vehicle-samples` store a plate STRING and a score; `vehicles`
|
|
23
|
+
* and `identities` store a name; the event store stores no derivative vector.
|
|
24
|
+
* They are not migration candidates and never were.
|
|
25
|
+
*
|
|
26
|
+
* Measured on the live hub the JSON encoding cost ~11.7 KB per row (512 floats
|
|
27
|
+
* as TEXT, `JSON.parse`d on every search) and made semantic search load 5,000
|
|
28
|
+
* rows before ranking anything.
|
|
29
|
+
*
|
|
30
|
+
* ## One index per COMPARISON, never per encoder
|
|
31
|
+
*
|
|
32
|
+
* `faces` and `identity-samples` hold the same 512 ArcFace dims from the same
|
|
33
|
+
* model, and they still get two indexes. An index is a set of things that are
|
|
34
|
+
* ranked against each other and that live and die together, and these two are
|
|
35
|
+
* neither: a `faces` row is TRACK-OWNED and cascades away with its track under
|
|
36
|
+
* a per-camera capacity cap, an `identity-samples` row is retention-EXEMPT
|
|
37
|
+
* forever and is the gallery every recognition ranks against. One index would
|
|
38
|
+
* mean every gallery load and every reconcile carried a filter whose failure
|
|
39
|
+
* mode is either ranking a candidate against itself or reclaiming an enrolled
|
|
40
|
+
* person's only sample. The dimension they share is not a reason to share an
|
|
41
|
+
* index; the question they answer is, and it differs.
|
|
42
|
+
*
|
|
43
|
+
* The fix is not a faster loop, it is a different backend — and the backend
|
|
44
|
+
* should be replaceable without touching six callers. So: a singleton
|
|
45
|
+
* capability. The provider shipped today is SQLite-backed brute force over
|
|
46
|
+
* COMPACT rows; an ANN index (sqlite-vec, usearch, …) can replace it later by
|
|
47
|
+
* registering a different provider and `setActiveSingleton`, with no caller
|
|
48
|
+
* change. That is the whole point of putting it here.
|
|
49
|
+
*
|
|
50
|
+
* ## Wire format: base64, deliberately
|
|
51
|
+
*
|
|
52
|
+
* `vector` is base64 of little-endian Float32 — NOT `number[]`, and NOT a
|
|
53
|
+
* `Float32Array`. Both alternatives have already cost this repo:
|
|
54
|
+
* a `Float32Array` does not survive msgpack across the UDS transport (it arrived
|
|
55
|
+
* as an empty object and froze audio dBFS), and `number[]` is the ~5x-larger
|
|
56
|
+
* encoding this capability exists to stop paying. A 512-dim vector is 2,048
|
|
57
|
+
* bytes raw, 2,732 as base64, against ~10-12 KB as JSON text.
|
|
58
|
+
*
|
|
59
|
+
* Helpers for both directions live in `@camstack/types` —
|
|
60
|
+
* `encodeVectorBase64` / `decodeVectorBase64` — so no caller hand-rolls the
|
|
61
|
+
* byte order.
|
|
62
|
+
*/
|
|
63
|
+
/** Similarity metric an index ranks by. */
|
|
64
|
+
var VectorMetricSchema = /* @__PURE__ */ zod.z.enum([
|
|
65
|
+
"cosine",
|
|
66
|
+
"dot",
|
|
67
|
+
"euclidean"
|
|
68
|
+
]);
|
|
69
|
+
/**
|
|
70
|
+
* Scalar metadata carried alongside a vector.
|
|
71
|
+
*
|
|
72
|
+
* Deliberately flat and scalar: it is what {@link VectorFilterSchema} can filter
|
|
73
|
+
* on, and a nested object cannot be indexed by any backend worth swapping in.
|
|
74
|
+
* Callers keep their rich records in their own store and put only the filterable
|
|
75
|
+
* columns here (deviceId, timestamp, className, modelId, …).
|
|
76
|
+
*/
|
|
77
|
+
var VectorMetadataSchema = /* @__PURE__ */ zod.z.record(/* @__PURE__ */ zod.z.string(), /* @__PURE__ */ zod.z.union([
|
|
78
|
+
/* @__PURE__ */ zod.z.string(),
|
|
79
|
+
/* @__PURE__ */ zod.z.number(),
|
|
80
|
+
/* @__PURE__ */ zod.z.boolean()
|
|
81
|
+
]));
|
|
82
|
+
/**
|
|
83
|
+
* Prefilter applied BEFORE ranking.
|
|
84
|
+
*
|
|
85
|
+
* `equals` and `between` are ANDed. A backend that cannot push a clause down
|
|
86
|
+
* must still apply it — a filter that is silently ignored returns results the
|
|
87
|
+
* caller will treat as matches.
|
|
88
|
+
*/
|
|
89
|
+
var VectorFilterSchema = /* @__PURE__ */ zod.z.object({
|
|
90
|
+
equals: /* @__PURE__ */ zod.z.record(/* @__PURE__ */ zod.z.string(), /* @__PURE__ */ zod.z.union([
|
|
91
|
+
/* @__PURE__ */ zod.z.string(),
|
|
92
|
+
/* @__PURE__ */ zod.z.number(),
|
|
93
|
+
/* @__PURE__ */ zod.z.boolean()
|
|
94
|
+
])).optional(),
|
|
95
|
+
between: /* @__PURE__ */ zod.z.record(/* @__PURE__ */ zod.z.string(), /* @__PURE__ */ zod.z.tuple([/* @__PURE__ */ zod.z.number(), /* @__PURE__ */ zod.z.number()])).optional()
|
|
96
|
+
});
|
|
97
|
+
/** One vector plus its identity and filterable metadata. */
|
|
98
|
+
var VectorItemSchema = /* @__PURE__ */ zod.z.object({
|
|
99
|
+
/** Caller-owned primary key. Upsert replaces the row with this id. */
|
|
100
|
+
id: /* @__PURE__ */ zod.z.string(),
|
|
101
|
+
/** base64 of little-endian Float32. See the module docblock. */
|
|
102
|
+
vector: /* @__PURE__ */ zod.z.string(),
|
|
103
|
+
metadata: VectorMetadataSchema
|
|
104
|
+
});
|
|
105
|
+
/** A ranked hit. */
|
|
106
|
+
var VectorMatchSchema = /* @__PURE__ */ zod.z.object({
|
|
107
|
+
id: /* @__PURE__ */ zod.z.string(),
|
|
108
|
+
/** Similarity under the index's metric; higher is nearer for cosine/dot. */
|
|
109
|
+
score: /* @__PURE__ */ zod.z.number(),
|
|
110
|
+
metadata: VectorMetadataSchema
|
|
111
|
+
});
|
|
112
|
+
var VectorDeclareIndexInputSchema = /* @__PURE__ */ zod.z.object({
|
|
113
|
+
index: /* @__PURE__ */ zod.z.string(),
|
|
114
|
+
/** Vector length. An item of a different length is rejected, not coerced. */
|
|
115
|
+
dim: /* @__PURE__ */ zod.z.number().int().positive(),
|
|
116
|
+
metric: /* @__PURE__ */ VectorMetricSchema.default("cosine")
|
|
117
|
+
});
|
|
118
|
+
var VectorUpsertInputSchema = /* @__PURE__ */ zod.z.object({
|
|
119
|
+
index: /* @__PURE__ */ zod.z.string(),
|
|
120
|
+
items: /* @__PURE__ */ zod.z.array(VectorItemSchema)
|
|
121
|
+
});
|
|
122
|
+
var VectorUpsertResultSchema = /* @__PURE__ */ zod.z.object({
|
|
123
|
+
upserted: /* @__PURE__ */ zod.z.number(),
|
|
124
|
+
/** Items refused for a dim mismatch. Never silent — see D-rule on dropped work. */
|
|
125
|
+
rejected: /* @__PURE__ */ zod.z.number()
|
|
126
|
+
});
|
|
127
|
+
var VectorQueryInputSchema = /* @__PURE__ */ zod.z.object({
|
|
128
|
+
index: /* @__PURE__ */ zod.z.string(),
|
|
129
|
+
/** base64 Float32LE query vector. */
|
|
130
|
+
vector: /* @__PURE__ */ zod.z.string(),
|
|
131
|
+
topK: /* @__PURE__ */ zod.z.number().int().positive(),
|
|
132
|
+
/** Drop matches scoring below this. */
|
|
133
|
+
minScore: /* @__PURE__ */ zod.z.number().optional(),
|
|
134
|
+
filter: /* @__PURE__ */ VectorFilterSchema.optional()
|
|
135
|
+
});
|
|
136
|
+
var VectorQueryResultSchema = /* @__PURE__ */ zod.z.object({
|
|
137
|
+
matches: /* @__PURE__ */ zod.z.array(VectorMatchSchema),
|
|
138
|
+
/**
|
|
139
|
+
* Rows the backend actually compared. When this equals the index size the
|
|
140
|
+
* search was exhaustive; when it is lower the backend approximated or
|
|
141
|
+
* truncated, and the caller can say so instead of reporting "nothing older
|
|
142
|
+
* matched".
|
|
143
|
+
*/
|
|
144
|
+
scanned: /* @__PURE__ */ zod.z.number(),
|
|
145
|
+
/** True when the backend could not consider every row that passed the filter. */
|
|
146
|
+
truncated: /* @__PURE__ */ zod.z.boolean(),
|
|
147
|
+
/**
|
|
148
|
+
* The `topK` the backend actually ran with.
|
|
149
|
+
*
|
|
150
|
+
* Every backend has a ceiling — sqlite-vec's is 4,096 — and a caller asking
|
|
151
|
+
* past it used to learn nothing but a boolean, from a WARN in the provider's
|
|
152
|
+
* own log rather than in its answer. That is how an audit asking for 20,000
|
|
153
|
+
* consumed 4,096 and reported `examined: 4096` as if it had walked the index,
|
|
154
|
+
* for weeks. `truncated` says THAT the answer was short; this says BY HOW
|
|
155
|
+
* MUCH, in the return value, where the caller cannot fail to see it.
|
|
156
|
+
*
|
|
157
|
+
* Equals the requested `topK` whenever nothing was lowered.
|
|
158
|
+
*/
|
|
159
|
+
effectiveTopK: /* @__PURE__ */ zod.z.number().int().positive()
|
|
160
|
+
});
|
|
161
|
+
var VectorDeleteInputSchema = /* @__PURE__ */ zod.z.object({
|
|
162
|
+
index: /* @__PURE__ */ zod.z.string(),
|
|
163
|
+
ids: /* @__PURE__ */ zod.z.array(/* @__PURE__ */ zod.z.string())
|
|
164
|
+
});
|
|
165
|
+
var VectorDeleteByFilterInputSchema = /* @__PURE__ */ zod.z.object({
|
|
166
|
+
index: /* @__PURE__ */ zod.z.string(),
|
|
167
|
+
filter: VectorFilterSchema
|
|
168
|
+
});
|
|
169
|
+
var VectorDeleteResultSchema = /* @__PURE__ */ zod.z.object({ deleted: /* @__PURE__ */ zod.z.number() });
|
|
170
|
+
var VectorGetInputSchema = /* @__PURE__ */ zod.z.object({
|
|
171
|
+
index: /* @__PURE__ */ zod.z.string(),
|
|
172
|
+
ids: /* @__PURE__ */ zod.z.array(/* @__PURE__ */ zod.z.string())
|
|
173
|
+
});
|
|
174
|
+
/**
|
|
175
|
+
* Metadata for the requested ids, WITHOUT their vectors.
|
|
176
|
+
*
|
|
177
|
+
* The only caller is a best-of gate that compares a candidate's confidence
|
|
178
|
+
* against the stored one, and shipping 512 floats back to answer "is 0.91 >
|
|
179
|
+
* 0.87" would undo the point of the compact encoding. Ids with no row are
|
|
180
|
+
* simply absent — a caller distinguishing "not stored" from "stored" reads the
|
|
181
|
+
* length, and a null placeholder would invite a `?? 0` that treats a missing
|
|
182
|
+
* row as confidence zero.
|
|
183
|
+
*/
|
|
184
|
+
var VectorGetResultSchema = /* @__PURE__ */ zod.z.object({ items: /* @__PURE__ */ zod.z.array(/* @__PURE__ */ zod.z.object({
|
|
185
|
+
id: /* @__PURE__ */ zod.z.string(),
|
|
186
|
+
metadata: VectorMetadataSchema
|
|
187
|
+
})) });
|
|
188
|
+
/**
|
|
189
|
+
* Ids to read back WITH their vectors.
|
|
190
|
+
*
|
|
191
|
+
* The sibling of {@link VectorGetResultSchema}, and deliberately a separate
|
|
192
|
+
* method rather than a flag on it: `getByIds` promises no vectors and its one
|
|
193
|
+
* caller depends on that promise. This one promises the opposite.
|
|
194
|
+
*
|
|
195
|
+
* It exists because a store cannot put its vectors here otherwise. An ArcFace
|
|
196
|
+
* gallery is ranked IN PROCESS, per detection, against every enrolled sample —
|
|
197
|
+
* a per-face cross-process KNN would be a network round trip inside the
|
|
198
|
+
* recognition loop. So the gallery is loaded once and held in RAM, and loading
|
|
199
|
+
* it requires the index to hand the floats back. Without this method the only
|
|
200
|
+
* way to keep a readable vector is a JSON column, which is the thing this
|
|
201
|
+
* capability exists to delete.
|
|
202
|
+
*
|
|
203
|
+
* BOUNDED BY THE CALLER: ids are named, never "everything". Enumerating an
|
|
204
|
+
* index is {@link VectorScanInputSchema}'s job, and it returns no vectors.
|
|
205
|
+
*/
|
|
206
|
+
var VectorFetchInputSchema = /* @__PURE__ */ zod.z.object({
|
|
207
|
+
index: /* @__PURE__ */ zod.z.string(),
|
|
208
|
+
ids: /* @__PURE__ */ zod.z.array(/* @__PURE__ */ zod.z.string())
|
|
209
|
+
});
|
|
210
|
+
var VectorFetchResultSchema = /* @__PURE__ */ zod.z.object({ items: /* @__PURE__ */ zod.z.array(/* @__PURE__ */ zod.z.object({
|
|
211
|
+
id: /* @__PURE__ */ zod.z.string(),
|
|
212
|
+
/** base64 Float32LE — the same wire form `upsert` accepts. */
|
|
213
|
+
vector: /* @__PURE__ */ zod.z.string(),
|
|
214
|
+
metadata: VectorMetadataSchema
|
|
215
|
+
})) });
|
|
216
|
+
/**
|
|
217
|
+
* ENUMERATE an index: one page of rows in a stable order, no ranking.
|
|
218
|
+
*
|
|
219
|
+
* A reconcile does not want the nearest rows, it wants ALL of them, and asking
|
|
220
|
+
* a KNN for "all" is the wrong question twice over. It hits the backend's `k`
|
|
221
|
+
* ceiling — 4,096 on sqlite-vec against a 22,128-row index — and it needs a
|
|
222
|
+
* probe vector it does not have, so the audit passed a ZERO vector whose cosine
|
|
223
|
+
* distance to every row is degenerate. `examined: 4096` then read as "we
|
|
224
|
+
* looked" for as long as anyone cared to read it.
|
|
225
|
+
*
|
|
226
|
+
* This is the primitive that question actually needs: a bounded page, ordered
|
|
227
|
+
* by the backend's own row order, costing no distance computation at all.
|
|
228
|
+
* Vectors are NOT returned — an enumeration that shipped 2 KB per row would be
|
|
229
|
+
* the full-table read this capability was built to stop.
|
|
230
|
+
*/
|
|
231
|
+
var VectorScanInputSchema = /* @__PURE__ */ zod.z.object({
|
|
232
|
+
index: /* @__PURE__ */ zod.z.string(),
|
|
233
|
+
/** Opaque resume point. `0` starts at the top; pass back `nextCursor`. */
|
|
234
|
+
cursor: /* @__PURE__ */ zod.z.number().int().nonnegative().default(0),
|
|
235
|
+
limit: /* @__PURE__ */ zod.z.number().int().positive()
|
|
236
|
+
});
|
|
237
|
+
var VectorScanResultSchema = /* @__PURE__ */ zod.z.object({
|
|
238
|
+
items: /* @__PURE__ */ zod.z.array(/* @__PURE__ */ zod.z.object({
|
|
239
|
+
id: /* @__PURE__ */ zod.z.string(),
|
|
240
|
+
metadata: VectorMetadataSchema
|
|
241
|
+
})),
|
|
242
|
+
/**
|
|
243
|
+
* Where the next page starts, or `null` when the walk reached the end.
|
|
244
|
+
*
|
|
245
|
+
* `null` is the ONLY end-of-index signal. A caller must not infer the end
|
|
246
|
+
* from a short page: a backend is free to return fewer rows than asked.
|
|
247
|
+
*/
|
|
248
|
+
nextCursor: /* @__PURE__ */ zod.z.number().int().nonnegative().nullable()
|
|
249
|
+
});
|
|
250
|
+
/**
|
|
251
|
+
* The ONE error code for "this index exists at another dimension; refusing to
|
|
252
|
+
* redeclare it" (D649). It rides in the MESSAGE — an Error's own properties do
|
|
253
|
+
* not survive the UDS/tRPC hop, its message does — and both sides go through
|
|
254
|
+
* the helpers below, never a copied phrase: a consumer that must tell "this
|
|
255
|
+
* index can never hold my vectors" from "the provider is unreachable" (a
|
|
256
|
+
* delete counts the first as nothing-to-delete and the second as still
|
|
257
|
+
* present) otherwise breaks silently the day the wording changes.
|
|
258
|
+
*/
|
|
259
|
+
var VECTOR_INDEX_DIM_CONFLICT = "vector-index-dim-conflict";
|
|
260
|
+
/** The provider's refusal, carrying {@link VECTOR_INDEX_DIM_CONFLICT}. */
|
|
261
|
+
function vectorIndexDimConflictError(index, declaredDim, requestedDim) {
|
|
262
|
+
return /* @__PURE__ */ new Error(`[${VECTOR_INDEX_DIM_CONFLICT}] vector-store: index "${index}" is declared with dim ${String(declaredDim)}; refusing to redeclare as ${String(requestedDim)}`);
|
|
263
|
+
}
|
|
264
|
+
var VectorStatsInputSchema = /* @__PURE__ */ zod.z.object({ index: /* @__PURE__ */ zod.z.string() });
|
|
265
|
+
var VectorStatsResultSchema = /* @__PURE__ */ zod.z.object({
|
|
266
|
+
/** Provider id, so an operator can tell brute force from an ANN index. */
|
|
267
|
+
backend: /* @__PURE__ */ zod.z.string(),
|
|
268
|
+
count: /* @__PURE__ */ zod.z.number(),
|
|
269
|
+
dim: /* @__PURE__ */ zod.z.number(),
|
|
270
|
+
metric: VectorMetricSchema,
|
|
271
|
+
/** Bytes on disk for this index, when the backend can report it. */
|
|
272
|
+
bytes: /* @__PURE__ */ zod.z.number().optional(),
|
|
273
|
+
/** False when the backend ranks approximately. */
|
|
274
|
+
exact: /* @__PURE__ */ zod.z.boolean()
|
|
275
|
+
});
|
|
276
|
+
/**
|
|
277
|
+
* `internal: true` did not gate the mount (see the 2026-08-26 note on
|
|
278
|
+
* `data-store-provider`) — every method below was reachable on the AppRouter
|
|
279
|
+
* by ANY authenticated session at the default `auth: 'protected'`. The only
|
|
280
|
+
* consumers (`addon-post-analysis`'s embedding stores) reach this cap via
|
|
281
|
+
* `ctx.api` — UDS/Moleculer, never tRPC — so `auth: 'admin'` on every method
|
|
282
|
+
* costs them nothing. No client (viewer or admin-ui) calls `vectorStore.*`.
|
|
283
|
+
*/
|
|
284
|
+
var vectorStoreCapability = {
|
|
285
|
+
name: "vector-store",
|
|
286
|
+
scope: "system",
|
|
287
|
+
mode: "singleton",
|
|
288
|
+
internal: true,
|
|
289
|
+
methods: {
|
|
290
|
+
/** Idempotent. Re-declaring with a different `dim` is an error, not a wipe. */
|
|
291
|
+
declareIndex: /* @__PURE__ */ require_capability_definition.method(VectorDeclareIndexInputSchema, /* @__PURE__ */ zod.z.void(), {
|
|
292
|
+
kind: "mutation",
|
|
293
|
+
auth: "admin"
|
|
294
|
+
}),
|
|
295
|
+
upsert: /* @__PURE__ */ require_capability_definition.method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
|
|
296
|
+
kind: "mutation",
|
|
297
|
+
auth: "admin"
|
|
298
|
+
}),
|
|
299
|
+
query: /* @__PURE__ */ require_capability_definition.method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }),
|
|
300
|
+
/** Metadata by id, no vectors — see {@link VectorGetResultSchema}. */
|
|
301
|
+
getByIds: /* @__PURE__ */ require_capability_definition.method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }),
|
|
302
|
+
/** Metadata AND vectors, by named id — see {@link VectorFetchInputSchema}. */
|
|
303
|
+
fetchByIds: /* @__PURE__ */ require_capability_definition.method(VectorFetchInputSchema, VectorFetchResultSchema, { auth: "admin" }),
|
|
304
|
+
/** One page of the whole index, unranked — see {@link VectorScanInputSchema}. */
|
|
305
|
+
scan: /* @__PURE__ */ require_capability_definition.method(VectorScanInputSchema, VectorScanResultSchema, { auth: "admin" }),
|
|
306
|
+
deleteByIds: /* @__PURE__ */ require_capability_definition.method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
|
|
307
|
+
kind: "mutation",
|
|
308
|
+
auth: "admin"
|
|
309
|
+
}),
|
|
310
|
+
deleteByFilter: /* @__PURE__ */ require_capability_definition.method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
|
|
311
|
+
kind: "mutation",
|
|
312
|
+
auth: "admin"
|
|
313
|
+
}),
|
|
314
|
+
stats: /* @__PURE__ */ require_capability_definition.method(VectorStatsInputSchema, VectorStatsResultSchema, { auth: "admin" })
|
|
315
|
+
},
|
|
316
|
+
vocabulary: { notOperatorFacing: require_system_reasons.NOT_A_DEVICE.INTERNAL }
|
|
317
|
+
};
|
|
318
|
+
//#endregion
|
|
319
|
+
Object.defineProperty(exports, "vectorIndexDimConflictError", {
|
|
320
|
+
enumerable: true,
|
|
321
|
+
get: function() {
|
|
322
|
+
return vectorIndexDimConflictError;
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
Object.defineProperty(exports, "vectorStoreCapability", {
|
|
326
|
+
enumerable: true,
|
|
327
|
+
get: function() {
|
|
328
|
+
return vectorStoreCapability;
|
|
329
|
+
}
|
|
330
|
+
});
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import { c as method } from "./capability-definition-C2rJdVeX.mjs";
|
|
2
|
+
import { t as NOT_A_DEVICE } from "./system-reasons-CYj4qwyS.mjs";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
//#region ../types/dist/esm/capabilities/vector-store.cap.mjs
|
|
5
|
+
/**
|
|
6
|
+
* vector-store — the dedicated home for embedding vectors and similarity search.
|
|
7
|
+
*
|
|
8
|
+
* ## Why this is a capability and not a helper
|
|
9
|
+
*
|
|
10
|
+
* This capability was introduced with the claim that SIX stores in
|
|
11
|
+
* `addon-post-analysis` held vectors in a `JSON` settings-store column — object
|
|
12
|
+
* CLIP, face, plate, vehicle, identity, and the event store's derivatives. That
|
|
13
|
+
* claim was never true, and leaving it here made five stores look like pending
|
|
14
|
+
* work when three of them have no vector at all. Counted column by column on
|
|
15
|
+
* 2026-08-30, exactly THREE ever held one:
|
|
16
|
+
*
|
|
17
|
+
* - `object-clip` — 512-dim CLIP image embedding, migrated 2026-08-06.
|
|
18
|
+
* - `faces.embedding` — 512-dim ArcFace face embedding, migrated 2026-08-30.
|
|
19
|
+
* - `identity-samples.embedding` — the same ArcFace vector for an ENROLLED
|
|
20
|
+
* face, migrated 2026-08-30 into its OWN index (see below).
|
|
21
|
+
*
|
|
22
|
+
* `plates` and `vehicle-samples` store a plate STRING and a score; `vehicles`
|
|
23
|
+
* and `identities` store a name; the event store stores no derivative vector.
|
|
24
|
+
* They are not migration candidates and never were.
|
|
25
|
+
*
|
|
26
|
+
* Measured on the live hub the JSON encoding cost ~11.7 KB per row (512 floats
|
|
27
|
+
* as TEXT, `JSON.parse`d on every search) and made semantic search load 5,000
|
|
28
|
+
* rows before ranking anything.
|
|
29
|
+
*
|
|
30
|
+
* ## One index per COMPARISON, never per encoder
|
|
31
|
+
*
|
|
32
|
+
* `faces` and `identity-samples` hold the same 512 ArcFace dims from the same
|
|
33
|
+
* model, and they still get two indexes. An index is a set of things that are
|
|
34
|
+
* ranked against each other and that live and die together, and these two are
|
|
35
|
+
* neither: a `faces` row is TRACK-OWNED and cascades away with its track under
|
|
36
|
+
* a per-camera capacity cap, an `identity-samples` row is retention-EXEMPT
|
|
37
|
+
* forever and is the gallery every recognition ranks against. One index would
|
|
38
|
+
* mean every gallery load and every reconcile carried a filter whose failure
|
|
39
|
+
* mode is either ranking a candidate against itself or reclaiming an enrolled
|
|
40
|
+
* person's only sample. The dimension they share is not a reason to share an
|
|
41
|
+
* index; the question they answer is, and it differs.
|
|
42
|
+
*
|
|
43
|
+
* The fix is not a faster loop, it is a different backend — and the backend
|
|
44
|
+
* should be replaceable without touching six callers. So: a singleton
|
|
45
|
+
* capability. The provider shipped today is SQLite-backed brute force over
|
|
46
|
+
* COMPACT rows; an ANN index (sqlite-vec, usearch, …) can replace it later by
|
|
47
|
+
* registering a different provider and `setActiveSingleton`, with no caller
|
|
48
|
+
* change. That is the whole point of putting it here.
|
|
49
|
+
*
|
|
50
|
+
* ## Wire format: base64, deliberately
|
|
51
|
+
*
|
|
52
|
+
* `vector` is base64 of little-endian Float32 — NOT `number[]`, and NOT a
|
|
53
|
+
* `Float32Array`. Both alternatives have already cost this repo:
|
|
54
|
+
* a `Float32Array` does not survive msgpack across the UDS transport (it arrived
|
|
55
|
+
* as an empty object and froze audio dBFS), and `number[]` is the ~5x-larger
|
|
56
|
+
* encoding this capability exists to stop paying. A 512-dim vector is 2,048
|
|
57
|
+
* bytes raw, 2,732 as base64, against ~10-12 KB as JSON text.
|
|
58
|
+
*
|
|
59
|
+
* Helpers for both directions live in `@camstack/types` —
|
|
60
|
+
* `encodeVectorBase64` / `decodeVectorBase64` — so no caller hand-rolls the
|
|
61
|
+
* byte order.
|
|
62
|
+
*/
|
|
63
|
+
/** Similarity metric an index ranks by. */
|
|
64
|
+
var VectorMetricSchema = /* @__PURE__ */ z.enum([
|
|
65
|
+
"cosine",
|
|
66
|
+
"dot",
|
|
67
|
+
"euclidean"
|
|
68
|
+
]);
|
|
69
|
+
/**
|
|
70
|
+
* Scalar metadata carried alongside a vector.
|
|
71
|
+
*
|
|
72
|
+
* Deliberately flat and scalar: it is what {@link VectorFilterSchema} can filter
|
|
73
|
+
* on, and a nested object cannot be indexed by any backend worth swapping in.
|
|
74
|
+
* Callers keep their rich records in their own store and put only the filterable
|
|
75
|
+
* columns here (deviceId, timestamp, className, modelId, …).
|
|
76
|
+
*/
|
|
77
|
+
var VectorMetadataSchema = /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.union([
|
|
78
|
+
/* @__PURE__ */ z.string(),
|
|
79
|
+
/* @__PURE__ */ z.number(),
|
|
80
|
+
/* @__PURE__ */ z.boolean()
|
|
81
|
+
]));
|
|
82
|
+
/**
|
|
83
|
+
* Prefilter applied BEFORE ranking.
|
|
84
|
+
*
|
|
85
|
+
* `equals` and `between` are ANDed. A backend that cannot push a clause down
|
|
86
|
+
* must still apply it — a filter that is silently ignored returns results the
|
|
87
|
+
* caller will treat as matches.
|
|
88
|
+
*/
|
|
89
|
+
var VectorFilterSchema = /* @__PURE__ */ z.object({
|
|
90
|
+
equals: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.union([
|
|
91
|
+
/* @__PURE__ */ z.string(),
|
|
92
|
+
/* @__PURE__ */ z.number(),
|
|
93
|
+
/* @__PURE__ */ z.boolean()
|
|
94
|
+
])).optional(),
|
|
95
|
+
between: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.tuple([/* @__PURE__ */ z.number(), /* @__PURE__ */ z.number()])).optional()
|
|
96
|
+
});
|
|
97
|
+
/** One vector plus its identity and filterable metadata. */
|
|
98
|
+
var VectorItemSchema = /* @__PURE__ */ z.object({
|
|
99
|
+
/** Caller-owned primary key. Upsert replaces the row with this id. */
|
|
100
|
+
id: /* @__PURE__ */ z.string(),
|
|
101
|
+
/** base64 of little-endian Float32. See the module docblock. */
|
|
102
|
+
vector: /* @__PURE__ */ z.string(),
|
|
103
|
+
metadata: VectorMetadataSchema
|
|
104
|
+
});
|
|
105
|
+
/** A ranked hit. */
|
|
106
|
+
var VectorMatchSchema = /* @__PURE__ */ z.object({
|
|
107
|
+
id: /* @__PURE__ */ z.string(),
|
|
108
|
+
/** Similarity under the index's metric; higher is nearer for cosine/dot. */
|
|
109
|
+
score: /* @__PURE__ */ z.number(),
|
|
110
|
+
metadata: VectorMetadataSchema
|
|
111
|
+
});
|
|
112
|
+
var VectorDeclareIndexInputSchema = /* @__PURE__ */ z.object({
|
|
113
|
+
index: /* @__PURE__ */ z.string(),
|
|
114
|
+
/** Vector length. An item of a different length is rejected, not coerced. */
|
|
115
|
+
dim: /* @__PURE__ */ z.number().int().positive(),
|
|
116
|
+
metric: /* @__PURE__ */ VectorMetricSchema.default("cosine")
|
|
117
|
+
});
|
|
118
|
+
var VectorUpsertInputSchema = /* @__PURE__ */ z.object({
|
|
119
|
+
index: /* @__PURE__ */ z.string(),
|
|
120
|
+
items: /* @__PURE__ */ z.array(VectorItemSchema)
|
|
121
|
+
});
|
|
122
|
+
var VectorUpsertResultSchema = /* @__PURE__ */ z.object({
|
|
123
|
+
upserted: /* @__PURE__ */ z.number(),
|
|
124
|
+
/** Items refused for a dim mismatch. Never silent — see D-rule on dropped work. */
|
|
125
|
+
rejected: /* @__PURE__ */ z.number()
|
|
126
|
+
});
|
|
127
|
+
var VectorQueryInputSchema = /* @__PURE__ */ z.object({
|
|
128
|
+
index: /* @__PURE__ */ z.string(),
|
|
129
|
+
/** base64 Float32LE query vector. */
|
|
130
|
+
vector: /* @__PURE__ */ z.string(),
|
|
131
|
+
topK: /* @__PURE__ */ z.number().int().positive(),
|
|
132
|
+
/** Drop matches scoring below this. */
|
|
133
|
+
minScore: /* @__PURE__ */ z.number().optional(),
|
|
134
|
+
filter: /* @__PURE__ */ VectorFilterSchema.optional()
|
|
135
|
+
});
|
|
136
|
+
var VectorQueryResultSchema = /* @__PURE__ */ z.object({
|
|
137
|
+
matches: /* @__PURE__ */ z.array(VectorMatchSchema),
|
|
138
|
+
/**
|
|
139
|
+
* Rows the backend actually compared. When this equals the index size the
|
|
140
|
+
* search was exhaustive; when it is lower the backend approximated or
|
|
141
|
+
* truncated, and the caller can say so instead of reporting "nothing older
|
|
142
|
+
* matched".
|
|
143
|
+
*/
|
|
144
|
+
scanned: /* @__PURE__ */ z.number(),
|
|
145
|
+
/** True when the backend could not consider every row that passed the filter. */
|
|
146
|
+
truncated: /* @__PURE__ */ z.boolean(),
|
|
147
|
+
/**
|
|
148
|
+
* The `topK` the backend actually ran with.
|
|
149
|
+
*
|
|
150
|
+
* Every backend has a ceiling — sqlite-vec's is 4,096 — and a caller asking
|
|
151
|
+
* past it used to learn nothing but a boolean, from a WARN in the provider's
|
|
152
|
+
* own log rather than in its answer. That is how an audit asking for 20,000
|
|
153
|
+
* consumed 4,096 and reported `examined: 4096` as if it had walked the index,
|
|
154
|
+
* for weeks. `truncated` says THAT the answer was short; this says BY HOW
|
|
155
|
+
* MUCH, in the return value, where the caller cannot fail to see it.
|
|
156
|
+
*
|
|
157
|
+
* Equals the requested `topK` whenever nothing was lowered.
|
|
158
|
+
*/
|
|
159
|
+
effectiveTopK: /* @__PURE__ */ z.number().int().positive()
|
|
160
|
+
});
|
|
161
|
+
var VectorDeleteInputSchema = /* @__PURE__ */ z.object({
|
|
162
|
+
index: /* @__PURE__ */ z.string(),
|
|
163
|
+
ids: /* @__PURE__ */ z.array(/* @__PURE__ */ z.string())
|
|
164
|
+
});
|
|
165
|
+
var VectorDeleteByFilterInputSchema = /* @__PURE__ */ z.object({
|
|
166
|
+
index: /* @__PURE__ */ z.string(),
|
|
167
|
+
filter: VectorFilterSchema
|
|
168
|
+
});
|
|
169
|
+
var VectorDeleteResultSchema = /* @__PURE__ */ z.object({ deleted: /* @__PURE__ */ z.number() });
|
|
170
|
+
var VectorGetInputSchema = /* @__PURE__ */ z.object({
|
|
171
|
+
index: /* @__PURE__ */ z.string(),
|
|
172
|
+
ids: /* @__PURE__ */ z.array(/* @__PURE__ */ z.string())
|
|
173
|
+
});
|
|
174
|
+
/**
|
|
175
|
+
* Metadata for the requested ids, WITHOUT their vectors.
|
|
176
|
+
*
|
|
177
|
+
* The only caller is a best-of gate that compares a candidate's confidence
|
|
178
|
+
* against the stored one, and shipping 512 floats back to answer "is 0.91 >
|
|
179
|
+
* 0.87" would undo the point of the compact encoding. Ids with no row are
|
|
180
|
+
* simply absent — a caller distinguishing "not stored" from "stored" reads the
|
|
181
|
+
* length, and a null placeholder would invite a `?? 0` that treats a missing
|
|
182
|
+
* row as confidence zero.
|
|
183
|
+
*/
|
|
184
|
+
var VectorGetResultSchema = /* @__PURE__ */ z.object({ items: /* @__PURE__ */ z.array(/* @__PURE__ */ z.object({
|
|
185
|
+
id: /* @__PURE__ */ z.string(),
|
|
186
|
+
metadata: VectorMetadataSchema
|
|
187
|
+
})) });
|
|
188
|
+
/**
|
|
189
|
+
* Ids to read back WITH their vectors.
|
|
190
|
+
*
|
|
191
|
+
* The sibling of {@link VectorGetResultSchema}, and deliberately a separate
|
|
192
|
+
* method rather than a flag on it: `getByIds` promises no vectors and its one
|
|
193
|
+
* caller depends on that promise. This one promises the opposite.
|
|
194
|
+
*
|
|
195
|
+
* It exists because a store cannot put its vectors here otherwise. An ArcFace
|
|
196
|
+
* gallery is ranked IN PROCESS, per detection, against every enrolled sample —
|
|
197
|
+
* a per-face cross-process KNN would be a network round trip inside the
|
|
198
|
+
* recognition loop. So the gallery is loaded once and held in RAM, and loading
|
|
199
|
+
* it requires the index to hand the floats back. Without this method the only
|
|
200
|
+
* way to keep a readable vector is a JSON column, which is the thing this
|
|
201
|
+
* capability exists to delete.
|
|
202
|
+
*
|
|
203
|
+
* BOUNDED BY THE CALLER: ids are named, never "everything". Enumerating an
|
|
204
|
+
* index is {@link VectorScanInputSchema}'s job, and it returns no vectors.
|
|
205
|
+
*/
|
|
206
|
+
var VectorFetchInputSchema = /* @__PURE__ */ z.object({
|
|
207
|
+
index: /* @__PURE__ */ z.string(),
|
|
208
|
+
ids: /* @__PURE__ */ z.array(/* @__PURE__ */ z.string())
|
|
209
|
+
});
|
|
210
|
+
var VectorFetchResultSchema = /* @__PURE__ */ z.object({ items: /* @__PURE__ */ z.array(/* @__PURE__ */ z.object({
|
|
211
|
+
id: /* @__PURE__ */ z.string(),
|
|
212
|
+
/** base64 Float32LE — the same wire form `upsert` accepts. */
|
|
213
|
+
vector: /* @__PURE__ */ z.string(),
|
|
214
|
+
metadata: VectorMetadataSchema
|
|
215
|
+
})) });
|
|
216
|
+
/**
|
|
217
|
+
* ENUMERATE an index: one page of rows in a stable order, no ranking.
|
|
218
|
+
*
|
|
219
|
+
* A reconcile does not want the nearest rows, it wants ALL of them, and asking
|
|
220
|
+
* a KNN for "all" is the wrong question twice over. It hits the backend's `k`
|
|
221
|
+
* ceiling — 4,096 on sqlite-vec against a 22,128-row index — and it needs a
|
|
222
|
+
* probe vector it does not have, so the audit passed a ZERO vector whose cosine
|
|
223
|
+
* distance to every row is degenerate. `examined: 4096` then read as "we
|
|
224
|
+
* looked" for as long as anyone cared to read it.
|
|
225
|
+
*
|
|
226
|
+
* This is the primitive that question actually needs: a bounded page, ordered
|
|
227
|
+
* by the backend's own row order, costing no distance computation at all.
|
|
228
|
+
* Vectors are NOT returned — an enumeration that shipped 2 KB per row would be
|
|
229
|
+
* the full-table read this capability was built to stop.
|
|
230
|
+
*/
|
|
231
|
+
var VectorScanInputSchema = /* @__PURE__ */ z.object({
|
|
232
|
+
index: /* @__PURE__ */ z.string(),
|
|
233
|
+
/** Opaque resume point. `0` starts at the top; pass back `nextCursor`. */
|
|
234
|
+
cursor: /* @__PURE__ */ z.number().int().nonnegative().default(0),
|
|
235
|
+
limit: /* @__PURE__ */ z.number().int().positive()
|
|
236
|
+
});
|
|
237
|
+
var VectorScanResultSchema = /* @__PURE__ */ z.object({
|
|
238
|
+
items: /* @__PURE__ */ z.array(/* @__PURE__ */ z.object({
|
|
239
|
+
id: /* @__PURE__ */ z.string(),
|
|
240
|
+
metadata: VectorMetadataSchema
|
|
241
|
+
})),
|
|
242
|
+
/**
|
|
243
|
+
* Where the next page starts, or `null` when the walk reached the end.
|
|
244
|
+
*
|
|
245
|
+
* `null` is the ONLY end-of-index signal. A caller must not infer the end
|
|
246
|
+
* from a short page: a backend is free to return fewer rows than asked.
|
|
247
|
+
*/
|
|
248
|
+
nextCursor: /* @__PURE__ */ z.number().int().nonnegative().nullable()
|
|
249
|
+
});
|
|
250
|
+
/**
|
|
251
|
+
* The ONE error code for "this index exists at another dimension; refusing to
|
|
252
|
+
* redeclare it" (D649). It rides in the MESSAGE — an Error's own properties do
|
|
253
|
+
* not survive the UDS/tRPC hop, its message does — and both sides go through
|
|
254
|
+
* the helpers below, never a copied phrase: a consumer that must tell "this
|
|
255
|
+
* index can never hold my vectors" from "the provider is unreachable" (a
|
|
256
|
+
* delete counts the first as nothing-to-delete and the second as still
|
|
257
|
+
* present) otherwise breaks silently the day the wording changes.
|
|
258
|
+
*/
|
|
259
|
+
var VECTOR_INDEX_DIM_CONFLICT = "vector-index-dim-conflict";
|
|
260
|
+
/** The provider's refusal, carrying {@link VECTOR_INDEX_DIM_CONFLICT}. */
|
|
261
|
+
function vectorIndexDimConflictError(index, declaredDim, requestedDim) {
|
|
262
|
+
return /* @__PURE__ */ new Error(`[${VECTOR_INDEX_DIM_CONFLICT}] vector-store: index "${index}" is declared with dim ${String(declaredDim)}; refusing to redeclare as ${String(requestedDim)}`);
|
|
263
|
+
}
|
|
264
|
+
var VectorStatsInputSchema = /* @__PURE__ */ z.object({ index: /* @__PURE__ */ z.string() });
|
|
265
|
+
var VectorStatsResultSchema = /* @__PURE__ */ z.object({
|
|
266
|
+
/** Provider id, so an operator can tell brute force from an ANN index. */
|
|
267
|
+
backend: /* @__PURE__ */ z.string(),
|
|
268
|
+
count: /* @__PURE__ */ z.number(),
|
|
269
|
+
dim: /* @__PURE__ */ z.number(),
|
|
270
|
+
metric: VectorMetricSchema,
|
|
271
|
+
/** Bytes on disk for this index, when the backend can report it. */
|
|
272
|
+
bytes: /* @__PURE__ */ z.number().optional(),
|
|
273
|
+
/** False when the backend ranks approximately. */
|
|
274
|
+
exact: /* @__PURE__ */ z.boolean()
|
|
275
|
+
});
|
|
276
|
+
/**
|
|
277
|
+
* `internal: true` did not gate the mount (see the 2026-08-26 note on
|
|
278
|
+
* `data-store-provider`) — every method below was reachable on the AppRouter
|
|
279
|
+
* by ANY authenticated session at the default `auth: 'protected'`. The only
|
|
280
|
+
* consumers (`addon-post-analysis`'s embedding stores) reach this cap via
|
|
281
|
+
* `ctx.api` — UDS/Moleculer, never tRPC — so `auth: 'admin'` on every method
|
|
282
|
+
* costs them nothing. No client (viewer or admin-ui) calls `vectorStore.*`.
|
|
283
|
+
*/
|
|
284
|
+
var vectorStoreCapability = {
|
|
285
|
+
name: "vector-store",
|
|
286
|
+
scope: "system",
|
|
287
|
+
mode: "singleton",
|
|
288
|
+
internal: true,
|
|
289
|
+
methods: {
|
|
290
|
+
/** Idempotent. Re-declaring with a different `dim` is an error, not a wipe. */
|
|
291
|
+
declareIndex: /* @__PURE__ */ method(VectorDeclareIndexInputSchema, /* @__PURE__ */ z.void(), {
|
|
292
|
+
kind: "mutation",
|
|
293
|
+
auth: "admin"
|
|
294
|
+
}),
|
|
295
|
+
upsert: /* @__PURE__ */ method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
|
|
296
|
+
kind: "mutation",
|
|
297
|
+
auth: "admin"
|
|
298
|
+
}),
|
|
299
|
+
query: /* @__PURE__ */ method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }),
|
|
300
|
+
/** Metadata by id, no vectors — see {@link VectorGetResultSchema}. */
|
|
301
|
+
getByIds: /* @__PURE__ */ method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }),
|
|
302
|
+
/** Metadata AND vectors, by named id — see {@link VectorFetchInputSchema}. */
|
|
303
|
+
fetchByIds: /* @__PURE__ */ method(VectorFetchInputSchema, VectorFetchResultSchema, { auth: "admin" }),
|
|
304
|
+
/** One page of the whole index, unranked — see {@link VectorScanInputSchema}. */
|
|
305
|
+
scan: /* @__PURE__ */ method(VectorScanInputSchema, VectorScanResultSchema, { auth: "admin" }),
|
|
306
|
+
deleteByIds: /* @__PURE__ */ method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
|
|
307
|
+
kind: "mutation",
|
|
308
|
+
auth: "admin"
|
|
309
|
+
}),
|
|
310
|
+
deleteByFilter: /* @__PURE__ */ method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
|
|
311
|
+
kind: "mutation",
|
|
312
|
+
auth: "admin"
|
|
313
|
+
}),
|
|
314
|
+
stats: /* @__PURE__ */ method(VectorStatsInputSchema, VectorStatsResultSchema, { auth: "admin" })
|
|
315
|
+
},
|
|
316
|
+
vocabulary: { notOperatorFacing: NOT_A_DEVICE.INTERNAL }
|
|
317
|
+
};
|
|
318
|
+
//#endregion
|
|
319
|
+
export { vectorStoreCapability as n, vectorIndexDimConflictError as t };
|
|
Binary file
|
|
Binary file
|