@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.mjs CHANGED
@@ -12,7 +12,7 @@ import { networkInterfaces } from "node:os";
12
12
  var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
13
13
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
14
14
  //#endregion
15
- //#region ../types/dist/event-category-C5xZWqz6.mjs
15
+ //#region ../types/dist/event-category-BGmz_oxW.mjs
16
16
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
17
17
  EventCategory["SystemBoot"] = "system.boot";
18
18
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -545,6 +545,15 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
545
545
  */
546
546
  EventCategory["PipelineAudioInferenceResult"] = "pipeline.audio-inference-result";
547
547
  EventCategory["DetectionPhaseTransition"] = "detection.phase-transition";
548
+ /**
549
+ * A camera provider's RAW onboard motion push (D673): the `MotionOnMotionChanged`
550
+ * data shape without `triggeredBy`, built by `providerMotionEvent`. Its one
551
+ * consumer is the orchestrator's camera-sensors bridge, which re-emits the
552
+ * camera's EFFECTIVE onboard motion as `MotionOnMotionChanged` (a pass-through
553
+ * for a camera with no attached sensor). Providers must not emit
554
+ * `MotionOnMotionChanged` themselves; `scripts/check-onboard-motion-emitters.ts`
555
+ * keeps it so (camera-grid is a named, deferred exception).
556
+ */
548
557
  EventCategory["ProviderMotion"] = "provider.motion";
549
558
  EventCategory["ProviderDetection"] = "provider.detection";
550
559
  EventCategory["EnrichmentEmbeddingStored"] = "enrichment.embedding.stored";
@@ -5383,7 +5392,7 @@ var ZodIssueCode = {
5383
5392
  var ZodFirstPartyTypeKind;
5384
5393
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5385
5394
  //#endregion
5386
- //#region ../types/dist/sleep-gU6hqv4_.mjs
5395
+ //#region ../types/dist/sleep-CDCONfkt.mjs
5387
5396
  /**
5388
5397
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5389
5398
  * window to float samples (D455).
@@ -7428,7 +7437,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
7428
7437
  return DeviceRole;
7429
7438
  }({});
7430
7439
  //#endregion
7431
- //#region ../types/dist/composition-Dq42XWp0.mjs
7440
+ //#region ../types/dist/composition-43aqsZQj.mjs
7432
7441
  /**
7433
7442
  * The ffmpeg build every CamStack node downloads, per platform and arch.
7434
7443
  *
@@ -7485,13 +7494,12 @@ portable("linux64"), portable("linuxarm64"), portable("macarm64"), portable("mac
7485
7494
  * LA tabella "quale booleano di questo tipo di device conta come ALTO", e il
7486
7495
  * valutatore puro del suo FRONTE.
7487
7496
  *
7488
- * Viveva dentro il builtin virtual-doorbell
7489
- * (`@camstack/system` — `builtins/doorbell/trigger-engine.ts`) e i suoi
7490
- * predicati erano privati al modulo. Il recorder ne ha bisogno per il trigger
7491
- * `RecordingTriggers.sensorDeviceIds`: copiarla avrebbe creato la SECONDA
7492
- * tabella, che diverge alla prima cap aggiunta e il cui sintomo — "il sensore
7493
- * fa suonare il campanello ma non registra" — è esattamente D62. Quindi si
7494
- * SPOSTA qui e il doorbell la ri-esporta.
7497
+ * UNA tabella per tutti quelli che chiedono "questo device è ALTO?": il
7498
+ * trigger `RecordingTriggers.sensorDeviceIds` del recorder, i marker dei
7499
+ * sensori della post-analysis, il bridge camera-sensors dell'orchestratore e
7500
+ * le sorgenti di un campanello composto (`doorbellFeatureSources`, D671).
7501
+ * Una seconda copia divergerebbe alla prima cap aggiunta, e il sintomo — "il
7502
+ * sensore fa suonare il campanello ma non registra" — è esattamente D62.
7495
7503
  *
7496
7504
  * ⚠ NON è `DEVICE_STATE_READERS` (`catalogs/device-state-vocabulary.ts`), e le
7497
7505
  * due non vanno unificate: quella risponde a "qual è la PAROLA di stato per una
@@ -7517,8 +7525,6 @@ var SOURCE_CAP_ACTIVE_FIELD = {
7517
7525
  vibration: "detected",
7518
7526
  tamper: "tampered"
7519
7527
  };
7520
- /** Cap names whose presence in a device's bindings qualify it as a source. */
7521
- var SOURCE_CAPS = Object.keys(SOURCE_CAP_ACTIVE_FIELD);
7522
7528
  /**
7523
7529
  * Error types for the safe expression engine. Two distinct classes so callers
7524
7530
  * can tell a compile-time (grammar) failure from a runtime (evaluation)
@@ -9248,7 +9254,7 @@ var RecordingTriggersSchema = object({
9248
9254
  *
9249
9255
  * Cosa vuol dire "alto" dipende dal TIPO di device e non è deciso qui:
9250
9256
  * `SOURCE_CAP_ACTIVE_FIELD` (`catalogs/sensor-active-state.ts`) è LA tabella,
9251
- * la stessa che il virtual-doorbell usa dal 2026-08-05. Ed è il FRONTE, non
9257
+ * la stessa del campanello composto (D671). Ed è il FRONTE, non
9252
9258
  * il livello: un contatto trovato già aperto al riavvio del runner non fa
9253
9259
  * registrare.
9254
9260
  */
@@ -11884,6 +11890,68 @@ method(object({
11884
11890
  password: string()
11885
11891
  }), AuthResultSchema.nullable(), { kind: "mutation" }), method(object({ state: string() }), string()), method(record(string(), string()), AuthResultSchema, { kind: "mutation" }), method(object({ token: string() }), AuthResultSchema.nullable());
11886
11892
  /**
11893
+ * How long one snapshot may take end to end: the pinned copy of the whole
11894
+ * database plus `PRAGMA integrity_check` over the copy, on the hub's slowest
11895
+ * disk. ~800 MB at a pessimistic 10 MB/s is under 3 minutes; the bound is
11896
+ * generous because a timeout fails the whole backup run.
11897
+ */
11898
+ var DATABASE_SNAPSHOT_TIMEOUT_MS = 30 * 6e4;
11899
+ /**
11900
+ * The databases an owner snapshots — declared by the OWNER, so a caller never
11901
+ * guesses which file is live from what sits beside it (a cleanly closed
11902
+ * database has no sidecars and is just as owned). Paths are absolute on the
11903
+ * owner's host.
11904
+ */
11905
+ var DatabaseSnapshotTargetsSchema = object({ databases: array(object({ livePath: string() })) });
11906
+ /** One b-tree table of the snapshot and the rows it holds. */
11907
+ var DatabaseSnapshotTableSchema = object({
11908
+ name: string(),
11909
+ rows: number().int().nonnegative()
11910
+ });
11911
+ /**
11912
+ * What the owner wrote. Every path is ABSOLUTE on the owner's host — the
11913
+ * caller pins the call to its own node, so it can read the file; a caller
11914
+ * that finds the path outside its own data root refuses it rather than
11915
+ * archiving something it cannot place.
11916
+ */
11917
+ var DatabaseSnapshotResultSchema = object({
11918
+ /** The live database the snapshot copies. Never to be copied as a file. */
11919
+ livePath: string(),
11920
+ /** The verified copy: `<livePath>` + {@link DATABASE_SNAPSHOT_SUFFIX}. */
11921
+ snapshotPath: string(),
11922
+ sizeBytes: number().int().nonnegative(),
11923
+ pageCount: number().int().nonnegative(),
11924
+ pageSize: number().int().positive(),
11925
+ /**
11926
+ * Every b-tree table with its row count. Read inside the SAME read
11927
+ * transaction the copy was taken from, and found EQUAL on the copy — so
11928
+ * this is the content of the snapshot, not an estimate of the source.
11929
+ */
11930
+ tables: array(DatabaseSnapshotTableSchema),
11931
+ /** Wall time of the pinned copy (row counts included). */
11932
+ copyMs: number().nonnegative(),
11933
+ /** Wall time of the checks on the copy (`integrity_check`, row counts). */
11934
+ verifyMs: number().nonnegative(),
11935
+ /** When the pinned read transaction began (ms epoch) — the snapshot's instant. */
11936
+ takenAt: number()
11937
+ });
11938
+ /**
11939
+ * A snapshot as an ARCHIVE records it (`ArchiveManifest.sqliteSnapshots`):
11940
+ * the same facts, with both paths relative to the archive root (the node's
11941
+ * data dir), because an archive outlives the host that made it.
11942
+ */
11943
+ var ArchiveSqliteSnapshotSchema = DatabaseSnapshotResultSchema.extend({
11944
+ /** Archive-relative path of the live database the archive does NOT carry. */
11945
+ livePath: string(),
11946
+ /** Archive-relative path of the verified copy it carries in its place. */
11947
+ snapshotPath: string()
11948
+ });
11949
+ method(object({}), DatabaseSnapshotTargetsSchema, { auth: "admin" }), method(object({}), DatabaseSnapshotResultSchema, {
11950
+ kind: "mutation",
11951
+ auth: "admin",
11952
+ timeoutMs: DATABASE_SNAPSHOT_TIMEOUT_MS
11953
+ });
11954
+ /**
11887
11955
  * Orchestrator-side destination metadata. The orchestrator computes
11888
11956
  * `id = <addonId>:<subId>` from its provider lookup so consumers
11889
11957
  * (admin UI, restore flow) see one canonical key.
@@ -11994,7 +12062,12 @@ var ArchiveManifestSchema = object({
11994
12062
  locations: array(string()),
11995
12063
  entries: array(ArchiveEntrySchema),
11996
12064
  totalBytes: number(),
11997
- totalFiles: number()
12065
+ totalFiles: number(),
12066
+ /**
12067
+ * Live SQLite databases this archive carries as their OWNER's verified
12068
+ * snapshot instead of as files (D693). Absent on archives made before.
12069
+ */
12070
+ sqliteSnapshots: array(ArchiveSqliteSnapshotSchema).optional()
11998
12071
  });
11999
12072
  var LocationStatSchema = object({
12000
12073
  name: string(),
@@ -13520,6 +13593,52 @@ var CompositionBlockStateSchema = object({
13520
13593
  reason: string().optional(),
13521
13594
  fields: array(CompositionFieldStateSchema)
13522
13595
  });
13596
+ var ComposerBlockSchema = object({
13597
+ id: string().min(1),
13598
+ name: string().min(1).max(120),
13599
+ enabled: boolean(),
13600
+ updatedAt: number(),
13601
+ composition: CompositionSchema
13602
+ });
13603
+ /**
13604
+ * A stored composition row that no longer PARSES — a schema a release
13605
+ * tightened, a row written by a newer build. Sent by id so the composer keeps
13606
+ * its device as a placeholder and reports the block `failed` naming the parse
13607
+ * error. Leaving it out would read, twice, exactly like a delete (D49).
13608
+ */
13609
+ var ComposerUnreadableBlockSchema = object({
13610
+ id: string().min(1),
13611
+ /** The row's stored name column; null when even that is unreadable (the device keeps the name it has). */
13612
+ name: string().nullable(),
13613
+ /** The parse error, in the operator's words. */
13614
+ error: string()
13615
+ });
13616
+ method(object({
13617
+ /** The shared Blocks integration; null until `core-blocks` has reconciled it. */
13618
+ integrationId: string().nullable(),
13619
+ /** False when the `core_blocks` read failed: then nothing may be withdrawn (D49). */
13620
+ storeLoaded: boolean(),
13621
+ blocks: array(ComposerBlockSchema),
13622
+ /** Operator restarts: rebuild these runtimes and re-resolve their sources. Stores nothing (D62). */
13623
+ restartBlockIds: array(string()),
13624
+ /** Composition rows that exist but do not parse: held, never withdrawn, reported failed. */
13625
+ unreadableBlocks: array(ComposerUnreadableBlockSchema)
13626
+ }), object({
13627
+ blocks: array(object({
13628
+ blockId: string(),
13629
+ status: CompositionRunStatusSchema,
13630
+ reason: string().optional()
13631
+ })),
13632
+ /**
13633
+ * False when the composer declared and withdrew NOTHING (store not loaded,
13634
+ * integration unknown, its own rows unread or read empty once). An empty
13635
+ * apply the caller owes is paid off only by one the composer acted on (D49).
13636
+ */
13637
+ acted: boolean()
13638
+ }), {
13639
+ kind: "mutation",
13640
+ auth: "admin"
13641
+ }), method(object({ blockIds: array(string()) }), object({ states: array(CompositionBlockStateSchema) }), { auth: "admin" });
13523
13642
  var NUMBER = {
13524
13643
  kind: "fixed",
13525
13644
  result: ["number"]
@@ -13756,52 +13875,6 @@ method(object({}), object({ blocks: array(CoreBlockSchema) }), { auth: "admin" }
13756
13875
  auth: "admin",
13757
13876
  access: "view"
13758
13877
  });
13759
- var ComposerBlockSchema = object({
13760
- id: string().min(1),
13761
- name: string().min(1).max(120),
13762
- enabled: boolean(),
13763
- updatedAt: number(),
13764
- composition: CompositionSchema
13765
- });
13766
- /**
13767
- * A stored composition row that no longer PARSES — a schema a release
13768
- * tightened, a row written by a newer build. Sent by id so the composer keeps
13769
- * its device as a placeholder and reports the block `failed` naming the parse
13770
- * error. Leaving it out would read, twice, exactly like a delete (D49).
13771
- */
13772
- var ComposerUnreadableBlockSchema = object({
13773
- id: string().min(1),
13774
- /** The row's stored name column; null when even that is unreadable (the device keeps the name it has). */
13775
- name: string().nullable(),
13776
- /** The parse error, in the operator's words. */
13777
- error: string()
13778
- });
13779
- method(object({
13780
- /** The shared Blocks integration; null until `core-blocks` has reconciled it. */
13781
- integrationId: string().nullable(),
13782
- /** False when the `core_blocks` read failed: then nothing may be withdrawn (D49). */
13783
- storeLoaded: boolean(),
13784
- blocks: array(ComposerBlockSchema),
13785
- /** Operator restarts: rebuild these runtimes and re-resolve their sources. Stores nothing (D62). */
13786
- restartBlockIds: array(string()),
13787
- /** Composition rows that exist but do not parse: held, never withdrawn, reported failed. */
13788
- unreadableBlocks: array(ComposerUnreadableBlockSchema)
13789
- }), object({
13790
- blocks: array(object({
13791
- blockId: string(),
13792
- status: CompositionRunStatusSchema,
13793
- reason: string().optional()
13794
- })),
13795
- /**
13796
- * False when the composer declared and withdrew NOTHING (store not loaded,
13797
- * integration unknown, its own rows unread or read empty once). An empty
13798
- * apply the caller owes is paid off only by one the composer acted on (D49).
13799
- */
13800
- acted: boolean()
13801
- }), {
13802
- kind: "mutation",
13803
- auth: "admin"
13804
- }), method(object({ blockIds: array(string()) }), object({ states: array(CompositionBlockStateSchema) }), { auth: "admin" });
13805
13878
  /**
13806
13879
  * `custom-model-registry` — collection cap exposing operator-registered
13807
13880
  * custom detection models. Each provider (today: `addon-model-studio`)
@@ -15951,6 +16024,121 @@ method(object({
15951
16024
  deviceIds: array(number()).readonly(),
15952
16025
  caps: array(string()).readonly().optional()
15953
16026
  }), record(string(), record(string(), unknown().nullable())));
16027
+ var ExtensionSlotIdSchema = _enum(["linked-devices"]);
16028
+ DeviceType.Camera;
16029
+ /** A slot's editable value, discriminated on `slot`. */
16030
+ var ExtensionSlotValueSchema = discriminatedUnion("slot", [LinkedDevicesSlotValueSchema.extend({ slot: literal("linked-devices") })]);
16031
+ DeviceType.Camera;
16032
+ var ExtensionSourceAvailabilitySchema = discriminatedUnion("state", [object({ state: literal("ok") }), object({
16033
+ state: literal("unreachable"),
16034
+ reason: string()
16035
+ })]);
16036
+ /** One provider of slots — the D554 source-listing row. */
16037
+ var ExtensionSourceSchema = object({
16038
+ /** The routing prefix of every `slotRef` this provider serves. */
16039
+ source: string(),
16040
+ label: string(),
16041
+ /** Stamped by the dispatcher from the registry (D557). */
16042
+ addonId: string().optional(),
16043
+ availability: ExtensionSourceAvailabilitySchema
16044
+ });
16045
+ /**
16046
+ * How one picked source stands. `missing` — no such device (deleted, or an id
16047
+ * that never existed); `foreign` — a device the slot's owner cannot read from
16048
+ * (a source owned by another addon); `unavailable` — it exists but is not a
16049
+ * valid source now (a container, which is never a pick). A source in any of
16050
+ * these states is SHOWN, never silently dropped or re-pointed.
16051
+ */
16052
+ var ExtensionSourceHealthSchema = _enum([
16053
+ "ok",
16054
+ "missing",
16055
+ "foreign",
16056
+ "unavailable"
16057
+ ]);
16058
+ var ExtensionSlotSourceSchema = object({
16059
+ deviceId: number().int(),
16060
+ /** The device's name, or null when it could not be resolved (`missing`). */
16061
+ name: string().nullable(),
16062
+ health: ExtensionSourceHealthSchema,
16063
+ detail: string().optional()
16064
+ });
16065
+ /**
16066
+ * A DIFFERENT authority that gates whether the slot's sources do anything —
16067
+ * reported read-only, named, never written through this contract (D62) — e.g.
16068
+ * a slot whose sources act only while a wrapper is bound to the host, a
16069
+ * binding that belongs to `deviceManager.setWrapperActive`. No slot reports
16070
+ * one today (`linked-devices` answers `null`). `unknown` means the gate could
16071
+ * not be read; it is not "inactive" (D315).
16072
+ */
16073
+ var ExtensionSlotActivationSchema = object({
16074
+ state: _enum([
16075
+ "active",
16076
+ "inactive",
16077
+ "unknown"
16078
+ ]),
16079
+ authority: string(),
16080
+ detail: string().optional()
16081
+ });
16082
+ var ExtensionSlotRowSchema = discriminatedUnion("state", [object({
16083
+ state: literal("ok"),
16084
+ /** `<source>:<slotId>` — the routing key for `listCandidates` / `setSlot`. */
16085
+ slotRef: string(),
16086
+ slot: ExtensionSlotIdSchema,
16087
+ /** Names the store written (D62), e.g. `device-manager:_linkedDeviceIds`. */
16088
+ authority: string(),
16089
+ activation: ExtensionSlotActivationSchema.nullable(),
16090
+ value: ExtensionSlotValueSchema,
16091
+ sources: array(ExtensionSlotSourceSchema),
16092
+ /**
16093
+ * Devices the owner links to the host ON ITS OWN, by structure, and that
16094
+ * are therefore not in `value` (D655): a camera's device-tree children, and
16095
+ * the child a picked container stands for (D356 — a container is never a
16096
+ * pick, its children are). Read-only; the editor shows them and may offer
16097
+ * per-device options on them (the linked-devices tracked-event opt-in).
16098
+ * Absent when the owner links nothing beyond the picks, and from an owner
16099
+ * older than D655.
16100
+ */
16101
+ impliedSources: array(ExtensionSlotSourceSchema).optional()
16102
+ }), object({
16103
+ state: literal("unreachable"),
16104
+ addonId: string(),
16105
+ reason: string()
16106
+ })]);
16107
+ var ExtensionCandidatesSchema = object({ candidates: array(object({
16108
+ deviceId: number().int(),
16109
+ name: string(),
16110
+ type: string(),
16111
+ location: string().nullable(),
16112
+ /** The container a child belongs to — "Spotlight 2" alone does not say which. */
16113
+ parentName: string().nullable(),
16114
+ /** Pre-marked by the owner's suggestion rule. NEVER saved on its own (D356). */
16115
+ suggested: boolean(),
16116
+ /** Why it is suggested ("same location"), null when it is not. */
16117
+ reason: string().nullable()
16118
+ })) });
16119
+ /**
16120
+ * What a write did. `none` — applied in place. `host` / `parent` — the owner
16121
+ * reloaded the host (or, for an accessory child, its parent) because the
16122
+ * write changed what the host REGISTERS. A slot never adds a capability to its
16123
+ * host — that is a composition (D663) — so today's owners answer `none`.
16124
+ */
16125
+ var ExtensionSetResultSchema = object({
16126
+ applied: literal(true),
16127
+ reload: _enum([
16128
+ "none",
16129
+ "host",
16130
+ "parent"
16131
+ ])
16132
+ });
16133
+ var ExtensionSlotRefInputSchema = object({
16134
+ deviceId: number().int(),
16135
+ slotRef: string().min(1)
16136
+ });
16137
+ var ExtensionSetSlotInputSchema = ExtensionSlotRefInputSchema.extend({ value: ExtensionSlotValueSchema });
16138
+ method(object({ deviceId: number().int() }), array(ExtensionSourceSchema)), method(object({ deviceId: number().int() }), array(ExtensionSlotRowSchema)), method(ExtensionSlotRefInputSchema, ExtensionCandidatesSchema), method(ExtensionSetSlotInputSchema, ExtensionSetResultSchema, {
16139
+ kind: "mutation",
16140
+ auth: "admin"
16141
+ });
15954
16142
  /**
15955
16143
  * Per-field ownership (D663). A composition may CLAIM fields of a native
15956
16144
  * cap's runtime-state slice on an existing device: `replace` overlays the
@@ -18980,17 +19168,25 @@ var NcScheduleSchema = object({
18980
19168
  */
18981
19169
  var NcSystemEventDeliveryModeSchema = _enum(["instant", "summary"]);
18982
19170
  /**
19171
+ * How a summary window is SENT (D698): `rule` (absent) = ONE notification with
19172
+ * every section; `section` = one notification per section with something to
19173
+ * say (an unavailable section included), each titled by its section.
19174
+ */
19175
+ var NcStateSummarySplitSchema = _enum(["rule", "section"]);
19176
+ /**
18983
19177
  * `summary`: the rule sends NOTHING per event. When a window of `schedule`
18984
19178
  * CLOSES, it sends one notification with the current state of its kinds
18985
19179
  * (low batteries, consumables to replace, devices offline, updates
18986
- * available, ...), after its own filters. Nothing to report sends nothing.
19180
+ * available, ...), after its own filters — or, with `split: 'section'`
19181
+ * (D698), one notification per section. Nothing to report sends nothing.
18987
19182
  * The schedule is the ordinary `NcSchedule` (weekly windows, IANA timezone,
18988
19183
  * midnight crossing); the send time is each window's END. Refused on the
18989
19184
  * `alarm` family, which stays instant (`systemEventDeliveryProblems`).
18990
19185
  */
18991
19186
  var NcSystemEventDeliverySchema = discriminatedUnion("mode", [object({ mode: literal("instant") }), object({
18992
19187
  mode: literal("summary"),
18993
- schedule: NcScheduleSchema
19188
+ schedule: NcScheduleSchema,
19189
+ split: NcStateSummarySplitSchema.optional()
18994
19190
  })]);
18995
19191
  /** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
18996
19192
  var NcPlateMatcherSchema = object({
@@ -19130,8 +19326,14 @@ var NcSensorTransitionSchema = _enum(["raised", "cleared"]);
19130
19326
  /** Admin-zone membership condition (zone IDs as stamped by the ZoneEngine). */
19131
19327
  var NcZoneConditionSchema = object({
19132
19328
  ids: array(string().min(1)).min(1),
19133
- /** Quantifier over `ids` — at least one / every one visited. */
19134
- match: _enum(["any", "all"]).default("any")
19329
+ /**
19330
+ * LEGACY quantifier over `ids`. Absent = `any` (at least one visited), which
19331
+ * is what both editors mean and all they write since D690: "all of" was
19332
+ * removed from the editors because on an immediate rule it asked one
19333
+ * detection to stand in every zone at once. Still ACCEPTED, and `all` still
19334
+ * evaluated, so a stored rule keeps parsing and meaning what it meant.
19335
+ */
19336
+ match: _enum(["any", "all"]).optional()
19135
19337
  });
19136
19338
  /**
19137
19339
  * The P1 condition set — a flat AND of groups; absent group = pass;
@@ -19635,10 +19837,12 @@ var NcMediaPolicySchema = object({
19635
19837
  /**
19636
19838
  * Cooldown GRANULARITY over the subject's class — how much a fired
19637
19839
  * notification suppresses.
19638
- * - `shared` (default, and the absent value) — one window for the whole
19639
- * rule/scope: a cat silences the next dog for `cooldownSec`.
19640
- * - `per-class` — an independent window per detected class, so cat→dog fires
19641
- * at once and cat→cat still waits.
19840
+ * - `per-class` (default, and the absent value since 2026-10-01 — D36) — an
19841
+ * independent window per detected class: cat→dog fires at once, cat→cat
19842
+ * still waits.
19843
+ * - `shared` — one window for the whole rule/scope: a cat silences the next
19844
+ * dog for `cooldownSec`. Only written when an operator picks it; it is no
19845
+ * longer what an unset rule means.
19642
19846
  *
19643
19847
  * AUDIO subjects are ALWAYS per-class regardless of this setting: a scream
19644
19848
  * must not be swallowed by a bark's window (the precedent this generalizes —
@@ -19653,8 +19857,11 @@ var NcThrottleSchema = object({
19653
19857
  /**
19654
19858
  * Class granularity of the cooldown key. Optional rather than defaulted:
19655
19859
  * a Zod default does NOT run on the addon→addon cap path, so a persisted
19656
- * rule authored before this field simply carries none — and the engine
19657
- * reads absent as `shared`, the pre-existing behaviour.
19860
+ * rule authored before this field simply carries none. The engine used to
19861
+ * read absent as `shared` (D36); since 2026-10-01 it reads absent as
19862
+ * `per-class` — the operator's default — and only an explicit `shared`
19863
+ * still means `shared`. See `cooldownKey` / `keysPerClass` in the rule
19864
+ * engine, and D36's dated note.
19658
19865
  */
19659
19866
  granularity: NcThrottleGranularitySchema.optional()
19660
19867
  });
@@ -19978,11 +20185,23 @@ var NcStateSummaryPreviewSectionSchema = object({
19978
20185
  reason: string().optional()
19979
20186
  });
19980
20187
  /**
20188
+ * One notification a previewed summary would send (D698): the whole summary on
20189
+ * a `rule` split (no `section`), one section's on a `section` split.
20190
+ */
20191
+ var NcStateSummaryPreviewRowSchema = object({
20192
+ section: string().optional(),
20193
+ /** The section's name on a per-section row; every reported section's, joined, on a combined one. */
20194
+ title: string(),
20195
+ text: string(),
20196
+ count: number().int().nonnegative()
20197
+ });
20198
+ /**
19981
20199
  * The summary a rule would send now. `empty` = nothing to report and every
19982
20200
  * section read: such a summary is NOT sent. `dropped` counts the open states
19983
20201
  * the rule's own filters (or a camera mute) left out, by reason.
19984
20202
  * `excludedGroups` names the kind groups selected that have no state to report
19985
- * (backups & exports).
20203
+ * (backups & exports). `split` and `rows` (D698) say how it would be sent —
20204
+ * optional, so an older hub's answer still parses.
19986
20205
  */
19987
20206
  var NcStateSummaryPreviewSchema = object({
19988
20207
  empty: boolean(),
@@ -19990,7 +20209,9 @@ var NcStateSummaryPreviewSchema = object({
19990
20209
  text: string(),
19991
20210
  sections: array(NcStateSummaryPreviewSectionSchema),
19992
20211
  dropped: record(string(), number().int().nonnegative()),
19993
- excludedGroups: array(string())
20212
+ excludedGroups: array(string()),
20213
+ split: NcStateSummarySplitSchema.optional(),
20214
+ rows: array(NcStateSummaryPreviewRowSchema).optional()
19994
20215
  });
19995
20216
  var NcTestResultSchema = object({
19996
20217
  recordId: string(),
@@ -21004,12 +21225,26 @@ var CameraSensorRefSchema = object({
21004
21225
  function cameraSensorRefKey(ref) {
21005
21226
  return `${ref.addonId}/${ref.stableId}`;
21006
21227
  }
21007
- /** CS-1 accepts exactly one mode; CS-2 (D673) widens it to confirm / replace. */
21008
- var CameraSensorsModeSchema = _enum(["in-addition"]);
21009
- var CameraSensorsConfigSchema = object({
21010
- mode: CameraSensorsModeSchema,
21011
- sensors: array(CameraSensorRefSchema).min(1).max(8)
21012
- }).superRefine((value, ctx) => {
21228
+ /**
21229
+ * A sensor's mode (D673). `in-addition`: its motion is the camera's motion too.
21230
+ * `replace`: its motion is the camera's, and while one is READY the camera's
21231
+ * own motion no longer counts on its own. `confirm`: while one is READY the
21232
+ * camera's own motion counts only while a confirm sensor is active — with or
21233
+ * without a replace sensor (spec C2, the controller's ruling on Q1).
21234
+ */
21235
+ var CameraSensorModeSchema = _enum([
21236
+ "in-addition",
21237
+ "confirm",
21238
+ "replace"
21239
+ ]);
21240
+ /** A stored sensor with no mode — every CS-1 row — is in addition. */
21241
+ var DEFAULT_CAMERA_SENSOR_MODE = "in-addition";
21242
+ /**
21243
+ * A camera's attached sensors. A CS-1 row carried an envelope
21244
+ * `mode: 'in-addition'`: `z.object` drops it on parse, and the PARSED value is
21245
+ * what the write stores (D672 rule 3), so it is never written again.
21246
+ */
21247
+ var CameraSensorsConfigSchema = object({ sensors: array(CameraSensorRefSchema.extend({ mode: CameraSensorModeSchema.default(DEFAULT_CAMERA_SENSOR_MODE) })).min(1).max(8) }).superRefine((value, ctx) => {
21013
21248
  const seen = /* @__PURE__ */ new Set();
21014
21249
  value.sensors.forEach((ref, index) => {
21015
21250
  const key = cameraSensorRefKey(ref);
@@ -21021,39 +21256,41 @@ var CameraSensorsConfigSchema = object({
21021
21256
  seen.add(key);
21022
21257
  });
21023
21258
  });
21024
- var RefFields = {
21259
+ /** Every attachment names its mode; an older orchestrator that does not is in addition. */
21260
+ var AttachmentFields = {
21025
21261
  addonId: string(),
21026
- stableId: string()
21262
+ stableId: string(),
21263
+ mode: CameraSensorModeSchema.default(DEFAULT_CAMERA_SENSOR_MODE)
21027
21264
  };
21028
21265
  var CameraSensorAttachmentSchema = discriminatedUnion("state", [
21029
21266
  object({
21030
- ...RefFields,
21267
+ ...AttachmentFields,
21031
21268
  state: literal("ready"),
21032
21269
  deviceId: number(),
21033
21270
  name: string(),
21034
21271
  caps: array(string()).readonly()
21035
21272
  }),
21036
21273
  object({
21037
- ...RefFields,
21274
+ ...AttachmentFields,
21038
21275
  state: literal("offline"),
21039
21276
  deviceId: number(),
21040
21277
  name: string(),
21041
21278
  reason: _enum(["offline", "disabled"])
21042
21279
  }),
21043
21280
  object({
21044
- ...RefFields,
21281
+ ...AttachmentFields,
21045
21282
  state: literal("missing"),
21046
21283
  reason: string()
21047
21284
  }),
21048
21285
  object({
21049
- ...RefFields,
21286
+ ...AttachmentFields,
21050
21287
  state: literal("unsupported"),
21051
21288
  deviceId: number(),
21052
21289
  name: string(),
21053
21290
  reason: string()
21054
21291
  }),
21055
21292
  object({
21056
- ...RefFields,
21293
+ ...AttachmentFields,
21057
21294
  state: literal("unreadable"),
21058
21295
  reason: string()
21059
21296
  })
@@ -21066,17 +21303,49 @@ var CameraSensorAttachmentSchema = discriminatedUnion("state", [
21066
21303
  * say.
21067
21304
  */
21068
21305
  var CameraSensorsNotForwardedSchema = _enum(["onboard-not-listed", "no-active-detection"]);
21306
+ /** Whether the camera's OWN motion counts on its own (D673 C2), from its READY sensors (C3). */
21307
+ var CameraOwnMotionSchema = _enum([
21308
+ "always",
21309
+ "when-confirmed",
21310
+ "never"
21311
+ ]);
21312
+ /** Confirm / Replace cannot suppress this camera's motion: its provider still emits it directly (D673 C13). */
21313
+ var CameraSensorsNotEnforcedSchema = _enum(["provider-not-split"]);
21314
+ /**
21315
+ * The camera's OWN onboard motion (D696): the raw input the bridge combines,
21316
+ * never the effective value. The camera's `motion` slice is the effective one,
21317
+ * so a view of the camera's own row reads this.
21318
+ * - `atMs`: when the bridge received the camera's last own edge.
21319
+ * - `detected`: evaluated WHEN THE STATUS IS ASKED — the last edge said `true`
21320
+ * AND it is younger than the window the bridge counts the camera's own motion
21321
+ * for (`motionCooldownMs`, floored at two sustain ticks). A camera that never
21322
+ * sends a clear (heartbeats only) therefore reads `false` once no push came
21323
+ * within the window; a status read is a snapshot, so a live view re-asks.
21324
+ * Absent = this orchestrator has not received the camera's own motion since it
21325
+ * started (unknown, never "quiet"), or an orchestrator older than D696.
21326
+ */
21327
+ var CameraRawLevelSchema = object({
21328
+ detected: boolean(),
21329
+ atMs: number()
21330
+ });
21069
21331
  var CameraSensorsStatusSchema = discriminatedUnion("state", [
21070
- object({ state: literal("not-configured") }),
21332
+ object({
21333
+ state: literal("not-configured"),
21334
+ cameraLevel: CameraRawLevelSchema.optional()
21335
+ }),
21071
21336
  object({
21072
21337
  state: literal("unreadable"),
21073
- reason: string()
21338
+ reason: string(),
21339
+ cameraLevel: CameraRawLevelSchema.optional()
21074
21340
  }),
21075
21341
  object({
21076
21342
  state: literal("configured"),
21077
- mode: CameraSensorsModeSchema,
21343
+ cameraLevel: CameraRawLevelSchema.optional(),
21078
21344
  sensors: array(CameraSensorAttachmentSchema).readonly(),
21079
- notForwarded: CameraSensorsNotForwardedSchema.optional()
21345
+ /** Absent = an orchestrator older than CS-2: it does not say (D315). */
21346
+ cameraMotion: CameraOwnMotionSchema.optional(),
21347
+ notForwarded: CameraSensorsNotForwardedSchema.optional(),
21348
+ notEnforced: CameraSensorsNotEnforcedSchema.optional()
21080
21349
  })
21081
21350
  ]);
21082
21351
  Object.freeze({
@@ -22911,7 +23180,8 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
22911
23180
  trackIds: array(string()).min(1)
22912
23181
  }), object({
22913
23182
  deleted: number().int(),
22914
- failed: array(string()).readonly()
23183
+ failed: array(string()).readonly(),
23184
+ sparedMediaIds: array(number().int()).readonly().optional()
22915
23185
  }), {
22916
23186
  kind: "mutation",
22917
23187
  auth: "admin"
@@ -24306,8 +24576,10 @@ var RunnerCameraConfigSchema = object({
24306
24576
  * - `analyzer`: ML/frame-diff motion detection (motion-wasm or other
24307
24577
  * analyzer providers) running on decoded frames in this runner.
24308
24578
  * - `onboard`: camera-native motion pushes (Reolink Baichuan, ONVIF
24309
- * analytics). The provider emits ProviderMotion
24310
- * events; the orchestrator forwards to `reportMotion`.
24579
+ * analytics). The provider emits its raw push as `ProviderMotion`
24580
+ * (D673); the orchestrator's camera-sensors bridge re-emits the camera's
24581
+ * effective motion as `MotionOnMotionChanged`, which is what reaches
24582
+ * `reportMotion`.
24311
24583
  */
24312
24584
  motionSources: MotionSourcesSchema.default(["analyzer"]),
24313
24585
  /**
@@ -24484,7 +24756,15 @@ var RunnerLocalLoadSchema = object({
24484
24756
  hasGpu: boolean(),
24485
24757
  inferenceBackend: string().optional(),
24486
24758
  cpuCores: number().optional()
24487
- })
24759
+ }),
24760
+ /**
24761
+ * Who writes a camera's `motion` runtime slice (D696). `'orchestrator'`: this
24762
+ * runner never writes it. ABSENT = a runner older than D696, which still
24763
+ * writes the slice from its phase machine; the orchestrator does not write
24764
+ * while any runner node is absent-or-unanswered, so one slice never has two
24765
+ * writers.
24766
+ */
24767
+ motionSliceWriter: literal("orchestrator").optional()
24488
24768
  });
24489
24769
  /**
24490
24770
  * Aggregate runtime metrics for the runner's whole local pool. Mirrors the
@@ -25140,7 +25420,42 @@ var SetCameraSensorsInputSchema = object({
25140
25420
  /** `null` removes the attachment: the camera goes back to `not-configured`. */
25141
25421
  config: CameraSensorsConfigSchema.nullable()
25142
25422
  });
25143
- method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
25423
+ /**
25424
+ * Why an early occupancy look (D691) was not scheduled.
25425
+ *
25426
+ * - `unknown-camera` — no session was ever dispatched for it, so there is no
25427
+ * node and no config to attach a burst with.
25428
+ * - `out-of-range` — the ask is negative or further out than the orchestrator
25429
+ * will hold a timer for; the parked-object cadence is the answer there.
25430
+ * - `no-burst-producer` — this build has no burst producer at all.
25431
+ * - `already-looked` — this camera's ONE early look since its last session has
25432
+ * been spent. A look's own burst can re-arm a flickering flip, and a look
25433
+ * per arm would chain a burst every ~30 s forever (review H2); the next
25434
+ * real session re-arms the budget.
25435
+ */
25436
+ var OccupancyLookRefusalSchema = _enum([
25437
+ "unknown-camera",
25438
+ "out-of-range",
25439
+ "no-burst-producer",
25440
+ "already-looked"
25441
+ ]);
25442
+ method(object({
25443
+ deviceId: number().int().nonnegative(),
25444
+ /** How long from NOW until the pending flip's sustain window ends. RELATIVE,
25445
+ * so the caller's clock and the orchestrator's never have to agree. */
25446
+ afterMs: number().finite(),
25447
+ /** Why, for the log. */
25448
+ reason: string()
25449
+ }), object({
25450
+ scheduled: boolean(),
25451
+ /** When `scheduled`: how long until the burst is dialled. */
25452
+ dueInMs: number().optional(),
25453
+ /** When not `scheduled`: why. */
25454
+ refusedBecause: OccupancyLookRefusalSchema.optional()
25455
+ }), {
25456
+ kind: "mutation",
25457
+ auth: "admin"
25458
+ }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
25144
25459
  kind: "mutation",
25145
25460
  auth: "admin"
25146
25461
  }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
@@ -28025,219 +28340,6 @@ var CLIP_PLAYBACK_OPTIONS = {
28025
28340
  }
28026
28341
  };
28027
28342
  /**
28028
- * Doorbell button cap. Two kinds of providers coexist behind this cap
28029
- * name (same pattern as `snapshot`):
28030
- *
28031
- * - **Native** providers: registered per-device by device-driver
28032
- * addons via `ctx.registerNativeCap` — either on a
28033
- * `DeviceType.Button` accessory with `role: DeviceRole.Doorbell`,
28034
- * or directly on the camera (Reolink registers at camera level).
28035
- * Emits an `onPressed` event every time the firmware pushes a
28036
- * ring; status tracks the last press and a pressCount since start
28037
- * (diagnostic).
28038
- *
28039
- * - **Wrapper** provider: the `virtual-doorbell` system builtin
28040
- * (`@camstack/system/builtins/doorbell`). Turns ANY binary-ish
28041
- * device (contact / switch / event-emitter …) into a doorbell for
28042
- * a camera. `defaultActive: false` — the operator explicitly binds
28043
- * it per camera in the device-bindings UI, then picks the source
28044
- * device + trigger in the per-device settings.
28045
- *
28046
- * The DeviceEventPropagator re-emits `onPressed` on the camera parent
28047
- * — subscribers listening at the camera level receive ring events
28048
- * with `via[]` populated. No code on the parent needed.
28049
- */
28050
- var DoorbellStatusSchema = object({
28051
- /** Ms epoch of the last press. null = never observed since this provider started. */
28052
- lastPressedAt: number().nullable(),
28053
- /** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
28054
- pressCountSinceStart: number()
28055
- });
28056
- var DoorbellPressEventSchema = object({
28057
- deviceId: number(),
28058
- timestamp: number()
28059
- });
28060
- /**
28061
- * The `doorbell-source` extension slot's editable value (D648): the camera's
28062
- * virtual-doorbell trigger devices, exactly what the wrapper's
28063
- * `doorbellSources` persists (as `{ deviceId }` records).
28064
- */
28065
- var DoorbellSourceSlotValueSchema = object({ deviceIds: array(number().int().positive()) });
28066
- /**
28067
- * The `doorbell-source` slot — which devices ring this camera's VIRTUAL
28068
- * doorbell, owned by the `virtual-doorbell` wrapper over its
28069
- * `doorbellSources` store (D648). A source rings when one of its
28070
- * `SOURCE_CAPS` rises. Whether the wrapper is bound to the camera at all is a
28071
- * different authority (`deviceManager.setWrapperActive`, D62) — the slot
28072
- * reports it, it never writes it.
28073
- */
28074
- var DOORBELL_SOURCE_SLOT = {
28075
- id: "doorbell-source",
28076
- label: "Doorbell trigger devices",
28077
- 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.",
28078
- shape: "association",
28079
- hostDeviceTypes: [DeviceType.Camera],
28080
- sourceCaps: SOURCE_CAPS,
28081
- cardinality: "many",
28082
- value: DoorbellSourceSlotValueSchema
28083
- };
28084
- var doorbellCapability = {
28085
- name: "doorbell",
28086
- scope: "device",
28087
- deviceNative: true,
28088
- mode: "singleton",
28089
- kind: "wrapper",
28090
- defaultActive: false,
28091
- deviceTypes: [DeviceType.Button, DeviceType.Camera],
28092
- extensionSlots: [DOORBELL_SOURCE_SLOT],
28093
- methods: {},
28094
- events: {
28095
- /**
28096
- * Fires once per physical press. Reolink delivers via Baichuan
28097
- * push (`ReolinkSimpleEvent.type === 'doorbell'`). There is no
28098
- * release/duration — it's a pulse.
28099
- */
28100
- onPressed: {
28101
- data: DoorbellPressEventSchema,
28102
- fromState: {
28103
- field: "lastPressedAt",
28104
- on: "advance"
28105
- }
28106
- } },
28107
- status: {
28108
- schema: DoorbellStatusSchema,
28109
- kind: "push"
28110
- },
28111
- /**
28112
- * Runtime-state slice — last press timestamp + lifetime press count.
28113
- * Mirrored by the kernel and readable via
28114
- * `device.state.doorbell.value`. UIs can show "last ring 5m ago"
28115
- * without subscribing.
28116
- */
28117
- runtimeState: DoorbellStatusSchema,
28118
- /**
28119
- * 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.
28120
- *
28121
- * See `RuntimeStateDurability`. Enforced by
28122
- * `scripts/check-runtime-state-durability.ts`.
28123
- */
28124
- durability: "restored"
28125
- };
28126
- var ExtensionSlotIdSchema = _enum(["doorbell-source", "linked-devices"]);
28127
- DeviceType.Camera, DeviceType.Camera;
28128
- /** A slot's editable value, discriminated on `slot`. */
28129
- var ExtensionSlotValueSchema = discriminatedUnion("slot", [DoorbellSourceSlotValueSchema.extend({ slot: literal("doorbell-source") }), LinkedDevicesSlotValueSchema.extend({ slot: literal("linked-devices") })]);
28130
- DeviceType.Camera;
28131
- var ExtensionSourceAvailabilitySchema = discriminatedUnion("state", [object({ state: literal("ok") }), object({
28132
- state: literal("unreachable"),
28133
- reason: string()
28134
- })]);
28135
- /** One provider of slots — the D554 source-listing row. */
28136
- var ExtensionSourceSchema = object({
28137
- /** The routing prefix of every `slotRef` this provider serves. */
28138
- source: string(),
28139
- label: string(),
28140
- /** Stamped by the dispatcher from the registry (D557). */
28141
- addonId: string().optional(),
28142
- availability: ExtensionSourceAvailabilitySchema
28143
- });
28144
- /**
28145
- * How one picked source stands. `missing` — no such device (deleted, or an id
28146
- * that never existed); `foreign` — a device the slot's owner cannot read from
28147
- * (a source owned by another addon); `unavailable` — it exists but is not a
28148
- * valid source now (a container, which is never a pick). A source in any of
28149
- * these states is SHOWN, never silently dropped or re-pointed.
28150
- */
28151
- var ExtensionSourceHealthSchema = _enum([
28152
- "ok",
28153
- "missing",
28154
- "foreign",
28155
- "unavailable"
28156
- ]);
28157
- var ExtensionSlotSourceSchema = object({
28158
- deviceId: number().int(),
28159
- /** The device's name, or null when it could not be resolved (`missing`). */
28160
- name: string().nullable(),
28161
- health: ExtensionSourceHealthSchema,
28162
- detail: string().optional()
28163
- });
28164
- /**
28165
- * A DIFFERENT authority that gates whether the slot's sources do anything —
28166
- * reported read-only, named, never written through this contract (D62). The
28167
- * virtual doorbell's sources ring only while the wrapper is bound to the
28168
- * camera, and that binding belongs to `deviceManager.setWrapperActive`.
28169
- * `unknown` means the gate could not be read; it is not "inactive" (D315).
28170
- */
28171
- var ExtensionSlotActivationSchema = object({
28172
- state: _enum([
28173
- "active",
28174
- "inactive",
28175
- "unknown"
28176
- ]),
28177
- authority: string(),
28178
- detail: string().optional()
28179
- });
28180
- var ExtensionSlotRowSchema = discriminatedUnion("state", [object({
28181
- state: literal("ok"),
28182
- /** `<source>:<slotId>` — the routing key for `listCandidates` / `setSlot`. */
28183
- slotRef: string(),
28184
- slot: ExtensionSlotIdSchema,
28185
- /** Names the store written (D62), e.g. `virtual-doorbell:doorbellSources`. */
28186
- authority: string(),
28187
- activation: ExtensionSlotActivationSchema.nullable(),
28188
- value: ExtensionSlotValueSchema,
28189
- sources: array(ExtensionSlotSourceSchema),
28190
- /**
28191
- * Devices the owner links to the host ON ITS OWN, by structure, and that
28192
- * are therefore not in `value` (D655): a camera's device-tree children, and
28193
- * the child a picked container stands for (D356 — a container is never a
28194
- * pick, its children are). Read-only; the editor shows them and may offer
28195
- * per-device options on them (the linked-devices tracked-event opt-in).
28196
- * Absent when the owner links nothing beyond the picks, and from an owner
28197
- * older than D655.
28198
- */
28199
- impliedSources: array(ExtensionSlotSourceSchema).optional()
28200
- }), object({
28201
- state: literal("unreachable"),
28202
- addonId: string(),
28203
- reason: string()
28204
- })]);
28205
- var ExtensionCandidatesSchema = object({ candidates: array(object({
28206
- deviceId: number().int(),
28207
- name: string(),
28208
- type: string(),
28209
- location: string().nullable(),
28210
- /** The container a child belongs to — "Spotlight 2" alone does not say which. */
28211
- parentName: string().nullable(),
28212
- /** Pre-marked by the owner's suggestion rule. NEVER saved on its own (D356). */
28213
- suggested: boolean(),
28214
- /** Why it is suggested ("same location"), null when it is not. */
28215
- reason: string().nullable()
28216
- })) });
28217
- /**
28218
- * What a write did. `none` — applied in place. `host` / `parent` — the owner
28219
- * reloaded the host (or, for an accessory child, its parent) because the
28220
- * write changed what the host REGISTERS. A slot never adds a capability to its
28221
- * host — that is a composition (D663) — so today's owners answer `none`.
28222
- */
28223
- var ExtensionSetResultSchema = object({
28224
- applied: literal(true),
28225
- reload: _enum([
28226
- "none",
28227
- "host",
28228
- "parent"
28229
- ])
28230
- });
28231
- var ExtensionSlotRefInputSchema = object({
28232
- deviceId: number().int(),
28233
- slotRef: string().min(1)
28234
- });
28235
- var ExtensionSetSlotInputSchema = ExtensionSlotRefInputSchema.extend({ value: ExtensionSlotValueSchema });
28236
- method(object({ deviceId: number().int() }), array(ExtensionSourceSchema)), method(object({ deviceId: number().int() }), array(ExtensionSlotRowSchema)), method(ExtensionSlotRefInputSchema, ExtensionCandidatesSchema), method(ExtensionSetSlotInputSchema, ExtensionSetResultSchema, {
28237
- kind: "mutation",
28238
- auth: "admin"
28239
- });
28240
- /**
28241
28343
  * Optional client-side hints sent at session creation to help the provider
28242
28344
  * pick the best native source. All fields optional — a viewer that knows
28243
28345
  * nothing still gets a sane default. (Relocated from the retired `webrtc`
@@ -30705,6 +30807,70 @@ onStatusChanged: { data: object({
30705
30807
  * whether persisting is worth a SQLite commit. */
30706
30808
  volatileStateFields: ["lastChangedAt"]
30707
30809
  };
30810
+ var DoorbellStatusSchema = object({
30811
+ /** Ms epoch of the last press. null = never observed since this provider started. */
30812
+ lastPressedAt: number().nullable(),
30813
+ /** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
30814
+ pressCountSinceStart: number()
30815
+ });
30816
+ var DoorbellPressEventSchema = object({
30817
+ deviceId: number(),
30818
+ timestamp: number()
30819
+ });
30820
+ /**
30821
+ * Doorbell button cap. Two kinds of provider serve it, and to every consumer
30822
+ * they are the same cap:
30823
+ *
30824
+ * - **Native** providers, registered per device by a driver addon through
30825
+ * `ctx.registerNativeCap` — a `DeviceType.Button` accessory with
30826
+ * `role: DeviceRole.Doorbell`, or the camera itself (Reolink registers at
30827
+ * camera level). They emit `onPressed` on every firmware ring.
30828
+ * - **A composed doorbell** (D670, D671): a camera's customization gives it
30829
+ * the cap, its `lastPressedAt` rising from the sources the operator
30830
+ * assigned in Customize → Doorbell, and the composer emits `onPressed`
30831
+ * from that field's advance (`fromState`).
30832
+ *
30833
+ * The DeviceEventPropagator re-emits `onPressed` on the camera parent.
30834
+ */
30835
+ var doorbellCapability = {
30836
+ name: "doorbell",
30837
+ scope: "device",
30838
+ deviceNative: true,
30839
+ mode: "singleton",
30840
+ deviceTypes: [DeviceType.Button, DeviceType.Camera],
30841
+ methods: {},
30842
+ events: {
30843
+ /**
30844
+ * Fires once per physical press. Reolink delivers via Baichuan
30845
+ * push (`ReolinkSimpleEvent.type === 'doorbell'`). There is no
30846
+ * release/duration — it's a pulse.
30847
+ */
30848
+ onPressed: {
30849
+ data: DoorbellPressEventSchema,
30850
+ fromState: {
30851
+ field: "lastPressedAt",
30852
+ on: "advance"
30853
+ }
30854
+ } },
30855
+ status: {
30856
+ schema: DoorbellStatusSchema,
30857
+ kind: "push"
30858
+ },
30859
+ /**
30860
+ * Runtime-state slice — last press timestamp + lifetime press count.
30861
+ * Mirrored by the kernel and readable via
30862
+ * `device.state.doorbell.value`. UIs can show "last ring 5m ago"
30863
+ * without subscribing.
30864
+ */
30865
+ runtimeState: DoorbellStatusSchema,
30866
+ /**
30867
+ * 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.
30868
+ *
30869
+ * See `RuntimeStateDurability`. Enforced by
30870
+ * `scripts/check-runtime-state-durability.ts`.
30871
+ */
30872
+ durability: "restored"
30873
+ };
30708
30874
  /**
30709
30875
  * Enum-state sensor — a string value picked from a finite option set.
30710
30876
  * Drives HA `sensor` entries with `state_class: enum` (HVAC action
@@ -32844,39 +33010,14 @@ authKey: string().optional() }), object({
32844
33010
  /** Human-readable error when `ok: false`. */
32845
33011
  error: string().optional()
32846
33012
  }), { kind: "mutation" });
32847
- /**
32848
- * Hardware / firmware motion sensor cap — binary detected state plus
32849
- * a timestamp of the last observation. Distinct from
32850
- * `motion-detection.cap.ts` which owns the LOCAL ML motion pipeline;
32851
- * `motion` is the lightweight readout from on-camera motion (Reolink
32852
- * `GetMdState`, Baichuan push `type: motion`, ONVIF analytics).
32853
- *
32854
- * Native-motion providers also fan out to `detection.camera-native`
32855
- * with `source: 'onboard'` so cross-cutting system services
32856
- * (alert-center, advanced-notifier) can subscribe once and receive
32857
- * motion from every camera.
32858
- */
32859
- /**
32860
- * How long after a camera's last rising edge `pipeline-analytics` closes the
32861
- * motion EPISODE row it kept open for it (D475) — "il delay della cap", in
32862
- * the operator's words. One authority for the whole system: every provider
32863
- * that seeds `autoClearAfterMs` on a `Camera` device writes this SAME
32864
- * constant while `detected: true` (never its own number — Hikvision used to
32865
- * seed its internal 3 s inactivity timer here, which is a different clock for
32866
- * a different purpose), and `MotionEpisodeTracker` imports it directly rather
32867
- * than reading the live cap value on the hot path. A `Sensor` device (HA
32868
- * binary sensor, Homematic) gets a genuine push both ways and has no episode
32869
- * to close on a timer, so it writes `null`, never this constant.
32870
- */
32871
- var MOTION_CLOSE_AFTER_MS = 15e3;
32872
33013
  var MotionStatusSchema = object({
32873
33014
  detected: boolean(),
32874
33015
  /** Ms epoch of the last detected-true observation. Null if never detected. */
32875
33016
  lastDetectedAt: number().nullable(),
32876
33017
  /**
32877
- * `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
32878
- * `null` while false and on every `Sensor` device (D475) — see that
32879
- * constant's doc for the one-authority rule.
33018
+ * `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device (the
33019
+ * orchestrator writes it, D696), `null` while false and on every `Sensor`
33020
+ * device (D475) — see that constant's doc for the one-authority rule.
32880
33021
  *
32881
33022
  * ## Reading this field still arms nothing
32882
33023
  *
@@ -32894,34 +33035,31 @@ var MotionStatusSchema = object({
32894
33035
  * `addon-export-alexa/src/motion-clear-hold.ts` and
32895
33036
  * `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
32896
33037
  *
32897
- * ## Who writes it
32898
- *
32899
- * - **Cameras** — the runner's phase machine, `active → watching` on
32900
- * `cooldown_expired`, which then writes this slice with
32901
- * `detected: false` (`handlePhaseChanged` in
32902
- * `pipeline-runner/index.ts`). It produces the FALLING edge, which
32903
- * matters most for the sources that only ever push a rising one:
32904
- * Reolink emits `MotionOnMotionChanged { detected: true }` and never
32905
- * a false.
32906
- * - **Sensors** (Home Assistant binary sensors, Homematic) — the
32907
- * provider pushes the false itself, from the upstream system's own
32908
- * state change. No phase machine is involved.
32909
- *
32910
- * ### The phase machine is CANONICAL, not sole — and that is a defect
32911
- *
32912
- * An earlier revision of this docblock (mine, 2026-09-12) claimed the
32913
- * phase machine is the sole writer for a camera. It is not.
32914
- * `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
32915
- * `setCapSlice(motionCapability, …)` on their own rising edge, and
32916
- * Hikvision's comment says why: it read THIS docblock, agreed the
32917
- * runner is canonical, and wrote anyway to avoid per-tick churn. So
32918
- * two authorities can disagree about one slice, which this repo
32919
- * forbids, and the doc said otherwise — which is worse than saying
32920
- * nothing, because it reads as verification.
32921
- *
32922
- * This predates D475 and is not fixed there: the fix touches every
32923
- * camera provider. Recorded in D475's Consequences. Do not restore the
32924
- * "sole writer" wording without also removing the other writers.
33038
+ * ## Who writes it (D696)
33039
+ *
33040
+ * - **Cameras** — the orchestrator, and nothing else. It writes the camera's
33041
+ * EFFECTIVE motion (`addon-pipeline-orchestrator`
33042
+ * `camera-sensors/motion-slice.ts`), alongside the effective
33043
+ * `MotionOnMotionChanged` it emits or receives: the camera-sensors bridge
33044
+ * for a split camera, an unsplit emitter's direct event, the analyzer and
33045
+ * device activity, as the camera's `motionSources` counts them. A source
33046
+ * that never sends a clear falls one window after its last `true`.
33047
+ * `lastDetectedAt` moves only on an effective rise. No camera provider
33048
+ * writes this slice (not even a boot seed), and neither does the runner's
33049
+ * phase machine: its phase is "a session is attached" for every on-motion
33050
+ * session, not motion, and it now has its own `DetectionPhaseTransition`.
33051
+ * A provider's `isDetected` answers from the hub's slice.
33052
+ * - **Sensors** (Home Assistant binary sensors, Homematic, Matter, Alexa
33053
+ * imports) — the provider pushes both edges itself, from the upstream
33054
+ * system's own state change. That is the sensor's own fact.
33055
+ *
33056
+ * `scripts/check-onboard-motion-emitters.ts` refuses any other writer of a
33057
+ * `motion` slice; each sensor writer is a named exemption.
33058
+ *
33059
+ * This replaces the D475 §4 rule ("the phase machine is the sole writer").
33060
+ * That rule was never true: Hikvision and Amcrest wrote the slice raw beside
33061
+ * it, every provider seeded it at boot, and every session left it
33062
+ * `detected: true` after its detach.
32925
33063
  */
32926
33064
  autoClearAfterMs: number().nullable()
32927
33065
  });
@@ -32993,11 +33131,12 @@ onMotionChanged: { data: MotionOnMotionChangedDataSchema } },
32993
33131
  */
32994
33132
  runtimeState: MotionStatusSchema,
32995
33133
  /**
32996
- * Runtime-state durability: **session** — every writer of this slice
33134
+ * Runtime-state durability: **session** — the writer of this slice
32997
33135
  * writes only on an EDGE, so a restored `detected: true` would stay
32998
33136
  * frozen until the next one instead of being corrected. The next edge
32999
- * re-publishes the real state. (On who the writers are, and why there
33000
- * is more than one, see `autoClearAfterMs` above.)
33137
+ * re-publishes the real state, and the orchestrator re-publishes every
33138
+ * camera when it starts writing (D696; on who writes it, see
33139
+ * `autoClearAfterMs` above).
33001
33140
  *
33002
33141
  * See `RuntimeStateDurability`. Enforced by
33003
33142
  * `scripts/check-runtime-state-durability.ts`.
@@ -35538,8 +35677,7 @@ var ptzAutotrackCapability = {
35538
35677
  deviceNative: true,
35539
35678
  mode: "singleton",
35540
35679
  /**
35541
- * Two kinds of provider behind one name, the same shape `snapshot` and
35542
- * `doorbell` use:
35680
+ * Two kinds of provider behind one name, the same shape `snapshot` uses:
35543
35681
  *
35544
35682
  * - **Native**: the camera's own firmware autotrack, registered per device by
35545
35683
  * the driver when the probe says it exists (Reolink: yes; Hikvision:
@@ -35547,7 +35685,7 @@ var ptzAutotrackCapability = {
35547
35685
  * - **Wrapper**: the emulated implementation (`@camstack/system`'s `autotrack` builtin),
35548
35686
  * which follows a subject with `ptz.move` pulses driven by the detection
35549
35687
  * pipeline. `defaultActive: false` — the operator binds it per camera in
35550
- * the bindings UI, exactly as `virtual-doorbell` is bound.
35688
+ * the bindings UI.
35551
35689
  *
35552
35690
  * The binding chooses WHICH implementation answers; `setEnabled` stays the
35553
35691
  * one switch for the function either way. A camera never has both driving its
@@ -44251,6 +44389,18 @@ Object.freeze({
44251
44389
  addonId: null,
44252
44390
  access: "view"
44253
44391
  },
44392
+ "databaseSnapshot.listDatabases": {
44393
+ capName: "database-snapshot",
44394
+ capScope: "system",
44395
+ addonId: null,
44396
+ access: "view"
44397
+ },
44398
+ "databaseSnapshot.writeSnapshot": {
44399
+ capName: "database-snapshot",
44400
+ capScope: "system",
44401
+ addonId: null,
44402
+ access: "create"
44403
+ },
44254
44404
  "dataStoreProvider.aggregate": {
44255
44405
  capName: "data-store-provider",
44256
44406
  capScope: "system",
@@ -47815,6 +47965,12 @@ Object.freeze({
47815
47965
  addonId: null,
47816
47966
  access: "delete"
47817
47967
  },
47968
+ "pipelineOrchestrator.requestOccupancyLook": {
47969
+ capName: "pipeline-orchestrator",
47970
+ capScope: "system",
47971
+ addonId: null,
47972
+ access: "create"
47973
+ },
47818
47974
  "pipelineOrchestrator.resetNodePipelineDefaults": {
47819
47975
  capName: "pipeline-orchestrator",
47820
47976
  capScope: "system",
@@ -51607,6 +51763,11 @@ Object.freeze({
51607
51763
  form: "single",
51608
51764
  optional: false
51609
51765
  }],
51766
+ "pipelineOrchestrator.requestOccupancyLook": [{
51767
+ name: "deviceId",
51768
+ form: "single",
51769
+ optional: false
51770
+ }],
51610
51771
  "pipelineOrchestrator.resolvePipeline": [{
51611
51772
  name: "deviceId",
51612
51773
  form: "single",
@@ -52768,6 +52929,18 @@ var STATE_SUMMARY_VARS = [
52768
52929
  systemEventKinds: [...SUMMARISABLE],
52769
52930
  systemEventDeliveries: ["summary"]
52770
52931
  },
52932
+ {
52933
+ name: "summarySection",
52934
+ label: "Summary: this section",
52935
+ description: "The section a per-section summary row is about (D698); on a summary sent as one message, every section it reports, comma-separated.",
52936
+ example: "Batterie scariche",
52937
+ group: "system",
52938
+ families: ["rule"],
52939
+ fields: [...RULE_TEXT],
52940
+ kinds: ["system"],
52941
+ systemEventKinds: [...SUMMARISABLE],
52942
+ systemEventDeliveries: ["summary"]
52943
+ },
52771
52944
  ...STATE_SUMMARY_SECTION_VARS.map((v) => ({
52772
52945
  name: v.name,
52773
52946
  label: v.label,
@@ -52844,6 +53017,37 @@ var STATE_SUMMARY_VARS = [
52844
53017
  [...RULE_TEXT],
52845
53018
  ...STATE_SUMMARY_VARS
52846
53019
  ];
53020
+ new Set([
53021
+ "disarmed",
53022
+ "armed_home",
53023
+ "armed_away",
53024
+ "armed_night",
53025
+ "armed_vacation",
53026
+ "armed_custom_bypass",
53027
+ "arming",
53028
+ "disarming",
53029
+ "pending",
53030
+ "triggered",
53031
+ "open",
53032
+ "opening",
53033
+ "closing",
53034
+ "closed",
53035
+ "stopped",
53036
+ "locked",
53037
+ "unlocked",
53038
+ "locking",
53039
+ "unlocking",
53040
+ "jammed",
53041
+ "on",
53042
+ "off",
53043
+ "home",
53044
+ "not_home",
53045
+ "matched",
53046
+ "diverged",
53047
+ "unknown",
53048
+ "latched",
53049
+ "live"
53050
+ ]);
52847
53051
  /**
52848
53052
  * TimelapseRule — the STANDALONE scheduled timelapse producer's rule model.
52849
53053
  *
@@ -53075,6 +53279,25 @@ TimelapseRuleInputSchema.extend({
53075
53279
  createdAt: number(),
53076
53280
  updatedAt: number()
53077
53281
  });
53282
+ async function readHubMotionDetected(deviceState, deviceId) {
53283
+ let slice;
53284
+ try {
53285
+ slice = await deviceState.getCapSlice.query({
53286
+ deviceId,
53287
+ capName: "motion"
53288
+ });
53289
+ } catch (err) {
53290
+ const reason = err instanceof Error ? err.message : String(err);
53291
+ throw new Error(`motion state of device ${deviceId} is unreadable: ${reason}`, { cause: err });
53292
+ }
53293
+ const detected = slice?.["detected"];
53294
+ if (typeof detected !== "boolean") throw new Error(`motion state of device ${deviceId} is not published yet (unknown)`);
53295
+ return detected;
53296
+ }
53297
+ MotionOnMotionChangedDataSchema.omit({ triggeredBy: true });
53298
+ function providerMotionEvent(source, data) {
53299
+ return createEvent(EventCategory.ProviderMotion, source, data);
53300
+ }
53078
53301
  object({
53079
53302
  /**
53080
53303
  * Fraction of the box's own size added on EACH side before cutting.
@@ -62887,15 +63110,7 @@ var HikvisionCamera = class HikvisionCamera extends BaseDevice {
62887
63110
  host
62888
63111
  };
62889
63112
  } });
62890
- this.ctx.registerNativeCap(motionCapability, { isDetected: async ({ deviceId }) => {
62891
- if (deviceId !== this.id) throw new Error(`HikvisionCamera: deviceId mismatch, expected ${this.id}, got ${deviceId}`);
62892
- return this.state.motion?.detected ?? false;
62893
- } });
62894
- this.setCapSlice(motionCapability, {
62895
- detected: false,
62896
- lastDetectedAt: null,
62897
- autoClearAfterMs: null
62898
- });
63113
+ this.registerMotionCap();
62899
63114
  this.registerIntercomIfSupported();
62900
63115
  this.registerOsdCap(1);
62901
63116
  this.registerStreamParamsCap(1);
@@ -65364,43 +65579,41 @@ var HikvisionCamera = class HikvisionCamera extends BaseDevice {
65364
65579
  deviceId: this.id
65365
65580
  };
65366
65581
  }
65582
+ /**
65583
+ * The native `motion` cap. Its presence is what defaults the camera to
65584
+ * `motionSources: ['onboard']`. This provider writes NO `motion` slice (D696):
65585
+ * the orchestrator is its only writer, with the EFFECTIVE motion, on the hub.
65586
+ * `isDetected` therefore answers from the hub's slice; an unreadable hub, or
65587
+ * a slice nobody has published since the hub started, makes the call fail.
65588
+ * It never answers `false` for "unknown" (D49, D393).
65589
+ */
65590
+ registerMotionCap() {
65591
+ this.ctx.registerNativeCap(motionCapability, { isDetected: async ({ deviceId }) => {
65592
+ if (deviceId !== this.id) throw new Error(`HikvisionCamera: deviceId mismatch, expected ${this.id}, got ${deviceId}`);
65593
+ return readHubMotionDetected(this.ctx.api.deviceState, this.id);
65594
+ } });
65595
+ }
65367
65596
  handleMotionEvent(ev, camStreamId) {
65368
65597
  const now = ev.observedAt;
65369
- const wasInactive = (this.lastMotionAt.get(camStreamId) ?? 0) === 0;
65370
65598
  this.lastMotionAt.set(camStreamId, now);
65371
- this.ctx.eventBus.emit(createEvent(EventCategory.MotionOnMotionChanged, this.eventSource, {
65599
+ this.ctx.eventBus.emit(providerMotionEvent(this.eventSource, {
65372
65600
  deviceId: this.id,
65373
65601
  detected: true,
65374
65602
  timestamp: now,
65375
65603
  source: "onboard"
65376
65604
  }));
65377
- if (wasInactive) try {
65378
- this.setCapSlice(motionCapability, {
65379
- detected: true,
65380
- lastDetectedAt: now,
65381
- autoClearAfterMs: MOTION_CLOSE_AFTER_MS
65382
- });
65383
- } catch {}
65384
65605
  const existing = this.motionInactiveTimers.get(camStreamId);
65385
65606
  if (existing) clearTimeout(existing);
65386
65607
  const timer = setTimeout(() => {
65387
65608
  const clearedAt = Date.now();
65388
65609
  this.lastMotionAt.set(camStreamId, 0);
65389
65610
  this.motionInactiveTimers.delete(camStreamId);
65390
- this.ctx.eventBus.emit(createEvent(EventCategory.MotionOnMotionChanged, this.eventSource, {
65611
+ this.ctx.eventBus.emit(providerMotionEvent(this.eventSource, {
65391
65612
  deviceId: this.id,
65392
65613
  detected: false,
65393
65614
  timestamp: clearedAt,
65394
65615
  source: "onboard"
65395
65616
  }));
65396
- try {
65397
- const lastDetectedAt = this.state.motion?.lastDetectedAt ?? clearedAt;
65398
- this.setCapSlice(motionCapability, {
65399
- detected: false,
65400
- lastDetectedAt,
65401
- autoClearAfterMs: null
65402
- });
65403
- } catch {}
65404
65617
  }, HikvisionCamera.MOTION_INACTIVE_AFTER_MS);
65405
65618
  this.motionInactiveTimers.set(camStreamId, timer);
65406
65619
  }