@camstack/addon-provider-tuya 0.2.43 → 0.2.46

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.
Files changed (3) hide show
  1. package/dist/addon.js +387 -19
  2. package/dist/addon.mjs +387 -19
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -8823,6 +8823,21 @@ var RelocateJobSchema = object({
8823
8823
  bytesMoved: number().int(),
8824
8824
  /** Total files discovered up front; null while (or when) unknown. */
8825
8825
  filesTotal: number().int().nullable(),
8826
+ /**
8827
+ * Rows this run CORRECTED while moving them — a durable mutation the move
8828
+ * made that nobody asked for, so it is reported where the operator reads the
8829
+ * job rather than only in a log line.
8830
+ *
8831
+ * A footage segment records its byte count in its own NAME, and the durable
8832
+ * hour row derives its aggregates from those names. A file that does not
8833
+ * match its name therefore makes the ledger's sums — and with them quota and
8834
+ * pressure eviction — wrong by the difference, and only a rename can fix it.
8835
+ * On 2026-08-30 one such row also stalled a 110 749-file drain permanently.
8836
+ *
8837
+ * Absent on lanes where the question has no meaning: a media blob's size is
8838
+ * in its row, not in its name, so `MediaRelocateEngine` never reconciles one.
8839
+ */
8840
+ rowsReconciled: number().int().nonnegative().optional(),
8826
8841
  startedAt: number(),
8827
8842
  finishedAt: number().nullable(),
8828
8843
  error: string().nullable()
@@ -8891,14 +8906,42 @@ var RelocateMediaInputSchema = object({
8891
8906
  /** Omitted = `move`, the pre-existing behaviour. */
8892
8907
  mode: MediaRelocateModeSchema.optional()
8893
8908
  });
8894
- /** How many rows still carry NO `locationId` — the population a repoint would
8895
- * silently re-aim at a disk that does not hold their bytes. Zero is the only
8896
- * value that permits a non-blocking `eventMedia` cutover. */
8897
- var UnstampedEventMediaCountSchema = object({
8898
- media: number().int().nonnegative(),
8899
- retrainFrames: number().int().nonnegative(),
8900
- total: number().int().nonnegative()
8909
+ /**
8910
+ * The unstamped population of ONE collection — split, because the gate and the
8911
+ * operator ask two different questions and only one of them has to be cheap.
8912
+ *
8913
+ * `present` is the GATE: "is there at least one row that would be orphaned by a
8914
+ * repoint". It is a single indexed seek to the first matching row, so it stays
8915
+ * answerable on a saturated disk and answers in O(log n) precisely in the state
8916
+ * that matters — after a seal, when the population is empty.
8917
+ *
8918
+ * `rows` is the NUMBER, for the refusal message and the operator's sense of
8919
+ * scale. It is a second, indexed `COUNT(*)`, and `null` means **not
8920
+ * measurable** — never zero. `{ present: true, rows: null }` is a legitimate
8921
+ * and useful answer: "there are some, and this read could not say how many"
8922
+ * still refuses the cutover, which is the whole job.
8923
+ */
8924
+ var UnstampedRowsSchema = object({
8925
+ present: boolean(),
8926
+ rows: number().int().nonnegative().nullable()
8901
8927
  });
8928
+ /**
8929
+ * How many rows still carry NO `locationId` — the population a repoint would
8930
+ * silently re-aim at a disk that does not hold their bytes.
8931
+ *
8932
+ * **`null` = the count could not be taken**, and it is NOT permission to cut
8933
+ * over. The gate opens on a measured absence and on nothing else; an unread
8934
+ * collection and an empty one are different facts, and this repo has already
8935
+ * paid for conflating them (`RelocateResidueSchema`, D295).
8936
+ */
8937
+ var UnstampedEventMediaCountSchema = object({
8938
+ media: UnstampedRowsSchema,
8939
+ retrainFrames: UnstampedRowsSchema,
8940
+ /** True when EITHER collection holds one. The refusal reads this. */
8941
+ anyPresent: boolean(),
8942
+ /** Sum across both, or `null` when either lane could not be counted. */
8943
+ total: number().int().nonnegative().nullable()
8944
+ }).nullable();
8902
8945
  var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
8903
8946
  /** The independently selectable logical storage classes — every class
8904
8947
  * `storage.listLocationDeclarations` reports, so an operator never meets a
@@ -8984,13 +9027,53 @@ var StorageMigrationParticipantSchema = _enum([
8984
9027
  "recorder",
8985
9028
  "analytics"
8986
9029
  ]);
9030
+ /**
9031
+ * The mover's own numbers, folded onto the coordinator's durable move record.
9032
+ *
9033
+ * The long half of a non-blocking migration is `draining`, and it is measured
9034
+ * in hours: 136 885 files at ~4 MB/s is about five of them. Before this shape
9035
+ * existed the only place those numbers appeared was a Loki line, so an operator
9036
+ * watching the Admin UI saw `phase: draining` and nothing else for a whole
9037
+ * afternoon.
9038
+ *
9039
+ * It is POLLED, never pushed. Events are telemetry and may be dropped
9040
+ * (D8/D11), and a dropped progress event is indistinguishable from a stalled
9041
+ * mover — which is the exact failure this is meant to end. The coordinator's
9042
+ * `waitForMoves` already fetches the whole {@link RelocateJob} on every tick to
9043
+ * read `state`; folding the counters costs no extra read and makes the durable
9044
+ * record say afterwards how far a move actually got.
9045
+ *
9046
+ * `filesTotal` is `null` for "no honest denominator" and is never zero-filled:
9047
+ * a windowed footage job (`sinceMs`) and a node with no ledger both genuinely
9048
+ * cannot say M, and a 0 there would render as "100 % done".
9049
+ */
9050
+ var StorageMigrationMoveProgressSchema = object({
9051
+ filesMoved: number().int().nonnegative(),
9052
+ /** The archive census — the **M** of "N of M" (D295). `null` = unknowable. */
9053
+ filesTotal: number().int().nonnegative().nullable(),
9054
+ bytesMoved: number().int().nonnegative(),
9055
+ /** Rows the mover corrected while moving them — see `RelocateJob`. Absent on
9056
+ * a lane that cannot reconcile. A migration that silently rewrote durable
9057
+ * rows would be the same failure as one that silently skipped them. */
9058
+ rowsReconciled: number().int().nonnegative().optional(),
9059
+ /** The MOVER's start, not the migration's: a drain restarted after an addon
9060
+ * crash gets a new mover, and a rate computed from the migration's start
9061
+ * would silently average in the time nothing was running. */
9062
+ startedAt: number(),
9063
+ /** When the coordinator last read these numbers. Paired with `startedAt` it
9064
+ * is the only honest rate: both clocks are the hub's, so a UI never has to
9065
+ * subtract its own. */
9066
+ observedAt: number()
9067
+ });
8987
9068
  var StorageMigrationMoveSchema = object({
8988
9069
  storageClass: StorageMigrationClassSchema,
8989
9070
  fromLocationId: string(),
8990
9071
  toLocationId: string(),
8991
9072
  moverJobId: string().nullable(),
8992
9073
  state: RelocateJobStateSchema.nullable(),
8993
- error: string().nullable()
9074
+ error: string().nullable(),
9075
+ /** Last observed mover counters; `null` until the mover has been polled once. */
9076
+ progress: StorageMigrationMoveProgressSchema.nullable()
8994
9077
  });
8995
9078
  var StorageMigrationJobSchema = object({
8996
9079
  jobId: string(),
@@ -9036,6 +9119,98 @@ var StorageMigrationPlanSchema = object({
9036
9119
  findings: array(StorageMigrationFindingSchema)
9037
9120
  });
9038
9121
  /**
9122
+ * A mover as it exists RIGHT NOW, whether or not a migration job owns it.
9123
+ *
9124
+ * The coordinator's job record is the state of record for a migration, and its
9125
+ * moves carry {@link StorageMigrationMoveProgress}. But the movers are usable
9126
+ * standalone — `recording.relocateFootage` and `pipelineAnalytics.relocateMedia`
9127
+ * are both operator-callable, and on 2026-08-29 a five-hour drain was armed that
9128
+ * way because no supported UI path existed. A mover armed like that has no job
9129
+ * to fold progress into, so it has to be readable on its own or it is invisible.
9130
+ *
9131
+ * `migrationJobId` is what tells the two apart: `null` means nothing here
9132
+ * orchestrated it.
9133
+ */
9134
+ var StorageMigrationMoverSchema = object({
9135
+ lane: _enum(["footage", "media"]),
9136
+ job: RelocateJobSchema,
9137
+ /** The coordinator job that armed this mover, or `null` for a mover armed
9138
+ * directly against the owning addon. */
9139
+ migrationJobId: string().nullable(),
9140
+ /** When the hub read these counters. Stamped here so a rate is `bytesMoved`
9141
+ * over (`observedAt` − `job.startedAt`) with BOTH ends on the hub's clock —
9142
+ * a browser subtracting its own `Date.now()` from a server `startedAt` is a
9143
+ * rate made of two different clocks. */
9144
+ observedAt: number()
9145
+ });
9146
+ /**
9147
+ * What a SOURCE still holds for one storage class — the number that makes a
9148
+ * "drain remaining" action honest rather than hopeful.
9149
+ *
9150
+ * It comes from the archive (`SegmentHourLedger.census` for footage, the media
9151
+ * engine's own selection count for media), never from the resident index: a
9152
+ * drain sized off `RecordingIndex` is what reported `done` over 80.3 GB it had
9153
+ * never been told about (D295).
9154
+ *
9155
+ * `items`/`bytes` are `null` for "the archive could not be asked", which is
9156
+ * deliberately NOT zero: a drain is still offered for an unknown residue,
9157
+ * because refusing on an unanswerable read would hide exactly the case an
9158
+ * operator needs to act on.
9159
+ */
9160
+ var StorageMigrationResidueSchema = object({
9161
+ storageClass: StorageMigrationClassSchema,
9162
+ /** The location still holding the data. `'*'` for the media lane, whose rows
9163
+ * move from wherever they are rather than from one named source. */
9164
+ fromLocationId: string(),
9165
+ /** Where a drain would move it — the class's CURRENT default. */
9166
+ toLocationId: string(),
9167
+ /** Segments (footage lane) or rows (media lane) still on the source. */
9168
+ items: number().int().nonnegative().nullable(),
9169
+ /** Bytes on the source; `null` when the lane counts rows rather than bytes. */
9170
+ bytes: number().int().nonnegative().nullable()
9171
+ });
9172
+ /**
9173
+ * Run the DRAIN half and nothing else.
9174
+ *
9175
+ * A migration that reached `done` has already repointed, so `start` correctly
9176
+ * refuses its destination ("already the default") — there is nothing left to
9177
+ * repoint. But the drain can fail, be cancelled, be interrupted by a restart,
9178
+ * or finish against a work list that was a tenth of the archive (D295), and
9179
+ * before this there was no supported way to run only that half: the only way
9180
+ * through was calling `recording.relocateFootage` by hand over admin tRPC.
9181
+ *
9182
+ * `drain` NEVER calls `setDefaultLocations`. That is what keeps `start`'s
9183
+ * refusal meaningful: the two verbs are disjoint, so nothing here can silently
9184
+ * re-repoint a class that is already migrated.
9185
+ */
9186
+ var StorageMigrationDrainInputSchema = object({
9187
+ /** The classes to drain. Each must appear in `storageMigration.residue`, so
9188
+ * a class whose source is already empty is refused rather than started. */
9189
+ classes: array(StorageMigrationClassSchema).min(1),
9190
+ throttleMbps: number().min(1).max(1e3).optional()
9191
+ });
9192
+ /** What a footage source still holds, asked of the durable hour ledger. */
9193
+ var RelocateResidueInputSchema = object({
9194
+ fromLocationId: string().min(1),
9195
+ /** Narrow to one logical class; omit for every profile on the location. */
9196
+ footageClass: RelocateFootageClassSchema.optional()
9197
+ });
9198
+ /** `null` = the archive could not answer (no ledger on this node, or the
9199
+ * aggregate failed). Never conflated with an empty source. */
9200
+ var RelocateResidueSchema = object({
9201
+ segments: number().int().nonnegative(),
9202
+ bytes: number().int().nonnegative()
9203
+ }).nullable();
9204
+ /** How many rows a media pass would still act on against a given target — the
9205
+ * media lane's denominator AND its residue, from ONE derivation so the two can
9206
+ * never disagree. `null` = the count could not be taken. */
9207
+ var RelocatableMediaCountSchema = object({ rows: number().int().nonnegative() }).nullable();
9208
+ var RelocatableMediaCountInputSchema = object({
9209
+ toLocationId: string().min(1),
9210
+ /** Omitted = `move`. */
9211
+ mode: MediaRelocateModeSchema.optional()
9212
+ });
9213
+ /**
9039
9214
  * `StorageLocationType` — an addon-declared id that identifies the *kind* of
9040
9215
  * storage a location serves. Defined here (not in `capabilities/storage.cap.ts`)
9041
9216
  * so the persisted record schema and the consumer-facing cap can both consume it
@@ -9139,6 +9314,32 @@ var StorageLocationRefSchema = union([StorageLocationTypeSchema, string().regex(
9139
9314
  * two addons declaring the same `id` must agree on `cardinality` (validated
9140
9315
  * at kernel aggregation time, not here).
9141
9316
  */
9317
+ /**
9318
+ * `StorageAccess` — how the service that DECLARED a storage-location kind
9319
+ * actually reaches the bytes. It is the constraint that decides which
9320
+ * `storage-provider`s may back a location of that kind.
9321
+ *
9322
+ * - `'local-path'` — the service asks `storage.resolve` for a path string and
9323
+ * then does its own `node:fs` I/O on it (the recorder's segment writer, the
9324
+ * post-analysis media roots). Only a provider that serves a genuine local
9325
+ * filesystem (`getProviderInfo().nodeLocal === true`) can satisfy that: a
9326
+ * remote provider's `resolve` returns a path on the REMOTE host, and
9327
+ * `fs.readdir` of it on this node either fails or — far worse — succeeds
9328
+ * against a same-named local directory that is something else entirely.
9329
+ *
9330
+ * - `'cap-mediated'` — every byte travels through the `storage` cap
9331
+ * (`read`/`write`, or `beginUpload`/`writeChunk`/`finalizeUpload`). The
9332
+ * service never sees a path, so any provider can back it. `backups` is the
9333
+ * one kind that qualifies today.
9334
+ *
9335
+ * Before this existed, `recordings` was unreachable by SFTP/S3/WebDAV only as
9336
+ * an EMERGENT property of how the recorder happened to be written. Nothing
9337
+ * refused the configuration; the first write simply went somewhere wrong, and
9338
+ * a recording write that goes wrong surfaces as a silent black window rather
9339
+ * than an error (the read path does not `stat`). This turns that accident into
9340
+ * a declared, enforced, testable refusal.
9341
+ */
9342
+ var StorageAccessSchema = _enum(["local-path", "cap-mediated"]);
9142
9343
  var StorageLocationDeclarationSchema = object({
9143
9344
  /**
9144
9345
  * Global location identifier, e.g. `recordings` or `recordingsLow`.
@@ -9158,6 +9359,19 @@ var StorageLocationDeclarationSchema = object({
9158
9359
  */
9159
9360
  cardinality: _enum(["single", "multi"]),
9160
9361
  /**
9362
+ * HOW the declaring service reaches the bytes — and therefore WHICH
9363
+ * providers may back a location of this kind. See {@link StorageAccessSchema}
9364
+ * and {@link STORAGE_ACCESS_FALLBACK}.
9365
+ *
9366
+ * Absent means `'local-path'`. That default is FAIL-CLOSED on purpose: it
9367
+ * can only over-restrict (refuse a remote provider for a kind that might
9368
+ * have coped) and never under-restrict. Declaring `'cap-mediated'` is the
9369
+ * permissive direction and is therefore never inferred — a repo guard
9370
+ * (`scripts/check-storage-access-declarations.ts`) refuses to let it be
9371
+ * reached by omission.
9372
+ */
9373
+ access: StorageAccessSchema.optional(),
9374
+ /**
9161
9375
  * When set, the default instance for this location inherits its resolved
9162
9376
  * root from the named location's default instance. Useful for derivative
9163
9377
  * slots (e.g. `recordingsLow` → `recordings`) so operators only need to
@@ -19042,8 +19256,10 @@ var TrackSchema = object({
19042
19256
  lastSeen: number(),
19043
19257
  /** Frame-rate position history (subject to maxPositionHistory cap). */
19044
19258
  positions: array(TrackPositionSchema).readonly(),
19045
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
19046
- * saveThumbnails policy). */
19259
+ /** Periodic snapshots at snapshotIntervalMs cadence — DEBUG media, produced
19260
+ * only while `MediaSettings.debugMediaEnabled` is on for the camera (D299;
19261
+ * the retired `saveThumbnails` used to gate this and the rolling
19262
+ * `lastFrame` together). Empty is the healthy default, not a capture gap. */
19047
19263
  snapshots: array(TrackSnapshotSchema).readonly(),
19048
19264
  /** Deduplicated zones the track has entered at least once. Zone IDS. */
19049
19265
  zonesVisited: array(string()).readonly(),
@@ -19903,7 +20119,10 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
19903
20119
  }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
19904
20120
  kind: "mutation",
19905
20121
  auth: "admin"
19906
- }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(object({}), array(RelocateJobSchema).readonly(), {
20122
+ }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
20123
+ kind: "query",
20124
+ auth: "admin"
20125
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
19907
20126
  kind: "query",
19908
20127
  auth: "admin"
19909
20128
  }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
@@ -21862,6 +22081,9 @@ method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin"
21862
22081
  }), method(object({ jobId: string().optional() }), StorageMigrationJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
21863
22082
  kind: "mutation",
21864
22083
  auth: "admin"
22084
+ }), method(object({}), array(StorageMigrationMoverSchema).readonly(), { auth: "admin" }), method(object({}), array(StorageMigrationResidueSchema).readonly(), { auth: "admin" }), method(StorageMigrationDrainInputSchema, object({ jobId: string() }), {
22085
+ kind: "mutation",
22086
+ auth: "admin"
21865
22087
  });
21866
22088
  var ProviderInfoSchema = discriminatedUnion("shouldSaveDiskSpace", [object({
21867
22089
  providerId: string().min(1),
@@ -22260,12 +22482,38 @@ response: record(string(), unknown()) }), object({
22260
22482
  *
22261
22483
  * ## Why this is a capability and not a helper
22262
22484
  *
22263
- * Six stores in `addon-post-analysis` already hold vectors — object CLIP, face,
22264
- * plate, vehicle, identity, and the event store's derivatives — and every one of
22265
- * them keeps its vectors in a `JSON` settings-store column and ranks them by
22266
- * brute-force cosine in JS. Measured on the live hub that costs ~11.7 KB per row
22267
- * (512 floats as TEXT, `JSON.parse`d on every search) and made semantic search
22268
- * load 5,000 rows before ranking anything.
22485
+ * This capability was introduced with the claim that SIX stores in
22486
+ * `addon-post-analysis` held vectors in a `JSON` settings-store column — object
22487
+ * CLIP, face, plate, vehicle, identity, and the event store's derivatives. That
22488
+ * claim was never true, and leaving it here made five stores look like pending
22489
+ * work when three of them have no vector at all. Counted column by column on
22490
+ * 2026-08-30, exactly THREE ever held one:
22491
+ *
22492
+ * - `object-clip` — 512-dim CLIP image embedding, migrated 2026-08-06.
22493
+ * - `faces.embedding` — 512-dim ArcFace face embedding, migrated 2026-08-30.
22494
+ * - `identity-samples.embedding` — the same ArcFace vector for an ENROLLED
22495
+ * face, migrated 2026-08-30 into its OWN index (see below).
22496
+ *
22497
+ * `plates` and `vehicle-samples` store a plate STRING and a score; `vehicles`
22498
+ * and `identities` store a name; the event store stores no derivative vector.
22499
+ * They are not migration candidates and never were.
22500
+ *
22501
+ * Measured on the live hub the JSON encoding cost ~11.7 KB per row (512 floats
22502
+ * as TEXT, `JSON.parse`d on every search) and made semantic search load 5,000
22503
+ * rows before ranking anything.
22504
+ *
22505
+ * ## One index per COMPARISON, never per encoder
22506
+ *
22507
+ * `faces` and `identity-samples` hold the same 512 ArcFace dims from the same
22508
+ * model, and they still get two indexes. An index is a set of things that are
22509
+ * ranked against each other and that live and die together, and these two are
22510
+ * neither: a `faces` row is TRACK-OWNED and cascades away with its track under
22511
+ * a per-camera capacity cap, an `identity-samples` row is retention-EXEMPT
22512
+ * forever and is the gallery every recognition ranks against. One index would
22513
+ * mean every gallery load and every reconcile carried a filter whose failure
22514
+ * mode is either ranking a candidate against itself or reclaiming an enrolled
22515
+ * person's only sample. The dimension they share is not a reason to share an
22516
+ * index; the question they answer is, and it differs.
22269
22517
  *
22270
22518
  * The fix is not a faster loop, it is a different backend — and the backend
22271
22519
  * should be replaceable without touching six callers. So: a singleton
@@ -22370,7 +22618,20 @@ var VectorQueryResultSchema = object({
22370
22618
  */
22371
22619
  scanned: number(),
22372
22620
  /** True when the backend could not consider every row that passed the filter. */
22373
- truncated: boolean()
22621
+ truncated: boolean(),
22622
+ /**
22623
+ * The `topK` the backend actually ran with.
22624
+ *
22625
+ * Every backend has a ceiling — sqlite-vec's is 4,096 — and a caller asking
22626
+ * past it used to learn nothing but a boolean, from a WARN in the provider's
22627
+ * own log rather than in its answer. That is how an audit asking for 20,000
22628
+ * consumed 4,096 and reported `examined: 4096` as if it had walked the index,
22629
+ * for weeks. `truncated` says THAT the answer was short; this says BY HOW
22630
+ * MUCH, in the return value, where the caller cannot fail to see it.
22631
+ *
22632
+ * Equals the requested `topK` whenever nothing was lowered.
22633
+ */
22634
+ effectiveTopK: number().int().positive()
22374
22635
  });
22375
22636
  var VectorDeleteInputSchema = object({
22376
22637
  index: string(),
@@ -22399,6 +22660,68 @@ var VectorGetResultSchema = object({ items: array(object({
22399
22660
  id: string(),
22400
22661
  metadata: VectorMetadataSchema
22401
22662
  })) });
22663
+ /**
22664
+ * Ids to read back WITH their vectors.
22665
+ *
22666
+ * The sibling of {@link VectorGetResultSchema}, and deliberately a separate
22667
+ * method rather than a flag on it: `getByIds` promises no vectors and its one
22668
+ * caller depends on that promise. This one promises the opposite.
22669
+ *
22670
+ * It exists because a store cannot put its vectors here otherwise. An ArcFace
22671
+ * gallery is ranked IN PROCESS, per detection, against every enrolled sample —
22672
+ * a per-face cross-process KNN would be a network round trip inside the
22673
+ * recognition loop. So the gallery is loaded once and held in RAM, and loading
22674
+ * it requires the index to hand the floats back. Without this method the only
22675
+ * way to keep a readable vector is a JSON column, which is the thing this
22676
+ * capability exists to delete.
22677
+ *
22678
+ * BOUNDED BY THE CALLER: ids are named, never "everything". Enumerating an
22679
+ * index is {@link VectorScanInputSchema}'s job, and it returns no vectors.
22680
+ */
22681
+ var VectorFetchInputSchema = object({
22682
+ index: string(),
22683
+ ids: array(string())
22684
+ });
22685
+ var VectorFetchResultSchema = object({ items: array(object({
22686
+ id: string(),
22687
+ /** base64 Float32LE — the same wire form `upsert` accepts. */
22688
+ vector: string(),
22689
+ metadata: VectorMetadataSchema
22690
+ })) });
22691
+ /**
22692
+ * ENUMERATE an index: one page of rows in a stable order, no ranking.
22693
+ *
22694
+ * A reconcile does not want the nearest rows, it wants ALL of them, and asking
22695
+ * a KNN for "all" is the wrong question twice over. It hits the backend's `k`
22696
+ * ceiling — 4,096 on sqlite-vec against a 22,128-row index — and it needs a
22697
+ * probe vector it does not have, so the audit passed a ZERO vector whose cosine
22698
+ * distance to every row is degenerate. `examined: 4096` then read as "we
22699
+ * looked" for as long as anyone cared to read it.
22700
+ *
22701
+ * This is the primitive that question actually needs: a bounded page, ordered
22702
+ * by the backend's own row order, costing no distance computation at all.
22703
+ * Vectors are NOT returned — an enumeration that shipped 2 KB per row would be
22704
+ * the full-table read this capability was built to stop.
22705
+ */
22706
+ var VectorScanInputSchema = object({
22707
+ index: string(),
22708
+ /** Opaque resume point. `0` starts at the top; pass back `nextCursor`. */
22709
+ cursor: number().int().nonnegative().default(0),
22710
+ limit: number().int().positive()
22711
+ });
22712
+ var VectorScanResultSchema = object({
22713
+ items: array(object({
22714
+ id: string(),
22715
+ metadata: VectorMetadataSchema
22716
+ })),
22717
+ /**
22718
+ * Where the next page starts, or `null` when the walk reached the end.
22719
+ *
22720
+ * `null` is the ONLY end-of-index signal. A caller must not infer the end
22721
+ * from a short page: a backend is free to return fewer rows than asked.
22722
+ */
22723
+ nextCursor: number().int().nonnegative().nullable()
22724
+ });
22402
22725
  var VectorStatsInputSchema = object({ index: string() });
22403
22726
  var VectorStatsResultSchema = object({
22404
22727
  /** Provider id, so an operator can tell brute force from an ANN index. */
@@ -22417,7 +22740,7 @@ method(VectorDeclareIndexInputSchema, _void(), {
22417
22740
  }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
22418
22741
  kind: "mutation",
22419
22742
  auth: "admin"
22420
- }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
22743
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorFetchInputSchema, VectorFetchResultSchema, { auth: "admin" }), method(VectorScanInputSchema, VectorScanResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
22421
22744
  kind: "mutation",
22422
22745
  auth: "admin"
22423
22746
  }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
@@ -29044,6 +29367,9 @@ method(object({
29044
29367
  }), method(object({}), array(RelocateJobSchema).readonly(), {
29045
29368
  kind: "query",
29046
29369
  auth: "admin"
29370
+ }), method(RelocateResidueInputSchema, RelocateResidueSchema, {
29371
+ kind: "query",
29372
+ auth: "admin"
29047
29373
  }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
29048
29374
  kind: "mutation",
29049
29375
  auth: "admin"
@@ -35678,6 +36004,12 @@ Object.freeze({
35678
36004
  addonId: null,
35679
36005
  access: "create"
35680
36006
  },
36007
+ "pipelineAnalytics.countRelocatableMedia": {
36008
+ capName: "pipeline-analytics",
36009
+ capScope: "device",
36010
+ addonId: null,
36011
+ access: "view"
36012
+ },
35681
36013
  "pipelineAnalytics.countUnstampedEventMedia": {
35682
36014
  capName: "pipeline-analytics",
35683
36015
  capScope: "device",
@@ -36842,6 +37174,12 @@ Object.freeze({
36842
37174
  addonId: null,
36843
37175
  access: "view"
36844
37176
  },
37177
+ "recording.getRelocateResidue": {
37178
+ capName: "recording",
37179
+ capScope: "system",
37180
+ addonId: null,
37181
+ access: "view"
37182
+ },
36845
37183
  "recording.getStorageMigrationMoveStatus": {
36846
37184
  capName: "recording",
36847
37185
  capScope: "system",
@@ -37388,12 +37726,30 @@ Object.freeze({
37388
37726
  addonId: null,
37389
37727
  access: "create"
37390
37728
  },
37729
+ "storageMigration.drain": {
37730
+ capName: "storage-migration",
37731
+ capScope: "system",
37732
+ addonId: null,
37733
+ access: "create"
37734
+ },
37735
+ "storageMigration.movers": {
37736
+ capName: "storage-migration",
37737
+ capScope: "system",
37738
+ addonId: null,
37739
+ access: "view"
37740
+ },
37391
37741
  "storageMigration.plan": {
37392
37742
  capName: "storage-migration",
37393
37743
  capScope: "system",
37394
37744
  addonId: null,
37395
37745
  access: "view"
37396
37746
  },
37747
+ "storageMigration.residue": {
37748
+ capName: "storage-migration",
37749
+ capScope: "system",
37750
+ addonId: null,
37751
+ access: "view"
37752
+ },
37397
37753
  "storageMigration.start": {
37398
37754
  capName: "storage-migration",
37399
37755
  capScope: "system",
@@ -38228,6 +38584,12 @@ Object.freeze({
38228
38584
  addonId: null,
38229
38585
  access: "delete"
38230
38586
  },
38587
+ "vectorStore.fetchByIds": {
38588
+ capName: "vector-store",
38589
+ capScope: "system",
38590
+ addonId: null,
38591
+ access: "view"
38592
+ },
38231
38593
  "vectorStore.getByIds": {
38232
38594
  capName: "vector-store",
38233
38595
  capScope: "system",
@@ -38240,6 +38602,12 @@ Object.freeze({
38240
38602
  addonId: null,
38241
38603
  access: "view"
38242
38604
  },
38605
+ "vectorStore.scan": {
38606
+ capName: "vector-store",
38607
+ capScope: "system",
38608
+ addonId: null,
38609
+ access: "view"
38610
+ },
38243
38611
  "vectorStore.stats": {
38244
38612
  capName: "vector-store",
38245
38613
  capScope: "system",
package/dist/addon.mjs CHANGED
@@ -8822,6 +8822,21 @@ var RelocateJobSchema = object({
8822
8822
  bytesMoved: number().int(),
8823
8823
  /** Total files discovered up front; null while (or when) unknown. */
8824
8824
  filesTotal: number().int().nullable(),
8825
+ /**
8826
+ * Rows this run CORRECTED while moving them — a durable mutation the move
8827
+ * made that nobody asked for, so it is reported where the operator reads the
8828
+ * job rather than only in a log line.
8829
+ *
8830
+ * A footage segment records its byte count in its own NAME, and the durable
8831
+ * hour row derives its aggregates from those names. A file that does not
8832
+ * match its name therefore makes the ledger's sums — and with them quota and
8833
+ * pressure eviction — wrong by the difference, and only a rename can fix it.
8834
+ * On 2026-08-30 one such row also stalled a 110 749-file drain permanently.
8835
+ *
8836
+ * Absent on lanes where the question has no meaning: a media blob's size is
8837
+ * in its row, not in its name, so `MediaRelocateEngine` never reconciles one.
8838
+ */
8839
+ rowsReconciled: number().int().nonnegative().optional(),
8825
8840
  startedAt: number(),
8826
8841
  finishedAt: number().nullable(),
8827
8842
  error: string().nullable()
@@ -8890,14 +8905,42 @@ var RelocateMediaInputSchema = object({
8890
8905
  /** Omitted = `move`, the pre-existing behaviour. */
8891
8906
  mode: MediaRelocateModeSchema.optional()
8892
8907
  });
8893
- /** How many rows still carry NO `locationId` — the population a repoint would
8894
- * silently re-aim at a disk that does not hold their bytes. Zero is the only
8895
- * value that permits a non-blocking `eventMedia` cutover. */
8896
- var UnstampedEventMediaCountSchema = object({
8897
- media: number().int().nonnegative(),
8898
- retrainFrames: number().int().nonnegative(),
8899
- total: number().int().nonnegative()
8908
+ /**
8909
+ * The unstamped population of ONE collection — split, because the gate and the
8910
+ * operator ask two different questions and only one of them has to be cheap.
8911
+ *
8912
+ * `present` is the GATE: "is there at least one row that would be orphaned by a
8913
+ * repoint". It is a single indexed seek to the first matching row, so it stays
8914
+ * answerable on a saturated disk and answers in O(log n) precisely in the state
8915
+ * that matters — after a seal, when the population is empty.
8916
+ *
8917
+ * `rows` is the NUMBER, for the refusal message and the operator's sense of
8918
+ * scale. It is a second, indexed `COUNT(*)`, and `null` means **not
8919
+ * measurable** — never zero. `{ present: true, rows: null }` is a legitimate
8920
+ * and useful answer: "there are some, and this read could not say how many"
8921
+ * still refuses the cutover, which is the whole job.
8922
+ */
8923
+ var UnstampedRowsSchema = object({
8924
+ present: boolean(),
8925
+ rows: number().int().nonnegative().nullable()
8900
8926
  });
8927
+ /**
8928
+ * How many rows still carry NO `locationId` — the population a repoint would
8929
+ * silently re-aim at a disk that does not hold their bytes.
8930
+ *
8931
+ * **`null` = the count could not be taken**, and it is NOT permission to cut
8932
+ * over. The gate opens on a measured absence and on nothing else; an unread
8933
+ * collection and an empty one are different facts, and this repo has already
8934
+ * paid for conflating them (`RelocateResidueSchema`, D295).
8935
+ */
8936
+ var UnstampedEventMediaCountSchema = object({
8937
+ media: UnstampedRowsSchema,
8938
+ retrainFrames: UnstampedRowsSchema,
8939
+ /** True when EITHER collection holds one. The refusal reads this. */
8940
+ anyPresent: boolean(),
8941
+ /** Sum across both, or `null` when either lane could not be counted. */
8942
+ total: number().int().nonnegative().nullable()
8943
+ }).nullable();
8901
8944
  var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
8902
8945
  /** The independently selectable logical storage classes — every class
8903
8946
  * `storage.listLocationDeclarations` reports, so an operator never meets a
@@ -8983,13 +9026,53 @@ var StorageMigrationParticipantSchema = _enum([
8983
9026
  "recorder",
8984
9027
  "analytics"
8985
9028
  ]);
9029
+ /**
9030
+ * The mover's own numbers, folded onto the coordinator's durable move record.
9031
+ *
9032
+ * The long half of a non-blocking migration is `draining`, and it is measured
9033
+ * in hours: 136 885 files at ~4 MB/s is about five of them. Before this shape
9034
+ * existed the only place those numbers appeared was a Loki line, so an operator
9035
+ * watching the Admin UI saw `phase: draining` and nothing else for a whole
9036
+ * afternoon.
9037
+ *
9038
+ * It is POLLED, never pushed. Events are telemetry and may be dropped
9039
+ * (D8/D11), and a dropped progress event is indistinguishable from a stalled
9040
+ * mover — which is the exact failure this is meant to end. The coordinator's
9041
+ * `waitForMoves` already fetches the whole {@link RelocateJob} on every tick to
9042
+ * read `state`; folding the counters costs no extra read and makes the durable
9043
+ * record say afterwards how far a move actually got.
9044
+ *
9045
+ * `filesTotal` is `null` for "no honest denominator" and is never zero-filled:
9046
+ * a windowed footage job (`sinceMs`) and a node with no ledger both genuinely
9047
+ * cannot say M, and a 0 there would render as "100 % done".
9048
+ */
9049
+ var StorageMigrationMoveProgressSchema = object({
9050
+ filesMoved: number().int().nonnegative(),
9051
+ /** The archive census — the **M** of "N of M" (D295). `null` = unknowable. */
9052
+ filesTotal: number().int().nonnegative().nullable(),
9053
+ bytesMoved: number().int().nonnegative(),
9054
+ /** Rows the mover corrected while moving them — see `RelocateJob`. Absent on
9055
+ * a lane that cannot reconcile. A migration that silently rewrote durable
9056
+ * rows would be the same failure as one that silently skipped them. */
9057
+ rowsReconciled: number().int().nonnegative().optional(),
9058
+ /** The MOVER's start, not the migration's: a drain restarted after an addon
9059
+ * crash gets a new mover, and a rate computed from the migration's start
9060
+ * would silently average in the time nothing was running. */
9061
+ startedAt: number(),
9062
+ /** When the coordinator last read these numbers. Paired with `startedAt` it
9063
+ * is the only honest rate: both clocks are the hub's, so a UI never has to
9064
+ * subtract its own. */
9065
+ observedAt: number()
9066
+ });
8986
9067
  var StorageMigrationMoveSchema = object({
8987
9068
  storageClass: StorageMigrationClassSchema,
8988
9069
  fromLocationId: string(),
8989
9070
  toLocationId: string(),
8990
9071
  moverJobId: string().nullable(),
8991
9072
  state: RelocateJobStateSchema.nullable(),
8992
- error: string().nullable()
9073
+ error: string().nullable(),
9074
+ /** Last observed mover counters; `null` until the mover has been polled once. */
9075
+ progress: StorageMigrationMoveProgressSchema.nullable()
8993
9076
  });
8994
9077
  var StorageMigrationJobSchema = object({
8995
9078
  jobId: string(),
@@ -9035,6 +9118,98 @@ var StorageMigrationPlanSchema = object({
9035
9118
  findings: array(StorageMigrationFindingSchema)
9036
9119
  });
9037
9120
  /**
9121
+ * A mover as it exists RIGHT NOW, whether or not a migration job owns it.
9122
+ *
9123
+ * The coordinator's job record is the state of record for a migration, and its
9124
+ * moves carry {@link StorageMigrationMoveProgress}. But the movers are usable
9125
+ * standalone — `recording.relocateFootage` and `pipelineAnalytics.relocateMedia`
9126
+ * are both operator-callable, and on 2026-08-29 a five-hour drain was armed that
9127
+ * way because no supported UI path existed. A mover armed like that has no job
9128
+ * to fold progress into, so it has to be readable on its own or it is invisible.
9129
+ *
9130
+ * `migrationJobId` is what tells the two apart: `null` means nothing here
9131
+ * orchestrated it.
9132
+ */
9133
+ var StorageMigrationMoverSchema = object({
9134
+ lane: _enum(["footage", "media"]),
9135
+ job: RelocateJobSchema,
9136
+ /** The coordinator job that armed this mover, or `null` for a mover armed
9137
+ * directly against the owning addon. */
9138
+ migrationJobId: string().nullable(),
9139
+ /** When the hub read these counters. Stamped here so a rate is `bytesMoved`
9140
+ * over (`observedAt` − `job.startedAt`) with BOTH ends on the hub's clock —
9141
+ * a browser subtracting its own `Date.now()` from a server `startedAt` is a
9142
+ * rate made of two different clocks. */
9143
+ observedAt: number()
9144
+ });
9145
+ /**
9146
+ * What a SOURCE still holds for one storage class — the number that makes a
9147
+ * "drain remaining" action honest rather than hopeful.
9148
+ *
9149
+ * It comes from the archive (`SegmentHourLedger.census` for footage, the media
9150
+ * engine's own selection count for media), never from the resident index: a
9151
+ * drain sized off `RecordingIndex` is what reported `done` over 80.3 GB it had
9152
+ * never been told about (D295).
9153
+ *
9154
+ * `items`/`bytes` are `null` for "the archive could not be asked", which is
9155
+ * deliberately NOT zero: a drain is still offered for an unknown residue,
9156
+ * because refusing on an unanswerable read would hide exactly the case an
9157
+ * operator needs to act on.
9158
+ */
9159
+ var StorageMigrationResidueSchema = object({
9160
+ storageClass: StorageMigrationClassSchema,
9161
+ /** The location still holding the data. `'*'` for the media lane, whose rows
9162
+ * move from wherever they are rather than from one named source. */
9163
+ fromLocationId: string(),
9164
+ /** Where a drain would move it — the class's CURRENT default. */
9165
+ toLocationId: string(),
9166
+ /** Segments (footage lane) or rows (media lane) still on the source. */
9167
+ items: number().int().nonnegative().nullable(),
9168
+ /** Bytes on the source; `null` when the lane counts rows rather than bytes. */
9169
+ bytes: number().int().nonnegative().nullable()
9170
+ });
9171
+ /**
9172
+ * Run the DRAIN half and nothing else.
9173
+ *
9174
+ * A migration that reached `done` has already repointed, so `start` correctly
9175
+ * refuses its destination ("already the default") — there is nothing left to
9176
+ * repoint. But the drain can fail, be cancelled, be interrupted by a restart,
9177
+ * or finish against a work list that was a tenth of the archive (D295), and
9178
+ * before this there was no supported way to run only that half: the only way
9179
+ * through was calling `recording.relocateFootage` by hand over admin tRPC.
9180
+ *
9181
+ * `drain` NEVER calls `setDefaultLocations`. That is what keeps `start`'s
9182
+ * refusal meaningful: the two verbs are disjoint, so nothing here can silently
9183
+ * re-repoint a class that is already migrated.
9184
+ */
9185
+ var StorageMigrationDrainInputSchema = object({
9186
+ /** The classes to drain. Each must appear in `storageMigration.residue`, so
9187
+ * a class whose source is already empty is refused rather than started. */
9188
+ classes: array(StorageMigrationClassSchema).min(1),
9189
+ throttleMbps: number().min(1).max(1e3).optional()
9190
+ });
9191
+ /** What a footage source still holds, asked of the durable hour ledger. */
9192
+ var RelocateResidueInputSchema = object({
9193
+ fromLocationId: string().min(1),
9194
+ /** Narrow to one logical class; omit for every profile on the location. */
9195
+ footageClass: RelocateFootageClassSchema.optional()
9196
+ });
9197
+ /** `null` = the archive could not answer (no ledger on this node, or the
9198
+ * aggregate failed). Never conflated with an empty source. */
9199
+ var RelocateResidueSchema = object({
9200
+ segments: number().int().nonnegative(),
9201
+ bytes: number().int().nonnegative()
9202
+ }).nullable();
9203
+ /** How many rows a media pass would still act on against a given target — the
9204
+ * media lane's denominator AND its residue, from ONE derivation so the two can
9205
+ * never disagree. `null` = the count could not be taken. */
9206
+ var RelocatableMediaCountSchema = object({ rows: number().int().nonnegative() }).nullable();
9207
+ var RelocatableMediaCountInputSchema = object({
9208
+ toLocationId: string().min(1),
9209
+ /** Omitted = `move`. */
9210
+ mode: MediaRelocateModeSchema.optional()
9211
+ });
9212
+ /**
9038
9213
  * `StorageLocationType` — an addon-declared id that identifies the *kind* of
9039
9214
  * storage a location serves. Defined here (not in `capabilities/storage.cap.ts`)
9040
9215
  * so the persisted record schema and the consumer-facing cap can both consume it
@@ -9138,6 +9313,32 @@ var StorageLocationRefSchema = union([StorageLocationTypeSchema, string().regex(
9138
9313
  * two addons declaring the same `id` must agree on `cardinality` (validated
9139
9314
  * at kernel aggregation time, not here).
9140
9315
  */
9316
+ /**
9317
+ * `StorageAccess` — how the service that DECLARED a storage-location kind
9318
+ * actually reaches the bytes. It is the constraint that decides which
9319
+ * `storage-provider`s may back a location of that kind.
9320
+ *
9321
+ * - `'local-path'` — the service asks `storage.resolve` for a path string and
9322
+ * then does its own `node:fs` I/O on it (the recorder's segment writer, the
9323
+ * post-analysis media roots). Only a provider that serves a genuine local
9324
+ * filesystem (`getProviderInfo().nodeLocal === true`) can satisfy that: a
9325
+ * remote provider's `resolve` returns a path on the REMOTE host, and
9326
+ * `fs.readdir` of it on this node either fails or — far worse — succeeds
9327
+ * against a same-named local directory that is something else entirely.
9328
+ *
9329
+ * - `'cap-mediated'` — every byte travels through the `storage` cap
9330
+ * (`read`/`write`, or `beginUpload`/`writeChunk`/`finalizeUpload`). The
9331
+ * service never sees a path, so any provider can back it. `backups` is the
9332
+ * one kind that qualifies today.
9333
+ *
9334
+ * Before this existed, `recordings` was unreachable by SFTP/S3/WebDAV only as
9335
+ * an EMERGENT property of how the recorder happened to be written. Nothing
9336
+ * refused the configuration; the first write simply went somewhere wrong, and
9337
+ * a recording write that goes wrong surfaces as a silent black window rather
9338
+ * than an error (the read path does not `stat`). This turns that accident into
9339
+ * a declared, enforced, testable refusal.
9340
+ */
9341
+ var StorageAccessSchema = _enum(["local-path", "cap-mediated"]);
9141
9342
  var StorageLocationDeclarationSchema = object({
9142
9343
  /**
9143
9344
  * Global location identifier, e.g. `recordings` or `recordingsLow`.
@@ -9157,6 +9358,19 @@ var StorageLocationDeclarationSchema = object({
9157
9358
  */
9158
9359
  cardinality: _enum(["single", "multi"]),
9159
9360
  /**
9361
+ * HOW the declaring service reaches the bytes — and therefore WHICH
9362
+ * providers may back a location of this kind. See {@link StorageAccessSchema}
9363
+ * and {@link STORAGE_ACCESS_FALLBACK}.
9364
+ *
9365
+ * Absent means `'local-path'`. That default is FAIL-CLOSED on purpose: it
9366
+ * can only over-restrict (refuse a remote provider for a kind that might
9367
+ * have coped) and never under-restrict. Declaring `'cap-mediated'` is the
9368
+ * permissive direction and is therefore never inferred — a repo guard
9369
+ * (`scripts/check-storage-access-declarations.ts`) refuses to let it be
9370
+ * reached by omission.
9371
+ */
9372
+ access: StorageAccessSchema.optional(),
9373
+ /**
9160
9374
  * When set, the default instance for this location inherits its resolved
9161
9375
  * root from the named location's default instance. Useful for derivative
9162
9376
  * slots (e.g. `recordingsLow` → `recordings`) so operators only need to
@@ -19041,8 +19255,10 @@ var TrackSchema = object({
19041
19255
  lastSeen: number(),
19042
19256
  /** Frame-rate position history (subject to maxPositionHistory cap). */
19043
19257
  positions: array(TrackPositionSchema).readonly(),
19044
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
19045
- * saveThumbnails policy). */
19258
+ /** Periodic snapshots at snapshotIntervalMs cadence — DEBUG media, produced
19259
+ * only while `MediaSettings.debugMediaEnabled` is on for the camera (D299;
19260
+ * the retired `saveThumbnails` used to gate this and the rolling
19261
+ * `lastFrame` together). Empty is the healthy default, not a capture gap. */
19046
19262
  snapshots: array(TrackSnapshotSchema).readonly(),
19047
19263
  /** Deduplicated zones the track has entered at least once. Zone IDS. */
19048
19264
  zonesVisited: array(string()).readonly(),
@@ -19902,7 +20118,10 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
19902
20118
  }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
19903
20119
  kind: "mutation",
19904
20120
  auth: "admin"
19905
- }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(object({}), array(RelocateJobSchema).readonly(), {
20121
+ }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
20122
+ kind: "query",
20123
+ auth: "admin"
20124
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
19906
20125
  kind: "query",
19907
20126
  auth: "admin"
19908
20127
  }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
@@ -21861,6 +22080,9 @@ method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin"
21861
22080
  }), method(object({ jobId: string().optional() }), StorageMigrationJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
21862
22081
  kind: "mutation",
21863
22082
  auth: "admin"
22083
+ }), method(object({}), array(StorageMigrationMoverSchema).readonly(), { auth: "admin" }), method(object({}), array(StorageMigrationResidueSchema).readonly(), { auth: "admin" }), method(StorageMigrationDrainInputSchema, object({ jobId: string() }), {
22084
+ kind: "mutation",
22085
+ auth: "admin"
21864
22086
  });
21865
22087
  var ProviderInfoSchema = discriminatedUnion("shouldSaveDiskSpace", [object({
21866
22088
  providerId: string().min(1),
@@ -22259,12 +22481,38 @@ response: record(string(), unknown()) }), object({
22259
22481
  *
22260
22482
  * ## Why this is a capability and not a helper
22261
22483
  *
22262
- * Six stores in `addon-post-analysis` already hold vectors — object CLIP, face,
22263
- * plate, vehicle, identity, and the event store's derivatives — and every one of
22264
- * them keeps its vectors in a `JSON` settings-store column and ranks them by
22265
- * brute-force cosine in JS. Measured on the live hub that costs ~11.7 KB per row
22266
- * (512 floats as TEXT, `JSON.parse`d on every search) and made semantic search
22267
- * load 5,000 rows before ranking anything.
22484
+ * This capability was introduced with the claim that SIX stores in
22485
+ * `addon-post-analysis` held vectors in a `JSON` settings-store column — object
22486
+ * CLIP, face, plate, vehicle, identity, and the event store's derivatives. That
22487
+ * claim was never true, and leaving it here made five stores look like pending
22488
+ * work when three of them have no vector at all. Counted column by column on
22489
+ * 2026-08-30, exactly THREE ever held one:
22490
+ *
22491
+ * - `object-clip` — 512-dim CLIP image embedding, migrated 2026-08-06.
22492
+ * - `faces.embedding` — 512-dim ArcFace face embedding, migrated 2026-08-30.
22493
+ * - `identity-samples.embedding` — the same ArcFace vector for an ENROLLED
22494
+ * face, migrated 2026-08-30 into its OWN index (see below).
22495
+ *
22496
+ * `plates` and `vehicle-samples` store a plate STRING and a score; `vehicles`
22497
+ * and `identities` store a name; the event store stores no derivative vector.
22498
+ * They are not migration candidates and never were.
22499
+ *
22500
+ * Measured on the live hub the JSON encoding cost ~11.7 KB per row (512 floats
22501
+ * as TEXT, `JSON.parse`d on every search) and made semantic search load 5,000
22502
+ * rows before ranking anything.
22503
+ *
22504
+ * ## One index per COMPARISON, never per encoder
22505
+ *
22506
+ * `faces` and `identity-samples` hold the same 512 ArcFace dims from the same
22507
+ * model, and they still get two indexes. An index is a set of things that are
22508
+ * ranked against each other and that live and die together, and these two are
22509
+ * neither: a `faces` row is TRACK-OWNED and cascades away with its track under
22510
+ * a per-camera capacity cap, an `identity-samples` row is retention-EXEMPT
22511
+ * forever and is the gallery every recognition ranks against. One index would
22512
+ * mean every gallery load and every reconcile carried a filter whose failure
22513
+ * mode is either ranking a candidate against itself or reclaiming an enrolled
22514
+ * person's only sample. The dimension they share is not a reason to share an
22515
+ * index; the question they answer is, and it differs.
22268
22516
  *
22269
22517
  * The fix is not a faster loop, it is a different backend — and the backend
22270
22518
  * should be replaceable without touching six callers. So: a singleton
@@ -22369,7 +22617,20 @@ var VectorQueryResultSchema = object({
22369
22617
  */
22370
22618
  scanned: number(),
22371
22619
  /** True when the backend could not consider every row that passed the filter. */
22372
- truncated: boolean()
22620
+ truncated: boolean(),
22621
+ /**
22622
+ * The `topK` the backend actually ran with.
22623
+ *
22624
+ * Every backend has a ceiling — sqlite-vec's is 4,096 — and a caller asking
22625
+ * past it used to learn nothing but a boolean, from a WARN in the provider's
22626
+ * own log rather than in its answer. That is how an audit asking for 20,000
22627
+ * consumed 4,096 and reported `examined: 4096` as if it had walked the index,
22628
+ * for weeks. `truncated` says THAT the answer was short; this says BY HOW
22629
+ * MUCH, in the return value, where the caller cannot fail to see it.
22630
+ *
22631
+ * Equals the requested `topK` whenever nothing was lowered.
22632
+ */
22633
+ effectiveTopK: number().int().positive()
22373
22634
  });
22374
22635
  var VectorDeleteInputSchema = object({
22375
22636
  index: string(),
@@ -22398,6 +22659,68 @@ var VectorGetResultSchema = object({ items: array(object({
22398
22659
  id: string(),
22399
22660
  metadata: VectorMetadataSchema
22400
22661
  })) });
22662
+ /**
22663
+ * Ids to read back WITH their vectors.
22664
+ *
22665
+ * The sibling of {@link VectorGetResultSchema}, and deliberately a separate
22666
+ * method rather than a flag on it: `getByIds` promises no vectors and its one
22667
+ * caller depends on that promise. This one promises the opposite.
22668
+ *
22669
+ * It exists because a store cannot put its vectors here otherwise. An ArcFace
22670
+ * gallery is ranked IN PROCESS, per detection, against every enrolled sample —
22671
+ * a per-face cross-process KNN would be a network round trip inside the
22672
+ * recognition loop. So the gallery is loaded once and held in RAM, and loading
22673
+ * it requires the index to hand the floats back. Without this method the only
22674
+ * way to keep a readable vector is a JSON column, which is the thing this
22675
+ * capability exists to delete.
22676
+ *
22677
+ * BOUNDED BY THE CALLER: ids are named, never "everything". Enumerating an
22678
+ * index is {@link VectorScanInputSchema}'s job, and it returns no vectors.
22679
+ */
22680
+ var VectorFetchInputSchema = object({
22681
+ index: string(),
22682
+ ids: array(string())
22683
+ });
22684
+ var VectorFetchResultSchema = object({ items: array(object({
22685
+ id: string(),
22686
+ /** base64 Float32LE — the same wire form `upsert` accepts. */
22687
+ vector: string(),
22688
+ metadata: VectorMetadataSchema
22689
+ })) });
22690
+ /**
22691
+ * ENUMERATE an index: one page of rows in a stable order, no ranking.
22692
+ *
22693
+ * A reconcile does not want the nearest rows, it wants ALL of them, and asking
22694
+ * a KNN for "all" is the wrong question twice over. It hits the backend's `k`
22695
+ * ceiling — 4,096 on sqlite-vec against a 22,128-row index — and it needs a
22696
+ * probe vector it does not have, so the audit passed a ZERO vector whose cosine
22697
+ * distance to every row is degenerate. `examined: 4096` then read as "we
22698
+ * looked" for as long as anyone cared to read it.
22699
+ *
22700
+ * This is the primitive that question actually needs: a bounded page, ordered
22701
+ * by the backend's own row order, costing no distance computation at all.
22702
+ * Vectors are NOT returned — an enumeration that shipped 2 KB per row would be
22703
+ * the full-table read this capability was built to stop.
22704
+ */
22705
+ var VectorScanInputSchema = object({
22706
+ index: string(),
22707
+ /** Opaque resume point. `0` starts at the top; pass back `nextCursor`. */
22708
+ cursor: number().int().nonnegative().default(0),
22709
+ limit: number().int().positive()
22710
+ });
22711
+ var VectorScanResultSchema = object({
22712
+ items: array(object({
22713
+ id: string(),
22714
+ metadata: VectorMetadataSchema
22715
+ })),
22716
+ /**
22717
+ * Where the next page starts, or `null` when the walk reached the end.
22718
+ *
22719
+ * `null` is the ONLY end-of-index signal. A caller must not infer the end
22720
+ * from a short page: a backend is free to return fewer rows than asked.
22721
+ */
22722
+ nextCursor: number().int().nonnegative().nullable()
22723
+ });
22401
22724
  var VectorStatsInputSchema = object({ index: string() });
22402
22725
  var VectorStatsResultSchema = object({
22403
22726
  /** Provider id, so an operator can tell brute force from an ANN index. */
@@ -22416,7 +22739,7 @@ method(VectorDeclareIndexInputSchema, _void(), {
22416
22739
  }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
22417
22740
  kind: "mutation",
22418
22741
  auth: "admin"
22419
- }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
22742
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorFetchInputSchema, VectorFetchResultSchema, { auth: "admin" }), method(VectorScanInputSchema, VectorScanResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
22420
22743
  kind: "mutation",
22421
22744
  auth: "admin"
22422
22745
  }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
@@ -29043,6 +29366,9 @@ method(object({
29043
29366
  }), method(object({}), array(RelocateJobSchema).readonly(), {
29044
29367
  kind: "query",
29045
29368
  auth: "admin"
29369
+ }), method(RelocateResidueInputSchema, RelocateResidueSchema, {
29370
+ kind: "query",
29371
+ auth: "admin"
29046
29372
  }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
29047
29373
  kind: "mutation",
29048
29374
  auth: "admin"
@@ -35677,6 +36003,12 @@ Object.freeze({
35677
36003
  addonId: null,
35678
36004
  access: "create"
35679
36005
  },
36006
+ "pipelineAnalytics.countRelocatableMedia": {
36007
+ capName: "pipeline-analytics",
36008
+ capScope: "device",
36009
+ addonId: null,
36010
+ access: "view"
36011
+ },
35680
36012
  "pipelineAnalytics.countUnstampedEventMedia": {
35681
36013
  capName: "pipeline-analytics",
35682
36014
  capScope: "device",
@@ -36841,6 +37173,12 @@ Object.freeze({
36841
37173
  addonId: null,
36842
37174
  access: "view"
36843
37175
  },
37176
+ "recording.getRelocateResidue": {
37177
+ capName: "recording",
37178
+ capScope: "system",
37179
+ addonId: null,
37180
+ access: "view"
37181
+ },
36844
37182
  "recording.getStorageMigrationMoveStatus": {
36845
37183
  capName: "recording",
36846
37184
  capScope: "system",
@@ -37387,12 +37725,30 @@ Object.freeze({
37387
37725
  addonId: null,
37388
37726
  access: "create"
37389
37727
  },
37728
+ "storageMigration.drain": {
37729
+ capName: "storage-migration",
37730
+ capScope: "system",
37731
+ addonId: null,
37732
+ access: "create"
37733
+ },
37734
+ "storageMigration.movers": {
37735
+ capName: "storage-migration",
37736
+ capScope: "system",
37737
+ addonId: null,
37738
+ access: "view"
37739
+ },
37390
37740
  "storageMigration.plan": {
37391
37741
  capName: "storage-migration",
37392
37742
  capScope: "system",
37393
37743
  addonId: null,
37394
37744
  access: "view"
37395
37745
  },
37746
+ "storageMigration.residue": {
37747
+ capName: "storage-migration",
37748
+ capScope: "system",
37749
+ addonId: null,
37750
+ access: "view"
37751
+ },
37396
37752
  "storageMigration.start": {
37397
37753
  capName: "storage-migration",
37398
37754
  capScope: "system",
@@ -38227,6 +38583,12 @@ Object.freeze({
38227
38583
  addonId: null,
38228
38584
  access: "delete"
38229
38585
  },
38586
+ "vectorStore.fetchByIds": {
38587
+ capName: "vector-store",
38588
+ capScope: "system",
38589
+ addonId: null,
38590
+ access: "view"
38591
+ },
38230
38592
  "vectorStore.getByIds": {
38231
38593
  capName: "vector-store",
38232
38594
  capScope: "system",
@@ -38239,6 +38601,12 @@ Object.freeze({
38239
38601
  addonId: null,
38240
38602
  access: "view"
38241
38603
  },
38604
+ "vectorStore.scan": {
38605
+ capName: "vector-store",
38606
+ capScope: "system",
38607
+ addonId: null,
38608
+ access: "view"
38609
+ },
38242
38610
  "vectorStore.stats": {
38243
38611
  capName: "vector-store",
38244
38612
  capScope: "system",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-tuya",
3
- "version": "0.2.43",
3
+ "version": "0.2.46",
4
4
  "description": "Tuya / Smart Life device-provider addon for CamStack — account-onboarded (Tuya IoT cloud fetch of device localKeys) + LOCAL DP control via the @apocaliss92/nodetuya encrypted-LAN client, exposing switch / water-heater-family kettle entities",
5
5
  "keywords": [
6
6
  "camstack",