@camstack/addon-ai 0.4.123 → 0.4.125

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/addon.mjs CHANGED
@@ -5551,7 +5551,7 @@ function number(params) {
5551
5551
  return /* @__PURE__ */ _coercedNumber(ZodNumber, params);
5552
5552
  }
5553
5553
  //#endregion
5554
- //#region ../types/dist/sleep-D_4W7xuQ.mjs
5554
+ //#region ../types/dist/sleep-BXv0ZcRa.mjs
5555
5555
  /**
5556
5556
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5557
5557
  * window to float samples (D455).
@@ -6336,6 +6336,40 @@ var BaseAddon = class {
6336
6336
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6337
6337
  return keys.size > 0 ? projectStore(raw, keys, node) : raw;
6338
6338
  }
6339
+ /**
6340
+ * Whether ONE global key of this addon's store was written, read three-way
6341
+ * (D651). For a question a hydrated view cannot answer: `getGlobalSettings`
6342
+ * reports `value ?? default`, so "the operator chose the default" and "nobody
6343
+ * chose" look the same, and a failed read looks like both. A `perNode` key is
6344
+ * not supported here: its stored name is scoped.
6345
+ */
6346
+ async readStoredGlobalKey(key) {
6347
+ const read = this._ctx?.settings?.readAddonStoreResult;
6348
+ if (read === void 0) return {
6349
+ kind: "unreadable",
6350
+ reason: "three-way-read-unavailable"
6351
+ };
6352
+ let result;
6353
+ try {
6354
+ result = await read.call(this._ctx?.settings);
6355
+ } catch (err) {
6356
+ return {
6357
+ kind: "unreadable",
6358
+ reason: "store-read-failed",
6359
+ error: err instanceof Error ? err.message : String(err)
6360
+ };
6361
+ }
6362
+ if (result.kind === "failed") return {
6363
+ kind: "unreadable",
6364
+ reason: "store-read-failed",
6365
+ error: result.error
6366
+ };
6367
+ if (result.kind === "missing" || !Object.prototype.hasOwnProperty.call(result.value, key)) return { kind: "absent" };
6368
+ return {
6369
+ kind: "present",
6370
+ value: result.value[key]
6371
+ };
6372
+ }
6339
6373
  async updateGlobalSettings(patch, nodeId) {
6340
6374
  const keys = this.perNodeKeys();
6341
6375
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
@@ -9637,6 +9671,43 @@ var LogChannelWindowSchema = object({
9637
9671
  /** `null` = every camera. A non-empty list narrows to those numeric ids. */
9638
9672
  deviceIds: array(number$1().int()).readonly().nullable()
9639
9673
  });
9674
+ var ClipModelMetaSchema = object({
9675
+ /** The paired text encoder's catalog id (the embedding-encoder's text catalog). */
9676
+ textModelId: string().min(1),
9677
+ /** Output dimension of BOTH towers. A vector of any other length is refused. */
9678
+ embeddingDim: number$1().int().positive(),
9679
+ /**
9680
+ * The `vector-store` index this model's vectors live in. ONE feature space
9681
+ * per index: two models share an index only when their vectors are ranked
9682
+ * against each other, which for CLIP means never across families. MobileCLIP
9683
+ * S1 and S2 share `object-clip` for history (separated by the row's
9684
+ * `modelId`); any other model gets its own.
9685
+ */
9686
+ vectorIndex: string().regex(/^object-clip(-[a-z0-9][a-z0-9-]*)?$/),
9687
+ /**
9688
+ * The text encoder's tokenizer, a declared SIBLING file of its onnx. The name
9689
+ * must be unique per tokenizer: every model's siblings land in ONE flat
9690
+ * models directory, so two different tokenizers under the same name would
9691
+ * silently overwrite each other (whichever model downloaded last wins, and
9692
+ * the other one tokenises with the wrong vocabulary).
9693
+ */
9694
+ tokenizerFile: string().min(1),
9695
+ /** Token window the text graph takes (SigLIP2: 64; CLIP BPE: 77). */
9696
+ contextLength: number$1().int().positive(),
9697
+ /** Id the tokenizer pads with. */
9698
+ padId: number$1().int().nonnegative(),
9699
+ /**
9700
+ * The search cosine floor at `strictness: 'loose'` — calibrated per model,
9701
+ * because cosine bands are a property of the model: 0.2 keeps 96% of matched
9702
+ * COCO caption-image pairs on MobileCLIP S1 and 2.7% on SigLIP2.
9703
+ */
9704
+ searchMinScore: number$1().min(0).max(1)
9705
+ });
9706
+ var ClipSearchStrictnessSchema = _enum([
9707
+ "loose",
9708
+ "balanced",
9709
+ "strict"
9710
+ ]);
9640
9711
  var MODEL_FORMATS = [
9641
9712
  "onnx",
9642
9713
  "coreml",
@@ -9665,7 +9736,7 @@ var ModelFormatEntrySchema = object({
9665
9736
  /** Multi-file payload (directory members or sibling files). */
9666
9737
  files: array(string()).readonly().optional(),
9667
9738
  /** Runtime(s) that can use this format. If omitted, inferred from ModelFormat key */
9668
- runtimes: array(_enum(["node", "python"])).readonly().optional()
9739
+ runtimes: array(_enum(["python"])).readonly().optional()
9669
9740
  });
9670
9741
  /**
9671
9742
  * Extra file that must be downloaded alongside the model (e.g., labels JSON, dict.txt).
@@ -9746,10 +9817,17 @@ var ModelCatalogEntrySchema = object({
9746
9817
  inputChannels: number$1().int().positive().optional(),
9747
9818
  labels: array(LabelDefinitionSchema).readonly(),
9748
9819
  inputLayout: _enum(["nchw", "nhwc"]).optional(),
9820
+ /**
9821
+ * `'scrfd'` applies InsightFace's SCRFD input contract, `(x - 127.5) / 128`
9822
+ * (upstream `insightface/model_zoo/scrfd.py`), instead of the historical
9823
+ * plain `/255`. Measured against COCO GT: 188 → 196 faces found on the
9824
+ * `scrfd-2.5g` catalog entry (2026-09-26 model-replacement spike, §2.4-2).
9825
+ */
9749
9826
  inputNormalization: _enum([
9750
9827
  "zero-one",
9751
9828
  "imagenet",
9752
- "none"
9829
+ "none",
9830
+ "scrfd"
9753
9831
  ]).optional(),
9754
9832
  /**
9755
9833
  * The model already applies softmax IN-GRAPH — its raw output is a
@@ -9833,7 +9911,14 @@ var ModelCatalogEntrySchema = object({
9833
9911
  * applies (Frigate / COCO public catalog). Set on a custom model whose raw
9834
9912
  * labels already ARE the CamStack macros (Scrypted identity map).
9835
9913
  */
9836
- classMap: DetectionCatalogClassMapSchema.optional()
9914
+ classMap: DetectionCatalogClassMapSchema.optional(),
9915
+ /**
9916
+ * The model's CLIP feature-space contract (text encoder, dimension, vector
9917
+ * index, token window, search floor) — see `clip-model.ts`. Present ONLY on a
9918
+ * CLIP image encoder; its absence is what "not a CLIP model" means to the
9919
+ * embedding encoder and the semantic-search store (D649).
9920
+ */
9921
+ clip: ClipModelMetaSchema.optional()
9837
9922
  });
9838
9923
  var ConvertTargetSchema = discriminatedUnion("format", [object({
9839
9924
  format: literal("openvino"),
@@ -9851,7 +9936,8 @@ var ModelConvertMetadataSchema = object({
9851
9936
  inputNormalization: _enum([
9852
9937
  "zero-one",
9853
9938
  "imagenet",
9854
- "none"
9939
+ "none",
9940
+ "scrfd"
9855
9941
  ]).optional(),
9856
9942
  preprocessMode: _enum(["letterbox", "resize"]).optional(),
9857
9943
  outputFormat: _enum([
@@ -14050,6 +14136,13 @@ var LinkedDeviceSchema = object({
14050
14136
  features: array(string()),
14051
14137
  producesTrackedEvents: boolean().optional()
14052
14138
  });
14139
+ /**
14140
+ * The `linked-devices` extension slot's editable value (D648): the operator's
14141
+ * pick list, exactly what `_linkedDeviceIds` persists. Tree children are NOT
14142
+ * in it — they are always linked and are not a pick.
14143
+ */
14144
+ var LinkedDevicesSlotValueSchema = object({ deviceIds: array(number$1().int().positive()) });
14145
+ DeviceType.Camera;
14053
14146
  /** One camera's resolved linked set, tagged with the camera it belongs to.
14054
14147
  * The batch answer needs the tag; the single-device answer already has it
14055
14148
  * from the input, which is why `getLinkedDevices` keeps the untagged shape. */
@@ -14575,16 +14668,101 @@ var EmbeddingResultSchema = object({
14575
14668
  embedding: array(number$1()),
14576
14669
  inferenceMs: number$1()
14577
14670
  });
14671
+ /** The two CLIP towers the encoder runs; a crash budget is kept per tower. */
14672
+ var EmbeddingTowerSchema = _enum(["image", "text"]);
14673
+ /**
14674
+ * A tower in the terminal `failed` state (D649, D6): it crashed or failed to
14675
+ * load `crashes` times within `windowMs`, and is refused by name until an
14676
+ * operator `resetFailedModels` or a model change — never on a timer.
14677
+ *
14678
+ * `nodeId` is the node whose tower failed. The state lives in THAT node's
14679
+ * encoder process (in memory — a runner respawn clears it), and one node's
14680
+ * answer says nothing about another's.
14681
+ */
14682
+ var EmbeddingFailedModelSchema = object({
14683
+ modelId: string(),
14684
+ tower: EmbeddingTowerSchema,
14685
+ nodeId: string(),
14686
+ crashes: number$1(),
14687
+ windowMs: number$1(),
14688
+ sinceMs: number$1(),
14689
+ lastReason: string()
14690
+ });
14691
+ /**
14692
+ * A model whose REQUIREMENTS can never be met on this node (D649 round 5):
14693
+ * an id the catalog does not know, a model URL answering 404/410, a declared
14694
+ * sibling (the tokenizer) that is not there. After `attempts` failed builds
14695
+ * it is terminally `requirements-failed`, refused by name until an operator
14696
+ * `resetFailedModels` or a model change — the same exits as a crashed tower.
14697
+ */
14698
+ var EmbeddingFailedRequirementSchema = object({
14699
+ modelId: string(),
14700
+ tower: EmbeddingTowerSchema,
14701
+ nodeId: string(),
14702
+ attempts: number$1(),
14703
+ sinceMs: number$1(),
14704
+ lastReason: string()
14705
+ });
14578
14706
  var EmbeddingInfoSchema = object({
14579
14707
  modelId: string(),
14580
14708
  embeddingDim: number$1(),
14581
- ready: boolean()
14582
- });
14709
+ ready: boolean(),
14710
+ /**
14711
+ * The node that answered. Absent only from an encoder older than D649's
14712
+ * crash budget — whose `failedModels` is then UNKNOWN (D315), never "none".
14713
+ */
14714
+ nodeId: string().optional(),
14715
+ /**
14716
+ * Towers in `failed` on the answering node, each row naming it. `undefined`
14717
+ * means the node could not say (pre-budget encoder); a node that has the
14718
+ * budget always answers an array, empty included.
14719
+ */
14720
+ failedModels: array(EmbeddingFailedModelSchema).optional(),
14721
+ /** Models terminally `requirements-failed` on the answering node; same reading as above. */
14722
+ failedRequirements: array(EmbeddingFailedRequirementSchema).optional()
14723
+ });
14724
+ /**
14725
+ * The THREE codes an encoder refusal can carry (D649, D6). Same shape as
14726
+ * `VECTOR_INDEX_DIM_CONFLICT`: the code rides in the MESSAGE, because an
14727
+ * Error's own properties do not survive the UDS/tRPC hop and its message does,
14728
+ * and both sides go through the helpers below — the encoder builds the
14729
+ * refusal, the live detail plane classifies on it to count refusals per
14730
+ * camera instead of logging one warning per track. The bracketed token
14731
+ * carries the code, the model, the tower and the node so a consumer never
14732
+ * parses prose.
14733
+ *
14734
+ * - `EMBEDDING_MODEL_FAILED`: the tower crashed / failed to load past the crash
14735
+ * budget — terminal until `resetFailedModels` or a model change.
14736
+ * - `EMBEDDING_REQUIREMENTS_UNAVAILABLE`: files or runtime not there right now
14737
+ * (a download or Python that failed, or the cooldown after one) — the next
14738
+ * request past the cooldown tries again.
14739
+ * - `EMBEDDING_REQUIREMENTS_FAILED`: the requirements can never be met (unknown
14740
+ * id, 404/410, missing sibling) and the bounded attempts are spent —
14741
+ * terminal, same exits as a crashed tower.
14742
+ */
14743
+ var EMBEDDING_MODEL_FAILED = "embedding-model-failed";
14744
+ var EMBEDDING_REQUIREMENTS_UNAVAILABLE = "embedding-requirements-unavailable";
14745
+ var EMBEDDING_REQUIREMENTS_FAILED = "embedding-requirements-failed";
14746
+ _enum([
14747
+ EMBEDDING_MODEL_FAILED,
14748
+ EMBEDDING_REQUIREMENTS_UNAVAILABLE,
14749
+ EMBEDDING_REQUIREMENTS_FAILED
14750
+ ]);
14751
+ new RegExp(`\\[(${EMBEDDING_MODEL_FAILED}|${EMBEDDING_REQUIREMENTS_UNAVAILABLE}|${EMBEDDING_REQUIREMENTS_FAILED}) model=([^\\s\\]]+) tower=(image|text) node=([^\\s\\]]+)\\]`);
14583
14752
  method(object({
14584
14753
  crop: _instanceof(Uint8Array),
14585
14754
  width: number$1(),
14586
14755
  height: number$1()
14587
- }), EmbeddingResultSchema, { auth: "admin" }), method(object({ text: string() }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" });
14756
+ }), EmbeddingResultSchema, { auth: "admin" }), method(object({
14757
+ text: string(),
14758
+ modelId: string().min(1).optional()
14759
+ }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" }), method(object({ modelId: string().min(1).optional() }), object({
14760
+ cleared: array(string()),
14761
+ nodeId: string()
14762
+ }), {
14763
+ kind: "mutation",
14764
+ auth: "admin"
14765
+ });
14588
14766
  /**
14589
14767
  * `failure-contribution` — the capability an addon reports its OWN losses
14590
14768
  * through, per camera, with the denominator attached. It stores nothing.
@@ -17337,6 +17515,9 @@ var NcSystemEventKindSchema = _enum([
17337
17515
  "device-battery-normal",
17338
17516
  "device-consumable-low",
17339
17517
  "device-consumable-normal",
17518
+ "device-tank-low",
17519
+ "device-tank-full",
17520
+ "device-tank-normal",
17340
17521
  "stream-online",
17341
17522
  "stream-offline",
17342
17523
  "node-online",
@@ -17374,6 +17555,29 @@ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
17374
17555
  ]);
17375
17556
  NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
17376
17557
  /**
17558
+ * The panel's transitions, as ONE list.
17559
+ *
17560
+ * Named here rather than spelled out at each of the four sites that need them
17561
+ * (the emitter, the intake, the editor group, the combined-notification gate),
17562
+ * because a transition added to the enum and forgotten at one of them is an
17563
+ * alarm state nobody can be notified about. That is exactly what this list
17564
+ * failed to prevent while it held three: `alarm-arming` was the fourth.
17565
+ *
17566
+ * In LIFECYCLE order, which is the order an editor lists them in and the order
17567
+ * a person experiences them — not the order they were added.
17568
+ */
17569
+ var NC_ALARM_SYSTEM_EVENT_KINDS = [
17570
+ "alarm-arm-refused",
17571
+ "alarm-check-failed",
17572
+ "alarm-arming",
17573
+ "alarm-armed",
17574
+ "alarm-pending",
17575
+ "alarm-triggered",
17576
+ "alarm-rearmed",
17577
+ "alarm-sensor-bypass",
17578
+ "alarm-disarmed"
17579
+ ];
17580
+ /**
17377
17581
  * One coherent system-event condition. `kinds` is the required opt-in safety
17378
17582
  * gate; the remaining lists are optional narrowing filters relevant to the
17379
17583
  * selected kinds.
@@ -17407,7 +17611,22 @@ var NcSystemEventConditionSchema = object({
17407
17611
  */
17408
17612
  excludeDeviceIds: array(number$1().int()).min(1).optional(),
17409
17613
  nodeIds: array(string().min(1)).min(1).optional(),
17410
- packageNames: array(string().min(1)).min(1).optional()
17614
+ packageNames: array(string().min(1)).min(1).optional(),
17615
+ /**
17616
+ * At or below this remaining-life %, a consumable is LOW for THIS rule
17617
+ * (D642). Absent = {@link NC_CONSUMABLE_LOW_PERCENT_DEFAULT}; at most
17618
+ * {@link NC_CONSUMABLE_LOW_PERCENT_MAX}, so every episode can recover. Scoped to the
17619
+ * consumable kinds (`systemEventFilterApplies`) and to the device-events
17620
+ * family; ignored on every other kind.
17621
+ *
17622
+ * It is a property of the RULE because the operator decided so: a rule at
17623
+ * 25 must be told about a filter at 20 %, a rule at 10 must not. The hub
17624
+ * keeps one episode per (threshold, device, item) — its own hysteresis, its
17625
+ * own reminder — and a rule hears only the episode judged at ITS threshold,
17626
+ * exactly as an occupancy rule hears only the edge of its own count. A
17627
+ * provider's own `replace` verdict is low at every threshold.
17628
+ */
17629
+ consumableLowPercent: number$1().int().min(1).max(95).optional()
17411
17630
  });
17412
17631
  /** Hard ceiling on a window (24h). A snooze that could not expire would be an
17413
17632
  * outage the operator asked for once and forgot. */
@@ -17425,6 +17644,25 @@ var NcScheduleSchema = object({
17425
17644
  /** Active OUTSIDE the windows (e.g. "only outside business hours"). */
17426
17645
  invert: boolean().optional()
17427
17646
  });
17647
+ /**
17648
+ * How a system-event rule of the `device-events` or `system` family speaks
17649
+ * (D647): at once, per event (`instant`, the only behaviour before D647), or
17650
+ * as a STATE SUMMARY at the end of each window of `schedule`.
17651
+ */
17652
+ var NcSystemEventDeliveryModeSchema = _enum(["instant", "summary"]);
17653
+ /**
17654
+ * `summary`: the rule sends NOTHING per event. When a window of `schedule`
17655
+ * CLOSES, it sends one notification with the current state of its kinds
17656
+ * (low batteries, consumables to replace, devices offline, updates
17657
+ * available, ...), after its own filters. Nothing to report sends nothing.
17658
+ * The schedule is the ordinary `NcSchedule` (weekly windows, IANA timezone,
17659
+ * midnight crossing); the send time is each window's END. Refused on the
17660
+ * `alarm` family, which stays instant (`systemEventDeliveryProblems`).
17661
+ */
17662
+ var NcSystemEventDeliverySchema = discriminatedUnion("mode", [object({ mode: literal("instant") }), object({
17663
+ mode: literal("summary"),
17664
+ schedule: NcScheduleSchema
17665
+ })]);
17428
17666
  /** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
17429
17667
  var NcPlateMatcherSchema = object({
17430
17668
  /**
@@ -17550,6 +17788,16 @@ var NcCrossingSchema = _enum([
17550
17788
  "exit",
17551
17789
  "any"
17552
17790
  ]);
17791
+ /**
17792
+ * Which edge of a BOOLEAN sensor fires a device-event rule (D640).
17793
+ * - `raised` — the sensor went high: water detected, smoke, open, tampered.
17794
+ * - `cleared` — it went back: dry, clear, closed.
17795
+ * - absent — both edges, which is what every rule authored before this did.
17796
+ *
17797
+ * There is no third member for "both": absence already says it, and a value
17798
+ * that means the same as absence is a second way to write one rule.
17799
+ */
17800
+ var NcSensorTransitionSchema = _enum(["raised", "cleared"]);
17553
17801
  /** Admin-zone membership condition (zone IDs as stamped by the ZoneEngine). */
17554
17802
  var NcZoneConditionSchema = object({
17555
17803
  ids: array(string().min(1)).min(1),
@@ -17739,6 +17987,20 @@ var NcConditionsSchema = object({
17739
17987
  scene: NcSceneConditionSchema.optional(),
17740
17988
  /** Device scope — absent = all devices. */
17741
17989
  devices: array(number$1()).optional(),
17990
+ /**
17991
+ * Device EXCLUSION (D641) — "every device except these". Judged on the SAME
17992
+ * subject ids {@link devices} is judged on (the camera, the sensor that
17993
+ * fired, a linked set's sensor and row cameras), so a sensor fanned out per
17994
+ * linked camera is excluded exactly where an include would have tested it.
17995
+ * `min(1)`: an empty exclusion excludes nothing and is written as absent.
17996
+ *
17997
+ * Not for `system-event` rules — those carry their own
17998
+ * `systemEvent.excludeDeviceIds` (D636), and the hub refuses this key there.
17999
+ * Editors present the two lists as ONE field (All | Only these | All except
18000
+ * these); the engine evaluates each independently, so a legacy rule
18001
+ * carrying both still means "these, minus those".
18002
+ */
18003
+ devicesExclude: array(number$1()).min(1).optional(),
17742
18004
  /** Detector class names (any overlap with the record's class set). */
17743
18005
  classes: array(string().min(1)).optional(),
17744
18006
  /** Veto classes — any overlap fails the rule. */
@@ -17872,6 +18134,16 @@ var NcConditionsSchema = object({
17872
18134
  */
17873
18135
  sensorKinds: array(string().min(1)).optional(),
17874
18136
  /**
18137
+ * DEVICE-EVENT only (D640). Fire on one edge of a boolean sensor —
18138
+ * {@link NcSensorTransitionSchema}. Which field of the slice means "raised"
18139
+ * is `@camstack/types` → `notification/sensor-raised.ts`. A reading the
18140
+ * engine cannot place (a kind with no raise, an unreadable slice) PASSES:
18141
+ * the condition fails open towards notifying, never towards silence. Editors
18142
+ * offer it only when every chosen {@link sensorKinds} member has a raise
18143
+ * (`sensorTransitionOffered`), and the hub refuses it on any other delivery.
18144
+ */
18145
+ sensorTransition: NcSensorTransitionSchema.optional(),
18146
+ /**
17875
18147
  * PACKAGE-EVENT only. Which package phase fires the rule — `delivered`
17876
18148
  * (a parked parcel appeared), `picked-up` (it departed), or `both`. Fails
17877
18149
  * when the subject's phase does not match (a subject always carries a phase
@@ -18004,7 +18276,12 @@ var NcMediaPolicySchema = object({
18004
18276
  * the degrade engine, which drops the video and keeps the still.
18005
18277
  */
18006
18278
  clip: boolean().optional(),
18007
- /** Seconds of footage BEFORE / AFTER the event instant. Defaults 3 / 7. */
18279
+ /**
18280
+ * Seconds of footage BEFORE / AFTER the event instant. Absent =
18281
+ * {@link NC_CLIP_PRE_ROLL_DEFAULT_SEC} / {@link NC_CLIP_POST_ROLL_DEFAULT_SEC}
18282
+ * (4 / 6), resolved by the Notification Center at dispatch — deliberately not
18283
+ * a Zod default, so a rule that never chose keeps following the hub's.
18284
+ */
18008
18285
  clipPreRollSec: number$1().int().min(0).max(30).optional(),
18009
18286
  clipPostRollSec: number$1().int().min(0).max(30).optional(),
18010
18287
  /**
@@ -18126,6 +18403,16 @@ var NcRuleInputSchema = object({
18126
18403
  delivery: NcDeliverySchema,
18127
18404
  conditions: NcConditionsSchema.default({}),
18128
18405
  schedule: NcScheduleSchema.optional(),
18406
+ /**
18407
+ * A `device-events` / `system` rule's delivery (D647): absent or `instant`
18408
+ * is a notification per event; `summary` is one state summary per closed
18409
+ * window of its schedule. `.optional()` and never defaulted: absent must
18410
+ * keep meaning what every rule authored before D647 meant, with no
18411
+ * migration. Top-level rather than inside `conditions.systemEvent`, so a
18412
+ * client that does not know it (an older viewer re-sending `conditions`
18413
+ * whole) leaves it standing through the store's patch merge.
18414
+ */
18415
+ systemEventDelivery: NcSystemEventDeliverySchema.optional(),
18129
18416
  /** May be empty when `targetUsers` addresses at least one user — the
18130
18417
  * "at least one addressee" invariant is enforced by the provider, because
18131
18418
  * a cross-field refine here would break `NcRulePatchSchema.partial()`. */
@@ -18354,6 +18641,28 @@ var NcRuleSchema = NcRuleInputSchema.extend({
18354
18641
  */
18355
18642
  disabledTargetIds: array(string()).default([])
18356
18643
  });
18644
+ /** One section of a previewed state summary. `unavailable` = its state could not be read. */
18645
+ var NcStateSummaryPreviewSectionSchema = object({
18646
+ id: string(),
18647
+ status: _enum(["read", "unavailable"]),
18648
+ items: number$1().int().nonnegative(),
18649
+ reason: string().optional()
18650
+ });
18651
+ /**
18652
+ * The summary a rule would send now. `empty` = nothing to report and every
18653
+ * section read: such a summary is NOT sent. `dropped` counts the open states
18654
+ * the rule's own filters (or a camera mute) left out, by reason.
18655
+ * `excludedGroups` names the kind groups selected that have no state to report
18656
+ * (backups & exports).
18657
+ */
18658
+ var NcStateSummaryPreviewSchema = object({
18659
+ empty: boolean(),
18660
+ count: number$1().int().nonnegative(),
18661
+ text: string(),
18662
+ sections: array(NcStateSummaryPreviewSectionSchema),
18663
+ dropped: record(string(), number$1().int().nonnegative()),
18664
+ excludedGroups: array(string())
18665
+ });
18357
18666
  var NcTestResultSchema = object({
18358
18667
  recordId: string(),
18359
18668
  recordKind: _enum([
@@ -18371,9 +18680,29 @@ var NcTestResultSchema = object({
18371
18680
  className: string().optional(),
18372
18681
  label: string().optional()
18373
18682
  });
18374
- /** The five rule kinds, as data. `NcRuleKind` in `notification/rule-kinds.ts`
18375
- * is the same union; the template-vars spec pins the two together. */
18683
+ /** The rule kinds, as data. `NcRuleKind` in `notification/rule-kinds.ts` is the
18684
+ * same union; the template-vars spec pins the two together. `mixed` is DERIVED
18685
+ * (a stored system rule whose kinds span families, D637) and never authored. */
18376
18686
  var NcRuleKindSchema = _enum([
18687
+ "detection",
18688
+ "sensor",
18689
+ "occupancy",
18690
+ "sound",
18691
+ "device-events",
18692
+ "system",
18693
+ "alarm",
18694
+ "mixed"
18695
+ ]);
18696
+ /**
18697
+ * The kinds a SERVED template-variable descriptor may name: the five that
18698
+ * existed before D637, frozen. `getTemplateCatalog` ships `kinds` to every
18699
+ * installed viewer, and a viewer at `@camstack/types` 1.2.25x parses them with a
18700
+ * strict five-member enum — one `device-events` in one descriptor fails the
18701
+ * whole catalog parse. So the WIRE says `system`, and the MATCH widens it:
18702
+ * `templateVarKindApplies` reads a `system` descriptor as applying to every
18703
+ * system rule kind (`device-events`, `system`, `alarm`, `mixed`).
18704
+ */
18705
+ var NcTemplateVarKindSchema = _enum([
18377
18706
  "detection",
18378
18707
  "sensor",
18379
18708
  "occupancy",
@@ -18411,7 +18740,7 @@ var NcTemplateVarGroupSchema = _enum([
18411
18740
  *
18412
18741
  * `families` / `fields` / `kinds` / `deliveries` / `systemEventKinds` say WHERE
18413
18742
  * it has a value; absent = no restriction on that axis. `systemEventKinds` is
18414
- * read only for a `system` rule. `dynamic` declares a FAMILY of names
18743
+ * read only for a system-event rule (any family, or `mixed`). `dynamic` declares a FAMILY of names
18415
18744
  * (`count_<class>`): the descriptor's `name` is the example member.
18416
18745
  */
18417
18746
  var NcTemplateVarDescriptorSchema = object({
@@ -18422,9 +18751,16 @@ var NcTemplateVarDescriptorSchema = object({
18422
18751
  group: NcTemplateVarGroupSchema,
18423
18752
  families: array(NcTemplateFamilySchema).min(1),
18424
18753
  fields: array(NcTemplateFieldSchema).optional(),
18425
- kinds: array(NcRuleKindSchema).optional(),
18754
+ kinds: array(NcTemplateVarKindSchema).optional(),
18426
18755
  deliveries: array(NcDeliverySchema).optional(),
18427
18756
  systemEventKinds: array(NcSystemEventKindSchema).optional(),
18757
+ /**
18758
+ * Which system-event DELIVERY has a value for it (D647). Absent = an
18759
+ * instant row only when the descriptor names `systemEventKinds` (a
18760
+ * per-event fact: a summary row has no single device), and both otherwise.
18761
+ * `['summary']` marks the state-summary vocabulary (`{{summaryText}}`, ...).
18762
+ */
18763
+ systemEventDeliveries: array(NcSystemEventDeliveryModeSchema).optional(),
18428
18764
  dynamic: object({
18429
18765
  prefix: literal("count_"),
18430
18766
  from: literal("classes")
@@ -18437,7 +18773,9 @@ var NcTemplatePreviewInputSchema = object({
18437
18773
  field: NcTemplateFieldSchema,
18438
18774
  kind: NcRuleKindSchema.optional(),
18439
18775
  delivery: NcDeliverySchema.optional(),
18440
- systemEventKinds: array(NcSystemEventKindSchema).optional()
18776
+ systemEventKinds: array(NcSystemEventKindSchema).optional(),
18777
+ /** The rule's system-event delivery (D647); absent = instant. */
18778
+ systemEventDelivery: NcSystemEventDeliveryModeSchema.optional()
18441
18779
  }),
18442
18780
  template: object({
18443
18781
  title: string().max(500).optional(),
@@ -18470,6 +18808,7 @@ var NcConditionDescriptorSchema = object({
18470
18808
  /** Editor widget the UI renders — never hardcode per-condition forms. */
18471
18809
  valueType: _enum([
18472
18810
  "deviceIdList",
18811
+ "deviceIdExcludeList",
18473
18812
  "stringList",
18474
18813
  "number01",
18475
18814
  "number",
@@ -18480,6 +18819,7 @@ var NcConditionDescriptorSchema = object({
18480
18819
  "plateMatcher",
18481
18820
  "packagePhase",
18482
18821
  "crossingSelect",
18822
+ "sensorTransition",
18483
18823
  "polygonDraw",
18484
18824
  "occupancy",
18485
18825
  "audio",
@@ -18630,6 +18970,28 @@ var NcHistoryFilterSchema = object({
18630
18970
  limit: number$1().int().min(1).max(500).default(100)
18631
18971
  });
18632
18972
  /**
18973
+ * Every rule's last run, in one answer.
18974
+ *
18975
+ * A rule ABSENT from `runs` produced no delivery inside `horizonMs` — how far
18976
+ * back this answer looked, in ms before the hub's now. It is the outbox prune
18977
+ * window (7 days by default, operator-configurable), NARROWED when the read hit
18978
+ * its row bound: the answer never claims a window it did not read. `null` means
18979
+ * the operator keeps the outbox forever AND the read reached its end, so absent
18980
+ * means "never on record". A UI derives its "not in the last N days" from this
18981
+ * value, never from a constant — and only when the call ANSWERED (D315).
18982
+ */
18983
+ var NcRuleLastRunsSchema = object({
18984
+ runs: array(object({
18985
+ ruleId: string(),
18986
+ /** Fire time of the newest row (`createdAt`, epoch ms). */
18987
+ lastAt: number$1(),
18988
+ status: NcHistoryStatusSchema,
18989
+ /** The camera/device of that row (a digest row files under its first camera). */
18990
+ deviceId: number$1()
18991
+ })),
18992
+ horizonMs: number$1().nonnegative().nullable()
18993
+ });
18994
+ /**
18633
18995
  * What a snooze covers. Broader scopes win when several overlap, so one window
18634
18996
  * leaves ONE digest rather than a rule snooze and a whole-feed snooze both
18635
18997
  * summarising the same silence.
@@ -18810,6 +19172,14 @@ var NcAlarmModeCoverageSchema = object({
18810
19172
  /** Ids named by the covering rules. A SUBSET when `allDevices` is true. */
18811
19173
  deviceIds: array(number$1().int()),
18812
19174
  /**
19175
+ * D641: the ids NOT covered although `allDevices` is true — every unscoped
19176
+ * covering rule EXCLUDES them (`conditions.devicesExclude`) and no named rule
19177
+ * covers them. Always `[]` when `allDevices` is false. Excluded by the rules,
19178
+ * which is not the same as skipped by a switch: never in `skippedDevices`.
19179
+ * Defaulted so an answer computed before this field parses as "none".
19180
+ */
19181
+ allDevicesExcept: array(number$1().int()).default([]),
19182
+ /**
18813
19183
  * Devices this mode NAMES but cannot actually arm, each with the switch that
18814
19184
  * excludes it.
18815
19185
  *
@@ -18939,13 +19309,17 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
18939
19309
  }), object({ results: array(NcTestResultSchema) }), {
18940
19310
  kind: "mutation",
18941
19311
  auth: "admin"
19312
+ }), method(object({ rule: NcRuleInputSchema }), NcStateSummaryPreviewSchema, {
19313
+ kind: "mutation",
19314
+ auth: "admin",
19315
+ access: "view"
18942
19316
  }), method(object({}), object({
18943
19317
  catalog: array(NcConditionDescriptorSchema),
18944
19318
  taxonomy: NcTaxonomySchema.optional()
18945
19319
  })), method(object({}), object({ vars: array(NcTemplateVarDescriptorSchema) })), method(NcTemplatePreviewInputSchema, NcTemplatePreviewSchema, {
18946
19320
  kind: "mutation",
18947
19321
  access: "view"
18948
- }), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" }), method(object({ artifactId: string().min(1) }), object({ url: string().nullable() }), { auth: "admin" }), method(object({}), object({ snoozes: array(NcSnoozeSchema) }), { caller: "required" }), method(object({ snooze: NcSnoozeInputSchema }), object({ snooze: NcSnoozeSchema }), {
19322
+ }), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" }), method(object({}), NcRuleLastRunsSchema, { auth: "admin" }), method(object({ artifactId: string().min(1) }), object({ url: string().nullable() }), { auth: "admin" }), method(object({}), object({ snoozes: array(NcSnoozeSchema) }), { caller: "required" }), method(object({ snooze: NcSnoozeInputSchema }), object({ snooze: NcSnoozeSchema }), {
18949
19323
  kind: "mutation",
18950
19324
  caller: "required"
18951
19325
  }), method(object({ snoozeId: string() }), object({ success: literal(true) }), {
@@ -19285,758 +19659,282 @@ var OauthIntegrationDescriptorSchema = object({
19285
19659
  });
19286
19660
  method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
19287
19661
  /**
19288
- * Reference to the frame's retained NATIVE surface + the parent crop's placement
19289
- * within the frame, so the executor can re-cut a leaf child ROI at native
19290
- * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
19662
+ * A model choice has a SCOPE, and a scope change has a workflow.
19663
+ *
19664
+ * ## The two scopes
19665
+ *
19666
+ * Almost every pipeline step's model is a **node** question: which build runs
19667
+ * fastest on THIS accelerator. Two nodes may legitimately answer differently —
19668
+ * a Coral runs the tflite SSD, a Mac runs the coreml YOLO — because the answers
19669
+ * are compared against nothing. They produce boxes, and a box is a box.
19670
+ *
19671
+ * Two steps are not like that. `face-embedding` and `clip-embedding` produce
19672
+ * **vectors that land in ONE shared index** (`identity_samples`,
19673
+ * `vec_object_clip`) and are ranked against each other by cosine similarity.
19674
+ * Cosine similarity between two encoders is not a weak signal, it is a
19675
+ * meaningless number — and nothing inside a vector can tell you it happened.
19676
+ * So for those two steps the model is a **cluster** question with exactly one
19677
+ * answer, stored in exactly one row.
19678
+ *
19679
+ * That is the same argument [D52](../../../../docs/decisions/adr-0052.md) makes
19680
+ * for the crop convention (`detail-crop.ts`), one level up: the crop decides
19681
+ * WHAT pixels the encoder sees, this decides WHICH encoder sees them. Both are
19682
+ * cluster-wide for the same reason and neither may become per-node.
19683
+ *
19684
+ * ## Why the registry lives here and not in the step catalog
19685
+ *
19686
+ * The scope itself is declared on the step, in
19687
+ * `detection-pipeline/registry/step-definitions.ts` (`StepDefinition.modelScope`)
19688
+ * — that is where a new step declares what kind of choice its model is. But the
19689
+ * catalog lives inside `addon-pipeline`, and three packages that must NOT
19690
+ * import an addon need to know the set: the orchestrator (which renders and
19691
+ * stores the row), post-analysis (which pins the row for a re-embed pass) and
19692
+ * admin-ui (which mirrors it). So the set is mirrored here, and
19693
+ * `scripts/check-cluster-model-scope.ts` fails the build when the two disagree.
19694
+ * A hand-copied key that stops matching is exactly how a setting silently stops
19695
+ * arriving while both sides still look correct.
19696
+ *
19697
+ * ## The defaults ARE today's behaviour
19698
+ *
19699
+ * {@link DEFAULT_CLUSTER_STEP_MODELS} reproduces the catalog `defaultModelId`
19700
+ * of both steps. Declaring the scope therefore changes nothing on the day it
19701
+ * ships: the cluster row starts out saying what every node was already doing.
19702
+ * Changing it is legitimate — that is what the knob is for — but it invalidates
19703
+ * the stored vectors of that surface, and must be followed by a re-embed pass
19704
+ * (`face-reembed-pass.ts`, `embedding-rebuild.ts`).
19705
+ */
19706
+ /**
19707
+ * Why the orchestrator cannot say which model the operator chose for a
19708
+ * cluster-scoped step (D651).
19709
+ */
19710
+ var CLUSTER_MODEL_CHOICE_UNREADABLE_REASONS = [
19711
+ "owner-not-ready",
19712
+ "store-read-failed",
19713
+ "three-way-read-unavailable",
19714
+ "invalid-stored",
19715
+ "not-cluster-scoped"
19716
+ ];
19717
+ Object.freeze(Object.fromEntries([{
19718
+ stepId: "face-embedding",
19719
+ label: "Face recognition model",
19720
+ defaultModelId: "auraface-r100",
19721
+ indexName: "the enrolled face gallery",
19722
+ options: [
19723
+ {
19724
+ id: "auraface-r100",
19725
+ label: "AuraFace R100"
19726
+ },
19727
+ {
19728
+ id: "arcface-r100",
19729
+ label: "ArcFace (ResNet34)"
19730
+ },
19731
+ {
19732
+ id: "inception-resnet-v1",
19733
+ label: "Inception ResNet V1"
19734
+ }
19735
+ ]
19736
+ }, {
19737
+ stepId: "clip-embedding",
19738
+ label: "Semantic search model",
19739
+ defaultModelId: "mobileclip-s1",
19740
+ indexName: "the object semantic-search index",
19741
+ options: [
19742
+ {
19743
+ id: "mobileclip-s1",
19744
+ label: "MobileCLIP S1"
19745
+ },
19746
+ {
19747
+ id: "mobileclip-s2",
19748
+ label: "MobileCLIP S2"
19749
+ },
19750
+ {
19751
+ id: "siglip2-b16-224",
19752
+ label: "SigLIP2 B/16 (Apache-2.0)"
19753
+ }
19754
+ ]
19755
+ }].map((s) => [s.stepId, s.defaultModelId])));
19756
+ var CLUSTER_STEP_SETTING_FIELDS = [{
19757
+ stepId: "face-embedding",
19758
+ key: "minLandmarkFaceSize",
19759
+ label: "Min face size for recognition (detection px)",
19760
+ description: "Refuse to embed a face smaller than this IN THE DETECTION FRAME. Applies to every node — the enrolled gallery is one index, and two admission floors would fill it from two policies. 0 disables the gate.",
19761
+ type: "slider",
19762
+ min: 0,
19763
+ max: 64,
19764
+ step: 2,
19765
+ default: 24
19766
+ }];
19767
+ function clusterStepSettingKey(stepId, fieldKey) {
19768
+ return `clusterStepSetting:${stepId}:${fieldKey}`;
19769
+ }
19770
+ var ClusterSettingNumberSchema = number$1().finite();
19771
+ function readClusterStepSettings(config) {
19772
+ const out = {};
19773
+ for (const field of CLUSTER_STEP_SETTING_FIELDS) {
19774
+ const parsed = ClusterSettingNumberSchema.safeParse(config[clusterStepSettingKey(field.stepId, field.key)]);
19775
+ const value = parsed.success ? parsed.data : field.default;
19776
+ const existing = out[field.stepId] ?? {};
19777
+ out[field.stepId] = {
19778
+ ...existing,
19779
+ [field.key]: value
19780
+ };
19781
+ }
19782
+ return out;
19783
+ }
19784
+ readClusterStepSettings({});
19785
+ /**
19786
+ * pipeline-analytics — device-scoped wrapper cap. Refines raw
19787
+ * per-frame detections emitted by the pipeline runner into tracked
19788
+ * objects, per-kind event collections (motion / object / audio), and
19789
+ * persisted media. Owns the post-detection domain end-to-end:
19790
+ *
19791
+ * runner emits PipelineInferenceResult
19792
+ * ↓ (event bus)
19793
+ * pipeline-analytics subscriber
19794
+ * ↓ SORT tracker + zone engine + state analyzer + event emitter
19795
+ * → three DB collections (one per kind), one FS media tree, one
19796
+ * unified event emitter (FrameTracked + TrackStarted/Ended +
19797
+ * DetectionEvent on bus)
19798
+ *
19799
+ * Pure subscriber model. No `processFrame` cap method — the runner
19800
+ * already publishes the raw frame on the bus. The cap surface is
19801
+ * only QUERIES + per-device settings, bound on/off via
19802
+ * `device-manager.setWrapperActive`. `defaultActive: true` because
19803
+ * every camera with a detection pipeline wants its raw detections
19804
+ * refined; operators opt out per-device via BindingsTab when needed.
19805
+ *
19806
+ * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
19807
+ * (per-device surface) and `track-trail` caps — see P11 cleanup.
19291
19808
  */
19292
- var NativeCropRefSchema = object({
19293
- /** Handle keying the retained native surface (node-pinned to its owner). */
19294
- handle: FrameHandleSchema,
19295
- /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
19296
- cropFrameSpace: object({
19297
- x: number$1(),
19298
- y: number$1(),
19299
- w: number$1(),
19300
- h: number$1()
19301
- })
19302
- });
19303
- object({
19304
- crop: object({
19305
- left: number$1(),
19306
- top: number$1(),
19307
- width: number$1().positive(),
19308
- height: number$1().positive()
19309
- }).optional(),
19310
- content: object({
19311
- width: number$1().int().positive(),
19312
- height: number$1().int().positive()
19313
- }),
19314
- fit: _enum(["stretch", "contain"]),
19315
- format: _enum([
19316
- "rgb",
19317
- "gray",
19318
- "jpeg"
19319
- ])
19320
- });
19809
+ var TrackStateSchema = _enum([
19810
+ "new",
19811
+ "entered",
19812
+ "left",
19813
+ "moving",
19814
+ "idle"
19815
+ ]);
19816
+ var EventKindSchema = _enum([
19817
+ "motion",
19818
+ "object",
19819
+ "audio"
19820
+ ]);
19321
19821
  /**
19322
- * Process-local frame identity. It is serializable so it can ride an in-process
19323
- * capability call, but `registryId` deliberately prevents resolution in any
19324
- * other process or execution group.
19822
+ * Spatial filter for `listTracks` — the rect + polygon variants of the shared
19823
+ * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
19824
+ * of the camera frame (top-left origin), matching the drawing-plane editor.
19325
19825
  */
19326
- var FrameRefSchema = object({
19327
- registryId: string().min(1),
19328
- id: string().min(1),
19329
- width: number$1().int().positive(),
19330
- height: number$1().int().positive(),
19331
- format: _enum(["rgb", "gray"]),
19332
- timestamp: number$1(),
19333
- capturedAt: number$1().optional()
19334
- });
19335
- var ModelFormatSchema$1 = _enum([
19336
- "onnx",
19337
- "coreml",
19338
- "openvino",
19339
- "tflite",
19340
- "pt",
19341
- "gguf"
19826
+ var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
19827
+ /** Closed icon vocabulary so clients render a known glyph per kind. */
19828
+ var EventKindIconSchema = _enum([
19829
+ "motion",
19830
+ "audio",
19831
+ "person",
19832
+ "vehicle",
19833
+ "animal",
19834
+ "door",
19835
+ "pir",
19836
+ "smoke",
19837
+ "water",
19838
+ "button",
19839
+ "package",
19840
+ "generic"
19342
19841
  ]);
19343
- var PipelineSlotSchema = _enum([
19344
- "detector",
19345
- "cropper",
19346
- "classifier",
19347
- "refiner",
19348
- "audio-classifier"
19842
+ var EventKindCategorySchema = _enum([
19843
+ "motion",
19844
+ "audio",
19845
+ "detection",
19846
+ "sensor",
19847
+ "control",
19848
+ "custom",
19849
+ "package"
19349
19850
  ]);
19350
- var PipelineEngineChoiceSchema = object({
19351
- runtime: _enum(["node", "python"]),
19352
- backend: string(),
19353
- format: ModelFormatSchema$1,
19354
- device: string().optional()
19355
- });
19356
- var AvailableEngineSchema = object({
19357
- engine: PipelineEngineChoiceSchema,
19358
- devices: array(object({
19359
- id: string(),
19360
- label: string(),
19361
- description: string().optional()
19362
- })).readonly(),
19363
- defaultDevice: string()
19364
- });
19365
- var PipelineDefaultStepSchema = lazy(() => object({
19366
- addonId: string(),
19367
- addonName: string(),
19368
- slot: PipelineSlotSchema,
19369
- inputClasses: array(string()).readonly(),
19370
- outputClasses: array(string()).readonly(),
19371
- enabled: boolean(),
19372
- modelId: string(),
19373
- children: array(PipelineDefaultStepSchema).readonly(),
19374
- group: string().optional(),
19375
- settings: record(string(), unknown()).optional()
19376
- }));
19377
- var PipelineTemplateStepSchema = lazy(() => object({
19378
- addonId: string(),
19379
- enabled: boolean(),
19380
- modelId: string(),
19381
- children: array(PipelineTemplateStepSchema).readonly(),
19382
- settings: record(string(), unknown()).optional()
19383
- }));
19384
- var PipelineTemplateSchema$1 = object({
19385
- id: string(),
19386
- name: string(),
19387
- createdAt: string(),
19388
- updatedAt: string(),
19389
- engine: PipelineEngineChoiceSchema,
19390
- steps: array(PipelineTemplateStepSchema).readonly()
19851
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
19852
+ var EventKindLevelSchema = _enum(["macro", "sub"]);
19853
+ var EventKindDescriptorSchema = object({
19854
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
19855
+ kind: string(),
19856
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
19857
+ labelKey: string(),
19858
+ /** English fallback label (kept for clients that don't translate). */
19859
+ label: string(),
19860
+ /** Hex color for timeline/legend rendering. */
19861
+ color: string(),
19862
+ /** Dictionary id → lucide component on the UI side. */
19863
+ iconId: string(),
19864
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
19865
+ icon: EventKindIconSchema,
19866
+ category: EventKindCategorySchema,
19867
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
19868
+ parentKind: string().nullable(),
19869
+ /** Derived from `parentKind`, explicit for the client tree. */
19870
+ level: EventKindLevelSchema,
19871
+ /** Which cap + device contributes this kind. For built-ins the camera
19872
+ * itself; for sensor kinds the LINKED source device. */
19873
+ source: object({
19874
+ capName: string(),
19875
+ deviceId: number$1()
19876
+ })
19391
19877
  });
19392
- var PipelineModelOptionSchema = object({
19393
- id: string(),
19394
- name: string(),
19395
- formats: record(string(), object({
19396
- downloaded: boolean(),
19397
- sizeMB: number$1()
19398
- })),
19399
- group: ModelVariantGroupSchema.optional(),
19400
- legacy: boolean().optional(),
19401
- provider: ModelProviderIdSchema.optional()
19878
+ /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
19879
+ var EventKindsForDeviceSchema = object({
19880
+ deviceId: number$1(),
19881
+ kinds: array(EventKindDescriptorSchema).readonly()
19402
19882
  });
19403
- var ConfigFieldBridge = custom();
19404
- var PipelineAddonSchemaSchema = object({
19883
+ var SensorEventSchema = object({
19405
19884
  id: string(),
19406
- name: string(),
19407
- slot: PipelineSlotSchema,
19408
- inputClasses: array(string()).readonly(),
19409
- outputClasses: array(string()).readonly(),
19410
- childSlots: array(PipelineSlotSchema).readonly(),
19411
- models: array(PipelineModelOptionSchema).readonly(),
19412
- defaultModelId: string(),
19413
- defaultModelIdByFormat: record(string(), string()).optional(),
19414
- enabledByDefault: boolean().optional(),
19415
- backfillIntoExistingOverrides: boolean().optional(),
19416
- defaultConfidence: number$1(),
19417
- group: string().optional(),
19418
- configSchema: array(ConfigFieldBridge).readonly().optional()
19419
- });
19420
- var PipelineSlotSchemaSchema = object({
19421
- id: PipelineSlotSchema,
19422
- label: string(),
19423
- priority: number$1(),
19424
- parentSlot: PipelineSlotSchema.nullable(),
19425
- addons: array(PipelineAddonSchemaSchema).readonly()
19426
- });
19427
- var PipelineSchemaSchema = object({
19428
- availableEngines: array(AvailableEngineSchema).readonly(),
19429
- selectedEngine: PipelineEngineChoiceSchema,
19430
- slots: array(PipelineSlotSchemaSchema).readonly()
19885
+ /** The CAMERA the event is attributed to (a sensor linked to N cameras
19886
+ * yields N rows, one per camera). */
19887
+ deviceId: number$1(),
19888
+ /** The linked sensor device whose state changed. */
19889
+ sourceDeviceId: number$1(),
19890
+ /** Event kind id — matches an `EventKindDescriptor.kind`. */
19891
+ kind: string(),
19892
+ /** Snapshot of the sensor cap's runtime-state slice at the change. */
19893
+ value: record(string(), unknown()).nullable(),
19894
+ timestamp: number$1()
19431
19895
  });
19432
- var EngineProvisioningSchema = object({
19433
- runtimeId: _enum([
19434
- "onnx",
19435
- "openvino",
19436
- "coreml",
19437
- "edgetpu"
19438
- ]).nullable(),
19439
- device: string().nullable(),
19440
- state: _enum([
19441
- "idle",
19442
- "installing",
19443
- "verifying",
19444
- "ready",
19445
- "failed"
19446
- ]),
19447
- progress: number$1().optional(),
19448
- error: string().optional(),
19449
- nextRetryAt: number$1().optional(),
19896
+ /**
19897
+ * One stored sighting on a track's trajectory.
19898
+ *
19899
+ * The array these live in is returned in TIME order (D399) — it is APPENDED in
19900
+ * arrival order, and the two detector passes interleave, so a consumer must not
19901
+ * assume the two are the same on a row written by an older build.
19902
+ */
19903
+ var TrackPositionSchema = object({
19904
+ x: number$1(),
19905
+ y: number$1(),
19906
+ timestamp: number$1(),
19907
+ bbox: BoundingBoxSchema,
19450
19908
  /**
19451
- * Gate A (config-correctness gate at engine change): human-readable
19452
- * config issues surfaced EAGERLY when the node's engine changes — model
19453
- * substitutions ("chose X, running Y") and zero-build steps ("no model
19454
- * has a <format> build"). Additive/optional: informational only, never
19455
- * enforced here — `assertEngineReady` (readiness) still gates inference.
19456
- * Absent/empty when the node-default tree resolves cleanly.
19909
+ * Which detector pass measured this box (D399): `frame` is the full-frame
19910
+ * pass on the analysis raster, `recovery` is the native-resolution
19911
+ * small-subject second pass (D377/D378). Both write into one array, and until
19912
+ * this field existed the only way to tell them apart was that full-frame boxes
19913
+ * are exact multiples of 1.2 while recovery boxes are full-precision floats.
19914
+ * Absent on rows written before D399.
19457
19915
  */
19458
- configIssues: array(string()).optional()
19459
- });
19460
- var PipelineStepInputSchema = lazy(() => object({
19461
- addonId: string(),
19462
- modelId: string().optional(),
19463
- enabled: boolean().default(true),
19464
- children: array(PipelineStepInputSchema).optional(),
19465
- settings: record(string(), unknown()).optional(),
19466
- jumpDeviceKey: string().optional()
19467
- }));
19468
- var ModelSubstitutionSchema = object({
19469
- addonId: string(),
19470
- chosen: string(),
19471
- running: string(),
19472
- format: string()
19473
- });
19474
- var PipelineValidationIssueSchema = object({
19475
- addonId: string(),
19476
- kind: _enum(["unknown-addon", "no-format-build"]),
19477
- detail: string()
19478
- });
19479
- var PipelineValidationResultSchema = object({
19480
- ok: boolean(),
19481
- issues: array(PipelineValidationIssueSchema).readonly(),
19482
- substitutions: array(ModelSubstitutionSchema).readonly(),
19483
- /** The node's `currentEngine.format` this validation ran against. */
19484
- format: string()
19916
+ source: _enum(["frame", "recovery"]).optional(),
19917
+ /** Detection score of this box, so a position can be weighed and not only
19918
+ * plotted. Absent on rows written before D399. */
19919
+ score: number$1().optional()
19485
19920
  });
19486
- var ReferenceImageEntrySchema = object({
19487
- filename: string(),
19488
- stepIds: array(string()).readonly().optional()
19921
+ var TrackSnapshotSchema = object({
19922
+ timestamp: number$1(),
19923
+ position: TrackPositionSchema,
19924
+ /** The snapshot's media row id (D482); resolve via `listTrackMedia({ trackId })`. */
19925
+ mediaId: number$1().int()
19489
19926
  });
19490
- var ReferenceImageBodySchema = object({
19491
- base64: string(),
19492
- filename: string()
19493
- });
19494
- var ReferenceAudioEntrySchema = object({
19495
- filename: string(),
19496
- sizeKb: number$1()
19497
- });
19498
- var ReferenceAudioBodySchema = object({ base64: string() });
19499
- var AudioBackendSchema = object({
19500
- id: string(),
19501
- name: string(),
19502
- description: string(),
19503
- available: boolean(),
19504
- /**
19505
- * Raw classifier labels this backend can emit (e.g. YAMNet's
19506
- * 521-class set or Apple SoundAnalysis's 303-class set). Used by
19507
- * the benchmark UI to populate the `enabledMicroClasses` filter
19508
- * specific to the selected backend without a separate fetch.
19509
- */
19510
- rawLabels: array(string()).readonly().optional()
19511
- });
19512
- var AudioCapabilitiesSchema = object({
19513
- activeBackend: string(),
19514
- availableBackends: array(AudioBackendSchema).readonly(),
19515
- sampleRate: number$1(),
19516
- chunkDurationMs: number$1()
19517
- });
19518
- var DownloadModelResultSchema = object({
19519
- filePath: string(),
19520
- sizeMB: number$1(),
19521
- durationMs: number$1()
19522
- });
19523
- /**
19524
- * Wrapper carrying a single test run's result. Replaces the legacy
19525
- * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
19526
- * canonical `AudioResult` from the Phase 6 output rework: one
19527
- * `AudioDetection` per class above `minScore`, top-N candidates in
19528
- * `debug.alternateLabels['audio-classifier']`, per-source timings in
19529
- * `debug.stepTimings`. The outer `success`/`error` fields stay so the
19530
- * benchmark UI can still report a clean failure when the classifier
19531
- * cap isn't available.
19532
- */
19533
- var AudioTestResultSchema = object({
19534
- success: boolean(),
19535
- error: string().optional(),
19536
- frame: custom().optional()
19537
- });
19538
- var PipelineConfigBridge = custom();
19539
- var ConfigUISchemaBridge = custom();
19540
- var ConfigUISchemaNullableBridge = custom();
19541
- var InferenceCapabilitiesBridge = custom();
19542
- var ModelAvailabilityListBridge = custom();
19543
- var PipelineRunResultBridge = custom();
19544
- method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
19545
- modelId: string(),
19546
- settings: record(string(), unknown()).readonly()
19547
- }))), method(object({ steps: record(string(), object({
19548
- modelId: string(),
19549
- settings: record(string(), unknown()).readonly()
19550
- })) }), object({ success: literal(true) }), {
19551
- kind: "mutation",
19552
- auth: "admin"
19553
- }), method(object({ nodeId: string() }), object({
19554
- success: literal(true),
19555
- clearedDevices: number$1()
19556
- }), {
19557
- kind: "mutation",
19558
- auth: "admin"
19559
- }), method(object({ nodeId: string() }), object({ unhealthy: array(object({
19560
- /** `<backend>:<device>`, e.g. `openvino:gpu`. */
19561
- deviceKey: string(),
19562
- /**
19563
- * `failed` — the per-device restart budget is exhausted; no pool
19564
- * will be spawned until an operator re-arms it or the runner
19565
- * respawns. `backoff` — under budget, waiting out the backoff (or
19566
- * a cached pool observed dead and not yet condemned).
19567
- */
19568
- state: _enum(["failed", "backoff"]),
19569
- /** Epoch ms of the death that produced this state. */
19570
- since: number$1(),
19571
- /** Pool deaths inside the current window. */
19572
- deaths: number$1(),
19573
- /** The last death's message. */
19574
- lastError: string()
19575
- })).readonly() })), method(object({
19576
- nodeId: string(),
19577
- deviceKey: string()
19578
- }), object({ rearmed: boolean() }), {
19579
- kind: "mutation",
19580
- auth: "admin"
19581
- }), method(_void(), PipelineSchemaSchema), method(_void(), array(PipelineDefaultStepSchema).readonly().nullable()), method(_void(), PipelineConfigBridge), method(_void(), ConfigUISchemaBridge), method(object({ steps: array(PipelineStepInputSchema) }), PipelineValidationResultSchema), method(_void(), array(PipelineTemplateSchema$1).readonly()), method(object({
19582
- name: string(),
19583
- steps: array(PipelineTemplateStepSchema).readonly(),
19584
- engine: PipelineEngineChoiceSchema
19585
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
19586
- id: string(),
19587
- name: string().optional(),
19588
- steps: array(PipelineTemplateStepSchema).readonly().optional()
19589
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
19590
- addonId: string(),
19591
- modelId: string(),
19592
- format: ModelFormatSchema$1
19593
- }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
19594
- addonId: string(),
19595
- modelId: string(),
19596
- format: ModelFormatSchema$1
19597
- }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
19598
- engine: PipelineEngineChoiceSchema.optional(),
19599
- steps: array(PipelineStepInputSchema).min(1),
19600
- frame: FrameInputSchema.optional(),
19601
- /**
19602
- * Process-local lazy frame. Valid only when caller and provider resolve
19603
- * in the same execution-group process; split/cross-node callers use
19604
- * `frame`/`image` inline compatibility instead.
19605
- */
19606
- frameRef: FrameRefSchema.optional(),
19607
- /**
19608
- * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
19609
- * the decoded pixels live in. One more member of the one-of
19610
- * frame/frameHandle/image/imageBase64/referenceImage group.
19611
- */
19612
- frameHandle: FrameHandleSchema.optional(),
19613
- imageBase64: string().optional(),
19614
- /**
19615
- * Binary JPEG bytes — preferred over `imageBase64` on internal
19616
- * hops (hub → forked worker via Moleculer MsgPack) because it
19617
- * skips the 33% base64 overhead + the per-call base64 decode on
19618
- * the detection-pipeline worker. Callers can pass either; exactly
19619
- * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
19620
- */
19621
- image: _instanceof(Uint8Array).optional(),
19622
- referenceImage: string().optional(),
19623
- deviceId: number$1().optional(),
19624
- sessionId: string().optional(),
19625
- /**
19626
- * Execution plane. 'full' (default) runs the whole tree — benchmark,
19627
- * reference-image, and detail-subtree calls. 'frame' is the live
19628
- * per-frame dispatch: ONLY root-plane steps run; crop children
19629
- * (inputClasses ≠ null) are skipped and served per-track via
19630
- * pipelineRunner.runDetailSubtree (two-plane design).
19631
- */
19632
- plane: _enum(["full", "frame"]).optional(),
19633
- /**
19634
- * Inference-device selector (Phase 2 multi-device). Format
19635
- * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
19636
- * Omitted ⇒ the runner's default device (current single-engine
19637
- * behaviour). Selects WHICH device pool of the node runs the call.
19638
- */
19639
- deviceKey: string().optional(),
19640
- /**
19641
- * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
19642
- * when the parent crop was resolved from the frame's retained NATIVE
19643
- * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
19644
- * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
19645
- * resolution from that surface — the SAME quality path faces already
19646
- * had — instead of the downscaled parent tile. `handle` keys the native
19647
- * surface (node-pinned to its owner); `cropFrameSpace` is the parent
19648
- * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
19649
- * the executor's crop-normalized child ROI back into frame-normalized
19650
- * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
19651
- * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
19652
- * (today's behaviour on the fallback path).
19653
- */
19654
- nativeCropRef: NativeCropRefSchema.optional()
19655
- }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
19656
- engine: PipelineEngineChoiceSchema.optional(),
19657
- steps: array(PipelineStepInputSchema).min(1),
19658
- frames: array(FrameInputSchema).min(1).max(255),
19659
- deviceId: number$1().optional(),
19660
- sessionId: string().optional(),
19661
- /**
19662
- * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
19663
- * the batch to the Python pool's bench preprocess cache
19664
- * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
19665
- * preprocessed ONCE and every later inference is a pure-inference cache
19666
- * hit — the sustained-throughput run measures inference, not
19667
- * decode+preprocess+infer. Omitted/0 for live frames (all different →
19668
- * full preprocess every call, correct). Fresh per sustained run;
19669
- * released via `uncacheFrame`.
19670
- */
19671
- frameId: number$1().int().nonnegative().optional(),
19672
- /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
19673
- deviceKey: string().optional()
19674
- }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
19675
- data: _instanceof(Uint8Array),
19676
- width: number$1().int().positive(),
19677
- height: number$1().int().positive(),
19678
- format: _enum([
19679
- "rgb",
19680
- "bgr",
19681
- "gray"
19682
- ])
19683
- }), object({
19684
- frameId: number$1(),
19685
- width: number$1(),
19686
- height: number$1()
19687
- }), { kind: "mutation" }), method(object({
19688
- stepId: string(),
19689
- frameId: number$1().int()
19690
- }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number$1().int() }), _void(), { kind: "mutation" }), method(_void(), object({
19691
- batchMode: string(),
19692
- windowMs: number$1(),
19693
- maxBatchSize: number$1(),
19694
- concurrency: number$1()
19695
- })), method(_void(), array(object({
19696
- engineKey: string(),
19697
- engine: PipelineEngineChoiceSchema,
19698
- modelsLoaded: array(string()).readonly(),
19699
- inUseByCameras: array(number$1()).readonly(),
19700
- /**
19701
- * Origin of this resident factory.
19702
- * - `runtime` — main camera-serving engine (no idle TTL).
19703
- * - `warm-override` — benchmark/test override held in the warm
19704
- * cache; auto-disposed after the idle TTL.
19705
- * - `device-pool` — a concurrent per-device pool (Phase 2
19706
- * multi-device, keyed by `deviceKey`) resolved
19707
- * via `resolveDeviceFactory`. Runs alongside the
19708
- * `runtime` engine on a DIFFERENT accelerator
19709
- * (NPU / iGPU / Coral) — this is how the
19710
- * Engines tab shows all pools running at once.
19711
- */
19712
- kind: _enum([
19713
- "runtime",
19714
- "warm-override",
19715
- "device-pool"
19716
- ]),
19717
- /** Native pid of the underlying Python pool (null when no pool). */
19718
- poolPid: number$1().nullable(),
19719
- /** ms since this factory was last used (null when not warm-tracked). */
19720
- idleMs: number$1().nullable(),
19721
- /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
19722
- idleTtlMs: number$1().nullable()
19723
- })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
19724
- kind: "mutation",
19725
- auth: "admin"
19726
- }), method(object({
19727
- engine: PipelineEngineChoiceSchema,
19728
- force: boolean().optional()
19729
- }), object({
19730
- success: boolean(),
19731
- reason: string().optional()
19732
- }), {
19733
- kind: "mutation",
19734
- auth: "admin"
19735
- }), method(_void(), array(ReferenceImageEntrySchema).readonly()), method(object({ filename: string() }), ReferenceImageBodySchema.nullable()), method(_void(), array(ReferenceAudioEntrySchema).readonly()), method(object({ filename: string() }), ReferenceAudioBodySchema.nullable()), method(_void(), AudioCapabilitiesSchema), method(object({
19736
- addonId: string(),
19737
- modelId: string(),
19738
- filename: string().optional(),
19739
- settings: record(string(), unknown()).optional()
19740
- }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
19741
- /**
19742
- * Per-stage gating mode applied to the zones a rule references.
19743
- *
19744
- * - `include`: the rule contributes to a **whitelist** for its stage.
19745
- * When at least one `include` rule fires for a stage, only entities
19746
- * inside one of those zones pass that stage.
19747
- * - `exclude`: the rule contributes to a **blacklist** for its stage.
19748
- * Entities inside one of those zones are dropped at that stage.
19749
- *
19750
- * `monitor`-style observation (count without filtering) is not a rule
19751
- * mode — zones without any matching rule are observed naturally by
19752
- * `zone-analytics` (live snapshot + history), so an "I just want to
19753
- * count, not filter" use case needs no rule at all.
19754
- */
19755
- var ZoneRuleModeEnum = _enum(["include", "exclude"]);
19756
- /**
19757
- * Per-consumer rule that references existing zones (geometry) and
19758
- * defines how a specific pipeline stage should treat them. Each
19759
- * consumer addon owns its own `ZoneRule[]` array in its per-device
19760
- * settings:
19761
- *
19762
- * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
19763
- * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
19764
- * - future: notification rules, audio gating, etc.
19765
- *
19766
- * One rule applies to N zones (`zoneIds[]`) so the operator can
19767
- * express "ignore motion in ALL of {garden, street}" with a single
19768
- * rule. `classFilter` narrows the rule to specific object classes —
19769
- * "drop person detections in the street, but keep cars" is one
19770
- * `exclude` rule with `classFilter: ['person']`.
19771
- *
19772
- * `enabled` is a soft toggle — the operator can keep the rule
19773
- * configured but inert without deleting it.
19774
- */
19775
- var ZoneRuleSchema = object({
19776
- /** Stable rule id — survives edits, used by the UI for diffing. */
19777
- id: string(),
19778
- /** Optional human-readable label rendered in the rule editor. */
19779
- name: string().optional(),
19780
- /** Zones this rule targets. The rule's `mode` applies to ALL
19781
- * listed zones (OR-set: a detection in any one of them counts).
19782
- * At least one zone id required — a rule with no targets is a
19783
- * configuration mistake and the form validator rejects it. */
19784
- zoneIds: array(string()).min(1).readonly(),
19785
- mode: ZoneRuleModeEnum,
19786
- /**
19787
- * Class names this rule applies to. Empty / undefined ⇒ rule
19788
- * applies to every class. Class strings match the `macroClass`
19789
- * field on detections (e.g. `person`, `car`, `dog`).
19790
- */
19791
- classFilter: array(string()).readonly().optional(),
19792
- /**
19793
- * Minimum bbox/mask overlap (0–1) with any of the rule's zones
19794
- * required to consider an entity "in the zone". Defaults to the
19795
- * consumer's stage default when omitted. Kept for back-compat with
19796
- * existing per-rule overrides; new operators pick the value via
19797
- * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
19798
- * set, the lower-level engine reads it as a 0–1 fraction.
19799
- */
19800
- overlapThreshold: number$1().min(0).max(1).optional(),
19801
- /**
19802
- * Operator-friendly version of `overlapThreshold` — the percentage
19803
- * of the detection's bbox that must lie inside the zone for the
19804
- * rule to match. Documented default is 85%; the engine substitutes
19805
- * that when the field is omitted (kept optional so existing rules
19806
- * stored without it stay valid).
19807
- *
19808
- * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
19809
- * rule, the engine prefers `bboxInclusionPct` because it's the
19810
- * field exposed in the UI. Internally both feed the same gate.
19811
- */
19812
- bboxInclusionPct: number$1().min(0).max(100).optional(),
19813
- /**
19814
- * When `true` and a detection has a segmentation mask, use the
19815
- * mask for overlap instead of the bbox. Detection-stage only;
19816
- * motion rules ignore this field.
19817
- */
19818
- preferMask: boolean().optional(),
19819
- /**
19820
- * Soft-toggle: `false` disables the rule without deleting it.
19821
- * Defaults to `true` so operators creating a rule via the UI
19822
- * see it active immediately.
19823
- */
19824
- enabled: boolean().default(true)
19825
- });
19826
- array(ZoneRuleSchema).readonly();
19827
- /**
19828
- * Zone — pure geometry + identity. NO filtering behaviour.
19829
- *
19830
- * Zones describe **where** in the frame the operator wants to flag
19831
- * something; consumer-owned {@link ZoneRule} arrays describe **how**
19832
- * each pipeline stage uses them. Splitting the two means a single
19833
- * polygon "Driveway" can simultaneously back a motion-exclude rule,
19834
- * a detection-include rule on `['car']`, and an occupancy aggregate
19835
- * — without three duplicated polygons.
19836
- *
19837
- * Owned by the orchestrator addon (provider) and mirrored into the
19838
- * `zones` device-state slice on every mutation. Consumers
19839
- * (motion-wasm, pipeline-executor, analytics, admin UI) read either
19840
- * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
19841
- * mirror with `onChanged`).
19842
- *
19843
- * Coordinates are normalised fractions of the frame (0–1) so zones
19844
- * survive resolution changes and stream profile switches.
19845
- *
19846
- * `kind` discriminates between full polygons (closed regions used
19847
- * for intrusion / occupancy filters) and tripwires (open 2-point
19848
- * line segments used for cross events). Onboard / firmware-reported
19849
- * zones (Reolink, ONVIF) are out of scope for now — see the deferred
19850
- * task list.
19851
- */
19852
- var ZoneKindEnum = _enum(["polygon", "tripwire"]);
19853
- /** Polygon vertex in fraction-of-frame coordinates (0–1). */
19854
- var PolygonPointSchema = object({
19855
- x: number$1(),
19856
- y: number$1()
19857
- });
19858
- /** A camera detection zone — pure geometry/identity. */
19859
- var ZoneSchema = object({
19860
- id: string(),
19861
- name: string(),
19862
- kind: ZoneKindEnum.default("polygon"),
19863
- /** Polygon vertices, fraction of frame (0–1). */
19864
- polygon: array(PolygonPointSchema).readonly(),
19865
- /** Visual color for UI rendering. */
19866
- color: string().default("#3b82f6")
19867
- });
19868
- DeviceType.Camera, method(object({ deviceId: number$1() }), array(ZoneSchema).readonly()), method(object({
19869
- deviceId: number$1(),
19870
- zone: ZoneSchema
19871
- }), _void(), {
19872
- kind: "mutation",
19873
- auth: "admin"
19874
- }), method(object({
19875
- deviceId: number$1(),
19876
- zoneId: string()
19877
- }), _void(), {
19878
- kind: "mutation",
19879
- auth: "admin"
19880
- }), method(object({
19881
- deviceId: number$1(),
19882
- zone: ZoneSchema
19883
- }), _void(), {
19884
- kind: "mutation",
19885
- auth: "admin"
19886
- }), object({ zones: array(ZoneSchema).readonly() });
19887
- /**
19888
- * pipeline-analytics — device-scoped wrapper cap. Refines raw
19889
- * per-frame detections emitted by the pipeline runner into tracked
19890
- * objects, per-kind event collections (motion / object / audio), and
19891
- * persisted media. Owns the post-detection domain end-to-end:
19892
- *
19893
- * runner emits PipelineInferenceResult
19894
- * ↓ (event bus)
19895
- * pipeline-analytics subscriber
19896
- * ↓ SORT tracker + zone engine + state analyzer + event emitter
19897
- * → three DB collections (one per kind), one FS media tree, one
19898
- * unified event emitter (FrameTracked + TrackStarted/Ended +
19899
- * DetectionEvent on bus)
19900
- *
19901
- * Pure subscriber model. No `processFrame` cap method — the runner
19902
- * already publishes the raw frame on the bus. The cap surface is
19903
- * only QUERIES + per-device settings, bound on/off via
19904
- * `device-manager.setWrapperActive`. `defaultActive: true` because
19905
- * every camera with a detection pipeline wants its raw detections
19906
- * refined; operators opt out per-device via BindingsTab when needed.
19907
- *
19908
- * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
19909
- * (per-device surface) and `track-trail` caps — see P11 cleanup.
19910
- */
19911
- var TrackStateSchema = _enum([
19912
- "new",
19913
- "entered",
19914
- "left",
19915
- "moving",
19916
- "idle"
19917
- ]);
19918
- var EventKindSchema = _enum([
19919
- "motion",
19920
- "object",
19921
- "audio"
19922
- ]);
19923
- /**
19924
- * Spatial filter for `listTracks` — the rect + polygon variants of the shared
19925
- * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
19926
- * of the camera frame (top-left origin), matching the drawing-plane editor.
19927
- */
19928
- var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
19929
- /** Closed icon vocabulary so clients render a known glyph per kind. */
19930
- var EventKindIconSchema = _enum([
19931
- "motion",
19932
- "audio",
19933
- "person",
19934
- "vehicle",
19935
- "animal",
19936
- "door",
19937
- "pir",
19938
- "smoke",
19939
- "water",
19940
- "button",
19941
- "package",
19942
- "generic"
19943
- ]);
19944
- var EventKindCategorySchema = _enum([
19945
- "motion",
19946
- "audio",
19947
- "detection",
19948
- "sensor",
19949
- "control",
19950
- "custom",
19951
- "package"
19952
- ]);
19953
- /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
19954
- var EventKindLevelSchema = _enum(["macro", "sub"]);
19955
- var EventKindDescriptorSchema = object({
19956
- /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
19957
- kind: string(),
19958
- /** i18n key resolved on the UI side; `label` is the English fallback. */
19959
- labelKey: string(),
19960
- /** English fallback label (kept for clients that don't translate). */
19961
- label: string(),
19962
- /** Hex color for timeline/legend rendering. */
19963
- color: string(),
19964
- /** Dictionary id → lucide component on the UI side. */
19965
- iconId: string(),
19966
- /** Legacy closed-vocab glyph — fallback for `iconId`. */
19967
- icon: EventKindIconSchema,
19968
- category: EventKindCategorySchema,
19969
- /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
19970
- parentKind: string().nullable(),
19971
- /** Derived from `parentKind`, explicit for the client tree. */
19972
- level: EventKindLevelSchema,
19973
- /** Which cap + device contributes this kind. For built-ins the camera
19974
- * itself; for sensor kinds the LINKED source device. */
19975
- source: object({
19976
- capName: string(),
19977
- deviceId: number$1()
19978
- })
19979
- });
19980
- /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
19981
- var EventKindsForDeviceSchema = object({
19982
- deviceId: number$1(),
19983
- kinds: array(EventKindDescriptorSchema).readonly()
19984
- });
19985
- var SensorEventSchema = object({
19986
- id: string(),
19987
- /** The CAMERA the event is attributed to (a sensor linked to N cameras
19988
- * yields N rows, one per camera). */
19989
- deviceId: number$1(),
19990
- /** The linked sensor device whose state changed. */
19991
- sourceDeviceId: number$1(),
19992
- /** Event kind id — matches an `EventKindDescriptor.kind`. */
19993
- kind: string(),
19994
- /** Snapshot of the sensor cap's runtime-state slice at the change. */
19995
- value: record(string(), unknown()).nullable(),
19996
- timestamp: number$1()
19997
- });
19998
- /**
19999
- * One stored sighting on a track's trajectory.
20000
- *
20001
- * The array these live in is returned in TIME order (D399) — it is APPENDED in
20002
- * arrival order, and the two detector passes interleave, so a consumer must not
20003
- * assume the two are the same on a row written by an older build.
20004
- */
20005
- var TrackPositionSchema = object({
20006
- x: number$1(),
20007
- y: number$1(),
20008
- timestamp: number$1(),
20009
- bbox: BoundingBoxSchema,
20010
- /**
20011
- * Which detector pass measured this box (D399): `frame` is the full-frame
20012
- * pass on the analysis raster, `recovery` is the native-resolution
20013
- * small-subject second pass (D377/D378). Both write into one array, and until
20014
- * this field existed the only way to tell them apart was that full-frame boxes
20015
- * are exact multiples of 1.2 while recovery boxes are full-precision floats.
20016
- * Absent on rows written before D399.
20017
- */
20018
- source: _enum(["frame", "recovery"]).optional(),
20019
- /** Detection score of this box, so a position can be weighed and not only
20020
- * plotted. Absent on rows written before D399. */
20021
- score: number$1().optional()
20022
- });
20023
- var TrackSnapshotSchema = object({
20024
- timestamp: number$1(),
20025
- position: TrackPositionSchema,
20026
- /** The snapshot's media row id (D482); resolve via `listTrackMedia({ trackId })`. */
20027
- mediaId: number$1().int()
20028
- });
20029
- /**
20030
- * Normalized 0..1 trajectory envelope (min/max over every position bbox,
20031
- * divided by the track's detection-frame dims), computed at persist time.
20032
- * Absent when the frame dims were unknown when the track was persisted
20033
- * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
20034
- */
20035
- var TrackEnvelopeSchema = object({
20036
- minX: number$1(),
20037
- minY: number$1(),
20038
- maxX: number$1(),
20039
- maxY: number$1()
19927
+ /**
19928
+ * Normalized 0..1 trajectory envelope (min/max over every position bbox,
19929
+ * divided by the track's detection-frame dims), computed at persist time.
19930
+ * Absent when the frame dims were unknown when the track was persisted
19931
+ * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
19932
+ */
19933
+ var TrackEnvelopeSchema = object({
19934
+ minX: number$1(),
19935
+ minY: number$1(),
19936
+ maxX: number$1(),
19937
+ maxY: number$1()
20040
19938
  });
20041
19939
  /**
20042
19940
  * Row projection for track list queries. `full` (default) returns the
@@ -20455,6 +20353,22 @@ var TrackSchema = object({
20455
20353
  * omit it. Render nothing when absent.
20456
20354
  */
20457
20355
  previewMissReason: string().optional(),
20356
+ /**
20357
+ * The ROOT model that produced this track — the `FrameResult.rootModelId` of
20358
+ * the frame it was BORN on (D646). What a later replay compares against, so
20359
+ * "the original model" is named rather than assumed. A birth fact: never
20360
+ * rewritten by a later frame. **Absent ≠ unknown-model**: a row from before
20361
+ * the column, and a track the camera's own detector produced, carry none.
20362
+ */
20363
+ modelId: string().optional(),
20364
+ /**
20365
+ * Size (px) of the detection frame this track's `positions[].bbox` live in —
20366
+ * the frame it was born on, else the camera's latest analysis frame at
20367
+ * persist time. Divide a position by these to normalise it. Absent when the
20368
+ * size was never known.
20369
+ */
20370
+ frameWidth: number$1().optional(),
20371
+ frameHeight: number$1().optional(),
20458
20372
  ...TrackFlagFields,
20459
20373
  ...TrackRetrainFields
20460
20374
  });
@@ -20684,7 +20598,8 @@ var MediaFileKindEnum = _enum([
20684
20598
  "thumbnailSmall",
20685
20599
  "confirmationCrop",
20686
20600
  "debugCrop",
20687
- "sceneFrame"
20601
+ "sceneFrame",
20602
+ "lastSceneFrame"
20688
20603
  ]);
20689
20604
  /**
20690
20605
  * One media row ON THE WIRE: what it is, how big it is, and WHERE ITS BYTES
@@ -21236,7 +21151,23 @@ var SearchObjectEventsInput = object({
21236
21151
  until: number$1().optional(),
21237
21152
  classFilter: string().optional(),
21238
21153
  limit: number$1().default(50),
21239
- minScore: number$1().min(0).max(1).default(.2)
21154
+ /**
21155
+ * An ABSOLUTE cosine floor. Optional since D649: a floor is a property of the
21156
+ * model (0.2 kept 96% of matched pairs on MobileCLIP S1 and 2.7% on SigLIP2),
21157
+ * so an absent one resolves to the searched model's own `searchMinScore`
21158
+ * scaled by `strictness`. A number sent here is honoured verbatim.
21159
+ */
21160
+ minScore: number$1().min(0).max(1).optional(),
21161
+ /** Model-relative floor — see `resolveClipSearchMinScore`. Default `loose`. */
21162
+ strictness: ClipSearchStrictnessSchema.optional(),
21163
+ /**
21164
+ * Search THIS CLIP model's index instead of the cluster row's. Every index a
21165
+ * model ever wrote stays searchable until it is wiped (the MobileCLIP index
21166
+ * through a SigLIP2 cutover and its rollback window). An id with no CLIP
21167
+ * metadata is refused; an id other than the cluster row's is ADMIN-only
21168
+ * (`model-override-requires-admin`).
21169
+ */
21170
+ modelId: string().min(1).optional()
21240
21171
  });
21241
21172
  var TrackCascadeCountsSchema = object({
21242
21173
  /** Persisted track roots deleted (authoritative). */
@@ -21371,7 +21302,41 @@ var RebuildObjectEmbeddingsInput = object({
21371
21302
  * comparable, so wiping and rebuilding is the only way to be sure every vector
21372
21303
  * means the same thing.
21373
21304
  */
21374
- var WipeObjectEmbeddingsResultSchema = object({ deleted: number$1() });
21305
+ var WipeObjectEmbeddingsResultSchema = object({
21306
+ deleted: number$1(),
21307
+ /**
21308
+ * CLIP indexes that could NOT be emptied (unreachable, or refused at their
21309
+ * dimension) — not a clean slate. Additive and optional (D649).
21310
+ */
21311
+ failedIndexes: array(string()).optional()
21312
+ });
21313
+ /**
21314
+ * Why a rebuild did not start, BY NAME — ONE vocabulary for both gates in front
21315
+ * of a pass (D649 over D651). A bare `started: false` read the same for "the
21316
+ * stores are booting" and "the cluster row names a model with no CLIP
21317
+ * metadata", which need different fixes.
21318
+ * - `stores-unavailable` — the analytics stores or the API are not up yet.
21319
+ * - the owner's confirmation of the cluster model (D651, `ClusterPinConfirmer`):
21320
+ * a pass that rewrites an index needs two agreeing reads of the OWNER's
21321
+ * answer (`pipelineOrchestrator.getClusterModelChoice`) — a pass that cannot
21322
+ * name its model does not run (D54):
21323
+ * - the owner's own `unreadable` reasons (`owner-not-ready`,
21324
+ * `store-read-failed`, `three-way-read-unavailable`, `invalid-stored`,
21325
+ * `not-cluster-scoped`);
21326
+ * - `method-unavailable` — the orchestrator predates the method;
21327
+ * - `read-failed` — the call failed or answered something unparseable;
21328
+ * - `reads-disagree` — the two reads named different choices.
21329
+ * - `not-a-clip-model` — the CONFIRMED id has no CLIP metadata, so there is no
21330
+ * index to fill and no dimension to check against (D649).
21331
+ */
21332
+ var RebuildObjectEmbeddingsRefusalSchema = _enum([
21333
+ "stores-unavailable",
21334
+ ...CLUSTER_MODEL_CHOICE_UNREADABLE_REASONS,
21335
+ "method-unavailable",
21336
+ "read-failed",
21337
+ "reads-disagree",
21338
+ "not-a-clip-model"
21339
+ ]);
21375
21340
  /**
21376
21341
  * Acknowledgement that a rebuild STARTED.
21377
21342
  *
@@ -21384,7 +21349,12 @@ var WipeObjectEmbeddingsResultSchema = object({ deleted: number$1() });
21384
21349
  var RebuildObjectEmbeddingsResultSchema = object({
21385
21350
  started: boolean(),
21386
21351
  /** True when a pass was already running; the new request is ignored. */
21387
- alreadyRunning: boolean()
21352
+ alreadyRunning: boolean(),
21353
+ /** Present when the pass refused to start — see `RebuildObjectEmbeddingsRefusalSchema`. */
21354
+ refusal: RebuildObjectEmbeddingsRefusalSchema.optional(),
21355
+ /** The CLIP model the pass pinned, and the index it fills (when it started). */
21356
+ modelId: string().optional(),
21357
+ index: string().optional()
21388
21358
  });
21389
21359
  var RebuildStatusSchema = object({
21390
21360
  running: boolean(),
@@ -21418,7 +21388,11 @@ var RebuildStatusSchema = object({
21418
21388
  startedAtMs: number$1().nullable(),
21419
21389
  finishedAtMs: number$1().nullable(),
21420
21390
  /** Present when the pass ended by throwing. */
21421
- error: string().nullable()
21391
+ error: string().nullable(),
21392
+ /** The CLIP model the current / last pass pinned (D54), `null` before any. */
21393
+ modelId: string().nullable(),
21394
+ /** The index that pass fills — `ClipModelMeta.vectorIndex` of `modelId` (D649). */
21395
+ index: string().nullable()
21422
21396
  });
21423
21397
  /**
21424
21398
  * Acknowledgement that a debug-media reclaim STARTED.
@@ -21461,24 +21435,6 @@ var MediaReclaimStatusSchema = object({
21461
21435
  finishedAtMs: number$1().nullable(),
21462
21436
  error: string().nullable()
21463
21437
  });
21464
- var ReplayFrameInputSchema = object({
21465
- timestamp: number$1(),
21466
- frame: PipelineRunResultBridge
21467
- });
21468
- var RunReplayFrameProcessorResultSchema = object({ tracks: array(object({
21469
- className: string(),
21470
- firstSeenMs: number$1(),
21471
- lastSeenMs: number$1(),
21472
- /** Bbox of the track's FIRST matched detection, pixel-space in the clip's
21473
- * frame — a representative box for the diff's `(className, window, IoU)`
21474
- * pairing (`replay-diff.ts`). A replay does not need the full per-frame
21475
- * trajectory production's `Track.positions` keeps. */
21476
- bbox: BoundingBoxSchema,
21477
- /** How many of the input frames this track matched a real detection on
21478
- * (never a coasted/extrapolated frame) — the replay's own signal for "how
21479
- * solid is this track", cheaper than re-deriving it from a trajectory. */
21480
- framesMatched: number$1().int()
21481
- })).readonly() });
21482
21438
  /**
21483
21439
  * The long-term series a camera produces. A closed union so a typo cannot
21484
21440
  * invent one, and the ONE declaration of it — the addon's `AnalyticsLtsSeries`
@@ -21591,209 +21547,671 @@ DeviceType.Camera, method(object({ deviceId: number$1() }), array(TrackSchema).r
21591
21547
  }), method(object({ deviceId: number$1() }), DiskReconcileCountsSchema, {
21592
21548
  kind: "mutation",
21593
21549
  auth: "admin"
21594
- }), method(object({
21595
- deviceId: number$1(),
21596
- trackIds: array(string()).min(1)
21597
- }), object({
21598
- deleted: number$1().int(),
21599
- failed: array(string()).readonly()
21550
+ }), method(object({
21551
+ deviceId: number$1(),
21552
+ trackIds: array(string()).min(1)
21553
+ }), object({
21554
+ deleted: number$1().int(),
21555
+ failed: array(string()).readonly()
21556
+ }), {
21557
+ kind: "mutation",
21558
+ auth: "admin"
21559
+ }), method(object({
21560
+ /** Log/audit scope only — the trackId is globally unique on its own. */
21561
+ deviceId: number$1(),
21562
+ trackId: string(),
21563
+ flags: TrackFlagsPatchSchema
21564
+ }), TrackFlagsSchema, { kind: "mutation" }), method(ArchivedDebugNoteQueryInputSchema, array(ArchivedDebugNoteSchema).readonly(), { kind: "query" }), method(BirthDecisionQueryInputSchema, array(BirthDecisionRecordSchema).readonly(), { kind: "query" }), method(object({}), EventStoreFootprintSchema, {
21565
+ kind: "query",
21566
+ auth: "admin"
21567
+ }), method(object({ deviceId: number$1().int().optional() }), EventMediaKindBreakdownSchema, {
21568
+ kind: "query",
21569
+ auth: "admin"
21570
+ }), method(object({
21571
+ olderThanMs: number$1(),
21572
+ reason: OpsLogReasonSchema.optional()
21573
+ }), EventPruneCountsSchema, {
21574
+ kind: "mutation",
21575
+ auth: "admin"
21576
+ }), method(object({ deviceId: number$1() }), EventPruneCountsSchema, {
21577
+ kind: "mutation",
21578
+ auth: "admin"
21579
+ }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
21580
+ kind: "mutation",
21581
+ auth: "admin"
21582
+ }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
21583
+ kind: "mutation",
21584
+ auth: "admin"
21585
+ }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
21586
+ kind: "mutation",
21587
+ auth: "admin"
21588
+ }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
21589
+ kind: "mutation",
21590
+ auth: "admin"
21591
+ }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
21592
+ kind: "mutation",
21593
+ auth: "admin"
21594
+ }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
21595
+ kind: "mutation",
21596
+ auth: "admin"
21597
+ }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
21598
+ kind: "query",
21599
+ auth: "admin"
21600
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
21601
+ kind: "query",
21602
+ auth: "admin"
21603
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
21604
+ kind: "mutation",
21605
+ auth: "admin"
21606
+ }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
21607
+ kind: "query",
21608
+ auth: "admin"
21609
+ }), method(MediaReclaimInputSchema, MediaReclaimStartResultSchema, {
21610
+ kind: "mutation",
21611
+ auth: "admin"
21612
+ }), method(object({}), MediaReclaimStatusSchema, {
21613
+ kind: "query",
21614
+ auth: "admin"
21615
+ }), method(object({ deviceIds: array(number$1()).optional() }), TrainingExportSummarySchema, {
21616
+ kind: "query",
21617
+ auth: "admin"
21618
+ }), method(object({ deviceIds: array(number$1()).optional() }), object({ url: string() }), {
21619
+ kind: "query",
21620
+ auth: "admin"
21621
+ }), method(object({
21622
+ /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
21623
+ * `deviceId`, deliberately: `deviceId` would make this device-bound and
21624
+ * route it at one camera's owner, and "every camera" would stop being
21625
+ * expressible at all. */
21626
+ deviceIds: array(number$1()).optional(),
21627
+ limit: number$1().int().min(1).max(500).optional()
21628
+ }), array(RetrainTrackSchema).readonly(), {
21629
+ kind: "query",
21630
+ auth: "admin"
21631
+ }), method(object({ trackId: string() }), RetrainFrameListSchema, {
21632
+ kind: "query",
21633
+ auth: "admin"
21634
+ }), method(object({
21635
+ deviceId: number$1(),
21636
+ trackId: string(),
21637
+ mediaIds: array(number$1().int()).min(1)
21638
+ }), RetrainFrameSelectionSchema, {
21639
+ kind: "mutation",
21640
+ auth: "admin"
21641
+ }), method(object({
21642
+ deviceId: number$1(),
21643
+ trackId: string(),
21644
+ frameId: string()
21645
+ }), object({
21646
+ removed: boolean(),
21647
+ removedAnnotations: number$1().int()
21648
+ }), {
21649
+ kind: "mutation",
21650
+ auth: "admin"
21651
+ }), method(object({ frameId: string() }), object({
21652
+ base64: string(),
21653
+ width: number$1().int(),
21654
+ height: number$1().int()
21655
+ }), {
21656
+ kind: "query",
21657
+ auth: "admin"
21658
+ }), method(object({
21659
+ deviceId: number$1(),
21660
+ trackId: string(),
21661
+ frameId: string(),
21662
+ subject: RetrainAssistSubjectSchema,
21663
+ /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
21664
+ nodeId: string().optional()
21665
+ }), RetrainAssistResultSchema, {
21666
+ kind: "mutation",
21667
+ auth: "admin"
21668
+ }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
21669
+ kind: "query",
21670
+ auth: "admin"
21671
+ }), method(object({
21672
+ deviceId: number$1(),
21673
+ trackId: string(),
21674
+ frameId: string(),
21675
+ annotations: array(RetrainAnnotationDraftSchema)
21676
+ }), array(RetrainAnnotationSchema).readonly(), {
21677
+ kind: "mutation",
21678
+ auth: "admin"
21679
+ }), method(object({
21680
+ deviceId: number$1(),
21681
+ trackId: string()
21682
+ }), RetrainTransitionResultSchema, {
21683
+ kind: "mutation",
21684
+ auth: "admin"
21685
+ }), method(object({
21686
+ deviceId: number$1(),
21687
+ trackId: string()
21688
+ }), RetrainTransitionResultSchema, {
21689
+ kind: "mutation",
21690
+ auth: "admin"
21691
+ }), method(object({ deviceIds: array(number$1()).optional() }), object({ url: string() }), {
21692
+ kind: "query",
21693
+ auth: "admin"
21694
+ }), method(object({
21695
+ /** Which of the three event tables owns the row. */
21696
+ ownerType: EventOwnerTypeSchema,
21697
+ /** The event's rowid in that table (D474: an event id is a number). */
21698
+ eventId: number$1().int(),
21699
+ kind: MediaFileKindEnum.optional(),
21700
+ deviceId: number$1()
21701
+ }), array(MediaFileSchema).readonly()), method(object({
21702
+ trackId: string(),
21703
+ kinds: array(MediaFileKindEnum).optional(),
21704
+ deviceId: number$1()
21705
+ }), array(MediaFileSchema).readonly()), method(object({
21706
+ trackId: string(),
21707
+ deviceId: number$1()
21708
+ }), array(MediaFileInfoSchema).readonly()), method(object({
21709
+ ownerType: EventOwnerTypeSchema,
21710
+ eventId: number$1().int(),
21711
+ deviceId: number$1()
21712
+ }), array(MediaFileInfoSchema).readonly()), method(object({
21713
+ deviceId: number$1(),
21714
+ ownerKind: MediaPresenceOwnerKindSchema,
21715
+ ownerIds: array(string()).max(5e3)
21716
+ }), array(string()).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly(), { caller: "required" }), method(object({}), WipeObjectEmbeddingsResultSchema, {
21717
+ kind: "mutation",
21718
+ auth: "admin"
21719
+ }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
21720
+ kind: "mutation",
21721
+ auth: "admin"
21722
+ }), method(object({}), RebuildStatusSchema), object({
21723
+ deviceId: number$1(),
21724
+ timestamp: number$1(),
21725
+ frameWidth: number$1(),
21726
+ frameHeight: number$1(),
21727
+ detections: array(OverlayDetectionSchema).readonly()
21728
+ }), object({
21729
+ deviceId: number$1(),
21730
+ trackId: string(),
21731
+ className: string()
21732
+ }), object({
21733
+ deviceId: number$1(),
21734
+ trackId: string(),
21735
+ className: string(),
21736
+ durationMs: number$1()
21737
+ }), object({
21738
+ deviceId: number$1(),
21739
+ kind: EventKindSchema,
21740
+ eventId: string(),
21741
+ timestamp: number$1()
21742
+ });
21743
+ /**
21744
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
21745
+ * within the frame, so the executor can re-cut a leaf child ROI at native
21746
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
21747
+ */
21748
+ var NativeCropRefSchema = object({
21749
+ /** Handle keying the retained native surface (node-pinned to its owner). */
21750
+ handle: FrameHandleSchema,
21751
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
21752
+ cropFrameSpace: object({
21753
+ x: number$1(),
21754
+ y: number$1(),
21755
+ w: number$1(),
21756
+ h: number$1()
21757
+ })
21758
+ });
21759
+ object({
21760
+ crop: object({
21761
+ left: number$1(),
21762
+ top: number$1(),
21763
+ width: number$1().positive(),
21764
+ height: number$1().positive()
21765
+ }).optional(),
21766
+ content: object({
21767
+ width: number$1().int().positive(),
21768
+ height: number$1().int().positive()
21769
+ }),
21770
+ fit: _enum(["stretch", "contain"]),
21771
+ format: _enum([
21772
+ "rgb",
21773
+ "gray",
21774
+ "jpeg"
21775
+ ])
21776
+ });
21777
+ /**
21778
+ * Process-local frame identity. It is serializable so it can ride an in-process
21779
+ * capability call, but `registryId` deliberately prevents resolution in any
21780
+ * other process or execution group.
21781
+ */
21782
+ var FrameRefSchema = object({
21783
+ registryId: string().min(1),
21784
+ id: string().min(1),
21785
+ width: number$1().int().positive(),
21786
+ height: number$1().int().positive(),
21787
+ format: _enum(["rgb", "gray"]),
21788
+ timestamp: number$1(),
21789
+ capturedAt: number$1().optional()
21790
+ });
21791
+ var ModelFormatSchema$1 = _enum([
21792
+ "onnx",
21793
+ "coreml",
21794
+ "openvino",
21795
+ "tflite",
21796
+ "pt",
21797
+ "gguf"
21798
+ ]);
21799
+ var PipelineSlotSchema = _enum([
21800
+ "detector",
21801
+ "cropper",
21802
+ "classifier",
21803
+ "refiner",
21804
+ "audio-classifier"
21805
+ ]);
21806
+ var PipelineEngineChoiceSchema = object({
21807
+ runtime: literal("python"),
21808
+ backend: string(),
21809
+ format: ModelFormatSchema$1,
21810
+ device: string().optional()
21811
+ });
21812
+ /**
21813
+ * One pool's resolved provisioning (`getEffectiveTuning`). `numWorkers` is the
21814
+ * knob that lifts a saturated pool (`inference-devices.md`); `concurrency` is
21815
+ * per-worker in-flight requests. `deviceKey` echoes the pool asked about —
21816
+ * `null` for the node-default pool.
21817
+ */
21818
+ var EffectiveTuningSchema = object({
21819
+ deviceKey: string().nullable(),
21820
+ runtime: string(),
21821
+ batchMode: string(),
21822
+ windowMs: number$1(),
21823
+ maxBatchSize: number$1(),
21824
+ concurrency: number$1(),
21825
+ numWorkers: number$1()
21826
+ });
21827
+ var AvailableEngineSchema = object({
21828
+ engine: PipelineEngineChoiceSchema,
21829
+ devices: array(object({
21830
+ id: string(),
21831
+ label: string(),
21832
+ description: string().optional()
21833
+ })).readonly(),
21834
+ defaultDevice: string()
21835
+ });
21836
+ var PipelineDefaultStepSchema = lazy(() => object({
21837
+ addonId: string(),
21838
+ addonName: string(),
21839
+ slot: PipelineSlotSchema,
21840
+ inputClasses: array(string()).readonly(),
21841
+ outputClasses: array(string()).readonly(),
21842
+ enabled: boolean(),
21843
+ modelId: string(),
21844
+ children: array(PipelineDefaultStepSchema).readonly(),
21845
+ group: string().optional(),
21846
+ settings: record(string(), unknown()).optional()
21847
+ }));
21848
+ var PipelineTemplateStepSchema = lazy(() => object({
21849
+ addonId: string(),
21850
+ enabled: boolean(),
21851
+ modelId: string(),
21852
+ children: array(PipelineTemplateStepSchema).readonly(),
21853
+ settings: record(string(), unknown()).optional()
21854
+ }));
21855
+ var PipelineTemplateSchema$1 = object({
21856
+ id: string(),
21857
+ name: string(),
21858
+ createdAt: string(),
21859
+ updatedAt: string(),
21860
+ engine: PipelineEngineChoiceSchema,
21861
+ steps: array(PipelineTemplateStepSchema).readonly()
21862
+ });
21863
+ var PipelineModelOptionSchema = object({
21864
+ id: string(),
21865
+ name: string(),
21866
+ formats: record(string(), object({
21867
+ downloaded: boolean(),
21868
+ sizeMB: number$1()
21869
+ })),
21870
+ group: ModelVariantGroupSchema.optional(),
21871
+ legacy: boolean().optional(),
21872
+ provider: ModelProviderIdSchema.optional()
21873
+ });
21874
+ var ConfigFieldBridge = custom();
21875
+ var PipelineAddonSchemaSchema = object({
21876
+ id: string(),
21877
+ name: string(),
21878
+ slot: PipelineSlotSchema,
21879
+ inputClasses: array(string()).readonly(),
21880
+ outputClasses: array(string()).readonly(),
21881
+ childSlots: array(PipelineSlotSchema).readonly(),
21882
+ models: array(PipelineModelOptionSchema).readonly(),
21883
+ defaultModelId: string(),
21884
+ defaultModelIdByFormat: record(string(), string()).optional(),
21885
+ enabledByDefault: boolean().optional(),
21886
+ backfillIntoExistingOverrides: boolean().optional(),
21887
+ defaultConfidence: number$1(),
21888
+ group: string().optional(),
21889
+ configSchema: array(ConfigFieldBridge).readonly().optional()
21890
+ });
21891
+ var PipelineSlotSchemaSchema = object({
21892
+ id: PipelineSlotSchema,
21893
+ label: string(),
21894
+ priority: number$1(),
21895
+ parentSlot: PipelineSlotSchema.nullable(),
21896
+ addons: array(PipelineAddonSchemaSchema).readonly()
21897
+ });
21898
+ var PipelineSchemaSchema = object({
21899
+ availableEngines: array(AvailableEngineSchema).readonly(),
21900
+ selectedEngine: PipelineEngineChoiceSchema,
21901
+ slots: array(PipelineSlotSchemaSchema).readonly()
21902
+ });
21903
+ var EngineProvisioningSchema = object({
21904
+ runtimeId: _enum([
21905
+ "onnx",
21906
+ "openvino",
21907
+ "coreml",
21908
+ "edgetpu"
21909
+ ]).nullable(),
21910
+ device: string().nullable(),
21911
+ state: _enum([
21912
+ "idle",
21913
+ "installing",
21914
+ "verifying",
21915
+ "ready",
21916
+ "failed"
21917
+ ]),
21918
+ progress: number$1().optional(),
21919
+ error: string().optional(),
21920
+ nextRetryAt: number$1().optional(),
21921
+ /**
21922
+ * Gate A (config-correctness gate at engine change): human-readable
21923
+ * config issues surfaced EAGERLY when the node's engine changes — model
21924
+ * substitutions ("chose X, running Y") and zero-build steps ("no model
21925
+ * has a <format> build"). Additive/optional: informational only, never
21926
+ * enforced here — `assertEngineReady` (readiness) still gates inference.
21927
+ * Absent/empty when the node-default tree resolves cleanly.
21928
+ */
21929
+ configIssues: array(string()).optional()
21930
+ });
21931
+ var PipelineStepInputSchema = lazy(() => object({
21932
+ addonId: string(),
21933
+ modelId: string().optional(),
21934
+ enabled: boolean().default(true),
21935
+ children: array(PipelineStepInputSchema).optional(),
21936
+ settings: record(string(), unknown()).optional(),
21937
+ jumpDeviceKey: string().optional()
21938
+ }));
21939
+ var ModelSubstitutionSchema = object({
21940
+ addonId: string(),
21941
+ chosen: string(),
21942
+ running: string(),
21943
+ format: string()
21944
+ });
21945
+ var PipelineValidationIssueSchema = object({
21946
+ addonId: string(),
21947
+ kind: _enum([
21948
+ "unknown-addon",
21949
+ "no-format-build",
21950
+ "unknown-device"
21951
+ ]),
21952
+ detail: string()
21953
+ });
21954
+ var PipelineValidationResultSchema = object({
21955
+ ok: boolean(),
21956
+ issues: array(PipelineValidationIssueSchema).readonly(),
21957
+ substitutions: array(ModelSubstitutionSchema).readonly(),
21958
+ /** The node's `currentEngine.format` this validation ran against. */
21959
+ format: string()
21960
+ });
21961
+ var ReferenceImageEntrySchema = object({
21962
+ filename: string(),
21963
+ stepIds: array(string()).readonly().optional()
21964
+ });
21965
+ var ReferenceImageBodySchema = object({
21966
+ base64: string(),
21967
+ filename: string()
21968
+ });
21969
+ var ReferenceAudioEntrySchema = object({
21970
+ filename: string(),
21971
+ sizeKb: number$1()
21972
+ });
21973
+ var ReferenceAudioBodySchema = object({ base64: string() });
21974
+ var AudioBackendSchema = object({
21975
+ id: string(),
21976
+ name: string(),
21977
+ description: string(),
21978
+ available: boolean(),
21979
+ /**
21980
+ * Raw classifier labels this backend can emit (e.g. YAMNet's
21981
+ * 521-class set or Apple SoundAnalysis's 303-class set). Used by
21982
+ * the benchmark UI to populate the `enabledMicroClasses` filter
21983
+ * specific to the selected backend without a separate fetch.
21984
+ */
21985
+ rawLabels: array(string()).readonly().optional()
21986
+ });
21987
+ var AudioCapabilitiesSchema = object({
21988
+ activeBackend: string(),
21989
+ availableBackends: array(AudioBackendSchema).readonly(),
21990
+ sampleRate: number$1(),
21991
+ chunkDurationMs: number$1()
21992
+ });
21993
+ var DownloadModelResultSchema = object({
21994
+ filePath: string(),
21995
+ sizeMB: number$1(),
21996
+ durationMs: number$1()
21997
+ });
21998
+ /**
21999
+ * Wrapper carrying a single test run's result. Replaces the legacy
22000
+ * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
22001
+ * canonical `AudioResult` from the Phase 6 output rework: one
22002
+ * `AudioDetection` per class above `minScore`, top-N candidates in
22003
+ * `debug.alternateLabels['audio-classifier']`, per-source timings in
22004
+ * `debug.stepTimings`. The outer `success`/`error` fields stay so the
22005
+ * benchmark UI can still report a clean failure when the classifier
22006
+ * cap isn't available.
22007
+ */
22008
+ var AudioTestResultSchema = object({
22009
+ success: boolean(),
22010
+ error: string().optional(),
22011
+ frame: custom().optional()
22012
+ });
22013
+ var PipelineConfigBridge = custom();
22014
+ var ConfigUISchemaBridge = custom();
22015
+ var ConfigUISchemaNullableBridge = custom();
22016
+ var InferenceCapabilitiesBridge = custom();
22017
+ var ModelAvailabilityListBridge = custom();
22018
+ var PipelineRunResultBridge = custom();
22019
+ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
22020
+ modelId: string(),
22021
+ settings: record(string(), unknown()).readonly()
22022
+ }))), method(object({ steps: record(string(), object({
22023
+ modelId: string(),
22024
+ settings: record(string(), unknown()).readonly()
22025
+ })) }), object({ success: literal(true) }), {
22026
+ kind: "mutation",
22027
+ auth: "admin"
22028
+ }), method(object({ nodeId: string() }), object({
22029
+ success: literal(true),
22030
+ clearedDevices: number$1()
21600
22031
  }), {
21601
22032
  kind: "mutation",
21602
22033
  auth: "admin"
21603
- }), method(object({
21604
- /** Log/audit scope only — the trackId is globally unique on its own. */
21605
- deviceId: number$1(),
21606
- trackId: string(),
21607
- flags: TrackFlagsPatchSchema
21608
- }), TrackFlagsSchema, { kind: "mutation" }), method(ArchivedDebugNoteQueryInputSchema, array(ArchivedDebugNoteSchema).readonly(), { kind: "query" }), method(BirthDecisionQueryInputSchema, array(BirthDecisionRecordSchema).readonly(), { kind: "query" }), method(object({}), EventStoreFootprintSchema, {
21609
- kind: "query",
21610
- auth: "admin"
21611
- }), method(object({ deviceId: number$1().int().optional() }), EventMediaKindBreakdownSchema, {
21612
- kind: "query",
21613
- auth: "admin"
21614
- }), method(object({
21615
- olderThanMs: number$1(),
21616
- reason: OpsLogReasonSchema.optional()
21617
- }), EventPruneCountsSchema, {
21618
- kind: "mutation",
21619
- auth: "admin"
21620
- }), method(object({ deviceId: number$1() }), EventPruneCountsSchema, {
21621
- kind: "mutation",
21622
- auth: "admin"
21623
- }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
21624
- kind: "mutation",
21625
- auth: "admin"
21626
- }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
21627
- kind: "mutation",
21628
- auth: "admin"
21629
- }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
21630
- kind: "mutation",
21631
- auth: "admin"
21632
- }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
21633
- kind: "mutation",
21634
- auth: "admin"
21635
- }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
21636
- kind: "mutation",
21637
- auth: "admin"
21638
- }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
21639
- kind: "mutation",
21640
- auth: "admin"
21641
- }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
21642
- kind: "query",
21643
- auth: "admin"
21644
- }), method(object({}), array(RelocateJobSchema).readonly(), {
21645
- kind: "query",
21646
- auth: "admin"
21647
- }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
21648
- kind: "mutation",
21649
- auth: "admin"
21650
- }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
21651
- kind: "query",
21652
- auth: "admin"
21653
- }), method(MediaReclaimInputSchema, MediaReclaimStartResultSchema, {
22034
+ }), method(object({ nodeId: string() }), object({ unhealthy: array(object({
22035
+ /** `<backend>:<device>`, e.g. `openvino:gpu`. */
22036
+ deviceKey: string(),
22037
+ /**
22038
+ * `failed` — the per-device restart budget is exhausted; no pool
22039
+ * will be spawned until an operator re-arms it or the runner
22040
+ * respawns. `backoff` — under budget, waiting out the backoff (or
22041
+ * a cached pool observed dead and not yet condemned).
22042
+ */
22043
+ state: _enum(["failed", "backoff"]),
22044
+ /** Epoch ms of the death that produced this state. */
22045
+ since: number$1(),
22046
+ /** Pool deaths inside the current window. */
22047
+ deaths: number$1(),
22048
+ /** The last death's message. */
22049
+ lastError: string()
22050
+ })).readonly() })), method(object({
22051
+ nodeId: string(),
22052
+ deviceKey: string()
22053
+ }), object({ rearmed: boolean() }), {
21654
22054
  kind: "mutation",
21655
22055
  auth: "admin"
21656
- }), method(object({}), MediaReclaimStatusSchema, {
21657
- kind: "query",
21658
- auth: "admin"
21659
- }), method(object({ deviceIds: array(number$1()).optional() }), TrainingExportSummarySchema, {
21660
- kind: "query",
21661
- auth: "admin"
21662
- }), method(object({ deviceIds: array(number$1()).optional() }), object({ url: string() }), {
21663
- kind: "query",
21664
- auth: "admin"
21665
- }), method(object({
21666
- /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
21667
- * `deviceId`, deliberately: `deviceId` would make this device-bound and
21668
- * route it at one camera's owner, and "every camera" would stop being
21669
- * expressible at all. */
21670
- deviceIds: array(number$1()).optional(),
21671
- limit: number$1().int().min(1).max(500).optional()
21672
- }), array(RetrainTrackSchema).readonly(), {
21673
- kind: "query",
21674
- auth: "admin"
21675
- }), method(object({ trackId: string() }), RetrainFrameListSchema, {
21676
- kind: "query",
21677
- auth: "admin"
21678
- }), method(object({
21679
- deviceId: number$1(),
21680
- trackId: string(),
21681
- mediaIds: array(number$1().int()).min(1)
21682
- }), RetrainFrameSelectionSchema, {
22056
+ }), method(_void(), PipelineSchemaSchema), method(_void(), array(PipelineDefaultStepSchema).readonly().nullable()), method(_void(), PipelineConfigBridge), method(_void(), ConfigUISchemaBridge), method(object({
22057
+ steps: array(PipelineStepInputSchema),
22058
+ deviceKey: string().optional()
22059
+ }), PipelineValidationResultSchema), method(_void(), array(PipelineTemplateSchema$1).readonly()), method(object({
22060
+ name: string(),
22061
+ steps: array(PipelineTemplateStepSchema).readonly(),
22062
+ engine: PipelineEngineChoiceSchema
22063
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
22064
+ id: string(),
22065
+ name: string().optional(),
22066
+ steps: array(PipelineTemplateStepSchema).readonly().optional()
22067
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
22068
+ addonId: string(),
22069
+ modelId: string(),
22070
+ format: ModelFormatSchema$1
22071
+ }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
22072
+ addonId: string(),
22073
+ modelId: string(),
22074
+ format: ModelFormatSchema$1
22075
+ }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
22076
+ steps: array(PipelineStepInputSchema).min(1),
22077
+ frame: FrameInputSchema.optional(),
22078
+ /**
22079
+ * Process-local lazy frame. Valid only when caller and provider resolve
22080
+ * in the same execution-group process; split/cross-node callers use
22081
+ * `frame`/`image` inline compatibility instead.
22082
+ */
22083
+ frameRef: FrameRefSchema.optional(),
22084
+ /**
22085
+ * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
22086
+ * the decoded pixels live in. One more member of the one-of
22087
+ * frame/frameHandle/image/imageBase64/referenceImage group.
22088
+ */
22089
+ frameHandle: FrameHandleSchema.optional(),
22090
+ imageBase64: string().optional(),
22091
+ /**
22092
+ * Binary JPEG bytes — preferred over `imageBase64` on internal
22093
+ * hops (hub → forked worker via Moleculer MsgPack) because it
22094
+ * skips the 33% base64 overhead + the per-call base64 decode on
22095
+ * the detection-pipeline worker. Callers can pass either; exactly
22096
+ * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
22097
+ */
22098
+ image: _instanceof(Uint8Array).optional(),
22099
+ referenceImage: string().optional(),
22100
+ deviceId: number$1().optional(),
22101
+ sessionId: string().optional(),
22102
+ /**
22103
+ * Execution plane. 'full' (default) runs the whole tree — benchmark,
22104
+ * reference-image, and detail-subtree calls. 'frame' is the live
22105
+ * per-frame dispatch: ONLY root-plane steps run; crop children
22106
+ * (inputClasses ≠ null) are skipped and served per-track via
22107
+ * pipelineRunner.runDetailSubtree (two-plane design).
22108
+ */
22109
+ plane: _enum(["full", "frame"]).optional(),
22110
+ /**
22111
+ * Inference-device selector (Phase 2 multi-device). Format
22112
+ * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
22113
+ * Omitted ⇒ the runner's default device (current single-engine
22114
+ * behaviour). Selects WHICH device pool of the node runs the call.
22115
+ */
22116
+ deviceKey: string().optional(),
22117
+ /**
22118
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
22119
+ * when the parent crop was resolved from the frame's retained NATIVE
22120
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
22121
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
22122
+ * resolution from that surface — the SAME quality path faces already
22123
+ * had — instead of the downscaled parent tile. `handle` keys the native
22124
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
22125
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
22126
+ * the executor's crop-normalized child ROI back into frame-normalized
22127
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
22128
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
22129
+ * (today's behaviour on the fallback path).
22130
+ */
22131
+ nativeCropRef: NativeCropRefSchema.optional(),
22132
+ /**
22133
+ * Offline REPLAY of stored media for `deviceId` (D56, D646): the
22134
+ * camera's zone gate and overrides apply as live, every executing
22135
+ * step runs EXACTLY the model it names on the `deviceKey` pool it
22136
+ * names or the call refuses (`model-not-servable` /
22137
+ * `device-not-servable`), and nothing reaches the camera's live
22138
+ * trace stream. Absent ⇒ unchanged behaviour.
22139
+ */
22140
+ replay: literal(true).optional()
22141
+ }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
22142
+ steps: array(PipelineStepInputSchema).min(1),
22143
+ frames: array(FrameInputSchema).min(1).max(255),
22144
+ deviceId: number$1().optional(),
22145
+ sessionId: string().optional(),
22146
+ /**
22147
+ * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
22148
+ * the batch to the Python pool's bench preprocess cache
22149
+ * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
22150
+ * preprocessed ONCE and every later inference is a pure-inference cache
22151
+ * hit — the sustained-throughput run measures inference, not
22152
+ * decode+preprocess+infer. Omitted/0 for live frames (all different →
22153
+ * full preprocess every call, correct). Fresh per sustained run;
22154
+ * released via `uncacheFrame`.
22155
+ */
22156
+ frameId: number$1().int().nonnegative().optional(),
22157
+ /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
22158
+ deviceKey: string().optional()
22159
+ }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
22160
+ data: _instanceof(Uint8Array),
22161
+ width: number$1().int().positive(),
22162
+ height: number$1().int().positive(),
22163
+ format: _enum([
22164
+ "rgb",
22165
+ "bgr",
22166
+ "gray"
22167
+ ])
22168
+ }), object({
22169
+ frameId: number$1(),
22170
+ width: number$1(),
22171
+ height: number$1()
22172
+ }), { kind: "mutation" }), method(object({
22173
+ stepId: string(),
22174
+ frameId: number$1().int()
22175
+ }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number$1().int() }), _void(), { kind: "mutation" }), method(object({ deviceKey: string().optional() }), EffectiveTuningSchema), method(_void(), array(object({
22176
+ engineKey: string(),
22177
+ engine: PipelineEngineChoiceSchema,
22178
+ modelsLoaded: array(string()).readonly(),
22179
+ inUseByCameras: array(number$1()).readonly(),
22180
+ /**
22181
+ * Origin of this resident factory.
22182
+ * - `runtime` — main camera-serving engine (no idle TTL).
22183
+ * - `device-pool` — a concurrent per-device pool (Phase 2
22184
+ * multi-device, keyed by `deviceKey`) resolved
22185
+ * via `resolveDeviceFactory`. Runs alongside the
22186
+ * `runtime` engine on a DIFFERENT accelerator
22187
+ * (NPU / iGPU / Coral) — this is how the
22188
+ * Engines tab shows all pools running at once.
22189
+ */
22190
+ kind: _enum(["runtime", "device-pool"]),
22191
+ /** Native pid of the underlying Python pool (null when no pool). */
22192
+ poolPid: number$1().nullable(),
22193
+ /** ms since this factory was last used (null when not warm-tracked). */
22194
+ idleMs: number$1().nullable(),
22195
+ /** Idle TTL after which the factory self-evicts (null when not applicable). */
22196
+ idleTtlMs: number$1().nullable()
22197
+ })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
21683
22198
  kind: "mutation",
21684
22199
  auth: "admin"
21685
22200
  }), method(object({
21686
- deviceId: number$1(),
21687
- trackId: string(),
21688
- frameId: string()
22201
+ engine: PipelineEngineChoiceSchema,
22202
+ force: boolean().optional()
21689
22203
  }), object({
21690
- removed: boolean(),
21691
- removedAnnotations: number$1().int()
21692
- }), {
21693
- kind: "mutation",
21694
- auth: "admin"
21695
- }), method(object({ frameId: string() }), object({
21696
- base64: string(),
21697
- width: number$1().int(),
21698
- height: number$1().int()
22204
+ success: boolean(),
22205
+ reason: string().optional()
21699
22206
  }), {
21700
- kind: "query",
21701
- auth: "admin"
21702
- }), method(object({
21703
- deviceId: number$1(),
21704
- trackId: string(),
21705
- frameId: string(),
21706
- subject: RetrainAssistSubjectSchema,
21707
- /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
21708
- nodeId: string().optional()
21709
- }), RetrainAssistResultSchema, {
21710
- kind: "mutation",
21711
- auth: "admin"
21712
- }), method(object({
21713
- deviceId: number$1(),
21714
- source: DetectionSourceSchema,
21715
- zones: array(ZoneSchema).readonly().optional(),
21716
- detectionRules: array(ZoneRuleSchema).readonly().optional(),
21717
- zoneMembershipMinOverlap: number$1().min(0).max(1).optional(),
21718
- frames: array(ReplayFrameInputSchema).min(1)
21719
- }), RunReplayFrameProcessorResultSchema, {
21720
- kind: "mutation",
21721
- auth: "admin"
21722
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
21723
- kind: "query",
21724
- auth: "admin"
21725
- }), method(object({
21726
- deviceId: number$1(),
21727
- trackId: string(),
21728
- frameId: string(),
21729
- annotations: array(RetrainAnnotationDraftSchema)
21730
- }), array(RetrainAnnotationSchema).readonly(), {
21731
- kind: "mutation",
21732
- auth: "admin"
21733
- }), method(object({
21734
- deviceId: number$1(),
21735
- trackId: string()
21736
- }), RetrainTransitionResultSchema, {
21737
- kind: "mutation",
21738
- auth: "admin"
21739
- }), method(object({
21740
- deviceId: number$1(),
21741
- trackId: string()
21742
- }), RetrainTransitionResultSchema, {
21743
- kind: "mutation",
21744
- auth: "admin"
21745
- }), method(object({ deviceIds: array(number$1()).optional() }), object({ url: string() }), {
21746
- kind: "query",
21747
- auth: "admin"
21748
- }), method(object({
21749
- /** Which of the three event tables owns the row. */
21750
- ownerType: EventOwnerTypeSchema,
21751
- /** The event's rowid in that table (D474: an event id is a number). */
21752
- eventId: number$1().int(),
21753
- kind: MediaFileKindEnum.optional(),
21754
- deviceId: number$1()
21755
- }), array(MediaFileSchema).readonly()), method(object({
21756
- trackId: string(),
21757
- kinds: array(MediaFileKindEnum).optional(),
21758
- deviceId: number$1()
21759
- }), array(MediaFileSchema).readonly()), method(object({
21760
- trackId: string(),
21761
- deviceId: number$1()
21762
- }), array(MediaFileInfoSchema).readonly()), method(object({
21763
- ownerType: EventOwnerTypeSchema,
21764
- eventId: number$1().int(),
21765
- deviceId: number$1()
21766
- }), array(MediaFileInfoSchema).readonly()), method(object({
21767
- deviceId: number$1(),
21768
- ownerKind: MediaPresenceOwnerKindSchema,
21769
- ownerIds: array(string()).max(5e3)
21770
- }), array(string()).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
21771
22207
  kind: "mutation",
21772
22208
  auth: "admin"
21773
- }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
21774
- kind: "mutation",
21775
- auth: "admin"
21776
- }), method(object({}), RebuildStatusSchema), object({
21777
- deviceId: number$1(),
21778
- timestamp: number$1(),
21779
- frameWidth: number$1(),
21780
- frameHeight: number$1(),
21781
- detections: array(OverlayDetectionSchema).readonly()
21782
- }), object({
21783
- deviceId: number$1(),
21784
- trackId: string(),
21785
- className: string()
21786
- }), object({
21787
- deviceId: number$1(),
21788
- trackId: string(),
21789
- className: string(),
21790
- durationMs: number$1()
21791
- }), object({
21792
- deviceId: number$1(),
21793
- kind: EventKindSchema,
21794
- eventId: string(),
21795
- timestamp: number$1()
21796
- });
22209
+ }), method(_void(), array(ReferenceImageEntrySchema).readonly()), method(object({ filename: string() }), ReferenceImageBodySchema.nullable()), method(_void(), array(ReferenceAudioEntrySchema).readonly()), method(object({ filename: string() }), ReferenceAudioBodySchema.nullable()), method(_void(), AudioCapabilitiesSchema), method(object({
22210
+ addonId: string(),
22211
+ modelId: string(),
22212
+ filename: string().optional(),
22213
+ settings: record(string(), unknown()).optional()
22214
+ }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
21797
22215
  object({
21798
22216
  activeCameras: number$1(),
21799
22217
  throttledCameras: number$1(),
@@ -21819,6 +22237,66 @@ var CameraMetricsSchema = object({
21819
22237
  });
21820
22238
  var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number$1() });
21821
22239
  /**
22240
+ * Zone — pure geometry + identity. NO filtering behaviour.
22241
+ *
22242
+ * Zones describe **where** in the frame the operator wants to flag
22243
+ * something; consumer-owned {@link ZoneRule} arrays describe **how**
22244
+ * each pipeline stage uses them. Splitting the two means a single
22245
+ * polygon "Driveway" can simultaneously back a motion-exclude rule,
22246
+ * a detection-include rule on `['car']`, and an occupancy aggregate
22247
+ * — without three duplicated polygons.
22248
+ *
22249
+ * Owned by the orchestrator addon (provider) and mirrored into the
22250
+ * `zones` device-state slice on every mutation. Consumers
22251
+ * (motion-wasm, pipeline-executor, analytics, admin UI) read either
22252
+ * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
22253
+ * mirror with `onChanged`).
22254
+ *
22255
+ * Coordinates are normalised fractions of the frame (0–1) so zones
22256
+ * survive resolution changes and stream profile switches.
22257
+ *
22258
+ * `kind` discriminates between full polygons (closed regions used
22259
+ * for intrusion / occupancy filters) and tripwires (open 2-point
22260
+ * line segments used for cross events). Onboard / firmware-reported
22261
+ * zones (Reolink, ONVIF) are out of scope for now — see the deferred
22262
+ * task list.
22263
+ */
22264
+ var ZoneKindEnum = _enum(["polygon", "tripwire"]);
22265
+ /** Polygon vertex in fraction-of-frame coordinates (0–1). */
22266
+ var PolygonPointSchema = object({
22267
+ x: number$1(),
22268
+ y: number$1()
22269
+ });
22270
+ /** A camera detection zone — pure geometry/identity. */
22271
+ var ZoneSchema = object({
22272
+ id: string(),
22273
+ name: string(),
22274
+ kind: ZoneKindEnum.default("polygon"),
22275
+ /** Polygon vertices, fraction of frame (0–1). */
22276
+ polygon: array(PolygonPointSchema).readonly(),
22277
+ /** Visual color for UI rendering. */
22278
+ color: string().default("#3b82f6")
22279
+ });
22280
+ DeviceType.Camera, method(object({ deviceId: number$1() }), array(ZoneSchema).readonly()), method(object({
22281
+ deviceId: number$1(),
22282
+ zone: ZoneSchema
22283
+ }), _void(), {
22284
+ kind: "mutation",
22285
+ auth: "admin"
22286
+ }), method(object({
22287
+ deviceId: number$1(),
22288
+ zoneId: string()
22289
+ }), _void(), {
22290
+ kind: "mutation",
22291
+ auth: "admin"
22292
+ }), method(object({
22293
+ deviceId: number$1(),
22294
+ zone: ZoneSchema
22295
+ }), _void(), {
22296
+ kind: "mutation",
22297
+ auth: "admin"
22298
+ }), object({ zones: array(ZoneSchema).readonly() });
22299
+ /**
21822
22300
  * A bounding box in NORMALIZED [0,1] frame coordinates for `getNativeCrop`. The
21823
22301
  * decode worker resolves it against the RETAINED native frame's real pixel dims,
21824
22302
  * so the caller supplies only the detection-res bbox divided by the detection
@@ -22005,7 +22483,17 @@ var DetailResultSchema = object({
22005
22483
  /** Face short side (px) measured on the NATIVE crop surface. The `bbox`
22006
22484
  * above is detection-frame px (≈6× smaller on a 4K camera) — min-face-size
22007
22485
  * consumers MUST prefer this when present (2026-07-22 native-gate fix). */
22008
- nativeFaceShortSidePx: number$1().optional()
22486
+ nativeFaceShortSidePx: number$1().optional(),
22487
+ /**
22488
+ * The five facial landmarks of a `face` detail, in the SAME frame space as
22489
+ * `bbox` (D644). Additive and optional: post-analysis stores them beside the
22490
+ * face's source frame so a future alignment can be re-derived exactly; a
22491
+ * runner that predates the field sends none and the face is stored without.
22492
+ */
22493
+ landmarks: array(object({
22494
+ x: number$1(),
22495
+ y: number$1()
22496
+ })).optional()
22009
22497
  });
22010
22498
  /**
22011
22499
  * Why an executing node REFUSED a stateless step run (`runStatelessStep`).
@@ -22260,6 +22748,17 @@ var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal
22260
22748
  hubHostnameOverride: string().optional()
22261
22749
  })]).describe("Per-camera frame-source mode for the runner (P2c)");
22262
22750
  /**
22751
+ * What ONE step runs with on ONE roster device for THIS camera (D650): the
22752
+ * device's per-(node,device) base with the camera's override for that device
22753
+ * on top — the same `override ?? base` merge the orchestrator applies to the
22754
+ * elected device (`applyDeviceProvisioning`). Absent `modelId` ⇒ the executor
22755
+ * resolves the device format's default, exactly as on the elected device.
22756
+ */
22757
+ var RunnerJumpStepProvisioningSchema = object({
22758
+ modelId: string().optional(),
22759
+ settings: record(string(), unknown()).optional()
22760
+ });
22761
+ /**
22263
22762
  * One ENABLED inference device on the runner's node, as the step-tree
22264
22763
  * device-jump resolver sees it (phase 1). The orchestrator populates this
22265
22764
  * roster on the attach payload whenever the camera is elected onto a specific
@@ -22271,7 +22770,16 @@ var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal
22271
22770
  var RunnerInferenceDeviceSchema = object({
22272
22771
  deviceKey: string(),
22273
22772
  weight: number$1().positive().default(1),
22274
- maxSessions: number$1().int().positive().nullable().default(null)
22773
+ maxSessions: number$1().int().positive().nullable().default(null),
22774
+ /**
22775
+ * Per-step provisioning for this camera on THIS device (D650), keyed by step
22776
+ * id. A step the runner jumps here runs with these fields, never with the
22777
+ * elected device's: `modelId` / `settings` are REPLACED on the jumped subtree
22778
+ * (a step absent from the map runs with neither — the target format default).
22779
+ * Absent field ⇒ an orchestrator that predates D650: the jumped step keeps
22780
+ * the elected device's provisioning, as before.
22781
+ */
22782
+ steps: record(string(), RunnerJumpStepProvisioningSchema).optional()
22275
22783
  });
22276
22784
  /**
22277
22785
  * Camera assignment payload sent by `addon-pipeline-orchestrator` to a
@@ -23146,6 +23654,28 @@ var NodeInferenceDeviceSchema = object({
23146
23654
  */
23147
23655
  exclusion: InferenceDeviceExclusionReasonSchema.nullable()
23148
23656
  });
23657
+ /**
23658
+ * The operator's model choice for one cluster-scoped step, answered by the
23659
+ * addon that OWNS the `clusterModel:*` settings (D651). Three answers, never
23660
+ * folded: a written choice, a key nobody wrote (the cluster runs the default
23661
+ * BY ABSENCE), or no answer. A caller that rewrites an index acts only on the
23662
+ * first two, read twice and agreeing.
23663
+ */
23664
+ var ClusterModelChoiceSchema = discriminatedUnion("kind", [
23665
+ object({
23666
+ kind: literal("stored"),
23667
+ modelId: string()
23668
+ }),
23669
+ object({
23670
+ kind: literal("absent"),
23671
+ defaultModelId: string()
23672
+ }),
23673
+ object({
23674
+ kind: literal("unreadable"),
23675
+ reason: _enum(CLUSTER_MODEL_CHOICE_UNREADABLE_REASONS),
23676
+ error: string().optional()
23677
+ })
23678
+ ]);
23149
23679
  var NodeInferenceDevicesSchema = object({
23150
23680
  nodeId: string(),
23151
23681
  /** False when the node's platform-probe was unreachable (no live device set). */
@@ -23173,10 +23703,17 @@ method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
23173
23703
  }), object({ success: literal(true) }), {
23174
23704
  kind: "mutation",
23175
23705
  auth: "admin"
23176
- }), method(object({ deviceId: number$1() }), object({ deviceKey: string().nullable() })), method(_void(), object({ migrated: number$1() }), {
23706
+ }), method(object({ deviceId: number$1() }), object({ deviceKey: string().nullable() })), method(_void(), object({
23707
+ migrated: number$1(),
23708
+ skipped: array(object({
23709
+ deviceId: number$1(),
23710
+ targetNodeId: string(),
23711
+ reason: string()
23712
+ })).default([])
23713
+ }), {
23177
23714
  kind: "mutation",
23178
23715
  auth: "admin"
23179
- }), method(_void(), array(PipelineAssignmentSchema).readonly()), method(object({ deviceId: number$1() }), PipelineAssignmentSchema.nullable()), method(_void(), array(AgentLoadSummarySchema).readonly()), method(_void(), GlobalMetricsSchema), method(object({ deviceId: number$1() }), CameraMetricsSchema.nullable()), method(object({ nodeId: string() }), CapabilityBindingsSchema), method(object({
23716
+ }), method(_void(), array(PipelineAssignmentSchema).readonly()), method(object({ deviceId: number$1() }), PipelineAssignmentSchema.nullable()), method(_void(), array(AgentLoadSummarySchema).readonly()), method(object({ stepId: string() }), ClusterModelChoiceSchema), method(_void(), GlobalMetricsSchema), method(object({ deviceId: number$1() }), CameraMetricsSchema.nullable()), method(object({ nodeId: string() }), CapabilityBindingsSchema), method(object({
23180
23717
  nodeId: string(),
23181
23718
  capName: string(),
23182
23719
  addonId: string()
@@ -23391,7 +23928,11 @@ function buildDescriptor(capName, kind) {
23391
23928
  icon: legacyIcon(t.iconId)
23392
23929
  };
23393
23930
  }
23394
- Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
23931
+ /**
23932
+ * Sensor / control cap name → static event-kind descriptor. A linked device
23933
+ * contributes one entry per bound cap present in this map.
23934
+ */
23935
+ var EVENT_KIND_BY_CAP = Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
23395
23936
  /**
23396
23937
  * server-management — per-NODE singleton capability for a node's ROOT
23397
23938
  * package lifecycle (runtime-updatable node packages).
@@ -25472,6 +26013,167 @@ DeviceType.Camera, method(object({
25472
26013
  auth: "protected"
25473
26014
  });
25474
26015
  /**
26016
+ * LA tabella "quale booleano di questo tipo di device conta come ALTO", e il
26017
+ * valutatore puro del suo FRONTE.
26018
+ *
26019
+ * Viveva dentro il builtin virtual-doorbell
26020
+ * (`@camstack/system` — `builtins/doorbell/trigger-engine.ts`) e i suoi
26021
+ * predicati erano privati al modulo. Il recorder ne ha bisogno per il trigger
26022
+ * `RecordingTriggers.sensorDeviceIds`: copiarla avrebbe creato la SECONDA
26023
+ * tabella, che diverge alla prima cap aggiunta e il cui sintomo — "il sensore
26024
+ * fa suonare il campanello ma non registra" — è esattamente D62. Quindi si
26025
+ * SPOSTA qui e il doorbell la ri-esporta.
26026
+ *
26027
+ * ⚠ NON è `DEVICE_STATE_READERS` (`catalogs/device-state-vocabulary.ts`), e le
26028
+ * due non vanno unificate: quella risponde a "qual è la PAROLA di stato per una
26029
+ * regola" (e include `presence`, `cover`, `alarm-panel`), questa a "qual è il
26030
+ * booleano il cui FRONTE conta". Vocabolari deliberatamente diversi.
26031
+ */
26032
+ /**
26033
+ * Known binary / switch source caps → the boolean slice field whose
26034
+ * false→true rise counts as ACTIVE. Every entry is "fire on active".
26035
+ * Sensors whose "active" reading is not a plain boolean (presence's string
26036
+ * state, connectivity's connected flag) are deliberately excluded — a
26037
+ * reconnect is not a doorbell press, and it is not a recording either.
26038
+ */
26039
+ var SOURCE_CAP_ACTIVE_FIELD = {
26040
+ contact: "entryOpen",
26041
+ binary: "on",
26042
+ switch: "on",
26043
+ motion: "detected",
26044
+ flood: "flooded",
26045
+ gas: "detected",
26046
+ smoke: "detected",
26047
+ "carbon-monoxide": "detected",
26048
+ vibration: "detected",
26049
+ tamper: "tampered"
26050
+ };
26051
+ object({
26052
+ /** Ms epoch of the last press. null = never observed since this provider started. */
26053
+ lastPressedAt: number$1().nullable(),
26054
+ /** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
26055
+ pressCountSinceStart: number$1()
26056
+ });
26057
+ object({
26058
+ deviceId: number$1(),
26059
+ timestamp: number$1()
26060
+ });
26061
+ /**
26062
+ * The `doorbell-source` extension slot's editable value (D648): the camera's
26063
+ * virtual-doorbell trigger devices, exactly what the wrapper's
26064
+ * `doorbellSources` persists (as `{ deviceId }` records).
26065
+ */
26066
+ var DoorbellSourceSlotValueSchema = object({ deviceIds: array(number$1().int().positive()) });
26067
+ DeviceType.Camera;
26068
+ DeviceType.Button, DeviceType.Camera;
26069
+ var ExtensionSlotIdSchema = _enum(["doorbell-source", "linked-devices"]);
26070
+ DeviceType.Camera, DeviceType.Camera;
26071
+ /** A slot's editable value, discriminated on `slot`. */
26072
+ var ExtensionSlotValueSchema = discriminatedUnion("slot", [DoorbellSourceSlotValueSchema.extend({ slot: literal("doorbell-source") }), LinkedDevicesSlotValueSchema.extend({ slot: literal("linked-devices") })]);
26073
+ DeviceType.Camera;
26074
+ var ExtensionSourceAvailabilitySchema = discriminatedUnion("state", [object({ state: literal("ok") }), object({
26075
+ state: literal("unreachable"),
26076
+ reason: string()
26077
+ })]);
26078
+ /** One provider of slots — the D554 source-listing row. */
26079
+ var ExtensionSourceSchema = object({
26080
+ /** The routing prefix of every `slotRef` this provider serves. */
26081
+ source: string(),
26082
+ label: string(),
26083
+ /** Stamped by the dispatcher from the registry (D557). */
26084
+ addonId: string().optional(),
26085
+ availability: ExtensionSourceAvailabilitySchema
26086
+ });
26087
+ /**
26088
+ * How one picked source stands. `missing` — no such device (deleted, or an id
26089
+ * that never existed); `foreign` — a device the slot's owner cannot read from
26090
+ * (slice 2's cross-owner graft source); `unavailable` — it exists but is not a
26091
+ * valid source now (a container, which is never a pick). A source in any of
26092
+ * these states is SHOWN, never silently dropped or re-pointed.
26093
+ */
26094
+ var ExtensionSourceHealthSchema = _enum([
26095
+ "ok",
26096
+ "missing",
26097
+ "foreign",
26098
+ "unavailable"
26099
+ ]);
26100
+ var ExtensionSlotSourceSchema = object({
26101
+ deviceId: number$1().int(),
26102
+ /** The device's name, or null when it could not be resolved (`missing`). */
26103
+ name: string().nullable(),
26104
+ health: ExtensionSourceHealthSchema,
26105
+ detail: string().optional()
26106
+ });
26107
+ /**
26108
+ * A DIFFERENT authority that gates whether the slot's sources do anything —
26109
+ * reported read-only, named, never written through this contract (D62). The
26110
+ * virtual doorbell's sources ring only while the wrapper is bound to the
26111
+ * camera, and that binding belongs to `deviceManager.setWrapperActive`.
26112
+ * `unknown` means the gate could not be read; it is not "inactive" (D315).
26113
+ */
26114
+ var ExtensionSlotActivationSchema = object({
26115
+ state: _enum([
26116
+ "active",
26117
+ "inactive",
26118
+ "unknown"
26119
+ ]),
26120
+ authority: string(),
26121
+ detail: string().optional()
26122
+ });
26123
+ var ExtensionSlotRowSchema = discriminatedUnion("state", [object({
26124
+ state: literal("ok"),
26125
+ /** `<source>:<slotId>` — the routing key for `listCandidates` / `setSlot`. */
26126
+ slotRef: string(),
26127
+ slot: ExtensionSlotIdSchema,
26128
+ /** Names the store written (D62), e.g. `virtual-doorbell:doorbellSources`. */
26129
+ authority: string(),
26130
+ /** graft: its switch. association: null — removing every source is "off". */
26131
+ enabled: boolean().nullable(),
26132
+ /** graft: the cap registered on the host. association: null. */
26133
+ projects: string().nullable(),
26134
+ activation: ExtensionSlotActivationSchema.nullable(),
26135
+ value: ExtensionSlotValueSchema,
26136
+ sources: array(ExtensionSlotSourceSchema)
26137
+ }), object({
26138
+ state: literal("unreachable"),
26139
+ addonId: string(),
26140
+ reason: string()
26141
+ })]);
26142
+ var ExtensionCandidatesSchema = object({ candidates: array(object({
26143
+ deviceId: number$1().int(),
26144
+ name: string(),
26145
+ type: string(),
26146
+ location: string().nullable(),
26147
+ /** The container a child belongs to — "Spotlight 2" alone does not say which. */
26148
+ parentName: string().nullable(),
26149
+ /** Pre-marked by the owner's suggestion rule. NEVER saved on its own (D356). */
26150
+ suggested: boolean(),
26151
+ /** Why it is suggested ("same location"), null when it is not. */
26152
+ reason: string().nullable()
26153
+ })) });
26154
+ /**
26155
+ * What a write did. `none` — applied in place. `host` / `parent` — the owner
26156
+ * reloaded the host (or, for an accessory child, its parent) because the
26157
+ * write changed what the host REGISTERS (a graft switched on or off, slice 2).
26158
+ */
26159
+ var ExtensionSetResultSchema = object({
26160
+ applied: literal(true),
26161
+ reload: _enum([
26162
+ "none",
26163
+ "host",
26164
+ "parent"
26165
+ ])
26166
+ });
26167
+ var ExtensionSlotRefInputSchema = object({
26168
+ deviceId: number$1().int(),
26169
+ slotRef: string().min(1)
26170
+ });
26171
+ var ExtensionSetSlotInputSchema = ExtensionSlotRefInputSchema.extend({ value: ExtensionSlotValueSchema });
26172
+ method(object({ deviceId: number$1().int() }), array(ExtensionSourceSchema)), method(object({ deviceId: number$1().int() }), array(ExtensionSlotRowSchema)), method(ExtensionSlotRefInputSchema, ExtensionCandidatesSchema), method(ExtensionSetSlotInputSchema, ExtensionSetResultSchema, {
26173
+ kind: "mutation",
26174
+ auth: "admin"
26175
+ });
26176
+ /**
25475
26177
  * Optional client-side hints sent at session creation to help the provider
25476
26178
  * pick the best native source. All fields optional — a viewer that knows
25477
26179
  * nothing still gets a sane default. (Relocated from the retired `webrtc`
@@ -27260,17 +27962,6 @@ object({
27260
27962
  deviceId: number$1(),
27261
27963
  status: DeviceStatusSchema
27262
27964
  });
27263
- object({
27264
- /** Ms epoch of the last press. null = never observed since this provider started. */
27265
- lastPressedAt: number$1().nullable(),
27266
- /** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
27267
- pressCountSinceStart: number$1()
27268
- });
27269
- object({
27270
- deviceId: number$1(),
27271
- timestamp: number$1()
27272
- });
27273
- DeviceType.Button, DeviceType.Camera;
27274
27965
  /**
27275
27966
  * Enum-state sensor — a string value picked from a finite option set.
27276
27967
  * Drives HA `sensor` entries with `state_class: enum` (HVAC action
@@ -29534,7 +30225,30 @@ var RenameNodeResultSchema = object({
29534
30225
  nodeId: string(),
29535
30226
  name: string()
29536
30227
  });
29537
- method(_void(), array(TopologyNodeSchema).readonly(), { auth: "admin" }), method(NodeAddonInputSchema, SuccessSchema, {
30228
+ /**
30229
+ * The cheap node list. A consumer's rule for a STORED node id (a rule's
30230
+ * `nodeIds`) that is missing from `nodes`, whatever `complete` says: render it
30231
+ * as a removable chip labelled unknown, never drop it (D49). Even a complete
30232
+ * list omits a node that joined and left between two history captures, so a
30233
+ * missing id means "not known to the hub", never "removed". Only the operator
30234
+ * removes it.
30235
+ *
30236
+ * `complete` changes only the WORDING: `false` = no history read has ever
30237
+ * answered, so the list may be missing offline nodes the hub does know (D315).
30238
+ *
30239
+ * `name` is the history row's name (≤ 30 s behind a rename), or the id when
30240
+ * the history has none.
30241
+ */
30242
+ var NodeDirectorySchema = object({
30243
+ nodes: array(object({
30244
+ id: string(),
30245
+ name: string(),
30246
+ isHub: boolean(),
30247
+ isOnline: boolean()
30248
+ })).readonly(),
30249
+ complete: boolean()
30250
+ });
30251
+ method(_void(), array(TopologyNodeSchema).readonly(), { auth: "admin" }), method(_void(), NodeDirectorySchema, { auth: "admin" }), method(NodeAddonInputSchema, SuccessSchema, {
29538
30252
  kind: "mutation",
29539
30253
  auth: "admin"
29540
30254
  }), method(NodeAddonInputSchema, SuccessSchema, {
@@ -30303,7 +31017,7 @@ var HardwareInfoSchema = object({
30303
31017
  coral: CoralInfoSchema.nullable().optional()
30304
31018
  });
30305
31019
  var PlatformScoreSchema = object({
30306
- runtime: _enum(["node", "python"]),
31020
+ runtime: literal("python"),
30307
31021
  backend: string(),
30308
31022
  format: _enum([
30309
31023
  "onnx",
@@ -30340,7 +31054,7 @@ var ModelRequirementSchema = object({
30340
31054
  });
30341
31055
  var ResolvedInferenceConfigSchema = object({
30342
31056
  modelId: string(),
30343
- runtime: _enum(["node", "python"]),
31057
+ runtime: literal("python"),
30344
31058
  backend: string(),
30345
31059
  format: ModelFormatSchema,
30346
31060
  reason: string()
@@ -32547,6 +33261,92 @@ DeviceType.Camera, method(object({ deviceId: number$1() }), SceneMonitorStatusSc
32547
33261
  kind: "mutation",
32548
33262
  auth: "admin"
32549
33263
  });
33264
+ /**
33265
+ * Per-stage gating mode applied to the zones a rule references.
33266
+ *
33267
+ * - `include`: the rule contributes to a **whitelist** for its stage.
33268
+ * When at least one `include` rule fires for a stage, only entities
33269
+ * inside one of those zones pass that stage.
33270
+ * - `exclude`: the rule contributes to a **blacklist** for its stage.
33271
+ * Entities inside one of those zones are dropped at that stage.
33272
+ *
33273
+ * `monitor`-style observation (count without filtering) is not a rule
33274
+ * mode — zones without any matching rule are observed naturally by
33275
+ * `zone-analytics` (live snapshot + history), so an "I just want to
33276
+ * count, not filter" use case needs no rule at all.
33277
+ */
33278
+ var ZoneRuleModeEnum = _enum(["include", "exclude"]);
33279
+ /**
33280
+ * Per-consumer rule that references existing zones (geometry) and
33281
+ * defines how a specific pipeline stage should treat them. Each
33282
+ * consumer addon owns its own `ZoneRule[]` array in its per-device
33283
+ * settings:
33284
+ *
33285
+ * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
33286
+ * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
33287
+ * - future: notification rules, audio gating, etc.
33288
+ *
33289
+ * One rule applies to N zones (`zoneIds[]`) so the operator can
33290
+ * express "ignore motion in ALL of {garden, street}" with a single
33291
+ * rule. `classFilter` narrows the rule to specific object classes —
33292
+ * "drop person detections in the street, but keep cars" is one
33293
+ * `exclude` rule with `classFilter: ['person']`.
33294
+ *
33295
+ * `enabled` is a soft toggle — the operator can keep the rule
33296
+ * configured but inert without deleting it.
33297
+ */
33298
+ var ZoneRuleSchema = object({
33299
+ /** Stable rule id — survives edits, used by the UI for diffing. */
33300
+ id: string(),
33301
+ /** Optional human-readable label rendered in the rule editor. */
33302
+ name: string().optional(),
33303
+ /** Zones this rule targets. The rule's `mode` applies to ALL
33304
+ * listed zones (OR-set: a detection in any one of them counts).
33305
+ * At least one zone id required — a rule with no targets is a
33306
+ * configuration mistake and the form validator rejects it. */
33307
+ zoneIds: array(string()).min(1).readonly(),
33308
+ mode: ZoneRuleModeEnum,
33309
+ /**
33310
+ * Class names this rule applies to. Empty / undefined ⇒ rule
33311
+ * applies to every class. Class strings match the `macroClass`
33312
+ * field on detections (e.g. `person`, `car`, `dog`).
33313
+ */
33314
+ classFilter: array(string()).readonly().optional(),
33315
+ /**
33316
+ * Minimum bbox/mask overlap (0–1) with any of the rule's zones
33317
+ * required to consider an entity "in the zone". Defaults to the
33318
+ * consumer's stage default when omitted. Kept for back-compat with
33319
+ * existing per-rule overrides; new operators pick the value via
33320
+ * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
33321
+ * set, the lower-level engine reads it as a 0–1 fraction.
33322
+ */
33323
+ overlapThreshold: number$1().min(0).max(1).optional(),
33324
+ /**
33325
+ * Operator-friendly version of `overlapThreshold` — the percentage
33326
+ * of the detection's bbox that must lie inside the zone for the
33327
+ * rule to match. Documented default is 85%; the engine substitutes
33328
+ * that when the field is omitted (kept optional so existing rules
33329
+ * stored without it stay valid).
33330
+ *
33331
+ * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
33332
+ * rule, the engine prefers `bboxInclusionPct` because it's the
33333
+ * field exposed in the UI. Internally both feed the same gate.
33334
+ */
33335
+ bboxInclusionPct: number$1().min(0).max(100).optional(),
33336
+ /**
33337
+ * When `true` and a detection has a segmentation mask, use the
33338
+ * mask for overlap instead of the bbox. Detection-stage only;
33339
+ * motion rules ignore this field.
33340
+ */
33341
+ preferMask: boolean().optional(),
33342
+ /**
33343
+ * Soft-toggle: `false` disables the rule without deleting it.
33344
+ * Defaults to `true` so operators creating a rule via the UI
33345
+ * see it active immediately.
33346
+ */
33347
+ enabled: boolean().default(true)
33348
+ });
33349
+ array(ZoneRuleSchema).readonly();
32550
33350
  object({
32551
33351
  /** Whether the script is currently executing. */
32552
33352
  isRunning: boolean(),
@@ -36727,6 +37527,30 @@ Object.freeze({
36727
37527
  addonId: null,
36728
37528
  access: "create"
36729
37529
  },
37530
+ "deviceExtension.listCandidates": {
37531
+ capName: "device-extension",
37532
+ capScope: "device",
37533
+ addonId: null,
37534
+ access: "view"
37535
+ },
37536
+ "deviceExtension.listSlots": {
37537
+ capName: "device-extension",
37538
+ capScope: "device",
37539
+ addonId: null,
37540
+ access: "view"
37541
+ },
37542
+ "deviceExtension.listSources": {
37543
+ capName: "device-extension",
37544
+ capScope: "device",
37545
+ addonId: null,
37546
+ access: "view"
37547
+ },
37548
+ "deviceExtension.setSlot": {
37549
+ capName: "device-extension",
37550
+ capScope: "device",
37551
+ addonId: null,
37552
+ access: "create"
37553
+ },
36730
37554
  "deviceManager.addLocation": {
36731
37555
  capName: "device-manager",
36732
37556
  capScope: "system",
@@ -37477,6 +38301,12 @@ Object.freeze({
37477
38301
  addonId: null,
37478
38302
  access: "view"
37479
38303
  },
38304
+ "embeddingEncoder.resetFailedModels": {
38305
+ capName: "embedding-encoder",
38306
+ capScope: "system",
38307
+ addonId: null,
38308
+ access: "delete"
38309
+ },
37480
38310
  "enumSensor.getStatus": {
37481
38311
  capName: "enum-sensor",
37482
38312
  capScope: "device",
@@ -38659,6 +39489,12 @@ Object.freeze({
38659
39489
  addonId: null,
38660
39490
  access: "create"
38661
39491
  },
39492
+ "nodes.directory": {
39493
+ capName: "nodes",
39494
+ capScope: "system",
39495
+ addonId: null,
39496
+ access: "view"
39497
+ },
38662
39498
  "nodes.executeQuery": {
38663
39499
  capName: "nodes",
38664
39500
  capScope: "system",
@@ -38827,6 +39663,12 @@ Object.freeze({
38827
39663
  addonId: null,
38828
39664
  access: "view"
38829
39665
  },
39666
+ "notificationRules.getRuleLastRuns": {
39667
+ capName: "notification-rules",
39668
+ capScope: "system",
39669
+ addonId: null,
39670
+ access: "view"
39671
+ },
38830
39672
  "notificationRules.getTemplateCatalog": {
38831
39673
  capName: "notification-rules",
38832
39674
  capScope: "system",
@@ -38851,6 +39693,12 @@ Object.freeze({
38851
39693
  addonId: null,
38852
39694
  access: "view"
38853
39695
  },
39696
+ "notificationRules.previewStateSummary": {
39697
+ capName: "notification-rules",
39698
+ capScope: "system",
39699
+ addonId: null,
39700
+ access: "view"
39701
+ },
38854
39702
  "notificationRules.previewTemplate": {
38855
39703
  capName: "notification-rules",
38856
39704
  capScope: "system",
@@ -39427,12 +40275,6 @@ Object.freeze({
39427
40275
  addonId: null,
39428
40276
  access: "create"
39429
40277
  },
39430
- "pipelineAnalytics.runReplayFrameProcessor": {
39431
- capName: "pipeline-analytics",
39432
- capScope: "device",
39433
- addonId: null,
39434
- access: "create"
39435
- },
39436
40278
  "pipelineAnalytics.saveRetrainAnnotations": {
39437
40279
  capName: "pipeline-analytics",
39438
40280
  capScope: "device",
@@ -39799,6 +40641,12 @@ Object.freeze({
39799
40641
  addonId: null,
39800
40642
  access: "view"
39801
40643
  },
40644
+ "pipelineOrchestrator.getClusterModelChoice": {
40645
+ capName: "pipeline-orchestrator",
40646
+ capScope: "system",
40647
+ addonId: null,
40648
+ access: "view"
40649
+ },
39802
40650
  "pipelineOrchestrator.getDeviceLiveContribution": {
39803
40651
  capName: "pipeline-orchestrator",
39804
40652
  capScope: "system",
@@ -42624,6 +43472,26 @@ Object.freeze({
42624
43472
  form: "single",
42625
43473
  optional: false
42626
43474
  }],
43475
+ "deviceExtension.listCandidates": [{
43476
+ name: "deviceId",
43477
+ form: "single",
43478
+ optional: false
43479
+ }],
43480
+ "deviceExtension.listSlots": [{
43481
+ name: "deviceId",
43482
+ form: "single",
43483
+ optional: false
43484
+ }],
43485
+ "deviceExtension.listSources": [{
43486
+ name: "deviceId",
43487
+ form: "single",
43488
+ optional: false
43489
+ }],
43490
+ "deviceExtension.setSlot": [{
43491
+ name: "deviceId",
43492
+ form: "single",
43493
+ optional: false
43494
+ }],
42627
43495
  "deviceManager.adoptionRelease": [{
42628
43496
  name: "camDeviceId",
42629
43497
  form: "single",
@@ -43530,11 +44398,6 @@ Object.freeze({
43530
44398
  form: "single",
43531
44399
  optional: false
43532
44400
  }],
43533
- "pipelineAnalytics.runReplayFrameProcessor": [{
43534
- name: "deviceId",
43535
- form: "single",
43536
- optional: false
43537
- }],
43538
44401
  "pipelineAnalytics.saveRetrainAnnotations": [{
43539
44402
  name: "deviceId",
43540
44403
  form: "single",
@@ -44423,11 +45286,232 @@ var NC_AUDIO_DEFAULTS = {
44423
45286
  samplingSeconds: 10
44424
45287
  };
44425
45288
  new Set(["devices", "classes"]);
45289
+ /**
45290
+ * WHICH narrowing filter speaks about WHICH system-event kind — one predicate,
45291
+ * consumed by the rule ENGINE and by every rule EDITOR.
45292
+ *
45293
+ * ── The failure this file exists for ───────────────────────────────────────
45294
+ * `NcSystemEventConditionSchema` carries four optional narrowing lists
45295
+ * (`deviceIds`, `deviceTypes`, `nodeIds`, `packageNames`) beside a required
45296
+ * `kinds` gate. They are not four filters over one vocabulary: each belongs to
45297
+ * a FAMILY of kinds and is meaningless outside it. A node going away has no
45298
+ * device type; a completed export has no package; `stream-offline` deliberately
45299
+ * carries no device type at all (a stream belongs to a camera by construction).
45300
+ *
45301
+ * The engine applied all four to every kind, so a filter from one family failed
45302
+ * a kind from another family CLOSED. The operator's live rule "Eventi di
45303
+ * sistema" selected eleven kinds and set `deviceTypes: ['camera']` — the only
45304
+ * way to say "only my cameras" about the two liveness kinds — and NINE of the
45305
+ * eleven silently stopped being deliverable. Four days of history contained
45306
+ * `device-online` and `device-offline` and nothing else, across a window in
45307
+ * which agents were restarted and addons were updated.
45308
+ *
45309
+ * Both editors already computed this scoping, to decide which filter boxes to
45310
+ * render; the cap's own docblock already promised it ("Narrow a `device-*` kind
45311
+ * to these device TYPES"). Only the engine disagreed, and it disagreed in the
45312
+ * destructive direction. So the rule is stated ONCE, here, and the engine and
45313
+ * the editors are readers of it rather than three independent authors.
45314
+ *
45315
+ * ── The direction ─────────────────────────────────────────────────────────
45316
+ * Out of family ⇒ the filter is IGNORED, never fail-closed. An editor that
45317
+ * hides a box has already told the operator this filter does not speak about
45318
+ * these kinds, so honouring it as an exclusion contradicts the only
45319
+ * explanation the operator was ever given. Inside its family the filter still
45320
+ * narrows, and still fails CLOSED on a subject that cannot produce the identity
45321
+ * it tests (a device the mirror cannot name is not evidence of a camera).
45322
+ */
45323
+ /**
45324
+ * Every filter, for the callers that must cover all of them (guards, tests).
45325
+ *
45326
+ * `consumableLowPercent` (D642) is not a list but it is a filter in exactly
45327
+ * this sense: it belongs to a family of kinds (the consumable pair) and the
45328
+ * engine consults it only there. It differs in one way the readers must know —
45329
+ * its ABSENCE is not "no narrowing" but the default threshold, because a
45330
+ * consumable episode is always judged at SOME threshold.
45331
+ */
45332
+ var NC_SYSTEM_EVENT_FILTER_KEYS = [
45333
+ "deviceIds",
45334
+ "deviceTypes",
45335
+ "nodeIds",
45336
+ "packageNames",
45337
+ "consumableLowPercent"
45338
+ ];
45339
+ new Map(Object.entries({
45340
+ "device-online": "device-events",
45341
+ "device-offline": "device-events",
45342
+ "device-disabled": "device-events",
45343
+ "device-enabled": "device-events",
45344
+ "device-battery-low": "device-events",
45345
+ "device-battery-normal": "device-events",
45346
+ "device-consumable-low": "device-events",
45347
+ "device-consumable-normal": "device-events",
45348
+ "device-tank-low": "device-events",
45349
+ "device-tank-full": "device-events",
45350
+ "device-tank-normal": "device-events",
45351
+ "stream-online": "device-events",
45352
+ "stream-offline": "device-events",
45353
+ "detection-blind": "device-events",
45354
+ "node-online": "system",
45355
+ "node-offline": "system",
45356
+ "node-inference-unavailable": "system",
45357
+ "addon-crash-loop": "system",
45358
+ "addon-update-available": "system",
45359
+ "addon-updated": "system",
45360
+ "server-update-available": "system",
45361
+ "server-updated": "system",
45362
+ "wrapper-update-available": "system",
45363
+ "backup-completed": "system",
45364
+ "export-completed": "system",
45365
+ "alarm-triggered": "alarm",
45366
+ "alarm-armed": "alarm",
45367
+ "alarm-disarmed": "alarm",
45368
+ "alarm-arming": "alarm",
45369
+ "alarm-arm-refused": "alarm",
45370
+ "alarm-pending": "alarm",
45371
+ "alarm-rearmed": "alarm",
45372
+ "alarm-sensor-bypass": "alarm",
45373
+ "alarm-check-failed": "alarm",
45374
+ "camera-online": null,
45375
+ "camera-offline": null,
45376
+ "camera-disabled": null,
45377
+ "camera-enabled": null
45378
+ }));
45379
+ [...NC_SYSTEM_EVENT_FILTER_KEYS];
45380
+ var NC_SYSTEM_EVENT_KIND_GROUP_SPECS = [
45381
+ {
45382
+ id: "device-state",
45383
+ family: "device-events",
45384
+ label: "Device state",
45385
+ kinds: [
45386
+ "device-offline",
45387
+ "device-online",
45388
+ "device-disabled",
45389
+ "device-enabled"
45390
+ ]
45391
+ },
45392
+ {
45393
+ id: "streams",
45394
+ family: "device-events",
45395
+ label: "Streams",
45396
+ kinds: ["stream-offline", "stream-online"]
45397
+ },
45398
+ {
45399
+ id: "battery",
45400
+ family: "device-events",
45401
+ label: "Battery",
45402
+ kinds: ["device-battery-low", "device-battery-normal"]
45403
+ },
45404
+ {
45405
+ id: "consumables",
45406
+ family: "device-events",
45407
+ label: "Consumables",
45408
+ kinds: ["device-consumable-low", "device-consumable-normal"]
45409
+ },
45410
+ {
45411
+ id: "tanks",
45412
+ family: "device-events",
45413
+ label: "Tanks",
45414
+ kinds: [
45415
+ "device-tank-low",
45416
+ "device-tank-full",
45417
+ "device-tank-normal"
45418
+ ]
45419
+ },
45420
+ {
45421
+ id: "detection-blind",
45422
+ family: "device-events",
45423
+ label: "Detecting nothing",
45424
+ kinds: ["detection-blind"]
45425
+ },
45426
+ {
45427
+ id: "nodes",
45428
+ family: "system",
45429
+ label: "Nodes",
45430
+ kinds: [
45431
+ "node-offline",
45432
+ "node-online",
45433
+ "node-inference-unavailable"
45434
+ ]
45435
+ },
45436
+ {
45437
+ id: "addons",
45438
+ family: "system",
45439
+ label: "Addons",
45440
+ kinds: [
45441
+ "addon-crash-loop",
45442
+ "addon-update-available",
45443
+ "addon-updated"
45444
+ ]
45445
+ },
45446
+ {
45447
+ id: "updates",
45448
+ family: "system",
45449
+ label: "Server & container updates",
45450
+ kinds: [
45451
+ "server-update-available",
45452
+ "server-updated",
45453
+ "wrapper-update-available"
45454
+ ]
45455
+ },
45456
+ {
45457
+ id: "backups-exports",
45458
+ family: "system",
45459
+ label: "Backups & exports",
45460
+ kinds: ["backup-completed", "export-completed"]
45461
+ },
45462
+ {
45463
+ id: "alarm",
45464
+ family: "alarm",
45465
+ label: "Alarm",
45466
+ kinds: NC_ALARM_SYSTEM_EVENT_KINDS
45467
+ }
45468
+ ];
45469
+ function systemEventKindsOfFamily(family) {
45470
+ return NC_SYSTEM_EVENT_KIND_GROUP_SPECS.filter((g) => g.family === family).flatMap((g) => g.kinds);
45471
+ }
44426
45472
  NC_AUDIO_DEFAULTS.hitPercent, NC_AUDIO_DEFAULTS.samplingSeconds;
45473
+ /**
45474
+ * WHICH WAY A BOOLEAN SENSOR MOVED — read off the one slice a sensor event
45475
+ * persists (D640 "a sensor rule fires on the raise, the clear, or both").
45476
+ *
45477
+ * A device-event rule over a flood sensor notified on BOTH edges: water
45478
+ * detected, and back to dry. `NcConditions.sensorTransition` lets the rule
45479
+ * name one edge; this file answers, for one `SensorEvent`, which edge it is.
45480
+ *
45481
+ * NOT A SECOND TABLE. The "which boolean of this cap counts as HIGH" question
45482
+ * already has one answer, `SOURCE_CAP_ACTIVE_FIELD`
45483
+ * (`catalogs/sensor-active-state.ts`, the doorbell's and the recorder's edge
45484
+ * table), and a sensor event names its kind, not its cap. So the table here is
45485
+ * DERIVED: event kind → cap (`EVENT_KIND_BY_CAP`) → that cap's active field.
45486
+ * Only kinds whose taxonomy category is `sensor` take part — a switch has an
45487
+ * `on` boolean too, but "it triggers / it clears" is not a sentence about a
45488
+ * light, and offering it there would be a knob with a misleading label.
45489
+ * `presence` is a WORD (`home` / `not_home` / a zone), not a boolean, and is
45490
+ * absent from the source table, so it is absent here.
45491
+ *
45492
+ * `undefined` = never guessed: a kind with no raise (a doorbell press, a
45493
+ * button, a cover), or a slice whose field is missing or not a boolean. The
45494
+ * engine then does NOT filter — a flood alert must not go silent because one
45495
+ * read came back unreadable (the same stance as the alarm's `sensorEdgeOf`).
45496
+ *
45497
+ * Pure, RN-safe: the viewer imports the support rule from here.
45498
+ */
45499
+ /** Event kind → the boolean field of its cap slice that means "raised". */
45500
+ var NC_SENSOR_RAISED_FIELD_BY_KIND = Object.freeze(Object.fromEntries(Object.entries(EVENT_KIND_BY_CAP).flatMap(([capName, descriptor]) => {
45501
+ const field = SOURCE_CAP_ACTIVE_FIELD[capName];
45502
+ if (field === void 0 || descriptor.category !== "sensor") return [];
45503
+ return [[descriptor.kind, field]];
45504
+ })));
45505
+ Object.freeze(Object.keys(NC_SENSOR_RAISED_FIELD_BY_KIND));
44427
45506
  var RULE_BODY_ONLY = ["body"];
44428
45507
  var RULE_TEXT = ["title", "body"];
44429
45508
  var BATTERY = ["device-battery-low", "device-battery-normal"];
44430
45509
  var CONSUMABLE = ["device-consumable-low", "device-consumable-normal"];
45510
+ var TANK = [
45511
+ "device-tank-low",
45512
+ "device-tank-full",
45513
+ "device-tank-normal"
45514
+ ];
44431
45515
  var UPDATES = [
44432
45516
  "addon-update-available",
44433
45517
  "server-update-available",
@@ -44453,12 +45537,189 @@ var DEVICE_EVENTS = [
44453
45537
  "device-enabled",
44454
45538
  ...BATTERY,
44455
45539
  ...CONSUMABLE,
45540
+ ...TANK,
44456
45541
  "stream-online",
44457
45542
  "stream-offline",
44458
45543
  "detection-blind",
44459
45544
  ...ALARM
44460
45545
  ];
44461
- [...DEVICE_EVENTS], [...RULE_TEXT], [...COMBINED_ALARM], [...RULE_TEXT], [...COMBINED_ALARM], [...RULE_TEXT], [...RULE_TEXT], [...COMBINED_ALARM], [...RULE_TEXT], [...PACKAGE_UPDATES], [...RULE_TEXT], [...RULE_TEXT], [...COMBINED_ALARM], [...RULE_TEXT], [...COMBINED_ALARM], [...RULE_TEXT], [...COMBINED_ALARM], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_BODY_ONLY], [...RULE_TEXT], [...RULE_TEXT], [...DEVICE_EVENTS], [...RULE_TEXT], [...DEVICE_EVENTS], [...RULE_TEXT], [...BATTERY, ...CONSUMABLE], [...RULE_TEXT], [...CONSUMABLE], [...RULE_TEXT], [...RULE_TEXT], [...UPDATES], [...RULE_TEXT], [...UPDATES], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...UPDATES], [...RULE_TEXT], [...PACKAGE_UPDATES], [...RULE_TEXT], [...PACKAGE_UPDATES], [...RULE_TEXT], [...UPDATES], [...RULE_TEXT], [...UPDATES], [...RULE_TEXT], [...PACKAGE_UPDATES], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT];
45546
+ /** Every kind a summary may speak about — the two summarisable families. */
45547
+ var SUMMARISABLE = [...systemEventKindsOfFamily("device-events"), ...systemEventKindsOfFamily("system")];
45548
+ /** One per summary SECTION (`NC_STATE_SUMMARY_SECTIONS` in the notification
45549
+ * centre): the section's lines, offered when one of its kinds is selected. */
45550
+ var STATE_SUMMARY_SECTION_VARS = [
45551
+ {
45552
+ name: "summaryDevices",
45553
+ label: "Summary: devices offline / switched off",
45554
+ example: "Garage — offline since 07:12",
45555
+ kinds: [
45556
+ "device-offline",
45557
+ "device-online",
45558
+ "device-disabled",
45559
+ "device-enabled"
45560
+ ]
45561
+ },
45562
+ {
45563
+ name: "summaryStreams",
45564
+ label: "Summary: streams offline",
45565
+ example: "Ingresso (high) — since 06:40",
45566
+ kinds: ["stream-offline", "stream-online"]
45567
+ },
45568
+ {
45569
+ name: "summaryBattery",
45570
+ label: "Summary: low batteries",
45571
+ example: "Sensore porta — 8 %",
45572
+ kinds: BATTERY
45573
+ },
45574
+ {
45575
+ name: "summaryConsumables",
45576
+ label: "Summary: consumables",
45577
+ example: "Robot — filter 10 %",
45578
+ kinds: CONSUMABLE
45579
+ },
45580
+ {
45581
+ name: "summaryTanks",
45582
+ label: "Summary: tanks",
45583
+ example: "Robot — clean water low",
45584
+ kinds: TANK
45585
+ },
45586
+ {
45587
+ name: "summaryDetection",
45588
+ label: "Summary: cameras detecting nothing",
45589
+ example: "Ingresso — since 05:10",
45590
+ kinds: ["detection-blind"]
45591
+ },
45592
+ {
45593
+ name: "summaryNodes",
45594
+ label: "Summary: nodes",
45595
+ example: "little-unraid — offline since 03:00",
45596
+ kinds: [
45597
+ "node-offline",
45598
+ "node-online",
45599
+ "node-inference-unavailable"
45600
+ ]
45601
+ },
45602
+ {
45603
+ name: "summaryAddons",
45604
+ label: "Summary: addons",
45605
+ example: "@camstack/addon-recorder 1.2.3 → 1.2.4",
45606
+ kinds: [
45607
+ "addon-crash-loop",
45608
+ "addon-update-available",
45609
+ "addon-updated"
45610
+ ]
45611
+ },
45612
+ {
45613
+ name: "summaryUpdates",
45614
+ label: "Summary: server & container updates",
45615
+ example: "server 1.2.377 → 1.2.378",
45616
+ kinds: [
45617
+ "server-update-available",
45618
+ "server-updated",
45619
+ "wrapper-update-available"
45620
+ ]
45621
+ }
45622
+ ];
45623
+ var STATE_SUMMARY_VARS = [
45624
+ {
45625
+ name: "summaryText",
45626
+ label: "Summary: every section",
45627
+ description: "One block per section with something to report, one line per item.",
45628
+ example: "Batterie scariche: Sensore porta — 8 %",
45629
+ group: "system",
45630
+ families: ["rule"],
45631
+ fields: [...RULE_TEXT],
45632
+ kinds: ["system"],
45633
+ systemEventKinds: [...SUMMARISABLE],
45634
+ systemEventDeliveries: ["summary"]
45635
+ },
45636
+ {
45637
+ name: "summaryCount",
45638
+ label: "Summary: items reported",
45639
+ example: "3",
45640
+ group: "system",
45641
+ families: ["rule"],
45642
+ fields: [...RULE_TEXT],
45643
+ kinds: ["system"],
45644
+ systemEventKinds: [...SUMMARISABLE],
45645
+ systemEventDeliveries: ["summary"]
45646
+ },
45647
+ ...STATE_SUMMARY_SECTION_VARS.map((v) => ({
45648
+ name: v.name,
45649
+ label: v.label,
45650
+ example: v.example,
45651
+ group: "system",
45652
+ families: ["rule"],
45653
+ fields: [...RULE_TEXT],
45654
+ kinds: ["system"],
45655
+ systemEventKinds: [...v.kinds],
45656
+ systemEventDeliveries: ["summary"]
45657
+ }))
45658
+ ];
45659
+ [
45660
+ [...DEVICE_EVENTS],
45661
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
45662
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
45663
+ [...RULE_TEXT],
45664
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
45665
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
45666
+ [...RULE_TEXT],
45667
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
45668
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
45669
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
45670
+ [...RULE_TEXT],
45671
+ [...RULE_TEXT],
45672
+ [...RULE_TEXT],
45673
+ [...RULE_TEXT],
45674
+ [...RULE_TEXT],
45675
+ [...RULE_TEXT],
45676
+ [...RULE_TEXT],
45677
+ [...RULE_TEXT],
45678
+ [...RULE_BODY_ONLY],
45679
+ [...RULE_TEXT],
45680
+ ([...RULE_TEXT], [...DEVICE_EVENTS]),
45681
+ ([...RULE_TEXT], [...DEVICE_EVENTS]),
45682
+ ([...RULE_TEXT], [...BATTERY, ...CONSUMABLE]),
45683
+ ([...RULE_TEXT], [...CONSUMABLE]),
45684
+ ([...RULE_TEXT], [...TANK]),
45685
+ [...RULE_TEXT],
45686
+ ([...RULE_TEXT], [...UPDATES]),
45687
+ ([...RULE_TEXT], [...UPDATES]),
45688
+ [...RULE_TEXT],
45689
+ [...RULE_TEXT],
45690
+ [...RULE_TEXT],
45691
+ ([...RULE_TEXT], [...UPDATES]),
45692
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
45693
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
45694
+ ([...RULE_TEXT], [...UPDATES]),
45695
+ ([...RULE_TEXT], [...UPDATES]),
45696
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
45697
+ [...RULE_TEXT],
45698
+ [...RULE_TEXT],
45699
+ [...RULE_TEXT],
45700
+ [...RULE_TEXT],
45701
+ [...RULE_TEXT],
45702
+ [...RULE_TEXT],
45703
+ [...RULE_TEXT],
45704
+ [...RULE_TEXT],
45705
+ [...RULE_TEXT],
45706
+ [...RULE_TEXT],
45707
+ [...RULE_TEXT],
45708
+ [...RULE_TEXT],
45709
+ [...RULE_TEXT],
45710
+ [...RULE_TEXT],
45711
+ [...RULE_TEXT],
45712
+ [...RULE_TEXT],
45713
+ [...RULE_TEXT],
45714
+ [...RULE_TEXT],
45715
+ [...RULE_TEXT],
45716
+ [...RULE_TEXT],
45717
+ [...RULE_TEXT],
45718
+ [...RULE_TEXT],
45719
+ [...RULE_TEXT],
45720
+ [...RULE_TEXT],
45721
+ ...STATE_SUMMARY_VARS
45722
+ ];
44462
45723
  /**
44463
45724
  * TimelapseRule — the STANDALONE scheduled timelapse producer's rule model.
44464
45725
  *
@@ -44690,68 +45951,6 @@ TimelapseRuleInputSchema.extend({
44690
45951
  createdAt: number$1(),
44691
45952
  updatedAt: number$1()
44692
45953
  });
44693
- Object.freeze(Object.fromEntries([{
44694
- stepId: "face-embedding",
44695
- label: "Face recognition model",
44696
- defaultModelId: "arcface-r100",
44697
- indexName: "the enrolled face gallery",
44698
- options: [
44699
- {
44700
- id: "arcface-r100",
44701
- label: "ArcFace (ResNet34)"
44702
- },
44703
- {
44704
- id: "auraface-r100",
44705
- label: "AuraFace R100"
44706
- },
44707
- {
44708
- id: "inception-resnet-v1",
44709
- label: "Inception ResNet V1"
44710
- }
44711
- ]
44712
- }, {
44713
- stepId: "clip-embedding",
44714
- label: "Semantic search model",
44715
- defaultModelId: "mobileclip-s1",
44716
- indexName: "the object semantic-search index",
44717
- options: [{
44718
- id: "mobileclip-s1",
44719
- label: "MobileCLIP S1"
44720
- }, {
44721
- id: "mobileclip-s2",
44722
- label: "MobileCLIP S2"
44723
- }]
44724
- }].map((s) => [s.stepId, s.defaultModelId])));
44725
- string().min(1);
44726
- var CLUSTER_STEP_SETTING_FIELDS = [{
44727
- stepId: "face-embedding",
44728
- key: "minLandmarkFaceSize",
44729
- label: "Min face size for recognition (detection px)",
44730
- description: "Refuse to embed a face smaller than this IN THE DETECTION FRAME. Applies to every node — the enrolled gallery is one index, and two admission floors would fill it from two policies. 0 disables the gate.",
44731
- type: "slider",
44732
- min: 0,
44733
- max: 64,
44734
- step: 2,
44735
- default: 24
44736
- }];
44737
- function clusterStepSettingKey(stepId, fieldKey) {
44738
- return `clusterStepSetting:${stepId}:${fieldKey}`;
44739
- }
44740
- var ClusterSettingNumberSchema = number$1().finite();
44741
- function readClusterStepSettings(config) {
44742
- const out = {};
44743
- for (const field of CLUSTER_STEP_SETTING_FIELDS) {
44744
- const parsed = ClusterSettingNumberSchema.safeParse(config[clusterStepSettingKey(field.stepId, field.key)]);
44745
- const value = parsed.success ? parsed.data : field.default;
44746
- const existing = out[field.stepId] ?? {};
44747
- out[field.stepId] = {
44748
- ...existing,
44749
- [field.key]: value
44750
- };
44751
- }
44752
- return out;
44753
- }
44754
- readClusterStepSettings({});
44755
45954
  object({
44756
45955
  /**
44757
45956
  * Fraction of the box's own size added on EACH side before cutting.