@camstack/addon-provider-hikvision 1.2.36 → 1.2.38

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