@camstack/addon-provider-hikvision 1.2.22 → 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.
Files changed (3) hide show
  1. package/dist/addon.js +639 -65
  2. package/dist/addon.mjs +639 -65
  3. package/package.json +1 -1
package/dist/addon.mjs CHANGED
@@ -5405,12 +5405,6 @@ Object.fromEntries([
5405
5405
  icon: "shapes",
5406
5406
  order: 38
5407
5407
  },
5408
- {
5409
- id: "scenes",
5410
- label: "Scenes",
5411
- icon: "scan-eye",
5412
- order: 36
5413
- },
5414
5408
  {
5415
5409
  id: "analytics",
5416
5410
  label: "Analytics",
@@ -11106,6 +11100,8 @@ var QueryFilterSchema = object({
11106
11100
  where: record(string(), unknown()).optional(),
11107
11101
  whereIn: record(string(), array(unknown())).optional(),
11108
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(),
11109
11105
  orderBy: object({
11110
11106
  field: string(),
11111
11107
  direction: _enum(["asc", "desc"])
@@ -11125,7 +11121,8 @@ var QueryFilterSchema = object({
11125
11121
  var MutationFilterSchema = object({
11126
11122
  where: record(string(), unknown()).optional(),
11127
11123
  whereIn: record(string(), array(unknown())).optional(),
11128
- whereBetween: record(string(), tuple([unknown(), unknown()])).optional()
11124
+ whereBetween: record(string(), tuple([unknown(), unknown()])).optional(),
11125
+ whereNot: record(string(), unknown()).optional()
11129
11126
  });
11130
11127
  /** A single stored record: `{ id, data }`. */
11131
11128
  var SettingsRecordSchema = object({
@@ -12644,6 +12641,17 @@ var LlmImageSchema = object({
12644
12641
  bytes: _instanceof(Uint8Array),
12645
12642
  mimeType: string()
12646
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
+ });
12647
12655
  var LlmGenerateBaseInputSchema = object({
12648
12656
  /** Collection routing (the notification-output posture). */
12649
12657
  addonId: string().optional(),
@@ -12658,7 +12666,28 @@ var LlmGenerateBaseInputSchema = object({
12658
12666
  jsonSchema: record(string(), unknown()).optional(),
12659
12667
  /** Per-call override of the profile default. */
12660
12668
  maxTokens: number().int().positive().optional(),
12661
- 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()
12662
12691
  });
12663
12692
  /**
12664
12693
  * `llm-runtime` — node-side managed llama.cpp executor (spec §4). Registered
@@ -12671,6 +12700,18 @@ var LlmGenerateBaseInputSchema = object({
12671
12700
  * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
12672
12701
  * watchdog — operator decision #3).
12673
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
+ });
12674
12715
  var ManagedModelRefSchema = discriminatedUnion("kind", [
12675
12716
  object({
12676
12717
  kind: literal("catalog"),
@@ -12679,7 +12720,11 @@ var ManagedModelRefSchema = discriminatedUnion("kind", [
12679
12720
  object({
12680
12721
  kind: literal("url"),
12681
12722
  url: string(),
12682
- 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()
12683
12728
  }),
12684
12729
  object({
12685
12730
  kind: literal("path"),
@@ -12697,13 +12742,82 @@ var ManagedRuntimeConfigSchema = object({
12697
12742
  gpuLayers: number().int().default(0),
12698
12743
  /** Default: cpus-2, clamped ≥1 (resolved node-side). */
12699
12744
  threads: number().int().optional(),
12700
- /** Concurrent slots. */
12745
+ /** Concurrent slots (`--parallel`). */
12701
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([]),
12702
12800
  /** Else lazy: first generate boots it. */
12703
12801
  autoStart: boolean().default(false),
12704
12802
  /** 0 = never; frees RAM after quiet periods. */
12705
12803
  idleStopMinutes: number().int().default(30)
12706
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
+ });
12707
12821
  var LlmRuntimeStatusSchema = object({
12708
12822
  /** Status is ALWAYS node-qualified. */
12709
12823
  nodeId: string(),
@@ -12720,6 +12834,8 @@ var LlmRuntimeStatusSchema = object({
12720
12834
  modelPath: string().optional(),
12721
12835
  modelId: string().optional(),
12722
12836
  downloadProgress: number().min(0).max(1).optional(),
12837
+ /** Detail behind `downloadProgress`; present for the same lifetime. */
12838
+ download: LlmDownloadProgressSchema.optional(),
12723
12839
  lastError: string().optional(),
12724
12840
  crashesInWindow: number(),
12725
12841
  /** Child RSS (sampled best-effort). */
@@ -12730,7 +12846,14 @@ var LlmNodeModelSchema = object({
12730
12846
  file: string(),
12731
12847
  sizeBytes: number(),
12732
12848
  catalogId: string().optional(),
12733
- 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()
12734
12857
  });
12735
12858
  var LlmRuntimeDiskUsageSchema = object({
12736
12859
  nodeId: string(),
@@ -12786,10 +12909,47 @@ var LlmProfileSchema = object({
12786
12909
  baseUrl: string().optional(),
12787
12910
  /** ConfigUISchema type:'password' — never round-trips (spec §5). */
12788
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. */
12789
12915
  supportsVision: boolean(),
12790
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(),
12791
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. */
12792
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),
12793
12953
  extraHeaders: record(string(), string()).optional(),
12794
12954
  /** kind === 'managed-local' only (spec §4). */
12795
12955
  runtime: ManagedRuntimeConfigSchema.optional()
@@ -12839,6 +12999,36 @@ var ManagedModelCatalogEntrySchema = object({
12839
12999
  /** Vision models: companion projector file. */
12840
13000
  mmprojUrl: string().optional()
12841
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
+ })]);
12842
13032
  var LlmRuntimeNodeSchema = object({
12843
13033
  nodeId: string(),
12844
13034
  reachable: boolean(),
@@ -12851,7 +13041,10 @@ var ProfileRefInputSchema = object({
12851
13041
  addonId: string(),
12852
13042
  profileId: string()
12853
13043
  });
12854
- 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, {
12855
13048
  kind: "mutation",
12856
13049
  auth: "admin"
12857
13050
  }), method(ProfileRefInputSchema, _void(), {
@@ -12872,6 +13065,15 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }
12872
13065
  consumer: string().optional(),
12873
13066
  profileId: string().optional()
12874
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({
12875
13077
  nodeId: string(),
12876
13078
  model: ManagedModelRefSchema
12877
13079
  }), _void(), {
@@ -14625,28 +14827,36 @@ var NcOccupancyConditionSchema = object({
14625
14827
  /**
14626
14828
  * Audio condition (IMMEDIATE trigger) — a rule on SOUND, not on a picture.
14627
14829
  *
14628
- * Operator-approved vocabulary (2026-08-12, option A — the same one the
14629
- * reference notifier uses, so an operator moving between them re-uses what
14630
- * they already know): a rule matches when, over a sampling window of
14631
- * `samplingSeconds`, at least `hitPercent`% of the audio samples in that
14632
- * window are HITS. A sample is a hit when it satisfies BOTH present filters:
14633
- *
14634
- * - `dbThreshold` its level is at or above this many dBFS (see
14635
- * {@link NC_AUDIO_DBFS_FLOOR}: negative-going, `0` = full scale);
14636
- * - `labels` the classifier put at least one of these labels on it.
14637
- *
14638
- * Both are OPTIONAL and independent, which is the point of the shape: a
14639
- * loudness rule ("something loud at 3am") needs no model to be right, and a
14640
- * label rule ("a dog barked") needs no threshold. **Fail-closed when NEITHER
14641
- * is given** a window in which every sample is trivially a hit would fire on
14642
- * silence, so the engine refuses such a condition rather than notifying on
14643
- * nothing (the schema cannot express "at least one of" without becoming a
14644
- * ZodEffects the cap path would have to special-case).
14645
- *
14646
- * `hitPercent` is over the samples the window actually HOLDS, and the window
14647
- * must be FULL before it can match a window that has been open for two
14648
- * seconds of its ten is 100% of nothing, and firing on it would make
14649
- * `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).
14650
14860
  *
14651
14861
  * Labels are the audio macro classes (`AUDIO_MACRO_LABELS` / the NC taxonomy's
14652
14862
  * `audio-*` ids). Both spellings are accepted — the matcher normalizes the
@@ -14654,13 +14864,13 @@ var NcOccupancyConditionSchema = object({
14654
14864
  * an operator who typed `dog` mean the same thing.
14655
14865
  */
14656
14866
  var NcAudioConditionSchema = object({
14657
- /** Audio macro labels; absent = any sound (level-only rule). */
14867
+ /** LABEL MODE: audio macro labels. Present fires on the first labelled frame. */
14658
14868
  labels: array(string().min(1)).min(1).optional(),
14659
- /** Level floor in dBFS (negative-going, `0` = full scale); absent = any level. */
14869
+ /** LEVEL MODE: floor in dBFS (negative-going, `0` = full scale). */
14660
14870
  dbThreshold: number().min(-96).max(0).optional(),
14661
- /** 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). */
14662
14872
  hitPercent: number().int().min(1).max(100).default(60),
14663
- /** Length of the sampling window in seconds. */
14873
+ /** LEVEL MODE ONLY: length of the sampling window in seconds. */
14664
14874
  samplingSeconds: number().int().min(1).max(300).default(10)
14665
14875
  });
14666
14876
  /**
@@ -14798,13 +15008,81 @@ var NcRuleActionsSchema = object({
14798
15008
  */
14799
15009
  buttons: array(NcRuleNotificationButtonSchema).max(8).optional()
14800
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
+ });
14801
15076
  var NcConditionsSchema = object({
14802
15077
  /** Gate on ANOTHER device's current state (the alarm armed, a switch on). */
14803
- deviceState: object({
14804
- deviceId: number().int(),
14805
- /** Any of these matches. */
14806
- states: array(string().min(1)).min(1)
14807
- }).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(),
14808
15086
  /** Device scope — absent = all devices. */
14809
15087
  devices: array(number()).optional(),
14810
15088
  /** Detector class names (any overlap with the record's class set). */
@@ -15442,6 +15720,7 @@ var NcConditionDescriptorSchema = object({
15442
15720
  "occupancy",
15443
15721
  "audio",
15444
15722
  "deviceState",
15723
+ "scene",
15445
15724
  "systemEvent"
15446
15725
  ]),
15447
15726
  operator: _enum([
@@ -16919,7 +17198,10 @@ var RecentTracksQueryInput = object({
16919
17198
  * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
16920
17199
  cursor: string().optional(),
16921
17200
  /** See {@link TrackProjectionSchema}. Default `full`. */
16922
- 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()
16923
17205
  });
16924
17206
  var RecentTracksPageSchema = object({
16925
17207
  /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
@@ -17137,7 +17419,11 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
17137
17419
  zone: TrackZoneFilterSchema.optional(),
17138
17420
  /** See {@link TrackProjectionSchema}. Default `full` (backward
17139
17421
  * compatible — omitting the field keeps today's exact behaviour). */
17140
- 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()
17141
17427
  }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(object({ deviceId: number() }), _void(), {
17142
17428
  kind: "mutation",
17143
17429
  auth: "admin"
@@ -17301,11 +17587,16 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
17301
17587
  auth: "admin"
17302
17588
  }), method(object({
17303
17589
  eventId: string(),
17304
- kind: MediaFileKindEnum.optional()
17590
+ kind: MediaFileKindEnum.optional(),
17591
+ deviceId: number()
17305
17592
  }), array(MediaFileSchema).readonly()), method(object({
17306
17593
  trackId: string(),
17307
- kinds: array(MediaFileKindEnum).optional()
17308
- }), 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, {
17309
17600
  kind: "mutation",
17310
17601
  auth: "admin"
17311
17602
  }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
@@ -18005,6 +18296,17 @@ var maxSessionHoldMsField = {
18005
18296
  default: 12e4,
18006
18297
  step: 5e3
18007
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
+ };
18008
18310
  var motionFpsField = {
18009
18311
  min: 1,
18010
18312
  max: 30,
@@ -18181,6 +18483,27 @@ var RunnerCameraConfigSchema = object({
18181
18483
  * resolved `CameraDetectionConfig`.
18182
18484
  */
18183
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(),
18184
18507
  motionFps: number().min(motionFpsField.min).max(motionFpsField.max).default(motionFpsField.default),
18185
18508
  detectionFps: number().min(detectionFpsField.min).max(detectionFpsField.max).default(detectionFpsField.default),
18186
18509
  motionStreamId: string(),
@@ -18276,7 +18599,7 @@ var RunnerCameraConfigSchema = object({
18276
18599
  */
18277
18600
  inferenceDevices: array(RunnerInferenceDeviceSchema).readonly().optional()
18278
18601
  });
18279
- 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;
18280
18603
  /**
18281
18604
  * Runtime load summary returned by `getLocalLoad`. Used by the orchestrator's
18282
18605
  * load-balancing levels (L2 capacity-based, L3 hardware-aware) to decide
@@ -19381,7 +19704,16 @@ targets: array(object({
19381
19704
  /** A sleeping battery camera: the frame is deliberately stale and will
19382
19705
  * NOT refresh in the background. A surface should say so rather than
19383
19706
  * present it as current. */
19384
- 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()
19385
19717
  })))
19386
19718
  },
19387
19719
  status: {
@@ -21041,6 +21373,25 @@ var BatteryStatusSchema = object({
21041
21373
  /** Ms epoch of the last observation. Lets consumers reason about freshness. */
21042
21374
  lastUpdated: number(),
21043
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
+ /**
21044
21395
  * True when the source is a BINARY low-battery indicator (HA
21045
21396
  * `binary_sensor` device_class=battery / `LOW_BAT`) that has no real
21046
21397
  * charge level — `percentage` is then a coarse stand-in (100 = normal,
@@ -26572,10 +26923,22 @@ method(object({
26572
26923
  * thing except the comparator: `similarity` (CLIP cosine at the same ROI coords
26573
26924
  * vs condition-tagged references) and `llm` (vision-LLM judgment over the crop).
26574
26925
  *
26575
- * D14 device-config archetype (`deviceConfig.ui.kind:'widget'`) the framework
26576
- * derives the device-detail contribution; the provider carries NO hand-written
26577
- * settings-contribution methods. `status.kind:'push'` the engine pushes on
26578
- * every hysteresis flip / availability change; consumers never poll.
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.
26579
26942
  */
26580
26943
  /** Extensible condition tag. Seeded 'day' | 'ir' (the two variants the operator
26581
26944
  * captures) plus 'night' | 'dawn' | 'dusk' from the resolver's sun-times band.
@@ -26586,6 +26949,33 @@ method(object({
26586
26949
  * as `unknown`, never guessed. A day reference scored against an IR frame
26587
26950
  * collapses the cosine and would latch a false alarm every single night. */
26588
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"]);
26589
26979
  /** `matched` = the baseline is what we see; `diverged` = it demonstrably is not;
26590
26980
  * `unknown` = we cannot judge (no reference for this condition, encoder model
26591
26981
  * changed, view shifted, no snapshot). `unknown` is a real value, not a null,
@@ -26641,6 +27031,9 @@ var SceneCheckSchema = discriminatedUnion("mode", [object({
26641
27031
  hysteresisCount: number().int().positive()
26642
27032
  })]);
26643
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";
26644
27037
  /**
26645
27038
  * Vision-model adjudication of a candidate flip. Field names deliberately
26646
27039
  * mirror `NcConfirmSchema` so an operator meets one vocabulary, not two.
@@ -26707,6 +27100,21 @@ var SceneMonitorSchema = object({
26707
27100
  * automation can react to the bin coming back without the operator's own
26708
27101
  * alarm silently clearing itself. */
26709
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),
26710
27118
  /** Named cause when `verdict === 'unknown'`. */
26711
27119
  unavailable: SceneUnavailableSchema.nullable(),
26712
27120
  /** Conditions that have at least one comparable reference — the coverage line
@@ -26724,12 +27132,6 @@ var sceneMonitorCapability = {
26724
27132
  kind: "wrapper",
26725
27133
  defaultActive: true,
26726
27134
  deviceTypes: [DeviceType.Camera],
26727
- deviceConfig: { ui: {
26728
- kind: "widget",
26729
- widgetId: "host/scene-monitor-editor",
26730
- tab: "scenes",
26731
- label: "Scenes"
26732
- } },
26733
27135
  methods: {
26734
27136
  listScenes: method(object({ deviceId: number() }), SceneMonitorStatusSchema),
26735
27137
  createScene: method(object({
@@ -26766,6 +27168,7 @@ var sceneMonitorCapability = {
26766
27168
  minObservationSpacingSec: number().int().min(0).max(3600).optional(),
26767
27169
  anchorThreshold: number().min(0).max(1).optional(),
26768
27170
  autoRestore: boolean().optional(),
27171
+ onUncoveredCondition: SceneUncoveredPolicySchema.optional(),
26769
27172
  /** `null` clears the vision-model adjudicator. */
26770
27173
  confirm: SceneConfirmSchema.nullable().optional()
26771
27174
  })
@@ -27070,13 +27473,63 @@ var CamStreamDescriptorSchema = object({
27070
27473
  * set of stream descriptors it can offer for the device, synchronously, so the
27071
27474
  * broker can reconcile its registry against the authoritative provider state.
27072
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
+ });
27073
27509
  var streamCatalogCapability = {
27074
27510
  name: "stream-catalog",
27075
27511
  scope: "device",
27076
27512
  deviceNative: true,
27077
27513
  mode: "singleton",
27078
27514
  deviceTypes: [DeviceType.Camera],
27079
- 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"]
27080
27533
  };
27081
27534
  /** One of the camera's stream profiles. */
27082
27535
  var StreamProfileSchema = _enum([
@@ -27529,12 +27982,64 @@ var NetworkAddressSchema = object({
27529
27982
  family: string(),
27530
27983
  internal: boolean()
27531
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();
27532
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(), {
27533
28032
  kind: "mutation",
27534
28033
  auth: "admin"
27535
28034
  }), method(_void(), _void(), {
27536
28035
  kind: "mutation",
27537
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"
27538
28043
  });
27539
28044
  /**
27540
28045
  * Tamper / case-open detection sensor. Drives Home Assistant
@@ -28888,6 +29393,7 @@ var DEVICE_LOCAL_STATE_CAPS = {
28888
29393
  sceneMonitor: sceneMonitorCapability,
28889
29394
  scriptRunner: scriptRunnerCapability,
28890
29395
  smoke: smokeCapability,
29396
+ streamCatalog: streamCatalogCapability,
28891
29397
  streamParams: streamParamsCapability,
28892
29398
  switch: switchCapability,
28893
29399
  tamper: tamperCapability,
@@ -29541,6 +30047,15 @@ var BaseDeviceProvider = class extends BaseAddon {
29541
30047
  labels: ["probe not implemented"]
29542
30048
  };
29543
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;
29544
30059
  async restoreDevices(savedDevices) {
29545
30060
  await this.onRestoreDevices(savedDevices);
29546
30061
  if (savedDevices.length > 0) this.ctx.logger.info(`Restored ${savedDevices.length} ${this.providerName} device(s)`);
@@ -29572,15 +30087,15 @@ var BaseDeviceProvider = class extends BaseAddon {
29572
30087
  */
29573
30088
  async onRestoreDevices(savedDevices) {
29574
30089
  const restored = /* @__PURE__ */ new Set();
29575
- for (const saved of savedDevices) {
29576
- if (saved.parentDeviceId !== null) continue;
30090
+ const topLevel = savedDevices.filter((saved) => saved.parentDeviceId === null);
30091
+ const restoreOne = async (saved) => {
29577
30092
  const Class = this.deviceClasses[saved.type];
29578
30093
  if (!Class) {
29579
30094
  this.ctx.logger.warn("No device class registered for restored type — skipping", {
29580
30095
  tags: { stableId: saved.stableId },
29581
30096
  meta: { type: saved.type }
29582
30097
  });
29583
- continue;
30098
+ return;
29584
30099
  }
29585
30100
  try {
29586
30101
  await this.ctx.kernel.devices.create(saved.stableId, Class, {});
@@ -29594,7 +30109,15 @@ var BaseDeviceProvider = class extends BaseAddon {
29594
30109
  }
29595
30110
  });
29596
30111
  }
29597
- }
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
+ }));
29598
30121
  const childRows = savedDevices.filter((s) => s.parentDeviceId !== null);
29599
30122
  for (const saved of childRows) {
29600
30123
  const Class = this.deviceClasses[saved.type];
@@ -31816,6 +32339,12 @@ Object.freeze({
31816
32339
  addonId: null,
31817
32340
  access: "create"
31818
32341
  },
32342
+ "llm.cancel": {
32343
+ capName: "llm",
32344
+ capScope: "system",
32345
+ addonId: null,
32346
+ access: "create"
32347
+ },
31819
32348
  "llm.deleteModel": {
31820
32349
  capName: "llm",
31821
32350
  capScope: "system",
@@ -31900,6 +32429,12 @@ Object.freeze({
31900
32429
  addonId: null,
31901
32430
  access: "view"
31902
32431
  },
32432
+ "llm.resolveModelRef": {
32433
+ capName: "llm",
32434
+ capScope: "system",
32435
+ addonId: null,
32436
+ access: "create"
32437
+ },
31903
32438
  "llm.setDefault": {
31904
32439
  capName: "llm",
31905
32440
  capScope: "system",
@@ -34750,6 +35285,12 @@ Object.freeze({
34750
35285
  addonId: null,
34751
35286
  access: "create"
34752
35287
  },
35288
+ "system.detectSiteLocation": {
35289
+ capName: "system",
35290
+ capScope: "system",
35291
+ addonId: null,
35292
+ access: "create"
35293
+ },
34753
35294
  "system.featureFlags": {
34754
35295
  capName: "system",
34755
35296
  capScope: "system",
@@ -34768,6 +35309,12 @@ Object.freeze({
34768
35309
  addonId: null,
34769
35310
  access: "view"
34770
35311
  },
35312
+ "system.getSiteLocation": {
35313
+ capName: "system",
35314
+ capScope: "system",
35315
+ addonId: null,
35316
+ access: "view"
35317
+ },
34771
35318
  "system.health": {
34772
35319
  capName: "system",
34773
35320
  capScope: "system",
@@ -34792,6 +35339,12 @@ Object.freeze({
34792
35339
  addonId: null,
34793
35340
  access: "create"
34794
35341
  },
35342
+ "system.setSiteLocation": {
35343
+ capName: "system",
35344
+ capScope: "system",
35345
+ addonId: null,
35346
+ access: "create"
35347
+ },
34795
35348
  "terminalSession.adoptLegacyMonitor": {
34796
35349
  capName: "terminal-session",
34797
35350
  capScope: "system",
@@ -36274,6 +36827,11 @@ Object.freeze({
36274
36827
  form: "single",
36275
36828
  optional: false
36276
36829
  }],
36830
+ "pipelineAnalytics.getEventMedia": [{
36831
+ name: "deviceId",
36832
+ form: "single",
36833
+ optional: false
36834
+ }],
36277
36835
  "pipelineAnalytics.getKeyEvents": [{
36278
36836
  name: "deviceId",
36279
36837
  form: "single",
@@ -36304,6 +36862,11 @@ Object.freeze({
36304
36862
  form: "single",
36305
36863
  optional: false
36306
36864
  }],
36865
+ "pipelineAnalytics.getTrackMedia": [{
36866
+ name: "deviceId",
36867
+ form: "single",
36868
+ optional: false
36869
+ }],
36307
36870
  "pipelineAnalytics.getTrainingExportSummary": [{
36308
36871
  name: "deviceIds",
36309
36872
  form: "array",
@@ -36339,6 +36902,11 @@ Object.freeze({
36339
36902
  form: "array",
36340
36903
  optional: true
36341
36904
  }],
36905
+ "pipelineAnalytics.listTrackMedia": [{
36906
+ name: "deviceId",
36907
+ form: "single",
36908
+ optional: false
36909
+ }],
36342
36910
  "pipelineAnalytics.listTracks": [{
36343
36911
  name: "deviceId",
36344
36912
  form: "single",
@@ -36779,6 +37347,12 @@ Object.freeze({
36779
37347
  form: "single",
36780
37348
  optional: false
36781
37349
  }],
37350
+ "snapshot.getSnapshotLinks": [{
37351
+ name: "targets",
37352
+ form: "object-array",
37353
+ optional: false,
37354
+ itemField: "deviceId"
37355
+ }],
36782
37356
  "snapshot.getSnapshotOverview": [{
36783
37357
  name: "deviceIds",
36784
37358
  form: "array",