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