@camstack/addon-provider-hikvision 1.2.134 → 1.2.136

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 +609 -396
  2. package/dist/addon.mjs +609 -396
  3. package/package.json +2 -2
package/dist/addon.js CHANGED
@@ -33,7 +33,7 @@ let node_net = require("node:net");
33
33
  let node_http = require("node:http");
34
34
  let node_https = require("node:https");
35
35
  let node_os = require("node:os");
36
- //#region ../types/dist/event-category-C5xZWqz6.mjs
36
+ //#region ../types/dist/event-category-BGmz_oxW.mjs
37
37
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
38
38
  EventCategory["SystemBoot"] = "system.boot";
39
39
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -566,6 +566,15 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
566
566
  */
567
567
  EventCategory["PipelineAudioInferenceResult"] = "pipeline.audio-inference-result";
568
568
  EventCategory["DetectionPhaseTransition"] = "detection.phase-transition";
569
+ /**
570
+ * A camera provider's RAW onboard motion push (D673): the `MotionOnMotionChanged`
571
+ * data shape without `triggeredBy`, built by `providerMotionEvent`. Its one
572
+ * consumer is the orchestrator's camera-sensors bridge, which re-emits the
573
+ * camera's EFFECTIVE onboard motion as `MotionOnMotionChanged` (a pass-through
574
+ * for a camera with no attached sensor). Providers must not emit
575
+ * `MotionOnMotionChanged` themselves; `scripts/check-onboard-motion-emitters.ts`
576
+ * keeps it so (camera-grid is a named, deferred exception).
577
+ */
569
578
  EventCategory["ProviderMotion"] = "provider.motion";
570
579
  EventCategory["ProviderDetection"] = "provider.detection";
571
580
  EventCategory["EnrichmentEmbeddingStored"] = "enrichment.embedding.stored";
@@ -5404,7 +5413,7 @@ var ZodIssueCode = {
5404
5413
  var ZodFirstPartyTypeKind;
5405
5414
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5406
5415
  //#endregion
5407
- //#region ../types/dist/sleep-gU6hqv4_.mjs
5416
+ //#region ../types/dist/sleep-CDCONfkt.mjs
5408
5417
  /**
5409
5418
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5410
5419
  * window to float samples (D455).
@@ -7449,7 +7458,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
7449
7458
  return DeviceRole;
7450
7459
  }({});
7451
7460
  //#endregion
7452
- //#region ../types/dist/composition-Dq42XWp0.mjs
7461
+ //#region ../types/dist/composition-43aqsZQj.mjs
7453
7462
  /**
7454
7463
  * The ffmpeg build every CamStack node downloads, per platform and arch.
7455
7464
  *
@@ -7506,13 +7515,12 @@ portable("linux64"), portable("linuxarm64"), portable("macarm64"), portable("mac
7506
7515
  * LA tabella "quale booleano di questo tipo di device conta come ALTO", e il
7507
7516
  * valutatore puro del suo FRONTE.
7508
7517
  *
7509
- * Viveva dentro il builtin virtual-doorbell
7510
- * (`@camstack/system` — `builtins/doorbell/trigger-engine.ts`) e i suoi
7511
- * predicati erano privati al modulo. Il recorder ne ha bisogno per il trigger
7512
- * `RecordingTriggers.sensorDeviceIds`: copiarla avrebbe creato la SECONDA
7513
- * tabella, che diverge alla prima cap aggiunta e il cui sintomo — "il sensore
7514
- * fa suonare il campanello ma non registra" — è esattamente D62. Quindi si
7515
- * SPOSTA qui e il doorbell la ri-esporta.
7518
+ * UNA tabella per tutti quelli che chiedono "questo device è ALTO?": il
7519
+ * trigger `RecordingTriggers.sensorDeviceIds` del recorder, i marker dei
7520
+ * sensori della post-analysis, il bridge camera-sensors dell'orchestratore e
7521
+ * le sorgenti di un campanello composto (`doorbellFeatureSources`, D671).
7522
+ * Una seconda copia divergerebbe alla prima cap aggiunta, e il sintomo — "il
7523
+ * sensore fa suonare il campanello ma non registra" — è esattamente D62.
7516
7524
  *
7517
7525
  * ⚠ NON è `DEVICE_STATE_READERS` (`catalogs/device-state-vocabulary.ts`), e le
7518
7526
  * due non vanno unificate: quella risponde a "qual è la PAROLA di stato per una
@@ -7538,8 +7546,6 @@ var SOURCE_CAP_ACTIVE_FIELD = {
7538
7546
  vibration: "detected",
7539
7547
  tamper: "tampered"
7540
7548
  };
7541
- /** Cap names whose presence in a device's bindings qualify it as a source. */
7542
- var SOURCE_CAPS = Object.keys(SOURCE_CAP_ACTIVE_FIELD);
7543
7549
  /**
7544
7550
  * Error types for the safe expression engine. Two distinct classes so callers
7545
7551
  * can tell a compile-time (grammar) failure from a runtime (evaluation)
@@ -9269,7 +9275,7 @@ var RecordingTriggersSchema = object({
9269
9275
  *
9270
9276
  * Cosa vuol dire "alto" dipende dal TIPO di device e non è deciso qui:
9271
9277
  * `SOURCE_CAP_ACTIVE_FIELD` (`catalogs/sensor-active-state.ts`) è LA tabella,
9272
- * la stessa che il virtual-doorbell usa dal 2026-08-05. Ed è il FRONTE, non
9278
+ * la stessa del campanello composto (D671). Ed è il FRONTE, non
9273
9279
  * il livello: un contatto trovato già aperto al riavvio del runner non fa
9274
9280
  * registrare.
9275
9281
  */
@@ -11905,6 +11911,68 @@ method(object({
11905
11911
  password: string()
11906
11912
  }), AuthResultSchema.nullable(), { kind: "mutation" }), method(object({ state: string() }), string()), method(record(string(), string()), AuthResultSchema, { kind: "mutation" }), method(object({ token: string() }), AuthResultSchema.nullable());
11907
11913
  /**
11914
+ * How long one snapshot may take end to end: the pinned copy of the whole
11915
+ * database plus `PRAGMA integrity_check` over the copy, on the hub's slowest
11916
+ * disk. ~800 MB at a pessimistic 10 MB/s is under 3 minutes; the bound is
11917
+ * generous because a timeout fails the whole backup run.
11918
+ */
11919
+ var DATABASE_SNAPSHOT_TIMEOUT_MS = 30 * 6e4;
11920
+ /**
11921
+ * The databases an owner snapshots — declared by the OWNER, so a caller never
11922
+ * guesses which file is live from what sits beside it (a cleanly closed
11923
+ * database has no sidecars and is just as owned). Paths are absolute on the
11924
+ * owner's host.
11925
+ */
11926
+ var DatabaseSnapshotTargetsSchema = object({ databases: array(object({ livePath: string() })) });
11927
+ /** One b-tree table of the snapshot and the rows it holds. */
11928
+ var DatabaseSnapshotTableSchema = object({
11929
+ name: string(),
11930
+ rows: number().int().nonnegative()
11931
+ });
11932
+ /**
11933
+ * What the owner wrote. Every path is ABSOLUTE on the owner's host — the
11934
+ * caller pins the call to its own node, so it can read the file; a caller
11935
+ * that finds the path outside its own data root refuses it rather than
11936
+ * archiving something it cannot place.
11937
+ */
11938
+ var DatabaseSnapshotResultSchema = object({
11939
+ /** The live database the snapshot copies. Never to be copied as a file. */
11940
+ livePath: string(),
11941
+ /** The verified copy: `<livePath>` + {@link DATABASE_SNAPSHOT_SUFFIX}. */
11942
+ snapshotPath: string(),
11943
+ sizeBytes: number().int().nonnegative(),
11944
+ pageCount: number().int().nonnegative(),
11945
+ pageSize: number().int().positive(),
11946
+ /**
11947
+ * Every b-tree table with its row count. Read inside the SAME read
11948
+ * transaction the copy was taken from, and found EQUAL on the copy — so
11949
+ * this is the content of the snapshot, not an estimate of the source.
11950
+ */
11951
+ tables: array(DatabaseSnapshotTableSchema),
11952
+ /** Wall time of the pinned copy (row counts included). */
11953
+ copyMs: number().nonnegative(),
11954
+ /** Wall time of the checks on the copy (`integrity_check`, row counts). */
11955
+ verifyMs: number().nonnegative(),
11956
+ /** When the pinned read transaction began (ms epoch) — the snapshot's instant. */
11957
+ takenAt: number()
11958
+ });
11959
+ /**
11960
+ * A snapshot as an ARCHIVE records it (`ArchiveManifest.sqliteSnapshots`):
11961
+ * the same facts, with both paths relative to the archive root (the node's
11962
+ * data dir), because an archive outlives the host that made it.
11963
+ */
11964
+ var ArchiveSqliteSnapshotSchema = DatabaseSnapshotResultSchema.extend({
11965
+ /** Archive-relative path of the live database the archive does NOT carry. */
11966
+ livePath: string(),
11967
+ /** Archive-relative path of the verified copy it carries in its place. */
11968
+ snapshotPath: string()
11969
+ });
11970
+ method(object({}), DatabaseSnapshotTargetsSchema, { auth: "admin" }), method(object({}), DatabaseSnapshotResultSchema, {
11971
+ kind: "mutation",
11972
+ auth: "admin",
11973
+ timeoutMs: DATABASE_SNAPSHOT_TIMEOUT_MS
11974
+ });
11975
+ /**
11908
11976
  * Orchestrator-side destination metadata. The orchestrator computes
11909
11977
  * `id = <addonId>:<subId>` from its provider lookup so consumers
11910
11978
  * (admin UI, restore flow) see one canonical key.
@@ -12015,7 +12083,12 @@ var ArchiveManifestSchema = object({
12015
12083
  locations: array(string()),
12016
12084
  entries: array(ArchiveEntrySchema),
12017
12085
  totalBytes: number(),
12018
- totalFiles: number()
12086
+ totalFiles: number(),
12087
+ /**
12088
+ * Live SQLite databases this archive carries as their OWNER's verified
12089
+ * snapshot instead of as files (D693). Absent on archives made before.
12090
+ */
12091
+ sqliteSnapshots: array(ArchiveSqliteSnapshotSchema).optional()
12019
12092
  });
12020
12093
  var LocationStatSchema = object({
12021
12094
  name: string(),
@@ -13541,6 +13614,52 @@ var CompositionBlockStateSchema = object({
13541
13614
  reason: string().optional(),
13542
13615
  fields: array(CompositionFieldStateSchema)
13543
13616
  });
13617
+ var ComposerBlockSchema = object({
13618
+ id: string().min(1),
13619
+ name: string().min(1).max(120),
13620
+ enabled: boolean(),
13621
+ updatedAt: number(),
13622
+ composition: CompositionSchema
13623
+ });
13624
+ /**
13625
+ * A stored composition row that no longer PARSES — a schema a release
13626
+ * tightened, a row written by a newer build. Sent by id so the composer keeps
13627
+ * its device as a placeholder and reports the block `failed` naming the parse
13628
+ * error. Leaving it out would read, twice, exactly like a delete (D49).
13629
+ */
13630
+ var ComposerUnreadableBlockSchema = object({
13631
+ id: string().min(1),
13632
+ /** The row's stored name column; null when even that is unreadable (the device keeps the name it has). */
13633
+ name: string().nullable(),
13634
+ /** The parse error, in the operator's words. */
13635
+ error: string()
13636
+ });
13637
+ method(object({
13638
+ /** The shared Blocks integration; null until `core-blocks` has reconciled it. */
13639
+ integrationId: string().nullable(),
13640
+ /** False when the `core_blocks` read failed: then nothing may be withdrawn (D49). */
13641
+ storeLoaded: boolean(),
13642
+ blocks: array(ComposerBlockSchema),
13643
+ /** Operator restarts: rebuild these runtimes and re-resolve their sources. Stores nothing (D62). */
13644
+ restartBlockIds: array(string()),
13645
+ /** Composition rows that exist but do not parse: held, never withdrawn, reported failed. */
13646
+ unreadableBlocks: array(ComposerUnreadableBlockSchema)
13647
+ }), object({
13648
+ blocks: array(object({
13649
+ blockId: string(),
13650
+ status: CompositionRunStatusSchema,
13651
+ reason: string().optional()
13652
+ })),
13653
+ /**
13654
+ * False when the composer declared and withdrew NOTHING (store not loaded,
13655
+ * integration unknown, its own rows unread or read empty once). An empty
13656
+ * apply the caller owes is paid off only by one the composer acted on (D49).
13657
+ */
13658
+ acted: boolean()
13659
+ }), {
13660
+ kind: "mutation",
13661
+ auth: "admin"
13662
+ }), method(object({ blockIds: array(string()) }), object({ states: array(CompositionBlockStateSchema) }), { auth: "admin" });
13544
13663
  var NUMBER = {
13545
13664
  kind: "fixed",
13546
13665
  result: ["number"]
@@ -13777,52 +13896,6 @@ method(object({}), object({ blocks: array(CoreBlockSchema) }), { auth: "admin" }
13777
13896
  auth: "admin",
13778
13897
  access: "view"
13779
13898
  });
13780
- var ComposerBlockSchema = object({
13781
- id: string().min(1),
13782
- name: string().min(1).max(120),
13783
- enabled: boolean(),
13784
- updatedAt: number(),
13785
- composition: CompositionSchema
13786
- });
13787
- /**
13788
- * A stored composition row that no longer PARSES — a schema a release
13789
- * tightened, a row written by a newer build. Sent by id so the composer keeps
13790
- * its device as a placeholder and reports the block `failed` naming the parse
13791
- * error. Leaving it out would read, twice, exactly like a delete (D49).
13792
- */
13793
- var ComposerUnreadableBlockSchema = object({
13794
- id: string().min(1),
13795
- /** The row's stored name column; null when even that is unreadable (the device keeps the name it has). */
13796
- name: string().nullable(),
13797
- /** The parse error, in the operator's words. */
13798
- error: string()
13799
- });
13800
- method(object({
13801
- /** The shared Blocks integration; null until `core-blocks` has reconciled it. */
13802
- integrationId: string().nullable(),
13803
- /** False when the `core_blocks` read failed: then nothing may be withdrawn (D49). */
13804
- storeLoaded: boolean(),
13805
- blocks: array(ComposerBlockSchema),
13806
- /** Operator restarts: rebuild these runtimes and re-resolve their sources. Stores nothing (D62). */
13807
- restartBlockIds: array(string()),
13808
- /** Composition rows that exist but do not parse: held, never withdrawn, reported failed. */
13809
- unreadableBlocks: array(ComposerUnreadableBlockSchema)
13810
- }), object({
13811
- blocks: array(object({
13812
- blockId: string(),
13813
- status: CompositionRunStatusSchema,
13814
- reason: string().optional()
13815
- })),
13816
- /**
13817
- * False when the composer declared and withdrew NOTHING (store not loaded,
13818
- * integration unknown, its own rows unread or read empty once). An empty
13819
- * apply the caller owes is paid off only by one the composer acted on (D49).
13820
- */
13821
- acted: boolean()
13822
- }), {
13823
- kind: "mutation",
13824
- auth: "admin"
13825
- }), method(object({ blockIds: array(string()) }), object({ states: array(CompositionBlockStateSchema) }), { auth: "admin" });
13826
13899
  /**
13827
13900
  * `custom-model-registry` — collection cap exposing operator-registered
13828
13901
  * custom detection models. Each provider (today: `addon-model-studio`)
@@ -15972,6 +16045,121 @@ method(object({
15972
16045
  deviceIds: array(number()).readonly(),
15973
16046
  caps: array(string()).readonly().optional()
15974
16047
  }), record(string(), record(string(), unknown().nullable())));
16048
+ var ExtensionSlotIdSchema = _enum(["linked-devices"]);
16049
+ DeviceType.Camera;
16050
+ /** A slot's editable value, discriminated on `slot`. */
16051
+ var ExtensionSlotValueSchema = discriminatedUnion("slot", [LinkedDevicesSlotValueSchema.extend({ slot: literal("linked-devices") })]);
16052
+ DeviceType.Camera;
16053
+ var ExtensionSourceAvailabilitySchema = discriminatedUnion("state", [object({ state: literal("ok") }), object({
16054
+ state: literal("unreachable"),
16055
+ reason: string()
16056
+ })]);
16057
+ /** One provider of slots — the D554 source-listing row. */
16058
+ var ExtensionSourceSchema = object({
16059
+ /** The routing prefix of every `slotRef` this provider serves. */
16060
+ source: string(),
16061
+ label: string(),
16062
+ /** Stamped by the dispatcher from the registry (D557). */
16063
+ addonId: string().optional(),
16064
+ availability: ExtensionSourceAvailabilitySchema
16065
+ });
16066
+ /**
16067
+ * How one picked source stands. `missing` — no such device (deleted, or an id
16068
+ * that never existed); `foreign` — a device the slot's owner cannot read from
16069
+ * (a source owned by another addon); `unavailable` — it exists but is not a
16070
+ * valid source now (a container, which is never a pick). A source in any of
16071
+ * these states is SHOWN, never silently dropped or re-pointed.
16072
+ */
16073
+ var ExtensionSourceHealthSchema = _enum([
16074
+ "ok",
16075
+ "missing",
16076
+ "foreign",
16077
+ "unavailable"
16078
+ ]);
16079
+ var ExtensionSlotSourceSchema = object({
16080
+ deviceId: number().int(),
16081
+ /** The device's name, or null when it could not be resolved (`missing`). */
16082
+ name: string().nullable(),
16083
+ health: ExtensionSourceHealthSchema,
16084
+ detail: string().optional()
16085
+ });
16086
+ /**
16087
+ * A DIFFERENT authority that gates whether the slot's sources do anything —
16088
+ * reported read-only, named, never written through this contract (D62) — e.g.
16089
+ * a slot whose sources act only while a wrapper is bound to the host, a
16090
+ * binding that belongs to `deviceManager.setWrapperActive`. No slot reports
16091
+ * one today (`linked-devices` answers `null`). `unknown` means the gate could
16092
+ * not be read; it is not "inactive" (D315).
16093
+ */
16094
+ var ExtensionSlotActivationSchema = object({
16095
+ state: _enum([
16096
+ "active",
16097
+ "inactive",
16098
+ "unknown"
16099
+ ]),
16100
+ authority: string(),
16101
+ detail: string().optional()
16102
+ });
16103
+ var ExtensionSlotRowSchema = discriminatedUnion("state", [object({
16104
+ state: literal("ok"),
16105
+ /** `<source>:<slotId>` — the routing key for `listCandidates` / `setSlot`. */
16106
+ slotRef: string(),
16107
+ slot: ExtensionSlotIdSchema,
16108
+ /** Names the store written (D62), e.g. `device-manager:_linkedDeviceIds`. */
16109
+ authority: string(),
16110
+ activation: ExtensionSlotActivationSchema.nullable(),
16111
+ value: ExtensionSlotValueSchema,
16112
+ sources: array(ExtensionSlotSourceSchema),
16113
+ /**
16114
+ * Devices the owner links to the host ON ITS OWN, by structure, and that
16115
+ * are therefore not in `value` (D655): a camera's device-tree children, and
16116
+ * the child a picked container stands for (D356 — a container is never a
16117
+ * pick, its children are). Read-only; the editor shows them and may offer
16118
+ * per-device options on them (the linked-devices tracked-event opt-in).
16119
+ * Absent when the owner links nothing beyond the picks, and from an owner
16120
+ * older than D655.
16121
+ */
16122
+ impliedSources: array(ExtensionSlotSourceSchema).optional()
16123
+ }), object({
16124
+ state: literal("unreachable"),
16125
+ addonId: string(),
16126
+ reason: string()
16127
+ })]);
16128
+ var ExtensionCandidatesSchema = object({ candidates: array(object({
16129
+ deviceId: number().int(),
16130
+ name: string(),
16131
+ type: string(),
16132
+ location: string().nullable(),
16133
+ /** The container a child belongs to — "Spotlight 2" alone does not say which. */
16134
+ parentName: string().nullable(),
16135
+ /** Pre-marked by the owner's suggestion rule. NEVER saved on its own (D356). */
16136
+ suggested: boolean(),
16137
+ /** Why it is suggested ("same location"), null when it is not. */
16138
+ reason: string().nullable()
16139
+ })) });
16140
+ /**
16141
+ * What a write did. `none` — applied in place. `host` / `parent` — the owner
16142
+ * reloaded the host (or, for an accessory child, its parent) because the
16143
+ * write changed what the host REGISTERS. A slot never adds a capability to its
16144
+ * host — that is a composition (D663) — so today's owners answer `none`.
16145
+ */
16146
+ var ExtensionSetResultSchema = object({
16147
+ applied: literal(true),
16148
+ reload: _enum([
16149
+ "none",
16150
+ "host",
16151
+ "parent"
16152
+ ])
16153
+ });
16154
+ var ExtensionSlotRefInputSchema = object({
16155
+ deviceId: number().int(),
16156
+ slotRef: string().min(1)
16157
+ });
16158
+ var ExtensionSetSlotInputSchema = ExtensionSlotRefInputSchema.extend({ value: ExtensionSlotValueSchema });
16159
+ method(object({ deviceId: number().int() }), array(ExtensionSourceSchema)), method(object({ deviceId: number().int() }), array(ExtensionSlotRowSchema)), method(ExtensionSlotRefInputSchema, ExtensionCandidatesSchema), method(ExtensionSetSlotInputSchema, ExtensionSetResultSchema, {
16160
+ kind: "mutation",
16161
+ auth: "admin"
16162
+ });
15975
16163
  /**
15976
16164
  * Per-field ownership (D663). A composition may CLAIM fields of a native
15977
16165
  * cap's runtime-state slice on an existing device: `replace` overlays the
@@ -19001,17 +19189,25 @@ var NcScheduleSchema = object({
19001
19189
  */
19002
19190
  var NcSystemEventDeliveryModeSchema = _enum(["instant", "summary"]);
19003
19191
  /**
19192
+ * How a summary window is SENT (D698): `rule` (absent) = ONE notification with
19193
+ * every section; `section` = one notification per section with something to
19194
+ * say (an unavailable section included), each titled by its section.
19195
+ */
19196
+ var NcStateSummarySplitSchema = _enum(["rule", "section"]);
19197
+ /**
19004
19198
  * `summary`: the rule sends NOTHING per event. When a window of `schedule`
19005
19199
  * CLOSES, it sends one notification with the current state of its kinds
19006
19200
  * (low batteries, consumables to replace, devices offline, updates
19007
- * available, ...), after its own filters. Nothing to report sends nothing.
19201
+ * available, ...), after its own filters — or, with `split: 'section'`
19202
+ * (D698), one notification per section. Nothing to report sends nothing.
19008
19203
  * The schedule is the ordinary `NcSchedule` (weekly windows, IANA timezone,
19009
19204
  * midnight crossing); the send time is each window's END. Refused on the
19010
19205
  * `alarm` family, which stays instant (`systemEventDeliveryProblems`).
19011
19206
  */
19012
19207
  var NcSystemEventDeliverySchema = discriminatedUnion("mode", [object({ mode: literal("instant") }), object({
19013
19208
  mode: literal("summary"),
19014
- schedule: NcScheduleSchema
19209
+ schedule: NcScheduleSchema,
19210
+ split: NcStateSummarySplitSchema.optional()
19015
19211
  })]);
19016
19212
  /** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
19017
19213
  var NcPlateMatcherSchema = object({
@@ -19151,8 +19347,14 @@ var NcSensorTransitionSchema = _enum(["raised", "cleared"]);
19151
19347
  /** Admin-zone membership condition (zone IDs as stamped by the ZoneEngine). */
19152
19348
  var NcZoneConditionSchema = object({
19153
19349
  ids: array(string().min(1)).min(1),
19154
- /** Quantifier over `ids` — at least one / every one visited. */
19155
- match: _enum(["any", "all"]).default("any")
19350
+ /**
19351
+ * LEGACY quantifier over `ids`. Absent = `any` (at least one visited), which
19352
+ * is what both editors mean and all they write since D690: "all of" was
19353
+ * removed from the editors because on an immediate rule it asked one
19354
+ * detection to stand in every zone at once. Still ACCEPTED, and `all` still
19355
+ * evaluated, so a stored rule keeps parsing and meaning what it meant.
19356
+ */
19357
+ match: _enum(["any", "all"]).optional()
19156
19358
  });
19157
19359
  /**
19158
19360
  * The P1 condition set — a flat AND of groups; absent group = pass;
@@ -19656,10 +19858,12 @@ var NcMediaPolicySchema = object({
19656
19858
  /**
19657
19859
  * Cooldown GRANULARITY over the subject's class — how much a fired
19658
19860
  * notification suppresses.
19659
- * - `shared` (default, and the absent value) — one window for the whole
19660
- * rule/scope: a cat silences the next dog for `cooldownSec`.
19661
- * - `per-class` — an independent window per detected class, so cat→dog fires
19662
- * at once and cat→cat still waits.
19861
+ * - `per-class` (default, and the absent value since 2026-10-01 — D36) — an
19862
+ * independent window per detected class: cat→dog fires at once, cat→cat
19863
+ * still waits.
19864
+ * - `shared` — one window for the whole rule/scope: a cat silences the next
19865
+ * dog for `cooldownSec`. Only written when an operator picks it; it is no
19866
+ * longer what an unset rule means.
19663
19867
  *
19664
19868
  * AUDIO subjects are ALWAYS per-class regardless of this setting: a scream
19665
19869
  * must not be swallowed by a bark's window (the precedent this generalizes —
@@ -19674,8 +19878,11 @@ var NcThrottleSchema = object({
19674
19878
  /**
19675
19879
  * Class granularity of the cooldown key. Optional rather than defaulted:
19676
19880
  * a Zod default does NOT run on the addon→addon cap path, so a persisted
19677
- * rule authored before this field simply carries none — and the engine
19678
- * reads absent as `shared`, the pre-existing behaviour.
19881
+ * rule authored before this field simply carries none. The engine used to
19882
+ * read absent as `shared` (D36); since 2026-10-01 it reads absent as
19883
+ * `per-class` — the operator's default — and only an explicit `shared`
19884
+ * still means `shared`. See `cooldownKey` / `keysPerClass` in the rule
19885
+ * engine, and D36's dated note.
19679
19886
  */
19680
19887
  granularity: NcThrottleGranularitySchema.optional()
19681
19888
  });
@@ -19999,11 +20206,23 @@ var NcStateSummaryPreviewSectionSchema = object({
19999
20206
  reason: string().optional()
20000
20207
  });
20001
20208
  /**
20209
+ * One notification a previewed summary would send (D698): the whole summary on
20210
+ * a `rule` split (no `section`), one section's on a `section` split.
20211
+ */
20212
+ var NcStateSummaryPreviewRowSchema = object({
20213
+ section: string().optional(),
20214
+ /** The section's name on a per-section row; every reported section's, joined, on a combined one. */
20215
+ title: string(),
20216
+ text: string(),
20217
+ count: number().int().nonnegative()
20218
+ });
20219
+ /**
20002
20220
  * The summary a rule would send now. `empty` = nothing to report and every
20003
20221
  * section read: such a summary is NOT sent. `dropped` counts the open states
20004
20222
  * the rule's own filters (or a camera mute) left out, by reason.
20005
20223
  * `excludedGroups` names the kind groups selected that have no state to report
20006
- * (backups & exports).
20224
+ * (backups & exports). `split` and `rows` (D698) say how it would be sent —
20225
+ * optional, so an older hub's answer still parses.
20007
20226
  */
20008
20227
  var NcStateSummaryPreviewSchema = object({
20009
20228
  empty: boolean(),
@@ -20011,7 +20230,9 @@ var NcStateSummaryPreviewSchema = object({
20011
20230
  text: string(),
20012
20231
  sections: array(NcStateSummaryPreviewSectionSchema),
20013
20232
  dropped: record(string(), number().int().nonnegative()),
20014
- excludedGroups: array(string())
20233
+ excludedGroups: array(string()),
20234
+ split: NcStateSummarySplitSchema.optional(),
20235
+ rows: array(NcStateSummaryPreviewRowSchema).optional()
20015
20236
  });
20016
20237
  var NcTestResultSchema = object({
20017
20238
  recordId: string(),
@@ -21025,12 +21246,26 @@ var CameraSensorRefSchema = object({
21025
21246
  function cameraSensorRefKey(ref) {
21026
21247
  return `${ref.addonId}/${ref.stableId}`;
21027
21248
  }
21028
- /** CS-1 accepts exactly one mode; CS-2 (D673) widens it to confirm / replace. */
21029
- var CameraSensorsModeSchema = _enum(["in-addition"]);
21030
- var CameraSensorsConfigSchema = object({
21031
- mode: CameraSensorsModeSchema,
21032
- sensors: array(CameraSensorRefSchema).min(1).max(8)
21033
- }).superRefine((value, ctx) => {
21249
+ /**
21250
+ * A sensor's mode (D673). `in-addition`: its motion is the camera's motion too.
21251
+ * `replace`: its motion is the camera's, and while one is READY the camera's
21252
+ * own motion no longer counts on its own. `confirm`: while one is READY the
21253
+ * camera's own motion counts only while a confirm sensor is active — with or
21254
+ * without a replace sensor (spec C2, the controller's ruling on Q1).
21255
+ */
21256
+ var CameraSensorModeSchema = _enum([
21257
+ "in-addition",
21258
+ "confirm",
21259
+ "replace"
21260
+ ]);
21261
+ /** A stored sensor with no mode — every CS-1 row — is in addition. */
21262
+ var DEFAULT_CAMERA_SENSOR_MODE = "in-addition";
21263
+ /**
21264
+ * A camera's attached sensors. A CS-1 row carried an envelope
21265
+ * `mode: 'in-addition'`: `z.object` drops it on parse, and the PARSED value is
21266
+ * what the write stores (D672 rule 3), so it is never written again.
21267
+ */
21268
+ var CameraSensorsConfigSchema = object({ sensors: array(CameraSensorRefSchema.extend({ mode: CameraSensorModeSchema.default(DEFAULT_CAMERA_SENSOR_MODE) })).min(1).max(8) }).superRefine((value, ctx) => {
21034
21269
  const seen = /* @__PURE__ */ new Set();
21035
21270
  value.sensors.forEach((ref, index) => {
21036
21271
  const key = cameraSensorRefKey(ref);
@@ -21042,39 +21277,41 @@ var CameraSensorsConfigSchema = object({
21042
21277
  seen.add(key);
21043
21278
  });
21044
21279
  });
21045
- var RefFields = {
21280
+ /** Every attachment names its mode; an older orchestrator that does not is in addition. */
21281
+ var AttachmentFields = {
21046
21282
  addonId: string(),
21047
- stableId: string()
21283
+ stableId: string(),
21284
+ mode: CameraSensorModeSchema.default(DEFAULT_CAMERA_SENSOR_MODE)
21048
21285
  };
21049
21286
  var CameraSensorAttachmentSchema = discriminatedUnion("state", [
21050
21287
  object({
21051
- ...RefFields,
21288
+ ...AttachmentFields,
21052
21289
  state: literal("ready"),
21053
21290
  deviceId: number(),
21054
21291
  name: string(),
21055
21292
  caps: array(string()).readonly()
21056
21293
  }),
21057
21294
  object({
21058
- ...RefFields,
21295
+ ...AttachmentFields,
21059
21296
  state: literal("offline"),
21060
21297
  deviceId: number(),
21061
21298
  name: string(),
21062
21299
  reason: _enum(["offline", "disabled"])
21063
21300
  }),
21064
21301
  object({
21065
- ...RefFields,
21302
+ ...AttachmentFields,
21066
21303
  state: literal("missing"),
21067
21304
  reason: string()
21068
21305
  }),
21069
21306
  object({
21070
- ...RefFields,
21307
+ ...AttachmentFields,
21071
21308
  state: literal("unsupported"),
21072
21309
  deviceId: number(),
21073
21310
  name: string(),
21074
21311
  reason: string()
21075
21312
  }),
21076
21313
  object({
21077
- ...RefFields,
21314
+ ...AttachmentFields,
21078
21315
  state: literal("unreadable"),
21079
21316
  reason: string()
21080
21317
  })
@@ -21087,17 +21324,49 @@ var CameraSensorAttachmentSchema = discriminatedUnion("state", [
21087
21324
  * say.
21088
21325
  */
21089
21326
  var CameraSensorsNotForwardedSchema = _enum(["onboard-not-listed", "no-active-detection"]);
21327
+ /** Whether the camera's OWN motion counts on its own (D673 C2), from its READY sensors (C3). */
21328
+ var CameraOwnMotionSchema = _enum([
21329
+ "always",
21330
+ "when-confirmed",
21331
+ "never"
21332
+ ]);
21333
+ /** Confirm / Replace cannot suppress this camera's motion: its provider still emits it directly (D673 C13). */
21334
+ var CameraSensorsNotEnforcedSchema = _enum(["provider-not-split"]);
21335
+ /**
21336
+ * The camera's OWN onboard motion (D696): the raw input the bridge combines,
21337
+ * never the effective value. The camera's `motion` slice is the effective one,
21338
+ * so a view of the camera's own row reads this.
21339
+ * - `atMs`: when the bridge received the camera's last own edge.
21340
+ * - `detected`: evaluated WHEN THE STATUS IS ASKED — the last edge said `true`
21341
+ * AND it is younger than the window the bridge counts the camera's own motion
21342
+ * for (`motionCooldownMs`, floored at two sustain ticks). A camera that never
21343
+ * sends a clear (heartbeats only) therefore reads `false` once no push came
21344
+ * within the window; a status read is a snapshot, so a live view re-asks.
21345
+ * Absent = this orchestrator has not received the camera's own motion since it
21346
+ * started (unknown, never "quiet"), or an orchestrator older than D696.
21347
+ */
21348
+ var CameraRawLevelSchema = object({
21349
+ detected: boolean(),
21350
+ atMs: number()
21351
+ });
21090
21352
  var CameraSensorsStatusSchema = discriminatedUnion("state", [
21091
- object({ state: literal("not-configured") }),
21353
+ object({
21354
+ state: literal("not-configured"),
21355
+ cameraLevel: CameraRawLevelSchema.optional()
21356
+ }),
21092
21357
  object({
21093
21358
  state: literal("unreadable"),
21094
- reason: string()
21359
+ reason: string(),
21360
+ cameraLevel: CameraRawLevelSchema.optional()
21095
21361
  }),
21096
21362
  object({
21097
21363
  state: literal("configured"),
21098
- mode: CameraSensorsModeSchema,
21364
+ cameraLevel: CameraRawLevelSchema.optional(),
21099
21365
  sensors: array(CameraSensorAttachmentSchema).readonly(),
21100
- notForwarded: CameraSensorsNotForwardedSchema.optional()
21366
+ /** Absent = an orchestrator older than CS-2: it does not say (D315). */
21367
+ cameraMotion: CameraOwnMotionSchema.optional(),
21368
+ notForwarded: CameraSensorsNotForwardedSchema.optional(),
21369
+ notEnforced: CameraSensorsNotEnforcedSchema.optional()
21101
21370
  })
21102
21371
  ]);
21103
21372
  Object.freeze({
@@ -22932,7 +23201,8 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
22932
23201
  trackIds: array(string()).min(1)
22933
23202
  }), object({
22934
23203
  deleted: number().int(),
22935
- failed: array(string()).readonly()
23204
+ failed: array(string()).readonly(),
23205
+ sparedMediaIds: array(number().int()).readonly().optional()
22936
23206
  }), {
22937
23207
  kind: "mutation",
22938
23208
  auth: "admin"
@@ -24327,8 +24597,10 @@ var RunnerCameraConfigSchema = object({
24327
24597
  * - `analyzer`: ML/frame-diff motion detection (motion-wasm or other
24328
24598
  * analyzer providers) running on decoded frames in this runner.
24329
24599
  * - `onboard`: camera-native motion pushes (Reolink Baichuan, ONVIF
24330
- * analytics). The provider emits ProviderMotion
24331
- * events; the orchestrator forwards to `reportMotion`.
24600
+ * analytics). The provider emits its raw push as `ProviderMotion`
24601
+ * (D673); the orchestrator's camera-sensors bridge re-emits the camera's
24602
+ * effective motion as `MotionOnMotionChanged`, which is what reaches
24603
+ * `reportMotion`.
24332
24604
  */
24333
24605
  motionSources: MotionSourcesSchema.default(["analyzer"]),
24334
24606
  /**
@@ -24505,7 +24777,15 @@ var RunnerLocalLoadSchema = object({
24505
24777
  hasGpu: boolean(),
24506
24778
  inferenceBackend: string().optional(),
24507
24779
  cpuCores: number().optional()
24508
- })
24780
+ }),
24781
+ /**
24782
+ * Who writes a camera's `motion` runtime slice (D696). `'orchestrator'`: this
24783
+ * runner never writes it. ABSENT = a runner older than D696, which still
24784
+ * writes the slice from its phase machine; the orchestrator does not write
24785
+ * while any runner node is absent-or-unanswered, so one slice never has two
24786
+ * writers.
24787
+ */
24788
+ motionSliceWriter: literal("orchestrator").optional()
24509
24789
  });
24510
24790
  /**
24511
24791
  * Aggregate runtime metrics for the runner's whole local pool. Mirrors the
@@ -25161,7 +25441,42 @@ var SetCameraSensorsInputSchema = object({
25161
25441
  /** `null` removes the attachment: the camera goes back to `not-configured`. */
25162
25442
  config: CameraSensorsConfigSchema.nullable()
25163
25443
  });
25164
- method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
25444
+ /**
25445
+ * Why an early occupancy look (D691) was not scheduled.
25446
+ *
25447
+ * - `unknown-camera` — no session was ever dispatched for it, so there is no
25448
+ * node and no config to attach a burst with.
25449
+ * - `out-of-range` — the ask is negative or further out than the orchestrator
25450
+ * will hold a timer for; the parked-object cadence is the answer there.
25451
+ * - `no-burst-producer` — this build has no burst producer at all.
25452
+ * - `already-looked` — this camera's ONE early look since its last session has
25453
+ * been spent. A look's own burst can re-arm a flickering flip, and a look
25454
+ * per arm would chain a burst every ~30 s forever (review H2); the next
25455
+ * real session re-arms the budget.
25456
+ */
25457
+ var OccupancyLookRefusalSchema = _enum([
25458
+ "unknown-camera",
25459
+ "out-of-range",
25460
+ "no-burst-producer",
25461
+ "already-looked"
25462
+ ]);
25463
+ method(object({
25464
+ deviceId: number().int().nonnegative(),
25465
+ /** How long from NOW until the pending flip's sustain window ends. RELATIVE,
25466
+ * so the caller's clock and the orchestrator's never have to agree. */
25467
+ afterMs: number().finite(),
25468
+ /** Why, for the log. */
25469
+ reason: string()
25470
+ }), object({
25471
+ scheduled: boolean(),
25472
+ /** When `scheduled`: how long until the burst is dialled. */
25473
+ dueInMs: number().optional(),
25474
+ /** When not `scheduled`: why. */
25475
+ refusedBecause: OccupancyLookRefusalSchema.optional()
25476
+ }), {
25477
+ kind: "mutation",
25478
+ auth: "admin"
25479
+ }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
25165
25480
  kind: "mutation",
25166
25481
  auth: "admin"
25167
25482
  }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
@@ -28046,219 +28361,6 @@ var CLIP_PLAYBACK_OPTIONS = {
28046
28361
  }
28047
28362
  };
28048
28363
  /**
28049
- * Doorbell button cap. Two kinds of providers coexist behind this cap
28050
- * name (same pattern as `snapshot`):
28051
- *
28052
- * - **Native** providers: registered per-device by device-driver
28053
- * addons via `ctx.registerNativeCap` — either on a
28054
- * `DeviceType.Button` accessory with `role: DeviceRole.Doorbell`,
28055
- * or directly on the camera (Reolink registers at camera level).
28056
- * Emits an `onPressed` event every time the firmware pushes a
28057
- * ring; status tracks the last press and a pressCount since start
28058
- * (diagnostic).
28059
- *
28060
- * - **Wrapper** provider: the `virtual-doorbell` system builtin
28061
- * (`@camstack/system/builtins/doorbell`). Turns ANY binary-ish
28062
- * device (contact / switch / event-emitter …) into a doorbell for
28063
- * a camera. `defaultActive: false` — the operator explicitly binds
28064
- * it per camera in the device-bindings UI, then picks the source
28065
- * device + trigger in the per-device settings.
28066
- *
28067
- * The DeviceEventPropagator re-emits `onPressed` on the camera parent
28068
- * — subscribers listening at the camera level receive ring events
28069
- * with `via[]` populated. No code on the parent needed.
28070
- */
28071
- var DoorbellStatusSchema = object({
28072
- /** Ms epoch of the last press. null = never observed since this provider started. */
28073
- lastPressedAt: number().nullable(),
28074
- /** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
28075
- pressCountSinceStart: number()
28076
- });
28077
- var DoorbellPressEventSchema = object({
28078
- deviceId: number(),
28079
- timestamp: number()
28080
- });
28081
- /**
28082
- * The `doorbell-source` extension slot's editable value (D648): the camera's
28083
- * virtual-doorbell trigger devices, exactly what the wrapper's
28084
- * `doorbellSources` persists (as `{ deviceId }` records).
28085
- */
28086
- var DoorbellSourceSlotValueSchema = object({ deviceIds: array(number().int().positive()) });
28087
- /**
28088
- * The `doorbell-source` slot — which devices ring this camera's VIRTUAL
28089
- * doorbell, owned by the `virtual-doorbell` wrapper over its
28090
- * `doorbellSources` store (D648). A source rings when one of its
28091
- * `SOURCE_CAPS` rises. Whether the wrapper is bound to the camera at all is a
28092
- * different authority (`deviceManager.setWrapperActive`, D62) — the slot
28093
- * reports it, it never writes it.
28094
- */
28095
- var DOORBELL_SOURCE_SLOT = {
28096
- id: "doorbell-source",
28097
- label: "Doorbell trigger devices",
28098
- 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.",
28099
- shape: "association",
28100
- hostDeviceTypes: [DeviceType.Camera],
28101
- sourceCaps: SOURCE_CAPS,
28102
- cardinality: "many",
28103
- value: DoorbellSourceSlotValueSchema
28104
- };
28105
- var doorbellCapability = {
28106
- name: "doorbell",
28107
- scope: "device",
28108
- deviceNative: true,
28109
- mode: "singleton",
28110
- kind: "wrapper",
28111
- defaultActive: false,
28112
- deviceTypes: [DeviceType.Button, DeviceType.Camera],
28113
- extensionSlots: [DOORBELL_SOURCE_SLOT],
28114
- methods: {},
28115
- events: {
28116
- /**
28117
- * Fires once per physical press. Reolink delivers via Baichuan
28118
- * push (`ReolinkSimpleEvent.type === 'doorbell'`). There is no
28119
- * release/duration — it's a pulse.
28120
- */
28121
- onPressed: {
28122
- data: DoorbellPressEventSchema,
28123
- fromState: {
28124
- field: "lastPressedAt",
28125
- on: "advance"
28126
- }
28127
- } },
28128
- status: {
28129
- schema: DoorbellStatusSchema,
28130
- kind: "push"
28131
- },
28132
- /**
28133
- * Runtime-state slice — last press timestamp + lifetime press count.
28134
- * Mirrored by the kernel and readable via
28135
- * `device.state.doorbell.value`. UIs can show "last ring 5m ago"
28136
- * without subscribing.
28137
- */
28138
- runtimeState: DoorbellStatusSchema,
28139
- /**
28140
- * 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.
28141
- *
28142
- * See `RuntimeStateDurability`. Enforced by
28143
- * `scripts/check-runtime-state-durability.ts`.
28144
- */
28145
- durability: "restored"
28146
- };
28147
- var ExtensionSlotIdSchema = _enum(["doorbell-source", "linked-devices"]);
28148
- DeviceType.Camera, DeviceType.Camera;
28149
- /** A slot's editable value, discriminated on `slot`. */
28150
- var ExtensionSlotValueSchema = discriminatedUnion("slot", [DoorbellSourceSlotValueSchema.extend({ slot: literal("doorbell-source") }), LinkedDevicesSlotValueSchema.extend({ slot: literal("linked-devices") })]);
28151
- DeviceType.Camera;
28152
- var ExtensionSourceAvailabilitySchema = discriminatedUnion("state", [object({ state: literal("ok") }), object({
28153
- state: literal("unreachable"),
28154
- reason: string()
28155
- })]);
28156
- /** One provider of slots — the D554 source-listing row. */
28157
- var ExtensionSourceSchema = object({
28158
- /** The routing prefix of every `slotRef` this provider serves. */
28159
- source: string(),
28160
- label: string(),
28161
- /** Stamped by the dispatcher from the registry (D557). */
28162
- addonId: string().optional(),
28163
- availability: ExtensionSourceAvailabilitySchema
28164
- });
28165
- /**
28166
- * How one picked source stands. `missing` — no such device (deleted, or an id
28167
- * that never existed); `foreign` — a device the slot's owner cannot read from
28168
- * (a source owned by another addon); `unavailable` — it exists but is not a
28169
- * valid source now (a container, which is never a pick). A source in any of
28170
- * these states is SHOWN, never silently dropped or re-pointed.
28171
- */
28172
- var ExtensionSourceHealthSchema = _enum([
28173
- "ok",
28174
- "missing",
28175
- "foreign",
28176
- "unavailable"
28177
- ]);
28178
- var ExtensionSlotSourceSchema = object({
28179
- deviceId: number().int(),
28180
- /** The device's name, or null when it could not be resolved (`missing`). */
28181
- name: string().nullable(),
28182
- health: ExtensionSourceHealthSchema,
28183
- detail: string().optional()
28184
- });
28185
- /**
28186
- * A DIFFERENT authority that gates whether the slot's sources do anything —
28187
- * reported read-only, named, never written through this contract (D62). The
28188
- * virtual doorbell's sources ring only while the wrapper is bound to the
28189
- * camera, and that binding belongs to `deviceManager.setWrapperActive`.
28190
- * `unknown` means the gate could not be read; it is not "inactive" (D315).
28191
- */
28192
- var ExtensionSlotActivationSchema = object({
28193
- state: _enum([
28194
- "active",
28195
- "inactive",
28196
- "unknown"
28197
- ]),
28198
- authority: string(),
28199
- detail: string().optional()
28200
- });
28201
- var ExtensionSlotRowSchema = discriminatedUnion("state", [object({
28202
- state: literal("ok"),
28203
- /** `<source>:<slotId>` — the routing key for `listCandidates` / `setSlot`. */
28204
- slotRef: string(),
28205
- slot: ExtensionSlotIdSchema,
28206
- /** Names the store written (D62), e.g. `virtual-doorbell:doorbellSources`. */
28207
- authority: string(),
28208
- activation: ExtensionSlotActivationSchema.nullable(),
28209
- value: ExtensionSlotValueSchema,
28210
- sources: array(ExtensionSlotSourceSchema),
28211
- /**
28212
- * Devices the owner links to the host ON ITS OWN, by structure, and that
28213
- * are therefore not in `value` (D655): a camera's device-tree children, and
28214
- * the child a picked container stands for (D356 — a container is never a
28215
- * pick, its children are). Read-only; the editor shows them and may offer
28216
- * per-device options on them (the linked-devices tracked-event opt-in).
28217
- * Absent when the owner links nothing beyond the picks, and from an owner
28218
- * older than D655.
28219
- */
28220
- impliedSources: array(ExtensionSlotSourceSchema).optional()
28221
- }), object({
28222
- state: literal("unreachable"),
28223
- addonId: string(),
28224
- reason: string()
28225
- })]);
28226
- var ExtensionCandidatesSchema = object({ candidates: array(object({
28227
- deviceId: number().int(),
28228
- name: string(),
28229
- type: string(),
28230
- location: string().nullable(),
28231
- /** The container a child belongs to — "Spotlight 2" alone does not say which. */
28232
- parentName: string().nullable(),
28233
- /** Pre-marked by the owner's suggestion rule. NEVER saved on its own (D356). */
28234
- suggested: boolean(),
28235
- /** Why it is suggested ("same location"), null when it is not. */
28236
- reason: string().nullable()
28237
- })) });
28238
- /**
28239
- * What a write did. `none` — applied in place. `host` / `parent` — the owner
28240
- * reloaded the host (or, for an accessory child, its parent) because the
28241
- * write changed what the host REGISTERS. A slot never adds a capability to its
28242
- * host — that is a composition (D663) — so today's owners answer `none`.
28243
- */
28244
- var ExtensionSetResultSchema = object({
28245
- applied: literal(true),
28246
- reload: _enum([
28247
- "none",
28248
- "host",
28249
- "parent"
28250
- ])
28251
- });
28252
- var ExtensionSlotRefInputSchema = object({
28253
- deviceId: number().int(),
28254
- slotRef: string().min(1)
28255
- });
28256
- var ExtensionSetSlotInputSchema = ExtensionSlotRefInputSchema.extend({ value: ExtensionSlotValueSchema });
28257
- method(object({ deviceId: number().int() }), array(ExtensionSourceSchema)), method(object({ deviceId: number().int() }), array(ExtensionSlotRowSchema)), method(ExtensionSlotRefInputSchema, ExtensionCandidatesSchema), method(ExtensionSetSlotInputSchema, ExtensionSetResultSchema, {
28258
- kind: "mutation",
28259
- auth: "admin"
28260
- });
28261
- /**
28262
28364
  * Optional client-side hints sent at session creation to help the provider
28263
28365
  * pick the best native source. All fields optional — a viewer that knows
28264
28366
  * nothing still gets a sane default. (Relocated from the retired `webrtc`
@@ -30726,6 +30828,70 @@ onStatusChanged: { data: object({
30726
30828
  * whether persisting is worth a SQLite commit. */
30727
30829
  volatileStateFields: ["lastChangedAt"]
30728
30830
  };
30831
+ var DoorbellStatusSchema = object({
30832
+ /** Ms epoch of the last press. null = never observed since this provider started. */
30833
+ lastPressedAt: number().nullable(),
30834
+ /** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
30835
+ pressCountSinceStart: number()
30836
+ });
30837
+ var DoorbellPressEventSchema = object({
30838
+ deviceId: number(),
30839
+ timestamp: number()
30840
+ });
30841
+ /**
30842
+ * Doorbell button cap. Two kinds of provider serve it, and to every consumer
30843
+ * they are the same cap:
30844
+ *
30845
+ * - **Native** providers, registered per device by a driver addon through
30846
+ * `ctx.registerNativeCap` — a `DeviceType.Button` accessory with
30847
+ * `role: DeviceRole.Doorbell`, or the camera itself (Reolink registers at
30848
+ * camera level). They emit `onPressed` on every firmware ring.
30849
+ * - **A composed doorbell** (D670, D671): a camera's customization gives it
30850
+ * the cap, its `lastPressedAt` rising from the sources the operator
30851
+ * assigned in Customize → Doorbell, and the composer emits `onPressed`
30852
+ * from that field's advance (`fromState`).
30853
+ *
30854
+ * The DeviceEventPropagator re-emits `onPressed` on the camera parent.
30855
+ */
30856
+ var doorbellCapability = {
30857
+ name: "doorbell",
30858
+ scope: "device",
30859
+ deviceNative: true,
30860
+ mode: "singleton",
30861
+ deviceTypes: [DeviceType.Button, DeviceType.Camera],
30862
+ methods: {},
30863
+ events: {
30864
+ /**
30865
+ * Fires once per physical press. Reolink delivers via Baichuan
30866
+ * push (`ReolinkSimpleEvent.type === 'doorbell'`). There is no
30867
+ * release/duration — it's a pulse.
30868
+ */
30869
+ onPressed: {
30870
+ data: DoorbellPressEventSchema,
30871
+ fromState: {
30872
+ field: "lastPressedAt",
30873
+ on: "advance"
30874
+ }
30875
+ } },
30876
+ status: {
30877
+ schema: DoorbellStatusSchema,
30878
+ kind: "push"
30879
+ },
30880
+ /**
30881
+ * Runtime-state slice — last press timestamp + lifetime press count.
30882
+ * Mirrored by the kernel and readable via
30883
+ * `device.state.doorbell.value`. UIs can show "last ring 5m ago"
30884
+ * without subscribing.
30885
+ */
30886
+ runtimeState: DoorbellStatusSchema,
30887
+ /**
30888
+ * 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.
30889
+ *
30890
+ * See `RuntimeStateDurability`. Enforced by
30891
+ * `scripts/check-runtime-state-durability.ts`.
30892
+ */
30893
+ durability: "restored"
30894
+ };
30729
30895
  /**
30730
30896
  * Enum-state sensor — a string value picked from a finite option set.
30731
30897
  * Drives HA `sensor` entries with `state_class: enum` (HVAC action
@@ -32865,39 +33031,14 @@ authKey: string().optional() }), object({
32865
33031
  /** Human-readable error when `ok: false`. */
32866
33032
  error: string().optional()
32867
33033
  }), { kind: "mutation" });
32868
- /**
32869
- * Hardware / firmware motion sensor cap — binary detected state plus
32870
- * a timestamp of the last observation. Distinct from
32871
- * `motion-detection.cap.ts` which owns the LOCAL ML motion pipeline;
32872
- * `motion` is the lightweight readout from on-camera motion (Reolink
32873
- * `GetMdState`, Baichuan push `type: motion`, ONVIF analytics).
32874
- *
32875
- * Native-motion providers also fan out to `detection.camera-native`
32876
- * with `source: 'onboard'` so cross-cutting system services
32877
- * (alert-center, advanced-notifier) can subscribe once and receive
32878
- * motion from every camera.
32879
- */
32880
- /**
32881
- * How long after a camera's last rising edge `pipeline-analytics` closes the
32882
- * motion EPISODE row it kept open for it (D475) — "il delay della cap", in
32883
- * the operator's words. One authority for the whole system: every provider
32884
- * that seeds `autoClearAfterMs` on a `Camera` device writes this SAME
32885
- * constant while `detected: true` (never its own number — Hikvision used to
32886
- * seed its internal 3 s inactivity timer here, which is a different clock for
32887
- * a different purpose), and `MotionEpisodeTracker` imports it directly rather
32888
- * than reading the live cap value on the hot path. A `Sensor` device (HA
32889
- * binary sensor, Homematic) gets a genuine push both ways and has no episode
32890
- * to close on a timer, so it writes `null`, never this constant.
32891
- */
32892
- var MOTION_CLOSE_AFTER_MS = 15e3;
32893
33034
  var MotionStatusSchema = object({
32894
33035
  detected: boolean(),
32895
33036
  /** Ms epoch of the last detected-true observation. Null if never detected. */
32896
33037
  lastDetectedAt: number().nullable(),
32897
33038
  /**
32898
- * `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
32899
- * `null` while false and on every `Sensor` device (D475) — see that
32900
- * constant's doc for the one-authority rule.
33039
+ * `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device (the
33040
+ * orchestrator writes it, D696), `null` while false and on every `Sensor`
33041
+ * device (D475) — see that constant's doc for the one-authority rule.
32901
33042
  *
32902
33043
  * ## Reading this field still arms nothing
32903
33044
  *
@@ -32915,34 +33056,31 @@ var MotionStatusSchema = object({
32915
33056
  * `addon-export-alexa/src/motion-clear-hold.ts` and
32916
33057
  * `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
32917
33058
  *
32918
- * ## Who writes it
32919
- *
32920
- * - **Cameras** — the runner's phase machine, `active → watching` on
32921
- * `cooldown_expired`, which then writes this slice with
32922
- * `detected: false` (`handlePhaseChanged` in
32923
- * `pipeline-runner/index.ts`). It produces the FALLING edge, which
32924
- * matters most for the sources that only ever push a rising one:
32925
- * Reolink emits `MotionOnMotionChanged { detected: true }` and never
32926
- * a false.
32927
- * - **Sensors** (Home Assistant binary sensors, Homematic) — the
32928
- * provider pushes the false itself, from the upstream system's own
32929
- * state change. No phase machine is involved.
32930
- *
32931
- * ### The phase machine is CANONICAL, not sole — and that is a defect
32932
- *
32933
- * An earlier revision of this docblock (mine, 2026-09-12) claimed the
32934
- * phase machine is the sole writer for a camera. It is not.
32935
- * `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
32936
- * `setCapSlice(motionCapability, …)` on their own rising edge, and
32937
- * Hikvision's comment says why: it read THIS docblock, agreed the
32938
- * runner is canonical, and wrote anyway to avoid per-tick churn. So
32939
- * two authorities can disagree about one slice, which this repo
32940
- * forbids, and the doc said otherwise — which is worse than saying
32941
- * nothing, because it reads as verification.
32942
- *
32943
- * This predates D475 and is not fixed there: the fix touches every
32944
- * camera provider. Recorded in D475's Consequences. Do not restore the
32945
- * "sole writer" wording without also removing the other writers.
33059
+ * ## Who writes it (D696)
33060
+ *
33061
+ * - **Cameras** — the orchestrator, and nothing else. It writes the camera's
33062
+ * EFFECTIVE motion (`addon-pipeline-orchestrator`
33063
+ * `camera-sensors/motion-slice.ts`), alongside the effective
33064
+ * `MotionOnMotionChanged` it emits or receives: the camera-sensors bridge
33065
+ * for a split camera, an unsplit emitter's direct event, the analyzer and
33066
+ * device activity, as the camera's `motionSources` counts them. A source
33067
+ * that never sends a clear falls one window after its last `true`.
33068
+ * `lastDetectedAt` moves only on an effective rise. No camera provider
33069
+ * writes this slice (not even a boot seed), and neither does the runner's
33070
+ * phase machine: its phase is "a session is attached" for every on-motion
33071
+ * session, not motion, and it now has its own `DetectionPhaseTransition`.
33072
+ * A provider's `isDetected` answers from the hub's slice.
33073
+ * - **Sensors** (Home Assistant binary sensors, Homematic, Matter, Alexa
33074
+ * imports) — the provider pushes both edges itself, from the upstream
33075
+ * system's own state change. That is the sensor's own fact.
33076
+ *
33077
+ * `scripts/check-onboard-motion-emitters.ts` refuses any other writer of a
33078
+ * `motion` slice; each sensor writer is a named exemption.
33079
+ *
33080
+ * This replaces the D475 §4 rule ("the phase machine is the sole writer").
33081
+ * That rule was never true: Hikvision and Amcrest wrote the slice raw beside
33082
+ * it, every provider seeded it at boot, and every session left it
33083
+ * `detected: true` after its detach.
32946
33084
  */
32947
33085
  autoClearAfterMs: number().nullable()
32948
33086
  });
@@ -33014,11 +33152,12 @@ onMotionChanged: { data: MotionOnMotionChangedDataSchema } },
33014
33152
  */
33015
33153
  runtimeState: MotionStatusSchema,
33016
33154
  /**
33017
- * Runtime-state durability: **session** — every writer of this slice
33155
+ * Runtime-state durability: **session** — the writer of this slice
33018
33156
  * writes only on an EDGE, so a restored `detected: true` would stay
33019
33157
  * frozen until the next one instead of being corrected. The next edge
33020
- * re-publishes the real state. (On who the writers are, and why there
33021
- * is more than one, see `autoClearAfterMs` above.)
33158
+ * re-publishes the real state, and the orchestrator re-publishes every
33159
+ * camera when it starts writing (D696; on who writes it, see
33160
+ * `autoClearAfterMs` above).
33022
33161
  *
33023
33162
  * See `RuntimeStateDurability`. Enforced by
33024
33163
  * `scripts/check-runtime-state-durability.ts`.
@@ -35559,8 +35698,7 @@ var ptzAutotrackCapability = {
35559
35698
  deviceNative: true,
35560
35699
  mode: "singleton",
35561
35700
  /**
35562
- * Two kinds of provider behind one name, the same shape `snapshot` and
35563
- * `doorbell` use:
35701
+ * Two kinds of provider behind one name, the same shape `snapshot` uses:
35564
35702
  *
35565
35703
  * - **Native**: the camera's own firmware autotrack, registered per device by
35566
35704
  * the driver when the probe says it exists (Reolink: yes; Hikvision:
@@ -35568,7 +35706,7 @@ var ptzAutotrackCapability = {
35568
35706
  * - **Wrapper**: the emulated implementation (`@camstack/system`'s `autotrack` builtin),
35569
35707
  * which follows a subject with `ptz.move` pulses driven by the detection
35570
35708
  * pipeline. `defaultActive: false` — the operator binds it per camera in
35571
- * the bindings UI, exactly as `virtual-doorbell` is bound.
35709
+ * the bindings UI.
35572
35710
  *
35573
35711
  * The binding chooses WHICH implementation answers; `setEnabled` stays the
35574
35712
  * one switch for the function either way. A camera never has both driving its
@@ -44272,6 +44410,18 @@ Object.freeze({
44272
44410
  addonId: null,
44273
44411
  access: "view"
44274
44412
  },
44413
+ "databaseSnapshot.listDatabases": {
44414
+ capName: "database-snapshot",
44415
+ capScope: "system",
44416
+ addonId: null,
44417
+ access: "view"
44418
+ },
44419
+ "databaseSnapshot.writeSnapshot": {
44420
+ capName: "database-snapshot",
44421
+ capScope: "system",
44422
+ addonId: null,
44423
+ access: "create"
44424
+ },
44275
44425
  "dataStoreProvider.aggregate": {
44276
44426
  capName: "data-store-provider",
44277
44427
  capScope: "system",
@@ -47836,6 +47986,12 @@ Object.freeze({
47836
47986
  addonId: null,
47837
47987
  access: "delete"
47838
47988
  },
47989
+ "pipelineOrchestrator.requestOccupancyLook": {
47990
+ capName: "pipeline-orchestrator",
47991
+ capScope: "system",
47992
+ addonId: null,
47993
+ access: "create"
47994
+ },
47839
47995
  "pipelineOrchestrator.resetNodePipelineDefaults": {
47840
47996
  capName: "pipeline-orchestrator",
47841
47997
  capScope: "system",
@@ -51628,6 +51784,11 @@ Object.freeze({
51628
51784
  form: "single",
51629
51785
  optional: false
51630
51786
  }],
51787
+ "pipelineOrchestrator.requestOccupancyLook": [{
51788
+ name: "deviceId",
51789
+ form: "single",
51790
+ optional: false
51791
+ }],
51631
51792
  "pipelineOrchestrator.resolvePipeline": [{
51632
51793
  name: "deviceId",
51633
51794
  form: "single",
@@ -52789,6 +52950,18 @@ var STATE_SUMMARY_VARS = [
52789
52950
  systemEventKinds: [...SUMMARISABLE],
52790
52951
  systemEventDeliveries: ["summary"]
52791
52952
  },
52953
+ {
52954
+ name: "summarySection",
52955
+ label: "Summary: this section",
52956
+ description: "The section a per-section summary row is about (D698); on a summary sent as one message, every section it reports, comma-separated.",
52957
+ example: "Batterie scariche",
52958
+ group: "system",
52959
+ families: ["rule"],
52960
+ fields: [...RULE_TEXT],
52961
+ kinds: ["system"],
52962
+ systemEventKinds: [...SUMMARISABLE],
52963
+ systemEventDeliveries: ["summary"]
52964
+ },
52792
52965
  ...STATE_SUMMARY_SECTION_VARS.map((v) => ({
52793
52966
  name: v.name,
52794
52967
  label: v.label,
@@ -52865,6 +53038,37 @@ var STATE_SUMMARY_VARS = [
52865
53038
  [...RULE_TEXT],
52866
53039
  ...STATE_SUMMARY_VARS
52867
53040
  ];
53041
+ new Set([
53042
+ "disarmed",
53043
+ "armed_home",
53044
+ "armed_away",
53045
+ "armed_night",
53046
+ "armed_vacation",
53047
+ "armed_custom_bypass",
53048
+ "arming",
53049
+ "disarming",
53050
+ "pending",
53051
+ "triggered",
53052
+ "open",
53053
+ "opening",
53054
+ "closing",
53055
+ "closed",
53056
+ "stopped",
53057
+ "locked",
53058
+ "unlocked",
53059
+ "locking",
53060
+ "unlocking",
53061
+ "jammed",
53062
+ "on",
53063
+ "off",
53064
+ "home",
53065
+ "not_home",
53066
+ "matched",
53067
+ "diverged",
53068
+ "unknown",
53069
+ "latched",
53070
+ "live"
53071
+ ]);
52868
53072
  /**
52869
53073
  * TimelapseRule — the STANDALONE scheduled timelapse producer's rule model.
52870
53074
  *
@@ -53096,6 +53300,25 @@ TimelapseRuleInputSchema.extend({
53096
53300
  createdAt: number(),
53097
53301
  updatedAt: number()
53098
53302
  });
53303
+ async function readHubMotionDetected(deviceState, deviceId) {
53304
+ let slice;
53305
+ try {
53306
+ slice = await deviceState.getCapSlice.query({
53307
+ deviceId,
53308
+ capName: "motion"
53309
+ });
53310
+ } catch (err) {
53311
+ const reason = err instanceof Error ? err.message : String(err);
53312
+ throw new Error(`motion state of device ${deviceId} is unreadable: ${reason}`, { cause: err });
53313
+ }
53314
+ const detected = slice?.["detected"];
53315
+ if (typeof detected !== "boolean") throw new Error(`motion state of device ${deviceId} is not published yet (unknown)`);
53316
+ return detected;
53317
+ }
53318
+ MotionOnMotionChangedDataSchema.omit({ triggeredBy: true });
53319
+ function providerMotionEvent(source, data) {
53320
+ return createEvent(EventCategory.ProviderMotion, source, data);
53321
+ }
53099
53322
  object({
53100
53323
  /**
53101
53324
  * Fraction of the box's own size added on EACH side before cutting.
@@ -62908,15 +63131,7 @@ var HikvisionCamera = class HikvisionCamera extends BaseDevice {
62908
63131
  host
62909
63132
  };
62910
63133
  } });
62911
- this.ctx.registerNativeCap(motionCapability, { isDetected: async ({ deviceId }) => {
62912
- if (deviceId !== this.id) throw new Error(`HikvisionCamera: deviceId mismatch, expected ${this.id}, got ${deviceId}`);
62913
- return this.state.motion?.detected ?? false;
62914
- } });
62915
- this.setCapSlice(motionCapability, {
62916
- detected: false,
62917
- lastDetectedAt: null,
62918
- autoClearAfterMs: null
62919
- });
63134
+ this.registerMotionCap();
62920
63135
  this.registerIntercomIfSupported();
62921
63136
  this.registerOsdCap(1);
62922
63137
  this.registerStreamParamsCap(1);
@@ -65385,43 +65600,41 @@ var HikvisionCamera = class HikvisionCamera extends BaseDevice {
65385
65600
  deviceId: this.id
65386
65601
  };
65387
65602
  }
65603
+ /**
65604
+ * The native `motion` cap. Its presence is what defaults the camera to
65605
+ * `motionSources: ['onboard']`. This provider writes NO `motion` slice (D696):
65606
+ * the orchestrator is its only writer, with the EFFECTIVE motion, on the hub.
65607
+ * `isDetected` therefore answers from the hub's slice; an unreadable hub, or
65608
+ * a slice nobody has published since the hub started, makes the call fail.
65609
+ * It never answers `false` for "unknown" (D49, D393).
65610
+ */
65611
+ registerMotionCap() {
65612
+ this.ctx.registerNativeCap(motionCapability, { isDetected: async ({ deviceId }) => {
65613
+ if (deviceId !== this.id) throw new Error(`HikvisionCamera: deviceId mismatch, expected ${this.id}, got ${deviceId}`);
65614
+ return readHubMotionDetected(this.ctx.api.deviceState, this.id);
65615
+ } });
65616
+ }
65388
65617
  handleMotionEvent(ev, camStreamId) {
65389
65618
  const now = ev.observedAt;
65390
- const wasInactive = (this.lastMotionAt.get(camStreamId) ?? 0) === 0;
65391
65619
  this.lastMotionAt.set(camStreamId, now);
65392
- this.ctx.eventBus.emit(createEvent(EventCategory.MotionOnMotionChanged, this.eventSource, {
65620
+ this.ctx.eventBus.emit(providerMotionEvent(this.eventSource, {
65393
65621
  deviceId: this.id,
65394
65622
  detected: true,
65395
65623
  timestamp: now,
65396
65624
  source: "onboard"
65397
65625
  }));
65398
- if (wasInactive) try {
65399
- this.setCapSlice(motionCapability, {
65400
- detected: true,
65401
- lastDetectedAt: now,
65402
- autoClearAfterMs: MOTION_CLOSE_AFTER_MS
65403
- });
65404
- } catch {}
65405
65626
  const existing = this.motionInactiveTimers.get(camStreamId);
65406
65627
  if (existing) clearTimeout(existing);
65407
65628
  const timer = setTimeout(() => {
65408
65629
  const clearedAt = Date.now();
65409
65630
  this.lastMotionAt.set(camStreamId, 0);
65410
65631
  this.motionInactiveTimers.delete(camStreamId);
65411
- this.ctx.eventBus.emit(createEvent(EventCategory.MotionOnMotionChanged, this.eventSource, {
65632
+ this.ctx.eventBus.emit(providerMotionEvent(this.eventSource, {
65412
65633
  deviceId: this.id,
65413
65634
  detected: false,
65414
65635
  timestamp: clearedAt,
65415
65636
  source: "onboard"
65416
65637
  }));
65417
- try {
65418
- const lastDetectedAt = this.state.motion?.lastDetectedAt ?? clearedAt;
65419
- this.setCapSlice(motionCapability, {
65420
- detected: false,
65421
- lastDetectedAt,
65422
- autoClearAfterMs: null
65423
- });
65424
- } catch {}
65425
65638
  }, HikvisionCamera.MOTION_INACTIVE_AFTER_MS);
65426
65639
  this.motionInactiveTimers.set(camStreamId, timer);
65427
65640
  }