@camstack/addon-provider-reolink 1.2.27 → 1.2.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/addon.js +1123 -102
- package/dist/addon.mjs +1123 -102
- package/package.json +1 -1
package/dist/addon.js
CHANGED
|
@@ -26,7 +26,7 @@ let fs_promises = require("fs/promises");
|
|
|
26
26
|
fs_promises = require_chunk.__toESM(fs_promises, 1);
|
|
27
27
|
let node_os = require("node:os");
|
|
28
28
|
node_os = require_chunk.__toESM(node_os);
|
|
29
|
-
//#region ../types/dist/event-category-
|
|
29
|
+
//#region ../types/dist/event-category-Bxo5yJjt.mjs
|
|
30
30
|
var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
31
31
|
EventCategory["SystemBoot"] = "system.boot";
|
|
32
32
|
EventCategory["SystemAddonsReady"] = "system.addons-ready";
|
|
@@ -233,6 +233,33 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
|
233
233
|
EventCategory["PipelineCameraAssigned"] = "pipeline.camera-assigned";
|
|
234
234
|
EventCategory["PipelineCameraUnassigned"] = "pipeline.camera-unassigned";
|
|
235
235
|
/**
|
|
236
|
+
* A node the orchestrator would otherwise place cameras on has NO usable
|
|
237
|
+
* inference device: the operator enabled one or more accelerators there and
|
|
238
|
+
* the live probe reports every one of them unavailable. Emitted once per
|
|
239
|
+
* TRANSITION into that state (never per dispatch), and the node is dropped
|
|
240
|
+
* from the placement candidate set for as long as it holds.
|
|
241
|
+
*
|
|
242
|
+
* This exists because the state was previously invisible: little-unraid
|
|
243
|
+
* absorbed 283k inference errors in a day while still being handed cameras,
|
|
244
|
+
* and nothing in the system said so.
|
|
245
|
+
*
|
|
246
|
+
* A node with no accelerators configured at all is NOT this — its devices
|
|
247
|
+
* are `disabled`, not `unavailable`, and the runner's default CPU pool
|
|
248
|
+
* serves it exactly as before.
|
|
249
|
+
*/
|
|
250
|
+
EventCategory["PipelineNodeInferenceUnavailable"] = "pipeline.node-inference-unavailable";
|
|
251
|
+
/**
|
|
252
|
+
* A camera has an OPEN detection session and has produced no detection at
|
|
253
|
+
* all for longer than the blind threshold — the camera is being decoded and
|
|
254
|
+
* inferred and is returning nothing. Emitted once per transition into blind,
|
|
255
|
+
* per camera.
|
|
256
|
+
*
|
|
257
|
+
* The failure it reports: a 1h43 detection blackout on the entrance camera
|
|
258
|
+
* that nobody noticed, because "a camera that detects nothing" and "a quiet
|
|
259
|
+
* camera" produce byte-identical silence.
|
|
260
|
+
*/
|
|
261
|
+
EventCategory["PipelineDetectionBlind"] = "pipeline.detection-blind";
|
|
262
|
+
/**
|
|
236
263
|
* Per-camera pipeline config was mutated by the orchestrator
|
|
237
264
|
* (3-level settings change via `setAgentAddonDefaults` /
|
|
238
265
|
* `setCameraStepToggle` / `setCameraPipelineForAgent` or a
|
|
@@ -12654,6 +12681,17 @@ var LlmImageSchema = object({
|
|
|
12654
12681
|
bytes: _instanceof(Uint8Array),
|
|
12655
12682
|
mimeType: string()
|
|
12656
12683
|
});
|
|
12684
|
+
/**
|
|
12685
|
+
* Retry policy. `enabled: false` is NOT the same as `maxAttempts: 1` in intent —
|
|
12686
|
+
* the flag is what a consumer table flips, the count is what the operator tunes.
|
|
12687
|
+
* A retry doubles the wall time of a call, so the two gates that run inside a
|
|
12688
|
+
* notification's budget keep it off (see `CONSUMER_RETRY_POLICY` in addon-ai).
|
|
12689
|
+
*/
|
|
12690
|
+
var LlmRetryPolicySchema = object({
|
|
12691
|
+
enabled: boolean().default(false),
|
|
12692
|
+
/** Total attempts INCLUDING the first. 1 = no retry. */
|
|
12693
|
+
maxAttempts: number().int().min(1).max(5).default(1)
|
|
12694
|
+
});
|
|
12657
12695
|
var LlmGenerateBaseInputSchema = object({
|
|
12658
12696
|
/** Collection routing (the notification-output posture). */
|
|
12659
12697
|
addonId: string().optional(),
|
|
@@ -12668,7 +12706,28 @@ var LlmGenerateBaseInputSchema = object({
|
|
|
12668
12706
|
jsonSchema: record(string(), unknown()).optional(),
|
|
12669
12707
|
/** Per-call override of the profile default. */
|
|
12670
12708
|
maxTokens: number().int().positive().optional(),
|
|
12671
|
-
temperature: number().optional()
|
|
12709
|
+
temperature: number().optional(),
|
|
12710
|
+
/** Per-call override of the profile default (nucleus sampling). */
|
|
12711
|
+
topP: number().min(0).max(1).optional(),
|
|
12712
|
+
/** Per-call override of the profile default (top-k sampling). */
|
|
12713
|
+
topK: number().int().positive().optional(),
|
|
12714
|
+
/** Per-call override of `profile.timeoutMs` — the total generation bound. */
|
|
12715
|
+
timeoutMs: number().int().positive().optional(),
|
|
12716
|
+
/** Per-call override; beats both the consumer table and the profile. */
|
|
12717
|
+
retry: LlmRetryPolicySchema.optional(),
|
|
12718
|
+
/**
|
|
12719
|
+
* Caller-minted id that makes this generation CANCELLABLE.
|
|
12720
|
+
*
|
|
12721
|
+
* Without it a caller that stops waiting cannot stop the work: the gates race
|
|
12722
|
+
* the call against 8 s and free their own slot when the timer wins, while the
|
|
12723
|
+
* generation upstream keeps running to `profile.timeoutMs` — 60 s by default,
|
|
12724
|
+
* on a single-threaded local model. The per-camera bound then counts WAITS,
|
|
12725
|
+
* not generations, and the real load is unbounded.
|
|
12726
|
+
*
|
|
12727
|
+
* `AbortSignal` cannot cross a process boundary; an id can. Pass one here and
|
|
12728
|
+
* `llm.cancel({ requestId })` tears the socket down.
|
|
12729
|
+
*/
|
|
12730
|
+
requestId: string().optional()
|
|
12672
12731
|
});
|
|
12673
12732
|
/**
|
|
12674
12733
|
* `llm-runtime` — node-side managed llama.cpp executor (spec §4). Registered
|
|
@@ -12681,6 +12740,18 @@ var LlmGenerateBaseInputSchema = object({
|
|
|
12681
12740
|
* Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
|
|
12682
12741
|
* watchdog — operator decision #3).
|
|
12683
12742
|
*/
|
|
12743
|
+
/**
|
|
12744
|
+
* A companion artifact that MUST land beside the main GGUF: the `mmproj`
|
|
12745
|
+
* projector of a vision model, or shards 2..N of a split GGUF. Carried on the
|
|
12746
|
+
* REF rather than looked up at install time, so what the operator approved in
|
|
12747
|
+
* the preview is exactly what the node downloads.
|
|
12748
|
+
*/
|
|
12749
|
+
var ManagedModelExtraFileSchema = object({
|
|
12750
|
+
url: string(),
|
|
12751
|
+
filename: string(),
|
|
12752
|
+
sizeBytes: number(),
|
|
12753
|
+
sha256: string().optional()
|
|
12754
|
+
});
|
|
12684
12755
|
var ManagedModelRefSchema = discriminatedUnion("kind", [
|
|
12685
12756
|
object({
|
|
12686
12757
|
kind: literal("catalog"),
|
|
@@ -12689,7 +12760,11 @@ var ManagedModelRefSchema = discriminatedUnion("kind", [
|
|
|
12689
12760
|
object({
|
|
12690
12761
|
kind: literal("url"),
|
|
12691
12762
|
url: string(),
|
|
12692
|
-
sha256: string().optional()
|
|
12763
|
+
sha256: string().optional(),
|
|
12764
|
+
/** Picker/status label; the file basename when absent. */
|
|
12765
|
+
label: string().optional(),
|
|
12766
|
+
sizeBytes: number().optional(),
|
|
12767
|
+
extraFiles: array(ManagedModelExtraFileSchema).optional()
|
|
12693
12768
|
}),
|
|
12694
12769
|
object({
|
|
12695
12770
|
kind: literal("path"),
|
|
@@ -12707,13 +12782,82 @@ var ManagedRuntimeConfigSchema = object({
|
|
|
12707
12782
|
gpuLayers: number().int().default(0),
|
|
12708
12783
|
/** Default: cpus-2, clamped ≥1 (resolved node-side). */
|
|
12709
12784
|
threads: number().int().optional(),
|
|
12710
|
-
/** Concurrent slots. */
|
|
12785
|
+
/** Concurrent slots (`--parallel`). */
|
|
12711
12786
|
parallel: number().int().default(1),
|
|
12787
|
+
/** Logical batch size (`-b`). Larger = faster prompt ingest, more RAM. */
|
|
12788
|
+
batchSize: number().int().positive().optional(),
|
|
12789
|
+
/** Physical batch / micro-batch (`-ub`). */
|
|
12790
|
+
ubatchSize: number().int().positive().optional(),
|
|
12791
|
+
/**
|
|
12792
|
+
* `--flash-attn`. Cuts KV-cache memory on the backends that implement it and
|
|
12793
|
+
* is a no-op elsewhere, so it is offered rather than assumed.
|
|
12794
|
+
*/
|
|
12795
|
+
flashAttention: boolean().default(false),
|
|
12796
|
+
/**
|
|
12797
|
+
* `--mlock`. Pins the weights in RAM so the OS cannot page them out mid
|
|
12798
|
+
* inference. Costs the full model size in resident memory — which is exactly
|
|
12799
|
+
* what the RAM budget is counting.
|
|
12800
|
+
*/
|
|
12801
|
+
mlock: boolean().default(false),
|
|
12802
|
+
/**
|
|
12803
|
+
* `--no-mmap`. Reads the whole GGUF up front instead of mapping it. Slower to
|
|
12804
|
+
* start, but avoids the page-fault stalls a network or spinning-disk model
|
|
12805
|
+
* store produces on every first token.
|
|
12806
|
+
*/
|
|
12807
|
+
noMmap: boolean().default(false),
|
|
12808
|
+
/** `--cache-type-k` / `--cache-type-v` — quantising the KV cache is the
|
|
12809
|
+
* cheapest way to fit a longer context in the same RAM. */
|
|
12810
|
+
cacheTypeK: _enum([
|
|
12811
|
+
"f32",
|
|
12812
|
+
"f16",
|
|
12813
|
+
"q8_0",
|
|
12814
|
+
"q5_1",
|
|
12815
|
+
"q5_0",
|
|
12816
|
+
"q4_1",
|
|
12817
|
+
"q4_0"
|
|
12818
|
+
]).optional(),
|
|
12819
|
+
cacheTypeV: _enum([
|
|
12820
|
+
"f32",
|
|
12821
|
+
"f16",
|
|
12822
|
+
"q8_0",
|
|
12823
|
+
"q5_1",
|
|
12824
|
+
"q5_0",
|
|
12825
|
+
"q4_1",
|
|
12826
|
+
"q4_0"
|
|
12827
|
+
]).optional(),
|
|
12828
|
+
/**
|
|
12829
|
+
* Escape hatch for llama-server flags this schema does NOT model — `--jinja`
|
|
12830
|
+
* (which most vision chat templates need and some language-only models
|
|
12831
|
+
* dislike), `--cont-batching`, `--rope-scaling`, …
|
|
12832
|
+
*
|
|
12833
|
+
* It is NOT a second place to set the flags above. A token that collides
|
|
12834
|
+
* with a typed field is REJECTED at start, naming the field that owns it
|
|
12835
|
+
* (`assertNoOwnedFlags`), because two knobs writing the same argv is exactly
|
|
12836
|
+
* the "two switches that disagree" failure this repo has already shipped
|
|
12837
|
+
* twice (D62).
|
|
12838
|
+
*/
|
|
12839
|
+
extraArgs: array(string()).default([]),
|
|
12712
12840
|
/** Else lazy: first generate boots it. */
|
|
12713
12841
|
autoStart: boolean().default(false),
|
|
12714
12842
|
/** 0 = never; frees RAM after quiet periods. */
|
|
12715
12843
|
idleStopMinutes: number().int().default(30)
|
|
12716
12844
|
});
|
|
12845
|
+
/**
|
|
12846
|
+
* Where a multi-GB install currently is. A single 0..1 fraction cannot answer
|
|
12847
|
+
* "is it stuck?" for an install that is three files (shards + mmproj) followed
|
|
12848
|
+
* by a sha256 pass over 22 GB — during which the fraction sat at 1.0 and the
|
|
12849
|
+
* node looked hung. Phase + file + bytes is the smallest shape that does.
|
|
12850
|
+
*/
|
|
12851
|
+
var LlmDownloadProgressSchema = object({
|
|
12852
|
+
phase: _enum(["downloading", "verifying"]),
|
|
12853
|
+
/** The artifact currently moving, e.g. `mmproj-F16.gguf`. */
|
|
12854
|
+
file: string(),
|
|
12855
|
+
fileIndex: number().int(),
|
|
12856
|
+
fileCount: number().int(),
|
|
12857
|
+
/** Across the WHOLE install, not the current file. */
|
|
12858
|
+
downloadedBytes: number(),
|
|
12859
|
+
totalBytes: number().optional()
|
|
12860
|
+
});
|
|
12717
12861
|
var LlmRuntimeStatusSchema = object({
|
|
12718
12862
|
/** Status is ALWAYS node-qualified. */
|
|
12719
12863
|
nodeId: string(),
|
|
@@ -12730,6 +12874,8 @@ var LlmRuntimeStatusSchema = object({
|
|
|
12730
12874
|
modelPath: string().optional(),
|
|
12731
12875
|
modelId: string().optional(),
|
|
12732
12876
|
downloadProgress: number().min(0).max(1).optional(),
|
|
12877
|
+
/** Detail behind `downloadProgress`; present for the same lifetime. */
|
|
12878
|
+
download: LlmDownloadProgressSchema.optional(),
|
|
12733
12879
|
lastError: string().optional(),
|
|
12734
12880
|
crashesInWindow: number(),
|
|
12735
12881
|
/** Child RSS (sampled best-effort). */
|
|
@@ -12740,7 +12886,14 @@ var LlmNodeModelSchema = object({
|
|
|
12740
12886
|
file: string(),
|
|
12741
12887
|
sizeBytes: number(),
|
|
12742
12888
|
catalogId: string().optional(),
|
|
12743
|
-
installedAt: number().optional()
|
|
12889
|
+
installedAt: number().optional(),
|
|
12890
|
+
/**
|
|
12891
|
+
* Absolute path on the node. Present so a file that is on disk but matches
|
|
12892
|
+
* no catalog entry — a custom Hugging Face install, or a GGUF the operator
|
|
12893
|
+
* copied in by hand — is still SELECTABLE, as a `{kind:'path'}` ref. Without
|
|
12894
|
+
* it the picker could list such a file and do nothing with it.
|
|
12895
|
+
*/
|
|
12896
|
+
path: string().optional()
|
|
12744
12897
|
});
|
|
12745
12898
|
var LlmRuntimeDiskUsageSchema = object({
|
|
12746
12899
|
nodeId: string(),
|
|
@@ -12796,10 +12949,47 @@ var LlmProfileSchema = object({
|
|
|
12796
12949
|
baseUrl: string().optional(),
|
|
12797
12950
|
/** ConfigUISchema type:'password' — never round-trips (spec §5). */
|
|
12798
12951
|
apiKey: string().optional(),
|
|
12952
|
+
/** Vision on/off. A vision call against a `false` profile is REFUSED, never
|
|
12953
|
+
* degraded to text — that shipped once and produced a confident answer to a
|
|
12954
|
+
* question about a picture nobody sent. */
|
|
12799
12955
|
supportsVision: boolean(),
|
|
12800
12956
|
temperature: number().min(0).max(2).optional(),
|
|
12957
|
+
/** Nucleus sampling. Every wire we speak has it. */
|
|
12958
|
+
topP: number().min(0).max(1).optional(),
|
|
12959
|
+
/** Top-k sampling. Carried only by the wires that have it — NEITHER OpenAI
|
|
12960
|
+
* wire does, and the client drops it there (measured: the request body gets
|
|
12961
|
+
* `top_p` and no `top_k`). The profile editor hides the field wherever it
|
|
12962
|
+
* would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
|
|
12963
|
+
topK: number().int().positive().optional(),
|
|
12801
12964
|
maxTokens: number().int().positive().optional(),
|
|
12965
|
+
/** Prompt context window. Advisory for cloud kinds (they enforce their own);
|
|
12966
|
+
* for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
|
|
12967
|
+
* the model with, so it is the one field that changes a PROCESS. */
|
|
12968
|
+
contextLength: number().int().positive().optional(),
|
|
12969
|
+
/** Default system prompt. A caller's `system` REPLACES it (never appends —
|
|
12970
|
+
* two system prompts fighting is worse than either alone). */
|
|
12971
|
+
systemPrompt: string().optional(),
|
|
12972
|
+
/** Total generation bound — the only one a unary call has. */
|
|
12802
12973
|
timeoutMs: number().int().positive().default(6e4),
|
|
12974
|
+
/** The TCP handshake only — "is the port even open". NOT the wait for
|
|
12975
|
+
* response headers: on the LM Studio / llama-server wire those are written
|
|
12976
|
+
* once the model has finished loading, so they belong to the bound below. */
|
|
12977
|
+
connectTimeoutMs: number().int().positive().default(1e4),
|
|
12978
|
+
/** Accepted, but no output yet — response headers included, because a cold
|
|
12979
|
+
* GPU load is exactly what happens before them. */
|
|
12980
|
+
firstTokenTimeoutMs: number().int().positive().default(12e4),
|
|
12981
|
+
/** Output started then stopped. */
|
|
12982
|
+
idleTimeoutMs: number().int().positive().default(6e4),
|
|
12983
|
+
/** Profile-level default. The per-consumer table and a per-call override
|
|
12984
|
+
* both beat it — see `resolveRetryPolicy`. */
|
|
12985
|
+
retry: LlmRetryPolicySchema.default({
|
|
12986
|
+
enabled: false,
|
|
12987
|
+
maxAttempts: 1
|
|
12988
|
+
}),
|
|
12989
|
+
/** Whether this profile may use tools. The tool-call plumbing rides the
|
|
12990
|
+
* library; the REGISTRY of callable tools is ours and is empty in v1, so a
|
|
12991
|
+
* `true` here buys the wiring, not behaviour, until tools are registered. */
|
|
12992
|
+
toolsEnabled: boolean().default(false),
|
|
12803
12993
|
extraHeaders: record(string(), string()).optional(),
|
|
12804
12994
|
/** kind === 'managed-local' only (spec §4). */
|
|
12805
12995
|
runtime: ManagedRuntimeConfigSchema.optional()
|
|
@@ -12849,6 +13039,36 @@ var ManagedModelCatalogEntrySchema = object({
|
|
|
12849
13039
|
/** Vision models: companion projector file. */
|
|
12850
13040
|
mmprojUrl: string().optional()
|
|
12851
13041
|
});
|
|
13042
|
+
/**
|
|
13043
|
+
* The outcome of turning one operator-typed Hugging Face reference into a
|
|
13044
|
+
* download plan. A RESULT, never a throw: "this repo has 24 quantizations and
|
|
13045
|
+
* I will not pick for you" is a normal answer the UI has to render, not an
|
|
13046
|
+
* exception.
|
|
13047
|
+
*
|
|
13048
|
+
* `candidates` is the whole reason the refusal is usable — every string in it
|
|
13049
|
+
* is a tag that resolves when pasted back as `<org>/<repo>:<TAG>`.
|
|
13050
|
+
*/
|
|
13051
|
+
var HfModelResolutionSchema = discriminatedUnion("ok", [object({
|
|
13052
|
+
ok: literal(true),
|
|
13053
|
+
/** Ready to hand to `installModel` unchanged. */
|
|
13054
|
+
model: ManagedModelRefSchema,
|
|
13055
|
+
label: string(),
|
|
13056
|
+
repo: string(),
|
|
13057
|
+
quantization: string(),
|
|
13058
|
+
purpose: _enum(["text", "vision"]),
|
|
13059
|
+
totalBytes: number(),
|
|
13060
|
+
/** mmproj + shards, for the preview: an operator approving 23 GB should
|
|
13061
|
+
* see that 0.9 GB of it is a projector they did not name. */
|
|
13062
|
+
extraFilenames: array(string())
|
|
13063
|
+
}), object({
|
|
13064
|
+
ok: literal(false),
|
|
13065
|
+
code: string(),
|
|
13066
|
+
message: string(),
|
|
13067
|
+
candidates: array(string()).optional(),
|
|
13068
|
+
/** Set when the refusal was only the ceiling: re-calling with
|
|
13069
|
+
* `maxBytes: requiredBytes` is the operator's explicit override. */
|
|
13070
|
+
requiredBytes: number().optional()
|
|
13071
|
+
})]);
|
|
12852
13072
|
var LlmRuntimeNodeSchema = object({
|
|
12853
13073
|
nodeId: string(),
|
|
12854
13074
|
reachable: boolean(),
|
|
@@ -12861,7 +13081,10 @@ var ProfileRefInputSchema = object({
|
|
|
12861
13081
|
addonId: string(),
|
|
12862
13082
|
profileId: string()
|
|
12863
13083
|
});
|
|
12864
|
-
method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({
|
|
13084
|
+
method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({
|
|
13085
|
+
addonId: string().optional(),
|
|
13086
|
+
requestId: string()
|
|
13087
|
+
}), _void(), { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
|
|
12865
13088
|
kind: "mutation",
|
|
12866
13089
|
auth: "admin"
|
|
12867
13090
|
}), method(ProfileRefInputSchema, _void(), {
|
|
@@ -12882,6 +13105,15 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }
|
|
|
12882
13105
|
consumer: string().optional(),
|
|
12883
13106
|
profileId: string().optional()
|
|
12884
13107
|
}), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
|
|
13108
|
+
/** `https://huggingface.co/<org>/<repo>/resolve/main/<f>.gguf`,
|
|
13109
|
+
* `<org>/<repo>/<f>.gguf`, `<org>/<repo>` or `<org>/<repo>:<QUANT>`. */
|
|
13110
|
+
ref: string(),
|
|
13111
|
+
/** Explicit ceiling override, in bytes. Absent = the built-in ceiling. */
|
|
13112
|
+
maxBytes: number().positive().optional()
|
|
13113
|
+
}), HfModelResolutionSchema, {
|
|
13114
|
+
kind: "mutation",
|
|
13115
|
+
auth: "admin"
|
|
13116
|
+
}), method(object({
|
|
12885
13117
|
nodeId: string(),
|
|
12886
13118
|
model: ManagedModelRefSchema
|
|
12887
13119
|
}), _void(), {
|
|
@@ -14529,6 +14761,8 @@ var NcSystemEventKindSchema = _enum([
|
|
|
14529
14761
|
"stream-offline",
|
|
14530
14762
|
"node-online",
|
|
14531
14763
|
"node-offline",
|
|
14764
|
+
"node-inference-unavailable",
|
|
14765
|
+
"detection-blind",
|
|
14532
14766
|
"addon-update-available",
|
|
14533
14767
|
"server-update-available",
|
|
14534
14768
|
"alarm-triggered",
|
|
@@ -14590,7 +14824,16 @@ var NcScheduleSchema = object({
|
|
|
14590
14824
|
});
|
|
14591
14825
|
/** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
|
|
14592
14826
|
var NcPlateMatcherSchema = object({
|
|
14593
|
-
|
|
14827
|
+
/**
|
|
14828
|
+
* Plate texts (or gallery vehicle names) to match. EMPTY = **any plate the
|
|
14829
|
+
* pipeline could read** — the plate half of "no selection = no narrowing",
|
|
14830
|
+
* and the switch that says this rule is about vehicles that were IDENTIFIED
|
|
14831
|
+
* rather than merely seen. A subject carrying no plate still fails.
|
|
14832
|
+
*
|
|
14833
|
+
* The `.min(1)` this used to carry made that state unauthorable; nothing has
|
|
14834
|
+
* ever persisted an empty list, so widening it cannot change an existing rule.
|
|
14835
|
+
*/
|
|
14836
|
+
values: array(string().min(1)),
|
|
14594
14837
|
/** Max Levenshtein distance after normalization (uppercase alphanumeric). */
|
|
14595
14838
|
maxDistance: number().int().min(0).max(3).default(1)
|
|
14596
14839
|
});
|
|
@@ -14624,28 +14867,36 @@ var NcOccupancyConditionSchema = object({
|
|
|
14624
14867
|
/**
|
|
14625
14868
|
* Audio condition (IMMEDIATE trigger) — a rule on SOUND, not on a picture.
|
|
14626
14869
|
*
|
|
14627
|
-
*
|
|
14628
|
-
*
|
|
14629
|
-
*
|
|
14630
|
-
*
|
|
14631
|
-
*
|
|
14632
|
-
*
|
|
14633
|
-
*
|
|
14634
|
-
*
|
|
14635
|
-
*
|
|
14636
|
-
*
|
|
14637
|
-
*
|
|
14638
|
-
*
|
|
14639
|
-
*
|
|
14640
|
-
*
|
|
14641
|
-
*
|
|
14642
|
-
*
|
|
14643
|
-
*
|
|
14644
|
-
*
|
|
14645
|
-
*
|
|
14646
|
-
*
|
|
14647
|
-
*
|
|
14648
|
-
* `
|
|
14870
|
+
* **TWO EXCLUSIVE MODES** (operator decision 2026-08-14, D157). Which one a
|
|
14871
|
+
* rule is in is not a stored field — it is WHICH FILTER the rule carries, so
|
|
14872
|
+
* there is no second switch that can disagree with the first and every rule
|
|
14873
|
+
* authored before the decision migrates for free (`audioModeOf`):
|
|
14874
|
+
*
|
|
14875
|
+
* - **LABEL mode — `labels` present.** The rule fires on the FIRST frame the
|
|
14876
|
+
* classifier labels with one of them. No window, no percentage:
|
|
14877
|
+
* `hitPercent` and `samplingSeconds` are ignored, and the rule's own
|
|
14878
|
+
* `throttle` cooldown is the only brake. The per-label confidence floor is
|
|
14879
|
+
* the analyzer's (`classificationMinScore`, per device) — a label only
|
|
14880
|
+
* reaches this condition if the classifier was already confident enough.
|
|
14881
|
+
* - **LEVEL mode — `dbThreshold` present, no labels.** The sampling window IS
|
|
14882
|
+
* the condition: at least `hitPercent`% of the samples over
|
|
14883
|
+
* `samplingSeconds` must be at or above `dbThreshold` dBFS (see
|
|
14884
|
+
* {@link NC_AUDIO_DBFS_FLOOR}: negative-going, `0` = full scale). The window
|
|
14885
|
+
* must be FULL before it can match — a window open for two of its ten
|
|
14886
|
+
* seconds is 100% of nothing.
|
|
14887
|
+
*
|
|
14888
|
+
* **Why label mode has no window.** It had one, and it never fired: the
|
|
14889
|
+
* analyzer emits ~1 audio frame per second but YAMNet only LABELS one to three
|
|
14890
|
+
* of them per episode, even through continuous crying. The measured maximum
|
|
14891
|
+
* `hitPercent` over the whole live history was 40 — under the shipped default
|
|
14892
|
+
* of 60, so a label rule could not fire at all, ever. A percentage of frames is
|
|
14893
|
+
* the wrong question to ask of a sparse classifier.
|
|
14894
|
+
*
|
|
14895
|
+
* **Fail-closed when NEITHER is given** — every sample would be a trivial hit
|
|
14896
|
+
* and the rule would fire on silence. The schema cannot express "exactly one
|
|
14897
|
+
* of" without becoming a ZodEffects the cap path would have to special-case, so
|
|
14898
|
+
* the exclusivity is enforced where every editor writes (`patchAudio`) and a
|
|
14899
|
+
* legacy rule carrying both resolves to LABEL (the mode that fires).
|
|
14649
14900
|
*
|
|
14650
14901
|
* Labels are the audio macro classes (`AUDIO_MACRO_LABELS` / the NC taxonomy's
|
|
14651
14902
|
* `audio-*` ids). Both spellings are accepted — the matcher normalizes the
|
|
@@ -14653,13 +14904,13 @@ var NcOccupancyConditionSchema = object({
|
|
|
14653
14904
|
* an operator who typed `dog` mean the same thing.
|
|
14654
14905
|
*/
|
|
14655
14906
|
var NcAudioConditionSchema = object({
|
|
14656
|
-
/**
|
|
14907
|
+
/** LABEL MODE: audio macro labels. Present ⇒ fires on the first labelled frame. */
|
|
14657
14908
|
labels: array(string().min(1)).min(1).optional(),
|
|
14658
|
-
/**
|
|
14909
|
+
/** LEVEL MODE: floor in dBFS (negative-going, `0` = full scale). */
|
|
14659
14910
|
dbThreshold: number().min(-96).max(0).optional(),
|
|
14660
|
-
/**
|
|
14911
|
+
/** LEVEL MODE ONLY: percentage of the window's samples that must be hits (1–100). */
|
|
14661
14912
|
hitPercent: number().int().min(1).max(100).default(60),
|
|
14662
|
-
/**
|
|
14913
|
+
/** LEVEL MODE ONLY: length of the sampling window in seconds. */
|
|
14663
14914
|
samplingSeconds: number().int().min(1).max(300).default(10)
|
|
14664
14915
|
});
|
|
14665
14916
|
/**
|
|
@@ -14797,13 +15048,81 @@ var NcRuleActionsSchema = object({
|
|
|
14797
15048
|
*/
|
|
14798
15049
|
buttons: array(NcRuleNotificationButtonSchema).max(8).optional()
|
|
14799
15050
|
});
|
|
15051
|
+
/**
|
|
15052
|
+
* "This rule applies only while `deviceId` is in one of `states`."
|
|
15053
|
+
*
|
|
15054
|
+
* The states are the DEVICE's own vocabulary — `AlarmState` for a panel,
|
|
15055
|
+
* `on`/`off` for a switch — not a normalised set, because normalising would
|
|
15056
|
+
* make the condition lie about devices whose states have no equivalent.
|
|
15057
|
+
*
|
|
15058
|
+
* An unreadable state does NOT match: see the engine's fail-closed gate. A
|
|
15059
|
+
* condition that fired on "I could not read it" would be worse than no gate.
|
|
15060
|
+
*/
|
|
15061
|
+
var NcDeviceStateConditionSchema = object({
|
|
15062
|
+
deviceId: number().int(),
|
|
15063
|
+
/** Any of these matches. */
|
|
15064
|
+
states: array(string().min(1)).min(1)
|
|
15065
|
+
});
|
|
15066
|
+
/**
|
|
15067
|
+
* "This rule applies only while scene `sceneId` is `matched` / `diverged`."
|
|
15068
|
+
*
|
|
15069
|
+
* A GATE, not a trigger. `occupancy` and `audio` each DISCRIMINATE their rule —
|
|
15070
|
+
* carrying one makes the rule fire on that subject and nothing else. Scene is
|
|
15071
|
+
* the other shape entirely, the `deviceState` shape: it narrows a rule that
|
|
15072
|
+
* already has a trigger ("tell me about a person at the front door, but only
|
|
15073
|
+
* while the bin is still out"). That is why it composes with every delivery
|
|
15074
|
+
* instead of owning one, and why no new `NcDelivery` member and no new subject
|
|
15075
|
+
* kind exist for it — see D159.
|
|
15076
|
+
*
|
|
15077
|
+
* ── Identity ───────────────────────────────────────────────────────────────
|
|
15078
|
+
* `sceneId` is `SceneMonitor.id`, a `randomUUID()` minted by `createScene` —
|
|
15079
|
+
* globally unique, so it needs no device to disambiguate it. `deviceId` is
|
|
15080
|
+
* carried as a HINT for the editor and for the log line, never as part of the
|
|
15081
|
+
* lookup key: a rule whose hint drifted must still gate correctly.
|
|
15082
|
+
*
|
|
15083
|
+
* ── Which boolean ──────────────────────────────────────────────────────────
|
|
15084
|
+
* `latched` ABSENT means "whatever the scene itself says" — `SceneMonitor.emit`
|
|
15085
|
+
* already declares which boolean drives notification rules, and a second knob
|
|
15086
|
+
* that could disagree with it is exactly the D62 failure. Set it only to
|
|
15087
|
+
* override one rule against the scene's own default.
|
|
15088
|
+
*
|
|
15089
|
+
* - LIVE reading (`emit`/`latched` resolve to live): passes iff
|
|
15090
|
+
* `verdict === requiredState`. `unknown` — no reference for this light, view
|
|
15091
|
+
* shifted, no snapshot — passes NEITHER. A scene that cannot judge is not
|
|
15092
|
+
* evidence, in either direction.
|
|
15093
|
+
* - LATCHED reading: passes iff `latched === (requiredState === 'diverged')`.
|
|
15094
|
+
* The latch is a durable fact about the past ("it has diverged since I armed
|
|
15095
|
+
* it"), so a camera that has gone dark does not clear it — that is the whole
|
|
15096
|
+
* reason the operator asked for a latch.
|
|
15097
|
+
*
|
|
15098
|
+
* The gate reads an in-memory mirror (`NcSceneStateCache`) refreshed OFF the
|
|
15099
|
+
* event path, never the cap: D49. A mirror that has never loaded, or a scene it
|
|
15100
|
+
* does not carry, reads absent and the rule does NOT fire — fail closed, and
|
|
15101
|
+
* said out loud in the log rather than dropped in silence.
|
|
15102
|
+
*/
|
|
15103
|
+
var NcSceneConditionSchema = object({
|
|
15104
|
+
/** `SceneMonitor.id` — the uuid the cap mints. The whole lookup key. */
|
|
15105
|
+
sceneId: string().min(1),
|
|
15106
|
+
/** The camera the scene lives on. A hint for the editor and the log line. */
|
|
15107
|
+
deviceId: number().int().optional(),
|
|
15108
|
+
/** The state the scene must be in for the rule to fire. */
|
|
15109
|
+
requiredState: _enum(["matched", "diverged"]),
|
|
15110
|
+
/**
|
|
15111
|
+
* Read the LATCH (`true`) or the LIVE verdict (`false`). Absent = follow the
|
|
15112
|
+
* scene's own `emit` field, which is the only place that decision belongs.
|
|
15113
|
+
*/
|
|
15114
|
+
latched: boolean().optional()
|
|
15115
|
+
});
|
|
14800
15116
|
var NcConditionsSchema = object({
|
|
14801
15117
|
/** Gate on ANOTHER device's current state (the alarm armed, a switch on). */
|
|
14802
|
-
deviceState:
|
|
14803
|
-
|
|
14804
|
-
|
|
14805
|
-
|
|
14806
|
-
|
|
15118
|
+
deviceState: NcDeviceStateConditionSchema.optional(),
|
|
15119
|
+
/**
|
|
15120
|
+
* Gate on a SCENE's state — "only while the bin is still out". Composes with
|
|
15121
|
+
* every trigger (detection, occupancy, audio, sensor, package, track-end);
|
|
15122
|
+
* unlike `occupancy`/`audio` it discriminates nothing. See
|
|
15123
|
+
* {@link NcSceneCondition} and D159.
|
|
15124
|
+
*/
|
|
15125
|
+
scene: NcSceneConditionSchema.optional(),
|
|
14807
15126
|
/** Device scope — absent = all devices. */
|
|
14808
15127
|
devices: array(number()).optional(),
|
|
14809
15128
|
/** Detector class names (any overlap with the record's class set). */
|
|
@@ -14829,18 +15148,47 @@ var NcConditionsSchema = object({
|
|
|
14829
15148
|
*/
|
|
14830
15149
|
labelEquals: array(string().min(1)).optional(),
|
|
14831
15150
|
/**
|
|
14832
|
-
*
|
|
14833
|
-
*
|
|
14834
|
-
*
|
|
15151
|
+
* KNOWN FACES — the rule's identity scope, and the switch that says the rule
|
|
15152
|
+
* is about recognised people at all.
|
|
15153
|
+
*
|
|
15154
|
+
* Three states, and the empty one is the point:
|
|
15155
|
+
*
|
|
15156
|
+
* | value | meaning |
|
|
15157
|
+
* | --- | --- |
|
|
15158
|
+
* | absent | the rule does not care who it is; an unrecognised person matches |
|
|
15159
|
+
* | `[]` | **only known faces** — any identity in the gallery, nobody in particular |
|
|
15160
|
+
* | a list | only these identities |
|
|
15161
|
+
*
|
|
15162
|
+
* `[]` is the repo-wide "no selection = no narrowing" reading (an absent
|
|
15163
|
+
* `devices` list is every device), applied one level down: the operator has
|
|
15164
|
+
* turned the face scope ON and narrowed it to nothing, which is every known
|
|
15165
|
+
* face. No second field states the same thing — a switch that can disagree
|
|
15166
|
+
* with the list under it is worse than no switch (D62).
|
|
15167
|
+
*
|
|
15168
|
+
* MEMBERS ARE FACE-GALLERY `Identity.id`s (uuid), not display names. A name is
|
|
15169
|
+
* renameable, and a rule authored on "Gianluca" went silently dark the moment
|
|
15170
|
+
* the operator fixed the spelling. The id reaches the record on
|
|
15171
|
+
* `LabelAttribution.identityId`; the name is what the editor shows and what
|
|
15172
|
+
* `{{label}}` renders.
|
|
15173
|
+
*
|
|
15174
|
+
* Rules written before this carry NAMES, and are resolved to ids lazily at
|
|
15175
|
+
* load (`NcRuleStore.load`) against the live gallery — a name nothing answers
|
|
15176
|
+
* for is left as it stands and reported, never dropped. The engine also
|
|
15177
|
+
* accepts a display-name hit as a compatibility leg, so a rule whose
|
|
15178
|
+
* migration could not resolve keeps matching exactly what it matched before.
|
|
14835
15179
|
*/
|
|
14836
15180
|
identities: array(string().min(1)).optional(),
|
|
14837
|
-
/**
|
|
15181
|
+
/**
|
|
15182
|
+
* KNOWN PLATES / VEHICLES — the plate mirror of {@link identities}, including
|
|
15183
|
+
* the empty-list reading: `values: []` is "any plate the OCR could read",
|
|
15184
|
+
* a non-empty list is those plates (fuzzily). See {@link NcPlateMatcherSchema}.
|
|
15185
|
+
*/
|
|
14838
15186
|
plates: NcPlateMatcherSchema.optional(),
|
|
14839
15187
|
/**
|
|
14840
|
-
* Identity EXCLUDE — mirror of {@link identities} with `notIn` semantics
|
|
14841
|
-
*
|
|
14842
|
-
* identity
|
|
14843
|
-
*
|
|
15188
|
+
* Identity EXCLUDE — mirror of {@link identities} with `notIn` semantics, and
|
|
15189
|
+
* the same id members and the same lazy name→id migration. A record with NO
|
|
15190
|
+
* identity passes (nothing to exclude), unlike the include variant which
|
|
15191
|
+
* fails on an unrecognised subject. An EMPTY list excludes nobody.
|
|
14844
15192
|
*/
|
|
14845
15193
|
identitiesExclude: array(string().min(1)).optional(),
|
|
14846
15194
|
/**
|
|
@@ -15232,7 +15580,80 @@ var NcRuleInputSchema = object({
|
|
|
15232
15580
|
* a rule that predates the gate must keep delivering byte-for-byte as it
|
|
15233
15581
|
* did, and absent is the only way to say that without a migration.
|
|
15234
15582
|
*/
|
|
15235
|
-
confirm: NcConfirmSchema.optional()
|
|
15583
|
+
confirm: NcConfirmSchema.optional(),
|
|
15584
|
+
/**
|
|
15585
|
+
* WAIT for face/plate recognition before saying anything.
|
|
15586
|
+
*
|
|
15587
|
+
* A notification's TEXT is frozen at enqueue and its media is re-resolved at
|
|
15588
|
+
* send; the identity is neither. A face is confirmed after `confirmFrames`
|
|
15589
|
+
* agreeing observations — p50 **11.4 s** after the track was first seen,
|
|
15590
|
+
* measured on this hub — and an `immediate` rule enqueues on the first object
|
|
15591
|
+
* event, seconds before that. So "Gianluca è arrivato" is unsayable on the
|
|
15592
|
+
* immediate path, and no amount of media re-resolution fixes a sentence.
|
|
15593
|
+
*
|
|
15594
|
+
* Only two honest answers exist, and this flag picks between them. It has
|
|
15595
|
+
* effect ONLY on a rule that declares a recognition scope
|
|
15596
|
+
* ({@link NcConditions.identities} or {@link NcConditions.plates}) — on any
|
|
15597
|
+
* other rule there is nothing to wait for and the flag is inert.
|
|
15598
|
+
*
|
|
15599
|
+
* | value | what happens |
|
|
15600
|
+
* | --- | --- |
|
|
15601
|
+
* | `true` | the rule stops firing on the object event and fires at TRACK CLOSE instead, once, with the name — later, and complete |
|
|
15602
|
+
* | absent / `false` | it fires at once WITHOUT the name, and if recognition lands before the track closes a SECOND, "…is Gianluca" notification follows (one per track, per rule, per target) |
|
|
15603
|
+
*
|
|
15604
|
+
* `.optional()` and deliberately NOT `.default()`: a Zod default does not run
|
|
15605
|
+
* on the addon cap path, and absent has to keep meaning exactly what every
|
|
15606
|
+
* rule authored before this field meant.
|
|
15607
|
+
*
|
|
15608
|
+
* The cost of `true` is stated here because the editor states it too: a rule
|
|
15609
|
+
* that waits also inherits track-close SEMANTICS — its `zones` condition
|
|
15610
|
+
* tests every zone the track visited and a `crossing` condition can no longer
|
|
15611
|
+
* be satisfied, because a closed track carries no crossing.
|
|
15612
|
+
*/
|
|
15613
|
+
waitForEnhancement: boolean().optional(),
|
|
15614
|
+
/**
|
|
15615
|
+
* GROUP a burst of subjects into ONE notification that grows.
|
|
15616
|
+
*
|
|
15617
|
+
* Seconds of quiet after the last matching subject before the burst is
|
|
15618
|
+
* considered over. While it is open, the first subject enqueues immediately —
|
|
15619
|
+
* **exactly as today, with no added latency** — and every real growth (a new
|
|
15620
|
+
* subject, or a name confirmed on one already in it) REPLACES that
|
|
15621
|
+
* notification with an updated one naming everybody. The push carries the
|
|
15622
|
+
* group's own coalescing tag, so the phone replaces rather than stacks.
|
|
15623
|
+
*
|
|
15624
|
+
* `0` / absent = off, and off is today's behaviour byte for byte.
|
|
15625
|
+
*
|
|
15626
|
+
* ### Why an idle cutoff and not a window
|
|
15627
|
+
*
|
|
15628
|
+
* The measured seven-person arrival on device 590 spans 110 s with every
|
|
15629
|
+
* internal gap under 30 s. A 12 s fixed window cuts it into three groups; an
|
|
15630
|
+
* idle cutoff holds it as one and ends it when the arrival actually ends.
|
|
15631
|
+
* 30 is Frigate's shipped value for the same decision.
|
|
15632
|
+
*
|
|
15633
|
+
* ### What it replaces
|
|
15634
|
+
*
|
|
15635
|
+
* The blind cooldown, which collapses a burst by DISCARDING it. Measured on
|
|
15636
|
+
* device 615 / *Persona su Uscio* over six days: 116 qualifying tracks → 74
|
|
15637
|
+
* notifications, **44 (37.9%) suppressed outright**, 23 of them overlapping a
|
|
15638
|
+
* track that did fire and 7 carrying a confirmed identity nobody heard about.
|
|
15639
|
+
* A group collapses the same volume by MERGING, so the cooldown becomes a
|
|
15640
|
+
* budget over GROUPS — which is what it always meant — and a growth is never
|
|
15641
|
+
* throttled by the window its own first member spent.
|
|
15642
|
+
*
|
|
15643
|
+
* ### Interaction with {@link waitForEnhancement}
|
|
15644
|
+
*
|
|
15645
|
+
* They compose, and the order matters. `waitForEnhancement` defers the rule to
|
|
15646
|
+
* TRACK CLOSE, so with both set the group is opened by the first member to
|
|
15647
|
+
* CLOSE — already carrying its name — and grows as later members close. That
|
|
15648
|
+
* is later, and complete. With grouping alone the group opens on the first
|
|
15649
|
+
* object event and picks up names as they are confirmed, through the growth
|
|
15650
|
+
* path. Neither combination fires twice for one subject.
|
|
15651
|
+
*
|
|
15652
|
+
* `.optional()` and deliberately NOT `.default()`: a Zod default does not run
|
|
15653
|
+
* on the addon cap path, so absent must keep meaning what it meant before this
|
|
15654
|
+
* field existed.
|
|
15655
|
+
*/
|
|
15656
|
+
groupIdleSec: number().int().min(0).max(600).optional()
|
|
15236
15657
|
});
|
|
15237
15658
|
/**
|
|
15238
15659
|
* Partial patch for `updateRule` — any subset of the input fields, plus the
|
|
@@ -15339,6 +15760,7 @@ var NcConditionDescriptorSchema = object({
|
|
|
15339
15760
|
"occupancy",
|
|
15340
15761
|
"audio",
|
|
15341
15762
|
"deviceState",
|
|
15763
|
+
"scene",
|
|
15342
15764
|
"systemEvent"
|
|
15343
15765
|
]),
|
|
15344
15766
|
operator: _enum([
|
|
@@ -16158,7 +16580,7 @@ var TrackEnvelopeSchema = object({
|
|
|
16158
16580
|
* `snapshots[]` references — megabytes across a page of tracks. `slim`
|
|
16159
16581
|
* keeps every scalar the list surfaces actually render (ids, class(es),
|
|
16160
16582
|
* label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
|
|
16161
|
-
* zonesVisited, bestEventId, envelope, hasFace) and returns `positions` /
|
|
16583
|
+
* zonesVisited, bestEventId, envelope, hasFace, hasRider) and returns `positions` /
|
|
16162
16584
|
* `snapshots` as EMPTY arrays — detail views re-fetch the full row via
|
|
16163
16585
|
* `getTrack`. Mirrors the event-store `projection` convention
|
|
16164
16586
|
* (`getObjectEvents` et al.).
|
|
@@ -16294,7 +16716,21 @@ union([literal(1), literal(2)]);
|
|
|
16294
16716
|
var LabelAttributionSchema = object({
|
|
16295
16717
|
stepId: string(),
|
|
16296
16718
|
modelId: string().optional(),
|
|
16297
|
-
decidedAt: number()
|
|
16719
|
+
decidedAt: number(),
|
|
16720
|
+
/**
|
|
16721
|
+
* The GALLERY id behind a recognised tier-2 label — a face-gallery
|
|
16722
|
+
* `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
|
|
16723
|
+
*
|
|
16724
|
+
* The text alone is a DISPLAY NAME, and a display name is renameable: a
|
|
16725
|
+
* notification rule authored on "Gianluca" stopped matching the moment the
|
|
16726
|
+
* operator fixed the spelling in the gallery, and nothing said so. The id is
|
|
16727
|
+
* the thing that does not move, so it is what a rule matches on
|
|
16728
|
+
* (`NcConditions.identities`) and the text is what a human is shown.
|
|
16729
|
+
*
|
|
16730
|
+
* Absent when the label names no gallery row — a plate the OCR read but no
|
|
16731
|
+
* vehicle claims, a sub-class, a species, any tier-1 value.
|
|
16732
|
+
*/
|
|
16733
|
+
identityId: string().optional()
|
|
16298
16734
|
});
|
|
16299
16735
|
/**
|
|
16300
16736
|
* The TIERED label model (roadmap 4g), spread into `TrackSchema` and
|
|
@@ -16431,6 +16867,28 @@ var TrackSchema = object({
|
|
|
16431
16867
|
* `=== true` and render nothing otherwise, never infer "no face".
|
|
16432
16868
|
*/
|
|
16433
16869
|
hasFace: boolean().optional(),
|
|
16870
|
+
/**
|
|
16871
|
+
* This subject CONTAINS a folded rider — a person the rider-pairing step
|
|
16872
|
+
* ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
|
|
16873
|
+
* so the passage is tracked once and as a VEHICLE.
|
|
16874
|
+
*
|
|
16875
|
+
* It exists because the fold's record was dishonest. D34 and the code both
|
|
16876
|
+
* said "the person is not lost — it is reported so both entities stay on the
|
|
16877
|
+
* record"; in fact the pair went into a per-processor RAM field behind an
|
|
16878
|
+
* accessor nobody called, and every durable surface said `vehicle`, full
|
|
16879
|
+
* stop. This is the composition note that makes the row true.
|
|
16880
|
+
*
|
|
16881
|
+
* A COMPOSITION, never a class and never a label. "This vehicle contains a
|
|
16882
|
+
* person" is not an answer to "what is this" — both label tiers would refuse
|
|
16883
|
+
* a macro token anyway (D89), and correctly. Nothing here changes what the
|
|
16884
|
+
* subject IS: a cyclist stays one vehicle track, occupancy still counts one,
|
|
16885
|
+
* and a `person` rule still does not fire for someone cycling past.
|
|
16886
|
+
*
|
|
16887
|
+
* **Absent ≠ false**, exactly like {@link hasFace}: every row written before
|
|
16888
|
+
* the column, and every hub that predates the field, omits it. Test
|
|
16889
|
+
* `=== true` and render nothing otherwise — never infer "no rider".
|
|
16890
|
+
*/
|
|
16891
|
+
hasRider: boolean().optional(),
|
|
16434
16892
|
...TrackFlagFields,
|
|
16435
16893
|
...TrackRetrainFields
|
|
16436
16894
|
});
|
|
@@ -17866,6 +18324,17 @@ var maxSessionHoldMsField = {
|
|
|
17866
18324
|
default: 12e4,
|
|
17867
18325
|
step: 5e3
|
|
17868
18326
|
};
|
|
18327
|
+
/**
|
|
18328
|
+
* Quiet period that closes an `audioMode: 'on-motion'` audio window. Floor of
|
|
18329
|
+
* 5s so a rearm can never degenerate into per-event stream churn; default 90s
|
|
18330
|
+
* comfortably outlives the gap between two PIR wakes on a battery camera.
|
|
18331
|
+
*/
|
|
18332
|
+
var audioMotionWindowMsField = {
|
|
18333
|
+
min: 5e3,
|
|
18334
|
+
max: 6e5,
|
|
18335
|
+
default: 9e4,
|
|
18336
|
+
step: 5e3
|
|
18337
|
+
};
|
|
17869
18338
|
var motionFpsField = {
|
|
17870
18339
|
min: 1,
|
|
17871
18340
|
max: 30,
|
|
@@ -18042,6 +18511,27 @@ var RunnerCameraConfigSchema = object({
|
|
|
18042
18511
|
* resolved `CameraDetectionConfig`.
|
|
18043
18512
|
*/
|
|
18044
18513
|
maxSessionHoldMs: number().min(maxSessionHoldMsField.min).max(maxSessionHoldMsField.max).optional(),
|
|
18514
|
+
/**
|
|
18515
|
+
* Orchestrator-side quiet period (ms) that closes an `audioMode:
|
|
18516
|
+
* 'on-motion'` audio window, measured from the LAST motion event.
|
|
18517
|
+
*
|
|
18518
|
+
* This exists because the falling edge cannot be relied on. Camera-native
|
|
18519
|
+
* providers emit motion as a RISING EDGE ONLY (Reolink's Baichuan push and
|
|
18520
|
+
* its email-push SMTP path both emit `detected: true` and never the
|
|
18521
|
+
* counterpart); only the frame-diff analyzer emits falls. So on an
|
|
18522
|
+
* onboard-only camera a window that closed only on `detected: false` never
|
|
18523
|
+
* closed at all, and `on-motion` silently behaved as `always-on` — on a
|
|
18524
|
+
* battery camera, the one failure mode the mode exists to prevent.
|
|
18525
|
+
*
|
|
18526
|
+
* Every motion event rearms this timer WITHOUT restarting the stream, so a
|
|
18527
|
+
* burst of re-fires costs nothing. A falling edge, when one does arrive,
|
|
18528
|
+
* still closes earlier via `motionCooldownMs` — whichever comes first wins.
|
|
18529
|
+
*
|
|
18530
|
+
* Not consumed by the runner: carried here so it shares the per-camera
|
|
18531
|
+
* device-settings surface with `motionCooldownMs`, exactly like
|
|
18532
|
+
* `maxSessionHoldMs`.
|
|
18533
|
+
*/
|
|
18534
|
+
audioMotionWindowMs: number().min(audioMotionWindowMsField.min).max(audioMotionWindowMsField.max).optional(),
|
|
18045
18535
|
motionFps: number().min(motionFpsField.min).max(motionFpsField.max).default(motionFpsField.default),
|
|
18046
18536
|
detectionFps: number().min(detectionFpsField.min).max(detectionFpsField.max).default(detectionFpsField.default),
|
|
18047
18537
|
motionStreamId: string(),
|
|
@@ -18137,7 +18627,7 @@ var RunnerCameraConfigSchema = object({
|
|
|
18137
18627
|
*/
|
|
18138
18628
|
inferenceDevices: array(RunnerInferenceDeviceSchema).readonly().optional()
|
|
18139
18629
|
});
|
|
18140
|
-
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;
|
|
18630
|
+
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;
|
|
18141
18631
|
/**
|
|
18142
18632
|
* Runtime load summary returned by `getLocalLoad`. Used by the orchestrator's
|
|
18143
18633
|
* load-balancing levels (L2 capacity-based, L3 hardware-aware) to decide
|
|
@@ -20902,6 +21392,25 @@ var BatteryStatusSchema = object({
|
|
|
20902
21392
|
/** Ms epoch of the last observation. Lets consumers reason about freshness. */
|
|
20903
21393
|
lastUpdated: number(),
|
|
20904
21394
|
/**
|
|
21395
|
+
* Ms epoch of the last time the device PROVED it was reachable — a
|
|
21396
|
+
* completed firmware round-trip, an observed wake, or an inbound push
|
|
21397
|
+
* (firmware event, email). `0`/absent = never since this slice was born.
|
|
21398
|
+
*
|
|
21399
|
+
* This is the ONLY input that separates "asleep" from "gone", and it is
|
|
21400
|
+
* fed exclusively by PASSIVE signals: nothing may write it by reaching
|
|
21401
|
+
* for the radio, because a poll that confirms reachability is the same
|
|
21402
|
+
* poll that drains the battery. See {@link deriveBatteryPresence} — the
|
|
21403
|
+
* single derivation every consumer must use; no surface computes its own.
|
|
21404
|
+
*
|
|
21405
|
+
* It is deliberately NOT a clock in the
|
|
21406
|
+
* `scripts/check-runtime-state-durability.ts` sense: it is the
|
|
21407
|
+
* observation itself, and it is the only thing a 30-hour silence is
|
|
21408
|
+
* visible in. Writers quantise it (see `CONTACT_WRITE_QUANTUM_MS` in the
|
|
21409
|
+
* Reolink provider) so a value that means "recently" cannot cost a
|
|
21410
|
+
* SQLite commit per round-trip.
|
|
21411
|
+
*/
|
|
21412
|
+
lastContactAt: number().optional(),
|
|
21413
|
+
/**
|
|
20905
21414
|
* True when the source is a BINARY low-battery indicator (HA
|
|
20906
21415
|
* `binary_sensor` device_class=battery / `LOW_BAT`) that has no real
|
|
20907
21416
|
* charge level — `percentage` is then a coarse stand-in (100 = normal,
|
|
@@ -26387,14 +26896,77 @@ method(object({
|
|
|
26387
26896
|
* thing except the comparator: `similarity` (CLIP cosine at the same ROI coords
|
|
26388
26897
|
* vs condition-tagged references) and `llm` (vision-LLM judgment over the crop).
|
|
26389
26898
|
*
|
|
26390
|
-
*
|
|
26391
|
-
*
|
|
26392
|
-
*
|
|
26393
|
-
*
|
|
26394
|
-
|
|
26395
|
-
|
|
26396
|
-
*
|
|
26899
|
+
* **No `deviceConfig`, deliberately.** This shipped as the D14 widget archetype,
|
|
26900
|
+
* which put a "Scenes" tab on one camera's detail page. That is the wrong shape
|
|
26901
|
+
* for the thing: a scene is a standing question about the property ("is the bin
|
|
26902
|
+
* still out"), and the operator's question is "which of my scenes have tripped",
|
|
26903
|
+
* across every camera at once — not "what does camera 617 think". Buried one
|
|
26904
|
+
* camera deep it also could not be found. The surface is now a top-level admin
|
|
26905
|
+
* page (`/scenes`, `pages/Scenes.tsx`) that lists every scene on every camera and
|
|
26906
|
+
* picks the camera inside the create flow, the same shape Events and Faces have.
|
|
26907
|
+
*
|
|
26908
|
+
* The consequence to keep in mind: `host/scene-monitor-editor` is gone from
|
|
26909
|
+
* `HOST_WIDGETS` too. `scripts/check-host-widget-resolves.ts` asserts BOTH
|
|
26910
|
+
* directions, so a registration nobody declares fails exactly as loudly as a
|
|
26911
|
+
* declaration nobody registers. The editor is imported directly by the page.
|
|
26912
|
+
*
|
|
26913
|
+
* `status.kind:'push'` — the engine pushes on every hysteresis flip /
|
|
26914
|
+
* availability change; consumers never poll.
|
|
26915
|
+
*/
|
|
26916
|
+
/** Extensible condition tag. Seeded 'day' | 'ir' (the two variants the operator
|
|
26917
|
+
* captures) plus 'night' | 'dawn' | 'dusk' from the resolver's sun-times band.
|
|
26918
|
+
* Open by design so more can be added without a wire break.
|
|
26919
|
+
*
|
|
26920
|
+
* Matching does NOT fall back across conditions: cross-condition cosines are
|
|
26921
|
+
* not comparable, so "I have never seen this scene in this light" is reported
|
|
26922
|
+
* as `unknown`, never guessed. A day reference scored against an IR frame
|
|
26923
|
+
* collapses the cosine and would latch a false alarm every single night. */
|
|
26397
26924
|
var SceneConditionSchema = string();
|
|
26925
|
+
/**
|
|
26926
|
+
* What a scene does when the CURRENT light has no reference of its own.
|
|
26927
|
+
*
|
|
26928
|
+
* The lighting variants are not equally likely to exist. Almost every operator
|
|
26929
|
+
* captures daylight and then never stands outside at 22:00 to capture IR, and a
|
|
26930
|
+
* scene that is only ever going to be asked about a daytime question ("is the
|
|
26931
|
+
* bin still on the kerb at 08:00") does not need a night reference at all. The
|
|
26932
|
+
* night half must therefore be OPTIONAL, and optional means the scene keeps
|
|
26933
|
+
* working without it rather than degrading into a permanent complaint.
|
|
26934
|
+
*
|
|
26935
|
+
* - `skip` (default) — the check in that light is not made. Not a verdict, not
|
|
26936
|
+
* an alarm, not even an `unknown`: the live state simply stays whatever the
|
|
26937
|
+
* last covered light left it at, the latch is untouched, and the hysteresis
|
|
26938
|
+
* run is neither spent nor cleared. The scene resumes by itself at first
|
|
26939
|
+
* light. This is the only behaviour under which "I never captured IR" is a
|
|
26940
|
+
* configuration choice instead of a nightly fault.
|
|
26941
|
+
* - `judge-anyway` — score against the OTHER conditions' references. Available
|
|
26942
|
+
* for cameras whose IR frame is close enough to daylight (a floodlit
|
|
26943
|
+
* driveway, an always-white-light doorbell), and wrong for everything else:
|
|
26944
|
+
* cross-condition cosines are not comparable, so a day reference against a
|
|
26945
|
+
* true IR frame collapses and the scene reports a theft at 21:40.
|
|
26946
|
+
*
|
|
26947
|
+
* Never applies when the scene has NO comparable reference at all — that is
|
|
26948
|
+
* "not armed yet", it is reported as `no-reference-for-condition`, and silence
|
|
26949
|
+
* there would hide a scene the operator never finished setting up.
|
|
26950
|
+
*/
|
|
26951
|
+
var SceneUncoveredPolicySchema = _enum(["skip", "judge-anyway"]);
|
|
26952
|
+
/** `matched` = the baseline is what we see; `diverged` = it demonstrably is not;
|
|
26953
|
+
* `unknown` = we cannot judge (no reference for this condition, encoder model
|
|
26954
|
+
* changed, view shifted, no snapshot). `unknown` is a real value, not a null,
|
|
26955
|
+
* and never counts toward hysteresis in either direction. */
|
|
26956
|
+
var SceneVerdictSchema = _enum([
|
|
26957
|
+
"matched",
|
|
26958
|
+
"diverged",
|
|
26959
|
+
"unknown"
|
|
26960
|
+
]);
|
|
26961
|
+
/** Why a scene cannot judge. Named, because this feature's failure mode is
|
|
26962
|
+
* silence that reads as "nothing has happened". */
|
|
26963
|
+
var SceneUnavailableSchema = _enum([
|
|
26964
|
+
"no-reference-for-condition",
|
|
26965
|
+
"view-shifted",
|
|
26966
|
+
"no-vision-profile",
|
|
26967
|
+
"encoder-model-changed",
|
|
26968
|
+
"no-snapshot"
|
|
26969
|
+
]);
|
|
26398
26970
|
/** One captured reference — condition-tagged, model-version-gated. `embedding`
|
|
26399
26971
|
* is `number[]` (Float32Array does NOT survive MsgPack/UDS). */
|
|
26400
26972
|
var SceneReferenceSchema = object({
|
|
@@ -26402,7 +26974,14 @@ var SceneReferenceSchema = object({
|
|
|
26402
26974
|
modelId: string(),
|
|
26403
26975
|
condition: SceneConditionSchema,
|
|
26404
26976
|
capturedAt: number(),
|
|
26405
|
-
thumbnailMediaId: string().optional()
|
|
26977
|
+
thumbnailMediaId: string().optional(),
|
|
26978
|
+
/** Whole-frame (downscaled) embedding captured alongside the ROI crop. The
|
|
26979
|
+
* anti-view-shift anchor: a bumped camera, a PTZ preset or a re-aim makes the
|
|
26980
|
+
* normalized rect frame a different piece of world, and the scene would
|
|
26981
|
+
* diverge forever with a perfectly plausible cosine. Checked LAZILY, only
|
|
26982
|
+
* when hysteresis is about to flip — one extra encode per candidate
|
|
26983
|
+
* transition, not per poll. */
|
|
26984
|
+
anchorEmbedding: array(number()).optional()
|
|
26406
26985
|
});
|
|
26407
26986
|
var SceneMonitorStateSchema = object({
|
|
26408
26987
|
id: string(),
|
|
@@ -26424,6 +27003,28 @@ var SceneCheckSchema = discriminatedUnion("mode", [object({
|
|
|
26424
27003
|
profileId: string().optional(),
|
|
26425
27004
|
hysteresisCount: number().int().positive()
|
|
26426
27005
|
})]);
|
|
27006
|
+
var SCENE_DEFAULT_ANCHOR_THRESHOLD = .85;
|
|
27007
|
+
/** Night is OPTIONAL. A scene with only a daylight reference sits the IR hours
|
|
27008
|
+
* out in silence rather than reporting a fault every night. */
|
|
27009
|
+
var SCENE_DEFAULT_UNCOVERED_POLICY = "skip";
|
|
27010
|
+
/**
|
|
27011
|
+
* Vision-model adjudication of a candidate flip. Field names deliberately
|
|
27012
|
+
* mirror `NcConfirmSchema` so an operator meets one vocabulary, not two.
|
|
27013
|
+
*
|
|
27014
|
+
* `onTimeout` defaults to **'hold'**, the OPPOSITE of `NcConfirmGate`'s
|
|
27015
|
+
* fail-open: a notification suppressed is the worse error there, but a vision
|
|
27016
|
+
* model that timed out has not told us the bin is gone, and a latch is a
|
|
27017
|
+
* stateful claim that costs the operator a trip to reset.
|
|
27018
|
+
*/
|
|
27019
|
+
var SceneConfirmSchema = object({
|
|
27020
|
+
enabled: boolean().default(false),
|
|
27021
|
+
prompt: string().min(1).max(1e3),
|
|
27022
|
+
profileId: string().optional(),
|
|
27023
|
+
timeoutMs: number().int().min(1e3).max(2e4).default(8e3),
|
|
27024
|
+
maxImagePx: number().int().min(64).max(2048).default(448),
|
|
27025
|
+
/** What a timeout / unavailable model means for the PENDING flip. */
|
|
27026
|
+
onTimeout: _enum(["flip", "hold"]).default("hold")
|
|
27027
|
+
});
|
|
26427
27028
|
var SceneMonitorSchema = object({
|
|
26428
27029
|
id: string(),
|
|
26429
27030
|
label: string(),
|
|
@@ -26442,7 +27043,56 @@ var SceneMonitorSchema = object({
|
|
|
26442
27043
|
lastConfidence: number().nullable(),
|
|
26443
27044
|
currentCondition: SceneConditionSchema.nullable(),
|
|
26444
27045
|
availability: _enum(["ok", "unavailable"]),
|
|
26445
|
-
unavailableReason: string().nullable()
|
|
27046
|
+
unavailableReason: string().nullable(),
|
|
27047
|
+
/** Which state is "the initial screen". `null` until the first capture. */
|
|
27048
|
+
baselineStateId: string().nullable(),
|
|
27049
|
+
/** Which boolean drives notification rules and any export. */
|
|
27050
|
+
emit: _enum(["latched", "live"]).default("latched"),
|
|
27051
|
+
/** Live: does the region match the baseline RIGHT NOW. */
|
|
27052
|
+
verdict: SceneVerdictSchema,
|
|
27053
|
+
/** Has it been `diverged` at least once since `armedAt` — the operator's boolean. */
|
|
27054
|
+
latched: boolean(),
|
|
27055
|
+
/** Last reset (or creation). */
|
|
27056
|
+
armedAt: number(),
|
|
27057
|
+
divergedAt: number().nullable(),
|
|
27058
|
+
restoredAt: number().nullable(),
|
|
27059
|
+
/** A check is only COUNTED when the device has been quiet this long. Motion
|
|
27060
|
+
* during the window DISCARDS the observation — a car pulling up in front of
|
|
27061
|
+
* the bin must not be able to spend hysteresis credit. */
|
|
27062
|
+
quietSeconds: number().int().min(0).max(3600).default(60),
|
|
27063
|
+
/** An observation only advances the pending count when it is at least this
|
|
27064
|
+
* far from the previously counted one, so N agreeing checks span real time
|
|
27065
|
+
* rather than N adjacent polls inside one occlusion. */
|
|
27066
|
+
minObservationSpacingSec: number().int().min(0).max(3600).default(120),
|
|
27067
|
+
/** Vision-model adjudication of a candidate flip. Similarity primary only. */
|
|
27068
|
+
confirm: SceneConfirmSchema.optional(),
|
|
27069
|
+
/** Whole-frame anchor cosine below which a flip is REFUSED as `view-shifted`. */
|
|
27070
|
+
anchorThreshold: number().min(0).max(1).default(SCENE_DEFAULT_ANCHOR_THRESHOLD),
|
|
27071
|
+
/** Clear the latch on its own when the scene matches again? Default false —
|
|
27072
|
+
* `restoredAt` and the `scene-restored` edge are recorded regardless, so an
|
|
27073
|
+
* automation can react to the bin coming back without the operator's own
|
|
27074
|
+
* alarm silently clearing itself. */
|
|
27075
|
+
autoRestore: boolean().default(false),
|
|
27076
|
+
/** What to do when the current light has no reference of its own. See
|
|
27077
|
+
* {@link SceneUncoveredPolicySchema} — the default makes night OPTIONAL. */
|
|
27078
|
+
onUncoveredCondition: SceneUncoveredPolicySchema.default(SCENE_DEFAULT_UNCOVERED_POLICY),
|
|
27079
|
+
/**
|
|
27080
|
+
* The light whose checks are currently being SAT OUT under
|
|
27081
|
+
* `onUncoveredCondition: 'skip'` — `null` when the scene is checking normally.
|
|
27082
|
+
*
|
|
27083
|
+
* Engine-reported and advisory only: it moves no verdict, no latch and no
|
|
27084
|
+
* hysteresis. It exists so the card can say *"night (IR) — checks paused,
|
|
27085
|
+
* nothing captured in this light"* in the same calm voice as the coverage
|
|
27086
|
+
* line, because the alternative is a scene that silently stops answering
|
|
27087
|
+
* after sunset with nothing anywhere saying why. A skipped check must never
|
|
27088
|
+
* read as a broken one.
|
|
27089
|
+
*/
|
|
27090
|
+
suspendedCondition: SceneConditionSchema.nullable().default(null),
|
|
27091
|
+
/** Named cause when `verdict === 'unknown'`. */
|
|
27092
|
+
unavailable: SceneUnavailableSchema.nullable(),
|
|
27093
|
+
/** Conditions that have at least one comparable reference — the coverage line
|
|
27094
|
+
* ("day ✓ · ir ✓ · dusk ✗") that turns a silent fallback into a visible fact. */
|
|
27095
|
+
coveredConditions: array(SceneConditionSchema)
|
|
26446
27096
|
});
|
|
26447
27097
|
var SceneMonitorStatusSchema = object({
|
|
26448
27098
|
monitors: array(SceneMonitorSchema),
|
|
@@ -26455,12 +27105,6 @@ var sceneMonitorCapability = {
|
|
|
26455
27105
|
kind: "wrapper",
|
|
26456
27106
|
defaultActive: true,
|
|
26457
27107
|
deviceTypes: [DeviceType.Camera],
|
|
26458
|
-
deviceConfig: { ui: {
|
|
26459
|
-
kind: "widget",
|
|
26460
|
-
widgetId: "host/scene-monitor-editor",
|
|
26461
|
-
tab: "scenes",
|
|
26462
|
-
label: "Scenes"
|
|
26463
|
-
} },
|
|
26464
27108
|
methods: {
|
|
26465
27109
|
listScenes: method(object({ deviceId: number() }), SceneMonitorStatusSchema),
|
|
26466
27110
|
createScene: method(object({
|
|
@@ -26491,7 +27135,15 @@ var sceneMonitorCapability = {
|
|
|
26491
27135
|
"both"
|
|
26492
27136
|
]).optional(),
|
|
26493
27137
|
checkIntervalSec: number().optional(),
|
|
26494
|
-
check: SceneCheckSchema.optional()
|
|
27138
|
+
check: SceneCheckSchema.optional(),
|
|
27139
|
+
emit: _enum(["latched", "live"]).optional(),
|
|
27140
|
+
quietSeconds: number().int().min(0).max(3600).optional(),
|
|
27141
|
+
minObservationSpacingSec: number().int().min(0).max(3600).optional(),
|
|
27142
|
+
anchorThreshold: number().min(0).max(1).optional(),
|
|
27143
|
+
autoRestore: boolean().optional(),
|
|
27144
|
+
onUncoveredCondition: SceneUncoveredPolicySchema.optional(),
|
|
27145
|
+
/** `null` clears the vision-model adjudicator. */
|
|
27146
|
+
confirm: SceneConfirmSchema.nullable().optional()
|
|
26495
27147
|
})
|
|
26496
27148
|
}), _void(), {
|
|
26497
27149
|
kind: "mutation",
|
|
@@ -26532,6 +27184,26 @@ var sceneMonitorCapability = {
|
|
|
26532
27184
|
}), _void(), {
|
|
26533
27185
|
kind: "mutation",
|
|
26534
27186
|
auth: "admin"
|
|
27187
|
+
}),
|
|
27188
|
+
/**
|
|
27189
|
+
* Clear the latch, re-arm, and — by default — RE-CAPTURE the baseline for
|
|
27190
|
+
* the CURRENT condition. The bin never goes back in exactly the same spot;
|
|
27191
|
+
* "reset" in the operator's head means *this is the new normal*, and
|
|
27192
|
+
* re-capture is what makes the feature self-healing against slow drift
|
|
27193
|
+
* instead of failing silently weeks later.
|
|
27194
|
+
*
|
|
27195
|
+
* Reachable from three surfaces on this one mutation: the scene card, a
|
|
27196
|
+
* notification button (an `onTrigger` sequence with a `kind:'cap'` step —
|
|
27197
|
+
* no new Notification-Center code at all), and tRPC for scripts.
|
|
27198
|
+
*/
|
|
27199
|
+
resetScene: method(object({
|
|
27200
|
+
deviceId: number(),
|
|
27201
|
+
monitorId: string(),
|
|
27202
|
+
/** Defaults to TRUE at the provider seam — see `SCENE_RESET_RECAPTURES`. */
|
|
27203
|
+
recapture: boolean().optional()
|
|
27204
|
+
}), _void(), {
|
|
27205
|
+
kind: "mutation",
|
|
27206
|
+
auth: "admin"
|
|
26535
27207
|
})
|
|
26536
27208
|
},
|
|
26537
27209
|
status: {
|
|
@@ -26774,13 +27446,63 @@ var CamStreamDescriptorSchema = object({
|
|
|
26774
27446
|
* set of stream descriptors it can offer for the device, synchronously, so the
|
|
26775
27447
|
* broker can reconcile its registry against the authoritative provider state.
|
|
26776
27448
|
*/
|
|
27449
|
+
/**
|
|
27450
|
+
* The catalog as a DURABLE fact rather than a live answer.
|
|
27451
|
+
*
|
|
27452
|
+
* A battery camera's descriptors are profile-stable — they change when the
|
|
27453
|
+
* operator rewrites an encoder profile, not minute to minute — but building
|
|
27454
|
+
* them costs a Baichuan login, which on a sleeping Argus IS a wake. So the
|
|
27455
|
+
* provider is allowed to build them exactly once per profile and must serve
|
|
27456
|
+
* every later pull from a cache.
|
|
27457
|
+
*
|
|
27458
|
+
* Holding that cache only in RAM is what turned a restart into an outage. The
|
|
27459
|
+
* runner comes back with the camera asleep, `buildStreamCatalogUncached`
|
|
27460
|
+
* correctly refuses to wake it, the pull answers `[]`, the broker has no
|
|
27461
|
+
* cam-stream entry to build a broker from, and `webrtcSession.handleOffer`
|
|
27462
|
+
* fails with a flat "No broker for stream" — for as long as the camera sleeps,
|
|
27463
|
+
* which on a battery cam is most of the day. The camera was fine. The stream
|
|
27464
|
+
* was unreachable because the process had forgotten what the camera offers.
|
|
27465
|
+
*
|
|
27466
|
+
* Declaring it here puts it in `device-runtime-state`, the kernel's canonical
|
|
27467
|
+
* declared collection, with the same `restored` durability `battery` uses for
|
|
27468
|
+
* the same reason: the last known value is the only value there is while the
|
|
27469
|
+
* device is asleep. The broker's brokers are therefore always DEFINABLE — it
|
|
27470
|
+
* is the DIAL that wakes a camera, never the catalog (D173).
|
|
27471
|
+
*/
|
|
27472
|
+
var StreamCatalogStateSchema = object({
|
|
27473
|
+
/** The descriptors as last built from a real camera response. Never a guess:
|
|
27474
|
+
* a failed or refused build writes NOTHING, so a restored catalog is always
|
|
27475
|
+
* one the camera itself once produced. */
|
|
27476
|
+
descriptors: array(CamStreamDescriptorSchema),
|
|
27477
|
+
/** Ms epoch of the build that produced {@link descriptors}. Lets the wake
|
|
27478
|
+
* path decide whether the camera's own awake window is worth spending on a
|
|
27479
|
+
* re-read. */
|
|
27480
|
+
lastFetchedAt: number()
|
|
27481
|
+
});
|
|
26777
27482
|
var streamCatalogCapability = {
|
|
26778
27483
|
name: "stream-catalog",
|
|
26779
27484
|
scope: "device",
|
|
26780
27485
|
deviceNative: true,
|
|
26781
27486
|
mode: "singleton",
|
|
26782
27487
|
deviceTypes: [DeviceType.Camera],
|
|
26783
|
-
methods: { getCatalog: method(object({ deviceId: number().int().nonnegative() }), array(CamStreamDescriptorSchema).readonly()) }
|
|
27488
|
+
methods: { getCatalog: method(object({ deviceId: number().int().nonnegative() }), array(CamStreamDescriptorSchema).readonly()) },
|
|
27489
|
+
runtimeState: StreamCatalogStateSchema,
|
|
27490
|
+
/**
|
|
27491
|
+
* Runtime-state durability: **restored** — see the schema doc. A cold
|
|
27492
|
+
* catalog on a sleeping battery camera is not a slow first frame, it is a
|
|
27493
|
+
* camera that cannot be watched at all until it happens to wake.
|
|
27494
|
+
*
|
|
27495
|
+
* Churn is nil by construction: the slice is written only by a SUCCESSFUL
|
|
27496
|
+
* build, and a build only runs when there is no cached copy (or the copy is
|
|
27497
|
+
* a day old and the camera is awake anyway).
|
|
27498
|
+
*
|
|
27499
|
+
* See `RuntimeStateDurability`. Enforced by
|
|
27500
|
+
* `scripts/check-runtime-state-durability.ts`.
|
|
27501
|
+
*/
|
|
27502
|
+
durability: "restored",
|
|
27503
|
+
/** Clock field: written, but excluded from the compare that decides whether
|
|
27504
|
+
* persisting is worth a SQLite commit — the descriptors are the value. */
|
|
27505
|
+
volatileStateFields: ["lastFetchedAt"]
|
|
26784
27506
|
};
|
|
26785
27507
|
/** One of the camera's stream profiles. */
|
|
26786
27508
|
var StreamProfileSchema = _enum([
|
|
@@ -27233,12 +27955,64 @@ var NetworkAddressSchema = object({
|
|
|
27233
27955
|
family: string(),
|
|
27234
27956
|
internal: boolean()
|
|
27235
27957
|
});
|
|
27958
|
+
/**
|
|
27959
|
+
* Provenance of the site coordinates, and the whole reason this is not just two
|
|
27960
|
+
* numbers.
|
|
27961
|
+
*
|
|
27962
|
+
* - `operator-set` — a human typed it, or accepted a detection. Authoritative;
|
|
27963
|
+
* nothing overwrites it.
|
|
27964
|
+
* - `derived-from-ip` — the hub geolocated its own public IP once, because a
|
|
27965
|
+
* default that is right to a few kilometres beats the coarse UTC clock split
|
|
27966
|
+
* the sun-times consumers otherwise fall back to.
|
|
27967
|
+
*
|
|
27968
|
+
* The UI shows which one it is. An operator who cannot tell a guess from their
|
|
27969
|
+
* own input will eventually trust the guess.
|
|
27970
|
+
*/
|
|
27971
|
+
var SiteLocationSourceSchema = _enum(["operator-set", "derived-from-ip"]);
|
|
27972
|
+
/**
|
|
27973
|
+
* The read shape: the location plus the honest state of the one-shot derivation.
|
|
27974
|
+
*
|
|
27975
|
+
* `derivationAttemptedAt` is what makes the "one call, ever" contract
|
|
27976
|
+
* inspectable. When it is set and `location` is null, the geo-IP lookup ran and
|
|
27977
|
+
* failed; the hub will NOT try again on its own — the fallback is declared
|
|
27978
|
+
* (consumers degrade to their own last resort) and the operator either types the
|
|
27979
|
+
* coordinates or presses detect.
|
|
27980
|
+
*/
|
|
27981
|
+
var SiteLocationStatusSchema = object({
|
|
27982
|
+
location: object({
|
|
27983
|
+
/** WGS84 decimal degrees. */
|
|
27984
|
+
latitude: number().min(-90).max(90),
|
|
27985
|
+
longitude: number().min(-180).max(180),
|
|
27986
|
+
source: SiteLocationSourceSchema,
|
|
27987
|
+
/** Epoch ms the value was last written. */
|
|
27988
|
+
updatedAt: number(),
|
|
27989
|
+
/**
|
|
27990
|
+
* Human-readable place the geo-IP service reported ("Napoli, IT"). Display
|
|
27991
|
+
* only — never parsed, never matched on. Absent for an operator-typed value.
|
|
27992
|
+
*/
|
|
27993
|
+
label: string().optional()
|
|
27994
|
+
}).nullable(),
|
|
27995
|
+
derivationAttemptedAt: number().nullable(),
|
|
27996
|
+
/** Why the last derivation failed, for the UI to show instead of a shrug. */
|
|
27997
|
+
derivationError: string().nullable()
|
|
27998
|
+
});
|
|
27999
|
+
/** `null` clears the location and re-arms nothing — the derivation stays spent. */
|
|
28000
|
+
var SetSiteLocationInputSchema = object({
|
|
28001
|
+
latitude: number().min(-90).max(90),
|
|
28002
|
+
longitude: number().min(-180).max(180)
|
|
28003
|
+
}).nullable();
|
|
27236
28004
|
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(), {
|
|
27237
28005
|
kind: "mutation",
|
|
27238
28006
|
auth: "admin"
|
|
27239
28007
|
}), method(_void(), _void(), {
|
|
27240
28008
|
kind: "mutation",
|
|
27241
28009
|
auth: "admin"
|
|
28010
|
+
}), method(_void(), SiteLocationStatusSchema), method(SetSiteLocationInputSchema, SiteLocationStatusSchema, {
|
|
28011
|
+
kind: "mutation",
|
|
28012
|
+
auth: "admin"
|
|
28013
|
+
}), method(_void(), SiteLocationStatusSchema, {
|
|
28014
|
+
kind: "mutation",
|
|
28015
|
+
auth: "admin"
|
|
27242
28016
|
});
|
|
27243
28017
|
/**
|
|
27244
28018
|
* Tamper / case-open detection sensor. Drives Home Assistant
|
|
@@ -28592,6 +29366,7 @@ var DEVICE_LOCAL_STATE_CAPS = {
|
|
|
28592
29366
|
sceneMonitor: sceneMonitorCapability,
|
|
28593
29367
|
scriptRunner: scriptRunnerCapability,
|
|
28594
29368
|
smoke: smokeCapability,
|
|
29369
|
+
streamCatalog: streamCatalogCapability,
|
|
28595
29370
|
streamParams: streamParamsCapability,
|
|
28596
29371
|
switch: switchCapability,
|
|
28597
29372
|
tamper: tamperCapability,
|
|
@@ -29245,6 +30020,15 @@ var BaseDeviceProvider = class extends BaseAddon {
|
|
|
29245
30020
|
labels: ["probe not implemented"]
|
|
29246
30021
|
};
|
|
29247
30022
|
}
|
|
30023
|
+
/**
|
|
30024
|
+
* Top-level devices restored at once in {@link onRestoreDevices}.
|
|
30025
|
+
*
|
|
30026
|
+
* Four covers the fleets this ships to without turning a boot into a burst a
|
|
30027
|
+
* camera NVR answers with a refusal. A provider whose upstream is a single
|
|
30028
|
+
* session with a serial command channel (a Baichuan hub, an NVR that
|
|
30029
|
+
* serialises ISAPI) should lower it; nothing needs to raise it.
|
|
30030
|
+
*/
|
|
30031
|
+
restoreConcurrency = 4;
|
|
29248
30032
|
async restoreDevices(savedDevices) {
|
|
29249
30033
|
await this.onRestoreDevices(savedDevices);
|
|
29250
30034
|
if (savedDevices.length > 0) this.ctx.logger.info(`Restored ${savedDevices.length} ${this.providerName} device(s)`);
|
|
@@ -29276,15 +30060,15 @@ var BaseDeviceProvider = class extends BaseAddon {
|
|
|
29276
30060
|
*/
|
|
29277
30061
|
async onRestoreDevices(savedDevices) {
|
|
29278
30062
|
const restored = /* @__PURE__ */ new Set();
|
|
29279
|
-
|
|
29280
|
-
|
|
30063
|
+
const topLevel = savedDevices.filter((saved) => saved.parentDeviceId === null);
|
|
30064
|
+
const restoreOne = async (saved) => {
|
|
29281
30065
|
const Class = this.deviceClasses[saved.type];
|
|
29282
30066
|
if (!Class) {
|
|
29283
30067
|
this.ctx.logger.warn("No device class registered for restored type — skipping", {
|
|
29284
30068
|
tags: { stableId: saved.stableId },
|
|
29285
30069
|
meta: { type: saved.type }
|
|
29286
30070
|
});
|
|
29287
|
-
|
|
30071
|
+
return;
|
|
29288
30072
|
}
|
|
29289
30073
|
try {
|
|
29290
30074
|
await this.ctx.kernel.devices.create(saved.stableId, Class, {});
|
|
@@ -29298,7 +30082,15 @@ var BaseDeviceProvider = class extends BaseAddon {
|
|
|
29298
30082
|
}
|
|
29299
30083
|
});
|
|
29300
30084
|
}
|
|
29301
|
-
}
|
|
30085
|
+
};
|
|
30086
|
+
let nextTopLevel = 0;
|
|
30087
|
+
await Promise.all(Array.from({ length: Math.min(Math.max(1, this.restoreConcurrency), topLevel.length) }, async () => {
|
|
30088
|
+
for (;;) {
|
|
30089
|
+
const saved = topLevel[nextTopLevel++];
|
|
30090
|
+
if (saved === void 0) return;
|
|
30091
|
+
await restoreOne(saved);
|
|
30092
|
+
}
|
|
30093
|
+
}));
|
|
29302
30094
|
const childRows = savedDevices.filter((s) => s.parentDeviceId !== null);
|
|
29303
30095
|
for (const saved of childRows) {
|
|
29304
30096
|
const Class = this.deviceClasses[saved.type];
|
|
@@ -31454,6 +32246,12 @@ Object.freeze({
|
|
|
31454
32246
|
addonId: null,
|
|
31455
32247
|
access: "create"
|
|
31456
32248
|
},
|
|
32249
|
+
"llm.cancel": {
|
|
32250
|
+
capName: "llm",
|
|
32251
|
+
capScope: "system",
|
|
32252
|
+
addonId: null,
|
|
32253
|
+
access: "create"
|
|
32254
|
+
},
|
|
31457
32255
|
"llm.deleteModel": {
|
|
31458
32256
|
capName: "llm",
|
|
31459
32257
|
capScope: "system",
|
|
@@ -31538,6 +32336,12 @@ Object.freeze({
|
|
|
31538
32336
|
addonId: null,
|
|
31539
32337
|
access: "view"
|
|
31540
32338
|
},
|
|
32339
|
+
"llm.resolveModelRef": {
|
|
32340
|
+
capName: "llm",
|
|
32341
|
+
capScope: "system",
|
|
32342
|
+
addonId: null,
|
|
32343
|
+
access: "create"
|
|
32344
|
+
},
|
|
31541
32345
|
"llm.setDefault": {
|
|
31542
32346
|
capName: "llm",
|
|
31543
32347
|
capScope: "system",
|
|
@@ -33704,6 +34508,12 @@ Object.freeze({
|
|
|
33704
34508
|
addonId: null,
|
|
33705
34509
|
access: "create"
|
|
33706
34510
|
},
|
|
34511
|
+
"sceneMonitor.resetScene": {
|
|
34512
|
+
capName: "scene-monitor",
|
|
34513
|
+
capScope: "device",
|
|
34514
|
+
addonId: null,
|
|
34515
|
+
access: "delete"
|
|
34516
|
+
},
|
|
33707
34517
|
"sceneMonitor.updateScene": {
|
|
33708
34518
|
capName: "scene-monitor",
|
|
33709
34519
|
capScope: "device",
|
|
@@ -34382,6 +35192,12 @@ Object.freeze({
|
|
|
34382
35192
|
addonId: null,
|
|
34383
35193
|
access: "create"
|
|
34384
35194
|
},
|
|
35195
|
+
"system.detectSiteLocation": {
|
|
35196
|
+
capName: "system",
|
|
35197
|
+
capScope: "system",
|
|
35198
|
+
addonId: null,
|
|
35199
|
+
access: "create"
|
|
35200
|
+
},
|
|
34385
35201
|
"system.featureFlags": {
|
|
34386
35202
|
capName: "system",
|
|
34387
35203
|
capScope: "system",
|
|
@@ -34400,6 +35216,12 @@ Object.freeze({
|
|
|
34400
35216
|
addonId: null,
|
|
34401
35217
|
access: "view"
|
|
34402
35218
|
},
|
|
35219
|
+
"system.getSiteLocation": {
|
|
35220
|
+
capName: "system",
|
|
35221
|
+
capScope: "system",
|
|
35222
|
+
addonId: null,
|
|
35223
|
+
access: "view"
|
|
35224
|
+
},
|
|
34403
35225
|
"system.health": {
|
|
34404
35226
|
capName: "system",
|
|
34405
35227
|
capScope: "system",
|
|
@@ -34424,6 +35246,12 @@ Object.freeze({
|
|
|
34424
35246
|
addonId: null,
|
|
34425
35247
|
access: "create"
|
|
34426
35248
|
},
|
|
35249
|
+
"system.setSiteLocation": {
|
|
35250
|
+
capName: "system",
|
|
35251
|
+
capScope: "system",
|
|
35252
|
+
addonId: null,
|
|
35253
|
+
access: "create"
|
|
35254
|
+
},
|
|
34427
35255
|
"terminalSession.adoptLegacyMonitor": {
|
|
34428
35256
|
capName: "terminal-session",
|
|
34429
35257
|
capScope: "system",
|
|
@@ -36386,6 +37214,11 @@ Object.freeze({
|
|
|
36386
37214
|
form: "single",
|
|
36387
37215
|
optional: false
|
|
36388
37216
|
}],
|
|
37217
|
+
"sceneMonitor.resetScene": [{
|
|
37218
|
+
name: "deviceId",
|
|
37219
|
+
form: "single",
|
|
37220
|
+
optional: false
|
|
37221
|
+
}],
|
|
36389
37222
|
"sceneMonitor.updateScene": [{
|
|
36390
37223
|
name: "deviceId",
|
|
36391
37224
|
form: "single",
|
|
@@ -225466,6 +226299,44 @@ function capDayNightModeToReolink(mode) {
|
|
|
225466
226299
|
}
|
|
225467
226300
|
}
|
|
225468
226301
|
//#endregion
|
|
226302
|
+
//#region src/device-features.ts
|
|
226303
|
+
/**
|
|
226304
|
+
* Derive the device-manager feature set for a Reolink camera.
|
|
226305
|
+
*
|
|
226306
|
+
* `battery-operated` is derived from the probe flag **OR** the driver's own
|
|
226307
|
+
* `isBattery` discriminator — never the probe alone. The probe slice is
|
|
226308
|
+
* written only by a SUCCESSFUL `feature-probe` round-trip, and a battery
|
|
226309
|
+
* camera that is asleep (or flat, or off-LAN) never answers one: device 640
|
|
226310
|
+
* "Baby monitor" held `deviceCache.deviceType === 'battery-cam'`, a
|
|
226311
|
+
* `battery` runtime slice reporting `sleeping: true`, and STILL published
|
|
226312
|
+
* `features = ['native-snapshot','rebootable']` because the `feature-probe`
|
|
226313
|
+
* slice had never been written.
|
|
226314
|
+
*
|
|
226315
|
+
* That miss is not cosmetic. `DeviceFeature.BatteryOperated` is the gate for:
|
|
226316
|
+
* - the viewer's battery badge + sleeping overlay (`use-cameras.ts` FEATURE
|
|
226317
|
+
* map) — without it the camera is drawn as an ordinary awake camera;
|
|
226318
|
+
* - the snapshot wrapper's sleep gate (`snapshot.addon.ts`
|
|
226319
|
+
* `lookupDeviceMeta().isBattery`) — without it every thumbnail refresh
|
|
226320
|
+
* issues a Baichuan login and WAKES the camera (observed hourly on 640
|
|
226321
|
+
* while it sat at 14%);
|
|
226322
|
+
* - the broker's `preBufferSec = 0` battery rule and its relaxed stall
|
|
226323
|
+
* watchdog.
|
|
226324
|
+
*
|
|
226325
|
+
* The probe's own `hasBattery` is already sticky-true (`applyProbe` never
|
|
226326
|
+
* clears it). This makes the DERIVED answer sticky the same way, for the
|
|
226327
|
+
* window before any probe has ever succeeded.
|
|
226328
|
+
*/
|
|
226329
|
+
function deriveReolinkCameraFeatures(inputs) {
|
|
226330
|
+
const { probe, isBattery } = inputs;
|
|
226331
|
+
const out = [DeviceFeature.NativeSnapshot, DeviceFeature.Rebootable];
|
|
226332
|
+
if (probe.hasBattery === true || isBattery) out.push(DeviceFeature.BatteryOperated);
|
|
226333
|
+
if (probe.hasPtz === true) out.push(DeviceFeature.PanTiltZoom);
|
|
226334
|
+
if (probe.hasAutotrack === true) out.push(DeviceFeature.PtzAutotrack);
|
|
226335
|
+
if (probe.hasIntercom === true) out.push(DeviceFeature.TwoWayAudio);
|
|
226336
|
+
if (probe.hasDoorbell === true) out.push(DeviceFeature.DoorbellButton);
|
|
226337
|
+
return out;
|
|
226338
|
+
}
|
|
226339
|
+
//#endregion
|
|
225469
226340
|
//#region src/image-settings-mapping.ts
|
|
225470
226341
|
/**
|
|
225471
226342
|
* Reolink's `InputAdvanceCfg.Exposure.mode` (Baichuan cmdId 25/26, via
|
|
@@ -228985,6 +229856,15 @@ function coerceNumber(value) {
|
|
|
228985
229856
|
return null;
|
|
228986
229857
|
}
|
|
228987
229858
|
/**
|
|
229859
|
+
* Per-device transient diagnostics blob populated from the lib's
|
|
229860
|
+
* `getOnlineUserSessionsForUi` + `getSocketPoolSummary` +
|
|
229861
|
+
* `getSocketPoolCooldownStatus` calls. NOT persisted — recomputed on
|
|
229862
|
+
* demand and shown in the device's "Sessions" tab. The aggregator UI
|
|
229863
|
+
* polls the device aggregate every ~2.5s and a stale snapshot triggers
|
|
229864
|
+
* a background refresh; the operator can also force one via the
|
|
229865
|
+
* tab's Refresh button (`_refreshSessions` patch sentinel).
|
|
229866
|
+
*/
|
|
229867
|
+
/**
|
|
228988
229868
|
* Reolink camera device — connects via Baichuan protocol and pushes
|
|
228989
229869
|
* Annex-B H.264/H.265 directly to the stream broker.
|
|
228990
229870
|
*
|
|
@@ -229075,24 +229955,24 @@ function slicesForPatch(patch) {
|
|
|
229075
229955
|
var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
229076
229956
|
type = DeviceType.Camera;
|
|
229077
229957
|
/**
|
|
229078
|
-
* Features derived from the
|
|
229079
|
-
*
|
|
229080
|
-
* the cluster (stream-broker,
|
|
229081
|
-
* can derive policy from a single
|
|
229958
|
+
* Features derived from the `feature-probe` runtime-state slice AND the
|
|
229959
|
+
* driver's own `isBattery` discriminator. Surfaced via
|
|
229960
|
+
* `device-manager.getDevice` so any service in the cluster (stream-broker,
|
|
229961
|
+
* snapshot orchestrator, pipeline-runner) can derive policy from a single
|
|
229962
|
+
* source.
|
|
229963
|
+
*
|
|
229964
|
+
* The rule itself lives in `deriveReolinkCameraFeatures` — see that
|
|
229965
|
+
* function for why `battery-operated` must NOT wait for a probe.
|
|
229082
229966
|
*
|
|
229083
229967
|
* Returns a fresh array on each read so consumers can't mutate the
|
|
229084
229968
|
* underlying state. The set is small (≤6 entries) so allocation cost
|
|
229085
229969
|
* is negligible vs the staleness of caching.
|
|
229086
229970
|
*/
|
|
229087
229971
|
get features() {
|
|
229088
|
-
|
|
229089
|
-
|
|
229090
|
-
|
|
229091
|
-
|
|
229092
|
-
if (probe.hasAutotrack === true) out.push(DeviceFeature.PtzAutotrack);
|
|
229093
|
-
if (probe.hasIntercom === true) out.push(DeviceFeature.TwoWayAudio);
|
|
229094
|
-
if (probe.hasDoorbell === true) out.push(DeviceFeature.DoorbellButton);
|
|
229095
|
-
return out;
|
|
229972
|
+
return deriveReolinkCameraFeatures({
|
|
229973
|
+
probe: this.getProbeFlags(),
|
|
229974
|
+
isBattery: this.isBattery
|
|
229975
|
+
});
|
|
229096
229976
|
}
|
|
229097
229977
|
/** Lazy-connected Baichuan API. Spans the lifetime of every active stream. */
|
|
229098
229978
|
api = null;
|
|
@@ -229361,6 +230241,13 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
229361
230241
|
* retries.
|
|
229362
230242
|
*/
|
|
229363
230243
|
async onProbe() {
|
|
230244
|
+
if (this.isBattery && this.sleeping) {
|
|
230245
|
+
this.ctx.logger.info("onProbe skipped — battery cam is sleeping (no login, no wake)", {
|
|
230246
|
+
tags: { deviceId: this.id },
|
|
230247
|
+
meta: { probeRetriesAvoided: true }
|
|
230248
|
+
});
|
|
230249
|
+
return;
|
|
230250
|
+
}
|
|
229364
230251
|
let api;
|
|
229365
230252
|
try {
|
|
229366
230253
|
api = await this.ensureApi();
|
|
@@ -230061,9 +230948,21 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
230061
230948
|
status: slice
|
|
230062
230949
|
}));
|
|
230063
230950
|
});
|
|
230064
|
-
this.refreshBatteryFromApi();
|
|
230951
|
+
this.refreshBatteryFromApi("register");
|
|
230065
230952
|
}
|
|
230066
|
-
|
|
230953
|
+
/**
|
|
230954
|
+
* @param reason - `'register'` and `'periodic'` are OUR initiative and are
|
|
230955
|
+
* refused while the camera sleeps; `'wake'` and `'demand'` run because
|
|
230956
|
+
* something already has the camera awake or is entitled to wake it.
|
|
230957
|
+
*/
|
|
230958
|
+
async refreshBatteryFromApi(reason) {
|
|
230959
|
+
if (this.isBattery && this.sleeping && (reason === "register" || reason === "periodic")) {
|
|
230960
|
+
this.ctx.logger.debug("battery refresh skipped — cam sleeping, reading restored slice", {
|
|
230961
|
+
tags: { deviceId: this.id },
|
|
230962
|
+
meta: { reason }
|
|
230963
|
+
});
|
|
230964
|
+
return;
|
|
230965
|
+
}
|
|
230067
230966
|
let api;
|
|
230068
230967
|
try {
|
|
230069
230968
|
api = await this.ensureApi();
|
|
@@ -230221,7 +231120,14 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
230221
231120
|
return true;
|
|
230222
231121
|
}
|
|
230223
231122
|
updateBatteryCache(info) {
|
|
230224
|
-
|
|
231123
|
+
const mapped = this.mapBatteryInfo(info);
|
|
231124
|
+
const now = Date.now();
|
|
231125
|
+
const quantised = now - now % ReolinkCamera.CONTACT_WRITE_QUANTUM_MS;
|
|
231126
|
+
const previousContact = this.state.battery.lastContactAt ?? 0;
|
|
231127
|
+
this.setCapSlice(batteryCapability, {
|
|
231128
|
+
...mapped,
|
|
231129
|
+
lastContactAt: Math.max(previousContact, quantised)
|
|
231130
|
+
});
|
|
230225
231131
|
}
|
|
230226
231132
|
/**
|
|
230227
231133
|
* Battery cams require an explicit wake before cmd_id 109 will
|
|
@@ -232546,6 +233452,8 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
232546
233452
|
*/
|
|
232547
233453
|
async buildStreamCatalog() {
|
|
232548
233454
|
if (this.cachedStreamDescriptors?.length) return this.withLiveNativeSdp(this.cachedStreamDescriptors);
|
|
233455
|
+
const restored = this.restoreStreamCatalogFromLedger();
|
|
233456
|
+
if (restored) return this.withLiveNativeSdp(restored);
|
|
232549
233457
|
if (this.buildStreamCatalogInFlight) return this.withLiveNativeSdp(await this.buildStreamCatalogInFlight);
|
|
232550
233458
|
const build = this.buildStreamCatalogUncached();
|
|
232551
233459
|
this.buildStreamCatalogInFlight = build;
|
|
@@ -232718,6 +233626,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
232718
233626
|
autoEligible: e.autoEligible
|
|
232719
233627
|
}));
|
|
232720
233628
|
this.cachedStreamDescriptors = descriptors;
|
|
233629
|
+
this.persistStreamCatalogToLedger(descriptors);
|
|
232721
233630
|
return descriptors;
|
|
232722
233631
|
}
|
|
232723
233632
|
/** Profile-stable stream descriptors, cached after the first successful
|
|
@@ -232725,6 +233634,66 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
232725
233634
|
* sleeping battery cam is never woken by a catalog poll. Invalidated by
|
|
232726
233635
|
* `applyStreamProfilePatch` (codec/resolution may change). */
|
|
232727
233636
|
cachedStreamDescriptors;
|
|
233637
|
+
/**
|
|
233638
|
+
* Write the just-built catalog to the durable `stream-catalog` slice, so a
|
|
233639
|
+
* restart with the camera asleep still has descriptors to serve (D173).
|
|
233640
|
+
*
|
|
233641
|
+
* Best-effort by design: the RAM copy is already advanced by the caller, and
|
|
233642
|
+
* losing this write costs one cold catalog after the next restart — never a
|
|
233643
|
+
* wrong catalog. A build that FAILED writes nothing at all and therefore
|
|
233644
|
+
* cannot demote a good stored copy (D49's failure direction).
|
|
233645
|
+
*/
|
|
233646
|
+
persistStreamCatalogToLedger(descriptors) {
|
|
233647
|
+
if (descriptors.length === 0) return;
|
|
233648
|
+
try {
|
|
233649
|
+
const state = {
|
|
233650
|
+
descriptors: [...descriptors],
|
|
233651
|
+
lastFetchedAt: Date.now()
|
|
233652
|
+
};
|
|
233653
|
+
this.runtimeState.setCapState(streamCatalogCapability.name, state);
|
|
233654
|
+
this.ctx.logger.debug("stream catalog persisted to the durable slice", {
|
|
233655
|
+
tags: { deviceId: this.id },
|
|
233656
|
+
meta: { count: descriptors.length }
|
|
233657
|
+
});
|
|
233658
|
+
} catch (err) {
|
|
233659
|
+
this.ctx.logger.debug("stream catalog persist failed — RAM copy stands", {
|
|
233660
|
+
tags: { deviceId: this.id },
|
|
233661
|
+
meta: { error: err instanceof Error ? err.message : String(err) }
|
|
233662
|
+
});
|
|
233663
|
+
}
|
|
233664
|
+
}
|
|
233665
|
+
/**
|
|
233666
|
+
* Rehydrate `cachedStreamDescriptors` from the durable slice. Returns the
|
|
233667
|
+
* restored descriptors, or `null` when there is nothing to restore.
|
|
233668
|
+
*
|
|
233669
|
+
* Logged at `info` when it fires: "these descriptors came from before the
|
|
233670
|
+
* restart" must never be something a reader has to infer (the DurableLedger
|
|
233671
|
+
* contract, D132).
|
|
233672
|
+
*/
|
|
233673
|
+
restoreStreamCatalogFromLedger() {
|
|
233674
|
+
const stored = this.runtimeState.getCapState(streamCatalogCapability.name);
|
|
233675
|
+
const descriptors = stored?.descriptors;
|
|
233676
|
+
if (!descriptors || descriptors.length === 0) return null;
|
|
233677
|
+
this.cachedStreamDescriptors = [...descriptors];
|
|
233678
|
+
this.ctx.logger.info("stream catalog restored from the durable slice (no camera contact)", {
|
|
233679
|
+
tags: { deviceId: this.id },
|
|
233680
|
+
meta: {
|
|
233681
|
+
count: descriptors.length,
|
|
233682
|
+
builtAt: stored?.lastFetchedAt ?? 0,
|
|
233683
|
+
ageMs: Date.now() - (stored?.lastFetchedAt ?? 0),
|
|
233684
|
+
sleeping: this.sleeping
|
|
233685
|
+
}
|
|
233686
|
+
});
|
|
233687
|
+
return this.cachedStreamDescriptors;
|
|
233688
|
+
}
|
|
233689
|
+
/**
|
|
233690
|
+
* How old a RESTORED catalog may get before a natural wake is worth spending
|
|
233691
|
+
* on a re-read. The catalog is profile-stable, so this is not about
|
|
233692
|
+
* freshness — it is the backstop for a profile changed by something that did
|
|
233693
|
+
* not invalidate the cache (a firmware update, an edit made on the Reolink
|
|
233694
|
+
* app). A day is several natural wakes on any camera that is working.
|
|
233695
|
+
*/
|
|
233696
|
+
static CATALOG_REFRESH_ON_WAKE_MS = 1440 * 6e4;
|
|
232728
233697
|
/** Single-flight guard for `buildStreamCatalog`. */
|
|
232729
233698
|
buildStreamCatalogInFlight = null;
|
|
232730
233699
|
/**
|
|
@@ -233187,7 +234156,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
233187
234156
|
auxAccessoryCount: this.auxAccessoryRefs.size
|
|
233188
234157
|
}
|
|
233189
234158
|
});
|
|
233190
|
-
await this.refreshBatteryFromApi().catch(() => {});
|
|
234159
|
+
await this.refreshBatteryFromApi("periodic").catch(() => {});
|
|
233191
234160
|
await this.alignAuxDevicesState("periodic").catch(() => {});
|
|
233192
234161
|
await this.refreshParentSettingsSnapshot().catch(() => {});
|
|
233193
234162
|
} finally {
|
|
@@ -233222,6 +234191,44 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
233222
234191
|
}
|
|
233223
234192
|
}
|
|
233224
234193
|
/**
|
|
234194
|
+
* Is this wake worth spending on a catalog re-read? See
|
|
234195
|
+
* `CATALOG_REFRESH_ON_WAKE_MS`. Held apart from `onWakeTransition` so the
|
|
234196
|
+
* decision is one expression a test can pin.
|
|
234197
|
+
*/
|
|
234198
|
+
shouldRebuildCatalogOnWake() {
|
|
234199
|
+
if (!this.cachedStreamDescriptors?.length) {
|
|
234200
|
+
if (!this.restoreStreamCatalogFromLedger()) return true;
|
|
234201
|
+
}
|
|
234202
|
+
const builtAt = this.runtimeState.getCapState(streamCatalogCapability.name)?.lastFetchedAt ?? 0;
|
|
234203
|
+
if (builtAt <= 0) return true;
|
|
234204
|
+
return Date.now() - builtAt > ReolinkCamera.CATALOG_REFRESH_ON_WAKE_MS;
|
|
234205
|
+
}
|
|
234206
|
+
/**
|
|
234207
|
+
* A PASSIVE proof of reachability just arrived — stamp `battery.lastContactAt`
|
|
234208
|
+
* so `deriveBatteryPresence` can tell "asleep" from "gone" (D173).
|
|
234209
|
+
*
|
|
234210
|
+
* Callable only from paths where the evidence cost us nothing: an inbound
|
|
234211
|
+
* firmware push, an observed wake, a round-trip somebody else's demand
|
|
234212
|
+
* already paid for. Never from a poll issued to answer this question — that
|
|
234213
|
+
* poll is the wake it is trying to detect.
|
|
234214
|
+
*
|
|
234215
|
+
* Quantised to `CONTACT_WRITE_QUANTUM_MS`: the value means "recently", and
|
|
234216
|
+
* writing it at millisecond resolution would put a SQLite commit behind
|
|
234217
|
+
* every Baichuan reply on the hub's busiest write path (the exact cost
|
|
234218
|
+
* `scripts/check-runtime-state-durability.ts` exists to bound).
|
|
234219
|
+
*/
|
|
234220
|
+
markPassiveContact() {
|
|
234221
|
+
if (!this.isBattery) return;
|
|
234222
|
+
const now = Date.now();
|
|
234223
|
+
const quantised = now - now % ReolinkCamera.CONTACT_WRITE_QUANTUM_MS;
|
|
234224
|
+
if (quantised <= (this.state.battery.lastContactAt ?? 0)) return;
|
|
234225
|
+
this.state.battery.lastContactAt = quantised;
|
|
234226
|
+
}
|
|
234227
|
+
/** Write granularity for `battery.lastContactAt` — see `markPassiveContact`.
|
|
234228
|
+
* Bounds the commit rate this field can cost at 12/hour/device, and only
|
|
234229
|
+
* for a device something is actually reaching. */
|
|
234230
|
+
static CONTACT_WRITE_QUANTUM_MS = 5 * 6e4;
|
|
234231
|
+
/**
|
|
233225
234232
|
* Shared wake-transition handler invoked by both the simpleEvent
|
|
233226
234233
|
* `awake` push (canonical fast path) and the sleep poll's
|
|
233227
234234
|
* `sleeping → awake` flip (backstop). Mirrors Scrypted's
|
|
@@ -233246,7 +234253,8 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
233246
234253
|
isBattery: this.isBattery
|
|
233247
234254
|
}
|
|
233248
234255
|
});
|
|
233249
|
-
if (
|
|
234256
|
+
if (this.shouldRebuildCatalogOnWake()) try {
|
|
234257
|
+
this.cachedStreamDescriptors = void 0;
|
|
233250
234258
|
if ((await this.buildStreamCatalog()).length > 0) this.ctx.eventBus.emit(createEvent(EventCategory.StreamParamsChanged, this.eventSource(), { deviceId: this.id }));
|
|
233251
234259
|
} catch (err) {
|
|
233252
234260
|
this.ctx.logger.debug("onWakeTransition: stream catalog build failed — will retry on next wake", {
|
|
@@ -234959,7 +235967,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
234959
235967
|
this.startSleepPoll();
|
|
234960
235968
|
this.startBatteryUpdatePolling();
|
|
234961
235969
|
this.registerBatteryIfSupported();
|
|
234962
|
-
this.refreshBatteryFromApi();
|
|
235970
|
+
this.refreshBatteryFromApi("demand");
|
|
234963
235971
|
} else this.startAlignAuxPolling();
|
|
234964
235972
|
this.resubscribeSimpleEvents(api, "adoptApi").catch((err) => {
|
|
234965
235973
|
this.ctx.logger.debug("Reolink adoptApi: simple-event subscribe failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
@@ -235071,7 +236079,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
235071
236079
|
this.startSleepPoll();
|
|
235072
236080
|
this.startBatteryUpdatePolling();
|
|
235073
236081
|
this.registerBatteryIfSupported();
|
|
235074
|
-
this.refreshBatteryFromApi();
|
|
236082
|
+
this.refreshBatteryFromApi("demand");
|
|
235075
236083
|
}
|
|
235076
236084
|
this.startWatchdogs();
|
|
235077
236085
|
this.probeAndPersistFeatures(api).catch((err) => {
|
|
@@ -235155,6 +236163,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
235155
236163
|
this.lastEventAt = Date.now();
|
|
235156
236164
|
this.consecutiveStaleHealthChecks = 0;
|
|
235157
236165
|
this.nextEventHealthCheckAt = 0;
|
|
236166
|
+
this.markPassiveContact();
|
|
235158
236167
|
const eventSource = this.eventSource();
|
|
235159
236168
|
if (event.type !== "battery") this.ctx.logger.info("Reolink simpleEvent received", { meta: {
|
|
235160
236169
|
type: event.type,
|
|
@@ -235587,6 +236596,9 @@ var ReolinkHub = class ReolinkHub extends BaseDevice {
|
|
|
235587
236596
|
const data = event.data;
|
|
235588
236597
|
if (data.parentDeviceId !== this.id) return;
|
|
235589
236598
|
const cid = typeof data.deviceId === "number" ? data.deviceId : null;
|
|
236599
|
+
if (cid !== null) {
|
|
236600
|
+
for (const [ch, did] of this.channelToDeviceId.entries()) if (did === cid) this.channelToDeviceId.delete(ch);
|
|
236601
|
+
}
|
|
235590
236602
|
this.ctx.logger.info("Reolink Hub: child unregistered externally — refreshing discovery", cid !== null ? { tags: { deviceId: cid } } : {});
|
|
235591
236603
|
this.refreshDiscoveryFromCamera().catch(() => {});
|
|
235592
236604
|
}));
|
|
@@ -235883,7 +236895,6 @@ var ReolinkHub = class ReolinkHub extends BaseDevice {
|
|
|
235883
236895
|
timeoutMs: HUB_DISCOVERY_REFRESH_TIMEOUT_MS
|
|
235884
236896
|
} });
|
|
235885
236897
|
const adoptedByChannel = await this.loadAdoptedChildrenByChannel();
|
|
235886
|
-
this.channelToDeviceId.clear();
|
|
235887
236898
|
for (const [channel, deviceId] of adoptedByChannel) this.channelToDeviceId.set(channel, deviceId);
|
|
235888
236899
|
try {
|
|
235889
236900
|
discovered = (await (await this.ensureApi()).getNvrChannelsSummary({
|
|
@@ -235891,7 +236902,7 @@ var ReolinkHub = class ReolinkHub extends BaseDevice {
|
|
|
235891
236902
|
timeoutMs: HUB_DISCOVERY_REFRESH_TIMEOUT_MS
|
|
235892
236903
|
})).devices.map((d) => {
|
|
235893
236904
|
const childNativeId = computeChildNativeId(this.stableId, d.channel, d.uid);
|
|
235894
|
-
const adoptedDeviceId =
|
|
236905
|
+
const adoptedDeviceId = this.channelToDeviceId.get(d.channel) ?? null;
|
|
235895
236906
|
return {
|
|
235896
236907
|
childNativeId,
|
|
235897
236908
|
name: d.name ?? `Channel ${d.channel}`,
|
|
@@ -236593,21 +237604,31 @@ var AutodetectCache = class {
|
|
|
236593
237604
|
//#endregion
|
|
236594
237605
|
//#region src/email-push-shared.ts
|
|
236595
237606
|
/**
|
|
236596
|
-
* Map the lib's email-push classifier output onto
|
|
236597
|
-
*
|
|
236598
|
-
*
|
|
237607
|
+
* Map the lib's email-push classifier output onto the `ReolinkSimpleEvent`
|
|
237608
|
+
* types the camera should be fed. AI subtypes + motion pass through;
|
|
237609
|
+
* anything unrecognised collapses to plain `motion` so a wake is never
|
|
236599
237610
|
* silently dropped.
|
|
236600
|
-
|
|
236601
|
-
|
|
237611
|
+
*
|
|
237612
|
+
* Returns a LIST rather than a single type because of `doorbell`. The
|
|
237613
|
+
* camera's `handleSimpleEvent` emits `MotionOnMotionChanged` for `motion`
|
|
237614
|
+
* and for every AI class, but the `doorbell` branch emits ONLY
|
|
237615
|
+
* `DoorbellOnPressed` and returns. An email is the sole signal a sleeping
|
|
237616
|
+
* battery camera can send, so a doorbell-classified email mapped to
|
|
237617
|
+
* `doorbell` alone rang the bell and left motion, recording and
|
|
237618
|
+
* notification rules blind — the exact "silently dropped wake" this mapping
|
|
237619
|
+
* exists to prevent. Pairing it with `motion` keeps the doorbell semantic
|
|
237620
|
+
* AND the wake.
|
|
237621
|
+
*/
|
|
237622
|
+
function mapInferredTypeToSimpleEvents(inferred) {
|
|
236602
237623
|
switch (inferred) {
|
|
236603
237624
|
case "people":
|
|
236604
237625
|
case "vehicle":
|
|
236605
237626
|
case "animal":
|
|
236606
237627
|
case "face":
|
|
236607
237628
|
case "package":
|
|
236608
|
-
case "
|
|
236609
|
-
case "
|
|
236610
|
-
default: return "motion";
|
|
237629
|
+
case "motion": return [inferred];
|
|
237630
|
+
case "doorbell": return ["doorbell", "motion"];
|
|
237631
|
+
default: return ["motion"];
|
|
236611
237632
|
}
|
|
236612
237633
|
}
|
|
236613
237634
|
/** Default SMTP listen port. Avoid privileged 25; Reolink firmwares are
|
|
@@ -236763,8 +237784,8 @@ var ReolinkEmailPushServer = class {
|
|
|
236763
237784
|
subject: event.subject.slice(0, 80)
|
|
236764
237785
|
}
|
|
236765
237786
|
});
|
|
236766
|
-
cam.handleSimpleEvent({
|
|
236767
|
-
type
|
|
237787
|
+
for (const type of mapInferredTypeToSimpleEvents(event.inferredType)) cam.handleSimpleEvent({
|
|
237788
|
+
type,
|
|
236768
237789
|
channel: cam.emailPushChannel,
|
|
236769
237790
|
timestamp: event.receivedAtMs
|
|
236770
237791
|
});
|