@camstack/addon-provider-velux 0.2.96 → 0.2.98

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
@@ -7303,6 +7303,23 @@ function errMsg(err) {
7303
7303
  if (typeof err === "string") return err;
7304
7304
  return String(err);
7305
7305
  }
7306
+ new Set([
7307
+ "track",
7308
+ "summary",
7309
+ "face",
7310
+ "identity",
7311
+ "plate",
7312
+ "vehicle",
7313
+ "scene",
7314
+ "motion",
7315
+ "object",
7316
+ "audio"
7317
+ ]);
7318
+ new Set([
7319
+ "motion",
7320
+ "object",
7321
+ "audio"
7322
+ ]);
7306
7323
  var EncodeProfileSchema = object({
7307
7324
  video: object({
7308
7325
  codec: _enum([
@@ -12503,8 +12520,17 @@ method(object({
12503
12520
  }), array(SettingsRecordSchema).readonly()), method(object({
12504
12521
  namespace: string().optional(),
12505
12522
  collection: string(),
12506
- record: SettingsRecordSchema
12507
- }), _void(), { kind: "mutation" }), method(object({
12523
+ record: object({
12524
+ id: string().optional(),
12525
+ data: record(string(), unknown())
12526
+ })
12527
+ }), object({
12528
+ /**
12529
+ * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
12530
+ * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
12531
+ * primary key — which is the only place an auto key is knowable.
12532
+ */
12533
+ id: union([string(), number()]) }), { kind: "mutation" }), method(object({
12508
12534
  namespace: string().optional(),
12509
12535
  collection: string(),
12510
12536
  records: array(BulkRecordSchema).readonly()
@@ -12613,8 +12639,17 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
12613
12639
  }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
12614
12640
  namespace: string().optional(),
12615
12641
  collection: string(),
12616
- record: SettingsRecordSchema
12617
- }), _void(), {
12642
+ record: object({
12643
+ id: string().optional(),
12644
+ data: record(string(), unknown())
12645
+ })
12646
+ }), object({
12647
+ /**
12648
+ * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
12649
+ * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
12650
+ * primary key — which is the only place an auto key is knowable.
12651
+ */
12652
+ id: union([string(), number()]) }), {
12618
12653
  kind: "mutation",
12619
12654
  auth: "admin"
12620
12655
  }), method(object({
@@ -19522,7 +19557,20 @@ var TrackSchema = object({
19522
19557
  ...TrackRetrainFields
19523
19558
  });
19524
19559
  var BaseEventFields = {
19525
- id: string(),
19560
+ /**
19561
+ * A SQLite ROWID, assigned by the database (D474).
19562
+ *
19563
+ * Was a 36-character UUID and cost 263 MB of a 1 117 MB database — paid
19564
+ * TWICE per row, in the row and in the primary-key index, across 2.1 million
19565
+ * motion, audio and object events. An `INTEGER PRIMARY KEY` in SQLite **is**
19566
+ * the rowid: the table itself is that B-tree, so the index stops existing
19567
+ * rather than getting smaller. No shorter string does that.
19568
+ *
19569
+ * Defined once here for all three event kinds, which is why they move
19570
+ * together: a per-table migration would have forked this and
19571
+ * `COMMON_BASE_COLUMNS` and reunited them two stages later.
19572
+ */
19573
+ id: number().int(),
19526
19574
  deviceId: number(),
19527
19575
  timestamp: number()
19528
19576
  };
@@ -19541,7 +19589,34 @@ var MotionEventSchema = object({
19541
19589
  /** Omitted in slim projection. */
19542
19590
  frameHeight: number().optional(),
19543
19591
  /** Populated by B5 (recording playback URL for this event). */
19544
- mediaUrl: string().optional()
19592
+ mediaUrl: string().optional(),
19593
+ /**
19594
+ * One row per motion EPISODE, not one per push (D475). `null` while the
19595
+ * episode is still open — a further rising edge extends it in place rather
19596
+ * than inserting a new row. Set once, at close, to `lastOnAt - startedAt`
19597
+ * (the span from the first rising edge to the LAST one, deliberately NOT
19598
+ * `closedAt - startedAt` — the close delay is a quiet CONFIRMATION, not
19599
+ * movement, and folding it in would report `MOTION_CLOSE_AFTER_MS` of
19600
+ * motion for an instantaneous trigger).
19601
+ *
19602
+ * **Absent** (not merely `null`) on a row written before D475 — that means
19603
+ * "closed the old way, before this column existed", never "still open".
19604
+ * Nothing in this codebase may read an absent `durationMs` as an open
19605
+ * episode; only `null` means open.
19606
+ */
19607
+ durationMs: number().nullable().optional(),
19608
+ /**
19609
+ * Ms offsets from `timestamp` (the episode's own first rising edge, so the
19610
+ * first entry is always `0`) of every genuine off→on transition the
19611
+ * episode saw — "ogni evento on si deve salvare" (D475). NOT one entry per
19612
+ * push: a firmware source that keepalives at ~1 Hz for the whole burst
19613
+ * (Reolink, Hikvision) produces exactly one edge; a source that reports an
19614
+ * explicit `false` mid-episode and then resumes before the quiet window
19615
+ * elapses produces another. Stored compactly — see `motion-edge-codec.ts`
19616
+ * — and decoded back to this shape on read. Absent/empty on a legacy row,
19617
+ * which must never be read as "no episode happened here".
19618
+ */
19619
+ edges: array(number()).readonly().optional()
19545
19620
  });
19546
19621
  /**
19547
19622
  * Which detection SOURCE produced an object event. `pipeline` = the ML
@@ -19596,6 +19671,23 @@ var ObjectEventSchema = object({
19596
19671
  * includes it (it is light). Absent on rows written before this field.
19597
19672
  */
19598
19673
  frameId: string().optional(),
19674
+ /**
19675
+ * A PRODUCER-chosen key that makes a synthetic event's emission idempotent
19676
+ * (D474).
19677
+ *
19678
+ * Only the package detector writes it, and it exists because the event id
19679
+ * stopped being choosable: the delivery and pick-up rows used to BE their
19680
+ * dedupe key (`pa-pkg-<entryId>-delivered`), which is how "never emit a
19681
+ * second delivery for this entry" survived a restart. An `INTEGER` rowid is
19682
+ * assigned by SQLite, so that key had to move off the primary key rather
19683
+ * than be dropped — a detector that cannot recognise its own row re-delivers
19684
+ * every parcel on every boot.
19685
+ *
19686
+ * Absent on every other object event, and on every row written before this
19687
+ * field. Never a substitute for `id`: it is unique per (producer, occasion),
19688
+ * not per row, and nothing addresses a row by it.
19689
+ */
19690
+ idempotencyKey: string().optional(),
19599
19691
  /** Omitted in slim projection. */
19600
19692
  trackId: string().optional(),
19601
19693
  className: string(),
@@ -20698,6 +20790,14 @@ var NativeCropResultSchema = object({
20698
20790
  * set `encodeJpeg: true`; `bytes` is then absent.
20699
20791
  */
20700
20792
  jpeg: string().optional(),
20793
+ /**
20794
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
20795
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
20796
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
20797
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
20798
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
20799
+ */
20800
+ jpegBytes: _instanceof(Uint8Array).optional(),
20701
20801
  width: number().int().positive(),
20702
20802
  height: number().int().positive(),
20703
20803
  /**
@@ -20764,7 +20864,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
20764
20864
  })]);
20765
20865
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
20766
20866
  var ParkedTrackFrameSchema = object({
20767
- jpeg: string(),
20867
+ /**
20868
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
20869
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
20870
+ * Exactly one of the two is present.
20871
+ */
20872
+ jpeg: string().optional(),
20873
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
20874
+ jpegBytes: _instanceof(Uint8Array).optional(),
20768
20875
  width: number().int().positive(),
20769
20876
  height: number().int().positive(),
20770
20877
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -21351,6 +21458,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21351
21458
  bbox: NativeCropBboxSchema,
21352
21459
  maxWidth: number().int().positive().optional(),
21353
21460
  /**
21461
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21462
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21463
+ * wire — never assume consent: a pre-D462 caller parses the field as
21464
+ * base64 and bytes would decode to garbage rather than fail.
21465
+ */
21466
+ acceptJpegBytes: boolean().optional(),
21467
+ /**
21354
21468
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
21355
21469
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
21356
21470
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -21418,7 +21532,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21418
21532
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
21419
21533
  deviceId: number(),
21420
21534
  trackId: string(),
21421
- kind: ParkedFrameKindSchema
21535
+ kind: ParkedFrameKindSchema,
21536
+ /**
21537
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21538
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21539
+ * wire — never assume consent: a pre-D462 caller parses the field as
21540
+ * base64 and bytes would decode to garbage rather than fail.
21541
+ */
21542
+ acceptJpegBytes: boolean().optional()
21422
21543
  }), ParkedTrackFrameSchema.nullable()), method(object({
21423
21544
  deviceId: number(),
21424
21545
  trackId: string()
@@ -27816,26 +27937,59 @@ authKey: string().optional() }), object({
27816
27937
  /** Human-readable error when `ok: false`. */
27817
27938
  error: string().optional()
27818
27939
  }), { kind: "mutation" });
27819
- /**
27820
- * Hardware / firmware motion sensor cap — binary detected state plus
27821
- * a timestamp of the last observation. Distinct from
27822
- * `motion-detection.cap.ts` which owns the LOCAL ML motion pipeline;
27823
- * `motion` is the lightweight readout from on-camera motion (Reolink
27824
- * `GetMdState`, Baichuan push `type: motion`, ONVIF analytics).
27825
- *
27826
- * Native-motion providers also fan out to `detection.camera-native`
27827
- * with `source: 'onboard'` so cross-cutting system services
27828
- * (alert-center, advanced-notifier) can subscribe once and receive
27829
- * motion from every camera.
27830
- */
27831
27940
  var MotionStatusSchema = object({
27832
27941
  detected: boolean(),
27833
27942
  /** Ms epoch of the last detected-true observation. Null if never detected. */
27834
27943
  lastDetectedAt: number().nullable(),
27835
27944
  /**
27836
- * Ms after which `detected` auto-reverts to false if no fresh push
27837
- * arrives. Null means the provider leaves detected state until a
27838
- * native "clear" event.
27945
+ * `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
27946
+ * `null` while false and on every `Sensor` device (D475) — see that
27947
+ * constant's doc for the one-authority rule.
27948
+ *
27949
+ * ## Reading this field still arms nothing
27950
+ *
27951
+ * It reads like an instruction to the consumer ("revert after N ms if
27952
+ * no fresh push arrives") and it is not one: nothing in this repo reads
27953
+ * the LIVE cap value to drive a timer. `pipeline-analytics`'s motion-episode
27954
+ * close DOES now use the same number — `MOTION_CLOSE_AFTER_MS` — but as an
27955
+ * imported constant, not as a read of `device.state.motion.value`, so this
27956
+ * field stays what it always was: DESCRIPTIVE output, mirroring an answer
27957
+ * computed elsewhere. Building a self-clear timer out of a READ of this
27958
+ * field would add a second falling-edge authority beside whichever one
27959
+ * already owns the device, and two that can disagree are worse than one.
27960
+ * Consumers that need a falling edge SHAPED differently — held open across
27961
+ * a flapping source — debounce on their own side and say so, as
27962
+ * `addon-export-alexa/src/motion-clear-hold.ts` and
27963
+ * `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
27964
+ *
27965
+ * ## Who writes it
27966
+ *
27967
+ * - **Cameras** — the runner's phase machine, `active → watching` on
27968
+ * `cooldown_expired`, which then writes this slice with
27969
+ * `detected: false` (`handlePhaseChanged` in
27970
+ * `pipeline-runner/index.ts`). It produces the FALLING edge, which
27971
+ * matters most for the sources that only ever push a rising one:
27972
+ * Reolink emits `MotionOnMotionChanged { detected: true }` and never
27973
+ * a false.
27974
+ * - **Sensors** (Home Assistant binary sensors, Homematic) — the
27975
+ * provider pushes the false itself, from the upstream system's own
27976
+ * state change. No phase machine is involved.
27977
+ *
27978
+ * ### The phase machine is CANONICAL, not sole — and that is a defect
27979
+ *
27980
+ * An earlier revision of this docblock (mine, 2026-09-12) claimed the
27981
+ * phase machine is the sole writer for a camera. It is not.
27982
+ * `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
27983
+ * `setCapSlice(motionCapability, …)` on their own rising edge, and
27984
+ * Hikvision's comment says why: it read THIS docblock, agreed the
27985
+ * runner is canonical, and wrote anyway to avoid per-tick churn. So
27986
+ * two authorities can disagree about one slice, which this repo
27987
+ * forbids, and the doc said otherwise — which is worse than saying
27988
+ * nothing, because it reads as verification.
27989
+ *
27990
+ * This predates D475 and is not fixed there: the fix touches every
27991
+ * camera provider. Recorded in D475's Consequences. Do not restore the
27992
+ * "sole writer" wording without also removing the other writers.
27839
27993
  */
27840
27994
  autoClearAfterMs: number().nullable()
27841
27995
  });
@@ -27905,7 +28059,11 @@ onMotionChanged: { data: MotionOnMotionChangedDataSchema } },
27905
28059
  */
27906
28060
  runtimeState: MotionStatusSchema,
27907
28061
  /**
27908
- * 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.
28062
+ * Runtime-state durability: **session** — every writer of this slice
28063
+ * writes only on an EDGE, so a restored `detected: true` would stay
28064
+ * frozen until the next one instead of being corrected. The next edge
28065
+ * re-publishes the real state. (On who the writers are, and why there
28066
+ * is more than one, see `autoClearAfterMs` above.)
27909
28067
  *
27910
28068
  * See `RuntimeStateDurability`. Enforced by
27911
28069
  * `scripts/check-runtime-state-durability.ts`.
package/dist/addon.mjs CHANGED
@@ -7302,6 +7302,23 @@ function errMsg(err) {
7302
7302
  if (typeof err === "string") return err;
7303
7303
  return String(err);
7304
7304
  }
7305
+ new Set([
7306
+ "track",
7307
+ "summary",
7308
+ "face",
7309
+ "identity",
7310
+ "plate",
7311
+ "vehicle",
7312
+ "scene",
7313
+ "motion",
7314
+ "object",
7315
+ "audio"
7316
+ ]);
7317
+ new Set([
7318
+ "motion",
7319
+ "object",
7320
+ "audio"
7321
+ ]);
7305
7322
  var EncodeProfileSchema = object({
7306
7323
  video: object({
7307
7324
  codec: _enum([
@@ -12502,8 +12519,17 @@ method(object({
12502
12519
  }), array(SettingsRecordSchema).readonly()), method(object({
12503
12520
  namespace: string().optional(),
12504
12521
  collection: string(),
12505
- record: SettingsRecordSchema
12506
- }), _void(), { kind: "mutation" }), method(object({
12522
+ record: object({
12523
+ id: string().optional(),
12524
+ data: record(string(), unknown())
12525
+ })
12526
+ }), object({
12527
+ /**
12528
+ * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
12529
+ * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
12530
+ * primary key — which is the only place an auto key is knowable.
12531
+ */
12532
+ id: union([string(), number()]) }), { kind: "mutation" }), method(object({
12507
12533
  namespace: string().optional(),
12508
12534
  collection: string(),
12509
12535
  records: array(BulkRecordSchema).readonly()
@@ -12612,8 +12638,17 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
12612
12638
  }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
12613
12639
  namespace: string().optional(),
12614
12640
  collection: string(),
12615
- record: SettingsRecordSchema
12616
- }), _void(), {
12641
+ record: object({
12642
+ id: string().optional(),
12643
+ data: record(string(), unknown())
12644
+ })
12645
+ }), object({
12646
+ /**
12647
+ * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
12648
+ * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
12649
+ * primary key — which is the only place an auto key is knowable.
12650
+ */
12651
+ id: union([string(), number()]) }), {
12617
12652
  kind: "mutation",
12618
12653
  auth: "admin"
12619
12654
  }), method(object({
@@ -19521,7 +19556,20 @@ var TrackSchema = object({
19521
19556
  ...TrackRetrainFields
19522
19557
  });
19523
19558
  var BaseEventFields = {
19524
- id: string(),
19559
+ /**
19560
+ * A SQLite ROWID, assigned by the database (D474).
19561
+ *
19562
+ * Was a 36-character UUID and cost 263 MB of a 1 117 MB database — paid
19563
+ * TWICE per row, in the row and in the primary-key index, across 2.1 million
19564
+ * motion, audio and object events. An `INTEGER PRIMARY KEY` in SQLite **is**
19565
+ * the rowid: the table itself is that B-tree, so the index stops existing
19566
+ * rather than getting smaller. No shorter string does that.
19567
+ *
19568
+ * Defined once here for all three event kinds, which is why they move
19569
+ * together: a per-table migration would have forked this and
19570
+ * `COMMON_BASE_COLUMNS` and reunited them two stages later.
19571
+ */
19572
+ id: number().int(),
19525
19573
  deviceId: number(),
19526
19574
  timestamp: number()
19527
19575
  };
@@ -19540,7 +19588,34 @@ var MotionEventSchema = object({
19540
19588
  /** Omitted in slim projection. */
19541
19589
  frameHeight: number().optional(),
19542
19590
  /** Populated by B5 (recording playback URL for this event). */
19543
- mediaUrl: string().optional()
19591
+ mediaUrl: string().optional(),
19592
+ /**
19593
+ * One row per motion EPISODE, not one per push (D475). `null` while the
19594
+ * episode is still open — a further rising edge extends it in place rather
19595
+ * than inserting a new row. Set once, at close, to `lastOnAt - startedAt`
19596
+ * (the span from the first rising edge to the LAST one, deliberately NOT
19597
+ * `closedAt - startedAt` — the close delay is a quiet CONFIRMATION, not
19598
+ * movement, and folding it in would report `MOTION_CLOSE_AFTER_MS` of
19599
+ * motion for an instantaneous trigger).
19600
+ *
19601
+ * **Absent** (not merely `null`) on a row written before D475 — that means
19602
+ * "closed the old way, before this column existed", never "still open".
19603
+ * Nothing in this codebase may read an absent `durationMs` as an open
19604
+ * episode; only `null` means open.
19605
+ */
19606
+ durationMs: number().nullable().optional(),
19607
+ /**
19608
+ * Ms offsets from `timestamp` (the episode's own first rising edge, so the
19609
+ * first entry is always `0`) of every genuine off→on transition the
19610
+ * episode saw — "ogni evento on si deve salvare" (D475). NOT one entry per
19611
+ * push: a firmware source that keepalives at ~1 Hz for the whole burst
19612
+ * (Reolink, Hikvision) produces exactly one edge; a source that reports an
19613
+ * explicit `false` mid-episode and then resumes before the quiet window
19614
+ * elapses produces another. Stored compactly — see `motion-edge-codec.ts`
19615
+ * — and decoded back to this shape on read. Absent/empty on a legacy row,
19616
+ * which must never be read as "no episode happened here".
19617
+ */
19618
+ edges: array(number()).readonly().optional()
19544
19619
  });
19545
19620
  /**
19546
19621
  * Which detection SOURCE produced an object event. `pipeline` = the ML
@@ -19595,6 +19670,23 @@ var ObjectEventSchema = object({
19595
19670
  * includes it (it is light). Absent on rows written before this field.
19596
19671
  */
19597
19672
  frameId: string().optional(),
19673
+ /**
19674
+ * A PRODUCER-chosen key that makes a synthetic event's emission idempotent
19675
+ * (D474).
19676
+ *
19677
+ * Only the package detector writes it, and it exists because the event id
19678
+ * stopped being choosable: the delivery and pick-up rows used to BE their
19679
+ * dedupe key (`pa-pkg-<entryId>-delivered`), which is how "never emit a
19680
+ * second delivery for this entry" survived a restart. An `INTEGER` rowid is
19681
+ * assigned by SQLite, so that key had to move off the primary key rather
19682
+ * than be dropped — a detector that cannot recognise its own row re-delivers
19683
+ * every parcel on every boot.
19684
+ *
19685
+ * Absent on every other object event, and on every row written before this
19686
+ * field. Never a substitute for `id`: it is unique per (producer, occasion),
19687
+ * not per row, and nothing addresses a row by it.
19688
+ */
19689
+ idempotencyKey: string().optional(),
19598
19690
  /** Omitted in slim projection. */
19599
19691
  trackId: string().optional(),
19600
19692
  className: string(),
@@ -20697,6 +20789,14 @@ var NativeCropResultSchema = object({
20697
20789
  * set `encodeJpeg: true`; `bytes` is then absent.
20698
20790
  */
20699
20791
  jpeg: string().optional(),
20792
+ /**
20793
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
20794
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
20795
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
20796
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
20797
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
20798
+ */
20799
+ jpegBytes: _instanceof(Uint8Array).optional(),
20700
20800
  width: number().int().positive(),
20701
20801
  height: number().int().positive(),
20702
20802
  /**
@@ -20763,7 +20863,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
20763
20863
  })]);
20764
20864
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
20765
20865
  var ParkedTrackFrameSchema = object({
20766
- jpeg: string(),
20866
+ /**
20867
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
20868
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
20869
+ * Exactly one of the two is present.
20870
+ */
20871
+ jpeg: string().optional(),
20872
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
20873
+ jpegBytes: _instanceof(Uint8Array).optional(),
20767
20874
  width: number().int().positive(),
20768
20875
  height: number().int().positive(),
20769
20876
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -21350,6 +21457,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21350
21457
  bbox: NativeCropBboxSchema,
21351
21458
  maxWidth: number().int().positive().optional(),
21352
21459
  /**
21460
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21461
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21462
+ * wire — never assume consent: a pre-D462 caller parses the field as
21463
+ * base64 and bytes would decode to garbage rather than fail.
21464
+ */
21465
+ acceptJpegBytes: boolean().optional(),
21466
+ /**
21353
21467
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
21354
21468
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
21355
21469
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -21417,7 +21531,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21417
21531
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
21418
21532
  deviceId: number(),
21419
21533
  trackId: string(),
21420
- kind: ParkedFrameKindSchema
21534
+ kind: ParkedFrameKindSchema,
21535
+ /**
21536
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21537
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21538
+ * wire — never assume consent: a pre-D462 caller parses the field as
21539
+ * base64 and bytes would decode to garbage rather than fail.
21540
+ */
21541
+ acceptJpegBytes: boolean().optional()
21421
21542
  }), ParkedTrackFrameSchema.nullable()), method(object({
21422
21543
  deviceId: number(),
21423
21544
  trackId: string()
@@ -27815,26 +27936,59 @@ authKey: string().optional() }), object({
27815
27936
  /** Human-readable error when `ok: false`. */
27816
27937
  error: string().optional()
27817
27938
  }), { kind: "mutation" });
27818
- /**
27819
- * Hardware / firmware motion sensor cap — binary detected state plus
27820
- * a timestamp of the last observation. Distinct from
27821
- * `motion-detection.cap.ts` which owns the LOCAL ML motion pipeline;
27822
- * `motion` is the lightweight readout from on-camera motion (Reolink
27823
- * `GetMdState`, Baichuan push `type: motion`, ONVIF analytics).
27824
- *
27825
- * Native-motion providers also fan out to `detection.camera-native`
27826
- * with `source: 'onboard'` so cross-cutting system services
27827
- * (alert-center, advanced-notifier) can subscribe once and receive
27828
- * motion from every camera.
27829
- */
27830
27939
  var MotionStatusSchema = object({
27831
27940
  detected: boolean(),
27832
27941
  /** Ms epoch of the last detected-true observation. Null if never detected. */
27833
27942
  lastDetectedAt: number().nullable(),
27834
27943
  /**
27835
- * Ms after which `detected` auto-reverts to false if no fresh push
27836
- * arrives. Null means the provider leaves detected state until a
27837
- * native "clear" event.
27944
+ * `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
27945
+ * `null` while false and on every `Sensor` device (D475) — see that
27946
+ * constant's doc for the one-authority rule.
27947
+ *
27948
+ * ## Reading this field still arms nothing
27949
+ *
27950
+ * It reads like an instruction to the consumer ("revert after N ms if
27951
+ * no fresh push arrives") and it is not one: nothing in this repo reads
27952
+ * the LIVE cap value to drive a timer. `pipeline-analytics`'s motion-episode
27953
+ * close DOES now use the same number — `MOTION_CLOSE_AFTER_MS` — but as an
27954
+ * imported constant, not as a read of `device.state.motion.value`, so this
27955
+ * field stays what it always was: DESCRIPTIVE output, mirroring an answer
27956
+ * computed elsewhere. Building a self-clear timer out of a READ of this
27957
+ * field would add a second falling-edge authority beside whichever one
27958
+ * already owns the device, and two that can disagree are worse than one.
27959
+ * Consumers that need a falling edge SHAPED differently — held open across
27960
+ * a flapping source — debounce on their own side and say so, as
27961
+ * `addon-export-alexa/src/motion-clear-hold.ts` and
27962
+ * `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
27963
+ *
27964
+ * ## Who writes it
27965
+ *
27966
+ * - **Cameras** — the runner's phase machine, `active → watching` on
27967
+ * `cooldown_expired`, which then writes this slice with
27968
+ * `detected: false` (`handlePhaseChanged` in
27969
+ * `pipeline-runner/index.ts`). It produces the FALLING edge, which
27970
+ * matters most for the sources that only ever push a rising one:
27971
+ * Reolink emits `MotionOnMotionChanged { detected: true }` and never
27972
+ * a false.
27973
+ * - **Sensors** (Home Assistant binary sensors, Homematic) — the
27974
+ * provider pushes the false itself, from the upstream system's own
27975
+ * state change. No phase machine is involved.
27976
+ *
27977
+ * ### The phase machine is CANONICAL, not sole — and that is a defect
27978
+ *
27979
+ * An earlier revision of this docblock (mine, 2026-09-12) claimed the
27980
+ * phase machine is the sole writer for a camera. It is not.
27981
+ * `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
27982
+ * `setCapSlice(motionCapability, …)` on their own rising edge, and
27983
+ * Hikvision's comment says why: it read THIS docblock, agreed the
27984
+ * runner is canonical, and wrote anyway to avoid per-tick churn. So
27985
+ * two authorities can disagree about one slice, which this repo
27986
+ * forbids, and the doc said otherwise — which is worse than saying
27987
+ * nothing, because it reads as verification.
27988
+ *
27989
+ * This predates D475 and is not fixed there: the fix touches every
27990
+ * camera provider. Recorded in D475's Consequences. Do not restore the
27991
+ * "sole writer" wording without also removing the other writers.
27838
27992
  */
27839
27993
  autoClearAfterMs: number().nullable()
27840
27994
  });
@@ -27904,7 +28058,11 @@ onMotionChanged: { data: MotionOnMotionChangedDataSchema } },
27904
28058
  */
27905
28059
  runtimeState: MotionStatusSchema,
27906
28060
  /**
27907
- * 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.
28061
+ * Runtime-state durability: **session** — every writer of this slice
28062
+ * writes only on an EDGE, so a restored `detected: true` would stay
28063
+ * frozen until the next one instead of being corrected. The next edge
28064
+ * re-publishes the real state. (On who the writers are, and why there
28065
+ * is more than one, see `autoClearAfterMs` above.)
27908
28066
  *
27909
28067
  * See `RuntimeStateDurability`. Enforced by
27910
28068
  * `scripts/check-runtime-state-durability.ts`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-velux",
3
- "version": "0.2.96",
3
+ "version": "0.2.98",
4
4
  "description": "Velux KLF-200 device-provider addon for CamStack — local-gateway window + shutter covers (positional, no tilt)",
5
5
  "keywords": [
6
6
  "camstack",