@camstack/addon-provider-reolink 1.2.119 → 1.2.121

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 +182 -24
  2. package/dist/addon.mjs +182 -24
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -7341,6 +7341,23 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
7341
7341
  function sleep$2(ms) {
7342
7342
  return new Promise((resolve) => setTimeout(resolve, Math.max(0, ms)));
7343
7343
  }
7344
+ new Set([
7345
+ "track",
7346
+ "summary",
7347
+ "face",
7348
+ "identity",
7349
+ "plate",
7350
+ "vehicle",
7351
+ "scene",
7352
+ "motion",
7353
+ "object",
7354
+ "audio"
7355
+ ]);
7356
+ new Set([
7357
+ "motion",
7358
+ "object",
7359
+ "audio"
7360
+ ]);
7344
7361
  var EncodeProfileSchema = object({
7345
7362
  video: object({
7346
7363
  codec: _enum([
@@ -13107,8 +13124,17 @@ method(object({
13107
13124
  }), array(SettingsRecordSchema).readonly()), method(object({
13108
13125
  namespace: string().optional(),
13109
13126
  collection: string(),
13110
- record: SettingsRecordSchema
13111
- }), _void(), { kind: "mutation" }), method(object({
13127
+ record: object({
13128
+ id: string().optional(),
13129
+ data: record(string(), unknown())
13130
+ })
13131
+ }), object({
13132
+ /**
13133
+ * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
13134
+ * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
13135
+ * primary key — which is the only place an auto key is knowable.
13136
+ */
13137
+ id: union([string(), number()]) }), { kind: "mutation" }), method(object({
13112
13138
  namespace: string().optional(),
13113
13139
  collection: string(),
13114
13140
  records: array(BulkRecordSchema).readonly()
@@ -13217,8 +13243,17 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
13217
13243
  }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
13218
13244
  namespace: string().optional(),
13219
13245
  collection: string(),
13220
- record: SettingsRecordSchema
13221
- }), _void(), {
13246
+ record: object({
13247
+ id: string().optional(),
13248
+ data: record(string(), unknown())
13249
+ })
13250
+ }), object({
13251
+ /**
13252
+ * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
13253
+ * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
13254
+ * primary key — which is the only place an auto key is knowable.
13255
+ */
13256
+ id: union([string(), number()]) }), {
13222
13257
  kind: "mutation",
13223
13258
  auth: "admin"
13224
13259
  }), method(object({
@@ -20166,7 +20201,20 @@ var TrackSchema = object({
20166
20201
  ...TrackRetrainFields
20167
20202
  });
20168
20203
  var BaseEventFields = {
20169
- id: string(),
20204
+ /**
20205
+ * A SQLite ROWID, assigned by the database (D474).
20206
+ *
20207
+ * Was a 36-character UUID and cost 263 MB of a 1 117 MB database — paid
20208
+ * TWICE per row, in the row and in the primary-key index, across 2.1 million
20209
+ * motion, audio and object events. An `INTEGER PRIMARY KEY` in SQLite **is**
20210
+ * the rowid: the table itself is that B-tree, so the index stops existing
20211
+ * rather than getting smaller. No shorter string does that.
20212
+ *
20213
+ * Defined once here for all three event kinds, which is why they move
20214
+ * together: a per-table migration would have forked this and
20215
+ * `COMMON_BASE_COLUMNS` and reunited them two stages later.
20216
+ */
20217
+ id: number().int(),
20170
20218
  deviceId: number(),
20171
20219
  timestamp: number()
20172
20220
  };
@@ -20185,7 +20233,34 @@ var MotionEventSchema = object({
20185
20233
  /** Omitted in slim projection. */
20186
20234
  frameHeight: number().optional(),
20187
20235
  /** Populated by B5 (recording playback URL for this event). */
20188
- mediaUrl: string().optional()
20236
+ mediaUrl: string().optional(),
20237
+ /**
20238
+ * One row per motion EPISODE, not one per push (D475). `null` while the
20239
+ * episode is still open — a further rising edge extends it in place rather
20240
+ * than inserting a new row. Set once, at close, to `lastOnAt - startedAt`
20241
+ * (the span from the first rising edge to the LAST one, deliberately NOT
20242
+ * `closedAt - startedAt` — the close delay is a quiet CONFIRMATION, not
20243
+ * movement, and folding it in would report `MOTION_CLOSE_AFTER_MS` of
20244
+ * motion for an instantaneous trigger).
20245
+ *
20246
+ * **Absent** (not merely `null`) on a row written before D475 — that means
20247
+ * "closed the old way, before this column existed", never "still open".
20248
+ * Nothing in this codebase may read an absent `durationMs` as an open
20249
+ * episode; only `null` means open.
20250
+ */
20251
+ durationMs: number().nullable().optional(),
20252
+ /**
20253
+ * Ms offsets from `timestamp` (the episode's own first rising edge, so the
20254
+ * first entry is always `0`) of every genuine off→on transition the
20255
+ * episode saw — "ogni evento on si deve salvare" (D475). NOT one entry per
20256
+ * push: a firmware source that keepalives at ~1 Hz for the whole burst
20257
+ * (Reolink, Hikvision) produces exactly one edge; a source that reports an
20258
+ * explicit `false` mid-episode and then resumes before the quiet window
20259
+ * elapses produces another. Stored compactly — see `motion-edge-codec.ts`
20260
+ * — and decoded back to this shape on read. Absent/empty on a legacy row,
20261
+ * which must never be read as "no episode happened here".
20262
+ */
20263
+ edges: array(number()).readonly().optional()
20189
20264
  });
20190
20265
  /**
20191
20266
  * Which detection SOURCE produced an object event. `pipeline` = the ML
@@ -20240,6 +20315,23 @@ var ObjectEventSchema = object({
20240
20315
  * includes it (it is light). Absent on rows written before this field.
20241
20316
  */
20242
20317
  frameId: string().optional(),
20318
+ /**
20319
+ * A PRODUCER-chosen key that makes a synthetic event's emission idempotent
20320
+ * (D474).
20321
+ *
20322
+ * Only the package detector writes it, and it exists because the event id
20323
+ * stopped being choosable: the delivery and pick-up rows used to BE their
20324
+ * dedupe key (`pa-pkg-<entryId>-delivered`), which is how "never emit a
20325
+ * second delivery for this entry" survived a restart. An `INTEGER` rowid is
20326
+ * assigned by SQLite, so that key had to move off the primary key rather
20327
+ * than be dropped — a detector that cannot recognise its own row re-delivers
20328
+ * every parcel on every boot.
20329
+ *
20330
+ * Absent on every other object event, and on every row written before this
20331
+ * field. Never a substitute for `id`: it is unique per (producer, occasion),
20332
+ * not per row, and nothing addresses a row by it.
20333
+ */
20334
+ idempotencyKey: string().optional(),
20243
20335
  /** Omitted in slim projection. */
20244
20336
  trackId: string().optional(),
20245
20337
  className: string(),
@@ -21342,6 +21434,14 @@ var NativeCropResultSchema = object({
21342
21434
  * set `encodeJpeg: true`; `bytes` is then absent.
21343
21435
  */
21344
21436
  jpeg: string().optional(),
21437
+ /**
21438
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
21439
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
21440
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
21441
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
21442
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
21443
+ */
21444
+ jpegBytes: _instanceof(Uint8Array).optional(),
21345
21445
  width: number().int().positive(),
21346
21446
  height: number().int().positive(),
21347
21447
  /**
@@ -21408,7 +21508,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
21408
21508
  })]);
21409
21509
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
21410
21510
  var ParkedTrackFrameSchema = object({
21411
- jpeg: string(),
21511
+ /**
21512
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
21513
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
21514
+ * Exactly one of the two is present.
21515
+ */
21516
+ jpeg: string().optional(),
21517
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
21518
+ jpegBytes: _instanceof(Uint8Array).optional(),
21412
21519
  width: number().int().positive(),
21413
21520
  height: number().int().positive(),
21414
21521
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -21995,6 +22102,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21995
22102
  bbox: NativeCropBboxSchema,
21996
22103
  maxWidth: number().int().positive().optional(),
21997
22104
  /**
22105
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
22106
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
22107
+ * wire — never assume consent: a pre-D462 caller parses the field as
22108
+ * base64 and bytes would decode to garbage rather than fail.
22109
+ */
22110
+ acceptJpegBytes: boolean().optional(),
22111
+ /**
21998
22112
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
21999
22113
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
22000
22114
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -22062,7 +22176,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
22062
22176
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
22063
22177
  deviceId: number(),
22064
22178
  trackId: string(),
22065
- kind: ParkedFrameKindSchema
22179
+ kind: ParkedFrameKindSchema,
22180
+ /**
22181
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
22182
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
22183
+ * wire — never assume consent: a pre-D462 caller parses the field as
22184
+ * base64 and bytes would decode to garbage rather than fail.
22185
+ */
22186
+ acceptJpegBytes: boolean().optional()
22066
22187
  }), ParkedTrackFrameSchema.nullable()), method(object({
22067
22188
  deviceId: number(),
22068
22189
  trackId: string()
@@ -28564,26 +28685,59 @@ authKey: string().optional() }), object({
28564
28685
  /** Human-readable error when `ok: false`. */
28565
28686
  error: string().optional()
28566
28687
  }), { kind: "mutation" });
28567
- /**
28568
- * Hardware / firmware motion sensor cap — binary detected state plus
28569
- * a timestamp of the last observation. Distinct from
28570
- * `motion-detection.cap.ts` which owns the LOCAL ML motion pipeline;
28571
- * `motion` is the lightweight readout from on-camera motion (Reolink
28572
- * `GetMdState`, Baichuan push `type: motion`, ONVIF analytics).
28573
- *
28574
- * Native-motion providers also fan out to `detection.camera-native`
28575
- * with `source: 'onboard'` so cross-cutting system services
28576
- * (alert-center, advanced-notifier) can subscribe once and receive
28577
- * motion from every camera.
28578
- */
28579
28688
  var MotionStatusSchema = object({
28580
28689
  detected: boolean(),
28581
28690
  /** Ms epoch of the last detected-true observation. Null if never detected. */
28582
28691
  lastDetectedAt: number().nullable(),
28583
28692
  /**
28584
- * Ms after which `detected` auto-reverts to false if no fresh push
28585
- * arrives. Null means the provider leaves detected state until a
28586
- * native "clear" event.
28693
+ * `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
28694
+ * `null` while false and on every `Sensor` device (D475) — see that
28695
+ * constant's doc for the one-authority rule.
28696
+ *
28697
+ * ## Reading this field still arms nothing
28698
+ *
28699
+ * It reads like an instruction to the consumer ("revert after N ms if
28700
+ * no fresh push arrives") and it is not one: nothing in this repo reads
28701
+ * the LIVE cap value to drive a timer. `pipeline-analytics`'s motion-episode
28702
+ * close DOES now use the same number — `MOTION_CLOSE_AFTER_MS` — but as an
28703
+ * imported constant, not as a read of `device.state.motion.value`, so this
28704
+ * field stays what it always was: DESCRIPTIVE output, mirroring an answer
28705
+ * computed elsewhere. Building a self-clear timer out of a READ of this
28706
+ * field would add a second falling-edge authority beside whichever one
28707
+ * already owns the device, and two that can disagree are worse than one.
28708
+ * Consumers that need a falling edge SHAPED differently — held open across
28709
+ * a flapping source — debounce on their own side and say so, as
28710
+ * `addon-export-alexa/src/motion-clear-hold.ts` and
28711
+ * `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
28712
+ *
28713
+ * ## Who writes it
28714
+ *
28715
+ * - **Cameras** — the runner's phase machine, `active → watching` on
28716
+ * `cooldown_expired`, which then writes this slice with
28717
+ * `detected: false` (`handlePhaseChanged` in
28718
+ * `pipeline-runner/index.ts`). It produces the FALLING edge, which
28719
+ * matters most for the sources that only ever push a rising one:
28720
+ * Reolink emits `MotionOnMotionChanged { detected: true }` and never
28721
+ * a false.
28722
+ * - **Sensors** (Home Assistant binary sensors, Homematic) — the
28723
+ * provider pushes the false itself, from the upstream system's own
28724
+ * state change. No phase machine is involved.
28725
+ *
28726
+ * ### The phase machine is CANONICAL, not sole — and that is a defect
28727
+ *
28728
+ * An earlier revision of this docblock (mine, 2026-09-12) claimed the
28729
+ * phase machine is the sole writer for a camera. It is not.
28730
+ * `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
28731
+ * `setCapSlice(motionCapability, …)` on their own rising edge, and
28732
+ * Hikvision's comment says why: it read THIS docblock, agreed the
28733
+ * runner is canonical, and wrote anyway to avoid per-tick churn. So
28734
+ * two authorities can disagree about one slice, which this repo
28735
+ * forbids, and the doc said otherwise — which is worse than saying
28736
+ * nothing, because it reads as verification.
28737
+ *
28738
+ * This predates D475 and is not fixed there: the fix touches every
28739
+ * camera provider. Recorded in D475's Consequences. Do not restore the
28740
+ * "sole writer" wording without also removing the other writers.
28587
28741
  */
28588
28742
  autoClearAfterMs: number().nullable()
28589
28743
  });
@@ -28653,7 +28807,11 @@ onMotionChanged: { data: MotionOnMotionChangedDataSchema } },
28653
28807
  */
28654
28808
  runtimeState: MotionStatusSchema,
28655
28809
  /**
28656
- * Runtime-state durability: **session** — self-clearing by construction (`autoClearAfterMs`); a restored `detected: true` is a frozen event, and the next frame re-publishes the real one.
28810
+ * Runtime-state durability: **session** — every writer of this slice
28811
+ * writes only on an EDGE, so a restored `detected: true` would stay
28812
+ * frozen until the next one instead of being corrected. The next edge
28813
+ * re-publishes the real state. (On who the writers are, and why there
28814
+ * is more than one, see `autoClearAfterMs` above.)
28657
28815
  *
28658
28816
  * See `RuntimeStateDurability`. Enforced by
28659
28817
  * `scripts/check-runtime-state-durability.ts`.
package/dist/addon.mjs CHANGED
@@ -7336,6 +7336,23 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
7336
7336
  function sleep$2(ms) {
7337
7337
  return new Promise((resolve) => setTimeout(resolve, Math.max(0, ms)));
7338
7338
  }
7339
+ new Set([
7340
+ "track",
7341
+ "summary",
7342
+ "face",
7343
+ "identity",
7344
+ "plate",
7345
+ "vehicle",
7346
+ "scene",
7347
+ "motion",
7348
+ "object",
7349
+ "audio"
7350
+ ]);
7351
+ new Set([
7352
+ "motion",
7353
+ "object",
7354
+ "audio"
7355
+ ]);
7339
7356
  var EncodeProfileSchema = object({
7340
7357
  video: object({
7341
7358
  codec: _enum([
@@ -13102,8 +13119,17 @@ method(object({
13102
13119
  }), array(SettingsRecordSchema).readonly()), method(object({
13103
13120
  namespace: string().optional(),
13104
13121
  collection: string(),
13105
- record: SettingsRecordSchema
13106
- }), _void(), { kind: "mutation" }), method(object({
13122
+ record: object({
13123
+ id: string().optional(),
13124
+ data: record(string(), unknown())
13125
+ })
13126
+ }), object({
13127
+ /**
13128
+ * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
13129
+ * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
13130
+ * primary key — which is the only place an auto key is knowable.
13131
+ */
13132
+ id: union([string(), number()]) }), { kind: "mutation" }), method(object({
13107
13133
  namespace: string().optional(),
13108
13134
  collection: string(),
13109
13135
  records: array(BulkRecordSchema).readonly()
@@ -13212,8 +13238,17 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
13212
13238
  }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
13213
13239
  namespace: string().optional(),
13214
13240
  collection: string(),
13215
- record: SettingsRecordSchema
13216
- }), _void(), {
13241
+ record: object({
13242
+ id: string().optional(),
13243
+ data: record(string(), unknown())
13244
+ })
13245
+ }), object({
13246
+ /**
13247
+ * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
13248
+ * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
13249
+ * primary key — which is the only place an auto key is knowable.
13250
+ */
13251
+ id: union([string(), number()]) }), {
13217
13252
  kind: "mutation",
13218
13253
  auth: "admin"
13219
13254
  }), method(object({
@@ -20161,7 +20196,20 @@ var TrackSchema = object({
20161
20196
  ...TrackRetrainFields
20162
20197
  });
20163
20198
  var BaseEventFields = {
20164
- id: string(),
20199
+ /**
20200
+ * A SQLite ROWID, assigned by the database (D474).
20201
+ *
20202
+ * Was a 36-character UUID and cost 263 MB of a 1 117 MB database — paid
20203
+ * TWICE per row, in the row and in the primary-key index, across 2.1 million
20204
+ * motion, audio and object events. An `INTEGER PRIMARY KEY` in SQLite **is**
20205
+ * the rowid: the table itself is that B-tree, so the index stops existing
20206
+ * rather than getting smaller. No shorter string does that.
20207
+ *
20208
+ * Defined once here for all three event kinds, which is why they move
20209
+ * together: a per-table migration would have forked this and
20210
+ * `COMMON_BASE_COLUMNS` and reunited them two stages later.
20211
+ */
20212
+ id: number().int(),
20165
20213
  deviceId: number(),
20166
20214
  timestamp: number()
20167
20215
  };
@@ -20180,7 +20228,34 @@ var MotionEventSchema = object({
20180
20228
  /** Omitted in slim projection. */
20181
20229
  frameHeight: number().optional(),
20182
20230
  /** Populated by B5 (recording playback URL for this event). */
20183
- mediaUrl: string().optional()
20231
+ mediaUrl: string().optional(),
20232
+ /**
20233
+ * One row per motion EPISODE, not one per push (D475). `null` while the
20234
+ * episode is still open — a further rising edge extends it in place rather
20235
+ * than inserting a new row. Set once, at close, to `lastOnAt - startedAt`
20236
+ * (the span from the first rising edge to the LAST one, deliberately NOT
20237
+ * `closedAt - startedAt` — the close delay is a quiet CONFIRMATION, not
20238
+ * movement, and folding it in would report `MOTION_CLOSE_AFTER_MS` of
20239
+ * motion for an instantaneous trigger).
20240
+ *
20241
+ * **Absent** (not merely `null`) on a row written before D475 — that means
20242
+ * "closed the old way, before this column existed", never "still open".
20243
+ * Nothing in this codebase may read an absent `durationMs` as an open
20244
+ * episode; only `null` means open.
20245
+ */
20246
+ durationMs: number().nullable().optional(),
20247
+ /**
20248
+ * Ms offsets from `timestamp` (the episode's own first rising edge, so the
20249
+ * first entry is always `0`) of every genuine off→on transition the
20250
+ * episode saw — "ogni evento on si deve salvare" (D475). NOT one entry per
20251
+ * push: a firmware source that keepalives at ~1 Hz for the whole burst
20252
+ * (Reolink, Hikvision) produces exactly one edge; a source that reports an
20253
+ * explicit `false` mid-episode and then resumes before the quiet window
20254
+ * elapses produces another. Stored compactly — see `motion-edge-codec.ts`
20255
+ * — and decoded back to this shape on read. Absent/empty on a legacy row,
20256
+ * which must never be read as "no episode happened here".
20257
+ */
20258
+ edges: array(number()).readonly().optional()
20184
20259
  });
20185
20260
  /**
20186
20261
  * Which detection SOURCE produced an object event. `pipeline` = the ML
@@ -20235,6 +20310,23 @@ var ObjectEventSchema = object({
20235
20310
  * includes it (it is light). Absent on rows written before this field.
20236
20311
  */
20237
20312
  frameId: string().optional(),
20313
+ /**
20314
+ * A PRODUCER-chosen key that makes a synthetic event's emission idempotent
20315
+ * (D474).
20316
+ *
20317
+ * Only the package detector writes it, and it exists because the event id
20318
+ * stopped being choosable: the delivery and pick-up rows used to BE their
20319
+ * dedupe key (`pa-pkg-<entryId>-delivered`), which is how "never emit a
20320
+ * second delivery for this entry" survived a restart. An `INTEGER` rowid is
20321
+ * assigned by SQLite, so that key had to move off the primary key rather
20322
+ * than be dropped — a detector that cannot recognise its own row re-delivers
20323
+ * every parcel on every boot.
20324
+ *
20325
+ * Absent on every other object event, and on every row written before this
20326
+ * field. Never a substitute for `id`: it is unique per (producer, occasion),
20327
+ * not per row, and nothing addresses a row by it.
20328
+ */
20329
+ idempotencyKey: string().optional(),
20238
20330
  /** Omitted in slim projection. */
20239
20331
  trackId: string().optional(),
20240
20332
  className: string(),
@@ -21337,6 +21429,14 @@ var NativeCropResultSchema = object({
21337
21429
  * set `encodeJpeg: true`; `bytes` is then absent.
21338
21430
  */
21339
21431
  jpeg: string().optional(),
21432
+ /**
21433
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
21434
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
21435
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
21436
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
21437
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
21438
+ */
21439
+ jpegBytes: _instanceof(Uint8Array).optional(),
21340
21440
  width: number().int().positive(),
21341
21441
  height: number().int().positive(),
21342
21442
  /**
@@ -21403,7 +21503,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
21403
21503
  })]);
21404
21504
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
21405
21505
  var ParkedTrackFrameSchema = object({
21406
- jpeg: string(),
21506
+ /**
21507
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
21508
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
21509
+ * Exactly one of the two is present.
21510
+ */
21511
+ jpeg: string().optional(),
21512
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
21513
+ jpegBytes: _instanceof(Uint8Array).optional(),
21407
21514
  width: number().int().positive(),
21408
21515
  height: number().int().positive(),
21409
21516
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -21990,6 +22097,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21990
22097
  bbox: NativeCropBboxSchema,
21991
22098
  maxWidth: number().int().positive().optional(),
21992
22099
  /**
22100
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
22101
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
22102
+ * wire — never assume consent: a pre-D462 caller parses the field as
22103
+ * base64 and bytes would decode to garbage rather than fail.
22104
+ */
22105
+ acceptJpegBytes: boolean().optional(),
22106
+ /**
21993
22107
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
21994
22108
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
21995
22109
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -22057,7 +22171,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
22057
22171
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
22058
22172
  deviceId: number(),
22059
22173
  trackId: string(),
22060
- kind: ParkedFrameKindSchema
22174
+ kind: ParkedFrameKindSchema,
22175
+ /**
22176
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
22177
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
22178
+ * wire — never assume consent: a pre-D462 caller parses the field as
22179
+ * base64 and bytes would decode to garbage rather than fail.
22180
+ */
22181
+ acceptJpegBytes: boolean().optional()
22061
22182
  }), ParkedTrackFrameSchema.nullable()), method(object({
22062
22183
  deviceId: number(),
22063
22184
  trackId: string()
@@ -28559,26 +28680,59 @@ authKey: string().optional() }), object({
28559
28680
  /** Human-readable error when `ok: false`. */
28560
28681
  error: string().optional()
28561
28682
  }), { kind: "mutation" });
28562
- /**
28563
- * Hardware / firmware motion sensor cap — binary detected state plus
28564
- * a timestamp of the last observation. Distinct from
28565
- * `motion-detection.cap.ts` which owns the LOCAL ML motion pipeline;
28566
- * `motion` is the lightweight readout from on-camera motion (Reolink
28567
- * `GetMdState`, Baichuan push `type: motion`, ONVIF analytics).
28568
- *
28569
- * Native-motion providers also fan out to `detection.camera-native`
28570
- * with `source: 'onboard'` so cross-cutting system services
28571
- * (alert-center, advanced-notifier) can subscribe once and receive
28572
- * motion from every camera.
28573
- */
28574
28683
  var MotionStatusSchema = object({
28575
28684
  detected: boolean(),
28576
28685
  /** Ms epoch of the last detected-true observation. Null if never detected. */
28577
28686
  lastDetectedAt: number().nullable(),
28578
28687
  /**
28579
- * Ms after which `detected` auto-reverts to false if no fresh push
28580
- * arrives. Null means the provider leaves detected state until a
28581
- * native "clear" event.
28688
+ * `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
28689
+ * `null` while false and on every `Sensor` device (D475) — see that
28690
+ * constant's doc for the one-authority rule.
28691
+ *
28692
+ * ## Reading this field still arms nothing
28693
+ *
28694
+ * It reads like an instruction to the consumer ("revert after N ms if
28695
+ * no fresh push arrives") and it is not one: nothing in this repo reads
28696
+ * the LIVE cap value to drive a timer. `pipeline-analytics`'s motion-episode
28697
+ * close DOES now use the same number — `MOTION_CLOSE_AFTER_MS` — but as an
28698
+ * imported constant, not as a read of `device.state.motion.value`, so this
28699
+ * field stays what it always was: DESCRIPTIVE output, mirroring an answer
28700
+ * computed elsewhere. Building a self-clear timer out of a READ of this
28701
+ * field would add a second falling-edge authority beside whichever one
28702
+ * already owns the device, and two that can disagree are worse than one.
28703
+ * Consumers that need a falling edge SHAPED differently — held open across
28704
+ * a flapping source — debounce on their own side and say so, as
28705
+ * `addon-export-alexa/src/motion-clear-hold.ts` and
28706
+ * `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
28707
+ *
28708
+ * ## Who writes it
28709
+ *
28710
+ * - **Cameras** — the runner's phase machine, `active → watching` on
28711
+ * `cooldown_expired`, which then writes this slice with
28712
+ * `detected: false` (`handlePhaseChanged` in
28713
+ * `pipeline-runner/index.ts`). It produces the FALLING edge, which
28714
+ * matters most for the sources that only ever push a rising one:
28715
+ * Reolink emits `MotionOnMotionChanged { detected: true }` and never
28716
+ * a false.
28717
+ * - **Sensors** (Home Assistant binary sensors, Homematic) — the
28718
+ * provider pushes the false itself, from the upstream system's own
28719
+ * state change. No phase machine is involved.
28720
+ *
28721
+ * ### The phase machine is CANONICAL, not sole — and that is a defect
28722
+ *
28723
+ * An earlier revision of this docblock (mine, 2026-09-12) claimed the
28724
+ * phase machine is the sole writer for a camera. It is not.
28725
+ * `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
28726
+ * `setCapSlice(motionCapability, …)` on their own rising edge, and
28727
+ * Hikvision's comment says why: it read THIS docblock, agreed the
28728
+ * runner is canonical, and wrote anyway to avoid per-tick churn. So
28729
+ * two authorities can disagree about one slice, which this repo
28730
+ * forbids, and the doc said otherwise — which is worse than saying
28731
+ * nothing, because it reads as verification.
28732
+ *
28733
+ * This predates D475 and is not fixed there: the fix touches every
28734
+ * camera provider. Recorded in D475's Consequences. Do not restore the
28735
+ * "sole writer" wording without also removing the other writers.
28582
28736
  */
28583
28737
  autoClearAfterMs: number().nullable()
28584
28738
  });
@@ -28648,7 +28802,11 @@ onMotionChanged: { data: MotionOnMotionChangedDataSchema } },
28648
28802
  */
28649
28803
  runtimeState: MotionStatusSchema,
28650
28804
  /**
28651
- * Runtime-state durability: **session** — self-clearing by construction (`autoClearAfterMs`); a restored `detected: true` is a frozen event, and the next frame re-publishes the real one.
28805
+ * Runtime-state durability: **session** — every writer of this slice
28806
+ * writes only on an EDGE, so a restored `detected: true` would stay
28807
+ * frozen until the next one instead of being corrected. The next edge
28808
+ * re-publishes the real state. (On who the writers are, and why there
28809
+ * is more than one, see `autoClearAfterMs` above.)
28652
28810
  *
28653
28811
  * See `RuntimeStateDurability`. Enforced by
28654
28812
  * `scripts/check-runtime-state-durability.ts`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-reolink",
3
- "version": "1.2.119",
3
+ "version": "1.2.121",
4
4
  "description": "Reolink camera device provider addon for CamStack — native Baichuan protocol",
5
5
  "keywords": [
6
6
  "camstack",