@camstack/addon-provider-hikvision 1.2.22 → 1.2.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/addon.js +683 -65
  2. package/dist/addon.mjs +683 -65
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -5404,12 +5404,6 @@ Object.fromEntries([
5404
5404
  icon: "shapes",
5405
5405
  order: 38
5406
5406
  },
5407
- {
5408
- id: "scenes",
5409
- label: "Scenes",
5410
- icon: "scan-eye",
5411
- order: 36
5412
- },
5413
5407
  {
5414
5408
  id: "analytics",
5415
5409
  label: "Analytics",
@@ -11105,6 +11099,8 @@ var QueryFilterSchema = object({
11105
11099
  where: record(string(), unknown()).optional(),
11106
11100
  whereIn: record(string(), array(unknown())).optional(),
11107
11101
  whereBetween: record(string(), tuple([unknown(), unknown()])).optional(),
11102
+ /** NULL-safe exclusion: matches rows whose field is NULL OR != the value. */
11103
+ whereNot: record(string(), unknown()).optional(),
11108
11104
  orderBy: object({
11109
11105
  field: string(),
11110
11106
  direction: _enum(["asc", "desc"])
@@ -11124,7 +11120,8 @@ var QueryFilterSchema = object({
11124
11120
  var MutationFilterSchema = object({
11125
11121
  where: record(string(), unknown()).optional(),
11126
11122
  whereIn: record(string(), array(unknown())).optional(),
11127
- whereBetween: record(string(), tuple([unknown(), unknown()])).optional()
11123
+ whereBetween: record(string(), tuple([unknown(), unknown()])).optional(),
11124
+ whereNot: record(string(), unknown()).optional()
11128
11125
  });
11129
11126
  /** A single stored record: `{ id, data }`. */
11130
11127
  var SettingsRecordSchema = object({
@@ -12643,6 +12640,17 @@ var LlmImageSchema = object({
12643
12640
  bytes: _instanceof(Uint8Array),
12644
12641
  mimeType: string()
12645
12642
  });
12643
+ /**
12644
+ * Retry policy. `enabled: false` is NOT the same as `maxAttempts: 1` in intent —
12645
+ * the flag is what a consumer table flips, the count is what the operator tunes.
12646
+ * A retry doubles the wall time of a call, so the two gates that run inside a
12647
+ * notification's budget keep it off (see `CONSUMER_RETRY_POLICY` in addon-ai).
12648
+ */
12649
+ var LlmRetryPolicySchema = object({
12650
+ enabled: boolean().default(false),
12651
+ /** Total attempts INCLUDING the first. 1 = no retry. */
12652
+ maxAttempts: number().int().min(1).max(5).default(1)
12653
+ });
12646
12654
  var LlmGenerateBaseInputSchema = object({
12647
12655
  /** Collection routing (the notification-output posture). */
12648
12656
  addonId: string().optional(),
@@ -12657,7 +12665,28 @@ var LlmGenerateBaseInputSchema = object({
12657
12665
  jsonSchema: record(string(), unknown()).optional(),
12658
12666
  /** Per-call override of the profile default. */
12659
12667
  maxTokens: number().int().positive().optional(),
12660
- temperature: number().optional()
12668
+ temperature: number().optional(),
12669
+ /** Per-call override of the profile default (nucleus sampling). */
12670
+ topP: number().min(0).max(1).optional(),
12671
+ /** Per-call override of the profile default (top-k sampling). */
12672
+ topK: number().int().positive().optional(),
12673
+ /** Per-call override of `profile.timeoutMs` — the total generation bound. */
12674
+ timeoutMs: number().int().positive().optional(),
12675
+ /** Per-call override; beats both the consumer table and the profile. */
12676
+ retry: LlmRetryPolicySchema.optional(),
12677
+ /**
12678
+ * Caller-minted id that makes this generation CANCELLABLE.
12679
+ *
12680
+ * Without it a caller that stops waiting cannot stop the work: the gates race
12681
+ * the call against 8 s and free their own slot when the timer wins, while the
12682
+ * generation upstream keeps running to `profile.timeoutMs` — 60 s by default,
12683
+ * on a single-threaded local model. The per-camera bound then counts WAITS,
12684
+ * not generations, and the real load is unbounded.
12685
+ *
12686
+ * `AbortSignal` cannot cross a process boundary; an id can. Pass one here and
12687
+ * `llm.cancel({ requestId })` tears the socket down.
12688
+ */
12689
+ requestId: string().optional()
12661
12690
  });
12662
12691
  /**
12663
12692
  * `llm-runtime` — node-side managed llama.cpp executor (spec §4). Registered
@@ -12670,6 +12699,18 @@ var LlmGenerateBaseInputSchema = object({
12670
12699
  * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
12671
12700
  * watchdog — operator decision #3).
12672
12701
  */
12702
+ /**
12703
+ * A companion artifact that MUST land beside the main GGUF: the `mmproj`
12704
+ * projector of a vision model, or shards 2..N of a split GGUF. Carried on the
12705
+ * REF rather than looked up at install time, so what the operator approved in
12706
+ * the preview is exactly what the node downloads.
12707
+ */
12708
+ var ManagedModelExtraFileSchema = object({
12709
+ url: string(),
12710
+ filename: string(),
12711
+ sizeBytes: number(),
12712
+ sha256: string().optional()
12713
+ });
12673
12714
  var ManagedModelRefSchema = discriminatedUnion("kind", [
12674
12715
  object({
12675
12716
  kind: literal("catalog"),
@@ -12678,7 +12719,11 @@ var ManagedModelRefSchema = discriminatedUnion("kind", [
12678
12719
  object({
12679
12720
  kind: literal("url"),
12680
12721
  url: string(),
12681
- sha256: string().optional()
12722
+ sha256: string().optional(),
12723
+ /** Picker/status label; the file basename when absent. */
12724
+ label: string().optional(),
12725
+ sizeBytes: number().optional(),
12726
+ extraFiles: array(ManagedModelExtraFileSchema).optional()
12682
12727
  }),
12683
12728
  object({
12684
12729
  kind: literal("path"),
@@ -12696,13 +12741,82 @@ var ManagedRuntimeConfigSchema = object({
12696
12741
  gpuLayers: number().int().default(0),
12697
12742
  /** Default: cpus-2, clamped ≥1 (resolved node-side). */
12698
12743
  threads: number().int().optional(),
12699
- /** Concurrent slots. */
12744
+ /** Concurrent slots (`--parallel`). */
12700
12745
  parallel: number().int().default(1),
12746
+ /** Logical batch size (`-b`). Larger = faster prompt ingest, more RAM. */
12747
+ batchSize: number().int().positive().optional(),
12748
+ /** Physical batch / micro-batch (`-ub`). */
12749
+ ubatchSize: number().int().positive().optional(),
12750
+ /**
12751
+ * `--flash-attn`. Cuts KV-cache memory on the backends that implement it and
12752
+ * is a no-op elsewhere, so it is offered rather than assumed.
12753
+ */
12754
+ flashAttention: boolean().default(false),
12755
+ /**
12756
+ * `--mlock`. Pins the weights in RAM so the OS cannot page them out mid
12757
+ * inference. Costs the full model size in resident memory — which is exactly
12758
+ * what the RAM budget is counting.
12759
+ */
12760
+ mlock: boolean().default(false),
12761
+ /**
12762
+ * `--no-mmap`. Reads the whole GGUF up front instead of mapping it. Slower to
12763
+ * start, but avoids the page-fault stalls a network or spinning-disk model
12764
+ * store produces on every first token.
12765
+ */
12766
+ noMmap: boolean().default(false),
12767
+ /** `--cache-type-k` / `--cache-type-v` — quantising the KV cache is the
12768
+ * cheapest way to fit a longer context in the same RAM. */
12769
+ cacheTypeK: _enum([
12770
+ "f32",
12771
+ "f16",
12772
+ "q8_0",
12773
+ "q5_1",
12774
+ "q5_0",
12775
+ "q4_1",
12776
+ "q4_0"
12777
+ ]).optional(),
12778
+ cacheTypeV: _enum([
12779
+ "f32",
12780
+ "f16",
12781
+ "q8_0",
12782
+ "q5_1",
12783
+ "q5_0",
12784
+ "q4_1",
12785
+ "q4_0"
12786
+ ]).optional(),
12787
+ /**
12788
+ * Escape hatch for llama-server flags this schema does NOT model — `--jinja`
12789
+ * (which most vision chat templates need and some language-only models
12790
+ * dislike), `--cont-batching`, `--rope-scaling`, …
12791
+ *
12792
+ * It is NOT a second place to set the flags above. A token that collides
12793
+ * with a typed field is REJECTED at start, naming the field that owns it
12794
+ * (`assertNoOwnedFlags`), because two knobs writing the same argv is exactly
12795
+ * the "two switches that disagree" failure this repo has already shipped
12796
+ * twice (D62).
12797
+ */
12798
+ extraArgs: array(string()).default([]),
12701
12799
  /** Else lazy: first generate boots it. */
12702
12800
  autoStart: boolean().default(false),
12703
12801
  /** 0 = never; frees RAM after quiet periods. */
12704
12802
  idleStopMinutes: number().int().default(30)
12705
12803
  });
12804
+ /**
12805
+ * Where a multi-GB install currently is. A single 0..1 fraction cannot answer
12806
+ * "is it stuck?" for an install that is three files (shards + mmproj) followed
12807
+ * by a sha256 pass over 22 GB — during which the fraction sat at 1.0 and the
12808
+ * node looked hung. Phase + file + bytes is the smallest shape that does.
12809
+ */
12810
+ var LlmDownloadProgressSchema = object({
12811
+ phase: _enum(["downloading", "verifying"]),
12812
+ /** The artifact currently moving, e.g. `mmproj-F16.gguf`. */
12813
+ file: string(),
12814
+ fileIndex: number().int(),
12815
+ fileCount: number().int(),
12816
+ /** Across the WHOLE install, not the current file. */
12817
+ downloadedBytes: number(),
12818
+ totalBytes: number().optional()
12819
+ });
12706
12820
  var LlmRuntimeStatusSchema = object({
12707
12821
  /** Status is ALWAYS node-qualified. */
12708
12822
  nodeId: string(),
@@ -12719,6 +12833,8 @@ var LlmRuntimeStatusSchema = object({
12719
12833
  modelPath: string().optional(),
12720
12834
  modelId: string().optional(),
12721
12835
  downloadProgress: number().min(0).max(1).optional(),
12836
+ /** Detail behind `downloadProgress`; present for the same lifetime. */
12837
+ download: LlmDownloadProgressSchema.optional(),
12722
12838
  lastError: string().optional(),
12723
12839
  crashesInWindow: number(),
12724
12840
  /** Child RSS (sampled best-effort). */
@@ -12729,7 +12845,14 @@ var LlmNodeModelSchema = object({
12729
12845
  file: string(),
12730
12846
  sizeBytes: number(),
12731
12847
  catalogId: string().optional(),
12732
- installedAt: number().optional()
12848
+ installedAt: number().optional(),
12849
+ /**
12850
+ * Absolute path on the node. Present so a file that is on disk but matches
12851
+ * no catalog entry — a custom Hugging Face install, or a GGUF the operator
12852
+ * copied in by hand — is still SELECTABLE, as a `{kind:'path'}` ref. Without
12853
+ * it the picker could list such a file and do nothing with it.
12854
+ */
12855
+ path: string().optional()
12733
12856
  });
12734
12857
  var LlmRuntimeDiskUsageSchema = object({
12735
12858
  nodeId: string(),
@@ -12785,10 +12908,47 @@ var LlmProfileSchema = object({
12785
12908
  baseUrl: string().optional(),
12786
12909
  /** ConfigUISchema type:'password' — never round-trips (spec §5). */
12787
12910
  apiKey: string().optional(),
12911
+ /** Vision on/off. A vision call against a `false` profile is REFUSED, never
12912
+ * degraded to text — that shipped once and produced a confident answer to a
12913
+ * question about a picture nobody sent. */
12788
12914
  supportsVision: boolean(),
12789
12915
  temperature: number().min(0).max(2).optional(),
12916
+ /** Nucleus sampling. Every wire we speak has it. */
12917
+ topP: number().min(0).max(1).optional(),
12918
+ /** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
12919
+ * wire does, and the client drops it there (measured: the request body gets
12920
+ * `top_p` and no `top_k`). The profile editor hides the field wherever it
12921
+ * would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
12922
+ topK: number().int().positive().optional(),
12790
12923
  maxTokens: number().int().positive().optional(),
12924
+ /** Prompt context window. Advisory for cloud kinds (they enforce their own);
12925
+ * for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
12926
+ * the model with, so it is the one field that changes a PROCESS. */
12927
+ contextLength: number().int().positive().optional(),
12928
+ /** Default system prompt. A caller's `system` REPLACES it (never appends —
12929
+ * two system prompts fighting is worse than either alone). */
12930
+ systemPrompt: string().optional(),
12931
+ /** Total generation bound — the only one a unary call has. */
12791
12932
  timeoutMs: number().int().positive().default(6e4),
12933
+ /** The TCP handshake only — "is the port even open". NOT the wait for
12934
+ * response headers: on the LM Studio / llama-server wire those are written
12935
+ * once the model has finished loading, so they belong to the bound below. */
12936
+ connectTimeoutMs: number().int().positive().default(1e4),
12937
+ /** Accepted, but no output yet — response headers included, because a cold
12938
+ * GPU load is exactly what happens before them. */
12939
+ firstTokenTimeoutMs: number().int().positive().default(12e4),
12940
+ /** Output started then stopped. */
12941
+ idleTimeoutMs: number().int().positive().default(6e4),
12942
+ /** Profile-level default. The per-consumer table and a per-call override
12943
+ * both beat it — see `resolveRetryPolicy`. */
12944
+ retry: LlmRetryPolicySchema.default({
12945
+ enabled: false,
12946
+ maxAttempts: 1
12947
+ }),
12948
+ /** Whether this profile may use tools. The tool-call plumbing rides the
12949
+ * library; the REGISTRY of callable tools is ours and is empty in v1, so a
12950
+ * `true` here buys the wiring, not behaviour, until tools are registered. */
12951
+ toolsEnabled: boolean().default(false),
12792
12952
  extraHeaders: record(string(), string()).optional(),
12793
12953
  /** kind === 'managed-local' only (spec §4). */
12794
12954
  runtime: ManagedRuntimeConfigSchema.optional()
@@ -12838,6 +12998,36 @@ var ManagedModelCatalogEntrySchema = object({
12838
12998
  /** Vision models: companion projector file. */
12839
12999
  mmprojUrl: string().optional()
12840
13000
  });
13001
+ /**
13002
+ * The outcome of turning one operator-typed Hugging Face reference into a
13003
+ * download plan. A RESULT, never a throw: "this repo has 24 quantizations and
13004
+ * I will not pick for you" is a normal answer the UI has to render, not an
13005
+ * exception.
13006
+ *
13007
+ * `candidates` is the whole reason the refusal is usable — every string in it
13008
+ * is a tag that resolves when pasted back as `<org>/<repo>:<TAG>`.
13009
+ */
13010
+ var HfModelResolutionSchema = discriminatedUnion("ok", [object({
13011
+ ok: literal(true),
13012
+ /** Ready to hand to `installModel` unchanged. */
13013
+ model: ManagedModelRefSchema,
13014
+ label: string(),
13015
+ repo: string(),
13016
+ quantization: string(),
13017
+ purpose: _enum(["text", "vision"]),
13018
+ totalBytes: number(),
13019
+ /** mmproj + shards, for the preview: an operator approving 23 GB should
13020
+ * see that 0.9 GB of it is a projector they did not name. */
13021
+ extraFilenames: array(string())
13022
+ }), object({
13023
+ ok: literal(false),
13024
+ code: string(),
13025
+ message: string(),
13026
+ candidates: array(string()).optional(),
13027
+ /** Set when the refusal was only the ceiling: re-calling with
13028
+ * `maxBytes: requiredBytes` is the operator's explicit override. */
13029
+ requiredBytes: number().optional()
13030
+ })]);
12841
13031
  var LlmRuntimeNodeSchema = object({
12842
13032
  nodeId: string(),
12843
13033
  reachable: boolean(),
@@ -12850,7 +13040,10 @@ var ProfileRefInputSchema = object({
12850
13040
  addonId: string(),
12851
13041
  profileId: string()
12852
13042
  });
12853
- method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
13043
+ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({
13044
+ addonId: string().optional(),
13045
+ requestId: string()
13046
+ }), _void(), { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
12854
13047
  kind: "mutation",
12855
13048
  auth: "admin"
12856
13049
  }), method(ProfileRefInputSchema, _void(), {
@@ -12871,6 +13064,15 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }
12871
13064
  consumer: string().optional(),
12872
13065
  profileId: string().optional()
12873
13066
  }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
13067
+ /** `https://huggingface.co/<org>/<repo>/resolve/main/<f>.gguf`,
13068
+ * `<org>/<repo>/<f>.gguf`, `<org>/<repo>` or `<org>/<repo>:<QUANT>`. */
13069
+ ref: string(),
13070
+ /** Explicit ceiling override, in bytes. Absent = the built-in ceiling. */
13071
+ maxBytes: number().positive().optional()
13072
+ }), HfModelResolutionSchema, {
13073
+ kind: "mutation",
13074
+ auth: "admin"
13075
+ }), method(object({
12874
13076
  nodeId: string(),
12875
13077
  model: ManagedModelRefSchema
12876
13078
  }), _void(), {
@@ -14624,28 +14826,36 @@ var NcOccupancyConditionSchema = object({
14624
14826
  /**
14625
14827
  * Audio condition (IMMEDIATE trigger) — a rule on SOUND, not on a picture.
14626
14828
  *
14627
- * Operator-approved vocabulary (2026-08-12, option A — the same one the
14628
- * reference notifier uses, so an operator moving between them re-uses what
14629
- * they already know): a rule matches when, over a sampling window of
14630
- * `samplingSeconds`, at least `hitPercent`% of the audio samples in that
14631
- * window are HITS. A sample is a hit when it satisfies BOTH present filters:
14632
- *
14633
- * - `dbThreshold` its level is at or above this many dBFS (see
14634
- * {@link NC_AUDIO_DBFS_FLOOR}: negative-going, `0` = full scale);
14635
- * - `labels` the classifier put at least one of these labels on it.
14636
- *
14637
- * Both are OPTIONAL and independent, which is the point of the shape: a
14638
- * loudness rule ("something loud at 3am") needs no model to be right, and a
14639
- * label rule ("a dog barked") needs no threshold. **Fail-closed when NEITHER
14640
- * is given** a window in which every sample is trivially a hit would fire on
14641
- * silence, so the engine refuses such a condition rather than notifying on
14642
- * nothing (the schema cannot express "at least one of" without becoming a
14643
- * ZodEffects the cap path would have to special-case).
14644
- *
14645
- * `hitPercent` is over the samples the window actually HOLDS, and the window
14646
- * must be FULL before it can match a window that has been open for two
14647
- * seconds of its ten is 100% of nothing, and firing on it would make
14648
- * `samplingSeconds` decorative.
14829
+ * **TWO EXCLUSIVE MODES** (operator decision 2026-08-14, D157). Which one a
14830
+ * rule is in is not a stored field it is WHICH FILTER the rule carries, so
14831
+ * there is no second switch that can disagree with the first and every rule
14832
+ * authored before the decision migrates for free (`audioModeOf`):
14833
+ *
14834
+ * - **LABEL mode — `labels` present.** The rule fires on the FIRST frame the
14835
+ * classifier labels with one of them. No window, no percentage:
14836
+ * `hitPercent` and `samplingSeconds` are ignored, and the rule's own
14837
+ * `throttle` cooldown is the only brake. The per-label confidence floor is
14838
+ * the analyzer's (`classificationMinScore`, per device) — a label only
14839
+ * reaches this condition if the classifier was already confident enough.
14840
+ * - **LEVEL mode `dbThreshold` present, no labels.** The sampling window IS
14841
+ * the condition: at least `hitPercent`% of the samples over
14842
+ * `samplingSeconds` must be at or above `dbThreshold` dBFS (see
14843
+ * {@link NC_AUDIO_DBFS_FLOOR}: negative-going, `0` = full scale). The window
14844
+ * must be FULL before it can match a window open for two of its ten
14845
+ * seconds is 100% of nothing.
14846
+ *
14847
+ * **Why label mode has no window.** It had one, and it never fired: the
14848
+ * analyzer emits ~1 audio frame per second but YAMNet only LABELS one to three
14849
+ * of them per episode, even through continuous crying. The measured maximum
14850
+ * `hitPercent` over the whole live history was 40 — under the shipped default
14851
+ * of 60, so a label rule could not fire at all, ever. A percentage of frames is
14852
+ * the wrong question to ask of a sparse classifier.
14853
+ *
14854
+ * **Fail-closed when NEITHER is given** — every sample would be a trivial hit
14855
+ * and the rule would fire on silence. The schema cannot express "exactly one
14856
+ * of" without becoming a ZodEffects the cap path would have to special-case, so
14857
+ * the exclusivity is enforced where every editor writes (`patchAudio`) and a
14858
+ * legacy rule carrying both resolves to LABEL (the mode that fires).
14649
14859
  *
14650
14860
  * Labels are the audio macro classes (`AUDIO_MACRO_LABELS` / the NC taxonomy's
14651
14861
  * `audio-*` ids). Both spellings are accepted — the matcher normalizes the
@@ -14653,13 +14863,13 @@ var NcOccupancyConditionSchema = object({
14653
14863
  * an operator who typed `dog` mean the same thing.
14654
14864
  */
14655
14865
  var NcAudioConditionSchema = object({
14656
- /** Audio macro labels; absent = any sound (level-only rule). */
14866
+ /** LABEL MODE: audio macro labels. Present fires on the first labelled frame. */
14657
14867
  labels: array(string().min(1)).min(1).optional(),
14658
- /** Level floor in dBFS (negative-going, `0` = full scale); absent = any level. */
14868
+ /** LEVEL MODE: floor in dBFS (negative-going, `0` = full scale). */
14659
14869
  dbThreshold: number().min(-96).max(0).optional(),
14660
- /** Percentage of the window's samples that must be hits (1–100). */
14870
+ /** LEVEL MODE ONLY: percentage of the window's samples that must be hits (1–100). */
14661
14871
  hitPercent: number().int().min(1).max(100).default(60),
14662
- /** Length of the sampling window in seconds. */
14872
+ /** LEVEL MODE ONLY: length of the sampling window in seconds. */
14663
14873
  samplingSeconds: number().int().min(1).max(300).default(10)
14664
14874
  });
14665
14875
  /**
@@ -14797,13 +15007,81 @@ var NcRuleActionsSchema = object({
14797
15007
  */
14798
15008
  buttons: array(NcRuleNotificationButtonSchema).max(8).optional()
14799
15009
  });
15010
+ /**
15011
+ * "This rule applies only while `deviceId` is in one of `states`."
15012
+ *
15013
+ * The states are the DEVICE's own vocabulary — `AlarmState` for a panel,
15014
+ * `on`/`off` for a switch — not a normalised set, because normalising would
15015
+ * make the condition lie about devices whose states have no equivalent.
15016
+ *
15017
+ * An unreadable state does NOT match: see the engine's fail-closed gate. A
15018
+ * condition that fired on "I could not read it" would be worse than no gate.
15019
+ */
15020
+ var NcDeviceStateConditionSchema = object({
15021
+ deviceId: number().int(),
15022
+ /** Any of these matches. */
15023
+ states: array(string().min(1)).min(1)
15024
+ });
15025
+ /**
15026
+ * "This rule applies only while scene `sceneId` is `matched` / `diverged`."
15027
+ *
15028
+ * A GATE, not a trigger. `occupancy` and `audio` each DISCRIMINATE their rule —
15029
+ * carrying one makes the rule fire on that subject and nothing else. Scene is
15030
+ * the other shape entirely, the `deviceState` shape: it narrows a rule that
15031
+ * already has a trigger ("tell me about a person at the front door, but only
15032
+ * while the bin is still out"). That is why it composes with every delivery
15033
+ * instead of owning one, and why no new `NcDelivery` member and no new subject
15034
+ * kind exist for it — see D159.
15035
+ *
15036
+ * ── Identity ───────────────────────────────────────────────────────────────
15037
+ * `sceneId` is `SceneMonitor.id`, a `randomUUID()` minted by `createScene` —
15038
+ * globally unique, so it needs no device to disambiguate it. `deviceId` is
15039
+ * carried as a HINT for the editor and for the log line, never as part of the
15040
+ * lookup key: a rule whose hint drifted must still gate correctly.
15041
+ *
15042
+ * ── Which boolean ──────────────────────────────────────────────────────────
15043
+ * `latched` ABSENT means "whatever the scene itself says" — `SceneMonitor.emit`
15044
+ * already declares which boolean drives notification rules, and a second knob
15045
+ * that could disagree with it is exactly the D62 failure. Set it only to
15046
+ * override one rule against the scene's own default.
15047
+ *
15048
+ * - LIVE reading (`emit`/`latched` resolve to live): passes iff
15049
+ * `verdict === requiredState`. `unknown` — no reference for this light, view
15050
+ * shifted, no snapshot — passes NEITHER. A scene that cannot judge is not
15051
+ * evidence, in either direction.
15052
+ * - LATCHED reading: passes iff `latched === (requiredState === 'diverged')`.
15053
+ * The latch is a durable fact about the past ("it has diverged since I armed
15054
+ * it"), so a camera that has gone dark does not clear it — that is the whole
15055
+ * reason the operator asked for a latch.
15056
+ *
15057
+ * The gate reads an in-memory mirror (`NcSceneStateCache`) refreshed OFF the
15058
+ * event path, never the cap: D49. A mirror that has never loaded, or a scene it
15059
+ * does not carry, reads absent and the rule does NOT fire — fail closed, and
15060
+ * said out loud in the log rather than dropped in silence.
15061
+ */
15062
+ var NcSceneConditionSchema = object({
15063
+ /** `SceneMonitor.id` — the uuid the cap mints. The whole lookup key. */
15064
+ sceneId: string().min(1),
15065
+ /** The camera the scene lives on. A hint for the editor and the log line. */
15066
+ deviceId: number().int().optional(),
15067
+ /** The state the scene must be in for the rule to fire. */
15068
+ requiredState: _enum(["matched", "diverged"]),
15069
+ /**
15070
+ * Read the LATCH (`true`) or the LIVE verdict (`false`). Absent = follow the
15071
+ * scene's own `emit` field, which is the only place that decision belongs.
15072
+ */
15073
+ latched: boolean().optional()
15074
+ });
14800
15075
  var NcConditionsSchema = object({
14801
15076
  /** Gate on ANOTHER device's current state (the alarm armed, a switch on). */
14802
- deviceState: object({
14803
- deviceId: number().int(),
14804
- /** Any of these matches. */
14805
- states: array(string().min(1)).min(1)
14806
- }).optional(),
15077
+ deviceState: NcDeviceStateConditionSchema.optional(),
15078
+ /**
15079
+ * Gate on a SCENE's state — "only while the bin is still out". Composes with
15080
+ * every trigger (detection, occupancy, audio, sensor, package, track-end);
15081
+ * unlike `occupancy`/`audio` it discriminates nothing. See
15082
+ * {@link NcSceneCondition} and D159.
15083
+ */
15084
+ scene: NcSceneConditionSchema.optional(),
14807
15085
  /** Device scope — absent = all devices. */
14808
15086
  devices: array(number()).optional(),
14809
15087
  /** Detector class names (any overlap with the record's class set). */
@@ -15441,6 +15719,7 @@ var NcConditionDescriptorSchema = object({
15441
15719
  "occupancy",
15442
15720
  "audio",
15443
15721
  "deviceState",
15722
+ "scene",
15444
15723
  "systemEvent"
15445
15724
  ]),
15446
15725
  operator: _enum([
@@ -16918,7 +17197,10 @@ var RecentTracksQueryInput = object({
16918
17197
  * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
16919
17198
  cursor: string().optional(),
16920
17199
  /** See {@link TrackProjectionSchema}. Default `full`. */
16921
- projection: TrackProjectionSchema.optional()
17200
+ projection: TrackProjectionSchema.optional(),
17201
+ /** Include stationary-promoted rows (parked objects). Default false: the
17202
+ * feed lists passages; parking records live on the stationary registry. */
17203
+ includeStationary: boolean().optional()
16922
17204
  });
16923
17205
  var RecentTracksPageSchema = object({
16924
17206
  /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
@@ -17136,7 +17418,11 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
17136
17418
  zone: TrackZoneFilterSchema.optional(),
17137
17419
  /** See {@link TrackProjectionSchema}. Default `full` (backward
17138
17420
  * compatible — omitting the field keeps today's exact behaviour). */
17139
- projection: TrackProjectionSchema.optional()
17421
+ projection: TrackProjectionSchema.optional(),
17422
+ /** Include stationary-promoted rows (parked objects handed to the
17423
+ * stationary registry). Default false: the timeline lists passages,
17424
+ * not parking records (operator decision, 2026-08-15). */
17425
+ includeStationary: boolean().optional()
17140
17426
  }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(object({ deviceId: number() }), _void(), {
17141
17427
  kind: "mutation",
17142
17428
  auth: "admin"
@@ -17300,11 +17586,16 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
17300
17586
  auth: "admin"
17301
17587
  }), method(object({
17302
17588
  eventId: string(),
17303
- kind: MediaFileKindEnum.optional()
17589
+ kind: MediaFileKindEnum.optional(),
17590
+ deviceId: number()
17304
17591
  }), array(MediaFileSchema).readonly()), method(object({
17305
17592
  trackId: string(),
17306
- kinds: array(MediaFileKindEnum).optional()
17307
- }), array(MediaFileSchema).readonly()), method(object({ trackId: string() }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
17593
+ kinds: array(MediaFileKindEnum).optional(),
17594
+ deviceId: number()
17595
+ }), array(MediaFileSchema).readonly()), method(object({
17596
+ trackId: string(),
17597
+ deviceId: number()
17598
+ }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
17308
17599
  kind: "mutation",
17309
17600
  auth: "admin"
17310
17601
  }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
@@ -18004,6 +18295,17 @@ var maxSessionHoldMsField = {
18004
18295
  default: 12e4,
18005
18296
  step: 5e3
18006
18297
  };
18298
+ /**
18299
+ * Quiet period that closes an `audioMode: 'on-motion'` audio window. Floor of
18300
+ * 5s so a rearm can never degenerate into per-event stream churn; default 90s
18301
+ * comfortably outlives the gap between two PIR wakes on a battery camera.
18302
+ */
18303
+ var audioMotionWindowMsField = {
18304
+ min: 5e3,
18305
+ max: 6e5,
18306
+ default: 9e4,
18307
+ step: 5e3
18308
+ };
18007
18309
  var motionFpsField = {
18008
18310
  min: 1,
18009
18311
  max: 30,
@@ -18180,6 +18482,27 @@ var RunnerCameraConfigSchema = object({
18180
18482
  * resolved `CameraDetectionConfig`.
18181
18483
  */
18182
18484
  maxSessionHoldMs: number().min(maxSessionHoldMsField.min).max(maxSessionHoldMsField.max).optional(),
18485
+ /**
18486
+ * Orchestrator-side quiet period (ms) that closes an `audioMode:
18487
+ * 'on-motion'` audio window, measured from the LAST motion event.
18488
+ *
18489
+ * This exists because the falling edge cannot be relied on. Camera-native
18490
+ * providers emit motion as a RISING EDGE ONLY (Reolink's Baichuan push and
18491
+ * its email-push SMTP path both emit `detected: true` and never the
18492
+ * counterpart); only the frame-diff analyzer emits falls. So on an
18493
+ * onboard-only camera a window that closed only on `detected: false` never
18494
+ * closed at all, and `on-motion` silently behaved as `always-on` — on a
18495
+ * battery camera, the one failure mode the mode exists to prevent.
18496
+ *
18497
+ * Every motion event rearms this timer WITHOUT restarting the stream, so a
18498
+ * burst of re-fires costs nothing. A falling edge, when one does arrive,
18499
+ * still closes earlier via `motionCooldownMs` — whichever comes first wins.
18500
+ *
18501
+ * Not consumed by the runner: carried here so it shares the per-camera
18502
+ * device-settings surface with `motionCooldownMs`, exactly like
18503
+ * `maxSessionHoldMs`.
18504
+ */
18505
+ audioMotionWindowMs: number().min(audioMotionWindowMsField.min).max(audioMotionWindowMsField.max).optional(),
18183
18506
  motionFps: number().min(motionFpsField.min).max(motionFpsField.max).default(motionFpsField.default),
18184
18507
  detectionFps: number().min(detectionFpsField.min).max(detectionFpsField.max).default(detectionFpsField.default),
18185
18508
  motionStreamId: string(),
@@ -18275,7 +18598,7 @@ var RunnerCameraConfigSchema = object({
18275
18598
  */
18276
18599
  inferenceDevices: array(RunnerInferenceDeviceSchema).readonly().optional()
18277
18600
  });
18278
- motionFpsField.min, motionFpsField.max, motionFpsField.step, motionFpsField.default, detectionFpsField.min, detectionFpsField.max, detectionFpsField.step, detectionFpsField.default, motionCooldownMsField.min, motionCooldownMsField.max, motionCooldownMsField.step, motionCooldownMsField.default, maxSessionHoldMsField.min, maxSessionHoldMsField.max, maxSessionHoldMsField.step, maxSessionHoldMsField.default, occupancyRecheckSecField.min, occupancyRecheckSecField.max, occupancyRecheckSecField.step, occupancyRecheckSecField.default, occupancyRecheckFramesField.min, occupancyRecheckFramesField.max, occupancyRecheckFramesField.step, occupancyRecheckFramesField.default;
18601
+ motionFpsField.min, motionFpsField.max, motionFpsField.step, motionFpsField.default, detectionFpsField.min, detectionFpsField.max, detectionFpsField.step, detectionFpsField.default, motionCooldownMsField.min, motionCooldownMsField.max, motionCooldownMsField.step, motionCooldownMsField.default, maxSessionHoldMsField.min, maxSessionHoldMsField.max, maxSessionHoldMsField.step, maxSessionHoldMsField.default, audioMotionWindowMsField.min, audioMotionWindowMsField.max, audioMotionWindowMsField.step, audioMotionWindowMsField.default, occupancyRecheckSecField.min, occupancyRecheckSecField.max, occupancyRecheckSecField.step, occupancyRecheckSecField.default, occupancyRecheckFramesField.min, occupancyRecheckFramesField.max, occupancyRecheckFramesField.step, occupancyRecheckFramesField.default;
18279
18602
  /**
18280
18603
  * Runtime load summary returned by `getLocalLoad`. Used by the orchestrator's
18281
18604
  * load-balancing levels (L2 capacity-based, L3 hardware-aware) to decide
@@ -19308,6 +19631,39 @@ var snapshotCapability = {
19308
19631
  etag: string().nullable()
19309
19632
  }))),
19310
19633
  /**
19634
+ * The full decision chain for ONE device, for the viewer's debug readout —
19635
+ * the answer to "why does this tile show what it shows" in a single poll:
19636
+ * the battery slice the state was derived from, the resolved state + its
19637
+ * reason, the cached frame's identity/age, whether a wake window is open,
19638
+ * and whether a fresh capture is in flight. Cache-only and capture-free:
19639
+ * a debug read must never wake a battery camera.
19640
+ */
19641
+ getDebugState: systemMethod(object({ deviceId: number() }), object({
19642
+ /** The battery slice as read, or null when the device has none. */
19643
+ battery: object({
19644
+ sleeping: boolean(),
19645
+ lastUpdated: number(),
19646
+ lastContactAt: number().optional()
19647
+ }).nullable(),
19648
+ /** The resolved snapshot state (what the overlay decision used). */
19649
+ state: object({
19650
+ isBattery: boolean(),
19651
+ reason: _enum([
19652
+ "disabled",
19653
+ "sleeping",
19654
+ "unreachable",
19655
+ "waking"
19656
+ ]).nullable()
19657
+ }),
19658
+ /** The cached frame behind the next paint. */
19659
+ frame: object({
19660
+ capturedAt: number().nullable(),
19661
+ ageMs: number().nullable()
19662
+ }),
19663
+ /** A wake window is currently open (the Waking overlay's source). */
19664
+ waking: boolean()
19665
+ })),
19666
+ /**
19311
19667
  * Signed, expiring links to a CLIENT-SIZED frame — and the demand signal
19312
19668
  * that makes those frames current.
19313
19669
  *
@@ -19380,7 +19736,16 @@ targets: array(object({
19380
19736
  /** A sleeping battery camera: the frame is deliberately stale and will
19381
19737
  * NOT refresh in the background. A surface should say so rather than
19382
19738
  * present it as current. */
19383
- sleeping: boolean()
19739
+ sleeping: boolean(),
19740
+ /** Current device state rendered over the cached frame. State images
19741
+ * remain authoritative even when their photographic background is
19742
+ * old; null means the link must carry a current camera frame. */
19743
+ stateReason: _enum([
19744
+ "disabled",
19745
+ "sleeping",
19746
+ "unreachable",
19747
+ "waking"
19748
+ ]).nullable()
19384
19749
  })))
19385
19750
  },
19386
19751
  status: {
@@ -21040,6 +21405,25 @@ var BatteryStatusSchema = object({
21040
21405
  /** Ms epoch of the last observation. Lets consumers reason about freshness. */
21041
21406
  lastUpdated: number(),
21042
21407
  /**
21408
+ * Ms epoch of the last time the device PROVED it was reachable — a
21409
+ * completed firmware round-trip, an observed wake, or an inbound push
21410
+ * (firmware event, email). `0`/absent = never since this slice was born.
21411
+ *
21412
+ * This is the ONLY input that separates "asleep" from "gone", and it is
21413
+ * fed exclusively by PASSIVE signals: nothing may write it by reaching
21414
+ * for the radio, because a poll that confirms reachability is the same
21415
+ * poll that drains the battery. See {@link deriveBatteryPresence} — the
21416
+ * single derivation every consumer must use; no surface computes its own.
21417
+ *
21418
+ * It is deliberately NOT a clock in the
21419
+ * `scripts/check-runtime-state-durability.ts` sense: it is the
21420
+ * observation itself, and it is the only thing a 30-hour silence is
21421
+ * visible in. Writers quantise it (see `CONTACT_WRITE_QUANTUM_MS` in the
21422
+ * Reolink provider) so a value that means "recently" cannot cost a
21423
+ * SQLite commit per round-trip.
21424
+ */
21425
+ lastContactAt: number().optional(),
21426
+ /**
21043
21427
  * True when the source is a BINARY low-battery indicator (HA
21044
21428
  * `binary_sensor` device_class=battery / `LOW_BAT`) that has no real
21045
21429
  * charge level — `percentage` is then a coarse stand-in (100 = normal,
@@ -26571,10 +26955,22 @@ method(object({
26571
26955
  * thing except the comparator: `similarity` (CLIP cosine at the same ROI coords
26572
26956
  * vs condition-tagged references) and `llm` (vision-LLM judgment over the crop).
26573
26957
  *
26574
- * D14 device-config archetype (`deviceConfig.ui.kind:'widget'`) the framework
26575
- * derives the device-detail contribution; the provider carries NO hand-written
26576
- * settings-contribution methods. `status.kind:'push'` the engine pushes on
26577
- * every hysteresis flip / availability change; consumers never poll.
26958
+ * **No `deviceConfig`, deliberately.** This shipped as the D14 widget archetype,
26959
+ * which put a "Scenes" tab on one camera's detail page. That is the wrong shape
26960
+ * for the thing: a scene is a standing question about the property ("is the bin
26961
+ * still out"), and the operator's question is "which of my scenes have tripped",
26962
+ * across every camera at once — not "what does camera 617 think". Buried one
26963
+ * camera deep it also could not be found. The surface is now a top-level admin
26964
+ * page (`/scenes`, `pages/Scenes.tsx`) that lists every scene on every camera and
26965
+ * picks the camera inside the create flow, the same shape Events and Faces have.
26966
+ *
26967
+ * The consequence to keep in mind: `host/scene-monitor-editor` is gone from
26968
+ * `HOST_WIDGETS` too. `scripts/check-host-widget-resolves.ts` asserts BOTH
26969
+ * directions, so a registration nobody declares fails exactly as loudly as a
26970
+ * declaration nobody registers. The editor is imported directly by the page.
26971
+ *
26972
+ * `status.kind:'push'` — the engine pushes on every hysteresis flip /
26973
+ * availability change; consumers never poll.
26578
26974
  */
26579
26975
  /** Extensible condition tag. Seeded 'day' | 'ir' (the two variants the operator
26580
26976
  * captures) plus 'night' | 'dawn' | 'dusk' from the resolver's sun-times band.
@@ -26585,6 +26981,33 @@ method(object({
26585
26981
  * as `unknown`, never guessed. A day reference scored against an IR frame
26586
26982
  * collapses the cosine and would latch a false alarm every single night. */
26587
26983
  var SceneConditionSchema = string();
26984
+ /**
26985
+ * What a scene does when the CURRENT light has no reference of its own.
26986
+ *
26987
+ * The lighting variants are not equally likely to exist. Almost every operator
26988
+ * captures daylight and then never stands outside at 22:00 to capture IR, and a
26989
+ * scene that is only ever going to be asked about a daytime question ("is the
26990
+ * bin still on the kerb at 08:00") does not need a night reference at all. The
26991
+ * night half must therefore be OPTIONAL, and optional means the scene keeps
26992
+ * working without it rather than degrading into a permanent complaint.
26993
+ *
26994
+ * - `skip` (default) — the check in that light is not made. Not a verdict, not
26995
+ * an alarm, not even an `unknown`: the live state simply stays whatever the
26996
+ * last covered light left it at, the latch is untouched, and the hysteresis
26997
+ * run is neither spent nor cleared. The scene resumes by itself at first
26998
+ * light. This is the only behaviour under which "I never captured IR" is a
26999
+ * configuration choice instead of a nightly fault.
27000
+ * - `judge-anyway` — score against the OTHER conditions' references. Available
27001
+ * for cameras whose IR frame is close enough to daylight (a floodlit
27002
+ * driveway, an always-white-light doorbell), and wrong for everything else:
27003
+ * cross-condition cosines are not comparable, so a day reference against a
27004
+ * true IR frame collapses and the scene reports a theft at 21:40.
27005
+ *
27006
+ * Never applies when the scene has NO comparable reference at all — that is
27007
+ * "not armed yet", it is reported as `no-reference-for-condition`, and silence
27008
+ * there would hide a scene the operator never finished setting up.
27009
+ */
27010
+ var SceneUncoveredPolicySchema = _enum(["skip", "judge-anyway"]);
26588
27011
  /** `matched` = the baseline is what we see; `diverged` = it demonstrably is not;
26589
27012
  * `unknown` = we cannot judge (no reference for this condition, encoder model
26590
27013
  * changed, view shifted, no snapshot). `unknown` is a real value, not a null,
@@ -26640,6 +27063,9 @@ var SceneCheckSchema = discriminatedUnion("mode", [object({
26640
27063
  hysteresisCount: number().int().positive()
26641
27064
  })]);
26642
27065
  var SCENE_DEFAULT_ANCHOR_THRESHOLD = .85;
27066
+ /** Night is OPTIONAL. A scene with only a daylight reference sits the IR hours
27067
+ * out in silence rather than reporting a fault every night. */
27068
+ var SCENE_DEFAULT_UNCOVERED_POLICY = "skip";
26643
27069
  /**
26644
27070
  * Vision-model adjudication of a candidate flip. Field names deliberately
26645
27071
  * mirror `NcConfirmSchema` so an operator meets one vocabulary, not two.
@@ -26706,6 +27132,21 @@ var SceneMonitorSchema = object({
26706
27132
  * automation can react to the bin coming back without the operator's own
26707
27133
  * alarm silently clearing itself. */
26708
27134
  autoRestore: boolean().default(false),
27135
+ /** What to do when the current light has no reference of its own. See
27136
+ * {@link SceneUncoveredPolicySchema} — the default makes night OPTIONAL. */
27137
+ onUncoveredCondition: SceneUncoveredPolicySchema.default(SCENE_DEFAULT_UNCOVERED_POLICY),
27138
+ /**
27139
+ * The light whose checks are currently being SAT OUT under
27140
+ * `onUncoveredCondition: 'skip'` — `null` when the scene is checking normally.
27141
+ *
27142
+ * Engine-reported and advisory only: it moves no verdict, no latch and no
27143
+ * hysteresis. It exists so the card can say *"night (IR) — checks paused,
27144
+ * nothing captured in this light"* in the same calm voice as the coverage
27145
+ * line, because the alternative is a scene that silently stops answering
27146
+ * after sunset with nothing anywhere saying why. A skipped check must never
27147
+ * read as a broken one.
27148
+ */
27149
+ suspendedCondition: SceneConditionSchema.nullable().default(null),
26709
27150
  /** Named cause when `verdict === 'unknown'`. */
26710
27151
  unavailable: SceneUnavailableSchema.nullable(),
26711
27152
  /** Conditions that have at least one comparable reference — the coverage line
@@ -26723,12 +27164,6 @@ var sceneMonitorCapability = {
26723
27164
  kind: "wrapper",
26724
27165
  defaultActive: true,
26725
27166
  deviceTypes: [DeviceType.Camera],
26726
- deviceConfig: { ui: {
26727
- kind: "widget",
26728
- widgetId: "host/scene-monitor-editor",
26729
- tab: "scenes",
26730
- label: "Scenes"
26731
- } },
26732
27167
  methods: {
26733
27168
  listScenes: method(object({ deviceId: number() }), SceneMonitorStatusSchema),
26734
27169
  createScene: method(object({
@@ -26765,6 +27200,7 @@ var sceneMonitorCapability = {
26765
27200
  minObservationSpacingSec: number().int().min(0).max(3600).optional(),
26766
27201
  anchorThreshold: number().min(0).max(1).optional(),
26767
27202
  autoRestore: boolean().optional(),
27203
+ onUncoveredCondition: SceneUncoveredPolicySchema.optional(),
26768
27204
  /** `null` clears the vision-model adjudicator. */
26769
27205
  confirm: SceneConfirmSchema.nullable().optional()
26770
27206
  })
@@ -27069,13 +27505,63 @@ var CamStreamDescriptorSchema = object({
27069
27505
  * set of stream descriptors it can offer for the device, synchronously, so the
27070
27506
  * broker can reconcile its registry against the authoritative provider state.
27071
27507
  */
27508
+ /**
27509
+ * The catalog as a DURABLE fact rather than a live answer.
27510
+ *
27511
+ * A battery camera's descriptors are profile-stable — they change when the
27512
+ * operator rewrites an encoder profile, not minute to minute — but building
27513
+ * them costs a Baichuan login, which on a sleeping Argus IS a wake. So the
27514
+ * provider is allowed to build them exactly once per profile and must serve
27515
+ * every later pull from a cache.
27516
+ *
27517
+ * Holding that cache only in RAM is what turned a restart into an outage. The
27518
+ * runner comes back with the camera asleep, `buildStreamCatalogUncached`
27519
+ * correctly refuses to wake it, the pull answers `[]`, the broker has no
27520
+ * cam-stream entry to build a broker from, and `webrtcSession.handleOffer`
27521
+ * fails with a flat "No broker for stream" — for as long as the camera sleeps,
27522
+ * which on a battery cam is most of the day. The camera was fine. The stream
27523
+ * was unreachable because the process had forgotten what the camera offers.
27524
+ *
27525
+ * Declaring it here puts it in `device-runtime-state`, the kernel's canonical
27526
+ * declared collection, with the same `restored` durability `battery` uses for
27527
+ * the same reason: the last known value is the only value there is while the
27528
+ * device is asleep. The broker's brokers are therefore always DEFINABLE — it
27529
+ * is the DIAL that wakes a camera, never the catalog (D173).
27530
+ */
27531
+ var StreamCatalogStateSchema = object({
27532
+ /** The descriptors as last built from a real camera response. Never a guess:
27533
+ * a failed or refused build writes NOTHING, so a restored catalog is always
27534
+ * one the camera itself once produced. */
27535
+ descriptors: array(CamStreamDescriptorSchema),
27536
+ /** Ms epoch of the build that produced {@link descriptors}. Lets the wake
27537
+ * path decide whether the camera's own awake window is worth spending on a
27538
+ * re-read. */
27539
+ lastFetchedAt: number()
27540
+ });
27072
27541
  var streamCatalogCapability = {
27073
27542
  name: "stream-catalog",
27074
27543
  scope: "device",
27075
27544
  deviceNative: true,
27076
27545
  mode: "singleton",
27077
27546
  deviceTypes: [DeviceType.Camera],
27078
- methods: { getCatalog: method(object({ deviceId: number().int().nonnegative() }), array(CamStreamDescriptorSchema).readonly()) }
27547
+ methods: { getCatalog: method(object({ deviceId: number().int().nonnegative() }), array(CamStreamDescriptorSchema).readonly()) },
27548
+ runtimeState: StreamCatalogStateSchema,
27549
+ /**
27550
+ * Runtime-state durability: **restored** — see the schema doc. A cold
27551
+ * catalog on a sleeping battery camera is not a slow first frame, it is a
27552
+ * camera that cannot be watched at all until it happens to wake.
27553
+ *
27554
+ * Churn is nil by construction: the slice is written only by a SUCCESSFUL
27555
+ * build, and a build only runs when there is no cached copy (or the copy is
27556
+ * a day old and the camera is awake anyway).
27557
+ *
27558
+ * See `RuntimeStateDurability`. Enforced by
27559
+ * `scripts/check-runtime-state-durability.ts`.
27560
+ */
27561
+ durability: "restored",
27562
+ /** Clock field: written, but excluded from the compare that decides whether
27563
+ * persisting is worth a SQLite commit — the descriptors are the value. */
27564
+ volatileStateFields: ["lastFetchedAt"]
27079
27565
  };
27080
27566
  /** One of the camera's stream profiles. */
27081
27567
  var StreamProfileSchema = _enum([
@@ -27528,12 +28014,64 @@ var NetworkAddressSchema = object({
27528
28014
  family: string(),
27529
28015
  internal: boolean()
27530
28016
  });
28017
+ /**
28018
+ * Provenance of the site coordinates, and the whole reason this is not just two
28019
+ * numbers.
28020
+ *
28021
+ * - `operator-set` — a human typed it, or accepted a detection. Authoritative;
28022
+ * nothing overwrites it.
28023
+ * - `derived-from-ip` — the hub geolocated its own public IP once, because a
28024
+ * default that is right to a few kilometres beats the coarse UTC clock split
28025
+ * the sun-times consumers otherwise fall back to.
28026
+ *
28027
+ * The UI shows which one it is. An operator who cannot tell a guess from their
28028
+ * own input will eventually trust the guess.
28029
+ */
28030
+ var SiteLocationSourceSchema = _enum(["operator-set", "derived-from-ip"]);
28031
+ /**
28032
+ * The read shape: the location plus the honest state of the one-shot derivation.
28033
+ *
28034
+ * `derivationAttemptedAt` is what makes the "one call, ever" contract
28035
+ * inspectable. When it is set and `location` is null, the geo-IP lookup ran and
28036
+ * failed; the hub will NOT try again on its own — the fallback is declared
28037
+ * (consumers degrade to their own last resort) and the operator either types the
28038
+ * coordinates or presses detect.
28039
+ */
28040
+ var SiteLocationStatusSchema = object({
28041
+ location: object({
28042
+ /** WGS84 decimal degrees. */
28043
+ latitude: number().min(-90).max(90),
28044
+ longitude: number().min(-180).max(180),
28045
+ source: SiteLocationSourceSchema,
28046
+ /** Epoch ms the value was last written. */
28047
+ updatedAt: number(),
28048
+ /**
28049
+ * Human-readable place the geo-IP service reported ("Napoli, IT"). Display
28050
+ * only — never parsed, never matched on. Absent for an operator-typed value.
28051
+ */
28052
+ label: string().optional()
28053
+ }).nullable(),
28054
+ derivationAttemptedAt: number().nullable(),
28055
+ /** Why the last derivation failed, for the UI to show instead of a shrug. */
28056
+ derivationError: string().nullable()
28057
+ });
28058
+ /** `null` clears the location and re-arms nothing — the derivation stays spent. */
28059
+ var SetSiteLocationInputSchema = object({
28060
+ latitude: number().min(-90).max(90),
28061
+ longitude: number().min(-180).max(180)
28062
+ }).nullable();
27531
28063
  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(), {
27532
28064
  kind: "mutation",
27533
28065
  auth: "admin"
27534
28066
  }), method(_void(), _void(), {
27535
28067
  kind: "mutation",
27536
28068
  auth: "admin"
28069
+ }), method(_void(), SiteLocationStatusSchema), method(SetSiteLocationInputSchema, SiteLocationStatusSchema, {
28070
+ kind: "mutation",
28071
+ auth: "admin"
28072
+ }), method(_void(), SiteLocationStatusSchema, {
28073
+ kind: "mutation",
28074
+ auth: "admin"
27537
28075
  });
27538
28076
  /**
27539
28077
  * Tamper / case-open detection sensor. Drives Home Assistant
@@ -28887,6 +29425,7 @@ var DEVICE_LOCAL_STATE_CAPS = {
28887
29425
  sceneMonitor: sceneMonitorCapability,
28888
29426
  scriptRunner: scriptRunnerCapability,
28889
29427
  smoke: smokeCapability,
29428
+ streamCatalog: streamCatalogCapability,
28890
29429
  streamParams: streamParamsCapability,
28891
29430
  switch: switchCapability,
28892
29431
  tamper: tamperCapability,
@@ -29540,6 +30079,15 @@ var BaseDeviceProvider = class extends BaseAddon {
29540
30079
  labels: ["probe not implemented"]
29541
30080
  };
29542
30081
  }
30082
+ /**
30083
+ * Top-level devices restored at once in {@link onRestoreDevices}.
30084
+ *
30085
+ * Four covers the fleets this ships to without turning a boot into a burst a
30086
+ * camera NVR answers with a refusal. A provider whose upstream is a single
30087
+ * session with a serial command channel (a Baichuan hub, an NVR that
30088
+ * serialises ISAPI) should lower it; nothing needs to raise it.
30089
+ */
30090
+ restoreConcurrency = 4;
29543
30091
  async restoreDevices(savedDevices) {
29544
30092
  await this.onRestoreDevices(savedDevices);
29545
30093
  if (savedDevices.length > 0) this.ctx.logger.info(`Restored ${savedDevices.length} ${this.providerName} device(s)`);
@@ -29571,15 +30119,15 @@ var BaseDeviceProvider = class extends BaseAddon {
29571
30119
  */
29572
30120
  async onRestoreDevices(savedDevices) {
29573
30121
  const restored = /* @__PURE__ */ new Set();
29574
- for (const saved of savedDevices) {
29575
- if (saved.parentDeviceId !== null) continue;
30122
+ const topLevel = savedDevices.filter((saved) => saved.parentDeviceId === null);
30123
+ const restoreOne = async (saved) => {
29576
30124
  const Class = this.deviceClasses[saved.type];
29577
30125
  if (!Class) {
29578
30126
  this.ctx.logger.warn("No device class registered for restored type — skipping", {
29579
30127
  tags: { stableId: saved.stableId },
29580
30128
  meta: { type: saved.type }
29581
30129
  });
29582
- continue;
30130
+ return;
29583
30131
  }
29584
30132
  try {
29585
30133
  await this.ctx.kernel.devices.create(saved.stableId, Class, {});
@@ -29593,7 +30141,15 @@ var BaseDeviceProvider = class extends BaseAddon {
29593
30141
  }
29594
30142
  });
29595
30143
  }
29596
- }
30144
+ };
30145
+ let nextTopLevel = 0;
30146
+ await Promise.all(Array.from({ length: Math.min(Math.max(1, this.restoreConcurrency), topLevel.length) }, async () => {
30147
+ for (;;) {
30148
+ const saved = topLevel[nextTopLevel++];
30149
+ if (saved === void 0) return;
30150
+ await restoreOne(saved);
30151
+ }
30152
+ }));
29597
30153
  const childRows = savedDevices.filter((s) => s.parentDeviceId !== null);
29598
30154
  for (const saved of childRows) {
29599
30155
  const Class = this.deviceClasses[saved.type];
@@ -31815,6 +32371,12 @@ Object.freeze({
31815
32371
  addonId: null,
31816
32372
  access: "create"
31817
32373
  },
32374
+ "llm.cancel": {
32375
+ capName: "llm",
32376
+ capScope: "system",
32377
+ addonId: null,
32378
+ access: "create"
32379
+ },
31818
32380
  "llm.deleteModel": {
31819
32381
  capName: "llm",
31820
32382
  capScope: "system",
@@ -31899,6 +32461,12 @@ Object.freeze({
31899
32461
  addonId: null,
31900
32462
  access: "view"
31901
32463
  },
32464
+ "llm.resolveModelRef": {
32465
+ capName: "llm",
32466
+ capScope: "system",
32467
+ addonId: null,
32468
+ access: "create"
32469
+ },
31902
32470
  "llm.setDefault": {
31903
32471
  capName: "llm",
31904
32472
  capScope: "system",
@@ -34209,6 +34777,12 @@ Object.freeze({
34209
34777
  addonId: null,
34210
34778
  access: "view"
34211
34779
  },
34780
+ "snapshot.getDebugState": {
34781
+ capName: "snapshot",
34782
+ capScope: "device",
34783
+ addonId: null,
34784
+ access: "view"
34785
+ },
34212
34786
  "snapshot.getSnapshot": {
34213
34787
  capName: "snapshot",
34214
34788
  capScope: "device",
@@ -34749,6 +35323,12 @@ Object.freeze({
34749
35323
  addonId: null,
34750
35324
  access: "create"
34751
35325
  },
35326
+ "system.detectSiteLocation": {
35327
+ capName: "system",
35328
+ capScope: "system",
35329
+ addonId: null,
35330
+ access: "create"
35331
+ },
34752
35332
  "system.featureFlags": {
34753
35333
  capName: "system",
34754
35334
  capScope: "system",
@@ -34767,6 +35347,12 @@ Object.freeze({
34767
35347
  addonId: null,
34768
35348
  access: "view"
34769
35349
  },
35350
+ "system.getSiteLocation": {
35351
+ capName: "system",
35352
+ capScope: "system",
35353
+ addonId: null,
35354
+ access: "view"
35355
+ },
34770
35356
  "system.health": {
34771
35357
  capName: "system",
34772
35358
  capScope: "system",
@@ -34791,6 +35377,12 @@ Object.freeze({
34791
35377
  addonId: null,
34792
35378
  access: "create"
34793
35379
  },
35380
+ "system.setSiteLocation": {
35381
+ capName: "system",
35382
+ capScope: "system",
35383
+ addonId: null,
35384
+ access: "create"
35385
+ },
34794
35386
  "terminalSession.adoptLegacyMonitor": {
34795
35387
  capName: "terminal-session",
34796
35388
  capScope: "system",
@@ -36273,6 +36865,11 @@ Object.freeze({
36273
36865
  form: "single",
36274
36866
  optional: false
36275
36867
  }],
36868
+ "pipelineAnalytics.getEventMedia": [{
36869
+ name: "deviceId",
36870
+ form: "single",
36871
+ optional: false
36872
+ }],
36276
36873
  "pipelineAnalytics.getKeyEvents": [{
36277
36874
  name: "deviceId",
36278
36875
  form: "single",
@@ -36303,6 +36900,11 @@ Object.freeze({
36303
36900
  form: "single",
36304
36901
  optional: false
36305
36902
  }],
36903
+ "pipelineAnalytics.getTrackMedia": [{
36904
+ name: "deviceId",
36905
+ form: "single",
36906
+ optional: false
36907
+ }],
36306
36908
  "pipelineAnalytics.getTrainingExportSummary": [{
36307
36909
  name: "deviceIds",
36308
36910
  form: "array",
@@ -36338,6 +36940,11 @@ Object.freeze({
36338
36940
  form: "array",
36339
36941
  optional: true
36340
36942
  }],
36943
+ "pipelineAnalytics.listTrackMedia": [{
36944
+ name: "deviceId",
36945
+ form: "single",
36946
+ optional: false
36947
+ }],
36341
36948
  "pipelineAnalytics.listTracks": [{
36342
36949
  name: "deviceId",
36343
36950
  form: "single",
@@ -36773,11 +37380,22 @@ Object.freeze({
36773
37380
  form: "single",
36774
37381
  optional: false
36775
37382
  }],
37383
+ "snapshot.getDebugState": [{
37384
+ name: "deviceId",
37385
+ form: "single",
37386
+ optional: false
37387
+ }],
36776
37388
  "snapshot.getSnapshot": [{
36777
37389
  name: "deviceId",
36778
37390
  form: "single",
36779
37391
  optional: false
36780
37392
  }],
37393
+ "snapshot.getSnapshotLinks": [{
37394
+ name: "targets",
37395
+ form: "object-array",
37396
+ optional: false,
37397
+ itemField: "deviceId"
37398
+ }],
36781
37399
  "snapshot.getSnapshotOverview": [{
36782
37400
  name: "deviceIds",
36783
37401
  form: "array",