@camstack/addon-import-alexa 0.2.95 → 0.2.97

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 -26
  2. package/dist/addon.mjs +182 -26
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -7342,8 +7342,23 @@ function errMsg(err) {
7342
7342
  if (typeof err === "string") return err;
7343
7343
  return String(err);
7344
7344
  }
7345
- //#endregion
7346
- //#region ../types/dist/index.mjs
7345
+ new Set([
7346
+ "track",
7347
+ "summary",
7348
+ "face",
7349
+ "identity",
7350
+ "plate",
7351
+ "vehicle",
7352
+ "scene",
7353
+ "motion",
7354
+ "object",
7355
+ "audio"
7356
+ ]);
7357
+ new Set([
7358
+ "motion",
7359
+ "object",
7360
+ "audio"
7361
+ ]);
7347
7362
  /**
7348
7363
  * Build an `IAddonRouteProvider` from a list of routes. Implements
7349
7364
  * both the operator-facing `getRoutes` (returning route descriptors
@@ -12729,8 +12744,17 @@ method(object({
12729
12744
  }), array(SettingsRecordSchema).readonly()), method(object({
12730
12745
  namespace: string().optional(),
12731
12746
  collection: string(),
12732
- record: SettingsRecordSchema
12733
- }), _void(), { kind: "mutation" }), method(object({
12747
+ record: object({
12748
+ id: string().optional(),
12749
+ data: record(string(), unknown())
12750
+ })
12751
+ }), object({
12752
+ /**
12753
+ * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
12754
+ * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
12755
+ * primary key — which is the only place an auto key is knowable.
12756
+ */
12757
+ id: union([string(), number()]) }), { kind: "mutation" }), method(object({
12734
12758
  namespace: string().optional(),
12735
12759
  collection: string(),
12736
12760
  records: array(BulkRecordSchema).readonly()
@@ -12839,8 +12863,17 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
12839
12863
  }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
12840
12864
  namespace: string().optional(),
12841
12865
  collection: string(),
12842
- record: SettingsRecordSchema
12843
- }), _void(), {
12866
+ record: object({
12867
+ id: string().optional(),
12868
+ data: record(string(), unknown())
12869
+ })
12870
+ }), object({
12871
+ /**
12872
+ * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
12873
+ * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
12874
+ * primary key — which is the only place an auto key is knowable.
12875
+ */
12876
+ id: union([string(), number()]) }), {
12844
12877
  kind: "mutation",
12845
12878
  auth: "admin"
12846
12879
  }), method(object({
@@ -19765,7 +19798,20 @@ var TrackSchema = object({
19765
19798
  ...TrackRetrainFields
19766
19799
  });
19767
19800
  var BaseEventFields = {
19768
- id: string(),
19801
+ /**
19802
+ * A SQLite ROWID, assigned by the database (D474).
19803
+ *
19804
+ * Was a 36-character UUID and cost 263 MB of a 1 117 MB database — paid
19805
+ * TWICE per row, in the row and in the primary-key index, across 2.1 million
19806
+ * motion, audio and object events. An `INTEGER PRIMARY KEY` in SQLite **is**
19807
+ * the rowid: the table itself is that B-tree, so the index stops existing
19808
+ * rather than getting smaller. No shorter string does that.
19809
+ *
19810
+ * Defined once here for all three event kinds, which is why they move
19811
+ * together: a per-table migration would have forked this and
19812
+ * `COMMON_BASE_COLUMNS` and reunited them two stages later.
19813
+ */
19814
+ id: number().int(),
19769
19815
  deviceId: number(),
19770
19816
  timestamp: number()
19771
19817
  };
@@ -19784,7 +19830,34 @@ var MotionEventSchema = object({
19784
19830
  /** Omitted in slim projection. */
19785
19831
  frameHeight: number().optional(),
19786
19832
  /** Populated by B5 (recording playback URL for this event). */
19787
- mediaUrl: string().optional()
19833
+ mediaUrl: string().optional(),
19834
+ /**
19835
+ * One row per motion EPISODE, not one per push (D475). `null` while the
19836
+ * episode is still open — a further rising edge extends it in place rather
19837
+ * than inserting a new row. Set once, at close, to `lastOnAt - startedAt`
19838
+ * (the span from the first rising edge to the LAST one, deliberately NOT
19839
+ * `closedAt - startedAt` — the close delay is a quiet CONFIRMATION, not
19840
+ * movement, and folding it in would report `MOTION_CLOSE_AFTER_MS` of
19841
+ * motion for an instantaneous trigger).
19842
+ *
19843
+ * **Absent** (not merely `null`) on a row written before D475 — that means
19844
+ * "closed the old way, before this column existed", never "still open".
19845
+ * Nothing in this codebase may read an absent `durationMs` as an open
19846
+ * episode; only `null` means open.
19847
+ */
19848
+ durationMs: number().nullable().optional(),
19849
+ /**
19850
+ * Ms offsets from `timestamp` (the episode's own first rising edge, so the
19851
+ * first entry is always `0`) of every genuine off→on transition the
19852
+ * episode saw — "ogni evento on si deve salvare" (D475). NOT one entry per
19853
+ * push: a firmware source that keepalives at ~1 Hz for the whole burst
19854
+ * (Reolink, Hikvision) produces exactly one edge; a source that reports an
19855
+ * explicit `false` mid-episode and then resumes before the quiet window
19856
+ * elapses produces another. Stored compactly — see `motion-edge-codec.ts`
19857
+ * — and decoded back to this shape on read. Absent/empty on a legacy row,
19858
+ * which must never be read as "no episode happened here".
19859
+ */
19860
+ edges: array(number()).readonly().optional()
19788
19861
  });
19789
19862
  /**
19790
19863
  * Which detection SOURCE produced an object event. `pipeline` = the ML
@@ -19839,6 +19912,23 @@ var ObjectEventSchema = object({
19839
19912
  * includes it (it is light). Absent on rows written before this field.
19840
19913
  */
19841
19914
  frameId: string().optional(),
19915
+ /**
19916
+ * A PRODUCER-chosen key that makes a synthetic event's emission idempotent
19917
+ * (D474).
19918
+ *
19919
+ * Only the package detector writes it, and it exists because the event id
19920
+ * stopped being choosable: the delivery and pick-up rows used to BE their
19921
+ * dedupe key (`pa-pkg-<entryId>-delivered`), which is how "never emit a
19922
+ * second delivery for this entry" survived a restart. An `INTEGER` rowid is
19923
+ * assigned by SQLite, so that key had to move off the primary key rather
19924
+ * than be dropped — a detector that cannot recognise its own row re-delivers
19925
+ * every parcel on every boot.
19926
+ *
19927
+ * Absent on every other object event, and on every row written before this
19928
+ * field. Never a substitute for `id`: it is unique per (producer, occasion),
19929
+ * not per row, and nothing addresses a row by it.
19930
+ */
19931
+ idempotencyKey: string().optional(),
19842
19932
  /** Omitted in slim projection. */
19843
19933
  trackId: string().optional(),
19844
19934
  className: string(),
@@ -20941,6 +21031,14 @@ var NativeCropResultSchema = object({
20941
21031
  * set `encodeJpeg: true`; `bytes` is then absent.
20942
21032
  */
20943
21033
  jpeg: string().optional(),
21034
+ /**
21035
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
21036
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
21037
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
21038
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
21039
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
21040
+ */
21041
+ jpegBytes: _instanceof(Uint8Array).optional(),
20944
21042
  width: number().int().positive(),
20945
21043
  height: number().int().positive(),
20946
21044
  /**
@@ -21007,7 +21105,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
21007
21105
  })]);
21008
21106
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
21009
21107
  var ParkedTrackFrameSchema = object({
21010
- jpeg: string(),
21108
+ /**
21109
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
21110
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
21111
+ * Exactly one of the two is present.
21112
+ */
21113
+ jpeg: string().optional(),
21114
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
21115
+ jpegBytes: _instanceof(Uint8Array).optional(),
21011
21116
  width: number().int().positive(),
21012
21117
  height: number().int().positive(),
21013
21118
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -21594,6 +21699,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21594
21699
  bbox: NativeCropBboxSchema,
21595
21700
  maxWidth: number().int().positive().optional(),
21596
21701
  /**
21702
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21703
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21704
+ * wire — never assume consent: a pre-D462 caller parses the field as
21705
+ * base64 and bytes would decode to garbage rather than fail.
21706
+ */
21707
+ acceptJpegBytes: boolean().optional(),
21708
+ /**
21597
21709
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
21598
21710
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
21599
21711
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -21661,7 +21773,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21661
21773
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
21662
21774
  deviceId: number(),
21663
21775
  trackId: string(),
21664
- kind: ParkedFrameKindSchema
21776
+ kind: ParkedFrameKindSchema,
21777
+ /**
21778
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21779
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21780
+ * wire — never assume consent: a pre-D462 caller parses the field as
21781
+ * base64 and bytes would decode to garbage rather than fail.
21782
+ */
21783
+ acceptJpegBytes: boolean().optional()
21665
21784
  }), ParkedTrackFrameSchema.nullable()), method(object({
21666
21785
  deviceId: number(),
21667
21786
  trackId: string()
@@ -28076,26 +28195,59 @@ authKey: string().optional() }), object({
28076
28195
  /** Human-readable error when `ok: false`. */
28077
28196
  error: string().optional()
28078
28197
  }), { kind: "mutation" });
28079
- /**
28080
- * Hardware / firmware motion sensor cap — binary detected state plus
28081
- * a timestamp of the last observation. Distinct from
28082
- * `motion-detection.cap.ts` which owns the LOCAL ML motion pipeline;
28083
- * `motion` is the lightweight readout from on-camera motion (Reolink
28084
- * `GetMdState`, Baichuan push `type: motion`, ONVIF analytics).
28085
- *
28086
- * Native-motion providers also fan out to `detection.camera-native`
28087
- * with `source: 'onboard'` so cross-cutting system services
28088
- * (alert-center, advanced-notifier) can subscribe once and receive
28089
- * motion from every camera.
28090
- */
28091
28198
  var MotionStatusSchema = object({
28092
28199
  detected: boolean(),
28093
28200
  /** Ms epoch of the last detected-true observation. Null if never detected. */
28094
28201
  lastDetectedAt: number().nullable(),
28095
28202
  /**
28096
- * Ms after which `detected` auto-reverts to false if no fresh push
28097
- * arrives. Null means the provider leaves detected state until a
28098
- * native "clear" event.
28203
+ * `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
28204
+ * `null` while false and on every `Sensor` device (D475) — see that
28205
+ * constant's doc for the one-authority rule.
28206
+ *
28207
+ * ## Reading this field still arms nothing
28208
+ *
28209
+ * It reads like an instruction to the consumer ("revert after N ms if
28210
+ * no fresh push arrives") and it is not one: nothing in this repo reads
28211
+ * the LIVE cap value to drive a timer. `pipeline-analytics`'s motion-episode
28212
+ * close DOES now use the same number — `MOTION_CLOSE_AFTER_MS` — but as an
28213
+ * imported constant, not as a read of `device.state.motion.value`, so this
28214
+ * field stays what it always was: DESCRIPTIVE output, mirroring an answer
28215
+ * computed elsewhere. Building a self-clear timer out of a READ of this
28216
+ * field would add a second falling-edge authority beside whichever one
28217
+ * already owns the device, and two that can disagree are worse than one.
28218
+ * Consumers that need a falling edge SHAPED differently — held open across
28219
+ * a flapping source — debounce on their own side and say so, as
28220
+ * `addon-export-alexa/src/motion-clear-hold.ts` and
28221
+ * `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
28222
+ *
28223
+ * ## Who writes it
28224
+ *
28225
+ * - **Cameras** — the runner's phase machine, `active → watching` on
28226
+ * `cooldown_expired`, which then writes this slice with
28227
+ * `detected: false` (`handlePhaseChanged` in
28228
+ * `pipeline-runner/index.ts`). It produces the FALLING edge, which
28229
+ * matters most for the sources that only ever push a rising one:
28230
+ * Reolink emits `MotionOnMotionChanged { detected: true }` and never
28231
+ * a false.
28232
+ * - **Sensors** (Home Assistant binary sensors, Homematic) — the
28233
+ * provider pushes the false itself, from the upstream system's own
28234
+ * state change. No phase machine is involved.
28235
+ *
28236
+ * ### The phase machine is CANONICAL, not sole — and that is a defect
28237
+ *
28238
+ * An earlier revision of this docblock (mine, 2026-09-12) claimed the
28239
+ * phase machine is the sole writer for a camera. It is not.
28240
+ * `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
28241
+ * `setCapSlice(motionCapability, …)` on their own rising edge, and
28242
+ * Hikvision's comment says why: it read THIS docblock, agreed the
28243
+ * runner is canonical, and wrote anyway to avoid per-tick churn. So
28244
+ * two authorities can disagree about one slice, which this repo
28245
+ * forbids, and the doc said otherwise — which is worse than saying
28246
+ * nothing, because it reads as verification.
28247
+ *
28248
+ * This predates D475 and is not fixed there: the fix touches every
28249
+ * camera provider. Recorded in D475's Consequences. Do not restore the
28250
+ * "sole writer" wording without also removing the other writers.
28099
28251
  */
28100
28252
  autoClearAfterMs: number().nullable()
28101
28253
  });
@@ -28165,7 +28317,11 @@ onMotionChanged: { data: MotionOnMotionChangedDataSchema } },
28165
28317
  */
28166
28318
  runtimeState: MotionStatusSchema,
28167
28319
  /**
28168
- * 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.
28320
+ * Runtime-state durability: **session** — every writer of this slice
28321
+ * writes only on an EDGE, so a restored `detected: true` would stay
28322
+ * frozen until the next one instead of being corrected. The next edge
28323
+ * re-publishes the real state. (On who the writers are, and why there
28324
+ * is more than one, see `autoClearAfterMs` above.)
28169
28325
  *
28170
28326
  * See `RuntimeStateDurability`. Enforced by
28171
28327
  * `scripts/check-runtime-state-durability.ts`.
package/dist/addon.mjs CHANGED
@@ -7342,8 +7342,23 @@ function errMsg(err) {
7342
7342
  if (typeof err === "string") return err;
7343
7343
  return String(err);
7344
7344
  }
7345
- //#endregion
7346
- //#region ../types/dist/index.mjs
7345
+ new Set([
7346
+ "track",
7347
+ "summary",
7348
+ "face",
7349
+ "identity",
7350
+ "plate",
7351
+ "vehicle",
7352
+ "scene",
7353
+ "motion",
7354
+ "object",
7355
+ "audio"
7356
+ ]);
7357
+ new Set([
7358
+ "motion",
7359
+ "object",
7360
+ "audio"
7361
+ ]);
7347
7362
  /**
7348
7363
  * Build an `IAddonRouteProvider` from a list of routes. Implements
7349
7364
  * both the operator-facing `getRoutes` (returning route descriptors
@@ -12729,8 +12744,17 @@ method(object({
12729
12744
  }), array(SettingsRecordSchema).readonly()), method(object({
12730
12745
  namespace: string().optional(),
12731
12746
  collection: string(),
12732
- record: SettingsRecordSchema
12733
- }), _void(), { kind: "mutation" }), method(object({
12747
+ record: object({
12748
+ id: string().optional(),
12749
+ data: record(string(), unknown())
12750
+ })
12751
+ }), object({
12752
+ /**
12753
+ * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
12754
+ * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
12755
+ * primary key — which is the only place an auto key is knowable.
12756
+ */
12757
+ id: union([string(), number()]) }), { kind: "mutation" }), method(object({
12734
12758
  namespace: string().optional(),
12735
12759
  collection: string(),
12736
12760
  records: array(BulkRecordSchema).readonly()
@@ -12839,8 +12863,17 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
12839
12863
  }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
12840
12864
  namespace: string().optional(),
12841
12865
  collection: string(),
12842
- record: SettingsRecordSchema
12843
- }), _void(), {
12866
+ record: object({
12867
+ id: string().optional(),
12868
+ data: record(string(), unknown())
12869
+ })
12870
+ }), object({
12871
+ /**
12872
+ * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
12873
+ * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
12874
+ * primary key — which is the only place an auto key is knowable.
12875
+ */
12876
+ id: union([string(), number()]) }), {
12844
12877
  kind: "mutation",
12845
12878
  auth: "admin"
12846
12879
  }), method(object({
@@ -19765,7 +19798,20 @@ var TrackSchema = object({
19765
19798
  ...TrackRetrainFields
19766
19799
  });
19767
19800
  var BaseEventFields = {
19768
- id: string(),
19801
+ /**
19802
+ * A SQLite ROWID, assigned by the database (D474).
19803
+ *
19804
+ * Was a 36-character UUID and cost 263 MB of a 1 117 MB database — paid
19805
+ * TWICE per row, in the row and in the primary-key index, across 2.1 million
19806
+ * motion, audio and object events. An `INTEGER PRIMARY KEY` in SQLite **is**
19807
+ * the rowid: the table itself is that B-tree, so the index stops existing
19808
+ * rather than getting smaller. No shorter string does that.
19809
+ *
19810
+ * Defined once here for all three event kinds, which is why they move
19811
+ * together: a per-table migration would have forked this and
19812
+ * `COMMON_BASE_COLUMNS` and reunited them two stages later.
19813
+ */
19814
+ id: number().int(),
19769
19815
  deviceId: number(),
19770
19816
  timestamp: number()
19771
19817
  };
@@ -19784,7 +19830,34 @@ var MotionEventSchema = object({
19784
19830
  /** Omitted in slim projection. */
19785
19831
  frameHeight: number().optional(),
19786
19832
  /** Populated by B5 (recording playback URL for this event). */
19787
- mediaUrl: string().optional()
19833
+ mediaUrl: string().optional(),
19834
+ /**
19835
+ * One row per motion EPISODE, not one per push (D475). `null` while the
19836
+ * episode is still open — a further rising edge extends it in place rather
19837
+ * than inserting a new row. Set once, at close, to `lastOnAt - startedAt`
19838
+ * (the span from the first rising edge to the LAST one, deliberately NOT
19839
+ * `closedAt - startedAt` — the close delay is a quiet CONFIRMATION, not
19840
+ * movement, and folding it in would report `MOTION_CLOSE_AFTER_MS` of
19841
+ * motion for an instantaneous trigger).
19842
+ *
19843
+ * **Absent** (not merely `null`) on a row written before D475 — that means
19844
+ * "closed the old way, before this column existed", never "still open".
19845
+ * Nothing in this codebase may read an absent `durationMs` as an open
19846
+ * episode; only `null` means open.
19847
+ */
19848
+ durationMs: number().nullable().optional(),
19849
+ /**
19850
+ * Ms offsets from `timestamp` (the episode's own first rising edge, so the
19851
+ * first entry is always `0`) of every genuine off→on transition the
19852
+ * episode saw — "ogni evento on si deve salvare" (D475). NOT one entry per
19853
+ * push: a firmware source that keepalives at ~1 Hz for the whole burst
19854
+ * (Reolink, Hikvision) produces exactly one edge; a source that reports an
19855
+ * explicit `false` mid-episode and then resumes before the quiet window
19856
+ * elapses produces another. Stored compactly — see `motion-edge-codec.ts`
19857
+ * — and decoded back to this shape on read. Absent/empty on a legacy row,
19858
+ * which must never be read as "no episode happened here".
19859
+ */
19860
+ edges: array(number()).readonly().optional()
19788
19861
  });
19789
19862
  /**
19790
19863
  * Which detection SOURCE produced an object event. `pipeline` = the ML
@@ -19839,6 +19912,23 @@ var ObjectEventSchema = object({
19839
19912
  * includes it (it is light). Absent on rows written before this field.
19840
19913
  */
19841
19914
  frameId: string().optional(),
19915
+ /**
19916
+ * A PRODUCER-chosen key that makes a synthetic event's emission idempotent
19917
+ * (D474).
19918
+ *
19919
+ * Only the package detector writes it, and it exists because the event id
19920
+ * stopped being choosable: the delivery and pick-up rows used to BE their
19921
+ * dedupe key (`pa-pkg-<entryId>-delivered`), which is how "never emit a
19922
+ * second delivery for this entry" survived a restart. An `INTEGER` rowid is
19923
+ * assigned by SQLite, so that key had to move off the primary key rather
19924
+ * than be dropped — a detector that cannot recognise its own row re-delivers
19925
+ * every parcel on every boot.
19926
+ *
19927
+ * Absent on every other object event, and on every row written before this
19928
+ * field. Never a substitute for `id`: it is unique per (producer, occasion),
19929
+ * not per row, and nothing addresses a row by it.
19930
+ */
19931
+ idempotencyKey: string().optional(),
19842
19932
  /** Omitted in slim projection. */
19843
19933
  trackId: string().optional(),
19844
19934
  className: string(),
@@ -20941,6 +21031,14 @@ var NativeCropResultSchema = object({
20941
21031
  * set `encodeJpeg: true`; `bytes` is then absent.
20942
21032
  */
20943
21033
  jpeg: string().optional(),
21034
+ /**
21035
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
21036
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
21037
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
21038
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
21039
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
21040
+ */
21041
+ jpegBytes: _instanceof(Uint8Array).optional(),
20944
21042
  width: number().int().positive(),
20945
21043
  height: number().int().positive(),
20946
21044
  /**
@@ -21007,7 +21105,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
21007
21105
  })]);
21008
21106
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
21009
21107
  var ParkedTrackFrameSchema = object({
21010
- jpeg: string(),
21108
+ /**
21109
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
21110
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
21111
+ * Exactly one of the two is present.
21112
+ */
21113
+ jpeg: string().optional(),
21114
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
21115
+ jpegBytes: _instanceof(Uint8Array).optional(),
21011
21116
  width: number().int().positive(),
21012
21117
  height: number().int().positive(),
21013
21118
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -21594,6 +21699,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21594
21699
  bbox: NativeCropBboxSchema,
21595
21700
  maxWidth: number().int().positive().optional(),
21596
21701
  /**
21702
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21703
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21704
+ * wire — never assume consent: a pre-D462 caller parses the field as
21705
+ * base64 and bytes would decode to garbage rather than fail.
21706
+ */
21707
+ acceptJpegBytes: boolean().optional(),
21708
+ /**
21597
21709
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
21598
21710
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
21599
21711
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -21661,7 +21773,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21661
21773
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
21662
21774
  deviceId: number(),
21663
21775
  trackId: string(),
21664
- kind: ParkedFrameKindSchema
21776
+ kind: ParkedFrameKindSchema,
21777
+ /**
21778
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21779
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21780
+ * wire — never assume consent: a pre-D462 caller parses the field as
21781
+ * base64 and bytes would decode to garbage rather than fail.
21782
+ */
21783
+ acceptJpegBytes: boolean().optional()
21665
21784
  }), ParkedTrackFrameSchema.nullable()), method(object({
21666
21785
  deviceId: number(),
21667
21786
  trackId: string()
@@ -28076,26 +28195,59 @@ authKey: string().optional() }), object({
28076
28195
  /** Human-readable error when `ok: false`. */
28077
28196
  error: string().optional()
28078
28197
  }), { kind: "mutation" });
28079
- /**
28080
- * Hardware / firmware motion sensor cap — binary detected state plus
28081
- * a timestamp of the last observation. Distinct from
28082
- * `motion-detection.cap.ts` which owns the LOCAL ML motion pipeline;
28083
- * `motion` is the lightweight readout from on-camera motion (Reolink
28084
- * `GetMdState`, Baichuan push `type: motion`, ONVIF analytics).
28085
- *
28086
- * Native-motion providers also fan out to `detection.camera-native`
28087
- * with `source: 'onboard'` so cross-cutting system services
28088
- * (alert-center, advanced-notifier) can subscribe once and receive
28089
- * motion from every camera.
28090
- */
28091
28198
  var MotionStatusSchema = object({
28092
28199
  detected: boolean(),
28093
28200
  /** Ms epoch of the last detected-true observation. Null if never detected. */
28094
28201
  lastDetectedAt: number().nullable(),
28095
28202
  /**
28096
- * Ms after which `detected` auto-reverts to false if no fresh push
28097
- * arrives. Null means the provider leaves detected state until a
28098
- * native "clear" event.
28203
+ * `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
28204
+ * `null` while false and on every `Sensor` device (D475) — see that
28205
+ * constant's doc for the one-authority rule.
28206
+ *
28207
+ * ## Reading this field still arms nothing
28208
+ *
28209
+ * It reads like an instruction to the consumer ("revert after N ms if
28210
+ * no fresh push arrives") and it is not one: nothing in this repo reads
28211
+ * the LIVE cap value to drive a timer. `pipeline-analytics`'s motion-episode
28212
+ * close DOES now use the same number — `MOTION_CLOSE_AFTER_MS` — but as an
28213
+ * imported constant, not as a read of `device.state.motion.value`, so this
28214
+ * field stays what it always was: DESCRIPTIVE output, mirroring an answer
28215
+ * computed elsewhere. Building a self-clear timer out of a READ of this
28216
+ * field would add a second falling-edge authority beside whichever one
28217
+ * already owns the device, and two that can disagree are worse than one.
28218
+ * Consumers that need a falling edge SHAPED differently — held open across
28219
+ * a flapping source — debounce on their own side and say so, as
28220
+ * `addon-export-alexa/src/motion-clear-hold.ts` and
28221
+ * `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
28222
+ *
28223
+ * ## Who writes it
28224
+ *
28225
+ * - **Cameras** — the runner's phase machine, `active → watching` on
28226
+ * `cooldown_expired`, which then writes this slice with
28227
+ * `detected: false` (`handlePhaseChanged` in
28228
+ * `pipeline-runner/index.ts`). It produces the FALLING edge, which
28229
+ * matters most for the sources that only ever push a rising one:
28230
+ * Reolink emits `MotionOnMotionChanged { detected: true }` and never
28231
+ * a false.
28232
+ * - **Sensors** (Home Assistant binary sensors, Homematic) — the
28233
+ * provider pushes the false itself, from the upstream system's own
28234
+ * state change. No phase machine is involved.
28235
+ *
28236
+ * ### The phase machine is CANONICAL, not sole — and that is a defect
28237
+ *
28238
+ * An earlier revision of this docblock (mine, 2026-09-12) claimed the
28239
+ * phase machine is the sole writer for a camera. It is not.
28240
+ * `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
28241
+ * `setCapSlice(motionCapability, …)` on their own rising edge, and
28242
+ * Hikvision's comment says why: it read THIS docblock, agreed the
28243
+ * runner is canonical, and wrote anyway to avoid per-tick churn. So
28244
+ * two authorities can disagree about one slice, which this repo
28245
+ * forbids, and the doc said otherwise — which is worse than saying
28246
+ * nothing, because it reads as verification.
28247
+ *
28248
+ * This predates D475 and is not fixed there: the fix touches every
28249
+ * camera provider. Recorded in D475's Consequences. Do not restore the
28250
+ * "sole writer" wording without also removing the other writers.
28099
28251
  */
28100
28252
  autoClearAfterMs: number().nullable()
28101
28253
  });
@@ -28165,7 +28317,11 @@ onMotionChanged: { data: MotionOnMotionChangedDataSchema } },
28165
28317
  */
28166
28318
  runtimeState: MotionStatusSchema,
28167
28319
  /**
28168
- * 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.
28320
+ * Runtime-state durability: **session** — every writer of this slice
28321
+ * writes only on an EDGE, so a restored `detected: true` would stay
28322
+ * frozen until the next one instead of being corrected. The next edge
28323
+ * re-publishes the real state. (On who the writers are, and why there
28324
+ * is more than one, see `autoClearAfterMs` above.)
28169
28325
  *
28170
28326
  * See `RuntimeStateDurability`. Enforced by
28171
28327
  * `scripts/check-runtime-state-durability.ts`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-import-alexa",
3
- "version": "0.2.95",
3
+ "version": "0.2.97",
4
4
  "description": "Alexa device-import provider for CamStack — imports the smart-home devices in a user's Alexa account via the unofficial alexa-remote2 cookie/token client (the inverse of the Alexa exporter)",
5
5
  "keywords": [
6
6
  "camstack",