@camstack/addon-osd-manager 0.1.139 → 0.1.140

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 (18) hide show
  1. package/dist/{MotionZonesSettings-CG1jsdMo.mjs → MotionZonesSettings-C80efbgF.mjs} +2 -2
  2. package/dist/{PrivacyMaskSettings-mBWMKyY2.mjs → PrivacyMaskSettings-CvVdYFwr.mjs} +4 -4
  3. package/dist/{SceneMonitorEditor-C_L1sFhf.mjs → SceneMonitorEditor-CkIz3-13.mjs} +3 -3
  4. package/dist/_stub.js +11 -11
  5. package/dist/{_virtual_mf-localSharedImportMap___mfe_internal__addon_osd_manager_page-COPuIhJm.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_osd_manager_page-DaUqGaKC.mjs} +3 -3
  6. package/dist/_virtual_mf___mfe_internal__addon_osd_manager_page__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-DG3UFggb.mjs +26 -0
  7. package/dist/{hostInit-CtlLZppQ.mjs → hostInit-Bkk-9STE.mjs} +2 -2
  8. package/dist/index.js +1866 -1379
  9. package/dist/index.mjs +1866 -1379
  10. package/dist/{player-overlays-Cxv7i44p.mjs → player-overlays-CbLYEs-S.mjs} +1 -1
  11. package/dist/remoteEntry.js +1 -1
  12. package/dist/{responsive-BpLjT1Jf.mjs → responsive-BghmipTp.mjs} +1 -1
  13. package/dist/{scene-monitor-copy-CglGNTA4.mjs → scene-monitor-copy-Cpz17vjT.mjs} +1 -1
  14. package/dist/{square-CeQEcUQK.mjs → square-D-Qx_njd.mjs} +1 -1
  15. package/dist/{trash-2-D4OQxTrz.mjs → trash-2-cC4gYobQ.mjs} +1 -1
  16. 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-Dao979S_.mjs} +1 -1
  17. package/package.json +1 -1
  18. package/dist/_virtual_mf___mfe_internal__addon_osd_manager_page__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-B8-UPDOD.mjs +0 -26
package/dist/index.js CHANGED
@@ -5363,7 +5363,7 @@ var ZodIssueCode = {
5363
5363
  var ZodFirstPartyTypeKind;
5364
5364
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5365
5365
  //#endregion
5366
- //#region ../types/dist/sleep-DU7mu4wb.mjs
5366
+ //#region ../types/dist/sleep-BaRu0bS5.mjs
5367
5367
  /**
5368
5368
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5369
5369
  * window to float samples (D455).
@@ -9530,7 +9530,7 @@ var ModelFormatEntrySchema = object({
9530
9530
  /** Multi-file payload (directory members or sibling files). */
9531
9531
  files: array(string()).readonly().optional(),
9532
9532
  /** Runtime(s) that can use this format. If omitted, inferred from ModelFormat key */
9533
- runtimes: array(_enum(["node", "python"])).readonly().optional()
9533
+ runtimes: array(_enum(["python"])).readonly().optional()
9534
9534
  });
9535
9535
  /**
9536
9536
  * Extra file that must be downloaded alongside the model (e.g., labels JSON, dict.txt).
@@ -9611,10 +9611,17 @@ var ModelCatalogEntrySchema = object({
9611
9611
  inputChannels: number().int().positive().optional(),
9612
9612
  labels: array(LabelDefinitionSchema).readonly(),
9613
9613
  inputLayout: _enum(["nchw", "nhwc"]).optional(),
9614
+ /**
9615
+ * `'scrfd'` applies InsightFace's SCRFD input contract, `(x - 127.5) / 128`
9616
+ * (upstream `insightface/model_zoo/scrfd.py`), instead of the historical
9617
+ * plain `/255`. Measured against COCO GT: 188 → 196 faces found on the
9618
+ * `scrfd-2.5g` catalog entry (2026-09-26 model-replacement spike, §2.4-2).
9619
+ */
9614
9620
  inputNormalization: _enum([
9615
9621
  "zero-one",
9616
9622
  "imagenet",
9617
- "none"
9623
+ "none",
9624
+ "scrfd"
9618
9625
  ]).optional(),
9619
9626
  /**
9620
9627
  * The model already applies softmax IN-GRAPH — its raw output is a
@@ -9716,7 +9723,8 @@ var ModelConvertMetadataSchema = object({
9716
9723
  inputNormalization: _enum([
9717
9724
  "zero-one",
9718
9725
  "imagenet",
9719
- "none"
9726
+ "none",
9727
+ "scrfd"
9720
9728
  ]).optional(),
9721
9729
  preprocessMode: _enum(["letterbox", "resize"]).optional(),
9722
9730
  outputFormat: _enum([
@@ -19531,6 +19539,9 @@ var NcSystemEventKindSchema = _enum([
19531
19539
  "device-battery-normal",
19532
19540
  "device-consumable-low",
19533
19541
  "device-consumable-normal",
19542
+ "device-tank-low",
19543
+ "device-tank-full",
19544
+ "device-tank-normal",
19534
19545
  "stream-online",
19535
19546
  "stream-offline",
19536
19547
  "node-online",
@@ -19568,6 +19579,29 @@ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
19568
19579
  ]);
19569
19580
  NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
19570
19581
  /**
19582
+ * The panel's transitions, as ONE list.
19583
+ *
19584
+ * Named here rather than spelled out at each of the four sites that need them
19585
+ * (the emitter, the intake, the editor group, the combined-notification gate),
19586
+ * because a transition added to the enum and forgotten at one of them is an
19587
+ * alarm state nobody can be notified about. That is exactly what this list
19588
+ * failed to prevent while it held three: `alarm-arming` was the fourth.
19589
+ *
19590
+ * In LIFECYCLE order, which is the order an editor lists them in and the order
19591
+ * a person experiences them — not the order they were added.
19592
+ */
19593
+ var NC_ALARM_SYSTEM_EVENT_KINDS = [
19594
+ "alarm-arm-refused",
19595
+ "alarm-check-failed",
19596
+ "alarm-arming",
19597
+ "alarm-armed",
19598
+ "alarm-pending",
19599
+ "alarm-triggered",
19600
+ "alarm-rearmed",
19601
+ "alarm-sensor-bypass",
19602
+ "alarm-disarmed"
19603
+ ];
19604
+ /**
19571
19605
  * One coherent system-event condition. `kinds` is the required opt-in safety
19572
19606
  * gate; the remaining lists are optional narrowing filters relevant to the
19573
19607
  * selected kinds.
@@ -19601,7 +19635,22 @@ var NcSystemEventConditionSchema = object({
19601
19635
  */
19602
19636
  excludeDeviceIds: array(number().int()).min(1).optional(),
19603
19637
  nodeIds: array(string().min(1)).min(1).optional(),
19604
- packageNames: array(string().min(1)).min(1).optional()
19638
+ packageNames: array(string().min(1)).min(1).optional(),
19639
+ /**
19640
+ * At or below this remaining-life %, a consumable is LOW for THIS rule
19641
+ * (D642). Absent = {@link NC_CONSUMABLE_LOW_PERCENT_DEFAULT}; at most
19642
+ * {@link NC_CONSUMABLE_LOW_PERCENT_MAX}, so every episode can recover. Scoped to the
19643
+ * consumable kinds (`systemEventFilterApplies`) and to the device-events
19644
+ * family; ignored on every other kind.
19645
+ *
19646
+ * It is a property of the RULE because the operator decided so: a rule at
19647
+ * 25 must be told about a filter at 20 %, a rule at 10 must not. The hub
19648
+ * keeps one episode per (threshold, device, item) — its own hysteresis, its
19649
+ * own reminder — and a rule hears only the episode judged at ITS threshold,
19650
+ * exactly as an occupancy rule hears only the edge of its own count. A
19651
+ * provider's own `replace` verdict is low at every threshold.
19652
+ */
19653
+ consumableLowPercent: number().int().min(1).max(95).optional()
19605
19654
  });
19606
19655
  /** Hard ceiling on a window (24h). A snooze that could not expire would be an
19607
19656
  * outage the operator asked for once and forgot. */
@@ -19619,6 +19668,25 @@ var NcScheduleSchema = object({
19619
19668
  /** Active OUTSIDE the windows (e.g. "only outside business hours"). */
19620
19669
  invert: boolean().optional()
19621
19670
  });
19671
+ /**
19672
+ * How a system-event rule of the `device-events` or `system` family speaks
19673
+ * (D647): at once, per event (`instant`, the only behaviour before D647), or
19674
+ * as a STATE SUMMARY at the end of each window of `schedule`.
19675
+ */
19676
+ var NcSystemEventDeliveryModeSchema = _enum(["instant", "summary"]);
19677
+ /**
19678
+ * `summary`: the rule sends NOTHING per event. When a window of `schedule`
19679
+ * CLOSES, it sends one notification with the current state of its kinds
19680
+ * (low batteries, consumables to replace, devices offline, updates
19681
+ * available, ...), after its own filters. Nothing to report sends nothing.
19682
+ * The schedule is the ordinary `NcSchedule` (weekly windows, IANA timezone,
19683
+ * midnight crossing); the send time is each window's END. Refused on the
19684
+ * `alarm` family, which stays instant (`systemEventDeliveryProblems`).
19685
+ */
19686
+ var NcSystemEventDeliverySchema = discriminatedUnion("mode", [object({ mode: literal("instant") }), object({
19687
+ mode: literal("summary"),
19688
+ schedule: NcScheduleSchema
19689
+ })]);
19622
19690
  /** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
19623
19691
  var NcPlateMatcherSchema = object({
19624
19692
  /**
@@ -20354,6 +20422,16 @@ var NcRuleInputSchema = object({
20354
20422
  delivery: NcDeliverySchema,
20355
20423
  conditions: NcConditionsSchema.default({}),
20356
20424
  schedule: NcScheduleSchema.optional(),
20425
+ /**
20426
+ * A `device-events` / `system` rule's delivery (D647): absent or `instant`
20427
+ * is a notification per event; `summary` is one state summary per closed
20428
+ * window of its schedule. `.optional()` and never defaulted: absent must
20429
+ * keep meaning what every rule authored before D647 meant, with no
20430
+ * migration. Top-level rather than inside `conditions.systemEvent`, so a
20431
+ * client that does not know it (an older viewer re-sending `conditions`
20432
+ * whole) leaves it standing through the store's patch merge.
20433
+ */
20434
+ systemEventDelivery: NcSystemEventDeliverySchema.optional(),
20357
20435
  /** May be empty when `targetUsers` addresses at least one user — the
20358
20436
  * "at least one addressee" invariant is enforced by the provider, because
20359
20437
  * a cross-field refine here would break `NcRulePatchSchema.partial()`. */
@@ -20582,6 +20660,28 @@ var NcRuleSchema = NcRuleInputSchema.extend({
20582
20660
  */
20583
20661
  disabledTargetIds: array(string()).default([])
20584
20662
  });
20663
+ /** One section of a previewed state summary. `unavailable` = its state could not be read. */
20664
+ var NcStateSummaryPreviewSectionSchema = object({
20665
+ id: string(),
20666
+ status: _enum(["read", "unavailable"]),
20667
+ items: number().int().nonnegative(),
20668
+ reason: string().optional()
20669
+ });
20670
+ /**
20671
+ * The summary a rule would send now. `empty` = nothing to report and every
20672
+ * section read: such a summary is NOT sent. `dropped` counts the open states
20673
+ * the rule's own filters (or a camera mute) left out, by reason.
20674
+ * `excludedGroups` names the kind groups selected that have no state to report
20675
+ * (backups & exports).
20676
+ */
20677
+ var NcStateSummaryPreviewSchema = object({
20678
+ empty: boolean(),
20679
+ count: number().int().nonnegative(),
20680
+ text: string(),
20681
+ sections: array(NcStateSummaryPreviewSectionSchema),
20682
+ dropped: record(string(), number().int().nonnegative()),
20683
+ excludedGroups: array(string())
20684
+ });
20585
20685
  var NcTestResultSchema = object({
20586
20686
  recordId: string(),
20587
20687
  recordKind: _enum([
@@ -20673,6 +20773,13 @@ var NcTemplateVarDescriptorSchema = object({
20673
20773
  kinds: array(NcTemplateVarKindSchema).optional(),
20674
20774
  deliveries: array(NcDeliverySchema).optional(),
20675
20775
  systemEventKinds: array(NcSystemEventKindSchema).optional(),
20776
+ /**
20777
+ * Which system-event DELIVERY has a value for it (D647). Absent = an
20778
+ * instant row only when the descriptor names `systemEventKinds` (a
20779
+ * per-event fact: a summary row has no single device), and both otherwise.
20780
+ * `['summary']` marks the state-summary vocabulary (`{{summaryText}}`, ...).
20781
+ */
20782
+ systemEventDeliveries: array(NcSystemEventDeliveryModeSchema).optional(),
20676
20783
  dynamic: object({
20677
20784
  prefix: literal("count_"),
20678
20785
  from: literal("classes")
@@ -20685,7 +20792,9 @@ var NcTemplatePreviewInputSchema = object({
20685
20792
  field: NcTemplateFieldSchema,
20686
20793
  kind: NcRuleKindSchema.optional(),
20687
20794
  delivery: NcDeliverySchema.optional(),
20688
- systemEventKinds: array(NcSystemEventKindSchema).optional()
20795
+ systemEventKinds: array(NcSystemEventKindSchema).optional(),
20796
+ /** The rule's system-event delivery (D647); absent = instant. */
20797
+ systemEventDelivery: NcSystemEventDeliveryModeSchema.optional()
20689
20798
  }),
20690
20799
  template: object({
20691
20800
  title: string().max(500).optional(),
@@ -20863,6 +20972,18 @@ var NC_CONDITION_CATALOG = [
20863
20972
  value: "device-consumable-normal",
20864
20973
  label: "Consumable replaced"
20865
20974
  },
20975
+ {
20976
+ value: "device-tank-low",
20977
+ label: "Tank low (water, detergent)"
20978
+ },
20979
+ {
20980
+ value: "device-tank-full",
20981
+ label: "Tank full (dirty water, dust)"
20982
+ },
20983
+ {
20984
+ value: "device-tank-normal",
20985
+ label: "Tank back to normal"
20986
+ },
20866
20987
  {
20867
20988
  value: "export-completed",
20868
20989
  label: "Export completed"
@@ -21806,6 +21927,17 @@ var notificationRulesCapability = {
21806
21927
  auth: "admin"
21807
21928
  }),
21808
21929
  /**
21930
+ * The STATE SUMMARY a system rule would send now (D647) — for a saved rule
21931
+ * or an unsaved draft. Pure: sends nothing, stamps nothing. A MUTATION
21932
+ * only for transport (a whole rule does not belong in a GET URL). Admin,
21933
+ * like `testRule`: it names devices and nodes across the installation.
21934
+ */
21935
+ previewStateSummary: method(object({ rule: NcRuleInputSchema }), NcStateSummaryPreviewSchema, {
21936
+ kind: "mutation",
21937
+ auth: "admin",
21938
+ access: "view"
21939
+ }),
21940
+ /**
21809
21941
  * The machine-readable condition surface a rule editor renders from, plus
21810
21942
  * the picker VOCABULARY those conditions draw on.
21811
21943
  *
@@ -22266,1036 +22398,212 @@ var oauthIntegrationCapability = {
22266
22398
  getDescriptor: method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" }) }
22267
22399
  };
22268
22400
  /**
22269
- * Reference to the frame's retained NATIVE surface + the parent crop's placement
22270
- * within the frame, so the executor can re-cut a leaf child ROI at native
22271
- * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
22401
+ * pipeline-analytics — device-scoped wrapper cap. Refines raw
22402
+ * per-frame detections emitted by the pipeline runner into tracked
22403
+ * objects, per-kind event collections (motion / object / audio), and
22404
+ * persisted media. Owns the post-detection domain end-to-end:
22405
+ *
22406
+ * runner emits PipelineInferenceResult
22407
+ * ↓ (event bus)
22408
+ * pipeline-analytics subscriber
22409
+ * ↓ SORT tracker + zone engine + state analyzer + event emitter
22410
+ * → three DB collections (one per kind), one FS media tree, one
22411
+ * unified event emitter (FrameTracked + TrackStarted/Ended +
22412
+ * DetectionEvent on bus)
22413
+ *
22414
+ * Pure subscriber model. No `processFrame` cap method — the runner
22415
+ * already publishes the raw frame on the bus. The cap surface is
22416
+ * only QUERIES + per-device settings, bound on/off via
22417
+ * `device-manager.setWrapperActive`. `defaultActive: true` because
22418
+ * every camera with a detection pipeline wants its raw detections
22419
+ * refined; operators opt out per-device via BindingsTab when needed.
22420
+ *
22421
+ * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
22422
+ * (per-device surface) and `track-trail` caps — see P11 cleanup.
22272
22423
  */
22273
- var NativeCropRefSchema = object({
22274
- /** Handle keying the retained native surface (node-pinned to its owner). */
22275
- handle: FrameHandleSchema,
22276
- /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
22277
- cropFrameSpace: object({
22278
- x: number(),
22279
- y: number(),
22280
- w: number(),
22281
- h: number()
22282
- })
22283
- });
22284
- object({
22285
- crop: object({
22286
- left: number(),
22287
- top: number(),
22288
- width: number().positive(),
22289
- height: number().positive()
22290
- }).optional(),
22291
- content: object({
22292
- width: number().int().positive(),
22293
- height: number().int().positive()
22294
- }),
22295
- fit: _enum(["stretch", "contain"]),
22296
- format: _enum([
22297
- "rgb",
22298
- "gray",
22299
- "jpeg"
22300
- ])
22301
- });
22424
+ var TrackStateSchema = _enum([
22425
+ "new",
22426
+ "entered",
22427
+ "left",
22428
+ "moving",
22429
+ "idle"
22430
+ ]);
22431
+ var EventKindSchema = _enum([
22432
+ "motion",
22433
+ "object",
22434
+ "audio"
22435
+ ]);
22302
22436
  /**
22303
- * Process-local frame identity. It is serializable so it can ride an in-process
22304
- * capability call, but `registryId` deliberately prevents resolution in any
22305
- * other process or execution group.
22437
+ * Spatial filter for `listTracks` — the rect + polygon variants of the shared
22438
+ * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
22439
+ * of the camera frame (top-left origin), matching the drawing-plane editor.
22306
22440
  */
22307
- var FrameRefSchema = object({
22308
- registryId: string().min(1),
22309
- id: string().min(1),
22310
- width: number().int().positive(),
22311
- height: number().int().positive(),
22312
- format: _enum(["rgb", "gray"]),
22313
- timestamp: number(),
22314
- capturedAt: number().optional()
22315
- });
22316
- var ModelFormatSchema$1 = _enum([
22317
- "onnx",
22318
- "coreml",
22319
- "openvino",
22320
- "tflite",
22321
- "pt",
22322
- "gguf"
22441
+ var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
22442
+ /** Closed icon vocabulary so clients render a known glyph per kind. */
22443
+ var EventKindIconSchema = _enum([
22444
+ "motion",
22445
+ "audio",
22446
+ "person",
22447
+ "vehicle",
22448
+ "animal",
22449
+ "door",
22450
+ "pir",
22451
+ "smoke",
22452
+ "water",
22453
+ "button",
22454
+ "package",
22455
+ "generic"
22323
22456
  ]);
22324
- var PipelineSlotSchema = _enum([
22325
- "detector",
22326
- "cropper",
22327
- "classifier",
22328
- "refiner",
22329
- "audio-classifier"
22457
+ var EventKindCategorySchema = _enum([
22458
+ "motion",
22459
+ "audio",
22460
+ "detection",
22461
+ "sensor",
22462
+ "control",
22463
+ "custom",
22464
+ "package"
22330
22465
  ]);
22331
- var PipelineEngineChoiceSchema = object({
22332
- runtime: _enum(["node", "python"]),
22333
- backend: string(),
22334
- format: ModelFormatSchema$1,
22335
- device: string().optional()
22336
- });
22337
- var AvailableEngineSchema = object({
22338
- engine: PipelineEngineChoiceSchema,
22339
- devices: array(object({
22340
- id: string(),
22341
- label: string(),
22342
- description: string().optional()
22343
- })).readonly(),
22344
- defaultDevice: string()
22345
- });
22346
- var PipelineDefaultStepSchema = lazy(() => object({
22347
- addonId: string(),
22348
- addonName: string(),
22349
- slot: PipelineSlotSchema,
22350
- inputClasses: array(string()).readonly(),
22351
- outputClasses: array(string()).readonly(),
22352
- enabled: boolean(),
22353
- modelId: string(),
22354
- children: array(PipelineDefaultStepSchema).readonly(),
22355
- group: string().optional(),
22356
- settings: record(string(), unknown()).optional()
22357
- }));
22358
- var PipelineTemplateStepSchema = lazy(() => object({
22359
- addonId: string(),
22360
- enabled: boolean(),
22361
- modelId: string(),
22362
- children: array(PipelineTemplateStepSchema).readonly(),
22363
- settings: record(string(), unknown()).optional()
22364
- }));
22365
- var PipelineTemplateSchema$1 = object({
22366
- id: string(),
22367
- name: string(),
22368
- createdAt: string(),
22369
- updatedAt: string(),
22370
- engine: PipelineEngineChoiceSchema,
22371
- steps: array(PipelineTemplateStepSchema).readonly()
22372
- });
22373
- var PipelineModelOptionSchema = object({
22374
- id: string(),
22375
- name: string(),
22376
- formats: record(string(), object({
22377
- downloaded: boolean(),
22378
- sizeMB: number()
22379
- })),
22380
- group: ModelVariantGroupSchema.optional(),
22381
- legacy: boolean().optional(),
22382
- provider: ModelProviderIdSchema.optional()
22383
- });
22384
- var ConfigFieldBridge = custom();
22385
- var PipelineAddonSchemaSchema = object({
22386
- id: string(),
22387
- name: string(),
22388
- slot: PipelineSlotSchema,
22389
- inputClasses: array(string()).readonly(),
22390
- outputClasses: array(string()).readonly(),
22391
- childSlots: array(PipelineSlotSchema).readonly(),
22392
- models: array(PipelineModelOptionSchema).readonly(),
22393
- defaultModelId: string(),
22394
- defaultModelIdByFormat: record(string(), string()).optional(),
22395
- enabledByDefault: boolean().optional(),
22396
- backfillIntoExistingOverrides: boolean().optional(),
22397
- defaultConfidence: number(),
22398
- group: string().optional(),
22399
- configSchema: array(ConfigFieldBridge).readonly().optional()
22400
- });
22401
- var PipelineSlotSchemaSchema = object({
22402
- id: PipelineSlotSchema,
22466
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
22467
+ var EventKindLevelSchema = _enum(["macro", "sub"]);
22468
+ var EventKindDescriptorSchema = object({
22469
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
22470
+ kind: string(),
22471
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
22472
+ labelKey: string(),
22473
+ /** English fallback label (kept for clients that don't translate). */
22403
22474
  label: string(),
22404
- priority: number(),
22405
- parentSlot: PipelineSlotSchema.nullable(),
22406
- addons: array(PipelineAddonSchemaSchema).readonly()
22407
- });
22408
- var PipelineSchemaSchema = object({
22409
- availableEngines: array(AvailableEngineSchema).readonly(),
22410
- selectedEngine: PipelineEngineChoiceSchema,
22411
- slots: array(PipelineSlotSchemaSchema).readonly()
22412
- });
22413
- var EngineProvisioningSchema = object({
22414
- runtimeId: _enum([
22415
- "onnx",
22416
- "openvino",
22417
- "coreml",
22418
- "edgetpu"
22419
- ]).nullable(),
22420
- device: string().nullable(),
22421
- state: _enum([
22422
- "idle",
22423
- "installing",
22424
- "verifying",
22425
- "ready",
22426
- "failed"
22427
- ]),
22428
- progress: number().optional(),
22429
- error: string().optional(),
22430
- nextRetryAt: number().optional(),
22431
- /**
22432
- * Gate A (config-correctness gate at engine change): human-readable
22433
- * config issues surfaced EAGERLY when the node's engine changes — model
22434
- * substitutions ("chose X, running Y") and zero-build steps ("no model
22435
- * has a <format> build"). Additive/optional: informational only, never
22436
- * enforced here — `assertEngineReady` (readiness) still gates inference.
22437
- * Absent/empty when the node-default tree resolves cleanly.
22438
- */
22439
- configIssues: array(string()).optional()
22440
- });
22441
- var PipelineStepInputSchema = lazy(() => object({
22442
- addonId: string(),
22443
- modelId: string().optional(),
22444
- enabled: boolean().default(true),
22445
- children: array(PipelineStepInputSchema).optional(),
22446
- settings: record(string(), unknown()).optional(),
22447
- jumpDeviceKey: string().optional()
22448
- }));
22449
- var ModelSubstitutionSchema = object({
22450
- addonId: string(),
22451
- chosen: string(),
22452
- running: string(),
22453
- format: string()
22454
- });
22455
- var PipelineValidationIssueSchema = object({
22456
- addonId: string(),
22457
- kind: _enum(["unknown-addon", "no-format-build"]),
22458
- detail: string()
22459
- });
22460
- var PipelineValidationResultSchema = object({
22461
- ok: boolean(),
22462
- issues: array(PipelineValidationIssueSchema).readonly(),
22463
- substitutions: array(ModelSubstitutionSchema).readonly(),
22464
- /** The node's `currentEngine.format` this validation ran against. */
22465
- format: string()
22466
- });
22467
- var ReferenceImageEntrySchema = object({
22468
- filename: string(),
22469
- stepIds: array(string()).readonly().optional()
22470
- });
22471
- var ReferenceImageBodySchema = object({
22472
- base64: string(),
22473
- filename: string()
22475
+ /** Hex color for timeline/legend rendering. */
22476
+ color: string(),
22477
+ /** Dictionary id → lucide component on the UI side. */
22478
+ iconId: string(),
22479
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
22480
+ icon: EventKindIconSchema,
22481
+ category: EventKindCategorySchema,
22482
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
22483
+ parentKind: string().nullable(),
22484
+ /** Derived from `parentKind`, explicit for the client tree. */
22485
+ level: EventKindLevelSchema,
22486
+ /** Which cap + device contributes this kind. For built-ins the camera
22487
+ * itself; for sensor kinds the LINKED source device. */
22488
+ source: object({
22489
+ capName: string(),
22490
+ deviceId: number()
22491
+ })
22474
22492
  });
22475
- var ReferenceAudioEntrySchema = object({
22476
- filename: string(),
22477
- sizeKb: number()
22493
+ /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
22494
+ var EventKindsForDeviceSchema = object({
22495
+ deviceId: number(),
22496
+ kinds: array(EventKindDescriptorSchema).readonly()
22478
22497
  });
22479
- var ReferenceAudioBodySchema = object({ base64: string() });
22480
- var AudioBackendSchema = object({
22498
+ var SensorEventSchema = object({
22481
22499
  id: string(),
22482
- name: string(),
22483
- description: string(),
22484
- available: boolean(),
22500
+ /** The CAMERA the event is attributed to (a sensor linked to N cameras
22501
+ * yields N rows, one per camera). */
22502
+ deviceId: number(),
22503
+ /** The linked sensor device whose state changed. */
22504
+ sourceDeviceId: number(),
22505
+ /** Event kind id — matches an `EventKindDescriptor.kind`. */
22506
+ kind: string(),
22507
+ /** Snapshot of the sensor cap's runtime-state slice at the change. */
22508
+ value: record(string(), unknown()).nullable(),
22509
+ timestamp: number()
22510
+ });
22511
+ /**
22512
+ * One stored sighting on a track's trajectory.
22513
+ *
22514
+ * The array these live in is returned in TIME order (D399) — it is APPENDED in
22515
+ * arrival order, and the two detector passes interleave, so a consumer must not
22516
+ * assume the two are the same on a row written by an older build.
22517
+ */
22518
+ var TrackPositionSchema = object({
22519
+ x: number(),
22520
+ y: number(),
22521
+ timestamp: number(),
22522
+ bbox: BoundingBoxSchema,
22485
22523
  /**
22486
- * Raw classifier labels this backend can emit (e.g. YAMNet's
22487
- * 521-class set or Apple SoundAnalysis's 303-class set). Used by
22488
- * the benchmark UI to populate the `enabledMicroClasses` filter
22489
- * specific to the selected backend without a separate fetch.
22524
+ * Which detector pass measured this box (D399): `frame` is the full-frame
22525
+ * pass on the analysis raster, `recovery` is the native-resolution
22526
+ * small-subject second pass (D377/D378). Both write into one array, and until
22527
+ * this field existed the only way to tell them apart was that full-frame boxes
22528
+ * are exact multiples of 1.2 while recovery boxes are full-precision floats.
22529
+ * Absent on rows written before D399.
22490
22530
  */
22491
- rawLabels: array(string()).readonly().optional()
22531
+ source: _enum(["frame", "recovery"]).optional(),
22532
+ /** Detection score of this box, so a position can be weighed and not only
22533
+ * plotted. Absent on rows written before D399. */
22534
+ score: number().optional()
22492
22535
  });
22493
- var AudioCapabilitiesSchema = object({
22494
- activeBackend: string(),
22495
- availableBackends: array(AudioBackendSchema).readonly(),
22496
- sampleRate: number(),
22497
- chunkDurationMs: number()
22536
+ var TrackSnapshotSchema = object({
22537
+ timestamp: number(),
22538
+ position: TrackPositionSchema,
22539
+ /** The snapshot's media row id (D482); resolve via `listTrackMedia({ trackId })`. */
22540
+ mediaId: number().int()
22498
22541
  });
22499
- var DownloadModelResultSchema = object({
22500
- filePath: string(),
22501
- sizeMB: number(),
22502
- durationMs: number()
22542
+ /**
22543
+ * Normalized 0..1 trajectory envelope (min/max over every position bbox,
22544
+ * divided by the track's detection-frame dims), computed at persist time.
22545
+ * Absent when the frame dims were unknown when the track was persisted
22546
+ * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
22547
+ */
22548
+ var TrackEnvelopeSchema = object({
22549
+ minX: number(),
22550
+ minY: number(),
22551
+ maxX: number(),
22552
+ maxY: number()
22503
22553
  });
22504
22554
  /**
22505
- * Wrapper carrying a single test run's result. Replaces the legacy
22506
- * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
22507
- * canonical `AudioResult` from the Phase 6 output rework: one
22508
- * `AudioDetection` per class above `minScore`, top-N candidates in
22509
- * `debug.alternateLabels['audio-classifier']`, per-source timings in
22510
- * `debug.stepTimings`. The outer `success`/`error` fields stay so the
22511
- * benchmark UI can still report a clean failure when the classifier
22512
- * cap isn't available.
22555
+ * Row projection for track list queries. `full` (default) returns the
22556
+ * complete Track including the frame-rate `positions[]` history and the
22557
+ * `snapshots[]` references — megabytes across a page of tracks. `slim`
22558
+ * keeps every scalar the list surfaces actually render (ids, class(es),
22559
+ * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
22560
+ * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
22561
+ * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
22562
+ * `getTrack`. Mirrors the event-store `projection` convention
22563
+ * (`getObjectEvents` et al.).
22513
22564
  */
22514
- var AudioTestResultSchema = object({
22515
- success: boolean(),
22516
- error: string().optional(),
22517
- frame: custom().optional()
22565
+ var TrackProjectionSchema = _enum(["full", "slim"]);
22566
+ /**
22567
+ * One audio-classification label heard on the track's camera while the
22568
+ * track was alive, aggregated per label. An "episode" is one persisted
22569
+ * audio event (the confident-classification path: score ≥ the device's
22570
+ * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
22571
+ * one 32 ms inference chunk, so counts stay human-scaled.
22572
+ */
22573
+ var TrackAudioLabelSchema = object({
22574
+ label: string(),
22575
+ /** Highest classification score observed across the label's episodes. */
22576
+ peakScore: number(),
22577
+ /** Number of coalesced audio-event episodes carrying this label. */
22578
+ count: number(),
22579
+ firstAt: number(),
22580
+ lastAt: number()
22518
22581
  });
22519
- var PipelineConfigBridge = custom();
22520
- var ConfigUISchemaBridge = custom();
22521
- var ConfigUISchemaNullableBridge = custom();
22522
- var InferenceCapabilitiesBridge = custom();
22523
- var ModelAvailabilityListBridge = custom();
22524
- var PipelineRunResultBridge = custom();
22525
22582
  /**
22526
- * Pipeline executor — detection engine + configuration + inference API.
22583
+ * How a track was produced. `pipeline` (default / absent) = the spatial
22584
+ * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
22585
+ * no positions, a single snapshot, and no bbox trajectory at all:
22527
22586
  *
22528
- * Merged from: pipeline-executor, pipeline-config, inference, detection-config.
22529
- * Implemented by the detection-pipeline addon.
22587
+ * - `sensor` — a linked sensor/control device state change.
22588
+ * - `audio` — an audio event on the camera itself that was anomalous for
22589
+ * THAT camera, loud, and heard while nothing visual was happening (D62).
22530
22590
  *
22531
- * Per-device surface (DeviceSettingsContribution + the "is detection
22532
- * enabled for this camera?" toggle) lives on the paired
22533
- * `detection-pipeline` cap (device-scoped, singleton, wrapper
22534
- * defaultActive) — same split pattern used by stream-broker /
22535
- * camera-streams and audio-analyzer / audio-analysis.
22536
- */
22537
- var pipelineExecutorCapability = {
22538
- name: "pipeline-executor",
22539
- scope: "system",
22540
- mode: "singleton",
22541
- methods: {
22542
- getAvailableEngines: method(_void(), array(PipelineEngineChoiceSchema)),
22543
- getSelectedEngine: method(_void(), PipelineEngineChoiceSchema),
22544
- getDefaultSteps: method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)),
22545
- /**
22546
- * Per-node detection-engine provisioning snapshot. Returns the live
22547
- * state of the lazy runtime-provisioning machine on `nodeId`
22548
- * (idle / installing / verifying / ready / failed). The UI pairs this
22549
- * one-shot query with the `pipeline.engine-provisioning` live event
22550
- * (emitted on every transition) to drive a per-node "engine ready?"
22551
- * indicator without polling. Phase 2.
22552
- */
22553
- getEngineProvisioning: method(object({ nodeId: string() }), EngineProvisioningSchema),
22554
- getVideoPipelineSteps: method(_void(), record(string(), object({
22555
- modelId: string(),
22556
- settings: record(string(), unknown()).readonly()
22557
- }))),
22558
- setVideoPipelineSteps: method(object({ steps: record(string(), object({
22559
- modelId: string(),
22560
- settings: record(string(), unknown()).readonly()
22561
- })) }), object({ success: literal(true) }), {
22562
- kind: "mutation",
22563
- auth: "admin"
22564
- }),
22565
- /**
22566
- * Clear THIS node's executor-side PER-DEVICE settings stores (the
22567
- * per-camera step overrides the object-detection root reads via
22568
- * `applyDeviceOverridesToTree`). `nodeId` is the ROUTING key — the
22569
- * generated cap-router strips it (default `nodeIdMode: 'routing'`) and
22570
- * dispatches to that node, so the provider method runs ON the target
22571
- * node and receives no `nodeId`.
22572
- *
22573
- * This is the slimmed executor leg of the orchestrator's
22574
- * `resetNodePipelineDefaults` flow (which owns the real reset: node
22575
- * addonDefaults pins + per-camera orchestrator overrides). The legacy
22576
- * `resetToDefault` — which reset a persisted global step-tree seed
22577
- * nothing in the live per-camera path read — was removed together with
22578
- * that seed.
22579
- */
22580
- clearDeviceOverrides: method(object({ nodeId: string() }), object({
22581
- success: literal(true),
22582
- clearedDevices: number()
22583
- }), {
22584
- kind: "mutation",
22585
- auth: "admin"
22586
- }),
22587
- /**
22588
- * Which of THIS node's inference devices the executor currently refuses,
22589
- * and why. `nodeId` is the ROUTING key (stripped by the generated router).
22590
- *
22591
- * The channel that did not exist. Pool health was known only inside the
22592
- * detection addon and was an input to no routing decision anywhere: the
22593
- * per-dispatch capability gate is keyed on model FORMAT and so can never
22594
- * separate `openvino:gpu` from `openvino:npu`, and the orchestrator's live
22595
- * eligibility probe (`platformProbe.getCapabilities`) answers about
22596
- * HARDWARE — which was present throughout. So when the hub's `openvino:gpu`
22597
- * Python worker was SIGABRT'd by the Intel GPU plugin on 2026-08-25, the
22598
- * balancer went on handing that dead pool cameras by rotation for 31 hours:
22599
- * ~370 000 `PoolWorker[w0]: not initialized` lines, every frame lost.
22600
- *
22601
- * Read semantics the caller depends on, and which the provider guarantees:
22602
- * this is a synchronous read of in-memory state. It never probes hardware,
22603
- * never spawns a pool and never throws — an EMPTY `unhealthy` means "asked,
22604
- * nothing is refused", which is what re-admits a device. A read that FAILS
22605
- * (node offline, version skew) must therefore be distinguishable from an
22606
- * empty answer, and it is: it rejects.
22607
- */
22608
- getInferenceDeviceHealth: method(object({ nodeId: string() }), object({ unhealthy: array(object({
22609
- /** `<backend>:<device>`, e.g. `openvino:gpu`. */
22610
- deviceKey: string(),
22611
- /**
22612
- * `failed` — the per-device restart budget is exhausted; no pool
22613
- * will be spawned until an operator re-arms it or the runner
22614
- * respawns. `backoff` — under budget, waiting out the backoff (or
22615
- * a cached pool observed dead and not yet condemned).
22616
- */
22617
- state: _enum(["failed", "backoff"]),
22618
- /** Epoch ms of the death that produced this state. */
22619
- since: number(),
22620
- /** Pool deaths inside the current window. */
22621
- deaths: number(),
22622
- /** The last death's message. */
22623
- lastError: string()
22624
- })).readonly() })),
22625
- /**
22626
- * Re-arm a terminally `failed` inference device on `nodeId`: forget its
22627
- * restart budget so the next dispatch builds a fresh pool.
22628
- *
22629
- * The terminal state is deliberate (the abort it bounds is deterministic —
22630
- * an automatic probation would just respawn Python forever, more slowly),
22631
- * and a terminal state an operator cannot leave is a silent fault. This is
22632
- * the way out. `rearmed:false` means there was nothing to forget.
22633
- */
22634
- rearmInferenceDevice: method(object({
22635
- nodeId: string(),
22636
- deviceKey: string()
22637
- }), object({ rearmed: boolean() }), {
22638
- kind: "mutation",
22639
- auth: "admin"
22640
- }),
22641
- getSchema: method(_void(), PipelineSchemaSchema),
22642
- getGlobalSteps: method(_void(), array(PipelineDefaultStepSchema).readonly().nullable()),
22643
- getGlobalPipelineConfig: method(_void(), PipelineConfigBridge),
22644
- getOrchestratorConfigSchema: method(_void(), ConfigUISchemaBridge),
22645
- /**
22646
- * Gate B (pre-init config-correctness gate). PURE COMPUTE against this
22647
- * node's `currentEngine.format` — resolves `steps` the same way the
22648
- * runtime dispatch path would, and reports what WOULD happen without
22649
- * touching any node-global state. Called by the orchestrator at attach
22650
- * time (`attachOn`), node-pinned to the TARGET node, so config problems
22651
- * surface BEFORE `pipelineRunner.attachCamera` rather than at the first
22652
- * per-frame resolve. `ok` is false iff `issues` is non-empty (both
22653
- * `unknown-addon` and `no-format-build` are HARD issues); `substitutions`
22654
- * is informational (a degraded-but-loadable model swap) and never
22655
- * affects `ok`. Never throws.
22656
- */
22657
- validatePipeline: method(object({ steps: array(PipelineStepInputSchema) }), PipelineValidationResultSchema),
22658
- listTemplates: method(_void(), array(PipelineTemplateSchema$1).readonly()),
22659
- saveTemplate: method(object({
22660
- name: string(),
22661
- steps: array(PipelineTemplateStepSchema).readonly(),
22662
- engine: PipelineEngineChoiceSchema
22663
- }), PipelineTemplateSchema$1, { kind: "mutation" }),
22664
- updateTemplate: method(object({
22665
- id: string(),
22666
- name: string().optional(),
22667
- steps: array(PipelineTemplateStepSchema).readonly().optional()
22668
- }), PipelineTemplateSchema$1, { kind: "mutation" }),
22669
- deleteTemplate: method(object({ id: string() }), _void(), { kind: "mutation" }),
22670
- getCapabilities: method(_void(), InferenceCapabilitiesBridge),
22671
- getAddonModels: method(object({ addonId: string() }), ModelAvailabilityListBridge),
22672
- downloadModel: method(object({
22673
- addonId: string(),
22674
- modelId: string(),
22675
- format: ModelFormatSchema$1
22676
- }), DownloadModelResultSchema, { kind: "mutation" }),
22677
- deleteModel: method(object({
22678
- addonId: string(),
22679
- modelId: string(),
22680
- format: ModelFormatSchema$1
22681
- }), object({ success: literal(true) }), { kind: "mutation" }),
22682
- /**
22683
- * Stateless single-frame execution. Callers (runner, benchmark) pass
22684
- * the complete `engine` + `steps` tree; the executor holds no state
22685
- * about cameras or saved pipelines.
22686
- *
22687
- * `engine` is optional during the migration window to preserve the
22688
- * legacy call shape used by existing benchmark code; once all
22689
- * callers pass it explicitly we make it required.
22690
- *
22691
- * Exactly one of `frame`, `frameRef`, `frameHandle`, `imageBase64`,
22692
- * `referenceImage` must be provided:
22693
- * - `frame`: runtime dispatch path (runner → decoded broker frame).
22694
- * Carries the raw buffer, dimensions, and format; the executor
22695
- * uses it directly without base64 round-tripping.
22696
- * - `frameHandle` (CB5): a zero-pixel shm `FrameHandle` for the SAME
22697
- * decoded frame. Both runner and executor are hub-local processes
22698
- * sharing `/dev/shm`, so the executor maps the named segment and
22699
- * reads the pixels back zero-copy — eliminating the ~1.2MB
22700
- * re-serialisation over UDS/MsgPack the `frame` path pays per call.
22701
- * High-risk: the FrameRing is a latest-wins seqlock with no
22702
- * refcount, so a recycled slot yields a null read; the executor
22703
- * then degrades to an empty result and the runner ships pixels via
22704
- * `frame` as the fallback (queue-depth gated on the runner side).
22705
- * - `imageBase64`: one-shot test path (benchmark ImageTab).
22706
- * - `referenceImage`: named file from the reference-image store.
22707
- */
22708
- runPipeline: method(object({
22709
- engine: PipelineEngineChoiceSchema.optional(),
22710
- steps: array(PipelineStepInputSchema).min(1),
22711
- frame: FrameInputSchema.optional(),
22712
- /**
22713
- * Process-local lazy frame. Valid only when caller and provider resolve
22714
- * in the same execution-group process; split/cross-node callers use
22715
- * `frame`/`image` inline compatibility instead.
22716
- */
22717
- frameRef: FrameRefSchema.optional(),
22718
- /**
22719
- * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
22720
- * the decoded pixels live in. One more member of the one-of
22721
- * frame/frameHandle/image/imageBase64/referenceImage group.
22722
- */
22723
- frameHandle: FrameHandleSchema.optional(),
22724
- imageBase64: string().optional(),
22725
- /**
22726
- * Binary JPEG bytes — preferred over `imageBase64` on internal
22727
- * hops (hub → forked worker via Moleculer MsgPack) because it
22728
- * skips the 33% base64 overhead + the per-call base64 decode on
22729
- * the detection-pipeline worker. Callers can pass either; exactly
22730
- * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
22731
- */
22732
- image: _instanceof(Uint8Array).optional(),
22733
- referenceImage: string().optional(),
22734
- deviceId: number().optional(),
22735
- sessionId: string().optional(),
22736
- /**
22737
- * Execution plane. 'full' (default) runs the whole tree — benchmark,
22738
- * reference-image, and detail-subtree calls. 'frame' is the live
22739
- * per-frame dispatch: ONLY root-plane steps run; crop children
22740
- * (inputClasses ≠ null) are skipped and served per-track via
22741
- * pipelineRunner.runDetailSubtree (two-plane design).
22742
- */
22743
- plane: _enum(["full", "frame"]).optional(),
22744
- /**
22745
- * Inference-device selector (Phase 2 multi-device). Format
22746
- * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
22747
- * Omitted ⇒ the runner's default device (current single-engine
22748
- * behaviour). Selects WHICH device pool of the node runs the call.
22749
- */
22750
- deviceKey: string().optional(),
22751
- /**
22752
- * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
22753
- * when the parent crop was resolved from the frame's retained NATIVE
22754
- * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
22755
- * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
22756
- * resolution from that surface — the SAME quality path faces already
22757
- * had — instead of the downscaled parent tile. `handle` keys the native
22758
- * surface (node-pinned to its owner); `cropFrameSpace` is the parent
22759
- * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
22760
- * the executor's crop-normalized child ROI back into frame-normalized
22761
- * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
22762
- * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
22763
- * (today's behaviour on the fallback path).
22764
- */
22765
- nativeCropRef: NativeCropRefSchema.optional()
22766
- }), PipelineRunResultBridge, { kind: "mutation" }),
22767
- /**
22768
- * Batched run — N raw frames packed into one cap call. The provider
22769
- * routes the batch through `SharedInferencePool.inferBatch`
22770
- * (`MSG_INFER_BATCH = 0x03`) so the IPC framing and JSON response
22771
- * envelope cost is amortised N:1 vs N concurrent `runPipeline`
22772
- * calls. Single root step + uniform model assumed; trees with crop
22773
- * children fall back to sequential execution.
22774
- *
22775
- * Used by `scripts/bench-batch-style.mts` for batch benchmarking —
22776
- * N frames in one call to amortise per-call IPC overhead.
22777
- */
22778
- runPipelineBatch: method(object({
22779
- engine: PipelineEngineChoiceSchema.optional(),
22780
- steps: array(PipelineStepInputSchema).min(1),
22781
- frames: array(FrameInputSchema).min(1).max(255),
22782
- deviceId: number().optional(),
22783
- sessionId: string().optional(),
22784
- /**
22785
- * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
22786
- * the batch to the Python pool's bench preprocess cache
22787
- * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
22788
- * preprocessed ONCE and every later inference is a pure-inference cache
22789
- * hit — the sustained-throughput run measures inference, not
22790
- * decode+preprocess+infer. Omitted/0 for live frames (all different →
22791
- * full preprocess every call, correct). Fresh per sustained run;
22792
- * released via `uncacheFrame`.
22793
- */
22794
- frameId: number().int().nonnegative().optional(),
22795
- /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
22796
- deviceKey: string().optional()
22797
- }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }),
22798
- /**
22799
- * Cache a raw frame inside the Python inference pool's memory.
22800
- * Returns a numeric `frameId` that `inferCached` references —
22801
- * subsequent calls send only 5 bytes through the pipe instead of
22802
- * 1.2MB raw data, eliminating the pipe transfer bottleneck.
22803
- */
22804
- cacheFrameInPool: method(object({
22805
- data: _instanceof(Uint8Array),
22806
- width: number().int().positive(),
22807
- height: number().int().positive(),
22808
- format: _enum([
22809
- "rgb",
22810
- "bgr",
22811
- "gray"
22812
- ])
22813
- }), object({
22814
- frameId: number(),
22815
- width: number(),
22816
- height: number()
22817
- }), { kind: "mutation" }),
22818
- /**
22819
- * Run inference on a previously cached frame. Sends only 5 bytes
22820
- * (model_idx + frameId) through the IPC pipe — eliminates the
22821
- * ~35ms per-call overhead of transferring 1.2MB raw data.
22822
- */
22823
- inferCached: method(object({
22824
- stepId: string(),
22825
- frameId: number().int()
22826
- }), record(string(), unknown()), { kind: "mutation" }),
22827
- /**
22828
- * Release a cached frame from the Python pool's memory.
22829
- */
22830
- uncacheFrame: method(object({ frameId: number().int() }), _void(), { kind: "mutation" }),
22831
- /** Returns the effective pool tuning (resolved from user overrides + backend defaults). */
22832
- getEffectiveTuning: method(_void(), object({
22833
- batchMode: string(),
22834
- windowMs: number(),
22835
- maxBatchSize: number(),
22836
- concurrency: number()
22837
- })),
22838
- /**
22839
- * List every EngineFactory currently loaded in this executor's RAM,
22840
- * with the models resident and a coarse "in use" marker derived from
22841
- * ongoing inference activity. Used by the Pipeline page Engines tab.
22842
- */
22843
- listLoadedEngines: method(_void(), array(object({
22844
- engineKey: string(),
22845
- engine: PipelineEngineChoiceSchema,
22846
- modelsLoaded: array(string()).readonly(),
22847
- inUseByCameras: array(number()).readonly(),
22848
- /**
22849
- * Origin of this resident factory.
22850
- * - `runtime` — main camera-serving engine (no idle TTL).
22851
- * - `warm-override` — benchmark/test override held in the warm
22852
- * cache; auto-disposed after the idle TTL.
22853
- * - `device-pool` — a concurrent per-device pool (Phase 2
22854
- * multi-device, keyed by `deviceKey`) resolved
22855
- * via `resolveDeviceFactory`. Runs alongside the
22856
- * `runtime` engine on a DIFFERENT accelerator
22857
- * (NPU / iGPU / Coral) — this is how the
22858
- * Engines tab shows all pools running at once.
22859
- */
22860
- kind: _enum([
22861
- "runtime",
22862
- "warm-override",
22863
- "device-pool"
22864
- ]),
22865
- /** Native pid of the underlying Python pool (null when no pool). */
22866
- poolPid: number().nullable(),
22867
- /** ms since this factory was last used (null when not warm-tracked). */
22868
- idleMs: number().nullable(),
22869
- /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
22870
- idleTtlMs: number().nullable()
22871
- })).readonly()),
22872
- /** Warm up an engine without running a frame. No-op if already loaded. */
22873
- spinEngine: method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
22874
- kind: "mutation",
22875
- auth: "admin"
22876
- }),
22877
- /**
22878
- * Unload an engine from RAM. `force:true` unloads even when cameras
22879
- * are actively using it (they re-spin on next frame). Default is
22880
- * gated — returns `{success:false, reason}` when in use.
22881
- */
22882
- killEngine: method(object({
22883
- engine: PipelineEngineChoiceSchema,
22884
- force: boolean().optional()
22885
- }), object({
22886
- success: boolean(),
22887
- reason: string().optional()
22888
- }), {
22889
- kind: "mutation",
22890
- auth: "admin"
22891
- }),
22892
- listReferenceImages: method(_void(), array(ReferenceImageEntrySchema).readonly()),
22893
- getReferenceImage: method(object({ filename: string() }), ReferenceImageBodySchema.nullable()),
22894
- getReferenceAudioFiles: method(_void(), array(ReferenceAudioEntrySchema).readonly()),
22895
- getReferenceAudio: method(object({ filename: string() }), ReferenceAudioBodySchema.nullable()),
22896
- getAudioCapabilities: method(_void(), AudioCapabilitiesSchema),
22897
- runAudioTest: method(object({
22898
- addonId: string(),
22899
- modelId: string(),
22900
- filename: string().optional(),
22901
- settings: record(string(), unknown()).optional()
22902
- }), AudioTestResultSchema, { kind: "mutation" }),
22903
- getDetectionConfigSchema: method(_void(), ConfigUISchemaNullableBridge)
22904
- }
22905
- };
22906
- /**
22907
- * Per-stage gating mode applied to the zones a rule references.
22908
- *
22909
- * - `include`: the rule contributes to a **whitelist** for its stage.
22910
- * When at least one `include` rule fires for a stage, only entities
22911
- * inside one of those zones pass that stage.
22912
- * - `exclude`: the rule contributes to a **blacklist** for its stage.
22913
- * Entities inside one of those zones are dropped at that stage.
22914
- *
22915
- * `monitor`-style observation (count without filtering) is not a rule
22916
- * mode — zones without any matching rule are observed naturally by
22917
- * `zone-analytics` (live snapshot + history), so an "I just want to
22918
- * count, not filter" use case needs no rule at all.
22919
- */
22920
- var ZoneRuleModeEnum = _enum(["include", "exclude"]);
22921
- /**
22922
- * Per-consumer rule that references existing zones (geometry) and
22923
- * defines how a specific pipeline stage should treat them. Each
22924
- * consumer addon owns its own `ZoneRule[]` array in its per-device
22925
- * settings:
22926
- *
22927
- * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
22928
- * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
22929
- * - future: notification rules, audio gating, etc.
22930
- *
22931
- * One rule applies to N zones (`zoneIds[]`) so the operator can
22932
- * express "ignore motion in ALL of {garden, street}" with a single
22933
- * rule. `classFilter` narrows the rule to specific object classes —
22934
- * "drop person detections in the street, but keep cars" is one
22935
- * `exclude` rule with `classFilter: ['person']`.
22936
- *
22937
- * `enabled` is a soft toggle — the operator can keep the rule
22938
- * configured but inert without deleting it.
22939
- */
22940
- var ZoneRuleSchema = object({
22941
- /** Stable rule id — survives edits, used by the UI for diffing. */
22942
- id: string(),
22943
- /** Optional human-readable label rendered in the rule editor. */
22944
- name: string().optional(),
22945
- /** Zones this rule targets. The rule's `mode` applies to ALL
22946
- * listed zones (OR-set: a detection in any one of them counts).
22947
- * At least one zone id required — a rule with no targets is a
22948
- * configuration mistake and the form validator rejects it. */
22949
- zoneIds: array(string()).min(1).readonly(),
22950
- mode: ZoneRuleModeEnum,
22951
- /**
22952
- * Class names this rule applies to. Empty / undefined ⇒ rule
22953
- * applies to every class. Class strings match the `macroClass`
22954
- * field on detections (e.g. `person`, `car`, `dog`).
22955
- */
22956
- classFilter: array(string()).readonly().optional(),
22957
- /**
22958
- * Minimum bbox/mask overlap (0–1) with any of the rule's zones
22959
- * required to consider an entity "in the zone". Defaults to the
22960
- * consumer's stage default when omitted. Kept for back-compat with
22961
- * existing per-rule overrides; new operators pick the value via
22962
- * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
22963
- * set, the lower-level engine reads it as a 0–1 fraction.
22964
- */
22965
- overlapThreshold: number().min(0).max(1).optional(),
22966
- /**
22967
- * Operator-friendly version of `overlapThreshold` — the percentage
22968
- * of the detection's bbox that must lie inside the zone for the
22969
- * rule to match. Documented default is 85%; the engine substitutes
22970
- * that when the field is omitted (kept optional so existing rules
22971
- * stored without it stay valid).
22972
- *
22973
- * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
22974
- * rule, the engine prefers `bboxInclusionPct` because it's the
22975
- * field exposed in the UI. Internally both feed the same gate.
22976
- */
22977
- bboxInclusionPct: number().min(0).max(100).optional(),
22978
- /**
22979
- * When `true` and a detection has a segmentation mask, use the
22980
- * mask for overlap instead of the bbox. Detection-stage only;
22981
- * motion rules ignore this field.
22982
- */
22983
- preferMask: boolean().optional(),
22984
- /**
22985
- * Soft-toggle: `false` disables the rule without deleting it.
22986
- * Defaults to `true` so operators creating a rule via the UI
22987
- * see it active immediately.
22988
- */
22989
- enabled: boolean().default(true)
22990
- });
22991
- array(ZoneRuleSchema).readonly();
22992
- /**
22993
- * Zone — pure geometry + identity. NO filtering behaviour.
22994
- *
22995
- * Zones describe **where** in the frame the operator wants to flag
22996
- * something; consumer-owned {@link ZoneRule} arrays describe **how**
22997
- * each pipeline stage uses them. Splitting the two means a single
22998
- * polygon "Driveway" can simultaneously back a motion-exclude rule,
22999
- * a detection-include rule on `['car']`, and an occupancy aggregate
23000
- * — without three duplicated polygons.
23001
- *
23002
- * Owned by the orchestrator addon (provider) and mirrored into the
23003
- * `zones` device-state slice on every mutation. Consumers
23004
- * (motion-wasm, pipeline-executor, analytics, admin UI) read either
23005
- * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
23006
- * mirror with `onChanged`).
23007
- *
23008
- * Coordinates are normalised fractions of the frame (0–1) so zones
23009
- * survive resolution changes and stream profile switches.
23010
- *
23011
- * `kind` discriminates between full polygons (closed regions used
23012
- * for intrusion / occupancy filters) and tripwires (open 2-point
23013
- * line segments used for cross events). Onboard / firmware-reported
23014
- * zones (Reolink, ONVIF) are out of scope for now — see the deferred
23015
- * task list.
23016
- */
23017
- var ZoneKindEnum = _enum(["polygon", "tripwire"]);
23018
- /** Polygon vertex in fraction-of-frame coordinates (0–1). */
23019
- var PolygonPointSchema = object({
23020
- x: number(),
23021
- y: number()
23022
- });
23023
- /** A camera detection zone — pure geometry/identity. */
23024
- var ZoneSchema = object({
23025
- id: string(),
23026
- name: string(),
23027
- kind: ZoneKindEnum.default("polygon"),
23028
- /** Polygon vertices, fraction of frame (0–1). */
23029
- polygon: array(PolygonPointSchema).readonly(),
23030
- /** Visual color for UI rendering. */
23031
- color: string().default("#3b82f6")
23032
- });
23033
- /**
23034
- * Zones capability — per-camera CRUD over polygon detection zones.
23035
- *
23036
- * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
23037
- * to per-device settings and mirrors into the `zones` device-state
23038
- * slice on every mutation, so downstream consumers can subscribe via
23039
- * `dev.state.zones.onChanged`.
23040
- *
23041
- * The cap surface only handles geometry + identity; filtering
23042
- * behaviour (per-class, include/exclude, threshold) lives in the
23043
- * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
23044
- * `capabilities/schemas/zone-rule.js`.
23045
- */
23046
- var zonesCapability = {
23047
- name: "zones",
23048
- scope: "device",
23049
- mode: "singleton",
23050
- deviceTypes: [DeviceType.Camera],
23051
- methods: {
23052
- listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
23053
- addZone: method(object({
23054
- deviceId: number(),
23055
- zone: ZoneSchema
23056
- }), _void(), {
23057
- kind: "mutation",
23058
- auth: "admin"
23059
- }),
23060
- removeZone: method(object({
23061
- deviceId: number(),
23062
- zoneId: string()
23063
- }), _void(), {
23064
- kind: "mutation",
23065
- auth: "admin"
23066
- }),
23067
- updateZone: method(object({
23068
- deviceId: number(),
23069
- zone: ZoneSchema
23070
- }), _void(), {
23071
- kind: "mutation",
23072
- auth: "admin"
23073
- })
23074
- },
23075
- /**
23076
- * Runtime-state slice — the live zone catalogue mirrored by the
23077
- * orchestrator on every CRUD mutation. Consumers read via
23078
- * `device.state.zones.value` / `.watch(...)` without round-tripping
23079
- * the cap, and the codegen DeviceProxy auto-wires the reactive
23080
- * handle. Slice shape is `{ zones: Zone[] }` so future extensions
23081
- * (e.g. zone groupings) can sit alongside the polygon list.
23082
- */
23083
- runtimeState: object({ zones: array(ZoneSchema).readonly() }),
23084
- /**
23085
- * Runtime-state durability: **restored** — written only on operator mutation, so a camera that never had one has nothing to re-derive from. This is the slice `zone-mirror-hydration.ts` exists to paper over.
23086
- *
23087
- * See `RuntimeStateDurability`. Enforced by
23088
- * `scripts/check-runtime-state-durability.ts`.
23089
- */
23090
- durability: "restored"
23091
- };
23092
- /**
23093
- * pipeline-analytics — device-scoped wrapper cap. Refines raw
23094
- * per-frame detections emitted by the pipeline runner into tracked
23095
- * objects, per-kind event collections (motion / object / audio), and
23096
- * persisted media. Owns the post-detection domain end-to-end:
23097
- *
23098
- * runner emits PipelineInferenceResult
23099
- * ↓ (event bus)
23100
- * pipeline-analytics subscriber
23101
- * ↓ SORT tracker + zone engine + state analyzer + event emitter
23102
- * → three DB collections (one per kind), one FS media tree, one
23103
- * unified event emitter (FrameTracked + TrackStarted/Ended +
23104
- * DetectionEvent on bus)
23105
- *
23106
- * Pure subscriber model. No `processFrame` cap method — the runner
23107
- * already publishes the raw frame on the bus. The cap surface is
23108
- * only QUERIES + per-device settings, bound on/off via
23109
- * `device-manager.setWrapperActive`. `defaultActive: true` because
23110
- * every camera with a detection pipeline wants its raw detections
23111
- * refined; operators opt out per-device via BindingsTab when needed.
23112
- *
23113
- * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
23114
- * (per-device surface) and `track-trail` caps — see P11 cleanup.
23115
- */
23116
- var TrackStateSchema = _enum([
23117
- "new",
23118
- "entered",
23119
- "left",
23120
- "moving",
23121
- "idle"
23122
- ]);
23123
- var EventKindSchema = _enum([
23124
- "motion",
23125
- "object",
23126
- "audio"
23127
- ]);
23128
- /**
23129
- * Spatial filter for `listTracks` — the rect + polygon variants of the shared
23130
- * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
23131
- * of the camera frame (top-left origin), matching the drawing-plane editor.
23132
- */
23133
- var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
23134
- /** Closed icon vocabulary so clients render a known glyph per kind. */
23135
- var EventKindIconSchema = _enum([
23136
- "motion",
23137
- "audio",
23138
- "person",
23139
- "vehicle",
23140
- "animal",
23141
- "door",
23142
- "pir",
23143
- "smoke",
23144
- "water",
23145
- "button",
23146
- "package",
23147
- "generic"
23148
- ]);
23149
- var EventKindCategorySchema = _enum([
23150
- "motion",
23151
- "audio",
23152
- "detection",
23153
- "sensor",
23154
- "control",
23155
- "custom",
23156
- "package"
23157
- ]);
23158
- /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
23159
- var EventKindLevelSchema = _enum(["macro", "sub"]);
23160
- var EventKindDescriptorSchema = object({
23161
- /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
23162
- kind: string(),
23163
- /** i18n key resolved on the UI side; `label` is the English fallback. */
23164
- labelKey: string(),
23165
- /** English fallback label (kept for clients that don't translate). */
23166
- label: string(),
23167
- /** Hex color for timeline/legend rendering. */
23168
- color: string(),
23169
- /** Dictionary id → lucide component on the UI side. */
23170
- iconId: string(),
23171
- /** Legacy closed-vocab glyph — fallback for `iconId`. */
23172
- icon: EventKindIconSchema,
23173
- category: EventKindCategorySchema,
23174
- /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
23175
- parentKind: string().nullable(),
23176
- /** Derived from `parentKind`, explicit for the client tree. */
23177
- level: EventKindLevelSchema,
23178
- /** Which cap + device contributes this kind. For built-ins the camera
23179
- * itself; for sensor kinds the LINKED source device. */
23180
- source: object({
23181
- capName: string(),
23182
- deviceId: number()
23183
- })
23184
- });
23185
- /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
23186
- var EventKindsForDeviceSchema = object({
23187
- deviceId: number(),
23188
- kinds: array(EventKindDescriptorSchema).readonly()
23189
- });
23190
- var SensorEventSchema = object({
23191
- id: string(),
23192
- /** The CAMERA the event is attributed to (a sensor linked to N cameras
23193
- * yields N rows, one per camera). */
23194
- deviceId: number(),
23195
- /** The linked sensor device whose state changed. */
23196
- sourceDeviceId: number(),
23197
- /** Event kind id — matches an `EventKindDescriptor.kind`. */
23198
- kind: string(),
23199
- /** Snapshot of the sensor cap's runtime-state slice at the change. */
23200
- value: record(string(), unknown()).nullable(),
23201
- timestamp: number()
23202
- });
23203
- /**
23204
- * One stored sighting on a track's trajectory.
23205
- *
23206
- * The array these live in is returned in TIME order (D399) — it is APPENDED in
23207
- * arrival order, and the two detector passes interleave, so a consumer must not
23208
- * assume the two are the same on a row written by an older build.
23209
- */
23210
- var TrackPositionSchema = object({
23211
- x: number(),
23212
- y: number(),
23213
- timestamp: number(),
23214
- bbox: BoundingBoxSchema,
23215
- /**
23216
- * Which detector pass measured this box (D399): `frame` is the full-frame
23217
- * pass on the analysis raster, `recovery` is the native-resolution
23218
- * small-subject second pass (D377/D378). Both write into one array, and until
23219
- * this field existed the only way to tell them apart was that full-frame boxes
23220
- * are exact multiples of 1.2 while recovery boxes are full-precision floats.
23221
- * Absent on rows written before D399.
23222
- */
23223
- source: _enum(["frame", "recovery"]).optional(),
23224
- /** Detection score of this box, so a position can be weighed and not only
23225
- * plotted. Absent on rows written before D399. */
23226
- score: number().optional()
23227
- });
23228
- var TrackSnapshotSchema = object({
23229
- timestamp: number(),
23230
- position: TrackPositionSchema,
23231
- /** The snapshot's media row id (D482); resolve via `listTrackMedia({ trackId })`. */
23232
- mediaId: number().int()
23233
- });
23234
- /**
23235
- * Normalized 0..1 trajectory envelope (min/max over every position bbox,
23236
- * divided by the track's detection-frame dims), computed at persist time.
23237
- * Absent when the frame dims were unknown when the track was persisted
23238
- * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
23239
- */
23240
- var TrackEnvelopeSchema = object({
23241
- minX: number(),
23242
- minY: number(),
23243
- maxX: number(),
23244
- maxY: number()
23245
- });
23246
- /**
23247
- * Row projection for track list queries. `full` (default) returns the
23248
- * complete Track including the frame-rate `positions[]` history and the
23249
- * `snapshots[]` references — megabytes across a page of tracks. `slim`
23250
- * keeps every scalar the list surfaces actually render (ids, class(es),
23251
- * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
23252
- * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
23253
- * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
23254
- * `getTrack`. Mirrors the event-store `projection` convention
23255
- * (`getObjectEvents` et al.).
23256
- */
23257
- var TrackProjectionSchema = _enum(["full", "slim"]);
23258
- /**
23259
- * One audio-classification label heard on the track's camera while the
23260
- * track was alive, aggregated per label. An "episode" is one persisted
23261
- * audio event (the confident-classification path: score ≥ the device's
23262
- * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
23263
- * one 32 ms inference chunk, so counts stay human-scaled.
23264
- */
23265
- var TrackAudioLabelSchema = object({
23266
- label: string(),
23267
- /** Highest classification score observed across the label's episodes. */
23268
- peakScore: number(),
23269
- /** Number of coalesced audio-event episodes carrying this label. */
23270
- count: number(),
23271
- firstAt: number(),
23272
- lastAt: number()
23273
- });
23274
- /**
23275
- * How a track was produced. `pipeline` (default / absent) = the spatial
23276
- * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
23277
- * no positions, a single snapshot, and no bbox trajectory at all:
23278
- *
23279
- * - `sensor` — a linked sensor/control device state change.
23280
- * - `audio` — an audio event on the camera itself that was anomalous for
23281
- * THAT camera, loud, and heard while nothing visual was happening (D62).
23282
- *
23283
- * - `onboard` — the CAMERA's own firmware, paired with a decoded frame in
23284
- * that frame's pixel space. A real root detector and a SPATIAL one: its
23285
- * boxes are the same kind of fact `pipeline`'s are, produced by a different
23286
- * detector.
23287
- *
23288
- * `onboard` was missing here while `DetectionSourceSchema` already had it, so
23289
- * a persisted onboard track failed `safeParse` on read and came back with NO
23290
- * source at all — which `isSpatialTrack` then admitted by accident, through the
23291
- * `undefined` arm rather than by anybody's decision, and which `excludeSources`
23292
- * could not name.
23293
- *
23294
- * The spatial subsystems (tracker association, occupancy count, re-id /
23295
- * embedding, resurrection) MUST skip every synthetic source. Test for that
23296
- * with `isSpatialTrack`, which allow-lists the spatial sources explicitly — a
23297
- * `!== 'sensor'` check silently readmits every source added after it was
23298
- * written.
22591
+ * - `onboard` — the CAMERA's own firmware, paired with a decoded frame in
22592
+ * that frame's pixel space. A real root detector and a SPATIAL one: its
22593
+ * boxes are the same kind of fact `pipeline`'s are, produced by a different
22594
+ * detector.
22595
+ *
22596
+ * `onboard` was missing here while `DetectionSourceSchema` already had it, so
22597
+ * a persisted onboard track failed `safeParse` on read and came back with NO
22598
+ * source at all — which `isSpatialTrack` then admitted by accident, through the
22599
+ * `undefined` arm rather than by anybody's decision, and which `excludeSources`
22600
+ * could not name.
22601
+ *
22602
+ * The spatial subsystems (tracker association, occupancy count, re-id /
22603
+ * embedding, resurrection) MUST skip every synthetic source. Test for that
22604
+ * with `isSpatialTrack`, which allow-lists the spatial sources explicitly — a
22605
+ * `!== 'sensor'` check silently readmits every source added after it was
22606
+ * written.
23299
22607
  */
23300
22608
  var TrackSourceSchema = _enum([
23301
22609
  "pipeline",
@@ -23660,6 +22968,22 @@ var TrackSchema = object({
23660
22968
  * omit it. Render nothing when absent.
23661
22969
  */
23662
22970
  previewMissReason: string().optional(),
22971
+ /**
22972
+ * The ROOT model that produced this track — the `FrameResult.rootModelId` of
22973
+ * the frame it was BORN on (D646). What a later replay compares against, so
22974
+ * "the original model" is named rather than assumed. A birth fact: never
22975
+ * rewritten by a later frame. **Absent ≠ unknown-model**: a row from before
22976
+ * the column, and a track the camera's own detector produced, carry none.
22977
+ */
22978
+ modelId: string().optional(),
22979
+ /**
22980
+ * Size (px) of the detection frame this track's `positions[].bbox` live in —
22981
+ * the frame it was born on, else the camera's latest analysis frame at
22982
+ * persist time. Divide a position by these to normalise it. Absent when the
22983
+ * size was never known.
22984
+ */
22985
+ frameWidth: number().optional(),
22986
+ frameHeight: number().optional(),
23663
22987
  ...TrackFlagFields,
23664
22988
  ...TrackRetrainFields
23665
22989
  });
@@ -24666,24 +23990,6 @@ var MediaReclaimStatusSchema = object({
24666
23990
  finishedAtMs: number().nullable(),
24667
23991
  error: string().nullable()
24668
23992
  });
24669
- var ReplayFrameInputSchema = object({
24670
- timestamp: number(),
24671
- frame: PipelineRunResultBridge
24672
- });
24673
- var RunReplayFrameProcessorResultSchema = object({ tracks: array(object({
24674
- className: string(),
24675
- firstSeenMs: number(),
24676
- lastSeenMs: number(),
24677
- /** Bbox of the track's FIRST matched detection, pixel-space in the clip's
24678
- * frame — a representative box for the diff's `(className, window, IoU)`
24679
- * pairing (`replay-diff.ts`). A replay does not need the full per-frame
24680
- * trajectory production's `Track.positions` keeps. */
24681
- bbox: BoundingBoxSchema,
24682
- /** How many of the input frames this track matched a real detection on
24683
- * (never a coasted/extrapolated frame) — the replay's own signal for "how
24684
- * solid is this track", cheaper than re-deriving it from a trajectory. */
24685
- framesMatched: number().int()
24686
- })).readonly() });
24687
23993
  /**
24688
23994
  * The long-term series a camera produces. A closed union so a typo cannot
24689
23995
  * invent one, and the ONE declaration of it — the addon's `AnalyticsLtsSeries`
@@ -25272,392 +24578,1034 @@ var pipelineAnalyticsCapability = {
25272
24578
  * VERBATIM under `tracks/<deviceId>/<trackId>/…`. No crop is derived and no
25273
24579
  * model is run: a training set's pixels must be the pixels the pipeline saw.
25274
24580
  */
25275
- getTrainingExportUrl: method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
24581
+ getTrainingExportUrl: method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
24582
+ kind: "query",
24583
+ auth: "admin"
24584
+ }),
24585
+ /**
24586
+ * The staging worklist for one camera, or for every camera that has one.
24587
+ *
24588
+ * Fetched ON DEMAND, over the staging set only — the page never scans
24589
+ * history, because making the working set small is the entire purpose of
24590
+ * the mark. Each row carries how many frames the dataset already holds from
24591
+ * the track and how many subjects were annotated on them, so
24592
+ * `frameCount: 0` reads as "still to work" without a second call per track.
24593
+ *
24594
+ * `auth: 'admin'`, unlike the viewer-level mark itself: marking a track is
24595
+ * curation you do while looking at it, but building the training set the
24596
+ * fleet's models are fine-tuned on is not.
24597
+ */
24598
+ listRetrainStaging: method(object({
24599
+ /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
24600
+ * `deviceId`, deliberately: `deviceId` would make this device-bound and
24601
+ * route it at one camera's owner, and "every camera" would stop being
24602
+ * expressible at all. */
24603
+ deviceIds: array(number()).optional(),
24604
+ limit: number().int().min(1).max(500).optional()
24605
+ }), array(RetrainTrackSchema).readonly(), {
24606
+ kind: "query",
24607
+ auth: "admin"
24608
+ }),
24609
+ /**
24610
+ * What a track can contribute, and what it already has.
24611
+ *
24612
+ * `candidates` are the track's whole, unannotated frames — index rows only,
24613
+ * so this is cheap. `copies` are the frames already inside the dataset, and
24614
+ * a candidate whose copy exists is marked `copied: true`: selecting it again
24615
+ * is free and CANNOT fail, whatever became of the original.
24616
+ *
24617
+ * A crop, a thumbnail and `fullFrameBoxed` are never candidates. The last
24618
+ * one matters most: it has the model's own rectangle burned into the pixels,
24619
+ * and a detector trained on it learns to find a green line.
24620
+ */
24621
+ listRetrainFrames: method(object({ trackId: string() }), RetrainFrameListSchema, {
24622
+ kind: "query",
24623
+ auth: "admin"
24624
+ }),
24625
+ /**
24626
+ * COPY-ON-SELECT — the write that makes `trained` safe to evict.
24627
+ *
24628
+ * Selecting a frame copies its bytes into retrain storage immediately: not
24629
+ * a reference, not a lease. Once the copy exists the dataset no longer
24630
+ * depends on the track's media, which is exactly what lets D81 hand a
24631
+ * `trained` track back to retention.
24632
+ *
24633
+ * The order inside is load-bearing and is pinned by a test: an EXISTING
24634
+ * copy is returned without touching the source, so an original that
24635
+ * evaporated blocks the selection of THAT ORIGINAL and never the copy
24636
+ * already taken. Every refusal comes back named — a dropped selection is
24637
+ * never silent, on the wire or in the log.
24638
+ */
24639
+ selectRetrainFrames: method(object({
24640
+ deviceId: number(),
24641
+ trackId: string(),
24642
+ mediaIds: array(number().int()).min(1)
24643
+ }), RetrainFrameSelectionSchema, {
24644
+ kind: "mutation",
24645
+ auth: "admin"
24646
+ }),
24647
+ /** Un-select a frame: its annotations go first, then the copy and its blob.
24648
+ * Deliberately destructive and deliberately explicit — it is the only way
24649
+ * a frame leaves the dataset before export. */
24650
+ deselectRetrainFrame: method(object({
24651
+ deviceId: number(),
24652
+ trackId: string(),
24653
+ frameId: string()
24654
+ }), object({
24655
+ removed: boolean(),
24656
+ removedAnnotations: number().int()
24657
+ }), {
24658
+ kind: "mutation",
24659
+ auth: "admin"
24660
+ }),
24661
+ /**
24662
+ * The pixels of ONE copied frame, base64.
24663
+ *
24664
+ * Through the cap rather than a data plane because it is genuinely one
24665
+ * frame at a time, on demand, at human speed — the shape D9/D18 permit
24666
+ * (what they forbid is frames crossing a boundary at frame RATE). The
24667
+ * annotation canvas needs the image and its exact dimensions in the same
24668
+ * answer: a canvas that places a normalised box against a size it guessed
24669
+ * draws every box in the wrong place.
24670
+ */
24671
+ getRetrainFrameImage: method(object({ frameId: string() }), object({
24672
+ base64: string(),
24673
+ width: number().int(),
24674
+ height: number().int()
24675
+ }), {
24676
+ kind: "query",
24677
+ auth: "admin"
24678
+ }),
24679
+ /**
24680
+ * Ask the pipeline what it sees, as a PROPOSAL.
24681
+ *
24682
+ * Runs through `pipelineRunner.runStatelessStep` on the COPIED frame, and
24683
+ * every box comes back as a draft with `source: 'assist'` plus the model and
24684
+ * score that produced it. The operator confirms, edits, adds and deletes;
24685
+ * nothing is stored until `saveRetrainAnnotations`.
24686
+ *
24687
+ * For packages the request is `rfdetr-package` on the ZONE CROP at 0.35 —
24688
+ * never the whole frame, where a package detector at that threshold proposes
24689
+ * furniture. A package request with no zone is REFUSED rather than widened,
24690
+ * because the silent widening would look like a bad model for as long as
24691
+ * nobody checked which rectangle it ran on.
24692
+ */
24693
+ proposeRetrainAnnotations: method(object({
24694
+ deviceId: number(),
24695
+ trackId: string(),
24696
+ frameId: string(),
24697
+ subject: RetrainAssistSubjectSchema,
24698
+ /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
24699
+ nodeId: string().optional()
24700
+ }), RetrainAssistResultSchema, {
24701
+ kind: "mutation",
24702
+ auth: "admin"
24703
+ }),
24704
+ /** Every annotation on a track, oldest first. */
24705
+ listRetrainAnnotations: method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
24706
+ kind: "query",
24707
+ auth: "admin"
24708
+ }),
24709
+ /**
24710
+ * Replace EVERY annotation on one frame with the supplied set.
24711
+ *
24712
+ * Whole-frame replacement, not per-box upsert: the unit of ground truth is
24713
+ * the frame, and "the operator deleted a box" must be the same durable
24714
+ * outcome as "the operator never drew it". A per-box patch would let a frame
24715
+ * keep a box the operator removed on a surface that only knew about the
24716
+ * boxes it sent.
24717
+ *
24718
+ * Refuses a macro class typed into `label` or `subLabel` — the tiers are
24719
+ * separate and the guard is at the WRITE, because a mixed taxonomy cannot
24720
+ * be un-mixed by reading it.
24721
+ */
24722
+ saveRetrainAnnotations: method(object({
24723
+ deviceId: number(),
24724
+ trackId: string(),
24725
+ frameId: string(),
24726
+ annotations: array(RetrainAnnotationDraftSchema)
24727
+ }), array(RetrainAnnotationSchema).readonly(), {
24728
+ kind: "mutation",
24729
+ auth: "admin"
24730
+ }),
24731
+ /**
24732
+ * Finish with a track: `staging → trained`. **The only writer of that
24733
+ * state** — D81 shipped the column with it deliberately unreachable.
24734
+ *
24735
+ * Refuses a track the dataset holds no copies from. `trained` un-pins the
24736
+ * track's media, so completing without a copy is a delete order for material
24737
+ * nothing ever extracted anything from; that refusal IS the safety argument
24738
+ * of D81, expressed as a precondition.
24739
+ */
24740
+ completeRetrainTrack: method(object({
24741
+ deviceId: number(),
24742
+ trackId: string()
24743
+ }), RetrainTransitionResultSchema, {
24744
+ kind: "mutation",
24745
+ auth: "admin"
24746
+ }),
24747
+ /**
24748
+ * The deliberate return: `trained → staging`, for the rare case.
24749
+ *
24750
+ * The generic `setTrackFlags` toggle refuses this in both directions by
24751
+ * design (D81) — re-staging from a checkbox is how the same material gets
24752
+ * annotated twice under two ground truths. Doing it here means the operator
24753
+ * is looking at the annotations that already exist while they decide, and
24754
+ * those annotations are LEFT ALONE: "put this back" must not be a
24755
+ * destructive act wearing a navigational name.
24756
+ */
24757
+ restageRetrainTrack: method(object({
24758
+ deviceId: number(),
24759
+ trackId: string()
24760
+ }), RetrainTransitionResultSchema, {
24761
+ kind: "mutation",
24762
+ auth: "admin"
24763
+ }),
24764
+ /**
24765
+ * Where to download the ANNOTATED dataset.
24766
+ *
24767
+ * The sibling of `getTrainingExportUrl` and deliberately not the same
24768
+ * archive: that one streams a marked track's stored media verbatim, this one
24769
+ * streams the retrain COPIES plus an `annotations.json` carrying, for every
24770
+ * subject, the canonical full-frame box AND the geometry derived for each
24771
+ * model shape (letterboxed root / zone-cropped package / subject-cropped
24772
+ * classifier). Derived at export, never stored — one box in, three shapes
24773
+ * out, so two crops of the same subject can never end up in one feature
24774
+ * space (D52).
24775
+ */
24776
+ getRetrainExportUrl: method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
25276
24777
  kind: "query",
25277
24778
  auth: "admin"
25278
24779
  }),
25279
24780
  /**
25280
- * The staging worklist for one camera, or for every camera that has one.
24781
+ * The media an EVENT owns.
25281
24782
  *
25282
- * Fetched ON DEMAND, over the staging set only — the page never scans
25283
- * history, because making the working set small is the entire purpose of
25284
- * the mark. Each row carries how many frames the dataset already holds from
25285
- * the track and how many subjects were annotated on them, so
25286
- * `frameCount: 0` reads as "still to work" without a second call per track.
24783
+ * `ownerType` is REQUIRED, and that is the whole correction (D482). An
24784
+ * event is a row in ONE of three tables, and since D474 each numbers from
24785
+ * 1 independently: `motion:101314` and `object:101314` both exist. This
24786
+ * method took a bare `eventId` and the provider probed motion → object →
24787
+ * audio, stopping at the first hit — so on the live hub, where object
24788
+ * events own no media of their own and 299 883 of 300 559 media rows are
24789
+ * motion-owned, EVERY object event resolved to its motion namesake. A
24790
+ * track from 17:34 on camera 615 was served a snapshot from 22:35 eleven
24791
+ * days earlier, silently.
25287
24792
  *
25288
- * `auth: 'admin'`, unlike the viewer-level mark itself: marking a track is
25289
- * curation you do while looking at it, but building the training set the
25290
- * fleet's models are fine-tuned on is not.
24793
+ * D476 had already disambiguated the KEY (`motion:` vs `object:`); this is
24794
+ * the API catching up to it. Naming the table is not a "qualification" of
24795
+ * the ambiguity — a listing BY OWNER has no address to make surrogate: the
24796
+ * owner IS (table, id), and half of it is not a question.
25291
24797
  */
25292
- listRetrainStaging: method(object({
25293
- /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
25294
- * `deviceId`, deliberately: `deviceId` would make this device-bound and
25295
- * route it at one camera's owner, and "every camera" would stop being
25296
- * expressible at all. */
25297
- deviceIds: array(number()).optional(),
25298
- limit: number().int().min(1).max(500).optional()
25299
- }), array(RetrainTrackSchema).readonly(), {
25300
- kind: "query",
25301
- auth: "admin"
25302
- }),
24798
+ getEventMedia: method(object({
24799
+ /** Which of the three event tables owns the row. */
24800
+ ownerType: EventOwnerTypeSchema,
24801
+ /** The event's rowid in that table (D474: an event id is a number). */
24802
+ eventId: number().int(),
24803
+ kind: MediaFileKindEnum.optional(),
24804
+ deviceId: number()
24805
+ }), array(MediaFileSchema).readonly()),
24806
+ /** All media rows owned by a track. `kinds` narrows to a kind subset so a
24807
+ * client can fetch the SMALL display variants on open and pull the
24808
+ * multi-MB native variants only on demand (mirrors `getEventMedia.kind`).
24809
+ * Absent ⇒ every kind (back-compat). */
24810
+ getTrackMedia: method(object({
24811
+ trackId: string(),
24812
+ kinds: array(MediaFileKindEnum).optional(),
24813
+ deviceId: number()
24814
+ }), array(MediaFileSchema).readonly()),
25303
24815
  /**
25304
- * What a track can contribute, and what it already has.
24816
+ * What media a track HAS, without any of it.
25305
24817
  *
25306
- * `candidates` are the track's whole, unannotated frames — index rows only,
25307
- * so this is cheap. `copies` are the frames already inside the dataset, and
25308
- * a candidate whose copy exists is marked `copied: true`: selecting it again
25309
- * is free and CANNOT fail, whatever became of the original.
24818
+ * The detail view needs the shape of a track's media to build its strip —
24819
+ * which kinds exist, in what order, at what size — and then wants each tile
24820
+ * fetched as an image, not as base64 inside this response. Measured: the
24821
+ * full `getTrackMedia` is 5.3-7.7 MB and blocks the view; this manifest is
24822
+ * ~2 KB.
25310
24823
  *
25311
- * A crop, a thumbnail and `fullFrameBoxed` are never candidates. The last
25312
- * one matters most: it has the model's own rectangle burned into the pixels,
25313
- * and a detector trained on it learns to find a green line.
24824
+ * It also restores a fact a `kinds` filter destroys: filtering
24825
+ * `getTrackMedia` drops whole ROWS, taking `kind` and `sizeBytes` with
24826
+ * them, so a client that fetched only the small variants could no longer
24827
+ * tell a full-resolution variant existed — and the affordance that opens it
24828
+ * would silently disappear.
25314
24829
  */
25315
- listRetrainFrames: method(object({ trackId: string() }), RetrainFrameListSchema, {
25316
- kind: "query",
25317
- auth: "admin"
25318
- }),
24830
+ listTrackMedia: method(object({
24831
+ trackId: string(),
24832
+ deviceId: number()
24833
+ }), array(MediaFileInfoSchema).readonly()),
25319
24834
  /**
25320
- * COPY-ON-SELECT — the write that makes `trained` safe to evict.
24835
+ * What media an EVENT has, without any of it — the twin `getEventMedia`
24836
+ * never had.
25321
24837
  *
25322
- * Selecting a frame copies its bytes into retrain storage immediately: not
25323
- * a reference, not a lease. Once the copy exists the dataset no longer
25324
- * depends on the track's media, which is exactly what lets D81 hand a
25325
- * `trained` track back to retention.
24838
+ * `listTrackMedia` above got this treatment because a track's media is
24839
+ * 5-8 MB. An event's is worse per row, not better: an old-style event owns
24840
+ * a `crop` AND a native-resolution `fullFrameBoxed`, and the track DETAIL
24841
+ * modal — the one surface that legitimately shows the big kinds — unions
24842
+ * both listings to build its filmstrip. It then renders every tile from
24843
+ * the `event-media` plane by key and throws the bytes away. Measured on
24844
+ * the live hub: one event's `fullFrameBoxed` is 2 824 077 B, base64'd to
24845
+ * ~3.8 MB, allocated whole in hub-main's heap, for a list of keys.
25326
24846
  *
25327
- * The order inside is load-bearing and is pinned by a test: an EXISTING
25328
- * copy is returned without touching the source, so an original that
25329
- * evaporated blocks the selection of THAT ORIGINAL and never the copy
25330
- * already taken. Every refusal comes back named — a dropped selection is
25331
- * never silent, on the wire or in the log.
24847
+ * Same `deviceId` authorization subject as `getEventMedia`, the same
24848
+ * REQUIRED `ownerType` (read that method's docblock for the night-time
24849
+ * thumbnail this closes — D482), and the same rows: this is a projection
24850
+ * of that method, never a different question.
25332
24851
  */
25333
- selectRetrainFrames: method(object({
24852
+ listEventMedia: method(object({
24853
+ ownerType: EventOwnerTypeSchema,
24854
+ eventId: number().int(),
24855
+ deviceId: number()
24856
+ }), array(MediaFileInfoSchema).readonly()),
24857
+ /**
24858
+ * Which of `ownerIds` hold at least ONE media row — an INDEX read, never a
24859
+ * blob read, and the LICENCE `videoclips` needs to publish a `thumbnail`.
24860
+ *
24861
+ * The event-media URL is stamped from a template for every event in the
24862
+ * system, so "the plane is up" was being served as "there are bytes": 64 of
24863
+ * one camera's 179 clips pointed at a 404 (device 3836, 2026-08-17). This
24864
+ * is the question that turns the stamp into a claim.
24865
+ *
24866
+ * It is on the WIRE because the clip source is registered by the addon that
24867
+ * owns the FOOTAGE, not by this one (D560) — the probe used to be an
24868
+ * in-process `MediaStore` read. One call per OWNER KIND, never one per
24869
+ * owner: that N+1 is what `MediaStore.ownersWithMedia` was written to
24870
+ * prevent, and crossing a process boundary makes it worse, not better.
24871
+ * `ownerIds` is bounded at the same 5 000 the annotation fetch is bounded
24872
+ * at, so one pathological camera-day cannot mint an unbounded request.
24873
+ *
24874
+ * THROWS rather than answering partially. A probe that quietly
24875
+ * under-reports reads as "these owners have nothing" and the caller drops
24876
+ * thumbnails that exist — the opposite failure to the one above, and
24877
+ * equally invisible.
24878
+ *
24879
+ * `deviceId` is the authorization subject, exactly as on `getEventMedia`.
24880
+ */
24881
+ ownersWithMedia: method(object({
25334
24882
  deviceId: number(),
25335
- trackId: string(),
25336
- mediaIds: array(number().int()).min(1)
25337
- }), RetrainFrameSelectionSchema, {
24883
+ ownerKind: MediaPresenceOwnerKindSchema,
24884
+ ownerIds: array(string()).max(5e3)
24885
+ }), array(string()).readonly()),
24886
+ /**
24887
+ * Search object events by text query using CLIP cosine similarity.
24888
+ * Encodes `text` via the `embedding-encoder` cap, queries the
24889
+ * `ObjectEmbeddingStore` with optional prefilters, ranks all matching
24890
+ * embeddings by cosine similarity, and joins winners to their
24891
+ * ObjectEvents by trackId. Returns up to `limit` events scored ≥
24892
+ * `minScore`, sorted descending by score.
24893
+ */
24894
+ searchObjectEvents: method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()),
24895
+ wipeObjectEmbeddings: method(object({}), WipeObjectEmbeddingsResultSchema, {
25338
24896
  kind: "mutation",
25339
24897
  auth: "admin"
25340
24898
  }),
25341
- /** Un-select a frame: its annotations go first, then the copy and its blob.
25342
- * Deliberately destructive and deliberately explicit — it is the only way
25343
- * a frame leaves the dataset before export. */
25344
- deselectRetrainFrame: method(object({
25345
- deviceId: number(),
25346
- trackId: string(),
25347
- frameId: string()
25348
- }), object({
25349
- removed: boolean(),
25350
- removedAnnotations: number().int()
25351
- }), {
24899
+ rebuildObjectEmbeddings: method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
25352
24900
  kind: "mutation",
25353
24901
  auth: "admin"
25354
24902
  }),
24903
+ getObjectEmbeddingRebuildStatus: method(object({}), RebuildStatusSchema)
24904
+ },
24905
+ events: {
25355
24906
  /**
25356
- * The pixels of ONE copied frame, base64.
25357
- *
25358
- * Through the cap rather than a data plane because it is genuinely one
25359
- * frame at a time, on demand, at human speed — the shape D9/D18 permit
25360
- * (what they forbid is frames crossing a boundary at frame RATE). The
25361
- * annotation canvas needs the image and its exact dimensions in the same
25362
- * answer: a canvas that places a normalised box against a size it guessed
25363
- * draws every box in the wrong place.
24907
+ * Enriched frame emitted after refinement — the live-overlay source of
24908
+ * truth (two-plane re-injection). Carries the frame's detections in the
24909
+ * `ObjectDetection` wire shape: first-level roots (with track info +
24910
+ * enrichment labels) plus synthesized `kind:'detail'` face/plate entries
24911
+ * re-projected from per-track detail state, so stream overlays render
24912
+ * boxes + recognized names without querying full Track state.
25364
24913
  */
25365
- getRetrainFrameImage: method(object({ frameId: string() }), object({
25366
- base64: string(),
25367
- width: number().int(),
25368
- height: number().int()
25369
- }), {
25370
- kind: "query",
25371
- auth: "admin"
25372
- }),
25373
- /**
25374
- * Ask the pipeline what it sees, as a PROPOSAL.
25375
- *
25376
- * Runs through `pipelineRunner.runStatelessStep` on the COPIED frame, and
25377
- * every box comes back as a draft with `source: 'assist'` plus the model and
25378
- * score that produced it. The operator confirms, edits, adds and deletes;
25379
- * nothing is stored until `saveRetrainAnnotations`.
25380
- *
25381
- * For packages the request is `rfdetr-package` on the ZONE CROP at 0.35 —
25382
- * never the whole frame, where a package detector at that threshold proposes
25383
- * furniture. A package request with no zone is REFUSED rather than widened,
25384
- * because the silent widening would look like a bad model for as long as
25385
- * nobody checked which rectangle it ran on.
24914
+ onFrameTracked: { data: object({
24915
+ deviceId: number(),
24916
+ timestamp: number(),
24917
+ frameWidth: number(),
24918
+ frameHeight: number(),
24919
+ detections: array(OverlayDetectionSchema).readonly()
24920
+ }) },
24921
+ /** Track entered active state (first-seen). */
24922
+ onTrackStarted: { data: object({
24923
+ deviceId: number(),
24924
+ trackId: string(),
24925
+ className: string()
24926
+ }) },
24927
+ /** Track expired (TTL reached after last detection). */
24928
+ onTrackEnded: { data: object({
24929
+ deviceId: number(),
24930
+ trackId: string(),
24931
+ className: string(),
24932
+ durationMs: number()
24933
+ }) },
24934
+ /** Canonical "something happened at device X" event, per-kind. */
24935
+ onDetectionEvent: { data: object({
24936
+ deviceId: number(),
24937
+ kind: EventKindSchema,
24938
+ eventId: string(),
24939
+ timestamp: number()
24940
+ }) }
24941
+ }
24942
+ };
24943
+ /**
24944
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
24945
+ * within the frame, so the executor can re-cut a leaf child ROI at native
24946
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
24947
+ */
24948
+ var NativeCropRefSchema = object({
24949
+ /** Handle keying the retained native surface (node-pinned to its owner). */
24950
+ handle: FrameHandleSchema,
24951
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
24952
+ cropFrameSpace: object({
24953
+ x: number(),
24954
+ y: number(),
24955
+ w: number(),
24956
+ h: number()
24957
+ })
24958
+ });
24959
+ object({
24960
+ crop: object({
24961
+ left: number(),
24962
+ top: number(),
24963
+ width: number().positive(),
24964
+ height: number().positive()
24965
+ }).optional(),
24966
+ content: object({
24967
+ width: number().int().positive(),
24968
+ height: number().int().positive()
24969
+ }),
24970
+ fit: _enum(["stretch", "contain"]),
24971
+ format: _enum([
24972
+ "rgb",
24973
+ "gray",
24974
+ "jpeg"
24975
+ ])
24976
+ });
24977
+ /**
24978
+ * Process-local frame identity. It is serializable so it can ride an in-process
24979
+ * capability call, but `registryId` deliberately prevents resolution in any
24980
+ * other process or execution group.
24981
+ */
24982
+ var FrameRefSchema = object({
24983
+ registryId: string().min(1),
24984
+ id: string().min(1),
24985
+ width: number().int().positive(),
24986
+ height: number().int().positive(),
24987
+ format: _enum(["rgb", "gray"]),
24988
+ timestamp: number(),
24989
+ capturedAt: number().optional()
24990
+ });
24991
+ var ModelFormatSchema$1 = _enum([
24992
+ "onnx",
24993
+ "coreml",
24994
+ "openvino",
24995
+ "tflite",
24996
+ "pt",
24997
+ "gguf"
24998
+ ]);
24999
+ var PipelineSlotSchema = _enum([
25000
+ "detector",
25001
+ "cropper",
25002
+ "classifier",
25003
+ "refiner",
25004
+ "audio-classifier"
25005
+ ]);
25006
+ var PipelineEngineChoiceSchema = object({
25007
+ runtime: literal("python"),
25008
+ backend: string(),
25009
+ format: ModelFormatSchema$1,
25010
+ device: string().optional()
25011
+ });
25012
+ /**
25013
+ * One pool's resolved provisioning (`getEffectiveTuning`). `numWorkers` is the
25014
+ * knob that lifts a saturated pool (`inference-devices.md`); `concurrency` is
25015
+ * per-worker in-flight requests. `deviceKey` echoes the pool asked about —
25016
+ * `null` for the node-default pool.
25017
+ */
25018
+ var EffectiveTuningSchema = object({
25019
+ deviceKey: string().nullable(),
25020
+ runtime: string(),
25021
+ batchMode: string(),
25022
+ windowMs: number(),
25023
+ maxBatchSize: number(),
25024
+ concurrency: number(),
25025
+ numWorkers: number()
25026
+ });
25027
+ var AvailableEngineSchema = object({
25028
+ engine: PipelineEngineChoiceSchema,
25029
+ devices: array(object({
25030
+ id: string(),
25031
+ label: string(),
25032
+ description: string().optional()
25033
+ })).readonly(),
25034
+ defaultDevice: string()
25035
+ });
25036
+ var PipelineDefaultStepSchema = lazy(() => object({
25037
+ addonId: string(),
25038
+ addonName: string(),
25039
+ slot: PipelineSlotSchema,
25040
+ inputClasses: array(string()).readonly(),
25041
+ outputClasses: array(string()).readonly(),
25042
+ enabled: boolean(),
25043
+ modelId: string(),
25044
+ children: array(PipelineDefaultStepSchema).readonly(),
25045
+ group: string().optional(),
25046
+ settings: record(string(), unknown()).optional()
25047
+ }));
25048
+ var PipelineTemplateStepSchema = lazy(() => object({
25049
+ addonId: string(),
25050
+ enabled: boolean(),
25051
+ modelId: string(),
25052
+ children: array(PipelineTemplateStepSchema).readonly(),
25053
+ settings: record(string(), unknown()).optional()
25054
+ }));
25055
+ var PipelineTemplateSchema$1 = object({
25056
+ id: string(),
25057
+ name: string(),
25058
+ createdAt: string(),
25059
+ updatedAt: string(),
25060
+ engine: PipelineEngineChoiceSchema,
25061
+ steps: array(PipelineTemplateStepSchema).readonly()
25062
+ });
25063
+ var PipelineModelOptionSchema = object({
25064
+ id: string(),
25065
+ name: string(),
25066
+ formats: record(string(), object({
25067
+ downloaded: boolean(),
25068
+ sizeMB: number()
25069
+ })),
25070
+ group: ModelVariantGroupSchema.optional(),
25071
+ legacy: boolean().optional(),
25072
+ provider: ModelProviderIdSchema.optional()
25073
+ });
25074
+ var ConfigFieldBridge = custom();
25075
+ var PipelineAddonSchemaSchema = object({
25076
+ id: string(),
25077
+ name: string(),
25078
+ slot: PipelineSlotSchema,
25079
+ inputClasses: array(string()).readonly(),
25080
+ outputClasses: array(string()).readonly(),
25081
+ childSlots: array(PipelineSlotSchema).readonly(),
25082
+ models: array(PipelineModelOptionSchema).readonly(),
25083
+ defaultModelId: string(),
25084
+ defaultModelIdByFormat: record(string(), string()).optional(),
25085
+ enabledByDefault: boolean().optional(),
25086
+ backfillIntoExistingOverrides: boolean().optional(),
25087
+ defaultConfidence: number(),
25088
+ group: string().optional(),
25089
+ configSchema: array(ConfigFieldBridge).readonly().optional()
25090
+ });
25091
+ var PipelineSlotSchemaSchema = object({
25092
+ id: PipelineSlotSchema,
25093
+ label: string(),
25094
+ priority: number(),
25095
+ parentSlot: PipelineSlotSchema.nullable(),
25096
+ addons: array(PipelineAddonSchemaSchema).readonly()
25097
+ });
25098
+ var PipelineSchemaSchema = object({
25099
+ availableEngines: array(AvailableEngineSchema).readonly(),
25100
+ selectedEngine: PipelineEngineChoiceSchema,
25101
+ slots: array(PipelineSlotSchemaSchema).readonly()
25102
+ });
25103
+ var EngineProvisioningSchema = object({
25104
+ runtimeId: _enum([
25105
+ "onnx",
25106
+ "openvino",
25107
+ "coreml",
25108
+ "edgetpu"
25109
+ ]).nullable(),
25110
+ device: string().nullable(),
25111
+ state: _enum([
25112
+ "idle",
25113
+ "installing",
25114
+ "verifying",
25115
+ "ready",
25116
+ "failed"
25117
+ ]),
25118
+ progress: number().optional(),
25119
+ error: string().optional(),
25120
+ nextRetryAt: number().optional(),
25121
+ /**
25122
+ * Gate A (config-correctness gate at engine change): human-readable
25123
+ * config issues surfaced EAGERLY when the node's engine changes — model
25124
+ * substitutions ("chose X, running Y") and zero-build steps ("no model
25125
+ * has a <format> build"). Additive/optional: informational only, never
25126
+ * enforced here — `assertEngineReady` (readiness) still gates inference.
25127
+ * Absent/empty when the node-default tree resolves cleanly.
25128
+ */
25129
+ configIssues: array(string()).optional()
25130
+ });
25131
+ var PipelineStepInputSchema = lazy(() => object({
25132
+ addonId: string(),
25133
+ modelId: string().optional(),
25134
+ enabled: boolean().default(true),
25135
+ children: array(PipelineStepInputSchema).optional(),
25136
+ settings: record(string(), unknown()).optional(),
25137
+ jumpDeviceKey: string().optional()
25138
+ }));
25139
+ var ModelSubstitutionSchema = object({
25140
+ addonId: string(),
25141
+ chosen: string(),
25142
+ running: string(),
25143
+ format: string()
25144
+ });
25145
+ var PipelineValidationIssueSchema = object({
25146
+ addonId: string(),
25147
+ kind: _enum([
25148
+ "unknown-addon",
25149
+ "no-format-build",
25150
+ "unknown-device"
25151
+ ]),
25152
+ detail: string()
25153
+ });
25154
+ var PipelineValidationResultSchema = object({
25155
+ ok: boolean(),
25156
+ issues: array(PipelineValidationIssueSchema).readonly(),
25157
+ substitutions: array(ModelSubstitutionSchema).readonly(),
25158
+ /** The node's `currentEngine.format` this validation ran against. */
25159
+ format: string()
25160
+ });
25161
+ var ReferenceImageEntrySchema = object({
25162
+ filename: string(),
25163
+ stepIds: array(string()).readonly().optional()
25164
+ });
25165
+ var ReferenceImageBodySchema = object({
25166
+ base64: string(),
25167
+ filename: string()
25168
+ });
25169
+ var ReferenceAudioEntrySchema = object({
25170
+ filename: string(),
25171
+ sizeKb: number()
25172
+ });
25173
+ var ReferenceAudioBodySchema = object({ base64: string() });
25174
+ var AudioBackendSchema = object({
25175
+ id: string(),
25176
+ name: string(),
25177
+ description: string(),
25178
+ available: boolean(),
25179
+ /**
25180
+ * Raw classifier labels this backend can emit (e.g. YAMNet's
25181
+ * 521-class set or Apple SoundAnalysis's 303-class set). Used by
25182
+ * the benchmark UI to populate the `enabledMicroClasses` filter
25183
+ * specific to the selected backend without a separate fetch.
25184
+ */
25185
+ rawLabels: array(string()).readonly().optional()
25186
+ });
25187
+ var AudioCapabilitiesSchema = object({
25188
+ activeBackend: string(),
25189
+ availableBackends: array(AudioBackendSchema).readonly(),
25190
+ sampleRate: number(),
25191
+ chunkDurationMs: number()
25192
+ });
25193
+ var DownloadModelResultSchema = object({
25194
+ filePath: string(),
25195
+ sizeMB: number(),
25196
+ durationMs: number()
25197
+ });
25198
+ /**
25199
+ * Wrapper carrying a single test run's result. Replaces the legacy
25200
+ * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
25201
+ * canonical `AudioResult` from the Phase 6 output rework: one
25202
+ * `AudioDetection` per class above `minScore`, top-N candidates in
25203
+ * `debug.alternateLabels['audio-classifier']`, per-source timings in
25204
+ * `debug.stepTimings`. The outer `success`/`error` fields stay so the
25205
+ * benchmark UI can still report a clean failure when the classifier
25206
+ * cap isn't available.
25207
+ */
25208
+ var AudioTestResultSchema = object({
25209
+ success: boolean(),
25210
+ error: string().optional(),
25211
+ frame: custom().optional()
25212
+ });
25213
+ var PipelineConfigBridge = custom();
25214
+ var ConfigUISchemaBridge = custom();
25215
+ var ConfigUISchemaNullableBridge = custom();
25216
+ var InferenceCapabilitiesBridge = custom();
25217
+ var ModelAvailabilityListBridge = custom();
25218
+ var PipelineRunResultBridge = custom();
25219
+ /**
25220
+ * Pipeline executor — detection engine + configuration + inference API.
25221
+ *
25222
+ * Merged from: pipeline-executor, pipeline-config, inference, detection-config.
25223
+ * Implemented by the detection-pipeline addon.
25224
+ *
25225
+ * Per-device surface (DeviceSettingsContribution + the "is detection
25226
+ * enabled for this camera?" toggle) lives on the paired
25227
+ * `detection-pipeline` cap (device-scoped, singleton, wrapper
25228
+ * defaultActive) — same split pattern used by stream-broker /
25229
+ * camera-streams and audio-analyzer / audio-analysis.
25230
+ */
25231
+ var pipelineExecutorCapability = {
25232
+ name: "pipeline-executor",
25233
+ scope: "system",
25234
+ mode: "singleton",
25235
+ methods: {
25236
+ getAvailableEngines: method(_void(), array(PipelineEngineChoiceSchema)),
25237
+ getSelectedEngine: method(_void(), PipelineEngineChoiceSchema),
25238
+ getDefaultSteps: method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)),
25239
+ /**
25240
+ * Per-node detection-engine provisioning snapshot. Returns the live
25241
+ * state of the lazy runtime-provisioning machine on `nodeId`
25242
+ * (idle / installing / verifying / ready / failed). The UI pairs this
25243
+ * one-shot query with the `pipeline.engine-provisioning` live event
25244
+ * (emitted on every transition) to drive a per-node "engine ready?"
25245
+ * indicator without polling. Phase 2.
25386
25246
  */
25387
- proposeRetrainAnnotations: method(object({
25388
- deviceId: number(),
25389
- trackId: string(),
25390
- frameId: string(),
25391
- subject: RetrainAssistSubjectSchema,
25392
- /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
25393
- nodeId: string().optional()
25394
- }), RetrainAssistResultSchema, {
25247
+ getEngineProvisioning: method(object({ nodeId: string() }), EngineProvisioningSchema),
25248
+ getVideoPipelineSteps: method(_void(), record(string(), object({
25249
+ modelId: string(),
25250
+ settings: record(string(), unknown()).readonly()
25251
+ }))),
25252
+ setVideoPipelineSteps: method(object({ steps: record(string(), object({
25253
+ modelId: string(),
25254
+ settings: record(string(), unknown()).readonly()
25255
+ })) }), object({ success: literal(true) }), {
25395
25256
  kind: "mutation",
25396
25257
  auth: "admin"
25397
25258
  }),
25398
25259
  /**
25399
- * The FrameProcessor pass of a replay run — see the `Replay` section
25400
- * above this capability's definition for why this is not the
25401
- * `processFrame` method this file's header says pipeline-analytics does
25402
- * not have.
25260
+ * Clear THIS node's executor-side PER-DEVICE settings stores (the
25261
+ * per-camera step overrides the object-detection root reads via
25262
+ * `applyDeviceOverridesToTree`). `nodeId` is the ROUTING key — the
25263
+ * generated cap-router strips it (default `nodeIdMode: 'routing'`) and
25264
+ * dispatches to that node, so the provider method runs ON the target
25265
+ * node and receives no `nodeId`.
25403
25266
  *
25404
- * Constructs a FRESH `FrameProcessor` for `(deviceId, source)`, feeds it
25405
- * `frames` IN THE ORDER GIVEN (the caller is responsible for time
25406
- * ordering — this method does not sort), and returns the tracks it
25407
- * produced. Zero persistence: no `TrackStore`, no event bus, no media
25408
- * capture. `zones` / `detectionRules` are the run's OWN zone set —
25409
- * typically the camera's real zones plus an ephemeral overlay
25410
- * (`addon-benchmark`'s `replay-plan.ts`), never read from or written to
25411
- * the `zones` capability by this method itself.
25267
+ * This is the slimmed executor leg of the orchestrator's
25268
+ * `resetNodePipelineDefaults` flow (which owns the real reset: node
25269
+ * addonDefaults pins + per-camera orchestrator overrides). The legacy
25270
+ * `resetToDefault` — which reset a persisted global step-tree seed
25271
+ * nothing in the live per-camera path read — was removed together with
25272
+ * that seed.
25412
25273
  */
25413
- runReplayFrameProcessor: method(object({
25414
- deviceId: number(),
25415
- source: DetectionSourceSchema,
25416
- zones: array(ZoneSchema).readonly().optional(),
25417
- detectionRules: array(ZoneRuleSchema).readonly().optional(),
25418
- zoneMembershipMinOverlap: number().min(0).max(1).optional(),
25419
- frames: array(ReplayFrameInputSchema).min(1)
25420
- }), RunReplayFrameProcessorResultSchema, {
25274
+ clearDeviceOverrides: method(object({ nodeId: string() }), object({
25275
+ success: literal(true),
25276
+ clearedDevices: number()
25277
+ }), {
25421
25278
  kind: "mutation",
25422
25279
  auth: "admin"
25423
25280
  }),
25424
- /** Every annotation on a track, oldest first. */
25425
- listRetrainAnnotations: method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
25426
- kind: "query",
25427
- auth: "admin"
25428
- }),
25429
25281
  /**
25430
- * Replace EVERY annotation on one frame with the supplied set.
25282
+ * Which of THIS node's inference devices the executor currently refuses,
25283
+ * and why. `nodeId` is the ROUTING key (stripped by the generated router).
25431
25284
  *
25432
- * Whole-frame replacement, not per-box upsert: the unit of ground truth is
25433
- * the frame, and "the operator deleted a box" must be the same durable
25434
- * outcome as "the operator never drew it". A per-box patch would let a frame
25435
- * keep a box the operator removed on a surface that only knew about the
25436
- * boxes it sent.
25285
+ * The channel that did not exist. Pool health was known only inside the
25286
+ * detection addon and was an input to no routing decision anywhere: the
25287
+ * per-dispatch capability gate is keyed on model FORMAT and so can never
25288
+ * separate `openvino:gpu` from `openvino:npu`, and the orchestrator's live
25289
+ * eligibility probe (`platformProbe.getCapabilities`) answers about
25290
+ * HARDWARE — which was present throughout. So when the hub's `openvino:gpu`
25291
+ * Python worker was SIGABRT'd by the Intel GPU plugin on 2026-08-25, the
25292
+ * balancer went on handing that dead pool cameras by rotation for 31 hours:
25293
+ * ~370 000 `PoolWorker[w0]: not initialized` lines, every frame lost.
25437
25294
  *
25438
- * Refuses a macro class typed into `label` or `subLabel` — the tiers are
25439
- * separate and the guard is at the WRITE, because a mixed taxonomy cannot
25440
- * be un-mixed by reading it.
25295
+ * Read semantics the caller depends on, and which the provider guarantees:
25296
+ * this is a synchronous read of in-memory state. It never probes hardware,
25297
+ * never spawns a pool and never throws — an EMPTY `unhealthy` means "asked,
25298
+ * nothing is refused", which is what re-admits a device. A read that FAILS
25299
+ * (node offline, version skew) must therefore be distinguishable from an
25300
+ * empty answer, and it is: it rejects.
25441
25301
  */
25442
- saveRetrainAnnotations: method(object({
25443
- deviceId: number(),
25444
- trackId: string(),
25445
- frameId: string(),
25446
- annotations: array(RetrainAnnotationDraftSchema)
25447
- }), array(RetrainAnnotationSchema).readonly(), {
25448
- kind: "mutation",
25449
- auth: "admin"
25450
- }),
25302
+ getInferenceDeviceHealth: method(object({ nodeId: string() }), object({ unhealthy: array(object({
25303
+ /** `<backend>:<device>`, e.g. `openvino:gpu`. */
25304
+ deviceKey: string(),
25305
+ /**
25306
+ * `failed` — the per-device restart budget is exhausted; no pool
25307
+ * will be spawned until an operator re-arms it or the runner
25308
+ * respawns. `backoff` — under budget, waiting out the backoff (or
25309
+ * a cached pool observed dead and not yet condemned).
25310
+ */
25311
+ state: _enum(["failed", "backoff"]),
25312
+ /** Epoch ms of the death that produced this state. */
25313
+ since: number(),
25314
+ /** Pool deaths inside the current window. */
25315
+ deaths: number(),
25316
+ /** The last death's message. */
25317
+ lastError: string()
25318
+ })).readonly() })),
25451
25319
  /**
25452
- * Finish with a track: `staging → trained`. **The only writer of that
25453
- * state** — D81 shipped the column with it deliberately unreachable.
25320
+ * Re-arm a terminally `failed` inference device on `nodeId`: forget its
25321
+ * restart budget so the next dispatch builds a fresh pool.
25454
25322
  *
25455
- * Refuses a track the dataset holds no copies from. `trained` un-pins the
25456
- * track's media, so completing without a copy is a delete order for material
25457
- * nothing ever extracted anything from; that refusal IS the safety argument
25458
- * of D81, expressed as a precondition.
25323
+ * The terminal state is deliberate (the abort it bounds is deterministic —
25324
+ * an automatic probation would just respawn Python forever, more slowly),
25325
+ * and a terminal state an operator cannot leave is a silent fault. This is
25326
+ * the way out. `rearmed:false` means there was nothing to forget.
25459
25327
  */
25460
- completeRetrainTrack: method(object({
25461
- deviceId: number(),
25462
- trackId: string()
25463
- }), RetrainTransitionResultSchema, {
25328
+ rearmInferenceDevice: method(object({
25329
+ nodeId: string(),
25330
+ deviceKey: string()
25331
+ }), object({ rearmed: boolean() }), {
25464
25332
  kind: "mutation",
25465
25333
  auth: "admin"
25466
25334
  }),
25335
+ getSchema: method(_void(), PipelineSchemaSchema),
25336
+ getGlobalSteps: method(_void(), array(PipelineDefaultStepSchema).readonly().nullable()),
25337
+ getGlobalPipelineConfig: method(_void(), PipelineConfigBridge),
25338
+ getOrchestratorConfigSchema: method(_void(), ConfigUISchemaBridge),
25467
25339
  /**
25468
- * The deliberate return: `trained → staging`, for the rare case.
25340
+ * Gate B (pre-init config-correctness gate). PURE COMPUTE against this
25341
+ * node's `currentEngine.format` — resolves `steps` the same way the
25342
+ * runtime dispatch path would, and reports what WOULD happen without
25343
+ * touching any node-global state. Called by the orchestrator at attach
25344
+ * time (`attachOn`), node-pinned to the TARGET node, so config problems
25345
+ * surface BEFORE `pipelineRunner.attachCamera` rather than at the first
25346
+ * per-frame resolve. `ok` is false iff `issues` is non-empty (both
25347
+ * `unknown-addon` and `no-format-build` are HARD issues); `substitutions`
25348
+ * is informational (a degraded-but-loadable model swap) and never
25349
+ * affects `ok`. Never throws.
25469
25350
  *
25470
- * The generic `setTrackFlags` toggle refuses this in both directions by
25471
- * design (D81) — re-staging from a checkbox is how the same material gets
25472
- * annotated twice under two ground truths. Doing it here means the operator
25473
- * is looking at the annotations that already exist while they decide, and
25474
- * those annotations are LEFT ALONE: "put this back" must not be a
25475
- * destructive act wearing a navigational name.
25351
+ * `deviceKey` validates against THAT device pool's format instead of the
25352
+ * node default (D646) — the cheap question a pinned replay asks before it
25353
+ * reads any media: can this (node, deviceKey) run exactly this model?
25476
25354
  */
25477
- restageRetrainTrack: method(object({
25478
- deviceId: number(),
25479
- trackId: string()
25480
- }), RetrainTransitionResultSchema, {
25481
- kind: "mutation",
25482
- auth: "admin"
25483
- }),
25355
+ validatePipeline: method(object({
25356
+ steps: array(PipelineStepInputSchema),
25357
+ deviceKey: string().optional()
25358
+ }), PipelineValidationResultSchema),
25359
+ listTemplates: method(_void(), array(PipelineTemplateSchema$1).readonly()),
25360
+ saveTemplate: method(object({
25361
+ name: string(),
25362
+ steps: array(PipelineTemplateStepSchema).readonly(),
25363
+ engine: PipelineEngineChoiceSchema
25364
+ }), PipelineTemplateSchema$1, { kind: "mutation" }),
25365
+ updateTemplate: method(object({
25366
+ id: string(),
25367
+ name: string().optional(),
25368
+ steps: array(PipelineTemplateStepSchema).readonly().optional()
25369
+ }), PipelineTemplateSchema$1, { kind: "mutation" }),
25370
+ deleteTemplate: method(object({ id: string() }), _void(), { kind: "mutation" }),
25371
+ getCapabilities: method(_void(), InferenceCapabilitiesBridge),
25372
+ getAddonModels: method(object({ addonId: string() }), ModelAvailabilityListBridge),
25373
+ downloadModel: method(object({
25374
+ addonId: string(),
25375
+ modelId: string(),
25376
+ format: ModelFormatSchema$1
25377
+ }), DownloadModelResultSchema, { kind: "mutation" }),
25378
+ deleteModel: method(object({
25379
+ addonId: string(),
25380
+ modelId: string(),
25381
+ format: ModelFormatSchema$1
25382
+ }), object({ success: literal(true) }), { kind: "mutation" }),
25484
25383
  /**
25485
- * Where to download the ANNOTATED dataset.
25384
+ * Stateless single-frame execution. Callers (runner, benchmark) pass
25385
+ * the complete `steps` tree; the executor holds no state about cameras
25386
+ * or saved pipelines. WHICH pool answers is the node's own engine, or the
25387
+ * `deviceKey` pool when one is named.
25486
25388
  *
25487
- * The sibling of `getTrainingExportUrl` and deliberately not the same
25488
- * archive: that one streams a marked track's stored media verbatim, this one
25489
- * streams the retrain COPIES plus an `annotations.json` carrying, for every
25490
- * subject, the canonical full-frame box AND the geometry derived for each
25491
- * model shape (letterboxed root / zone-cropped package / subject-cropped
25492
- * classifier). Derived at export, never stored — one box in, three shapes
25493
- * out, so two crops of the same subject can never end up in one feature
25494
- * space (D52).
25389
+ * There is no `engine` field (D646). It existed for the benchmark and was
25390
+ * honoured by swapping the SHARED provider's engine, factory and executor
25391
+ * for the duration of the call, on a node serving live cameras. A caller
25392
+ * that still sends the key has it stripped here and changes nothing.
25393
+ *
25394
+ * Exactly one of `frame`, `frameRef`, `frameHandle`, `imageBase64`,
25395
+ * `referenceImage` must be provided:
25396
+ * - `frame`: runtime dispatch path (runner → decoded broker frame).
25397
+ * Carries the raw buffer, dimensions, and format; the executor
25398
+ * uses it directly without base64 round-tripping.
25399
+ * - `frameHandle` (CB5): a zero-pixel shm `FrameHandle` for the SAME
25400
+ * decoded frame. Both runner and executor are hub-local processes
25401
+ * sharing `/dev/shm`, so the executor maps the named segment and
25402
+ * reads the pixels back zero-copy — eliminating the ~1.2MB
25403
+ * re-serialisation over UDS/MsgPack the `frame` path pays per call.
25404
+ * High-risk: the FrameRing is a latest-wins seqlock with no
25405
+ * refcount, so a recycled slot yields a null read; the executor
25406
+ * then degrades to an empty result and the runner ships pixels via
25407
+ * `frame` as the fallback (queue-depth gated on the runner side).
25408
+ * - `imageBase64`: one-shot test path (benchmark ImageTab).
25409
+ * - `referenceImage`: named file from the reference-image store.
25495
25410
  */
25496
- getRetrainExportUrl: method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
25497
- kind: "query",
25498
- auth: "admin"
25499
- }),
25411
+ runPipeline: method(object({
25412
+ steps: array(PipelineStepInputSchema).min(1),
25413
+ frame: FrameInputSchema.optional(),
25414
+ /**
25415
+ * Process-local lazy frame. Valid only when caller and provider resolve
25416
+ * in the same execution-group process; split/cross-node callers use
25417
+ * `frame`/`image` inline compatibility instead.
25418
+ */
25419
+ frameRef: FrameRefSchema.optional(),
25420
+ /**
25421
+ * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
25422
+ * the decoded pixels live in. One more member of the one-of
25423
+ * frame/frameHandle/image/imageBase64/referenceImage group.
25424
+ */
25425
+ frameHandle: FrameHandleSchema.optional(),
25426
+ imageBase64: string().optional(),
25427
+ /**
25428
+ * Binary JPEG bytes — preferred over `imageBase64` on internal
25429
+ * hops (hub → forked worker via Moleculer MsgPack) because it
25430
+ * skips the 33% base64 overhead + the per-call base64 decode on
25431
+ * the detection-pipeline worker. Callers can pass either; exactly
25432
+ * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
25433
+ */
25434
+ image: _instanceof(Uint8Array).optional(),
25435
+ referenceImage: string().optional(),
25436
+ deviceId: number().optional(),
25437
+ sessionId: string().optional(),
25438
+ /**
25439
+ * Execution plane. 'full' (default) runs the whole tree — benchmark,
25440
+ * reference-image, and detail-subtree calls. 'frame' is the live
25441
+ * per-frame dispatch: ONLY root-plane steps run; crop children
25442
+ * (inputClasses ≠ null) are skipped and served per-track via
25443
+ * pipelineRunner.runDetailSubtree (two-plane design).
25444
+ */
25445
+ plane: _enum(["full", "frame"]).optional(),
25446
+ /**
25447
+ * Inference-device selector (Phase 2 multi-device). Format
25448
+ * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
25449
+ * Omitted ⇒ the runner's default device (current single-engine
25450
+ * behaviour). Selects WHICH device pool of the node runs the call.
25451
+ */
25452
+ deviceKey: string().optional(),
25453
+ /**
25454
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
25455
+ * when the parent crop was resolved from the frame's retained NATIVE
25456
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
25457
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
25458
+ * resolution from that surface — the SAME quality path faces already
25459
+ * had — instead of the downscaled parent tile. `handle` keys the native
25460
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
25461
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
25462
+ * the executor's crop-normalized child ROI back into frame-normalized
25463
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
25464
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
25465
+ * (today's behaviour on the fallback path).
25466
+ */
25467
+ nativeCropRef: NativeCropRefSchema.optional(),
25468
+ /**
25469
+ * Offline REPLAY of stored media for `deviceId` (D56, D646): the
25470
+ * camera's zone gate and overrides apply as live, every executing
25471
+ * step runs EXACTLY the model it names on the `deviceKey` pool it
25472
+ * names or the call refuses (`model-not-servable` /
25473
+ * `device-not-servable`), and nothing reaches the camera's live
25474
+ * trace stream. Absent ⇒ unchanged behaviour.
25475
+ */
25476
+ replay: literal(true).optional()
25477
+ }), PipelineRunResultBridge, { kind: "mutation" }),
25500
25478
  /**
25501
- * The media an EVENT owns.
25502
- *
25503
- * `ownerType` is REQUIRED, and that is the whole correction (D482). An
25504
- * event is a row in ONE of three tables, and since D474 each numbers from
25505
- * 1 independently: `motion:101314` and `object:101314` both exist. This
25506
- * method took a bare `eventId` and the provider probed motion → object →
25507
- * audio, stopping at the first hit — so on the live hub, where object
25508
- * events own no media of their own and 299 883 of 300 559 media rows are
25509
- * motion-owned, EVERY object event resolved to its motion namesake. A
25510
- * track from 17:34 on camera 615 was served a snapshot from 22:35 eleven
25511
- * days earlier, silently.
25479
+ * Batched run — N raw frames packed into one cap call. The provider
25480
+ * routes the batch through `SharedInferencePool.inferBatch`
25481
+ * (`MSG_INFER_BATCH = 0x03`) so the IPC framing and JSON response
25482
+ * envelope cost is amortised N:1 vs N concurrent `runPipeline`
25483
+ * calls. Single root step + uniform model assumed; trees with crop
25484
+ * children fall back to sequential execution.
25512
25485
  *
25513
- * D476 had already disambiguated the KEY (`motion:` vs `object:`); this is
25514
- * the API catching up to it. Naming the table is not a "qualification" of
25515
- * the ambiguity — a listing BY OWNER has no address to make surrogate: the
25516
- * owner IS (table, id), and half of it is not a question.
25486
+ * Used by `scripts/bench-batch-style.mts` for batch benchmarking —
25487
+ * N frames in one call to amortise per-call IPC overhead.
25517
25488
  */
25518
- getEventMedia: method(object({
25519
- /** Which of the three event tables owns the row. */
25520
- ownerType: EventOwnerTypeSchema,
25521
- /** The event's rowid in that table (D474: an event id is a number). */
25522
- eventId: number().int(),
25523
- kind: MediaFileKindEnum.optional(),
25524
- deviceId: number()
25525
- }), array(MediaFileSchema).readonly()),
25526
- /** All media rows owned by a track. `kinds` narrows to a kind subset so a
25527
- * client can fetch the SMALL display variants on open and pull the
25528
- * multi-MB native variants only on demand (mirrors `getEventMedia.kind`).
25529
- * Absent ⇒ every kind (back-compat). */
25530
- getTrackMedia: method(object({
25531
- trackId: string(),
25532
- kinds: array(MediaFileKindEnum).optional(),
25533
- deviceId: number()
25534
- }), array(MediaFileSchema).readonly()),
25489
+ runPipelineBatch: method(object({
25490
+ steps: array(PipelineStepInputSchema).min(1),
25491
+ frames: array(FrameInputSchema).min(1).max(255),
25492
+ deviceId: number().optional(),
25493
+ sessionId: string().optional(),
25494
+ /**
25495
+ * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
25496
+ * the batch to the Python pool's bench preprocess cache
25497
+ * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
25498
+ * preprocessed ONCE and every later inference is a pure-inference cache
25499
+ * hit — the sustained-throughput run measures inference, not
25500
+ * decode+preprocess+infer. Omitted/0 for live frames (all different →
25501
+ * full preprocess every call, correct). Fresh per sustained run;
25502
+ * released via `uncacheFrame`.
25503
+ */
25504
+ frameId: number().int().nonnegative().optional(),
25505
+ /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
25506
+ deviceKey: string().optional()
25507
+ }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }),
25535
25508
  /**
25536
- * What media a track HAS, without any of it.
25537
- *
25538
- * The detail view needs the shape of a track's media to build its strip —
25539
- * which kinds exist, in what order, at what size — and then wants each tile
25540
- * fetched as an image, not as base64 inside this response. Measured: the
25541
- * full `getTrackMedia` is 5.3-7.7 MB and blocks the view; this manifest is
25542
- * ~2 KB.
25543
- *
25544
- * It also restores a fact a `kinds` filter destroys: filtering
25545
- * `getTrackMedia` drops whole ROWS, taking `kind` and `sizeBytes` with
25546
- * them, so a client that fetched only the small variants could no longer
25547
- * tell a full-resolution variant existed — and the affordance that opens it
25548
- * would silently disappear.
25509
+ * Cache a raw frame inside the Python inference pool's memory.
25510
+ * Returns a numeric `frameId` that `inferCached` references —
25511
+ * subsequent calls send only 5 bytes through the pipe instead of
25512
+ * 1.2MB raw data, eliminating the pipe transfer bottleneck.
25549
25513
  */
25550
- listTrackMedia: method(object({
25551
- trackId: string(),
25552
- deviceId: number()
25553
- }), array(MediaFileInfoSchema).readonly()),
25514
+ cacheFrameInPool: method(object({
25515
+ data: _instanceof(Uint8Array),
25516
+ width: number().int().positive(),
25517
+ height: number().int().positive(),
25518
+ format: _enum([
25519
+ "rgb",
25520
+ "bgr",
25521
+ "gray"
25522
+ ])
25523
+ }), object({
25524
+ frameId: number(),
25525
+ width: number(),
25526
+ height: number()
25527
+ }), { kind: "mutation" }),
25554
25528
  /**
25555
- * What media an EVENT has, without any of it — the twin `getEventMedia`
25556
- * never had.
25557
- *
25558
- * `listTrackMedia` above got this treatment because a track's media is
25559
- * 5-8 MB. An event's is worse per row, not better: an old-style event owns
25560
- * a `crop` AND a native-resolution `fullFrameBoxed`, and the track DETAIL
25561
- * modal — the one surface that legitimately shows the big kinds — unions
25562
- * both listings to build its filmstrip. It then renders every tile from
25563
- * the `event-media` plane by key and throws the bytes away. Measured on
25564
- * the live hub: one event's `fullFrameBoxed` is 2 824 077 B, base64'd to
25565
- * ~3.8 MB, allocated whole in hub-main's heap, for a list of keys.
25566
- *
25567
- * Same `deviceId` authorization subject as `getEventMedia`, the same
25568
- * REQUIRED `ownerType` (read that method's docblock for the night-time
25569
- * thumbnail this closes — D482), and the same rows: this is a projection
25570
- * of that method, never a different question.
25529
+ * Run inference on a previously cached frame. Sends only 5 bytes
25530
+ * (model_idx + frameId) through the IPC pipe — eliminates the
25531
+ * ~35ms per-call overhead of transferring 1.2MB raw data.
25571
25532
  */
25572
- listEventMedia: method(object({
25573
- ownerType: EventOwnerTypeSchema,
25574
- eventId: number().int(),
25575
- deviceId: number()
25576
- }), array(MediaFileInfoSchema).readonly()),
25533
+ inferCached: method(object({
25534
+ stepId: string(),
25535
+ frameId: number().int()
25536
+ }), record(string(), unknown()), { kind: "mutation" }),
25577
25537
  /**
25578
- * Which of `ownerIds` hold at least ONE media row — an INDEX read, never a
25579
- * blob read, and the LICENCE `videoclips` needs to publish a `thumbnail`.
25580
- *
25581
- * The event-media URL is stamped from a template for every event in the
25582
- * system, so "the plane is up" was being served as "there are bytes": 64 of
25583
- * one camera's 179 clips pointed at a 404 (device 3836, 2026-08-17). This
25584
- * is the question that turns the stamp into a claim.
25585
- *
25586
- * It is on the WIRE because the clip source is registered by the addon that
25587
- * owns the FOOTAGE, not by this one (D560) — the probe used to be an
25588
- * in-process `MediaStore` read. One call per OWNER KIND, never one per
25589
- * owner: that N+1 is what `MediaStore.ownersWithMedia` was written to
25590
- * prevent, and crossing a process boundary makes it worse, not better.
25591
- * `ownerIds` is bounded at the same 5 000 the annotation fetch is bounded
25592
- * at, so one pathological camera-day cannot mint an unbounded request.
25593
- *
25594
- * THROWS rather than answering partially. A probe that quietly
25595
- * under-reports reads as "these owners have nothing" and the caller drops
25596
- * thumbnails that exist — the opposite failure to the one above, and
25597
- * equally invisible.
25598
- *
25599
- * `deviceId` is the authorization subject, exactly as on `getEventMedia`.
25538
+ * Release a cached frame from the Python pool's memory.
25600
25539
  */
25601
- ownersWithMedia: method(object({
25602
- deviceId: number(),
25603
- ownerKind: MediaPresenceOwnerKindSchema,
25604
- ownerIds: array(string()).max(5e3)
25605
- }), array(string()).readonly()),
25540
+ uncacheFrame: method(object({ frameId: number().int() }), _void(), { kind: "mutation" }),
25606
25541
  /**
25607
- * Search object events by text query using CLIP cosine similarity.
25608
- * Encodes `text` via the `embedding-encoder` cap, queries the
25609
- * `ObjectEmbeddingStore` with optional prefilters, ranks all matching
25610
- * embeddings by cosine similarity, and joins winners to their
25611
- * ObjectEvents by trackId. Returns up to `limit` events scored ≥
25612
- * `minScore`, sorted descending by score.
25542
+ * The effective provisioning of ONE pool of this node (operator override →
25543
+ * the pool's own runtime row). `deviceKey` names the device pool; absent is
25544
+ * the node-default pool. It answered only for the node default until
25545
+ * D646, so a benchmark on `openvino:npu` recorded the onnx pool's tuning
25546
+ * beside an NPU measurement.
25613
25547
  */
25614
- searchObjectEvents: method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()),
25615
- wipeObjectEmbeddings: method(object({}), WipeObjectEmbeddingsResultSchema, {
25548
+ getEffectiveTuning: method(object({ deviceKey: string().optional() }), EffectiveTuningSchema),
25549
+ /**
25550
+ * List every EngineFactory currently loaded in this executor's RAM,
25551
+ * with the models resident and a coarse "in use" marker derived from
25552
+ * ongoing inference activity. Used by the Pipeline page Engines tab.
25553
+ */
25554
+ listLoadedEngines: method(_void(), array(object({
25555
+ engineKey: string(),
25556
+ engine: PipelineEngineChoiceSchema,
25557
+ modelsLoaded: array(string()).readonly(),
25558
+ inUseByCameras: array(number()).readonly(),
25559
+ /**
25560
+ * Origin of this resident factory.
25561
+ * - `runtime` — main camera-serving engine (no idle TTL).
25562
+ * - `device-pool` — a concurrent per-device pool (Phase 2
25563
+ * multi-device, keyed by `deviceKey`) resolved
25564
+ * via `resolveDeviceFactory`. Runs alongside the
25565
+ * `runtime` engine on a DIFFERENT accelerator
25566
+ * (NPU / iGPU / Coral) — this is how the
25567
+ * Engines tab shows all pools running at once.
25568
+ */
25569
+ kind: _enum(["runtime", "device-pool"]),
25570
+ /** Native pid of the underlying Python pool (null when no pool). */
25571
+ poolPid: number().nullable(),
25572
+ /** ms since this factory was last used (null when not warm-tracked). */
25573
+ idleMs: number().nullable(),
25574
+ /** Idle TTL after which the factory self-evicts (null when not applicable). */
25575
+ idleTtlMs: number().nullable()
25576
+ })).readonly()),
25577
+ /** Warm up an engine without running a frame. No-op if already loaded. */
25578
+ spinEngine: method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
25616
25579
  kind: "mutation",
25617
25580
  auth: "admin"
25618
25581
  }),
25619
- rebuildObjectEmbeddings: method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
25582
+ /**
25583
+ * Unload an engine from RAM. `force:true` unloads even when cameras
25584
+ * are actively using it (they re-spin on next frame). Default is
25585
+ * gated — returns `{success:false, reason}` when in use.
25586
+ */
25587
+ killEngine: method(object({
25588
+ engine: PipelineEngineChoiceSchema,
25589
+ force: boolean().optional()
25590
+ }), object({
25591
+ success: boolean(),
25592
+ reason: string().optional()
25593
+ }), {
25620
25594
  kind: "mutation",
25621
25595
  auth: "admin"
25622
25596
  }),
25623
- getObjectEmbeddingRebuildStatus: method(object({}), RebuildStatusSchema)
25624
- },
25625
- events: {
25626
- /**
25627
- * Enriched frame emitted after refinement — the live-overlay source of
25628
- * truth (two-plane re-injection). Carries the frame's detections in the
25629
- * `ObjectDetection` wire shape: first-level roots (with track info +
25630
- * enrichment labels) plus synthesized `kind:'detail'` face/plate entries
25631
- * re-projected from per-track detail state, so stream overlays render
25632
- * boxes + recognized names without querying full Track state.
25633
- */
25634
- onFrameTracked: { data: object({
25635
- deviceId: number(),
25636
- timestamp: number(),
25637
- frameWidth: number(),
25638
- frameHeight: number(),
25639
- detections: array(OverlayDetectionSchema).readonly()
25640
- }) },
25641
- /** Track entered active state (first-seen). */
25642
- onTrackStarted: { data: object({
25643
- deviceId: number(),
25644
- trackId: string(),
25645
- className: string()
25646
- }) },
25647
- /** Track expired (TTL reached after last detection). */
25648
- onTrackEnded: { data: object({
25649
- deviceId: number(),
25650
- trackId: string(),
25651
- className: string(),
25652
- durationMs: number()
25653
- }) },
25654
- /** Canonical "something happened at device X" event, per-kind. */
25655
- onDetectionEvent: { data: object({
25656
- deviceId: number(),
25657
- kind: EventKindSchema,
25658
- eventId: string(),
25659
- timestamp: number()
25660
- }) }
25597
+ listReferenceImages: method(_void(), array(ReferenceImageEntrySchema).readonly()),
25598
+ getReferenceImage: method(object({ filename: string() }), ReferenceImageBodySchema.nullable()),
25599
+ getReferenceAudioFiles: method(_void(), array(ReferenceAudioEntrySchema).readonly()),
25600
+ getReferenceAudio: method(object({ filename: string() }), ReferenceAudioBodySchema.nullable()),
25601
+ getAudioCapabilities: method(_void(), AudioCapabilitiesSchema),
25602
+ runAudioTest: method(object({
25603
+ addonId: string(),
25604
+ modelId: string(),
25605
+ filename: string().optional(),
25606
+ settings: record(string(), unknown()).optional()
25607
+ }), AudioTestResultSchema, { kind: "mutation" }),
25608
+ getDetectionConfigSchema: method(_void(), ConfigUISchemaNullableBridge)
25661
25609
  }
25662
25610
  };
25663
25611
  object({
@@ -25685,6 +25633,106 @@ var CameraMetricsSchema = object({
25685
25633
  });
25686
25634
  var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
25687
25635
  /**
25636
+ * Zone — pure geometry + identity. NO filtering behaviour.
25637
+ *
25638
+ * Zones describe **where** in the frame the operator wants to flag
25639
+ * something; consumer-owned {@link ZoneRule} arrays describe **how**
25640
+ * each pipeline stage uses them. Splitting the two means a single
25641
+ * polygon "Driveway" can simultaneously back a motion-exclude rule,
25642
+ * a detection-include rule on `['car']`, and an occupancy aggregate
25643
+ * — without three duplicated polygons.
25644
+ *
25645
+ * Owned by the orchestrator addon (provider) and mirrored into the
25646
+ * `zones` device-state slice on every mutation. Consumers
25647
+ * (motion-wasm, pipeline-executor, analytics, admin UI) read either
25648
+ * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
25649
+ * mirror with `onChanged`).
25650
+ *
25651
+ * Coordinates are normalised fractions of the frame (0–1) so zones
25652
+ * survive resolution changes and stream profile switches.
25653
+ *
25654
+ * `kind` discriminates between full polygons (closed regions used
25655
+ * for intrusion / occupancy filters) and tripwires (open 2-point
25656
+ * line segments used for cross events). Onboard / firmware-reported
25657
+ * zones (Reolink, ONVIF) are out of scope for now — see the deferred
25658
+ * task list.
25659
+ */
25660
+ var ZoneKindEnum = _enum(["polygon", "tripwire"]);
25661
+ /** Polygon vertex in fraction-of-frame coordinates (0–1). */
25662
+ var PolygonPointSchema = object({
25663
+ x: number(),
25664
+ y: number()
25665
+ });
25666
+ /** A camera detection zone — pure geometry/identity. */
25667
+ var ZoneSchema = object({
25668
+ id: string(),
25669
+ name: string(),
25670
+ kind: ZoneKindEnum.default("polygon"),
25671
+ /** Polygon vertices, fraction of frame (0–1). */
25672
+ polygon: array(PolygonPointSchema).readonly(),
25673
+ /** Visual color for UI rendering. */
25674
+ color: string().default("#3b82f6")
25675
+ });
25676
+ /**
25677
+ * Zones capability — per-camera CRUD over polygon detection zones.
25678
+ *
25679
+ * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
25680
+ * to per-device settings and mirrors into the `zones` device-state
25681
+ * slice on every mutation, so downstream consumers can subscribe via
25682
+ * `dev.state.zones.onChanged`.
25683
+ *
25684
+ * The cap surface only handles geometry + identity; filtering
25685
+ * behaviour (per-class, include/exclude, threshold) lives in the
25686
+ * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
25687
+ * `capabilities/schemas/zone-rule.js`.
25688
+ */
25689
+ var zonesCapability = {
25690
+ name: "zones",
25691
+ scope: "device",
25692
+ mode: "singleton",
25693
+ deviceTypes: [DeviceType.Camera],
25694
+ methods: {
25695
+ listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
25696
+ addZone: method(object({
25697
+ deviceId: number(),
25698
+ zone: ZoneSchema
25699
+ }), _void(), {
25700
+ kind: "mutation",
25701
+ auth: "admin"
25702
+ }),
25703
+ removeZone: method(object({
25704
+ deviceId: number(),
25705
+ zoneId: string()
25706
+ }), _void(), {
25707
+ kind: "mutation",
25708
+ auth: "admin"
25709
+ }),
25710
+ updateZone: method(object({
25711
+ deviceId: number(),
25712
+ zone: ZoneSchema
25713
+ }), _void(), {
25714
+ kind: "mutation",
25715
+ auth: "admin"
25716
+ })
25717
+ },
25718
+ /**
25719
+ * Runtime-state slice — the live zone catalogue mirrored by the
25720
+ * orchestrator on every CRUD mutation. Consumers read via
25721
+ * `device.state.zones.value` / `.watch(...)` without round-tripping
25722
+ * the cap, and the codegen DeviceProxy auto-wires the reactive
25723
+ * handle. Slice shape is `{ zones: Zone[] }` so future extensions
25724
+ * (e.g. zone groupings) can sit alongside the polygon list.
25725
+ */
25726
+ runtimeState: object({ zones: array(ZoneSchema).readonly() }),
25727
+ /**
25728
+ * 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.
25729
+ *
25730
+ * See `RuntimeStateDurability`. Enforced by
25731
+ * `scripts/check-runtime-state-durability.ts`.
25732
+ */
25733
+ durability: "restored"
25734
+ };
25735
+ /**
25688
25736
  * A bounding box in NORMALIZED [0,1] frame coordinates for `getNativeCrop`. The
25689
25737
  * decode worker resolves it against the RETAINED native frame's real pixel dims,
25690
25738
  * so the caller supplies only the detection-res bbox divided by the detection
@@ -25871,7 +25919,17 @@ var DetailResultSchema = object({
25871
25919
  /** Face short side (px) measured on the NATIVE crop surface. The `bbox`
25872
25920
  * above is detection-frame px (≈6× smaller on a 4K camera) — min-face-size
25873
25921
  * consumers MUST prefer this when present (2026-07-22 native-gate fix). */
25874
- nativeFaceShortSidePx: number().optional()
25922
+ nativeFaceShortSidePx: number().optional(),
25923
+ /**
25924
+ * The five facial landmarks of a `face` detail, in the SAME frame space as
25925
+ * `bbox` (D644). Additive and optional: post-analysis stores them beside the
25926
+ * face's source frame so a future alignment can be re-derived exactly; a
25927
+ * runner that predates the field sends none and the face is stored without.
25928
+ */
25929
+ landmarks: array(object({
25930
+ x: number(),
25931
+ y: number()
25932
+ })).optional()
25875
25933
  });
25876
25934
  /**
25877
25935
  * Why an executing node REFUSED a stateless step run (`runStatelessStep`).
@@ -33015,12 +33073,20 @@ reset: method(object({
33015
33073
  },
33016
33074
  runtimeState: ConsumablesStatusSchema.extend({ lastFetchedAt: number() }),
33017
33075
  /**
33018
- * Runtime-state durability: **session** — the authority is the appliance; the provider re-reads the whole item array on connect.
33076
+ * Runtime-state durability: **restored** — nothing else holds the value
33077
+ * (D642). A consumable can often be read only in a device's wake window (the
33078
+ * Dreame mower's CMS counters answer only while it charges), so a restart
33079
+ * that wiped the slice left the panel empty and the alerts blind until the
33080
+ * next wake — 2026-09-26, mower 503 idle with `items: []`. A restored item is
33081
+ * the previous observation, not a claim about now; the provider overwrites it
33082
+ * the moment it reads the device again.
33019
33083
  *
33020
33084
  * See `RuntimeStateDurability`. Enforced by
33021
33085
  * `scripts/check-runtime-state-durability.ts`.
33022
33086
  */
33023
- durability: "session"
33087
+ durability: "restored",
33088
+ /** Clocks, not content: a re-read that changed no item costs no commit. */
33089
+ volatileStateFields: ["lastChangedAt", "lastFetchedAt"]
33024
33090
  };
33025
33091
  /**
33026
33092
  * Door / window / opening / garage / valve contact sensor. Boolean
@@ -37893,7 +37959,7 @@ var HardwareInfoSchema = object({
37893
37959
  coral: CoralInfoSchema.nullable().optional()
37894
37960
  });
37895
37961
  var PlatformScoreSchema = object({
37896
- runtime: _enum(["node", "python"]),
37962
+ runtime: literal("python"),
37897
37963
  backend: string(),
37898
37964
  format: _enum([
37899
37965
  "onnx",
@@ -37930,7 +37996,7 @@ var ModelRequirementSchema = object({
37930
37996
  });
37931
37997
  var ResolvedInferenceConfigSchema = object({
37932
37998
  modelId: string(),
37933
- runtime: _enum(["node", "python"]),
37999
+ runtime: literal("python"),
37934
38000
  backend: string(),
37935
38001
  format: ModelFormatSchema,
37936
38002
  reason: string()
@@ -40937,6 +41003,92 @@ var sceneMonitorCapability = {
40937
41003
  durability: "session"
40938
41004
  };
40939
41005
  /**
41006
+ * Per-stage gating mode applied to the zones a rule references.
41007
+ *
41008
+ * - `include`: the rule contributes to a **whitelist** for its stage.
41009
+ * When at least one `include` rule fires for a stage, only entities
41010
+ * inside one of those zones pass that stage.
41011
+ * - `exclude`: the rule contributes to a **blacklist** for its stage.
41012
+ * Entities inside one of those zones are dropped at that stage.
41013
+ *
41014
+ * `monitor`-style observation (count without filtering) is not a rule
41015
+ * mode — zones without any matching rule are observed naturally by
41016
+ * `zone-analytics` (live snapshot + history), so an "I just want to
41017
+ * count, not filter" use case needs no rule at all.
41018
+ */
41019
+ var ZoneRuleModeEnum = _enum(["include", "exclude"]);
41020
+ /**
41021
+ * Per-consumer rule that references existing zones (geometry) and
41022
+ * defines how a specific pipeline stage should treat them. Each
41023
+ * consumer addon owns its own `ZoneRule[]` array in its per-device
41024
+ * settings:
41025
+ *
41026
+ * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
41027
+ * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
41028
+ * - future: notification rules, audio gating, etc.
41029
+ *
41030
+ * One rule applies to N zones (`zoneIds[]`) so the operator can
41031
+ * express "ignore motion in ALL of {garden, street}" with a single
41032
+ * rule. `classFilter` narrows the rule to specific object classes —
41033
+ * "drop person detections in the street, but keep cars" is one
41034
+ * `exclude` rule with `classFilter: ['person']`.
41035
+ *
41036
+ * `enabled` is a soft toggle — the operator can keep the rule
41037
+ * configured but inert without deleting it.
41038
+ */
41039
+ var ZoneRuleSchema = object({
41040
+ /** Stable rule id — survives edits, used by the UI for diffing. */
41041
+ id: string(),
41042
+ /** Optional human-readable label rendered in the rule editor. */
41043
+ name: string().optional(),
41044
+ /** Zones this rule targets. The rule's `mode` applies to ALL
41045
+ * listed zones (OR-set: a detection in any one of them counts).
41046
+ * At least one zone id required — a rule with no targets is a
41047
+ * configuration mistake and the form validator rejects it. */
41048
+ zoneIds: array(string()).min(1).readonly(),
41049
+ mode: ZoneRuleModeEnum,
41050
+ /**
41051
+ * Class names this rule applies to. Empty / undefined ⇒ rule
41052
+ * applies to every class. Class strings match the `macroClass`
41053
+ * field on detections (e.g. `person`, `car`, `dog`).
41054
+ */
41055
+ classFilter: array(string()).readonly().optional(),
41056
+ /**
41057
+ * Minimum bbox/mask overlap (0–1) with any of the rule's zones
41058
+ * required to consider an entity "in the zone". Defaults to the
41059
+ * consumer's stage default when omitted. Kept for back-compat with
41060
+ * existing per-rule overrides; new operators pick the value via
41061
+ * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
41062
+ * set, the lower-level engine reads it as a 0–1 fraction.
41063
+ */
41064
+ overlapThreshold: number().min(0).max(1).optional(),
41065
+ /**
41066
+ * Operator-friendly version of `overlapThreshold` — the percentage
41067
+ * of the detection's bbox that must lie inside the zone for the
41068
+ * rule to match. Documented default is 85%; the engine substitutes
41069
+ * that when the field is omitted (kept optional so existing rules
41070
+ * stored without it stay valid).
41071
+ *
41072
+ * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
41073
+ * rule, the engine prefers `bboxInclusionPct` because it's the
41074
+ * field exposed in the UI. Internally both feed the same gate.
41075
+ */
41076
+ bboxInclusionPct: number().min(0).max(100).optional(),
41077
+ /**
41078
+ * When `true` and a detection has a segmentation mask, use the
41079
+ * mask for overlap instead of the bbox. Detection-stage only;
41080
+ * motion rules ignore this field.
41081
+ */
41082
+ preferMask: boolean().optional(),
41083
+ /**
41084
+ * Soft-toggle: `false` disables the rule without deleting it.
41085
+ * Defaults to `true` so operators creating a rule via the UI
41086
+ * see it active immediately.
41087
+ */
41088
+ enabled: boolean().default(true)
41089
+ });
41090
+ array(ZoneRuleSchema).readonly();
41091
+ /**
40940
41092
  * Script-runner cap. Models HA `script.*` entities on
40941
41093
  * `DeviceType.Script`. A Script is a pre-recorded action sequence
40942
41094
  * that can be invoked imperatively — optionally with a variables
@@ -48286,6 +48438,12 @@ Object.freeze({
48286
48438
  addonId: null,
48287
48439
  access: "view"
48288
48440
  },
48441
+ "notificationRules.previewStateSummary": {
48442
+ capName: "notification-rules",
48443
+ capScope: "system",
48444
+ addonId: null,
48445
+ access: "view"
48446
+ },
48289
48447
  "notificationRules.previewTemplate": {
48290
48448
  capName: "notification-rules",
48291
48449
  capScope: "system",
@@ -48862,12 +49020,6 @@ Object.freeze({
48862
49020
  addonId: null,
48863
49021
  access: "create"
48864
49022
  },
48865
- "pipelineAnalytics.runReplayFrameProcessor": {
48866
- capName: "pipeline-analytics",
48867
- capScope: "device",
48868
- addonId: null,
48869
- access: "create"
48870
- },
48871
49023
  "pipelineAnalytics.saveRetrainAnnotations": {
48872
49024
  capName: "pipeline-analytics",
48873
49025
  capScope: "device",
@@ -52965,11 +53117,6 @@ Object.freeze({
52965
53117
  form: "single",
52966
53118
  optional: false
52967
53119
  }],
52968
- "pipelineAnalytics.runReplayFrameProcessor": [{
52969
- name: "deviceId",
52970
- form: "single",
52971
- optional: false
52972
- }],
52973
53120
  "pipelineAnalytics.saveRetrainAnnotations": [{
52974
53121
  name: "deviceId",
52975
53122
  form: "single",
@@ -53858,12 +54005,55 @@ var NC_AUDIO_DEFAULTS = {
53858
54005
  samplingSeconds: 10
53859
54006
  };
53860
54007
  new Set(["devices", "classes"]);
53861
- /** Every filter, for the callers that must cover all four (guards, tests). */
54008
+ /**
54009
+ * WHICH narrowing filter speaks about WHICH system-event kind — one predicate,
54010
+ * consumed by the rule ENGINE and by every rule EDITOR.
54011
+ *
54012
+ * ── The failure this file exists for ───────────────────────────────────────
54013
+ * `NcSystemEventConditionSchema` carries four optional narrowing lists
54014
+ * (`deviceIds`, `deviceTypes`, `nodeIds`, `packageNames`) beside a required
54015
+ * `kinds` gate. They are not four filters over one vocabulary: each belongs to
54016
+ * a FAMILY of kinds and is meaningless outside it. A node going away has no
54017
+ * device type; a completed export has no package; `stream-offline` deliberately
54018
+ * carries no device type at all (a stream belongs to a camera by construction).
54019
+ *
54020
+ * The engine applied all four to every kind, so a filter from one family failed
54021
+ * a kind from another family CLOSED. The operator's live rule "Eventi di
54022
+ * sistema" selected eleven kinds and set `deviceTypes: ['camera']` — the only
54023
+ * way to say "only my cameras" about the two liveness kinds — and NINE of the
54024
+ * eleven silently stopped being deliverable. Four days of history contained
54025
+ * `device-online` and `device-offline` and nothing else, across a window in
54026
+ * which agents were restarted and addons were updated.
54027
+ *
54028
+ * Both editors already computed this scoping, to decide which filter boxes to
54029
+ * render; the cap's own docblock already promised it ("Narrow a `device-*` kind
54030
+ * to these device TYPES"). Only the engine disagreed, and it disagreed in the
54031
+ * destructive direction. So the rule is stated ONCE, here, and the engine and
54032
+ * the editors are readers of it rather than three independent authors.
54033
+ *
54034
+ * ── The direction ─────────────────────────────────────────────────────────
54035
+ * Out of family ⇒ the filter is IGNORED, never fail-closed. An editor that
54036
+ * hides a box has already told the operator this filter does not speak about
54037
+ * these kinds, so honouring it as an exclusion contradicts the only
54038
+ * explanation the operator was ever given. Inside its family the filter still
54039
+ * narrows, and still fails CLOSED on a subject that cannot produce the identity
54040
+ * it tests (a device the mirror cannot name is not evidence of a camera).
54041
+ */
54042
+ /**
54043
+ * Every filter, for the callers that must cover all of them (guards, tests).
54044
+ *
54045
+ * `consumableLowPercent` (D642) is not a list but it is a filter in exactly
54046
+ * this sense: it belongs to a family of kinds (the consumable pair) and the
54047
+ * engine consults it only there. It differs in one way the readers must know —
54048
+ * its ABSENCE is not "no narrowing" but the default threshold, because a
54049
+ * consumable episode is always judged at SOME threshold.
54050
+ */
53862
54051
  var NC_SYSTEM_EVENT_FILTER_KEYS = [
53863
54052
  "deviceIds",
53864
54053
  "deviceTypes",
53865
54054
  "nodeIds",
53866
- "packageNames"
54055
+ "packageNames",
54056
+ "consumableLowPercent"
53867
54057
  ];
53868
54058
  new Map(Object.entries({
53869
54059
  "device-online": "device-events",
@@ -53874,6 +54064,9 @@ new Map(Object.entries({
53874
54064
  "device-battery-normal": "device-events",
53875
54065
  "device-consumable-low": "device-events",
53876
54066
  "device-consumable-normal": "device-events",
54067
+ "device-tank-low": "device-events",
54068
+ "device-tank-full": "device-events",
54069
+ "device-tank-normal": "device-events",
53877
54070
  "stream-online": "device-events",
53878
54071
  "stream-offline": "device-events",
53879
54072
  "detection-blind": "device-events",
@@ -53903,6 +54096,98 @@ new Map(Object.entries({
53903
54096
  "camera-enabled": null
53904
54097
  }));
53905
54098
  [...NC_SYSTEM_EVENT_FILTER_KEYS];
54099
+ var NC_SYSTEM_EVENT_KIND_GROUP_SPECS = [
54100
+ {
54101
+ id: "device-state",
54102
+ family: "device-events",
54103
+ label: "Device state",
54104
+ kinds: [
54105
+ "device-offline",
54106
+ "device-online",
54107
+ "device-disabled",
54108
+ "device-enabled"
54109
+ ]
54110
+ },
54111
+ {
54112
+ id: "streams",
54113
+ family: "device-events",
54114
+ label: "Streams",
54115
+ kinds: ["stream-offline", "stream-online"]
54116
+ },
54117
+ {
54118
+ id: "battery",
54119
+ family: "device-events",
54120
+ label: "Battery",
54121
+ kinds: ["device-battery-low", "device-battery-normal"]
54122
+ },
54123
+ {
54124
+ id: "consumables",
54125
+ family: "device-events",
54126
+ label: "Consumables",
54127
+ kinds: ["device-consumable-low", "device-consumable-normal"]
54128
+ },
54129
+ {
54130
+ id: "tanks",
54131
+ family: "device-events",
54132
+ label: "Tanks",
54133
+ kinds: [
54134
+ "device-tank-low",
54135
+ "device-tank-full",
54136
+ "device-tank-normal"
54137
+ ]
54138
+ },
54139
+ {
54140
+ id: "detection-blind",
54141
+ family: "device-events",
54142
+ label: "Detecting nothing",
54143
+ kinds: ["detection-blind"]
54144
+ },
54145
+ {
54146
+ id: "nodes",
54147
+ family: "system",
54148
+ label: "Nodes",
54149
+ kinds: [
54150
+ "node-offline",
54151
+ "node-online",
54152
+ "node-inference-unavailable"
54153
+ ]
54154
+ },
54155
+ {
54156
+ id: "addons",
54157
+ family: "system",
54158
+ label: "Addons",
54159
+ kinds: [
54160
+ "addon-crash-loop",
54161
+ "addon-update-available",
54162
+ "addon-updated"
54163
+ ]
54164
+ },
54165
+ {
54166
+ id: "updates",
54167
+ family: "system",
54168
+ label: "Server & container updates",
54169
+ kinds: [
54170
+ "server-update-available",
54171
+ "server-updated",
54172
+ "wrapper-update-available"
54173
+ ]
54174
+ },
54175
+ {
54176
+ id: "backups-exports",
54177
+ family: "system",
54178
+ label: "Backups & exports",
54179
+ kinds: ["backup-completed", "export-completed"]
54180
+ },
54181
+ {
54182
+ id: "alarm",
54183
+ family: "alarm",
54184
+ label: "Alarm",
54185
+ kinds: NC_ALARM_SYSTEM_EVENT_KINDS
54186
+ }
54187
+ ];
54188
+ function systemEventKindsOfFamily(family) {
54189
+ return NC_SYSTEM_EVENT_KIND_GROUP_SPECS.filter((g) => g.family === family).flatMap((g) => g.kinds);
54190
+ }
53906
54191
  NC_AUDIO_DEFAULTS.hitPercent, NC_AUDIO_DEFAULTS.samplingSeconds;
53907
54192
  var WEEKDAY_TO_DAY = {
53908
54193
  Sun: 0,
@@ -53913,18 +54198,38 @@ var WEEKDAY_TO_DAY = {
53913
54198
  Fri: 5,
53914
54199
  Sat: 6
53915
54200
  };
53916
- /** Resolve (weekday, minute-of-day) of `atMs` in the schedule's timezone.
53917
- * An invalid/unknown IANA name falls back to the host timezone. */
53918
- function localDayMinute(atMs, timezone) {
53919
- const d = new Date(atMs);
53920
- if (timezone !== void 0) try {
53921
- const parts = new Intl.DateTimeFormat("en-US", {
54201
+ /**
54202
+ * One formatter per timezone, built once (D647 review I4). Constructing an
54203
+ * `Intl.DateTimeFormat` is the expensive part of this function, and a caller
54204
+ * that asks about many instants — a window scan — used to build one per
54205
+ * instant. `null` = an invalid IANA name (the host timezone is used).
54206
+ */
54207
+ var FORMATTERS = /* @__PURE__ */ new Map();
54208
+ function formatterFor(timezone) {
54209
+ const held = FORMATTERS.get(timezone);
54210
+ if (held !== void 0) return held;
54211
+ let made;
54212
+ try {
54213
+ made = new Intl.DateTimeFormat("en-US", {
53922
54214
  timeZone: timezone,
53923
54215
  weekday: "short",
53924
54216
  hour: "numeric",
53925
54217
  minute: "numeric",
53926
54218
  hourCycle: "h23"
53927
- }).formatToParts(d);
54219
+ });
54220
+ } catch {
54221
+ made = null;
54222
+ }
54223
+ FORMATTERS.set(timezone, made);
54224
+ return made;
54225
+ }
54226
+ /** Resolve (weekday, minute-of-day) of `atMs` in the schedule's timezone.
54227
+ * An invalid/unknown IANA name falls back to the host timezone. */
54228
+ function localDayMinute(atMs, timezone) {
54229
+ const d = new Date(atMs);
54230
+ const formatter = timezone !== void 0 ? formatterFor(timezone) : null;
54231
+ if (formatter !== null) try {
54232
+ const parts = formatter.formatToParts(d);
53928
54233
  let weekday;
53929
54234
  let hour;
53930
54235
  let minute;
@@ -54001,6 +54306,11 @@ var RULE_BODY_ONLY = ["body"];
54001
54306
  var RULE_TEXT = ["title", "body"];
54002
54307
  var BATTERY = ["device-battery-low", "device-battery-normal"];
54003
54308
  var CONSUMABLE = ["device-consumable-low", "device-consumable-normal"];
54309
+ var TANK = [
54310
+ "device-tank-low",
54311
+ "device-tank-full",
54312
+ "device-tank-normal"
54313
+ ];
54004
54314
  var UPDATES = [
54005
54315
  "addon-update-available",
54006
54316
  "server-update-available",
@@ -54026,12 +54336,189 @@ var DEVICE_EVENTS = [
54026
54336
  "device-enabled",
54027
54337
  ...BATTERY,
54028
54338
  ...CONSUMABLE,
54339
+ ...TANK,
54029
54340
  "stream-online",
54030
54341
  "stream-offline",
54031
54342
  "detection-blind",
54032
54343
  ...ALARM
54033
54344
  ];
54034
- [...DEVICE_EVENTS], [...RULE_TEXT], [...COMBINED_ALARM], [...RULE_TEXT], [...COMBINED_ALARM], [...RULE_TEXT], [...RULE_TEXT], [...COMBINED_ALARM], [...RULE_TEXT], [...PACKAGE_UPDATES], [...RULE_TEXT], [...RULE_TEXT], [...COMBINED_ALARM], [...RULE_TEXT], [...COMBINED_ALARM], [...RULE_TEXT], [...COMBINED_ALARM], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_BODY_ONLY], [...RULE_TEXT], [...RULE_TEXT], [...DEVICE_EVENTS], [...RULE_TEXT], [...DEVICE_EVENTS], [...RULE_TEXT], [...BATTERY, ...CONSUMABLE], [...RULE_TEXT], [...CONSUMABLE], [...RULE_TEXT], [...RULE_TEXT], [...UPDATES], [...RULE_TEXT], [...UPDATES], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...UPDATES], [...RULE_TEXT], [...PACKAGE_UPDATES], [...RULE_TEXT], [...PACKAGE_UPDATES], [...RULE_TEXT], [...UPDATES], [...RULE_TEXT], [...UPDATES], [...RULE_TEXT], [...PACKAGE_UPDATES], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT];
54345
+ /** Every kind a summary may speak about — the two summarisable families. */
54346
+ var SUMMARISABLE = [...systemEventKindsOfFamily("device-events"), ...systemEventKindsOfFamily("system")];
54347
+ /** One per summary SECTION (`NC_STATE_SUMMARY_SECTIONS` in the notification
54348
+ * centre): the section's lines, offered when one of its kinds is selected. */
54349
+ var STATE_SUMMARY_SECTION_VARS = [
54350
+ {
54351
+ name: "summaryDevices",
54352
+ label: "Summary: devices offline / switched off",
54353
+ example: "Garage — offline since 07:12",
54354
+ kinds: [
54355
+ "device-offline",
54356
+ "device-online",
54357
+ "device-disabled",
54358
+ "device-enabled"
54359
+ ]
54360
+ },
54361
+ {
54362
+ name: "summaryStreams",
54363
+ label: "Summary: streams offline",
54364
+ example: "Ingresso (high) — since 06:40",
54365
+ kinds: ["stream-offline", "stream-online"]
54366
+ },
54367
+ {
54368
+ name: "summaryBattery",
54369
+ label: "Summary: low batteries",
54370
+ example: "Sensore porta — 8 %",
54371
+ kinds: BATTERY
54372
+ },
54373
+ {
54374
+ name: "summaryConsumables",
54375
+ label: "Summary: consumables",
54376
+ example: "Robot — filter 10 %",
54377
+ kinds: CONSUMABLE
54378
+ },
54379
+ {
54380
+ name: "summaryTanks",
54381
+ label: "Summary: tanks",
54382
+ example: "Robot — clean water low",
54383
+ kinds: TANK
54384
+ },
54385
+ {
54386
+ name: "summaryDetection",
54387
+ label: "Summary: cameras detecting nothing",
54388
+ example: "Ingresso — since 05:10",
54389
+ kinds: ["detection-blind"]
54390
+ },
54391
+ {
54392
+ name: "summaryNodes",
54393
+ label: "Summary: nodes",
54394
+ example: "little-unraid — offline since 03:00",
54395
+ kinds: [
54396
+ "node-offline",
54397
+ "node-online",
54398
+ "node-inference-unavailable"
54399
+ ]
54400
+ },
54401
+ {
54402
+ name: "summaryAddons",
54403
+ label: "Summary: addons",
54404
+ example: "@camstack/addon-recorder 1.2.3 → 1.2.4",
54405
+ kinds: [
54406
+ "addon-crash-loop",
54407
+ "addon-update-available",
54408
+ "addon-updated"
54409
+ ]
54410
+ },
54411
+ {
54412
+ name: "summaryUpdates",
54413
+ label: "Summary: server & container updates",
54414
+ example: "server 1.2.377 → 1.2.378",
54415
+ kinds: [
54416
+ "server-update-available",
54417
+ "server-updated",
54418
+ "wrapper-update-available"
54419
+ ]
54420
+ }
54421
+ ];
54422
+ var STATE_SUMMARY_VARS = [
54423
+ {
54424
+ name: "summaryText",
54425
+ label: "Summary: every section",
54426
+ description: "One block per section with something to report, one line per item.",
54427
+ example: "Batterie scariche: Sensore porta — 8 %",
54428
+ group: "system",
54429
+ families: ["rule"],
54430
+ fields: [...RULE_TEXT],
54431
+ kinds: ["system"],
54432
+ systemEventKinds: [...SUMMARISABLE],
54433
+ systemEventDeliveries: ["summary"]
54434
+ },
54435
+ {
54436
+ name: "summaryCount",
54437
+ label: "Summary: items reported",
54438
+ example: "3",
54439
+ group: "system",
54440
+ families: ["rule"],
54441
+ fields: [...RULE_TEXT],
54442
+ kinds: ["system"],
54443
+ systemEventKinds: [...SUMMARISABLE],
54444
+ systemEventDeliveries: ["summary"]
54445
+ },
54446
+ ...STATE_SUMMARY_SECTION_VARS.map((v) => ({
54447
+ name: v.name,
54448
+ label: v.label,
54449
+ example: v.example,
54450
+ group: "system",
54451
+ families: ["rule"],
54452
+ fields: [...RULE_TEXT],
54453
+ kinds: ["system"],
54454
+ systemEventKinds: [...v.kinds],
54455
+ systemEventDeliveries: ["summary"]
54456
+ }))
54457
+ ];
54458
+ [
54459
+ [...DEVICE_EVENTS],
54460
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
54461
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
54462
+ [...RULE_TEXT],
54463
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
54464
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
54465
+ [...RULE_TEXT],
54466
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
54467
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
54468
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
54469
+ [...RULE_TEXT],
54470
+ [...RULE_TEXT],
54471
+ [...RULE_TEXT],
54472
+ [...RULE_TEXT],
54473
+ [...RULE_TEXT],
54474
+ [...RULE_TEXT],
54475
+ [...RULE_TEXT],
54476
+ [...RULE_TEXT],
54477
+ [...RULE_BODY_ONLY],
54478
+ [...RULE_TEXT],
54479
+ ([...RULE_TEXT], [...DEVICE_EVENTS]),
54480
+ ([...RULE_TEXT], [...DEVICE_EVENTS]),
54481
+ ([...RULE_TEXT], [...BATTERY, ...CONSUMABLE]),
54482
+ ([...RULE_TEXT], [...CONSUMABLE]),
54483
+ ([...RULE_TEXT], [...TANK]),
54484
+ [...RULE_TEXT],
54485
+ ([...RULE_TEXT], [...UPDATES]),
54486
+ ([...RULE_TEXT], [...UPDATES]),
54487
+ [...RULE_TEXT],
54488
+ [...RULE_TEXT],
54489
+ [...RULE_TEXT],
54490
+ ([...RULE_TEXT], [...UPDATES]),
54491
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
54492
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
54493
+ ([...RULE_TEXT], [...UPDATES]),
54494
+ ([...RULE_TEXT], [...UPDATES]),
54495
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
54496
+ [...RULE_TEXT],
54497
+ [...RULE_TEXT],
54498
+ [...RULE_TEXT],
54499
+ [...RULE_TEXT],
54500
+ [...RULE_TEXT],
54501
+ [...RULE_TEXT],
54502
+ [...RULE_TEXT],
54503
+ [...RULE_TEXT],
54504
+ [...RULE_TEXT],
54505
+ [...RULE_TEXT],
54506
+ [...RULE_TEXT],
54507
+ [...RULE_TEXT],
54508
+ [...RULE_TEXT],
54509
+ [...RULE_TEXT],
54510
+ [...RULE_TEXT],
54511
+ [...RULE_TEXT],
54512
+ [...RULE_TEXT],
54513
+ [...RULE_TEXT],
54514
+ [...RULE_TEXT],
54515
+ [...RULE_TEXT],
54516
+ [...RULE_TEXT],
54517
+ [...RULE_TEXT],
54518
+ [...RULE_TEXT],
54519
+ [...RULE_TEXT],
54520
+ ...STATE_SUMMARY_VARS
54521
+ ];
54035
54522
  /**
54036
54523
  * TimelapseRule — the STANDALONE scheduled timelapse producer's rule model.
54037
54524
  *