@camstack/addon-terminal 0.1.101 → 0.1.103

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
@@ -7394,6 +7394,23 @@ function errMsg(err) {
7394
7394
  if (typeof err === "string") return err;
7395
7395
  return String(err);
7396
7396
  }
7397
+ new Set([
7398
+ "track",
7399
+ "summary",
7400
+ "face",
7401
+ "identity",
7402
+ "plate",
7403
+ "vehicle",
7404
+ "scene",
7405
+ "motion",
7406
+ "object",
7407
+ "audio"
7408
+ ]);
7409
+ new Set([
7410
+ "motion",
7411
+ "object",
7412
+ "audio"
7413
+ ]);
7397
7414
  var EncodeProfileSchema = object({
7398
7415
  video: object({
7399
7416
  codec: _enum([
@@ -12602,8 +12619,17 @@ method(object({
12602
12619
  }), array(SettingsRecordSchema).readonly()), method(object({
12603
12620
  namespace: string().optional(),
12604
12621
  collection: string(),
12605
- record: SettingsRecordSchema
12606
- }), _void(), { kind: "mutation" }), method(object({
12622
+ record: object({
12623
+ id: string().optional(),
12624
+ data: record(string(), unknown())
12625
+ })
12626
+ }), object({
12627
+ /**
12628
+ * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
12629
+ * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
12630
+ * primary key — which is the only place an auto key is knowable.
12631
+ */
12632
+ id: union([string(), number()]) }), { kind: "mutation" }), method(object({
12607
12633
  namespace: string().optional(),
12608
12634
  collection: string(),
12609
12635
  records: array(BulkRecordSchema).readonly()
@@ -12712,8 +12738,17 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
12712
12738
  }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
12713
12739
  namespace: string().optional(),
12714
12740
  collection: string(),
12715
- record: SettingsRecordSchema
12716
- }), _void(), {
12741
+ record: object({
12742
+ id: string().optional(),
12743
+ data: record(string(), unknown())
12744
+ })
12745
+ }), object({
12746
+ /**
12747
+ * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
12748
+ * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
12749
+ * primary key — which is the only place an auto key is knowable.
12750
+ */
12751
+ id: union([string(), number()]) }), {
12717
12752
  kind: "mutation",
12718
12753
  auth: "admin"
12719
12754
  }), method(object({
@@ -19540,7 +19575,20 @@ var TrackSchema = object({
19540
19575
  ...TrackRetrainFields
19541
19576
  });
19542
19577
  var BaseEventFields = {
19543
- id: string(),
19578
+ /**
19579
+ * A SQLite ROWID, assigned by the database (D474).
19580
+ *
19581
+ * Was a 36-character UUID and cost 263 MB of a 1 117 MB database — paid
19582
+ * TWICE per row, in the row and in the primary-key index, across 2.1 million
19583
+ * motion, audio and object events. An `INTEGER PRIMARY KEY` in SQLite **is**
19584
+ * the rowid: the table itself is that B-tree, so the index stops existing
19585
+ * rather than getting smaller. No shorter string does that.
19586
+ *
19587
+ * Defined once here for all three event kinds, which is why they move
19588
+ * together: a per-table migration would have forked this and
19589
+ * `COMMON_BASE_COLUMNS` and reunited them two stages later.
19590
+ */
19591
+ id: number().int(),
19544
19592
  deviceId: number(),
19545
19593
  timestamp: number()
19546
19594
  };
@@ -19559,7 +19607,34 @@ var MotionEventSchema = object({
19559
19607
  /** Omitted in slim projection. */
19560
19608
  frameHeight: number().optional(),
19561
19609
  /** Populated by B5 (recording playback URL for this event). */
19562
- mediaUrl: string().optional()
19610
+ mediaUrl: string().optional(),
19611
+ /**
19612
+ * One row per motion EPISODE, not one per push (D475). `null` while the
19613
+ * episode is still open — a further rising edge extends it in place rather
19614
+ * than inserting a new row. Set once, at close, to `lastOnAt - startedAt`
19615
+ * (the span from the first rising edge to the LAST one, deliberately NOT
19616
+ * `closedAt - startedAt` — the close delay is a quiet CONFIRMATION, not
19617
+ * movement, and folding it in would report `MOTION_CLOSE_AFTER_MS` of
19618
+ * motion for an instantaneous trigger).
19619
+ *
19620
+ * **Absent** (not merely `null`) on a row written before D475 — that means
19621
+ * "closed the old way, before this column existed", never "still open".
19622
+ * Nothing in this codebase may read an absent `durationMs` as an open
19623
+ * episode; only `null` means open.
19624
+ */
19625
+ durationMs: number().nullable().optional(),
19626
+ /**
19627
+ * Ms offsets from `timestamp` (the episode's own first rising edge, so the
19628
+ * first entry is always `0`) of every genuine off→on transition the
19629
+ * episode saw — "ogni evento on si deve salvare" (D475). NOT one entry per
19630
+ * push: a firmware source that keepalives at ~1 Hz for the whole burst
19631
+ * (Reolink, Hikvision) produces exactly one edge; a source that reports an
19632
+ * explicit `false` mid-episode and then resumes before the quiet window
19633
+ * elapses produces another. Stored compactly — see `motion-edge-codec.ts`
19634
+ * — and decoded back to this shape on read. Absent/empty on a legacy row,
19635
+ * which must never be read as "no episode happened here".
19636
+ */
19637
+ edges: array(number()).readonly().optional()
19563
19638
  });
19564
19639
  /**
19565
19640
  * Which detection SOURCE produced an object event. `pipeline` = the ML
@@ -19614,6 +19689,23 @@ var ObjectEventSchema = object({
19614
19689
  * includes it (it is light). Absent on rows written before this field.
19615
19690
  */
19616
19691
  frameId: string().optional(),
19692
+ /**
19693
+ * A PRODUCER-chosen key that makes a synthetic event's emission idempotent
19694
+ * (D474).
19695
+ *
19696
+ * Only the package detector writes it, and it exists because the event id
19697
+ * stopped being choosable: the delivery and pick-up rows used to BE their
19698
+ * dedupe key (`pa-pkg-<entryId>-delivered`), which is how "never emit a
19699
+ * second delivery for this entry" survived a restart. An `INTEGER` rowid is
19700
+ * assigned by SQLite, so that key had to move off the primary key rather
19701
+ * than be dropped — a detector that cannot recognise its own row re-delivers
19702
+ * every parcel on every boot.
19703
+ *
19704
+ * Absent on every other object event, and on every row written before this
19705
+ * field. Never a substitute for `id`: it is unique per (producer, occasion),
19706
+ * not per row, and nothing addresses a row by it.
19707
+ */
19708
+ idempotencyKey: string().optional(),
19617
19709
  /** Omitted in slim projection. */
19618
19710
  trackId: string().optional(),
19619
19711
  className: string(),
@@ -20716,6 +20808,14 @@ var NativeCropResultSchema = object({
20716
20808
  * set `encodeJpeg: true`; `bytes` is then absent.
20717
20809
  */
20718
20810
  jpeg: string().optional(),
20811
+ /**
20812
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
20813
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
20814
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
20815
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
20816
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
20817
+ */
20818
+ jpegBytes: _instanceof(Uint8Array).optional(),
20719
20819
  width: number().int().positive(),
20720
20820
  height: number().int().positive(),
20721
20821
  /**
@@ -20782,7 +20882,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
20782
20882
  })]);
20783
20883
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
20784
20884
  var ParkedTrackFrameSchema = object({
20785
- jpeg: string(),
20885
+ /**
20886
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
20887
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
20888
+ * Exactly one of the two is present.
20889
+ */
20890
+ jpeg: string().optional(),
20891
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
20892
+ jpegBytes: _instanceof(Uint8Array).optional(),
20786
20893
  width: number().int().positive(),
20787
20894
  height: number().int().positive(),
20788
20895
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -21369,6 +21476,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21369
21476
  bbox: NativeCropBboxSchema,
21370
21477
  maxWidth: number().int().positive().optional(),
21371
21478
  /**
21479
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21480
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21481
+ * wire — never assume consent: a pre-D462 caller parses the field as
21482
+ * base64 and bytes would decode to garbage rather than fail.
21483
+ */
21484
+ acceptJpegBytes: boolean().optional(),
21485
+ /**
21372
21486
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
21373
21487
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
21374
21488
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -21436,7 +21550,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21436
21550
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
21437
21551
  deviceId: number(),
21438
21552
  trackId: string(),
21439
- kind: ParkedFrameKindSchema
21553
+ kind: ParkedFrameKindSchema,
21554
+ /**
21555
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21556
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21557
+ * wire — never assume consent: a pre-D462 caller parses the field as
21558
+ * base64 and bytes would decode to garbage rather than fail.
21559
+ */
21560
+ acceptJpegBytes: boolean().optional()
21440
21561
  }), ParkedTrackFrameSchema.nullable()), method(object({
21441
21562
  deviceId: number(),
21442
21563
  trackId: string()
@@ -27982,26 +28103,59 @@ authKey: string().optional() }), object({
27982
28103
  /** Human-readable error when `ok: false`. */
27983
28104
  error: string().optional()
27984
28105
  }), { kind: "mutation" });
27985
- /**
27986
- * Hardware / firmware motion sensor cap — binary detected state plus
27987
- * a timestamp of the last observation. Distinct from
27988
- * `motion-detection.cap.ts` which owns the LOCAL ML motion pipeline;
27989
- * `motion` is the lightweight readout from on-camera motion (Reolink
27990
- * `GetMdState`, Baichuan push `type: motion`, ONVIF analytics).
27991
- *
27992
- * Native-motion providers also fan out to `detection.camera-native`
27993
- * with `source: 'onboard'` so cross-cutting system services
27994
- * (alert-center, advanced-notifier) can subscribe once and receive
27995
- * motion from every camera.
27996
- */
27997
28106
  var MotionStatusSchema = object({
27998
28107
  detected: boolean(),
27999
28108
  /** Ms epoch of the last detected-true observation. Null if never detected. */
28000
28109
  lastDetectedAt: number().nullable(),
28001
28110
  /**
28002
- * Ms after which `detected` auto-reverts to false if no fresh push
28003
- * arrives. Null means the provider leaves detected state until a
28004
- * native "clear" event.
28111
+ * `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
28112
+ * `null` while false and on every `Sensor` device (D475) — see that
28113
+ * constant's doc for the one-authority rule.
28114
+ *
28115
+ * ## Reading this field still arms nothing
28116
+ *
28117
+ * It reads like an instruction to the consumer ("revert after N ms if
28118
+ * no fresh push arrives") and it is not one: nothing in this repo reads
28119
+ * the LIVE cap value to drive a timer. `pipeline-analytics`'s motion-episode
28120
+ * close DOES now use the same number — `MOTION_CLOSE_AFTER_MS` — but as an
28121
+ * imported constant, not as a read of `device.state.motion.value`, so this
28122
+ * field stays what it always was: DESCRIPTIVE output, mirroring an answer
28123
+ * computed elsewhere. Building a self-clear timer out of a READ of this
28124
+ * field would add a second falling-edge authority beside whichever one
28125
+ * already owns the device, and two that can disagree are worse than one.
28126
+ * Consumers that need a falling edge SHAPED differently — held open across
28127
+ * a flapping source — debounce on their own side and say so, as
28128
+ * `addon-export-alexa/src/motion-clear-hold.ts` and
28129
+ * `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
28130
+ *
28131
+ * ## Who writes it
28132
+ *
28133
+ * - **Cameras** — the runner's phase machine, `active → watching` on
28134
+ * `cooldown_expired`, which then writes this slice with
28135
+ * `detected: false` (`handlePhaseChanged` in
28136
+ * `pipeline-runner/index.ts`). It produces the FALLING edge, which
28137
+ * matters most for the sources that only ever push a rising one:
28138
+ * Reolink emits `MotionOnMotionChanged { detected: true }` and never
28139
+ * a false.
28140
+ * - **Sensors** (Home Assistant binary sensors, Homematic) — the
28141
+ * provider pushes the false itself, from the upstream system's own
28142
+ * state change. No phase machine is involved.
28143
+ *
28144
+ * ### The phase machine is CANONICAL, not sole — and that is a defect
28145
+ *
28146
+ * An earlier revision of this docblock (mine, 2026-09-12) claimed the
28147
+ * phase machine is the sole writer for a camera. It is not.
28148
+ * `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
28149
+ * `setCapSlice(motionCapability, …)` on their own rising edge, and
28150
+ * Hikvision's comment says why: it read THIS docblock, agreed the
28151
+ * runner is canonical, and wrote anyway to avoid per-tick churn. So
28152
+ * two authorities can disagree about one slice, which this repo
28153
+ * forbids, and the doc said otherwise — which is worse than saying
28154
+ * nothing, because it reads as verification.
28155
+ *
28156
+ * This predates D475 and is not fixed there: the fix touches every
28157
+ * camera provider. Recorded in D475's Consequences. Do not restore the
28158
+ * "sole writer" wording without also removing the other writers.
28005
28159
  */
28006
28160
  autoClearAfterMs: number().nullable()
28007
28161
  });
@@ -28071,7 +28225,11 @@ onMotionChanged: { data: MotionOnMotionChangedDataSchema } },
28071
28225
  */
28072
28226
  runtimeState: MotionStatusSchema,
28073
28227
  /**
28074
- * 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.
28228
+ * Runtime-state durability: **session** — every writer of this slice
28229
+ * writes only on an EDGE, so a restored `detected: true` would stay
28230
+ * frozen until the next one instead of being corrected. The next edge
28231
+ * re-publishes the real state. (On who the writers are, and why there
28232
+ * is more than one, see `autoClearAfterMs` above.)
28075
28233
  *
28076
28234
  * See `RuntimeStateDurability`. Enforced by
28077
28235
  * `scripts/check-runtime-state-durability.ts`.
package/dist/addon.mjs CHANGED
@@ -7371,6 +7371,23 @@ function errMsg(err) {
7371
7371
  if (typeof err === "string") return err;
7372
7372
  return String(err);
7373
7373
  }
7374
+ new Set([
7375
+ "track",
7376
+ "summary",
7377
+ "face",
7378
+ "identity",
7379
+ "plate",
7380
+ "vehicle",
7381
+ "scene",
7382
+ "motion",
7383
+ "object",
7384
+ "audio"
7385
+ ]);
7386
+ new Set([
7387
+ "motion",
7388
+ "object",
7389
+ "audio"
7390
+ ]);
7374
7391
  var EncodeProfileSchema = object({
7375
7392
  video: object({
7376
7393
  codec: _enum([
@@ -12579,8 +12596,17 @@ method(object({
12579
12596
  }), array(SettingsRecordSchema).readonly()), method(object({
12580
12597
  namespace: string().optional(),
12581
12598
  collection: string(),
12582
- record: SettingsRecordSchema
12583
- }), _void(), { kind: "mutation" }), method(object({
12599
+ record: object({
12600
+ id: string().optional(),
12601
+ data: record(string(), unknown())
12602
+ })
12603
+ }), object({
12604
+ /**
12605
+ * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
12606
+ * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
12607
+ * primary key — which is the only place an auto key is knowable.
12608
+ */
12609
+ id: union([string(), number()]) }), { kind: "mutation" }), method(object({
12584
12610
  namespace: string().optional(),
12585
12611
  collection: string(),
12586
12612
  records: array(BulkRecordSchema).readonly()
@@ -12689,8 +12715,17 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
12689
12715
  }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
12690
12716
  namespace: string().optional(),
12691
12717
  collection: string(),
12692
- record: SettingsRecordSchema
12693
- }), _void(), {
12718
+ record: object({
12719
+ id: string().optional(),
12720
+ data: record(string(), unknown())
12721
+ })
12722
+ }), object({
12723
+ /**
12724
+ * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
12725
+ * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
12726
+ * primary key — which is the only place an auto key is knowable.
12727
+ */
12728
+ id: union([string(), number()]) }), {
12694
12729
  kind: "mutation",
12695
12730
  auth: "admin"
12696
12731
  }), method(object({
@@ -19517,7 +19552,20 @@ var TrackSchema = object({
19517
19552
  ...TrackRetrainFields
19518
19553
  });
19519
19554
  var BaseEventFields = {
19520
- id: string(),
19555
+ /**
19556
+ * A SQLite ROWID, assigned by the database (D474).
19557
+ *
19558
+ * Was a 36-character UUID and cost 263 MB of a 1 117 MB database — paid
19559
+ * TWICE per row, in the row and in the primary-key index, across 2.1 million
19560
+ * motion, audio and object events. An `INTEGER PRIMARY KEY` in SQLite **is**
19561
+ * the rowid: the table itself is that B-tree, so the index stops existing
19562
+ * rather than getting smaller. No shorter string does that.
19563
+ *
19564
+ * Defined once here for all three event kinds, which is why they move
19565
+ * together: a per-table migration would have forked this and
19566
+ * `COMMON_BASE_COLUMNS` and reunited them two stages later.
19567
+ */
19568
+ id: number().int(),
19521
19569
  deviceId: number(),
19522
19570
  timestamp: number()
19523
19571
  };
@@ -19536,7 +19584,34 @@ var MotionEventSchema = object({
19536
19584
  /** Omitted in slim projection. */
19537
19585
  frameHeight: number().optional(),
19538
19586
  /** Populated by B5 (recording playback URL for this event). */
19539
- mediaUrl: string().optional()
19587
+ mediaUrl: string().optional(),
19588
+ /**
19589
+ * One row per motion EPISODE, not one per push (D475). `null` while the
19590
+ * episode is still open — a further rising edge extends it in place rather
19591
+ * than inserting a new row. Set once, at close, to `lastOnAt - startedAt`
19592
+ * (the span from the first rising edge to the LAST one, deliberately NOT
19593
+ * `closedAt - startedAt` — the close delay is a quiet CONFIRMATION, not
19594
+ * movement, and folding it in would report `MOTION_CLOSE_AFTER_MS` of
19595
+ * motion for an instantaneous trigger).
19596
+ *
19597
+ * **Absent** (not merely `null`) on a row written before D475 — that means
19598
+ * "closed the old way, before this column existed", never "still open".
19599
+ * Nothing in this codebase may read an absent `durationMs` as an open
19600
+ * episode; only `null` means open.
19601
+ */
19602
+ durationMs: number().nullable().optional(),
19603
+ /**
19604
+ * Ms offsets from `timestamp` (the episode's own first rising edge, so the
19605
+ * first entry is always `0`) of every genuine off→on transition the
19606
+ * episode saw — "ogni evento on si deve salvare" (D475). NOT one entry per
19607
+ * push: a firmware source that keepalives at ~1 Hz for the whole burst
19608
+ * (Reolink, Hikvision) produces exactly one edge; a source that reports an
19609
+ * explicit `false` mid-episode and then resumes before the quiet window
19610
+ * elapses produces another. Stored compactly — see `motion-edge-codec.ts`
19611
+ * — and decoded back to this shape on read. Absent/empty on a legacy row,
19612
+ * which must never be read as "no episode happened here".
19613
+ */
19614
+ edges: array(number()).readonly().optional()
19540
19615
  });
19541
19616
  /**
19542
19617
  * Which detection SOURCE produced an object event. `pipeline` = the ML
@@ -19591,6 +19666,23 @@ var ObjectEventSchema = object({
19591
19666
  * includes it (it is light). Absent on rows written before this field.
19592
19667
  */
19593
19668
  frameId: string().optional(),
19669
+ /**
19670
+ * A PRODUCER-chosen key that makes a synthetic event's emission idempotent
19671
+ * (D474).
19672
+ *
19673
+ * Only the package detector writes it, and it exists because the event id
19674
+ * stopped being choosable: the delivery and pick-up rows used to BE their
19675
+ * dedupe key (`pa-pkg-<entryId>-delivered`), which is how "never emit a
19676
+ * second delivery for this entry" survived a restart. An `INTEGER` rowid is
19677
+ * assigned by SQLite, so that key had to move off the primary key rather
19678
+ * than be dropped — a detector that cannot recognise its own row re-delivers
19679
+ * every parcel on every boot.
19680
+ *
19681
+ * Absent on every other object event, and on every row written before this
19682
+ * field. Never a substitute for `id`: it is unique per (producer, occasion),
19683
+ * not per row, and nothing addresses a row by it.
19684
+ */
19685
+ idempotencyKey: string().optional(),
19594
19686
  /** Omitted in slim projection. */
19595
19687
  trackId: string().optional(),
19596
19688
  className: string(),
@@ -20693,6 +20785,14 @@ var NativeCropResultSchema = object({
20693
20785
  * set `encodeJpeg: true`; `bytes` is then absent.
20694
20786
  */
20695
20787
  jpeg: string().optional(),
20788
+ /**
20789
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
20790
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
20791
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
20792
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
20793
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
20794
+ */
20795
+ jpegBytes: _instanceof(Uint8Array).optional(),
20696
20796
  width: number().int().positive(),
20697
20797
  height: number().int().positive(),
20698
20798
  /**
@@ -20759,7 +20859,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
20759
20859
  })]);
20760
20860
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
20761
20861
  var ParkedTrackFrameSchema = object({
20762
- jpeg: string(),
20862
+ /**
20863
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
20864
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
20865
+ * Exactly one of the two is present.
20866
+ */
20867
+ jpeg: string().optional(),
20868
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
20869
+ jpegBytes: _instanceof(Uint8Array).optional(),
20763
20870
  width: number().int().positive(),
20764
20871
  height: number().int().positive(),
20765
20872
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -21346,6 +21453,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21346
21453
  bbox: NativeCropBboxSchema,
21347
21454
  maxWidth: number().int().positive().optional(),
21348
21455
  /**
21456
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21457
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21458
+ * wire — never assume consent: a pre-D462 caller parses the field as
21459
+ * base64 and bytes would decode to garbage rather than fail.
21460
+ */
21461
+ acceptJpegBytes: boolean().optional(),
21462
+ /**
21349
21463
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
21350
21464
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
21351
21465
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -21413,7 +21527,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21413
21527
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
21414
21528
  deviceId: number(),
21415
21529
  trackId: string(),
21416
- kind: ParkedFrameKindSchema
21530
+ kind: ParkedFrameKindSchema,
21531
+ /**
21532
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21533
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21534
+ * wire — never assume consent: a pre-D462 caller parses the field as
21535
+ * base64 and bytes would decode to garbage rather than fail.
21536
+ */
21537
+ acceptJpegBytes: boolean().optional()
21417
21538
  }), ParkedTrackFrameSchema.nullable()), method(object({
21418
21539
  deviceId: number(),
21419
21540
  trackId: string()
@@ -27959,26 +28080,59 @@ authKey: string().optional() }), object({
27959
28080
  /** Human-readable error when `ok: false`. */
27960
28081
  error: string().optional()
27961
28082
  }), { kind: "mutation" });
27962
- /**
27963
- * Hardware / firmware motion sensor cap — binary detected state plus
27964
- * a timestamp of the last observation. Distinct from
27965
- * `motion-detection.cap.ts` which owns the LOCAL ML motion pipeline;
27966
- * `motion` is the lightweight readout from on-camera motion (Reolink
27967
- * `GetMdState`, Baichuan push `type: motion`, ONVIF analytics).
27968
- *
27969
- * Native-motion providers also fan out to `detection.camera-native`
27970
- * with `source: 'onboard'` so cross-cutting system services
27971
- * (alert-center, advanced-notifier) can subscribe once and receive
27972
- * motion from every camera.
27973
- */
27974
28083
  var MotionStatusSchema = object({
27975
28084
  detected: boolean(),
27976
28085
  /** Ms epoch of the last detected-true observation. Null if never detected. */
27977
28086
  lastDetectedAt: number().nullable(),
27978
28087
  /**
27979
- * Ms after which `detected` auto-reverts to false if no fresh push
27980
- * arrives. Null means the provider leaves detected state until a
27981
- * native "clear" event.
28088
+ * `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
28089
+ * `null` while false and on every `Sensor` device (D475) — see that
28090
+ * constant's doc for the one-authority rule.
28091
+ *
28092
+ * ## Reading this field still arms nothing
28093
+ *
28094
+ * It reads like an instruction to the consumer ("revert after N ms if
28095
+ * no fresh push arrives") and it is not one: nothing in this repo reads
28096
+ * the LIVE cap value to drive a timer. `pipeline-analytics`'s motion-episode
28097
+ * close DOES now use the same number — `MOTION_CLOSE_AFTER_MS` — but as an
28098
+ * imported constant, not as a read of `device.state.motion.value`, so this
28099
+ * field stays what it always was: DESCRIPTIVE output, mirroring an answer
28100
+ * computed elsewhere. Building a self-clear timer out of a READ of this
28101
+ * field would add a second falling-edge authority beside whichever one
28102
+ * already owns the device, and two that can disagree are worse than one.
28103
+ * Consumers that need a falling edge SHAPED differently — held open across
28104
+ * a flapping source — debounce on their own side and say so, as
28105
+ * `addon-export-alexa/src/motion-clear-hold.ts` and
28106
+ * `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
28107
+ *
28108
+ * ## Who writes it
28109
+ *
28110
+ * - **Cameras** — the runner's phase machine, `active → watching` on
28111
+ * `cooldown_expired`, which then writes this slice with
28112
+ * `detected: false` (`handlePhaseChanged` in
28113
+ * `pipeline-runner/index.ts`). It produces the FALLING edge, which
28114
+ * matters most for the sources that only ever push a rising one:
28115
+ * Reolink emits `MotionOnMotionChanged { detected: true }` and never
28116
+ * a false.
28117
+ * - **Sensors** (Home Assistant binary sensors, Homematic) — the
28118
+ * provider pushes the false itself, from the upstream system's own
28119
+ * state change. No phase machine is involved.
28120
+ *
28121
+ * ### The phase machine is CANONICAL, not sole — and that is a defect
28122
+ *
28123
+ * An earlier revision of this docblock (mine, 2026-09-12) claimed the
28124
+ * phase machine is the sole writer for a camera. It is not.
28125
+ * `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
28126
+ * `setCapSlice(motionCapability, …)` on their own rising edge, and
28127
+ * Hikvision's comment says why: it read THIS docblock, agreed the
28128
+ * runner is canonical, and wrote anyway to avoid per-tick churn. So
28129
+ * two authorities can disagree about one slice, which this repo
28130
+ * forbids, and the doc said otherwise — which is worse than saying
28131
+ * nothing, because it reads as verification.
28132
+ *
28133
+ * This predates D475 and is not fixed there: the fix touches every
28134
+ * camera provider. Recorded in D475's Consequences. Do not restore the
28135
+ * "sole writer" wording without also removing the other writers.
27982
28136
  */
27983
28137
  autoClearAfterMs: number().nullable()
27984
28138
  });
@@ -28048,7 +28202,11 @@ onMotionChanged: { data: MotionOnMotionChangedDataSchema } },
28048
28202
  */
28049
28203
  runtimeState: MotionStatusSchema,
28050
28204
  /**
28051
- * 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.
28205
+ * Runtime-state durability: **session** — every writer of this slice
28206
+ * writes only on an EDGE, so a restored `detected: true` would stay
28207
+ * frozen until the next one instead of being corrected. The next edge
28208
+ * re-publishes the real state. (On who the writers are, and why there
28209
+ * is more than one, see `autoClearAfterMs` above.)
28052
28210
  *
28053
28211
  * See `RuntimeStateDurability`. Enforced by
28054
28212
  * `scripts/check-runtime-state-durability.ts`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-terminal",
3
- "version": "0.1.101",
3
+ "version": "0.1.103",
4
4
  "description": "Interactive terminal sessions (pty + xterm) as a CamStack addon",
5
5
  "keywords": [
6
6
  "camstack",