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