@camstack/addon-provider-homeassistant 1.2.29 → 1.2.31

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.
@@ -1,4 +1,4 @@
1
- //#region ../types/dist/event-category-Cv9dO26A.mjs
1
+ //#region ../types/dist/event-category-Bxo5yJjt.mjs
2
2
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
3
3
  EventCategory["SystemBoot"] = "system.boot";
4
4
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -205,6 +205,33 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
205
205
  EventCategory["PipelineCameraAssigned"] = "pipeline.camera-assigned";
206
206
  EventCategory["PipelineCameraUnassigned"] = "pipeline.camera-unassigned";
207
207
  /**
208
+ * A node the orchestrator would otherwise place cameras on has NO usable
209
+ * inference device: the operator enabled one or more accelerators there and
210
+ * the live probe reports every one of them unavailable. Emitted once per
211
+ * TRANSITION into that state (never per dispatch), and the node is dropped
212
+ * from the placement candidate set for as long as it holds.
213
+ *
214
+ * This exists because the state was previously invisible: little-unraid
215
+ * absorbed 283k inference errors in a day while still being handed cameras,
216
+ * and nothing in the system said so.
217
+ *
218
+ * A node with no accelerators configured at all is NOT this — its devices
219
+ * are `disabled`, not `unavailable`, and the runner's default CPU pool
220
+ * serves it exactly as before.
221
+ */
222
+ EventCategory["PipelineNodeInferenceUnavailable"] = "pipeline.node-inference-unavailable";
223
+ /**
224
+ * A camera has an OPEN detection session and has produced no detection at
225
+ * all for longer than the blind threshold — the camera is being decoded and
226
+ * inferred and is returning nothing. Emitted once per transition into blind,
227
+ * per camera.
228
+ *
229
+ * The failure it reports: a 1h43 detection blackout on the entrance camera
230
+ * that nobody noticed, because "a camera that detects nothing" and "a quiet
231
+ * camera" produce byte-identical silence.
232
+ */
233
+ EventCategory["PipelineDetectionBlind"] = "pipeline.detection-blind";
234
+ /**
208
235
  * Per-camera pipeline config was mutated by the orchestrator
209
236
  * (3-level settings change via `setAgentAddonDefaults` /
210
237
  * `setCameraStepToggle` / `setCameraPipelineForAgent` or a
@@ -11076,6 +11103,8 @@ var QueryFilterSchema = object({
11076
11103
  where: record(string(), unknown()).optional(),
11077
11104
  whereIn: record(string(), array(unknown())).optional(),
11078
11105
  whereBetween: record(string(), tuple([unknown(), unknown()])).optional(),
11106
+ /** NULL-safe exclusion: matches rows whose field is NULL OR != the value. */
11107
+ whereNot: record(string(), unknown()).optional(),
11079
11108
  orderBy: object({
11080
11109
  field: string(),
11081
11110
  direction: _enum(["asc", "desc"])
@@ -11095,7 +11124,8 @@ var QueryFilterSchema = object({
11095
11124
  var MutationFilterSchema = object({
11096
11125
  where: record(string(), unknown()).optional(),
11097
11126
  whereIn: record(string(), array(unknown())).optional(),
11098
- whereBetween: record(string(), tuple([unknown(), unknown()])).optional()
11127
+ whereBetween: record(string(), tuple([unknown(), unknown()])).optional(),
11128
+ whereNot: record(string(), unknown()).optional()
11099
11129
  });
11100
11130
  /** A single stored record: `{ id, data }`. */
11101
11131
  var SettingsRecordSchema = object({
@@ -12701,6 +12731,17 @@ var LlmImageSchema = object({
12701
12731
  bytes: _instanceof(Uint8Array),
12702
12732
  mimeType: string()
12703
12733
  });
12734
+ /**
12735
+ * Retry policy. `enabled: false` is NOT the same as `maxAttempts: 1` in intent —
12736
+ * the flag is what a consumer table flips, the count is what the operator tunes.
12737
+ * A retry doubles the wall time of a call, so the two gates that run inside a
12738
+ * notification's budget keep it off (see `CONSUMER_RETRY_POLICY` in addon-ai).
12739
+ */
12740
+ var LlmRetryPolicySchema = object({
12741
+ enabled: boolean().default(false),
12742
+ /** Total attempts INCLUDING the first. 1 = no retry. */
12743
+ maxAttempts: number().int().min(1).max(5).default(1)
12744
+ });
12704
12745
  var LlmGenerateBaseInputSchema = object({
12705
12746
  /** Collection routing (the notification-output posture). */
12706
12747
  addonId: string().optional(),
@@ -12715,7 +12756,28 @@ var LlmGenerateBaseInputSchema = object({
12715
12756
  jsonSchema: record(string(), unknown()).optional(),
12716
12757
  /** Per-call override of the profile default. */
12717
12758
  maxTokens: number().int().positive().optional(),
12718
- temperature: number().optional()
12759
+ temperature: number().optional(),
12760
+ /** Per-call override of the profile default (nucleus sampling). */
12761
+ topP: number().min(0).max(1).optional(),
12762
+ /** Per-call override of the profile default (top-k sampling). */
12763
+ topK: number().int().positive().optional(),
12764
+ /** Per-call override of `profile.timeoutMs` — the total generation bound. */
12765
+ timeoutMs: number().int().positive().optional(),
12766
+ /** Per-call override; beats both the consumer table and the profile. */
12767
+ retry: LlmRetryPolicySchema.optional(),
12768
+ /**
12769
+ * Caller-minted id that makes this generation CANCELLABLE.
12770
+ *
12771
+ * Without it a caller that stops waiting cannot stop the work: the gates race
12772
+ * the call against 8 s and free their own slot when the timer wins, while the
12773
+ * generation upstream keeps running to `profile.timeoutMs` — 60 s by default,
12774
+ * on a single-threaded local model. The per-camera bound then counts WAITS,
12775
+ * not generations, and the real load is unbounded.
12776
+ *
12777
+ * `AbortSignal` cannot cross a process boundary; an id can. Pass one here and
12778
+ * `llm.cancel({ requestId })` tears the socket down.
12779
+ */
12780
+ requestId: string().optional()
12719
12781
  });
12720
12782
  /**
12721
12783
  * `llm-runtime` — node-side managed llama.cpp executor (spec §4). Registered
@@ -12728,6 +12790,18 @@ var LlmGenerateBaseInputSchema = object({
12728
12790
  * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
12729
12791
  * watchdog — operator decision #3).
12730
12792
  */
12793
+ /**
12794
+ * A companion artifact that MUST land beside the main GGUF: the `mmproj`
12795
+ * projector of a vision model, or shards 2..N of a split GGUF. Carried on the
12796
+ * REF rather than looked up at install time, so what the operator approved in
12797
+ * the preview is exactly what the node downloads.
12798
+ */
12799
+ var ManagedModelExtraFileSchema = object({
12800
+ url: string(),
12801
+ filename: string(),
12802
+ sizeBytes: number(),
12803
+ sha256: string().optional()
12804
+ });
12731
12805
  var ManagedModelRefSchema = discriminatedUnion("kind", [
12732
12806
  object({
12733
12807
  kind: literal("catalog"),
@@ -12736,7 +12810,11 @@ var ManagedModelRefSchema = discriminatedUnion("kind", [
12736
12810
  object({
12737
12811
  kind: literal("url"),
12738
12812
  url: string(),
12739
- sha256: string().optional()
12813
+ sha256: string().optional(),
12814
+ /** Picker/status label; the file basename when absent. */
12815
+ label: string().optional(),
12816
+ sizeBytes: number().optional(),
12817
+ extraFiles: array(ManagedModelExtraFileSchema).optional()
12740
12818
  }),
12741
12819
  object({
12742
12820
  kind: literal("path"),
@@ -12754,13 +12832,82 @@ var ManagedRuntimeConfigSchema = object({
12754
12832
  gpuLayers: number().int().default(0),
12755
12833
  /** Default: cpus-2, clamped ≥1 (resolved node-side). */
12756
12834
  threads: number().int().optional(),
12757
- /** Concurrent slots. */
12835
+ /** Concurrent slots (`--parallel`). */
12758
12836
  parallel: number().int().default(1),
12837
+ /** Logical batch size (`-b`). Larger = faster prompt ingest, more RAM. */
12838
+ batchSize: number().int().positive().optional(),
12839
+ /** Physical batch / micro-batch (`-ub`). */
12840
+ ubatchSize: number().int().positive().optional(),
12841
+ /**
12842
+ * `--flash-attn`. Cuts KV-cache memory on the backends that implement it and
12843
+ * is a no-op elsewhere, so it is offered rather than assumed.
12844
+ */
12845
+ flashAttention: boolean().default(false),
12846
+ /**
12847
+ * `--mlock`. Pins the weights in RAM so the OS cannot page them out mid
12848
+ * inference. Costs the full model size in resident memory — which is exactly
12849
+ * what the RAM budget is counting.
12850
+ */
12851
+ mlock: boolean().default(false),
12852
+ /**
12853
+ * `--no-mmap`. Reads the whole GGUF up front instead of mapping it. Slower to
12854
+ * start, but avoids the page-fault stalls a network or spinning-disk model
12855
+ * store produces on every first token.
12856
+ */
12857
+ noMmap: boolean().default(false),
12858
+ /** `--cache-type-k` / `--cache-type-v` — quantising the KV cache is the
12859
+ * cheapest way to fit a longer context in the same RAM. */
12860
+ cacheTypeK: _enum([
12861
+ "f32",
12862
+ "f16",
12863
+ "q8_0",
12864
+ "q5_1",
12865
+ "q5_0",
12866
+ "q4_1",
12867
+ "q4_0"
12868
+ ]).optional(),
12869
+ cacheTypeV: _enum([
12870
+ "f32",
12871
+ "f16",
12872
+ "q8_0",
12873
+ "q5_1",
12874
+ "q5_0",
12875
+ "q4_1",
12876
+ "q4_0"
12877
+ ]).optional(),
12878
+ /**
12879
+ * Escape hatch for llama-server flags this schema does NOT model — `--jinja`
12880
+ * (which most vision chat templates need and some language-only models
12881
+ * dislike), `--cont-batching`, `--rope-scaling`, …
12882
+ *
12883
+ * It is NOT a second place to set the flags above. A token that collides
12884
+ * with a typed field is REJECTED at start, naming the field that owns it
12885
+ * (`assertNoOwnedFlags`), because two knobs writing the same argv is exactly
12886
+ * the "two switches that disagree" failure this repo has already shipped
12887
+ * twice (D62).
12888
+ */
12889
+ extraArgs: array(string()).default([]),
12759
12890
  /** Else lazy: first generate boots it. */
12760
12891
  autoStart: boolean().default(false),
12761
12892
  /** 0 = never; frees RAM after quiet periods. */
12762
12893
  idleStopMinutes: number().int().default(30)
12763
12894
  });
12895
+ /**
12896
+ * Where a multi-GB install currently is. A single 0..1 fraction cannot answer
12897
+ * "is it stuck?" for an install that is three files (shards + mmproj) followed
12898
+ * by a sha256 pass over 22 GB — during which the fraction sat at 1.0 and the
12899
+ * node looked hung. Phase + file + bytes is the smallest shape that does.
12900
+ */
12901
+ var LlmDownloadProgressSchema = object({
12902
+ phase: _enum(["downloading", "verifying"]),
12903
+ /** The artifact currently moving, e.g. `mmproj-F16.gguf`. */
12904
+ file: string(),
12905
+ fileIndex: number().int(),
12906
+ fileCount: number().int(),
12907
+ /** Across the WHOLE install, not the current file. */
12908
+ downloadedBytes: number(),
12909
+ totalBytes: number().optional()
12910
+ });
12764
12911
  var LlmRuntimeStatusSchema = object({
12765
12912
  /** Status is ALWAYS node-qualified. */
12766
12913
  nodeId: string(),
@@ -12777,6 +12924,8 @@ var LlmRuntimeStatusSchema = object({
12777
12924
  modelPath: string().optional(),
12778
12925
  modelId: string().optional(),
12779
12926
  downloadProgress: number().min(0).max(1).optional(),
12927
+ /** Detail behind `downloadProgress`; present for the same lifetime. */
12928
+ download: LlmDownloadProgressSchema.optional(),
12780
12929
  lastError: string().optional(),
12781
12930
  crashesInWindow: number(),
12782
12931
  /** Child RSS (sampled best-effort). */
@@ -12787,7 +12936,14 @@ var LlmNodeModelSchema = object({
12787
12936
  file: string(),
12788
12937
  sizeBytes: number(),
12789
12938
  catalogId: string().optional(),
12790
- installedAt: number().optional()
12939
+ installedAt: number().optional(),
12940
+ /**
12941
+ * Absolute path on the node. Present so a file that is on disk but matches
12942
+ * no catalog entry — a custom Hugging Face install, or a GGUF the operator
12943
+ * copied in by hand — is still SELECTABLE, as a `{kind:'path'}` ref. Without
12944
+ * it the picker could list such a file and do nothing with it.
12945
+ */
12946
+ path: string().optional()
12791
12947
  });
12792
12948
  var LlmRuntimeDiskUsageSchema = object({
12793
12949
  nodeId: string(),
@@ -12843,10 +12999,47 @@ var LlmProfileSchema = object({
12843
12999
  baseUrl: string().optional(),
12844
13000
  /** ConfigUISchema type:'password' — never round-trips (spec §5). */
12845
13001
  apiKey: string().optional(),
13002
+ /** Vision on/off. A vision call against a `false` profile is REFUSED, never
13003
+ * degraded to text — that shipped once and produced a confident answer to a
13004
+ * question about a picture nobody sent. */
12846
13005
  supportsVision: boolean(),
12847
13006
  temperature: number().min(0).max(2).optional(),
13007
+ /** Nucleus sampling. Every wire we speak has it. */
13008
+ topP: number().min(0).max(1).optional(),
13009
+ /** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
13010
+ * wire does, and the client drops it there (measured: the request body gets
13011
+ * `top_p` and no `top_k`). The profile editor hides the field wherever it
13012
+ * would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
13013
+ topK: number().int().positive().optional(),
12848
13014
  maxTokens: number().int().positive().optional(),
13015
+ /** Prompt context window. Advisory for cloud kinds (they enforce their own);
13016
+ * for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
13017
+ * the model with, so it is the one field that changes a PROCESS. */
13018
+ contextLength: number().int().positive().optional(),
13019
+ /** Default system prompt. A caller's `system` REPLACES it (never appends —
13020
+ * two system prompts fighting is worse than either alone). */
13021
+ systemPrompt: string().optional(),
13022
+ /** Total generation bound — the only one a unary call has. */
12849
13023
  timeoutMs: number().int().positive().default(6e4),
13024
+ /** The TCP handshake only — "is the port even open". NOT the wait for
13025
+ * response headers: on the LM Studio / llama-server wire those are written
13026
+ * once the model has finished loading, so they belong to the bound below. */
13027
+ connectTimeoutMs: number().int().positive().default(1e4),
13028
+ /** Accepted, but no output yet — response headers included, because a cold
13029
+ * GPU load is exactly what happens before them. */
13030
+ firstTokenTimeoutMs: number().int().positive().default(12e4),
13031
+ /** Output started then stopped. */
13032
+ idleTimeoutMs: number().int().positive().default(6e4),
13033
+ /** Profile-level default. The per-consumer table and a per-call override
13034
+ * both beat it — see `resolveRetryPolicy`. */
13035
+ retry: LlmRetryPolicySchema.default({
13036
+ enabled: false,
13037
+ maxAttempts: 1
13038
+ }),
13039
+ /** Whether this profile may use tools. The tool-call plumbing rides the
13040
+ * library; the REGISTRY of callable tools is ours and is empty in v1, so a
13041
+ * `true` here buys the wiring, not behaviour, until tools are registered. */
13042
+ toolsEnabled: boolean().default(false),
12850
13043
  extraHeaders: record(string(), string()).optional(),
12851
13044
  /** kind === 'managed-local' only (spec §4). */
12852
13045
  runtime: ManagedRuntimeConfigSchema.optional()
@@ -12896,6 +13089,36 @@ var ManagedModelCatalogEntrySchema = object({
12896
13089
  /** Vision models: companion projector file. */
12897
13090
  mmprojUrl: string().optional()
12898
13091
  });
13092
+ /**
13093
+ * The outcome of turning one operator-typed Hugging Face reference into a
13094
+ * download plan. A RESULT, never a throw: "this repo has 24 quantizations and
13095
+ * I will not pick for you" is a normal answer the UI has to render, not an
13096
+ * exception.
13097
+ *
13098
+ * `candidates` is the whole reason the refusal is usable — every string in it
13099
+ * is a tag that resolves when pasted back as `<org>/<repo>:<TAG>`.
13100
+ */
13101
+ var HfModelResolutionSchema = discriminatedUnion("ok", [object({
13102
+ ok: literal(true),
13103
+ /** Ready to hand to `installModel` unchanged. */
13104
+ model: ManagedModelRefSchema,
13105
+ label: string(),
13106
+ repo: string(),
13107
+ quantization: string(),
13108
+ purpose: _enum(["text", "vision"]),
13109
+ totalBytes: number(),
13110
+ /** mmproj + shards, for the preview: an operator approving 23 GB should
13111
+ * see that 0.9 GB of it is a projector they did not name. */
13112
+ extraFilenames: array(string())
13113
+ }), object({
13114
+ ok: literal(false),
13115
+ code: string(),
13116
+ message: string(),
13117
+ candidates: array(string()).optional(),
13118
+ /** Set when the refusal was only the ceiling: re-calling with
13119
+ * `maxBytes: requiredBytes` is the operator's explicit override. */
13120
+ requiredBytes: number().optional()
13121
+ })]);
12899
13122
  var LlmRuntimeNodeSchema = object({
12900
13123
  nodeId: string(),
12901
13124
  reachable: boolean(),
@@ -12908,7 +13131,10 @@ var ProfileRefInputSchema = object({
12908
13131
  addonId: string(),
12909
13132
  profileId: string()
12910
13133
  });
12911
- method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
13134
+ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({
13135
+ addonId: string().optional(),
13136
+ requestId: string()
13137
+ }), _void(), { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
12912
13138
  kind: "mutation",
12913
13139
  auth: "admin"
12914
13140
  }), method(ProfileRefInputSchema, _void(), {
@@ -12929,6 +13155,15 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }
12929
13155
  consumer: string().optional(),
12930
13156
  profileId: string().optional()
12931
13157
  }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
13158
+ /** `https://huggingface.co/<org>/<repo>/resolve/main/<f>.gguf`,
13159
+ * `<org>/<repo>/<f>.gguf`, `<org>/<repo>` or `<org>/<repo>:<QUANT>`. */
13160
+ ref: string(),
13161
+ /** Explicit ceiling override, in bytes. Absent = the built-in ceiling. */
13162
+ maxBytes: number().positive().optional()
13163
+ }), HfModelResolutionSchema, {
13164
+ kind: "mutation",
13165
+ auth: "admin"
13166
+ }), method(object({
12932
13167
  nodeId: string(),
12933
13168
  model: ManagedModelRefSchema
12934
13169
  }), _void(), {
@@ -14590,6 +14825,8 @@ var NcSystemEventKindSchema = _enum([
14590
14825
  "stream-offline",
14591
14826
  "node-online",
14592
14827
  "node-offline",
14828
+ "node-inference-unavailable",
14829
+ "detection-blind",
14593
14830
  "addon-update-available",
14594
14831
  "server-update-available",
14595
14832
  "alarm-triggered",
@@ -14651,7 +14888,16 @@ var NcScheduleSchema = object({
14651
14888
  });
14652
14889
  /** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
14653
14890
  var NcPlateMatcherSchema = object({
14654
- values: array(string().min(1)).min(1),
14891
+ /**
14892
+ * Plate texts (or gallery vehicle names) to match. EMPTY = **any plate the
14893
+ * pipeline could read** — the plate half of "no selection = no narrowing",
14894
+ * and the switch that says this rule is about vehicles that were IDENTIFIED
14895
+ * rather than merely seen. A subject carrying no plate still fails.
14896
+ *
14897
+ * The `.min(1)` this used to carry made that state unauthorable; nothing has
14898
+ * ever persisted an empty list, so widening it cannot change an existing rule.
14899
+ */
14900
+ values: array(string().min(1)),
14655
14901
  /** Max Levenshtein distance after normalization (uppercase alphanumeric). */
14656
14902
  maxDistance: number().int().min(0).max(3).default(1)
14657
14903
  });
@@ -14685,28 +14931,36 @@ var NcOccupancyConditionSchema = object({
14685
14931
  /**
14686
14932
  * Audio condition (IMMEDIATE trigger) — a rule on SOUND, not on a picture.
14687
14933
  *
14688
- * Operator-approved vocabulary (2026-08-12, option A — the same one the
14689
- * reference notifier uses, so an operator moving between them re-uses what
14690
- * they already know): a rule matches when, over a sampling window of
14691
- * `samplingSeconds`, at least `hitPercent`% of the audio samples in that
14692
- * window are HITS. A sample is a hit when it satisfies BOTH present filters:
14693
- *
14694
- * - `dbThreshold` its level is at or above this many dBFS (see
14695
- * {@link NC_AUDIO_DBFS_FLOOR}: negative-going, `0` = full scale);
14696
- * - `labels` the classifier put at least one of these labels on it.
14697
- *
14698
- * Both are OPTIONAL and independent, which is the point of the shape: a
14699
- * loudness rule ("something loud at 3am") needs no model to be right, and a
14700
- * label rule ("a dog barked") needs no threshold. **Fail-closed when NEITHER
14701
- * is given** a window in which every sample is trivially a hit would fire on
14702
- * silence, so the engine refuses such a condition rather than notifying on
14703
- * nothing (the schema cannot express "at least one of" without becoming a
14704
- * ZodEffects the cap path would have to special-case).
14705
- *
14706
- * `hitPercent` is over the samples the window actually HOLDS, and the window
14707
- * must be FULL before it can match a window that has been open for two
14708
- * seconds of its ten is 100% of nothing, and firing on it would make
14709
- * `samplingSeconds` decorative.
14934
+ * **TWO EXCLUSIVE MODES** (operator decision 2026-08-14, D157). Which one a
14935
+ * rule is in is not a stored field it is WHICH FILTER the rule carries, so
14936
+ * there is no second switch that can disagree with the first and every rule
14937
+ * authored before the decision migrates for free (`audioModeOf`):
14938
+ *
14939
+ * - **LABEL mode — `labels` present.** The rule fires on the FIRST frame the
14940
+ * classifier labels with one of them. No window, no percentage:
14941
+ * `hitPercent` and `samplingSeconds` are ignored, and the rule's own
14942
+ * `throttle` cooldown is the only brake. The per-label confidence floor is
14943
+ * the analyzer's (`classificationMinScore`, per device) — a label only
14944
+ * reaches this condition if the classifier was already confident enough.
14945
+ * - **LEVEL mode `dbThreshold` present, no labels.** The sampling window IS
14946
+ * the condition: at least `hitPercent`% of the samples over
14947
+ * `samplingSeconds` must be at or above `dbThreshold` dBFS (see
14948
+ * {@link NC_AUDIO_DBFS_FLOOR}: negative-going, `0` = full scale). The window
14949
+ * must be FULL before it can match a window open for two of its ten
14950
+ * seconds is 100% of nothing.
14951
+ *
14952
+ * **Why label mode has no window.** It had one, and it never fired: the
14953
+ * analyzer emits ~1 audio frame per second but YAMNet only LABELS one to three
14954
+ * of them per episode, even through continuous crying. The measured maximum
14955
+ * `hitPercent` over the whole live history was 40 — under the shipped default
14956
+ * of 60, so a label rule could not fire at all, ever. A percentage of frames is
14957
+ * the wrong question to ask of a sparse classifier.
14958
+ *
14959
+ * **Fail-closed when NEITHER is given** — every sample would be a trivial hit
14960
+ * and the rule would fire on silence. The schema cannot express "exactly one
14961
+ * of" without becoming a ZodEffects the cap path would have to special-case, so
14962
+ * the exclusivity is enforced where every editor writes (`patchAudio`) and a
14963
+ * legacy rule carrying both resolves to LABEL (the mode that fires).
14710
14964
  *
14711
14965
  * Labels are the audio macro classes (`AUDIO_MACRO_LABELS` / the NC taxonomy's
14712
14966
  * `audio-*` ids). Both spellings are accepted — the matcher normalizes the
@@ -14714,13 +14968,13 @@ var NcOccupancyConditionSchema = object({
14714
14968
  * an operator who typed `dog` mean the same thing.
14715
14969
  */
14716
14970
  var NcAudioConditionSchema = object({
14717
- /** Audio macro labels; absent = any sound (level-only rule). */
14971
+ /** LABEL MODE: audio macro labels. Present fires on the first labelled frame. */
14718
14972
  labels: array(string().min(1)).min(1).optional(),
14719
- /** Level floor in dBFS (negative-going, `0` = full scale); absent = any level. */
14973
+ /** LEVEL MODE: floor in dBFS (negative-going, `0` = full scale). */
14720
14974
  dbThreshold: number().min(-96).max(0).optional(),
14721
- /** Percentage of the window's samples that must be hits (1–100). */
14975
+ /** LEVEL MODE ONLY: percentage of the window's samples that must be hits (1–100). */
14722
14976
  hitPercent: number().int().min(1).max(100).default(60),
14723
- /** Length of the sampling window in seconds. */
14977
+ /** LEVEL MODE ONLY: length of the sampling window in seconds. */
14724
14978
  samplingSeconds: number().int().min(1).max(300).default(10)
14725
14979
  });
14726
14980
  /**
@@ -14858,13 +15112,81 @@ var NcRuleActionsSchema = object({
14858
15112
  */
14859
15113
  buttons: array(NcRuleNotificationButtonSchema).max(8).optional()
14860
15114
  });
15115
+ /**
15116
+ * "This rule applies only while `deviceId` is in one of `states`."
15117
+ *
15118
+ * The states are the DEVICE's own vocabulary — `AlarmState` for a panel,
15119
+ * `on`/`off` for a switch — not a normalised set, because normalising would
15120
+ * make the condition lie about devices whose states have no equivalent.
15121
+ *
15122
+ * An unreadable state does NOT match: see the engine's fail-closed gate. A
15123
+ * condition that fired on "I could not read it" would be worse than no gate.
15124
+ */
15125
+ var NcDeviceStateConditionSchema = object({
15126
+ deviceId: number().int(),
15127
+ /** Any of these matches. */
15128
+ states: array(string().min(1)).min(1)
15129
+ });
15130
+ /**
15131
+ * "This rule applies only while scene `sceneId` is `matched` / `diverged`."
15132
+ *
15133
+ * A GATE, not a trigger. `occupancy` and `audio` each DISCRIMINATE their rule —
15134
+ * carrying one makes the rule fire on that subject and nothing else. Scene is
15135
+ * the other shape entirely, the `deviceState` shape: it narrows a rule that
15136
+ * already has a trigger ("tell me about a person at the front door, but only
15137
+ * while the bin is still out"). That is why it composes with every delivery
15138
+ * instead of owning one, and why no new `NcDelivery` member and no new subject
15139
+ * kind exist for it — see D159.
15140
+ *
15141
+ * ── Identity ───────────────────────────────────────────────────────────────
15142
+ * `sceneId` is `SceneMonitor.id`, a `randomUUID()` minted by `createScene` —
15143
+ * globally unique, so it needs no device to disambiguate it. `deviceId` is
15144
+ * carried as a HINT for the editor and for the log line, never as part of the
15145
+ * lookup key: a rule whose hint drifted must still gate correctly.
15146
+ *
15147
+ * ── Which boolean ──────────────────────────────────────────────────────────
15148
+ * `latched` ABSENT means "whatever the scene itself says" — `SceneMonitor.emit`
15149
+ * already declares which boolean drives notification rules, and a second knob
15150
+ * that could disagree with it is exactly the D62 failure. Set it only to
15151
+ * override one rule against the scene's own default.
15152
+ *
15153
+ * - LIVE reading (`emit`/`latched` resolve to live): passes iff
15154
+ * `verdict === requiredState`. `unknown` — no reference for this light, view
15155
+ * shifted, no snapshot — passes NEITHER. A scene that cannot judge is not
15156
+ * evidence, in either direction.
15157
+ * - LATCHED reading: passes iff `latched === (requiredState === 'diverged')`.
15158
+ * The latch is a durable fact about the past ("it has diverged since I armed
15159
+ * it"), so a camera that has gone dark does not clear it — that is the whole
15160
+ * reason the operator asked for a latch.
15161
+ *
15162
+ * The gate reads an in-memory mirror (`NcSceneStateCache`) refreshed OFF the
15163
+ * event path, never the cap: D49. A mirror that has never loaded, or a scene it
15164
+ * does not carry, reads absent and the rule does NOT fire — fail closed, and
15165
+ * said out loud in the log rather than dropped in silence.
15166
+ */
15167
+ var NcSceneConditionSchema = object({
15168
+ /** `SceneMonitor.id` — the uuid the cap mints. The whole lookup key. */
15169
+ sceneId: string().min(1),
15170
+ /** The camera the scene lives on. A hint for the editor and the log line. */
15171
+ deviceId: number().int().optional(),
15172
+ /** The state the scene must be in for the rule to fire. */
15173
+ requiredState: _enum(["matched", "diverged"]),
15174
+ /**
15175
+ * Read the LATCH (`true`) or the LIVE verdict (`false`). Absent = follow the
15176
+ * scene's own `emit` field, which is the only place that decision belongs.
15177
+ */
15178
+ latched: boolean().optional()
15179
+ });
14861
15180
  var NcConditionsSchema = object({
14862
15181
  /** Gate on ANOTHER device's current state (the alarm armed, a switch on). */
14863
- deviceState: object({
14864
- deviceId: number().int(),
14865
- /** Any of these matches. */
14866
- states: array(string().min(1)).min(1)
14867
- }).optional(),
15182
+ deviceState: NcDeviceStateConditionSchema.optional(),
15183
+ /**
15184
+ * Gate on a SCENE's state — "only while the bin is still out". Composes with
15185
+ * every trigger (detection, occupancy, audio, sensor, package, track-end);
15186
+ * unlike `occupancy`/`audio` it discriminates nothing. See
15187
+ * {@link NcSceneCondition} and D159.
15188
+ */
15189
+ scene: NcSceneConditionSchema.optional(),
14868
15190
  /** Device scope — absent = all devices. */
14869
15191
  devices: array(number()).optional(),
14870
15192
  /** Detector class names (any overlap with the record's class set). */
@@ -14890,18 +15212,47 @@ var NcConditionsSchema = object({
14890
15212
  */
14891
15213
  labelEquals: array(string().min(1)).optional(),
14892
15214
  /**
14893
- * Identity matcher. P1 boundary: matched against the record's collapsed
14894
- * `label` (the identity display name propagated by the face pipeline) —
14895
- * identity-ID matching rides in P2 when identity ids reach the record.
15215
+ * KNOWN FACES the rule's identity scope, and the switch that says the rule
15216
+ * is about recognised people at all.
15217
+ *
15218
+ * Three states, and the empty one is the point:
15219
+ *
15220
+ * | value | meaning |
15221
+ * | --- | --- |
15222
+ * | absent | the rule does not care who it is; an unrecognised person matches |
15223
+ * | `[]` | **only known faces** — any identity in the gallery, nobody in particular |
15224
+ * | a list | only these identities |
15225
+ *
15226
+ * `[]` is the repo-wide "no selection = no narrowing" reading (an absent
15227
+ * `devices` list is every device), applied one level down: the operator has
15228
+ * turned the face scope ON and narrowed it to nothing, which is every known
15229
+ * face. No second field states the same thing — a switch that can disagree
15230
+ * with the list under it is worse than no switch (D62).
15231
+ *
15232
+ * MEMBERS ARE FACE-GALLERY `Identity.id`s (uuid), not display names. A name is
15233
+ * renameable, and a rule authored on "Gianluca" went silently dark the moment
15234
+ * the operator fixed the spelling. The id reaches the record on
15235
+ * `LabelAttribution.identityId`; the name is what the editor shows and what
15236
+ * `{{label}}` renders.
15237
+ *
15238
+ * Rules written before this carry NAMES, and are resolved to ids lazily at
15239
+ * load (`NcRuleStore.load`) against the live gallery — a name nothing answers
15240
+ * for is left as it stands and reported, never dropped. The engine also
15241
+ * accepts a display-name hit as a compatibility leg, so a rule whose
15242
+ * migration could not resolve keeps matching exactly what it matched before.
14896
15243
  */
14897
15244
  identities: array(string().min(1)).optional(),
14898
- /** Fuzzy plate matcher against the record's `label` (plate text). */
15245
+ /**
15246
+ * KNOWN PLATES / VEHICLES — the plate mirror of {@link identities}, including
15247
+ * the empty-list reading: `values: []` is "any plate the OCR could read",
15248
+ * a non-empty list is those plates (fuzzily). See {@link NcPlateMatcherSchema}.
15249
+ */
14899
15250
  plates: NcPlateMatcherSchema.optional(),
14900
15251
  /**
14901
- * Identity EXCLUDE — mirror of {@link identities} with `notIn` semantics.
14902
- * Same P1 boundary: matched against the record's collapsed `label` (the
14903
- * identity display name). A record with NO label passes (nothing to
14904
- * exclude), unlike the include variant which fails on an absent label.
15252
+ * Identity EXCLUDE — mirror of {@link identities} with `notIn` semantics, and
15253
+ * the same id members and the same lazy name→id migration. A record with NO
15254
+ * identity passes (nothing to exclude), unlike the include variant which
15255
+ * fails on an unrecognised subject. An EMPTY list excludes nobody.
14905
15256
  */
14906
15257
  identitiesExclude: array(string().min(1)).optional(),
14907
15258
  /**
@@ -15293,7 +15644,80 @@ var NcRuleInputSchema = object({
15293
15644
  * a rule that predates the gate must keep delivering byte-for-byte as it
15294
15645
  * did, and absent is the only way to say that without a migration.
15295
15646
  */
15296
- confirm: NcConfirmSchema.optional()
15647
+ confirm: NcConfirmSchema.optional(),
15648
+ /**
15649
+ * WAIT for face/plate recognition before saying anything.
15650
+ *
15651
+ * A notification's TEXT is frozen at enqueue and its media is re-resolved at
15652
+ * send; the identity is neither. A face is confirmed after `confirmFrames`
15653
+ * agreeing observations — p50 **11.4 s** after the track was first seen,
15654
+ * measured on this hub — and an `immediate` rule enqueues on the first object
15655
+ * event, seconds before that. So "Gianluca è arrivato" is unsayable on the
15656
+ * immediate path, and no amount of media re-resolution fixes a sentence.
15657
+ *
15658
+ * Only two honest answers exist, and this flag picks between them. It has
15659
+ * effect ONLY on a rule that declares a recognition scope
15660
+ * ({@link NcConditions.identities} or {@link NcConditions.plates}) — on any
15661
+ * other rule there is nothing to wait for and the flag is inert.
15662
+ *
15663
+ * | value | what happens |
15664
+ * | --- | --- |
15665
+ * | `true` | the rule stops firing on the object event and fires at TRACK CLOSE instead, once, with the name — later, and complete |
15666
+ * | 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) |
15667
+ *
15668
+ * `.optional()` and deliberately NOT `.default()`: a Zod default does not run
15669
+ * on the addon cap path, and absent has to keep meaning exactly what every
15670
+ * rule authored before this field meant.
15671
+ *
15672
+ * The cost of `true` is stated here because the editor states it too: a rule
15673
+ * that waits also inherits track-close SEMANTICS — its `zones` condition
15674
+ * tests every zone the track visited and a `crossing` condition can no longer
15675
+ * be satisfied, because a closed track carries no crossing.
15676
+ */
15677
+ waitForEnhancement: boolean().optional(),
15678
+ /**
15679
+ * GROUP a burst of subjects into ONE notification that grows.
15680
+ *
15681
+ * Seconds of quiet after the last matching subject before the burst is
15682
+ * considered over. While it is open, the first subject enqueues immediately —
15683
+ * **exactly as today, with no added latency** — and every real growth (a new
15684
+ * subject, or a name confirmed on one already in it) REPLACES that
15685
+ * notification with an updated one naming everybody. The push carries the
15686
+ * group's own coalescing tag, so the phone replaces rather than stacks.
15687
+ *
15688
+ * `0` / absent = off, and off is today's behaviour byte for byte.
15689
+ *
15690
+ * ### Why an idle cutoff and not a window
15691
+ *
15692
+ * The measured seven-person arrival on device 590 spans 110 s with every
15693
+ * internal gap under 30 s. A 12 s fixed window cuts it into three groups; an
15694
+ * idle cutoff holds it as one and ends it when the arrival actually ends.
15695
+ * 30 is Frigate's shipped value for the same decision.
15696
+ *
15697
+ * ### What it replaces
15698
+ *
15699
+ * The blind cooldown, which collapses a burst by DISCARDING it. Measured on
15700
+ * device 615 / *Persona su Uscio* over six days: 116 qualifying tracks → 74
15701
+ * notifications, **44 (37.9%) suppressed outright**, 23 of them overlapping a
15702
+ * track that did fire and 7 carrying a confirmed identity nobody heard about.
15703
+ * A group collapses the same volume by MERGING, so the cooldown becomes a
15704
+ * budget over GROUPS — which is what it always meant — and a growth is never
15705
+ * throttled by the window its own first member spent.
15706
+ *
15707
+ * ### Interaction with {@link waitForEnhancement}
15708
+ *
15709
+ * They compose, and the order matters. `waitForEnhancement` defers the rule to
15710
+ * TRACK CLOSE, so with both set the group is opened by the first member to
15711
+ * CLOSE — already carrying its name — and grows as later members close. That
15712
+ * is later, and complete. With grouping alone the group opens on the first
15713
+ * object event and picks up names as they are confirmed, through the growth
15714
+ * path. Neither combination fires twice for one subject.
15715
+ *
15716
+ * `.optional()` and deliberately NOT `.default()`: a Zod default does not run
15717
+ * on the addon cap path, so absent must keep meaning what it meant before this
15718
+ * field existed.
15719
+ */
15720
+ groupIdleSec: number().int().min(0).max(600).optional()
15297
15721
  });
15298
15722
  /**
15299
15723
  * Partial patch for `updateRule` — any subset of the input fields, plus the
@@ -15400,6 +15824,7 @@ var NcConditionDescriptorSchema = object({
15400
15824
  "occupancy",
15401
15825
  "audio",
15402
15826
  "deviceState",
15827
+ "scene",
15403
15828
  "systemEvent"
15404
15829
  ]),
15405
15830
  operator: _enum([
@@ -16225,7 +16650,7 @@ var TrackEnvelopeSchema = object({
16225
16650
  * `snapshots[]` references — megabytes across a page of tracks. `slim`
16226
16651
  * keeps every scalar the list surfaces actually render (ids, class(es),
16227
16652
  * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
16228
- * zonesVisited, bestEventId, envelope, hasFace) and returns `positions` /
16653
+ * zonesVisited, bestEventId, envelope, hasFace, hasRider) and returns `positions` /
16229
16654
  * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
16230
16655
  * `getTrack`. Mirrors the event-store `projection` convention
16231
16656
  * (`getObjectEvents` et al.).
@@ -16361,7 +16786,21 @@ union([literal(1), literal(2)]);
16361
16786
  var LabelAttributionSchema = object({
16362
16787
  stepId: string(),
16363
16788
  modelId: string().optional(),
16364
- decidedAt: number()
16789
+ decidedAt: number(),
16790
+ /**
16791
+ * The GALLERY id behind a recognised tier-2 label — a face-gallery
16792
+ * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
16793
+ *
16794
+ * The text alone is a DISPLAY NAME, and a display name is renameable: a
16795
+ * notification rule authored on "Gianluca" stopped matching the moment the
16796
+ * operator fixed the spelling in the gallery, and nothing said so. The id is
16797
+ * the thing that does not move, so it is what a rule matches on
16798
+ * (`NcConditions.identities`) and the text is what a human is shown.
16799
+ *
16800
+ * Absent when the label names no gallery row — a plate the OCR read but no
16801
+ * vehicle claims, a sub-class, a species, any tier-1 value.
16802
+ */
16803
+ identityId: string().optional()
16365
16804
  });
16366
16805
  /**
16367
16806
  * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
@@ -16498,6 +16937,28 @@ var TrackSchema = object({
16498
16937
  * `=== true` and render nothing otherwise, never infer "no face".
16499
16938
  */
16500
16939
  hasFace: boolean().optional(),
16940
+ /**
16941
+ * This subject CONTAINS a folded rider — a person the rider-pairing step
16942
+ * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
16943
+ * so the passage is tracked once and as a VEHICLE.
16944
+ *
16945
+ * It exists because the fold's record was dishonest. D34 and the code both
16946
+ * said "the person is not lost — it is reported so both entities stay on the
16947
+ * record"; in fact the pair went into a per-processor RAM field behind an
16948
+ * accessor nobody called, and every durable surface said `vehicle`, full
16949
+ * stop. This is the composition note that makes the row true.
16950
+ *
16951
+ * A COMPOSITION, never a class and never a label. "This vehicle contains a
16952
+ * person" is not an answer to "what is this" — both label tiers would refuse
16953
+ * a macro token anyway (D89), and correctly. Nothing here changes what the
16954
+ * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
16955
+ * and a `person` rule still does not fire for someone cycling past.
16956
+ *
16957
+ * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
16958
+ * the column, and every hub that predates the field, omits it. Test
16959
+ * `=== true` and render nothing otherwise — never infer "no rider".
16960
+ */
16961
+ hasRider: boolean().optional(),
16501
16962
  ...TrackFlagFields,
16502
16963
  ...TrackRetrainFields
16503
16964
  });
@@ -16847,7 +17308,10 @@ var RecentTracksQueryInput = object({
16847
17308
  * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
16848
17309
  cursor: string().optional(),
16849
17310
  /** See {@link TrackProjectionSchema}. Default `full`. */
16850
- projection: TrackProjectionSchema.optional()
17311
+ projection: TrackProjectionSchema.optional(),
17312
+ /** Include stationary-promoted rows (parked objects). Default false: the
17313
+ * feed lists passages; parking records live on the stationary registry. */
17314
+ includeStationary: boolean().optional()
16851
17315
  });
16852
17316
  var RecentTracksPageSchema = object({
16853
17317
  /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
@@ -17065,7 +17529,11 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
17065
17529
  zone: TrackZoneFilterSchema.optional(),
17066
17530
  /** See {@link TrackProjectionSchema}. Default `full` (backward
17067
17531
  * compatible — omitting the field keeps today's exact behaviour). */
17068
- projection: TrackProjectionSchema.optional()
17532
+ projection: TrackProjectionSchema.optional(),
17533
+ /** Include stationary-promoted rows (parked objects handed to the
17534
+ * stationary registry). Default false: the timeline lists passages,
17535
+ * not parking records (operator decision, 2026-08-15). */
17536
+ includeStationary: boolean().optional()
17069
17537
  }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(object({ deviceId: number() }), _void(), {
17070
17538
  kind: "mutation",
17071
17539
  auth: "admin"
@@ -17229,11 +17697,16 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
17229
17697
  auth: "admin"
17230
17698
  }), method(object({
17231
17699
  eventId: string(),
17232
- kind: MediaFileKindEnum.optional()
17700
+ kind: MediaFileKindEnum.optional(),
17701
+ deviceId: number()
17233
17702
  }), array(MediaFileSchema).readonly()), method(object({
17234
17703
  trackId: string(),
17235
- kinds: array(MediaFileKindEnum).optional()
17236
- }), array(MediaFileSchema).readonly()), method(object({ trackId: string() }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
17704
+ kinds: array(MediaFileKindEnum).optional(),
17705
+ deviceId: number()
17706
+ }), array(MediaFileSchema).readonly()), method(object({
17707
+ trackId: string(),
17708
+ deviceId: number()
17709
+ }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
17237
17710
  kind: "mutation",
17238
17711
  auth: "admin"
17239
17712
  }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
@@ -17933,6 +18406,17 @@ var maxSessionHoldMsField = {
17933
18406
  default: 12e4,
17934
18407
  step: 5e3
17935
18408
  };
18409
+ /**
18410
+ * Quiet period that closes an `audioMode: 'on-motion'` audio window. Floor of
18411
+ * 5s so a rearm can never degenerate into per-event stream churn; default 90s
18412
+ * comfortably outlives the gap between two PIR wakes on a battery camera.
18413
+ */
18414
+ var audioMotionWindowMsField = {
18415
+ min: 5e3,
18416
+ max: 6e5,
18417
+ default: 9e4,
18418
+ step: 5e3
18419
+ };
17936
18420
  var motionFpsField = {
17937
18421
  min: 1,
17938
18422
  max: 30,
@@ -18109,6 +18593,27 @@ var RunnerCameraConfigSchema = object({
18109
18593
  * resolved `CameraDetectionConfig`.
18110
18594
  */
18111
18595
  maxSessionHoldMs: number().min(maxSessionHoldMsField.min).max(maxSessionHoldMsField.max).optional(),
18596
+ /**
18597
+ * Orchestrator-side quiet period (ms) that closes an `audioMode:
18598
+ * 'on-motion'` audio window, measured from the LAST motion event.
18599
+ *
18600
+ * This exists because the falling edge cannot be relied on. Camera-native
18601
+ * providers emit motion as a RISING EDGE ONLY (Reolink's Baichuan push and
18602
+ * its email-push SMTP path both emit `detected: true` and never the
18603
+ * counterpart); only the frame-diff analyzer emits falls. So on an
18604
+ * onboard-only camera a window that closed only on `detected: false` never
18605
+ * closed at all, and `on-motion` silently behaved as `always-on` — on a
18606
+ * battery camera, the one failure mode the mode exists to prevent.
18607
+ *
18608
+ * Every motion event rearms this timer WITHOUT restarting the stream, so a
18609
+ * burst of re-fires costs nothing. A falling edge, when one does arrive,
18610
+ * still closes earlier via `motionCooldownMs` — whichever comes first wins.
18611
+ *
18612
+ * Not consumed by the runner: carried here so it shares the per-camera
18613
+ * device-settings surface with `motionCooldownMs`, exactly like
18614
+ * `maxSessionHoldMs`.
18615
+ */
18616
+ audioMotionWindowMs: number().min(audioMotionWindowMsField.min).max(audioMotionWindowMsField.max).optional(),
18112
18617
  motionFps: number().min(motionFpsField.min).max(motionFpsField.max).default(motionFpsField.default),
18113
18618
  detectionFps: number().min(detectionFpsField.min).max(detectionFpsField.max).default(detectionFpsField.default),
18114
18619
  motionStreamId: string(),
@@ -18204,7 +18709,7 @@ var RunnerCameraConfigSchema = object({
18204
18709
  */
18205
18710
  inferenceDevices: array(RunnerInferenceDeviceSchema).readonly().optional()
18206
18711
  });
18207
- 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;
18712
+ 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;
18208
18713
  /**
18209
18714
  * Runtime load summary returned by `getLocalLoad`. Used by the orchestrator's
18210
18715
  * load-balancing levels (L2 capacity-based, L3 hardware-aware) to decide
@@ -19220,7 +19725,16 @@ targets: array(object({
19220
19725
  /** A sleeping battery camera: the frame is deliberately stale and will
19221
19726
  * NOT refresh in the background. A surface should say so rather than
19222
19727
  * present it as current. */
19223
- sleeping: boolean()
19728
+ sleeping: boolean(),
19729
+ /** Current device state rendered over the cached frame. State images
19730
+ * remain authoritative even when their photographic background is
19731
+ * old; null means the link must carry a current camera frame. */
19732
+ stateReason: _enum([
19733
+ "disabled",
19734
+ "sleeping",
19735
+ "unreachable",
19736
+ "waking"
19737
+ ]).nullable()
19224
19738
  })));
19225
19739
  /**
19226
19740
  * `sso-bridge` — internal hub-only cap that lets SSO-style auth
@@ -20946,6 +21460,25 @@ var BatteryStatusSchema = object({
20946
21460
  /** Ms epoch of the last observation. Lets consumers reason about freshness. */
20947
21461
  lastUpdated: number(),
20948
21462
  /**
21463
+ * Ms epoch of the last time the device PROVED it was reachable — a
21464
+ * completed firmware round-trip, an observed wake, or an inbound push
21465
+ * (firmware event, email). `0`/absent = never since this slice was born.
21466
+ *
21467
+ * This is the ONLY input that separates "asleep" from "gone", and it is
21468
+ * fed exclusively by PASSIVE signals: nothing may write it by reaching
21469
+ * for the radio, because a poll that confirms reachability is the same
21470
+ * poll that drains the battery. See {@link deriveBatteryPresence} — the
21471
+ * single derivation every consumer must use; no surface computes its own.
21472
+ *
21473
+ * It is deliberately NOT a clock in the
21474
+ * `scripts/check-runtime-state-durability.ts` sense: it is the
21475
+ * observation itself, and it is the only thing a 30-hour silence is
21476
+ * visible in. Writers quantise it (see `CONTACT_WRITE_QUANTUM_MS` in the
21477
+ * Reolink provider) so a value that means "recently" cannot cost a
21478
+ * SQLite commit per round-trip.
21479
+ */
21480
+ lastContactAt: number().optional(),
21481
+ /**
20949
21482
  * True when the source is a BINARY low-battery indicator (HA
20950
21483
  * `binary_sensor` device_class=battery / `LOW_BAT`) that has no real
20951
21484
  * charge level — `percentage` is then a coarse stand-in (100 = normal,
@@ -26361,14 +26894,77 @@ method(object({
26361
26894
  * thing except the comparator: `similarity` (CLIP cosine at the same ROI coords
26362
26895
  * vs condition-tagged references) and `llm` (vision-LLM judgment over the crop).
26363
26896
  *
26364
- * D14 device-config archetype (`deviceConfig.ui.kind:'widget'`) the framework
26365
- * derives the device-detail contribution; the provider carries NO hand-written
26366
- * settings-contribution methods. `status.kind:'push'` the engine pushes on
26367
- * every hysteresis flip / availability change; consumers never poll.
26368
- */
26369
- /** Extensible condition tag. Seeded 'day' | 'night'; open by design so more can
26370
- * be added without a wire break (matching falls back to any-condition refs). */
26897
+ * **No `deviceConfig`, deliberately.** This shipped as the D14 widget archetype,
26898
+ * which put a "Scenes" tab on one camera's detail page. That is the wrong shape
26899
+ * for the thing: a scene is a standing question about the property ("is the bin
26900
+ * still out"), and the operator's question is "which of my scenes have tripped",
26901
+ * across every camera at once — not "what does camera 617 think". Buried one
26902
+ * camera deep it also could not be found. The surface is now a top-level admin
26903
+ * page (`/scenes`, `pages/Scenes.tsx`) that lists every scene on every camera and
26904
+ * picks the camera inside the create flow, the same shape Events and Faces have.
26905
+ *
26906
+ * The consequence to keep in mind: `host/scene-monitor-editor` is gone from
26907
+ * `HOST_WIDGETS` too. `scripts/check-host-widget-resolves.ts` asserts BOTH
26908
+ * directions, so a registration nobody declares fails exactly as loudly as a
26909
+ * declaration nobody registers. The editor is imported directly by the page.
26910
+ *
26911
+ * `status.kind:'push'` — the engine pushes on every hysteresis flip /
26912
+ * availability change; consumers never poll.
26913
+ */
26914
+ /** Extensible condition tag. Seeded 'day' | 'ir' (the two variants the operator
26915
+ * captures) plus 'night' | 'dawn' | 'dusk' from the resolver's sun-times band.
26916
+ * Open by design so more can be added without a wire break.
26917
+ *
26918
+ * Matching does NOT fall back across conditions: cross-condition cosines are
26919
+ * not comparable, so "I have never seen this scene in this light" is reported
26920
+ * as `unknown`, never guessed. A day reference scored against an IR frame
26921
+ * collapses the cosine and would latch a false alarm every single night. */
26371
26922
  var SceneConditionSchema = string();
26923
+ /**
26924
+ * What a scene does when the CURRENT light has no reference of its own.
26925
+ *
26926
+ * The lighting variants are not equally likely to exist. Almost every operator
26927
+ * captures daylight and then never stands outside at 22:00 to capture IR, and a
26928
+ * scene that is only ever going to be asked about a daytime question ("is the
26929
+ * bin still on the kerb at 08:00") does not need a night reference at all. The
26930
+ * night half must therefore be OPTIONAL, and optional means the scene keeps
26931
+ * working without it rather than degrading into a permanent complaint.
26932
+ *
26933
+ * - `skip` (default) — the check in that light is not made. Not a verdict, not
26934
+ * an alarm, not even an `unknown`: the live state simply stays whatever the
26935
+ * last covered light left it at, the latch is untouched, and the hysteresis
26936
+ * run is neither spent nor cleared. The scene resumes by itself at first
26937
+ * light. This is the only behaviour under which "I never captured IR" is a
26938
+ * configuration choice instead of a nightly fault.
26939
+ * - `judge-anyway` — score against the OTHER conditions' references. Available
26940
+ * for cameras whose IR frame is close enough to daylight (a floodlit
26941
+ * driveway, an always-white-light doorbell), and wrong for everything else:
26942
+ * cross-condition cosines are not comparable, so a day reference against a
26943
+ * true IR frame collapses and the scene reports a theft at 21:40.
26944
+ *
26945
+ * Never applies when the scene has NO comparable reference at all — that is
26946
+ * "not armed yet", it is reported as `no-reference-for-condition`, and silence
26947
+ * there would hide a scene the operator never finished setting up.
26948
+ */
26949
+ var SceneUncoveredPolicySchema = _enum(["skip", "judge-anyway"]);
26950
+ /** `matched` = the baseline is what we see; `diverged` = it demonstrably is not;
26951
+ * `unknown` = we cannot judge (no reference for this condition, encoder model
26952
+ * changed, view shifted, no snapshot). `unknown` is a real value, not a null,
26953
+ * and never counts toward hysteresis in either direction. */
26954
+ var SceneVerdictSchema = _enum([
26955
+ "matched",
26956
+ "diverged",
26957
+ "unknown"
26958
+ ]);
26959
+ /** Why a scene cannot judge. Named, because this feature's failure mode is
26960
+ * silence that reads as "nothing has happened". */
26961
+ var SceneUnavailableSchema = _enum([
26962
+ "no-reference-for-condition",
26963
+ "view-shifted",
26964
+ "no-vision-profile",
26965
+ "encoder-model-changed",
26966
+ "no-snapshot"
26967
+ ]);
26372
26968
  /** One captured reference — condition-tagged, model-version-gated. `embedding`
26373
26969
  * is `number[]` (Float32Array does NOT survive MsgPack/UDS). */
26374
26970
  var SceneReferenceSchema = object({
@@ -26376,7 +26972,14 @@ var SceneReferenceSchema = object({
26376
26972
  modelId: string(),
26377
26973
  condition: SceneConditionSchema,
26378
26974
  capturedAt: number(),
26379
- thumbnailMediaId: string().optional()
26975
+ thumbnailMediaId: string().optional(),
26976
+ /** Whole-frame (downscaled) embedding captured alongside the ROI crop. The
26977
+ * anti-view-shift anchor: a bumped camera, a PTZ preset or a re-aim makes the
26978
+ * normalized rect frame a different piece of world, and the scene would
26979
+ * diverge forever with a perfectly plausible cosine. Checked LAZILY, only
26980
+ * when hysteresis is about to flip — one extra encode per candidate
26981
+ * transition, not per poll. */
26982
+ anchorEmbedding: array(number()).optional()
26380
26983
  });
26381
26984
  var SceneMonitorStateSchema = object({
26382
26985
  id: string(),
@@ -26398,6 +27001,28 @@ var SceneCheckSchema = discriminatedUnion("mode", [object({
26398
27001
  profileId: string().optional(),
26399
27002
  hysteresisCount: number().int().positive()
26400
27003
  })]);
27004
+ var SCENE_DEFAULT_ANCHOR_THRESHOLD = .85;
27005
+ /** Night is OPTIONAL. A scene with only a daylight reference sits the IR hours
27006
+ * out in silence rather than reporting a fault every night. */
27007
+ var SCENE_DEFAULT_UNCOVERED_POLICY = "skip";
27008
+ /**
27009
+ * Vision-model adjudication of a candidate flip. Field names deliberately
27010
+ * mirror `NcConfirmSchema` so an operator meets one vocabulary, not two.
27011
+ *
27012
+ * `onTimeout` defaults to **'hold'**, the OPPOSITE of `NcConfirmGate`'s
27013
+ * fail-open: a notification suppressed is the worse error there, but a vision
27014
+ * model that timed out has not told us the bin is gone, and a latch is a
27015
+ * stateful claim that costs the operator a trip to reset.
27016
+ */
27017
+ var SceneConfirmSchema = object({
27018
+ enabled: boolean().default(false),
27019
+ prompt: string().min(1).max(1e3),
27020
+ profileId: string().optional(),
27021
+ timeoutMs: number().int().min(1e3).max(2e4).default(8e3),
27022
+ maxImagePx: number().int().min(64).max(2048).default(448),
27023
+ /** What a timeout / unavailable model means for the PENDING flip. */
27024
+ onTimeout: _enum(["flip", "hold"]).default("hold")
27025
+ });
26401
27026
  var SceneMonitorSchema = object({
26402
27027
  id: string(),
26403
27028
  label: string(),
@@ -26416,7 +27041,56 @@ var SceneMonitorSchema = object({
26416
27041
  lastConfidence: number().nullable(),
26417
27042
  currentCondition: SceneConditionSchema.nullable(),
26418
27043
  availability: _enum(["ok", "unavailable"]),
26419
- unavailableReason: string().nullable()
27044
+ unavailableReason: string().nullable(),
27045
+ /** Which state is "the initial screen". `null` until the first capture. */
27046
+ baselineStateId: string().nullable(),
27047
+ /** Which boolean drives notification rules and any export. */
27048
+ emit: _enum(["latched", "live"]).default("latched"),
27049
+ /** Live: does the region match the baseline RIGHT NOW. */
27050
+ verdict: SceneVerdictSchema,
27051
+ /** Has it been `diverged` at least once since `armedAt` — the operator's boolean. */
27052
+ latched: boolean(),
27053
+ /** Last reset (or creation). */
27054
+ armedAt: number(),
27055
+ divergedAt: number().nullable(),
27056
+ restoredAt: number().nullable(),
27057
+ /** A check is only COUNTED when the device has been quiet this long. Motion
27058
+ * during the window DISCARDS the observation — a car pulling up in front of
27059
+ * the bin must not be able to spend hysteresis credit. */
27060
+ quietSeconds: number().int().min(0).max(3600).default(60),
27061
+ /** An observation only advances the pending count when it is at least this
27062
+ * far from the previously counted one, so N agreeing checks span real time
27063
+ * rather than N adjacent polls inside one occlusion. */
27064
+ minObservationSpacingSec: number().int().min(0).max(3600).default(120),
27065
+ /** Vision-model adjudication of a candidate flip. Similarity primary only. */
27066
+ confirm: SceneConfirmSchema.optional(),
27067
+ /** Whole-frame anchor cosine below which a flip is REFUSED as `view-shifted`. */
27068
+ anchorThreshold: number().min(0).max(1).default(SCENE_DEFAULT_ANCHOR_THRESHOLD),
27069
+ /** Clear the latch on its own when the scene matches again? Default false —
27070
+ * `restoredAt` and the `scene-restored` edge are recorded regardless, so an
27071
+ * automation can react to the bin coming back without the operator's own
27072
+ * alarm silently clearing itself. */
27073
+ autoRestore: boolean().default(false),
27074
+ /** What to do when the current light has no reference of its own. See
27075
+ * {@link SceneUncoveredPolicySchema} — the default makes night OPTIONAL. */
27076
+ onUncoveredCondition: SceneUncoveredPolicySchema.default(SCENE_DEFAULT_UNCOVERED_POLICY),
27077
+ /**
27078
+ * The light whose checks are currently being SAT OUT under
27079
+ * `onUncoveredCondition: 'skip'` — `null` when the scene is checking normally.
27080
+ *
27081
+ * Engine-reported and advisory only: it moves no verdict, no latch and no
27082
+ * hysteresis. It exists so the card can say *"night (IR) — checks paused,
27083
+ * nothing captured in this light"* in the same calm voice as the coverage
27084
+ * line, because the alternative is a scene that silently stops answering
27085
+ * after sunset with nothing anywhere saying why. A skipped check must never
27086
+ * read as a broken one.
27087
+ */
27088
+ suspendedCondition: SceneConditionSchema.nullable().default(null),
27089
+ /** Named cause when `verdict === 'unknown'`. */
27090
+ unavailable: SceneUnavailableSchema.nullable(),
27091
+ /** Conditions that have at least one comparable reference — the coverage line
27092
+ * ("day ✓ · ir ✓ · dusk ✗") that turns a silent fallback into a visible fact. */
27093
+ coveredConditions: array(SceneConditionSchema)
26420
27094
  });
26421
27095
  var SceneMonitorStatusSchema = object({
26422
27096
  monitors: array(SceneMonitorSchema),
@@ -26429,12 +27103,6 @@ var sceneMonitorCapability = {
26429
27103
  kind: "wrapper",
26430
27104
  defaultActive: true,
26431
27105
  deviceTypes: [DeviceType.Camera],
26432
- deviceConfig: { ui: {
26433
- kind: "widget",
26434
- widgetId: "host/scene-monitor-editor",
26435
- tab: "scenes",
26436
- label: "Scenes"
26437
- } },
26438
27106
  methods: {
26439
27107
  listScenes: method(object({ deviceId: number() }), SceneMonitorStatusSchema),
26440
27108
  createScene: method(object({
@@ -26465,7 +27133,15 @@ var sceneMonitorCapability = {
26465
27133
  "both"
26466
27134
  ]).optional(),
26467
27135
  checkIntervalSec: number().optional(),
26468
- check: SceneCheckSchema.optional()
27136
+ check: SceneCheckSchema.optional(),
27137
+ emit: _enum(["latched", "live"]).optional(),
27138
+ quietSeconds: number().int().min(0).max(3600).optional(),
27139
+ minObservationSpacingSec: number().int().min(0).max(3600).optional(),
27140
+ anchorThreshold: number().min(0).max(1).optional(),
27141
+ autoRestore: boolean().optional(),
27142
+ onUncoveredCondition: SceneUncoveredPolicySchema.optional(),
27143
+ /** `null` clears the vision-model adjudicator. */
27144
+ confirm: SceneConfirmSchema.nullable().optional()
26469
27145
  })
26470
27146
  }), _void(), {
26471
27147
  kind: "mutation",
@@ -26506,6 +27182,26 @@ var sceneMonitorCapability = {
26506
27182
  }), _void(), {
26507
27183
  kind: "mutation",
26508
27184
  auth: "admin"
27185
+ }),
27186
+ /**
27187
+ * Clear the latch, re-arm, and — by default — RE-CAPTURE the baseline for
27188
+ * the CURRENT condition. The bin never goes back in exactly the same spot;
27189
+ * "reset" in the operator's head means *this is the new normal*, and
27190
+ * re-capture is what makes the feature self-healing against slow drift
27191
+ * instead of failing silently weeks later.
27192
+ *
27193
+ * Reachable from three surfaces on this one mutation: the scene card, a
27194
+ * notification button (an `onTrigger` sequence with a `kind:'cap'` step —
27195
+ * no new Notification-Center code at all), and tRPC for scripts.
27196
+ */
27197
+ resetScene: method(object({
27198
+ deviceId: number(),
27199
+ monitorId: string(),
27200
+ /** Defaults to TRUE at the provider seam — see `SCENE_RESET_RECAPTURES`. */
27201
+ recapture: boolean().optional()
27202
+ }), _void(), {
27203
+ kind: "mutation",
27204
+ auth: "admin"
26509
27205
  })
26510
27206
  },
26511
27207
  status: {
@@ -26742,7 +27438,70 @@ var CamStreamDescriptorSchema = object({
26742
27438
  /** Transport-specific opaque metadata (e.g. rfc4571 SDP). */
26743
27439
  metadata: record(string(), unknown()).optional()
26744
27440
  });
26745
- DeviceType.Camera, method(object({ deviceId: number().int().nonnegative() }), array(CamStreamDescriptorSchema).readonly());
27441
+ /**
27442
+ * `stream-catalog` — device-scoped, provider-implemented. The pull counterpart
27443
+ * of the removed `publishCameraStream` push: a camera provider returns the full
27444
+ * set of stream descriptors it can offer for the device, synchronously, so the
27445
+ * broker can reconcile its registry against the authoritative provider state.
27446
+ */
27447
+ /**
27448
+ * The catalog as a DURABLE fact rather than a live answer.
27449
+ *
27450
+ * A battery camera's descriptors are profile-stable — they change when the
27451
+ * operator rewrites an encoder profile, not minute to minute — but building
27452
+ * them costs a Baichuan login, which on a sleeping Argus IS a wake. So the
27453
+ * provider is allowed to build them exactly once per profile and must serve
27454
+ * every later pull from a cache.
27455
+ *
27456
+ * Holding that cache only in RAM is what turned a restart into an outage. The
27457
+ * runner comes back with the camera asleep, `buildStreamCatalogUncached`
27458
+ * correctly refuses to wake it, the pull answers `[]`, the broker has no
27459
+ * cam-stream entry to build a broker from, and `webrtcSession.handleOffer`
27460
+ * fails with a flat "No broker for stream" — for as long as the camera sleeps,
27461
+ * which on a battery cam is most of the day. The camera was fine. The stream
27462
+ * was unreachable because the process had forgotten what the camera offers.
27463
+ *
27464
+ * Declaring it here puts it in `device-runtime-state`, the kernel's canonical
27465
+ * declared collection, with the same `restored` durability `battery` uses for
27466
+ * the same reason: the last known value is the only value there is while the
27467
+ * device is asleep. The broker's brokers are therefore always DEFINABLE — it
27468
+ * is the DIAL that wakes a camera, never the catalog (D173).
27469
+ */
27470
+ var StreamCatalogStateSchema = object({
27471
+ /** The descriptors as last built from a real camera response. Never a guess:
27472
+ * a failed or refused build writes NOTHING, so a restored catalog is always
27473
+ * one the camera itself once produced. */
27474
+ descriptors: array(CamStreamDescriptorSchema),
27475
+ /** Ms epoch of the build that produced {@link descriptors}. Lets the wake
27476
+ * path decide whether the camera's own awake window is worth spending on a
27477
+ * re-read. */
27478
+ lastFetchedAt: number()
27479
+ });
27480
+ var streamCatalogCapability = {
27481
+ name: "stream-catalog",
27482
+ scope: "device",
27483
+ deviceNative: true,
27484
+ mode: "singleton",
27485
+ deviceTypes: [DeviceType.Camera],
27486
+ methods: { getCatalog: method(object({ deviceId: number().int().nonnegative() }), array(CamStreamDescriptorSchema).readonly()) },
27487
+ runtimeState: StreamCatalogStateSchema,
27488
+ /**
27489
+ * Runtime-state durability: **restored** — see the schema doc. A cold
27490
+ * catalog on a sleeping battery camera is not a slow first frame, it is a
27491
+ * camera that cannot be watched at all until it happens to wake.
27492
+ *
27493
+ * Churn is nil by construction: the slice is written only by a SUCCESSFUL
27494
+ * build, and a build only runs when there is no cached copy (or the copy is
27495
+ * a day old and the camera is awake anyway).
27496
+ *
27497
+ * See `RuntimeStateDurability`. Enforced by
27498
+ * `scripts/check-runtime-state-durability.ts`.
27499
+ */
27500
+ durability: "restored",
27501
+ /** Clock field: written, but excluded from the compare that decides whether
27502
+ * persisting is worth a SQLite commit — the descriptors are the value. */
27503
+ volatileStateFields: ["lastFetchedAt"]
27504
+ };
26746
27505
  /** One of the camera's stream profiles. */
26747
27506
  var StreamProfileSchema = _enum([
26748
27507
  "main",
@@ -26996,12 +27755,64 @@ var NetworkAddressSchema = object({
26996
27755
  family: string(),
26997
27756
  internal: boolean()
26998
27757
  });
27758
+ /**
27759
+ * Provenance of the site coordinates, and the whole reason this is not just two
27760
+ * numbers.
27761
+ *
27762
+ * - `operator-set` — a human typed it, or accepted a detection. Authoritative;
27763
+ * nothing overwrites it.
27764
+ * - `derived-from-ip` — the hub geolocated its own public IP once, because a
27765
+ * default that is right to a few kilometres beats the coarse UTC clock split
27766
+ * the sun-times consumers otherwise fall back to.
27767
+ *
27768
+ * The UI shows which one it is. An operator who cannot tell a guess from their
27769
+ * own input will eventually trust the guess.
27770
+ */
27771
+ var SiteLocationSourceSchema = _enum(["operator-set", "derived-from-ip"]);
27772
+ /**
27773
+ * The read shape: the location plus the honest state of the one-shot derivation.
27774
+ *
27775
+ * `derivationAttemptedAt` is what makes the "one call, ever" contract
27776
+ * inspectable. When it is set and `location` is null, the geo-IP lookup ran and
27777
+ * failed; the hub will NOT try again on its own — the fallback is declared
27778
+ * (consumers degrade to their own last resort) and the operator either types the
27779
+ * coordinates or presses detect.
27780
+ */
27781
+ var SiteLocationStatusSchema = object({
27782
+ location: object({
27783
+ /** WGS84 decimal degrees. */
27784
+ latitude: number().min(-90).max(90),
27785
+ longitude: number().min(-180).max(180),
27786
+ source: SiteLocationSourceSchema,
27787
+ /** Epoch ms the value was last written. */
27788
+ updatedAt: number(),
27789
+ /**
27790
+ * Human-readable place the geo-IP service reported ("Napoli, IT"). Display
27791
+ * only — never parsed, never matched on. Absent for an operator-typed value.
27792
+ */
27793
+ label: string().optional()
27794
+ }).nullable(),
27795
+ derivationAttemptedAt: number().nullable(),
27796
+ /** Why the last derivation failed, for the UI to show instead of a shrug. */
27797
+ derivationError: string().nullable()
27798
+ });
27799
+ /** `null` clears the location and re-arms nothing — the derivation stays spent. */
27800
+ var SetSiteLocationInputSchema = object({
27801
+ latitude: number().min(-90).max(90),
27802
+ longitude: number().min(-180).max(180)
27803
+ }).nullable();
26999
27804
  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(), {
27000
27805
  kind: "mutation",
27001
27806
  auth: "admin"
27002
27807
  }), method(_void(), _void(), {
27003
27808
  kind: "mutation",
27004
27809
  auth: "admin"
27810
+ }), method(_void(), SiteLocationStatusSchema), method(SetSiteLocationInputSchema, SiteLocationStatusSchema, {
27811
+ kind: "mutation",
27812
+ auth: "admin"
27813
+ }), method(_void(), SiteLocationStatusSchema, {
27814
+ kind: "mutation",
27815
+ auth: "admin"
27005
27816
  });
27006
27817
  /**
27007
27818
  * Tamper / case-open detection sensor. Drives Home Assistant
@@ -28340,6 +29151,7 @@ var DEVICE_LOCAL_STATE_CAPS = {
28340
29151
  sceneMonitor: sceneMonitorCapability,
28341
29152
  scriptRunner: scriptRunnerCapability,
28342
29153
  smoke: smokeCapability,
29154
+ streamCatalog: streamCatalogCapability,
28343
29155
  streamParams: streamParamsCapability,
28344
29156
  switch: switchCapability,
28345
29157
  tamper: tamperCapability,
@@ -28993,6 +29805,15 @@ var BaseDeviceProvider = class extends BaseAddon {
28993
29805
  labels: ["probe not implemented"]
28994
29806
  };
28995
29807
  }
29808
+ /**
29809
+ * Top-level devices restored at once in {@link onRestoreDevices}.
29810
+ *
29811
+ * Four covers the fleets this ships to without turning a boot into a burst a
29812
+ * camera NVR answers with a refusal. A provider whose upstream is a single
29813
+ * session with a serial command channel (a Baichuan hub, an NVR that
29814
+ * serialises ISAPI) should lower it; nothing needs to raise it.
29815
+ */
29816
+ restoreConcurrency = 4;
28996
29817
  async restoreDevices(savedDevices) {
28997
29818
  await this.onRestoreDevices(savedDevices);
28998
29819
  if (savedDevices.length > 0) this.ctx.logger.info(`Restored ${savedDevices.length} ${this.providerName} device(s)`);
@@ -29024,15 +29845,15 @@ var BaseDeviceProvider = class extends BaseAddon {
29024
29845
  */
29025
29846
  async onRestoreDevices(savedDevices) {
29026
29847
  const restored = /* @__PURE__ */ new Set();
29027
- for (const saved of savedDevices) {
29028
- if (saved.parentDeviceId !== null) continue;
29848
+ const topLevel = savedDevices.filter((saved) => saved.parentDeviceId === null);
29849
+ const restoreOne = async (saved) => {
29029
29850
  const Class = this.deviceClasses[saved.type];
29030
29851
  if (!Class) {
29031
29852
  this.ctx.logger.warn("No device class registered for restored type — skipping", {
29032
29853
  tags: { stableId: saved.stableId },
29033
29854
  meta: { type: saved.type }
29034
29855
  });
29035
- continue;
29856
+ return;
29036
29857
  }
29037
29858
  try {
29038
29859
  await this.ctx.kernel.devices.create(saved.stableId, Class, {});
@@ -29046,7 +29867,15 @@ var BaseDeviceProvider = class extends BaseAddon {
29046
29867
  }
29047
29868
  });
29048
29869
  }
29049
- }
29870
+ };
29871
+ let nextTopLevel = 0;
29872
+ await Promise.all(Array.from({ length: Math.min(Math.max(1, this.restoreConcurrency), topLevel.length) }, async () => {
29873
+ for (;;) {
29874
+ const saved = topLevel[nextTopLevel++];
29875
+ if (saved === void 0) return;
29876
+ await restoreOne(saved);
29877
+ }
29878
+ }));
29050
29879
  const childRows = savedDevices.filter((s) => s.parentDeviceId !== null);
29051
29880
  for (const saved of childRows) {
29052
29881
  const Class = this.deviceClasses[saved.type];
@@ -31137,6 +31966,12 @@ Object.freeze({
31137
31966
  addonId: null,
31138
31967
  access: "create"
31139
31968
  },
31969
+ "llm.cancel": {
31970
+ capName: "llm",
31971
+ capScope: "system",
31972
+ addonId: null,
31973
+ access: "create"
31974
+ },
31140
31975
  "llm.deleteModel": {
31141
31976
  capName: "llm",
31142
31977
  capScope: "system",
@@ -31221,6 +32056,12 @@ Object.freeze({
31221
32056
  addonId: null,
31222
32057
  access: "view"
31223
32058
  },
32059
+ "llm.resolveModelRef": {
32060
+ capName: "llm",
32061
+ capScope: "system",
32062
+ addonId: null,
32063
+ access: "create"
32064
+ },
31224
32065
  "llm.setDefault": {
31225
32066
  capName: "llm",
31226
32067
  capScope: "system",
@@ -33387,6 +34228,12 @@ Object.freeze({
33387
34228
  addonId: null,
33388
34229
  access: "create"
33389
34230
  },
34231
+ "sceneMonitor.resetScene": {
34232
+ capName: "scene-monitor",
34233
+ capScope: "device",
34234
+ addonId: null,
34235
+ access: "delete"
34236
+ },
33390
34237
  "sceneMonitor.updateScene": {
33391
34238
  capName: "scene-monitor",
33392
34239
  capScope: "device",
@@ -34065,6 +34912,12 @@ Object.freeze({
34065
34912
  addonId: null,
34066
34913
  access: "create"
34067
34914
  },
34915
+ "system.detectSiteLocation": {
34916
+ capName: "system",
34917
+ capScope: "system",
34918
+ addonId: null,
34919
+ access: "create"
34920
+ },
34068
34921
  "system.featureFlags": {
34069
34922
  capName: "system",
34070
34923
  capScope: "system",
@@ -34083,6 +34936,12 @@ Object.freeze({
34083
34936
  addonId: null,
34084
34937
  access: "view"
34085
34938
  },
34939
+ "system.getSiteLocation": {
34940
+ capName: "system",
34941
+ capScope: "system",
34942
+ addonId: null,
34943
+ access: "view"
34944
+ },
34086
34945
  "system.health": {
34087
34946
  capName: "system",
34088
34947
  capScope: "system",
@@ -34107,6 +34966,12 @@ Object.freeze({
34107
34966
  addonId: null,
34108
34967
  access: "create"
34109
34968
  },
34969
+ "system.setSiteLocation": {
34970
+ capName: "system",
34971
+ capScope: "system",
34972
+ addonId: null,
34973
+ access: "create"
34974
+ },
34110
34975
  "terminalSession.adoptLegacyMonitor": {
34111
34976
  capName: "terminal-session",
34112
34977
  capScope: "system",
@@ -35589,6 +36454,11 @@ Object.freeze({
35589
36454
  form: "single",
35590
36455
  optional: false
35591
36456
  }],
36457
+ "pipelineAnalytics.getEventMedia": [{
36458
+ name: "deviceId",
36459
+ form: "single",
36460
+ optional: false
36461
+ }],
35592
36462
  "pipelineAnalytics.getKeyEvents": [{
35593
36463
  name: "deviceId",
35594
36464
  form: "single",
@@ -35619,6 +36489,11 @@ Object.freeze({
35619
36489
  form: "single",
35620
36490
  optional: false
35621
36491
  }],
36492
+ "pipelineAnalytics.getTrackMedia": [{
36493
+ name: "deviceId",
36494
+ form: "single",
36495
+ optional: false
36496
+ }],
35622
36497
  "pipelineAnalytics.getTrainingExportSummary": [{
35623
36498
  name: "deviceIds",
35624
36499
  form: "array",
@@ -35654,6 +36529,11 @@ Object.freeze({
35654
36529
  form: "array",
35655
36530
  optional: true
35656
36531
  }],
36532
+ "pipelineAnalytics.listTrackMedia": [{
36533
+ name: "deviceId",
36534
+ form: "single",
36535
+ optional: false
36536
+ }],
35657
36537
  "pipelineAnalytics.listTracks": [{
35658
36538
  name: "deviceId",
35659
36539
  form: "single",
@@ -36069,6 +36949,11 @@ Object.freeze({
36069
36949
  form: "single",
36070
36950
  optional: false
36071
36951
  }],
36952
+ "sceneMonitor.resetScene": [{
36953
+ name: "deviceId",
36954
+ form: "single",
36955
+ optional: false
36956
+ }],
36072
36957
  "sceneMonitor.updateScene": [{
36073
36958
  name: "deviceId",
36074
36959
  form: "single",
@@ -36089,6 +36974,12 @@ Object.freeze({
36089
36974
  form: "single",
36090
36975
  optional: false
36091
36976
  }],
36977
+ "snapshot.getSnapshotLinks": [{
36978
+ name: "targets",
36979
+ form: "object-array",
36980
+ optional: false,
36981
+ itemField: "deviceId"
36982
+ }],
36092
36983
  "snapshot.getSnapshotOverview": [{
36093
36984
  name: "deviceIds",
36094
36985
  form: "array",