@camstack/addon-provider-hikvision 1.2.21 → 1.2.23

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.
package/dist/addon.js CHANGED
@@ -6,7 +6,7 @@ let node_crypto = require("node:crypto");
6
6
  let node_http = require("node:http");
7
7
  let node_https = require("node:https");
8
8
  let node_os = require("node:os");
9
- //#region ../types/dist/event-category-Cv9dO26A.mjs
9
+ //#region ../types/dist/event-category-Bxo5yJjt.mjs
10
10
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
11
11
  EventCategory["SystemBoot"] = "system.boot";
12
12
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -213,6 +213,33 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
213
213
  EventCategory["PipelineCameraAssigned"] = "pipeline.camera-assigned";
214
214
  EventCategory["PipelineCameraUnassigned"] = "pipeline.camera-unassigned";
215
215
  /**
216
+ * A node the orchestrator would otherwise place cameras on has NO usable
217
+ * inference device: the operator enabled one or more accelerators there and
218
+ * the live probe reports every one of them unavailable. Emitted once per
219
+ * TRANSITION into that state (never per dispatch), and the node is dropped
220
+ * from the placement candidate set for as long as it holds.
221
+ *
222
+ * This exists because the state was previously invisible: little-unraid
223
+ * absorbed 283k inference errors in a day while still being handed cameras,
224
+ * and nothing in the system said so.
225
+ *
226
+ * A node with no accelerators configured at all is NOT this — its devices
227
+ * are `disabled`, not `unavailable`, and the runner's default CPU pool
228
+ * serves it exactly as before.
229
+ */
230
+ EventCategory["PipelineNodeInferenceUnavailable"] = "pipeline.node-inference-unavailable";
231
+ /**
232
+ * A camera has an OPEN detection session and has produced no detection at
233
+ * all for longer than the blind threshold — the camera is being decoded and
234
+ * inferred and is returning nothing. Emitted once per transition into blind,
235
+ * per camera.
236
+ *
237
+ * The failure it reports: a 1h43 detection blackout on the entrance camera
238
+ * that nobody noticed, because "a camera that detects nothing" and "a quiet
239
+ * camera" produce byte-identical silence.
240
+ */
241
+ EventCategory["PipelineDetectionBlind"] = "pipeline.detection-blind";
242
+ /**
216
243
  * Per-camera pipeline config was mutated by the orchestrator
217
244
  * (3-level settings change via `setAgentAddonDefaults` /
218
245
  * `setCameraStepToggle` / `setCameraPipelineForAgent` or a
@@ -11072,6 +11099,8 @@ var QueryFilterSchema = object({
11072
11099
  where: record(string(), unknown()).optional(),
11073
11100
  whereIn: record(string(), array(unknown())).optional(),
11074
11101
  whereBetween: record(string(), tuple([unknown(), unknown()])).optional(),
11102
+ /** NULL-safe exclusion: matches rows whose field is NULL OR != the value. */
11103
+ whereNot: record(string(), unknown()).optional(),
11075
11104
  orderBy: object({
11076
11105
  field: string(),
11077
11106
  direction: _enum(["asc", "desc"])
@@ -11091,7 +11120,8 @@ var QueryFilterSchema = object({
11091
11120
  var MutationFilterSchema = object({
11092
11121
  where: record(string(), unknown()).optional(),
11093
11122
  whereIn: record(string(), array(unknown())).optional(),
11094
- whereBetween: record(string(), tuple([unknown(), unknown()])).optional()
11123
+ whereBetween: record(string(), tuple([unknown(), unknown()])).optional(),
11124
+ whereNot: record(string(), unknown()).optional()
11095
11125
  });
11096
11126
  /** A single stored record: `{ id, data }`. */
11097
11127
  var SettingsRecordSchema = object({
@@ -12610,6 +12640,17 @@ var LlmImageSchema = object({
12610
12640
  bytes: _instanceof(Uint8Array),
12611
12641
  mimeType: string()
12612
12642
  });
12643
+ /**
12644
+ * Retry policy. `enabled: false` is NOT the same as `maxAttempts: 1` in intent —
12645
+ * the flag is what a consumer table flips, the count is what the operator tunes.
12646
+ * A retry doubles the wall time of a call, so the two gates that run inside a
12647
+ * notification's budget keep it off (see `CONSUMER_RETRY_POLICY` in addon-ai).
12648
+ */
12649
+ var LlmRetryPolicySchema = object({
12650
+ enabled: boolean().default(false),
12651
+ /** Total attempts INCLUDING the first. 1 = no retry. */
12652
+ maxAttempts: number().int().min(1).max(5).default(1)
12653
+ });
12613
12654
  var LlmGenerateBaseInputSchema = object({
12614
12655
  /** Collection routing (the notification-output posture). */
12615
12656
  addonId: string().optional(),
@@ -12624,7 +12665,28 @@ var LlmGenerateBaseInputSchema = object({
12624
12665
  jsonSchema: record(string(), unknown()).optional(),
12625
12666
  /** Per-call override of the profile default. */
12626
12667
  maxTokens: number().int().positive().optional(),
12627
- temperature: number().optional()
12668
+ temperature: number().optional(),
12669
+ /** Per-call override of the profile default (nucleus sampling). */
12670
+ topP: number().min(0).max(1).optional(),
12671
+ /** Per-call override of the profile default (top-k sampling). */
12672
+ topK: number().int().positive().optional(),
12673
+ /** Per-call override of `profile.timeoutMs` — the total generation bound. */
12674
+ timeoutMs: number().int().positive().optional(),
12675
+ /** Per-call override; beats both the consumer table and the profile. */
12676
+ retry: LlmRetryPolicySchema.optional(),
12677
+ /**
12678
+ * Caller-minted id that makes this generation CANCELLABLE.
12679
+ *
12680
+ * Without it a caller that stops waiting cannot stop the work: the gates race
12681
+ * the call against 8 s and free their own slot when the timer wins, while the
12682
+ * generation upstream keeps running to `profile.timeoutMs` — 60 s by default,
12683
+ * on a single-threaded local model. The per-camera bound then counts WAITS,
12684
+ * not generations, and the real load is unbounded.
12685
+ *
12686
+ * `AbortSignal` cannot cross a process boundary; an id can. Pass one here and
12687
+ * `llm.cancel({ requestId })` tears the socket down.
12688
+ */
12689
+ requestId: string().optional()
12628
12690
  });
12629
12691
  /**
12630
12692
  * `llm-runtime` — node-side managed llama.cpp executor (spec §4). Registered
@@ -12637,6 +12699,18 @@ var LlmGenerateBaseInputSchema = object({
12637
12699
  * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
12638
12700
  * watchdog — operator decision #3).
12639
12701
  */
12702
+ /**
12703
+ * A companion artifact that MUST land beside the main GGUF: the `mmproj`
12704
+ * projector of a vision model, or shards 2..N of a split GGUF. Carried on the
12705
+ * REF rather than looked up at install time, so what the operator approved in
12706
+ * the preview is exactly what the node downloads.
12707
+ */
12708
+ var ManagedModelExtraFileSchema = object({
12709
+ url: string(),
12710
+ filename: string(),
12711
+ sizeBytes: number(),
12712
+ sha256: string().optional()
12713
+ });
12640
12714
  var ManagedModelRefSchema = discriminatedUnion("kind", [
12641
12715
  object({
12642
12716
  kind: literal("catalog"),
@@ -12645,7 +12719,11 @@ var ManagedModelRefSchema = discriminatedUnion("kind", [
12645
12719
  object({
12646
12720
  kind: literal("url"),
12647
12721
  url: string(),
12648
- sha256: string().optional()
12722
+ sha256: string().optional(),
12723
+ /** Picker/status label; the file basename when absent. */
12724
+ label: string().optional(),
12725
+ sizeBytes: number().optional(),
12726
+ extraFiles: array(ManagedModelExtraFileSchema).optional()
12649
12727
  }),
12650
12728
  object({
12651
12729
  kind: literal("path"),
@@ -12663,13 +12741,82 @@ var ManagedRuntimeConfigSchema = object({
12663
12741
  gpuLayers: number().int().default(0),
12664
12742
  /** Default: cpus-2, clamped ≥1 (resolved node-side). */
12665
12743
  threads: number().int().optional(),
12666
- /** Concurrent slots. */
12744
+ /** Concurrent slots (`--parallel`). */
12667
12745
  parallel: number().int().default(1),
12746
+ /** Logical batch size (`-b`). Larger = faster prompt ingest, more RAM. */
12747
+ batchSize: number().int().positive().optional(),
12748
+ /** Physical batch / micro-batch (`-ub`). */
12749
+ ubatchSize: number().int().positive().optional(),
12750
+ /**
12751
+ * `--flash-attn`. Cuts KV-cache memory on the backends that implement it and
12752
+ * is a no-op elsewhere, so it is offered rather than assumed.
12753
+ */
12754
+ flashAttention: boolean().default(false),
12755
+ /**
12756
+ * `--mlock`. Pins the weights in RAM so the OS cannot page them out mid
12757
+ * inference. Costs the full model size in resident memory — which is exactly
12758
+ * what the RAM budget is counting.
12759
+ */
12760
+ mlock: boolean().default(false),
12761
+ /**
12762
+ * `--no-mmap`. Reads the whole GGUF up front instead of mapping it. Slower to
12763
+ * start, but avoids the page-fault stalls a network or spinning-disk model
12764
+ * store produces on every first token.
12765
+ */
12766
+ noMmap: boolean().default(false),
12767
+ /** `--cache-type-k` / `--cache-type-v` — quantising the KV cache is the
12768
+ * cheapest way to fit a longer context in the same RAM. */
12769
+ cacheTypeK: _enum([
12770
+ "f32",
12771
+ "f16",
12772
+ "q8_0",
12773
+ "q5_1",
12774
+ "q5_0",
12775
+ "q4_1",
12776
+ "q4_0"
12777
+ ]).optional(),
12778
+ cacheTypeV: _enum([
12779
+ "f32",
12780
+ "f16",
12781
+ "q8_0",
12782
+ "q5_1",
12783
+ "q5_0",
12784
+ "q4_1",
12785
+ "q4_0"
12786
+ ]).optional(),
12787
+ /**
12788
+ * Escape hatch for llama-server flags this schema does NOT model — `--jinja`
12789
+ * (which most vision chat templates need and some language-only models
12790
+ * dislike), `--cont-batching`, `--rope-scaling`, …
12791
+ *
12792
+ * It is NOT a second place to set the flags above. A token that collides
12793
+ * with a typed field is REJECTED at start, naming the field that owns it
12794
+ * (`assertNoOwnedFlags`), because two knobs writing the same argv is exactly
12795
+ * the "two switches that disagree" failure this repo has already shipped
12796
+ * twice (D62).
12797
+ */
12798
+ extraArgs: array(string()).default([]),
12668
12799
  /** Else lazy: first generate boots it. */
12669
12800
  autoStart: boolean().default(false),
12670
12801
  /** 0 = never; frees RAM after quiet periods. */
12671
12802
  idleStopMinutes: number().int().default(30)
12672
12803
  });
12804
+ /**
12805
+ * Where a multi-GB install currently is. A single 0..1 fraction cannot answer
12806
+ * "is it stuck?" for an install that is three files (shards + mmproj) followed
12807
+ * by a sha256 pass over 22 GB — during which the fraction sat at 1.0 and the
12808
+ * node looked hung. Phase + file + bytes is the smallest shape that does.
12809
+ */
12810
+ var LlmDownloadProgressSchema = object({
12811
+ phase: _enum(["downloading", "verifying"]),
12812
+ /** The artifact currently moving, e.g. `mmproj-F16.gguf`. */
12813
+ file: string(),
12814
+ fileIndex: number().int(),
12815
+ fileCount: number().int(),
12816
+ /** Across the WHOLE install, not the current file. */
12817
+ downloadedBytes: number(),
12818
+ totalBytes: number().optional()
12819
+ });
12673
12820
  var LlmRuntimeStatusSchema = object({
12674
12821
  /** Status is ALWAYS node-qualified. */
12675
12822
  nodeId: string(),
@@ -12686,6 +12833,8 @@ var LlmRuntimeStatusSchema = object({
12686
12833
  modelPath: string().optional(),
12687
12834
  modelId: string().optional(),
12688
12835
  downloadProgress: number().min(0).max(1).optional(),
12836
+ /** Detail behind `downloadProgress`; present for the same lifetime. */
12837
+ download: LlmDownloadProgressSchema.optional(),
12689
12838
  lastError: string().optional(),
12690
12839
  crashesInWindow: number(),
12691
12840
  /** Child RSS (sampled best-effort). */
@@ -12696,7 +12845,14 @@ var LlmNodeModelSchema = object({
12696
12845
  file: string(),
12697
12846
  sizeBytes: number(),
12698
12847
  catalogId: string().optional(),
12699
- installedAt: number().optional()
12848
+ installedAt: number().optional(),
12849
+ /**
12850
+ * Absolute path on the node. Present so a file that is on disk but matches
12851
+ * no catalog entry — a custom Hugging Face install, or a GGUF the operator
12852
+ * copied in by hand — is still SELECTABLE, as a `{kind:'path'}` ref. Without
12853
+ * it the picker could list such a file and do nothing with it.
12854
+ */
12855
+ path: string().optional()
12700
12856
  });
12701
12857
  var LlmRuntimeDiskUsageSchema = object({
12702
12858
  nodeId: string(),
@@ -12752,10 +12908,47 @@ var LlmProfileSchema = object({
12752
12908
  baseUrl: string().optional(),
12753
12909
  /** ConfigUISchema type:'password' — never round-trips (spec §5). */
12754
12910
  apiKey: string().optional(),
12911
+ /** Vision on/off. A vision call against a `false` profile is REFUSED, never
12912
+ * degraded to text — that shipped once and produced a confident answer to a
12913
+ * question about a picture nobody sent. */
12755
12914
  supportsVision: boolean(),
12756
12915
  temperature: number().min(0).max(2).optional(),
12916
+ /** Nucleus sampling. Every wire we speak has it. */
12917
+ topP: number().min(0).max(1).optional(),
12918
+ /** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
12919
+ * wire does, and the client drops it there (measured: the request body gets
12920
+ * `top_p` and no `top_k`). The profile editor hides the field wherever it
12921
+ * would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
12922
+ topK: number().int().positive().optional(),
12757
12923
  maxTokens: number().int().positive().optional(),
12924
+ /** Prompt context window. Advisory for cloud kinds (they enforce their own);
12925
+ * for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
12926
+ * the model with, so it is the one field that changes a PROCESS. */
12927
+ contextLength: number().int().positive().optional(),
12928
+ /** Default system prompt. A caller's `system` REPLACES it (never appends —
12929
+ * two system prompts fighting is worse than either alone). */
12930
+ systemPrompt: string().optional(),
12931
+ /** Total generation bound — the only one a unary call has. */
12758
12932
  timeoutMs: number().int().positive().default(6e4),
12933
+ /** The TCP handshake only — "is the port even open". NOT the wait for
12934
+ * response headers: on the LM Studio / llama-server wire those are written
12935
+ * once the model has finished loading, so they belong to the bound below. */
12936
+ connectTimeoutMs: number().int().positive().default(1e4),
12937
+ /** Accepted, but no output yet — response headers included, because a cold
12938
+ * GPU load is exactly what happens before them. */
12939
+ firstTokenTimeoutMs: number().int().positive().default(12e4),
12940
+ /** Output started then stopped. */
12941
+ idleTimeoutMs: number().int().positive().default(6e4),
12942
+ /** Profile-level default. The per-consumer table and a per-call override
12943
+ * both beat it — see `resolveRetryPolicy`. */
12944
+ retry: LlmRetryPolicySchema.default({
12945
+ enabled: false,
12946
+ maxAttempts: 1
12947
+ }),
12948
+ /** Whether this profile may use tools. The tool-call plumbing rides the
12949
+ * library; the REGISTRY of callable tools is ours and is empty in v1, so a
12950
+ * `true` here buys the wiring, not behaviour, until tools are registered. */
12951
+ toolsEnabled: boolean().default(false),
12759
12952
  extraHeaders: record(string(), string()).optional(),
12760
12953
  /** kind === 'managed-local' only (spec §4). */
12761
12954
  runtime: ManagedRuntimeConfigSchema.optional()
@@ -12805,6 +12998,36 @@ var ManagedModelCatalogEntrySchema = object({
12805
12998
  /** Vision models: companion projector file. */
12806
12999
  mmprojUrl: string().optional()
12807
13000
  });
13001
+ /**
13002
+ * The outcome of turning one operator-typed Hugging Face reference into a
13003
+ * download plan. A RESULT, never a throw: "this repo has 24 quantizations and
13004
+ * I will not pick for you" is a normal answer the UI has to render, not an
13005
+ * exception.
13006
+ *
13007
+ * `candidates` is the whole reason the refusal is usable — every string in it
13008
+ * is a tag that resolves when pasted back as `<org>/<repo>:<TAG>`.
13009
+ */
13010
+ var HfModelResolutionSchema = discriminatedUnion("ok", [object({
13011
+ ok: literal(true),
13012
+ /** Ready to hand to `installModel` unchanged. */
13013
+ model: ManagedModelRefSchema,
13014
+ label: string(),
13015
+ repo: string(),
13016
+ quantization: string(),
13017
+ purpose: _enum(["text", "vision"]),
13018
+ totalBytes: number(),
13019
+ /** mmproj + shards, for the preview: an operator approving 23 GB should
13020
+ * see that 0.9 GB of it is a projector they did not name. */
13021
+ extraFilenames: array(string())
13022
+ }), object({
13023
+ ok: literal(false),
13024
+ code: string(),
13025
+ message: string(),
13026
+ candidates: array(string()).optional(),
13027
+ /** Set when the refusal was only the ceiling: re-calling with
13028
+ * `maxBytes: requiredBytes` is the operator's explicit override. */
13029
+ requiredBytes: number().optional()
13030
+ })]);
12808
13031
  var LlmRuntimeNodeSchema = object({
12809
13032
  nodeId: string(),
12810
13033
  reachable: boolean(),
@@ -12817,7 +13040,10 @@ var ProfileRefInputSchema = object({
12817
13040
  addonId: string(),
12818
13041
  profileId: string()
12819
13042
  });
12820
- method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
13043
+ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({
13044
+ addonId: string().optional(),
13045
+ requestId: string()
13046
+ }), _void(), { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
12821
13047
  kind: "mutation",
12822
13048
  auth: "admin"
12823
13049
  }), method(ProfileRefInputSchema, _void(), {
@@ -12838,6 +13064,15 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }
12838
13064
  consumer: string().optional(),
12839
13065
  profileId: string().optional()
12840
13066
  }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
13067
+ /** `https://huggingface.co/<org>/<repo>/resolve/main/<f>.gguf`,
13068
+ * `<org>/<repo>/<f>.gguf`, `<org>/<repo>` or `<org>/<repo>:<QUANT>`. */
13069
+ ref: string(),
13070
+ /** Explicit ceiling override, in bytes. Absent = the built-in ceiling. */
13071
+ maxBytes: number().positive().optional()
13072
+ }), HfModelResolutionSchema, {
13073
+ kind: "mutation",
13074
+ auth: "admin"
13075
+ }), method(object({
12841
13076
  nodeId: string(),
12842
13077
  model: ManagedModelRefSchema
12843
13078
  }), _void(), {
@@ -14485,6 +14720,8 @@ var NcSystemEventKindSchema = _enum([
14485
14720
  "stream-offline",
14486
14721
  "node-online",
14487
14722
  "node-offline",
14723
+ "node-inference-unavailable",
14724
+ "detection-blind",
14488
14725
  "addon-update-available",
14489
14726
  "server-update-available",
14490
14727
  "alarm-triggered",
@@ -14546,7 +14783,16 @@ var NcScheduleSchema = object({
14546
14783
  });
14547
14784
  /** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
14548
14785
  var NcPlateMatcherSchema = object({
14549
- values: array(string().min(1)).min(1),
14786
+ /**
14787
+ * Plate texts (or gallery vehicle names) to match. EMPTY = **any plate the
14788
+ * pipeline could read** — the plate half of "no selection = no narrowing",
14789
+ * and the switch that says this rule is about vehicles that were IDENTIFIED
14790
+ * rather than merely seen. A subject carrying no plate still fails.
14791
+ *
14792
+ * The `.min(1)` this used to carry made that state unauthorable; nothing has
14793
+ * ever persisted an empty list, so widening it cannot change an existing rule.
14794
+ */
14795
+ values: array(string().min(1)),
14550
14796
  /** Max Levenshtein distance after normalization (uppercase alphanumeric). */
14551
14797
  maxDistance: number().int().min(0).max(3).default(1)
14552
14798
  });
@@ -14580,28 +14826,36 @@ var NcOccupancyConditionSchema = object({
14580
14826
  /**
14581
14827
  * Audio condition (IMMEDIATE trigger) — a rule on SOUND, not on a picture.
14582
14828
  *
14583
- * Operator-approved vocabulary (2026-08-12, option A — the same one the
14584
- * reference notifier uses, so an operator moving between them re-uses what
14585
- * they already know): a rule matches when, over a sampling window of
14586
- * `samplingSeconds`, at least `hitPercent`% of the audio samples in that
14587
- * window are HITS. A sample is a hit when it satisfies BOTH present filters:
14588
- *
14589
- * - `dbThreshold` its level is at or above this many dBFS (see
14590
- * {@link NC_AUDIO_DBFS_FLOOR}: negative-going, `0` = full scale);
14591
- * - `labels` the classifier put at least one of these labels on it.
14592
- *
14593
- * Both are OPTIONAL and independent, which is the point of the shape: a
14594
- * loudness rule ("something loud at 3am") needs no model to be right, and a
14595
- * label rule ("a dog barked") needs no threshold. **Fail-closed when NEITHER
14596
- * is given** a window in which every sample is trivially a hit would fire on
14597
- * silence, so the engine refuses such a condition rather than notifying on
14598
- * nothing (the schema cannot express "at least one of" without becoming a
14599
- * ZodEffects the cap path would have to special-case).
14600
- *
14601
- * `hitPercent` is over the samples the window actually HOLDS, and the window
14602
- * must be FULL before it can match a window that has been open for two
14603
- * seconds of its ten is 100% of nothing, and firing on it would make
14604
- * `samplingSeconds` decorative.
14829
+ * **TWO EXCLUSIVE MODES** (operator decision 2026-08-14, D157). Which one a
14830
+ * rule is in is not a stored field it is WHICH FILTER the rule carries, so
14831
+ * there is no second switch that can disagree with the first and every rule
14832
+ * authored before the decision migrates for free (`audioModeOf`):
14833
+ *
14834
+ * - **LABEL mode — `labels` present.** The rule fires on the FIRST frame the
14835
+ * classifier labels with one of them. No window, no percentage:
14836
+ * `hitPercent` and `samplingSeconds` are ignored, and the rule's own
14837
+ * `throttle` cooldown is the only brake. The per-label confidence floor is
14838
+ * the analyzer's (`classificationMinScore`, per device) — a label only
14839
+ * reaches this condition if the classifier was already confident enough.
14840
+ * - **LEVEL mode `dbThreshold` present, no labels.** The sampling window IS
14841
+ * the condition: at least `hitPercent`% of the samples over
14842
+ * `samplingSeconds` must be at or above `dbThreshold` dBFS (see
14843
+ * {@link NC_AUDIO_DBFS_FLOOR}: negative-going, `0` = full scale). The window
14844
+ * must be FULL before it can match a window open for two of its ten
14845
+ * seconds is 100% of nothing.
14846
+ *
14847
+ * **Why label mode has no window.** It had one, and it never fired: the
14848
+ * analyzer emits ~1 audio frame per second but YAMNet only LABELS one to three
14849
+ * of them per episode, even through continuous crying. The measured maximum
14850
+ * `hitPercent` over the whole live history was 40 — under the shipped default
14851
+ * of 60, so a label rule could not fire at all, ever. A percentage of frames is
14852
+ * the wrong question to ask of a sparse classifier.
14853
+ *
14854
+ * **Fail-closed when NEITHER is given** — every sample would be a trivial hit
14855
+ * and the rule would fire on silence. The schema cannot express "exactly one
14856
+ * of" without becoming a ZodEffects the cap path would have to special-case, so
14857
+ * the exclusivity is enforced where every editor writes (`patchAudio`) and a
14858
+ * legacy rule carrying both resolves to LABEL (the mode that fires).
14605
14859
  *
14606
14860
  * Labels are the audio macro classes (`AUDIO_MACRO_LABELS` / the NC taxonomy's
14607
14861
  * `audio-*` ids). Both spellings are accepted — the matcher normalizes the
@@ -14609,13 +14863,13 @@ var NcOccupancyConditionSchema = object({
14609
14863
  * an operator who typed `dog` mean the same thing.
14610
14864
  */
14611
14865
  var NcAudioConditionSchema = object({
14612
- /** Audio macro labels; absent = any sound (level-only rule). */
14866
+ /** LABEL MODE: audio macro labels. Present fires on the first labelled frame. */
14613
14867
  labels: array(string().min(1)).min(1).optional(),
14614
- /** Level floor in dBFS (negative-going, `0` = full scale); absent = any level. */
14868
+ /** LEVEL MODE: floor in dBFS (negative-going, `0` = full scale). */
14615
14869
  dbThreshold: number().min(-96).max(0).optional(),
14616
- /** Percentage of the window's samples that must be hits (1–100). */
14870
+ /** LEVEL MODE ONLY: percentage of the window's samples that must be hits (1–100). */
14617
14871
  hitPercent: number().int().min(1).max(100).default(60),
14618
- /** Length of the sampling window in seconds. */
14872
+ /** LEVEL MODE ONLY: length of the sampling window in seconds. */
14619
14873
  samplingSeconds: number().int().min(1).max(300).default(10)
14620
14874
  });
14621
14875
  /**
@@ -14753,13 +15007,81 @@ var NcRuleActionsSchema = object({
14753
15007
  */
14754
15008
  buttons: array(NcRuleNotificationButtonSchema).max(8).optional()
14755
15009
  });
15010
+ /**
15011
+ * "This rule applies only while `deviceId` is in one of `states`."
15012
+ *
15013
+ * The states are the DEVICE's own vocabulary — `AlarmState` for a panel,
15014
+ * `on`/`off` for a switch — not a normalised set, because normalising would
15015
+ * make the condition lie about devices whose states have no equivalent.
15016
+ *
15017
+ * An unreadable state does NOT match: see the engine's fail-closed gate. A
15018
+ * condition that fired on "I could not read it" would be worse than no gate.
15019
+ */
15020
+ var NcDeviceStateConditionSchema = object({
15021
+ deviceId: number().int(),
15022
+ /** Any of these matches. */
15023
+ states: array(string().min(1)).min(1)
15024
+ });
15025
+ /**
15026
+ * "This rule applies only while scene `sceneId` is `matched` / `diverged`."
15027
+ *
15028
+ * A GATE, not a trigger. `occupancy` and `audio` each DISCRIMINATE their rule —
15029
+ * carrying one makes the rule fire on that subject and nothing else. Scene is
15030
+ * the other shape entirely, the `deviceState` shape: it narrows a rule that
15031
+ * already has a trigger ("tell me about a person at the front door, but only
15032
+ * while the bin is still out"). That is why it composes with every delivery
15033
+ * instead of owning one, and why no new `NcDelivery` member and no new subject
15034
+ * kind exist for it — see D159.
15035
+ *
15036
+ * ── Identity ───────────────────────────────────────────────────────────────
15037
+ * `sceneId` is `SceneMonitor.id`, a `randomUUID()` minted by `createScene` —
15038
+ * globally unique, so it needs no device to disambiguate it. `deviceId` is
15039
+ * carried as a HINT for the editor and for the log line, never as part of the
15040
+ * lookup key: a rule whose hint drifted must still gate correctly.
15041
+ *
15042
+ * ── Which boolean ──────────────────────────────────────────────────────────
15043
+ * `latched` ABSENT means "whatever the scene itself says" — `SceneMonitor.emit`
15044
+ * already declares which boolean drives notification rules, and a second knob
15045
+ * that could disagree with it is exactly the D62 failure. Set it only to
15046
+ * override one rule against the scene's own default.
15047
+ *
15048
+ * - LIVE reading (`emit`/`latched` resolve to live): passes iff
15049
+ * `verdict === requiredState`. `unknown` — no reference for this light, view
15050
+ * shifted, no snapshot — passes NEITHER. A scene that cannot judge is not
15051
+ * evidence, in either direction.
15052
+ * - LATCHED reading: passes iff `latched === (requiredState === 'diverged')`.
15053
+ * The latch is a durable fact about the past ("it has diverged since I armed
15054
+ * it"), so a camera that has gone dark does not clear it — that is the whole
15055
+ * reason the operator asked for a latch.
15056
+ *
15057
+ * The gate reads an in-memory mirror (`NcSceneStateCache`) refreshed OFF the
15058
+ * event path, never the cap: D49. A mirror that has never loaded, or a scene it
15059
+ * does not carry, reads absent and the rule does NOT fire — fail closed, and
15060
+ * said out loud in the log rather than dropped in silence.
15061
+ */
15062
+ var NcSceneConditionSchema = object({
15063
+ /** `SceneMonitor.id` — the uuid the cap mints. The whole lookup key. */
15064
+ sceneId: string().min(1),
15065
+ /** The camera the scene lives on. A hint for the editor and the log line. */
15066
+ deviceId: number().int().optional(),
15067
+ /** The state the scene must be in for the rule to fire. */
15068
+ requiredState: _enum(["matched", "diverged"]),
15069
+ /**
15070
+ * Read the LATCH (`true`) or the LIVE verdict (`false`). Absent = follow the
15071
+ * scene's own `emit` field, which is the only place that decision belongs.
15072
+ */
15073
+ latched: boolean().optional()
15074
+ });
14756
15075
  var NcConditionsSchema = object({
14757
15076
  /** Gate on ANOTHER device's current state (the alarm armed, a switch on). */
14758
- deviceState: object({
14759
- deviceId: number().int(),
14760
- /** Any of these matches. */
14761
- states: array(string().min(1)).min(1)
14762
- }).optional(),
15077
+ deviceState: NcDeviceStateConditionSchema.optional(),
15078
+ /**
15079
+ * Gate on a SCENE's state — "only while the bin is still out". Composes with
15080
+ * every trigger (detection, occupancy, audio, sensor, package, track-end);
15081
+ * unlike `occupancy`/`audio` it discriminates nothing. See
15082
+ * {@link NcSceneCondition} and D159.
15083
+ */
15084
+ scene: NcSceneConditionSchema.optional(),
14763
15085
  /** Device scope — absent = all devices. */
14764
15086
  devices: array(number()).optional(),
14765
15087
  /** Detector class names (any overlap with the record's class set). */
@@ -14785,18 +15107,47 @@ var NcConditionsSchema = object({
14785
15107
  */
14786
15108
  labelEquals: array(string().min(1)).optional(),
14787
15109
  /**
14788
- * Identity matcher. P1 boundary: matched against the record's collapsed
14789
- * `label` (the identity display name propagated by the face pipeline) —
14790
- * identity-ID matching rides in P2 when identity ids reach the record.
15110
+ * KNOWN FACES the rule's identity scope, and the switch that says the rule
15111
+ * is about recognised people at all.
15112
+ *
15113
+ * Three states, and the empty one is the point:
15114
+ *
15115
+ * | value | meaning |
15116
+ * | --- | --- |
15117
+ * | absent | the rule does not care who it is; an unrecognised person matches |
15118
+ * | `[]` | **only known faces** — any identity in the gallery, nobody in particular |
15119
+ * | a list | only these identities |
15120
+ *
15121
+ * `[]` is the repo-wide "no selection = no narrowing" reading (an absent
15122
+ * `devices` list is every device), applied one level down: the operator has
15123
+ * turned the face scope ON and narrowed it to nothing, which is every known
15124
+ * face. No second field states the same thing — a switch that can disagree
15125
+ * with the list under it is worse than no switch (D62).
15126
+ *
15127
+ * MEMBERS ARE FACE-GALLERY `Identity.id`s (uuid), not display names. A name is
15128
+ * renameable, and a rule authored on "Gianluca" went silently dark the moment
15129
+ * the operator fixed the spelling. The id reaches the record on
15130
+ * `LabelAttribution.identityId`; the name is what the editor shows and what
15131
+ * `{{label}}` renders.
15132
+ *
15133
+ * Rules written before this carry NAMES, and are resolved to ids lazily at
15134
+ * load (`NcRuleStore.load`) against the live gallery — a name nothing answers
15135
+ * for is left as it stands and reported, never dropped. The engine also
15136
+ * accepts a display-name hit as a compatibility leg, so a rule whose
15137
+ * migration could not resolve keeps matching exactly what it matched before.
14791
15138
  */
14792
15139
  identities: array(string().min(1)).optional(),
14793
- /** Fuzzy plate matcher against the record's `label` (plate text). */
15140
+ /**
15141
+ * KNOWN PLATES / VEHICLES — the plate mirror of {@link identities}, including
15142
+ * the empty-list reading: `values: []` is "any plate the OCR could read",
15143
+ * a non-empty list is those plates (fuzzily). See {@link NcPlateMatcherSchema}.
15144
+ */
14794
15145
  plates: NcPlateMatcherSchema.optional(),
14795
15146
  /**
14796
- * Identity EXCLUDE — mirror of {@link identities} with `notIn` semantics.
14797
- * Same P1 boundary: matched against the record's collapsed `label` (the
14798
- * identity display name). A record with NO label passes (nothing to
14799
- * exclude), unlike the include variant which fails on an absent label.
15147
+ * Identity EXCLUDE — mirror of {@link identities} with `notIn` semantics, and
15148
+ * the same id members and the same lazy name→id migration. A record with NO
15149
+ * identity passes (nothing to exclude), unlike the include variant which
15150
+ * fails on an unrecognised subject. An EMPTY list excludes nobody.
14800
15151
  */
14801
15152
  identitiesExclude: array(string().min(1)).optional(),
14802
15153
  /**
@@ -15188,7 +15539,80 @@ var NcRuleInputSchema = object({
15188
15539
  * a rule that predates the gate must keep delivering byte-for-byte as it
15189
15540
  * did, and absent is the only way to say that without a migration.
15190
15541
  */
15191
- confirm: NcConfirmSchema.optional()
15542
+ confirm: NcConfirmSchema.optional(),
15543
+ /**
15544
+ * WAIT for face/plate recognition before saying anything.
15545
+ *
15546
+ * A notification's TEXT is frozen at enqueue and its media is re-resolved at
15547
+ * send; the identity is neither. A face is confirmed after `confirmFrames`
15548
+ * agreeing observations — p50 **11.4 s** after the track was first seen,
15549
+ * measured on this hub — and an `immediate` rule enqueues on the first object
15550
+ * event, seconds before that. So "Gianluca è arrivato" is unsayable on the
15551
+ * immediate path, and no amount of media re-resolution fixes a sentence.
15552
+ *
15553
+ * Only two honest answers exist, and this flag picks between them. It has
15554
+ * effect ONLY on a rule that declares a recognition scope
15555
+ * ({@link NcConditions.identities} or {@link NcConditions.plates}) — on any
15556
+ * other rule there is nothing to wait for and the flag is inert.
15557
+ *
15558
+ * | value | what happens |
15559
+ * | --- | --- |
15560
+ * | `true` | the rule stops firing on the object event and fires at TRACK CLOSE instead, once, with the name — later, and complete |
15561
+ * | absent / `false` | it fires at once WITHOUT the name, and if recognition lands before the track closes a SECOND, "…is Gianluca" notification follows (one per track, per rule, per target) |
15562
+ *
15563
+ * `.optional()` and deliberately NOT `.default()`: a Zod default does not run
15564
+ * on the addon cap path, and absent has to keep meaning exactly what every
15565
+ * rule authored before this field meant.
15566
+ *
15567
+ * The cost of `true` is stated here because the editor states it too: a rule
15568
+ * that waits also inherits track-close SEMANTICS — its `zones` condition
15569
+ * tests every zone the track visited and a `crossing` condition can no longer
15570
+ * be satisfied, because a closed track carries no crossing.
15571
+ */
15572
+ waitForEnhancement: boolean().optional(),
15573
+ /**
15574
+ * GROUP a burst of subjects into ONE notification that grows.
15575
+ *
15576
+ * Seconds of quiet after the last matching subject before the burst is
15577
+ * considered over. While it is open, the first subject enqueues immediately —
15578
+ * **exactly as today, with no added latency** — and every real growth (a new
15579
+ * subject, or a name confirmed on one already in it) REPLACES that
15580
+ * notification with an updated one naming everybody. The push carries the
15581
+ * group's own coalescing tag, so the phone replaces rather than stacks.
15582
+ *
15583
+ * `0` / absent = off, and off is today's behaviour byte for byte.
15584
+ *
15585
+ * ### Why an idle cutoff and not a window
15586
+ *
15587
+ * The measured seven-person arrival on device 590 spans 110 s with every
15588
+ * internal gap under 30 s. A 12 s fixed window cuts it into three groups; an
15589
+ * idle cutoff holds it as one and ends it when the arrival actually ends.
15590
+ * 30 is Frigate's shipped value for the same decision.
15591
+ *
15592
+ * ### What it replaces
15593
+ *
15594
+ * The blind cooldown, which collapses a burst by DISCARDING it. Measured on
15595
+ * device 615 / *Persona su Uscio* over six days: 116 qualifying tracks → 74
15596
+ * notifications, **44 (37.9%) suppressed outright**, 23 of them overlapping a
15597
+ * track that did fire and 7 carrying a confirmed identity nobody heard about.
15598
+ * A group collapses the same volume by MERGING, so the cooldown becomes a
15599
+ * budget over GROUPS — which is what it always meant — and a growth is never
15600
+ * throttled by the window its own first member spent.
15601
+ *
15602
+ * ### Interaction with {@link waitForEnhancement}
15603
+ *
15604
+ * They compose, and the order matters. `waitForEnhancement` defers the rule to
15605
+ * TRACK CLOSE, so with both set the group is opened by the first member to
15606
+ * CLOSE — already carrying its name — and grows as later members close. That
15607
+ * is later, and complete. With grouping alone the group opens on the first
15608
+ * object event and picks up names as they are confirmed, through the growth
15609
+ * path. Neither combination fires twice for one subject.
15610
+ *
15611
+ * `.optional()` and deliberately NOT `.default()`: a Zod default does not run
15612
+ * on the addon cap path, so absent must keep meaning what it meant before this
15613
+ * field existed.
15614
+ */
15615
+ groupIdleSec: number().int().min(0).max(600).optional()
15192
15616
  });
15193
15617
  /**
15194
15618
  * Partial patch for `updateRule` — any subset of the input fields, plus the
@@ -15295,6 +15719,7 @@ var NcConditionDescriptorSchema = object({
15295
15719
  "occupancy",
15296
15720
  "audio",
15297
15721
  "deviceState",
15722
+ "scene",
15298
15723
  "systemEvent"
15299
15724
  ]),
15300
15725
  operator: _enum([
@@ -16114,7 +16539,7 @@ var TrackEnvelopeSchema = object({
16114
16539
  * `snapshots[]` references — megabytes across a page of tracks. `slim`
16115
16540
  * keeps every scalar the list surfaces actually render (ids, class(es),
16116
16541
  * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
16117
- * zonesVisited, bestEventId, envelope, hasFace) and returns `positions` /
16542
+ * zonesVisited, bestEventId, envelope, hasFace, hasRider) and returns `positions` /
16118
16543
  * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
16119
16544
  * `getTrack`. Mirrors the event-store `projection` convention
16120
16545
  * (`getObjectEvents` et al.).
@@ -16250,7 +16675,21 @@ union([literal(1), literal(2)]);
16250
16675
  var LabelAttributionSchema = object({
16251
16676
  stepId: string(),
16252
16677
  modelId: string().optional(),
16253
- decidedAt: number()
16678
+ decidedAt: number(),
16679
+ /**
16680
+ * The GALLERY id behind a recognised tier-2 label — a face-gallery
16681
+ * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
16682
+ *
16683
+ * The text alone is a DISPLAY NAME, and a display name is renameable: a
16684
+ * notification rule authored on "Gianluca" stopped matching the moment the
16685
+ * operator fixed the spelling in the gallery, and nothing said so. The id is
16686
+ * the thing that does not move, so it is what a rule matches on
16687
+ * (`NcConditions.identities`) and the text is what a human is shown.
16688
+ *
16689
+ * Absent when the label names no gallery row — a plate the OCR read but no
16690
+ * vehicle claims, a sub-class, a species, any tier-1 value.
16691
+ */
16692
+ identityId: string().optional()
16254
16693
  });
16255
16694
  /**
16256
16695
  * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
@@ -16387,6 +16826,28 @@ var TrackSchema = object({
16387
16826
  * `=== true` and render nothing otherwise, never infer "no face".
16388
16827
  */
16389
16828
  hasFace: boolean().optional(),
16829
+ /**
16830
+ * This subject CONTAINS a folded rider — a person the rider-pairing step
16831
+ * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
16832
+ * so the passage is tracked once and as a VEHICLE.
16833
+ *
16834
+ * It exists because the fold's record was dishonest. D34 and the code both
16835
+ * said "the person is not lost — it is reported so both entities stay on the
16836
+ * record"; in fact the pair went into a per-processor RAM field behind an
16837
+ * accessor nobody called, and every durable surface said `vehicle`, full
16838
+ * stop. This is the composition note that makes the row true.
16839
+ *
16840
+ * A COMPOSITION, never a class and never a label. "This vehicle contains a
16841
+ * person" is not an answer to "what is this" — both label tiers would refuse
16842
+ * a macro token anyway (D89), and correctly. Nothing here changes what the
16843
+ * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
16844
+ * and a `person` rule still does not fire for someone cycling past.
16845
+ *
16846
+ * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
16847
+ * the column, and every hub that predates the field, omits it. Test
16848
+ * `=== true` and render nothing otherwise — never infer "no rider".
16849
+ */
16850
+ hasRider: boolean().optional(),
16390
16851
  ...TrackFlagFields,
16391
16852
  ...TrackRetrainFields
16392
16853
  });
@@ -16736,7 +17197,10 @@ var RecentTracksQueryInput = object({
16736
17197
  * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
16737
17198
  cursor: string().optional(),
16738
17199
  /** See {@link TrackProjectionSchema}. Default `full`. */
16739
- projection: TrackProjectionSchema.optional()
17200
+ projection: TrackProjectionSchema.optional(),
17201
+ /** Include stationary-promoted rows (parked objects). Default false: the
17202
+ * feed lists passages; parking records live on the stationary registry. */
17203
+ includeStationary: boolean().optional()
16740
17204
  });
16741
17205
  var RecentTracksPageSchema = object({
16742
17206
  /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
@@ -16954,7 +17418,11 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
16954
17418
  zone: TrackZoneFilterSchema.optional(),
16955
17419
  /** See {@link TrackProjectionSchema}. Default `full` (backward
16956
17420
  * compatible — omitting the field keeps today's exact behaviour). */
16957
- projection: TrackProjectionSchema.optional()
17421
+ projection: TrackProjectionSchema.optional(),
17422
+ /** Include stationary-promoted rows (parked objects handed to the
17423
+ * stationary registry). Default false: the timeline lists passages,
17424
+ * not parking records (operator decision, 2026-08-15). */
17425
+ includeStationary: boolean().optional()
16958
17426
  }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(object({ deviceId: number() }), _void(), {
16959
17427
  kind: "mutation",
16960
17428
  auth: "admin"
@@ -17118,11 +17586,16 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
17118
17586
  auth: "admin"
17119
17587
  }), method(object({
17120
17588
  eventId: string(),
17121
- kind: MediaFileKindEnum.optional()
17589
+ kind: MediaFileKindEnum.optional(),
17590
+ deviceId: number()
17122
17591
  }), array(MediaFileSchema).readonly()), method(object({
17123
17592
  trackId: string(),
17124
- kinds: array(MediaFileKindEnum).optional()
17125
- }), array(MediaFileSchema).readonly()), method(object({ trackId: string() }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
17593
+ kinds: array(MediaFileKindEnum).optional(),
17594
+ deviceId: number()
17595
+ }), array(MediaFileSchema).readonly()), method(object({
17596
+ trackId: string(),
17597
+ deviceId: number()
17598
+ }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
17126
17599
  kind: "mutation",
17127
17600
  auth: "admin"
17128
17601
  }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
@@ -17822,6 +18295,17 @@ var maxSessionHoldMsField = {
17822
18295
  default: 12e4,
17823
18296
  step: 5e3
17824
18297
  };
18298
+ /**
18299
+ * Quiet period that closes an `audioMode: 'on-motion'` audio window. Floor of
18300
+ * 5s so a rearm can never degenerate into per-event stream churn; default 90s
18301
+ * comfortably outlives the gap between two PIR wakes on a battery camera.
18302
+ */
18303
+ var audioMotionWindowMsField = {
18304
+ min: 5e3,
18305
+ max: 6e5,
18306
+ default: 9e4,
18307
+ step: 5e3
18308
+ };
17825
18309
  var motionFpsField = {
17826
18310
  min: 1,
17827
18311
  max: 30,
@@ -17998,6 +18482,27 @@ var RunnerCameraConfigSchema = object({
17998
18482
  * resolved `CameraDetectionConfig`.
17999
18483
  */
18000
18484
  maxSessionHoldMs: number().min(maxSessionHoldMsField.min).max(maxSessionHoldMsField.max).optional(),
18485
+ /**
18486
+ * Orchestrator-side quiet period (ms) that closes an `audioMode:
18487
+ * 'on-motion'` audio window, measured from the LAST motion event.
18488
+ *
18489
+ * This exists because the falling edge cannot be relied on. Camera-native
18490
+ * providers emit motion as a RISING EDGE ONLY (Reolink's Baichuan push and
18491
+ * its email-push SMTP path both emit `detected: true` and never the
18492
+ * counterpart); only the frame-diff analyzer emits falls. So on an
18493
+ * onboard-only camera a window that closed only on `detected: false` never
18494
+ * closed at all, and `on-motion` silently behaved as `always-on` — on a
18495
+ * battery camera, the one failure mode the mode exists to prevent.
18496
+ *
18497
+ * Every motion event rearms this timer WITHOUT restarting the stream, so a
18498
+ * burst of re-fires costs nothing. A falling edge, when one does arrive,
18499
+ * still closes earlier via `motionCooldownMs` — whichever comes first wins.
18500
+ *
18501
+ * Not consumed by the runner: carried here so it shares the per-camera
18502
+ * device-settings surface with `motionCooldownMs`, exactly like
18503
+ * `maxSessionHoldMs`.
18504
+ */
18505
+ audioMotionWindowMs: number().min(audioMotionWindowMsField.min).max(audioMotionWindowMsField.max).optional(),
18001
18506
  motionFps: number().min(motionFpsField.min).max(motionFpsField.max).default(motionFpsField.default),
18002
18507
  detectionFps: number().min(detectionFpsField.min).max(detectionFpsField.max).default(detectionFpsField.default),
18003
18508
  motionStreamId: string(),
@@ -18093,7 +18598,7 @@ var RunnerCameraConfigSchema = object({
18093
18598
  */
18094
18599
  inferenceDevices: array(RunnerInferenceDeviceSchema).readonly().optional()
18095
18600
  });
18096
- motionFpsField.min, motionFpsField.max, motionFpsField.step, motionFpsField.default, detectionFpsField.min, detectionFpsField.max, detectionFpsField.step, detectionFpsField.default, motionCooldownMsField.min, motionCooldownMsField.max, motionCooldownMsField.step, motionCooldownMsField.default, maxSessionHoldMsField.min, maxSessionHoldMsField.max, maxSessionHoldMsField.step, maxSessionHoldMsField.default, occupancyRecheckSecField.min, occupancyRecheckSecField.max, occupancyRecheckSecField.step, occupancyRecheckSecField.default, occupancyRecheckFramesField.min, occupancyRecheckFramesField.max, occupancyRecheckFramesField.step, occupancyRecheckFramesField.default;
18601
+ motionFpsField.min, motionFpsField.max, motionFpsField.step, motionFpsField.default, detectionFpsField.min, detectionFpsField.max, detectionFpsField.step, detectionFpsField.default, motionCooldownMsField.min, motionCooldownMsField.max, motionCooldownMsField.step, motionCooldownMsField.default, maxSessionHoldMsField.min, maxSessionHoldMsField.max, maxSessionHoldMsField.step, maxSessionHoldMsField.default, audioMotionWindowMsField.min, audioMotionWindowMsField.max, audioMotionWindowMsField.step, audioMotionWindowMsField.default, occupancyRecheckSecField.min, occupancyRecheckSecField.max, occupancyRecheckSecField.step, occupancyRecheckSecField.default, occupancyRecheckFramesField.min, occupancyRecheckFramesField.max, occupancyRecheckFramesField.step, occupancyRecheckFramesField.default;
18097
18602
  /**
18098
18603
  * Runtime load summary returned by `getLocalLoad`. Used by the orchestrator's
18099
18604
  * load-balancing levels (L2 capacity-based, L3 hardware-aware) to decide
@@ -19198,7 +19703,16 @@ targets: array(object({
19198
19703
  /** A sleeping battery camera: the frame is deliberately stale and will
19199
19704
  * NOT refresh in the background. A surface should say so rather than
19200
19705
  * present it as current. */
19201
- sleeping: boolean()
19706
+ sleeping: boolean(),
19707
+ /** Current device state rendered over the cached frame. State images
19708
+ * remain authoritative even when their photographic background is
19709
+ * old; null means the link must carry a current camera frame. */
19710
+ stateReason: _enum([
19711
+ "disabled",
19712
+ "sleeping",
19713
+ "unreachable",
19714
+ "waking"
19715
+ ]).nullable()
19202
19716
  })))
19203
19717
  },
19204
19718
  status: {
@@ -20858,6 +21372,25 @@ var BatteryStatusSchema = object({
20858
21372
  /** Ms epoch of the last observation. Lets consumers reason about freshness. */
20859
21373
  lastUpdated: number(),
20860
21374
  /**
21375
+ * Ms epoch of the last time the device PROVED it was reachable — a
21376
+ * completed firmware round-trip, an observed wake, or an inbound push
21377
+ * (firmware event, email). `0`/absent = never since this slice was born.
21378
+ *
21379
+ * This is the ONLY input that separates "asleep" from "gone", and it is
21380
+ * fed exclusively by PASSIVE signals: nothing may write it by reaching
21381
+ * for the radio, because a poll that confirms reachability is the same
21382
+ * poll that drains the battery. See {@link deriveBatteryPresence} — the
21383
+ * single derivation every consumer must use; no surface computes its own.
21384
+ *
21385
+ * It is deliberately NOT a clock in the
21386
+ * `scripts/check-runtime-state-durability.ts` sense: it is the
21387
+ * observation itself, and it is the only thing a 30-hour silence is
21388
+ * visible in. Writers quantise it (see `CONTACT_WRITE_QUANTUM_MS` in the
21389
+ * Reolink provider) so a value that means "recently" cannot cost a
21390
+ * SQLite commit per round-trip.
21391
+ */
21392
+ lastContactAt: number().optional(),
21393
+ /**
20861
21394
  * True when the source is a BINARY low-battery indicator (HA
20862
21395
  * `binary_sensor` device_class=battery / `LOW_BAT`) that has no real
20863
21396
  * charge level — `percentage` is then a coarse stand-in (100 = normal,
@@ -26389,14 +26922,77 @@ method(object({
26389
26922
  * thing except the comparator: `similarity` (CLIP cosine at the same ROI coords
26390
26923
  * vs condition-tagged references) and `llm` (vision-LLM judgment over the crop).
26391
26924
  *
26392
- * D14 device-config archetype (`deviceConfig.ui.kind:'widget'`) the framework
26393
- * derives the device-detail contribution; the provider carries NO hand-written
26394
- * settings-contribution methods. `status.kind:'push'` the engine pushes on
26395
- * every hysteresis flip / availability change; consumers never poll.
26396
- */
26397
- /** Extensible condition tag. Seeded 'day' | 'night'; open by design so more can
26398
- * be added without a wire break (matching falls back to any-condition refs). */
26925
+ * **No `deviceConfig`, deliberately.** This shipped as the D14 widget archetype,
26926
+ * which put a "Scenes" tab on one camera's detail page. That is the wrong shape
26927
+ * for the thing: a scene is a standing question about the property ("is the bin
26928
+ * still out"), and the operator's question is "which of my scenes have tripped",
26929
+ * across every camera at once — not "what does camera 617 think". Buried one
26930
+ * camera deep it also could not be found. The surface is now a top-level admin
26931
+ * page (`/scenes`, `pages/Scenes.tsx`) that lists every scene on every camera and
26932
+ * picks the camera inside the create flow, the same shape Events and Faces have.
26933
+ *
26934
+ * The consequence to keep in mind: `host/scene-monitor-editor` is gone from
26935
+ * `HOST_WIDGETS` too. `scripts/check-host-widget-resolves.ts` asserts BOTH
26936
+ * directions, so a registration nobody declares fails exactly as loudly as a
26937
+ * declaration nobody registers. The editor is imported directly by the page.
26938
+ *
26939
+ * `status.kind:'push'` — the engine pushes on every hysteresis flip /
26940
+ * availability change; consumers never poll.
26941
+ */
26942
+ /** Extensible condition tag. Seeded 'day' | 'ir' (the two variants the operator
26943
+ * captures) plus 'night' | 'dawn' | 'dusk' from the resolver's sun-times band.
26944
+ * Open by design so more can be added without a wire break.
26945
+ *
26946
+ * Matching does NOT fall back across conditions: cross-condition cosines are
26947
+ * not comparable, so "I have never seen this scene in this light" is reported
26948
+ * as `unknown`, never guessed. A day reference scored against an IR frame
26949
+ * collapses the cosine and would latch a false alarm every single night. */
26399
26950
  var SceneConditionSchema = string();
26951
+ /**
26952
+ * What a scene does when the CURRENT light has no reference of its own.
26953
+ *
26954
+ * The lighting variants are not equally likely to exist. Almost every operator
26955
+ * captures daylight and then never stands outside at 22:00 to capture IR, and a
26956
+ * scene that is only ever going to be asked about a daytime question ("is the
26957
+ * bin still on the kerb at 08:00") does not need a night reference at all. The
26958
+ * night half must therefore be OPTIONAL, and optional means the scene keeps
26959
+ * working without it rather than degrading into a permanent complaint.
26960
+ *
26961
+ * - `skip` (default) — the check in that light is not made. Not a verdict, not
26962
+ * an alarm, not even an `unknown`: the live state simply stays whatever the
26963
+ * last covered light left it at, the latch is untouched, and the hysteresis
26964
+ * run is neither spent nor cleared. The scene resumes by itself at first
26965
+ * light. This is the only behaviour under which "I never captured IR" is a
26966
+ * configuration choice instead of a nightly fault.
26967
+ * - `judge-anyway` — score against the OTHER conditions' references. Available
26968
+ * for cameras whose IR frame is close enough to daylight (a floodlit
26969
+ * driveway, an always-white-light doorbell), and wrong for everything else:
26970
+ * cross-condition cosines are not comparable, so a day reference against a
26971
+ * true IR frame collapses and the scene reports a theft at 21:40.
26972
+ *
26973
+ * Never applies when the scene has NO comparable reference at all — that is
26974
+ * "not armed yet", it is reported as `no-reference-for-condition`, and silence
26975
+ * there would hide a scene the operator never finished setting up.
26976
+ */
26977
+ var SceneUncoveredPolicySchema = _enum(["skip", "judge-anyway"]);
26978
+ /** `matched` = the baseline is what we see; `diverged` = it demonstrably is not;
26979
+ * `unknown` = we cannot judge (no reference for this condition, encoder model
26980
+ * changed, view shifted, no snapshot). `unknown` is a real value, not a null,
26981
+ * and never counts toward hysteresis in either direction. */
26982
+ var SceneVerdictSchema = _enum([
26983
+ "matched",
26984
+ "diverged",
26985
+ "unknown"
26986
+ ]);
26987
+ /** Why a scene cannot judge. Named, because this feature's failure mode is
26988
+ * silence that reads as "nothing has happened". */
26989
+ var SceneUnavailableSchema = _enum([
26990
+ "no-reference-for-condition",
26991
+ "view-shifted",
26992
+ "no-vision-profile",
26993
+ "encoder-model-changed",
26994
+ "no-snapshot"
26995
+ ]);
26400
26996
  /** One captured reference — condition-tagged, model-version-gated. `embedding`
26401
26997
  * is `number[]` (Float32Array does NOT survive MsgPack/UDS). */
26402
26998
  var SceneReferenceSchema = object({
@@ -26404,7 +27000,14 @@ var SceneReferenceSchema = object({
26404
27000
  modelId: string(),
26405
27001
  condition: SceneConditionSchema,
26406
27002
  capturedAt: number(),
26407
- thumbnailMediaId: string().optional()
27003
+ thumbnailMediaId: string().optional(),
27004
+ /** Whole-frame (downscaled) embedding captured alongside the ROI crop. The
27005
+ * anti-view-shift anchor: a bumped camera, a PTZ preset or a re-aim makes the
27006
+ * normalized rect frame a different piece of world, and the scene would
27007
+ * diverge forever with a perfectly plausible cosine. Checked LAZILY, only
27008
+ * when hysteresis is about to flip — one extra encode per candidate
27009
+ * transition, not per poll. */
27010
+ anchorEmbedding: array(number()).optional()
26408
27011
  });
26409
27012
  var SceneMonitorStateSchema = object({
26410
27013
  id: string(),
@@ -26426,6 +27029,28 @@ var SceneCheckSchema = discriminatedUnion("mode", [object({
26426
27029
  profileId: string().optional(),
26427
27030
  hysteresisCount: number().int().positive()
26428
27031
  })]);
27032
+ var SCENE_DEFAULT_ANCHOR_THRESHOLD = .85;
27033
+ /** Night is OPTIONAL. A scene with only a daylight reference sits the IR hours
27034
+ * out in silence rather than reporting a fault every night. */
27035
+ var SCENE_DEFAULT_UNCOVERED_POLICY = "skip";
27036
+ /**
27037
+ * Vision-model adjudication of a candidate flip. Field names deliberately
27038
+ * mirror `NcConfirmSchema` so an operator meets one vocabulary, not two.
27039
+ *
27040
+ * `onTimeout` defaults to **'hold'**, the OPPOSITE of `NcConfirmGate`'s
27041
+ * fail-open: a notification suppressed is the worse error there, but a vision
27042
+ * model that timed out has not told us the bin is gone, and a latch is a
27043
+ * stateful claim that costs the operator a trip to reset.
27044
+ */
27045
+ var SceneConfirmSchema = object({
27046
+ enabled: boolean().default(false),
27047
+ prompt: string().min(1).max(1e3),
27048
+ profileId: string().optional(),
27049
+ timeoutMs: number().int().min(1e3).max(2e4).default(8e3),
27050
+ maxImagePx: number().int().min(64).max(2048).default(448),
27051
+ /** What a timeout / unavailable model means for the PENDING flip. */
27052
+ onTimeout: _enum(["flip", "hold"]).default("hold")
27053
+ });
26429
27054
  var SceneMonitorSchema = object({
26430
27055
  id: string(),
26431
27056
  label: string(),
@@ -26444,7 +27069,56 @@ var SceneMonitorSchema = object({
26444
27069
  lastConfidence: number().nullable(),
26445
27070
  currentCondition: SceneConditionSchema.nullable(),
26446
27071
  availability: _enum(["ok", "unavailable"]),
26447
- unavailableReason: string().nullable()
27072
+ unavailableReason: string().nullable(),
27073
+ /** Which state is "the initial screen". `null` until the first capture. */
27074
+ baselineStateId: string().nullable(),
27075
+ /** Which boolean drives notification rules and any export. */
27076
+ emit: _enum(["latched", "live"]).default("latched"),
27077
+ /** Live: does the region match the baseline RIGHT NOW. */
27078
+ verdict: SceneVerdictSchema,
27079
+ /** Has it been `diverged` at least once since `armedAt` — the operator's boolean. */
27080
+ latched: boolean(),
27081
+ /** Last reset (or creation). */
27082
+ armedAt: number(),
27083
+ divergedAt: number().nullable(),
27084
+ restoredAt: number().nullable(),
27085
+ /** A check is only COUNTED when the device has been quiet this long. Motion
27086
+ * during the window DISCARDS the observation — a car pulling up in front of
27087
+ * the bin must not be able to spend hysteresis credit. */
27088
+ quietSeconds: number().int().min(0).max(3600).default(60),
27089
+ /** An observation only advances the pending count when it is at least this
27090
+ * far from the previously counted one, so N agreeing checks span real time
27091
+ * rather than N adjacent polls inside one occlusion. */
27092
+ minObservationSpacingSec: number().int().min(0).max(3600).default(120),
27093
+ /** Vision-model adjudication of a candidate flip. Similarity primary only. */
27094
+ confirm: SceneConfirmSchema.optional(),
27095
+ /** Whole-frame anchor cosine below which a flip is REFUSED as `view-shifted`. */
27096
+ anchorThreshold: number().min(0).max(1).default(SCENE_DEFAULT_ANCHOR_THRESHOLD),
27097
+ /** Clear the latch on its own when the scene matches again? Default false —
27098
+ * `restoredAt` and the `scene-restored` edge are recorded regardless, so an
27099
+ * automation can react to the bin coming back without the operator's own
27100
+ * alarm silently clearing itself. */
27101
+ autoRestore: boolean().default(false),
27102
+ /** What to do when the current light has no reference of its own. See
27103
+ * {@link SceneUncoveredPolicySchema} — the default makes night OPTIONAL. */
27104
+ onUncoveredCondition: SceneUncoveredPolicySchema.default(SCENE_DEFAULT_UNCOVERED_POLICY),
27105
+ /**
27106
+ * The light whose checks are currently being SAT OUT under
27107
+ * `onUncoveredCondition: 'skip'` — `null` when the scene is checking normally.
27108
+ *
27109
+ * Engine-reported and advisory only: it moves no verdict, no latch and no
27110
+ * hysteresis. It exists so the card can say *"night (IR) — checks paused,
27111
+ * nothing captured in this light"* in the same calm voice as the coverage
27112
+ * line, because the alternative is a scene that silently stops answering
27113
+ * after sunset with nothing anywhere saying why. A skipped check must never
27114
+ * read as a broken one.
27115
+ */
27116
+ suspendedCondition: SceneConditionSchema.nullable().default(null),
27117
+ /** Named cause when `verdict === 'unknown'`. */
27118
+ unavailable: SceneUnavailableSchema.nullable(),
27119
+ /** Conditions that have at least one comparable reference — the coverage line
27120
+ * ("day ✓ · ir ✓ · dusk ✗") that turns a silent fallback into a visible fact. */
27121
+ coveredConditions: array(SceneConditionSchema)
26448
27122
  });
26449
27123
  var SceneMonitorStatusSchema = object({
26450
27124
  monitors: array(SceneMonitorSchema),
@@ -26457,12 +27131,6 @@ var sceneMonitorCapability = {
26457
27131
  kind: "wrapper",
26458
27132
  defaultActive: true,
26459
27133
  deviceTypes: [DeviceType.Camera],
26460
- deviceConfig: { ui: {
26461
- kind: "widget",
26462
- widgetId: "host/scene-monitor-editor",
26463
- tab: "scenes",
26464
- label: "Scenes"
26465
- } },
26466
27134
  methods: {
26467
27135
  listScenes: method(object({ deviceId: number() }), SceneMonitorStatusSchema),
26468
27136
  createScene: method(object({
@@ -26493,7 +27161,15 @@ var sceneMonitorCapability = {
26493
27161
  "both"
26494
27162
  ]).optional(),
26495
27163
  checkIntervalSec: number().optional(),
26496
- check: SceneCheckSchema.optional()
27164
+ check: SceneCheckSchema.optional(),
27165
+ emit: _enum(["latched", "live"]).optional(),
27166
+ quietSeconds: number().int().min(0).max(3600).optional(),
27167
+ minObservationSpacingSec: number().int().min(0).max(3600).optional(),
27168
+ anchorThreshold: number().min(0).max(1).optional(),
27169
+ autoRestore: boolean().optional(),
27170
+ onUncoveredCondition: SceneUncoveredPolicySchema.optional(),
27171
+ /** `null` clears the vision-model adjudicator. */
27172
+ confirm: SceneConfirmSchema.nullable().optional()
26497
27173
  })
26498
27174
  }), _void(), {
26499
27175
  kind: "mutation",
@@ -26534,6 +27210,26 @@ var sceneMonitorCapability = {
26534
27210
  }), _void(), {
26535
27211
  kind: "mutation",
26536
27212
  auth: "admin"
27213
+ }),
27214
+ /**
27215
+ * Clear the latch, re-arm, and — by default — RE-CAPTURE the baseline for
27216
+ * the CURRENT condition. The bin never goes back in exactly the same spot;
27217
+ * "reset" in the operator's head means *this is the new normal*, and
27218
+ * re-capture is what makes the feature self-healing against slow drift
27219
+ * instead of failing silently weeks later.
27220
+ *
27221
+ * Reachable from three surfaces on this one mutation: the scene card, a
27222
+ * notification button (an `onTrigger` sequence with a `kind:'cap'` step —
27223
+ * no new Notification-Center code at all), and tRPC for scripts.
27224
+ */
27225
+ resetScene: method(object({
27226
+ deviceId: number(),
27227
+ monitorId: string(),
27228
+ /** Defaults to TRUE at the provider seam — see `SCENE_RESET_RECAPTURES`. */
27229
+ recapture: boolean().optional()
27230
+ }), _void(), {
27231
+ kind: "mutation",
27232
+ auth: "admin"
26537
27233
  })
26538
27234
  },
26539
27235
  status: {
@@ -26776,13 +27472,63 @@ var CamStreamDescriptorSchema = object({
26776
27472
  * set of stream descriptors it can offer for the device, synchronously, so the
26777
27473
  * broker can reconcile its registry against the authoritative provider state.
26778
27474
  */
27475
+ /**
27476
+ * The catalog as a DURABLE fact rather than a live answer.
27477
+ *
27478
+ * A battery camera's descriptors are profile-stable — they change when the
27479
+ * operator rewrites an encoder profile, not minute to minute — but building
27480
+ * them costs a Baichuan login, which on a sleeping Argus IS a wake. So the
27481
+ * provider is allowed to build them exactly once per profile and must serve
27482
+ * every later pull from a cache.
27483
+ *
27484
+ * Holding that cache only in RAM is what turned a restart into an outage. The
27485
+ * runner comes back with the camera asleep, `buildStreamCatalogUncached`
27486
+ * correctly refuses to wake it, the pull answers `[]`, the broker has no
27487
+ * cam-stream entry to build a broker from, and `webrtcSession.handleOffer`
27488
+ * fails with a flat "No broker for stream" — for as long as the camera sleeps,
27489
+ * which on a battery cam is most of the day. The camera was fine. The stream
27490
+ * was unreachable because the process had forgotten what the camera offers.
27491
+ *
27492
+ * Declaring it here puts it in `device-runtime-state`, the kernel's canonical
27493
+ * declared collection, with the same `restored` durability `battery` uses for
27494
+ * the same reason: the last known value is the only value there is while the
27495
+ * device is asleep. The broker's brokers are therefore always DEFINABLE — it
27496
+ * is the DIAL that wakes a camera, never the catalog (D173).
27497
+ */
27498
+ var StreamCatalogStateSchema = object({
27499
+ /** The descriptors as last built from a real camera response. Never a guess:
27500
+ * a failed or refused build writes NOTHING, so a restored catalog is always
27501
+ * one the camera itself once produced. */
27502
+ descriptors: array(CamStreamDescriptorSchema),
27503
+ /** Ms epoch of the build that produced {@link descriptors}. Lets the wake
27504
+ * path decide whether the camera's own awake window is worth spending on a
27505
+ * re-read. */
27506
+ lastFetchedAt: number()
27507
+ });
26779
27508
  var streamCatalogCapability = {
26780
27509
  name: "stream-catalog",
26781
27510
  scope: "device",
26782
27511
  deviceNative: true,
26783
27512
  mode: "singleton",
26784
27513
  deviceTypes: [DeviceType.Camera],
26785
- methods: { getCatalog: method(object({ deviceId: number().int().nonnegative() }), array(CamStreamDescriptorSchema).readonly()) }
27514
+ methods: { getCatalog: method(object({ deviceId: number().int().nonnegative() }), array(CamStreamDescriptorSchema).readonly()) },
27515
+ runtimeState: StreamCatalogStateSchema,
27516
+ /**
27517
+ * Runtime-state durability: **restored** — see the schema doc. A cold
27518
+ * catalog on a sleeping battery camera is not a slow first frame, it is a
27519
+ * camera that cannot be watched at all until it happens to wake.
27520
+ *
27521
+ * Churn is nil by construction: the slice is written only by a SUCCESSFUL
27522
+ * build, and a build only runs when there is no cached copy (or the copy is
27523
+ * a day old and the camera is awake anyway).
27524
+ *
27525
+ * See `RuntimeStateDurability`. Enforced by
27526
+ * `scripts/check-runtime-state-durability.ts`.
27527
+ */
27528
+ durability: "restored",
27529
+ /** Clock field: written, but excluded from the compare that decides whether
27530
+ * persisting is worth a SQLite commit — the descriptors are the value. */
27531
+ volatileStateFields: ["lastFetchedAt"]
26786
27532
  };
26787
27533
  /** One of the camera's stream profiles. */
26788
27534
  var StreamProfileSchema = _enum([
@@ -27235,12 +27981,64 @@ var NetworkAddressSchema = object({
27235
27981
  family: string(),
27236
27982
  internal: boolean()
27237
27983
  });
27984
+ /**
27985
+ * Provenance of the site coordinates, and the whole reason this is not just two
27986
+ * numbers.
27987
+ *
27988
+ * - `operator-set` — a human typed it, or accepted a detection. Authoritative;
27989
+ * nothing overwrites it.
27990
+ * - `derived-from-ip` — the hub geolocated its own public IP once, because a
27991
+ * default that is right to a few kilometres beats the coarse UTC clock split
27992
+ * the sun-times consumers otherwise fall back to.
27993
+ *
27994
+ * The UI shows which one it is. An operator who cannot tell a guess from their
27995
+ * own input will eventually trust the guess.
27996
+ */
27997
+ var SiteLocationSourceSchema = _enum(["operator-set", "derived-from-ip"]);
27998
+ /**
27999
+ * The read shape: the location plus the honest state of the one-shot derivation.
28000
+ *
28001
+ * `derivationAttemptedAt` is what makes the "one call, ever" contract
28002
+ * inspectable. When it is set and `location` is null, the geo-IP lookup ran and
28003
+ * failed; the hub will NOT try again on its own — the fallback is declared
28004
+ * (consumers degrade to their own last resort) and the operator either types the
28005
+ * coordinates or presses detect.
28006
+ */
28007
+ var SiteLocationStatusSchema = object({
28008
+ location: object({
28009
+ /** WGS84 decimal degrees. */
28010
+ latitude: number().min(-90).max(90),
28011
+ longitude: number().min(-180).max(180),
28012
+ source: SiteLocationSourceSchema,
28013
+ /** Epoch ms the value was last written. */
28014
+ updatedAt: number(),
28015
+ /**
28016
+ * Human-readable place the geo-IP service reported ("Napoli, IT"). Display
28017
+ * only — never parsed, never matched on. Absent for an operator-typed value.
28018
+ */
28019
+ label: string().optional()
28020
+ }).nullable(),
28021
+ derivationAttemptedAt: number().nullable(),
28022
+ /** Why the last derivation failed, for the UI to show instead of a shrug. */
28023
+ derivationError: string().nullable()
28024
+ });
28025
+ /** `null` clears the location and re-arms nothing — the derivation stays spent. */
28026
+ var SetSiteLocationInputSchema = object({
28027
+ latitude: number().min(-90).max(90),
28028
+ longitude: number().min(-180).max(180)
28029
+ }).nullable();
27238
28030
  method(_void(), FeatureManifestSchema), method(_void(), HealthStatusSchema), method(_void(), FeatureManifestSchema), method(_void(), array(NetworkAddressSchema).readonly()), method(_void(), unknown().nullable(), { auth: "admin" }), method(record(string(), unknown()), _null(), {
27239
28031
  kind: "mutation",
27240
28032
  auth: "admin"
27241
28033
  }), method(_void(), _void(), {
27242
28034
  kind: "mutation",
27243
28035
  auth: "admin"
28036
+ }), method(_void(), SiteLocationStatusSchema), method(SetSiteLocationInputSchema, SiteLocationStatusSchema, {
28037
+ kind: "mutation",
28038
+ auth: "admin"
28039
+ }), method(_void(), SiteLocationStatusSchema, {
28040
+ kind: "mutation",
28041
+ auth: "admin"
27244
28042
  });
27245
28043
  /**
27246
28044
  * Tamper / case-open detection sensor. Drives Home Assistant
@@ -28594,6 +29392,7 @@ var DEVICE_LOCAL_STATE_CAPS = {
28594
29392
  sceneMonitor: sceneMonitorCapability,
28595
29393
  scriptRunner: scriptRunnerCapability,
28596
29394
  smoke: smokeCapability,
29395
+ streamCatalog: streamCatalogCapability,
28597
29396
  streamParams: streamParamsCapability,
28598
29397
  switch: switchCapability,
28599
29398
  tamper: tamperCapability,
@@ -29247,6 +30046,15 @@ var BaseDeviceProvider = class extends BaseAddon {
29247
30046
  labels: ["probe not implemented"]
29248
30047
  };
29249
30048
  }
30049
+ /**
30050
+ * Top-level devices restored at once in {@link onRestoreDevices}.
30051
+ *
30052
+ * Four covers the fleets this ships to without turning a boot into a burst a
30053
+ * camera NVR answers with a refusal. A provider whose upstream is a single
30054
+ * session with a serial command channel (a Baichuan hub, an NVR that
30055
+ * serialises ISAPI) should lower it; nothing needs to raise it.
30056
+ */
30057
+ restoreConcurrency = 4;
29250
30058
  async restoreDevices(savedDevices) {
29251
30059
  await this.onRestoreDevices(savedDevices);
29252
30060
  if (savedDevices.length > 0) this.ctx.logger.info(`Restored ${savedDevices.length} ${this.providerName} device(s)`);
@@ -29278,15 +30086,15 @@ var BaseDeviceProvider = class extends BaseAddon {
29278
30086
  */
29279
30087
  async onRestoreDevices(savedDevices) {
29280
30088
  const restored = /* @__PURE__ */ new Set();
29281
- for (const saved of savedDevices) {
29282
- if (saved.parentDeviceId !== null) continue;
30089
+ const topLevel = savedDevices.filter((saved) => saved.parentDeviceId === null);
30090
+ const restoreOne = async (saved) => {
29283
30091
  const Class = this.deviceClasses[saved.type];
29284
30092
  if (!Class) {
29285
30093
  this.ctx.logger.warn("No device class registered for restored type — skipping", {
29286
30094
  tags: { stableId: saved.stableId },
29287
30095
  meta: { type: saved.type }
29288
30096
  });
29289
- continue;
30097
+ return;
29290
30098
  }
29291
30099
  try {
29292
30100
  await this.ctx.kernel.devices.create(saved.stableId, Class, {});
@@ -29300,7 +30108,15 @@ var BaseDeviceProvider = class extends BaseAddon {
29300
30108
  }
29301
30109
  });
29302
30110
  }
29303
- }
30111
+ };
30112
+ let nextTopLevel = 0;
30113
+ await Promise.all(Array.from({ length: Math.min(Math.max(1, this.restoreConcurrency), topLevel.length) }, async () => {
30114
+ for (;;) {
30115
+ const saved = topLevel[nextTopLevel++];
30116
+ if (saved === void 0) return;
30117
+ await restoreOne(saved);
30118
+ }
30119
+ }));
29304
30120
  const childRows = savedDevices.filter((s) => s.parentDeviceId !== null);
29305
30121
  for (const saved of childRows) {
29306
30122
  const Class = this.deviceClasses[saved.type];
@@ -31522,6 +32338,12 @@ Object.freeze({
31522
32338
  addonId: null,
31523
32339
  access: "create"
31524
32340
  },
32341
+ "llm.cancel": {
32342
+ capName: "llm",
32343
+ capScope: "system",
32344
+ addonId: null,
32345
+ access: "create"
32346
+ },
31525
32347
  "llm.deleteModel": {
31526
32348
  capName: "llm",
31527
32349
  capScope: "system",
@@ -31606,6 +32428,12 @@ Object.freeze({
31606
32428
  addonId: null,
31607
32429
  access: "view"
31608
32430
  },
32431
+ "llm.resolveModelRef": {
32432
+ capName: "llm",
32433
+ capScope: "system",
32434
+ addonId: null,
32435
+ access: "create"
32436
+ },
31609
32437
  "llm.setDefault": {
31610
32438
  capName: "llm",
31611
32439
  capScope: "system",
@@ -33772,6 +34600,12 @@ Object.freeze({
33772
34600
  addonId: null,
33773
34601
  access: "create"
33774
34602
  },
34603
+ "sceneMonitor.resetScene": {
34604
+ capName: "scene-monitor",
34605
+ capScope: "device",
34606
+ addonId: null,
34607
+ access: "delete"
34608
+ },
33775
34609
  "sceneMonitor.updateScene": {
33776
34610
  capName: "scene-monitor",
33777
34611
  capScope: "device",
@@ -34450,6 +35284,12 @@ Object.freeze({
34450
35284
  addonId: null,
34451
35285
  access: "create"
34452
35286
  },
35287
+ "system.detectSiteLocation": {
35288
+ capName: "system",
35289
+ capScope: "system",
35290
+ addonId: null,
35291
+ access: "create"
35292
+ },
34453
35293
  "system.featureFlags": {
34454
35294
  capName: "system",
34455
35295
  capScope: "system",
@@ -34468,6 +35308,12 @@ Object.freeze({
34468
35308
  addonId: null,
34469
35309
  access: "view"
34470
35310
  },
35311
+ "system.getSiteLocation": {
35312
+ capName: "system",
35313
+ capScope: "system",
35314
+ addonId: null,
35315
+ access: "view"
35316
+ },
34471
35317
  "system.health": {
34472
35318
  capName: "system",
34473
35319
  capScope: "system",
@@ -34492,6 +35338,12 @@ Object.freeze({
34492
35338
  addonId: null,
34493
35339
  access: "create"
34494
35340
  },
35341
+ "system.setSiteLocation": {
35342
+ capName: "system",
35343
+ capScope: "system",
35344
+ addonId: null,
35345
+ access: "create"
35346
+ },
34495
35347
  "terminalSession.adoptLegacyMonitor": {
34496
35348
  capName: "terminal-session",
34497
35349
  capScope: "system",
@@ -35974,6 +36826,11 @@ Object.freeze({
35974
36826
  form: "single",
35975
36827
  optional: false
35976
36828
  }],
36829
+ "pipelineAnalytics.getEventMedia": [{
36830
+ name: "deviceId",
36831
+ form: "single",
36832
+ optional: false
36833
+ }],
35977
36834
  "pipelineAnalytics.getKeyEvents": [{
35978
36835
  name: "deviceId",
35979
36836
  form: "single",
@@ -36004,6 +36861,11 @@ Object.freeze({
36004
36861
  form: "single",
36005
36862
  optional: false
36006
36863
  }],
36864
+ "pipelineAnalytics.getTrackMedia": [{
36865
+ name: "deviceId",
36866
+ form: "single",
36867
+ optional: false
36868
+ }],
36007
36869
  "pipelineAnalytics.getTrainingExportSummary": [{
36008
36870
  name: "deviceIds",
36009
36871
  form: "array",
@@ -36039,6 +36901,11 @@ Object.freeze({
36039
36901
  form: "array",
36040
36902
  optional: true
36041
36903
  }],
36904
+ "pipelineAnalytics.listTrackMedia": [{
36905
+ name: "deviceId",
36906
+ form: "single",
36907
+ optional: false
36908
+ }],
36042
36909
  "pipelineAnalytics.listTracks": [{
36043
36910
  name: "deviceId",
36044
36911
  form: "single",
@@ -36454,6 +37321,11 @@ Object.freeze({
36454
37321
  form: "single",
36455
37322
  optional: false
36456
37323
  }],
37324
+ "sceneMonitor.resetScene": [{
37325
+ name: "deviceId",
37326
+ form: "single",
37327
+ optional: false
37328
+ }],
36457
37329
  "sceneMonitor.updateScene": [{
36458
37330
  name: "deviceId",
36459
37331
  form: "single",
@@ -36474,6 +37346,12 @@ Object.freeze({
36474
37346
  form: "single",
36475
37347
  optional: false
36476
37348
  }],
37349
+ "snapshot.getSnapshotLinks": [{
37350
+ name: "targets",
37351
+ form: "object-array",
37352
+ optional: false,
37353
+ itemField: "deviceId"
37354
+ }],
36477
37355
  "snapshot.getSnapshotOverview": [{
36478
37356
  name: "deviceIds",
36479
37357
  form: "array",