@camstack/addon-provider-homematic 1.2.30 → 1.2.32

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 (3) hide show
  1. package/dist/addon.js +1968 -1820
  2. package/dist/addon.mjs +1968 -1820
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -15857,7 +15857,23 @@ var NcHistoryEntrySchema = object({
15857
15857
  updatedAt: number(),
15858
15858
  /** Failure detail — present on a `dead` row. */
15859
15859
  error: string().optional(),
15860
- subject: NcHistorySubjectSchema
15860
+ subject: NcHistorySubjectSchema,
15861
+ /**
15862
+ * Ids of the artefacts (still, then gif, then clip) this row's successful
15863
+ * delivery indexed in the artefact library — a REFERENCE, never the bytes
15864
+ * (an artefact is often megabytes; this row is durable JSON rewritten on
15865
+ * every delivery attempt). Absent on a row still pending/dead, a row
15866
+ * delivered before this field shipped, or a wiring with no artefact index.
15867
+ *
15868
+ * Resolve one to a fetchable URL with `resolveArtifactUrl` — an id
15869
+ * outlives any one URL's TTL, so a caller mints a fresh link on demand
15870
+ * rather than trusting one frozen at delivery time. `resolveArtifactUrl`
15871
+ * also answers `null` for an id whose artefact has since expired past the
15872
+ * retained shelf's own age bound — the degrade a caller (the Home
15873
+ * Assistant export) must render as "no image right now", never as a
15874
+ * broken link.
15875
+ */
15876
+ artifactIds: array(string().min(1)).optional()
15861
15877
  });
15862
15878
  /**
15863
15879
  * Query filter for `getHistory` (spec §4.2). Every field is a narrowing
@@ -16084,7 +16100,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
16084
16100
  }), method(object({}), object({
16085
16101
  catalog: array(NcConditionDescriptorSchema),
16086
16102
  taxonomy: NcTaxonomySchema.optional()
16087
- })), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" }), method(object({}), object({ snoozes: array(NcSnoozeSchema) }), { caller: "required" }), method(object({ snooze: NcSnoozeInputSchema }), object({ snooze: NcSnoozeSchema }), {
16103
+ })), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" }), method(object({ artifactId: string().min(1) }), object({ url: string().nullable() }), { auth: "admin" }), method(object({}), object({ snoozes: array(NcSnoozeSchema) }), { caller: "required" }), method(object({ snooze: NcSnoozeInputSchema }), object({ snooze: NcSnoozeSchema }), {
16088
16104
  kind: "mutation",
16089
16105
  caller: "required"
16090
16106
  }), method(object({ snoozeId: string() }), object({ success: literal(true) }), {
@@ -16424,1760 +16440,1996 @@ var OauthIntegrationDescriptorSchema = object({
16424
16440
  });
16425
16441
  method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
16426
16442
  /**
16427
- * pipeline-analytics — device-scoped wrapper cap. Refines raw
16428
- * per-frame detections emitted by the pipeline runner into tracked
16429
- * objects, per-kind event collections (motion / object / audio), and
16430
- * persisted media. Owns the post-detection domain end-to-end:
16431
- *
16432
- * runner emits PipelineInferenceResult
16433
- * ↓ (event bus)
16434
- * pipeline-analytics subscriber
16435
- * ↓ SORT tracker + zone engine + state analyzer + event emitter
16436
- * → three DB collections (one per kind), one FS media tree, one
16437
- * unified event emitter (FrameTracked + TrackStarted/Ended +
16438
- * DetectionEvent on bus)
16439
- *
16440
- * Pure subscriber model. No `processFrame` cap method — the runner
16441
- * already publishes the raw frame on the bus. The cap surface is
16442
- * only QUERIES + per-device settings, bound on/off via
16443
- * `device-manager.setWrapperActive`. `defaultActive: true` because
16444
- * every camera with a detection pipeline wants its raw detections
16445
- * refined; operators opt out per-device via BindingsTab when needed.
16446
- *
16447
- * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
16448
- * (per-device surface) and `track-trail` caps — see P11 cleanup.
16443
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
16444
+ * within the frame, so the executor can re-cut a leaf child ROI at native
16445
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
16449
16446
  */
16450
- var TrackStateSchema = _enum([
16451
- "new",
16452
- "entered",
16453
- "left",
16454
- "moving",
16455
- "idle"
16456
- ]);
16457
- var EventKindSchema = _enum([
16458
- "motion",
16459
- "object",
16460
- "audio"
16461
- ]);
16447
+ var NativeCropRefSchema = object({
16448
+ /** Handle keying the retained native surface (node-pinned to its owner). */
16449
+ handle: FrameHandleSchema,
16450
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
16451
+ cropFrameSpace: object({
16452
+ x: number(),
16453
+ y: number(),
16454
+ w: number(),
16455
+ h: number()
16456
+ })
16457
+ });
16458
+ object({
16459
+ crop: object({
16460
+ left: number(),
16461
+ top: number(),
16462
+ width: number().positive(),
16463
+ height: number().positive()
16464
+ }).optional(),
16465
+ content: object({
16466
+ width: number().int().positive(),
16467
+ height: number().int().positive()
16468
+ }),
16469
+ fit: _enum(["stretch", "contain"]),
16470
+ format: _enum([
16471
+ "rgb",
16472
+ "gray",
16473
+ "jpeg"
16474
+ ])
16475
+ });
16462
16476
  /**
16463
- * Spatial filter for `listTracks` — the rect + polygon variants of the shared
16464
- * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
16465
- * of the camera frame (top-left origin), matching the drawing-plane editor.
16477
+ * Process-local frame identity. It is serializable so it can ride an in-process
16478
+ * capability call, but `registryId` deliberately prevents resolution in any
16479
+ * other process or execution group.
16466
16480
  */
16467
- var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
16468
- /** Closed icon vocabulary so clients render a known glyph per kind. */
16469
- var EventKindIconSchema = _enum([
16470
- "motion",
16471
- "audio",
16472
- "person",
16473
- "vehicle",
16474
- "animal",
16475
- "door",
16476
- "pir",
16477
- "smoke",
16478
- "water",
16479
- "button",
16480
- "package",
16481
- "generic"
16481
+ var FrameRefSchema = object({
16482
+ registryId: string().min(1),
16483
+ id: string().min(1),
16484
+ width: number().int().positive(),
16485
+ height: number().int().positive(),
16486
+ format: _enum(["rgb", "gray"]),
16487
+ timestamp: number(),
16488
+ capturedAt: number().optional()
16489
+ });
16490
+ var ModelFormatSchema$1 = _enum([
16491
+ "onnx",
16492
+ "coreml",
16493
+ "openvino",
16494
+ "tflite",
16495
+ "pt",
16496
+ "gguf"
16482
16497
  ]);
16483
- var EventKindCategorySchema = _enum([
16484
- "motion",
16485
- "audio",
16486
- "detection",
16487
- "sensor",
16488
- "control",
16489
- "custom",
16490
- "package"
16498
+ var PipelineSlotSchema = _enum([
16499
+ "detector",
16500
+ "cropper",
16501
+ "classifier",
16502
+ "refiner",
16503
+ "audio-classifier"
16491
16504
  ]);
16492
- /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
16493
- var EventKindLevelSchema = _enum(["macro", "sub"]);
16494
- var EventKindDescriptorSchema = object({
16495
- /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
16496
- kind: string(),
16497
- /** i18n key resolved on the UI side; `label` is the English fallback. */
16498
- labelKey: string(),
16499
- /** English fallback label (kept for clients that don't translate). */
16500
- label: string(),
16501
- /** Hex color for timeline/legend rendering. */
16502
- color: string(),
16503
- /** Dictionary id → lucide component on the UI side. */
16504
- iconId: string(),
16505
- /** Legacy closed-vocab glyph — fallback for `iconId`. */
16506
- icon: EventKindIconSchema,
16507
- category: EventKindCategorySchema,
16508
- /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
16509
- parentKind: string().nullable(),
16510
- /** Derived from `parentKind`, explicit for the client tree. */
16511
- level: EventKindLevelSchema,
16512
- /** Which cap + device contributes this kind. For built-ins the camera
16513
- * itself; for sensor kinds the LINKED source device. */
16514
- source: object({
16515
- capName: string(),
16516
- deviceId: number()
16517
- })
16505
+ var PipelineEngineChoiceSchema = object({
16506
+ runtime: _enum(["node", "python"]),
16507
+ backend: string(),
16508
+ format: ModelFormatSchema$1,
16509
+ device: string().optional()
16518
16510
  });
16519
- /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
16520
- var EventKindsForDeviceSchema = object({
16521
- deviceId: number(),
16522
- kinds: array(EventKindDescriptorSchema).readonly()
16511
+ var AvailableEngineSchema = object({
16512
+ engine: PipelineEngineChoiceSchema,
16513
+ devices: array(object({
16514
+ id: string(),
16515
+ label: string(),
16516
+ description: string().optional()
16517
+ })).readonly(),
16518
+ defaultDevice: string()
16523
16519
  });
16524
- var SensorEventSchema = object({
16520
+ var PipelineDefaultStepSchema = lazy(() => object({
16521
+ addonId: string(),
16522
+ addonName: string(),
16523
+ slot: PipelineSlotSchema,
16524
+ inputClasses: array(string()).readonly(),
16525
+ outputClasses: array(string()).readonly(),
16526
+ enabled: boolean(),
16527
+ modelId: string(),
16528
+ children: array(PipelineDefaultStepSchema).readonly(),
16529
+ group: string().optional(),
16530
+ settings: record(string(), unknown()).optional()
16531
+ }));
16532
+ var PipelineTemplateStepSchema = lazy(() => object({
16533
+ addonId: string(),
16534
+ enabled: boolean(),
16535
+ modelId: string(),
16536
+ children: array(PipelineTemplateStepSchema).readonly(),
16537
+ settings: record(string(), unknown()).optional()
16538
+ }));
16539
+ var PipelineTemplateSchema$1 = object({
16525
16540
  id: string(),
16526
- /** The CAMERA the event is attributed to (a sensor linked to N cameras
16527
- * yields N rows, one per camera). */
16528
- deviceId: number(),
16529
- /** The linked sensor device whose state changed. */
16530
- sourceDeviceId: number(),
16531
- /** Event kind id — matches an `EventKindDescriptor.kind`. */
16532
- kind: string(),
16533
- /** Snapshot of the sensor cap's runtime-state slice at the change. */
16534
- value: record(string(), unknown()).nullable(),
16535
- timestamp: number()
16541
+ name: string(),
16542
+ createdAt: string(),
16543
+ updatedAt: string(),
16544
+ engine: PipelineEngineChoiceSchema,
16545
+ steps: array(PipelineTemplateStepSchema).readonly()
16536
16546
  });
16537
- var TrackPositionSchema = object({
16538
- x: number(),
16539
- y: number(),
16540
- timestamp: number(),
16541
- bbox: BoundingBoxSchema
16547
+ var PipelineModelOptionSchema = object({
16548
+ id: string(),
16549
+ name: string(),
16550
+ formats: record(string(), object({
16551
+ downloaded: boolean(),
16552
+ sizeMB: number()
16553
+ })),
16554
+ group: ModelVariantGroupSchema.optional(),
16555
+ legacy: boolean().optional(),
16556
+ provider: ModelProviderIdSchema.optional()
16542
16557
  });
16543
- var TrackSnapshotSchema = object({
16544
- timestamp: number(),
16545
- position: TrackPositionSchema,
16546
- /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
16547
- mediaKey: string()
16558
+ var ConfigFieldBridge = custom();
16559
+ var PipelineAddonSchemaSchema = object({
16560
+ id: string(),
16561
+ name: string(),
16562
+ slot: PipelineSlotSchema,
16563
+ inputClasses: array(string()).readonly(),
16564
+ outputClasses: array(string()).readonly(),
16565
+ childSlots: array(PipelineSlotSchema).readonly(),
16566
+ models: array(PipelineModelOptionSchema).readonly(),
16567
+ defaultModelId: string(),
16568
+ defaultModelIdByFormat: record(string(), string()).optional(),
16569
+ enabledByDefault: boolean().optional(),
16570
+ backfillIntoExistingOverrides: boolean().optional(),
16571
+ defaultConfidence: number(),
16572
+ group: string().optional(),
16573
+ configSchema: array(ConfigFieldBridge).readonly().optional()
16548
16574
  });
16549
- /**
16550
- * Normalized 0..1 trajectory envelope (min/max over every position bbox,
16551
- * divided by the track's detection-frame dims), computed at persist time.
16552
- * Absent when the frame dims were unknown when the track was persisted
16553
- * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
16554
- */
16555
- var TrackEnvelopeSchema = object({
16556
- minX: number(),
16557
- minY: number(),
16558
- maxX: number(),
16559
- maxY: number()
16575
+ var PipelineSlotSchemaSchema = object({
16576
+ id: PipelineSlotSchema,
16577
+ label: string(),
16578
+ priority: number(),
16579
+ parentSlot: PipelineSlotSchema.nullable(),
16580
+ addons: array(PipelineAddonSchemaSchema).readonly()
16560
16581
  });
16561
- /**
16562
- * Row projection for track list queries. `full` (default) returns the
16563
- * complete Track including the frame-rate `positions[]` history and the
16564
- * `snapshots[]` references — megabytes across a page of tracks. `slim`
16565
- * keeps every scalar the list surfaces actually render (ids, class(es),
16566
- * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
16567
- * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
16568
- * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
16569
- * `getTrack`. Mirrors the event-store `projection` convention
16570
- * (`getObjectEvents` et al.).
16571
- */
16572
- var TrackProjectionSchema = _enum(["full", "slim"]);
16573
- /**
16574
- * One audio-classification label heard on the track's camera while the
16575
- * track was alive, aggregated per label. An "episode" is one persisted
16576
- * audio event (the confident-classification path: score ≥ the device's
16577
- * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
16578
- * one 32 ms inference chunk, so counts stay human-scaled.
16579
- */
16580
- var TrackAudioLabelSchema = object({
16581
- label: string(),
16582
- /** Highest classification score observed across the label's episodes. */
16583
- peakScore: number(),
16584
- /** Number of coalesced audio-event episodes carrying this label. */
16585
- count: number(),
16586
- firstAt: number(),
16587
- lastAt: number()
16582
+ var PipelineSchemaSchema = object({
16583
+ availableEngines: array(AvailableEngineSchema).readonly(),
16584
+ selectedEngine: PipelineEngineChoiceSchema,
16585
+ slots: array(PipelineSlotSchemaSchema).readonly()
16588
16586
  });
16589
- /**
16590
- * How a track was produced. `pipeline` (default / absent) = the spatial
16591
- * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
16592
- * no positions, a single snapshot, and no bbox trajectory at all:
16593
- *
16594
- * - `sensor` — a linked sensor/control device state change.
16595
- * - `audio` — an audio event on the camera itself that was anomalous for
16596
- * THAT camera, loud, and heard while nothing visual was happening (D62).
16597
- *
16598
- * The spatial subsystems (tracker association, occupancy count, re-id /
16599
- * embedding, resurrection) MUST skip every synthetic source. Test for that
16600
- * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
16601
- * check silently readmits every source added after it was written.
16602
- */
16603
- var TrackSourceSchema = _enum([
16604
- "pipeline",
16605
- "sensor",
16606
- "audio"
16607
- ]);
16608
- /**
16609
- * Where a track sits in the RETRAIN lifecycle (D81).
16610
- *
16611
- * - `none` — never marked, or un-marked. Evictable.
16612
- * - `staging` — the operator wants this track as training material and has not
16613
- * finished with it. **This is the only state retention holds**: the track and
16614
- * everything it owns (object events, crops, keyframes, CLIP vector) survive
16615
- * the device's age window.
16616
- * - `trained` — the retrain page has taken what it needed. The frames it chose
16617
- * were COPIED into the retrain dataset at selection time, so the dataset no
16618
- * longer depends on the track's media and the track becomes EVICTABLE again.
16619
- * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
16620
- * a deliberate action of the retrain page, not a side effect of a checkbox.
16621
- *
16622
- * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
16623
- * the store's filter language has only positive equality and `whereIn` — no
16624
- * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
16625
- * would make the entire pre-column history immortal in one deploy.
16626
- */
16627
- var RetrainStatusSchema = _enum([
16628
- "none",
16629
- "staging",
16630
- "trained"
16631
- ]);
16632
- /**
16633
- * Per-track OPERATOR flags — set by hand from the admin UI or the viewer, never
16634
- * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
16635
- * so the two surfaces cannot drift.
16636
- *
16637
- * **Absent ≠ false.** A track that has never been touched omits the field; an
16638
- * explicitly un-flagged track carries `false`. Legacy rows written before the
16639
- * columns existed read as absent, and a consumer that needs a boolean should say
16640
- * `flag === true`, not `flag !== false`.
16641
- *
16642
- * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
16643
- * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
16644
- * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
16645
- * `trained` track reports `false` while refusing both writes. The boolean is
16646
- * kept because three surfaces drive a toggle off it; anything that needs to tell
16647
- * "never marked" from "already trained" must read `retrainStatus`.
16648
- *
16649
- * `debug` does NOT pin; it is attention, not durability.
16650
- *
16651
- * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
16652
- * A favourited track is skipped by retention the same way `staging` is, but
16653
- * it does not enter `none|staging|trained` and has no staging budget.
16654
- */
16655
- var TrackFlagFields = {
16656
- /** Operator marked this track as training material — i.e. `retrainStatus` is
16657
- * `'staging'`. */
16658
- markForTrain: boolean().optional(),
16659
- /** Operator marked this track for diagnostic attention. */
16660
- debug: boolean().optional(),
16661
- /** Operator favourited this track. Pins it against pruning. */
16662
- favourited: boolean().optional()
16663
- };
16664
- /**
16665
- * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
16666
- * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
16667
- * write patch, and the status is not something the toggle sets — it is what the
16668
- * toggle's boolean is derived from. Absent on an in-RAM track never touched;
16669
- * always present on a persisted row (the column default materialises `'none'`).
16670
- */
16671
- var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
16672
- /**
16673
- * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
16674
- * one flag can never clear the other — the toggles are independent and are
16675
- * driven from three surfaces that do not know about each other.
16676
- */
16677
- var TrackFlagsPatchSchema = object(TrackFlagFields);
16678
- /**
16679
- * The resolved flag state after a write. Both fields are REQUIRED here (absent
16680
- * collapses to `false`) so a caller can drive a toggle's checked state off the
16681
- * mutation result without a re-fetch.
16682
- */
16683
- var TrackFlagsSchema = object({
16684
- trackId: string(),
16685
- markForTrain: boolean(),
16686
- debug: boolean(),
16687
- favourited: boolean(),
16688
- /** The lifecycle state the boolean was derived from. Required here (unlike on
16689
- * a track row) because this shape is only ever produced by the write body,
16690
- * which always knows it — and a surface that has just written needs to render
16691
- * `trained` without a re-fetch. */
16692
- retrainStatus: RetrainStatusSchema
16587
+ var EngineProvisioningSchema = object({
16588
+ runtimeId: _enum([
16589
+ "onnx",
16590
+ "openvino",
16591
+ "coreml",
16592
+ "edgetpu"
16593
+ ]).nullable(),
16594
+ device: string().nullable(),
16595
+ state: _enum([
16596
+ "idle",
16597
+ "installing",
16598
+ "verifying",
16599
+ "ready",
16600
+ "failed"
16601
+ ]),
16602
+ progress: number().optional(),
16603
+ error: string().optional(),
16604
+ nextRetryAt: number().optional(),
16605
+ /**
16606
+ * Gate A (config-correctness gate at engine change): human-readable
16607
+ * config issues surfaced EAGERLY when the node's engine changes — model
16608
+ * substitutions ("chose X, running Y") and zero-build steps ("no model
16609
+ * has a <format> build"). Additive/optional: informational only, never
16610
+ * enforced here — `assertEngineReady` (readiness) still gates inference.
16611
+ * Absent/empty when the node-default tree resolves cleanly.
16612
+ */
16613
+ configIssues: array(string()).optional()
16693
16614
  });
16694
- union([literal(1), literal(2)]);
16695
- /**
16696
- * WHO decided a label, and when. Carried per tier so a value can be traced to
16697
- * the step and model that produced it — which is what makes the write rule
16698
- * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
16699
- * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
16700
- *
16701
- * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
16702
- * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
16703
- * `migration:4g` for a value the 4g migration moved from the single-slot era —
16704
- * that value has no provenance, and the write rule lets ANY properly-attributed
16705
- * write of the same tier replace it regardless of score.
16706
- */
16707
- var LabelAttributionSchema = object({
16708
- stepId: string(),
16615
+ var PipelineStepInputSchema = lazy(() => object({
16616
+ addonId: string(),
16709
16617
  modelId: string().optional(),
16710
- decidedAt: number(),
16618
+ enabled: boolean().default(true),
16619
+ children: array(PipelineStepInputSchema).optional(),
16620
+ settings: record(string(), unknown()).optional(),
16621
+ jumpDeviceKey: string().optional()
16622
+ }));
16623
+ var ModelSubstitutionSchema = object({
16624
+ addonId: string(),
16625
+ chosen: string(),
16626
+ running: string(),
16627
+ format: string()
16628
+ });
16629
+ var PipelineValidationIssueSchema = object({
16630
+ addonId: string(),
16631
+ kind: _enum(["unknown-addon", "no-format-build"]),
16632
+ detail: string()
16633
+ });
16634
+ var PipelineValidationResultSchema = object({
16635
+ ok: boolean(),
16636
+ issues: array(PipelineValidationIssueSchema).readonly(),
16637
+ substitutions: array(ModelSubstitutionSchema).readonly(),
16638
+ /** The node's `currentEngine.format` this validation ran against. */
16639
+ format: string()
16640
+ });
16641
+ var ReferenceImageEntrySchema = object({
16642
+ filename: string(),
16643
+ stepIds: array(string()).readonly().optional()
16644
+ });
16645
+ var ReferenceImageBodySchema = object({
16646
+ base64: string(),
16647
+ filename: string()
16648
+ });
16649
+ var ReferenceAudioEntrySchema = object({
16650
+ filename: string(),
16651
+ sizeKb: number()
16652
+ });
16653
+ var ReferenceAudioBodySchema = object({ base64: string() });
16654
+ var AudioBackendSchema = object({
16655
+ id: string(),
16656
+ name: string(),
16657
+ description: string(),
16658
+ available: boolean(),
16711
16659
  /**
16712
- * The GALLERY id behind a recognised tier-2 label — a face-gallery
16713
- * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
16714
- *
16715
- * The text alone is a DISPLAY NAME, and a display name is renameable: a
16716
- * notification rule authored on "Gianluca" stopped matching the moment the
16717
- * operator fixed the spelling in the gallery, and nothing said so. The id is
16718
- * the thing that does not move, so it is what a rule matches on
16719
- * (`NcConditions.identities`) and the text is what a human is shown.
16720
- *
16721
- * Absent when the label names no gallery row — a plate the OCR read but no
16722
- * vehicle claims, a sub-class, a species, any tier-1 value.
16660
+ * Raw classifier labels this backend can emit (e.g. YAMNet's
16661
+ * 521-class set or Apple SoundAnalysis's 303-class set). Used by
16662
+ * the benchmark UI to populate the `enabledMicroClasses` filter
16663
+ * specific to the selected backend without a separate fetch.
16723
16664
  */
16724
- identityId: string().optional()
16665
+ rawLabels: array(string()).readonly().optional()
16666
+ });
16667
+ var AudioCapabilitiesSchema = object({
16668
+ activeBackend: string(),
16669
+ availableBackends: array(AudioBackendSchema).readonly(),
16670
+ sampleRate: number(),
16671
+ chunkDurationMs: number()
16672
+ });
16673
+ var DownloadModelResultSchema = object({
16674
+ filePath: string(),
16675
+ sizeMB: number(),
16676
+ durationMs: number()
16725
16677
  });
16726
16678
  /**
16727
- * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
16728
- * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
16729
- * track and its events always answer the same question the same way.
16730
- *
16731
- * Two scalar columns, not an array: every consumer wants "the coarse one" or
16732
- * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
16733
- * is tier 2, and each carries its own score + attribution.
16734
- *
16735
- * **Reading it.** What a human should be shown is `subLabel ?? label` — the
16736
- * finest thing known. Before 4g the single `label` column held the finest
16737
- * value, so a consumer that has not been updated reads the tier-1 slot and
16738
- * shows nothing on a species-only row; that is why the migration puts every
16739
- * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
16740
- * and why the read surfaces were changed in the same train.
16741
- *
16742
- * **Writing it.** The slots are independent, which is the whole point: a
16743
- * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
16744
- * migratorius`), so fineness cannot regress by construction. Within a tier the
16745
- * higher score wins. One rule, one implementation — see
16746
- * `pipeline/label-tier.ts` in addon-post-analysis.
16747
- */
16748
- var TieredLabelFields = {
16749
- /** Tier 1 — the sub-class. See {@link LabelTierSchema}. */
16750
- label: string().optional(),
16751
- /** Confidence of the tier-1 value, as reported by the deciding step. */
16752
- labelScore: number().optional(),
16753
- /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
16754
- labelMeta: LabelAttributionSchema.optional(),
16755
- /** Tier 2 — the instance. See {@link LabelTierSchema}. */
16756
- subLabel: string().optional(),
16757
- /** Confidence of the tier-2 value, as reported by the deciding step. */
16758
- subLabelScore: number().optional(),
16759
- /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
16760
- subLabelMeta: LabelAttributionSchema.optional()
16761
- };
16762
- /** Per-camera slice of a training-export estimate. */
16763
- var TrainingExportDeviceTotalsSchema = object({
16764
- deviceId: number(),
16765
- tracks: number().int(),
16766
- files: number().int(),
16767
- bytes: number().int()
16768
- });
16769
- /**
16770
- * What a training export WOULD contain. Computed from media index rows only —
16771
- * no blob is read to produce this.
16679
+ * Wrapper carrying a single test run's result. Replaces the legacy
16680
+ * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
16681
+ * canonical `AudioResult` from the Phase 6 output rework: one
16682
+ * `AudioDetection` per class above `minScore`, top-N candidates in
16683
+ * `debug.alternateLabels['audio-classifier']`, per-source timings in
16684
+ * `debug.stepTimings`. The outer `success`/`error` fields stay so the
16685
+ * benchmark UI can still report a clean failure when the classifier
16686
+ * cap isn't available.
16772
16687
  */
16773
- var TrainingExportSummarySchema = object({
16774
- generatedAt: number(),
16775
- trackCount: number().int(),
16776
- fileCount: number().int(),
16777
- byteCount: number().int(),
16778
- /** More marked tracks exist than a single pass carries. */
16779
- truncated: boolean(),
16780
- devices: array(TrainingExportDeviceTotalsSchema).readonly()
16688
+ var AudioTestResultSchema = object({
16689
+ success: boolean(),
16690
+ error: string().optional(),
16691
+ frame: custom().optional()
16781
16692
  });
16782
- var TrackSchema = object({
16783
- trackId: string(),
16784
- deviceId: number(),
16785
- className: string(),
16786
- ...TieredLabelFields,
16787
- producingDeviceName: string().optional(),
16788
- /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
16789
- source: TrackSourceSchema.optional(),
16790
- firstSeen: number(),
16791
- lastSeen: number(),
16792
- /** Frame-rate position history (subject to maxPositionHistory cap). */
16793
- positions: array(TrackPositionSchema).readonly(),
16794
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
16795
- * saveThumbnails policy). */
16796
- snapshots: array(TrackSnapshotSchema).readonly(),
16797
- /** Deduplicated zones the track has entered at least once. Zone IDS. */
16798
- zonesVisited: array(string()).readonly(),
16693
+ var PipelineConfigBridge = custom();
16694
+ var ConfigUISchemaBridge = custom();
16695
+ var ConfigUISchemaNullableBridge = custom();
16696
+ var InferenceCapabilitiesBridge = custom();
16697
+ var ModelAvailabilityListBridge = custom();
16698
+ var PipelineRunResultBridge = custom();
16699
+ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
16700
+ modelId: string(),
16701
+ settings: record(string(), unknown()).readonly()
16702
+ }))), method(object({ steps: record(string(), object({
16703
+ modelId: string(),
16704
+ settings: record(string(), unknown()).readonly()
16705
+ })) }), object({ success: literal(true) }), {
16706
+ kind: "mutation",
16707
+ auth: "admin"
16708
+ }), method(object({ nodeId: string() }), object({
16709
+ success: literal(true),
16710
+ clearedDevices: number()
16711
+ }), {
16712
+ kind: "mutation",
16713
+ auth: "admin"
16714
+ }), method(object({ nodeId: string() }), object({ unhealthy: array(object({
16715
+ /** `<backend>:<device>`, e.g. `openvino:gpu`. */
16716
+ deviceKey: string(),
16799
16717
  /**
16800
- * Human NAMES for {@link zonesVisited}, resolved at READ time against the
16801
- * `zones` capability.
16802
- *
16803
- * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
16804
- * and no card can render — so every free-text search surface was structurally
16805
- * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
16806
- * just returned nothing. Resolving here rather than in each client keeps ONE
16807
- * derivation and costs the clients no extra call (the `zones` cap is
16808
- * per-device, so a client-side resolve would be a per-camera fan-out on a
16809
- * surface built to avoid exactly that).
16810
- *
16811
- * Resolved, never invented: a zone deleted since the track was written has no
16812
- * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
16813
- * two are not positionally aligned. Absent when the track visited no zone, or
16814
- * when the zone catalogue could not be read.
16718
+ * `failed` — the per-device restart budget is exhausted; no pool
16719
+ * will be spawned until an operator re-arms it or the runner
16720
+ * respawns. `backoff` — under budget, waiting out the backoff (or
16721
+ * a cached pool observed dead and not yet condemned).
16815
16722
  */
16816
- zoneNames: array(string()).readonly().optional(),
16817
- /** Deduplicated set of detector classes observed for this track over its
16818
- * life (a track may be reclassified, e.g. person→vehicle). Absent on
16819
- * legacy rows written before class accumulation shipped. */
16820
- classes: array(string()).readonly().optional(),
16821
- /** Cumulative normalized distance travelled (0..1 units = full frame width). */
16822
- totalDistance: number(),
16823
- state: TrackStateSchema,
16824
- active: boolean(),
16825
- /** Deterministic key-event importance score in [0,1] (server-computed at
16826
- * track expiry, recomputed on late label). Absent on legacy rows written
16827
- * before scoring shipped — consumers degrade to absence / compute-on-read. */
16828
- importance: number().optional(),
16829
- /** Id of the track's highest-confidence ObjectEvent (its representative
16830
- * "best" frame). Absent when the track produced no object events. */
16831
- bestEventId: string().optional(),
16832
- /** Tag of the importance sub-signal that dominated the score
16833
- * (identity|dwell|proximity|class|confidence|travel|zone). */
16834
- importanceReason: string().optional(),
16835
- /** Audio-classification labels heard on the camera during the track's
16836
- * life (score ≥ device `classificationMinScore`), aggregated per label.
16837
- * Absent on legacy rows / tracks with no confident audio. */
16838
- audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
16839
- /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
16840
- * Populated from the persisted envelope columns on historical reads;
16841
- * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
16842
- envelope: TrackEnvelopeSchema.optional(),
16723
+ state: _enum(["failed", "backoff"]),
16724
+ /** Epoch ms of the death that produced this state. */
16725
+ since: number(),
16726
+ /** Pool deaths inside the current window. */
16727
+ deaths: number(),
16728
+ /** The last death's message. */
16729
+ lastError: string()
16730
+ })).readonly() })), method(object({
16731
+ nodeId: string(),
16732
+ deviceKey: string()
16733
+ }), object({ rearmed: boolean() }), {
16734
+ kind: "mutation",
16735
+ auth: "admin"
16736
+ }), method(_void(), PipelineSchemaSchema), method(_void(), array(PipelineDefaultStepSchema).readonly().nullable()), method(_void(), PipelineConfigBridge), method(_void(), ConfigUISchemaBridge), method(object({ steps: array(PipelineStepInputSchema) }), PipelineValidationResultSchema), method(_void(), array(PipelineTemplateSchema$1).readonly()), method(object({
16737
+ name: string(),
16738
+ steps: array(PipelineTemplateStepSchema).readonly(),
16739
+ engine: PipelineEngineChoiceSchema
16740
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
16741
+ id: string(),
16742
+ name: string().optional(),
16743
+ steps: array(PipelineTemplateStepSchema).readonly().optional()
16744
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
16745
+ addonId: string(),
16746
+ modelId: string(),
16747
+ format: ModelFormatSchema$1
16748
+ }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
16749
+ addonId: string(),
16750
+ modelId: string(),
16751
+ format: ModelFormatSchema$1
16752
+ }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
16753
+ engine: PipelineEngineChoiceSchema.optional(),
16754
+ steps: array(PipelineStepInputSchema).min(1),
16755
+ frame: FrameInputSchema.optional(),
16843
16756
  /**
16844
- * A face DETECTOR found a face on this track — nothing more. It says the
16845
- * detail plane produced a `face` detail; it does NOT say the face was
16846
- * embedded, matched, above `minFacePx`, or that the recognizer was even
16847
- * enabled. Set once and never cleared.
16848
- *
16849
- * **This exists so "face present but not recognised" is expressible.** A
16850
- * recognised identity lands in `subLabel` (attributed to the face chain via
16851
- * `subLabelMeta.stepId`), so before this field a track with an unmatched face
16852
- * and a track with no face at all were byte-identical on the wire and no
16853
- * surface could tell them apart. The read is `hasFace === true && subLabel
16854
- * === undefined`.
16855
- *
16856
- * **Absent ≠ false.** Every row written before the column existed omits it,
16857
- * and so does every server that predates the field — a consumer must test
16858
- * `=== true` and render nothing otherwise, never infer "no face".
16757
+ * Process-local lazy frame. Valid only when caller and provider resolve
16758
+ * in the same execution-group process; split/cross-node callers use
16759
+ * `frame`/`image` inline compatibility instead.
16859
16760
  */
16860
- hasFace: boolean().optional(),
16761
+ frameRef: FrameRefSchema.optional(),
16861
16762
  /**
16862
- * This track has a face row IN THE GALLERY: a crop **and** an embedding — a
16863
- * face an operator could ASSIGN to an identity.
16864
- *
16865
- * The STRICT twin of {@link hasFace}, and the pair only earns its keep
16866
- * because the two disagree. `hasFace` is stamped at the TOP of the face
16867
- * branch, before every gate, and means no more than "a face detector produced
16868
- * a face detail". This one is stamped at the single moment the gallery row
16869
- * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
16870
- * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
16871
- * candidate gate, the imageless-track drop (no crop was ever captured) and
16872
- * the crop-store drop. Everything between the detector and that insert can
16873
- * legitimately refuse the face, so a flag written any earlier promises the
16874
- * operator something to assign and delivers nothing.
16875
- *
16876
- * **Independent of recognition.** A face collected but never auto-matched is
16877
- * still assignable — it is in fact the face an operator most wants to reach —
16878
- * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
16879
- * `subLabel`; this says only that the raw material exists.
16880
- *
16881
- * **Set once, never cleared.** A track that produced a gallery row produced
16882
- * one; deleting the row later is the gallery's business, not this flag's.
16883
- *
16884
- * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
16885
- * before the column omits it, and so does every server that predates the
16886
- * field. A consumer must test `=== true` and render nothing otherwise —
16887
- * never infer "no assignable face".
16763
+ * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
16764
+ * the decoded pixels live in. One more member of the one-of
16765
+ * frame/frameHandle/image/imageBase64/referenceImage group.
16888
16766
  */
16889
- hasEmbeddedFace: boolean().optional(),
16767
+ frameHandle: FrameHandleSchema.optional(),
16768
+ imageBase64: string().optional(),
16890
16769
  /**
16891
- * This subject CONTAINS a folded rider — a person the rider-pairing step
16892
- * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
16893
- * so the passage is tracked once and as a VEHICLE.
16894
- *
16895
- * It exists because the fold's record was dishonest. D34 and the code both
16896
- * said "the person is not lost — it is reported so both entities stay on the
16897
- * record"; in fact the pair went into a per-processor RAM field behind an
16898
- * accessor nobody called, and every durable surface said `vehicle`, full
16899
- * stop. This is the composition note that makes the row true.
16900
- *
16901
- * A COMPOSITION, never a class and never a label. "This vehicle contains a
16902
- * person" is not an answer to "what is this" — both label tiers would refuse
16903
- * a macro token anyway (D89), and correctly. Nothing here changes what the
16904
- * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
16905
- * and a `person` rule still does not fire for someone cycling past.
16906
- *
16907
- * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
16908
- * the column, and every hub that predates the field, omits it. Test
16909
- * `=== true` and render nothing otherwise — never infer "no rider".
16770
+ * Binary JPEG bytes — preferred over `imageBase64` on internal
16771
+ * hops (hub → forked worker via Moleculer MsgPack) because it
16772
+ * skips the 33% base64 overhead + the per-call base64 decode on
16773
+ * the detection-pipeline worker. Callers can pass either; exactly
16774
+ * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
16910
16775
  */
16911
- hasRider: boolean().optional(),
16912
- ...TrackFlagFields,
16913
- ...TrackRetrainFields
16914
- });
16915
- var BaseEventFields = {
16916
- id: string(),
16917
- deviceId: number(),
16918
- timestamp: number()
16919
- };
16920
- var MotionEventSchema = object({
16921
- ...BaseEventFields,
16922
- kind: literal("motion"),
16923
- regionCount: number(),
16924
- /** Heavy JSON array — omitted in slim projection. */
16925
- regions: array(object({
16926
- bbox: BoundingBoxSchema,
16927
- pixelCount: number(),
16928
- intensity: number()
16929
- })).readonly().optional(),
16930
- /** Omitted in slim projection. */
16931
- frameWidth: number().optional(),
16932
- /** Omitted in slim projection. */
16933
- frameHeight: number().optional(),
16934
- /** Populated by B5 (recording playback URL for this event). */
16935
- mediaUrl: string().optional()
16936
- });
16776
+ image: _instanceof(Uint8Array).optional(),
16777
+ referenceImage: string().optional(),
16778
+ deviceId: number().optional(),
16779
+ sessionId: string().optional(),
16780
+ /**
16781
+ * Execution plane. 'full' (default) runs the whole tree — benchmark,
16782
+ * reference-image, and detail-subtree calls. 'frame' is the live
16783
+ * per-frame dispatch: ONLY root-plane steps run; crop children
16784
+ * (inputClasses ≠ null) are skipped and served per-track via
16785
+ * pipelineRunner.runDetailSubtree (two-plane design).
16786
+ */
16787
+ plane: _enum(["full", "frame"]).optional(),
16788
+ /**
16789
+ * Inference-device selector (Phase 2 multi-device). Format
16790
+ * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
16791
+ * Omitted ⇒ the runner's default device (current single-engine
16792
+ * behaviour). Selects WHICH device pool of the node runs the call.
16793
+ */
16794
+ deviceKey: string().optional(),
16795
+ /**
16796
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
16797
+ * when the parent crop was resolved from the frame's retained NATIVE
16798
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
16799
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
16800
+ * resolution from that surface — the SAME quality path faces already
16801
+ * had — instead of the downscaled parent tile. `handle` keys the native
16802
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
16803
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
16804
+ * the executor's crop-normalized child ROI back into frame-normalized
16805
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
16806
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
16807
+ * (today's behaviour on the fallback path).
16808
+ */
16809
+ nativeCropRef: NativeCropRefSchema.optional()
16810
+ }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
16811
+ engine: PipelineEngineChoiceSchema.optional(),
16812
+ steps: array(PipelineStepInputSchema).min(1),
16813
+ frames: array(FrameInputSchema).min(1).max(255),
16814
+ deviceId: number().optional(),
16815
+ sessionId: string().optional(),
16816
+ /**
16817
+ * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
16818
+ * the batch to the Python pool's bench preprocess cache
16819
+ * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
16820
+ * preprocessed ONCE and every later inference is a pure-inference cache
16821
+ * hit — the sustained-throughput run measures inference, not
16822
+ * decode+preprocess+infer. Omitted/0 for live frames (all different →
16823
+ * full preprocess every call, correct). Fresh per sustained run;
16824
+ * released via `uncacheFrame`.
16825
+ */
16826
+ frameId: number().int().nonnegative().optional(),
16827
+ /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
16828
+ deviceKey: string().optional()
16829
+ }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
16830
+ data: _instanceof(Uint8Array),
16831
+ width: number().int().positive(),
16832
+ height: number().int().positive(),
16833
+ format: _enum([
16834
+ "rgb",
16835
+ "bgr",
16836
+ "gray"
16837
+ ])
16838
+ }), object({
16839
+ frameId: number(),
16840
+ width: number(),
16841
+ height: number()
16842
+ }), { kind: "mutation" }), method(object({
16843
+ stepId: string(),
16844
+ frameId: number().int()
16845
+ }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
16846
+ batchMode: string(),
16847
+ windowMs: number(),
16848
+ maxBatchSize: number(),
16849
+ concurrency: number()
16850
+ })), method(_void(), array(object({
16851
+ engineKey: string(),
16852
+ engine: PipelineEngineChoiceSchema,
16853
+ modelsLoaded: array(string()).readonly(),
16854
+ inUseByCameras: array(number()).readonly(),
16855
+ /**
16856
+ * Origin of this resident factory.
16857
+ * - `runtime` — main camera-serving engine (no idle TTL).
16858
+ * - `warm-override` — benchmark/test override held in the warm
16859
+ * cache; auto-disposed after the idle TTL.
16860
+ * - `device-pool` — a concurrent per-device pool (Phase 2
16861
+ * multi-device, keyed by `deviceKey`) resolved
16862
+ * via `resolveDeviceFactory`. Runs alongside the
16863
+ * `runtime` engine on a DIFFERENT accelerator
16864
+ * (NPU / iGPU / Coral) — this is how the
16865
+ * Engines tab shows all pools running at once.
16866
+ */
16867
+ kind: _enum([
16868
+ "runtime",
16869
+ "warm-override",
16870
+ "device-pool"
16871
+ ]),
16872
+ /** Native pid of the underlying Python pool (null when no pool). */
16873
+ poolPid: number().nullable(),
16874
+ /** ms since this factory was last used (null when not warm-tracked). */
16875
+ idleMs: number().nullable(),
16876
+ /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
16877
+ idleTtlMs: number().nullable()
16878
+ })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
16879
+ kind: "mutation",
16880
+ auth: "admin"
16881
+ }), method(object({
16882
+ engine: PipelineEngineChoiceSchema,
16883
+ force: boolean().optional()
16884
+ }), object({
16885
+ success: boolean(),
16886
+ reason: string().optional()
16887
+ }), {
16888
+ kind: "mutation",
16889
+ auth: "admin"
16890
+ }), method(_void(), array(ReferenceImageEntrySchema).readonly()), method(object({ filename: string() }), ReferenceImageBodySchema.nullable()), method(_void(), array(ReferenceAudioEntrySchema).readonly()), method(object({ filename: string() }), ReferenceAudioBodySchema.nullable()), method(_void(), AudioCapabilitiesSchema), method(object({
16891
+ addonId: string(),
16892
+ modelId: string(),
16893
+ filename: string().optional(),
16894
+ settings: record(string(), unknown()).optional()
16895
+ }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
16937
16896
  /**
16938
- * Which detection SOURCE produced an object event. `pipeline` = the ML
16939
- * detection pipeline (decoded-frame inference); `onboard` = the camera's
16940
- * native on-device AI. Both flow through the SAME analysis layers (zoning,
16941
- * tracking, per-kind persistence) but stay distinguishable so consumers
16942
- * (advanced-notifier, occupancy, …) can select which source(s) to act on.
16943
- * Absent on legacy rows ⇒ treat as `pipeline`.
16897
+ * Per-stage gating mode applied to the zones a rule references.
16898
+ *
16899
+ * - `include`: the rule contributes to a **whitelist** for its stage.
16900
+ * When at least one `include` rule fires for a stage, only entities
16901
+ * inside one of those zones pass that stage.
16902
+ * - `exclude`: the rule contributes to a **blacklist** for its stage.
16903
+ * Entities inside one of those zones are dropped at that stage.
16904
+ *
16905
+ * `monitor`-style observation (count without filtering) is not a rule
16906
+ * mode — zones without any matching rule are observed naturally by
16907
+ * `zone-analytics` (live snapshot + history), so an "I just want to
16908
+ * count, not filter" use case needs no rule at all.
16944
16909
  */
16945
- var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
16910
+ var ZoneRuleModeEnum = _enum(["include", "exclude"]);
16946
16911
  /**
16947
- * The confirmed zone crossing that produced an object event. Present ONLY on
16948
- * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
16949
- * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
16950
- * appearance event carry none, so a rule asking for a direction fails closed
16951
- * on them.
16912
+ * Per-consumer rule that references existing zones (geometry) and
16913
+ * defines how a specific pipeline stage should treat them. Each
16914
+ * consumer addon owns its own `ZoneRule[]` array in its per-device
16915
+ * settings:
16952
16916
  *
16953
- * Exactly ONE crossing per event: the emitter turns each confirmed crossing
16954
- * into its own event, so a frame in which a track enters A while leaving B
16955
- * produces two events with two directions — never one ambiguous row.
16917
+ * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
16918
+ * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
16919
+ * - future: notification rules, audio gating, etc.
16956
16920
  *
16957
- * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
16958
- * membership the box has NOW, and by definition it no longer contains the zone
16959
- * that was just left. Without the id here, a zone-scoped rule could never match
16960
- * the exit it asked for.
16921
+ * One rule applies to N zones (`zoneIds[]`) so the operator can
16922
+ * express "ignore motion in ALL of {garden, street}" with a single
16923
+ * rule. `classFilter` narrows the rule to specific object classes —
16924
+ * "drop person detections in the street, but keep cars" is one
16925
+ * `exclude` rule with `classFilter: ['person']`.
16926
+ *
16927
+ * `enabled` is a soft toggle — the operator can keep the rule
16928
+ * configured but inert without deleting it.
16961
16929
  */
16962
- var ZoneCrossingSchema = object({
16963
- direction: _enum(["enter", "exit"]),
16964
- /** Admin zone id crossed. */
16965
- zoneId: string(),
16966
- /** Zone display name at crossing time (falls back to the id). */
16967
- zoneName: string().optional()
16968
- });
16969
- var ObjectEventSchema = object({
16970
- ...BaseEventFields,
16971
- kind: literal("object"),
16972
- /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
16973
- source: DetectionSourceSchema.optional(),
16930
+ var ZoneRuleSchema = object({
16931
+ /** Stable rule id — survives edits, used by the UI for diffing. */
16932
+ id: string(),
16933
+ /** Optional human-readable label rendered in the rule editor. */
16934
+ name: string().optional(),
16935
+ /** Zones this rule targets. The rule's `mode` applies to ALL
16936
+ * listed zones (OR-set: a detection in any one of them counts).
16937
+ * At least one zone id required — a rule with no targets is a
16938
+ * configuration mistake and the form validator rejects it. */
16939
+ zoneIds: array(string()).min(1).readonly(),
16940
+ mode: ZoneRuleModeEnum,
16974
16941
  /**
16975
- * Inference-frame id shared by every object event emitted from the SAME frame
16976
- * — the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
16977
- * 2 people + 1 dog) under one full frame, and link a track's frames over time
16978
- * (group by `trackId`, pick a representative `frameId` as the parent frame).
16979
- * Optional for backward-compat with pre-existing rows / the slim projection
16980
- * includes it (it is light). Absent on rows written before this field.
16942
+ * Class names this rule applies to. Empty / undefined ⇒ rule
16943
+ * applies to every class. Class strings match the `macroClass`
16944
+ * field on detections (e.g. `person`, `car`, `dog`).
16981
16945
  */
16982
- frameId: string().optional(),
16983
- /** Omitted in slim projection. */
16984
- trackId: string().optional(),
16985
- className: string(),
16986
- ...TieredLabelFields,
16987
- /** Omitted in slim projection. */
16988
- confidence: number().optional(),
16989
- /** Heavy JSON — omitted in slim projection. */
16990
- bbox: BoundingBoxSchema.optional(),
16991
- /** Heavy JSON — omitted in slim projection. */
16992
- zones: array(string()).readonly().optional(),
16993
- /** Omitted in slim projection. */
16994
- state: TrackStateSchema.optional(),
16946
+ classFilter: array(string()).readonly().optional(),
16995
16947
  /**
16996
- * The zone crossing this event IS, when it is one. Absent on every other
16997
- * event kind (movement state, appearance, package) — see
16998
- * {@link ZoneCrossingSchema}. Omitted in slim projection.
16948
+ * Minimum bbox/mask overlap (0–1) with any of the rule's zones
16949
+ * required to consider an entity "in the zone". Defaults to the
16950
+ * consumer's stage default when omitted. Kept for back-compat with
16951
+ * existing per-rule overrides; new operators pick the value via
16952
+ * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
16953
+ * set, the lower-level engine reads it as a 0–1 fraction.
16999
16954
  */
17000
- zoneCrossing: ZoneCrossingSchema.optional(),
17001
- /** Detection-frame dimensions in pixels — let consumers normalize the
17002
- * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
17003
- frameWidth: number().optional(),
17004
- frameHeight: number().optional(),
17005
- /** MediaStore key for the crop attached to this event (if any). */
17006
- mediaKey: string().optional(),
17007
- /** Design B: MediaStore key of the track's native-resolution key frame (the
17008
- * best-detection full frame). Resolve via the event-media data-plane
17009
- * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
17010
- * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
17011
- * sources — consumers fall back to `mediaKey` (the tight crop). */
17012
- keyFrameMediaKey: string().optional(),
17013
- /** Populated by B5 (recording playback URL for this event). */
17014
- mediaUrl: string().optional(),
17015
- /** The parent track's key-event importance [0,1], propagated to every object
17016
- * event of the track (so an event row can be sorted by importance without a
17017
- * track join). Absent on legacy rows / before the track was scored. */
17018
- importance: number().optional()
17019
- });
17020
- var AudioEventSchema = object({
17021
- ...BaseEventFields,
17022
- kind: literal("audio"),
17023
- rms: number(),
17024
- dbfs: number(),
17025
- classification: object({
17026
- className: string(),
17027
- originalClass: string().optional(),
17028
- score: number()
17029
- }).optional(),
17030
- /** Populated by B5 (recording playback URL for this event). */
17031
- mediaUrl: string().optional()
16955
+ overlapThreshold: number().min(0).max(1).optional(),
16956
+ /**
16957
+ * Operator-friendly version of `overlapThreshold` — the percentage
16958
+ * of the detection's bbox that must lie inside the zone for the
16959
+ * rule to match. Documented default is 85%; the engine substitutes
16960
+ * that when the field is omitted (kept optional so existing rules
16961
+ * stored without it stay valid).
16962
+ *
16963
+ * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
16964
+ * rule, the engine prefers `bboxInclusionPct` because it's the
16965
+ * field exposed in the UI. Internally both feed the same gate.
16966
+ */
16967
+ bboxInclusionPct: number().min(0).max(100).optional(),
16968
+ /**
16969
+ * When `true` and a detection has a segmentation mask, use the
16970
+ * mask for overlap instead of the bbox. Detection-stage only;
16971
+ * motion rules ignore this field.
16972
+ */
16973
+ preferMask: boolean().optional(),
16974
+ /**
16975
+ * Soft-toggle: `false` disables the rule without deleting it.
16976
+ * Defaults to `true` so operators creating a rule via the UI
16977
+ * see it active immediately.
16978
+ */
16979
+ enabled: boolean().default(true)
17032
16980
  });
17033
- var MediaFileKindEnum = _enum([
17034
- "crop",
17035
- "thumbnail",
17036
- "snapshot",
17037
- "firstFrame",
17038
- "lastFrame",
17039
- "fullFrame",
17040
- "fullFrameBoxed",
17041
- "faceCrop",
17042
- "plateCrop",
17043
- "keyFrame",
17044
- "keyFrameSmall",
17045
- "thumbnailSmall"
17046
- ]);
17047
- var MediaFileSchema = object({
17048
- key: string(),
17049
- kind: MediaFileKindEnum,
17050
- base64: string(),
17051
- sizeBytes: number(),
17052
- timestamp: number()
16981
+ array(ZoneRuleSchema).readonly();
16982
+ /**
16983
+ * Zone — pure geometry + identity. NO filtering behaviour.
16984
+ *
16985
+ * Zones describe **where** in the frame the operator wants to flag
16986
+ * something; consumer-owned {@link ZoneRule} arrays describe **how**
16987
+ * each pipeline stage uses them. Splitting the two means a single
16988
+ * polygon "Driveway" can simultaneously back a motion-exclude rule,
16989
+ * a detection-include rule on `['car']`, and an occupancy aggregate
16990
+ * — without three duplicated polygons.
16991
+ *
16992
+ * Owned by the orchestrator addon (provider) and mirrored into the
16993
+ * `zones` device-state slice on every mutation. Consumers
16994
+ * (motion-wasm, pipeline-executor, analytics, admin UI) read either
16995
+ * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
16996
+ * mirror with `onChanged`).
16997
+ *
16998
+ * Coordinates are normalised fractions of the frame (0–1) so zones
16999
+ * survive resolution changes and stream profile switches.
17000
+ *
17001
+ * `kind` discriminates between full polygons (closed regions used
17002
+ * for intrusion / occupancy filters) and tripwires (open 2-point
17003
+ * line segments used for cross events). Onboard / firmware-reported
17004
+ * zones (Reolink, ONVIF) are out of scope for now — see the deferred
17005
+ * task list.
17006
+ */
17007
+ var ZoneKindEnum = _enum(["polygon", "tripwire"]);
17008
+ /** Polygon vertex in fraction-of-frame coordinates (0–1). */
17009
+ var PolygonPointSchema = object({
17010
+ x: number(),
17011
+ y: number()
17012
+ });
17013
+ /** A camera detection zone — pure geometry/identity. */
17014
+ var ZoneSchema = object({
17015
+ id: string(),
17016
+ name: string(),
17017
+ kind: ZoneKindEnum.default("polygon"),
17018
+ /** Polygon vertices, fraction of frame (0–1). */
17019
+ polygon: array(PolygonPointSchema).readonly(),
17020
+ /** Visual color for UI rendering. */
17021
+ color: string().default("#3b82f6")
17053
17022
  });
17054
17023
  /**
17055
- * One media row WITHOUT its bytes.
17024
+ * Zones capability — per-camera CRUD over polygon detection zones.
17056
17025
  *
17057
- * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
17058
- * 140 s track), and a client that renders tiles from the media data plane needs
17059
- * to know only WHAT EXISTS — the bytes then arrive per tile, lazily, over HTTP
17060
- * with an immutable cache, instead of all at once inside a tRPC response that
17061
- * blocks the whole view.
17026
+ * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
17027
+ * to per-device settings and mirrors into the `zones` device-state
17028
+ * slice on every mutation, so downstream consumers can subscribe via
17029
+ * `dev.state.zones.onChanged`.
17062
17030
  *
17063
- * `sizeBytes` is carried because it is what lets a client decide between the
17064
- * stored blob and a `?variant=thumb` rendering without fetching either.
17031
+ * The cap surface only handles geometry + identity; filtering
17032
+ * behaviour (per-class, include/exclude, threshold) lives in the
17033
+ * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
17034
+ * `capabilities/schemas/zone-rule.js`.
17065
17035
  */
17066
- var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
17036
+ var zonesCapability = {
17037
+ name: "zones",
17038
+ scope: "device",
17039
+ mode: "singleton",
17040
+ deviceTypes: [DeviceType.Camera],
17041
+ methods: {
17042
+ listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
17043
+ addZone: method(object({
17044
+ deviceId: number(),
17045
+ zone: ZoneSchema
17046
+ }), _void(), {
17047
+ kind: "mutation",
17048
+ auth: "admin"
17049
+ }),
17050
+ removeZone: method(object({
17051
+ deviceId: number(),
17052
+ zoneId: string()
17053
+ }), _void(), {
17054
+ kind: "mutation",
17055
+ auth: "admin"
17056
+ }),
17057
+ updateZone: method(object({
17058
+ deviceId: number(),
17059
+ zone: ZoneSchema
17060
+ }), _void(), {
17061
+ kind: "mutation",
17062
+ auth: "admin"
17063
+ })
17064
+ },
17065
+ /**
17066
+ * Runtime-state slice — the live zone catalogue mirrored by the
17067
+ * orchestrator on every CRUD mutation. Consumers read via
17068
+ * `device.state.zones.value` / `.watch(...)` without round-tripping
17069
+ * the cap, and the codegen DeviceProxy auto-wires the reactive
17070
+ * handle. Slice shape is `{ zones: Zone[] }` so future extensions
17071
+ * (e.g. zone groupings) can sit alongside the polygon list.
17072
+ */
17073
+ runtimeState: object({ zones: array(ZoneSchema).readonly() }),
17074
+ /**
17075
+ * 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.
17076
+ *
17077
+ * See `RuntimeStateDurability`. Enforced by
17078
+ * `scripts/check-runtime-state-durability.ts`.
17079
+ */
17080
+ durability: "restored"
17081
+ };
17067
17082
  /**
17068
- * The MACRO tier of an annotation — a CLOSED set.
17083
+ * pipeline-analytics — device-scoped wrapper cap. Refines raw
17084
+ * per-frame detections emitted by the pipeline runner into tracked
17085
+ * objects, per-kind event collections (motion / object / audio), and
17086
+ * persisted media. Owns the post-detection domain end-to-end:
17069
17087
  *
17070
- * This is what the exported detector predicts, so a typo here is a new class
17071
- * with one example in it. `label` and `subLabel` are open strings by contrast:
17072
- * the whole point of the page is teaching the model things it does not know
17073
- * yet, and constraining that vocabulary would make it useless.
17088
+ * runner emits PipelineInferenceResult
17089
+ * ↓ (event bus)
17090
+ * pipeline-analytics subscriber
17091
+ * ↓ SORT tracker + zone engine + state analyzer + event emitter
17092
+ * → three DB collections (one per kind), one FS media tree, one
17093
+ * unified event emitter (FrameTracked + TrackStarted/Ended +
17094
+ * DetectionEvent on bus)
17074
17095
  *
17075
- * A macro class is NEVER a label. The provider refuses a write whose `label` or
17076
- * `subLabel` is one of these values, in any casing, because once `person`
17077
- * exists in both tiers "every person box" stops being answerable without
17078
- * knowing every string anyone ever typed — and the damage is retroactive.
17096
+ * Pure subscriber model. No `processFrame` cap method — the runner
17097
+ * already publishes the raw frame on the bus. The cap surface is
17098
+ * only QUERIES + per-device settings, bound on/off via
17099
+ * `device-manager.setWrapperActive`. `defaultActive: true` because
17100
+ * every camera with a detection pipeline wants its raw detections
17101
+ * refined; operators opt out per-device via BindingsTab when needed.
17102
+ *
17103
+ * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
17104
+ * (per-device surface) and `track-trail` caps — see P11 cleanup.
17079
17105
  */
17080
- var RetrainMacroClassSchema = _enum([
17106
+ var TrackStateSchema = _enum([
17107
+ "new",
17108
+ "entered",
17109
+ "left",
17110
+ "moving",
17111
+ "idle"
17112
+ ]);
17113
+ var EventKindSchema = _enum([
17114
+ "motion",
17115
+ "object",
17116
+ "audio"
17117
+ ]);
17118
+ /**
17119
+ * Spatial filter for `listTracks` — the rect + polygon variants of the shared
17120
+ * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
17121
+ * of the camera frame (top-left origin), matching the drawing-plane editor.
17122
+ */
17123
+ var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
17124
+ /** Closed icon vocabulary so clients render a known glyph per kind. */
17125
+ var EventKindIconSchema = _enum([
17126
+ "motion",
17127
+ "audio",
17081
17128
  "person",
17082
17129
  "vehicle",
17083
17130
  "animal",
17131
+ "door",
17132
+ "pir",
17133
+ "smoke",
17134
+ "water",
17135
+ "button",
17084
17136
  "package",
17085
- "face",
17086
- "plate"
17137
+ "generic"
17087
17138
  ]);
17088
- /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
17089
- var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
17090
- /** Did a human draw this box, or did the assist propose it? */
17091
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
17092
- /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
17093
- var RetrainBboxSchema = object({
17094
- x: number(),
17095
- y: number(),
17096
- w: number(),
17097
- h: number()
17098
- });
17099
- /**
17100
- * One annotated subject.
17101
- *
17102
- * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
17103
- * (letterboxed root / zone-cropped package / subject-cropped classifier) are
17104
- * derived from it at export and never stored — storing them is how one feature
17105
- * space ends up holding two crops of the same subject (D52).
17106
- */
17107
- var RetrainAnnotationSchema = object({
17108
- id: string(),
17109
- trackId: string(),
17110
- deviceId: number(),
17111
- /** The COPY in retrain storage — never the source track's media key. */
17112
- mediaKey: string(),
17113
- bbox: RetrainBboxSchema,
17114
- macroClass: RetrainMacroClassSchema,
17115
- label: string().optional(),
17116
- subLabel: string().optional(),
17117
- kind: RetrainAnnotationKindSchema,
17118
- source: RetrainAnnotationSourceSchema,
17119
- /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
17120
- assistModelId: string().optional(),
17121
- assistScore: number().optional(),
17122
- exportedInBatch: string().optional(),
17123
- createdAt: number()
17124
- });
17125
- /** The write form — the server owns `id`, `createdAt` and the frame binding. */
17126
- var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
17127
- id: true,
17128
- trackId: true,
17129
- deviceId: true,
17130
- mediaKey: true,
17131
- createdAt: true,
17132
- exportedInBatch: true
17139
+ var EventKindCategorySchema = _enum([
17140
+ "motion",
17141
+ "audio",
17142
+ "detection",
17143
+ "sensor",
17144
+ "control",
17145
+ "custom",
17146
+ "package"
17147
+ ]);
17148
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
17149
+ var EventKindLevelSchema = _enum(["macro", "sub"]);
17150
+ var EventKindDescriptorSchema = object({
17151
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
17152
+ kind: string(),
17153
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
17154
+ labelKey: string(),
17155
+ /** English fallback label (kept for clients that don't translate). */
17156
+ label: string(),
17157
+ /** Hex color for timeline/legend rendering. */
17158
+ color: string(),
17159
+ /** Dictionary id → lucide component on the UI side. */
17160
+ iconId: string(),
17161
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
17162
+ icon: EventKindIconSchema,
17163
+ category: EventKindCategorySchema,
17164
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
17165
+ parentKind: string().nullable(),
17166
+ /** Derived from `parentKind`, explicit for the client tree. */
17167
+ level: EventKindLevelSchema,
17168
+ /** Which cap + device contributes this kind. For built-ins the camera
17169
+ * itself; for sensor kinds the LINKED source device. */
17170
+ source: object({
17171
+ capName: string(),
17172
+ deviceId: number()
17173
+ })
17133
17174
  });
17134
- /** A track sitting in `staging`, with everything the worklist needs to rank it. */
17135
- var RetrainTrackSchema = object({
17136
- trackId: string(),
17175
+ /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
17176
+ var EventKindsForDeviceSchema = object({
17137
17177
  deviceId: number(),
17138
- className: string(),
17139
- label: string().optional(),
17140
- firstSeen: number(),
17141
- lastSeen: number(),
17142
- /** How many frames the dataset already holds from this track. */
17143
- frameCount: number().int(),
17144
- /** How many subjects have been annotated on those frames. `0` with
17145
- * `frameCount: 0` is exactly "staging, still to work". */
17146
- annotationCount: number().int()
17147
- });
17148
- /** A frame the picker may offer — an index row, no blob was read to produce it. */
17149
- var RetrainFrameCandidateSchema = object({
17150
- mediaKey: string(),
17151
- kind: MediaFileKindEnum,
17152
- timestamp: number(),
17153
- sizeBytes: number().int(),
17154
- /** A copy of this original already exists — selecting it is free and cannot
17155
- * fail, whatever became of the original. */
17156
- copied: boolean()
17178
+ kinds: array(EventKindDescriptorSchema).readonly()
17157
17179
  });
17158
- /** A frame the dataset OWNS: bytes copied at selection time. */
17159
- var RetrainFrameSchema = object({
17160
- frameId: string(),
17180
+ var SensorEventSchema = object({
17181
+ id: string(),
17182
+ /** The CAMERA the event is attributed to (a sensor linked to N cameras
17183
+ * yields N rows, one per camera). */
17161
17184
  deviceId: number(),
17162
- trackId: string(),
17163
- /** Provenance only. It may already point at nothing — that is expected. */
17164
- sourceMediaKey: string(),
17165
- sourceKind: MediaFileKindEnum,
17166
- sizeBytes: number().int(),
17167
- width: number().int(),
17168
- height: number().int(),
17169
- copiedAt: number()
17185
+ /** The linked sensor device whose state changed. */
17186
+ sourceDeviceId: number(),
17187
+ /** Event kind id — matches an `EventKindDescriptor.kind`. */
17188
+ kind: string(),
17189
+ /** Snapshot of the sensor cap's runtime-state slice at the change. */
17190
+ value: record(string(), unknown()).nullable(),
17191
+ timestamp: number()
17170
17192
  });
17171
- /** Why a copy-on-select could not be honoured — named, never a silent skip. */
17172
- var RetrainCopyRefusalSchema = _enum([
17173
- "source-missing",
17174
- "unreadable-image",
17175
- "write-failed"
17176
- ]);
17177
- var RetrainFrameSelectionSchema = object({
17178
- copied: array(RetrainFrameSchema).readonly(),
17179
- refused: array(object({
17180
- sourceMediaKey: string(),
17181
- reason: RetrainCopyRefusalSchema
17182
- })).readonly()
17193
+ var TrackPositionSchema = object({
17194
+ x: number(),
17195
+ y: number(),
17196
+ timestamp: number(),
17197
+ bbox: BoundingBoxSchema
17183
17198
  });
17184
- var RetrainFrameListSchema = object({
17185
- candidates: array(RetrainFrameCandidateSchema).readonly(),
17186
- copies: array(RetrainFrameSchema).readonly(),
17187
- /** What the page pre-selects — the native key frame when one survives. */
17188
- autoPickMediaKey: string().optional()
17199
+ var TrackSnapshotSchema = object({
17200
+ timestamp: number(),
17201
+ position: TrackPositionSchema,
17202
+ /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
17203
+ mediaKey: string()
17189
17204
  });
17190
- /** What the operator asked the assist to look for. */
17191
- var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
17192
- kind: literal("package"),
17193
- zone: RetrainBboxSchema.optional()
17194
- }), object({
17195
- kind: literal("objects"),
17196
- modelId: string(),
17197
- minScore: number().optional()
17198
- })]);
17199
17205
  /**
17200
- * The assist's answer — a discriminated union, because "the model saw nothing"
17201
- * and "this node cannot run that model" lead to different next moves and a
17202
- * nullable result cannot tell them apart.
17206
+ * Normalized 0..1 trajectory envelope (min/max over every position bbox,
17207
+ * divided by the track's detection-frame dims), computed at persist time.
17208
+ * Absent when the frame dims were unknown when the track was persisted
17209
+ * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
17203
17210
  */
17204
- var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
17205
- kind: literal("proposed"),
17206
- modelId: string(),
17207
- stepId: string(),
17208
- minScore: number(),
17209
- /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
17210
- proposals: array(RetrainAnnotationDraftSchema).readonly(),
17211
- /** Returned by the runner but removed by the threshold. */
17212
- belowThreshold: number().int()
17213
- }), object({
17214
- kind: literal("refused"),
17215
- /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
17216
- reason: string(),
17217
- detail: string().optional()
17218
- })]);
17219
- /** The outcome of a lifecycle move owned by the retrain page. */
17220
- var RetrainTransitionResultSchema = object({
17221
- trackId: string(),
17222
- /** Where the track ended up, whatever happened. */
17223
- retrainStatus: RetrainStatusSchema,
17224
- /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
17225
- changed: boolean(),
17226
- reason: _enum([
17227
- "unknown-track",
17228
- "no-frames-copied",
17229
- "not-staging",
17230
- "not-trained",
17231
- "unchanged"
17232
- ]).optional()
17233
- });
17234
- var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
17235
- var MAX_EVENT_QUERY_LIMIT = 5e3;
17236
- var DeviceEventQueryInput = object({
17237
- deviceId: number(),
17238
- since: number().optional(),
17239
- until: number().optional(),
17240
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
17241
- /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
17242
- * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
17243
- * exact behaviour. Callers may omit this field — the store defaults to
17244
- * `full` when not provided. */
17245
- projection: _enum(["full", "slim"]).optional()
17246
- });
17247
- var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
17248
- var RecentTracksQueryInput = object({
17249
- /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
17250
- deviceIds: array(number()),
17251
- /** Window lower bound on `lastSeen` (inclusive). */
17252
- since: number().optional(),
17253
- /** Window upper bound on `lastSeen` (inclusive). */
17254
- until: number().optional(),
17255
- /** Page size. Default 200, max 1000. */
17256
- limit: number().int().min(1).max(1e3).default(200),
17257
- /** Opaque continuation cursor from a previous page's `nextCursor`.
17258
- * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
17259
- cursor: string().optional(),
17260
- /** See {@link TrackProjectionSchema}. Default `full`. */
17261
- projection: TrackProjectionSchema.optional(),
17262
- /** Include stationary-promoted rows (parked objects). Default false: the
17263
- * feed lists passages; parking records live on the stationary registry. */
17264
- includeStationary: boolean().optional()
17265
- });
17266
- var RecentTracksPageSchema = object({
17267
- /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
17268
- tracks: array(TrackSchema).readonly(),
17269
- /** Cursor for the next page, or null when this page is the last. */
17270
- nextCursor: string().nullable()
17271
- });
17272
- var LIST_GROUPS_DEFAULT_LIMIT = 40;
17273
- var LIST_GROUPS_MAX_LIMIT = 100;
17274
- var AnalyticsGroupRecordSchema = object({
17275
- id: string(),
17276
- deviceId: number().int(),
17277
- openedAt: number().int(),
17278
- closedAt: number().int(),
17279
- timestamp: number().int(),
17280
- memberCount: number().int(),
17281
- memberTrackIds: array(string()).readonly(),
17282
- className: string(),
17283
- classes: array(string()).readonly(),
17284
- /** Relative event-media path, or null when the group has no picture yet. */
17285
- mediaUrl: string().nullable(),
17286
- singleton: boolean()
17211
+ var TrackEnvelopeSchema = object({
17212
+ minX: number(),
17213
+ minY: number(),
17214
+ maxX: number(),
17215
+ maxY: number()
17287
17216
  });
17288
- var AnalyticsGroupMemberSchema = object({
17289
- trackId: string(),
17290
- deviceId: number().int(),
17291
- className: string(),
17292
- firstSeen: number().int(),
17293
- lastSeen: number().int(),
17294
- mediaUrl: string().nullable()
17295
- });
17296
- var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
17297
- var ListGroupsQueryInput = object({
17298
- /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
17299
- deviceIds: array(number()),
17300
- /** Window lower bound on `closedAt` (inclusive). */
17301
- since: number().optional(),
17302
- /** Window upper bound on `openedAt` (inclusive). */
17303
- until: number().optional(),
17304
- limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
17305
- /** Opaque continuation cursor from a previous page's `nextCursor`. */
17306
- cursor: string().optional()
17307
- });
17308
- var ListGroupsPageSchema = object({
17309
- groups: array(AnalyticsGroupRecordSchema).readonly(),
17310
- nextCursor: string().nullable()
17311
- });
17312
- var KeyEventQueryInput = object({
17313
- deviceId: number(),
17314
- /** Window lower bound (track firstSeen ≥ since). */
17315
- since: number(),
17316
- /** Window upper bound (track firstSeen ≤ until). */
17317
- until: number(),
17318
- limit: number().int().min(1).max(200).default(50),
17319
- /** Drop tracks scoring below this importance. */
17320
- minImportance: number().min(0).max(1).optional(),
17321
- /** Restrict to a single class (e.g. 'person'). */
17322
- classFilter: string().optional()
17323
- });
17324
- var KeyEventSchema = object({
17325
- /** The representative event id (the track's best ObjectEvent, else its trackId). */
17326
- id: string(),
17327
- trackId: string(),
17328
- /** Track start time (firstSeen). */
17329
- timestamp: number(),
17330
- className: string(),
17331
- ...TieredLabelFields,
17332
- importance: number(),
17333
- /** Highest-confidence ObjectEvent id for the track (empty when none). */
17334
- bestEventId: string(),
17335
- /** Track lifetime in ms (lastSeen - firstSeen). */
17336
- windowMs: number().optional(),
17337
- ...TrackFlagFields,
17338
- ...TrackRetrainFields
17339
- });
17340
- object({
17341
- trackId: string(),
17342
- className: string(),
17343
- confidence: number(),
17344
- bbox: BoundingBoxSchema,
17345
- zones: array(string()).readonly(),
17346
- state: TrackStateSchema
17347
- });
17348
- var OverlayDetectionSchema = looseObject({
17349
- id: string(),
17350
- kind: _enum(["first-level", "detail"]),
17351
- macroClass: string(),
17352
- score: number(),
17353
- bbox: object({
17354
- x: number(),
17355
- y: number(),
17356
- width: number(),
17357
- height: number()
17358
- }),
17359
- labels: array(looseObject({
17360
- label: string(),
17361
- score: number()
17362
- })).readonly(),
17363
- parentId: string().optional()
17364
- });
17365
- var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
17366
- var SearchObjectEventsInput = object({
17367
- text: string(),
17368
- deviceId: number().optional(),
17369
- since: number().optional(),
17370
- until: number().optional(),
17371
- classFilter: string().optional(),
17372
- limit: number().default(50),
17373
- minScore: number().min(0).max(1).default(.2)
17374
- });
17375
- var TrackCascadeCountsSchema = object({
17376
- /** Persisted track roots deleted (authoritative). */
17377
- tracks: number().int(),
17378
- /** Object events removed with their tracks (best-effort; see note above). */
17379
- events: number().int(),
17380
- /** Track/face/plate-owned media removed (best-effort). Never identity media. */
17381
- media: number().int(),
17382
- /** Unassigned (non-enrolled) face reads removed (best-effort). */
17383
- faces: number().int(),
17384
- /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
17385
- plates: number().int(),
17386
- /** Per-track CLIP search vectors removed (best-effort). */
17387
- embeddings: number().int(),
17388
- /** Group membership + group rows removed with their last member (best-effort). */
17389
- groups: number().int()
17390
- });
17391
- /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
17392
- var DiskReconcileCountsSchema = object({
17393
- mediaDropped: number().int(),
17394
- tracks: number().int(),
17395
- events: number().int()
17396
- });
17397
- /** Event-store footprint for one camera. */
17398
- var EventStoreDeviceFootprintSchema = object({
17399
- deviceId: number(),
17400
- /** Persisted event rows (motion + object + audio) for the camera. */
17401
- rows: number().int(),
17402
- /** Event-owned media bytes on disk for the camera. */
17403
- bytes: number().int()
17404
- });
17405
- /** Aggregate event-store footprint: global totals + per-camera breakdown. */
17406
- var EventStoreFootprintSchema = object({
17407
- totalRows: number().int(),
17408
- totalBytes: number().int(),
17409
- devices: array(EventStoreDeviceFootprintSchema).readonly()
17410
- });
17411
- /** Per-kind counts returned by the event-prune / device-delete mutations. */
17412
- var EventPruneCountsSchema = object({
17413
- motion: number().int(),
17414
- object: number().int(),
17415
- audio: number().int()
17217
+ /**
17218
+ * Row projection for track list queries. `full` (default) returns the
17219
+ * complete Track including the frame-rate `positions[]` history and the
17220
+ * `snapshots[]` references — megabytes across a page of tracks. `slim`
17221
+ * keeps every scalar the list surfaces actually render (ids, class(es),
17222
+ * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
17223
+ * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
17224
+ * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
17225
+ * `getTrack`. Mirrors the event-store `projection` convention
17226
+ * (`getObjectEvents` et al.).
17227
+ */
17228
+ var TrackProjectionSchema = _enum(["full", "slim"]);
17229
+ /**
17230
+ * One audio-classification label heard on the track's camera while the
17231
+ * track was alive, aggregated per label. An "episode" is one persisted
17232
+ * audio event (the confident-classification path: score ≥ the device's
17233
+ * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
17234
+ * one 32 ms inference chunk, so counts stay human-scaled.
17235
+ */
17236
+ var TrackAudioLabelSchema = object({
17237
+ label: string(),
17238
+ /** Highest classification score observed across the label's episodes. */
17239
+ peakScore: number(),
17240
+ /** Number of coalesced audio-event episodes carrying this label. */
17241
+ count: number(),
17242
+ firstAt: number(),
17243
+ lastAt: number()
17416
17244
  });
17417
17245
  /**
17418
- * Re-embed stored tracks from their key frames.
17246
+ * How a track was produced. `pipeline` (default / absent) = the spatial
17247
+ * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
17248
+ * no positions, a single snapshot, and no bbox trajectory at all:
17419
17249
  *
17420
- * The reason this is an operator-callable method and not a migration script:
17421
- * every knob that decides what a vector MEANS — encoder model, crop margin,
17422
- * squaring — is only changeable if the existing vectors can be regenerated.
17423
- * Mixing feature spaces in one index makes cosine scores incomparable, and the
17424
- * symptom is a quality regression with no visible cause.
17250
+ * - `sensor` — a linked sensor/control device state change.
17251
+ * - `audio` — an audio event on the camera itself that was anomalous for
17252
+ * THAT camera, loud, and heard while nothing visual was happening (D62).
17253
+ *
17254
+ * The spatial subsystems (tracker association, occupancy count, re-id /
17255
+ * embedding, resurrection) MUST skip every synthetic source. Test for that
17256
+ * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
17257
+ * check silently readmits every source added after it was written.
17425
17258
  */
17426
- var RebuildObjectEmbeddingsInput = object({
17427
- /** Restrict to one camera. Omit for the whole fleet. */
17428
- deviceId: number().optional(),
17429
- since: number().optional(),
17430
- until: number().optional(),
17431
- /** Stop after this many tracks; the result reports whether more remain. */
17432
- maxTracks: number().int().positive().optional(),
17433
- /**
17434
- * Run every embedding on THIS node instead of round-robining the fleet.
17435
- *
17436
- * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
17437
- * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
17438
- * calling it that would pin the rebuild REQUEST itself to that node — the
17439
- * rebuild orchestration lives on the hub, and only the per-track step runs
17440
- * remotely. This field is data; the per-track pin is applied inside.
17441
- *
17442
- * Absent ⇒ round-robin over every online node whose runner can serve the
17443
- * pinned model.
17444
- */
17445
- executeOnNodeId: string().optional(),
17446
- /**
17447
- * Milliseconds to wait between tracks; omit for the built-in default, `0` to
17448
- * run flat out.
17449
- *
17450
- * A rebuild is bulk maintenance on hub-main's single thread. Measured
17451
- * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
17452
- * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
17453
- * force is logged at start and finish so a deliberately slow pass reads
17454
- * differently from a stalled one.
17455
- */
17456
- pacingMs: number().int().nonnegative().optional()
17457
- });
17259
+ var TrackSourceSchema = _enum([
17260
+ "pipeline",
17261
+ "sensor",
17262
+ "audio"
17263
+ ]);
17458
17264
  /**
17459
- * Result of emptying the CLIP index.
17265
+ * Where a track sits in the RETRAIN lifecycle (D81).
17460
17266
  *
17461
- * The clean slate before a policy change: a new crop margin or encoder model
17462
- * leaves two feature spaces in one index whose cosine scores are not
17463
- * comparable, so wiping and rebuilding is the only way to be sure every vector
17464
- * means the same thing.
17267
+ * - `none` — never marked, or un-marked. Evictable.
17268
+ * - `staging` — the operator wants this track as training material and has not
17269
+ * finished with it. **This is the only state retention holds**: the track and
17270
+ * everything it owns (object events, crops, keyframes, CLIP vector) survive
17271
+ * the device's age window.
17272
+ * - `trained` — the retrain page has taken what it needed. The frames it chose
17273
+ * were COPIED into the retrain dataset at selection time, so the dataset no
17274
+ * longer depends on the track's media and the track becomes EVICTABLE again.
17275
+ * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
17276
+ * a deliberate action of the retrain page, not a side effect of a checkbox.
17277
+ *
17278
+ * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
17279
+ * the store's filter language has only positive equality and `whereIn` — no
17280
+ * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
17281
+ * would make the entire pre-column history immortal in one deploy.
17465
17282
  */
17466
- var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
17283
+ var RetrainStatusSchema = _enum([
17284
+ "none",
17285
+ "staging",
17286
+ "trained"
17287
+ ]);
17467
17288
  /**
17468
- * Acknowledgement that a rebuild STARTED.
17289
+ * Per-track OPERATOR flags — set by hand from the admin UI or the viewer, never
17290
+ * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
17291
+ * so the two surfaces cannot drift.
17469
17292
  *
17470
- * The pass costs ~1s per track — 45 minutes for a 2,600-track fleet — so it
17471
- * runs detached and this returns immediately. Waiting for it made the client
17472
- * time out while the work carried on server-side, which is the worst of both:
17473
- * no result and no way to know it was still going. Poll
17474
- * `getObjectEmbeddingRebuildStatus` for progress.
17293
+ * **Absent ≠ false.** A track that has never been touched omits the field; an
17294
+ * explicitly un-flagged track carries `false`. Legacy rows written before the
17295
+ * columns existed read as absent, and a consumer that needs a boolean should say
17296
+ * `flag === true`, not `flag !== false`.
17297
+ *
17298
+ * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
17299
+ * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
17300
+ * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
17301
+ * `trained` track reports `false` while refusing both writes. The boolean is
17302
+ * kept because three surfaces drive a toggle off it; anything that needs to tell
17303
+ * "never marked" from "already trained" must read `retrainStatus`.
17304
+ *
17305
+ * `debug` does NOT pin; it is attention, not durability.
17306
+ *
17307
+ * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
17308
+ * A favourited track is skipped by retention the same way `staging` is, but
17309
+ * it does not enter `none|staging|trained` and has no staging budget.
17475
17310
  */
17476
- var RebuildObjectEmbeddingsResultSchema = object({
17477
- started: boolean(),
17478
- /** True when a pass was already running; the new request is ignored. */
17479
- alreadyRunning: boolean()
17480
- });
17481
- var RebuildStatusSchema = object({
17482
- running: boolean(),
17483
- scanned: number(),
17484
- rebuilt: number(),
17485
- /** Tracks whose key frame is gone — nothing to re-embed from. */
17486
- missingKeyFrame: number(),
17487
- /** Tracks with no usable detection box. */
17488
- missingBbox: number(),
17489
- /**
17490
- * Tracks an executing node REFUSED rather than broke on — an unreadable key
17491
- * frame, a step that threw. Separate from `failed` because the remedy is
17492
- * different, and because a whole camera silently contributing zero vectors
17493
- * is the shape of failure a rebuild must never hide.
17494
- */
17495
- notRunnable: number(),
17496
- /**
17497
- * The pass stopped because NO node could serve the pinned model.
17498
- *
17499
- * Distinct from `notRunnable` on purpose: that one says "this track was
17500
- * refused", this one says "the cluster cannot do this work at all" — every
17501
- * candidate node either lacks the `clip-embedding` step, lacks a build of the
17502
- * pinned model for its engine format, or dropped out. The remedy is a model /
17503
- * engine change, not a per-camera one. Non-zero here always comes with
17504
- * `complete: false`.
17505
- */
17506
- noCapableNode: number(),
17507
- failed: number(),
17508
- /** Set once a pass ends: true only when EVERYTHING was covered. */
17509
- complete: boolean().nullable(),
17510
- startedAtMs: number().nullable(),
17511
- finishedAtMs: number().nullable(),
17512
- /** Present when the pass ended by throwing. */
17513
- error: string().nullable()
17311
+ var TrackFlagFields = {
17312
+ /** Operator marked this track as training material — i.e. `retrainStatus` is
17313
+ * `'staging'`. */
17314
+ markForTrain: boolean().optional(),
17315
+ /** Operator marked this track for diagnostic attention. */
17316
+ debug: boolean().optional(),
17317
+ /** Operator favourited this track. Pins it against pruning. */
17318
+ favourited: boolean().optional()
17319
+ };
17320
+ /**
17321
+ * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
17322
+ * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
17323
+ * write patch, and the status is not something the toggle sets — it is what the
17324
+ * toggle's boolean is derived from. Absent on an in-RAM track never touched;
17325
+ * always present on a persisted row (the column default materialises `'none'`).
17326
+ */
17327
+ var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
17328
+ /**
17329
+ * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
17330
+ * one flag can never clear the other — the toggles are independent and are
17331
+ * driven from three surfaces that do not know about each other.
17332
+ */
17333
+ var TrackFlagsPatchSchema = object(TrackFlagFields);
17334
+ /**
17335
+ * The resolved flag state after a write. Both fields are REQUIRED here (absent
17336
+ * collapses to `false`) so a caller can drive a toggle's checked state off the
17337
+ * mutation result without a re-fetch.
17338
+ */
17339
+ var TrackFlagsSchema = object({
17340
+ trackId: string(),
17341
+ markForTrain: boolean(),
17342
+ debug: boolean(),
17343
+ favourited: boolean(),
17344
+ /** The lifecycle state the boolean was derived from. Required here (unlike on
17345
+ * a track row) because this shape is only ever produced by the write body,
17346
+ * which always knows it — and a surface that has just written needs to render
17347
+ * `trained` without a re-fetch. */
17348
+ retrainStatus: RetrainStatusSchema
17514
17349
  });
17515
- DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
17516
- deviceId: number(),
17517
- trackId: string()
17518
- }), TrackSchema.nullable()), method(object({
17519
- deviceId: number(),
17520
- since: number().optional(),
17521
- until: number().optional(),
17522
- limit: number().optional(),
17523
- /** Spatial filter — only tracks whose trajectory intersects the zone
17524
- * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
17525
- * envelope columns, then precisely tested per position. Tracks with
17526
- * an unknown envelope (no frame dims at persist time) always match. */
17527
- zone: TrackZoneFilterSchema.optional(),
17528
- /** See {@link TrackProjectionSchema}. Default `full` (backward
17529
- * compatible — omitting the field keeps today's exact behaviour). */
17530
- projection: TrackProjectionSchema.optional(),
17531
- /** Include stationary-promoted rows (parked objects handed to the
17532
- * stationary registry). Default false: the timeline lists passages,
17533
- * not parking records (operator decision, 2026-08-15). */
17534
- includeStationary: boolean().optional()
17535
- }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
17536
- deviceId: number(),
17537
- groupId: string().min(1)
17538
- }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
17539
- kind: "mutation",
17540
- auth: "admin"
17541
- }), method(DeviceEventQueryInput, array(MotionEventSchema).readonly()), method(ObjectEventQueryInput, array(ObjectEventSchema).readonly()), method(DeviceEventQueryInput, array(AudioEventSchema).readonly()), method(object({ deviceId: number() }), array(EventKindDescriptorSchema).readonly()), method(object({ deviceIds: array(number()).min(1).max(200) }), array(EventKindsForDeviceSchema).readonly()), method(object({
17542
- deviceId: number(),
17543
- since: number().optional(),
17544
- until: number().optional(),
17545
- kinds: array(string()).optional(),
17546
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
17547
- }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
17548
- deviceId: number(),
17549
- since: number(),
17550
- until: number(),
17551
- bucketMs: number().int().positive()
17552
- }), array(object({
17553
- bucketStart: number(),
17554
- motion: number().int(),
17555
- object: number().int(),
17556
- audio: number().int()
17557
- })).readonly()), method(object({
17558
- deviceId: number(),
17559
- cutoffMs: number()
17560
- }), object({
17561
- motion: number().int(),
17562
- object: number().int(),
17563
- audio: number().int()
17564
- }), {
17565
- kind: "mutation",
17566
- auth: "admin"
17567
- }), method(object({
17568
- deviceId: number(),
17569
- cutoffMs: number()
17570
- }), TrackCascadeCountsSchema, {
17571
- kind: "mutation",
17572
- auth: "admin"
17573
- }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
17574
- kind: "mutation",
17575
- auth: "admin"
17576
- }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
17577
- kind: "mutation",
17578
- auth: "admin"
17579
- }), method(object({
17580
- deviceId: number(),
17581
- trackIds: array(string()).min(1)
17582
- }), object({
17583
- deleted: number().int(),
17584
- failed: array(string()).readonly()
17585
- }), {
17586
- kind: "mutation",
17587
- auth: "admin"
17588
- }), method(object({
17589
- /** Log/audit scope only — the trackId is globally unique on its own. */
17350
+ union([literal(1), literal(2)]);
17351
+ /**
17352
+ * WHO decided a label, and when. Carried per tier so a value can be traced to
17353
+ * the step and model that produced it — which is what makes the write rule
17354
+ * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
17355
+ * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
17356
+ *
17357
+ * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
17358
+ * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
17359
+ * `migration:4g` for a value the 4g migration moved from the single-slot era —
17360
+ * that value has no provenance, and the write rule lets ANY properly-attributed
17361
+ * write of the same tier replace it regardless of score.
17362
+ */
17363
+ var LabelAttributionSchema = object({
17364
+ stepId: string(),
17365
+ modelId: string().optional(),
17366
+ decidedAt: number(),
17367
+ /**
17368
+ * The GALLERY id behind a recognised tier-2 label — a face-gallery
17369
+ * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
17370
+ *
17371
+ * The text alone is a DISPLAY NAME, and a display name is renameable: a
17372
+ * notification rule authored on "Gianluca" stopped matching the moment the
17373
+ * operator fixed the spelling in the gallery, and nothing said so. The id is
17374
+ * the thing that does not move, so it is what a rule matches on
17375
+ * (`NcConditions.identities`) and the text is what a human is shown.
17376
+ *
17377
+ * Absent when the label names no gallery row — a plate the OCR read but no
17378
+ * vehicle claims, a sub-class, a species, any tier-1 value.
17379
+ */
17380
+ identityId: string().optional()
17381
+ });
17382
+ /**
17383
+ * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
17384
+ * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
17385
+ * track and its events always answer the same question the same way.
17386
+ *
17387
+ * Two scalar columns, not an array: every consumer wants "the coarse one" or
17388
+ * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
17389
+ * is tier 2, and each carries its own score + attribution.
17390
+ *
17391
+ * **Reading it.** What a human should be shown is `subLabel ?? label` — the
17392
+ * finest thing known. Before 4g the single `label` column held the finest
17393
+ * value, so a consumer that has not been updated reads the tier-1 slot and
17394
+ * shows nothing on a species-only row; that is why the migration puts every
17395
+ * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
17396
+ * and why the read surfaces were changed in the same train.
17397
+ *
17398
+ * **Writing it.** The slots are independent, which is the whole point: a
17399
+ * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
17400
+ * migratorius`), so fineness cannot regress by construction. Within a tier the
17401
+ * higher score wins. One rule, one implementation — see
17402
+ * `pipeline/label-tier.ts` in addon-post-analysis.
17403
+ */
17404
+ var TieredLabelFields = {
17405
+ /** Tier 1 — the sub-class. See {@link LabelTierSchema}. */
17406
+ label: string().optional(),
17407
+ /** Confidence of the tier-1 value, as reported by the deciding step. */
17408
+ labelScore: number().optional(),
17409
+ /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
17410
+ labelMeta: LabelAttributionSchema.optional(),
17411
+ /** Tier 2 — the instance. See {@link LabelTierSchema}. */
17412
+ subLabel: string().optional(),
17413
+ /** Confidence of the tier-2 value, as reported by the deciding step. */
17414
+ subLabelScore: number().optional(),
17415
+ /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
17416
+ subLabelMeta: LabelAttributionSchema.optional()
17417
+ };
17418
+ /** Per-camera slice of a training-export estimate. */
17419
+ var TrainingExportDeviceTotalsSchema = object({
17590
17420
  deviceId: number(),
17421
+ tracks: number().int(),
17422
+ files: number().int(),
17423
+ bytes: number().int()
17424
+ });
17425
+ /**
17426
+ * What a training export WOULD contain. Computed from media index rows only —
17427
+ * no blob is read to produce this.
17428
+ */
17429
+ var TrainingExportSummarySchema = object({
17430
+ generatedAt: number(),
17431
+ trackCount: number().int(),
17432
+ fileCount: number().int(),
17433
+ byteCount: number().int(),
17434
+ /** More marked tracks exist than a single pass carries. */
17435
+ truncated: boolean(),
17436
+ devices: array(TrainingExportDeviceTotalsSchema).readonly()
17437
+ });
17438
+ var TrackSchema = object({
17591
17439
  trackId: string(),
17592
- flags: TrackFlagsPatchSchema
17593
- }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
17594
- kind: "query",
17595
- auth: "admin"
17596
- }), method(object({
17597
- olderThanMs: number(),
17598
- reason: OpsLogReasonSchema.optional()
17599
- }), EventPruneCountsSchema, {
17600
- kind: "mutation",
17601
- auth: "admin"
17602
- }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
17603
- kind: "mutation",
17604
- auth: "admin"
17605
- }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
17606
- kind: "mutation",
17607
- auth: "admin"
17608
- }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
17609
- kind: "mutation",
17610
- auth: "admin"
17611
- }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
17612
- kind: "mutation",
17613
- auth: "admin"
17614
- }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
17615
- kind: "mutation",
17616
- auth: "admin"
17617
- }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
17618
- kind: "mutation",
17619
- auth: "admin"
17620
- }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
17621
- kind: "mutation",
17622
- auth: "admin"
17623
- }), method(object({}), array(RelocateJobSchema).readonly(), {
17624
- kind: "query",
17625
- auth: "admin"
17626
- }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
17627
- kind: "mutation",
17628
- auth: "admin"
17629
- }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
17630
- kind: "query",
17631
- auth: "admin"
17632
- }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
17633
- kind: "query",
17634
- auth: "admin"
17635
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
17636
- kind: "query",
17637
- auth: "admin"
17638
- }), method(object({
17639
- /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
17640
- * `deviceId`, deliberately: `deviceId` would make this device-bound and
17641
- * route it at one camera's owner, and "every camera" would stop being
17642
- * expressible at all. */
17643
- deviceIds: array(number()).optional(),
17644
- limit: number().int().min(1).max(500).optional()
17645
- }), array(RetrainTrackSchema).readonly(), {
17646
- kind: "query",
17647
- auth: "admin"
17648
- }), method(object({ trackId: string() }), RetrainFrameListSchema, {
17649
- kind: "query",
17650
- auth: "admin"
17651
- }), method(object({
17652
17440
  deviceId: number(),
17653
- trackId: string(),
17654
- mediaKeys: array(string()).min(1)
17655
- }), RetrainFrameSelectionSchema, {
17656
- kind: "mutation",
17657
- auth: "admin"
17658
- }), method(object({
17441
+ className: string(),
17442
+ ...TieredLabelFields,
17443
+ producingDeviceName: string().optional(),
17444
+ /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
17445
+ source: TrackSourceSchema.optional(),
17446
+ firstSeen: number(),
17447
+ lastSeen: number(),
17448
+ /** Frame-rate position history (subject to maxPositionHistory cap). */
17449
+ positions: array(TrackPositionSchema).readonly(),
17450
+ /** Periodic snapshots at snapshotIntervalMs cadence (subject to
17451
+ * saveThumbnails policy). */
17452
+ snapshots: array(TrackSnapshotSchema).readonly(),
17453
+ /** Deduplicated zones the track has entered at least once. Zone IDS. */
17454
+ zonesVisited: array(string()).readonly(),
17455
+ /**
17456
+ * Human NAMES for {@link zonesVisited}, resolved at READ time against the
17457
+ * `zones` capability.
17458
+ *
17459
+ * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
17460
+ * and no card can render — so every free-text search surface was structurally
17461
+ * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
17462
+ * just returned nothing. Resolving here rather than in each client keeps ONE
17463
+ * derivation and costs the clients no extra call (the `zones` cap is
17464
+ * per-device, so a client-side resolve would be a per-camera fan-out on a
17465
+ * surface built to avoid exactly that).
17466
+ *
17467
+ * Resolved, never invented: a zone deleted since the track was written has no
17468
+ * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
17469
+ * two are not positionally aligned. Absent when the track visited no zone, or
17470
+ * when the zone catalogue could not be read.
17471
+ */
17472
+ zoneNames: array(string()).readonly().optional(),
17473
+ /** Deduplicated set of detector classes observed for this track over its
17474
+ * life (a track may be reclassified, e.g. person→vehicle). Absent on
17475
+ * legacy rows written before class accumulation shipped. */
17476
+ classes: array(string()).readonly().optional(),
17477
+ /** Cumulative normalized distance travelled (0..1 units = full frame width). */
17478
+ totalDistance: number(),
17479
+ state: TrackStateSchema,
17480
+ active: boolean(),
17481
+ /** Deterministic key-event importance score in [0,1] (server-computed at
17482
+ * track expiry, recomputed on late label). Absent on legacy rows written
17483
+ * before scoring shipped — consumers degrade to absence / compute-on-read. */
17484
+ importance: number().optional(),
17485
+ /** Id of the track's highest-confidence ObjectEvent (its representative
17486
+ * "best" frame). Absent when the track produced no object events. */
17487
+ bestEventId: string().optional(),
17488
+ /** Tag of the importance sub-signal that dominated the score
17489
+ * (identity|dwell|proximity|class|confidence|travel|zone). */
17490
+ importanceReason: string().optional(),
17491
+ /** Audio-classification labels heard on the camera during the track's
17492
+ * life (score ≥ device `classificationMinScore`), aggregated per label.
17493
+ * Absent on legacy rows / tracks with no confident audio. */
17494
+ audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
17495
+ /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
17496
+ * Populated from the persisted envelope columns on historical reads;
17497
+ * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
17498
+ envelope: TrackEnvelopeSchema.optional(),
17499
+ /**
17500
+ * A face DETECTOR found a face on this track — nothing more. It says the
17501
+ * detail plane produced a `face` detail; it does NOT say the face was
17502
+ * embedded, matched, above `minFacePx`, or that the recognizer was even
17503
+ * enabled. Set once and never cleared.
17504
+ *
17505
+ * **This exists so "face present but not recognised" is expressible.** A
17506
+ * recognised identity lands in `subLabel` (attributed to the face chain via
17507
+ * `subLabelMeta.stepId`), so before this field a track with an unmatched face
17508
+ * and a track with no face at all were byte-identical on the wire and no
17509
+ * surface could tell them apart. The read is `hasFace === true && subLabel
17510
+ * === undefined`.
17511
+ *
17512
+ * **Absent ≠ false.** Every row written before the column existed omits it,
17513
+ * and so does every server that predates the field — a consumer must test
17514
+ * `=== true` and render nothing otherwise, never infer "no face".
17515
+ */
17516
+ hasFace: boolean().optional(),
17517
+ /**
17518
+ * This track has a face row IN THE GALLERY: a crop **and** an embedding — a
17519
+ * face an operator could ASSIGN to an identity.
17520
+ *
17521
+ * The STRICT twin of {@link hasFace}, and the pair only earns its keep
17522
+ * because the two disagree. `hasFace` is stamped at the TOP of the face
17523
+ * branch, before every gate, and means no more than "a face detector produced
17524
+ * a face detail". This one is stamped at the single moment the gallery row
17525
+ * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
17526
+ * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
17527
+ * candidate gate, the imageless-track drop (no crop was ever captured) and
17528
+ * the crop-store drop. Everything between the detector and that insert can
17529
+ * legitimately refuse the face, so a flag written any earlier promises the
17530
+ * operator something to assign and delivers nothing.
17531
+ *
17532
+ * **Independent of recognition.** A face collected but never auto-matched is
17533
+ * still assignable — it is in fact the face an operator most wants to reach —
17534
+ * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
17535
+ * `subLabel`; this says only that the raw material exists.
17536
+ *
17537
+ * **Set once, never cleared.** A track that produced a gallery row produced
17538
+ * one; deleting the row later is the gallery's business, not this flag's.
17539
+ *
17540
+ * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
17541
+ * before the column omits it, and so does every server that predates the
17542
+ * field. A consumer must test `=== true` and render nothing otherwise —
17543
+ * never infer "no assignable face".
17544
+ */
17545
+ hasEmbeddedFace: boolean().optional(),
17546
+ /**
17547
+ * This subject CONTAINS a folded rider — a person the rider-pairing step
17548
+ * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
17549
+ * so the passage is tracked once and as a VEHICLE.
17550
+ *
17551
+ * It exists because the fold's record was dishonest. D34 and the code both
17552
+ * said "the person is not lost — it is reported so both entities stay on the
17553
+ * record"; in fact the pair went into a per-processor RAM field behind an
17554
+ * accessor nobody called, and every durable surface said `vehicle`, full
17555
+ * stop. This is the composition note that makes the row true.
17556
+ *
17557
+ * A COMPOSITION, never a class and never a label. "This vehicle contains a
17558
+ * person" is not an answer to "what is this" — both label tiers would refuse
17559
+ * a macro token anyway (D89), and correctly. Nothing here changes what the
17560
+ * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
17561
+ * and a `person` rule still does not fire for someone cycling past.
17562
+ *
17563
+ * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
17564
+ * the column, and every hub that predates the field, omits it. Test
17565
+ * `=== true` and render nothing otherwise — never infer "no rider".
17566
+ */
17567
+ hasRider: boolean().optional(),
17568
+ ...TrackFlagFields,
17569
+ ...TrackRetrainFields
17570
+ });
17571
+ var BaseEventFields = {
17572
+ id: string(),
17659
17573
  deviceId: number(),
17660
- trackId: string(),
17661
- frameId: string()
17662
- }), object({
17663
- removed: boolean(),
17664
- removedAnnotations: number().int()
17665
- }), {
17666
- kind: "mutation",
17667
- auth: "admin"
17668
- }), method(object({ frameId: string() }), object({
17574
+ timestamp: number()
17575
+ };
17576
+ var MotionEventSchema = object({
17577
+ ...BaseEventFields,
17578
+ kind: literal("motion"),
17579
+ regionCount: number(),
17580
+ /** Heavy JSON array — omitted in slim projection. */
17581
+ regions: array(object({
17582
+ bbox: BoundingBoxSchema,
17583
+ pixelCount: number(),
17584
+ intensity: number()
17585
+ })).readonly().optional(),
17586
+ /** Omitted in slim projection. */
17587
+ frameWidth: number().optional(),
17588
+ /** Omitted in slim projection. */
17589
+ frameHeight: number().optional(),
17590
+ /** Populated by B5 (recording playback URL for this event). */
17591
+ mediaUrl: string().optional()
17592
+ });
17593
+ /**
17594
+ * Which detection SOURCE produced an object event. `pipeline` = the ML
17595
+ * detection pipeline (decoded-frame inference); `onboard` = the camera's
17596
+ * native on-device AI. Both flow through the SAME analysis layers (zoning,
17597
+ * tracking, per-kind persistence) but stay distinguishable so consumers
17598
+ * (advanced-notifier, occupancy, …) can select which source(s) to act on.
17599
+ * Absent on legacy rows ⇒ treat as `pipeline`.
17600
+ */
17601
+ var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
17602
+ /**
17603
+ * The confirmed zone crossing that produced an object event. Present ONLY on
17604
+ * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
17605
+ * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
17606
+ * appearance event carry none, so a rule asking for a direction fails closed
17607
+ * on them.
17608
+ *
17609
+ * Exactly ONE crossing per event: the emitter turns each confirmed crossing
17610
+ * into its own event, so a frame in which a track enters A while leaving B
17611
+ * produces two events with two directions — never one ambiguous row.
17612
+ *
17613
+ * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
17614
+ * membership the box has NOW, and by definition it no longer contains the zone
17615
+ * that was just left. Without the id here, a zone-scoped rule could never match
17616
+ * the exit it asked for.
17617
+ */
17618
+ var ZoneCrossingSchema = object({
17619
+ direction: _enum(["enter", "exit"]),
17620
+ /** Admin zone id crossed. */
17621
+ zoneId: string(),
17622
+ /** Zone display name at crossing time (falls back to the id). */
17623
+ zoneName: string().optional()
17624
+ });
17625
+ var ObjectEventSchema = object({
17626
+ ...BaseEventFields,
17627
+ kind: literal("object"),
17628
+ /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
17629
+ source: DetectionSourceSchema.optional(),
17630
+ /**
17631
+ * Inference-frame id shared by every object event emitted from the SAME frame
17632
+ * — the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
17633
+ * 2 people + 1 dog) under one full frame, and link a track's frames over time
17634
+ * (group by `trackId`, pick a representative `frameId` as the parent frame).
17635
+ * Optional for backward-compat with pre-existing rows / the slim projection
17636
+ * includes it (it is light). Absent on rows written before this field.
17637
+ */
17638
+ frameId: string().optional(),
17639
+ /** Omitted in slim projection. */
17640
+ trackId: string().optional(),
17641
+ className: string(),
17642
+ ...TieredLabelFields,
17643
+ /** Omitted in slim projection. */
17644
+ confidence: number().optional(),
17645
+ /** Heavy JSON — omitted in slim projection. */
17646
+ bbox: BoundingBoxSchema.optional(),
17647
+ /** Heavy JSON — omitted in slim projection. */
17648
+ zones: array(string()).readonly().optional(),
17649
+ /** Omitted in slim projection. */
17650
+ state: TrackStateSchema.optional(),
17651
+ /**
17652
+ * The zone crossing this event IS, when it is one. Absent on every other
17653
+ * event kind (movement state, appearance, package) — see
17654
+ * {@link ZoneCrossingSchema}. Omitted in slim projection.
17655
+ */
17656
+ zoneCrossing: ZoneCrossingSchema.optional(),
17657
+ /** Detection-frame dimensions in pixels — let consumers normalize the
17658
+ * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
17659
+ frameWidth: number().optional(),
17660
+ frameHeight: number().optional(),
17661
+ /** MediaStore key for the crop attached to this event (if any). */
17662
+ mediaKey: string().optional(),
17663
+ /** Design B: MediaStore key of the track's native-resolution key frame (the
17664
+ * best-detection full frame). Resolve via the event-media data-plane
17665
+ * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
17666
+ * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
17667
+ * sources — consumers fall back to `mediaKey` (the tight crop). */
17668
+ keyFrameMediaKey: string().optional(),
17669
+ /** Populated by B5 (recording playback URL for this event). */
17670
+ mediaUrl: string().optional(),
17671
+ /** The parent track's key-event importance [0,1], propagated to every object
17672
+ * event of the track (so an event row can be sorted by importance without a
17673
+ * track join). Absent on legacy rows / before the track was scored. */
17674
+ importance: number().optional()
17675
+ });
17676
+ var AudioEventSchema = object({
17677
+ ...BaseEventFields,
17678
+ kind: literal("audio"),
17679
+ rms: number(),
17680
+ dbfs: number(),
17681
+ classification: object({
17682
+ className: string(),
17683
+ originalClass: string().optional(),
17684
+ score: number()
17685
+ }).optional(),
17686
+ /** Populated by B5 (recording playback URL for this event). */
17687
+ mediaUrl: string().optional()
17688
+ });
17689
+ var MediaFileKindEnum = _enum([
17690
+ "crop",
17691
+ "thumbnail",
17692
+ "snapshot",
17693
+ "firstFrame",
17694
+ "lastFrame",
17695
+ "fullFrame",
17696
+ "fullFrameBoxed",
17697
+ "faceCrop",
17698
+ "plateCrop",
17699
+ "keyFrame",
17700
+ "keyFrameSmall",
17701
+ "thumbnailSmall"
17702
+ ]);
17703
+ var MediaFileSchema = object({
17704
+ key: string(),
17705
+ kind: MediaFileKindEnum,
17669
17706
  base64: string(),
17670
- width: number().int(),
17671
- height: number().int()
17672
- }), {
17673
- kind: "query",
17674
- auth: "admin"
17675
- }), method(object({
17676
- deviceId: number(),
17677
- trackId: string(),
17678
- frameId: string(),
17679
- subject: RetrainAssistSubjectSchema,
17680
- /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
17681
- nodeId: string().optional()
17682
- }), RetrainAssistResultSchema, {
17683
- kind: "mutation",
17684
- auth: "admin"
17685
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
17686
- kind: "query",
17687
- auth: "admin"
17688
- }), method(object({
17689
- deviceId: number(),
17690
- trackId: string(),
17691
- frameId: string(),
17692
- annotations: array(RetrainAnnotationDraftSchema)
17693
- }), array(RetrainAnnotationSchema).readonly(), {
17694
- kind: "mutation",
17695
- auth: "admin"
17696
- }), method(object({
17697
- deviceId: number(),
17698
- trackId: string()
17699
- }), RetrainTransitionResultSchema, {
17700
- kind: "mutation",
17701
- auth: "admin"
17702
- }), method(object({
17703
- deviceId: number(),
17704
- trackId: string()
17705
- }), RetrainTransitionResultSchema, {
17706
- kind: "mutation",
17707
- auth: "admin"
17708
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
17709
- kind: "query",
17710
- auth: "admin"
17711
- }), method(object({
17712
- eventId: string(),
17713
- kind: MediaFileKindEnum.optional(),
17714
- deviceId: number()
17715
- }), array(MediaFileSchema).readonly()), method(object({
17716
- trackId: string(),
17717
- kinds: array(MediaFileKindEnum).optional(),
17718
- deviceId: number()
17719
- }), array(MediaFileSchema).readonly()), method(object({
17707
+ sizeBytes: number(),
17708
+ timestamp: number()
17709
+ });
17710
+ /**
17711
+ * One media row WITHOUT its bytes.
17712
+ *
17713
+ * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
17714
+ * 140 s track), and a client that renders tiles from the media data plane needs
17715
+ * to know only WHAT EXISTS — the bytes then arrive per tile, lazily, over HTTP
17716
+ * with an immutable cache, instead of all at once inside a tRPC response that
17717
+ * blocks the whole view.
17718
+ *
17719
+ * `sizeBytes` is carried because it is what lets a client decide between the
17720
+ * stored blob and a `?variant=thumb` rendering without fetching either.
17721
+ */
17722
+ var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
17723
+ /**
17724
+ * The MACRO tier of an annotation — a CLOSED set.
17725
+ *
17726
+ * This is what the exported detector predicts, so a typo here is a new class
17727
+ * with one example in it. `label` and `subLabel` are open strings by contrast:
17728
+ * the whole point of the page is teaching the model things it does not know
17729
+ * yet, and constraining that vocabulary would make it useless.
17730
+ *
17731
+ * A macro class is NEVER a label. The provider refuses a write whose `label` or
17732
+ * `subLabel` is one of these values, in any casing, because once `person`
17733
+ * exists in both tiers "every person box" stops being answerable without
17734
+ * knowing every string anyone ever typed — and the damage is retroactive.
17735
+ */
17736
+ var RetrainMacroClassSchema = _enum([
17737
+ "person",
17738
+ "vehicle",
17739
+ "animal",
17740
+ "package",
17741
+ "face",
17742
+ "plate"
17743
+ ]);
17744
+ /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
17745
+ var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
17746
+ /** Did a human draw this box, or did the assist propose it? */
17747
+ var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
17748
+ /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
17749
+ var RetrainBboxSchema = object({
17750
+ x: number(),
17751
+ y: number(),
17752
+ w: number(),
17753
+ h: number()
17754
+ });
17755
+ /**
17756
+ * One annotated subject.
17757
+ *
17758
+ * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
17759
+ * (letterboxed root / zone-cropped package / subject-cropped classifier) are
17760
+ * derived from it at export and never stored — storing them is how one feature
17761
+ * space ends up holding two crops of the same subject (D52).
17762
+ */
17763
+ var RetrainAnnotationSchema = object({
17764
+ id: string(),
17720
17765
  trackId: string(),
17721
- deviceId: number()
17722
- }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
17723
- kind: "mutation",
17724
- auth: "admin"
17725
- }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
17726
- kind: "mutation",
17727
- auth: "admin"
17728
- }), method(object({}), RebuildStatusSchema), object({
17729
- deviceId: number(),
17730
- timestamp: number(),
17731
- frameWidth: number(),
17732
- frameHeight: number(),
17733
- detections: array(OverlayDetectionSchema).readonly()
17734
- }), object({
17735
17766
  deviceId: number(),
17767
+ /** The COPY in retrain storage — never the source track's media key. */
17768
+ mediaKey: string(),
17769
+ bbox: RetrainBboxSchema,
17770
+ macroClass: RetrainMacroClassSchema,
17771
+ label: string().optional(),
17772
+ subLabel: string().optional(),
17773
+ kind: RetrainAnnotationKindSchema,
17774
+ source: RetrainAnnotationSourceSchema,
17775
+ /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
17776
+ assistModelId: string().optional(),
17777
+ assistScore: number().optional(),
17778
+ exportedInBatch: string().optional(),
17779
+ createdAt: number()
17780
+ });
17781
+ /** The write form — the server owns `id`, `createdAt` and the frame binding. */
17782
+ var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
17783
+ id: true,
17784
+ trackId: true,
17785
+ deviceId: true,
17786
+ mediaKey: true,
17787
+ createdAt: true,
17788
+ exportedInBatch: true
17789
+ });
17790
+ /** A track sitting in `staging`, with everything the worklist needs to rank it. */
17791
+ var RetrainTrackSchema = object({
17736
17792
  trackId: string(),
17737
- className: string()
17738
- }), object({
17739
17793
  deviceId: number(),
17740
- trackId: string(),
17741
17794
  className: string(),
17742
- durationMs: number()
17743
- }), object({
17795
+ label: string().optional(),
17796
+ firstSeen: number(),
17797
+ lastSeen: number(),
17798
+ /** How many frames the dataset already holds from this track. */
17799
+ frameCount: number().int(),
17800
+ /** How many subjects have been annotated on those frames. `0` with
17801
+ * `frameCount: 0` is exactly "staging, still to work". */
17802
+ annotationCount: number().int()
17803
+ });
17804
+ /** A frame the picker may offer — an index row, no blob was read to produce it. */
17805
+ var RetrainFrameCandidateSchema = object({
17806
+ mediaKey: string(),
17807
+ kind: MediaFileKindEnum,
17808
+ timestamp: number(),
17809
+ sizeBytes: number().int(),
17810
+ /** A copy of this original already exists — selecting it is free and cannot
17811
+ * fail, whatever became of the original. */
17812
+ copied: boolean()
17813
+ });
17814
+ /** A frame the dataset OWNS: bytes copied at selection time. */
17815
+ var RetrainFrameSchema = object({
17816
+ frameId: string(),
17744
17817
  deviceId: number(),
17745
- kind: EventKindSchema,
17746
- eventId: string(),
17747
- timestamp: number()
17818
+ trackId: string(),
17819
+ /** Provenance only. It may already point at nothing — that is expected. */
17820
+ sourceMediaKey: string(),
17821
+ sourceKind: MediaFileKindEnum,
17822
+ sizeBytes: number().int(),
17823
+ width: number().int(),
17824
+ height: number().int(),
17825
+ copiedAt: number()
17748
17826
  });
17749
- /**
17750
- * Reference to the frame's retained NATIVE surface + the parent crop's placement
17751
- * within the frame, so the executor can re-cut a leaf child ROI at native
17752
- * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
17753
- */
17754
- var NativeCropRefSchema = object({
17755
- /** Handle keying the retained native surface (node-pinned to its owner). */
17756
- handle: FrameHandleSchema,
17757
- /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
17758
- cropFrameSpace: object({
17759
- x: number(),
17760
- y: number(),
17761
- w: number(),
17762
- h: number()
17763
- })
17827
+ /** Why a copy-on-select could not be honoured — named, never a silent skip. */
17828
+ var RetrainCopyRefusalSchema = _enum([
17829
+ "source-missing",
17830
+ "unreadable-image",
17831
+ "write-failed"
17832
+ ]);
17833
+ var RetrainFrameSelectionSchema = object({
17834
+ copied: array(RetrainFrameSchema).readonly(),
17835
+ refused: array(object({
17836
+ sourceMediaKey: string(),
17837
+ reason: RetrainCopyRefusalSchema
17838
+ })).readonly()
17764
17839
  });
17765
- object({
17766
- crop: object({
17767
- left: number(),
17768
- top: number(),
17769
- width: number().positive(),
17770
- height: number().positive()
17771
- }).optional(),
17772
- content: object({
17773
- width: number().int().positive(),
17774
- height: number().int().positive()
17775
- }),
17776
- fit: _enum(["stretch", "contain"]),
17777
- format: _enum([
17778
- "rgb",
17779
- "gray",
17780
- "jpeg"
17781
- ])
17840
+ var RetrainFrameListSchema = object({
17841
+ candidates: array(RetrainFrameCandidateSchema).readonly(),
17842
+ copies: array(RetrainFrameSchema).readonly(),
17843
+ /** What the page pre-selects — the native key frame when one survives. */
17844
+ autoPickMediaKey: string().optional()
17782
17845
  });
17846
+ /** What the operator asked the assist to look for. */
17847
+ var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
17848
+ kind: literal("package"),
17849
+ zone: RetrainBboxSchema.optional()
17850
+ }), object({
17851
+ kind: literal("objects"),
17852
+ modelId: string(),
17853
+ minScore: number().optional()
17854
+ })]);
17783
17855
  /**
17784
- * Process-local frame identity. It is serializable so it can ride an in-process
17785
- * capability call, but `registryId` deliberately prevents resolution in any
17786
- * other process or execution group.
17856
+ * The assist's answer — a discriminated union, because "the model saw nothing"
17857
+ * and "this node cannot run that model" lead to different next moves and a
17858
+ * nullable result cannot tell them apart.
17787
17859
  */
17788
- var FrameRefSchema = object({
17789
- registryId: string().min(1),
17790
- id: string().min(1),
17791
- width: number().int().positive(),
17792
- height: number().int().positive(),
17793
- format: _enum(["rgb", "gray"]),
17794
- timestamp: number(),
17795
- capturedAt: number().optional()
17860
+ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
17861
+ kind: literal("proposed"),
17862
+ modelId: string(),
17863
+ stepId: string(),
17864
+ minScore: number(),
17865
+ /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
17866
+ proposals: array(RetrainAnnotationDraftSchema).readonly(),
17867
+ /** Returned by the runner but removed by the threshold. */
17868
+ belowThreshold: number().int()
17869
+ }), object({
17870
+ kind: literal("refused"),
17871
+ /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
17872
+ reason: string(),
17873
+ detail: string().optional()
17874
+ })]);
17875
+ /** The outcome of a lifecycle move owned by the retrain page. */
17876
+ var RetrainTransitionResultSchema = object({
17877
+ trackId: string(),
17878
+ /** Where the track ended up, whatever happened. */
17879
+ retrainStatus: RetrainStatusSchema,
17880
+ /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
17881
+ changed: boolean(),
17882
+ reason: _enum([
17883
+ "unknown-track",
17884
+ "no-frames-copied",
17885
+ "not-staging",
17886
+ "not-trained",
17887
+ "unchanged"
17888
+ ]).optional()
17796
17889
  });
17797
- var ModelFormatSchema$1 = _enum([
17798
- "onnx",
17799
- "coreml",
17800
- "openvino",
17801
- "tflite",
17802
- "pt",
17803
- "gguf"
17804
- ]);
17805
- var PipelineSlotSchema = _enum([
17806
- "detector",
17807
- "cropper",
17808
- "classifier",
17809
- "refiner",
17810
- "audio-classifier"
17811
- ]);
17812
- var PipelineEngineChoiceSchema = object({
17813
- runtime: _enum(["node", "python"]),
17814
- backend: string(),
17815
- format: ModelFormatSchema$1,
17816
- device: string().optional()
17890
+ var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
17891
+ var MAX_EVENT_QUERY_LIMIT = 5e3;
17892
+ var DeviceEventQueryInput = object({
17893
+ deviceId: number(),
17894
+ since: number().optional(),
17895
+ until: number().optional(),
17896
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
17897
+ /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
17898
+ * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
17899
+ * exact behaviour. Callers may omit this field — the store defaults to
17900
+ * `full` when not provided. */
17901
+ projection: _enum(["full", "slim"]).optional()
17817
17902
  });
17818
- var AvailableEngineSchema = object({
17819
- engine: PipelineEngineChoiceSchema,
17820
- devices: array(object({
17821
- id: string(),
17822
- label: string(),
17823
- description: string().optional()
17824
- })).readonly(),
17825
- defaultDevice: string()
17903
+ var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
17904
+ var RecentTracksQueryInput = object({
17905
+ /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
17906
+ deviceIds: array(number()),
17907
+ /** Window lower bound on `lastSeen` (inclusive). */
17908
+ since: number().optional(),
17909
+ /** Window upper bound on `lastSeen` (inclusive). */
17910
+ until: number().optional(),
17911
+ /** Page size. Default 200, max 1000. */
17912
+ limit: number().int().min(1).max(1e3).default(200),
17913
+ /** Opaque continuation cursor from a previous page's `nextCursor`.
17914
+ * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
17915
+ cursor: string().optional(),
17916
+ /** See {@link TrackProjectionSchema}. Default `full`. */
17917
+ projection: TrackProjectionSchema.optional(),
17918
+ /** Include stationary-promoted rows (parked objects). Default false: the
17919
+ * feed lists passages; parking records live on the stationary registry. */
17920
+ includeStationary: boolean().optional()
17921
+ });
17922
+ var RecentTracksPageSchema = object({
17923
+ /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
17924
+ tracks: array(TrackSchema).readonly(),
17925
+ /** Cursor for the next page, or null when this page is the last. */
17926
+ nextCursor: string().nullable()
17826
17927
  });
17827
- var PipelineDefaultStepSchema = lazy(() => object({
17828
- addonId: string(),
17829
- addonName: string(),
17830
- slot: PipelineSlotSchema,
17831
- inputClasses: array(string()).readonly(),
17832
- outputClasses: array(string()).readonly(),
17833
- enabled: boolean(),
17834
- modelId: string(),
17835
- children: array(PipelineDefaultStepSchema).readonly(),
17836
- group: string().optional(),
17837
- settings: record(string(), unknown()).optional()
17838
- }));
17839
- var PipelineTemplateStepSchema = lazy(() => object({
17840
- addonId: string(),
17841
- enabled: boolean(),
17842
- modelId: string(),
17843
- children: array(PipelineTemplateStepSchema).readonly(),
17844
- settings: record(string(), unknown()).optional()
17845
- }));
17846
- var PipelineTemplateSchema$1 = object({
17928
+ var LIST_GROUPS_DEFAULT_LIMIT = 40;
17929
+ var LIST_GROUPS_MAX_LIMIT = 100;
17930
+ var AnalyticsGroupRecordSchema = object({
17847
17931
  id: string(),
17848
- name: string(),
17849
- createdAt: string(),
17850
- updatedAt: string(),
17851
- engine: PipelineEngineChoiceSchema,
17852
- steps: array(PipelineTemplateStepSchema).readonly()
17932
+ deviceId: number().int(),
17933
+ openedAt: number().int(),
17934
+ closedAt: number().int(),
17935
+ timestamp: number().int(),
17936
+ memberCount: number().int(),
17937
+ memberTrackIds: array(string()).readonly(),
17938
+ className: string(),
17939
+ classes: array(string()).readonly(),
17940
+ /** Relative event-media path, or null when the group has no picture yet. */
17941
+ mediaUrl: string().nullable(),
17942
+ singleton: boolean()
17853
17943
  });
17854
- var PipelineModelOptionSchema = object({
17855
- id: string(),
17856
- name: string(),
17857
- formats: record(string(), object({
17858
- downloaded: boolean(),
17859
- sizeMB: number()
17860
- })),
17861
- group: ModelVariantGroupSchema.optional(),
17862
- legacy: boolean().optional(),
17863
- provider: ModelProviderIdSchema.optional()
17944
+ var AnalyticsGroupMemberSchema = object({
17945
+ trackId: string(),
17946
+ deviceId: number().int(),
17947
+ className: string(),
17948
+ firstSeen: number().int(),
17949
+ lastSeen: number().int(),
17950
+ mediaUrl: string().nullable()
17864
17951
  });
17865
- var ConfigFieldBridge = custom();
17866
- var PipelineAddonSchemaSchema = object({
17867
- id: string(),
17868
- name: string(),
17869
- slot: PipelineSlotSchema,
17870
- inputClasses: array(string()).readonly(),
17871
- outputClasses: array(string()).readonly(),
17872
- childSlots: array(PipelineSlotSchema).readonly(),
17873
- models: array(PipelineModelOptionSchema).readonly(),
17874
- defaultModelId: string(),
17875
- defaultModelIdByFormat: record(string(), string()).optional(),
17876
- enabledByDefault: boolean().optional(),
17877
- backfillIntoExistingOverrides: boolean().optional(),
17878
- defaultConfidence: number(),
17879
- group: string().optional(),
17880
- configSchema: array(ConfigFieldBridge).readonly().optional()
17952
+ var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
17953
+ var ListGroupsQueryInput = object({
17954
+ /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
17955
+ deviceIds: array(number()),
17956
+ /** Window lower bound on `closedAt` (inclusive). */
17957
+ since: number().optional(),
17958
+ /** Window upper bound on `openedAt` (inclusive). */
17959
+ until: number().optional(),
17960
+ limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
17961
+ /** Opaque continuation cursor from a previous page's `nextCursor`. */
17962
+ cursor: string().optional()
17881
17963
  });
17882
- var PipelineSlotSchemaSchema = object({
17883
- id: PipelineSlotSchema,
17884
- label: string(),
17885
- priority: number(),
17886
- parentSlot: PipelineSlotSchema.nullable(),
17887
- addons: array(PipelineAddonSchemaSchema).readonly()
17964
+ var ListGroupsPageSchema = object({
17965
+ groups: array(AnalyticsGroupRecordSchema).readonly(),
17966
+ nextCursor: string().nullable()
17888
17967
  });
17889
- var PipelineSchemaSchema = object({
17890
- availableEngines: array(AvailableEngineSchema).readonly(),
17891
- selectedEngine: PipelineEngineChoiceSchema,
17892
- slots: array(PipelineSlotSchemaSchema).readonly()
17968
+ var KeyEventQueryInput = object({
17969
+ deviceId: number(),
17970
+ /** Window lower bound (track firstSeen ≥ since). */
17971
+ since: number(),
17972
+ /** Window upper bound (track firstSeen ≤ until). */
17973
+ until: number(),
17974
+ limit: number().int().min(1).max(200).default(50),
17975
+ /** Drop tracks scoring below this importance. */
17976
+ minImportance: number().min(0).max(1).optional(),
17977
+ /** Restrict to a single class (e.g. 'person'). */
17978
+ classFilter: string().optional()
17893
17979
  });
17894
- var EngineProvisioningSchema = object({
17895
- runtimeId: _enum([
17896
- "onnx",
17897
- "openvino",
17898
- "coreml",
17899
- "edgetpu"
17900
- ]).nullable(),
17901
- device: string().nullable(),
17902
- state: _enum([
17903
- "idle",
17904
- "installing",
17905
- "verifying",
17906
- "ready",
17907
- "failed"
17908
- ]),
17909
- progress: number().optional(),
17910
- error: string().optional(),
17911
- nextRetryAt: number().optional(),
17912
- /**
17913
- * Gate A (config-correctness gate at engine change): human-readable
17914
- * config issues surfaced EAGERLY when the node's engine changes — model
17915
- * substitutions ("chose X, running Y") and zero-build steps ("no model
17916
- * has a <format> build"). Additive/optional: informational only, never
17917
- * enforced here — `assertEngineReady` (readiness) still gates inference.
17918
- * Absent/empty when the node-default tree resolves cleanly.
17919
- */
17920
- configIssues: array(string()).optional()
17980
+ var KeyEventSchema = object({
17981
+ /** The representative event id (the track's best ObjectEvent, else its trackId). */
17982
+ id: string(),
17983
+ trackId: string(),
17984
+ /** Track start time (firstSeen). */
17985
+ timestamp: number(),
17986
+ className: string(),
17987
+ ...TieredLabelFields,
17988
+ importance: number(),
17989
+ /** Highest-confidence ObjectEvent id for the track (empty when none). */
17990
+ bestEventId: string(),
17991
+ /** Track lifetime in ms (lastSeen - firstSeen). */
17992
+ windowMs: number().optional(),
17993
+ ...TrackFlagFields,
17994
+ ...TrackRetrainFields
17921
17995
  });
17922
- var PipelineStepInputSchema = lazy(() => object({
17923
- addonId: string(),
17924
- modelId: string().optional(),
17925
- enabled: boolean().default(true),
17926
- children: array(PipelineStepInputSchema).optional(),
17927
- settings: record(string(), unknown()).optional(),
17928
- jumpDeviceKey: string().optional()
17929
- }));
17930
- var ModelSubstitutionSchema = object({
17931
- addonId: string(),
17932
- chosen: string(),
17933
- running: string(),
17934
- format: string()
17996
+ object({
17997
+ trackId: string(),
17998
+ className: string(),
17999
+ confidence: number(),
18000
+ bbox: BoundingBoxSchema,
18001
+ zones: array(string()).readonly(),
18002
+ state: TrackStateSchema
17935
18003
  });
17936
- var PipelineValidationIssueSchema = object({
17937
- addonId: string(),
17938
- kind: _enum(["unknown-addon", "no-format-build"]),
17939
- detail: string()
18004
+ var OverlayDetectionSchema = looseObject({
18005
+ id: string(),
18006
+ kind: _enum(["first-level", "detail"]),
18007
+ macroClass: string(),
18008
+ score: number(),
18009
+ bbox: object({
18010
+ x: number(),
18011
+ y: number(),
18012
+ width: number(),
18013
+ height: number()
18014
+ }),
18015
+ labels: array(looseObject({
18016
+ label: string(),
18017
+ score: number()
18018
+ })).readonly(),
18019
+ parentId: string().optional()
17940
18020
  });
17941
- var PipelineValidationResultSchema = object({
17942
- ok: boolean(),
17943
- issues: array(PipelineValidationIssueSchema).readonly(),
17944
- substitutions: array(ModelSubstitutionSchema).readonly(),
17945
- /** The node's `currentEngine.format` this validation ran against. */
17946
- format: string()
18021
+ var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
18022
+ var SearchObjectEventsInput = object({
18023
+ text: string(),
18024
+ deviceId: number().optional(),
18025
+ since: number().optional(),
18026
+ until: number().optional(),
18027
+ classFilter: string().optional(),
18028
+ limit: number().default(50),
18029
+ minScore: number().min(0).max(1).default(.2)
17947
18030
  });
17948
- var ReferenceImageEntrySchema = object({
17949
- filename: string(),
17950
- stepIds: array(string()).readonly().optional()
18031
+ var TrackCascadeCountsSchema = object({
18032
+ /** Persisted track roots deleted (authoritative). */
18033
+ tracks: number().int(),
18034
+ /** Object events removed with their tracks (best-effort; see note above). */
18035
+ events: number().int(),
18036
+ /** Track/face/plate-owned media removed (best-effort). Never identity media. */
18037
+ media: number().int(),
18038
+ /** Unassigned (non-enrolled) face reads removed (best-effort). */
18039
+ faces: number().int(),
18040
+ /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
18041
+ plates: number().int(),
18042
+ /** Per-track CLIP search vectors removed (best-effort). */
18043
+ embeddings: number().int(),
18044
+ /** Group membership + group rows removed with their last member (best-effort). */
18045
+ groups: number().int()
17951
18046
  });
17952
- var ReferenceImageBodySchema = object({
17953
- base64: string(),
17954
- filename: string()
18047
+ /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
18048
+ var DiskReconcileCountsSchema = object({
18049
+ mediaDropped: number().int(),
18050
+ tracks: number().int(),
18051
+ events: number().int()
17955
18052
  });
17956
- var ReferenceAudioEntrySchema = object({
17957
- filename: string(),
17958
- sizeKb: number()
18053
+ /** Event-store footprint for one camera. */
18054
+ var EventStoreDeviceFootprintSchema = object({
18055
+ deviceId: number(),
18056
+ /** Persisted event rows (motion + object + audio) for the camera. */
18057
+ rows: number().int(),
18058
+ /** Event-owned media bytes on disk for the camera. */
18059
+ bytes: number().int()
18060
+ });
18061
+ /** Aggregate event-store footprint: global totals + per-camera breakdown. */
18062
+ var EventStoreFootprintSchema = object({
18063
+ totalRows: number().int(),
18064
+ totalBytes: number().int(),
18065
+ devices: array(EventStoreDeviceFootprintSchema).readonly()
18066
+ });
18067
+ /** Per-kind counts returned by the event-prune / device-delete mutations. */
18068
+ var EventPruneCountsSchema = object({
18069
+ motion: number().int(),
18070
+ object: number().int(),
18071
+ audio: number().int()
17959
18072
  });
17960
- var ReferenceAudioBodySchema = object({ base64: string() });
17961
- var AudioBackendSchema = object({
17962
- id: string(),
17963
- name: string(),
17964
- description: string(),
17965
- available: boolean(),
18073
+ /**
18074
+ * Re-embed stored tracks from their key frames.
18075
+ *
18076
+ * The reason this is an operator-callable method and not a migration script:
18077
+ * every knob that decides what a vector MEANS — encoder model, crop margin,
18078
+ * squaring — is only changeable if the existing vectors can be regenerated.
18079
+ * Mixing feature spaces in one index makes cosine scores incomparable, and the
18080
+ * symptom is a quality regression with no visible cause.
18081
+ */
18082
+ var RebuildObjectEmbeddingsInput = object({
18083
+ /** Restrict to one camera. Omit for the whole fleet. */
18084
+ deviceId: number().optional(),
18085
+ since: number().optional(),
18086
+ until: number().optional(),
18087
+ /** Stop after this many tracks; the result reports whether more remain. */
18088
+ maxTracks: number().int().positive().optional(),
17966
18089
  /**
17967
- * Raw classifier labels this backend can emit (e.g. YAMNet's
17968
- * 521-class set or Apple SoundAnalysis's 303-class set). Used by
17969
- * the benchmark UI to populate the `enabledMicroClasses` filter
17970
- * specific to the selected backend without a separate fetch.
18090
+ * Run every embedding on THIS node instead of round-robining the fleet.
18091
+ *
18092
+ * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
18093
+ * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
18094
+ * calling it that would pin the rebuild REQUEST itself to that node — the
18095
+ * rebuild orchestration lives on the hub, and only the per-track step runs
18096
+ * remotely. This field is data; the per-track pin is applied inside.
18097
+ *
18098
+ * Absent ⇒ round-robin over every online node whose runner can serve the
18099
+ * pinned model.
17971
18100
  */
17972
- rawLabels: array(string()).readonly().optional()
17973
- });
17974
- var AudioCapabilitiesSchema = object({
17975
- activeBackend: string(),
17976
- availableBackends: array(AudioBackendSchema).readonly(),
17977
- sampleRate: number(),
17978
- chunkDurationMs: number()
17979
- });
17980
- var DownloadModelResultSchema = object({
17981
- filePath: string(),
17982
- sizeMB: number(),
17983
- durationMs: number()
18101
+ executeOnNodeId: string().optional(),
18102
+ /**
18103
+ * Milliseconds to wait between tracks; omit for the built-in default, `0` to
18104
+ * run flat out.
18105
+ *
18106
+ * A rebuild is bulk maintenance on hub-main's single thread. Measured
18107
+ * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
18108
+ * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
18109
+ * force is logged at start and finish so a deliberately slow pass reads
18110
+ * differently from a stalled one.
18111
+ */
18112
+ pacingMs: number().int().nonnegative().optional()
17984
18113
  });
17985
18114
  /**
17986
- * Wrapper carrying a single test run's result. Replaces the legacy
17987
- * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
17988
- * canonical `AudioResult` from the Phase 6 output rework: one
17989
- * `AudioDetection` per class above `minScore`, top-N candidates in
17990
- * `debug.alternateLabels['audio-classifier']`, per-source timings in
17991
- * `debug.stepTimings`. The outer `success`/`error` fields stay so the
17992
- * benchmark UI can still report a clean failure when the classifier
17993
- * cap isn't available.
18115
+ * Result of emptying the CLIP index.
18116
+ *
18117
+ * The clean slate before a policy change: a new crop margin or encoder model
18118
+ * leaves two feature spaces in one index whose cosine scores are not
18119
+ * comparable, so wiping and rebuilding is the only way to be sure every vector
18120
+ * means the same thing.
17994
18121
  */
17995
- var AudioTestResultSchema = object({
17996
- success: boolean(),
17997
- error: string().optional(),
17998
- frame: custom().optional()
18122
+ var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
18123
+ /**
18124
+ * Acknowledgement that a rebuild STARTED.
18125
+ *
18126
+ * The pass costs ~1s per track — 45 minutes for a 2,600-track fleet — so it
18127
+ * runs detached and this returns immediately. Waiting for it made the client
18128
+ * time out while the work carried on server-side, which is the worst of both:
18129
+ * no result and no way to know it was still going. Poll
18130
+ * `getObjectEmbeddingRebuildStatus` for progress.
18131
+ */
18132
+ var RebuildObjectEmbeddingsResultSchema = object({
18133
+ started: boolean(),
18134
+ /** True when a pass was already running; the new request is ignored. */
18135
+ alreadyRunning: boolean()
17999
18136
  });
18000
- var PipelineConfigBridge = custom();
18001
- var ConfigUISchemaBridge = custom();
18002
- var ConfigUISchemaNullableBridge = custom();
18003
- var InferenceCapabilitiesBridge = custom();
18004
- var ModelAvailabilityListBridge = custom();
18005
- var PipelineRunResultBridge = custom();
18006
- method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
18007
- modelId: string(),
18008
- settings: record(string(), unknown()).readonly()
18009
- }))), method(object({ steps: record(string(), object({
18010
- modelId: string(),
18011
- settings: record(string(), unknown()).readonly()
18012
- })) }), object({ success: literal(true) }), {
18137
+ var RebuildStatusSchema = object({
18138
+ running: boolean(),
18139
+ scanned: number(),
18140
+ rebuilt: number(),
18141
+ /** Tracks whose key frame is gone — nothing to re-embed from. */
18142
+ missingKeyFrame: number(),
18143
+ /** Tracks with no usable detection box. */
18144
+ missingBbox: number(),
18145
+ /**
18146
+ * Tracks an executing node REFUSED rather than broke on — an unreadable key
18147
+ * frame, a step that threw. Separate from `failed` because the remedy is
18148
+ * different, and because a whole camera silently contributing zero vectors
18149
+ * is the shape of failure a rebuild must never hide.
18150
+ */
18151
+ notRunnable: number(),
18152
+ /**
18153
+ * The pass stopped because NO node could serve the pinned model.
18154
+ *
18155
+ * Distinct from `notRunnable` on purpose: that one says "this track was
18156
+ * refused", this one says "the cluster cannot do this work at all" — every
18157
+ * candidate node either lacks the `clip-embedding` step, lacks a build of the
18158
+ * pinned model for its engine format, or dropped out. The remedy is a model /
18159
+ * engine change, not a per-camera one. Non-zero here always comes with
18160
+ * `complete: false`.
18161
+ */
18162
+ noCapableNode: number(),
18163
+ failed: number(),
18164
+ /** Set once a pass ends: true only when EVERYTHING was covered. */
18165
+ complete: boolean().nullable(),
18166
+ startedAtMs: number().nullable(),
18167
+ finishedAtMs: number().nullable(),
18168
+ /** Present when the pass ended by throwing. */
18169
+ error: string().nullable()
18170
+ });
18171
+ var ReplayFrameInputSchema = object({
18172
+ timestamp: number(),
18173
+ frame: PipelineRunResultBridge
18174
+ });
18175
+ var RunReplayFrameProcessorResultSchema = object({ tracks: array(object({
18176
+ className: string(),
18177
+ firstSeenMs: number(),
18178
+ lastSeenMs: number(),
18179
+ /** Bbox of the track's FIRST matched detection, pixel-space in the clip's
18180
+ * frame — a representative box for the diff's `(className, window, IoU)`
18181
+ * pairing (`replay-diff.ts`). A replay does not need the full per-frame
18182
+ * trajectory production's `Track.positions` keeps. */
18183
+ bbox: BoundingBoxSchema,
18184
+ /** How many of the input frames this track matched a real detection on
18185
+ * (never a coasted/extrapolated frame) — the replay's own signal for "how
18186
+ * solid is this track", cheaper than re-deriving it from a trajectory. */
18187
+ framesMatched: number().int()
18188
+ })).readonly() });
18189
+ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
18190
+ deviceId: number(),
18191
+ trackId: string()
18192
+ }), TrackSchema.nullable()), method(object({
18193
+ deviceId: number(),
18194
+ since: number().optional(),
18195
+ until: number().optional(),
18196
+ limit: number().optional(),
18197
+ /** Spatial filter — only tracks whose trajectory intersects the zone
18198
+ * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
18199
+ * envelope columns, then precisely tested per position. Tracks with
18200
+ * an unknown envelope (no frame dims at persist time) always match. */
18201
+ zone: TrackZoneFilterSchema.optional(),
18202
+ /** See {@link TrackProjectionSchema}. Default `full` (backward
18203
+ * compatible — omitting the field keeps today's exact behaviour). */
18204
+ projection: TrackProjectionSchema.optional(),
18205
+ /** Include stationary-promoted rows (parked objects handed to the
18206
+ * stationary registry). Default false: the timeline lists passages,
18207
+ * not parking records (operator decision, 2026-08-15). */
18208
+ includeStationary: boolean().optional()
18209
+ }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
18210
+ deviceId: number(),
18211
+ groupId: string().min(1)
18212
+ }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
18213
+ kind: "mutation",
18214
+ auth: "admin"
18215
+ }), method(DeviceEventQueryInput, array(MotionEventSchema).readonly()), method(ObjectEventQueryInput, array(ObjectEventSchema).readonly()), method(DeviceEventQueryInput, array(AudioEventSchema).readonly()), method(object({ deviceId: number() }), array(EventKindDescriptorSchema).readonly()), method(object({ deviceIds: array(number()).min(1).max(200) }), array(EventKindsForDeviceSchema).readonly()), method(object({
18216
+ deviceId: number(),
18217
+ since: number().optional(),
18218
+ until: number().optional(),
18219
+ kinds: array(string()).optional(),
18220
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
18221
+ }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
18222
+ deviceId: number(),
18223
+ since: number(),
18224
+ until: number(),
18225
+ bucketMs: number().int().positive()
18226
+ }), array(object({
18227
+ bucketStart: number(),
18228
+ motion: number().int(),
18229
+ object: number().int(),
18230
+ audio: number().int()
18231
+ })).readonly()), method(object({
18232
+ deviceId: number(),
18233
+ cutoffMs: number()
18234
+ }), object({
18235
+ motion: number().int(),
18236
+ object: number().int(),
18237
+ audio: number().int()
18238
+ }), {
18239
+ kind: "mutation",
18240
+ auth: "admin"
18241
+ }), method(object({
18242
+ deviceId: number(),
18243
+ cutoffMs: number()
18244
+ }), TrackCascadeCountsSchema, {
18245
+ kind: "mutation",
18246
+ auth: "admin"
18247
+ }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
18248
+ kind: "mutation",
18249
+ auth: "admin"
18250
+ }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
18251
+ kind: "mutation",
18252
+ auth: "admin"
18253
+ }), method(object({
18254
+ deviceId: number(),
18255
+ trackIds: array(string()).min(1)
18256
+ }), object({
18257
+ deleted: number().int(),
18258
+ failed: array(string()).readonly()
18259
+ }), {
18260
+ kind: "mutation",
18261
+ auth: "admin"
18262
+ }), method(object({
18263
+ /** Log/audit scope only — the trackId is globally unique on its own. */
18264
+ deviceId: number(),
18265
+ trackId: string(),
18266
+ flags: TrackFlagsPatchSchema
18267
+ }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
18268
+ kind: "query",
18269
+ auth: "admin"
18270
+ }), method(object({
18271
+ olderThanMs: number(),
18272
+ reason: OpsLogReasonSchema.optional()
18273
+ }), EventPruneCountsSchema, {
18274
+ kind: "mutation",
18275
+ auth: "admin"
18276
+ }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
18277
+ kind: "mutation",
18278
+ auth: "admin"
18279
+ }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
18280
+ kind: "mutation",
18281
+ auth: "admin"
18282
+ }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
18283
+ kind: "mutation",
18284
+ auth: "admin"
18285
+ }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
18286
+ kind: "mutation",
18287
+ auth: "admin"
18288
+ }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
18289
+ kind: "mutation",
18290
+ auth: "admin"
18291
+ }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18292
+ kind: "mutation",
18293
+ auth: "admin"
18294
+ }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
18295
+ kind: "mutation",
18296
+ auth: "admin"
18297
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
18298
+ kind: "query",
18299
+ auth: "admin"
18300
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18013
18301
  kind: "mutation",
18014
18302
  auth: "admin"
18015
- }), method(object({ nodeId: string() }), object({
18016
- success: literal(true),
18017
- clearedDevices: number()
18018
- }), {
18303
+ }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
18304
+ kind: "query",
18305
+ auth: "admin"
18306
+ }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
18307
+ kind: "query",
18308
+ auth: "admin"
18309
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18310
+ kind: "query",
18311
+ auth: "admin"
18312
+ }), method(object({
18313
+ /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
18314
+ * `deviceId`, deliberately: `deviceId` would make this device-bound and
18315
+ * route it at one camera's owner, and "every camera" would stop being
18316
+ * expressible at all. */
18317
+ deviceIds: array(number()).optional(),
18318
+ limit: number().int().min(1).max(500).optional()
18319
+ }), array(RetrainTrackSchema).readonly(), {
18320
+ kind: "query",
18321
+ auth: "admin"
18322
+ }), method(object({ trackId: string() }), RetrainFrameListSchema, {
18323
+ kind: "query",
18324
+ auth: "admin"
18325
+ }), method(object({
18326
+ deviceId: number(),
18327
+ trackId: string(),
18328
+ mediaKeys: array(string()).min(1)
18329
+ }), RetrainFrameSelectionSchema, {
18019
18330
  kind: "mutation",
18020
18331
  auth: "admin"
18021
- }), method(_void(), PipelineSchemaSchema), method(_void(), array(PipelineDefaultStepSchema).readonly().nullable()), method(_void(), PipelineConfigBridge), method(_void(), ConfigUISchemaBridge), method(object({ steps: array(PipelineStepInputSchema) }), PipelineValidationResultSchema), method(_void(), array(PipelineTemplateSchema$1).readonly()), method(object({
18022
- name: string(),
18023
- steps: array(PipelineTemplateStepSchema).readonly(),
18024
- engine: PipelineEngineChoiceSchema
18025
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
18026
- id: string(),
18027
- name: string().optional(),
18028
- steps: array(PipelineTemplateStepSchema).readonly().optional()
18029
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
18030
- addonId: string(),
18031
- modelId: string(),
18032
- format: ModelFormatSchema$1
18033
- }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
18034
- addonId: string(),
18035
- modelId: string(),
18036
- format: ModelFormatSchema$1
18037
- }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
18038
- engine: PipelineEngineChoiceSchema.optional(),
18039
- steps: array(PipelineStepInputSchema).min(1),
18040
- frame: FrameInputSchema.optional(),
18041
- /**
18042
- * Process-local lazy frame. Valid only when caller and provider resolve
18043
- * in the same execution-group process; split/cross-node callers use
18044
- * `frame`/`image` inline compatibility instead.
18045
- */
18046
- frameRef: FrameRefSchema.optional(),
18047
- /**
18048
- * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
18049
- * the decoded pixels live in. One more member of the one-of
18050
- * frame/frameHandle/image/imageBase64/referenceImage group.
18051
- */
18052
- frameHandle: FrameHandleSchema.optional(),
18053
- imageBase64: string().optional(),
18054
- /**
18055
- * Binary JPEG bytes — preferred over `imageBase64` on internal
18056
- * hops (hub → forked worker via Moleculer MsgPack) because it
18057
- * skips the 33% base64 overhead + the per-call base64 decode on
18058
- * the detection-pipeline worker. Callers can pass either; exactly
18059
- * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
18060
- */
18061
- image: _instanceof(Uint8Array).optional(),
18062
- referenceImage: string().optional(),
18063
- deviceId: number().optional(),
18064
- sessionId: string().optional(),
18065
- /**
18066
- * Execution plane. 'full' (default) runs the whole tree — benchmark,
18067
- * reference-image, and detail-subtree calls. 'frame' is the live
18068
- * per-frame dispatch: ONLY root-plane steps run; crop children
18069
- * (inputClasses ≠ null) are skipped and served per-track via
18070
- * pipelineRunner.runDetailSubtree (two-plane design).
18071
- */
18072
- plane: _enum(["full", "frame"]).optional(),
18073
- /**
18074
- * Inference-device selector (Phase 2 multi-device). Format
18075
- * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
18076
- * Omitted ⇒ the runner's default device (current single-engine
18077
- * behaviour). Selects WHICH device pool of the node runs the call.
18078
- */
18079
- deviceKey: string().optional(),
18080
- /**
18081
- * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
18082
- * when the parent crop was resolved from the frame's retained NATIVE
18083
- * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
18084
- * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
18085
- * resolution from that surface — the SAME quality path faces already
18086
- * had — instead of the downscaled parent tile. `handle` keys the native
18087
- * surface (node-pinned to its owner); `cropFrameSpace` is the parent
18088
- * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
18089
- * the executor's crop-normalized child ROI back into frame-normalized
18090
- * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
18091
- * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
18092
- * (today's behaviour on the fallback path).
18093
- */
18094
- nativeCropRef: NativeCropRefSchema.optional()
18095
- }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
18096
- engine: PipelineEngineChoiceSchema.optional(),
18097
- steps: array(PipelineStepInputSchema).min(1),
18098
- frames: array(FrameInputSchema).min(1).max(255),
18099
- deviceId: number().optional(),
18100
- sessionId: string().optional(),
18101
- /**
18102
- * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
18103
- * the batch to the Python pool's bench preprocess cache
18104
- * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
18105
- * preprocessed ONCE and every later inference is a pure-inference cache
18106
- * hit — the sustained-throughput run measures inference, not
18107
- * decode+preprocess+infer. Omitted/0 for live frames (all different →
18108
- * full preprocess every call, correct). Fresh per sustained run;
18109
- * released via `uncacheFrame`.
18110
- */
18111
- frameId: number().int().nonnegative().optional(),
18112
- /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
18113
- deviceKey: string().optional()
18114
- }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
18115
- data: _instanceof(Uint8Array),
18116
- width: number().int().positive(),
18117
- height: number().int().positive(),
18118
- format: _enum([
18119
- "rgb",
18120
- "bgr",
18121
- "gray"
18122
- ])
18332
+ }), method(object({
18333
+ deviceId: number(),
18334
+ trackId: string(),
18335
+ frameId: string()
18123
18336
  }), object({
18124
- frameId: number(),
18125
- width: number(),
18126
- height: number()
18127
- }), { kind: "mutation" }), method(object({
18128
- stepId: string(),
18129
- frameId: number().int()
18130
- }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
18131
- batchMode: string(),
18132
- windowMs: number(),
18133
- maxBatchSize: number(),
18134
- concurrency: number()
18135
- })), method(_void(), array(object({
18136
- engineKey: string(),
18137
- engine: PipelineEngineChoiceSchema,
18138
- modelsLoaded: array(string()).readonly(),
18139
- inUseByCameras: array(number()).readonly(),
18140
- /**
18141
- * Origin of this resident factory.
18142
- * - `runtime` — main camera-serving engine (no idle TTL).
18143
- * - `warm-override` — benchmark/test override held in the warm
18144
- * cache; auto-disposed after the idle TTL.
18145
- * - `device-pool` — a concurrent per-device pool (Phase 2
18146
- * multi-device, keyed by `deviceKey`) resolved
18147
- * via `resolveDeviceFactory`. Runs alongside the
18148
- * `runtime` engine on a DIFFERENT accelerator
18149
- * (NPU / iGPU / Coral) — this is how the
18150
- * Engines tab shows all pools running at once.
18151
- */
18152
- kind: _enum([
18153
- "runtime",
18154
- "warm-override",
18155
- "device-pool"
18156
- ]),
18157
- /** Native pid of the underlying Python pool (null when no pool). */
18158
- poolPid: number().nullable(),
18159
- /** ms since this factory was last used (null when not warm-tracked). */
18160
- idleMs: number().nullable(),
18161
- /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
18162
- idleTtlMs: number().nullable()
18163
- })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
18337
+ removed: boolean(),
18338
+ removedAnnotations: number().int()
18339
+ }), {
18164
18340
  kind: "mutation",
18165
18341
  auth: "admin"
18342
+ }), method(object({ frameId: string() }), object({
18343
+ base64: string(),
18344
+ width: number().int(),
18345
+ height: number().int()
18346
+ }), {
18347
+ kind: "query",
18348
+ auth: "admin"
18166
18349
  }), method(object({
18167
- engine: PipelineEngineChoiceSchema,
18168
- force: boolean().optional()
18350
+ deviceId: number(),
18351
+ trackId: string(),
18352
+ frameId: string(),
18353
+ subject: RetrainAssistSubjectSchema,
18354
+ /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
18355
+ nodeId: string().optional()
18356
+ }), RetrainAssistResultSchema, {
18357
+ kind: "mutation",
18358
+ auth: "admin"
18359
+ }), method(object({
18360
+ deviceId: number(),
18361
+ source: DetectionSourceSchema,
18362
+ zones: array(ZoneSchema).readonly().optional(),
18363
+ detectionRules: array(ZoneRuleSchema).readonly().optional(),
18364
+ zoneMembershipMinOverlap: number().min(0).max(1).optional(),
18365
+ frames: array(ReplayFrameInputSchema).min(1)
18366
+ }), RunReplayFrameProcessorResultSchema, {
18367
+ kind: "mutation",
18368
+ auth: "admin"
18369
+ }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
18370
+ kind: "query",
18371
+ auth: "admin"
18372
+ }), method(object({
18373
+ deviceId: number(),
18374
+ trackId: string(),
18375
+ frameId: string(),
18376
+ annotations: array(RetrainAnnotationDraftSchema)
18377
+ }), array(RetrainAnnotationSchema).readonly(), {
18378
+ kind: "mutation",
18379
+ auth: "admin"
18380
+ }), method(object({
18381
+ deviceId: number(),
18382
+ trackId: string()
18383
+ }), RetrainTransitionResultSchema, {
18384
+ kind: "mutation",
18385
+ auth: "admin"
18386
+ }), method(object({
18387
+ deviceId: number(),
18388
+ trackId: string()
18389
+ }), RetrainTransitionResultSchema, {
18390
+ kind: "mutation",
18391
+ auth: "admin"
18392
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18393
+ kind: "query",
18394
+ auth: "admin"
18395
+ }), method(object({
18396
+ eventId: string(),
18397
+ kind: MediaFileKindEnum.optional(),
18398
+ deviceId: number()
18399
+ }), array(MediaFileSchema).readonly()), method(object({
18400
+ trackId: string(),
18401
+ kinds: array(MediaFileKindEnum).optional(),
18402
+ deviceId: number()
18403
+ }), array(MediaFileSchema).readonly()), method(object({
18404
+ trackId: string(),
18405
+ deviceId: number()
18406
+ }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
18407
+ kind: "mutation",
18408
+ auth: "admin"
18409
+ }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
18410
+ kind: "mutation",
18411
+ auth: "admin"
18412
+ }), method(object({}), RebuildStatusSchema), object({
18413
+ deviceId: number(),
18414
+ timestamp: number(),
18415
+ frameWidth: number(),
18416
+ frameHeight: number(),
18417
+ detections: array(OverlayDetectionSchema).readonly()
18418
+ }), object({
18419
+ deviceId: number(),
18420
+ trackId: string(),
18421
+ className: string()
18169
18422
  }), object({
18170
- success: boolean(),
18171
- reason: string().optional()
18172
- }), {
18173
- kind: "mutation",
18174
- auth: "admin"
18175
- }), method(_void(), array(ReferenceImageEntrySchema).readonly()), method(object({ filename: string() }), ReferenceImageBodySchema.nullable()), method(_void(), array(ReferenceAudioEntrySchema).readonly()), method(object({ filename: string() }), ReferenceAudioBodySchema.nullable()), method(_void(), AudioCapabilitiesSchema), method(object({
18176
- addonId: string(),
18177
- modelId: string(),
18178
- filename: string().optional(),
18179
- settings: record(string(), unknown()).optional()
18180
- }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
18423
+ deviceId: number(),
18424
+ trackId: string(),
18425
+ className: string(),
18426
+ durationMs: number()
18427
+ }), object({
18428
+ deviceId: number(),
18429
+ kind: EventKindSchema,
18430
+ eventId: string(),
18431
+ timestamp: number()
18432
+ });
18181
18433
  object({
18182
18434
  activeCameras: number(),
18183
18435
  throttledCameras: number(),
@@ -18203,106 +18455,6 @@ var CameraMetricsSchema = object({
18203
18455
  });
18204
18456
  var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
18205
18457
  /**
18206
- * Zone — pure geometry + identity. NO filtering behaviour.
18207
- *
18208
- * Zones describe **where** in the frame the operator wants to flag
18209
- * something; consumer-owned {@link ZoneRule} arrays describe **how**
18210
- * each pipeline stage uses them. Splitting the two means a single
18211
- * polygon "Driveway" can simultaneously back a motion-exclude rule,
18212
- * a detection-include rule on `['car']`, and an occupancy aggregate
18213
- * — without three duplicated polygons.
18214
- *
18215
- * Owned by the orchestrator addon (provider) and mirrored into the
18216
- * `zones` device-state slice on every mutation. Consumers
18217
- * (motion-wasm, pipeline-executor, analytics, admin UI) read either
18218
- * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
18219
- * mirror with `onChanged`).
18220
- *
18221
- * Coordinates are normalised fractions of the frame (0–1) so zones
18222
- * survive resolution changes and stream profile switches.
18223
- *
18224
- * `kind` discriminates between full polygons (closed regions used
18225
- * for intrusion / occupancy filters) and tripwires (open 2-point
18226
- * line segments used for cross events). Onboard / firmware-reported
18227
- * zones (Reolink, ONVIF) are out of scope for now — see the deferred
18228
- * task list.
18229
- */
18230
- var ZoneKindEnum = _enum(["polygon", "tripwire"]);
18231
- /** Polygon vertex in fraction-of-frame coordinates (0–1). */
18232
- var PolygonPointSchema = object({
18233
- x: number(),
18234
- y: number()
18235
- });
18236
- /** A camera detection zone — pure geometry/identity. */
18237
- var ZoneSchema = object({
18238
- id: string(),
18239
- name: string(),
18240
- kind: ZoneKindEnum.default("polygon"),
18241
- /** Polygon vertices, fraction of frame (0–1). */
18242
- polygon: array(PolygonPointSchema).readonly(),
18243
- /** Visual color for UI rendering. */
18244
- color: string().default("#3b82f6")
18245
- });
18246
- /**
18247
- * Zones capability — per-camera CRUD over polygon detection zones.
18248
- *
18249
- * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
18250
- * to per-device settings and mirrors into the `zones` device-state
18251
- * slice on every mutation, so downstream consumers can subscribe via
18252
- * `dev.state.zones.onChanged`.
18253
- *
18254
- * The cap surface only handles geometry + identity; filtering
18255
- * behaviour (per-class, include/exclude, threshold) lives in the
18256
- * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
18257
- * `capabilities/schemas/zone-rule.js`.
18258
- */
18259
- var zonesCapability = {
18260
- name: "zones",
18261
- scope: "device",
18262
- mode: "singleton",
18263
- deviceTypes: [DeviceType.Camera],
18264
- methods: {
18265
- listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
18266
- addZone: method(object({
18267
- deviceId: number(),
18268
- zone: ZoneSchema
18269
- }), _void(), {
18270
- kind: "mutation",
18271
- auth: "admin"
18272
- }),
18273
- removeZone: method(object({
18274
- deviceId: number(),
18275
- zoneId: string()
18276
- }), _void(), {
18277
- kind: "mutation",
18278
- auth: "admin"
18279
- }),
18280
- updateZone: method(object({
18281
- deviceId: number(),
18282
- zone: ZoneSchema
18283
- }), _void(), {
18284
- kind: "mutation",
18285
- auth: "admin"
18286
- })
18287
- },
18288
- /**
18289
- * Runtime-state slice — the live zone catalogue mirrored by the
18290
- * orchestrator on every CRUD mutation. Consumers read via
18291
- * `device.state.zones.value` / `.watch(...)` without round-tripping
18292
- * the cap, and the codegen DeviceProxy auto-wires the reactive
18293
- * handle. Slice shape is `{ zones: Zone[] }` so future extensions
18294
- * (e.g. zone groupings) can sit alongside the polygon list.
18295
- */
18296
- runtimeState: object({ zones: array(ZoneSchema).readonly() }),
18297
- /**
18298
- * 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.
18299
- *
18300
- * See `RuntimeStateDurability`. Enforced by
18301
- * `scripts/check-runtime-state-durability.ts`.
18302
- */
18303
- durability: "restored"
18304
- };
18305
- /**
18306
18458
  * A bounding box in NORMALIZED [0,1] frame coordinates for `getNativeCrop`. The
18307
18459
  * decode worker resolves it against the RETAINED native frame's real pixel dims,
18308
18460
  * so the caller supplies only the detection-res bbox divided by the detection
@@ -26968,6 +27120,39 @@ var ReadGopBytesResultSchema = object({
26968
27120
  /** Media ms the returned fragment covers. */
26969
27121
  gopDurMs: number()
26970
27122
  });
27123
+ /**
27124
+ * A time WINDOW of one finalized segment, cut by byte range — the multi-GOP
27125
+ * twin of {@link ReadGopBytesResultSchema}'s single instant. Built for the
27126
+ * replay clip's `recording` source (`docs/design/plans/2026-08-26-replay-clip-su-pipeline.md`):
27127
+ * a replay needs several seconds of native pixels, not one frame.
27128
+ *
27129
+ * `ok.data` is standalone-demuxable, same as a GOP read. `ok.reachesRequestedEnd`
27130
+ * is `false` when the returned bytes were cut short by the read's own safety
27131
+ * byte cap before covering `[fromMs, toMs)` — a truncation, reported, not a
27132
+ * silently shorter answer. `spans-multiple-segments` is a REFUSAL, not a
27133
+ * degradation: a window whose end falls past the covering segment would need
27134
+ * bytes stitched from a second segment file (its own `ftyp`+`moov`), which is
27135
+ * not one standalone-demuxable stream — the caller's answer is to request a
27136
+ * shorter window or one aligned to a single segment, not to receive spliced
27137
+ * bytes nothing has proven decodable.
27138
+ */
27139
+ var ReadWindowBytesResultSchema = discriminatedUnion("kind", [object({
27140
+ kind: literal("ok"),
27141
+ data: _instanceof(Uint8Array),
27142
+ /** Absolute epoch ms of the returned bytes' first sample — at or before
27143
+ * the requested `fromMs` (anchored on the nearest keyframe). */
27144
+ gopStartMs: number(),
27145
+ /** Media ms the returned bytes cover, from `gopStartMs`. */
27146
+ gopDurMs: number(),
27147
+ /** `false` ⇒ the safety byte cap cut the read short before it reached
27148
+ * the requested `toMs`; the caller got fewer frames than asked for. */
27149
+ reachesRequestedEnd: boolean()
27150
+ }), object({
27151
+ kind: literal("spans-multiple-segments"),
27152
+ /** Where the covering segment's own footage runs out — informational,
27153
+ * not a retry hint (retrying the same window would refuse again). */
27154
+ segmentEndMs: number()
27155
+ })]);
26971
27156
  method(object({
26972
27157
  deviceId: number(),
26973
27158
  fromMs: number(),
@@ -27018,6 +27203,15 @@ method(object({
27018
27203
  }), ReadGopBytesResultSchema, {
27019
27204
  kind: "query",
27020
27205
  auth: "admin"
27206
+ }), method(object({
27207
+ deviceId: number(),
27208
+ profile: string(),
27209
+ startMs: number(),
27210
+ fromMs: number(),
27211
+ toMs: number()
27212
+ }), ReadWindowBytesResultSchema, {
27213
+ kind: "query",
27214
+ auth: "admin"
27021
27215
  }), method(object({
27022
27216
  deviceId: number(),
27023
27217
  config: RecordingConfigSchema
@@ -27613,92 +27807,6 @@ var sceneMonitorCapability = {
27613
27807
  durability: "session"
27614
27808
  };
27615
27809
  /**
27616
- * Per-stage gating mode applied to the zones a rule references.
27617
- *
27618
- * - `include`: the rule contributes to a **whitelist** for its stage.
27619
- * When at least one `include` rule fires for a stage, only entities
27620
- * inside one of those zones pass that stage.
27621
- * - `exclude`: the rule contributes to a **blacklist** for its stage.
27622
- * Entities inside one of those zones are dropped at that stage.
27623
- *
27624
- * `monitor`-style observation (count without filtering) is not a rule
27625
- * mode — zones without any matching rule are observed naturally by
27626
- * `zone-analytics` (live snapshot + history), so an "I just want to
27627
- * count, not filter" use case needs no rule at all.
27628
- */
27629
- var ZoneRuleModeEnum = _enum(["include", "exclude"]);
27630
- /**
27631
- * Per-consumer rule that references existing zones (geometry) and
27632
- * defines how a specific pipeline stage should treat them. Each
27633
- * consumer addon owns its own `ZoneRule[]` array in its per-device
27634
- * settings:
27635
- *
27636
- * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
27637
- * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
27638
- * - future: notification rules, audio gating, etc.
27639
- *
27640
- * One rule applies to N zones (`zoneIds[]`) so the operator can
27641
- * express "ignore motion in ALL of {garden, street}" with a single
27642
- * rule. `classFilter` narrows the rule to specific object classes —
27643
- * "drop person detections in the street, but keep cars" is one
27644
- * `exclude` rule with `classFilter: ['person']`.
27645
- *
27646
- * `enabled` is a soft toggle — the operator can keep the rule
27647
- * configured but inert without deleting it.
27648
- */
27649
- var ZoneRuleSchema = object({
27650
- /** Stable rule id — survives edits, used by the UI for diffing. */
27651
- id: string(),
27652
- /** Optional human-readable label rendered in the rule editor. */
27653
- name: string().optional(),
27654
- /** Zones this rule targets. The rule's `mode` applies to ALL
27655
- * listed zones (OR-set: a detection in any one of them counts).
27656
- * At least one zone id required — a rule with no targets is a
27657
- * configuration mistake and the form validator rejects it. */
27658
- zoneIds: array(string()).min(1).readonly(),
27659
- mode: ZoneRuleModeEnum,
27660
- /**
27661
- * Class names this rule applies to. Empty / undefined ⇒ rule
27662
- * applies to every class. Class strings match the `macroClass`
27663
- * field on detections (e.g. `person`, `car`, `dog`).
27664
- */
27665
- classFilter: array(string()).readonly().optional(),
27666
- /**
27667
- * Minimum bbox/mask overlap (0–1) with any of the rule's zones
27668
- * required to consider an entity "in the zone". Defaults to the
27669
- * consumer's stage default when omitted. Kept for back-compat with
27670
- * existing per-rule overrides; new operators pick the value via
27671
- * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
27672
- * set, the lower-level engine reads it as a 0–1 fraction.
27673
- */
27674
- overlapThreshold: number().min(0).max(1).optional(),
27675
- /**
27676
- * Operator-friendly version of `overlapThreshold` — the percentage
27677
- * of the detection's bbox that must lie inside the zone for the
27678
- * rule to match. Documented default is 85%; the engine substitutes
27679
- * that when the field is omitted (kept optional so existing rules
27680
- * stored without it stay valid).
27681
- *
27682
- * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
27683
- * rule, the engine prefers `bboxInclusionPct` because it's the
27684
- * field exposed in the UI. Internally both feed the same gate.
27685
- */
27686
- bboxInclusionPct: number().min(0).max(100).optional(),
27687
- /**
27688
- * When `true` and a detection has a segmentation mask, use the
27689
- * mask for overlap instead of the bbox. Detection-stage only;
27690
- * motion rules ignore this field.
27691
- */
27692
- preferMask: boolean().optional(),
27693
- /**
27694
- * Soft-toggle: `false` disables the rule without deleting it.
27695
- * Defaults to `true` so operators creating a rule via the UI
27696
- * see it active immediately.
27697
- */
27698
- enabled: boolean().default(true)
27699
- });
27700
- array(ZoneRuleSchema).readonly();
27701
- /**
27702
27810
  * Script-runner cap. Models HA `script.*` entities on
27703
27811
  * `DeviceType.Script`. A Script is a pre-recorded action sequence
27704
27812
  * that can be invoked imperatively — optionally with a variables
@@ -33191,6 +33299,12 @@ Object.freeze({
33191
33299
  addonId: null,
33192
33300
  access: "view"
33193
33301
  },
33302
+ "notificationRules.resolveArtifactUrl": {
33303
+ capName: "notification-rules",
33304
+ capScope: "system",
33305
+ addonId: null,
33306
+ access: "view"
33307
+ },
33194
33308
  "notificationRules.setAlarmConfig": {
33195
33309
  capName: "notification-rules",
33196
33310
  capScope: "system",
@@ -33635,6 +33749,12 @@ Object.freeze({
33635
33749
  addonId: null,
33636
33750
  access: "create"
33637
33751
  },
33752
+ "pipelineAnalytics.runReplayFrameProcessor": {
33753
+ capName: "pipeline-analytics",
33754
+ capScope: "device",
33755
+ addonId: null,
33756
+ access: "create"
33757
+ },
33638
33758
  "pipelineAnalytics.saveRetrainAnnotations": {
33639
33759
  capName: "pipeline-analytics",
33640
33760
  capScope: "device",
@@ -33767,6 +33887,12 @@ Object.freeze({
33767
33887
  addonId: null,
33768
33888
  access: "view"
33769
33889
  },
33890
+ "pipelineExecutor.getInferenceDeviceHealth": {
33891
+ capName: "pipeline-executor",
33892
+ capScope: "system",
33893
+ addonId: null,
33894
+ access: "view"
33895
+ },
33770
33896
  "pipelineExecutor.getOrchestratorConfigSchema": {
33771
33897
  capName: "pipeline-executor",
33772
33898
  capScope: "system",
@@ -33839,6 +33965,12 @@ Object.freeze({
33839
33965
  addonId: null,
33840
33966
  access: "view"
33841
33967
  },
33968
+ "pipelineExecutor.rearmInferenceDevice": {
33969
+ capName: "pipeline-executor",
33970
+ capScope: "system",
33971
+ addonId: null,
33972
+ access: "create"
33973
+ },
33842
33974
  "pipelineExecutor.runAudioTest": {
33843
33975
  capName: "pipeline-executor",
33844
33976
  capScope: "system",
@@ -34577,6 +34709,12 @@ Object.freeze({
34577
34709
  addonId: null,
34578
34710
  access: "view"
34579
34711
  },
34712
+ "recording.readWindowBytes": {
34713
+ capName: "recording",
34714
+ capScope: "system",
34715
+ addonId: null,
34716
+ access: "view"
34717
+ },
34580
34718
  "recording.refreshStorageLocationsForMigration": {
34581
34719
  capName: "recording",
34582
34720
  capScope: "system",
@@ -37087,6 +37225,11 @@ Object.freeze({
37087
37225
  form: "single",
37088
37226
  optional: false
37089
37227
  }],
37228
+ "pipelineAnalytics.runReplayFrameProcessor": [{
37229
+ name: "deviceId",
37230
+ form: "single",
37231
+ optional: false
37232
+ }],
37090
37233
  "pipelineAnalytics.saveRetrainAnnotations": [{
37091
37234
  name: "deviceId",
37092
37235
  form: "single",
@@ -37402,6 +37545,11 @@ Object.freeze({
37402
37545
  form: "single",
37403
37546
  optional: false
37404
37547
  }],
37548
+ "recording.readWindowBytes": [{
37549
+ name: "deviceId",
37550
+ form: "single",
37551
+ optional: false
37552
+ }],
37405
37553
  "recording.relocateFootage": [{
37406
37554
  name: "deviceId",
37407
37555
  form: "single",