@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.js CHANGED
@@ -5525,7 +5525,7 @@ function number(params) {
5525
5525
  return /* @__PURE__ */ _coercedNumber(ZodNumber, params);
5526
5526
  }
5527
5527
  //#endregion
5528
- //#region ../types/dist/sleep-D_4W7xuQ.mjs
5528
+ //#region ../types/dist/sleep-BXv0ZcRa.mjs
5529
5529
  /**
5530
5530
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5531
5531
  * window to float samples (D455).
@@ -6310,6 +6310,40 @@ var BaseAddon = class {
6310
6310
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6311
6311
  return keys.size > 0 ? projectStore(raw, keys, node) : raw;
6312
6312
  }
6313
+ /**
6314
+ * Whether ONE global key of this addon's store was written, read three-way
6315
+ * (D651). For a question a hydrated view cannot answer: `getGlobalSettings`
6316
+ * reports `value ?? default`, so "the operator chose the default" and "nobody
6317
+ * chose" look the same, and a failed read looks like both. A `perNode` key is
6318
+ * not supported here: its stored name is scoped.
6319
+ */
6320
+ async readStoredGlobalKey(key) {
6321
+ const read = this._ctx?.settings?.readAddonStoreResult;
6322
+ if (read === void 0) return {
6323
+ kind: "unreadable",
6324
+ reason: "three-way-read-unavailable"
6325
+ };
6326
+ let result;
6327
+ try {
6328
+ result = await read.call(this._ctx?.settings);
6329
+ } catch (err) {
6330
+ return {
6331
+ kind: "unreadable",
6332
+ reason: "store-read-failed",
6333
+ error: err instanceof Error ? err.message : String(err)
6334
+ };
6335
+ }
6336
+ if (result.kind === "failed") return {
6337
+ kind: "unreadable",
6338
+ reason: "store-read-failed",
6339
+ error: result.error
6340
+ };
6341
+ if (result.kind === "missing" || !Object.prototype.hasOwnProperty.call(result.value, key)) return { kind: "absent" };
6342
+ return {
6343
+ kind: "present",
6344
+ value: result.value[key]
6345
+ };
6346
+ }
6313
6347
  async updateGlobalSettings(patch, nodeId) {
6314
6348
  const keys = this.perNodeKeys();
6315
6349
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
@@ -9611,6 +9645,43 @@ var LogChannelWindowSchema = object({
9611
9645
  /** `null` = every camera. A non-empty list narrows to those numeric ids. */
9612
9646
  deviceIds: array(number$1().int()).readonly().nullable()
9613
9647
  });
9648
+ var ClipModelMetaSchema = object({
9649
+ /** The paired text encoder's catalog id (the embedding-encoder's text catalog). */
9650
+ textModelId: string().min(1),
9651
+ /** Output dimension of BOTH towers. A vector of any other length is refused. */
9652
+ embeddingDim: number$1().int().positive(),
9653
+ /**
9654
+ * The `vector-store` index this model's vectors live in. ONE feature space
9655
+ * per index: two models share an index only when their vectors are ranked
9656
+ * against each other, which for CLIP means never across families. MobileCLIP
9657
+ * S1 and S2 share `object-clip` for history (separated by the row's
9658
+ * `modelId`); any other model gets its own.
9659
+ */
9660
+ vectorIndex: string().regex(/^object-clip(-[a-z0-9][a-z0-9-]*)?$/),
9661
+ /**
9662
+ * The text encoder's tokenizer, a declared SIBLING file of its onnx. The name
9663
+ * must be unique per tokenizer: every model's siblings land in ONE flat
9664
+ * models directory, so two different tokenizers under the same name would
9665
+ * silently overwrite each other (whichever model downloaded last wins, and
9666
+ * the other one tokenises with the wrong vocabulary).
9667
+ */
9668
+ tokenizerFile: string().min(1),
9669
+ /** Token window the text graph takes (SigLIP2: 64; CLIP BPE: 77). */
9670
+ contextLength: number$1().int().positive(),
9671
+ /** Id the tokenizer pads with. */
9672
+ padId: number$1().int().nonnegative(),
9673
+ /**
9674
+ * The search cosine floor at `strictness: 'loose'` — calibrated per model,
9675
+ * because cosine bands are a property of the model: 0.2 keeps 96% of matched
9676
+ * COCO caption-image pairs on MobileCLIP S1 and 2.7% on SigLIP2.
9677
+ */
9678
+ searchMinScore: number$1().min(0).max(1)
9679
+ });
9680
+ var ClipSearchStrictnessSchema = _enum([
9681
+ "loose",
9682
+ "balanced",
9683
+ "strict"
9684
+ ]);
9614
9685
  var MODEL_FORMATS = [
9615
9686
  "onnx",
9616
9687
  "coreml",
@@ -9639,7 +9710,7 @@ var ModelFormatEntrySchema = object({
9639
9710
  /** Multi-file payload (directory members or sibling files). */
9640
9711
  files: array(string()).readonly().optional(),
9641
9712
  /** Runtime(s) that can use this format. If omitted, inferred from ModelFormat key */
9642
- runtimes: array(_enum(["node", "python"])).readonly().optional()
9713
+ runtimes: array(_enum(["python"])).readonly().optional()
9643
9714
  });
9644
9715
  /**
9645
9716
  * Extra file that must be downloaded alongside the model (e.g., labels JSON, dict.txt).
@@ -9720,10 +9791,17 @@ var ModelCatalogEntrySchema = object({
9720
9791
  inputChannels: number$1().int().positive().optional(),
9721
9792
  labels: array(LabelDefinitionSchema).readonly(),
9722
9793
  inputLayout: _enum(["nchw", "nhwc"]).optional(),
9794
+ /**
9795
+ * `'scrfd'` applies InsightFace's SCRFD input contract, `(x - 127.5) / 128`
9796
+ * (upstream `insightface/model_zoo/scrfd.py`), instead of the historical
9797
+ * plain `/255`. Measured against COCO GT: 188 → 196 faces found on the
9798
+ * `scrfd-2.5g` catalog entry (2026-09-26 model-replacement spike, §2.4-2).
9799
+ */
9723
9800
  inputNormalization: _enum([
9724
9801
  "zero-one",
9725
9802
  "imagenet",
9726
- "none"
9803
+ "none",
9804
+ "scrfd"
9727
9805
  ]).optional(),
9728
9806
  /**
9729
9807
  * The model already applies softmax IN-GRAPH — its raw output is a
@@ -9807,7 +9885,14 @@ var ModelCatalogEntrySchema = object({
9807
9885
  * applies (Frigate / COCO public catalog). Set on a custom model whose raw
9808
9886
  * labels already ARE the CamStack macros (Scrypted identity map).
9809
9887
  */
9810
- classMap: DetectionCatalogClassMapSchema.optional()
9888
+ classMap: DetectionCatalogClassMapSchema.optional(),
9889
+ /**
9890
+ * The model's CLIP feature-space contract (text encoder, dimension, vector
9891
+ * index, token window, search floor) — see `clip-model.ts`. Present ONLY on a
9892
+ * CLIP image encoder; its absence is what "not a CLIP model" means to the
9893
+ * embedding encoder and the semantic-search store (D649).
9894
+ */
9895
+ clip: ClipModelMetaSchema.optional()
9811
9896
  });
9812
9897
  var ConvertTargetSchema = discriminatedUnion("format", [object({
9813
9898
  format: literal("openvino"),
@@ -9825,7 +9910,8 @@ var ModelConvertMetadataSchema = object({
9825
9910
  inputNormalization: _enum([
9826
9911
  "zero-one",
9827
9912
  "imagenet",
9828
- "none"
9913
+ "none",
9914
+ "scrfd"
9829
9915
  ]).optional(),
9830
9916
  preprocessMode: _enum(["letterbox", "resize"]).optional(),
9831
9917
  outputFormat: _enum([
@@ -14024,6 +14110,13 @@ var LinkedDeviceSchema = object({
14024
14110
  features: array(string()),
14025
14111
  producesTrackedEvents: boolean().optional()
14026
14112
  });
14113
+ /**
14114
+ * The `linked-devices` extension slot's editable value (D648): the operator's
14115
+ * pick list, exactly what `_linkedDeviceIds` persists. Tree children are NOT
14116
+ * in it — they are always linked and are not a pick.
14117
+ */
14118
+ var LinkedDevicesSlotValueSchema = object({ deviceIds: array(number$1().int().positive()) });
14119
+ DeviceType.Camera;
14027
14120
  /** One camera's resolved linked set, tagged with the camera it belongs to.
14028
14121
  * The batch answer needs the tag; the single-device answer already has it
14029
14122
  * from the input, which is why `getLinkedDevices` keeps the untagged shape. */
@@ -14549,16 +14642,101 @@ var EmbeddingResultSchema = object({
14549
14642
  embedding: array(number$1()),
14550
14643
  inferenceMs: number$1()
14551
14644
  });
14645
+ /** The two CLIP towers the encoder runs; a crash budget is kept per tower. */
14646
+ var EmbeddingTowerSchema = _enum(["image", "text"]);
14647
+ /**
14648
+ * A tower in the terminal `failed` state (D649, D6): it crashed or failed to
14649
+ * load `crashes` times within `windowMs`, and is refused by name until an
14650
+ * operator `resetFailedModels` or a model change — never on a timer.
14651
+ *
14652
+ * `nodeId` is the node whose tower failed. The state lives in THAT node's
14653
+ * encoder process (in memory — a runner respawn clears it), and one node's
14654
+ * answer says nothing about another's.
14655
+ */
14656
+ var EmbeddingFailedModelSchema = object({
14657
+ modelId: string(),
14658
+ tower: EmbeddingTowerSchema,
14659
+ nodeId: string(),
14660
+ crashes: number$1(),
14661
+ windowMs: number$1(),
14662
+ sinceMs: number$1(),
14663
+ lastReason: string()
14664
+ });
14665
+ /**
14666
+ * A model whose REQUIREMENTS can never be met on this node (D649 round 5):
14667
+ * an id the catalog does not know, a model URL answering 404/410, a declared
14668
+ * sibling (the tokenizer) that is not there. After `attempts` failed builds
14669
+ * it is terminally `requirements-failed`, refused by name until an operator
14670
+ * `resetFailedModels` or a model change — the same exits as a crashed tower.
14671
+ */
14672
+ var EmbeddingFailedRequirementSchema = object({
14673
+ modelId: string(),
14674
+ tower: EmbeddingTowerSchema,
14675
+ nodeId: string(),
14676
+ attempts: number$1(),
14677
+ sinceMs: number$1(),
14678
+ lastReason: string()
14679
+ });
14552
14680
  var EmbeddingInfoSchema = object({
14553
14681
  modelId: string(),
14554
14682
  embeddingDim: number$1(),
14555
- ready: boolean()
14556
- });
14683
+ ready: boolean(),
14684
+ /**
14685
+ * The node that answered. Absent only from an encoder older than D649's
14686
+ * crash budget — whose `failedModels` is then UNKNOWN (D315), never "none".
14687
+ */
14688
+ nodeId: string().optional(),
14689
+ /**
14690
+ * Towers in `failed` on the answering node, each row naming it. `undefined`
14691
+ * means the node could not say (pre-budget encoder); a node that has the
14692
+ * budget always answers an array, empty included.
14693
+ */
14694
+ failedModels: array(EmbeddingFailedModelSchema).optional(),
14695
+ /** Models terminally `requirements-failed` on the answering node; same reading as above. */
14696
+ failedRequirements: array(EmbeddingFailedRequirementSchema).optional()
14697
+ });
14698
+ /**
14699
+ * The THREE codes an encoder refusal can carry (D649, D6). Same shape as
14700
+ * `VECTOR_INDEX_DIM_CONFLICT`: the code rides in the MESSAGE, because an
14701
+ * Error's own properties do not survive the UDS/tRPC hop and its message does,
14702
+ * and both sides go through the helpers below — the encoder builds the
14703
+ * refusal, the live detail plane classifies on it to count refusals per
14704
+ * camera instead of logging one warning per track. The bracketed token
14705
+ * carries the code, the model, the tower and the node so a consumer never
14706
+ * parses prose.
14707
+ *
14708
+ * - `EMBEDDING_MODEL_FAILED`: the tower crashed / failed to load past the crash
14709
+ * budget — terminal until `resetFailedModels` or a model change.
14710
+ * - `EMBEDDING_REQUIREMENTS_UNAVAILABLE`: files or runtime not there right now
14711
+ * (a download or Python that failed, or the cooldown after one) — the next
14712
+ * request past the cooldown tries again.
14713
+ * - `EMBEDDING_REQUIREMENTS_FAILED`: the requirements can never be met (unknown
14714
+ * id, 404/410, missing sibling) and the bounded attempts are spent —
14715
+ * terminal, same exits as a crashed tower.
14716
+ */
14717
+ var EMBEDDING_MODEL_FAILED = "embedding-model-failed";
14718
+ var EMBEDDING_REQUIREMENTS_UNAVAILABLE = "embedding-requirements-unavailable";
14719
+ var EMBEDDING_REQUIREMENTS_FAILED = "embedding-requirements-failed";
14720
+ _enum([
14721
+ EMBEDDING_MODEL_FAILED,
14722
+ EMBEDDING_REQUIREMENTS_UNAVAILABLE,
14723
+ EMBEDDING_REQUIREMENTS_FAILED
14724
+ ]);
14725
+ new RegExp(`\\[(${EMBEDDING_MODEL_FAILED}|${EMBEDDING_REQUIREMENTS_UNAVAILABLE}|${EMBEDDING_REQUIREMENTS_FAILED}) model=([^\\s\\]]+) tower=(image|text) node=([^\\s\\]]+)\\]`);
14557
14726
  method(object({
14558
14727
  crop: _instanceof(Uint8Array),
14559
14728
  width: number$1(),
14560
14729
  height: number$1()
14561
- }), EmbeddingResultSchema, { auth: "admin" }), method(object({ text: string() }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" });
14730
+ }), EmbeddingResultSchema, { auth: "admin" }), method(object({
14731
+ text: string(),
14732
+ modelId: string().min(1).optional()
14733
+ }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" }), method(object({ modelId: string().min(1).optional() }), object({
14734
+ cleared: array(string()),
14735
+ nodeId: string()
14736
+ }), {
14737
+ kind: "mutation",
14738
+ auth: "admin"
14739
+ });
14562
14740
  /**
14563
14741
  * `failure-contribution` — the capability an addon reports its OWN losses
14564
14742
  * through, per camera, with the denominator attached. It stores nothing.
@@ -17311,6 +17489,9 @@ var NcSystemEventKindSchema = _enum([
17311
17489
  "device-battery-normal",
17312
17490
  "device-consumable-low",
17313
17491
  "device-consumable-normal",
17492
+ "device-tank-low",
17493
+ "device-tank-full",
17494
+ "device-tank-normal",
17314
17495
  "stream-online",
17315
17496
  "stream-offline",
17316
17497
  "node-online",
@@ -17348,6 +17529,29 @@ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
17348
17529
  ]);
17349
17530
  NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
17350
17531
  /**
17532
+ * The panel's transitions, as ONE list.
17533
+ *
17534
+ * Named here rather than spelled out at each of the four sites that need them
17535
+ * (the emitter, the intake, the editor group, the combined-notification gate),
17536
+ * because a transition added to the enum and forgotten at one of them is an
17537
+ * alarm state nobody can be notified about. That is exactly what this list
17538
+ * failed to prevent while it held three: `alarm-arming` was the fourth.
17539
+ *
17540
+ * In LIFECYCLE order, which is the order an editor lists them in and the order
17541
+ * a person experiences them — not the order they were added.
17542
+ */
17543
+ var NC_ALARM_SYSTEM_EVENT_KINDS = [
17544
+ "alarm-arm-refused",
17545
+ "alarm-check-failed",
17546
+ "alarm-arming",
17547
+ "alarm-armed",
17548
+ "alarm-pending",
17549
+ "alarm-triggered",
17550
+ "alarm-rearmed",
17551
+ "alarm-sensor-bypass",
17552
+ "alarm-disarmed"
17553
+ ];
17554
+ /**
17351
17555
  * One coherent system-event condition. `kinds` is the required opt-in safety
17352
17556
  * gate; the remaining lists are optional narrowing filters relevant to the
17353
17557
  * selected kinds.
@@ -17381,7 +17585,22 @@ var NcSystemEventConditionSchema = object({
17381
17585
  */
17382
17586
  excludeDeviceIds: array(number$1().int()).min(1).optional(),
17383
17587
  nodeIds: array(string().min(1)).min(1).optional(),
17384
- packageNames: array(string().min(1)).min(1).optional()
17588
+ packageNames: array(string().min(1)).min(1).optional(),
17589
+ /**
17590
+ * At or below this remaining-life %, a consumable is LOW for THIS rule
17591
+ * (D642). Absent = {@link NC_CONSUMABLE_LOW_PERCENT_DEFAULT}; at most
17592
+ * {@link NC_CONSUMABLE_LOW_PERCENT_MAX}, so every episode can recover. Scoped to the
17593
+ * consumable kinds (`systemEventFilterApplies`) and to the device-events
17594
+ * family; ignored on every other kind.
17595
+ *
17596
+ * It is a property of the RULE because the operator decided so: a rule at
17597
+ * 25 must be told about a filter at 20 %, a rule at 10 must not. The hub
17598
+ * keeps one episode per (threshold, device, item) — its own hysteresis, its
17599
+ * own reminder — and a rule hears only the episode judged at ITS threshold,
17600
+ * exactly as an occupancy rule hears only the edge of its own count. A
17601
+ * provider's own `replace` verdict is low at every threshold.
17602
+ */
17603
+ consumableLowPercent: number$1().int().min(1).max(95).optional()
17385
17604
  });
17386
17605
  /** Hard ceiling on a window (24h). A snooze that could not expire would be an
17387
17606
  * outage the operator asked for once and forgot. */
@@ -17399,6 +17618,25 @@ var NcScheduleSchema = object({
17399
17618
  /** Active OUTSIDE the windows (e.g. "only outside business hours"). */
17400
17619
  invert: boolean().optional()
17401
17620
  });
17621
+ /**
17622
+ * How a system-event rule of the `device-events` or `system` family speaks
17623
+ * (D647): at once, per event (`instant`, the only behaviour before D647), or
17624
+ * as a STATE SUMMARY at the end of each window of `schedule`.
17625
+ */
17626
+ var NcSystemEventDeliveryModeSchema = _enum(["instant", "summary"]);
17627
+ /**
17628
+ * `summary`: the rule sends NOTHING per event. When a window of `schedule`
17629
+ * CLOSES, it sends one notification with the current state of its kinds
17630
+ * (low batteries, consumables to replace, devices offline, updates
17631
+ * available, ...), after its own filters. Nothing to report sends nothing.
17632
+ * The schedule is the ordinary `NcSchedule` (weekly windows, IANA timezone,
17633
+ * midnight crossing); the send time is each window's END. Refused on the
17634
+ * `alarm` family, which stays instant (`systemEventDeliveryProblems`).
17635
+ */
17636
+ var NcSystemEventDeliverySchema = discriminatedUnion("mode", [object({ mode: literal("instant") }), object({
17637
+ mode: literal("summary"),
17638
+ schedule: NcScheduleSchema
17639
+ })]);
17402
17640
  /** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
17403
17641
  var NcPlateMatcherSchema = object({
17404
17642
  /**
@@ -17524,6 +17762,16 @@ var NcCrossingSchema = _enum([
17524
17762
  "exit",
17525
17763
  "any"
17526
17764
  ]);
17765
+ /**
17766
+ * Which edge of a BOOLEAN sensor fires a device-event rule (D640).
17767
+ * - `raised` — the sensor went high: water detected, smoke, open, tampered.
17768
+ * - `cleared` — it went back: dry, clear, closed.
17769
+ * - absent — both edges, which is what every rule authored before this did.
17770
+ *
17771
+ * There is no third member for "both": absence already says it, and a value
17772
+ * that means the same as absence is a second way to write one rule.
17773
+ */
17774
+ var NcSensorTransitionSchema = _enum(["raised", "cleared"]);
17527
17775
  /** Admin-zone membership condition (zone IDs as stamped by the ZoneEngine). */
17528
17776
  var NcZoneConditionSchema = object({
17529
17777
  ids: array(string().min(1)).min(1),
@@ -17713,6 +17961,20 @@ var NcConditionsSchema = object({
17713
17961
  scene: NcSceneConditionSchema.optional(),
17714
17962
  /** Device scope — absent = all devices. */
17715
17963
  devices: array(number$1()).optional(),
17964
+ /**
17965
+ * Device EXCLUSION (D641) — "every device except these". Judged on the SAME
17966
+ * subject ids {@link devices} is judged on (the camera, the sensor that
17967
+ * fired, a linked set's sensor and row cameras), so a sensor fanned out per
17968
+ * linked camera is excluded exactly where an include would have tested it.
17969
+ * `min(1)`: an empty exclusion excludes nothing and is written as absent.
17970
+ *
17971
+ * Not for `system-event` rules — those carry their own
17972
+ * `systemEvent.excludeDeviceIds` (D636), and the hub refuses this key there.
17973
+ * Editors present the two lists as ONE field (All | Only these | All except
17974
+ * these); the engine evaluates each independently, so a legacy rule
17975
+ * carrying both still means "these, minus those".
17976
+ */
17977
+ devicesExclude: array(number$1()).min(1).optional(),
17716
17978
  /** Detector class names (any overlap with the record's class set). */
17717
17979
  classes: array(string().min(1)).optional(),
17718
17980
  /** Veto classes — any overlap fails the rule. */
@@ -17846,6 +18108,16 @@ var NcConditionsSchema = object({
17846
18108
  */
17847
18109
  sensorKinds: array(string().min(1)).optional(),
17848
18110
  /**
18111
+ * DEVICE-EVENT only (D640). Fire on one edge of a boolean sensor —
18112
+ * {@link NcSensorTransitionSchema}. Which field of the slice means "raised"
18113
+ * is `@camstack/types` → `notification/sensor-raised.ts`. A reading the
18114
+ * engine cannot place (a kind with no raise, an unreadable slice) PASSES:
18115
+ * the condition fails open towards notifying, never towards silence. Editors
18116
+ * offer it only when every chosen {@link sensorKinds} member has a raise
18117
+ * (`sensorTransitionOffered`), and the hub refuses it on any other delivery.
18118
+ */
18119
+ sensorTransition: NcSensorTransitionSchema.optional(),
18120
+ /**
17849
18121
  * PACKAGE-EVENT only. Which package phase fires the rule — `delivered`
17850
18122
  * (a parked parcel appeared), `picked-up` (it departed), or `both`. Fails
17851
18123
  * when the subject's phase does not match (a subject always carries a phase
@@ -17978,7 +18250,12 @@ var NcMediaPolicySchema = object({
17978
18250
  * the degrade engine, which drops the video and keeps the still.
17979
18251
  */
17980
18252
  clip: boolean().optional(),
17981
- /** Seconds of footage BEFORE / AFTER the event instant. Defaults 3 / 7. */
18253
+ /**
18254
+ * Seconds of footage BEFORE / AFTER the event instant. Absent =
18255
+ * {@link NC_CLIP_PRE_ROLL_DEFAULT_SEC} / {@link NC_CLIP_POST_ROLL_DEFAULT_SEC}
18256
+ * (4 / 6), resolved by the Notification Center at dispatch — deliberately not
18257
+ * a Zod default, so a rule that never chose keeps following the hub's.
18258
+ */
17982
18259
  clipPreRollSec: number$1().int().min(0).max(30).optional(),
17983
18260
  clipPostRollSec: number$1().int().min(0).max(30).optional(),
17984
18261
  /**
@@ -18100,6 +18377,16 @@ var NcRuleInputSchema = object({
18100
18377
  delivery: NcDeliverySchema,
18101
18378
  conditions: NcConditionsSchema.default({}),
18102
18379
  schedule: NcScheduleSchema.optional(),
18380
+ /**
18381
+ * A `device-events` / `system` rule's delivery (D647): absent or `instant`
18382
+ * is a notification per event; `summary` is one state summary per closed
18383
+ * window of its schedule. `.optional()` and never defaulted: absent must
18384
+ * keep meaning what every rule authored before D647 meant, with no
18385
+ * migration. Top-level rather than inside `conditions.systemEvent`, so a
18386
+ * client that does not know it (an older viewer re-sending `conditions`
18387
+ * whole) leaves it standing through the store's patch merge.
18388
+ */
18389
+ systemEventDelivery: NcSystemEventDeliverySchema.optional(),
18103
18390
  /** May be empty when `targetUsers` addresses at least one user — the
18104
18391
  * "at least one addressee" invariant is enforced by the provider, because
18105
18392
  * a cross-field refine here would break `NcRulePatchSchema.partial()`. */
@@ -18328,6 +18615,28 @@ var NcRuleSchema = NcRuleInputSchema.extend({
18328
18615
  */
18329
18616
  disabledTargetIds: array(string()).default([])
18330
18617
  });
18618
+ /** One section of a previewed state summary. `unavailable` = its state could not be read. */
18619
+ var NcStateSummaryPreviewSectionSchema = object({
18620
+ id: string(),
18621
+ status: _enum(["read", "unavailable"]),
18622
+ items: number$1().int().nonnegative(),
18623
+ reason: string().optional()
18624
+ });
18625
+ /**
18626
+ * The summary a rule would send now. `empty` = nothing to report and every
18627
+ * section read: such a summary is NOT sent. `dropped` counts the open states
18628
+ * the rule's own filters (or a camera mute) left out, by reason.
18629
+ * `excludedGroups` names the kind groups selected that have no state to report
18630
+ * (backups & exports).
18631
+ */
18632
+ var NcStateSummaryPreviewSchema = object({
18633
+ empty: boolean(),
18634
+ count: number$1().int().nonnegative(),
18635
+ text: string(),
18636
+ sections: array(NcStateSummaryPreviewSectionSchema),
18637
+ dropped: record(string(), number$1().int().nonnegative()),
18638
+ excludedGroups: array(string())
18639
+ });
18331
18640
  var NcTestResultSchema = object({
18332
18641
  recordId: string(),
18333
18642
  recordKind: _enum([
@@ -18345,9 +18654,29 @@ var NcTestResultSchema = object({
18345
18654
  className: string().optional(),
18346
18655
  label: string().optional()
18347
18656
  });
18348
- /** The five rule kinds, as data. `NcRuleKind` in `notification/rule-kinds.ts`
18349
- * is the same union; the template-vars spec pins the two together. */
18657
+ /** The rule kinds, as data. `NcRuleKind` in `notification/rule-kinds.ts` is the
18658
+ * same union; the template-vars spec pins the two together. `mixed` is DERIVED
18659
+ * (a stored system rule whose kinds span families, D637) and never authored. */
18350
18660
  var NcRuleKindSchema = _enum([
18661
+ "detection",
18662
+ "sensor",
18663
+ "occupancy",
18664
+ "sound",
18665
+ "device-events",
18666
+ "system",
18667
+ "alarm",
18668
+ "mixed"
18669
+ ]);
18670
+ /**
18671
+ * The kinds a SERVED template-variable descriptor may name: the five that
18672
+ * existed before D637, frozen. `getTemplateCatalog` ships `kinds` to every
18673
+ * installed viewer, and a viewer at `@camstack/types` 1.2.25x parses them with a
18674
+ * strict five-member enum — one `device-events` in one descriptor fails the
18675
+ * whole catalog parse. So the WIRE says `system`, and the MATCH widens it:
18676
+ * `templateVarKindApplies` reads a `system` descriptor as applying to every
18677
+ * system rule kind (`device-events`, `system`, `alarm`, `mixed`).
18678
+ */
18679
+ var NcTemplateVarKindSchema = _enum([
18351
18680
  "detection",
18352
18681
  "sensor",
18353
18682
  "occupancy",
@@ -18385,7 +18714,7 @@ var NcTemplateVarGroupSchema = _enum([
18385
18714
  *
18386
18715
  * `families` / `fields` / `kinds` / `deliveries` / `systemEventKinds` say WHERE
18387
18716
  * it has a value; absent = no restriction on that axis. `systemEventKinds` is
18388
- * read only for a `system` rule. `dynamic` declares a FAMILY of names
18717
+ * read only for a system-event rule (any family, or `mixed`). `dynamic` declares a FAMILY of names
18389
18718
  * (`count_<class>`): the descriptor's `name` is the example member.
18390
18719
  */
18391
18720
  var NcTemplateVarDescriptorSchema = object({
@@ -18396,9 +18725,16 @@ var NcTemplateVarDescriptorSchema = object({
18396
18725
  group: NcTemplateVarGroupSchema,
18397
18726
  families: array(NcTemplateFamilySchema).min(1),
18398
18727
  fields: array(NcTemplateFieldSchema).optional(),
18399
- kinds: array(NcRuleKindSchema).optional(),
18728
+ kinds: array(NcTemplateVarKindSchema).optional(),
18400
18729
  deliveries: array(NcDeliverySchema).optional(),
18401
18730
  systemEventKinds: array(NcSystemEventKindSchema).optional(),
18731
+ /**
18732
+ * Which system-event DELIVERY has a value for it (D647). Absent = an
18733
+ * instant row only when the descriptor names `systemEventKinds` (a
18734
+ * per-event fact: a summary row has no single device), and both otherwise.
18735
+ * `['summary']` marks the state-summary vocabulary (`{{summaryText}}`, ...).
18736
+ */
18737
+ systemEventDeliveries: array(NcSystemEventDeliveryModeSchema).optional(),
18402
18738
  dynamic: object({
18403
18739
  prefix: literal("count_"),
18404
18740
  from: literal("classes")
@@ -18411,7 +18747,9 @@ var NcTemplatePreviewInputSchema = object({
18411
18747
  field: NcTemplateFieldSchema,
18412
18748
  kind: NcRuleKindSchema.optional(),
18413
18749
  delivery: NcDeliverySchema.optional(),
18414
- systemEventKinds: array(NcSystemEventKindSchema).optional()
18750
+ systemEventKinds: array(NcSystemEventKindSchema).optional(),
18751
+ /** The rule's system-event delivery (D647); absent = instant. */
18752
+ systemEventDelivery: NcSystemEventDeliveryModeSchema.optional()
18415
18753
  }),
18416
18754
  template: object({
18417
18755
  title: string().max(500).optional(),
@@ -18444,6 +18782,7 @@ var NcConditionDescriptorSchema = object({
18444
18782
  /** Editor widget the UI renders — never hardcode per-condition forms. */
18445
18783
  valueType: _enum([
18446
18784
  "deviceIdList",
18785
+ "deviceIdExcludeList",
18447
18786
  "stringList",
18448
18787
  "number01",
18449
18788
  "number",
@@ -18454,6 +18793,7 @@ var NcConditionDescriptorSchema = object({
18454
18793
  "plateMatcher",
18455
18794
  "packagePhase",
18456
18795
  "crossingSelect",
18796
+ "sensorTransition",
18457
18797
  "polygonDraw",
18458
18798
  "occupancy",
18459
18799
  "audio",
@@ -18604,6 +18944,28 @@ var NcHistoryFilterSchema = object({
18604
18944
  limit: number$1().int().min(1).max(500).default(100)
18605
18945
  });
18606
18946
  /**
18947
+ * Every rule's last run, in one answer.
18948
+ *
18949
+ * A rule ABSENT from `runs` produced no delivery inside `horizonMs` — how far
18950
+ * back this answer looked, in ms before the hub's now. It is the outbox prune
18951
+ * window (7 days by default, operator-configurable), NARROWED when the read hit
18952
+ * its row bound: the answer never claims a window it did not read. `null` means
18953
+ * the operator keeps the outbox forever AND the read reached its end, so absent
18954
+ * means "never on record". A UI derives its "not in the last N days" from this
18955
+ * value, never from a constant — and only when the call ANSWERED (D315).
18956
+ */
18957
+ var NcRuleLastRunsSchema = object({
18958
+ runs: array(object({
18959
+ ruleId: string(),
18960
+ /** Fire time of the newest row (`createdAt`, epoch ms). */
18961
+ lastAt: number$1(),
18962
+ status: NcHistoryStatusSchema,
18963
+ /** The camera/device of that row (a digest row files under its first camera). */
18964
+ deviceId: number$1()
18965
+ })),
18966
+ horizonMs: number$1().nonnegative().nullable()
18967
+ });
18968
+ /**
18607
18969
  * What a snooze covers. Broader scopes win when several overlap, so one window
18608
18970
  * leaves ONE digest rather than a rule snooze and a whole-feed snooze both
18609
18971
  * summarising the same silence.
@@ -18784,6 +19146,14 @@ var NcAlarmModeCoverageSchema = object({
18784
19146
  /** Ids named by the covering rules. A SUBSET when `allDevices` is true. */
18785
19147
  deviceIds: array(number$1().int()),
18786
19148
  /**
19149
+ * D641: the ids NOT covered although `allDevices` is true — every unscoped
19150
+ * covering rule EXCLUDES them (`conditions.devicesExclude`) and no named rule
19151
+ * covers them. Always `[]` when `allDevices` is false. Excluded by the rules,
19152
+ * which is not the same as skipped by a switch: never in `skippedDevices`.
19153
+ * Defaulted so an answer computed before this field parses as "none".
19154
+ */
19155
+ allDevicesExcept: array(number$1().int()).default([]),
19156
+ /**
18787
19157
  * Devices this mode NAMES but cannot actually arm, each with the switch that
18788
19158
  * excludes it.
18789
19159
  *
@@ -18913,13 +19283,17 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
18913
19283
  }), object({ results: array(NcTestResultSchema) }), {
18914
19284
  kind: "mutation",
18915
19285
  auth: "admin"
19286
+ }), method(object({ rule: NcRuleInputSchema }), NcStateSummaryPreviewSchema, {
19287
+ kind: "mutation",
19288
+ auth: "admin",
19289
+ access: "view"
18916
19290
  }), method(object({}), object({
18917
19291
  catalog: array(NcConditionDescriptorSchema),
18918
19292
  taxonomy: NcTaxonomySchema.optional()
18919
19293
  })), method(object({}), object({ vars: array(NcTemplateVarDescriptorSchema) })), method(NcTemplatePreviewInputSchema, NcTemplatePreviewSchema, {
18920
19294
  kind: "mutation",
18921
19295
  access: "view"
18922
- }), 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 }), {
19296
+ }), 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 }), {
18923
19297
  kind: "mutation",
18924
19298
  caller: "required"
18925
19299
  }), method(object({ snoozeId: string() }), object({ success: literal(true) }), {
@@ -19259,758 +19633,282 @@ var OauthIntegrationDescriptorSchema = object({
19259
19633
  });
19260
19634
  method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
19261
19635
  /**
19262
- * Reference to the frame's retained NATIVE surface + the parent crop's placement
19263
- * within the frame, so the executor can re-cut a leaf child ROI at native
19264
- * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
19636
+ * A model choice has a SCOPE, and a scope change has a workflow.
19637
+ *
19638
+ * ## The two scopes
19639
+ *
19640
+ * Almost every pipeline step's model is a **node** question: which build runs
19641
+ * fastest on THIS accelerator. Two nodes may legitimately answer differently —
19642
+ * a Coral runs the tflite SSD, a Mac runs the coreml YOLO — because the answers
19643
+ * are compared against nothing. They produce boxes, and a box is a box.
19644
+ *
19645
+ * Two steps are not like that. `face-embedding` and `clip-embedding` produce
19646
+ * **vectors that land in ONE shared index** (`identity_samples`,
19647
+ * `vec_object_clip`) and are ranked against each other by cosine similarity.
19648
+ * Cosine similarity between two encoders is not a weak signal, it is a
19649
+ * meaningless number — and nothing inside a vector can tell you it happened.
19650
+ * So for those two steps the model is a **cluster** question with exactly one
19651
+ * answer, stored in exactly one row.
19652
+ *
19653
+ * That is the same argument [D52](../../../../docs/decisions/adr-0052.md) makes
19654
+ * for the crop convention (`detail-crop.ts`), one level up: the crop decides
19655
+ * WHAT pixels the encoder sees, this decides WHICH encoder sees them. Both are
19656
+ * cluster-wide for the same reason and neither may become per-node.
19657
+ *
19658
+ * ## Why the registry lives here and not in the step catalog
19659
+ *
19660
+ * The scope itself is declared on the step, in
19661
+ * `detection-pipeline/registry/step-definitions.ts` (`StepDefinition.modelScope`)
19662
+ * — that is where a new step declares what kind of choice its model is. But the
19663
+ * catalog lives inside `addon-pipeline`, and three packages that must NOT
19664
+ * import an addon need to know the set: the orchestrator (which renders and
19665
+ * stores the row), post-analysis (which pins the row for a re-embed pass) and
19666
+ * admin-ui (which mirrors it). So the set is mirrored here, and
19667
+ * `scripts/check-cluster-model-scope.ts` fails the build when the two disagree.
19668
+ * A hand-copied key that stops matching is exactly how a setting silently stops
19669
+ * arriving while both sides still look correct.
19670
+ *
19671
+ * ## The defaults ARE today's behaviour
19672
+ *
19673
+ * {@link DEFAULT_CLUSTER_STEP_MODELS} reproduces the catalog `defaultModelId`
19674
+ * of both steps. Declaring the scope therefore changes nothing on the day it
19675
+ * ships: the cluster row starts out saying what every node was already doing.
19676
+ * Changing it is legitimate — that is what the knob is for — but it invalidates
19677
+ * the stored vectors of that surface, and must be followed by a re-embed pass
19678
+ * (`face-reembed-pass.ts`, `embedding-rebuild.ts`).
19679
+ */
19680
+ /**
19681
+ * Why the orchestrator cannot say which model the operator chose for a
19682
+ * cluster-scoped step (D651).
19683
+ */
19684
+ var CLUSTER_MODEL_CHOICE_UNREADABLE_REASONS = [
19685
+ "owner-not-ready",
19686
+ "store-read-failed",
19687
+ "three-way-read-unavailable",
19688
+ "invalid-stored",
19689
+ "not-cluster-scoped"
19690
+ ];
19691
+ Object.freeze(Object.fromEntries([{
19692
+ stepId: "face-embedding",
19693
+ label: "Face recognition model",
19694
+ defaultModelId: "auraface-r100",
19695
+ indexName: "the enrolled face gallery",
19696
+ options: [
19697
+ {
19698
+ id: "auraface-r100",
19699
+ label: "AuraFace R100"
19700
+ },
19701
+ {
19702
+ id: "arcface-r100",
19703
+ label: "ArcFace (ResNet34)"
19704
+ },
19705
+ {
19706
+ id: "inception-resnet-v1",
19707
+ label: "Inception ResNet V1"
19708
+ }
19709
+ ]
19710
+ }, {
19711
+ stepId: "clip-embedding",
19712
+ label: "Semantic search model",
19713
+ defaultModelId: "mobileclip-s1",
19714
+ indexName: "the object semantic-search index",
19715
+ options: [
19716
+ {
19717
+ id: "mobileclip-s1",
19718
+ label: "MobileCLIP S1"
19719
+ },
19720
+ {
19721
+ id: "mobileclip-s2",
19722
+ label: "MobileCLIP S2"
19723
+ },
19724
+ {
19725
+ id: "siglip2-b16-224",
19726
+ label: "SigLIP2 B/16 (Apache-2.0)"
19727
+ }
19728
+ ]
19729
+ }].map((s) => [s.stepId, s.defaultModelId])));
19730
+ var CLUSTER_STEP_SETTING_FIELDS = [{
19731
+ stepId: "face-embedding",
19732
+ key: "minLandmarkFaceSize",
19733
+ label: "Min face size for recognition (detection px)",
19734
+ 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.",
19735
+ type: "slider",
19736
+ min: 0,
19737
+ max: 64,
19738
+ step: 2,
19739
+ default: 24
19740
+ }];
19741
+ function clusterStepSettingKey(stepId, fieldKey) {
19742
+ return `clusterStepSetting:${stepId}:${fieldKey}`;
19743
+ }
19744
+ var ClusterSettingNumberSchema = number$1().finite();
19745
+ function readClusterStepSettings(config) {
19746
+ const out = {};
19747
+ for (const field of CLUSTER_STEP_SETTING_FIELDS) {
19748
+ const parsed = ClusterSettingNumberSchema.safeParse(config[clusterStepSettingKey(field.stepId, field.key)]);
19749
+ const value = parsed.success ? parsed.data : field.default;
19750
+ const existing = out[field.stepId] ?? {};
19751
+ out[field.stepId] = {
19752
+ ...existing,
19753
+ [field.key]: value
19754
+ };
19755
+ }
19756
+ return out;
19757
+ }
19758
+ readClusterStepSettings({});
19759
+ /**
19760
+ * pipeline-analytics — device-scoped wrapper cap. Refines raw
19761
+ * per-frame detections emitted by the pipeline runner into tracked
19762
+ * objects, per-kind event collections (motion / object / audio), and
19763
+ * persisted media. Owns the post-detection domain end-to-end:
19764
+ *
19765
+ * runner emits PipelineInferenceResult
19766
+ * ↓ (event bus)
19767
+ * pipeline-analytics subscriber
19768
+ * ↓ SORT tracker + zone engine + state analyzer + event emitter
19769
+ * → three DB collections (one per kind), one FS media tree, one
19770
+ * unified event emitter (FrameTracked + TrackStarted/Ended +
19771
+ * DetectionEvent on bus)
19772
+ *
19773
+ * Pure subscriber model. No `processFrame` cap method — the runner
19774
+ * already publishes the raw frame on the bus. The cap surface is
19775
+ * only QUERIES + per-device settings, bound on/off via
19776
+ * `device-manager.setWrapperActive`. `defaultActive: true` because
19777
+ * every camera with a detection pipeline wants its raw detections
19778
+ * refined; operators opt out per-device via BindingsTab when needed.
19779
+ *
19780
+ * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
19781
+ * (per-device surface) and `track-trail` caps — see P11 cleanup.
19265
19782
  */
19266
- var NativeCropRefSchema = object({
19267
- /** Handle keying the retained native surface (node-pinned to its owner). */
19268
- handle: FrameHandleSchema,
19269
- /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
19270
- cropFrameSpace: object({
19271
- x: number$1(),
19272
- y: number$1(),
19273
- w: number$1(),
19274
- h: number$1()
19275
- })
19276
- });
19277
- object({
19278
- crop: object({
19279
- left: number$1(),
19280
- top: number$1(),
19281
- width: number$1().positive(),
19282
- height: number$1().positive()
19283
- }).optional(),
19284
- content: object({
19285
- width: number$1().int().positive(),
19286
- height: number$1().int().positive()
19287
- }),
19288
- fit: _enum(["stretch", "contain"]),
19289
- format: _enum([
19290
- "rgb",
19291
- "gray",
19292
- "jpeg"
19293
- ])
19294
- });
19783
+ var TrackStateSchema = _enum([
19784
+ "new",
19785
+ "entered",
19786
+ "left",
19787
+ "moving",
19788
+ "idle"
19789
+ ]);
19790
+ var EventKindSchema = _enum([
19791
+ "motion",
19792
+ "object",
19793
+ "audio"
19794
+ ]);
19295
19795
  /**
19296
- * Process-local frame identity. It is serializable so it can ride an in-process
19297
- * capability call, but `registryId` deliberately prevents resolution in any
19298
- * other process or execution group.
19796
+ * Spatial filter for `listTracks` — the rect + polygon variants of the shared
19797
+ * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
19798
+ * of the camera frame (top-left origin), matching the drawing-plane editor.
19299
19799
  */
19300
- var FrameRefSchema = object({
19301
- registryId: string().min(1),
19302
- id: string().min(1),
19303
- width: number$1().int().positive(),
19304
- height: number$1().int().positive(),
19305
- format: _enum(["rgb", "gray"]),
19306
- timestamp: number$1(),
19307
- capturedAt: number$1().optional()
19308
- });
19309
- var ModelFormatSchema$1 = _enum([
19310
- "onnx",
19311
- "coreml",
19312
- "openvino",
19313
- "tflite",
19314
- "pt",
19315
- "gguf"
19800
+ var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
19801
+ /** Closed icon vocabulary so clients render a known glyph per kind. */
19802
+ var EventKindIconSchema = _enum([
19803
+ "motion",
19804
+ "audio",
19805
+ "person",
19806
+ "vehicle",
19807
+ "animal",
19808
+ "door",
19809
+ "pir",
19810
+ "smoke",
19811
+ "water",
19812
+ "button",
19813
+ "package",
19814
+ "generic"
19316
19815
  ]);
19317
- var PipelineSlotSchema = _enum([
19318
- "detector",
19319
- "cropper",
19320
- "classifier",
19321
- "refiner",
19322
- "audio-classifier"
19816
+ var EventKindCategorySchema = _enum([
19817
+ "motion",
19818
+ "audio",
19819
+ "detection",
19820
+ "sensor",
19821
+ "control",
19822
+ "custom",
19823
+ "package"
19323
19824
  ]);
19324
- var PipelineEngineChoiceSchema = object({
19325
- runtime: _enum(["node", "python"]),
19326
- backend: string(),
19327
- format: ModelFormatSchema$1,
19328
- device: string().optional()
19329
- });
19330
- var AvailableEngineSchema = object({
19331
- engine: PipelineEngineChoiceSchema,
19332
- devices: array(object({
19333
- id: string(),
19334
- label: string(),
19335
- description: string().optional()
19336
- })).readonly(),
19337
- defaultDevice: string()
19338
- });
19339
- var PipelineDefaultStepSchema = lazy(() => object({
19340
- addonId: string(),
19341
- addonName: string(),
19342
- slot: PipelineSlotSchema,
19343
- inputClasses: array(string()).readonly(),
19344
- outputClasses: array(string()).readonly(),
19345
- enabled: boolean(),
19346
- modelId: string(),
19347
- children: array(PipelineDefaultStepSchema).readonly(),
19348
- group: string().optional(),
19349
- settings: record(string(), unknown()).optional()
19350
- }));
19351
- var PipelineTemplateStepSchema = lazy(() => object({
19352
- addonId: string(),
19353
- enabled: boolean(),
19354
- modelId: string(),
19355
- children: array(PipelineTemplateStepSchema).readonly(),
19356
- settings: record(string(), unknown()).optional()
19357
- }));
19358
- var PipelineTemplateSchema$1 = object({
19359
- id: string(),
19360
- name: string(),
19361
- createdAt: string(),
19362
- updatedAt: string(),
19363
- engine: PipelineEngineChoiceSchema,
19364
- steps: array(PipelineTemplateStepSchema).readonly()
19825
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
19826
+ var EventKindLevelSchema = _enum(["macro", "sub"]);
19827
+ var EventKindDescriptorSchema = object({
19828
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
19829
+ kind: string(),
19830
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
19831
+ labelKey: string(),
19832
+ /** English fallback label (kept for clients that don't translate). */
19833
+ label: string(),
19834
+ /** Hex color for timeline/legend rendering. */
19835
+ color: string(),
19836
+ /** Dictionary id → lucide component on the UI side. */
19837
+ iconId: string(),
19838
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
19839
+ icon: EventKindIconSchema,
19840
+ category: EventKindCategorySchema,
19841
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
19842
+ parentKind: string().nullable(),
19843
+ /** Derived from `parentKind`, explicit for the client tree. */
19844
+ level: EventKindLevelSchema,
19845
+ /** Which cap + device contributes this kind. For built-ins the camera
19846
+ * itself; for sensor kinds the LINKED source device. */
19847
+ source: object({
19848
+ capName: string(),
19849
+ deviceId: number$1()
19850
+ })
19365
19851
  });
19366
- var PipelineModelOptionSchema = object({
19367
- id: string(),
19368
- name: string(),
19369
- formats: record(string(), object({
19370
- downloaded: boolean(),
19371
- sizeMB: number$1()
19372
- })),
19373
- group: ModelVariantGroupSchema.optional(),
19374
- legacy: boolean().optional(),
19375
- provider: ModelProviderIdSchema.optional()
19852
+ /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
19853
+ var EventKindsForDeviceSchema = object({
19854
+ deviceId: number$1(),
19855
+ kinds: array(EventKindDescriptorSchema).readonly()
19376
19856
  });
19377
- var ConfigFieldBridge = custom();
19378
- var PipelineAddonSchemaSchema = object({
19857
+ var SensorEventSchema = object({
19379
19858
  id: string(),
19380
- name: string(),
19381
- slot: PipelineSlotSchema,
19382
- inputClasses: array(string()).readonly(),
19383
- outputClasses: array(string()).readonly(),
19384
- childSlots: array(PipelineSlotSchema).readonly(),
19385
- models: array(PipelineModelOptionSchema).readonly(),
19386
- defaultModelId: string(),
19387
- defaultModelIdByFormat: record(string(), string()).optional(),
19388
- enabledByDefault: boolean().optional(),
19389
- backfillIntoExistingOverrides: boolean().optional(),
19390
- defaultConfidence: number$1(),
19391
- group: string().optional(),
19392
- configSchema: array(ConfigFieldBridge).readonly().optional()
19393
- });
19394
- var PipelineSlotSchemaSchema = object({
19395
- id: PipelineSlotSchema,
19396
- label: string(),
19397
- priority: number$1(),
19398
- parentSlot: PipelineSlotSchema.nullable(),
19399
- addons: array(PipelineAddonSchemaSchema).readonly()
19400
- });
19401
- var PipelineSchemaSchema = object({
19402
- availableEngines: array(AvailableEngineSchema).readonly(),
19403
- selectedEngine: PipelineEngineChoiceSchema,
19404
- slots: array(PipelineSlotSchemaSchema).readonly()
19859
+ /** The CAMERA the event is attributed to (a sensor linked to N cameras
19860
+ * yields N rows, one per camera). */
19861
+ deviceId: number$1(),
19862
+ /** The linked sensor device whose state changed. */
19863
+ sourceDeviceId: number$1(),
19864
+ /** Event kind id — matches an `EventKindDescriptor.kind`. */
19865
+ kind: string(),
19866
+ /** Snapshot of the sensor cap's runtime-state slice at the change. */
19867
+ value: record(string(), unknown()).nullable(),
19868
+ timestamp: number$1()
19405
19869
  });
19406
- var EngineProvisioningSchema = object({
19407
- runtimeId: _enum([
19408
- "onnx",
19409
- "openvino",
19410
- "coreml",
19411
- "edgetpu"
19412
- ]).nullable(),
19413
- device: string().nullable(),
19414
- state: _enum([
19415
- "idle",
19416
- "installing",
19417
- "verifying",
19418
- "ready",
19419
- "failed"
19420
- ]),
19421
- progress: number$1().optional(),
19422
- error: string().optional(),
19423
- nextRetryAt: number$1().optional(),
19870
+ /**
19871
+ * One stored sighting on a track's trajectory.
19872
+ *
19873
+ * The array these live in is returned in TIME order (D399) — it is APPENDED in
19874
+ * arrival order, and the two detector passes interleave, so a consumer must not
19875
+ * assume the two are the same on a row written by an older build.
19876
+ */
19877
+ var TrackPositionSchema = object({
19878
+ x: number$1(),
19879
+ y: number$1(),
19880
+ timestamp: number$1(),
19881
+ bbox: BoundingBoxSchema,
19424
19882
  /**
19425
- * Gate A (config-correctness gate at engine change): human-readable
19426
- * config issues surfaced EAGERLY when the node's engine changes — model
19427
- * substitutions ("chose X, running Y") and zero-build steps ("no model
19428
- * has a <format> build"). Additive/optional: informational only, never
19429
- * enforced here — `assertEngineReady` (readiness) still gates inference.
19430
- * Absent/empty when the node-default tree resolves cleanly.
19883
+ * Which detector pass measured this box (D399): `frame` is the full-frame
19884
+ * pass on the analysis raster, `recovery` is the native-resolution
19885
+ * small-subject second pass (D377/D378). Both write into one array, and until
19886
+ * this field existed the only way to tell them apart was that full-frame boxes
19887
+ * are exact multiples of 1.2 while recovery boxes are full-precision floats.
19888
+ * Absent on rows written before D399.
19431
19889
  */
19432
- configIssues: array(string()).optional()
19433
- });
19434
- var PipelineStepInputSchema = lazy(() => object({
19435
- addonId: string(),
19436
- modelId: string().optional(),
19437
- enabled: boolean().default(true),
19438
- children: array(PipelineStepInputSchema).optional(),
19439
- settings: record(string(), unknown()).optional(),
19440
- jumpDeviceKey: string().optional()
19441
- }));
19442
- var ModelSubstitutionSchema = object({
19443
- addonId: string(),
19444
- chosen: string(),
19445
- running: string(),
19446
- format: string()
19447
- });
19448
- var PipelineValidationIssueSchema = object({
19449
- addonId: string(),
19450
- kind: _enum(["unknown-addon", "no-format-build"]),
19451
- detail: string()
19452
- });
19453
- var PipelineValidationResultSchema = object({
19454
- ok: boolean(),
19455
- issues: array(PipelineValidationIssueSchema).readonly(),
19456
- substitutions: array(ModelSubstitutionSchema).readonly(),
19457
- /** The node's `currentEngine.format` this validation ran against. */
19458
- format: string()
19890
+ source: _enum(["frame", "recovery"]).optional(),
19891
+ /** Detection score of this box, so a position can be weighed and not only
19892
+ * plotted. Absent on rows written before D399. */
19893
+ score: number$1().optional()
19459
19894
  });
19460
- var ReferenceImageEntrySchema = object({
19461
- filename: string(),
19462
- stepIds: array(string()).readonly().optional()
19895
+ var TrackSnapshotSchema = object({
19896
+ timestamp: number$1(),
19897
+ position: TrackPositionSchema,
19898
+ /** The snapshot's media row id (D482); resolve via `listTrackMedia({ trackId })`. */
19899
+ mediaId: number$1().int()
19463
19900
  });
19464
- var ReferenceImageBodySchema = object({
19465
- base64: string(),
19466
- filename: string()
19467
- });
19468
- var ReferenceAudioEntrySchema = object({
19469
- filename: string(),
19470
- sizeKb: number$1()
19471
- });
19472
- var ReferenceAudioBodySchema = object({ base64: string() });
19473
- var AudioBackendSchema = object({
19474
- id: string(),
19475
- name: string(),
19476
- description: string(),
19477
- available: boolean(),
19478
- /**
19479
- * Raw classifier labels this backend can emit (e.g. YAMNet's
19480
- * 521-class set or Apple SoundAnalysis's 303-class set). Used by
19481
- * the benchmark UI to populate the `enabledMicroClasses` filter
19482
- * specific to the selected backend without a separate fetch.
19483
- */
19484
- rawLabels: array(string()).readonly().optional()
19485
- });
19486
- var AudioCapabilitiesSchema = object({
19487
- activeBackend: string(),
19488
- availableBackends: array(AudioBackendSchema).readonly(),
19489
- sampleRate: number$1(),
19490
- chunkDurationMs: number$1()
19491
- });
19492
- var DownloadModelResultSchema = object({
19493
- filePath: string(),
19494
- sizeMB: number$1(),
19495
- durationMs: number$1()
19496
- });
19497
- /**
19498
- * Wrapper carrying a single test run's result. Replaces the legacy
19499
- * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
19500
- * canonical `AudioResult` from the Phase 6 output rework: one
19501
- * `AudioDetection` per class above `minScore`, top-N candidates in
19502
- * `debug.alternateLabels['audio-classifier']`, per-source timings in
19503
- * `debug.stepTimings`. The outer `success`/`error` fields stay so the
19504
- * benchmark UI can still report a clean failure when the classifier
19505
- * cap isn't available.
19506
- */
19507
- var AudioTestResultSchema = object({
19508
- success: boolean(),
19509
- error: string().optional(),
19510
- frame: custom().optional()
19511
- });
19512
- var PipelineConfigBridge = custom();
19513
- var ConfigUISchemaBridge = custom();
19514
- var ConfigUISchemaNullableBridge = custom();
19515
- var InferenceCapabilitiesBridge = custom();
19516
- var ModelAvailabilityListBridge = custom();
19517
- var PipelineRunResultBridge = custom();
19518
- method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
19519
- modelId: string(),
19520
- settings: record(string(), unknown()).readonly()
19521
- }))), method(object({ steps: record(string(), object({
19522
- modelId: string(),
19523
- settings: record(string(), unknown()).readonly()
19524
- })) }), object({ success: literal(true) }), {
19525
- kind: "mutation",
19526
- auth: "admin"
19527
- }), method(object({ nodeId: string() }), object({
19528
- success: literal(true),
19529
- clearedDevices: number$1()
19530
- }), {
19531
- kind: "mutation",
19532
- auth: "admin"
19533
- }), method(object({ nodeId: string() }), object({ unhealthy: array(object({
19534
- /** `<backend>:<device>`, e.g. `openvino:gpu`. */
19535
- deviceKey: string(),
19536
- /**
19537
- * `failed` — the per-device restart budget is exhausted; no pool
19538
- * will be spawned until an operator re-arms it or the runner
19539
- * respawns. `backoff` — under budget, waiting out the backoff (or
19540
- * a cached pool observed dead and not yet condemned).
19541
- */
19542
- state: _enum(["failed", "backoff"]),
19543
- /** Epoch ms of the death that produced this state. */
19544
- since: number$1(),
19545
- /** Pool deaths inside the current window. */
19546
- deaths: number$1(),
19547
- /** The last death's message. */
19548
- lastError: string()
19549
- })).readonly() })), method(object({
19550
- nodeId: string(),
19551
- deviceKey: string()
19552
- }), object({ rearmed: boolean() }), {
19553
- kind: "mutation",
19554
- auth: "admin"
19555
- }), 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({
19556
- name: string(),
19557
- steps: array(PipelineTemplateStepSchema).readonly(),
19558
- engine: PipelineEngineChoiceSchema
19559
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
19560
- id: string(),
19561
- name: string().optional(),
19562
- steps: array(PipelineTemplateStepSchema).readonly().optional()
19563
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
19564
- addonId: string(),
19565
- modelId: string(),
19566
- format: ModelFormatSchema$1
19567
- }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
19568
- addonId: string(),
19569
- modelId: string(),
19570
- format: ModelFormatSchema$1
19571
- }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
19572
- engine: PipelineEngineChoiceSchema.optional(),
19573
- steps: array(PipelineStepInputSchema).min(1),
19574
- frame: FrameInputSchema.optional(),
19575
- /**
19576
- * Process-local lazy frame. Valid only when caller and provider resolve
19577
- * in the same execution-group process; split/cross-node callers use
19578
- * `frame`/`image` inline compatibility instead.
19579
- */
19580
- frameRef: FrameRefSchema.optional(),
19581
- /**
19582
- * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
19583
- * the decoded pixels live in. One more member of the one-of
19584
- * frame/frameHandle/image/imageBase64/referenceImage group.
19585
- */
19586
- frameHandle: FrameHandleSchema.optional(),
19587
- imageBase64: string().optional(),
19588
- /**
19589
- * Binary JPEG bytes — preferred over `imageBase64` on internal
19590
- * hops (hub → forked worker via Moleculer MsgPack) because it
19591
- * skips the 33% base64 overhead + the per-call base64 decode on
19592
- * the detection-pipeline worker. Callers can pass either; exactly
19593
- * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
19594
- */
19595
- image: _instanceof(Uint8Array).optional(),
19596
- referenceImage: string().optional(),
19597
- deviceId: number$1().optional(),
19598
- sessionId: string().optional(),
19599
- /**
19600
- * Execution plane. 'full' (default) runs the whole tree — benchmark,
19601
- * reference-image, and detail-subtree calls. 'frame' is the live
19602
- * per-frame dispatch: ONLY root-plane steps run; crop children
19603
- * (inputClasses ≠ null) are skipped and served per-track via
19604
- * pipelineRunner.runDetailSubtree (two-plane design).
19605
- */
19606
- plane: _enum(["full", "frame"]).optional(),
19607
- /**
19608
- * Inference-device selector (Phase 2 multi-device). Format
19609
- * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
19610
- * Omitted ⇒ the runner's default device (current single-engine
19611
- * behaviour). Selects WHICH device pool of the node runs the call.
19612
- */
19613
- deviceKey: string().optional(),
19614
- /**
19615
- * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
19616
- * when the parent crop was resolved from the frame's retained NATIVE
19617
- * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
19618
- * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
19619
- * resolution from that surface — the SAME quality path faces already
19620
- * had — instead of the downscaled parent tile. `handle` keys the native
19621
- * surface (node-pinned to its owner); `cropFrameSpace` is the parent
19622
- * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
19623
- * the executor's crop-normalized child ROI back into frame-normalized
19624
- * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
19625
- * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
19626
- * (today's behaviour on the fallback path).
19627
- */
19628
- nativeCropRef: NativeCropRefSchema.optional()
19629
- }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
19630
- engine: PipelineEngineChoiceSchema.optional(),
19631
- steps: array(PipelineStepInputSchema).min(1),
19632
- frames: array(FrameInputSchema).min(1).max(255),
19633
- deviceId: number$1().optional(),
19634
- sessionId: string().optional(),
19635
- /**
19636
- * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
19637
- * the batch to the Python pool's bench preprocess cache
19638
- * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
19639
- * preprocessed ONCE and every later inference is a pure-inference cache
19640
- * hit — the sustained-throughput run measures inference, not
19641
- * decode+preprocess+infer. Omitted/0 for live frames (all different →
19642
- * full preprocess every call, correct). Fresh per sustained run;
19643
- * released via `uncacheFrame`.
19644
- */
19645
- frameId: number$1().int().nonnegative().optional(),
19646
- /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
19647
- deviceKey: string().optional()
19648
- }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
19649
- data: _instanceof(Uint8Array),
19650
- width: number$1().int().positive(),
19651
- height: number$1().int().positive(),
19652
- format: _enum([
19653
- "rgb",
19654
- "bgr",
19655
- "gray"
19656
- ])
19657
- }), object({
19658
- frameId: number$1(),
19659
- width: number$1(),
19660
- height: number$1()
19661
- }), { kind: "mutation" }), method(object({
19662
- stepId: string(),
19663
- frameId: number$1().int()
19664
- }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number$1().int() }), _void(), { kind: "mutation" }), method(_void(), object({
19665
- batchMode: string(),
19666
- windowMs: number$1(),
19667
- maxBatchSize: number$1(),
19668
- concurrency: number$1()
19669
- })), method(_void(), array(object({
19670
- engineKey: string(),
19671
- engine: PipelineEngineChoiceSchema,
19672
- modelsLoaded: array(string()).readonly(),
19673
- inUseByCameras: array(number$1()).readonly(),
19674
- /**
19675
- * Origin of this resident factory.
19676
- * - `runtime` — main camera-serving engine (no idle TTL).
19677
- * - `warm-override` — benchmark/test override held in the warm
19678
- * cache; auto-disposed after the idle TTL.
19679
- * - `device-pool` — a concurrent per-device pool (Phase 2
19680
- * multi-device, keyed by `deviceKey`) resolved
19681
- * via `resolveDeviceFactory`. Runs alongside the
19682
- * `runtime` engine on a DIFFERENT accelerator
19683
- * (NPU / iGPU / Coral) — this is how the
19684
- * Engines tab shows all pools running at once.
19685
- */
19686
- kind: _enum([
19687
- "runtime",
19688
- "warm-override",
19689
- "device-pool"
19690
- ]),
19691
- /** Native pid of the underlying Python pool (null when no pool). */
19692
- poolPid: number$1().nullable(),
19693
- /** ms since this factory was last used (null when not warm-tracked). */
19694
- idleMs: number$1().nullable(),
19695
- /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
19696
- idleTtlMs: number$1().nullable()
19697
- })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
19698
- kind: "mutation",
19699
- auth: "admin"
19700
- }), method(object({
19701
- engine: PipelineEngineChoiceSchema,
19702
- force: boolean().optional()
19703
- }), object({
19704
- success: boolean(),
19705
- reason: string().optional()
19706
- }), {
19707
- kind: "mutation",
19708
- auth: "admin"
19709
- }), 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({
19710
- addonId: string(),
19711
- modelId: string(),
19712
- filename: string().optional(),
19713
- settings: record(string(), unknown()).optional()
19714
- }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
19715
- /**
19716
- * Per-stage gating mode applied to the zones a rule references.
19717
- *
19718
- * - `include`: the rule contributes to a **whitelist** for its stage.
19719
- * When at least one `include` rule fires for a stage, only entities
19720
- * inside one of those zones pass that stage.
19721
- * - `exclude`: the rule contributes to a **blacklist** for its stage.
19722
- * Entities inside one of those zones are dropped at that stage.
19723
- *
19724
- * `monitor`-style observation (count without filtering) is not a rule
19725
- * mode — zones without any matching rule are observed naturally by
19726
- * `zone-analytics` (live snapshot + history), so an "I just want to
19727
- * count, not filter" use case needs no rule at all.
19728
- */
19729
- var ZoneRuleModeEnum = _enum(["include", "exclude"]);
19730
- /**
19731
- * Per-consumer rule that references existing zones (geometry) and
19732
- * defines how a specific pipeline stage should treat them. Each
19733
- * consumer addon owns its own `ZoneRule[]` array in its per-device
19734
- * settings:
19735
- *
19736
- * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
19737
- * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
19738
- * - future: notification rules, audio gating, etc.
19739
- *
19740
- * One rule applies to N zones (`zoneIds[]`) so the operator can
19741
- * express "ignore motion in ALL of {garden, street}" with a single
19742
- * rule. `classFilter` narrows the rule to specific object classes —
19743
- * "drop person detections in the street, but keep cars" is one
19744
- * `exclude` rule with `classFilter: ['person']`.
19745
- *
19746
- * `enabled` is a soft toggle — the operator can keep the rule
19747
- * configured but inert without deleting it.
19748
- */
19749
- var ZoneRuleSchema = object({
19750
- /** Stable rule id — survives edits, used by the UI for diffing. */
19751
- id: string(),
19752
- /** Optional human-readable label rendered in the rule editor. */
19753
- name: string().optional(),
19754
- /** Zones this rule targets. The rule's `mode` applies to ALL
19755
- * listed zones (OR-set: a detection in any one of them counts).
19756
- * At least one zone id required — a rule with no targets is a
19757
- * configuration mistake and the form validator rejects it. */
19758
- zoneIds: array(string()).min(1).readonly(),
19759
- mode: ZoneRuleModeEnum,
19760
- /**
19761
- * Class names this rule applies to. Empty / undefined ⇒ rule
19762
- * applies to every class. Class strings match the `macroClass`
19763
- * field on detections (e.g. `person`, `car`, `dog`).
19764
- */
19765
- classFilter: array(string()).readonly().optional(),
19766
- /**
19767
- * Minimum bbox/mask overlap (0–1) with any of the rule's zones
19768
- * required to consider an entity "in the zone". Defaults to the
19769
- * consumer's stage default when omitted. Kept for back-compat with
19770
- * existing per-rule overrides; new operators pick the value via
19771
- * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
19772
- * set, the lower-level engine reads it as a 0–1 fraction.
19773
- */
19774
- overlapThreshold: number$1().min(0).max(1).optional(),
19775
- /**
19776
- * Operator-friendly version of `overlapThreshold` — the percentage
19777
- * of the detection's bbox that must lie inside the zone for the
19778
- * rule to match. Documented default is 85%; the engine substitutes
19779
- * that when the field is omitted (kept optional so existing rules
19780
- * stored without it stay valid).
19781
- *
19782
- * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
19783
- * rule, the engine prefers `bboxInclusionPct` because it's the
19784
- * field exposed in the UI. Internally both feed the same gate.
19785
- */
19786
- bboxInclusionPct: number$1().min(0).max(100).optional(),
19787
- /**
19788
- * When `true` and a detection has a segmentation mask, use the
19789
- * mask for overlap instead of the bbox. Detection-stage only;
19790
- * motion rules ignore this field.
19791
- */
19792
- preferMask: boolean().optional(),
19793
- /**
19794
- * Soft-toggle: `false` disables the rule without deleting it.
19795
- * Defaults to `true` so operators creating a rule via the UI
19796
- * see it active immediately.
19797
- */
19798
- enabled: boolean().default(true)
19799
- });
19800
- array(ZoneRuleSchema).readonly();
19801
- /**
19802
- * Zone — pure geometry + identity. NO filtering behaviour.
19803
- *
19804
- * Zones describe **where** in the frame the operator wants to flag
19805
- * something; consumer-owned {@link ZoneRule} arrays describe **how**
19806
- * each pipeline stage uses them. Splitting the two means a single
19807
- * polygon "Driveway" can simultaneously back a motion-exclude rule,
19808
- * a detection-include rule on `['car']`, and an occupancy aggregate
19809
- * — without three duplicated polygons.
19810
- *
19811
- * Owned by the orchestrator addon (provider) and mirrored into the
19812
- * `zones` device-state slice on every mutation. Consumers
19813
- * (motion-wasm, pipeline-executor, analytics, admin UI) read either
19814
- * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
19815
- * mirror with `onChanged`).
19816
- *
19817
- * Coordinates are normalised fractions of the frame (0–1) so zones
19818
- * survive resolution changes and stream profile switches.
19819
- *
19820
- * `kind` discriminates between full polygons (closed regions used
19821
- * for intrusion / occupancy filters) and tripwires (open 2-point
19822
- * line segments used for cross events). Onboard / firmware-reported
19823
- * zones (Reolink, ONVIF) are out of scope for now — see the deferred
19824
- * task list.
19825
- */
19826
- var ZoneKindEnum = _enum(["polygon", "tripwire"]);
19827
- /** Polygon vertex in fraction-of-frame coordinates (0–1). */
19828
- var PolygonPointSchema = object({
19829
- x: number$1(),
19830
- y: number$1()
19831
- });
19832
- /** A camera detection zone — pure geometry/identity. */
19833
- var ZoneSchema = object({
19834
- id: string(),
19835
- name: string(),
19836
- kind: ZoneKindEnum.default("polygon"),
19837
- /** Polygon vertices, fraction of frame (0–1). */
19838
- polygon: array(PolygonPointSchema).readonly(),
19839
- /** Visual color for UI rendering. */
19840
- color: string().default("#3b82f6")
19841
- });
19842
- DeviceType.Camera, method(object({ deviceId: number$1() }), array(ZoneSchema).readonly()), method(object({
19843
- deviceId: number$1(),
19844
- zone: ZoneSchema
19845
- }), _void(), {
19846
- kind: "mutation",
19847
- auth: "admin"
19848
- }), method(object({
19849
- deviceId: number$1(),
19850
- zoneId: string()
19851
- }), _void(), {
19852
- kind: "mutation",
19853
- auth: "admin"
19854
- }), method(object({
19855
- deviceId: number$1(),
19856
- zone: ZoneSchema
19857
- }), _void(), {
19858
- kind: "mutation",
19859
- auth: "admin"
19860
- }), object({ zones: array(ZoneSchema).readonly() });
19861
- /**
19862
- * pipeline-analytics — device-scoped wrapper cap. Refines raw
19863
- * per-frame detections emitted by the pipeline runner into tracked
19864
- * objects, per-kind event collections (motion / object / audio), and
19865
- * persisted media. Owns the post-detection domain end-to-end:
19866
- *
19867
- * runner emits PipelineInferenceResult
19868
- * ↓ (event bus)
19869
- * pipeline-analytics subscriber
19870
- * ↓ SORT tracker + zone engine + state analyzer + event emitter
19871
- * → three DB collections (one per kind), one FS media tree, one
19872
- * unified event emitter (FrameTracked + TrackStarted/Ended +
19873
- * DetectionEvent on bus)
19874
- *
19875
- * Pure subscriber model. No `processFrame` cap method — the runner
19876
- * already publishes the raw frame on the bus. The cap surface is
19877
- * only QUERIES + per-device settings, bound on/off via
19878
- * `device-manager.setWrapperActive`. `defaultActive: true` because
19879
- * every camera with a detection pipeline wants its raw detections
19880
- * refined; operators opt out per-device via BindingsTab when needed.
19881
- *
19882
- * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
19883
- * (per-device surface) and `track-trail` caps — see P11 cleanup.
19884
- */
19885
- var TrackStateSchema = _enum([
19886
- "new",
19887
- "entered",
19888
- "left",
19889
- "moving",
19890
- "idle"
19891
- ]);
19892
- var EventKindSchema = _enum([
19893
- "motion",
19894
- "object",
19895
- "audio"
19896
- ]);
19897
- /**
19898
- * Spatial filter for `listTracks` — the rect + polygon variants of the shared
19899
- * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
19900
- * of the camera frame (top-left origin), matching the drawing-plane editor.
19901
- */
19902
- var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
19903
- /** Closed icon vocabulary so clients render a known glyph per kind. */
19904
- var EventKindIconSchema = _enum([
19905
- "motion",
19906
- "audio",
19907
- "person",
19908
- "vehicle",
19909
- "animal",
19910
- "door",
19911
- "pir",
19912
- "smoke",
19913
- "water",
19914
- "button",
19915
- "package",
19916
- "generic"
19917
- ]);
19918
- var EventKindCategorySchema = _enum([
19919
- "motion",
19920
- "audio",
19921
- "detection",
19922
- "sensor",
19923
- "control",
19924
- "custom",
19925
- "package"
19926
- ]);
19927
- /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
19928
- var EventKindLevelSchema = _enum(["macro", "sub"]);
19929
- var EventKindDescriptorSchema = object({
19930
- /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
19931
- kind: string(),
19932
- /** i18n key resolved on the UI side; `label` is the English fallback. */
19933
- labelKey: string(),
19934
- /** English fallback label (kept for clients that don't translate). */
19935
- label: string(),
19936
- /** Hex color for timeline/legend rendering. */
19937
- color: string(),
19938
- /** Dictionary id → lucide component on the UI side. */
19939
- iconId: string(),
19940
- /** Legacy closed-vocab glyph — fallback for `iconId`. */
19941
- icon: EventKindIconSchema,
19942
- category: EventKindCategorySchema,
19943
- /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
19944
- parentKind: string().nullable(),
19945
- /** Derived from `parentKind`, explicit for the client tree. */
19946
- level: EventKindLevelSchema,
19947
- /** Which cap + device contributes this kind. For built-ins the camera
19948
- * itself; for sensor kinds the LINKED source device. */
19949
- source: object({
19950
- capName: string(),
19951
- deviceId: number$1()
19952
- })
19953
- });
19954
- /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
19955
- var EventKindsForDeviceSchema = object({
19956
- deviceId: number$1(),
19957
- kinds: array(EventKindDescriptorSchema).readonly()
19958
- });
19959
- var SensorEventSchema = object({
19960
- id: string(),
19961
- /** The CAMERA the event is attributed to (a sensor linked to N cameras
19962
- * yields N rows, one per camera). */
19963
- deviceId: number$1(),
19964
- /** The linked sensor device whose state changed. */
19965
- sourceDeviceId: number$1(),
19966
- /** Event kind id — matches an `EventKindDescriptor.kind`. */
19967
- kind: string(),
19968
- /** Snapshot of the sensor cap's runtime-state slice at the change. */
19969
- value: record(string(), unknown()).nullable(),
19970
- timestamp: number$1()
19971
- });
19972
- /**
19973
- * One stored sighting on a track's trajectory.
19974
- *
19975
- * The array these live in is returned in TIME order (D399) — it is APPENDED in
19976
- * arrival order, and the two detector passes interleave, so a consumer must not
19977
- * assume the two are the same on a row written by an older build.
19978
- */
19979
- var TrackPositionSchema = object({
19980
- x: number$1(),
19981
- y: number$1(),
19982
- timestamp: number$1(),
19983
- bbox: BoundingBoxSchema,
19984
- /**
19985
- * Which detector pass measured this box (D399): `frame` is the full-frame
19986
- * pass on the analysis raster, `recovery` is the native-resolution
19987
- * small-subject second pass (D377/D378). Both write into one array, and until
19988
- * this field existed the only way to tell them apart was that full-frame boxes
19989
- * are exact multiples of 1.2 while recovery boxes are full-precision floats.
19990
- * Absent on rows written before D399.
19991
- */
19992
- source: _enum(["frame", "recovery"]).optional(),
19993
- /** Detection score of this box, so a position can be weighed and not only
19994
- * plotted. Absent on rows written before D399. */
19995
- score: number$1().optional()
19996
- });
19997
- var TrackSnapshotSchema = object({
19998
- timestamp: number$1(),
19999
- position: TrackPositionSchema,
20000
- /** The snapshot's media row id (D482); resolve via `listTrackMedia({ trackId })`. */
20001
- mediaId: number$1().int()
20002
- });
20003
- /**
20004
- * Normalized 0..1 trajectory envelope (min/max over every position bbox,
20005
- * divided by the track's detection-frame dims), computed at persist time.
20006
- * Absent when the frame dims were unknown when the track was persisted
20007
- * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
20008
- */
20009
- var TrackEnvelopeSchema = object({
20010
- minX: number$1(),
20011
- minY: number$1(),
20012
- maxX: number$1(),
20013
- maxY: number$1()
19901
+ /**
19902
+ * Normalized 0..1 trajectory envelope (min/max over every position bbox,
19903
+ * divided by the track's detection-frame dims), computed at persist time.
19904
+ * Absent when the frame dims were unknown when the track was persisted
19905
+ * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
19906
+ */
19907
+ var TrackEnvelopeSchema = object({
19908
+ minX: number$1(),
19909
+ minY: number$1(),
19910
+ maxX: number$1(),
19911
+ maxY: number$1()
20014
19912
  });
20015
19913
  /**
20016
19914
  * Row projection for track list queries. `full` (default) returns the
@@ -20429,6 +20327,22 @@ var TrackSchema = object({
20429
20327
  * omit it. Render nothing when absent.
20430
20328
  */
20431
20329
  previewMissReason: string().optional(),
20330
+ /**
20331
+ * The ROOT model that produced this track — the `FrameResult.rootModelId` of
20332
+ * the frame it was BORN on (D646). What a later replay compares against, so
20333
+ * "the original model" is named rather than assumed. A birth fact: never
20334
+ * rewritten by a later frame. **Absent ≠ unknown-model**: a row from before
20335
+ * the column, and a track the camera's own detector produced, carry none.
20336
+ */
20337
+ modelId: string().optional(),
20338
+ /**
20339
+ * Size (px) of the detection frame this track's `positions[].bbox` live in —
20340
+ * the frame it was born on, else the camera's latest analysis frame at
20341
+ * persist time. Divide a position by these to normalise it. Absent when the
20342
+ * size was never known.
20343
+ */
20344
+ frameWidth: number$1().optional(),
20345
+ frameHeight: number$1().optional(),
20432
20346
  ...TrackFlagFields,
20433
20347
  ...TrackRetrainFields
20434
20348
  });
@@ -20658,7 +20572,8 @@ var MediaFileKindEnum = _enum([
20658
20572
  "thumbnailSmall",
20659
20573
  "confirmationCrop",
20660
20574
  "debugCrop",
20661
- "sceneFrame"
20575
+ "sceneFrame",
20576
+ "lastSceneFrame"
20662
20577
  ]);
20663
20578
  /**
20664
20579
  * One media row ON THE WIRE: what it is, how big it is, and WHERE ITS BYTES
@@ -21210,7 +21125,23 @@ var SearchObjectEventsInput = object({
21210
21125
  until: number$1().optional(),
21211
21126
  classFilter: string().optional(),
21212
21127
  limit: number$1().default(50),
21213
- minScore: number$1().min(0).max(1).default(.2)
21128
+ /**
21129
+ * An ABSOLUTE cosine floor. Optional since D649: a floor is a property of the
21130
+ * model (0.2 kept 96% of matched pairs on MobileCLIP S1 and 2.7% on SigLIP2),
21131
+ * so an absent one resolves to the searched model's own `searchMinScore`
21132
+ * scaled by `strictness`. A number sent here is honoured verbatim.
21133
+ */
21134
+ minScore: number$1().min(0).max(1).optional(),
21135
+ /** Model-relative floor — see `resolveClipSearchMinScore`. Default `loose`. */
21136
+ strictness: ClipSearchStrictnessSchema.optional(),
21137
+ /**
21138
+ * Search THIS CLIP model's index instead of the cluster row's. Every index a
21139
+ * model ever wrote stays searchable until it is wiped (the MobileCLIP index
21140
+ * through a SigLIP2 cutover and its rollback window). An id with no CLIP
21141
+ * metadata is refused; an id other than the cluster row's is ADMIN-only
21142
+ * (`model-override-requires-admin`).
21143
+ */
21144
+ modelId: string().min(1).optional()
21214
21145
  });
21215
21146
  var TrackCascadeCountsSchema = object({
21216
21147
  /** Persisted track roots deleted (authoritative). */
@@ -21345,7 +21276,41 @@ var RebuildObjectEmbeddingsInput = object({
21345
21276
  * comparable, so wiping and rebuilding is the only way to be sure every vector
21346
21277
  * means the same thing.
21347
21278
  */
21348
- var WipeObjectEmbeddingsResultSchema = object({ deleted: number$1() });
21279
+ var WipeObjectEmbeddingsResultSchema = object({
21280
+ deleted: number$1(),
21281
+ /**
21282
+ * CLIP indexes that could NOT be emptied (unreachable, or refused at their
21283
+ * dimension) — not a clean slate. Additive and optional (D649).
21284
+ */
21285
+ failedIndexes: array(string()).optional()
21286
+ });
21287
+ /**
21288
+ * Why a rebuild did not start, BY NAME — ONE vocabulary for both gates in front
21289
+ * of a pass (D649 over D651). A bare `started: false` read the same for "the
21290
+ * stores are booting" and "the cluster row names a model with no CLIP
21291
+ * metadata", which need different fixes.
21292
+ * - `stores-unavailable` — the analytics stores or the API are not up yet.
21293
+ * - the owner's confirmation of the cluster model (D651, `ClusterPinConfirmer`):
21294
+ * a pass that rewrites an index needs two agreeing reads of the OWNER's
21295
+ * answer (`pipelineOrchestrator.getClusterModelChoice`) — a pass that cannot
21296
+ * name its model does not run (D54):
21297
+ * - the owner's own `unreadable` reasons (`owner-not-ready`,
21298
+ * `store-read-failed`, `three-way-read-unavailable`, `invalid-stored`,
21299
+ * `not-cluster-scoped`);
21300
+ * - `method-unavailable` — the orchestrator predates the method;
21301
+ * - `read-failed` — the call failed or answered something unparseable;
21302
+ * - `reads-disagree` — the two reads named different choices.
21303
+ * - `not-a-clip-model` — the CONFIRMED id has no CLIP metadata, so there is no
21304
+ * index to fill and no dimension to check against (D649).
21305
+ */
21306
+ var RebuildObjectEmbeddingsRefusalSchema = _enum([
21307
+ "stores-unavailable",
21308
+ ...CLUSTER_MODEL_CHOICE_UNREADABLE_REASONS,
21309
+ "method-unavailable",
21310
+ "read-failed",
21311
+ "reads-disagree",
21312
+ "not-a-clip-model"
21313
+ ]);
21349
21314
  /**
21350
21315
  * Acknowledgement that a rebuild STARTED.
21351
21316
  *
@@ -21358,7 +21323,12 @@ var WipeObjectEmbeddingsResultSchema = object({ deleted: number$1() });
21358
21323
  var RebuildObjectEmbeddingsResultSchema = object({
21359
21324
  started: boolean(),
21360
21325
  /** True when a pass was already running; the new request is ignored. */
21361
- alreadyRunning: boolean()
21326
+ alreadyRunning: boolean(),
21327
+ /** Present when the pass refused to start — see `RebuildObjectEmbeddingsRefusalSchema`. */
21328
+ refusal: RebuildObjectEmbeddingsRefusalSchema.optional(),
21329
+ /** The CLIP model the pass pinned, and the index it fills (when it started). */
21330
+ modelId: string().optional(),
21331
+ index: string().optional()
21362
21332
  });
21363
21333
  var RebuildStatusSchema = object({
21364
21334
  running: boolean(),
@@ -21392,7 +21362,11 @@ var RebuildStatusSchema = object({
21392
21362
  startedAtMs: number$1().nullable(),
21393
21363
  finishedAtMs: number$1().nullable(),
21394
21364
  /** Present when the pass ended by throwing. */
21395
- error: string().nullable()
21365
+ error: string().nullable(),
21366
+ /** The CLIP model the current / last pass pinned (D54), `null` before any. */
21367
+ modelId: string().nullable(),
21368
+ /** The index that pass fills — `ClipModelMeta.vectorIndex` of `modelId` (D649). */
21369
+ index: string().nullable()
21396
21370
  });
21397
21371
  /**
21398
21372
  * Acknowledgement that a debug-media reclaim STARTED.
@@ -21435,24 +21409,6 @@ var MediaReclaimStatusSchema = object({
21435
21409
  finishedAtMs: number$1().nullable(),
21436
21410
  error: string().nullable()
21437
21411
  });
21438
- var ReplayFrameInputSchema = object({
21439
- timestamp: number$1(),
21440
- frame: PipelineRunResultBridge
21441
- });
21442
- var RunReplayFrameProcessorResultSchema = object({ tracks: array(object({
21443
- className: string(),
21444
- firstSeenMs: number$1(),
21445
- lastSeenMs: number$1(),
21446
- /** Bbox of the track's FIRST matched detection, pixel-space in the clip's
21447
- * frame — a representative box for the diff's `(className, window, IoU)`
21448
- * pairing (`replay-diff.ts`). A replay does not need the full per-frame
21449
- * trajectory production's `Track.positions` keeps. */
21450
- bbox: BoundingBoxSchema,
21451
- /** How many of the input frames this track matched a real detection on
21452
- * (never a coasted/extrapolated frame) — the replay's own signal for "how
21453
- * solid is this track", cheaper than re-deriving it from a trajectory. */
21454
- framesMatched: number$1().int()
21455
- })).readonly() });
21456
21412
  /**
21457
21413
  * The long-term series a camera produces. A closed union so a typo cannot
21458
21414
  * invent one, and the ONE declaration of it — the addon's `AnalyticsLtsSeries`
@@ -21565,209 +21521,671 @@ DeviceType.Camera, method(object({ deviceId: number$1() }), array(TrackSchema).r
21565
21521
  }), method(object({ deviceId: number$1() }), DiskReconcileCountsSchema, {
21566
21522
  kind: "mutation",
21567
21523
  auth: "admin"
21568
- }), method(object({
21569
- deviceId: number$1(),
21570
- trackIds: array(string()).min(1)
21571
- }), object({
21572
- deleted: number$1().int(),
21573
- failed: array(string()).readonly()
21524
+ }), method(object({
21525
+ deviceId: number$1(),
21526
+ trackIds: array(string()).min(1)
21527
+ }), object({
21528
+ deleted: number$1().int(),
21529
+ failed: array(string()).readonly()
21530
+ }), {
21531
+ kind: "mutation",
21532
+ auth: "admin"
21533
+ }), method(object({
21534
+ /** Log/audit scope only — the trackId is globally unique on its own. */
21535
+ deviceId: number$1(),
21536
+ trackId: string(),
21537
+ flags: TrackFlagsPatchSchema
21538
+ }), TrackFlagsSchema, { kind: "mutation" }), method(ArchivedDebugNoteQueryInputSchema, array(ArchivedDebugNoteSchema).readonly(), { kind: "query" }), method(BirthDecisionQueryInputSchema, array(BirthDecisionRecordSchema).readonly(), { kind: "query" }), method(object({}), EventStoreFootprintSchema, {
21539
+ kind: "query",
21540
+ auth: "admin"
21541
+ }), method(object({ deviceId: number$1().int().optional() }), EventMediaKindBreakdownSchema, {
21542
+ kind: "query",
21543
+ auth: "admin"
21544
+ }), method(object({
21545
+ olderThanMs: number$1(),
21546
+ reason: OpsLogReasonSchema.optional()
21547
+ }), EventPruneCountsSchema, {
21548
+ kind: "mutation",
21549
+ auth: "admin"
21550
+ }), method(object({ deviceId: number$1() }), EventPruneCountsSchema, {
21551
+ kind: "mutation",
21552
+ auth: "admin"
21553
+ }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
21554
+ kind: "mutation",
21555
+ auth: "admin"
21556
+ }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
21557
+ kind: "mutation",
21558
+ auth: "admin"
21559
+ }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
21560
+ kind: "mutation",
21561
+ auth: "admin"
21562
+ }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
21563
+ kind: "mutation",
21564
+ auth: "admin"
21565
+ }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
21566
+ kind: "mutation",
21567
+ auth: "admin"
21568
+ }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
21569
+ kind: "mutation",
21570
+ auth: "admin"
21571
+ }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
21572
+ kind: "query",
21573
+ auth: "admin"
21574
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
21575
+ kind: "query",
21576
+ auth: "admin"
21577
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
21578
+ kind: "mutation",
21579
+ auth: "admin"
21580
+ }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
21581
+ kind: "query",
21582
+ auth: "admin"
21583
+ }), method(MediaReclaimInputSchema, MediaReclaimStartResultSchema, {
21584
+ kind: "mutation",
21585
+ auth: "admin"
21586
+ }), method(object({}), MediaReclaimStatusSchema, {
21587
+ kind: "query",
21588
+ auth: "admin"
21589
+ }), method(object({ deviceIds: array(number$1()).optional() }), TrainingExportSummarySchema, {
21590
+ kind: "query",
21591
+ auth: "admin"
21592
+ }), method(object({ deviceIds: array(number$1()).optional() }), object({ url: string() }), {
21593
+ kind: "query",
21594
+ auth: "admin"
21595
+ }), method(object({
21596
+ /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
21597
+ * `deviceId`, deliberately: `deviceId` would make this device-bound and
21598
+ * route it at one camera's owner, and "every camera" would stop being
21599
+ * expressible at all. */
21600
+ deviceIds: array(number$1()).optional(),
21601
+ limit: number$1().int().min(1).max(500).optional()
21602
+ }), array(RetrainTrackSchema).readonly(), {
21603
+ kind: "query",
21604
+ auth: "admin"
21605
+ }), method(object({ trackId: string() }), RetrainFrameListSchema, {
21606
+ kind: "query",
21607
+ auth: "admin"
21608
+ }), method(object({
21609
+ deviceId: number$1(),
21610
+ trackId: string(),
21611
+ mediaIds: array(number$1().int()).min(1)
21612
+ }), RetrainFrameSelectionSchema, {
21613
+ kind: "mutation",
21614
+ auth: "admin"
21615
+ }), method(object({
21616
+ deviceId: number$1(),
21617
+ trackId: string(),
21618
+ frameId: string()
21619
+ }), object({
21620
+ removed: boolean(),
21621
+ removedAnnotations: number$1().int()
21622
+ }), {
21623
+ kind: "mutation",
21624
+ auth: "admin"
21625
+ }), method(object({ frameId: string() }), object({
21626
+ base64: string(),
21627
+ width: number$1().int(),
21628
+ height: number$1().int()
21629
+ }), {
21630
+ kind: "query",
21631
+ auth: "admin"
21632
+ }), method(object({
21633
+ deviceId: number$1(),
21634
+ trackId: string(),
21635
+ frameId: string(),
21636
+ subject: RetrainAssistSubjectSchema,
21637
+ /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
21638
+ nodeId: string().optional()
21639
+ }), RetrainAssistResultSchema, {
21640
+ kind: "mutation",
21641
+ auth: "admin"
21642
+ }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
21643
+ kind: "query",
21644
+ auth: "admin"
21645
+ }), method(object({
21646
+ deviceId: number$1(),
21647
+ trackId: string(),
21648
+ frameId: string(),
21649
+ annotations: array(RetrainAnnotationDraftSchema)
21650
+ }), array(RetrainAnnotationSchema).readonly(), {
21651
+ kind: "mutation",
21652
+ auth: "admin"
21653
+ }), method(object({
21654
+ deviceId: number$1(),
21655
+ trackId: string()
21656
+ }), RetrainTransitionResultSchema, {
21657
+ kind: "mutation",
21658
+ auth: "admin"
21659
+ }), method(object({
21660
+ deviceId: number$1(),
21661
+ trackId: string()
21662
+ }), RetrainTransitionResultSchema, {
21663
+ kind: "mutation",
21664
+ auth: "admin"
21665
+ }), method(object({ deviceIds: array(number$1()).optional() }), object({ url: string() }), {
21666
+ kind: "query",
21667
+ auth: "admin"
21668
+ }), method(object({
21669
+ /** Which of the three event tables owns the row. */
21670
+ ownerType: EventOwnerTypeSchema,
21671
+ /** The event's rowid in that table (D474: an event id is a number). */
21672
+ eventId: number$1().int(),
21673
+ kind: MediaFileKindEnum.optional(),
21674
+ deviceId: number$1()
21675
+ }), array(MediaFileSchema).readonly()), method(object({
21676
+ trackId: string(),
21677
+ kinds: array(MediaFileKindEnum).optional(),
21678
+ deviceId: number$1()
21679
+ }), array(MediaFileSchema).readonly()), method(object({
21680
+ trackId: string(),
21681
+ deviceId: number$1()
21682
+ }), array(MediaFileInfoSchema).readonly()), method(object({
21683
+ ownerType: EventOwnerTypeSchema,
21684
+ eventId: number$1().int(),
21685
+ deviceId: number$1()
21686
+ }), array(MediaFileInfoSchema).readonly()), method(object({
21687
+ deviceId: number$1(),
21688
+ ownerKind: MediaPresenceOwnerKindSchema,
21689
+ ownerIds: array(string()).max(5e3)
21690
+ }), array(string()).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly(), { caller: "required" }), method(object({}), WipeObjectEmbeddingsResultSchema, {
21691
+ kind: "mutation",
21692
+ auth: "admin"
21693
+ }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
21694
+ kind: "mutation",
21695
+ auth: "admin"
21696
+ }), method(object({}), RebuildStatusSchema), object({
21697
+ deviceId: number$1(),
21698
+ timestamp: number$1(),
21699
+ frameWidth: number$1(),
21700
+ frameHeight: number$1(),
21701
+ detections: array(OverlayDetectionSchema).readonly()
21702
+ }), object({
21703
+ deviceId: number$1(),
21704
+ trackId: string(),
21705
+ className: string()
21706
+ }), object({
21707
+ deviceId: number$1(),
21708
+ trackId: string(),
21709
+ className: string(),
21710
+ durationMs: number$1()
21711
+ }), object({
21712
+ deviceId: number$1(),
21713
+ kind: EventKindSchema,
21714
+ eventId: string(),
21715
+ timestamp: number$1()
21716
+ });
21717
+ /**
21718
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
21719
+ * within the frame, so the executor can re-cut a leaf child ROI at native
21720
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
21721
+ */
21722
+ var NativeCropRefSchema = object({
21723
+ /** Handle keying the retained native surface (node-pinned to its owner). */
21724
+ handle: FrameHandleSchema,
21725
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
21726
+ cropFrameSpace: object({
21727
+ x: number$1(),
21728
+ y: number$1(),
21729
+ w: number$1(),
21730
+ h: number$1()
21731
+ })
21732
+ });
21733
+ object({
21734
+ crop: object({
21735
+ left: number$1(),
21736
+ top: number$1(),
21737
+ width: number$1().positive(),
21738
+ height: number$1().positive()
21739
+ }).optional(),
21740
+ content: object({
21741
+ width: number$1().int().positive(),
21742
+ height: number$1().int().positive()
21743
+ }),
21744
+ fit: _enum(["stretch", "contain"]),
21745
+ format: _enum([
21746
+ "rgb",
21747
+ "gray",
21748
+ "jpeg"
21749
+ ])
21750
+ });
21751
+ /**
21752
+ * Process-local frame identity. It is serializable so it can ride an in-process
21753
+ * capability call, but `registryId` deliberately prevents resolution in any
21754
+ * other process or execution group.
21755
+ */
21756
+ var FrameRefSchema = object({
21757
+ registryId: string().min(1),
21758
+ id: string().min(1),
21759
+ width: number$1().int().positive(),
21760
+ height: number$1().int().positive(),
21761
+ format: _enum(["rgb", "gray"]),
21762
+ timestamp: number$1(),
21763
+ capturedAt: number$1().optional()
21764
+ });
21765
+ var ModelFormatSchema$1 = _enum([
21766
+ "onnx",
21767
+ "coreml",
21768
+ "openvino",
21769
+ "tflite",
21770
+ "pt",
21771
+ "gguf"
21772
+ ]);
21773
+ var PipelineSlotSchema = _enum([
21774
+ "detector",
21775
+ "cropper",
21776
+ "classifier",
21777
+ "refiner",
21778
+ "audio-classifier"
21779
+ ]);
21780
+ var PipelineEngineChoiceSchema = object({
21781
+ runtime: literal("python"),
21782
+ backend: string(),
21783
+ format: ModelFormatSchema$1,
21784
+ device: string().optional()
21785
+ });
21786
+ /**
21787
+ * One pool's resolved provisioning (`getEffectiveTuning`). `numWorkers` is the
21788
+ * knob that lifts a saturated pool (`inference-devices.md`); `concurrency` is
21789
+ * per-worker in-flight requests. `deviceKey` echoes the pool asked about —
21790
+ * `null` for the node-default pool.
21791
+ */
21792
+ var EffectiveTuningSchema = object({
21793
+ deviceKey: string().nullable(),
21794
+ runtime: string(),
21795
+ batchMode: string(),
21796
+ windowMs: number$1(),
21797
+ maxBatchSize: number$1(),
21798
+ concurrency: number$1(),
21799
+ numWorkers: number$1()
21800
+ });
21801
+ var AvailableEngineSchema = object({
21802
+ engine: PipelineEngineChoiceSchema,
21803
+ devices: array(object({
21804
+ id: string(),
21805
+ label: string(),
21806
+ description: string().optional()
21807
+ })).readonly(),
21808
+ defaultDevice: string()
21809
+ });
21810
+ var PipelineDefaultStepSchema = lazy(() => object({
21811
+ addonId: string(),
21812
+ addonName: string(),
21813
+ slot: PipelineSlotSchema,
21814
+ inputClasses: array(string()).readonly(),
21815
+ outputClasses: array(string()).readonly(),
21816
+ enabled: boolean(),
21817
+ modelId: string(),
21818
+ children: array(PipelineDefaultStepSchema).readonly(),
21819
+ group: string().optional(),
21820
+ settings: record(string(), unknown()).optional()
21821
+ }));
21822
+ var PipelineTemplateStepSchema = lazy(() => object({
21823
+ addonId: string(),
21824
+ enabled: boolean(),
21825
+ modelId: string(),
21826
+ children: array(PipelineTemplateStepSchema).readonly(),
21827
+ settings: record(string(), unknown()).optional()
21828
+ }));
21829
+ var PipelineTemplateSchema$1 = object({
21830
+ id: string(),
21831
+ name: string(),
21832
+ createdAt: string(),
21833
+ updatedAt: string(),
21834
+ engine: PipelineEngineChoiceSchema,
21835
+ steps: array(PipelineTemplateStepSchema).readonly()
21836
+ });
21837
+ var PipelineModelOptionSchema = object({
21838
+ id: string(),
21839
+ name: string(),
21840
+ formats: record(string(), object({
21841
+ downloaded: boolean(),
21842
+ sizeMB: number$1()
21843
+ })),
21844
+ group: ModelVariantGroupSchema.optional(),
21845
+ legacy: boolean().optional(),
21846
+ provider: ModelProviderIdSchema.optional()
21847
+ });
21848
+ var ConfigFieldBridge = custom();
21849
+ var PipelineAddonSchemaSchema = object({
21850
+ id: string(),
21851
+ name: string(),
21852
+ slot: PipelineSlotSchema,
21853
+ inputClasses: array(string()).readonly(),
21854
+ outputClasses: array(string()).readonly(),
21855
+ childSlots: array(PipelineSlotSchema).readonly(),
21856
+ models: array(PipelineModelOptionSchema).readonly(),
21857
+ defaultModelId: string(),
21858
+ defaultModelIdByFormat: record(string(), string()).optional(),
21859
+ enabledByDefault: boolean().optional(),
21860
+ backfillIntoExistingOverrides: boolean().optional(),
21861
+ defaultConfidence: number$1(),
21862
+ group: string().optional(),
21863
+ configSchema: array(ConfigFieldBridge).readonly().optional()
21864
+ });
21865
+ var PipelineSlotSchemaSchema = object({
21866
+ id: PipelineSlotSchema,
21867
+ label: string(),
21868
+ priority: number$1(),
21869
+ parentSlot: PipelineSlotSchema.nullable(),
21870
+ addons: array(PipelineAddonSchemaSchema).readonly()
21871
+ });
21872
+ var PipelineSchemaSchema = object({
21873
+ availableEngines: array(AvailableEngineSchema).readonly(),
21874
+ selectedEngine: PipelineEngineChoiceSchema,
21875
+ slots: array(PipelineSlotSchemaSchema).readonly()
21876
+ });
21877
+ var EngineProvisioningSchema = object({
21878
+ runtimeId: _enum([
21879
+ "onnx",
21880
+ "openvino",
21881
+ "coreml",
21882
+ "edgetpu"
21883
+ ]).nullable(),
21884
+ device: string().nullable(),
21885
+ state: _enum([
21886
+ "idle",
21887
+ "installing",
21888
+ "verifying",
21889
+ "ready",
21890
+ "failed"
21891
+ ]),
21892
+ progress: number$1().optional(),
21893
+ error: string().optional(),
21894
+ nextRetryAt: number$1().optional(),
21895
+ /**
21896
+ * Gate A (config-correctness gate at engine change): human-readable
21897
+ * config issues surfaced EAGERLY when the node's engine changes — model
21898
+ * substitutions ("chose X, running Y") and zero-build steps ("no model
21899
+ * has a <format> build"). Additive/optional: informational only, never
21900
+ * enforced here — `assertEngineReady` (readiness) still gates inference.
21901
+ * Absent/empty when the node-default tree resolves cleanly.
21902
+ */
21903
+ configIssues: array(string()).optional()
21904
+ });
21905
+ var PipelineStepInputSchema = lazy(() => object({
21906
+ addonId: string(),
21907
+ modelId: string().optional(),
21908
+ enabled: boolean().default(true),
21909
+ children: array(PipelineStepInputSchema).optional(),
21910
+ settings: record(string(), unknown()).optional(),
21911
+ jumpDeviceKey: string().optional()
21912
+ }));
21913
+ var ModelSubstitutionSchema = object({
21914
+ addonId: string(),
21915
+ chosen: string(),
21916
+ running: string(),
21917
+ format: string()
21918
+ });
21919
+ var PipelineValidationIssueSchema = object({
21920
+ addonId: string(),
21921
+ kind: _enum([
21922
+ "unknown-addon",
21923
+ "no-format-build",
21924
+ "unknown-device"
21925
+ ]),
21926
+ detail: string()
21927
+ });
21928
+ var PipelineValidationResultSchema = object({
21929
+ ok: boolean(),
21930
+ issues: array(PipelineValidationIssueSchema).readonly(),
21931
+ substitutions: array(ModelSubstitutionSchema).readonly(),
21932
+ /** The node's `currentEngine.format` this validation ran against. */
21933
+ format: string()
21934
+ });
21935
+ var ReferenceImageEntrySchema = object({
21936
+ filename: string(),
21937
+ stepIds: array(string()).readonly().optional()
21938
+ });
21939
+ var ReferenceImageBodySchema = object({
21940
+ base64: string(),
21941
+ filename: string()
21942
+ });
21943
+ var ReferenceAudioEntrySchema = object({
21944
+ filename: string(),
21945
+ sizeKb: number$1()
21946
+ });
21947
+ var ReferenceAudioBodySchema = object({ base64: string() });
21948
+ var AudioBackendSchema = object({
21949
+ id: string(),
21950
+ name: string(),
21951
+ description: string(),
21952
+ available: boolean(),
21953
+ /**
21954
+ * Raw classifier labels this backend can emit (e.g. YAMNet's
21955
+ * 521-class set or Apple SoundAnalysis's 303-class set). Used by
21956
+ * the benchmark UI to populate the `enabledMicroClasses` filter
21957
+ * specific to the selected backend without a separate fetch.
21958
+ */
21959
+ rawLabels: array(string()).readonly().optional()
21960
+ });
21961
+ var AudioCapabilitiesSchema = object({
21962
+ activeBackend: string(),
21963
+ availableBackends: array(AudioBackendSchema).readonly(),
21964
+ sampleRate: number$1(),
21965
+ chunkDurationMs: number$1()
21966
+ });
21967
+ var DownloadModelResultSchema = object({
21968
+ filePath: string(),
21969
+ sizeMB: number$1(),
21970
+ durationMs: number$1()
21971
+ });
21972
+ /**
21973
+ * Wrapper carrying a single test run's result. Replaces the legacy
21974
+ * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
21975
+ * canonical `AudioResult` from the Phase 6 output rework: one
21976
+ * `AudioDetection` per class above `minScore`, top-N candidates in
21977
+ * `debug.alternateLabels['audio-classifier']`, per-source timings in
21978
+ * `debug.stepTimings`. The outer `success`/`error` fields stay so the
21979
+ * benchmark UI can still report a clean failure when the classifier
21980
+ * cap isn't available.
21981
+ */
21982
+ var AudioTestResultSchema = object({
21983
+ success: boolean(),
21984
+ error: string().optional(),
21985
+ frame: custom().optional()
21986
+ });
21987
+ var PipelineConfigBridge = custom();
21988
+ var ConfigUISchemaBridge = custom();
21989
+ var ConfigUISchemaNullableBridge = custom();
21990
+ var InferenceCapabilitiesBridge = custom();
21991
+ var ModelAvailabilityListBridge = custom();
21992
+ var PipelineRunResultBridge = custom();
21993
+ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
21994
+ modelId: string(),
21995
+ settings: record(string(), unknown()).readonly()
21996
+ }))), method(object({ steps: record(string(), object({
21997
+ modelId: string(),
21998
+ settings: record(string(), unknown()).readonly()
21999
+ })) }), object({ success: literal(true) }), {
22000
+ kind: "mutation",
22001
+ auth: "admin"
22002
+ }), method(object({ nodeId: string() }), object({
22003
+ success: literal(true),
22004
+ clearedDevices: number$1()
21574
22005
  }), {
21575
22006
  kind: "mutation",
21576
22007
  auth: "admin"
21577
- }), method(object({
21578
- /** Log/audit scope only — the trackId is globally unique on its own. */
21579
- deviceId: number$1(),
21580
- trackId: string(),
21581
- flags: TrackFlagsPatchSchema
21582
- }), TrackFlagsSchema, { kind: "mutation" }), method(ArchivedDebugNoteQueryInputSchema, array(ArchivedDebugNoteSchema).readonly(), { kind: "query" }), method(BirthDecisionQueryInputSchema, array(BirthDecisionRecordSchema).readonly(), { kind: "query" }), method(object({}), EventStoreFootprintSchema, {
21583
- kind: "query",
21584
- auth: "admin"
21585
- }), method(object({ deviceId: number$1().int().optional() }), EventMediaKindBreakdownSchema, {
21586
- kind: "query",
21587
- auth: "admin"
21588
- }), method(object({
21589
- olderThanMs: number$1(),
21590
- reason: OpsLogReasonSchema.optional()
21591
- }), EventPruneCountsSchema, {
21592
- kind: "mutation",
21593
- auth: "admin"
21594
- }), method(object({ deviceId: number$1() }), EventPruneCountsSchema, {
21595
- kind: "mutation",
21596
- auth: "admin"
21597
- }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
21598
- kind: "mutation",
21599
- auth: "admin"
21600
- }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
21601
- kind: "mutation",
21602
- auth: "admin"
21603
- }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
21604
- kind: "mutation",
21605
- auth: "admin"
21606
- }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
21607
- kind: "mutation",
21608
- auth: "admin"
21609
- }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
21610
- kind: "mutation",
21611
- auth: "admin"
21612
- }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
21613
- kind: "mutation",
21614
- auth: "admin"
21615
- }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
21616
- kind: "query",
21617
- auth: "admin"
21618
- }), method(object({}), array(RelocateJobSchema).readonly(), {
21619
- kind: "query",
21620
- auth: "admin"
21621
- }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
21622
- kind: "mutation",
21623
- auth: "admin"
21624
- }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
21625
- kind: "query",
21626
- auth: "admin"
21627
- }), method(MediaReclaimInputSchema, MediaReclaimStartResultSchema, {
22008
+ }), method(object({ nodeId: string() }), object({ unhealthy: array(object({
22009
+ /** `<backend>:<device>`, e.g. `openvino:gpu`. */
22010
+ deviceKey: string(),
22011
+ /**
22012
+ * `failed` — the per-device restart budget is exhausted; no pool
22013
+ * will be spawned until an operator re-arms it or the runner
22014
+ * respawns. `backoff` — under budget, waiting out the backoff (or
22015
+ * a cached pool observed dead and not yet condemned).
22016
+ */
22017
+ state: _enum(["failed", "backoff"]),
22018
+ /** Epoch ms of the death that produced this state. */
22019
+ since: number$1(),
22020
+ /** Pool deaths inside the current window. */
22021
+ deaths: number$1(),
22022
+ /** The last death's message. */
22023
+ lastError: string()
22024
+ })).readonly() })), method(object({
22025
+ nodeId: string(),
22026
+ deviceKey: string()
22027
+ }), object({ rearmed: boolean() }), {
21628
22028
  kind: "mutation",
21629
22029
  auth: "admin"
21630
- }), method(object({}), MediaReclaimStatusSchema, {
21631
- kind: "query",
21632
- auth: "admin"
21633
- }), method(object({ deviceIds: array(number$1()).optional() }), TrainingExportSummarySchema, {
21634
- kind: "query",
21635
- auth: "admin"
21636
- }), method(object({ deviceIds: array(number$1()).optional() }), object({ url: string() }), {
21637
- kind: "query",
21638
- auth: "admin"
21639
- }), method(object({
21640
- /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
21641
- * `deviceId`, deliberately: `deviceId` would make this device-bound and
21642
- * route it at one camera's owner, and "every camera" would stop being
21643
- * expressible at all. */
21644
- deviceIds: array(number$1()).optional(),
21645
- limit: number$1().int().min(1).max(500).optional()
21646
- }), array(RetrainTrackSchema).readonly(), {
21647
- kind: "query",
21648
- auth: "admin"
21649
- }), method(object({ trackId: string() }), RetrainFrameListSchema, {
21650
- kind: "query",
21651
- auth: "admin"
21652
- }), method(object({
21653
- deviceId: number$1(),
21654
- trackId: string(),
21655
- mediaIds: array(number$1().int()).min(1)
21656
- }), RetrainFrameSelectionSchema, {
22030
+ }), method(_void(), PipelineSchemaSchema), method(_void(), array(PipelineDefaultStepSchema).readonly().nullable()), method(_void(), PipelineConfigBridge), method(_void(), ConfigUISchemaBridge), method(object({
22031
+ steps: array(PipelineStepInputSchema),
22032
+ deviceKey: string().optional()
22033
+ }), PipelineValidationResultSchema), method(_void(), array(PipelineTemplateSchema$1).readonly()), method(object({
22034
+ name: string(),
22035
+ steps: array(PipelineTemplateStepSchema).readonly(),
22036
+ engine: PipelineEngineChoiceSchema
22037
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
22038
+ id: string(),
22039
+ name: string().optional(),
22040
+ steps: array(PipelineTemplateStepSchema).readonly().optional()
22041
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
22042
+ addonId: string(),
22043
+ modelId: string(),
22044
+ format: ModelFormatSchema$1
22045
+ }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
22046
+ addonId: string(),
22047
+ modelId: string(),
22048
+ format: ModelFormatSchema$1
22049
+ }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
22050
+ steps: array(PipelineStepInputSchema).min(1),
22051
+ frame: FrameInputSchema.optional(),
22052
+ /**
22053
+ * Process-local lazy frame. Valid only when caller and provider resolve
22054
+ * in the same execution-group process; split/cross-node callers use
22055
+ * `frame`/`image` inline compatibility instead.
22056
+ */
22057
+ frameRef: FrameRefSchema.optional(),
22058
+ /**
22059
+ * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
22060
+ * the decoded pixels live in. One more member of the one-of
22061
+ * frame/frameHandle/image/imageBase64/referenceImage group.
22062
+ */
22063
+ frameHandle: FrameHandleSchema.optional(),
22064
+ imageBase64: string().optional(),
22065
+ /**
22066
+ * Binary JPEG bytes — preferred over `imageBase64` on internal
22067
+ * hops (hub → forked worker via Moleculer MsgPack) because it
22068
+ * skips the 33% base64 overhead + the per-call base64 decode on
22069
+ * the detection-pipeline worker. Callers can pass either; exactly
22070
+ * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
22071
+ */
22072
+ image: _instanceof(Uint8Array).optional(),
22073
+ referenceImage: string().optional(),
22074
+ deviceId: number$1().optional(),
22075
+ sessionId: string().optional(),
22076
+ /**
22077
+ * Execution plane. 'full' (default) runs the whole tree — benchmark,
22078
+ * reference-image, and detail-subtree calls. 'frame' is the live
22079
+ * per-frame dispatch: ONLY root-plane steps run; crop children
22080
+ * (inputClasses ≠ null) are skipped and served per-track via
22081
+ * pipelineRunner.runDetailSubtree (two-plane design).
22082
+ */
22083
+ plane: _enum(["full", "frame"]).optional(),
22084
+ /**
22085
+ * Inference-device selector (Phase 2 multi-device). Format
22086
+ * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
22087
+ * Omitted ⇒ the runner's default device (current single-engine
22088
+ * behaviour). Selects WHICH device pool of the node runs the call.
22089
+ */
22090
+ deviceKey: string().optional(),
22091
+ /**
22092
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
22093
+ * when the parent crop was resolved from the frame's retained NATIVE
22094
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
22095
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
22096
+ * resolution from that surface — the SAME quality path faces already
22097
+ * had — instead of the downscaled parent tile. `handle` keys the native
22098
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
22099
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
22100
+ * the executor's crop-normalized child ROI back into frame-normalized
22101
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
22102
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
22103
+ * (today's behaviour on the fallback path).
22104
+ */
22105
+ nativeCropRef: NativeCropRefSchema.optional(),
22106
+ /**
22107
+ * Offline REPLAY of stored media for `deviceId` (D56, D646): the
22108
+ * camera's zone gate and overrides apply as live, every executing
22109
+ * step runs EXACTLY the model it names on the `deviceKey` pool it
22110
+ * names or the call refuses (`model-not-servable` /
22111
+ * `device-not-servable`), and nothing reaches the camera's live
22112
+ * trace stream. Absent ⇒ unchanged behaviour.
22113
+ */
22114
+ replay: literal(true).optional()
22115
+ }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
22116
+ steps: array(PipelineStepInputSchema).min(1),
22117
+ frames: array(FrameInputSchema).min(1).max(255),
22118
+ deviceId: number$1().optional(),
22119
+ sessionId: string().optional(),
22120
+ /**
22121
+ * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
22122
+ * the batch to the Python pool's bench preprocess cache
22123
+ * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
22124
+ * preprocessed ONCE and every later inference is a pure-inference cache
22125
+ * hit — the sustained-throughput run measures inference, not
22126
+ * decode+preprocess+infer. Omitted/0 for live frames (all different →
22127
+ * full preprocess every call, correct). Fresh per sustained run;
22128
+ * released via `uncacheFrame`.
22129
+ */
22130
+ frameId: number$1().int().nonnegative().optional(),
22131
+ /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
22132
+ deviceKey: string().optional()
22133
+ }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
22134
+ data: _instanceof(Uint8Array),
22135
+ width: number$1().int().positive(),
22136
+ height: number$1().int().positive(),
22137
+ format: _enum([
22138
+ "rgb",
22139
+ "bgr",
22140
+ "gray"
22141
+ ])
22142
+ }), object({
22143
+ frameId: number$1(),
22144
+ width: number$1(),
22145
+ height: number$1()
22146
+ }), { kind: "mutation" }), method(object({
22147
+ stepId: string(),
22148
+ frameId: number$1().int()
22149
+ }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number$1().int() }), _void(), { kind: "mutation" }), method(object({ deviceKey: string().optional() }), EffectiveTuningSchema), method(_void(), array(object({
22150
+ engineKey: string(),
22151
+ engine: PipelineEngineChoiceSchema,
22152
+ modelsLoaded: array(string()).readonly(),
22153
+ inUseByCameras: array(number$1()).readonly(),
22154
+ /**
22155
+ * Origin of this resident factory.
22156
+ * - `runtime` — main camera-serving engine (no idle TTL).
22157
+ * - `device-pool` — a concurrent per-device pool (Phase 2
22158
+ * multi-device, keyed by `deviceKey`) resolved
22159
+ * via `resolveDeviceFactory`. Runs alongside the
22160
+ * `runtime` engine on a DIFFERENT accelerator
22161
+ * (NPU / iGPU / Coral) — this is how the
22162
+ * Engines tab shows all pools running at once.
22163
+ */
22164
+ kind: _enum(["runtime", "device-pool"]),
22165
+ /** Native pid of the underlying Python pool (null when no pool). */
22166
+ poolPid: number$1().nullable(),
22167
+ /** ms since this factory was last used (null when not warm-tracked). */
22168
+ idleMs: number$1().nullable(),
22169
+ /** Idle TTL after which the factory self-evicts (null when not applicable). */
22170
+ idleTtlMs: number$1().nullable()
22171
+ })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
21657
22172
  kind: "mutation",
21658
22173
  auth: "admin"
21659
22174
  }), method(object({
21660
- deviceId: number$1(),
21661
- trackId: string(),
21662
- frameId: string()
22175
+ engine: PipelineEngineChoiceSchema,
22176
+ force: boolean().optional()
21663
22177
  }), object({
21664
- removed: boolean(),
21665
- removedAnnotations: number$1().int()
21666
- }), {
21667
- kind: "mutation",
21668
- auth: "admin"
21669
- }), method(object({ frameId: string() }), object({
21670
- base64: string(),
21671
- width: number$1().int(),
21672
- height: number$1().int()
22178
+ success: boolean(),
22179
+ reason: string().optional()
21673
22180
  }), {
21674
- kind: "query",
21675
- auth: "admin"
21676
- }), method(object({
21677
- deviceId: number$1(),
21678
- trackId: string(),
21679
- frameId: string(),
21680
- subject: RetrainAssistSubjectSchema,
21681
- /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
21682
- nodeId: string().optional()
21683
- }), RetrainAssistResultSchema, {
21684
- kind: "mutation",
21685
- auth: "admin"
21686
- }), method(object({
21687
- deviceId: number$1(),
21688
- source: DetectionSourceSchema,
21689
- zones: array(ZoneSchema).readonly().optional(),
21690
- detectionRules: array(ZoneRuleSchema).readonly().optional(),
21691
- zoneMembershipMinOverlap: number$1().min(0).max(1).optional(),
21692
- frames: array(ReplayFrameInputSchema).min(1)
21693
- }), RunReplayFrameProcessorResultSchema, {
21694
- kind: "mutation",
21695
- auth: "admin"
21696
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
21697
- kind: "query",
21698
- auth: "admin"
21699
- }), method(object({
21700
- deviceId: number$1(),
21701
- trackId: string(),
21702
- frameId: string(),
21703
- annotations: array(RetrainAnnotationDraftSchema)
21704
- }), array(RetrainAnnotationSchema).readonly(), {
21705
- kind: "mutation",
21706
- auth: "admin"
21707
- }), method(object({
21708
- deviceId: number$1(),
21709
- trackId: string()
21710
- }), RetrainTransitionResultSchema, {
21711
- kind: "mutation",
21712
- auth: "admin"
21713
- }), method(object({
21714
- deviceId: number$1(),
21715
- trackId: string()
21716
- }), RetrainTransitionResultSchema, {
21717
- kind: "mutation",
21718
- auth: "admin"
21719
- }), method(object({ deviceIds: array(number$1()).optional() }), object({ url: string() }), {
21720
- kind: "query",
21721
- auth: "admin"
21722
- }), method(object({
21723
- /** Which of the three event tables owns the row. */
21724
- ownerType: EventOwnerTypeSchema,
21725
- /** The event's rowid in that table (D474: an event id is a number). */
21726
- eventId: number$1().int(),
21727
- kind: MediaFileKindEnum.optional(),
21728
- deviceId: number$1()
21729
- }), array(MediaFileSchema).readonly()), method(object({
21730
- trackId: string(),
21731
- kinds: array(MediaFileKindEnum).optional(),
21732
- deviceId: number$1()
21733
- }), array(MediaFileSchema).readonly()), method(object({
21734
- trackId: string(),
21735
- deviceId: number$1()
21736
- }), array(MediaFileInfoSchema).readonly()), method(object({
21737
- ownerType: EventOwnerTypeSchema,
21738
- eventId: number$1().int(),
21739
- deviceId: number$1()
21740
- }), array(MediaFileInfoSchema).readonly()), method(object({
21741
- deviceId: number$1(),
21742
- ownerKind: MediaPresenceOwnerKindSchema,
21743
- ownerIds: array(string()).max(5e3)
21744
- }), array(string()).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
21745
22181
  kind: "mutation",
21746
22182
  auth: "admin"
21747
- }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
21748
- kind: "mutation",
21749
- auth: "admin"
21750
- }), method(object({}), RebuildStatusSchema), object({
21751
- deviceId: number$1(),
21752
- timestamp: number$1(),
21753
- frameWidth: number$1(),
21754
- frameHeight: number$1(),
21755
- detections: array(OverlayDetectionSchema).readonly()
21756
- }), object({
21757
- deviceId: number$1(),
21758
- trackId: string(),
21759
- className: string()
21760
- }), object({
21761
- deviceId: number$1(),
21762
- trackId: string(),
21763
- className: string(),
21764
- durationMs: number$1()
21765
- }), object({
21766
- deviceId: number$1(),
21767
- kind: EventKindSchema,
21768
- eventId: string(),
21769
- timestamp: number$1()
21770
- });
22183
+ }), 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({
22184
+ addonId: string(),
22185
+ modelId: string(),
22186
+ filename: string().optional(),
22187
+ settings: record(string(), unknown()).optional()
22188
+ }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
21771
22189
  object({
21772
22190
  activeCameras: number$1(),
21773
22191
  throttledCameras: number$1(),
@@ -21793,6 +22211,66 @@ var CameraMetricsSchema = object({
21793
22211
  });
21794
22212
  var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number$1() });
21795
22213
  /**
22214
+ * Zone — pure geometry + identity. NO filtering behaviour.
22215
+ *
22216
+ * Zones describe **where** in the frame the operator wants to flag
22217
+ * something; consumer-owned {@link ZoneRule} arrays describe **how**
22218
+ * each pipeline stage uses them. Splitting the two means a single
22219
+ * polygon "Driveway" can simultaneously back a motion-exclude rule,
22220
+ * a detection-include rule on `['car']`, and an occupancy aggregate
22221
+ * — without three duplicated polygons.
22222
+ *
22223
+ * Owned by the orchestrator addon (provider) and mirrored into the
22224
+ * `zones` device-state slice on every mutation. Consumers
22225
+ * (motion-wasm, pipeline-executor, analytics, admin UI) read either
22226
+ * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
22227
+ * mirror with `onChanged`).
22228
+ *
22229
+ * Coordinates are normalised fractions of the frame (0–1) so zones
22230
+ * survive resolution changes and stream profile switches.
22231
+ *
22232
+ * `kind` discriminates between full polygons (closed regions used
22233
+ * for intrusion / occupancy filters) and tripwires (open 2-point
22234
+ * line segments used for cross events). Onboard / firmware-reported
22235
+ * zones (Reolink, ONVIF) are out of scope for now — see the deferred
22236
+ * task list.
22237
+ */
22238
+ var ZoneKindEnum = _enum(["polygon", "tripwire"]);
22239
+ /** Polygon vertex in fraction-of-frame coordinates (0–1). */
22240
+ var PolygonPointSchema = object({
22241
+ x: number$1(),
22242
+ y: number$1()
22243
+ });
22244
+ /** A camera detection zone — pure geometry/identity. */
22245
+ var ZoneSchema = object({
22246
+ id: string(),
22247
+ name: string(),
22248
+ kind: ZoneKindEnum.default("polygon"),
22249
+ /** Polygon vertices, fraction of frame (0–1). */
22250
+ polygon: array(PolygonPointSchema).readonly(),
22251
+ /** Visual color for UI rendering. */
22252
+ color: string().default("#3b82f6")
22253
+ });
22254
+ DeviceType.Camera, method(object({ deviceId: number$1() }), array(ZoneSchema).readonly()), method(object({
22255
+ deviceId: number$1(),
22256
+ zone: ZoneSchema
22257
+ }), _void(), {
22258
+ kind: "mutation",
22259
+ auth: "admin"
22260
+ }), method(object({
22261
+ deviceId: number$1(),
22262
+ zoneId: string()
22263
+ }), _void(), {
22264
+ kind: "mutation",
22265
+ auth: "admin"
22266
+ }), method(object({
22267
+ deviceId: number$1(),
22268
+ zone: ZoneSchema
22269
+ }), _void(), {
22270
+ kind: "mutation",
22271
+ auth: "admin"
22272
+ }), object({ zones: array(ZoneSchema).readonly() });
22273
+ /**
21796
22274
  * A bounding box in NORMALIZED [0,1] frame coordinates for `getNativeCrop`. The
21797
22275
  * decode worker resolves it against the RETAINED native frame's real pixel dims,
21798
22276
  * so the caller supplies only the detection-res bbox divided by the detection
@@ -21979,7 +22457,17 @@ var DetailResultSchema = object({
21979
22457
  /** Face short side (px) measured on the NATIVE crop surface. The `bbox`
21980
22458
  * above is detection-frame px (≈6× smaller on a 4K camera) — min-face-size
21981
22459
  * consumers MUST prefer this when present (2026-07-22 native-gate fix). */
21982
- nativeFaceShortSidePx: number$1().optional()
22460
+ nativeFaceShortSidePx: number$1().optional(),
22461
+ /**
22462
+ * The five facial landmarks of a `face` detail, in the SAME frame space as
22463
+ * `bbox` (D644). Additive and optional: post-analysis stores them beside the
22464
+ * face's source frame so a future alignment can be re-derived exactly; a
22465
+ * runner that predates the field sends none and the face is stored without.
22466
+ */
22467
+ landmarks: array(object({
22468
+ x: number$1(),
22469
+ y: number$1()
22470
+ })).optional()
21983
22471
  });
21984
22472
  /**
21985
22473
  * Why an executing node REFUSED a stateless step run (`runStatelessStep`).
@@ -22234,6 +22722,17 @@ var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal
22234
22722
  hubHostnameOverride: string().optional()
22235
22723
  })]).describe("Per-camera frame-source mode for the runner (P2c)");
22236
22724
  /**
22725
+ * What ONE step runs with on ONE roster device for THIS camera (D650): the
22726
+ * device's per-(node,device) base with the camera's override for that device
22727
+ * on top — the same `override ?? base` merge the orchestrator applies to the
22728
+ * elected device (`applyDeviceProvisioning`). Absent `modelId` ⇒ the executor
22729
+ * resolves the device format's default, exactly as on the elected device.
22730
+ */
22731
+ var RunnerJumpStepProvisioningSchema = object({
22732
+ modelId: string().optional(),
22733
+ settings: record(string(), unknown()).optional()
22734
+ });
22735
+ /**
22237
22736
  * One ENABLED inference device on the runner's node, as the step-tree
22238
22737
  * device-jump resolver sees it (phase 1). The orchestrator populates this
22239
22738
  * roster on the attach payload whenever the camera is elected onto a specific
@@ -22245,7 +22744,16 @@ var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal
22245
22744
  var RunnerInferenceDeviceSchema = object({
22246
22745
  deviceKey: string(),
22247
22746
  weight: number$1().positive().default(1),
22248
- maxSessions: number$1().int().positive().nullable().default(null)
22747
+ maxSessions: number$1().int().positive().nullable().default(null),
22748
+ /**
22749
+ * Per-step provisioning for this camera on THIS device (D650), keyed by step
22750
+ * id. A step the runner jumps here runs with these fields, never with the
22751
+ * elected device's: `modelId` / `settings` are REPLACED on the jumped subtree
22752
+ * (a step absent from the map runs with neither — the target format default).
22753
+ * Absent field ⇒ an orchestrator that predates D650: the jumped step keeps
22754
+ * the elected device's provisioning, as before.
22755
+ */
22756
+ steps: record(string(), RunnerJumpStepProvisioningSchema).optional()
22249
22757
  });
22250
22758
  /**
22251
22759
  * Camera assignment payload sent by `addon-pipeline-orchestrator` to a
@@ -23120,6 +23628,28 @@ var NodeInferenceDeviceSchema = object({
23120
23628
  */
23121
23629
  exclusion: InferenceDeviceExclusionReasonSchema.nullable()
23122
23630
  });
23631
+ /**
23632
+ * The operator's model choice for one cluster-scoped step, answered by the
23633
+ * addon that OWNS the `clusterModel:*` settings (D651). Three answers, never
23634
+ * folded: a written choice, a key nobody wrote (the cluster runs the default
23635
+ * BY ABSENCE), or no answer. A caller that rewrites an index acts only on the
23636
+ * first two, read twice and agreeing.
23637
+ */
23638
+ var ClusterModelChoiceSchema = discriminatedUnion("kind", [
23639
+ object({
23640
+ kind: literal("stored"),
23641
+ modelId: string()
23642
+ }),
23643
+ object({
23644
+ kind: literal("absent"),
23645
+ defaultModelId: string()
23646
+ }),
23647
+ object({
23648
+ kind: literal("unreadable"),
23649
+ reason: _enum(CLUSTER_MODEL_CHOICE_UNREADABLE_REASONS),
23650
+ error: string().optional()
23651
+ })
23652
+ ]);
23123
23653
  var NodeInferenceDevicesSchema = object({
23124
23654
  nodeId: string(),
23125
23655
  /** False when the node's platform-probe was unreachable (no live device set). */
@@ -23147,10 +23677,17 @@ method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
23147
23677
  }), object({ success: literal(true) }), {
23148
23678
  kind: "mutation",
23149
23679
  auth: "admin"
23150
- }), method(object({ deviceId: number$1() }), object({ deviceKey: string().nullable() })), method(_void(), object({ migrated: number$1() }), {
23680
+ }), method(object({ deviceId: number$1() }), object({ deviceKey: string().nullable() })), method(_void(), object({
23681
+ migrated: number$1(),
23682
+ skipped: array(object({
23683
+ deviceId: number$1(),
23684
+ targetNodeId: string(),
23685
+ reason: string()
23686
+ })).default([])
23687
+ }), {
23151
23688
  kind: "mutation",
23152
23689
  auth: "admin"
23153
- }), 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({
23690
+ }), 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({
23154
23691
  nodeId: string(),
23155
23692
  capName: string(),
23156
23693
  addonId: string()
@@ -23365,7 +23902,11 @@ function buildDescriptor(capName, kind) {
23365
23902
  icon: legacyIcon(t.iconId)
23366
23903
  };
23367
23904
  }
23368
- Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
23905
+ /**
23906
+ * Sensor / control cap name → static event-kind descriptor. A linked device
23907
+ * contributes one entry per bound cap present in this map.
23908
+ */
23909
+ var EVENT_KIND_BY_CAP = Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
23369
23910
  /**
23370
23911
  * server-management — per-NODE singleton capability for a node's ROOT
23371
23912
  * package lifecycle (runtime-updatable node packages).
@@ -25446,6 +25987,167 @@ DeviceType.Camera, method(object({
25446
25987
  auth: "protected"
25447
25988
  });
25448
25989
  /**
25990
+ * LA tabella "quale booleano di questo tipo di device conta come ALTO", e il
25991
+ * valutatore puro del suo FRONTE.
25992
+ *
25993
+ * Viveva dentro il builtin virtual-doorbell
25994
+ * (`@camstack/system` — `builtins/doorbell/trigger-engine.ts`) e i suoi
25995
+ * predicati erano privati al modulo. Il recorder ne ha bisogno per il trigger
25996
+ * `RecordingTriggers.sensorDeviceIds`: copiarla avrebbe creato la SECONDA
25997
+ * tabella, che diverge alla prima cap aggiunta e il cui sintomo — "il sensore
25998
+ * fa suonare il campanello ma non registra" — è esattamente D62. Quindi si
25999
+ * SPOSTA qui e il doorbell la ri-esporta.
26000
+ *
26001
+ * ⚠ NON è `DEVICE_STATE_READERS` (`catalogs/device-state-vocabulary.ts`), e le
26002
+ * due non vanno unificate: quella risponde a "qual è la PAROLA di stato per una
26003
+ * regola" (e include `presence`, `cover`, `alarm-panel`), questa a "qual è il
26004
+ * booleano il cui FRONTE conta". Vocabolari deliberatamente diversi.
26005
+ */
26006
+ /**
26007
+ * Known binary / switch source caps → the boolean slice field whose
26008
+ * false→true rise counts as ACTIVE. Every entry is "fire on active".
26009
+ * Sensors whose "active" reading is not a plain boolean (presence's string
26010
+ * state, connectivity's connected flag) are deliberately excluded — a
26011
+ * reconnect is not a doorbell press, and it is not a recording either.
26012
+ */
26013
+ var SOURCE_CAP_ACTIVE_FIELD = {
26014
+ contact: "entryOpen",
26015
+ binary: "on",
26016
+ switch: "on",
26017
+ motion: "detected",
26018
+ flood: "flooded",
26019
+ gas: "detected",
26020
+ smoke: "detected",
26021
+ "carbon-monoxide": "detected",
26022
+ vibration: "detected",
26023
+ tamper: "tampered"
26024
+ };
26025
+ object({
26026
+ /** Ms epoch of the last press. null = never observed since this provider started. */
26027
+ lastPressedAt: number$1().nullable(),
26028
+ /** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
26029
+ pressCountSinceStart: number$1()
26030
+ });
26031
+ object({
26032
+ deviceId: number$1(),
26033
+ timestamp: number$1()
26034
+ });
26035
+ /**
26036
+ * The `doorbell-source` extension slot's editable value (D648): the camera's
26037
+ * virtual-doorbell trigger devices, exactly what the wrapper's
26038
+ * `doorbellSources` persists (as `{ deviceId }` records).
26039
+ */
26040
+ var DoorbellSourceSlotValueSchema = object({ deviceIds: array(number$1().int().positive()) });
26041
+ DeviceType.Camera;
26042
+ DeviceType.Button, DeviceType.Camera;
26043
+ var ExtensionSlotIdSchema = _enum(["doorbell-source", "linked-devices"]);
26044
+ DeviceType.Camera, DeviceType.Camera;
26045
+ /** A slot's editable value, discriminated on `slot`. */
26046
+ var ExtensionSlotValueSchema = discriminatedUnion("slot", [DoorbellSourceSlotValueSchema.extend({ slot: literal("doorbell-source") }), LinkedDevicesSlotValueSchema.extend({ slot: literal("linked-devices") })]);
26047
+ DeviceType.Camera;
26048
+ var ExtensionSourceAvailabilitySchema = discriminatedUnion("state", [object({ state: literal("ok") }), object({
26049
+ state: literal("unreachable"),
26050
+ reason: string()
26051
+ })]);
26052
+ /** One provider of slots — the D554 source-listing row. */
26053
+ var ExtensionSourceSchema = object({
26054
+ /** The routing prefix of every `slotRef` this provider serves. */
26055
+ source: string(),
26056
+ label: string(),
26057
+ /** Stamped by the dispatcher from the registry (D557). */
26058
+ addonId: string().optional(),
26059
+ availability: ExtensionSourceAvailabilitySchema
26060
+ });
26061
+ /**
26062
+ * How one picked source stands. `missing` — no such device (deleted, or an id
26063
+ * that never existed); `foreign` — a device the slot's owner cannot read from
26064
+ * (slice 2's cross-owner graft source); `unavailable` — it exists but is not a
26065
+ * valid source now (a container, which is never a pick). A source in any of
26066
+ * these states is SHOWN, never silently dropped or re-pointed.
26067
+ */
26068
+ var ExtensionSourceHealthSchema = _enum([
26069
+ "ok",
26070
+ "missing",
26071
+ "foreign",
26072
+ "unavailable"
26073
+ ]);
26074
+ var ExtensionSlotSourceSchema = object({
26075
+ deviceId: number$1().int(),
26076
+ /** The device's name, or null when it could not be resolved (`missing`). */
26077
+ name: string().nullable(),
26078
+ health: ExtensionSourceHealthSchema,
26079
+ detail: string().optional()
26080
+ });
26081
+ /**
26082
+ * A DIFFERENT authority that gates whether the slot's sources do anything —
26083
+ * reported read-only, named, never written through this contract (D62). The
26084
+ * virtual doorbell's sources ring only while the wrapper is bound to the
26085
+ * camera, and that binding belongs to `deviceManager.setWrapperActive`.
26086
+ * `unknown` means the gate could not be read; it is not "inactive" (D315).
26087
+ */
26088
+ var ExtensionSlotActivationSchema = object({
26089
+ state: _enum([
26090
+ "active",
26091
+ "inactive",
26092
+ "unknown"
26093
+ ]),
26094
+ authority: string(),
26095
+ detail: string().optional()
26096
+ });
26097
+ var ExtensionSlotRowSchema = discriminatedUnion("state", [object({
26098
+ state: literal("ok"),
26099
+ /** `<source>:<slotId>` — the routing key for `listCandidates` / `setSlot`. */
26100
+ slotRef: string(),
26101
+ slot: ExtensionSlotIdSchema,
26102
+ /** Names the store written (D62), e.g. `virtual-doorbell:doorbellSources`. */
26103
+ authority: string(),
26104
+ /** graft: its switch. association: null — removing every source is "off". */
26105
+ enabled: boolean().nullable(),
26106
+ /** graft: the cap registered on the host. association: null. */
26107
+ projects: string().nullable(),
26108
+ activation: ExtensionSlotActivationSchema.nullable(),
26109
+ value: ExtensionSlotValueSchema,
26110
+ sources: array(ExtensionSlotSourceSchema)
26111
+ }), object({
26112
+ state: literal("unreachable"),
26113
+ addonId: string(),
26114
+ reason: string()
26115
+ })]);
26116
+ var ExtensionCandidatesSchema = object({ candidates: array(object({
26117
+ deviceId: number$1().int(),
26118
+ name: string(),
26119
+ type: string(),
26120
+ location: string().nullable(),
26121
+ /** The container a child belongs to — "Spotlight 2" alone does not say which. */
26122
+ parentName: string().nullable(),
26123
+ /** Pre-marked by the owner's suggestion rule. NEVER saved on its own (D356). */
26124
+ suggested: boolean(),
26125
+ /** Why it is suggested ("same location"), null when it is not. */
26126
+ reason: string().nullable()
26127
+ })) });
26128
+ /**
26129
+ * What a write did. `none` — applied in place. `host` / `parent` — the owner
26130
+ * reloaded the host (or, for an accessory child, its parent) because the
26131
+ * write changed what the host REGISTERS (a graft switched on or off, slice 2).
26132
+ */
26133
+ var ExtensionSetResultSchema = object({
26134
+ applied: literal(true),
26135
+ reload: _enum([
26136
+ "none",
26137
+ "host",
26138
+ "parent"
26139
+ ])
26140
+ });
26141
+ var ExtensionSlotRefInputSchema = object({
26142
+ deviceId: number$1().int(),
26143
+ slotRef: string().min(1)
26144
+ });
26145
+ var ExtensionSetSlotInputSchema = ExtensionSlotRefInputSchema.extend({ value: ExtensionSlotValueSchema });
26146
+ method(object({ deviceId: number$1().int() }), array(ExtensionSourceSchema)), method(object({ deviceId: number$1().int() }), array(ExtensionSlotRowSchema)), method(ExtensionSlotRefInputSchema, ExtensionCandidatesSchema), method(ExtensionSetSlotInputSchema, ExtensionSetResultSchema, {
26147
+ kind: "mutation",
26148
+ auth: "admin"
26149
+ });
26150
+ /**
25449
26151
  * Optional client-side hints sent at session creation to help the provider
25450
26152
  * pick the best native source. All fields optional — a viewer that knows
25451
26153
  * nothing still gets a sane default. (Relocated from the retired `webrtc`
@@ -27234,17 +27936,6 @@ object({
27234
27936
  deviceId: number$1(),
27235
27937
  status: DeviceStatusSchema
27236
27938
  });
27237
- object({
27238
- /** Ms epoch of the last press. null = never observed since this provider started. */
27239
- lastPressedAt: number$1().nullable(),
27240
- /** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
27241
- pressCountSinceStart: number$1()
27242
- });
27243
- object({
27244
- deviceId: number$1(),
27245
- timestamp: number$1()
27246
- });
27247
- DeviceType.Button, DeviceType.Camera;
27248
27939
  /**
27249
27940
  * Enum-state sensor — a string value picked from a finite option set.
27250
27941
  * Drives HA `sensor` entries with `state_class: enum` (HVAC action
@@ -29508,7 +30199,30 @@ var RenameNodeResultSchema = object({
29508
30199
  nodeId: string(),
29509
30200
  name: string()
29510
30201
  });
29511
- method(_void(), array(TopologyNodeSchema).readonly(), { auth: "admin" }), method(NodeAddonInputSchema, SuccessSchema, {
30202
+ /**
30203
+ * The cheap node list. A consumer's rule for a STORED node id (a rule's
30204
+ * `nodeIds`) that is missing from `nodes`, whatever `complete` says: render it
30205
+ * as a removable chip labelled unknown, never drop it (D49). Even a complete
30206
+ * list omits a node that joined and left between two history captures, so a
30207
+ * missing id means "not known to the hub", never "removed". Only the operator
30208
+ * removes it.
30209
+ *
30210
+ * `complete` changes only the WORDING: `false` = no history read has ever
30211
+ * answered, so the list may be missing offline nodes the hub does know (D315).
30212
+ *
30213
+ * `name` is the history row's name (≤ 30 s behind a rename), or the id when
30214
+ * the history has none.
30215
+ */
30216
+ var NodeDirectorySchema = object({
30217
+ nodes: array(object({
30218
+ id: string(),
30219
+ name: string(),
30220
+ isHub: boolean(),
30221
+ isOnline: boolean()
30222
+ })).readonly(),
30223
+ complete: boolean()
30224
+ });
30225
+ method(_void(), array(TopologyNodeSchema).readonly(), { auth: "admin" }), method(_void(), NodeDirectorySchema, { auth: "admin" }), method(NodeAddonInputSchema, SuccessSchema, {
29512
30226
  kind: "mutation",
29513
30227
  auth: "admin"
29514
30228
  }), method(NodeAddonInputSchema, SuccessSchema, {
@@ -30277,7 +30991,7 @@ var HardwareInfoSchema = object({
30277
30991
  coral: CoralInfoSchema.nullable().optional()
30278
30992
  });
30279
30993
  var PlatformScoreSchema = object({
30280
- runtime: _enum(["node", "python"]),
30994
+ runtime: literal("python"),
30281
30995
  backend: string(),
30282
30996
  format: _enum([
30283
30997
  "onnx",
@@ -30314,7 +31028,7 @@ var ModelRequirementSchema = object({
30314
31028
  });
30315
31029
  var ResolvedInferenceConfigSchema = object({
30316
31030
  modelId: string(),
30317
- runtime: _enum(["node", "python"]),
31031
+ runtime: literal("python"),
30318
31032
  backend: string(),
30319
31033
  format: ModelFormatSchema,
30320
31034
  reason: string()
@@ -32521,6 +33235,92 @@ DeviceType.Camera, method(object({ deviceId: number$1() }), SceneMonitorStatusSc
32521
33235
  kind: "mutation",
32522
33236
  auth: "admin"
32523
33237
  });
33238
+ /**
33239
+ * Per-stage gating mode applied to the zones a rule references.
33240
+ *
33241
+ * - `include`: the rule contributes to a **whitelist** for its stage.
33242
+ * When at least one `include` rule fires for a stage, only entities
33243
+ * inside one of those zones pass that stage.
33244
+ * - `exclude`: the rule contributes to a **blacklist** for its stage.
33245
+ * Entities inside one of those zones are dropped at that stage.
33246
+ *
33247
+ * `monitor`-style observation (count without filtering) is not a rule
33248
+ * mode — zones without any matching rule are observed naturally by
33249
+ * `zone-analytics` (live snapshot + history), so an "I just want to
33250
+ * count, not filter" use case needs no rule at all.
33251
+ */
33252
+ var ZoneRuleModeEnum = _enum(["include", "exclude"]);
33253
+ /**
33254
+ * Per-consumer rule that references existing zones (geometry) and
33255
+ * defines how a specific pipeline stage should treat them. Each
33256
+ * consumer addon owns its own `ZoneRule[]` array in its per-device
33257
+ * settings:
33258
+ *
33259
+ * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
33260
+ * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
33261
+ * - future: notification rules, audio gating, etc.
33262
+ *
33263
+ * One rule applies to N zones (`zoneIds[]`) so the operator can
33264
+ * express "ignore motion in ALL of {garden, street}" with a single
33265
+ * rule. `classFilter` narrows the rule to specific object classes —
33266
+ * "drop person detections in the street, but keep cars" is one
33267
+ * `exclude` rule with `classFilter: ['person']`.
33268
+ *
33269
+ * `enabled` is a soft toggle — the operator can keep the rule
33270
+ * configured but inert without deleting it.
33271
+ */
33272
+ var ZoneRuleSchema = object({
33273
+ /** Stable rule id — survives edits, used by the UI for diffing. */
33274
+ id: string(),
33275
+ /** Optional human-readable label rendered in the rule editor. */
33276
+ name: string().optional(),
33277
+ /** Zones this rule targets. The rule's `mode` applies to ALL
33278
+ * listed zones (OR-set: a detection in any one of them counts).
33279
+ * At least one zone id required — a rule with no targets is a
33280
+ * configuration mistake and the form validator rejects it. */
33281
+ zoneIds: array(string()).min(1).readonly(),
33282
+ mode: ZoneRuleModeEnum,
33283
+ /**
33284
+ * Class names this rule applies to. Empty / undefined ⇒ rule
33285
+ * applies to every class. Class strings match the `macroClass`
33286
+ * field on detections (e.g. `person`, `car`, `dog`).
33287
+ */
33288
+ classFilter: array(string()).readonly().optional(),
33289
+ /**
33290
+ * Minimum bbox/mask overlap (0–1) with any of the rule's zones
33291
+ * required to consider an entity "in the zone". Defaults to the
33292
+ * consumer's stage default when omitted. Kept for back-compat with
33293
+ * existing per-rule overrides; new operators pick the value via
33294
+ * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
33295
+ * set, the lower-level engine reads it as a 0–1 fraction.
33296
+ */
33297
+ overlapThreshold: number$1().min(0).max(1).optional(),
33298
+ /**
33299
+ * Operator-friendly version of `overlapThreshold` — the percentage
33300
+ * of the detection's bbox that must lie inside the zone for the
33301
+ * rule to match. Documented default is 85%; the engine substitutes
33302
+ * that when the field is omitted (kept optional so existing rules
33303
+ * stored without it stay valid).
33304
+ *
33305
+ * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
33306
+ * rule, the engine prefers `bboxInclusionPct` because it's the
33307
+ * field exposed in the UI. Internally both feed the same gate.
33308
+ */
33309
+ bboxInclusionPct: number$1().min(0).max(100).optional(),
33310
+ /**
33311
+ * When `true` and a detection has a segmentation mask, use the
33312
+ * mask for overlap instead of the bbox. Detection-stage only;
33313
+ * motion rules ignore this field.
33314
+ */
33315
+ preferMask: boolean().optional(),
33316
+ /**
33317
+ * Soft-toggle: `false` disables the rule without deleting it.
33318
+ * Defaults to `true` so operators creating a rule via the UI
33319
+ * see it active immediately.
33320
+ */
33321
+ enabled: boolean().default(true)
33322
+ });
33323
+ array(ZoneRuleSchema).readonly();
32524
33324
  object({
32525
33325
  /** Whether the script is currently executing. */
32526
33326
  isRunning: boolean(),
@@ -36701,6 +37501,30 @@ Object.freeze({
36701
37501
  addonId: null,
36702
37502
  access: "create"
36703
37503
  },
37504
+ "deviceExtension.listCandidates": {
37505
+ capName: "device-extension",
37506
+ capScope: "device",
37507
+ addonId: null,
37508
+ access: "view"
37509
+ },
37510
+ "deviceExtension.listSlots": {
37511
+ capName: "device-extension",
37512
+ capScope: "device",
37513
+ addonId: null,
37514
+ access: "view"
37515
+ },
37516
+ "deviceExtension.listSources": {
37517
+ capName: "device-extension",
37518
+ capScope: "device",
37519
+ addonId: null,
37520
+ access: "view"
37521
+ },
37522
+ "deviceExtension.setSlot": {
37523
+ capName: "device-extension",
37524
+ capScope: "device",
37525
+ addonId: null,
37526
+ access: "create"
37527
+ },
36704
37528
  "deviceManager.addLocation": {
36705
37529
  capName: "device-manager",
36706
37530
  capScope: "system",
@@ -37451,6 +38275,12 @@ Object.freeze({
37451
38275
  addonId: null,
37452
38276
  access: "view"
37453
38277
  },
38278
+ "embeddingEncoder.resetFailedModels": {
38279
+ capName: "embedding-encoder",
38280
+ capScope: "system",
38281
+ addonId: null,
38282
+ access: "delete"
38283
+ },
37454
38284
  "enumSensor.getStatus": {
37455
38285
  capName: "enum-sensor",
37456
38286
  capScope: "device",
@@ -38633,6 +39463,12 @@ Object.freeze({
38633
39463
  addonId: null,
38634
39464
  access: "create"
38635
39465
  },
39466
+ "nodes.directory": {
39467
+ capName: "nodes",
39468
+ capScope: "system",
39469
+ addonId: null,
39470
+ access: "view"
39471
+ },
38636
39472
  "nodes.executeQuery": {
38637
39473
  capName: "nodes",
38638
39474
  capScope: "system",
@@ -38801,6 +39637,12 @@ Object.freeze({
38801
39637
  addonId: null,
38802
39638
  access: "view"
38803
39639
  },
39640
+ "notificationRules.getRuleLastRuns": {
39641
+ capName: "notification-rules",
39642
+ capScope: "system",
39643
+ addonId: null,
39644
+ access: "view"
39645
+ },
38804
39646
  "notificationRules.getTemplateCatalog": {
38805
39647
  capName: "notification-rules",
38806
39648
  capScope: "system",
@@ -38825,6 +39667,12 @@ Object.freeze({
38825
39667
  addonId: null,
38826
39668
  access: "view"
38827
39669
  },
39670
+ "notificationRules.previewStateSummary": {
39671
+ capName: "notification-rules",
39672
+ capScope: "system",
39673
+ addonId: null,
39674
+ access: "view"
39675
+ },
38828
39676
  "notificationRules.previewTemplate": {
38829
39677
  capName: "notification-rules",
38830
39678
  capScope: "system",
@@ -39401,12 +40249,6 @@ Object.freeze({
39401
40249
  addonId: null,
39402
40250
  access: "create"
39403
40251
  },
39404
- "pipelineAnalytics.runReplayFrameProcessor": {
39405
- capName: "pipeline-analytics",
39406
- capScope: "device",
39407
- addonId: null,
39408
- access: "create"
39409
- },
39410
40252
  "pipelineAnalytics.saveRetrainAnnotations": {
39411
40253
  capName: "pipeline-analytics",
39412
40254
  capScope: "device",
@@ -39773,6 +40615,12 @@ Object.freeze({
39773
40615
  addonId: null,
39774
40616
  access: "view"
39775
40617
  },
40618
+ "pipelineOrchestrator.getClusterModelChoice": {
40619
+ capName: "pipeline-orchestrator",
40620
+ capScope: "system",
40621
+ addonId: null,
40622
+ access: "view"
40623
+ },
39776
40624
  "pipelineOrchestrator.getDeviceLiveContribution": {
39777
40625
  capName: "pipeline-orchestrator",
39778
40626
  capScope: "system",
@@ -42598,6 +43446,26 @@ Object.freeze({
42598
43446
  form: "single",
42599
43447
  optional: false
42600
43448
  }],
43449
+ "deviceExtension.listCandidates": [{
43450
+ name: "deviceId",
43451
+ form: "single",
43452
+ optional: false
43453
+ }],
43454
+ "deviceExtension.listSlots": [{
43455
+ name: "deviceId",
43456
+ form: "single",
43457
+ optional: false
43458
+ }],
43459
+ "deviceExtension.listSources": [{
43460
+ name: "deviceId",
43461
+ form: "single",
43462
+ optional: false
43463
+ }],
43464
+ "deviceExtension.setSlot": [{
43465
+ name: "deviceId",
43466
+ form: "single",
43467
+ optional: false
43468
+ }],
42601
43469
  "deviceManager.adoptionRelease": [{
42602
43470
  name: "camDeviceId",
42603
43471
  form: "single",
@@ -43504,11 +44372,6 @@ Object.freeze({
43504
44372
  form: "single",
43505
44373
  optional: false
43506
44374
  }],
43507
- "pipelineAnalytics.runReplayFrameProcessor": [{
43508
- name: "deviceId",
43509
- form: "single",
43510
- optional: false
43511
- }],
43512
44375
  "pipelineAnalytics.saveRetrainAnnotations": [{
43513
44376
  name: "deviceId",
43514
44377
  form: "single",
@@ -44397,11 +45260,232 @@ var NC_AUDIO_DEFAULTS = {
44397
45260
  samplingSeconds: 10
44398
45261
  };
44399
45262
  new Set(["devices", "classes"]);
45263
+ /**
45264
+ * WHICH narrowing filter speaks about WHICH system-event kind — one predicate,
45265
+ * consumed by the rule ENGINE and by every rule EDITOR.
45266
+ *
45267
+ * ── The failure this file exists for ───────────────────────────────────────
45268
+ * `NcSystemEventConditionSchema` carries four optional narrowing lists
45269
+ * (`deviceIds`, `deviceTypes`, `nodeIds`, `packageNames`) beside a required
45270
+ * `kinds` gate. They are not four filters over one vocabulary: each belongs to
45271
+ * a FAMILY of kinds and is meaningless outside it. A node going away has no
45272
+ * device type; a completed export has no package; `stream-offline` deliberately
45273
+ * carries no device type at all (a stream belongs to a camera by construction).
45274
+ *
45275
+ * The engine applied all four to every kind, so a filter from one family failed
45276
+ * a kind from another family CLOSED. The operator's live rule "Eventi di
45277
+ * sistema" selected eleven kinds and set `deviceTypes: ['camera']` — the only
45278
+ * way to say "only my cameras" about the two liveness kinds — and NINE of the
45279
+ * eleven silently stopped being deliverable. Four days of history contained
45280
+ * `device-online` and `device-offline` and nothing else, across a window in
45281
+ * which agents were restarted and addons were updated.
45282
+ *
45283
+ * Both editors already computed this scoping, to decide which filter boxes to
45284
+ * render; the cap's own docblock already promised it ("Narrow a `device-*` kind
45285
+ * to these device TYPES"). Only the engine disagreed, and it disagreed in the
45286
+ * destructive direction. So the rule is stated ONCE, here, and the engine and
45287
+ * the editors are readers of it rather than three independent authors.
45288
+ *
45289
+ * ── The direction ─────────────────────────────────────────────────────────
45290
+ * Out of family ⇒ the filter is IGNORED, never fail-closed. An editor that
45291
+ * hides a box has already told the operator this filter does not speak about
45292
+ * these kinds, so honouring it as an exclusion contradicts the only
45293
+ * explanation the operator was ever given. Inside its family the filter still
45294
+ * narrows, and still fails CLOSED on a subject that cannot produce the identity
45295
+ * it tests (a device the mirror cannot name is not evidence of a camera).
45296
+ */
45297
+ /**
45298
+ * Every filter, for the callers that must cover all of them (guards, tests).
45299
+ *
45300
+ * `consumableLowPercent` (D642) is not a list but it is a filter in exactly
45301
+ * this sense: it belongs to a family of kinds (the consumable pair) and the
45302
+ * engine consults it only there. It differs in one way the readers must know —
45303
+ * its ABSENCE is not "no narrowing" but the default threshold, because a
45304
+ * consumable episode is always judged at SOME threshold.
45305
+ */
45306
+ var NC_SYSTEM_EVENT_FILTER_KEYS = [
45307
+ "deviceIds",
45308
+ "deviceTypes",
45309
+ "nodeIds",
45310
+ "packageNames",
45311
+ "consumableLowPercent"
45312
+ ];
45313
+ new Map(Object.entries({
45314
+ "device-online": "device-events",
45315
+ "device-offline": "device-events",
45316
+ "device-disabled": "device-events",
45317
+ "device-enabled": "device-events",
45318
+ "device-battery-low": "device-events",
45319
+ "device-battery-normal": "device-events",
45320
+ "device-consumable-low": "device-events",
45321
+ "device-consumable-normal": "device-events",
45322
+ "device-tank-low": "device-events",
45323
+ "device-tank-full": "device-events",
45324
+ "device-tank-normal": "device-events",
45325
+ "stream-online": "device-events",
45326
+ "stream-offline": "device-events",
45327
+ "detection-blind": "device-events",
45328
+ "node-online": "system",
45329
+ "node-offline": "system",
45330
+ "node-inference-unavailable": "system",
45331
+ "addon-crash-loop": "system",
45332
+ "addon-update-available": "system",
45333
+ "addon-updated": "system",
45334
+ "server-update-available": "system",
45335
+ "server-updated": "system",
45336
+ "wrapper-update-available": "system",
45337
+ "backup-completed": "system",
45338
+ "export-completed": "system",
45339
+ "alarm-triggered": "alarm",
45340
+ "alarm-armed": "alarm",
45341
+ "alarm-disarmed": "alarm",
45342
+ "alarm-arming": "alarm",
45343
+ "alarm-arm-refused": "alarm",
45344
+ "alarm-pending": "alarm",
45345
+ "alarm-rearmed": "alarm",
45346
+ "alarm-sensor-bypass": "alarm",
45347
+ "alarm-check-failed": "alarm",
45348
+ "camera-online": null,
45349
+ "camera-offline": null,
45350
+ "camera-disabled": null,
45351
+ "camera-enabled": null
45352
+ }));
45353
+ [...NC_SYSTEM_EVENT_FILTER_KEYS];
45354
+ var NC_SYSTEM_EVENT_KIND_GROUP_SPECS = [
45355
+ {
45356
+ id: "device-state",
45357
+ family: "device-events",
45358
+ label: "Device state",
45359
+ kinds: [
45360
+ "device-offline",
45361
+ "device-online",
45362
+ "device-disabled",
45363
+ "device-enabled"
45364
+ ]
45365
+ },
45366
+ {
45367
+ id: "streams",
45368
+ family: "device-events",
45369
+ label: "Streams",
45370
+ kinds: ["stream-offline", "stream-online"]
45371
+ },
45372
+ {
45373
+ id: "battery",
45374
+ family: "device-events",
45375
+ label: "Battery",
45376
+ kinds: ["device-battery-low", "device-battery-normal"]
45377
+ },
45378
+ {
45379
+ id: "consumables",
45380
+ family: "device-events",
45381
+ label: "Consumables",
45382
+ kinds: ["device-consumable-low", "device-consumable-normal"]
45383
+ },
45384
+ {
45385
+ id: "tanks",
45386
+ family: "device-events",
45387
+ label: "Tanks",
45388
+ kinds: [
45389
+ "device-tank-low",
45390
+ "device-tank-full",
45391
+ "device-tank-normal"
45392
+ ]
45393
+ },
45394
+ {
45395
+ id: "detection-blind",
45396
+ family: "device-events",
45397
+ label: "Detecting nothing",
45398
+ kinds: ["detection-blind"]
45399
+ },
45400
+ {
45401
+ id: "nodes",
45402
+ family: "system",
45403
+ label: "Nodes",
45404
+ kinds: [
45405
+ "node-offline",
45406
+ "node-online",
45407
+ "node-inference-unavailable"
45408
+ ]
45409
+ },
45410
+ {
45411
+ id: "addons",
45412
+ family: "system",
45413
+ label: "Addons",
45414
+ kinds: [
45415
+ "addon-crash-loop",
45416
+ "addon-update-available",
45417
+ "addon-updated"
45418
+ ]
45419
+ },
45420
+ {
45421
+ id: "updates",
45422
+ family: "system",
45423
+ label: "Server & container updates",
45424
+ kinds: [
45425
+ "server-update-available",
45426
+ "server-updated",
45427
+ "wrapper-update-available"
45428
+ ]
45429
+ },
45430
+ {
45431
+ id: "backups-exports",
45432
+ family: "system",
45433
+ label: "Backups & exports",
45434
+ kinds: ["backup-completed", "export-completed"]
45435
+ },
45436
+ {
45437
+ id: "alarm",
45438
+ family: "alarm",
45439
+ label: "Alarm",
45440
+ kinds: NC_ALARM_SYSTEM_EVENT_KINDS
45441
+ }
45442
+ ];
45443
+ function systemEventKindsOfFamily(family) {
45444
+ return NC_SYSTEM_EVENT_KIND_GROUP_SPECS.filter((g) => g.family === family).flatMap((g) => g.kinds);
45445
+ }
44400
45446
  NC_AUDIO_DEFAULTS.hitPercent, NC_AUDIO_DEFAULTS.samplingSeconds;
45447
+ /**
45448
+ * WHICH WAY A BOOLEAN SENSOR MOVED — read off the one slice a sensor event
45449
+ * persists (D640 "a sensor rule fires on the raise, the clear, or both").
45450
+ *
45451
+ * A device-event rule over a flood sensor notified on BOTH edges: water
45452
+ * detected, and back to dry. `NcConditions.sensorTransition` lets the rule
45453
+ * name one edge; this file answers, for one `SensorEvent`, which edge it is.
45454
+ *
45455
+ * NOT A SECOND TABLE. The "which boolean of this cap counts as HIGH" question
45456
+ * already has one answer, `SOURCE_CAP_ACTIVE_FIELD`
45457
+ * (`catalogs/sensor-active-state.ts`, the doorbell's and the recorder's edge
45458
+ * table), and a sensor event names its kind, not its cap. So the table here is
45459
+ * DERIVED: event kind → cap (`EVENT_KIND_BY_CAP`) → that cap's active field.
45460
+ * Only kinds whose taxonomy category is `sensor` take part — a switch has an
45461
+ * `on` boolean too, but "it triggers / it clears" is not a sentence about a
45462
+ * light, and offering it there would be a knob with a misleading label.
45463
+ * `presence` is a WORD (`home` / `not_home` / a zone), not a boolean, and is
45464
+ * absent from the source table, so it is absent here.
45465
+ *
45466
+ * `undefined` = never guessed: a kind with no raise (a doorbell press, a
45467
+ * button, a cover), or a slice whose field is missing or not a boolean. The
45468
+ * engine then does NOT filter — a flood alert must not go silent because one
45469
+ * read came back unreadable (the same stance as the alarm's `sensorEdgeOf`).
45470
+ *
45471
+ * Pure, RN-safe: the viewer imports the support rule from here.
45472
+ */
45473
+ /** Event kind → the boolean field of its cap slice that means "raised". */
45474
+ var NC_SENSOR_RAISED_FIELD_BY_KIND = Object.freeze(Object.fromEntries(Object.entries(EVENT_KIND_BY_CAP).flatMap(([capName, descriptor]) => {
45475
+ const field = SOURCE_CAP_ACTIVE_FIELD[capName];
45476
+ if (field === void 0 || descriptor.category !== "sensor") return [];
45477
+ return [[descriptor.kind, field]];
45478
+ })));
45479
+ Object.freeze(Object.keys(NC_SENSOR_RAISED_FIELD_BY_KIND));
44401
45480
  var RULE_BODY_ONLY = ["body"];
44402
45481
  var RULE_TEXT = ["title", "body"];
44403
45482
  var BATTERY = ["device-battery-low", "device-battery-normal"];
44404
45483
  var CONSUMABLE = ["device-consumable-low", "device-consumable-normal"];
45484
+ var TANK = [
45485
+ "device-tank-low",
45486
+ "device-tank-full",
45487
+ "device-tank-normal"
45488
+ ];
44405
45489
  var UPDATES = [
44406
45490
  "addon-update-available",
44407
45491
  "server-update-available",
@@ -44427,12 +45511,189 @@ var DEVICE_EVENTS = [
44427
45511
  "device-enabled",
44428
45512
  ...BATTERY,
44429
45513
  ...CONSUMABLE,
45514
+ ...TANK,
44430
45515
  "stream-online",
44431
45516
  "stream-offline",
44432
45517
  "detection-blind",
44433
45518
  ...ALARM
44434
45519
  ];
44435
- [...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];
45520
+ /** Every kind a summary may speak about — the two summarisable families. */
45521
+ var SUMMARISABLE = [...systemEventKindsOfFamily("device-events"), ...systemEventKindsOfFamily("system")];
45522
+ /** One per summary SECTION (`NC_STATE_SUMMARY_SECTIONS` in the notification
45523
+ * centre): the section's lines, offered when one of its kinds is selected. */
45524
+ var STATE_SUMMARY_SECTION_VARS = [
45525
+ {
45526
+ name: "summaryDevices",
45527
+ label: "Summary: devices offline / switched off",
45528
+ example: "Garage — offline since 07:12",
45529
+ kinds: [
45530
+ "device-offline",
45531
+ "device-online",
45532
+ "device-disabled",
45533
+ "device-enabled"
45534
+ ]
45535
+ },
45536
+ {
45537
+ name: "summaryStreams",
45538
+ label: "Summary: streams offline",
45539
+ example: "Ingresso (high) — since 06:40",
45540
+ kinds: ["stream-offline", "stream-online"]
45541
+ },
45542
+ {
45543
+ name: "summaryBattery",
45544
+ label: "Summary: low batteries",
45545
+ example: "Sensore porta — 8 %",
45546
+ kinds: BATTERY
45547
+ },
45548
+ {
45549
+ name: "summaryConsumables",
45550
+ label: "Summary: consumables",
45551
+ example: "Robot — filter 10 %",
45552
+ kinds: CONSUMABLE
45553
+ },
45554
+ {
45555
+ name: "summaryTanks",
45556
+ label: "Summary: tanks",
45557
+ example: "Robot — clean water low",
45558
+ kinds: TANK
45559
+ },
45560
+ {
45561
+ name: "summaryDetection",
45562
+ label: "Summary: cameras detecting nothing",
45563
+ example: "Ingresso — since 05:10",
45564
+ kinds: ["detection-blind"]
45565
+ },
45566
+ {
45567
+ name: "summaryNodes",
45568
+ label: "Summary: nodes",
45569
+ example: "little-unraid — offline since 03:00",
45570
+ kinds: [
45571
+ "node-offline",
45572
+ "node-online",
45573
+ "node-inference-unavailable"
45574
+ ]
45575
+ },
45576
+ {
45577
+ name: "summaryAddons",
45578
+ label: "Summary: addons",
45579
+ example: "@camstack/addon-recorder 1.2.3 → 1.2.4",
45580
+ kinds: [
45581
+ "addon-crash-loop",
45582
+ "addon-update-available",
45583
+ "addon-updated"
45584
+ ]
45585
+ },
45586
+ {
45587
+ name: "summaryUpdates",
45588
+ label: "Summary: server & container updates",
45589
+ example: "server 1.2.377 → 1.2.378",
45590
+ kinds: [
45591
+ "server-update-available",
45592
+ "server-updated",
45593
+ "wrapper-update-available"
45594
+ ]
45595
+ }
45596
+ ];
45597
+ var STATE_SUMMARY_VARS = [
45598
+ {
45599
+ name: "summaryText",
45600
+ label: "Summary: every section",
45601
+ description: "One block per section with something to report, one line per item.",
45602
+ example: "Batterie scariche: Sensore porta — 8 %",
45603
+ group: "system",
45604
+ families: ["rule"],
45605
+ fields: [...RULE_TEXT],
45606
+ kinds: ["system"],
45607
+ systemEventKinds: [...SUMMARISABLE],
45608
+ systemEventDeliveries: ["summary"]
45609
+ },
45610
+ {
45611
+ name: "summaryCount",
45612
+ label: "Summary: items reported",
45613
+ example: "3",
45614
+ group: "system",
45615
+ families: ["rule"],
45616
+ fields: [...RULE_TEXT],
45617
+ kinds: ["system"],
45618
+ systemEventKinds: [...SUMMARISABLE],
45619
+ systemEventDeliveries: ["summary"]
45620
+ },
45621
+ ...STATE_SUMMARY_SECTION_VARS.map((v) => ({
45622
+ name: v.name,
45623
+ label: v.label,
45624
+ example: v.example,
45625
+ group: "system",
45626
+ families: ["rule"],
45627
+ fields: [...RULE_TEXT],
45628
+ kinds: ["system"],
45629
+ systemEventKinds: [...v.kinds],
45630
+ systemEventDeliveries: ["summary"]
45631
+ }))
45632
+ ];
45633
+ [
45634
+ [...DEVICE_EVENTS],
45635
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
45636
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
45637
+ [...RULE_TEXT],
45638
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
45639
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
45640
+ [...RULE_TEXT],
45641
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
45642
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
45643
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
45644
+ [...RULE_TEXT],
45645
+ [...RULE_TEXT],
45646
+ [...RULE_TEXT],
45647
+ [...RULE_TEXT],
45648
+ [...RULE_TEXT],
45649
+ [...RULE_TEXT],
45650
+ [...RULE_TEXT],
45651
+ [...RULE_TEXT],
45652
+ [...RULE_BODY_ONLY],
45653
+ [...RULE_TEXT],
45654
+ ([...RULE_TEXT], [...DEVICE_EVENTS]),
45655
+ ([...RULE_TEXT], [...DEVICE_EVENTS]),
45656
+ ([...RULE_TEXT], [...BATTERY, ...CONSUMABLE]),
45657
+ ([...RULE_TEXT], [...CONSUMABLE]),
45658
+ ([...RULE_TEXT], [...TANK]),
45659
+ [...RULE_TEXT],
45660
+ ([...RULE_TEXT], [...UPDATES]),
45661
+ ([...RULE_TEXT], [...UPDATES]),
45662
+ [...RULE_TEXT],
45663
+ [...RULE_TEXT],
45664
+ [...RULE_TEXT],
45665
+ ([...RULE_TEXT], [...UPDATES]),
45666
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
45667
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
45668
+ ([...RULE_TEXT], [...UPDATES]),
45669
+ ([...RULE_TEXT], [...UPDATES]),
45670
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
45671
+ [...RULE_TEXT],
45672
+ [...RULE_TEXT],
45673
+ [...RULE_TEXT],
45674
+ [...RULE_TEXT],
45675
+ [...RULE_TEXT],
45676
+ [...RULE_TEXT],
45677
+ [...RULE_TEXT],
45678
+ [...RULE_TEXT],
45679
+ [...RULE_TEXT],
45680
+ [...RULE_TEXT],
45681
+ [...RULE_TEXT],
45682
+ [...RULE_TEXT],
45683
+ [...RULE_TEXT],
45684
+ [...RULE_TEXT],
45685
+ [...RULE_TEXT],
45686
+ [...RULE_TEXT],
45687
+ [...RULE_TEXT],
45688
+ [...RULE_TEXT],
45689
+ [...RULE_TEXT],
45690
+ [...RULE_TEXT],
45691
+ [...RULE_TEXT],
45692
+ [...RULE_TEXT],
45693
+ [...RULE_TEXT],
45694
+ [...RULE_TEXT],
45695
+ ...STATE_SUMMARY_VARS
45696
+ ];
44436
45697
  /**
44437
45698
  * TimelapseRule — the STANDALONE scheduled timelapse producer's rule model.
44438
45699
  *
@@ -44664,68 +45925,6 @@ TimelapseRuleInputSchema.extend({
44664
45925
  createdAt: number$1(),
44665
45926
  updatedAt: number$1()
44666
45927
  });
44667
- Object.freeze(Object.fromEntries([{
44668
- stepId: "face-embedding",
44669
- label: "Face recognition model",
44670
- defaultModelId: "arcface-r100",
44671
- indexName: "the enrolled face gallery",
44672
- options: [
44673
- {
44674
- id: "arcface-r100",
44675
- label: "ArcFace (ResNet34)"
44676
- },
44677
- {
44678
- id: "auraface-r100",
44679
- label: "AuraFace R100"
44680
- },
44681
- {
44682
- id: "inception-resnet-v1",
44683
- label: "Inception ResNet V1"
44684
- }
44685
- ]
44686
- }, {
44687
- stepId: "clip-embedding",
44688
- label: "Semantic search model",
44689
- defaultModelId: "mobileclip-s1",
44690
- indexName: "the object semantic-search index",
44691
- options: [{
44692
- id: "mobileclip-s1",
44693
- label: "MobileCLIP S1"
44694
- }, {
44695
- id: "mobileclip-s2",
44696
- label: "MobileCLIP S2"
44697
- }]
44698
- }].map((s) => [s.stepId, s.defaultModelId])));
44699
- string().min(1);
44700
- var CLUSTER_STEP_SETTING_FIELDS = [{
44701
- stepId: "face-embedding",
44702
- key: "minLandmarkFaceSize",
44703
- label: "Min face size for recognition (detection px)",
44704
- 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.",
44705
- type: "slider",
44706
- min: 0,
44707
- max: 64,
44708
- step: 2,
44709
- default: 24
44710
- }];
44711
- function clusterStepSettingKey(stepId, fieldKey) {
44712
- return `clusterStepSetting:${stepId}:${fieldKey}`;
44713
- }
44714
- var ClusterSettingNumberSchema = number$1().finite();
44715
- function readClusterStepSettings(config) {
44716
- const out = {};
44717
- for (const field of CLUSTER_STEP_SETTING_FIELDS) {
44718
- const parsed = ClusterSettingNumberSchema.safeParse(config[clusterStepSettingKey(field.stepId, field.key)]);
44719
- const value = parsed.success ? parsed.data : field.default;
44720
- const existing = out[field.stepId] ?? {};
44721
- out[field.stepId] = {
44722
- ...existing,
44723
- [field.key]: value
44724
- };
44725
- }
44726
- return out;
44727
- }
44728
- readClusterStepSettings({});
44729
45928
  object({
44730
45929
  /**
44731
45930
  * Fraction of the box's own size added on EACH side before cutting.