@camstack/addon-post-analysis 1.2.308 → 1.2.310

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.
@@ -30,7 +30,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
30
30
  }) : target, mod));
31
31
  //#endregion
32
32
  let node_crypto = require("node:crypto");
33
- //#region ../types/dist/event-category-C5xZWqz6.mjs
33
+ //#region ../types/dist/event-category-BGmz_oxW.mjs
34
34
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
35
35
  EventCategory["SystemBoot"] = "system.boot";
36
36
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -563,6 +563,15 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
563
563
  */
564
564
  EventCategory["PipelineAudioInferenceResult"] = "pipeline.audio-inference-result";
565
565
  EventCategory["DetectionPhaseTransition"] = "detection.phase-transition";
566
+ /**
567
+ * A camera provider's RAW onboard motion push (D673): the `MotionOnMotionChanged`
568
+ * data shape without `triggeredBy`, built by `providerMotionEvent`. Its one
569
+ * consumer is the orchestrator's camera-sensors bridge, which re-emits the
570
+ * camera's EFFECTIVE onboard motion as `MotionOnMotionChanged` (a pass-through
571
+ * for a camera with no attached sensor). Providers must not emit
572
+ * `MotionOnMotionChanged` themselves; `scripts/check-onboard-motion-emitters.ts`
573
+ * keeps it so (camera-grid is a named, deferred exception).
574
+ */
566
575
  EventCategory["ProviderMotion"] = "provider.motion";
567
576
  EventCategory["ProviderDetection"] = "provider.detection";
568
577
  EventCategory["EnrichmentEmbeddingStored"] = "enrichment.embedding.stored";
@@ -5409,7 +5418,7 @@ var ZodIssueCode = {
5409
5418
  var ZodFirstPartyTypeKind;
5410
5419
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5411
5420
  //#endregion
5412
- //#region ../types/dist/sleep-gU6hqv4_.mjs
5421
+ //#region ../types/dist/sleep-CDCONfkt.mjs
5413
5422
  /**
5414
5423
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5415
5424
  * window to float samples (D455).
@@ -7668,7 +7677,7 @@ function errMsg(err) {
7668
7677
  return String(err);
7669
7678
  }
7670
7679
  //#endregion
7671
- //#region ../types/dist/composition-Dq42XWp0.mjs
7680
+ //#region ../types/dist/composition-43aqsZQj.mjs
7672
7681
  /**
7673
7682
  * Deterministic SHA-256 hash of an arbitrary serialisable value. The
7674
7683
  * canonical form sorts object keys alphabetically at every depth so two
@@ -7756,13 +7765,12 @@ portable("linux64"), portable("linuxarm64"), portable("macarm64"), portable("mac
7756
7765
  * LA tabella "quale booleano di questo tipo di device conta come ALTO", e il
7757
7766
  * valutatore puro del suo FRONTE.
7758
7767
  *
7759
- * Viveva dentro il builtin virtual-doorbell
7760
- * (`@camstack/system` — `builtins/doorbell/trigger-engine.ts`) e i suoi
7761
- * predicati erano privati al modulo. Il recorder ne ha bisogno per il trigger
7762
- * `RecordingTriggers.sensorDeviceIds`: copiarla avrebbe creato la SECONDA
7763
- * tabella, che diverge alla prima cap aggiunta e il cui sintomo — "il sensore
7764
- * fa suonare il campanello ma non registra" — è esattamente D62. Quindi si
7765
- * SPOSTA qui e il doorbell la ri-esporta.
7768
+ * UNA tabella per tutti quelli che chiedono "questo device è ALTO?": il
7769
+ * trigger `RecordingTriggers.sensorDeviceIds` del recorder, i marker dei
7770
+ * sensori della post-analysis, il bridge camera-sensors dell'orchestratore e
7771
+ * le sorgenti di un campanello composto (`doorbellFeatureSources`, D671).
7772
+ * Una seconda copia divergerebbe alla prima cap aggiunta, e il sintomo — "il
7773
+ * sensore fa suonare il campanello ma non registra" — è esattamente D62.
7766
7774
  *
7767
7775
  * ⚠ NON è `DEVICE_STATE_READERS` (`catalogs/device-state-vocabulary.ts`), e le
7768
7776
  * due non vanno unificate: quella risponde a "qual è la PAROLA di stato per una
@@ -7812,8 +7820,6 @@ var SOURCE_CAP_CHANGED_AT_FIELD = {
7812
7820
  vibration: "lastChangedAt",
7813
7821
  tamper: "lastChangedAt"
7814
7822
  };
7815
- /** Cap names whose presence in a device's bindings qualify it as a source. */
7816
- var SOURCE_CAPS = Object.keys(SOURCE_CAP_ACTIVE_FIELD);
7817
7823
  /** True when a cap is a recognised binary/switch source. */
7818
7824
  function isSourceCap(capName) {
7819
7825
  return Object.prototype.hasOwnProperty.call(SOURCE_CAP_ACTIVE_FIELD, capName);
@@ -9894,7 +9900,7 @@ var RecordingTriggersSchema = object({
9894
9900
  *
9895
9901
  * Cosa vuol dire "alto" dipende dal TIPO di device e non è deciso qui:
9896
9902
  * `SOURCE_CAP_ACTIVE_FIELD` (`catalogs/sensor-active-state.ts`) è LA tabella,
9897
- * la stessa che il virtual-doorbell usa dal 2026-08-05. Ed è il FRONTE, non
9903
+ * la stessa del campanello composto (D671). Ed è il FRONTE, non
9898
9904
  * il livello: un contatto trovato già aperto al riavvio del runner non fa
9899
9905
  * registrare.
9900
9906
  */
@@ -16454,109 +16460,10 @@ method(object({
16454
16460
  deviceIds: array(number()).readonly(),
16455
16461
  caps: array(string()).readonly().optional()
16456
16462
  }), record(string(), record(string(), unknown().nullable())));
16457
- /**
16458
- * Doorbell button cap. Two kinds of providers coexist behind this cap
16459
- * name (same pattern as `snapshot`):
16460
- *
16461
- * - **Native** providers: registered per-device by device-driver
16462
- * addons via `ctx.registerNativeCap` — either on a
16463
- * `DeviceType.Button` accessory with `role: DeviceRole.Doorbell`,
16464
- * or directly on the camera (Reolink registers at camera level).
16465
- * Emits an `onPressed` event every time the firmware pushes a
16466
- * ring; status tracks the last press and a pressCount since start
16467
- * (diagnostic).
16468
- *
16469
- * - **Wrapper** provider: the `virtual-doorbell` system builtin
16470
- * (`@camstack/system/builtins/doorbell`). Turns ANY binary-ish
16471
- * device (contact / switch / event-emitter …) into a doorbell for
16472
- * a camera. `defaultActive: false` — the operator explicitly binds
16473
- * it per camera in the device-bindings UI, then picks the source
16474
- * device + trigger in the per-device settings.
16475
- *
16476
- * The DeviceEventPropagator re-emits `onPressed` on the camera parent
16477
- * — subscribers listening at the camera level receive ring events
16478
- * with `via[]` populated. No code on the parent needed.
16479
- */
16480
- var DoorbellStatusSchema = object({
16481
- /** Ms epoch of the last press. null = never observed since this provider started. */
16482
- lastPressedAt: number().nullable(),
16483
- /** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
16484
- pressCountSinceStart: number()
16485
- });
16486
- var DoorbellPressEventSchema = object({
16487
- deviceId: number(),
16488
- timestamp: number()
16489
- });
16490
- /**
16491
- * The `doorbell-source` extension slot's editable value (D648): the camera's
16492
- * virtual-doorbell trigger devices, exactly what the wrapper's
16493
- * `doorbellSources` persists (as `{ deviceId }` records).
16494
- */
16495
- var DoorbellSourceSlotValueSchema = object({ deviceIds: array(number().int().positive()) });
16496
- /**
16497
- * The `doorbell-source` slot — which devices ring this camera's VIRTUAL
16498
- * doorbell, owned by the `virtual-doorbell` wrapper over its
16499
- * `doorbellSources` store (D648). A source rings when one of its
16500
- * `SOURCE_CAPS` rises. Whether the wrapper is bound to the camera at all is a
16501
- * different authority (`deviceManager.setWrapperActive`, D62) — the slot
16502
- * reports it, it never writes it.
16503
- */
16504
- var DOORBELL_SOURCE_SLOT = {
16505
- id: "doorbell-source",
16506
- label: "Doorbell trigger devices",
16507
- description: "Any of these becoming active rings this camera's virtual doorbell: a binary sensor when it goes active, a switch when it turns on.",
16508
- shape: "association",
16509
- hostDeviceTypes: [DeviceType.Camera],
16510
- sourceCaps: SOURCE_CAPS,
16511
- cardinality: "many",
16512
- value: DoorbellSourceSlotValueSchema
16513
- };
16514
- var doorbellCapability = {
16515
- name: "doorbell",
16516
- scope: "device",
16517
- deviceNative: true,
16518
- mode: "singleton",
16519
- kind: "wrapper",
16520
- defaultActive: false,
16521
- deviceTypes: [DeviceType.Button, DeviceType.Camera],
16522
- extensionSlots: [DOORBELL_SOURCE_SLOT],
16523
- methods: {},
16524
- events: {
16525
- /**
16526
- * Fires once per physical press. Reolink delivers via Baichuan
16527
- * push (`ReolinkSimpleEvent.type === 'doorbell'`). There is no
16528
- * release/duration — it's a pulse.
16529
- */
16530
- onPressed: {
16531
- data: DoorbellPressEventSchema,
16532
- fromState: {
16533
- field: "lastPressedAt",
16534
- on: "advance"
16535
- }
16536
- } },
16537
- status: {
16538
- schema: DoorbellStatusSchema,
16539
- kind: "push"
16540
- },
16541
- /**
16542
- * Runtime-state slice — last press timestamp + lifetime press count.
16543
- * Mirrored by the kernel and readable via
16544
- * `device.state.doorbell.value`. UIs can show "last ring 5m ago"
16545
- * without subscribing.
16546
- */
16547
- runtimeState: DoorbellStatusSchema,
16548
- /**
16549
- * Runtime-state durability: **restored** — a monotonic accumulator: the slice IS the record. `lastPressedAt` is content here, not a clock, so it is deliberately NOT volatile.
16550
- *
16551
- * See `RuntimeStateDurability`. Enforced by
16552
- * `scripts/check-runtime-state-durability.ts`.
16553
- */
16554
- durability: "restored"
16555
- };
16556
- var ExtensionSlotIdSchema = _enum(["doorbell-source", "linked-devices"]);
16557
- DeviceType.Camera, DeviceType.Camera;
16463
+ var ExtensionSlotIdSchema = _enum(["linked-devices"]);
16464
+ DeviceType.Camera;
16558
16465
  /** A slot's editable value, discriminated on `slot`. */
16559
- var ExtensionSlotValueSchema = discriminatedUnion("slot", [DoorbellSourceSlotValueSchema.extend({ slot: literal("doorbell-source") }), LinkedDevicesSlotValueSchema.extend({ slot: literal("linked-devices") })]);
16466
+ var ExtensionSlotValueSchema = discriminatedUnion("slot", [LinkedDevicesSlotValueSchema.extend({ slot: literal("linked-devices") })]);
16560
16467
  DeviceType.Camera;
16561
16468
  var ExtensionSourceAvailabilitySchema = discriminatedUnion("state", [object({ state: literal("ok") }), object({
16562
16469
  state: literal("unreachable"),
@@ -16593,10 +16500,11 @@ var ExtensionSlotSourceSchema = object({
16593
16500
  });
16594
16501
  /**
16595
16502
  * A DIFFERENT authority that gates whether the slot's sources do anything —
16596
- * reported read-only, named, never written through this contract (D62). The
16597
- * virtual doorbell's sources ring only while the wrapper is bound to the
16598
- * camera, and that binding belongs to `deviceManager.setWrapperActive`.
16599
- * `unknown` means the gate could not be read; it is not "inactive" (D315).
16503
+ * reported read-only, named, never written through this contract (D62) — e.g.
16504
+ * a slot whose sources act only while a wrapper is bound to the host, a
16505
+ * binding that belongs to `deviceManager.setWrapperActive`. No slot reports
16506
+ * one today (`linked-devices` answers `null`). `unknown` means the gate could
16507
+ * not be read; it is not "inactive" (D315).
16600
16508
  */
16601
16509
  var ExtensionSlotActivationSchema = object({
16602
16510
  state: _enum([
@@ -16612,7 +16520,7 @@ var ExtensionSlotRowSchema = discriminatedUnion("state", [object({
16612
16520
  /** `<source>:<slotId>` — the routing key for `listCandidates` / `setSlot`. */
16613
16521
  slotRef: string(),
16614
16522
  slot: ExtensionSlotIdSchema,
16615
- /** Names the store written (D62), e.g. `virtual-doorbell:doorbellSources`. */
16523
+ /** Names the store written (D62), e.g. `device-manager:_linkedDeviceIds`. */
16616
16524
  authority: string(),
16617
16525
  activation: ExtensionSlotActivationSchema.nullable(),
16618
16526
  value: ExtensionSlotValueSchema,
@@ -19837,17 +19745,25 @@ var NcScheduleSchema = object({
19837
19745
  */
19838
19746
  var NcSystemEventDeliveryModeSchema = _enum(["instant", "summary"]);
19839
19747
  /**
19748
+ * How a summary window is SENT (D698): `rule` (absent) = ONE notification with
19749
+ * every section; `section` = one notification per section with something to
19750
+ * say (an unavailable section included), each titled by its section.
19751
+ */
19752
+ var NcStateSummarySplitSchema = _enum(["rule", "section"]);
19753
+ /**
19840
19754
  * `summary`: the rule sends NOTHING per event. When a window of `schedule`
19841
19755
  * CLOSES, it sends one notification with the current state of its kinds
19842
19756
  * (low batteries, consumables to replace, devices offline, updates
19843
- * available, ...), after its own filters. Nothing to report sends nothing.
19757
+ * available, ...), after its own filters — or, with `split: 'section'`
19758
+ * (D698), one notification per section. Nothing to report sends nothing.
19844
19759
  * The schedule is the ordinary `NcSchedule` (weekly windows, IANA timezone,
19845
19760
  * midnight crossing); the send time is each window's END. Refused on the
19846
19761
  * `alarm` family, which stays instant (`systemEventDeliveryProblems`).
19847
19762
  */
19848
19763
  var NcSystemEventDeliverySchema = discriminatedUnion("mode", [object({ mode: literal("instant") }), object({
19849
19764
  mode: literal("summary"),
19850
- schedule: NcScheduleSchema
19765
+ schedule: NcScheduleSchema,
19766
+ split: NcStateSummarySplitSchema.optional()
19851
19767
  })]);
19852
19768
  /** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
19853
19769
  var NcPlateMatcherSchema = object({
@@ -20864,11 +20780,23 @@ var NcStateSummaryPreviewSectionSchema = object({
20864
20780
  reason: string().optional()
20865
20781
  });
20866
20782
  /**
20783
+ * One notification a previewed summary would send (D698): the whole summary on
20784
+ * a `rule` split (no `section`), one section's on a `section` split.
20785
+ */
20786
+ var NcStateSummaryPreviewRowSchema = object({
20787
+ section: string().optional(),
20788
+ /** The section's name on a per-section row; every reported section's, joined, on a combined one. */
20789
+ title: string(),
20790
+ text: string(),
20791
+ count: number().int().nonnegative()
20792
+ });
20793
+ /**
20867
20794
  * The summary a rule would send now. `empty` = nothing to report and every
20868
20795
  * section read: such a summary is NOT sent. `dropped` counts the open states
20869
20796
  * the rule's own filters (or a camera mute) left out, by reason.
20870
20797
  * `excludedGroups` names the kind groups selected that have no state to report
20871
- * (backups & exports).
20798
+ * (backups & exports). `split` and `rows` (D698) say how it would be sent —
20799
+ * optional, so an older hub's answer still parses.
20872
20800
  */
20873
20801
  var NcStateSummaryPreviewSchema = object({
20874
20802
  empty: boolean(),
@@ -20876,7 +20804,9 @@ var NcStateSummaryPreviewSchema = object({
20876
20804
  text: string(),
20877
20805
  sections: array(NcStateSummaryPreviewSectionSchema),
20878
20806
  dropped: record(string(), number().int().nonnegative()),
20879
- excludedGroups: array(string())
20807
+ excludedGroups: array(string()),
20808
+ split: NcStateSummarySplitSchema.optional(),
20809
+ rows: array(NcStateSummaryPreviewRowSchema).optional()
20880
20810
  });
20881
20811
  var NcTestResultSchema = object({
20882
20812
  recordId: string(),
@@ -22622,12 +22552,26 @@ var CameraSensorRefSchema = object({
22622
22552
  function cameraSensorRefKey(ref) {
22623
22553
  return `${ref.addonId}/${ref.stableId}`;
22624
22554
  }
22625
- /** CS-1 accepts exactly one mode; CS-2 (D673) widens it to confirm / replace. */
22626
- var CameraSensorsModeSchema = _enum(["in-addition"]);
22627
- var CameraSensorsConfigSchema = object({
22628
- mode: CameraSensorsModeSchema,
22629
- sensors: array(CameraSensorRefSchema).min(1).max(8)
22630
- }).superRefine((value, ctx) => {
22555
+ /**
22556
+ * A sensor's mode (D673). `in-addition`: its motion is the camera's motion too.
22557
+ * `replace`: its motion is the camera's, and while one is READY the camera's
22558
+ * own motion no longer counts on its own. `confirm`: while one is READY the
22559
+ * camera's own motion counts only while a confirm sensor is active — with or
22560
+ * without a replace sensor (spec C2, the controller's ruling on Q1).
22561
+ */
22562
+ var CameraSensorModeSchema = _enum([
22563
+ "in-addition",
22564
+ "confirm",
22565
+ "replace"
22566
+ ]);
22567
+ /** A stored sensor with no mode — every CS-1 row — is in addition. */
22568
+ var DEFAULT_CAMERA_SENSOR_MODE = "in-addition";
22569
+ /**
22570
+ * A camera's attached sensors. A CS-1 row carried an envelope
22571
+ * `mode: 'in-addition'`: `z.object` drops it on parse, and the PARSED value is
22572
+ * what the write stores (D672 rule 3), so it is never written again.
22573
+ */
22574
+ var CameraSensorsConfigSchema = object({ sensors: array(CameraSensorRefSchema.extend({ mode: CameraSensorModeSchema.default(DEFAULT_CAMERA_SENSOR_MODE) })).min(1).max(8) }).superRefine((value, ctx) => {
22631
22575
  const seen = /* @__PURE__ */ new Set();
22632
22576
  value.sensors.forEach((ref, index) => {
22633
22577
  const key = cameraSensorRefKey(ref);
@@ -22639,39 +22583,41 @@ var CameraSensorsConfigSchema = object({
22639
22583
  seen.add(key);
22640
22584
  });
22641
22585
  });
22642
- var RefFields = {
22586
+ /** Every attachment names its mode; an older orchestrator that does not is in addition. */
22587
+ var AttachmentFields = {
22643
22588
  addonId: string(),
22644
- stableId: string()
22589
+ stableId: string(),
22590
+ mode: CameraSensorModeSchema.default(DEFAULT_CAMERA_SENSOR_MODE)
22645
22591
  };
22646
22592
  var CameraSensorAttachmentSchema = discriminatedUnion("state", [
22647
22593
  object({
22648
- ...RefFields,
22594
+ ...AttachmentFields,
22649
22595
  state: literal("ready"),
22650
22596
  deviceId: number(),
22651
22597
  name: string(),
22652
22598
  caps: array(string()).readonly()
22653
22599
  }),
22654
22600
  object({
22655
- ...RefFields,
22601
+ ...AttachmentFields,
22656
22602
  state: literal("offline"),
22657
22603
  deviceId: number(),
22658
22604
  name: string(),
22659
22605
  reason: _enum(["offline", "disabled"])
22660
22606
  }),
22661
22607
  object({
22662
- ...RefFields,
22608
+ ...AttachmentFields,
22663
22609
  state: literal("missing"),
22664
22610
  reason: string()
22665
22611
  }),
22666
22612
  object({
22667
- ...RefFields,
22613
+ ...AttachmentFields,
22668
22614
  state: literal("unsupported"),
22669
22615
  deviceId: number(),
22670
22616
  name: string(),
22671
22617
  reason: string()
22672
22618
  }),
22673
22619
  object({
22674
- ...RefFields,
22620
+ ...AttachmentFields,
22675
22621
  state: literal("unreadable"),
22676
22622
  reason: string()
22677
22623
  })
@@ -22684,17 +22630,49 @@ var CameraSensorAttachmentSchema = discriminatedUnion("state", [
22684
22630
  * say.
22685
22631
  */
22686
22632
  var CameraSensorsNotForwardedSchema = _enum(["onboard-not-listed", "no-active-detection"]);
22633
+ /** Whether the camera's OWN motion counts on its own (D673 C2), from its READY sensors (C3). */
22634
+ var CameraOwnMotionSchema = _enum([
22635
+ "always",
22636
+ "when-confirmed",
22637
+ "never"
22638
+ ]);
22639
+ /** Confirm / Replace cannot suppress this camera's motion: its provider still emits it directly (D673 C13). */
22640
+ var CameraSensorsNotEnforcedSchema = _enum(["provider-not-split"]);
22641
+ /**
22642
+ * The camera's OWN onboard motion (D696): the raw input the bridge combines,
22643
+ * never the effective value. The camera's `motion` slice is the effective one,
22644
+ * so a view of the camera's own row reads this.
22645
+ * - `atMs`: when the bridge received the camera's last own edge.
22646
+ * - `detected`: evaluated WHEN THE STATUS IS ASKED — the last edge said `true`
22647
+ * AND it is younger than the window the bridge counts the camera's own motion
22648
+ * for (`motionCooldownMs`, floored at two sustain ticks). A camera that never
22649
+ * sends a clear (heartbeats only) therefore reads `false` once no push came
22650
+ * within the window; a status read is a snapshot, so a live view re-asks.
22651
+ * Absent = this orchestrator has not received the camera's own motion since it
22652
+ * started (unknown, never "quiet"), or an orchestrator older than D696.
22653
+ */
22654
+ var CameraRawLevelSchema = object({
22655
+ detected: boolean(),
22656
+ atMs: number()
22657
+ });
22687
22658
  var CameraSensorsStatusSchema = discriminatedUnion("state", [
22688
- object({ state: literal("not-configured") }),
22659
+ object({
22660
+ state: literal("not-configured"),
22661
+ cameraLevel: CameraRawLevelSchema.optional()
22662
+ }),
22689
22663
  object({
22690
22664
  state: literal("unreadable"),
22691
- reason: string()
22665
+ reason: string(),
22666
+ cameraLevel: CameraRawLevelSchema.optional()
22692
22667
  }),
22693
22668
  object({
22694
22669
  state: literal("configured"),
22695
- mode: CameraSensorsModeSchema,
22670
+ cameraLevel: CameraRawLevelSchema.optional(),
22696
22671
  sensors: array(CameraSensorAttachmentSchema).readonly(),
22697
- notForwarded: CameraSensorsNotForwardedSchema.optional()
22672
+ /** Absent = an orchestrator older than CS-2: it does not say (D315). */
22673
+ cameraMotion: CameraOwnMotionSchema.optional(),
22674
+ notForwarded: CameraSensorsNotForwardedSchema.optional(),
22675
+ notEnforced: CameraSensorsNotEnforcedSchema.optional()
22698
22676
  })
22699
22677
  ]);
22700
22678
  Object.freeze({
@@ -26687,8 +26665,10 @@ var RunnerCameraConfigSchema = object({
26687
26665
  * - `analyzer`: ML/frame-diff motion detection (motion-wasm or other
26688
26666
  * analyzer providers) running on decoded frames in this runner.
26689
26667
  * - `onboard`: camera-native motion pushes (Reolink Baichuan, ONVIF
26690
- * analytics). The provider emits ProviderMotion
26691
- * events; the orchestrator forwards to `reportMotion`.
26668
+ * analytics). The provider emits its raw push as `ProviderMotion`
26669
+ * (D673); the orchestrator's camera-sensors bridge re-emits the camera's
26670
+ * effective motion as `MotionOnMotionChanged`, which is what reaches
26671
+ * `reportMotion`.
26692
26672
  */
26693
26673
  motionSources: MotionSourcesSchema.default(["analyzer"]),
26694
26674
  /**
@@ -26865,7 +26845,15 @@ var RunnerLocalLoadSchema = object({
26865
26845
  hasGpu: boolean(),
26866
26846
  inferenceBackend: string().optional(),
26867
26847
  cpuCores: number().optional()
26868
- })
26848
+ }),
26849
+ /**
26850
+ * Who writes a camera's `motion` runtime slice (D696). `'orchestrator'`: this
26851
+ * runner never writes it. ABSENT = a runner older than D696, which still
26852
+ * writes the slice from its phase machine; the orchestrator does not write
26853
+ * while any runner node is absent-or-unanswered, so one slice never has two
26854
+ * writers.
26855
+ */
26856
+ motionSliceWriter: literal("orchestrator").optional()
26869
26857
  });
26870
26858
  /**
26871
26859
  * Aggregate runtime metrics for the runner's whole local pool. Mirrors the
@@ -32470,6 +32458,70 @@ onStatusChanged: { data: object({
32470
32458
  * whether persisting is worth a SQLite commit. */
32471
32459
  volatileStateFields: ["lastChangedAt"]
32472
32460
  };
32461
+ var DoorbellStatusSchema = object({
32462
+ /** Ms epoch of the last press. null = never observed since this provider started. */
32463
+ lastPressedAt: number().nullable(),
32464
+ /** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
32465
+ pressCountSinceStart: number()
32466
+ });
32467
+ var DoorbellPressEventSchema = object({
32468
+ deviceId: number(),
32469
+ timestamp: number()
32470
+ });
32471
+ /**
32472
+ * Doorbell button cap. Two kinds of provider serve it, and to every consumer
32473
+ * they are the same cap:
32474
+ *
32475
+ * - **Native** providers, registered per device by a driver addon through
32476
+ * `ctx.registerNativeCap` — a `DeviceType.Button` accessory with
32477
+ * `role: DeviceRole.Doorbell`, or the camera itself (Reolink registers at
32478
+ * camera level). They emit `onPressed` on every firmware ring.
32479
+ * - **A composed doorbell** (D670, D671): a camera's customization gives it
32480
+ * the cap, its `lastPressedAt` rising from the sources the operator
32481
+ * assigned in Customize → Doorbell, and the composer emits `onPressed`
32482
+ * from that field's advance (`fromState`).
32483
+ *
32484
+ * The DeviceEventPropagator re-emits `onPressed` on the camera parent.
32485
+ */
32486
+ var doorbellCapability = {
32487
+ name: "doorbell",
32488
+ scope: "device",
32489
+ deviceNative: true,
32490
+ mode: "singleton",
32491
+ deviceTypes: [DeviceType.Button, DeviceType.Camera],
32492
+ methods: {},
32493
+ events: {
32494
+ /**
32495
+ * Fires once per physical press. Reolink delivers via Baichuan
32496
+ * push (`ReolinkSimpleEvent.type === 'doorbell'`). There is no
32497
+ * release/duration — it's a pulse.
32498
+ */
32499
+ onPressed: {
32500
+ data: DoorbellPressEventSchema,
32501
+ fromState: {
32502
+ field: "lastPressedAt",
32503
+ on: "advance"
32504
+ }
32505
+ } },
32506
+ status: {
32507
+ schema: DoorbellStatusSchema,
32508
+ kind: "push"
32509
+ },
32510
+ /**
32511
+ * Runtime-state slice — last press timestamp + lifetime press count.
32512
+ * Mirrored by the kernel and readable via
32513
+ * `device.state.doorbell.value`. UIs can show "last ring 5m ago"
32514
+ * without subscribing.
32515
+ */
32516
+ runtimeState: DoorbellStatusSchema,
32517
+ /**
32518
+ * Runtime-state durability: **restored** — a monotonic accumulator: the slice IS the record. `lastPressedAt` is content here, not a clock, so it is deliberately NOT volatile.
32519
+ *
32520
+ * See `RuntimeStateDurability`. Enforced by
32521
+ * `scripts/check-runtime-state-durability.ts`.
32522
+ */
32523
+ durability: "restored"
32524
+ };
32473
32525
  /**
32474
32526
  * Enum-state sensor — a string value picked from a finite option set.
32475
32527
  * Drives HA `sensor` entries with `state_class: enum` (HVAC action
@@ -34684,11 +34736,11 @@ authKey: string().optional() }), object({
34684
34736
  /**
34685
34737
  * How long after a camera's last rising edge `pipeline-analytics` closes the
34686
34738
  * motion EPISODE row it kept open for it (D475) — "il delay della cap", in
34687
- * the operator's words. One authority for the whole system: every provider
34688
- * that seeds `autoClearAfterMs` on a `Camera` device writes this SAME
34689
- * constant while `detected: true` (never its own number — Hikvision used to
34690
- * seed its internal 3 s inactivity timer here, which is a different clock for
34691
- * a different purpose), and `MotionEpisodeTracker` imports it directly rather
34739
+ * the operator's words. One authority for the whole system: the writer of a
34740
+ * `Camera` device's slice (the orchestrator, D696) writes this SAME constant
34741
+ * in `autoClearAfterMs` while `detected: true` (never a camera's own clock —
34742
+ * Hikvision used to seed its internal 3 s inactivity timer here, a different
34743
+ * clock for a different purpose), and `MotionEpisodeTracker` imports it directly rather
34692
34744
  * than reading the live cap value on the hot path. A `Sensor` device (HA
34693
34745
  * binary sensor, Homematic) gets a genuine push both ways and has no episode
34694
34746
  * to close on a timer, so it writes `null`, never this constant.
@@ -34699,9 +34751,9 @@ var MotionStatusSchema = object({
34699
34751
  /** Ms epoch of the last detected-true observation. Null if never detected. */
34700
34752
  lastDetectedAt: number().nullable(),
34701
34753
  /**
34702
- * `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
34703
- * `null` while false and on every `Sensor` device (D475) — see that
34704
- * constant's doc for the one-authority rule.
34754
+ * `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device (the
34755
+ * orchestrator writes it, D696), `null` while false and on every `Sensor`
34756
+ * device (D475) — see that constant's doc for the one-authority rule.
34705
34757
  *
34706
34758
  * ## Reading this field still arms nothing
34707
34759
  *
@@ -34719,34 +34771,31 @@ var MotionStatusSchema = object({
34719
34771
  * `addon-export-alexa/src/motion-clear-hold.ts` and
34720
34772
  * `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
34721
34773
  *
34722
- * ## Who writes it
34723
- *
34724
- * - **Cameras** — the runner's phase machine, `active → watching` on
34725
- * `cooldown_expired`, which then writes this slice with
34726
- * `detected: false` (`handlePhaseChanged` in
34727
- * `pipeline-runner/index.ts`). It produces the FALLING edge, which
34728
- * matters most for the sources that only ever push a rising one:
34729
- * Reolink emits `MotionOnMotionChanged { detected: true }` and never
34730
- * a false.
34731
- * - **Sensors** (Home Assistant binary sensors, Homematic) — the
34732
- * provider pushes the false itself, from the upstream system's own
34733
- * state change. No phase machine is involved.
34734
- *
34735
- * ### The phase machine is CANONICAL, not sole — and that is a defect
34736
- *
34737
- * An earlier revision of this docblock (mine, 2026-09-12) claimed the
34738
- * phase machine is the sole writer for a camera. It is not.
34739
- * `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
34740
- * `setCapSlice(motionCapability, …)` on their own rising edge, and
34741
- * Hikvision's comment says why: it read THIS docblock, agreed the
34742
- * runner is canonical, and wrote anyway to avoid per-tick churn. So
34743
- * two authorities can disagree about one slice, which this repo
34744
- * forbids, and the doc said otherwise — which is worse than saying
34745
- * nothing, because it reads as verification.
34746
- *
34747
- * This predates D475 and is not fixed there: the fix touches every
34748
- * camera provider. Recorded in D475's Consequences. Do not restore the
34749
- * "sole writer" wording without also removing the other writers.
34774
+ * ## Who writes it (D696)
34775
+ *
34776
+ * - **Cameras** — the orchestrator, and nothing else. It writes the camera's
34777
+ * EFFECTIVE motion (`addon-pipeline-orchestrator`
34778
+ * `camera-sensors/motion-slice.ts`), alongside the effective
34779
+ * `MotionOnMotionChanged` it emits or receives: the camera-sensors bridge
34780
+ * for a split camera, an unsplit emitter's direct event, the analyzer and
34781
+ * device activity, as the camera's `motionSources` counts them. A source
34782
+ * that never sends a clear falls one window after its last `true`.
34783
+ * `lastDetectedAt` moves only on an effective rise. No camera provider
34784
+ * writes this slice (not even a boot seed), and neither does the runner's
34785
+ * phase machine: its phase is "a session is attached" for every on-motion
34786
+ * session, not motion, and it now has its own `DetectionPhaseTransition`.
34787
+ * A provider's `isDetected` answers from the hub's slice.
34788
+ * - **Sensors** (Home Assistant binary sensors, Homematic, Matter, Alexa
34789
+ * imports) — the provider pushes both edges itself, from the upstream
34790
+ * system's own state change. That is the sensor's own fact.
34791
+ *
34792
+ * `scripts/check-onboard-motion-emitters.ts` refuses any other writer of a
34793
+ * `motion` slice; each sensor writer is a named exemption.
34794
+ *
34795
+ * This replaces the D475 §4 rule ("the phase machine is the sole writer").
34796
+ * That rule was never true: Hikvision and Amcrest wrote the slice raw beside
34797
+ * it, every provider seeded it at boot, and every session left it
34798
+ * `detected: true` after its detach.
34750
34799
  */
34751
34800
  autoClearAfterMs: number().nullable()
34752
34801
  });
@@ -34818,11 +34867,12 @@ onMotionChanged: { data: MotionOnMotionChangedDataSchema } },
34818
34867
  */
34819
34868
  runtimeState: MotionStatusSchema,
34820
34869
  /**
34821
- * Runtime-state durability: **session** — every writer of this slice
34870
+ * Runtime-state durability: **session** — the writer of this slice
34822
34871
  * writes only on an EDGE, so a restored `detected: true` would stay
34823
34872
  * frozen until the next one instead of being corrected. The next edge
34824
- * re-publishes the real state. (On who the writers are, and why there
34825
- * is more than one, see `autoClearAfterMs` above.)
34873
+ * re-publishes the real state, and the orchestrator re-publishes every
34874
+ * camera when it starts writing (D696; on who writes it, see
34875
+ * `autoClearAfterMs` above).
34826
34876
  *
34827
34877
  * See `RuntimeStateDurability`. Enforced by
34828
34878
  * `scripts/check-runtime-state-durability.ts`.
@@ -37239,8 +37289,7 @@ var ptzAutotrackCapability = {
37239
37289
  deviceNative: true,
37240
37290
  mode: "singleton",
37241
37291
  /**
37242
- * Two kinds of provider behind one name, the same shape `snapshot` and
37243
- * `doorbell` use:
37292
+ * Two kinds of provider behind one name, the same shape `snapshot` uses:
37244
37293
  *
37245
37294
  * - **Native**: the camera's own firmware autotrack, registered per device by
37246
37295
  * the driver when the probe says it exists (Reolink: yes; Hikvision:
@@ -37248,7 +37297,7 @@ var ptzAutotrackCapability = {
37248
37297
  * - **Wrapper**: the emulated implementation (`@camstack/system`'s `autotrack` builtin),
37249
37298
  * which follows a subject with `ptz.move` pulses driven by the detection
37250
37299
  * pipeline. `defaultActive: false` — the operator binds it per camera in
37251
- * the bindings UI, exactly as `virtual-doorbell` is bound.
37300
+ * the bindings UI.
37252
37301
  *
37253
37302
  * The binding chooses WHICH implementation answers; `setEnabled` stays the
37254
37303
  * one switch for the function either way. A camera never has both driving its
@@ -53869,6 +53918,18 @@ var STATE_SUMMARY_VARS = [
53869
53918
  systemEventKinds: [...SUMMARISABLE],
53870
53919
  systemEventDeliveries: ["summary"]
53871
53920
  },
53921
+ {
53922
+ name: "summarySection",
53923
+ label: "Summary: this section",
53924
+ description: "The section a per-section summary row is about (D698); on a summary sent as one message, every section it reports, comma-separated.",
53925
+ example: "Batterie scariche",
53926
+ group: "system",
53927
+ families: ["rule"],
53928
+ fields: [...RULE_TEXT],
53929
+ kinds: ["system"],
53930
+ systemEventKinds: [...SUMMARISABLE],
53931
+ systemEventDeliveries: ["summary"]
53932
+ },
53872
53933
  ...STATE_SUMMARY_SECTION_VARS.map((v) => ({
53873
53934
  name: v.name,
53874
53935
  label: v.label,
@@ -54709,6 +54770,15 @@ function systemEventSummaryScheduleOf(rule) {
54709
54770
  const delivery = rule.systemEventDelivery;
54710
54771
  return delivery?.mode === "summary" ? delivery.schedule : null;
54711
54772
  }
54773
+ /**
54774
+ * How a summary rule's window is sent (D698): `section` = one notification per
54775
+ * section; absent (every rule before D698) and any non-summary rule = `rule`.
54776
+ * The ONE reader — the scheduler, the rule test, the preview and both editors.
54777
+ */
54778
+ function systemEventSummarySplitOf(rule) {
54779
+ const delivery = rule.systemEventDelivery;
54780
+ return delivery?.mode === "summary" ? delivery.split ?? "rule" : "rule";
54781
+ }
54712
54782
  /** Absent and `instant` are the same answer: a notification per event. */
54713
54783
  function isSystemEventSummaryRule(rule) {
54714
54784
  return systemEventSummaryScheduleOf(rule) !== null;
@@ -55102,6 +55172,7 @@ function readTimelapseGeneratedAt(rule, deviceId) {
55102
55172
  if (map !== void 0) return map[String(deviceId)] ?? 0;
55103
55173
  return rule.lastGeneratedAt ?? 0;
55104
55174
  }
55175
+ MotionOnMotionChangedDataSchema.omit({ triggeredBy: true });
55105
55176
  object({
55106
55177
  /**
55107
55178
  * Fraction of the box's own size added on EACH side before cutting.
@@ -57293,6 +57364,12 @@ Object.defineProperty(exports, "systemEventSummaryScheduleOf", {
57293
57364
  return systemEventSummaryScheduleOf;
57294
57365
  }
57295
57366
  });
57367
+ Object.defineProperty(exports, "systemEventSummarySplitOf", {
57368
+ enumerable: true,
57369
+ get: function() {
57370
+ return systemEventSummarySplitOf;
57371
+ }
57372
+ });
57296
57373
  Object.defineProperty(exports, "templateCarriesSummary", {
57297
57374
  enumerable: true,
57298
57375
  get: function() {