@camstack/addon-osd-manager 0.1.139 → 0.1.141

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (19) hide show
  1. package/dist/{MotionZonesSettings-CG1jsdMo.mjs → MotionZonesSettings-DJKtseSs.mjs} +2 -2
  2. package/dist/{PrivacyMaskSettings-mBWMKyY2.mjs → PrivacyMaskSettings-DGuTzxj8.mjs} +4 -4
  3. package/dist/{SceneMonitorEditor-C_L1sFhf.mjs → SceneMonitorEditor-DmbBliPj.mjs} +3 -3
  4. package/dist/_stub.js +28 -28
  5. package/dist/{_virtual_mf-localSharedImportMap___mfe_internal__addon_osd_manager_page-COPuIhJm.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_osd_manager_page-CFuJP8Er.mjs} +3 -3
  6. package/dist/_virtual_mf___mfe_internal__addon_osd_manager_page__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-3cAFRv9T.mjs +26 -0
  7. package/dist/addon-osd-manager.css +1 -1
  8. package/dist/{hostInit-CtlLZppQ.mjs → hostInit-CwuHzT6C.mjs} +2 -2
  9. package/dist/index.js +2592 -1485
  10. package/dist/index.mjs +2592 -1485
  11. package/dist/{player-overlays-Cxv7i44p.mjs → player-overlays-BeNrtbAl.mjs} +1 -1
  12. package/dist/remoteEntry.js +1 -1
  13. package/dist/{responsive-BpLjT1Jf.mjs → responsive-CBuD1VHv.mjs} +1 -1
  14. package/dist/{scene-monitor-copy-CglGNTA4.mjs → scene-monitor-copy-BzF_xKZH.mjs} +1 -1
  15. package/dist/{square-CeQEcUQK.mjs → square-Cz6wpss1.mjs} +1 -1
  16. package/dist/{trash-2-D4OQxTrz.mjs → trash-2-B9H3d-I8.mjs} +1 -1
  17. package/dist/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_osd_manager_page__remoteEntry_js-CJGlrZlS.mjs → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_osd_manager_page__remoteEntry_js-vTWFpP59.mjs} +1 -1
  18. package/package.json +1 -1
  19. package/dist/_virtual_mf___mfe_internal__addon_osd_manager_page__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-B8-UPDOD.mjs +0 -26
package/dist/index.js CHANGED
@@ -5363,7 +5363,7 @@ var ZodIssueCode = {
5363
5363
  var ZodFirstPartyTypeKind;
5364
5364
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5365
5365
  //#endregion
5366
- //#region ../types/dist/sleep-DU7mu4wb.mjs
5366
+ //#region ../types/dist/sleep-BXv0ZcRa.mjs
5367
5367
  /**
5368
5368
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5369
5369
  * window to float samples (D455).
@@ -6148,6 +6148,40 @@ var BaseAddon = class {
6148
6148
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6149
6149
  return keys.size > 0 ? projectStore(raw, keys, node) : raw;
6150
6150
  }
6151
+ /**
6152
+ * Whether ONE global key of this addon's store was written, read three-way
6153
+ * (D651). For a question a hydrated view cannot answer: `getGlobalSettings`
6154
+ * reports `value ?? default`, so "the operator chose the default" and "nobody
6155
+ * chose" look the same, and a failed read looks like both. A `perNode` key is
6156
+ * not supported here: its stored name is scoped.
6157
+ */
6158
+ async readStoredGlobalKey(key) {
6159
+ const read = this._ctx?.settings?.readAddonStoreResult;
6160
+ if (read === void 0) return {
6161
+ kind: "unreadable",
6162
+ reason: "three-way-read-unavailable"
6163
+ };
6164
+ let result;
6165
+ try {
6166
+ result = await read.call(this._ctx?.settings);
6167
+ } catch (err) {
6168
+ return {
6169
+ kind: "unreadable",
6170
+ reason: "store-read-failed",
6171
+ error: err instanceof Error ? err.message : String(err)
6172
+ };
6173
+ }
6174
+ if (result.kind === "failed") return {
6175
+ kind: "unreadable",
6176
+ reason: "store-read-failed",
6177
+ error: result.error
6178
+ };
6179
+ if (result.kind === "missing" || !Object.prototype.hasOwnProperty.call(result.value, key)) return { kind: "absent" };
6180
+ return {
6181
+ kind: "present",
6182
+ value: result.value[key]
6183
+ };
6184
+ }
6151
6185
  async updateGlobalSettings(patch, nodeId) {
6152
6186
  const keys = this.perNodeKeys();
6153
6187
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
@@ -9502,6 +9536,43 @@ var LogChannelWindowSchema = object({
9502
9536
  /** `null` = every camera. A non-empty list narrows to those numeric ids. */
9503
9537
  deviceIds: array(number().int()).readonly().nullable()
9504
9538
  });
9539
+ var ClipModelMetaSchema = object({
9540
+ /** The paired text encoder's catalog id (the embedding-encoder's text catalog). */
9541
+ textModelId: string().min(1),
9542
+ /** Output dimension of BOTH towers. A vector of any other length is refused. */
9543
+ embeddingDim: number().int().positive(),
9544
+ /**
9545
+ * The `vector-store` index this model's vectors live in. ONE feature space
9546
+ * per index: two models share an index only when their vectors are ranked
9547
+ * against each other, which for CLIP means never across families. MobileCLIP
9548
+ * S1 and S2 share `object-clip` for history (separated by the row's
9549
+ * `modelId`); any other model gets its own.
9550
+ */
9551
+ vectorIndex: string().regex(/^object-clip(-[a-z0-9][a-z0-9-]*)?$/),
9552
+ /**
9553
+ * The text encoder's tokenizer, a declared SIBLING file of its onnx. The name
9554
+ * must be unique per tokenizer: every model's siblings land in ONE flat
9555
+ * models directory, so two different tokenizers under the same name would
9556
+ * silently overwrite each other (whichever model downloaded last wins, and
9557
+ * the other one tokenises with the wrong vocabulary).
9558
+ */
9559
+ tokenizerFile: string().min(1),
9560
+ /** Token window the text graph takes (SigLIP2: 64; CLIP BPE: 77). */
9561
+ contextLength: number().int().positive(),
9562
+ /** Id the tokenizer pads with. */
9563
+ padId: number().int().nonnegative(),
9564
+ /**
9565
+ * The search cosine floor at `strictness: 'loose'` — calibrated per model,
9566
+ * because cosine bands are a property of the model: 0.2 keeps 96% of matched
9567
+ * COCO caption-image pairs on MobileCLIP S1 and 2.7% on SigLIP2.
9568
+ */
9569
+ searchMinScore: number().min(0).max(1)
9570
+ });
9571
+ var ClipSearchStrictnessSchema = _enum([
9572
+ "loose",
9573
+ "balanced",
9574
+ "strict"
9575
+ ]);
9505
9576
  var MODEL_FORMATS = [
9506
9577
  "onnx",
9507
9578
  "coreml",
@@ -9530,7 +9601,7 @@ var ModelFormatEntrySchema = object({
9530
9601
  /** Multi-file payload (directory members or sibling files). */
9531
9602
  files: array(string()).readonly().optional(),
9532
9603
  /** Runtime(s) that can use this format. If omitted, inferred from ModelFormat key */
9533
- runtimes: array(_enum(["node", "python"])).readonly().optional()
9604
+ runtimes: array(_enum(["python"])).readonly().optional()
9534
9605
  });
9535
9606
  /**
9536
9607
  * Extra file that must be downloaded alongside the model (e.g., labels JSON, dict.txt).
@@ -9611,10 +9682,17 @@ var ModelCatalogEntrySchema = object({
9611
9682
  inputChannels: number().int().positive().optional(),
9612
9683
  labels: array(LabelDefinitionSchema).readonly(),
9613
9684
  inputLayout: _enum(["nchw", "nhwc"]).optional(),
9685
+ /**
9686
+ * `'scrfd'` applies InsightFace's SCRFD input contract, `(x - 127.5) / 128`
9687
+ * (upstream `insightface/model_zoo/scrfd.py`), instead of the historical
9688
+ * plain `/255`. Measured against COCO GT: 188 → 196 faces found on the
9689
+ * `scrfd-2.5g` catalog entry (2026-09-26 model-replacement spike, §2.4-2).
9690
+ */
9614
9691
  inputNormalization: _enum([
9615
9692
  "zero-one",
9616
9693
  "imagenet",
9617
- "none"
9694
+ "none",
9695
+ "scrfd"
9618
9696
  ]).optional(),
9619
9697
  /**
9620
9698
  * The model already applies softmax IN-GRAPH — its raw output is a
@@ -9698,7 +9776,14 @@ var ModelCatalogEntrySchema = object({
9698
9776
  * applies (Frigate / COCO public catalog). Set on a custom model whose raw
9699
9777
  * labels already ARE the CamStack macros (Scrypted identity map).
9700
9778
  */
9701
- classMap: DetectionCatalogClassMapSchema.optional()
9779
+ classMap: DetectionCatalogClassMapSchema.optional(),
9780
+ /**
9781
+ * The model's CLIP feature-space contract (text encoder, dimension, vector
9782
+ * index, token window, search floor) — see `clip-model.ts`. Present ONLY on a
9783
+ * CLIP image encoder; its absence is what "not a CLIP model" means to the
9784
+ * embedding encoder and the semantic-search store (D649).
9785
+ */
9786
+ clip: ClipModelMetaSchema.optional()
9702
9787
  });
9703
9788
  var ConvertTargetSchema = discriminatedUnion("format", [object({
9704
9789
  format: literal("openvino"),
@@ -9716,7 +9801,8 @@ var ModelConvertMetadataSchema = object({
9716
9801
  inputNormalization: _enum([
9717
9802
  "zero-one",
9718
9803
  "imagenet",
9719
- "none"
9804
+ "none",
9805
+ "scrfd"
9720
9806
  ]).optional(),
9721
9807
  preprocessMode: _enum(["letterbox", "resize"]).optional(),
9722
9808
  outputFormat: _enum([
@@ -15299,6 +15385,28 @@ var LinkedDeviceSchema = object({
15299
15385
  features: array(string()),
15300
15386
  producesTrackedEvents: boolean().optional()
15301
15387
  });
15388
+ /**
15389
+ * The `linked-devices` extension slot's editable value (D648): the operator's
15390
+ * pick list, exactly what `_linkedDeviceIds` persists. Tree children are NOT
15391
+ * in it — they are always linked and are not a pick.
15392
+ */
15393
+ var LinkedDevicesSlotValueSchema = object({ deviceIds: array(number().int().positive()) });
15394
+ /**
15395
+ * The `linked-devices` slot — a camera's companion devices, owned by the
15396
+ * device manager over `_linkedDeviceIds` (D648, D356). Any device may be a
15397
+ * source except a container (its children are picked in its place) and the
15398
+ * camera itself.
15399
+ */
15400
+ var LINKED_DEVICES_SLOT = {
15401
+ id: "linked-devices",
15402
+ label: "Linked devices",
15403
+ description: "Companion devices of this camera: their controls appear with it, and the ones you opt in produce tracked events on it.",
15404
+ shape: "association",
15405
+ hostDeviceTypes: [DeviceType.Camera],
15406
+ sourceCaps: "any",
15407
+ cardinality: "many",
15408
+ value: LinkedDevicesSlotValueSchema
15409
+ };
15302
15410
  /** One camera's resolved linked set, tagged with the camera it belongs to.
15303
15411
  * The batch answer needs the tag; the single-device answer already has it
15304
15412
  * from the input, which is why `getLinkedDevices` keeps the untagged shape. */
@@ -15448,6 +15556,7 @@ var deviceManagerCapability = {
15448
15556
  name: "device-manager",
15449
15557
  scope: "system",
15450
15558
  mode: "singleton",
15559
+ extensionSlots: [LINKED_DEVICES_SLOT],
15451
15560
  exposesDeviceSettings: true,
15452
15561
  methods: {
15453
15562
  /** Reserve (or re-resolve) a progressive numeric id for `(addonId, stableId)`.
@@ -15951,11 +16060,12 @@ var deviceManagerCapability = {
15951
16060
  /**
15952
16061
  * Resolve the devices LINKED to a camera — the single policy authority
15953
16062
  * both consumers call (viewer devices panel + pipeline-analytics event
15954
- * kinds/ingest). Device-tree children are ALWAYS included; mode 'auto'
15955
- * (default) adds every device sharing the camera's non-null `location`,
15956
- * mode 'manual' adds the persisted manual list instead. Excludes the
15957
- * camera itself; deduped. Configuration is standard per-device settings
15958
- * (see the module docblock) — there are no bespoke link mutations.
16063
+ * kinds/ingest). Device-tree children are ALWAYS included, plus the
16064
+ * operator's persisted pick list (`mode` is always `manual` since D356:
16065
+ * same-location devices are suggested by the picker, never linked on
16066
+ * their own). Excludes the camera itself; deduped. The list is written by
16067
+ * the settings section or the `linked-devices` extension slot, both over
16068
+ * `_linkedDeviceIds` (see the module docblock).
15959
16069
  */
15960
16070
  getLinkedDevices: method(object({ deviceId: number() }), object({
15961
16071
  mode: LinkedDevicesModeSchema,
@@ -16500,11 +16610,98 @@ var EmbeddingResultSchema = object({
16500
16610
  embedding: array(number()),
16501
16611
  inferenceMs: number()
16502
16612
  });
16613
+ /** The two CLIP towers the encoder runs; a crash budget is kept per tower. */
16614
+ var EmbeddingTowerSchema = _enum(["image", "text"]);
16615
+ /**
16616
+ * A tower in the terminal `failed` state (D649, D6): it crashed or failed to
16617
+ * load `crashes` times within `windowMs`, and is refused by name until an
16618
+ * operator `resetFailedModels` or a model change — never on a timer.
16619
+ *
16620
+ * `nodeId` is the node whose tower failed. The state lives in THAT node's
16621
+ * encoder process (in memory — a runner respawn clears it), and one node's
16622
+ * answer says nothing about another's.
16623
+ */
16624
+ var EmbeddingFailedModelSchema = object({
16625
+ modelId: string(),
16626
+ tower: EmbeddingTowerSchema,
16627
+ nodeId: string(),
16628
+ crashes: number(),
16629
+ windowMs: number(),
16630
+ sinceMs: number(),
16631
+ lastReason: string()
16632
+ });
16633
+ /**
16634
+ * A model whose REQUIREMENTS can never be met on this node (D649 round 5):
16635
+ * an id the catalog does not know, a model URL answering 404/410, a declared
16636
+ * sibling (the tokenizer) that is not there. After `attempts` failed builds
16637
+ * it is terminally `requirements-failed`, refused by name until an operator
16638
+ * `resetFailedModels` or a model change — the same exits as a crashed tower.
16639
+ */
16640
+ var EmbeddingFailedRequirementSchema = object({
16641
+ modelId: string(),
16642
+ tower: EmbeddingTowerSchema,
16643
+ nodeId: string(),
16644
+ attempts: number(),
16645
+ sinceMs: number(),
16646
+ lastReason: string()
16647
+ });
16503
16648
  var EmbeddingInfoSchema = object({
16504
16649
  modelId: string(),
16505
16650
  embeddingDim: number(),
16506
- ready: boolean()
16507
- });
16651
+ ready: boolean(),
16652
+ /**
16653
+ * The node that answered. Absent only from an encoder older than D649's
16654
+ * crash budget — whose `failedModels` is then UNKNOWN (D315), never "none".
16655
+ */
16656
+ nodeId: string().optional(),
16657
+ /**
16658
+ * Towers in `failed` on the answering node, each row naming it. `undefined`
16659
+ * means the node could not say (pre-budget encoder); a node that has the
16660
+ * budget always answers an array, empty included.
16661
+ */
16662
+ failedModels: array(EmbeddingFailedModelSchema).optional(),
16663
+ /** Models terminally `requirements-failed` on the answering node; same reading as above. */
16664
+ failedRequirements: array(EmbeddingFailedRequirementSchema).optional()
16665
+ });
16666
+ /**
16667
+ * The THREE codes an encoder refusal can carry (D649, D6). Same shape as
16668
+ * `VECTOR_INDEX_DIM_CONFLICT`: the code rides in the MESSAGE, because an
16669
+ * Error's own properties do not survive the UDS/tRPC hop and its message does,
16670
+ * and both sides go through the helpers below — the encoder builds the
16671
+ * refusal, the live detail plane classifies on it to count refusals per
16672
+ * camera instead of logging one warning per track. The bracketed token
16673
+ * carries the code, the model, the tower and the node so a consumer never
16674
+ * parses prose.
16675
+ *
16676
+ * - `EMBEDDING_MODEL_FAILED`: the tower crashed / failed to load past the crash
16677
+ * budget — terminal until `resetFailedModels` or a model change.
16678
+ * - `EMBEDDING_REQUIREMENTS_UNAVAILABLE`: files or runtime not there right now
16679
+ * (a download or Python that failed, or the cooldown after one) — the next
16680
+ * request past the cooldown tries again.
16681
+ * - `EMBEDDING_REQUIREMENTS_FAILED`: the requirements can never be met (unknown
16682
+ * id, 404/410, missing sibling) and the bounded attempts are spent —
16683
+ * terminal, same exits as a crashed tower.
16684
+ */
16685
+ var EMBEDDING_MODEL_FAILED = "embedding-model-failed";
16686
+ var EMBEDDING_REQUIREMENTS_UNAVAILABLE = "embedding-requirements-unavailable";
16687
+ var EMBEDDING_REQUIREMENTS_FAILED = "embedding-requirements-failed";
16688
+ _enum([
16689
+ EMBEDDING_MODEL_FAILED,
16690
+ EMBEDDING_REQUIREMENTS_UNAVAILABLE,
16691
+ EMBEDDING_REQUIREMENTS_FAILED
16692
+ ]);
16693
+ new RegExp(`\\[(${EMBEDDING_MODEL_FAILED}|${EMBEDDING_REQUIREMENTS_UNAVAILABLE}|${EMBEDDING_REQUIREMENTS_FAILED}) model=([^\\s\\]]+) tower=(image|text) node=([^\\s\\]]+)\\]`);
16694
+ /**
16695
+ * ONE provider per node (`placement: any-node`), addressed like every global
16696
+ * collection: the codegen injects a `{ nodeId?, addonId? }` selector on the
16697
+ * void methods and lifts a top-level `nodeId` off the object ones. A call
16698
+ * that names no node is answered by the HUB's provider — never by a merge
16699
+ * across nodes, because no global collection fans out across nodes (only the
16700
+ * providers of one node are `concatCollection`-fanned). So a fleet view of
16701
+ * `failedModels` is one `getInfo({ nodeId })` per node, and every answer
16702
+ * names the node it came from (D649 round 4); a node that cannot be asked is
16703
+ * UNKNOWN to the reader, never "no failures" (D315).
16704
+ */
16508
16705
  var embeddingEncoderCapability = {
16509
16706
  name: "embedding-encoder",
16510
16707
  scope: "system",
@@ -16523,8 +16720,30 @@ var embeddingEncoderCapability = {
16523
16720
  width: number(),
16524
16721
  height: number()
16525
16722
  }), EmbeddingResultSchema, { auth: "admin" }),
16526
- encodeText: method(object({ text: string() }), EmbeddingResultSchema, { auth: "admin" }),
16527
- getInfo: method(_void(), EmbeddingInfoSchema, { auth: "admin" })
16723
+ /**
16724
+ * `modelId` (a CLIP IMAGE model id, whose catalog `clip.textModelId` names
16725
+ * the text tower) encodes in that model's space; absent, the cluster row's
16726
+ * `clip-embedding` model — the space every writer is in (D649).
16727
+ */
16728
+ encodeText: method(object({
16729
+ text: string(),
16730
+ modelId: string().min(1).optional()
16731
+ }), EmbeddingResultSchema, { auth: "admin" }),
16732
+ /** Answers for ONE node — the `nodeId` selector's, else the hub's. */
16733
+ getInfo: method(_void(), EmbeddingInfoSchema, { auth: "admin" }),
16734
+ /**
16735
+ * The operator's explicit clear of the `failed` state (one model, or all)
16736
+ * on ONE node — pass `nodeId` for an agent; the result names the node it
16737
+ * cleared. The only way out besides a model change: a crashing tower is
16738
+ * not retried on a timer.
16739
+ */
16740
+ resetFailedModels: method(object({ modelId: string().min(1).optional() }), object({
16741
+ cleared: array(string()),
16742
+ nodeId: string()
16743
+ }), {
16744
+ kind: "mutation",
16745
+ auth: "admin"
16746
+ })
16528
16747
  }
16529
16748
  };
16530
16749
  /**
@@ -19531,6 +19750,9 @@ var NcSystemEventKindSchema = _enum([
19531
19750
  "device-battery-normal",
19532
19751
  "device-consumable-low",
19533
19752
  "device-consumable-normal",
19753
+ "device-tank-low",
19754
+ "device-tank-full",
19755
+ "device-tank-normal",
19534
19756
  "stream-online",
19535
19757
  "stream-offline",
19536
19758
  "node-online",
@@ -19568,6 +19790,29 @@ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
19568
19790
  ]);
19569
19791
  NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
19570
19792
  /**
19793
+ * The panel's transitions, as ONE list.
19794
+ *
19795
+ * Named here rather than spelled out at each of the four sites that need them
19796
+ * (the emitter, the intake, the editor group, the combined-notification gate),
19797
+ * because a transition added to the enum and forgotten at one of them is an
19798
+ * alarm state nobody can be notified about. That is exactly what this list
19799
+ * failed to prevent while it held three: `alarm-arming` was the fourth.
19800
+ *
19801
+ * In LIFECYCLE order, which is the order an editor lists them in and the order
19802
+ * a person experiences them — not the order they were added.
19803
+ */
19804
+ var NC_ALARM_SYSTEM_EVENT_KINDS = [
19805
+ "alarm-arm-refused",
19806
+ "alarm-check-failed",
19807
+ "alarm-arming",
19808
+ "alarm-armed",
19809
+ "alarm-pending",
19810
+ "alarm-triggered",
19811
+ "alarm-rearmed",
19812
+ "alarm-sensor-bypass",
19813
+ "alarm-disarmed"
19814
+ ];
19815
+ /**
19571
19816
  * One coherent system-event condition. `kinds` is the required opt-in safety
19572
19817
  * gate; the remaining lists are optional narrowing filters relevant to the
19573
19818
  * selected kinds.
@@ -19601,7 +19846,22 @@ var NcSystemEventConditionSchema = object({
19601
19846
  */
19602
19847
  excludeDeviceIds: array(number().int()).min(1).optional(),
19603
19848
  nodeIds: array(string().min(1)).min(1).optional(),
19604
- packageNames: array(string().min(1)).min(1).optional()
19849
+ packageNames: array(string().min(1)).min(1).optional(),
19850
+ /**
19851
+ * At or below this remaining-life %, a consumable is LOW for THIS rule
19852
+ * (D642). Absent = {@link NC_CONSUMABLE_LOW_PERCENT_DEFAULT}; at most
19853
+ * {@link NC_CONSUMABLE_LOW_PERCENT_MAX}, so every episode can recover. Scoped to the
19854
+ * consumable kinds (`systemEventFilterApplies`) and to the device-events
19855
+ * family; ignored on every other kind.
19856
+ *
19857
+ * It is a property of the RULE because the operator decided so: a rule at
19858
+ * 25 must be told about a filter at 20 %, a rule at 10 must not. The hub
19859
+ * keeps one episode per (threshold, device, item) — its own hysteresis, its
19860
+ * own reminder — and a rule hears only the episode judged at ITS threshold,
19861
+ * exactly as an occupancy rule hears only the edge of its own count. A
19862
+ * provider's own `replace` verdict is low at every threshold.
19863
+ */
19864
+ consumableLowPercent: number().int().min(1).max(95).optional()
19605
19865
  });
19606
19866
  /** Hard ceiling on a window (24h). A snooze that could not expire would be an
19607
19867
  * outage the operator asked for once and forgot. */
@@ -19619,6 +19879,25 @@ var NcScheduleSchema = object({
19619
19879
  /** Active OUTSIDE the windows (e.g. "only outside business hours"). */
19620
19880
  invert: boolean().optional()
19621
19881
  });
19882
+ /**
19883
+ * How a system-event rule of the `device-events` or `system` family speaks
19884
+ * (D647): at once, per event (`instant`, the only behaviour before D647), or
19885
+ * as a STATE SUMMARY at the end of each window of `schedule`.
19886
+ */
19887
+ var NcSystemEventDeliveryModeSchema = _enum(["instant", "summary"]);
19888
+ /**
19889
+ * `summary`: the rule sends NOTHING per event. When a window of `schedule`
19890
+ * CLOSES, it sends one notification with the current state of its kinds
19891
+ * (low batteries, consumables to replace, devices offline, updates
19892
+ * available, ...), after its own filters. Nothing to report sends nothing.
19893
+ * The schedule is the ordinary `NcSchedule` (weekly windows, IANA timezone,
19894
+ * midnight crossing); the send time is each window's END. Refused on the
19895
+ * `alarm` family, which stays instant (`systemEventDeliveryProblems`).
19896
+ */
19897
+ var NcSystemEventDeliverySchema = discriminatedUnion("mode", [object({ mode: literal("instant") }), object({
19898
+ mode: literal("summary"),
19899
+ schedule: NcScheduleSchema
19900
+ })]);
19622
19901
  /** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
19623
19902
  var NcPlateMatcherSchema = object({
19624
19903
  /**
@@ -20232,7 +20511,12 @@ var NcMediaPolicySchema = object({
20232
20511
  * the degrade engine, which drops the video and keeps the still.
20233
20512
  */
20234
20513
  clip: boolean().optional(),
20235
- /** Seconds of footage BEFORE / AFTER the event instant. Defaults 3 / 7. */
20514
+ /**
20515
+ * Seconds of footage BEFORE / AFTER the event instant. Absent =
20516
+ * {@link NC_CLIP_PRE_ROLL_DEFAULT_SEC} / {@link NC_CLIP_POST_ROLL_DEFAULT_SEC}
20517
+ * (4 / 6), resolved by the Notification Center at dispatch — deliberately not
20518
+ * a Zod default, so a rule that never chose keeps following the hub's.
20519
+ */
20236
20520
  clipPreRollSec: number().int().min(0).max(30).optional(),
20237
20521
  clipPostRollSec: number().int().min(0).max(30).optional(),
20238
20522
  /**
@@ -20354,6 +20638,16 @@ var NcRuleInputSchema = object({
20354
20638
  delivery: NcDeliverySchema,
20355
20639
  conditions: NcConditionsSchema.default({}),
20356
20640
  schedule: NcScheduleSchema.optional(),
20641
+ /**
20642
+ * A `device-events` / `system` rule's delivery (D647): absent or `instant`
20643
+ * is a notification per event; `summary` is one state summary per closed
20644
+ * window of its schedule. `.optional()` and never defaulted: absent must
20645
+ * keep meaning what every rule authored before D647 meant, with no
20646
+ * migration. Top-level rather than inside `conditions.systemEvent`, so a
20647
+ * client that does not know it (an older viewer re-sending `conditions`
20648
+ * whole) leaves it standing through the store's patch merge.
20649
+ */
20650
+ systemEventDelivery: NcSystemEventDeliverySchema.optional(),
20357
20651
  /** May be empty when `targetUsers` addresses at least one user — the
20358
20652
  * "at least one addressee" invariant is enforced by the provider, because
20359
20653
  * a cross-field refine here would break `NcRulePatchSchema.partial()`. */
@@ -20582,6 +20876,28 @@ var NcRuleSchema = NcRuleInputSchema.extend({
20582
20876
  */
20583
20877
  disabledTargetIds: array(string()).default([])
20584
20878
  });
20879
+ /** One section of a previewed state summary. `unavailable` = its state could not be read. */
20880
+ var NcStateSummaryPreviewSectionSchema = object({
20881
+ id: string(),
20882
+ status: _enum(["read", "unavailable"]),
20883
+ items: number().int().nonnegative(),
20884
+ reason: string().optional()
20885
+ });
20886
+ /**
20887
+ * The summary a rule would send now. `empty` = nothing to report and every
20888
+ * section read: such a summary is NOT sent. `dropped` counts the open states
20889
+ * the rule's own filters (or a camera mute) left out, by reason.
20890
+ * `excludedGroups` names the kind groups selected that have no state to report
20891
+ * (backups & exports).
20892
+ */
20893
+ var NcStateSummaryPreviewSchema = object({
20894
+ empty: boolean(),
20895
+ count: number().int().nonnegative(),
20896
+ text: string(),
20897
+ sections: array(NcStateSummaryPreviewSectionSchema),
20898
+ dropped: record(string(), number().int().nonnegative()),
20899
+ excludedGroups: array(string())
20900
+ });
20585
20901
  var NcTestResultSchema = object({
20586
20902
  recordId: string(),
20587
20903
  recordKind: _enum([
@@ -20673,6 +20989,13 @@ var NcTemplateVarDescriptorSchema = object({
20673
20989
  kinds: array(NcTemplateVarKindSchema).optional(),
20674
20990
  deliveries: array(NcDeliverySchema).optional(),
20675
20991
  systemEventKinds: array(NcSystemEventKindSchema).optional(),
20992
+ /**
20993
+ * Which system-event DELIVERY has a value for it (D647). Absent = an
20994
+ * instant row only when the descriptor names `systemEventKinds` (a
20995
+ * per-event fact: a summary row has no single device), and both otherwise.
20996
+ * `['summary']` marks the state-summary vocabulary (`{{summaryText}}`, ...).
20997
+ */
20998
+ systemEventDeliveries: array(NcSystemEventDeliveryModeSchema).optional(),
20676
20999
  dynamic: object({
20677
21000
  prefix: literal("count_"),
20678
21001
  from: literal("classes")
@@ -20685,7 +21008,9 @@ var NcTemplatePreviewInputSchema = object({
20685
21008
  field: NcTemplateFieldSchema,
20686
21009
  kind: NcRuleKindSchema.optional(),
20687
21010
  delivery: NcDeliverySchema.optional(),
20688
- systemEventKinds: array(NcSystemEventKindSchema).optional()
21011
+ systemEventKinds: array(NcSystemEventKindSchema).optional(),
21012
+ /** The rule's system-event delivery (D647); absent = instant. */
21013
+ systemEventDelivery: NcSystemEventDeliveryModeSchema.optional()
20689
21014
  }),
20690
21015
  template: object({
20691
21016
  title: string().max(500).optional(),
@@ -20863,6 +21188,18 @@ var NC_CONDITION_CATALOG = [
20863
21188
  value: "device-consumable-normal",
20864
21189
  label: "Consumable replaced"
20865
21190
  },
21191
+ {
21192
+ value: "device-tank-low",
21193
+ label: "Tank low (water, detergent)"
21194
+ },
21195
+ {
21196
+ value: "device-tank-full",
21197
+ label: "Tank full (dirty water, dust)"
21198
+ },
21199
+ {
21200
+ value: "device-tank-normal",
21201
+ label: "Tank back to normal"
21202
+ },
20866
21203
  {
20867
21204
  value: "export-completed",
20868
21205
  label: "Export completed"
@@ -21806,6 +22143,17 @@ var notificationRulesCapability = {
21806
22143
  auth: "admin"
21807
22144
  }),
21808
22145
  /**
22146
+ * The STATE SUMMARY a system rule would send now (D647) — for a saved rule
22147
+ * or an unsaved draft. Pure: sends nothing, stamps nothing. A MUTATION
22148
+ * only for transport (a whole rule does not belong in a GET URL). Admin,
22149
+ * like `testRule`: it names devices and nodes across the installation.
22150
+ */
22151
+ previewStateSummary: method(object({ rule: NcRuleInputSchema }), NcStateSummaryPreviewSchema, {
22152
+ kind: "mutation",
22153
+ auth: "admin",
22154
+ access: "view"
22155
+ }),
22156
+ /**
21809
22157
  * The machine-readable condition surface a rule editor renders from, plus
21810
22158
  * the picker VOCABULARY those conditions draw on.
21811
22159
  *
@@ -22266,982 +22614,282 @@ var oauthIntegrationCapability = {
22266
22614
  getDescriptor: method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" }) }
22267
22615
  };
22268
22616
  /**
22269
- * Reference to the frame's retained NATIVE surface + the parent crop's placement
22270
- * within the frame, so the executor can re-cut a leaf child ROI at native
22271
- * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
22617
+ * A model choice has a SCOPE, and a scope change has a workflow.
22618
+ *
22619
+ * ## The two scopes
22620
+ *
22621
+ * Almost every pipeline step's model is a **node** question: which build runs
22622
+ * fastest on THIS accelerator. Two nodes may legitimately answer differently —
22623
+ * a Coral runs the tflite SSD, a Mac runs the coreml YOLO — because the answers
22624
+ * are compared against nothing. They produce boxes, and a box is a box.
22625
+ *
22626
+ * Two steps are not like that. `face-embedding` and `clip-embedding` produce
22627
+ * **vectors that land in ONE shared index** (`identity_samples`,
22628
+ * `vec_object_clip`) and are ranked against each other by cosine similarity.
22629
+ * Cosine similarity between two encoders is not a weak signal, it is a
22630
+ * meaningless number — and nothing inside a vector can tell you it happened.
22631
+ * So for those two steps the model is a **cluster** question with exactly one
22632
+ * answer, stored in exactly one row.
22633
+ *
22634
+ * That is the same argument [D52](../../../../docs/decisions/adr-0052.md) makes
22635
+ * for the crop convention (`detail-crop.ts`), one level up: the crop decides
22636
+ * WHAT pixels the encoder sees, this decides WHICH encoder sees them. Both are
22637
+ * cluster-wide for the same reason and neither may become per-node.
22638
+ *
22639
+ * ## Why the registry lives here and not in the step catalog
22640
+ *
22641
+ * The scope itself is declared on the step, in
22642
+ * `detection-pipeline/registry/step-definitions.ts` (`StepDefinition.modelScope`)
22643
+ * — that is where a new step declares what kind of choice its model is. But the
22644
+ * catalog lives inside `addon-pipeline`, and three packages that must NOT
22645
+ * import an addon need to know the set: the orchestrator (which renders and
22646
+ * stores the row), post-analysis (which pins the row for a re-embed pass) and
22647
+ * admin-ui (which mirrors it). So the set is mirrored here, and
22648
+ * `scripts/check-cluster-model-scope.ts` fails the build when the two disagree.
22649
+ * A hand-copied key that stops matching is exactly how a setting silently stops
22650
+ * arriving while both sides still look correct.
22651
+ *
22652
+ * ## The defaults ARE today's behaviour
22653
+ *
22654
+ * {@link DEFAULT_CLUSTER_STEP_MODELS} reproduces the catalog `defaultModelId`
22655
+ * of both steps. Declaring the scope therefore changes nothing on the day it
22656
+ * ships: the cluster row starts out saying what every node was already doing.
22657
+ * Changing it is legitimate — that is what the knob is for — but it invalidates
22658
+ * the stored vectors of that surface, and must be followed by a re-embed pass
22659
+ * (`face-reembed-pass.ts`, `embedding-rebuild.ts`).
22660
+ */
22661
+ /**
22662
+ * Why the orchestrator cannot say which model the operator chose for a
22663
+ * cluster-scoped step (D651).
22664
+ */
22665
+ var CLUSTER_MODEL_CHOICE_UNREADABLE_REASONS = [
22666
+ "owner-not-ready",
22667
+ "store-read-failed",
22668
+ "three-way-read-unavailable",
22669
+ "invalid-stored",
22670
+ "not-cluster-scoped"
22671
+ ];
22672
+ Object.freeze(Object.fromEntries([{
22673
+ stepId: "face-embedding",
22674
+ label: "Face recognition model",
22675
+ defaultModelId: "auraface-r100",
22676
+ indexName: "the enrolled face gallery",
22677
+ options: [
22678
+ {
22679
+ id: "auraface-r100",
22680
+ label: "AuraFace R100"
22681
+ },
22682
+ {
22683
+ id: "arcface-r100",
22684
+ label: "ArcFace (ResNet34)"
22685
+ },
22686
+ {
22687
+ id: "inception-resnet-v1",
22688
+ label: "Inception ResNet V1"
22689
+ }
22690
+ ]
22691
+ }, {
22692
+ stepId: "clip-embedding",
22693
+ label: "Semantic search model",
22694
+ defaultModelId: "mobileclip-s1",
22695
+ indexName: "the object semantic-search index",
22696
+ options: [
22697
+ {
22698
+ id: "mobileclip-s1",
22699
+ label: "MobileCLIP S1"
22700
+ },
22701
+ {
22702
+ id: "mobileclip-s2",
22703
+ label: "MobileCLIP S2"
22704
+ },
22705
+ {
22706
+ id: "siglip2-b16-224",
22707
+ label: "SigLIP2 B/16 (Apache-2.0)"
22708
+ }
22709
+ ]
22710
+ }].map((s) => [s.stepId, s.defaultModelId])));
22711
+ var CLUSTER_STEP_SETTING_FIELDS = [{
22712
+ stepId: "face-embedding",
22713
+ key: "minLandmarkFaceSize",
22714
+ label: "Min face size for recognition (detection px)",
22715
+ 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.",
22716
+ type: "slider",
22717
+ min: 0,
22718
+ max: 64,
22719
+ step: 2,
22720
+ default: 24
22721
+ }];
22722
+ function clusterStepSettingKey(stepId, fieldKey) {
22723
+ return `clusterStepSetting:${stepId}:${fieldKey}`;
22724
+ }
22725
+ var ClusterSettingNumberSchema = number().finite();
22726
+ function readClusterStepSettings(config) {
22727
+ const out = {};
22728
+ for (const field of CLUSTER_STEP_SETTING_FIELDS) {
22729
+ const parsed = ClusterSettingNumberSchema.safeParse(config[clusterStepSettingKey(field.stepId, field.key)]);
22730
+ const value = parsed.success ? parsed.data : field.default;
22731
+ const existing = out[field.stepId] ?? {};
22732
+ out[field.stepId] = {
22733
+ ...existing,
22734
+ [field.key]: value
22735
+ };
22736
+ }
22737
+ return out;
22738
+ }
22739
+ readClusterStepSettings({});
22740
+ /**
22741
+ * pipeline-analytics — device-scoped wrapper cap. Refines raw
22742
+ * per-frame detections emitted by the pipeline runner into tracked
22743
+ * objects, per-kind event collections (motion / object / audio), and
22744
+ * persisted media. Owns the post-detection domain end-to-end:
22745
+ *
22746
+ * runner emits PipelineInferenceResult
22747
+ * ↓ (event bus)
22748
+ * pipeline-analytics subscriber
22749
+ * ↓ SORT tracker + zone engine + state analyzer + event emitter
22750
+ * → three DB collections (one per kind), one FS media tree, one
22751
+ * unified event emitter (FrameTracked + TrackStarted/Ended +
22752
+ * DetectionEvent on bus)
22753
+ *
22754
+ * Pure subscriber model. No `processFrame` cap method — the runner
22755
+ * already publishes the raw frame on the bus. The cap surface is
22756
+ * only QUERIES + per-device settings, bound on/off via
22757
+ * `device-manager.setWrapperActive`. `defaultActive: true` because
22758
+ * every camera with a detection pipeline wants its raw detections
22759
+ * refined; operators opt out per-device via BindingsTab when needed.
22760
+ *
22761
+ * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
22762
+ * (per-device surface) and `track-trail` caps — see P11 cleanup.
22272
22763
  */
22273
- var NativeCropRefSchema = object({
22274
- /** Handle keying the retained native surface (node-pinned to its owner). */
22275
- handle: FrameHandleSchema,
22276
- /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
22277
- cropFrameSpace: object({
22278
- x: number(),
22279
- y: number(),
22280
- w: number(),
22281
- h: number()
22282
- })
22283
- });
22284
- object({
22285
- crop: object({
22286
- left: number(),
22287
- top: number(),
22288
- width: number().positive(),
22289
- height: number().positive()
22290
- }).optional(),
22291
- content: object({
22292
- width: number().int().positive(),
22293
- height: number().int().positive()
22294
- }),
22295
- fit: _enum(["stretch", "contain"]),
22296
- format: _enum([
22297
- "rgb",
22298
- "gray",
22299
- "jpeg"
22300
- ])
22301
- });
22764
+ var TrackStateSchema = _enum([
22765
+ "new",
22766
+ "entered",
22767
+ "left",
22768
+ "moving",
22769
+ "idle"
22770
+ ]);
22771
+ var EventKindSchema = _enum([
22772
+ "motion",
22773
+ "object",
22774
+ "audio"
22775
+ ]);
22302
22776
  /**
22303
- * Process-local frame identity. It is serializable so it can ride an in-process
22304
- * capability call, but `registryId` deliberately prevents resolution in any
22305
- * other process or execution group.
22777
+ * Spatial filter for `listTracks` — the rect + polygon variants of the shared
22778
+ * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
22779
+ * of the camera frame (top-left origin), matching the drawing-plane editor.
22306
22780
  */
22307
- var FrameRefSchema = object({
22308
- registryId: string().min(1),
22309
- id: string().min(1),
22310
- width: number().int().positive(),
22311
- height: number().int().positive(),
22312
- format: _enum(["rgb", "gray"]),
22313
- timestamp: number(),
22314
- capturedAt: number().optional()
22315
- });
22316
- var ModelFormatSchema$1 = _enum([
22317
- "onnx",
22318
- "coreml",
22319
- "openvino",
22320
- "tflite",
22321
- "pt",
22322
- "gguf"
22781
+ var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
22782
+ /** Closed icon vocabulary so clients render a known glyph per kind. */
22783
+ var EventKindIconSchema = _enum([
22784
+ "motion",
22785
+ "audio",
22786
+ "person",
22787
+ "vehicle",
22788
+ "animal",
22789
+ "door",
22790
+ "pir",
22791
+ "smoke",
22792
+ "water",
22793
+ "button",
22794
+ "package",
22795
+ "generic"
22323
22796
  ]);
22324
- var PipelineSlotSchema = _enum([
22325
- "detector",
22326
- "cropper",
22327
- "classifier",
22328
- "refiner",
22329
- "audio-classifier"
22797
+ var EventKindCategorySchema = _enum([
22798
+ "motion",
22799
+ "audio",
22800
+ "detection",
22801
+ "sensor",
22802
+ "control",
22803
+ "custom",
22804
+ "package"
22330
22805
  ]);
22331
- var PipelineEngineChoiceSchema = object({
22332
- runtime: _enum(["node", "python"]),
22333
- backend: string(),
22334
- format: ModelFormatSchema$1,
22335
- device: string().optional()
22336
- });
22337
- var AvailableEngineSchema = object({
22338
- engine: PipelineEngineChoiceSchema,
22339
- devices: array(object({
22340
- id: string(),
22341
- label: string(),
22342
- description: string().optional()
22343
- })).readonly(),
22344
- defaultDevice: string()
22345
- });
22346
- var PipelineDefaultStepSchema = lazy(() => object({
22347
- addonId: string(),
22348
- addonName: string(),
22349
- slot: PipelineSlotSchema,
22350
- inputClasses: array(string()).readonly(),
22351
- outputClasses: array(string()).readonly(),
22352
- enabled: boolean(),
22353
- modelId: string(),
22354
- children: array(PipelineDefaultStepSchema).readonly(),
22355
- group: string().optional(),
22356
- settings: record(string(), unknown()).optional()
22357
- }));
22358
- var PipelineTemplateStepSchema = lazy(() => object({
22359
- addonId: string(),
22360
- enabled: boolean(),
22361
- modelId: string(),
22362
- children: array(PipelineTemplateStepSchema).readonly(),
22363
- settings: record(string(), unknown()).optional()
22364
- }));
22365
- var PipelineTemplateSchema$1 = object({
22366
- id: string(),
22367
- name: string(),
22368
- createdAt: string(),
22369
- updatedAt: string(),
22370
- engine: PipelineEngineChoiceSchema,
22371
- steps: array(PipelineTemplateStepSchema).readonly()
22806
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
22807
+ var EventKindLevelSchema = _enum(["macro", "sub"]);
22808
+ var EventKindDescriptorSchema = object({
22809
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
22810
+ kind: string(),
22811
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
22812
+ labelKey: string(),
22813
+ /** English fallback label (kept for clients that don't translate). */
22814
+ label: string(),
22815
+ /** Hex color for timeline/legend rendering. */
22816
+ color: string(),
22817
+ /** Dictionary id → lucide component on the UI side. */
22818
+ iconId: string(),
22819
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
22820
+ icon: EventKindIconSchema,
22821
+ category: EventKindCategorySchema,
22822
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
22823
+ parentKind: string().nullable(),
22824
+ /** Derived from `parentKind`, explicit for the client tree. */
22825
+ level: EventKindLevelSchema,
22826
+ /** Which cap + device contributes this kind. For built-ins the camera
22827
+ * itself; for sensor kinds the LINKED source device. */
22828
+ source: object({
22829
+ capName: string(),
22830
+ deviceId: number()
22831
+ })
22372
22832
  });
22373
- var PipelineModelOptionSchema = object({
22374
- id: string(),
22375
- name: string(),
22376
- formats: record(string(), object({
22377
- downloaded: boolean(),
22378
- sizeMB: number()
22379
- })),
22380
- group: ModelVariantGroupSchema.optional(),
22381
- legacy: boolean().optional(),
22382
- provider: ModelProviderIdSchema.optional()
22833
+ /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
22834
+ var EventKindsForDeviceSchema = object({
22835
+ deviceId: number(),
22836
+ kinds: array(EventKindDescriptorSchema).readonly()
22383
22837
  });
22384
- var ConfigFieldBridge = custom();
22385
- var PipelineAddonSchemaSchema = object({
22838
+ var SensorEventSchema = object({
22386
22839
  id: string(),
22387
- name: string(),
22388
- slot: PipelineSlotSchema,
22389
- inputClasses: array(string()).readonly(),
22390
- outputClasses: array(string()).readonly(),
22391
- childSlots: array(PipelineSlotSchema).readonly(),
22392
- models: array(PipelineModelOptionSchema).readonly(),
22393
- defaultModelId: string(),
22394
- defaultModelIdByFormat: record(string(), string()).optional(),
22395
- enabledByDefault: boolean().optional(),
22396
- backfillIntoExistingOverrides: boolean().optional(),
22397
- defaultConfidence: number(),
22398
- group: string().optional(),
22399
- configSchema: array(ConfigFieldBridge).readonly().optional()
22400
- });
22401
- var PipelineSlotSchemaSchema = object({
22402
- id: PipelineSlotSchema,
22403
- label: string(),
22404
- priority: number(),
22405
- parentSlot: PipelineSlotSchema.nullable(),
22406
- addons: array(PipelineAddonSchemaSchema).readonly()
22407
- });
22408
- var PipelineSchemaSchema = object({
22409
- availableEngines: array(AvailableEngineSchema).readonly(),
22410
- selectedEngine: PipelineEngineChoiceSchema,
22411
- slots: array(PipelineSlotSchemaSchema).readonly()
22840
+ /** The CAMERA the event is attributed to (a sensor linked to N cameras
22841
+ * yields N rows, one per camera). */
22842
+ deviceId: number(),
22843
+ /** The linked sensor device whose state changed. */
22844
+ sourceDeviceId: number(),
22845
+ /** Event kind id — matches an `EventKindDescriptor.kind`. */
22846
+ kind: string(),
22847
+ /** Snapshot of the sensor cap's runtime-state slice at the change. */
22848
+ value: record(string(), unknown()).nullable(),
22849
+ timestamp: number()
22412
22850
  });
22413
- var EngineProvisioningSchema = object({
22414
- runtimeId: _enum([
22415
- "onnx",
22416
- "openvino",
22417
- "coreml",
22418
- "edgetpu"
22419
- ]).nullable(),
22420
- device: string().nullable(),
22421
- state: _enum([
22422
- "idle",
22423
- "installing",
22424
- "verifying",
22425
- "ready",
22426
- "failed"
22427
- ]),
22428
- progress: number().optional(),
22429
- error: string().optional(),
22430
- nextRetryAt: number().optional(),
22851
+ /**
22852
+ * One stored sighting on a track's trajectory.
22853
+ *
22854
+ * The array these live in is returned in TIME order (D399) — it is APPENDED in
22855
+ * arrival order, and the two detector passes interleave, so a consumer must not
22856
+ * assume the two are the same on a row written by an older build.
22857
+ */
22858
+ var TrackPositionSchema = object({
22859
+ x: number(),
22860
+ y: number(),
22861
+ timestamp: number(),
22862
+ bbox: BoundingBoxSchema,
22431
22863
  /**
22432
- * Gate A (config-correctness gate at engine change): human-readable
22433
- * config issues surfaced EAGERLY when the node's engine changes — model
22434
- * substitutions ("chose X, running Y") and zero-build steps ("no model
22435
- * has a <format> build"). Additive/optional: informational only, never
22436
- * enforced here — `assertEngineReady` (readiness) still gates inference.
22437
- * Absent/empty when the node-default tree resolves cleanly.
22864
+ * Which detector pass measured this box (D399): `frame` is the full-frame
22865
+ * pass on the analysis raster, `recovery` is the native-resolution
22866
+ * small-subject second pass (D377/D378). Both write into one array, and until
22867
+ * this field existed the only way to tell them apart was that full-frame boxes
22868
+ * are exact multiples of 1.2 while recovery boxes are full-precision floats.
22869
+ * Absent on rows written before D399.
22438
22870
  */
22439
- configIssues: array(string()).optional()
22440
- });
22441
- var PipelineStepInputSchema = lazy(() => object({
22442
- addonId: string(),
22443
- modelId: string().optional(),
22444
- enabled: boolean().default(true),
22445
- children: array(PipelineStepInputSchema).optional(),
22446
- settings: record(string(), unknown()).optional(),
22447
- jumpDeviceKey: string().optional()
22448
- }));
22449
- var ModelSubstitutionSchema = object({
22450
- addonId: string(),
22451
- chosen: string(),
22452
- running: string(),
22453
- format: string()
22454
- });
22455
- var PipelineValidationIssueSchema = object({
22456
- addonId: string(),
22457
- kind: _enum(["unknown-addon", "no-format-build"]),
22458
- detail: string()
22459
- });
22460
- var PipelineValidationResultSchema = object({
22461
- ok: boolean(),
22462
- issues: array(PipelineValidationIssueSchema).readonly(),
22463
- substitutions: array(ModelSubstitutionSchema).readonly(),
22464
- /** The node's `currentEngine.format` this validation ran against. */
22465
- format: string()
22466
- });
22467
- var ReferenceImageEntrySchema = object({
22468
- filename: string(),
22469
- stepIds: array(string()).readonly().optional()
22871
+ source: _enum(["frame", "recovery"]).optional(),
22872
+ /** Detection score of this box, so a position can be weighed and not only
22873
+ * plotted. Absent on rows written before D399. */
22874
+ score: number().optional()
22470
22875
  });
22471
- var ReferenceImageBodySchema = object({
22472
- base64: string(),
22473
- filename: string()
22876
+ var TrackSnapshotSchema = object({
22877
+ timestamp: number(),
22878
+ position: TrackPositionSchema,
22879
+ /** The snapshot's media row id (D482); resolve via `listTrackMedia({ trackId })`. */
22880
+ mediaId: number().int()
22474
22881
  });
22475
- var ReferenceAudioEntrySchema = object({
22476
- filename: string(),
22477
- sizeKb: number()
22478
- });
22479
- var ReferenceAudioBodySchema = object({ base64: string() });
22480
- var AudioBackendSchema = object({
22481
- id: string(),
22482
- name: string(),
22483
- description: string(),
22484
- available: boolean(),
22485
- /**
22486
- * Raw classifier labels this backend can emit (e.g. YAMNet's
22487
- * 521-class set or Apple SoundAnalysis's 303-class set). Used by
22488
- * the benchmark UI to populate the `enabledMicroClasses` filter
22489
- * specific to the selected backend without a separate fetch.
22490
- */
22491
- rawLabels: array(string()).readonly().optional()
22492
- });
22493
- var AudioCapabilitiesSchema = object({
22494
- activeBackend: string(),
22495
- availableBackends: array(AudioBackendSchema).readonly(),
22496
- sampleRate: number(),
22497
- chunkDurationMs: number()
22498
- });
22499
- var DownloadModelResultSchema = object({
22500
- filePath: string(),
22501
- sizeMB: number(),
22502
- durationMs: number()
22503
- });
22504
- /**
22505
- * Wrapper carrying a single test run's result. Replaces the legacy
22506
- * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
22507
- * canonical `AudioResult` from the Phase 6 output rework: one
22508
- * `AudioDetection` per class above `minScore`, top-N candidates in
22509
- * `debug.alternateLabels['audio-classifier']`, per-source timings in
22510
- * `debug.stepTimings`. The outer `success`/`error` fields stay so the
22511
- * benchmark UI can still report a clean failure when the classifier
22512
- * cap isn't available.
22513
- */
22514
- var AudioTestResultSchema = object({
22515
- success: boolean(),
22516
- error: string().optional(),
22517
- frame: custom().optional()
22518
- });
22519
- var PipelineConfigBridge = custom();
22520
- var ConfigUISchemaBridge = custom();
22521
- var ConfigUISchemaNullableBridge = custom();
22522
- var InferenceCapabilitiesBridge = custom();
22523
- var ModelAvailabilityListBridge = custom();
22524
- var PipelineRunResultBridge = custom();
22525
- /**
22526
- * Pipeline executor — detection engine + configuration + inference API.
22527
- *
22528
- * Merged from: pipeline-executor, pipeline-config, inference, detection-config.
22529
- * Implemented by the detection-pipeline addon.
22530
- *
22531
- * Per-device surface (DeviceSettingsContribution + the "is detection
22532
- * enabled for this camera?" toggle) lives on the paired
22533
- * `detection-pipeline` cap (device-scoped, singleton, wrapper
22534
- * defaultActive) — same split pattern used by stream-broker /
22535
- * camera-streams and audio-analyzer / audio-analysis.
22536
- */
22537
- var pipelineExecutorCapability = {
22538
- name: "pipeline-executor",
22539
- scope: "system",
22540
- mode: "singleton",
22541
- methods: {
22542
- getAvailableEngines: method(_void(), array(PipelineEngineChoiceSchema)),
22543
- getSelectedEngine: method(_void(), PipelineEngineChoiceSchema),
22544
- getDefaultSteps: method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)),
22545
- /**
22546
- * Per-node detection-engine provisioning snapshot. Returns the live
22547
- * state of the lazy runtime-provisioning machine on `nodeId`
22548
- * (idle / installing / verifying / ready / failed). The UI pairs this
22549
- * one-shot query with the `pipeline.engine-provisioning` live event
22550
- * (emitted on every transition) to drive a per-node "engine ready?"
22551
- * indicator without polling. Phase 2.
22552
- */
22553
- getEngineProvisioning: method(object({ nodeId: string() }), EngineProvisioningSchema),
22554
- getVideoPipelineSteps: method(_void(), record(string(), object({
22555
- modelId: string(),
22556
- settings: record(string(), unknown()).readonly()
22557
- }))),
22558
- setVideoPipelineSteps: method(object({ steps: record(string(), object({
22559
- modelId: string(),
22560
- settings: record(string(), unknown()).readonly()
22561
- })) }), object({ success: literal(true) }), {
22562
- kind: "mutation",
22563
- auth: "admin"
22564
- }),
22565
- /**
22566
- * Clear THIS node's executor-side PER-DEVICE settings stores (the
22567
- * per-camera step overrides the object-detection root reads via
22568
- * `applyDeviceOverridesToTree`). `nodeId` is the ROUTING key — the
22569
- * generated cap-router strips it (default `nodeIdMode: 'routing'`) and
22570
- * dispatches to that node, so the provider method runs ON the target
22571
- * node and receives no `nodeId`.
22572
- *
22573
- * This is the slimmed executor leg of the orchestrator's
22574
- * `resetNodePipelineDefaults` flow (which owns the real reset: node
22575
- * addonDefaults pins + per-camera orchestrator overrides). The legacy
22576
- * `resetToDefault` — which reset a persisted global step-tree seed
22577
- * nothing in the live per-camera path read — was removed together with
22578
- * that seed.
22579
- */
22580
- clearDeviceOverrides: method(object({ nodeId: string() }), object({
22581
- success: literal(true),
22582
- clearedDevices: number()
22583
- }), {
22584
- kind: "mutation",
22585
- auth: "admin"
22586
- }),
22587
- /**
22588
- * Which of THIS node's inference devices the executor currently refuses,
22589
- * and why. `nodeId` is the ROUTING key (stripped by the generated router).
22590
- *
22591
- * The channel that did not exist. Pool health was known only inside the
22592
- * detection addon and was an input to no routing decision anywhere: the
22593
- * per-dispatch capability gate is keyed on model FORMAT and so can never
22594
- * separate `openvino:gpu` from `openvino:npu`, and the orchestrator's live
22595
- * eligibility probe (`platformProbe.getCapabilities`) answers about
22596
- * HARDWARE — which was present throughout. So when the hub's `openvino:gpu`
22597
- * Python worker was SIGABRT'd by the Intel GPU plugin on 2026-08-25, the
22598
- * balancer went on handing that dead pool cameras by rotation for 31 hours:
22599
- * ~370 000 `PoolWorker[w0]: not initialized` lines, every frame lost.
22600
- *
22601
- * Read semantics the caller depends on, and which the provider guarantees:
22602
- * this is a synchronous read of in-memory state. It never probes hardware,
22603
- * never spawns a pool and never throws — an EMPTY `unhealthy` means "asked,
22604
- * nothing is refused", which is what re-admits a device. A read that FAILS
22605
- * (node offline, version skew) must therefore be distinguishable from an
22606
- * empty answer, and it is: it rejects.
22607
- */
22608
- getInferenceDeviceHealth: method(object({ nodeId: string() }), object({ unhealthy: array(object({
22609
- /** `<backend>:<device>`, e.g. `openvino:gpu`. */
22610
- deviceKey: string(),
22611
- /**
22612
- * `failed` — the per-device restart budget is exhausted; no pool
22613
- * will be spawned until an operator re-arms it or the runner
22614
- * respawns. `backoff` — under budget, waiting out the backoff (or
22615
- * a cached pool observed dead and not yet condemned).
22616
- */
22617
- state: _enum(["failed", "backoff"]),
22618
- /** Epoch ms of the death that produced this state. */
22619
- since: number(),
22620
- /** Pool deaths inside the current window. */
22621
- deaths: number(),
22622
- /** The last death's message. */
22623
- lastError: string()
22624
- })).readonly() })),
22625
- /**
22626
- * Re-arm a terminally `failed` inference device on `nodeId`: forget its
22627
- * restart budget so the next dispatch builds a fresh pool.
22628
- *
22629
- * The terminal state is deliberate (the abort it bounds is deterministic —
22630
- * an automatic probation would just respawn Python forever, more slowly),
22631
- * and a terminal state an operator cannot leave is a silent fault. This is
22632
- * the way out. `rearmed:false` means there was nothing to forget.
22633
- */
22634
- rearmInferenceDevice: method(object({
22635
- nodeId: string(),
22636
- deviceKey: string()
22637
- }), object({ rearmed: boolean() }), {
22638
- kind: "mutation",
22639
- auth: "admin"
22640
- }),
22641
- getSchema: method(_void(), PipelineSchemaSchema),
22642
- getGlobalSteps: method(_void(), array(PipelineDefaultStepSchema).readonly().nullable()),
22643
- getGlobalPipelineConfig: method(_void(), PipelineConfigBridge),
22644
- getOrchestratorConfigSchema: method(_void(), ConfigUISchemaBridge),
22645
- /**
22646
- * Gate B (pre-init config-correctness gate). PURE COMPUTE against this
22647
- * node's `currentEngine.format` — resolves `steps` the same way the
22648
- * runtime dispatch path would, and reports what WOULD happen without
22649
- * touching any node-global state. Called by the orchestrator at attach
22650
- * time (`attachOn`), node-pinned to the TARGET node, so config problems
22651
- * surface BEFORE `pipelineRunner.attachCamera` rather than at the first
22652
- * per-frame resolve. `ok` is false iff `issues` is non-empty (both
22653
- * `unknown-addon` and `no-format-build` are HARD issues); `substitutions`
22654
- * is informational (a degraded-but-loadable model swap) and never
22655
- * affects `ok`. Never throws.
22656
- */
22657
- validatePipeline: method(object({ steps: array(PipelineStepInputSchema) }), PipelineValidationResultSchema),
22658
- listTemplates: method(_void(), array(PipelineTemplateSchema$1).readonly()),
22659
- saveTemplate: method(object({
22660
- name: string(),
22661
- steps: array(PipelineTemplateStepSchema).readonly(),
22662
- engine: PipelineEngineChoiceSchema
22663
- }), PipelineTemplateSchema$1, { kind: "mutation" }),
22664
- updateTemplate: method(object({
22665
- id: string(),
22666
- name: string().optional(),
22667
- steps: array(PipelineTemplateStepSchema).readonly().optional()
22668
- }), PipelineTemplateSchema$1, { kind: "mutation" }),
22669
- deleteTemplate: method(object({ id: string() }), _void(), { kind: "mutation" }),
22670
- getCapabilities: method(_void(), InferenceCapabilitiesBridge),
22671
- getAddonModels: method(object({ addonId: string() }), ModelAvailabilityListBridge),
22672
- downloadModel: method(object({
22673
- addonId: string(),
22674
- modelId: string(),
22675
- format: ModelFormatSchema$1
22676
- }), DownloadModelResultSchema, { kind: "mutation" }),
22677
- deleteModel: method(object({
22678
- addonId: string(),
22679
- modelId: string(),
22680
- format: ModelFormatSchema$1
22681
- }), object({ success: literal(true) }), { kind: "mutation" }),
22682
- /**
22683
- * Stateless single-frame execution. Callers (runner, benchmark) pass
22684
- * the complete `engine` + `steps` tree; the executor holds no state
22685
- * about cameras or saved pipelines.
22686
- *
22687
- * `engine` is optional during the migration window to preserve the
22688
- * legacy call shape used by existing benchmark code; once all
22689
- * callers pass it explicitly we make it required.
22690
- *
22691
- * Exactly one of `frame`, `frameRef`, `frameHandle`, `imageBase64`,
22692
- * `referenceImage` must be provided:
22693
- * - `frame`: runtime dispatch path (runner → decoded broker frame).
22694
- * Carries the raw buffer, dimensions, and format; the executor
22695
- * uses it directly without base64 round-tripping.
22696
- * - `frameHandle` (CB5): a zero-pixel shm `FrameHandle` for the SAME
22697
- * decoded frame. Both runner and executor are hub-local processes
22698
- * sharing `/dev/shm`, so the executor maps the named segment and
22699
- * reads the pixels back zero-copy — eliminating the ~1.2MB
22700
- * re-serialisation over UDS/MsgPack the `frame` path pays per call.
22701
- * High-risk: the FrameRing is a latest-wins seqlock with no
22702
- * refcount, so a recycled slot yields a null read; the executor
22703
- * then degrades to an empty result and the runner ships pixels via
22704
- * `frame` as the fallback (queue-depth gated on the runner side).
22705
- * - `imageBase64`: one-shot test path (benchmark ImageTab).
22706
- * - `referenceImage`: named file from the reference-image store.
22707
- */
22708
- runPipeline: method(object({
22709
- engine: PipelineEngineChoiceSchema.optional(),
22710
- steps: array(PipelineStepInputSchema).min(1),
22711
- frame: FrameInputSchema.optional(),
22712
- /**
22713
- * Process-local lazy frame. Valid only when caller and provider resolve
22714
- * in the same execution-group process; split/cross-node callers use
22715
- * `frame`/`image` inline compatibility instead.
22716
- */
22717
- frameRef: FrameRefSchema.optional(),
22718
- /**
22719
- * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
22720
- * the decoded pixels live in. One more member of the one-of
22721
- * frame/frameHandle/image/imageBase64/referenceImage group.
22722
- */
22723
- frameHandle: FrameHandleSchema.optional(),
22724
- imageBase64: string().optional(),
22725
- /**
22726
- * Binary JPEG bytes — preferred over `imageBase64` on internal
22727
- * hops (hub → forked worker via Moleculer MsgPack) because it
22728
- * skips the 33% base64 overhead + the per-call base64 decode on
22729
- * the detection-pipeline worker. Callers can pass either; exactly
22730
- * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
22731
- */
22732
- image: _instanceof(Uint8Array).optional(),
22733
- referenceImage: string().optional(),
22734
- deviceId: number().optional(),
22735
- sessionId: string().optional(),
22736
- /**
22737
- * Execution plane. 'full' (default) runs the whole tree — benchmark,
22738
- * reference-image, and detail-subtree calls. 'frame' is the live
22739
- * per-frame dispatch: ONLY root-plane steps run; crop children
22740
- * (inputClasses ≠ null) are skipped and served per-track via
22741
- * pipelineRunner.runDetailSubtree (two-plane design).
22742
- */
22743
- plane: _enum(["full", "frame"]).optional(),
22744
- /**
22745
- * Inference-device selector (Phase 2 multi-device). Format
22746
- * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
22747
- * Omitted ⇒ the runner's default device (current single-engine
22748
- * behaviour). Selects WHICH device pool of the node runs the call.
22749
- */
22750
- deviceKey: string().optional(),
22751
- /**
22752
- * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
22753
- * when the parent crop was resolved from the frame's retained NATIVE
22754
- * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
22755
- * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
22756
- * resolution from that surface — the SAME quality path faces already
22757
- * had — instead of the downscaled parent tile. `handle` keys the native
22758
- * surface (node-pinned to its owner); `cropFrameSpace` is the parent
22759
- * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
22760
- * the executor's crop-normalized child ROI back into frame-normalized
22761
- * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
22762
- * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
22763
- * (today's behaviour on the fallback path).
22764
- */
22765
- nativeCropRef: NativeCropRefSchema.optional()
22766
- }), PipelineRunResultBridge, { kind: "mutation" }),
22767
- /**
22768
- * Batched run — N raw frames packed into one cap call. The provider
22769
- * routes the batch through `SharedInferencePool.inferBatch`
22770
- * (`MSG_INFER_BATCH = 0x03`) so the IPC framing and JSON response
22771
- * envelope cost is amortised N:1 vs N concurrent `runPipeline`
22772
- * calls. Single root step + uniform model assumed; trees with crop
22773
- * children fall back to sequential execution.
22774
- *
22775
- * Used by `scripts/bench-batch-style.mts` for batch benchmarking —
22776
- * N frames in one call to amortise per-call IPC overhead.
22777
- */
22778
- runPipelineBatch: method(object({
22779
- engine: PipelineEngineChoiceSchema.optional(),
22780
- steps: array(PipelineStepInputSchema).min(1),
22781
- frames: array(FrameInputSchema).min(1).max(255),
22782
- deviceId: number().optional(),
22783
- sessionId: string().optional(),
22784
- /**
22785
- * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
22786
- * the batch to the Python pool's bench preprocess cache
22787
- * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
22788
- * preprocessed ONCE and every later inference is a pure-inference cache
22789
- * hit — the sustained-throughput run measures inference, not
22790
- * decode+preprocess+infer. Omitted/0 for live frames (all different →
22791
- * full preprocess every call, correct). Fresh per sustained run;
22792
- * released via `uncacheFrame`.
22793
- */
22794
- frameId: number().int().nonnegative().optional(),
22795
- /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
22796
- deviceKey: string().optional()
22797
- }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }),
22798
- /**
22799
- * Cache a raw frame inside the Python inference pool's memory.
22800
- * Returns a numeric `frameId` that `inferCached` references —
22801
- * subsequent calls send only 5 bytes through the pipe instead of
22802
- * 1.2MB raw data, eliminating the pipe transfer bottleneck.
22803
- */
22804
- cacheFrameInPool: method(object({
22805
- data: _instanceof(Uint8Array),
22806
- width: number().int().positive(),
22807
- height: number().int().positive(),
22808
- format: _enum([
22809
- "rgb",
22810
- "bgr",
22811
- "gray"
22812
- ])
22813
- }), object({
22814
- frameId: number(),
22815
- width: number(),
22816
- height: number()
22817
- }), { kind: "mutation" }),
22818
- /**
22819
- * Run inference on a previously cached frame. Sends only 5 bytes
22820
- * (model_idx + frameId) through the IPC pipe — eliminates the
22821
- * ~35ms per-call overhead of transferring 1.2MB raw data.
22822
- */
22823
- inferCached: method(object({
22824
- stepId: string(),
22825
- frameId: number().int()
22826
- }), record(string(), unknown()), { kind: "mutation" }),
22827
- /**
22828
- * Release a cached frame from the Python pool's memory.
22829
- */
22830
- uncacheFrame: method(object({ frameId: number().int() }), _void(), { kind: "mutation" }),
22831
- /** Returns the effective pool tuning (resolved from user overrides + backend defaults). */
22832
- getEffectiveTuning: method(_void(), object({
22833
- batchMode: string(),
22834
- windowMs: number(),
22835
- maxBatchSize: number(),
22836
- concurrency: number()
22837
- })),
22838
- /**
22839
- * List every EngineFactory currently loaded in this executor's RAM,
22840
- * with the models resident and a coarse "in use" marker derived from
22841
- * ongoing inference activity. Used by the Pipeline page Engines tab.
22842
- */
22843
- listLoadedEngines: method(_void(), array(object({
22844
- engineKey: string(),
22845
- engine: PipelineEngineChoiceSchema,
22846
- modelsLoaded: array(string()).readonly(),
22847
- inUseByCameras: array(number()).readonly(),
22848
- /**
22849
- * Origin of this resident factory.
22850
- * - `runtime` — main camera-serving engine (no idle TTL).
22851
- * - `warm-override` — benchmark/test override held in the warm
22852
- * cache; auto-disposed after the idle TTL.
22853
- * - `device-pool` — a concurrent per-device pool (Phase 2
22854
- * multi-device, keyed by `deviceKey`) resolved
22855
- * via `resolveDeviceFactory`. Runs alongside the
22856
- * `runtime` engine on a DIFFERENT accelerator
22857
- * (NPU / iGPU / Coral) — this is how the
22858
- * Engines tab shows all pools running at once.
22859
- */
22860
- kind: _enum([
22861
- "runtime",
22862
- "warm-override",
22863
- "device-pool"
22864
- ]),
22865
- /** Native pid of the underlying Python pool (null when no pool). */
22866
- poolPid: number().nullable(),
22867
- /** ms since this factory was last used (null when not warm-tracked). */
22868
- idleMs: number().nullable(),
22869
- /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
22870
- idleTtlMs: number().nullable()
22871
- })).readonly()),
22872
- /** Warm up an engine without running a frame. No-op if already loaded. */
22873
- spinEngine: method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
22874
- kind: "mutation",
22875
- auth: "admin"
22876
- }),
22877
- /**
22878
- * Unload an engine from RAM. `force:true` unloads even when cameras
22879
- * are actively using it (they re-spin on next frame). Default is
22880
- * gated — returns `{success:false, reason}` when in use.
22881
- */
22882
- killEngine: method(object({
22883
- engine: PipelineEngineChoiceSchema,
22884
- force: boolean().optional()
22885
- }), object({
22886
- success: boolean(),
22887
- reason: string().optional()
22888
- }), {
22889
- kind: "mutation",
22890
- auth: "admin"
22891
- }),
22892
- listReferenceImages: method(_void(), array(ReferenceImageEntrySchema).readonly()),
22893
- getReferenceImage: method(object({ filename: string() }), ReferenceImageBodySchema.nullable()),
22894
- getReferenceAudioFiles: method(_void(), array(ReferenceAudioEntrySchema).readonly()),
22895
- getReferenceAudio: method(object({ filename: string() }), ReferenceAudioBodySchema.nullable()),
22896
- getAudioCapabilities: method(_void(), AudioCapabilitiesSchema),
22897
- runAudioTest: method(object({
22898
- addonId: string(),
22899
- modelId: string(),
22900
- filename: string().optional(),
22901
- settings: record(string(), unknown()).optional()
22902
- }), AudioTestResultSchema, { kind: "mutation" }),
22903
- getDetectionConfigSchema: method(_void(), ConfigUISchemaNullableBridge)
22904
- }
22905
- };
22906
- /**
22907
- * Per-stage gating mode applied to the zones a rule references.
22908
- *
22909
- * - `include`: the rule contributes to a **whitelist** for its stage.
22910
- * When at least one `include` rule fires for a stage, only entities
22911
- * inside one of those zones pass that stage.
22912
- * - `exclude`: the rule contributes to a **blacklist** for its stage.
22913
- * Entities inside one of those zones are dropped at that stage.
22914
- *
22915
- * `monitor`-style observation (count without filtering) is not a rule
22916
- * mode — zones without any matching rule are observed naturally by
22917
- * `zone-analytics` (live snapshot + history), so an "I just want to
22918
- * count, not filter" use case needs no rule at all.
22919
- */
22920
- var ZoneRuleModeEnum = _enum(["include", "exclude"]);
22921
- /**
22922
- * Per-consumer rule that references existing zones (geometry) and
22923
- * defines how a specific pipeline stage should treat them. Each
22924
- * consumer addon owns its own `ZoneRule[]` array in its per-device
22925
- * settings:
22926
- *
22927
- * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
22928
- * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
22929
- * - future: notification rules, audio gating, etc.
22930
- *
22931
- * One rule applies to N zones (`zoneIds[]`) so the operator can
22932
- * express "ignore motion in ALL of {garden, street}" with a single
22933
- * rule. `classFilter` narrows the rule to specific object classes —
22934
- * "drop person detections in the street, but keep cars" is one
22935
- * `exclude` rule with `classFilter: ['person']`.
22936
- *
22937
- * `enabled` is a soft toggle — the operator can keep the rule
22938
- * configured but inert without deleting it.
22939
- */
22940
- var ZoneRuleSchema = object({
22941
- /** Stable rule id — survives edits, used by the UI for diffing. */
22942
- id: string(),
22943
- /** Optional human-readable label rendered in the rule editor. */
22944
- name: string().optional(),
22945
- /** Zones this rule targets. The rule's `mode` applies to ALL
22946
- * listed zones (OR-set: a detection in any one of them counts).
22947
- * At least one zone id required — a rule with no targets is a
22948
- * configuration mistake and the form validator rejects it. */
22949
- zoneIds: array(string()).min(1).readonly(),
22950
- mode: ZoneRuleModeEnum,
22951
- /**
22952
- * Class names this rule applies to. Empty / undefined ⇒ rule
22953
- * applies to every class. Class strings match the `macroClass`
22954
- * field on detections (e.g. `person`, `car`, `dog`).
22955
- */
22956
- classFilter: array(string()).readonly().optional(),
22957
- /**
22958
- * Minimum bbox/mask overlap (0–1) with any of the rule's zones
22959
- * required to consider an entity "in the zone". Defaults to the
22960
- * consumer's stage default when omitted. Kept for back-compat with
22961
- * existing per-rule overrides; new operators pick the value via
22962
- * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
22963
- * set, the lower-level engine reads it as a 0–1 fraction.
22964
- */
22965
- overlapThreshold: number().min(0).max(1).optional(),
22966
- /**
22967
- * Operator-friendly version of `overlapThreshold` — the percentage
22968
- * of the detection's bbox that must lie inside the zone for the
22969
- * rule to match. Documented default is 85%; the engine substitutes
22970
- * that when the field is omitted (kept optional so existing rules
22971
- * stored without it stay valid).
22972
- *
22973
- * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
22974
- * rule, the engine prefers `bboxInclusionPct` because it's the
22975
- * field exposed in the UI. Internally both feed the same gate.
22976
- */
22977
- bboxInclusionPct: number().min(0).max(100).optional(),
22978
- /**
22979
- * When `true` and a detection has a segmentation mask, use the
22980
- * mask for overlap instead of the bbox. Detection-stage only;
22981
- * motion rules ignore this field.
22982
- */
22983
- preferMask: boolean().optional(),
22984
- /**
22985
- * Soft-toggle: `false` disables the rule without deleting it.
22986
- * Defaults to `true` so operators creating a rule via the UI
22987
- * see it active immediately.
22988
- */
22989
- enabled: boolean().default(true)
22990
- });
22991
- array(ZoneRuleSchema).readonly();
22992
- /**
22993
- * Zone — pure geometry + identity. NO filtering behaviour.
22994
- *
22995
- * Zones describe **where** in the frame the operator wants to flag
22996
- * something; consumer-owned {@link ZoneRule} arrays describe **how**
22997
- * each pipeline stage uses them. Splitting the two means a single
22998
- * polygon "Driveway" can simultaneously back a motion-exclude rule,
22999
- * a detection-include rule on `['car']`, and an occupancy aggregate
23000
- * — without three duplicated polygons.
23001
- *
23002
- * Owned by the orchestrator addon (provider) and mirrored into the
23003
- * `zones` device-state slice on every mutation. Consumers
23004
- * (motion-wasm, pipeline-executor, analytics, admin UI) read either
23005
- * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
23006
- * mirror with `onChanged`).
23007
- *
23008
- * Coordinates are normalised fractions of the frame (0–1) so zones
23009
- * survive resolution changes and stream profile switches.
23010
- *
23011
- * `kind` discriminates between full polygons (closed regions used
23012
- * for intrusion / occupancy filters) and tripwires (open 2-point
23013
- * line segments used for cross events). Onboard / firmware-reported
23014
- * zones (Reolink, ONVIF) are out of scope for now — see the deferred
23015
- * task list.
23016
- */
23017
- var ZoneKindEnum = _enum(["polygon", "tripwire"]);
23018
- /** Polygon vertex in fraction-of-frame coordinates (0–1). */
23019
- var PolygonPointSchema = object({
23020
- x: number(),
23021
- y: number()
23022
- });
23023
- /** A camera detection zone — pure geometry/identity. */
23024
- var ZoneSchema = object({
23025
- id: string(),
23026
- name: string(),
23027
- kind: ZoneKindEnum.default("polygon"),
23028
- /** Polygon vertices, fraction of frame (0–1). */
23029
- polygon: array(PolygonPointSchema).readonly(),
23030
- /** Visual color for UI rendering. */
23031
- color: string().default("#3b82f6")
23032
- });
23033
- /**
23034
- * Zones capability — per-camera CRUD over polygon detection zones.
23035
- *
23036
- * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
23037
- * to per-device settings and mirrors into the `zones` device-state
23038
- * slice on every mutation, so downstream consumers can subscribe via
23039
- * `dev.state.zones.onChanged`.
23040
- *
23041
- * The cap surface only handles geometry + identity; filtering
23042
- * behaviour (per-class, include/exclude, threshold) lives in the
23043
- * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
23044
- * `capabilities/schemas/zone-rule.js`.
23045
- */
23046
- var zonesCapability = {
23047
- name: "zones",
23048
- scope: "device",
23049
- mode: "singleton",
23050
- deviceTypes: [DeviceType.Camera],
23051
- methods: {
23052
- listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
23053
- addZone: method(object({
23054
- deviceId: number(),
23055
- zone: ZoneSchema
23056
- }), _void(), {
23057
- kind: "mutation",
23058
- auth: "admin"
23059
- }),
23060
- removeZone: method(object({
23061
- deviceId: number(),
23062
- zoneId: string()
23063
- }), _void(), {
23064
- kind: "mutation",
23065
- auth: "admin"
23066
- }),
23067
- updateZone: method(object({
23068
- deviceId: number(),
23069
- zone: ZoneSchema
23070
- }), _void(), {
23071
- kind: "mutation",
23072
- auth: "admin"
23073
- })
23074
- },
23075
- /**
23076
- * Runtime-state slice — the live zone catalogue mirrored by the
23077
- * orchestrator on every CRUD mutation. Consumers read via
23078
- * `device.state.zones.value` / `.watch(...)` without round-tripping
23079
- * the cap, and the codegen DeviceProxy auto-wires the reactive
23080
- * handle. Slice shape is `{ zones: Zone[] }` so future extensions
23081
- * (e.g. zone groupings) can sit alongside the polygon list.
23082
- */
23083
- runtimeState: object({ zones: array(ZoneSchema).readonly() }),
23084
- /**
23085
- * Runtime-state durability: **restored** — written only on operator mutation, so a camera that never had one has nothing to re-derive from. This is the slice `zone-mirror-hydration.ts` exists to paper over.
23086
- *
23087
- * See `RuntimeStateDurability`. Enforced by
23088
- * `scripts/check-runtime-state-durability.ts`.
23089
- */
23090
- durability: "restored"
23091
- };
23092
- /**
23093
- * pipeline-analytics — device-scoped wrapper cap. Refines raw
23094
- * per-frame detections emitted by the pipeline runner into tracked
23095
- * objects, per-kind event collections (motion / object / audio), and
23096
- * persisted media. Owns the post-detection domain end-to-end:
23097
- *
23098
- * runner emits PipelineInferenceResult
23099
- * ↓ (event bus)
23100
- * pipeline-analytics subscriber
23101
- * ↓ SORT tracker + zone engine + state analyzer + event emitter
23102
- * → three DB collections (one per kind), one FS media tree, one
23103
- * unified event emitter (FrameTracked + TrackStarted/Ended +
23104
- * DetectionEvent on bus)
23105
- *
23106
- * Pure subscriber model. No `processFrame` cap method — the runner
23107
- * already publishes the raw frame on the bus. The cap surface is
23108
- * only QUERIES + per-device settings, bound on/off via
23109
- * `device-manager.setWrapperActive`. `defaultActive: true` because
23110
- * every camera with a detection pipeline wants its raw detections
23111
- * refined; operators opt out per-device via BindingsTab when needed.
23112
- *
23113
- * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
23114
- * (per-device surface) and `track-trail` caps — see P11 cleanup.
23115
- */
23116
- var TrackStateSchema = _enum([
23117
- "new",
23118
- "entered",
23119
- "left",
23120
- "moving",
23121
- "idle"
23122
- ]);
23123
- var EventKindSchema = _enum([
23124
- "motion",
23125
- "object",
23126
- "audio"
23127
- ]);
23128
- /**
23129
- * Spatial filter for `listTracks` — the rect + polygon variants of the shared
23130
- * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
23131
- * of the camera frame (top-left origin), matching the drawing-plane editor.
23132
- */
23133
- var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
23134
- /** Closed icon vocabulary so clients render a known glyph per kind. */
23135
- var EventKindIconSchema = _enum([
23136
- "motion",
23137
- "audio",
23138
- "person",
23139
- "vehicle",
23140
- "animal",
23141
- "door",
23142
- "pir",
23143
- "smoke",
23144
- "water",
23145
- "button",
23146
- "package",
23147
- "generic"
23148
- ]);
23149
- var EventKindCategorySchema = _enum([
23150
- "motion",
23151
- "audio",
23152
- "detection",
23153
- "sensor",
23154
- "control",
23155
- "custom",
23156
- "package"
23157
- ]);
23158
- /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
23159
- var EventKindLevelSchema = _enum(["macro", "sub"]);
23160
- var EventKindDescriptorSchema = object({
23161
- /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
23162
- kind: string(),
23163
- /** i18n key resolved on the UI side; `label` is the English fallback. */
23164
- labelKey: string(),
23165
- /** English fallback label (kept for clients that don't translate). */
23166
- label: string(),
23167
- /** Hex color for timeline/legend rendering. */
23168
- color: string(),
23169
- /** Dictionary id → lucide component on the UI side. */
23170
- iconId: string(),
23171
- /** Legacy closed-vocab glyph — fallback for `iconId`. */
23172
- icon: EventKindIconSchema,
23173
- category: EventKindCategorySchema,
23174
- /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
23175
- parentKind: string().nullable(),
23176
- /** Derived from `parentKind`, explicit for the client tree. */
23177
- level: EventKindLevelSchema,
23178
- /** Which cap + device contributes this kind. For built-ins the camera
23179
- * itself; for sensor kinds the LINKED source device. */
23180
- source: object({
23181
- capName: string(),
23182
- deviceId: number()
23183
- })
23184
- });
23185
- /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
23186
- var EventKindsForDeviceSchema = object({
23187
- deviceId: number(),
23188
- kinds: array(EventKindDescriptorSchema).readonly()
23189
- });
23190
- var SensorEventSchema = object({
23191
- id: string(),
23192
- /** The CAMERA the event is attributed to (a sensor linked to N cameras
23193
- * yields N rows, one per camera). */
23194
- deviceId: number(),
23195
- /** The linked sensor device whose state changed. */
23196
- sourceDeviceId: number(),
23197
- /** Event kind id — matches an `EventKindDescriptor.kind`. */
23198
- kind: string(),
23199
- /** Snapshot of the sensor cap's runtime-state slice at the change. */
23200
- value: record(string(), unknown()).nullable(),
23201
- timestamp: number()
23202
- });
23203
- /**
23204
- * One stored sighting on a track's trajectory.
23205
- *
23206
- * The array these live in is returned in TIME order (D399) — it is APPENDED in
23207
- * arrival order, and the two detector passes interleave, so a consumer must not
23208
- * assume the two are the same on a row written by an older build.
23209
- */
23210
- var TrackPositionSchema = object({
23211
- x: number(),
23212
- y: number(),
23213
- timestamp: number(),
23214
- bbox: BoundingBoxSchema,
23215
- /**
23216
- * Which detector pass measured this box (D399): `frame` is the full-frame
23217
- * pass on the analysis raster, `recovery` is the native-resolution
23218
- * small-subject second pass (D377/D378). Both write into one array, and until
23219
- * this field existed the only way to tell them apart was that full-frame boxes
23220
- * are exact multiples of 1.2 while recovery boxes are full-precision floats.
23221
- * Absent on rows written before D399.
23222
- */
23223
- source: _enum(["frame", "recovery"]).optional(),
23224
- /** Detection score of this box, so a position can be weighed and not only
23225
- * plotted. Absent on rows written before D399. */
23226
- score: number().optional()
23227
- });
23228
- var TrackSnapshotSchema = object({
23229
- timestamp: number(),
23230
- position: TrackPositionSchema,
23231
- /** The snapshot's media row id (D482); resolve via `listTrackMedia({ trackId })`. */
23232
- mediaId: number().int()
23233
- });
23234
- /**
23235
- * Normalized 0..1 trajectory envelope (min/max over every position bbox,
23236
- * divided by the track's detection-frame dims), computed at persist time.
23237
- * Absent when the frame dims were unknown when the track was persisted
23238
- * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
23239
- */
23240
- var TrackEnvelopeSchema = object({
23241
- minX: number(),
23242
- minY: number(),
23243
- maxX: number(),
23244
- maxY: number()
22882
+ /**
22883
+ * Normalized 0..1 trajectory envelope (min/max over every position bbox,
22884
+ * divided by the track's detection-frame dims), computed at persist time.
22885
+ * Absent when the frame dims were unknown when the track was persisted
22886
+ * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
22887
+ */
22888
+ var TrackEnvelopeSchema = object({
22889
+ minX: number(),
22890
+ minY: number(),
22891
+ maxX: number(),
22892
+ maxY: number()
23245
22893
  });
23246
22894
  /**
23247
22895
  * Row projection for track list queries. `full` (default) returns the
@@ -23660,6 +23308,22 @@ var TrackSchema = object({
23660
23308
  * omit it. Render nothing when absent.
23661
23309
  */
23662
23310
  previewMissReason: string().optional(),
23311
+ /**
23312
+ * The ROOT model that produced this track — the `FrameResult.rootModelId` of
23313
+ * the frame it was BORN on (D646). What a later replay compares against, so
23314
+ * "the original model" is named rather than assumed. A birth fact: never
23315
+ * rewritten by a later frame. **Absent ≠ unknown-model**: a row from before
23316
+ * the column, and a track the camera's own detector produced, carry none.
23317
+ */
23318
+ modelId: string().optional(),
23319
+ /**
23320
+ * Size (px) of the detection frame this track's `positions[].bbox` live in —
23321
+ * the frame it was born on, else the camera's latest analysis frame at
23322
+ * persist time. Divide a position by these to normalise it. Absent when the
23323
+ * size was never known.
23324
+ */
23325
+ frameWidth: number().optional(),
23326
+ frameHeight: number().optional(),
23663
23327
  ...TrackFlagFields,
23664
23328
  ...TrackRetrainFields
23665
23329
  });
@@ -23889,7 +23553,8 @@ var MediaFileKindEnum = _enum([
23889
23553
  "thumbnailSmall",
23890
23554
  "confirmationCrop",
23891
23555
  "debugCrop",
23892
- "sceneFrame"
23556
+ "sceneFrame",
23557
+ "lastSceneFrame"
23893
23558
  ]);
23894
23559
  /**
23895
23560
  * One media row ON THE WIRE: what it is, how big it is, and WHERE ITS BYTES
@@ -24441,7 +24106,23 @@ var SearchObjectEventsInput = object({
24441
24106
  until: number().optional(),
24442
24107
  classFilter: string().optional(),
24443
24108
  limit: number().default(50),
24444
- minScore: number().min(0).max(1).default(.2)
24109
+ /**
24110
+ * An ABSOLUTE cosine floor. Optional since D649: a floor is a property of the
24111
+ * model (0.2 kept 96% of matched pairs on MobileCLIP S1 and 2.7% on SigLIP2),
24112
+ * so an absent one resolves to the searched model's own `searchMinScore`
24113
+ * scaled by `strictness`. A number sent here is honoured verbatim.
24114
+ */
24115
+ minScore: number().min(0).max(1).optional(),
24116
+ /** Model-relative floor — see `resolveClipSearchMinScore`. Default `loose`. */
24117
+ strictness: ClipSearchStrictnessSchema.optional(),
24118
+ /**
24119
+ * Search THIS CLIP model's index instead of the cluster row's. Every index a
24120
+ * model ever wrote stays searchable until it is wiped (the MobileCLIP index
24121
+ * through a SigLIP2 cutover and its rollback window). An id with no CLIP
24122
+ * metadata is refused; an id other than the cluster row's is ADMIN-only
24123
+ * (`model-override-requires-admin`).
24124
+ */
24125
+ modelId: string().min(1).optional()
24445
24126
  });
24446
24127
  var TrackCascadeCountsSchema = object({
24447
24128
  /** Persisted track roots deleted (authoritative). */
@@ -24576,7 +24257,41 @@ var RebuildObjectEmbeddingsInput = object({
24576
24257
  * comparable, so wiping and rebuilding is the only way to be sure every vector
24577
24258
  * means the same thing.
24578
24259
  */
24579
- var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
24260
+ var WipeObjectEmbeddingsResultSchema = object({
24261
+ deleted: number(),
24262
+ /**
24263
+ * CLIP indexes that could NOT be emptied (unreachable, or refused at their
24264
+ * dimension) — not a clean slate. Additive and optional (D649).
24265
+ */
24266
+ failedIndexes: array(string()).optional()
24267
+ });
24268
+ /**
24269
+ * Why a rebuild did not start, BY NAME — ONE vocabulary for both gates in front
24270
+ * of a pass (D649 over D651). A bare `started: false` read the same for "the
24271
+ * stores are booting" and "the cluster row names a model with no CLIP
24272
+ * metadata", which need different fixes.
24273
+ * - `stores-unavailable` — the analytics stores or the API are not up yet.
24274
+ * - the owner's confirmation of the cluster model (D651, `ClusterPinConfirmer`):
24275
+ * a pass that rewrites an index needs two agreeing reads of the OWNER's
24276
+ * answer (`pipelineOrchestrator.getClusterModelChoice`) — a pass that cannot
24277
+ * name its model does not run (D54):
24278
+ * - the owner's own `unreadable` reasons (`owner-not-ready`,
24279
+ * `store-read-failed`, `three-way-read-unavailable`, `invalid-stored`,
24280
+ * `not-cluster-scoped`);
24281
+ * - `method-unavailable` — the orchestrator predates the method;
24282
+ * - `read-failed` — the call failed or answered something unparseable;
24283
+ * - `reads-disagree` — the two reads named different choices.
24284
+ * - `not-a-clip-model` — the CONFIRMED id has no CLIP metadata, so there is no
24285
+ * index to fill and no dimension to check against (D649).
24286
+ */
24287
+ var RebuildObjectEmbeddingsRefusalSchema = _enum([
24288
+ "stores-unavailable",
24289
+ ...CLUSTER_MODEL_CHOICE_UNREADABLE_REASONS,
24290
+ "method-unavailable",
24291
+ "read-failed",
24292
+ "reads-disagree",
24293
+ "not-a-clip-model"
24294
+ ]);
24580
24295
  /**
24581
24296
  * Acknowledgement that a rebuild STARTED.
24582
24297
  *
@@ -24589,7 +24304,12 @@ var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
24589
24304
  var RebuildObjectEmbeddingsResultSchema = object({
24590
24305
  started: boolean(),
24591
24306
  /** True when a pass was already running; the new request is ignored. */
24592
- alreadyRunning: boolean()
24307
+ alreadyRunning: boolean(),
24308
+ /** Present when the pass refused to start — see `RebuildObjectEmbeddingsRefusalSchema`. */
24309
+ refusal: RebuildObjectEmbeddingsRefusalSchema.optional(),
24310
+ /** The CLIP model the pass pinned, and the index it fills (when it started). */
24311
+ modelId: string().optional(),
24312
+ index: string().optional()
24593
24313
  });
24594
24314
  var RebuildStatusSchema = object({
24595
24315
  running: boolean(),
@@ -24623,7 +24343,11 @@ var RebuildStatusSchema = object({
24623
24343
  startedAtMs: number().nullable(),
24624
24344
  finishedAtMs: number().nullable(),
24625
24345
  /** Present when the pass ended by throwing. */
24626
- error: string().nullable()
24346
+ error: string().nullable(),
24347
+ /** The CLIP model the current / last pass pinned (D54), `null` before any. */
24348
+ modelId: string().nullable(),
24349
+ /** The index that pass fills — `ClipModelMeta.vectorIndex` of `modelId` (D649). */
24350
+ index: string().nullable()
24627
24351
  });
24628
24352
  /**
24629
24353
  * Acknowledgement that a debug-media reclaim STARTED.
@@ -24666,24 +24390,6 @@ var MediaReclaimStatusSchema = object({
24666
24390
  finishedAtMs: number().nullable(),
24667
24391
  error: string().nullable()
24668
24392
  });
24669
- var ReplayFrameInputSchema = object({
24670
- timestamp: number(),
24671
- frame: PipelineRunResultBridge
24672
- });
24673
- var RunReplayFrameProcessorResultSchema = object({ tracks: array(object({
24674
- className: string(),
24675
- firstSeenMs: number(),
24676
- lastSeenMs: number(),
24677
- /** Bbox of the track's FIRST matched detection, pixel-space in the clip's
24678
- * frame — a representative box for the diff's `(className, window, IoU)`
24679
- * pairing (`replay-diff.ts`). A replay does not need the full per-frame
24680
- * trajectory production's `Track.positions` keeps. */
24681
- bbox: BoundingBoxSchema,
24682
- /** How many of the input frames this track matched a real detection on
24683
- * (never a coasted/extrapolated frame) — the replay's own signal for "how
24684
- * solid is this track", cheaper than re-deriving it from a trajectory. */
24685
- framesMatched: number().int()
24686
- })).readonly() });
24687
24393
  /**
24688
24394
  * The long-term series a camera produces. A closed union so a typo cannot
24689
24395
  * invent one, and the ONE declaration of it — the addon's `AnalyticsLtsSeries`
@@ -25317,347 +25023,989 @@ var pipelineAnalyticsCapability = {
25317
25023
  auth: "admin"
25318
25024
  }),
25319
25025
  /**
25320
- * COPY-ON-SELECT — the write that makes `trained` safe to evict.
25026
+ * COPY-ON-SELECT — the write that makes `trained` safe to evict.
25027
+ *
25028
+ * Selecting a frame copies its bytes into retrain storage immediately: not
25029
+ * a reference, not a lease. Once the copy exists the dataset no longer
25030
+ * depends on the track's media, which is exactly what lets D81 hand a
25031
+ * `trained` track back to retention.
25032
+ *
25033
+ * The order inside is load-bearing and is pinned by a test: an EXISTING
25034
+ * copy is returned without touching the source, so an original that
25035
+ * evaporated blocks the selection of THAT ORIGINAL and never the copy
25036
+ * already taken. Every refusal comes back named — a dropped selection is
25037
+ * never silent, on the wire or in the log.
25038
+ */
25039
+ selectRetrainFrames: method(object({
25040
+ deviceId: number(),
25041
+ trackId: string(),
25042
+ mediaIds: array(number().int()).min(1)
25043
+ }), RetrainFrameSelectionSchema, {
25044
+ kind: "mutation",
25045
+ auth: "admin"
25046
+ }),
25047
+ /** Un-select a frame: its annotations go first, then the copy and its blob.
25048
+ * Deliberately destructive and deliberately explicit — it is the only way
25049
+ * a frame leaves the dataset before export. */
25050
+ deselectRetrainFrame: method(object({
25051
+ deviceId: number(),
25052
+ trackId: string(),
25053
+ frameId: string()
25054
+ }), object({
25055
+ removed: boolean(),
25056
+ removedAnnotations: number().int()
25057
+ }), {
25058
+ kind: "mutation",
25059
+ auth: "admin"
25060
+ }),
25061
+ /**
25062
+ * The pixels of ONE copied frame, base64.
25063
+ *
25064
+ * Through the cap rather than a data plane because it is genuinely one
25065
+ * frame at a time, on demand, at human speed — the shape D9/D18 permit
25066
+ * (what they forbid is frames crossing a boundary at frame RATE). The
25067
+ * annotation canvas needs the image and its exact dimensions in the same
25068
+ * answer: a canvas that places a normalised box against a size it guessed
25069
+ * draws every box in the wrong place.
25070
+ */
25071
+ getRetrainFrameImage: method(object({ frameId: string() }), object({
25072
+ base64: string(),
25073
+ width: number().int(),
25074
+ height: number().int()
25075
+ }), {
25076
+ kind: "query",
25077
+ auth: "admin"
25078
+ }),
25079
+ /**
25080
+ * Ask the pipeline what it sees, as a PROPOSAL.
25081
+ *
25082
+ * Runs through `pipelineRunner.runStatelessStep` on the COPIED frame, and
25083
+ * every box comes back as a draft with `source: 'assist'` plus the model and
25084
+ * score that produced it. The operator confirms, edits, adds and deletes;
25085
+ * nothing is stored until `saveRetrainAnnotations`.
25086
+ *
25087
+ * For packages the request is `rfdetr-package` on the ZONE CROP at 0.35 —
25088
+ * never the whole frame, where a package detector at that threshold proposes
25089
+ * furniture. A package request with no zone is REFUSED rather than widened,
25090
+ * because the silent widening would look like a bad model for as long as
25091
+ * nobody checked which rectangle it ran on.
25092
+ */
25093
+ proposeRetrainAnnotations: method(object({
25094
+ deviceId: number(),
25095
+ trackId: string(),
25096
+ frameId: string(),
25097
+ subject: RetrainAssistSubjectSchema,
25098
+ /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
25099
+ nodeId: string().optional()
25100
+ }), RetrainAssistResultSchema, {
25101
+ kind: "mutation",
25102
+ auth: "admin"
25103
+ }),
25104
+ /** Every annotation on a track, oldest first. */
25105
+ listRetrainAnnotations: method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
25106
+ kind: "query",
25107
+ auth: "admin"
25108
+ }),
25109
+ /**
25110
+ * Replace EVERY annotation on one frame with the supplied set.
25111
+ *
25112
+ * Whole-frame replacement, not per-box upsert: the unit of ground truth is
25113
+ * the frame, and "the operator deleted a box" must be the same durable
25114
+ * outcome as "the operator never drew it". A per-box patch would let a frame
25115
+ * keep a box the operator removed on a surface that only knew about the
25116
+ * boxes it sent.
25117
+ *
25118
+ * Refuses a macro class typed into `label` or `subLabel` — the tiers are
25119
+ * separate and the guard is at the WRITE, because a mixed taxonomy cannot
25120
+ * be un-mixed by reading it.
25121
+ */
25122
+ saveRetrainAnnotations: method(object({
25123
+ deviceId: number(),
25124
+ trackId: string(),
25125
+ frameId: string(),
25126
+ annotations: array(RetrainAnnotationDraftSchema)
25127
+ }), array(RetrainAnnotationSchema).readonly(), {
25128
+ kind: "mutation",
25129
+ auth: "admin"
25130
+ }),
25131
+ /**
25132
+ * Finish with a track: `staging → trained`. **The only writer of that
25133
+ * state** — D81 shipped the column with it deliberately unreachable.
25134
+ *
25135
+ * Refuses a track the dataset holds no copies from. `trained` un-pins the
25136
+ * track's media, so completing without a copy is a delete order for material
25137
+ * nothing ever extracted anything from; that refusal IS the safety argument
25138
+ * of D81, expressed as a precondition.
25139
+ */
25140
+ completeRetrainTrack: method(object({
25141
+ deviceId: number(),
25142
+ trackId: string()
25143
+ }), RetrainTransitionResultSchema, {
25144
+ kind: "mutation",
25145
+ auth: "admin"
25146
+ }),
25147
+ /**
25148
+ * The deliberate return: `trained → staging`, for the rare case.
25149
+ *
25150
+ * The generic `setTrackFlags` toggle refuses this in both directions by
25151
+ * design (D81) — re-staging from a checkbox is how the same material gets
25152
+ * annotated twice under two ground truths. Doing it here means the operator
25153
+ * is looking at the annotations that already exist while they decide, and
25154
+ * those annotations are LEFT ALONE: "put this back" must not be a
25155
+ * destructive act wearing a navigational name.
25156
+ */
25157
+ restageRetrainTrack: method(object({
25158
+ deviceId: number(),
25159
+ trackId: string()
25160
+ }), RetrainTransitionResultSchema, {
25161
+ kind: "mutation",
25162
+ auth: "admin"
25163
+ }),
25164
+ /**
25165
+ * Where to download the ANNOTATED dataset.
25166
+ *
25167
+ * The sibling of `getTrainingExportUrl` and deliberately not the same
25168
+ * archive: that one streams a marked track's stored media verbatim, this one
25169
+ * streams the retrain COPIES plus an `annotations.json` carrying, for every
25170
+ * subject, the canonical full-frame box AND the geometry derived for each
25171
+ * model shape (letterboxed root / zone-cropped package / subject-cropped
25172
+ * classifier). Derived at export, never stored — one box in, three shapes
25173
+ * out, so two crops of the same subject can never end up in one feature
25174
+ * space (D52).
25175
+ */
25176
+ getRetrainExportUrl: method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
25177
+ kind: "query",
25178
+ auth: "admin"
25179
+ }),
25180
+ /**
25181
+ * The media an EVENT owns.
25182
+ *
25183
+ * `ownerType` is REQUIRED, and that is the whole correction (D482). An
25184
+ * event is a row in ONE of three tables, and since D474 each numbers from
25185
+ * 1 independently: `motion:101314` and `object:101314` both exist. This
25186
+ * method took a bare `eventId` and the provider probed motion → object →
25187
+ * audio, stopping at the first hit — so on the live hub, where object
25188
+ * events own no media of their own and 299 883 of 300 559 media rows are
25189
+ * motion-owned, EVERY object event resolved to its motion namesake. A
25190
+ * track from 17:34 on camera 615 was served a snapshot from 22:35 eleven
25191
+ * days earlier, silently.
25192
+ *
25193
+ * D476 had already disambiguated the KEY (`motion:` vs `object:`); this is
25194
+ * the API catching up to it. Naming the table is not a "qualification" of
25195
+ * the ambiguity — a listing BY OWNER has no address to make surrogate: the
25196
+ * owner IS (table, id), and half of it is not a question.
25197
+ */
25198
+ getEventMedia: method(object({
25199
+ /** Which of the three event tables owns the row. */
25200
+ ownerType: EventOwnerTypeSchema,
25201
+ /** The event's rowid in that table (D474: an event id is a number). */
25202
+ eventId: number().int(),
25203
+ kind: MediaFileKindEnum.optional(),
25204
+ deviceId: number()
25205
+ }), array(MediaFileSchema).readonly()),
25206
+ /** All media rows owned by a track. `kinds` narrows to a kind subset so a
25207
+ * client can fetch the SMALL display variants on open and pull the
25208
+ * multi-MB native variants only on demand (mirrors `getEventMedia.kind`).
25209
+ * Absent ⇒ every kind (back-compat). */
25210
+ getTrackMedia: method(object({
25211
+ trackId: string(),
25212
+ kinds: array(MediaFileKindEnum).optional(),
25213
+ deviceId: number()
25214
+ }), array(MediaFileSchema).readonly()),
25215
+ /**
25216
+ * What media a track HAS, without any of it.
25217
+ *
25218
+ * The detail view needs the shape of a track's media to build its strip —
25219
+ * which kinds exist, in what order, at what size — and then wants each tile
25220
+ * fetched as an image, not as base64 inside this response. Measured: the
25221
+ * full `getTrackMedia` is 5.3-7.7 MB and blocks the view; this manifest is
25222
+ * ~2 KB.
25223
+ *
25224
+ * It also restores a fact a `kinds` filter destroys: filtering
25225
+ * `getTrackMedia` drops whole ROWS, taking `kind` and `sizeBytes` with
25226
+ * them, so a client that fetched only the small variants could no longer
25227
+ * tell a full-resolution variant existed — and the affordance that opens it
25228
+ * would silently disappear.
25229
+ */
25230
+ listTrackMedia: method(object({
25231
+ trackId: string(),
25232
+ deviceId: number()
25233
+ }), array(MediaFileInfoSchema).readonly()),
25234
+ /**
25235
+ * What media an EVENT has, without any of it — the twin `getEventMedia`
25236
+ * never had.
25237
+ *
25238
+ * `listTrackMedia` above got this treatment because a track's media is
25239
+ * 5-8 MB. An event's is worse per row, not better: an old-style event owns
25240
+ * a `crop` AND a native-resolution `fullFrameBoxed`, and the track DETAIL
25241
+ * modal — the one surface that legitimately shows the big kinds — unions
25242
+ * both listings to build its filmstrip. It then renders every tile from
25243
+ * the `event-media` plane by key and throws the bytes away. Measured on
25244
+ * the live hub: one event's `fullFrameBoxed` is 2 824 077 B, base64'd to
25245
+ * ~3.8 MB, allocated whole in hub-main's heap, for a list of keys.
25246
+ *
25247
+ * Same `deviceId` authorization subject as `getEventMedia`, the same
25248
+ * REQUIRED `ownerType` (read that method's docblock for the night-time
25249
+ * thumbnail this closes — D482), and the same rows: this is a projection
25250
+ * of that method, never a different question.
25251
+ */
25252
+ listEventMedia: method(object({
25253
+ ownerType: EventOwnerTypeSchema,
25254
+ eventId: number().int(),
25255
+ deviceId: number()
25256
+ }), array(MediaFileInfoSchema).readonly()),
25257
+ /**
25258
+ * Which of `ownerIds` hold at least ONE media row — an INDEX read, never a
25259
+ * blob read, and the LICENCE `videoclips` needs to publish a `thumbnail`.
25321
25260
  *
25322
- * Selecting a frame copies its bytes into retrain storage immediately: not
25323
- * a reference, not a lease. Once the copy exists the dataset no longer
25324
- * depends on the track's media, which is exactly what lets D81 hand a
25325
- * `trained` track back to retention.
25261
+ * The event-media URL is stamped from a template for every event in the
25262
+ * system, so "the plane is up" was being served as "there are bytes": 64 of
25263
+ * one camera's 179 clips pointed at a 404 (device 3836, 2026-08-17). This
25264
+ * is the question that turns the stamp into a claim.
25326
25265
  *
25327
- * The order inside is load-bearing and is pinned by a test: an EXISTING
25328
- * copy is returned without touching the source, so an original that
25329
- * evaporated blocks the selection of THAT ORIGINAL and never the copy
25330
- * already taken. Every refusal comes back named — a dropped selection is
25331
- * never silent, on the wire or in the log.
25266
+ * It is on the WIRE because the clip source is registered by the addon that
25267
+ * owns the FOOTAGE, not by this one (D560) — the probe used to be an
25268
+ * in-process `MediaStore` read. One call per OWNER KIND, never one per
25269
+ * owner: that N+1 is what `MediaStore.ownersWithMedia` was written to
25270
+ * prevent, and crossing a process boundary makes it worse, not better.
25271
+ * `ownerIds` is bounded at the same 5 000 the annotation fetch is bounded
25272
+ * at, so one pathological camera-day cannot mint an unbounded request.
25273
+ *
25274
+ * THROWS rather than answering partially. A probe that quietly
25275
+ * under-reports reads as "these owners have nothing" and the caller drops
25276
+ * thumbnails that exist — the opposite failure to the one above, and
25277
+ * equally invisible.
25278
+ *
25279
+ * `deviceId` is the authorization subject, exactly as on `getEventMedia`.
25332
25280
  */
25333
- selectRetrainFrames: method(object({
25281
+ ownersWithMedia: method(object({
25334
25282
  deviceId: number(),
25335
- trackId: string(),
25336
- mediaIds: array(number().int()).min(1)
25337
- }), RetrainFrameSelectionSchema, {
25283
+ ownerKind: MediaPresenceOwnerKindSchema,
25284
+ ownerIds: array(string()).max(5e3)
25285
+ }), array(string()).readonly()),
25286
+ /**
25287
+ * Search object events by text query using CLIP cosine similarity.
25288
+ * Encodes `text` via the `embedding-encoder` cap, queries the
25289
+ * `ObjectEmbeddingStore` with optional prefilters, ranks all matching
25290
+ * embeddings by cosine similarity, and joins winners to their
25291
+ * ObjectEvents by trackId. Returns up to `limit` events scored ≥
25292
+ * `minScore`, sorted descending by score.
25293
+ */
25294
+ searchObjectEvents: method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly(), { caller: "required" }),
25295
+ wipeObjectEmbeddings: method(object({}), WipeObjectEmbeddingsResultSchema, {
25338
25296
  kind: "mutation",
25339
25297
  auth: "admin"
25340
25298
  }),
25341
- /** Un-select a frame: its annotations go first, then the copy and its blob.
25342
- * Deliberately destructive and deliberately explicit — it is the only way
25343
- * a frame leaves the dataset before export. */
25344
- deselectRetrainFrame: method(object({
25345
- deviceId: number(),
25346
- trackId: string(),
25347
- frameId: string()
25348
- }), object({
25349
- removed: boolean(),
25350
- removedAnnotations: number().int()
25351
- }), {
25299
+ rebuildObjectEmbeddings: method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
25352
25300
  kind: "mutation",
25353
25301
  auth: "admin"
25354
25302
  }),
25303
+ getObjectEmbeddingRebuildStatus: method(object({}), RebuildStatusSchema)
25304
+ },
25305
+ events: {
25355
25306
  /**
25356
- * The pixels of ONE copied frame, base64.
25357
- *
25358
- * Through the cap rather than a data plane because it is genuinely one
25359
- * frame at a time, on demand, at human speed — the shape D9/D18 permit
25360
- * (what they forbid is frames crossing a boundary at frame RATE). The
25361
- * annotation canvas needs the image and its exact dimensions in the same
25362
- * answer: a canvas that places a normalised box against a size it guessed
25363
- * draws every box in the wrong place.
25364
- */
25365
- getRetrainFrameImage: method(object({ frameId: string() }), object({
25366
- base64: string(),
25367
- width: number().int(),
25368
- height: number().int()
25369
- }), {
25370
- kind: "query",
25371
- auth: "admin"
25372
- }),
25373
- /**
25374
- * Ask the pipeline what it sees, as a PROPOSAL.
25375
- *
25376
- * Runs through `pipelineRunner.runStatelessStep` on the COPIED frame, and
25377
- * every box comes back as a draft with `source: 'assist'` plus the model and
25378
- * score that produced it. The operator confirms, edits, adds and deletes;
25379
- * nothing is stored until `saveRetrainAnnotations`.
25380
- *
25381
- * For packages the request is `rfdetr-package` on the ZONE CROP at 0.35 —
25382
- * never the whole frame, where a package detector at that threshold proposes
25383
- * furniture. A package request with no zone is REFUSED rather than widened,
25384
- * because the silent widening would look like a bad model for as long as
25385
- * nobody checked which rectangle it ran on.
25307
+ * Enriched frame emitted after refinement — the live-overlay source of
25308
+ * truth (two-plane re-injection). Carries the frame's detections in the
25309
+ * `ObjectDetection` wire shape: first-level roots (with track info +
25310
+ * enrichment labels) plus synthesized `kind:'detail'` face/plate entries
25311
+ * re-projected from per-track detail state, so stream overlays render
25312
+ * boxes + recognized names without querying full Track state.
25386
25313
  */
25387
- proposeRetrainAnnotations: method(object({
25314
+ onFrameTracked: { data: object({
25315
+ deviceId: number(),
25316
+ timestamp: number(),
25317
+ frameWidth: number(),
25318
+ frameHeight: number(),
25319
+ detections: array(OverlayDetectionSchema).readonly()
25320
+ }) },
25321
+ /** Track entered active state (first-seen). */
25322
+ onTrackStarted: { data: object({
25388
25323
  deviceId: number(),
25389
25324
  trackId: string(),
25390
- frameId: string(),
25391
- subject: RetrainAssistSubjectSchema,
25392
- /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
25393
- nodeId: string().optional()
25394
- }), RetrainAssistResultSchema, {
25325
+ className: string()
25326
+ }) },
25327
+ /** Track expired (TTL reached after last detection). */
25328
+ onTrackEnded: { data: object({
25329
+ deviceId: number(),
25330
+ trackId: string(),
25331
+ className: string(),
25332
+ durationMs: number()
25333
+ }) },
25334
+ /** Canonical "something happened at device X" event, per-kind. */
25335
+ onDetectionEvent: { data: object({
25336
+ deviceId: number(),
25337
+ kind: EventKindSchema,
25338
+ eventId: string(),
25339
+ timestamp: number()
25340
+ }) }
25341
+ }
25342
+ };
25343
+ /**
25344
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
25345
+ * within the frame, so the executor can re-cut a leaf child ROI at native
25346
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
25347
+ */
25348
+ var NativeCropRefSchema = object({
25349
+ /** Handle keying the retained native surface (node-pinned to its owner). */
25350
+ handle: FrameHandleSchema,
25351
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
25352
+ cropFrameSpace: object({
25353
+ x: number(),
25354
+ y: number(),
25355
+ w: number(),
25356
+ h: number()
25357
+ })
25358
+ });
25359
+ object({
25360
+ crop: object({
25361
+ left: number(),
25362
+ top: number(),
25363
+ width: number().positive(),
25364
+ height: number().positive()
25365
+ }).optional(),
25366
+ content: object({
25367
+ width: number().int().positive(),
25368
+ height: number().int().positive()
25369
+ }),
25370
+ fit: _enum(["stretch", "contain"]),
25371
+ format: _enum([
25372
+ "rgb",
25373
+ "gray",
25374
+ "jpeg"
25375
+ ])
25376
+ });
25377
+ /**
25378
+ * Process-local frame identity. It is serializable so it can ride an in-process
25379
+ * capability call, but `registryId` deliberately prevents resolution in any
25380
+ * other process or execution group.
25381
+ */
25382
+ var FrameRefSchema = object({
25383
+ registryId: string().min(1),
25384
+ id: string().min(1),
25385
+ width: number().int().positive(),
25386
+ height: number().int().positive(),
25387
+ format: _enum(["rgb", "gray"]),
25388
+ timestamp: number(),
25389
+ capturedAt: number().optional()
25390
+ });
25391
+ var ModelFormatSchema$1 = _enum([
25392
+ "onnx",
25393
+ "coreml",
25394
+ "openvino",
25395
+ "tflite",
25396
+ "pt",
25397
+ "gguf"
25398
+ ]);
25399
+ var PipelineSlotSchema = _enum([
25400
+ "detector",
25401
+ "cropper",
25402
+ "classifier",
25403
+ "refiner",
25404
+ "audio-classifier"
25405
+ ]);
25406
+ var PipelineEngineChoiceSchema = object({
25407
+ runtime: literal("python"),
25408
+ backend: string(),
25409
+ format: ModelFormatSchema$1,
25410
+ device: string().optional()
25411
+ });
25412
+ /**
25413
+ * One pool's resolved provisioning (`getEffectiveTuning`). `numWorkers` is the
25414
+ * knob that lifts a saturated pool (`inference-devices.md`); `concurrency` is
25415
+ * per-worker in-flight requests. `deviceKey` echoes the pool asked about —
25416
+ * `null` for the node-default pool.
25417
+ */
25418
+ var EffectiveTuningSchema = object({
25419
+ deviceKey: string().nullable(),
25420
+ runtime: string(),
25421
+ batchMode: string(),
25422
+ windowMs: number(),
25423
+ maxBatchSize: number(),
25424
+ concurrency: number(),
25425
+ numWorkers: number()
25426
+ });
25427
+ var AvailableEngineSchema = object({
25428
+ engine: PipelineEngineChoiceSchema,
25429
+ devices: array(object({
25430
+ id: string(),
25431
+ label: string(),
25432
+ description: string().optional()
25433
+ })).readonly(),
25434
+ defaultDevice: string()
25435
+ });
25436
+ var PipelineDefaultStepSchema = lazy(() => object({
25437
+ addonId: string(),
25438
+ addonName: string(),
25439
+ slot: PipelineSlotSchema,
25440
+ inputClasses: array(string()).readonly(),
25441
+ outputClasses: array(string()).readonly(),
25442
+ enabled: boolean(),
25443
+ modelId: string(),
25444
+ children: array(PipelineDefaultStepSchema).readonly(),
25445
+ group: string().optional(),
25446
+ settings: record(string(), unknown()).optional()
25447
+ }));
25448
+ var PipelineTemplateStepSchema = lazy(() => object({
25449
+ addonId: string(),
25450
+ enabled: boolean(),
25451
+ modelId: string(),
25452
+ children: array(PipelineTemplateStepSchema).readonly(),
25453
+ settings: record(string(), unknown()).optional()
25454
+ }));
25455
+ var PipelineTemplateSchema$1 = object({
25456
+ id: string(),
25457
+ name: string(),
25458
+ createdAt: string(),
25459
+ updatedAt: string(),
25460
+ engine: PipelineEngineChoiceSchema,
25461
+ steps: array(PipelineTemplateStepSchema).readonly()
25462
+ });
25463
+ var PipelineModelOptionSchema = object({
25464
+ id: string(),
25465
+ name: string(),
25466
+ formats: record(string(), object({
25467
+ downloaded: boolean(),
25468
+ sizeMB: number()
25469
+ })),
25470
+ group: ModelVariantGroupSchema.optional(),
25471
+ legacy: boolean().optional(),
25472
+ provider: ModelProviderIdSchema.optional()
25473
+ });
25474
+ var ConfigFieldBridge = custom();
25475
+ var PipelineAddonSchemaSchema = object({
25476
+ id: string(),
25477
+ name: string(),
25478
+ slot: PipelineSlotSchema,
25479
+ inputClasses: array(string()).readonly(),
25480
+ outputClasses: array(string()).readonly(),
25481
+ childSlots: array(PipelineSlotSchema).readonly(),
25482
+ models: array(PipelineModelOptionSchema).readonly(),
25483
+ defaultModelId: string(),
25484
+ defaultModelIdByFormat: record(string(), string()).optional(),
25485
+ enabledByDefault: boolean().optional(),
25486
+ backfillIntoExistingOverrides: boolean().optional(),
25487
+ defaultConfidence: number(),
25488
+ group: string().optional(),
25489
+ configSchema: array(ConfigFieldBridge).readonly().optional()
25490
+ });
25491
+ var PipelineSlotSchemaSchema = object({
25492
+ id: PipelineSlotSchema,
25493
+ label: string(),
25494
+ priority: number(),
25495
+ parentSlot: PipelineSlotSchema.nullable(),
25496
+ addons: array(PipelineAddonSchemaSchema).readonly()
25497
+ });
25498
+ var PipelineSchemaSchema = object({
25499
+ availableEngines: array(AvailableEngineSchema).readonly(),
25500
+ selectedEngine: PipelineEngineChoiceSchema,
25501
+ slots: array(PipelineSlotSchemaSchema).readonly()
25502
+ });
25503
+ var EngineProvisioningSchema = object({
25504
+ runtimeId: _enum([
25505
+ "onnx",
25506
+ "openvino",
25507
+ "coreml",
25508
+ "edgetpu"
25509
+ ]).nullable(),
25510
+ device: string().nullable(),
25511
+ state: _enum([
25512
+ "idle",
25513
+ "installing",
25514
+ "verifying",
25515
+ "ready",
25516
+ "failed"
25517
+ ]),
25518
+ progress: number().optional(),
25519
+ error: string().optional(),
25520
+ nextRetryAt: number().optional(),
25521
+ /**
25522
+ * Gate A (config-correctness gate at engine change): human-readable
25523
+ * config issues surfaced EAGERLY when the node's engine changes — model
25524
+ * substitutions ("chose X, running Y") and zero-build steps ("no model
25525
+ * has a <format> build"). Additive/optional: informational only, never
25526
+ * enforced here — `assertEngineReady` (readiness) still gates inference.
25527
+ * Absent/empty when the node-default tree resolves cleanly.
25528
+ */
25529
+ configIssues: array(string()).optional()
25530
+ });
25531
+ var PipelineStepInputSchema = lazy(() => object({
25532
+ addonId: string(),
25533
+ modelId: string().optional(),
25534
+ enabled: boolean().default(true),
25535
+ children: array(PipelineStepInputSchema).optional(),
25536
+ settings: record(string(), unknown()).optional(),
25537
+ jumpDeviceKey: string().optional()
25538
+ }));
25539
+ var ModelSubstitutionSchema = object({
25540
+ addonId: string(),
25541
+ chosen: string(),
25542
+ running: string(),
25543
+ format: string()
25544
+ });
25545
+ var PipelineValidationIssueSchema = object({
25546
+ addonId: string(),
25547
+ kind: _enum([
25548
+ "unknown-addon",
25549
+ "no-format-build",
25550
+ "unknown-device"
25551
+ ]),
25552
+ detail: string()
25553
+ });
25554
+ var PipelineValidationResultSchema = object({
25555
+ ok: boolean(),
25556
+ issues: array(PipelineValidationIssueSchema).readonly(),
25557
+ substitutions: array(ModelSubstitutionSchema).readonly(),
25558
+ /** The node's `currentEngine.format` this validation ran against. */
25559
+ format: string()
25560
+ });
25561
+ var ReferenceImageEntrySchema = object({
25562
+ filename: string(),
25563
+ stepIds: array(string()).readonly().optional()
25564
+ });
25565
+ var ReferenceImageBodySchema = object({
25566
+ base64: string(),
25567
+ filename: string()
25568
+ });
25569
+ var ReferenceAudioEntrySchema = object({
25570
+ filename: string(),
25571
+ sizeKb: number()
25572
+ });
25573
+ var ReferenceAudioBodySchema = object({ base64: string() });
25574
+ var AudioBackendSchema = object({
25575
+ id: string(),
25576
+ name: string(),
25577
+ description: string(),
25578
+ available: boolean(),
25579
+ /**
25580
+ * Raw classifier labels this backend can emit (e.g. YAMNet's
25581
+ * 521-class set or Apple SoundAnalysis's 303-class set). Used by
25582
+ * the benchmark UI to populate the `enabledMicroClasses` filter
25583
+ * specific to the selected backend without a separate fetch.
25584
+ */
25585
+ rawLabels: array(string()).readonly().optional()
25586
+ });
25587
+ var AudioCapabilitiesSchema = object({
25588
+ activeBackend: string(),
25589
+ availableBackends: array(AudioBackendSchema).readonly(),
25590
+ sampleRate: number(),
25591
+ chunkDurationMs: number()
25592
+ });
25593
+ var DownloadModelResultSchema = object({
25594
+ filePath: string(),
25595
+ sizeMB: number(),
25596
+ durationMs: number()
25597
+ });
25598
+ /**
25599
+ * Wrapper carrying a single test run's result. Replaces the legacy
25600
+ * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
25601
+ * canonical `AudioResult` from the Phase 6 output rework: one
25602
+ * `AudioDetection` per class above `minScore`, top-N candidates in
25603
+ * `debug.alternateLabels['audio-classifier']`, per-source timings in
25604
+ * `debug.stepTimings`. The outer `success`/`error` fields stay so the
25605
+ * benchmark UI can still report a clean failure when the classifier
25606
+ * cap isn't available.
25607
+ */
25608
+ var AudioTestResultSchema = object({
25609
+ success: boolean(),
25610
+ error: string().optional(),
25611
+ frame: custom().optional()
25612
+ });
25613
+ var PipelineConfigBridge = custom();
25614
+ var ConfigUISchemaBridge = custom();
25615
+ var ConfigUISchemaNullableBridge = custom();
25616
+ var InferenceCapabilitiesBridge = custom();
25617
+ var ModelAvailabilityListBridge = custom();
25618
+ var PipelineRunResultBridge = custom();
25619
+ /**
25620
+ * Pipeline executor — detection engine + configuration + inference API.
25621
+ *
25622
+ * Merged from: pipeline-executor, pipeline-config, inference, detection-config.
25623
+ * Implemented by the detection-pipeline addon.
25624
+ *
25625
+ * Per-device surface (DeviceSettingsContribution + the "is detection
25626
+ * enabled for this camera?" toggle) lives on the paired
25627
+ * `detection-pipeline` cap (device-scoped, singleton, wrapper
25628
+ * defaultActive) — same split pattern used by stream-broker /
25629
+ * camera-streams and audio-analyzer / audio-analysis.
25630
+ */
25631
+ var pipelineExecutorCapability = {
25632
+ name: "pipeline-executor",
25633
+ scope: "system",
25634
+ mode: "singleton",
25635
+ methods: {
25636
+ getAvailableEngines: method(_void(), array(PipelineEngineChoiceSchema)),
25637
+ getSelectedEngine: method(_void(), PipelineEngineChoiceSchema),
25638
+ getDefaultSteps: method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)),
25639
+ /**
25640
+ * Per-node detection-engine provisioning snapshot. Returns the live
25641
+ * state of the lazy runtime-provisioning machine on `nodeId`
25642
+ * (idle / installing / verifying / ready / failed). The UI pairs this
25643
+ * one-shot query with the `pipeline.engine-provisioning` live event
25644
+ * (emitted on every transition) to drive a per-node "engine ready?"
25645
+ * indicator without polling. Phase 2.
25646
+ */
25647
+ getEngineProvisioning: method(object({ nodeId: string() }), EngineProvisioningSchema),
25648
+ getVideoPipelineSteps: method(_void(), record(string(), object({
25649
+ modelId: string(),
25650
+ settings: record(string(), unknown()).readonly()
25651
+ }))),
25652
+ setVideoPipelineSteps: method(object({ steps: record(string(), object({
25653
+ modelId: string(),
25654
+ settings: record(string(), unknown()).readonly()
25655
+ })) }), object({ success: literal(true) }), {
25395
25656
  kind: "mutation",
25396
25657
  auth: "admin"
25397
25658
  }),
25398
25659
  /**
25399
- * The FrameProcessor pass of a replay run — see the `Replay` section
25400
- * above this capability's definition for why this is not the
25401
- * `processFrame` method this file's header says pipeline-analytics does
25402
- * not have.
25660
+ * Clear THIS node's executor-side PER-DEVICE settings stores (the
25661
+ * per-camera step overrides the object-detection root reads via
25662
+ * `applyDeviceOverridesToTree`). `nodeId` is the ROUTING key — the
25663
+ * generated cap-router strips it (default `nodeIdMode: 'routing'`) and
25664
+ * dispatches to that node, so the provider method runs ON the target
25665
+ * node and receives no `nodeId`.
25403
25666
  *
25404
- * Constructs a FRESH `FrameProcessor` for `(deviceId, source)`, feeds it
25405
- * `frames` IN THE ORDER GIVEN (the caller is responsible for time
25406
- * ordering — this method does not sort), and returns the tracks it
25407
- * produced. Zero persistence: no `TrackStore`, no event bus, no media
25408
- * capture. `zones` / `detectionRules` are the run's OWN zone set —
25409
- * typically the camera's real zones plus an ephemeral overlay
25410
- * (`addon-benchmark`'s `replay-plan.ts`), never read from or written to
25411
- * the `zones` capability by this method itself.
25667
+ * This is the slimmed executor leg of the orchestrator's
25668
+ * `resetNodePipelineDefaults` flow (which owns the real reset: node
25669
+ * addonDefaults pins + per-camera orchestrator overrides). The legacy
25670
+ * `resetToDefault` — which reset a persisted global step-tree seed
25671
+ * nothing in the live per-camera path read — was removed together with
25672
+ * that seed.
25412
25673
  */
25413
- runReplayFrameProcessor: method(object({
25414
- deviceId: number(),
25415
- source: DetectionSourceSchema,
25416
- zones: array(ZoneSchema).readonly().optional(),
25417
- detectionRules: array(ZoneRuleSchema).readonly().optional(),
25418
- zoneMembershipMinOverlap: number().min(0).max(1).optional(),
25419
- frames: array(ReplayFrameInputSchema).min(1)
25420
- }), RunReplayFrameProcessorResultSchema, {
25674
+ clearDeviceOverrides: method(object({ nodeId: string() }), object({
25675
+ success: literal(true),
25676
+ clearedDevices: number()
25677
+ }), {
25421
25678
  kind: "mutation",
25422
25679
  auth: "admin"
25423
25680
  }),
25424
- /** Every annotation on a track, oldest first. */
25425
- listRetrainAnnotations: method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
25426
- kind: "query",
25427
- auth: "admin"
25428
- }),
25429
25681
  /**
25430
- * Replace EVERY annotation on one frame with the supplied set.
25682
+ * Which of THIS node's inference devices the executor currently refuses,
25683
+ * and why. `nodeId` is the ROUTING key (stripped by the generated router).
25431
25684
  *
25432
- * Whole-frame replacement, not per-box upsert: the unit of ground truth is
25433
- * the frame, and "the operator deleted a box" must be the same durable
25434
- * outcome as "the operator never drew it". A per-box patch would let a frame
25435
- * keep a box the operator removed on a surface that only knew about the
25436
- * boxes it sent.
25685
+ * The channel that did not exist. Pool health was known only inside the
25686
+ * detection addon and was an input to no routing decision anywhere: the
25687
+ * per-dispatch capability gate is keyed on model FORMAT and so can never
25688
+ * separate `openvino:gpu` from `openvino:npu`, and the orchestrator's live
25689
+ * eligibility probe (`platformProbe.getCapabilities`) answers about
25690
+ * HARDWARE — which was present throughout. So when the hub's `openvino:gpu`
25691
+ * Python worker was SIGABRT'd by the Intel GPU plugin on 2026-08-25, the
25692
+ * balancer went on handing that dead pool cameras by rotation for 31 hours:
25693
+ * ~370 000 `PoolWorker[w0]: not initialized` lines, every frame lost.
25437
25694
  *
25438
- * Refuses a macro class typed into `label` or `subLabel` — the tiers are
25439
- * separate and the guard is at the WRITE, because a mixed taxonomy cannot
25440
- * be un-mixed by reading it.
25695
+ * Read semantics the caller depends on, and which the provider guarantees:
25696
+ * this is a synchronous read of in-memory state. It never probes hardware,
25697
+ * never spawns a pool and never throws — an EMPTY `unhealthy` means "asked,
25698
+ * nothing is refused", which is what re-admits a device. A read that FAILS
25699
+ * (node offline, version skew) must therefore be distinguishable from an
25700
+ * empty answer, and it is: it rejects.
25441
25701
  */
25442
- saveRetrainAnnotations: method(object({
25443
- deviceId: number(),
25444
- trackId: string(),
25445
- frameId: string(),
25446
- annotations: array(RetrainAnnotationDraftSchema)
25447
- }), array(RetrainAnnotationSchema).readonly(), {
25448
- kind: "mutation",
25449
- auth: "admin"
25450
- }),
25702
+ getInferenceDeviceHealth: method(object({ nodeId: string() }), object({ unhealthy: array(object({
25703
+ /** `<backend>:<device>`, e.g. `openvino:gpu`. */
25704
+ deviceKey: string(),
25705
+ /**
25706
+ * `failed` — the per-device restart budget is exhausted; no pool
25707
+ * will be spawned until an operator re-arms it or the runner
25708
+ * respawns. `backoff` — under budget, waiting out the backoff (or
25709
+ * a cached pool observed dead and not yet condemned).
25710
+ */
25711
+ state: _enum(["failed", "backoff"]),
25712
+ /** Epoch ms of the death that produced this state. */
25713
+ since: number(),
25714
+ /** Pool deaths inside the current window. */
25715
+ deaths: number(),
25716
+ /** The last death's message. */
25717
+ lastError: string()
25718
+ })).readonly() })),
25451
25719
  /**
25452
- * Finish with a track: `staging → trained`. **The only writer of that
25453
- * state** — D81 shipped the column with it deliberately unreachable.
25720
+ * Re-arm a terminally `failed` inference device on `nodeId`: forget its
25721
+ * restart budget so the next dispatch builds a fresh pool.
25454
25722
  *
25455
- * Refuses a track the dataset holds no copies from. `trained` un-pins the
25456
- * track's media, so completing without a copy is a delete order for material
25457
- * nothing ever extracted anything from; that refusal IS the safety argument
25458
- * of D81, expressed as a precondition.
25723
+ * The terminal state is deliberate (the abort it bounds is deterministic —
25724
+ * an automatic probation would just respawn Python forever, more slowly),
25725
+ * and a terminal state an operator cannot leave is a silent fault. This is
25726
+ * the way out. `rearmed:false` means there was nothing to forget.
25459
25727
  */
25460
- completeRetrainTrack: method(object({
25461
- deviceId: number(),
25462
- trackId: string()
25463
- }), RetrainTransitionResultSchema, {
25728
+ rearmInferenceDevice: method(object({
25729
+ nodeId: string(),
25730
+ deviceKey: string()
25731
+ }), object({ rearmed: boolean() }), {
25464
25732
  kind: "mutation",
25465
25733
  auth: "admin"
25466
25734
  }),
25735
+ getSchema: method(_void(), PipelineSchemaSchema),
25736
+ getGlobalSteps: method(_void(), array(PipelineDefaultStepSchema).readonly().nullable()),
25737
+ getGlobalPipelineConfig: method(_void(), PipelineConfigBridge),
25738
+ getOrchestratorConfigSchema: method(_void(), ConfigUISchemaBridge),
25467
25739
  /**
25468
- * The deliberate return: `trained → staging`, for the rare case.
25740
+ * Gate B (pre-init config-correctness gate). PURE COMPUTE against this
25741
+ * node's `currentEngine.format` — resolves `steps` the same way the
25742
+ * runtime dispatch path would, and reports what WOULD happen without
25743
+ * touching any node-global state. Called by the orchestrator at attach
25744
+ * time (`attachOn`), node-pinned to the TARGET node, so config problems
25745
+ * surface BEFORE `pipelineRunner.attachCamera` rather than at the first
25746
+ * per-frame resolve. `ok` is false iff `issues` is non-empty (both
25747
+ * `unknown-addon` and `no-format-build` are HARD issues); `substitutions`
25748
+ * is informational (a degraded-but-loadable model swap) and never
25749
+ * affects `ok`. Never throws.
25469
25750
  *
25470
- * The generic `setTrackFlags` toggle refuses this in both directions by
25471
- * design (D81) — re-staging from a checkbox is how the same material gets
25472
- * annotated twice under two ground truths. Doing it here means the operator
25473
- * is looking at the annotations that already exist while they decide, and
25474
- * those annotations are LEFT ALONE: "put this back" must not be a
25475
- * destructive act wearing a navigational name.
25751
+ * `deviceKey` validates against THAT device pool's format instead of the
25752
+ * node default (D646) — the cheap question a pinned replay asks before it
25753
+ * reads any media: can this (node, deviceKey) run exactly this model?
25476
25754
  */
25477
- restageRetrainTrack: method(object({
25478
- deviceId: number(),
25479
- trackId: string()
25480
- }), RetrainTransitionResultSchema, {
25481
- kind: "mutation",
25482
- auth: "admin"
25483
- }),
25755
+ validatePipeline: method(object({
25756
+ steps: array(PipelineStepInputSchema),
25757
+ deviceKey: string().optional()
25758
+ }), PipelineValidationResultSchema),
25759
+ listTemplates: method(_void(), array(PipelineTemplateSchema$1).readonly()),
25760
+ saveTemplate: method(object({
25761
+ name: string(),
25762
+ steps: array(PipelineTemplateStepSchema).readonly(),
25763
+ engine: PipelineEngineChoiceSchema
25764
+ }), PipelineTemplateSchema$1, { kind: "mutation" }),
25765
+ updateTemplate: method(object({
25766
+ id: string(),
25767
+ name: string().optional(),
25768
+ steps: array(PipelineTemplateStepSchema).readonly().optional()
25769
+ }), PipelineTemplateSchema$1, { kind: "mutation" }),
25770
+ deleteTemplate: method(object({ id: string() }), _void(), { kind: "mutation" }),
25771
+ getCapabilities: method(_void(), InferenceCapabilitiesBridge),
25772
+ getAddonModels: method(object({ addonId: string() }), ModelAvailabilityListBridge),
25773
+ downloadModel: method(object({
25774
+ addonId: string(),
25775
+ modelId: string(),
25776
+ format: ModelFormatSchema$1
25777
+ }), DownloadModelResultSchema, { kind: "mutation" }),
25778
+ deleteModel: method(object({
25779
+ addonId: string(),
25780
+ modelId: string(),
25781
+ format: ModelFormatSchema$1
25782
+ }), object({ success: literal(true) }), { kind: "mutation" }),
25484
25783
  /**
25485
- * Where to download the ANNOTATED dataset.
25784
+ * Stateless single-frame execution. Callers (runner, benchmark) pass
25785
+ * the complete `steps` tree; the executor holds no state about cameras
25786
+ * or saved pipelines. WHICH pool answers is the node's own engine, or the
25787
+ * `deviceKey` pool when one is named.
25486
25788
  *
25487
- * The sibling of `getTrainingExportUrl` and deliberately not the same
25488
- * archive: that one streams a marked track's stored media verbatim, this one
25489
- * streams the retrain COPIES plus an `annotations.json` carrying, for every
25490
- * subject, the canonical full-frame box AND the geometry derived for each
25491
- * model shape (letterboxed root / zone-cropped package / subject-cropped
25492
- * classifier). Derived at export, never stored — one box in, three shapes
25493
- * out, so two crops of the same subject can never end up in one feature
25494
- * space (D52).
25789
+ * There is no `engine` field (D646). It existed for the benchmark and was
25790
+ * honoured by swapping the SHARED provider's engine, factory and executor
25791
+ * for the duration of the call, on a node serving live cameras. A caller
25792
+ * that still sends the key has it stripped here and changes nothing.
25793
+ *
25794
+ * Exactly one of `frame`, `frameRef`, `frameHandle`, `imageBase64`,
25795
+ * `referenceImage` must be provided:
25796
+ * - `frame`: runtime dispatch path (runner → decoded broker frame).
25797
+ * Carries the raw buffer, dimensions, and format; the executor
25798
+ * uses it directly without base64 round-tripping.
25799
+ * - `frameHandle` (CB5): a zero-pixel shm `FrameHandle` for the SAME
25800
+ * decoded frame. Both runner and executor are hub-local processes
25801
+ * sharing `/dev/shm`, so the executor maps the named segment and
25802
+ * reads the pixels back zero-copy — eliminating the ~1.2MB
25803
+ * re-serialisation over UDS/MsgPack the `frame` path pays per call.
25804
+ * High-risk: the FrameRing is a latest-wins seqlock with no
25805
+ * refcount, so a recycled slot yields a null read; the executor
25806
+ * then degrades to an empty result and the runner ships pixels via
25807
+ * `frame` as the fallback (queue-depth gated on the runner side).
25808
+ * - `imageBase64`: one-shot test path (benchmark ImageTab).
25809
+ * - `referenceImage`: named file from the reference-image store.
25495
25810
  */
25496
- getRetrainExportUrl: method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
25497
- kind: "query",
25498
- auth: "admin"
25499
- }),
25811
+ runPipeline: method(object({
25812
+ steps: array(PipelineStepInputSchema).min(1),
25813
+ frame: FrameInputSchema.optional(),
25814
+ /**
25815
+ * Process-local lazy frame. Valid only when caller and provider resolve
25816
+ * in the same execution-group process; split/cross-node callers use
25817
+ * `frame`/`image` inline compatibility instead.
25818
+ */
25819
+ frameRef: FrameRefSchema.optional(),
25820
+ /**
25821
+ * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
25822
+ * the decoded pixels live in. One more member of the one-of
25823
+ * frame/frameHandle/image/imageBase64/referenceImage group.
25824
+ */
25825
+ frameHandle: FrameHandleSchema.optional(),
25826
+ imageBase64: string().optional(),
25827
+ /**
25828
+ * Binary JPEG bytes — preferred over `imageBase64` on internal
25829
+ * hops (hub → forked worker via Moleculer MsgPack) because it
25830
+ * skips the 33% base64 overhead + the per-call base64 decode on
25831
+ * the detection-pipeline worker. Callers can pass either; exactly
25832
+ * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
25833
+ */
25834
+ image: _instanceof(Uint8Array).optional(),
25835
+ referenceImage: string().optional(),
25836
+ deviceId: number().optional(),
25837
+ sessionId: string().optional(),
25838
+ /**
25839
+ * Execution plane. 'full' (default) runs the whole tree — benchmark,
25840
+ * reference-image, and detail-subtree calls. 'frame' is the live
25841
+ * per-frame dispatch: ONLY root-plane steps run; crop children
25842
+ * (inputClasses ≠ null) are skipped and served per-track via
25843
+ * pipelineRunner.runDetailSubtree (two-plane design).
25844
+ */
25845
+ plane: _enum(["full", "frame"]).optional(),
25846
+ /**
25847
+ * Inference-device selector (Phase 2 multi-device). Format
25848
+ * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
25849
+ * Omitted ⇒ the runner's default device (current single-engine
25850
+ * behaviour). Selects WHICH device pool of the node runs the call.
25851
+ */
25852
+ deviceKey: string().optional(),
25853
+ /**
25854
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
25855
+ * when the parent crop was resolved from the frame's retained NATIVE
25856
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
25857
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
25858
+ * resolution from that surface — the SAME quality path faces already
25859
+ * had — instead of the downscaled parent tile. `handle` keys the native
25860
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
25861
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
25862
+ * the executor's crop-normalized child ROI back into frame-normalized
25863
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
25864
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
25865
+ * (today's behaviour on the fallback path).
25866
+ */
25867
+ nativeCropRef: NativeCropRefSchema.optional(),
25868
+ /**
25869
+ * Offline REPLAY of stored media for `deviceId` (D56, D646): the
25870
+ * camera's zone gate and overrides apply as live, every executing
25871
+ * step runs EXACTLY the model it names on the `deviceKey` pool it
25872
+ * names or the call refuses (`model-not-servable` /
25873
+ * `device-not-servable`), and nothing reaches the camera's live
25874
+ * trace stream. Absent ⇒ unchanged behaviour.
25875
+ */
25876
+ replay: literal(true).optional()
25877
+ }), PipelineRunResultBridge, { kind: "mutation" }),
25500
25878
  /**
25501
- * The media an EVENT owns.
25502
- *
25503
- * `ownerType` is REQUIRED, and that is the whole correction (D482). An
25504
- * event is a row in ONE of three tables, and since D474 each numbers from
25505
- * 1 independently: `motion:101314` and `object:101314` both exist. This
25506
- * method took a bare `eventId` and the provider probed motion → object →
25507
- * audio, stopping at the first hit — so on the live hub, where object
25508
- * events own no media of their own and 299 883 of 300 559 media rows are
25509
- * motion-owned, EVERY object event resolved to its motion namesake. A
25510
- * track from 17:34 on camera 615 was served a snapshot from 22:35 eleven
25511
- * days earlier, silently.
25879
+ * Batched run — N raw frames packed into one cap call. The provider
25880
+ * routes the batch through `SharedInferencePool.inferBatch`
25881
+ * (`MSG_INFER_BATCH = 0x03`) so the IPC framing and JSON response
25882
+ * envelope cost is amortised N:1 vs N concurrent `runPipeline`
25883
+ * calls. Single root step + uniform model assumed; trees with crop
25884
+ * children fall back to sequential execution.
25512
25885
  *
25513
- * D476 had already disambiguated the KEY (`motion:` vs `object:`); this is
25514
- * the API catching up to it. Naming the table is not a "qualification" of
25515
- * the ambiguity — a listing BY OWNER has no address to make surrogate: the
25516
- * owner IS (table, id), and half of it is not a question.
25886
+ * Used by `scripts/bench-batch-style.mts` for batch benchmarking —
25887
+ * N frames in one call to amortise per-call IPC overhead.
25517
25888
  */
25518
- getEventMedia: method(object({
25519
- /** Which of the three event tables owns the row. */
25520
- ownerType: EventOwnerTypeSchema,
25521
- /** The event's rowid in that table (D474: an event id is a number). */
25522
- eventId: number().int(),
25523
- kind: MediaFileKindEnum.optional(),
25524
- deviceId: number()
25525
- }), array(MediaFileSchema).readonly()),
25526
- /** All media rows owned by a track. `kinds` narrows to a kind subset so a
25527
- * client can fetch the SMALL display variants on open and pull the
25528
- * multi-MB native variants only on demand (mirrors `getEventMedia.kind`).
25529
- * Absent ⇒ every kind (back-compat). */
25530
- getTrackMedia: method(object({
25531
- trackId: string(),
25532
- kinds: array(MediaFileKindEnum).optional(),
25533
- deviceId: number()
25534
- }), array(MediaFileSchema).readonly()),
25889
+ runPipelineBatch: method(object({
25890
+ steps: array(PipelineStepInputSchema).min(1),
25891
+ frames: array(FrameInputSchema).min(1).max(255),
25892
+ deviceId: number().optional(),
25893
+ sessionId: string().optional(),
25894
+ /**
25895
+ * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
25896
+ * the batch to the Python pool's bench preprocess cache
25897
+ * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
25898
+ * preprocessed ONCE and every later inference is a pure-inference cache
25899
+ * hit — the sustained-throughput run measures inference, not
25900
+ * decode+preprocess+infer. Omitted/0 for live frames (all different →
25901
+ * full preprocess every call, correct). Fresh per sustained run;
25902
+ * released via `uncacheFrame`.
25903
+ */
25904
+ frameId: number().int().nonnegative().optional(),
25905
+ /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
25906
+ deviceKey: string().optional()
25907
+ }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }),
25535
25908
  /**
25536
- * What media a track HAS, without any of it.
25537
- *
25538
- * The detail view needs the shape of a track's media to build its strip —
25539
- * which kinds exist, in what order, at what size — and then wants each tile
25540
- * fetched as an image, not as base64 inside this response. Measured: the
25541
- * full `getTrackMedia` is 5.3-7.7 MB and blocks the view; this manifest is
25542
- * ~2 KB.
25543
- *
25544
- * It also restores a fact a `kinds` filter destroys: filtering
25545
- * `getTrackMedia` drops whole ROWS, taking `kind` and `sizeBytes` with
25546
- * them, so a client that fetched only the small variants could no longer
25547
- * tell a full-resolution variant existed — and the affordance that opens it
25548
- * would silently disappear.
25909
+ * Cache a raw frame inside the Python inference pool's memory.
25910
+ * Returns a numeric `frameId` that `inferCached` references —
25911
+ * subsequent calls send only 5 bytes through the pipe instead of
25912
+ * 1.2MB raw data, eliminating the pipe transfer bottleneck.
25549
25913
  */
25550
- listTrackMedia: method(object({
25551
- trackId: string(),
25552
- deviceId: number()
25553
- }), array(MediaFileInfoSchema).readonly()),
25914
+ cacheFrameInPool: method(object({
25915
+ data: _instanceof(Uint8Array),
25916
+ width: number().int().positive(),
25917
+ height: number().int().positive(),
25918
+ format: _enum([
25919
+ "rgb",
25920
+ "bgr",
25921
+ "gray"
25922
+ ])
25923
+ }), object({
25924
+ frameId: number(),
25925
+ width: number(),
25926
+ height: number()
25927
+ }), { kind: "mutation" }),
25554
25928
  /**
25555
- * What media an EVENT has, without any of it — the twin `getEventMedia`
25556
- * never had.
25557
- *
25558
- * `listTrackMedia` above got this treatment because a track's media is
25559
- * 5-8 MB. An event's is worse per row, not better: an old-style event owns
25560
- * a `crop` AND a native-resolution `fullFrameBoxed`, and the track DETAIL
25561
- * modal — the one surface that legitimately shows the big kinds — unions
25562
- * both listings to build its filmstrip. It then renders every tile from
25563
- * the `event-media` plane by key and throws the bytes away. Measured on
25564
- * the live hub: one event's `fullFrameBoxed` is 2 824 077 B, base64'd to
25565
- * ~3.8 MB, allocated whole in hub-main's heap, for a list of keys.
25566
- *
25567
- * Same `deviceId` authorization subject as `getEventMedia`, the same
25568
- * REQUIRED `ownerType` (read that method's docblock for the night-time
25569
- * thumbnail this closes — D482), and the same rows: this is a projection
25570
- * of that method, never a different question.
25929
+ * Run inference on a previously cached frame. Sends only 5 bytes
25930
+ * (model_idx + frameId) through the IPC pipe — eliminates the
25931
+ * ~35ms per-call overhead of transferring 1.2MB raw data.
25571
25932
  */
25572
- listEventMedia: method(object({
25573
- ownerType: EventOwnerTypeSchema,
25574
- eventId: number().int(),
25575
- deviceId: number()
25576
- }), array(MediaFileInfoSchema).readonly()),
25933
+ inferCached: method(object({
25934
+ stepId: string(),
25935
+ frameId: number().int()
25936
+ }), record(string(), unknown()), { kind: "mutation" }),
25577
25937
  /**
25578
- * Which of `ownerIds` hold at least ONE media row — an INDEX read, never a
25579
- * blob read, and the LICENCE `videoclips` needs to publish a `thumbnail`.
25580
- *
25581
- * The event-media URL is stamped from a template for every event in the
25582
- * system, so "the plane is up" was being served as "there are bytes": 64 of
25583
- * one camera's 179 clips pointed at a 404 (device 3836, 2026-08-17). This
25584
- * is the question that turns the stamp into a claim.
25585
- *
25586
- * It is on the WIRE because the clip source is registered by the addon that
25587
- * owns the FOOTAGE, not by this one (D560) — the probe used to be an
25588
- * in-process `MediaStore` read. One call per OWNER KIND, never one per
25589
- * owner: that N+1 is what `MediaStore.ownersWithMedia` was written to
25590
- * prevent, and crossing a process boundary makes it worse, not better.
25591
- * `ownerIds` is bounded at the same 5 000 the annotation fetch is bounded
25592
- * at, so one pathological camera-day cannot mint an unbounded request.
25593
- *
25594
- * THROWS rather than answering partially. A probe that quietly
25595
- * under-reports reads as "these owners have nothing" and the caller drops
25596
- * thumbnails that exist — the opposite failure to the one above, and
25597
- * equally invisible.
25598
- *
25599
- * `deviceId` is the authorization subject, exactly as on `getEventMedia`.
25938
+ * Release a cached frame from the Python pool's memory.
25600
25939
  */
25601
- ownersWithMedia: method(object({
25602
- deviceId: number(),
25603
- ownerKind: MediaPresenceOwnerKindSchema,
25604
- ownerIds: array(string()).max(5e3)
25605
- }), array(string()).readonly()),
25940
+ uncacheFrame: method(object({ frameId: number().int() }), _void(), { kind: "mutation" }),
25606
25941
  /**
25607
- * Search object events by text query using CLIP cosine similarity.
25608
- * Encodes `text` via the `embedding-encoder` cap, queries the
25609
- * `ObjectEmbeddingStore` with optional prefilters, ranks all matching
25610
- * embeddings by cosine similarity, and joins winners to their
25611
- * ObjectEvents by trackId. Returns up to `limit` events scored ≥
25612
- * `minScore`, sorted descending by score.
25942
+ * The effective provisioning of ONE pool of this node (operator override →
25943
+ * the pool's own runtime row). `deviceKey` names the device pool; absent is
25944
+ * the node-default pool. It answered only for the node default until
25945
+ * D646, so a benchmark on `openvino:npu` recorded the onnx pool's tuning
25946
+ * beside an NPU measurement.
25613
25947
  */
25614
- searchObjectEvents: method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()),
25615
- wipeObjectEmbeddings: method(object({}), WipeObjectEmbeddingsResultSchema, {
25948
+ getEffectiveTuning: method(object({ deviceKey: string().optional() }), EffectiveTuningSchema),
25949
+ /**
25950
+ * List every EngineFactory currently loaded in this executor's RAM,
25951
+ * with the models resident and a coarse "in use" marker derived from
25952
+ * ongoing inference activity. Used by the Pipeline page Engines tab.
25953
+ */
25954
+ listLoadedEngines: method(_void(), array(object({
25955
+ engineKey: string(),
25956
+ engine: PipelineEngineChoiceSchema,
25957
+ modelsLoaded: array(string()).readonly(),
25958
+ inUseByCameras: array(number()).readonly(),
25959
+ /**
25960
+ * Origin of this resident factory.
25961
+ * - `runtime` — main camera-serving engine (no idle TTL).
25962
+ * - `device-pool` — a concurrent per-device pool (Phase 2
25963
+ * multi-device, keyed by `deviceKey`) resolved
25964
+ * via `resolveDeviceFactory`. Runs alongside the
25965
+ * `runtime` engine on a DIFFERENT accelerator
25966
+ * (NPU / iGPU / Coral) — this is how the
25967
+ * Engines tab shows all pools running at once.
25968
+ */
25969
+ kind: _enum(["runtime", "device-pool"]),
25970
+ /** Native pid of the underlying Python pool (null when no pool). */
25971
+ poolPid: number().nullable(),
25972
+ /** ms since this factory was last used (null when not warm-tracked). */
25973
+ idleMs: number().nullable(),
25974
+ /** Idle TTL after which the factory self-evicts (null when not applicable). */
25975
+ idleTtlMs: number().nullable()
25976
+ })).readonly()),
25977
+ /** Warm up an engine without running a frame. No-op if already loaded. */
25978
+ spinEngine: method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
25616
25979
  kind: "mutation",
25617
25980
  auth: "admin"
25618
25981
  }),
25619
- rebuildObjectEmbeddings: method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
25982
+ /**
25983
+ * Unload an engine from RAM. `force:true` unloads even when cameras
25984
+ * are actively using it (they re-spin on next frame). Default is
25985
+ * gated — returns `{success:false, reason}` when in use.
25986
+ */
25987
+ killEngine: method(object({
25988
+ engine: PipelineEngineChoiceSchema,
25989
+ force: boolean().optional()
25990
+ }), object({
25991
+ success: boolean(),
25992
+ reason: string().optional()
25993
+ }), {
25620
25994
  kind: "mutation",
25621
25995
  auth: "admin"
25622
25996
  }),
25623
- getObjectEmbeddingRebuildStatus: method(object({}), RebuildStatusSchema)
25624
- },
25625
- events: {
25626
- /**
25627
- * Enriched frame emitted after refinement — the live-overlay source of
25628
- * truth (two-plane re-injection). Carries the frame's detections in the
25629
- * `ObjectDetection` wire shape: first-level roots (with track info +
25630
- * enrichment labels) plus synthesized `kind:'detail'` face/plate entries
25631
- * re-projected from per-track detail state, so stream overlays render
25632
- * boxes + recognized names without querying full Track state.
25633
- */
25634
- onFrameTracked: { data: object({
25635
- deviceId: number(),
25636
- timestamp: number(),
25637
- frameWidth: number(),
25638
- frameHeight: number(),
25639
- detections: array(OverlayDetectionSchema).readonly()
25640
- }) },
25641
- /** Track entered active state (first-seen). */
25642
- onTrackStarted: { data: object({
25643
- deviceId: number(),
25644
- trackId: string(),
25645
- className: string()
25646
- }) },
25647
- /** Track expired (TTL reached after last detection). */
25648
- onTrackEnded: { data: object({
25649
- deviceId: number(),
25650
- trackId: string(),
25651
- className: string(),
25652
- durationMs: number()
25653
- }) },
25654
- /** Canonical "something happened at device X" event, per-kind. */
25655
- onDetectionEvent: { data: object({
25656
- deviceId: number(),
25657
- kind: EventKindSchema,
25658
- eventId: string(),
25659
- timestamp: number()
25660
- }) }
25997
+ listReferenceImages: method(_void(), array(ReferenceImageEntrySchema).readonly()),
25998
+ getReferenceImage: method(object({ filename: string() }), ReferenceImageBodySchema.nullable()),
25999
+ getReferenceAudioFiles: method(_void(), array(ReferenceAudioEntrySchema).readonly()),
26000
+ getReferenceAudio: method(object({ filename: string() }), ReferenceAudioBodySchema.nullable()),
26001
+ getAudioCapabilities: method(_void(), AudioCapabilitiesSchema),
26002
+ runAudioTest: method(object({
26003
+ addonId: string(),
26004
+ modelId: string(),
26005
+ filename: string().optional(),
26006
+ settings: record(string(), unknown()).optional()
26007
+ }), AudioTestResultSchema, { kind: "mutation" }),
26008
+ getDetectionConfigSchema: method(_void(), ConfigUISchemaNullableBridge)
25661
26009
  }
25662
26010
  };
25663
26011
  object({
@@ -25685,6 +26033,106 @@ var CameraMetricsSchema = object({
25685
26033
  });
25686
26034
  var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
25687
26035
  /**
26036
+ * Zone — pure geometry + identity. NO filtering behaviour.
26037
+ *
26038
+ * Zones describe **where** in the frame the operator wants to flag
26039
+ * something; consumer-owned {@link ZoneRule} arrays describe **how**
26040
+ * each pipeline stage uses them. Splitting the two means a single
26041
+ * polygon "Driveway" can simultaneously back a motion-exclude rule,
26042
+ * a detection-include rule on `['car']`, and an occupancy aggregate
26043
+ * — without three duplicated polygons.
26044
+ *
26045
+ * Owned by the orchestrator addon (provider) and mirrored into the
26046
+ * `zones` device-state slice on every mutation. Consumers
26047
+ * (motion-wasm, pipeline-executor, analytics, admin UI) read either
26048
+ * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
26049
+ * mirror with `onChanged`).
26050
+ *
26051
+ * Coordinates are normalised fractions of the frame (0–1) so zones
26052
+ * survive resolution changes and stream profile switches.
26053
+ *
26054
+ * `kind` discriminates between full polygons (closed regions used
26055
+ * for intrusion / occupancy filters) and tripwires (open 2-point
26056
+ * line segments used for cross events). Onboard / firmware-reported
26057
+ * zones (Reolink, ONVIF) are out of scope for now — see the deferred
26058
+ * task list.
26059
+ */
26060
+ var ZoneKindEnum = _enum(["polygon", "tripwire"]);
26061
+ /** Polygon vertex in fraction-of-frame coordinates (0–1). */
26062
+ var PolygonPointSchema = object({
26063
+ x: number(),
26064
+ y: number()
26065
+ });
26066
+ /** A camera detection zone — pure geometry/identity. */
26067
+ var ZoneSchema = object({
26068
+ id: string(),
26069
+ name: string(),
26070
+ kind: ZoneKindEnum.default("polygon"),
26071
+ /** Polygon vertices, fraction of frame (0–1). */
26072
+ polygon: array(PolygonPointSchema).readonly(),
26073
+ /** Visual color for UI rendering. */
26074
+ color: string().default("#3b82f6")
26075
+ });
26076
+ /**
26077
+ * Zones capability — per-camera CRUD over polygon detection zones.
26078
+ *
26079
+ * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
26080
+ * to per-device settings and mirrors into the `zones` device-state
26081
+ * slice on every mutation, so downstream consumers can subscribe via
26082
+ * `dev.state.zones.onChanged`.
26083
+ *
26084
+ * The cap surface only handles geometry + identity; filtering
26085
+ * behaviour (per-class, include/exclude, threshold) lives in the
26086
+ * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
26087
+ * `capabilities/schemas/zone-rule.js`.
26088
+ */
26089
+ var zonesCapability = {
26090
+ name: "zones",
26091
+ scope: "device",
26092
+ mode: "singleton",
26093
+ deviceTypes: [DeviceType.Camera],
26094
+ methods: {
26095
+ listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
26096
+ addZone: method(object({
26097
+ deviceId: number(),
26098
+ zone: ZoneSchema
26099
+ }), _void(), {
26100
+ kind: "mutation",
26101
+ auth: "admin"
26102
+ }),
26103
+ removeZone: method(object({
26104
+ deviceId: number(),
26105
+ zoneId: string()
26106
+ }), _void(), {
26107
+ kind: "mutation",
26108
+ auth: "admin"
26109
+ }),
26110
+ updateZone: method(object({
26111
+ deviceId: number(),
26112
+ zone: ZoneSchema
26113
+ }), _void(), {
26114
+ kind: "mutation",
26115
+ auth: "admin"
26116
+ })
26117
+ },
26118
+ /**
26119
+ * Runtime-state slice — the live zone catalogue mirrored by the
26120
+ * orchestrator on every CRUD mutation. Consumers read via
26121
+ * `device.state.zones.value` / `.watch(...)` without round-tripping
26122
+ * the cap, and the codegen DeviceProxy auto-wires the reactive
26123
+ * handle. Slice shape is `{ zones: Zone[] }` so future extensions
26124
+ * (e.g. zone groupings) can sit alongside the polygon list.
26125
+ */
26126
+ runtimeState: object({ zones: array(ZoneSchema).readonly() }),
26127
+ /**
26128
+ * Runtime-state durability: **restored** — written only on operator mutation, so a camera that never had one has nothing to re-derive from. This is the slice `zone-mirror-hydration.ts` exists to paper over.
26129
+ *
26130
+ * See `RuntimeStateDurability`. Enforced by
26131
+ * `scripts/check-runtime-state-durability.ts`.
26132
+ */
26133
+ durability: "restored"
26134
+ };
26135
+ /**
25688
26136
  * A bounding box in NORMALIZED [0,1] frame coordinates for `getNativeCrop`. The
25689
26137
  * decode worker resolves it against the RETAINED native frame's real pixel dims,
25690
26138
  * so the caller supplies only the detection-res bbox divided by the detection
@@ -25871,7 +26319,17 @@ var DetailResultSchema = object({
25871
26319
  /** Face short side (px) measured on the NATIVE crop surface. The `bbox`
25872
26320
  * above is detection-frame px (≈6× smaller on a 4K camera) — min-face-size
25873
26321
  * consumers MUST prefer this when present (2026-07-22 native-gate fix). */
25874
- nativeFaceShortSidePx: number().optional()
26322
+ nativeFaceShortSidePx: number().optional(),
26323
+ /**
26324
+ * The five facial landmarks of a `face` detail, in the SAME frame space as
26325
+ * `bbox` (D644). Additive and optional: post-analysis stores them beside the
26326
+ * face's source frame so a future alignment can be re-derived exactly; a
26327
+ * runner that predates the field sends none and the face is stored without.
26328
+ */
26329
+ landmarks: array(object({
26330
+ x: number(),
26331
+ y: number()
26332
+ })).optional()
25875
26333
  });
25876
26334
  /**
25877
26335
  * Why an executing node REFUSED a stateless step run (`runStatelessStep`).
@@ -26126,6 +26584,17 @@ var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal
26126
26584
  hubHostnameOverride: string().optional()
26127
26585
  })]).describe("Per-camera frame-source mode for the runner (P2c)");
26128
26586
  /**
26587
+ * What ONE step runs with on ONE roster device for THIS camera (D650): the
26588
+ * device's per-(node,device) base with the camera's override for that device
26589
+ * on top — the same `override ?? base` merge the orchestrator applies to the
26590
+ * elected device (`applyDeviceProvisioning`). Absent `modelId` ⇒ the executor
26591
+ * resolves the device format's default, exactly as on the elected device.
26592
+ */
26593
+ var RunnerJumpStepProvisioningSchema = object({
26594
+ modelId: string().optional(),
26595
+ settings: record(string(), unknown()).optional()
26596
+ });
26597
+ /**
26129
26598
  * One ENABLED inference device on the runner's node, as the step-tree
26130
26599
  * device-jump resolver sees it (phase 1). The orchestrator populates this
26131
26600
  * roster on the attach payload whenever the camera is elected onto a specific
@@ -26137,7 +26606,16 @@ var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal
26137
26606
  var RunnerInferenceDeviceSchema = object({
26138
26607
  deviceKey: string(),
26139
26608
  weight: number().positive().default(1),
26140
- maxSessions: number().int().positive().nullable().default(null)
26609
+ maxSessions: number().int().positive().nullable().default(null),
26610
+ /**
26611
+ * Per-step provisioning for this camera on THIS device (D650), keyed by step
26612
+ * id. A step the runner jumps here runs with these fields, never with the
26613
+ * elected device's: `modelId` / `settings` are REPLACED on the jumped subtree
26614
+ * (a step absent from the map runs with neither — the target format default).
26615
+ * Absent field ⇒ an orchestrator that predates D650: the jumped step keeps
26616
+ * the elected device's provisioning, as before.
26617
+ */
26618
+ steps: record(string(), RunnerJumpStepProvisioningSchema).optional()
26141
26619
  });
26142
26620
  /**
26143
26621
  * Camera assignment payload sent by `addon-pipeline-orchestrator` to a
@@ -27204,6 +27682,28 @@ var NodeInferenceDeviceSchema = object({
27204
27682
  */
27205
27683
  exclusion: InferenceDeviceExclusionReasonSchema.nullable()
27206
27684
  });
27685
+ /**
27686
+ * The operator's model choice for one cluster-scoped step, answered by the
27687
+ * addon that OWNS the `clusterModel:*` settings (D651). Three answers, never
27688
+ * folded: a written choice, a key nobody wrote (the cluster runs the default
27689
+ * BY ABSENCE), or no answer. A caller that rewrites an index acts only on the
27690
+ * first two, read twice and agreeing.
27691
+ */
27692
+ var ClusterModelChoiceSchema = discriminatedUnion("kind", [
27693
+ object({
27694
+ kind: literal("stored"),
27695
+ modelId: string()
27696
+ }),
27697
+ object({
27698
+ kind: literal("absent"),
27699
+ defaultModelId: string()
27700
+ }),
27701
+ object({
27702
+ kind: literal("unreadable"),
27703
+ reason: _enum(CLUSTER_MODEL_CHOICE_UNREADABLE_REASONS),
27704
+ error: string().optional()
27705
+ })
27706
+ ]);
27207
27707
  var NodeInferenceDevicesSchema = object({
27208
27708
  nodeId: string(),
27209
27709
  /** False when the node's platform-probe was unreachable (no live device set). */
@@ -27300,9 +27800,19 @@ var pipelineOrchestratorCapability = {
27300
27800
  * Trigger a full rebalance pass. Iterates over all assigned cameras,
27301
27801
  * recomputes the optimal agent for each one based on current load +
27302
27802
  * hardware affinity, and migrates cameras whose current agent is no
27303
- * longer optimal. Pinned cameras are never migrated.
27304
- */
27305
- rebalance: method(_void(), object({ migrated: number() }), {
27803
+ * longer optimal. Pinned cameras are never migrated. `skipped` names the
27804
+ * cameras the pass wanted to move and could not, with why — a target node
27805
+ * that has not answered its catalog / device health yet, or a device that
27806
+ * cannot run the camera's root (D650).
27807
+ */
27808
+ rebalance: method(_void(), object({
27809
+ migrated: number(),
27810
+ skipped: array(object({
27811
+ deviceId: number(),
27812
+ targetNodeId: string(),
27813
+ reason: string()
27814
+ })).default([])
27815
+ }), {
27306
27816
  kind: "mutation",
27307
27817
  auth: "admin"
27308
27818
  }),
@@ -27312,6 +27822,13 @@ var pipelineOrchestratorCapability = {
27312
27822
  getPipelineAssignment: method(object({ deviceId: number() }), PipelineAssignmentSchema.nullable()),
27313
27823
  /** Get per-agent load summaries used by the load balancer + dashboards. */
27314
27824
  getAgentLoad: method(_void(), array(AgentLoadSummarySchema).readonly()),
27825
+ /**
27826
+ * The operator's STORED model choice for one cluster-scoped step (D651).
27827
+ * Read three-way from this addon's own store, only once its boot has
27828
+ * settled. Unlike `addonSettings.getGlobalSettings`, it never answers a
27829
+ * default as though someone chose it.
27830
+ */
27831
+ getClusterModelChoice: method(object({ stepId: string() }), ClusterModelChoiceSchema),
27315
27832
  /** Aggregate global metrics across the whole detection cluster. */
27316
27833
  getGlobalMetrics: method(_void(), GlobalMetricsSchema),
27317
27834
  /**
@@ -30572,6 +31089,277 @@ var videoclipsCapability = {
30572
31089
  }
30573
31090
  };
30574
31091
  /**
31092
+ * LA tabella "quale booleano di questo tipo di device conta come ALTO", e il
31093
+ * valutatore puro del suo FRONTE.
31094
+ *
31095
+ * Viveva dentro il builtin virtual-doorbell
31096
+ * (`@camstack/system` — `builtins/doorbell/trigger-engine.ts`) e i suoi
31097
+ * predicati erano privati al modulo. Il recorder ne ha bisogno per il trigger
31098
+ * `RecordingTriggers.sensorDeviceIds`: copiarla avrebbe creato la SECONDA
31099
+ * tabella, che diverge alla prima cap aggiunta e il cui sintomo — "il sensore
31100
+ * fa suonare il campanello ma non registra" — è esattamente D62. Quindi si
31101
+ * SPOSTA qui e il doorbell la ri-esporta.
31102
+ *
31103
+ * ⚠ NON è `DEVICE_STATE_READERS` (`catalogs/device-state-vocabulary.ts`), e le
31104
+ * due non vanno unificate: quella risponde a "qual è la PAROLA di stato per una
31105
+ * regola" (e include `presence`, `cover`, `alarm-panel`), questa a "qual è il
31106
+ * booleano il cui FRONTE conta". Vocabolari deliberatamente diversi.
31107
+ */
31108
+ /**
31109
+ * Known binary / switch source caps → the boolean slice field whose
31110
+ * false→true rise counts as ACTIVE. Every entry is "fire on active".
31111
+ * Sensors whose "active" reading is not a plain boolean (presence's string
31112
+ * state, connectivity's connected flag) are deliberately excluded — a
31113
+ * reconnect is not a doorbell press, and it is not a recording either.
31114
+ */
31115
+ var SOURCE_CAP_ACTIVE_FIELD = {
31116
+ contact: "entryOpen",
31117
+ binary: "on",
31118
+ switch: "on",
31119
+ motion: "detected",
31120
+ flood: "flooded",
31121
+ gas: "detected",
31122
+ smoke: "detected",
31123
+ "carbon-monoxide": "detected",
31124
+ vibration: "detected",
31125
+ tamper: "tampered"
31126
+ };
31127
+ /** Cap names whose presence in a device's bindings qualify it as a source. */
31128
+ var SOURCE_CAPS = Object.keys(SOURCE_CAP_ACTIVE_FIELD);
31129
+ /**
31130
+ * Doorbell button cap. Two kinds of providers coexist behind this cap
31131
+ * name (same pattern as `snapshot`):
31132
+ *
31133
+ * - **Native** providers: registered per-device by device-driver
31134
+ * addons via `ctx.registerNativeCap` — either on a
31135
+ * `DeviceType.Button` accessory with `role: DeviceRole.Doorbell`,
31136
+ * or directly on the camera (Reolink registers at camera level).
31137
+ * Emits an `onPressed` event every time the firmware pushes a
31138
+ * ring; status tracks the last press and a pressCount since start
31139
+ * (diagnostic).
31140
+ *
31141
+ * - **Wrapper** provider: the `virtual-doorbell` system builtin
31142
+ * (`@camstack/system/builtins/doorbell`). Turns ANY binary-ish
31143
+ * device (contact / switch / event-emitter …) into a doorbell for
31144
+ * a camera. `defaultActive: false` — the operator explicitly binds
31145
+ * it per camera in the device-bindings UI, then picks the source
31146
+ * device + trigger in the per-device settings.
31147
+ *
31148
+ * The DeviceEventPropagator re-emits `onPressed` on the camera parent
31149
+ * — subscribers listening at the camera level receive ring events
31150
+ * with `via[]` populated. No code on the parent needed.
31151
+ */
31152
+ var DoorbellStatusSchema = object({
31153
+ /** Ms epoch of the last press. null = never observed since this provider started. */
31154
+ lastPressedAt: number().nullable(),
31155
+ /** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
31156
+ pressCountSinceStart: number()
31157
+ });
31158
+ var DoorbellPressEventSchema = object({
31159
+ deviceId: number(),
31160
+ timestamp: number()
31161
+ });
31162
+ /**
31163
+ * The `doorbell-source` extension slot's editable value (D648): the camera's
31164
+ * virtual-doorbell trigger devices, exactly what the wrapper's
31165
+ * `doorbellSources` persists (as `{ deviceId }` records).
31166
+ */
31167
+ var DoorbellSourceSlotValueSchema = object({ deviceIds: array(number().int().positive()) });
31168
+ /**
31169
+ * The `doorbell-source` slot — which devices ring this camera's VIRTUAL
31170
+ * doorbell, owned by the `virtual-doorbell` wrapper over its
31171
+ * `doorbellSources` store (D648). A source rings when one of its
31172
+ * `SOURCE_CAPS` rises. Whether the wrapper is bound to the camera at all is a
31173
+ * different authority (`deviceManager.setWrapperActive`, D62) — the slot
31174
+ * reports it, it never writes it.
31175
+ */
31176
+ var DOORBELL_SOURCE_SLOT = {
31177
+ id: "doorbell-source",
31178
+ label: "Doorbell trigger devices",
31179
+ description: "Any of these becoming active rings this camera's virtual doorbell: a binary sensor when it goes active, a switch when it turns on.",
31180
+ shape: "association",
31181
+ hostDeviceTypes: [DeviceType.Camera],
31182
+ sourceCaps: SOURCE_CAPS,
31183
+ cardinality: "many",
31184
+ value: DoorbellSourceSlotValueSchema
31185
+ };
31186
+ var doorbellCapability = {
31187
+ name: "doorbell",
31188
+ scope: "device",
31189
+ deviceNative: true,
31190
+ mode: "singleton",
31191
+ kind: "wrapper",
31192
+ defaultActive: false,
31193
+ deviceTypes: [DeviceType.Button, DeviceType.Camera],
31194
+ exposesDeviceSettings: true,
31195
+ extensionSlots: [DOORBELL_SOURCE_SLOT],
31196
+ methods: {},
31197
+ events: {
31198
+ /**
31199
+ * Fires once per physical press. Reolink delivers via Baichuan
31200
+ * push (`ReolinkSimpleEvent.type === 'doorbell'`). There is no
31201
+ * release/duration — it's a pulse.
31202
+ */
31203
+ onPressed: { data: DoorbellPressEventSchema } },
31204
+ status: {
31205
+ schema: DoorbellStatusSchema,
31206
+ kind: "push"
31207
+ },
31208
+ /**
31209
+ * Runtime-state slice — last press timestamp + lifetime press count.
31210
+ * Mirrored by the kernel and readable via
31211
+ * `device.state.doorbell.value`. UIs can show "last ring 5m ago"
31212
+ * without subscribing.
31213
+ */
31214
+ runtimeState: DoorbellStatusSchema,
31215
+ /**
31216
+ * Runtime-state durability: **restored** — a monotonic accumulator: the slice IS the record. `lastPressedAt` is content here, not a clock, so it is deliberately NOT volatile.
31217
+ *
31218
+ * See `RuntimeStateDurability`. Enforced by
31219
+ * `scripts/check-runtime-state-durability.ts`.
31220
+ */
31221
+ durability: "restored"
31222
+ };
31223
+ var ExtensionSlotIdSchema = _enum(["doorbell-source", "linked-devices"]);
31224
+ DeviceType.Camera, DeviceType.Camera;
31225
+ /** A slot's editable value, discriminated on `slot`. */
31226
+ var ExtensionSlotValueSchema = discriminatedUnion("slot", [DoorbellSourceSlotValueSchema.extend({ slot: literal("doorbell-source") }), LinkedDevicesSlotValueSchema.extend({ slot: literal("linked-devices") })]);
31227
+ /** Every device type at least one slot is offered on — `device-extension`'s `deviceTypes`. */
31228
+ var EXTENSION_HOST_DEVICE_TYPES = [DeviceType.Camera];
31229
+ var ExtensionSourceAvailabilitySchema = discriminatedUnion("state", [object({ state: literal("ok") }), object({
31230
+ state: literal("unreachable"),
31231
+ reason: string()
31232
+ })]);
31233
+ /** One provider of slots — the D554 source-listing row. */
31234
+ var ExtensionSourceSchema = object({
31235
+ /** The routing prefix of every `slotRef` this provider serves. */
31236
+ source: string(),
31237
+ label: string(),
31238
+ /** Stamped by the dispatcher from the registry (D557). */
31239
+ addonId: string().optional(),
31240
+ availability: ExtensionSourceAvailabilitySchema
31241
+ });
31242
+ /**
31243
+ * How one picked source stands. `missing` — no such device (deleted, or an id
31244
+ * that never existed); `foreign` — a device the slot's owner cannot read from
31245
+ * (slice 2's cross-owner graft source); `unavailable` — it exists but is not a
31246
+ * valid source now (a container, which is never a pick). A source in any of
31247
+ * these states is SHOWN, never silently dropped or re-pointed.
31248
+ */
31249
+ var ExtensionSourceHealthSchema = _enum([
31250
+ "ok",
31251
+ "missing",
31252
+ "foreign",
31253
+ "unavailable"
31254
+ ]);
31255
+ var ExtensionSlotSourceSchema = object({
31256
+ deviceId: number().int(),
31257
+ /** The device's name, or null when it could not be resolved (`missing`). */
31258
+ name: string().nullable(),
31259
+ health: ExtensionSourceHealthSchema,
31260
+ detail: string().optional()
31261
+ });
31262
+ /**
31263
+ * A DIFFERENT authority that gates whether the slot's sources do anything —
31264
+ * reported read-only, named, never written through this contract (D62). The
31265
+ * virtual doorbell's sources ring only while the wrapper is bound to the
31266
+ * camera, and that binding belongs to `deviceManager.setWrapperActive`.
31267
+ * `unknown` means the gate could not be read; it is not "inactive" (D315).
31268
+ */
31269
+ var ExtensionSlotActivationSchema = object({
31270
+ state: _enum([
31271
+ "active",
31272
+ "inactive",
31273
+ "unknown"
31274
+ ]),
31275
+ authority: string(),
31276
+ detail: string().optional()
31277
+ });
31278
+ var ExtensionSlotRowSchema = discriminatedUnion("state", [object({
31279
+ state: literal("ok"),
31280
+ /** `<source>:<slotId>` — the routing key for `listCandidates` / `setSlot`. */
31281
+ slotRef: string(),
31282
+ slot: ExtensionSlotIdSchema,
31283
+ /** Names the store written (D62), e.g. `virtual-doorbell:doorbellSources`. */
31284
+ authority: string(),
31285
+ /** graft: its switch. association: null — removing every source is "off". */
31286
+ enabled: boolean().nullable(),
31287
+ /** graft: the cap registered on the host. association: null. */
31288
+ projects: string().nullable(),
31289
+ activation: ExtensionSlotActivationSchema.nullable(),
31290
+ value: ExtensionSlotValueSchema,
31291
+ sources: array(ExtensionSlotSourceSchema)
31292
+ }), object({
31293
+ state: literal("unreachable"),
31294
+ addonId: string(),
31295
+ reason: string()
31296
+ })]);
31297
+ var ExtensionCandidatesSchema = object({ candidates: array(object({
31298
+ deviceId: number().int(),
31299
+ name: string(),
31300
+ type: string(),
31301
+ location: string().nullable(),
31302
+ /** The container a child belongs to — "Spotlight 2" alone does not say which. */
31303
+ parentName: string().nullable(),
31304
+ /** Pre-marked by the owner's suggestion rule. NEVER saved on its own (D356). */
31305
+ suggested: boolean(),
31306
+ /** Why it is suggested ("same location"), null when it is not. */
31307
+ reason: string().nullable()
31308
+ })) });
31309
+ /**
31310
+ * What a write did. `none` — applied in place. `host` / `parent` — the owner
31311
+ * reloaded the host (or, for an accessory child, its parent) because the
31312
+ * write changed what the host REGISTERS (a graft switched on or off, slice 2).
31313
+ */
31314
+ var ExtensionSetResultSchema = object({
31315
+ applied: literal(true),
31316
+ reload: _enum([
31317
+ "none",
31318
+ "host",
31319
+ "parent"
31320
+ ])
31321
+ });
31322
+ var ExtensionSlotRefInputSchema = object({
31323
+ deviceId: number().int(),
31324
+ slotRef: string().min(1)
31325
+ });
31326
+ var ExtensionSetSlotInputSchema = ExtensionSlotRefInputSchema.extend({ value: ExtensionSlotValueSchema });
31327
+ var deviceExtensionCapability = {
31328
+ name: "device-extension",
31329
+ scope: "device",
31330
+ mode: "collection",
31331
+ kind: "wrapper",
31332
+ defaultActive: true,
31333
+ deviceTypes: EXTENSION_HOST_DEVICE_TYPES,
31334
+ deviceConfig: { ui: {
31335
+ kind: "widget",
31336
+ widgetId: "host/extensions-panel",
31337
+ tab: "general",
31338
+ label: "Extensions",
31339
+ order: 72
31340
+ } },
31341
+ methods: {
31342
+ /** One row per slot owner — the D554 source listing `slotRef` routes by. */
31343
+ listSources: method(object({ deviceId: number().int() }), array(ExtensionSourceSchema)),
31344
+ /**
31345
+ * Every slot this device is offered, read by each owner from its own
31346
+ * store. A provider that throws is ONE `unreachable` row (D554.4).
31347
+ */
31348
+ listSlots: method(object({ deviceId: number().int() }), array(ExtensionSlotRowSchema)),
31349
+ /** The devices the slot's editor may offer, suggestions pre-marked (D356). */
31350
+ listCandidates: method(ExtensionSlotRefInputSchema, ExtensionCandidatesSchema),
31351
+ /**
31352
+ * Write one slot through its owner's EXISTING write path. The owner
31353
+ * validates (a container is never a linked device, a camera is never its
31354
+ * own source) and refuses by name before persisting.
31355
+ */
31356
+ setSlot: method(ExtensionSetSlotInputSchema, ExtensionSetResultSchema, {
31357
+ kind: "mutation",
31358
+ auth: "admin"
31359
+ })
31360
+ }
31361
+ };
31362
+ /**
30575
31363
  * Optional client-side hints sent at session creation to help the provider
30576
31364
  * pick the best native source. All fields optional — a viewer that knows
30577
31365
  * nothing still gets a sane default. (Relocated from the retired `webrtc`
@@ -33015,12 +33803,20 @@ reset: method(object({
33015
33803
  },
33016
33804
  runtimeState: ConsumablesStatusSchema.extend({ lastFetchedAt: number() }),
33017
33805
  /**
33018
- * Runtime-state durability: **session** — the authority is the appliance; the provider re-reads the whole item array on connect.
33806
+ * Runtime-state durability: **restored** — nothing else holds the value
33807
+ * (D642). A consumable can often be read only in a device's wake window (the
33808
+ * Dreame mower's CMS counters answer only while it charges), so a restart
33809
+ * that wiped the slice left the panel empty and the alerts blind until the
33810
+ * next wake — 2026-09-26, mower 503 idle with `items: []`. A restored item is
33811
+ * the previous observation, not a claim about now; the provider overwrites it
33812
+ * the moment it reads the device again.
33019
33813
  *
33020
33814
  * See `RuntimeStateDurability`. Enforced by
33021
33815
  * `scripts/check-runtime-state-durability.ts`.
33022
33816
  */
33023
- durability: "session"
33817
+ durability: "restored",
33818
+ /** Clocks, not content: a re-read that changed no item costs no commit. */
33819
+ volatileStateFields: ["lastChangedAt", "lastFetchedAt"]
33024
33820
  };
33025
33821
  /**
33026
33822
  * Door / window / opening / garage / valve contact sensor. Boolean
@@ -33409,75 +34205,6 @@ onStatusChanged: { data: object({
33409
34205
  volatileStateFields: ["lastChangedAt"]
33410
34206
  };
33411
34207
  /**
33412
- * Doorbell button cap. Two kinds of providers coexist behind this cap
33413
- * name (same pattern as `snapshot`):
33414
- *
33415
- * - **Native** providers: registered per-device by device-driver
33416
- * addons via `ctx.registerNativeCap` — either on a
33417
- * `DeviceType.Button` accessory with `role: DeviceRole.Doorbell`,
33418
- * or directly on the camera (Reolink registers at camera level).
33419
- * Emits an `onPressed` event every time the firmware pushes a
33420
- * ring; status tracks the last press and a pressCount since start
33421
- * (diagnostic).
33422
- *
33423
- * - **Wrapper** provider: the `virtual-doorbell` system builtin
33424
- * (`@camstack/system/builtins/doorbell`). Turns ANY binary-ish
33425
- * device (contact / switch / event-emitter …) into a doorbell for
33426
- * a camera. `defaultActive: false` — the operator explicitly binds
33427
- * it per camera in the device-bindings UI, then picks the source
33428
- * device + trigger in the per-device settings.
33429
- *
33430
- * The DeviceEventPropagator re-emits `onPressed` on the camera parent
33431
- * — subscribers listening at the camera level receive ring events
33432
- * with `via[]` populated. No code on the parent needed.
33433
- */
33434
- var DoorbellStatusSchema = object({
33435
- /** Ms epoch of the last press. null = never observed since this provider started. */
33436
- lastPressedAt: number().nullable(),
33437
- /** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
33438
- pressCountSinceStart: number()
33439
- });
33440
- var DoorbellPressEventSchema = object({
33441
- deviceId: number(),
33442
- timestamp: number()
33443
- });
33444
- var doorbellCapability = {
33445
- name: "doorbell",
33446
- scope: "device",
33447
- deviceNative: true,
33448
- mode: "singleton",
33449
- kind: "wrapper",
33450
- defaultActive: false,
33451
- deviceTypes: [DeviceType.Button, DeviceType.Camera],
33452
- exposesDeviceSettings: true,
33453
- methods: {},
33454
- events: {
33455
- /**
33456
- * Fires once per physical press. Reolink delivers via Baichuan
33457
- * push (`ReolinkSimpleEvent.type === 'doorbell'`). There is no
33458
- * release/duration — it's a pulse.
33459
- */
33460
- onPressed: { data: DoorbellPressEventSchema } },
33461
- status: {
33462
- schema: DoorbellStatusSchema,
33463
- kind: "push"
33464
- },
33465
- /**
33466
- * Runtime-state slice — last press timestamp + lifetime press count.
33467
- * Mirrored by the kernel and readable via
33468
- * `device.state.doorbell.value`. UIs can show "last ring 5m ago"
33469
- * without subscribing.
33470
- */
33471
- runtimeState: DoorbellStatusSchema,
33472
- /**
33473
- * Runtime-state durability: **restored** — a monotonic accumulator: the slice IS the record. `lastPressedAt` is content here, not a clock, so it is deliberately NOT volatile.
33474
- *
33475
- * See `RuntimeStateDurability`. Enforced by
33476
- * `scripts/check-runtime-state-durability.ts`.
33477
- */
33478
- durability: "restored"
33479
- };
33480
- /**
33481
34208
  * Enum-state sensor — a string value picked from a finite option set.
33482
34209
  * Drives HA `sensor` entries with `state_class: enum` (HVAC action
33483
34210
  * states, weather conditions, contact-source channels, mode strings).
@@ -37893,7 +38620,7 @@ var HardwareInfoSchema = object({
37893
38620
  coral: CoralInfoSchema.nullable().optional()
37894
38621
  });
37895
38622
  var PlatformScoreSchema = object({
37896
- runtime: _enum(["node", "python"]),
38623
+ runtime: literal("python"),
37897
38624
  backend: string(),
37898
38625
  format: _enum([
37899
38626
  "onnx",
@@ -37930,7 +38657,7 @@ var ModelRequirementSchema = object({
37930
38657
  });
37931
38658
  var ResolvedInferenceConfigSchema = object({
37932
38659
  modelId: string(),
37933
- runtime: _enum(["node", "python"]),
38660
+ runtime: literal("python"),
37934
38661
  backend: string(),
37935
38662
  format: ModelFormatSchema,
37936
38663
  reason: string()
@@ -40937,6 +41664,92 @@ var sceneMonitorCapability = {
40937
41664
  durability: "session"
40938
41665
  };
40939
41666
  /**
41667
+ * Per-stage gating mode applied to the zones a rule references.
41668
+ *
41669
+ * - `include`: the rule contributes to a **whitelist** for its stage.
41670
+ * When at least one `include` rule fires for a stage, only entities
41671
+ * inside one of those zones pass that stage.
41672
+ * - `exclude`: the rule contributes to a **blacklist** for its stage.
41673
+ * Entities inside one of those zones are dropped at that stage.
41674
+ *
41675
+ * `monitor`-style observation (count without filtering) is not a rule
41676
+ * mode — zones without any matching rule are observed naturally by
41677
+ * `zone-analytics` (live snapshot + history), so an "I just want to
41678
+ * count, not filter" use case needs no rule at all.
41679
+ */
41680
+ var ZoneRuleModeEnum = _enum(["include", "exclude"]);
41681
+ /**
41682
+ * Per-consumer rule that references existing zones (geometry) and
41683
+ * defines how a specific pipeline stage should treat them. Each
41684
+ * consumer addon owns its own `ZoneRule[]` array in its per-device
41685
+ * settings:
41686
+ *
41687
+ * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
41688
+ * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
41689
+ * - future: notification rules, audio gating, etc.
41690
+ *
41691
+ * One rule applies to N zones (`zoneIds[]`) so the operator can
41692
+ * express "ignore motion in ALL of {garden, street}" with a single
41693
+ * rule. `classFilter` narrows the rule to specific object classes —
41694
+ * "drop person detections in the street, but keep cars" is one
41695
+ * `exclude` rule with `classFilter: ['person']`.
41696
+ *
41697
+ * `enabled` is a soft toggle — the operator can keep the rule
41698
+ * configured but inert without deleting it.
41699
+ */
41700
+ var ZoneRuleSchema = object({
41701
+ /** Stable rule id — survives edits, used by the UI for diffing. */
41702
+ id: string(),
41703
+ /** Optional human-readable label rendered in the rule editor. */
41704
+ name: string().optional(),
41705
+ /** Zones this rule targets. The rule's `mode` applies to ALL
41706
+ * listed zones (OR-set: a detection in any one of them counts).
41707
+ * At least one zone id required — a rule with no targets is a
41708
+ * configuration mistake and the form validator rejects it. */
41709
+ zoneIds: array(string()).min(1).readonly(),
41710
+ mode: ZoneRuleModeEnum,
41711
+ /**
41712
+ * Class names this rule applies to. Empty / undefined ⇒ rule
41713
+ * applies to every class. Class strings match the `macroClass`
41714
+ * field on detections (e.g. `person`, `car`, `dog`).
41715
+ */
41716
+ classFilter: array(string()).readonly().optional(),
41717
+ /**
41718
+ * Minimum bbox/mask overlap (0–1) with any of the rule's zones
41719
+ * required to consider an entity "in the zone". Defaults to the
41720
+ * consumer's stage default when omitted. Kept for back-compat with
41721
+ * existing per-rule overrides; new operators pick the value via
41722
+ * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
41723
+ * set, the lower-level engine reads it as a 0–1 fraction.
41724
+ */
41725
+ overlapThreshold: number().min(0).max(1).optional(),
41726
+ /**
41727
+ * Operator-friendly version of `overlapThreshold` — the percentage
41728
+ * of the detection's bbox that must lie inside the zone for the
41729
+ * rule to match. Documented default is 85%; the engine substitutes
41730
+ * that when the field is omitted (kept optional so existing rules
41731
+ * stored without it stay valid).
41732
+ *
41733
+ * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
41734
+ * rule, the engine prefers `bboxInclusionPct` because it's the
41735
+ * field exposed in the UI. Internally both feed the same gate.
41736
+ */
41737
+ bboxInclusionPct: number().min(0).max(100).optional(),
41738
+ /**
41739
+ * When `true` and a detection has a segmentation mask, use the
41740
+ * mask for overlap instead of the bbox. Detection-stage only;
41741
+ * motion rules ignore this field.
41742
+ */
41743
+ preferMask: boolean().optional(),
41744
+ /**
41745
+ * Soft-toggle: `false` disables the rule without deleting it.
41746
+ * Defaults to `true` so operators creating a rule via the UI
41747
+ * see it active immediately.
41748
+ */
41749
+ enabled: boolean().default(true)
41750
+ });
41751
+ array(ZoneRuleSchema).readonly();
41752
+ /**
40940
41753
  * Script-runner cap. Models HA `script.*` entities on
40941
41754
  * `DeviceType.Script`. A Script is a pre-recorded action sequence
40942
41755
  * that can be invoked imperatively — optionally with a variables
@@ -43144,42 +43957,6 @@ function readDeviceStateFrom(runtimeState) {
43144
43957
  }
43145
43958
  }
43146
43959
  /**
43147
- * LA tabella "quale booleano di questo tipo di device conta come ALTO", e il
43148
- * valutatore puro del suo FRONTE.
43149
- *
43150
- * Viveva dentro il builtin virtual-doorbell
43151
- * (`@camstack/system` — `builtins/doorbell/trigger-engine.ts`) e i suoi
43152
- * predicati erano privati al modulo. Il recorder ne ha bisogno per il trigger
43153
- * `RecordingTriggers.sensorDeviceIds`: copiarla avrebbe creato la SECONDA
43154
- * tabella, che diverge alla prima cap aggiunta e il cui sintomo — "il sensore
43155
- * fa suonare il campanello ma non registra" — è esattamente D62. Quindi si
43156
- * SPOSTA qui e il doorbell la ri-esporta.
43157
- *
43158
- * ⚠ NON è `DEVICE_STATE_READERS` (`catalogs/device-state-vocabulary.ts`), e le
43159
- * due non vanno unificate: quella risponde a "qual è la PAROLA di stato per una
43160
- * regola" (e include `presence`, `cover`, `alarm-panel`), questa a "qual è il
43161
- * booleano il cui FRONTE conta". Vocabolari deliberatamente diversi.
43162
- */
43163
- /**
43164
- * Known binary / switch source caps → the boolean slice field whose
43165
- * false→true rise counts as ACTIVE. Every entry is "fire on active".
43166
- * Sensors whose "active" reading is not a plain boolean (presence's string
43167
- * state, connectivity's connected flag) are deliberately excluded — a
43168
- * reconnect is not a doorbell press, and it is not a recording either.
43169
- */
43170
- var SOURCE_CAP_ACTIVE_FIELD = {
43171
- contact: "entryOpen",
43172
- binary: "on",
43173
- switch: "on",
43174
- motion: "detected",
43175
- flood: "flooded",
43176
- gas: "detected",
43177
- smoke: "detected",
43178
- "carbon-monoxide": "detected",
43179
- vibration: "detected",
43180
- tamper: "tampered"
43181
- };
43182
- /**
43183
43960
  * Accessory device helpers — shared across drivers.
43184
43961
  *
43185
43962
  * Many vendor-specific drivers register accessory child devices on
@@ -44602,6 +45379,7 @@ var ALL_CAPABILITY_DEFINITIONS = [
44602
45379
  deviceAdoptionCapability,
44603
45380
  deviceDiscoveryCapability,
44604
45381
  deviceExportCapability,
45382
+ deviceExtensionCapability,
44605
45383
  deviceManagerCapability,
44606
45384
  deviceOpsCapability,
44607
45385
  deviceProviderCapability,
@@ -46150,6 +46928,30 @@ Object.freeze({
46150
46928
  addonId: null,
46151
46929
  access: "create"
46152
46930
  },
46931
+ "deviceExtension.listCandidates": {
46932
+ capName: "device-extension",
46933
+ capScope: "device",
46934
+ addonId: null,
46935
+ access: "view"
46936
+ },
46937
+ "deviceExtension.listSlots": {
46938
+ capName: "device-extension",
46939
+ capScope: "device",
46940
+ addonId: null,
46941
+ access: "view"
46942
+ },
46943
+ "deviceExtension.listSources": {
46944
+ capName: "device-extension",
46945
+ capScope: "device",
46946
+ addonId: null,
46947
+ access: "view"
46948
+ },
46949
+ "deviceExtension.setSlot": {
46950
+ capName: "device-extension",
46951
+ capScope: "device",
46952
+ addonId: null,
46953
+ access: "create"
46954
+ },
46153
46955
  "deviceManager.addLocation": {
46154
46956
  capName: "device-manager",
46155
46957
  capScope: "system",
@@ -46900,6 +47702,12 @@ Object.freeze({
46900
47702
  addonId: null,
46901
47703
  access: "view"
46902
47704
  },
47705
+ "embeddingEncoder.resetFailedModels": {
47706
+ capName: "embedding-encoder",
47707
+ capScope: "system",
47708
+ addonId: null,
47709
+ access: "delete"
47710
+ },
46903
47711
  "enumSensor.getStatus": {
46904
47712
  capName: "enum-sensor",
46905
47713
  capScope: "device",
@@ -48286,6 +49094,12 @@ Object.freeze({
48286
49094
  addonId: null,
48287
49095
  access: "view"
48288
49096
  },
49097
+ "notificationRules.previewStateSummary": {
49098
+ capName: "notification-rules",
49099
+ capScope: "system",
49100
+ addonId: null,
49101
+ access: "view"
49102
+ },
48289
49103
  "notificationRules.previewTemplate": {
48290
49104
  capName: "notification-rules",
48291
49105
  capScope: "system",
@@ -48862,12 +49676,6 @@ Object.freeze({
48862
49676
  addonId: null,
48863
49677
  access: "create"
48864
49678
  },
48865
- "pipelineAnalytics.runReplayFrameProcessor": {
48866
- capName: "pipeline-analytics",
48867
- capScope: "device",
48868
- addonId: null,
48869
- access: "create"
48870
- },
48871
49679
  "pipelineAnalytics.saveRetrainAnnotations": {
48872
49680
  capName: "pipeline-analytics",
48873
49681
  capScope: "device",
@@ -49234,6 +50042,12 @@ Object.freeze({
49234
50042
  addonId: null,
49235
50043
  access: "view"
49236
50044
  },
50045
+ "pipelineOrchestrator.getClusterModelChoice": {
50046
+ capName: "pipeline-orchestrator",
50047
+ capScope: "system",
50048
+ addonId: null,
50049
+ access: "view"
50050
+ },
49237
50051
  "pipelineOrchestrator.getDeviceLiveContribution": {
49238
50052
  capName: "pipeline-orchestrator",
49239
50053
  capScope: "system",
@@ -52059,6 +52873,26 @@ Object.freeze({
52059
52873
  form: "single",
52060
52874
  optional: false
52061
52875
  }],
52876
+ "deviceExtension.listCandidates": [{
52877
+ name: "deviceId",
52878
+ form: "single",
52879
+ optional: false
52880
+ }],
52881
+ "deviceExtension.listSlots": [{
52882
+ name: "deviceId",
52883
+ form: "single",
52884
+ optional: false
52885
+ }],
52886
+ "deviceExtension.listSources": [{
52887
+ name: "deviceId",
52888
+ form: "single",
52889
+ optional: false
52890
+ }],
52891
+ "deviceExtension.setSlot": [{
52892
+ name: "deviceId",
52893
+ form: "single",
52894
+ optional: false
52895
+ }],
52062
52896
  "deviceManager.adoptionRelease": [{
52063
52897
  name: "camDeviceId",
52064
52898
  form: "single",
@@ -52965,11 +53799,6 @@ Object.freeze({
52965
53799
  form: "single",
52966
53800
  optional: false
52967
53801
  }],
52968
- "pipelineAnalytics.runReplayFrameProcessor": [{
52969
- name: "deviceId",
52970
- form: "single",
52971
- optional: false
52972
- }],
52973
53802
  "pipelineAnalytics.saveRetrainAnnotations": [{
52974
53803
  name: "deviceId",
52975
53804
  form: "single",
@@ -53858,12 +54687,55 @@ var NC_AUDIO_DEFAULTS = {
53858
54687
  samplingSeconds: 10
53859
54688
  };
53860
54689
  new Set(["devices", "classes"]);
53861
- /** Every filter, for the callers that must cover all four (guards, tests). */
54690
+ /**
54691
+ * WHICH narrowing filter speaks about WHICH system-event kind — one predicate,
54692
+ * consumed by the rule ENGINE and by every rule EDITOR.
54693
+ *
54694
+ * ── The failure this file exists for ───────────────────────────────────────
54695
+ * `NcSystemEventConditionSchema` carries four optional narrowing lists
54696
+ * (`deviceIds`, `deviceTypes`, `nodeIds`, `packageNames`) beside a required
54697
+ * `kinds` gate. They are not four filters over one vocabulary: each belongs to
54698
+ * a FAMILY of kinds and is meaningless outside it. A node going away has no
54699
+ * device type; a completed export has no package; `stream-offline` deliberately
54700
+ * carries no device type at all (a stream belongs to a camera by construction).
54701
+ *
54702
+ * The engine applied all four to every kind, so a filter from one family failed
54703
+ * a kind from another family CLOSED. The operator's live rule "Eventi di
54704
+ * sistema" selected eleven kinds and set `deviceTypes: ['camera']` — the only
54705
+ * way to say "only my cameras" about the two liveness kinds — and NINE of the
54706
+ * eleven silently stopped being deliverable. Four days of history contained
54707
+ * `device-online` and `device-offline` and nothing else, across a window in
54708
+ * which agents were restarted and addons were updated.
54709
+ *
54710
+ * Both editors already computed this scoping, to decide which filter boxes to
54711
+ * render; the cap's own docblock already promised it ("Narrow a `device-*` kind
54712
+ * to these device TYPES"). Only the engine disagreed, and it disagreed in the
54713
+ * destructive direction. So the rule is stated ONCE, here, and the engine and
54714
+ * the editors are readers of it rather than three independent authors.
54715
+ *
54716
+ * ── The direction ─────────────────────────────────────────────────────────
54717
+ * Out of family ⇒ the filter is IGNORED, never fail-closed. An editor that
54718
+ * hides a box has already told the operator this filter does not speak about
54719
+ * these kinds, so honouring it as an exclusion contradicts the only
54720
+ * explanation the operator was ever given. Inside its family the filter still
54721
+ * narrows, and still fails CLOSED on a subject that cannot produce the identity
54722
+ * it tests (a device the mirror cannot name is not evidence of a camera).
54723
+ */
54724
+ /**
54725
+ * Every filter, for the callers that must cover all of them (guards, tests).
54726
+ *
54727
+ * `consumableLowPercent` (D642) is not a list but it is a filter in exactly
54728
+ * this sense: it belongs to a family of kinds (the consumable pair) and the
54729
+ * engine consults it only there. It differs in one way the readers must know —
54730
+ * its ABSENCE is not "no narrowing" but the default threshold, because a
54731
+ * consumable episode is always judged at SOME threshold.
54732
+ */
53862
54733
  var NC_SYSTEM_EVENT_FILTER_KEYS = [
53863
54734
  "deviceIds",
53864
54735
  "deviceTypes",
53865
54736
  "nodeIds",
53866
- "packageNames"
54737
+ "packageNames",
54738
+ "consumableLowPercent"
53867
54739
  ];
53868
54740
  new Map(Object.entries({
53869
54741
  "device-online": "device-events",
@@ -53874,6 +54746,9 @@ new Map(Object.entries({
53874
54746
  "device-battery-normal": "device-events",
53875
54747
  "device-consumable-low": "device-events",
53876
54748
  "device-consumable-normal": "device-events",
54749
+ "device-tank-low": "device-events",
54750
+ "device-tank-full": "device-events",
54751
+ "device-tank-normal": "device-events",
53877
54752
  "stream-online": "device-events",
53878
54753
  "stream-offline": "device-events",
53879
54754
  "detection-blind": "device-events",
@@ -53903,6 +54778,98 @@ new Map(Object.entries({
53903
54778
  "camera-enabled": null
53904
54779
  }));
53905
54780
  [...NC_SYSTEM_EVENT_FILTER_KEYS];
54781
+ var NC_SYSTEM_EVENT_KIND_GROUP_SPECS = [
54782
+ {
54783
+ id: "device-state",
54784
+ family: "device-events",
54785
+ label: "Device state",
54786
+ kinds: [
54787
+ "device-offline",
54788
+ "device-online",
54789
+ "device-disabled",
54790
+ "device-enabled"
54791
+ ]
54792
+ },
54793
+ {
54794
+ id: "streams",
54795
+ family: "device-events",
54796
+ label: "Streams",
54797
+ kinds: ["stream-offline", "stream-online"]
54798
+ },
54799
+ {
54800
+ id: "battery",
54801
+ family: "device-events",
54802
+ label: "Battery",
54803
+ kinds: ["device-battery-low", "device-battery-normal"]
54804
+ },
54805
+ {
54806
+ id: "consumables",
54807
+ family: "device-events",
54808
+ label: "Consumables",
54809
+ kinds: ["device-consumable-low", "device-consumable-normal"]
54810
+ },
54811
+ {
54812
+ id: "tanks",
54813
+ family: "device-events",
54814
+ label: "Tanks",
54815
+ kinds: [
54816
+ "device-tank-low",
54817
+ "device-tank-full",
54818
+ "device-tank-normal"
54819
+ ]
54820
+ },
54821
+ {
54822
+ id: "detection-blind",
54823
+ family: "device-events",
54824
+ label: "Detecting nothing",
54825
+ kinds: ["detection-blind"]
54826
+ },
54827
+ {
54828
+ id: "nodes",
54829
+ family: "system",
54830
+ label: "Nodes",
54831
+ kinds: [
54832
+ "node-offline",
54833
+ "node-online",
54834
+ "node-inference-unavailable"
54835
+ ]
54836
+ },
54837
+ {
54838
+ id: "addons",
54839
+ family: "system",
54840
+ label: "Addons",
54841
+ kinds: [
54842
+ "addon-crash-loop",
54843
+ "addon-update-available",
54844
+ "addon-updated"
54845
+ ]
54846
+ },
54847
+ {
54848
+ id: "updates",
54849
+ family: "system",
54850
+ label: "Server & container updates",
54851
+ kinds: [
54852
+ "server-update-available",
54853
+ "server-updated",
54854
+ "wrapper-update-available"
54855
+ ]
54856
+ },
54857
+ {
54858
+ id: "backups-exports",
54859
+ family: "system",
54860
+ label: "Backups & exports",
54861
+ kinds: ["backup-completed", "export-completed"]
54862
+ },
54863
+ {
54864
+ id: "alarm",
54865
+ family: "alarm",
54866
+ label: "Alarm",
54867
+ kinds: NC_ALARM_SYSTEM_EVENT_KINDS
54868
+ }
54869
+ ];
54870
+ function systemEventKindsOfFamily(family) {
54871
+ return NC_SYSTEM_EVENT_KIND_GROUP_SPECS.filter((g) => g.family === family).flatMap((g) => g.kinds);
54872
+ }
53906
54873
  NC_AUDIO_DEFAULTS.hitPercent, NC_AUDIO_DEFAULTS.samplingSeconds;
53907
54874
  var WEEKDAY_TO_DAY = {
53908
54875
  Sun: 0,
@@ -53913,18 +54880,38 @@ var WEEKDAY_TO_DAY = {
53913
54880
  Fri: 5,
53914
54881
  Sat: 6
53915
54882
  };
53916
- /** Resolve (weekday, minute-of-day) of `atMs` in the schedule's timezone.
53917
- * An invalid/unknown IANA name falls back to the host timezone. */
53918
- function localDayMinute(atMs, timezone) {
53919
- const d = new Date(atMs);
53920
- if (timezone !== void 0) try {
53921
- const parts = new Intl.DateTimeFormat("en-US", {
54883
+ /**
54884
+ * One formatter per timezone, built once (D647 review I4). Constructing an
54885
+ * `Intl.DateTimeFormat` is the expensive part of this function, and a caller
54886
+ * that asks about many instants — a window scan — used to build one per
54887
+ * instant. `null` = an invalid IANA name (the host timezone is used).
54888
+ */
54889
+ var FORMATTERS = /* @__PURE__ */ new Map();
54890
+ function formatterFor(timezone) {
54891
+ const held = FORMATTERS.get(timezone);
54892
+ if (held !== void 0) return held;
54893
+ let made;
54894
+ try {
54895
+ made = new Intl.DateTimeFormat("en-US", {
53922
54896
  timeZone: timezone,
53923
54897
  weekday: "short",
53924
54898
  hour: "numeric",
53925
54899
  minute: "numeric",
53926
54900
  hourCycle: "h23"
53927
- }).formatToParts(d);
54901
+ });
54902
+ } catch {
54903
+ made = null;
54904
+ }
54905
+ FORMATTERS.set(timezone, made);
54906
+ return made;
54907
+ }
54908
+ /** Resolve (weekday, minute-of-day) of `atMs` in the schedule's timezone.
54909
+ * An invalid/unknown IANA name falls back to the host timezone. */
54910
+ function localDayMinute(atMs, timezone) {
54911
+ const d = new Date(atMs);
54912
+ const formatter = timezone !== void 0 ? formatterFor(timezone) : null;
54913
+ if (formatter !== null) try {
54914
+ const parts = formatter.formatToParts(d);
53928
54915
  let weekday;
53929
54916
  let hour;
53930
54917
  let minute;
@@ -54001,6 +54988,11 @@ var RULE_BODY_ONLY = ["body"];
54001
54988
  var RULE_TEXT = ["title", "body"];
54002
54989
  var BATTERY = ["device-battery-low", "device-battery-normal"];
54003
54990
  var CONSUMABLE = ["device-consumable-low", "device-consumable-normal"];
54991
+ var TANK = [
54992
+ "device-tank-low",
54993
+ "device-tank-full",
54994
+ "device-tank-normal"
54995
+ ];
54004
54996
  var UPDATES = [
54005
54997
  "addon-update-available",
54006
54998
  "server-update-available",
@@ -54026,12 +55018,189 @@ var DEVICE_EVENTS = [
54026
55018
  "device-enabled",
54027
55019
  ...BATTERY,
54028
55020
  ...CONSUMABLE,
55021
+ ...TANK,
54029
55022
  "stream-online",
54030
55023
  "stream-offline",
54031
55024
  "detection-blind",
54032
55025
  ...ALARM
54033
55026
  ];
54034
- [...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];
55027
+ /** Every kind a summary may speak about — the two summarisable families. */
55028
+ var SUMMARISABLE = [...systemEventKindsOfFamily("device-events"), ...systemEventKindsOfFamily("system")];
55029
+ /** One per summary SECTION (`NC_STATE_SUMMARY_SECTIONS` in the notification
55030
+ * centre): the section's lines, offered when one of its kinds is selected. */
55031
+ var STATE_SUMMARY_SECTION_VARS = [
55032
+ {
55033
+ name: "summaryDevices",
55034
+ label: "Summary: devices offline / switched off",
55035
+ example: "Garage — offline since 07:12",
55036
+ kinds: [
55037
+ "device-offline",
55038
+ "device-online",
55039
+ "device-disabled",
55040
+ "device-enabled"
55041
+ ]
55042
+ },
55043
+ {
55044
+ name: "summaryStreams",
55045
+ label: "Summary: streams offline",
55046
+ example: "Ingresso (high) — since 06:40",
55047
+ kinds: ["stream-offline", "stream-online"]
55048
+ },
55049
+ {
55050
+ name: "summaryBattery",
55051
+ label: "Summary: low batteries",
55052
+ example: "Sensore porta — 8 %",
55053
+ kinds: BATTERY
55054
+ },
55055
+ {
55056
+ name: "summaryConsumables",
55057
+ label: "Summary: consumables",
55058
+ example: "Robot — filter 10 %",
55059
+ kinds: CONSUMABLE
55060
+ },
55061
+ {
55062
+ name: "summaryTanks",
55063
+ label: "Summary: tanks",
55064
+ example: "Robot — clean water low",
55065
+ kinds: TANK
55066
+ },
55067
+ {
55068
+ name: "summaryDetection",
55069
+ label: "Summary: cameras detecting nothing",
55070
+ example: "Ingresso — since 05:10",
55071
+ kinds: ["detection-blind"]
55072
+ },
55073
+ {
55074
+ name: "summaryNodes",
55075
+ label: "Summary: nodes",
55076
+ example: "little-unraid — offline since 03:00",
55077
+ kinds: [
55078
+ "node-offline",
55079
+ "node-online",
55080
+ "node-inference-unavailable"
55081
+ ]
55082
+ },
55083
+ {
55084
+ name: "summaryAddons",
55085
+ label: "Summary: addons",
55086
+ example: "@camstack/addon-recorder 1.2.3 → 1.2.4",
55087
+ kinds: [
55088
+ "addon-crash-loop",
55089
+ "addon-update-available",
55090
+ "addon-updated"
55091
+ ]
55092
+ },
55093
+ {
55094
+ name: "summaryUpdates",
55095
+ label: "Summary: server & container updates",
55096
+ example: "server 1.2.377 → 1.2.378",
55097
+ kinds: [
55098
+ "server-update-available",
55099
+ "server-updated",
55100
+ "wrapper-update-available"
55101
+ ]
55102
+ }
55103
+ ];
55104
+ var STATE_SUMMARY_VARS = [
55105
+ {
55106
+ name: "summaryText",
55107
+ label: "Summary: every section",
55108
+ description: "One block per section with something to report, one line per item.",
55109
+ example: "Batterie scariche: Sensore porta — 8 %",
55110
+ group: "system",
55111
+ families: ["rule"],
55112
+ fields: [...RULE_TEXT],
55113
+ kinds: ["system"],
55114
+ systemEventKinds: [...SUMMARISABLE],
55115
+ systemEventDeliveries: ["summary"]
55116
+ },
55117
+ {
55118
+ name: "summaryCount",
55119
+ label: "Summary: items reported",
55120
+ example: "3",
55121
+ group: "system",
55122
+ families: ["rule"],
55123
+ fields: [...RULE_TEXT],
55124
+ kinds: ["system"],
55125
+ systemEventKinds: [...SUMMARISABLE],
55126
+ systemEventDeliveries: ["summary"]
55127
+ },
55128
+ ...STATE_SUMMARY_SECTION_VARS.map((v) => ({
55129
+ name: v.name,
55130
+ label: v.label,
55131
+ example: v.example,
55132
+ group: "system",
55133
+ families: ["rule"],
55134
+ fields: [...RULE_TEXT],
55135
+ kinds: ["system"],
55136
+ systemEventKinds: [...v.kinds],
55137
+ systemEventDeliveries: ["summary"]
55138
+ }))
55139
+ ];
55140
+ [
55141
+ [...DEVICE_EVENTS],
55142
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
55143
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
55144
+ [...RULE_TEXT],
55145
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
55146
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
55147
+ [...RULE_TEXT],
55148
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
55149
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
55150
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
55151
+ [...RULE_TEXT],
55152
+ [...RULE_TEXT],
55153
+ [...RULE_TEXT],
55154
+ [...RULE_TEXT],
55155
+ [...RULE_TEXT],
55156
+ [...RULE_TEXT],
55157
+ [...RULE_TEXT],
55158
+ [...RULE_TEXT],
55159
+ [...RULE_BODY_ONLY],
55160
+ [...RULE_TEXT],
55161
+ ([...RULE_TEXT], [...DEVICE_EVENTS]),
55162
+ ([...RULE_TEXT], [...DEVICE_EVENTS]),
55163
+ ([...RULE_TEXT], [...BATTERY, ...CONSUMABLE]),
55164
+ ([...RULE_TEXT], [...CONSUMABLE]),
55165
+ ([...RULE_TEXT], [...TANK]),
55166
+ [...RULE_TEXT],
55167
+ ([...RULE_TEXT], [...UPDATES]),
55168
+ ([...RULE_TEXT], [...UPDATES]),
55169
+ [...RULE_TEXT],
55170
+ [...RULE_TEXT],
55171
+ [...RULE_TEXT],
55172
+ ([...RULE_TEXT], [...UPDATES]),
55173
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
55174
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
55175
+ ([...RULE_TEXT], [...UPDATES]),
55176
+ ([...RULE_TEXT], [...UPDATES]),
55177
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
55178
+ [...RULE_TEXT],
55179
+ [...RULE_TEXT],
55180
+ [...RULE_TEXT],
55181
+ [...RULE_TEXT],
55182
+ [...RULE_TEXT],
55183
+ [...RULE_TEXT],
55184
+ [...RULE_TEXT],
55185
+ [...RULE_TEXT],
55186
+ [...RULE_TEXT],
55187
+ [...RULE_TEXT],
55188
+ [...RULE_TEXT],
55189
+ [...RULE_TEXT],
55190
+ [...RULE_TEXT],
55191
+ [...RULE_TEXT],
55192
+ [...RULE_TEXT],
55193
+ [...RULE_TEXT],
55194
+ [...RULE_TEXT],
55195
+ [...RULE_TEXT],
55196
+ [...RULE_TEXT],
55197
+ [...RULE_TEXT],
55198
+ [...RULE_TEXT],
55199
+ [...RULE_TEXT],
55200
+ [...RULE_TEXT],
55201
+ [...RULE_TEXT],
55202
+ ...STATE_SUMMARY_VARS
55203
+ ];
54035
55204
  /**
54036
55205
  * TimelapseRule — the STANDALONE scheduled timelapse producer's rule model.
54037
55206
  *
@@ -54263,68 +55432,6 @@ TimelapseRuleInputSchema.extend({
54263
55432
  createdAt: number(),
54264
55433
  updatedAt: number()
54265
55434
  });
54266
- Object.freeze(Object.fromEntries([{
54267
- stepId: "face-embedding",
54268
- label: "Face recognition model",
54269
- defaultModelId: "arcface-r100",
54270
- indexName: "the enrolled face gallery",
54271
- options: [
54272
- {
54273
- id: "arcface-r100",
54274
- label: "ArcFace (ResNet34)"
54275
- },
54276
- {
54277
- id: "auraface-r100",
54278
- label: "AuraFace R100"
54279
- },
54280
- {
54281
- id: "inception-resnet-v1",
54282
- label: "Inception ResNet V1"
54283
- }
54284
- ]
54285
- }, {
54286
- stepId: "clip-embedding",
54287
- label: "Semantic search model",
54288
- defaultModelId: "mobileclip-s1",
54289
- indexName: "the object semantic-search index",
54290
- options: [{
54291
- id: "mobileclip-s1",
54292
- label: "MobileCLIP S1"
54293
- }, {
54294
- id: "mobileclip-s2",
54295
- label: "MobileCLIP S2"
54296
- }]
54297
- }].map((s) => [s.stepId, s.defaultModelId])));
54298
- string().min(1);
54299
- var CLUSTER_STEP_SETTING_FIELDS = [{
54300
- stepId: "face-embedding",
54301
- key: "minLandmarkFaceSize",
54302
- label: "Min face size for recognition (detection px)",
54303
- 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.",
54304
- type: "slider",
54305
- min: 0,
54306
- max: 64,
54307
- step: 2,
54308
- default: 24
54309
- }];
54310
- function clusterStepSettingKey(stepId, fieldKey) {
54311
- return `clusterStepSetting:${stepId}:${fieldKey}`;
54312
- }
54313
- var ClusterSettingNumberSchema = number().finite();
54314
- function readClusterStepSettings(config) {
54315
- const out = {};
54316
- for (const field of CLUSTER_STEP_SETTING_FIELDS) {
54317
- const parsed = ClusterSettingNumberSchema.safeParse(config[clusterStepSettingKey(field.stepId, field.key)]);
54318
- const value = parsed.success ? parsed.data : field.default;
54319
- const existing = out[field.stepId] ?? {};
54320
- out[field.stepId] = {
54321
- ...existing,
54322
- [field.key]: value
54323
- };
54324
- }
54325
- return out;
54326
- }
54327
- readClusterStepSettings({});
54328
55435
  object({
54329
55436
  /**
54330
55437
  * Fraction of the box's own size added on EACH side before cutting.