@camstack/addon-provider-reolink 1.2.51 → 1.2.53

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