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