@camstack/addon-provider-petkit 0.2.29 → 0.2.31

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
@@ -16900,7 +16900,23 @@ var NcHistoryEntrySchema = object({
16900
16900
  updatedAt: number(),
16901
16901
  /** Failure detail — present on a `dead` row. */
16902
16902
  error: string().optional(),
16903
- subject: NcHistorySubjectSchema
16903
+ subject: NcHistorySubjectSchema,
16904
+ /**
16905
+ * Ids of the artefacts (still, then gif, then clip) this row's successful
16906
+ * delivery indexed in the artefact library — a REFERENCE, never the bytes
16907
+ * (an artefact is often megabytes; this row is durable JSON rewritten on
16908
+ * every delivery attempt). Absent on a row still pending/dead, a row
16909
+ * delivered before this field shipped, or a wiring with no artefact index.
16910
+ *
16911
+ * Resolve one to a fetchable URL with `resolveArtifactUrl` — an id
16912
+ * outlives any one URL's TTL, so a caller mints a fresh link on demand
16913
+ * rather than trusting one frozen at delivery time. `resolveArtifactUrl`
16914
+ * also answers `null` for an id whose artefact has since expired past the
16915
+ * retained shelf's own age bound — the degrade a caller (the Home
16916
+ * Assistant export) must render as "no image right now", never as a
16917
+ * broken link.
16918
+ */
16919
+ artifactIds: array(string().min(1)).optional()
16904
16920
  });
16905
16921
  /**
16906
16922
  * Query filter for `getHistory` (spec §4.2). Every field is a narrowing
@@ -17127,7 +17143,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
17127
17143
  }), method(object({}), object({
17128
17144
  catalog: array(NcConditionDescriptorSchema),
17129
17145
  taxonomy: NcTaxonomySchema.optional()
17130
- })), 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 }), {
17146
+ })), 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 }), {
17131
17147
  kind: "mutation",
17132
17148
  caller: "required"
17133
17149
  }), method(object({ snoozeId: string() }), object({ success: literal(true) }), {
@@ -17467,1760 +17483,1996 @@ var OauthIntegrationDescriptorSchema = object({
17467
17483
  });
17468
17484
  method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
17469
17485
  /**
17470
- * pipeline-analytics device-scoped wrapper cap. Refines raw
17471
- * per-frame detections emitted by the pipeline runner into tracked
17472
- * objects, per-kind event collections (motion / object / audio), and
17473
- * persisted media. Owns the post-detection domain end-to-end:
17474
- *
17475
- * runner emits PipelineInferenceResult
17476
- * ↓ (event bus)
17477
- * pipeline-analytics subscriber
17478
- * ↓ SORT tracker + zone engine + state analyzer + event emitter
17479
- * → three DB collections (one per kind), one FS media tree, one
17480
- * unified event emitter (FrameTracked + TrackStarted/Ended +
17481
- * DetectionEvent on bus)
17482
- *
17483
- * Pure subscriber model. No `processFrame` cap method — the runner
17484
- * already publishes the raw frame on the bus. The cap surface is
17485
- * only QUERIES + per-device settings, bound on/off via
17486
- * `device-manager.setWrapperActive`. `defaultActive: true` because
17487
- * every camera with a detection pipeline wants its raw detections
17488
- * refined; operators opt out per-device via BindingsTab when needed.
17489
- *
17490
- * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
17491
- * (per-device surface) and `track-trail` caps — see P11 cleanup.
17486
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
17487
+ * within the frame, so the executor can re-cut a leaf child ROI at native
17488
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
17492
17489
  */
17493
- var TrackStateSchema = _enum([
17494
- "new",
17495
- "entered",
17496
- "left",
17497
- "moving",
17498
- "idle"
17499
- ]);
17500
- var EventKindSchema = _enum([
17501
- "motion",
17502
- "object",
17503
- "audio"
17504
- ]);
17490
+ var NativeCropRefSchema = object({
17491
+ /** Handle keying the retained native surface (node-pinned to its owner). */
17492
+ handle: FrameHandleSchema,
17493
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
17494
+ cropFrameSpace: object({
17495
+ x: number(),
17496
+ y: number(),
17497
+ w: number(),
17498
+ h: number()
17499
+ })
17500
+ });
17501
+ object({
17502
+ crop: object({
17503
+ left: number(),
17504
+ top: number(),
17505
+ width: number().positive(),
17506
+ height: number().positive()
17507
+ }).optional(),
17508
+ content: object({
17509
+ width: number().int().positive(),
17510
+ height: number().int().positive()
17511
+ }),
17512
+ fit: _enum(["stretch", "contain"]),
17513
+ format: _enum([
17514
+ "rgb",
17515
+ "gray",
17516
+ "jpeg"
17517
+ ])
17518
+ });
17505
17519
  /**
17506
- * Spatial filter for `listTracks` the rect + polygon variants of the shared
17507
- * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
17508
- * of the camera frame (top-left origin), matching the drawing-plane editor.
17520
+ * Process-local frame identity. It is serializable so it can ride an in-process
17521
+ * capability call, but `registryId` deliberately prevents resolution in any
17522
+ * other process or execution group.
17509
17523
  */
17510
- var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
17511
- /** Closed icon vocabulary so clients render a known glyph per kind. */
17512
- var EventKindIconSchema = _enum([
17513
- "motion",
17514
- "audio",
17515
- "person",
17516
- "vehicle",
17517
- "animal",
17518
- "door",
17519
- "pir",
17520
- "smoke",
17521
- "water",
17522
- "button",
17523
- "package",
17524
- "generic"
17524
+ var FrameRefSchema = object({
17525
+ registryId: string().min(1),
17526
+ id: string().min(1),
17527
+ width: number().int().positive(),
17528
+ height: number().int().positive(),
17529
+ format: _enum(["rgb", "gray"]),
17530
+ timestamp: number(),
17531
+ capturedAt: number().optional()
17532
+ });
17533
+ var ModelFormatSchema$1 = _enum([
17534
+ "onnx",
17535
+ "coreml",
17536
+ "openvino",
17537
+ "tflite",
17538
+ "pt",
17539
+ "gguf"
17525
17540
  ]);
17526
- var EventKindCategorySchema = _enum([
17527
- "motion",
17528
- "audio",
17529
- "detection",
17530
- "sensor",
17531
- "control",
17532
- "custom",
17533
- "package"
17541
+ var PipelineSlotSchema = _enum([
17542
+ "detector",
17543
+ "cropper",
17544
+ "classifier",
17545
+ "refiner",
17546
+ "audio-classifier"
17534
17547
  ]);
17535
- /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
17536
- var EventKindLevelSchema = _enum(["macro", "sub"]);
17537
- var EventKindDescriptorSchema = object({
17538
- /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
17539
- kind: string(),
17540
- /** i18n key resolved on the UI side; `label` is the English fallback. */
17541
- labelKey: string(),
17542
- /** English fallback label (kept for clients that don't translate). */
17543
- label: string(),
17544
- /** Hex color for timeline/legend rendering. */
17545
- color: string(),
17546
- /** Dictionary id → lucide component on the UI side. */
17547
- iconId: string(),
17548
- /** Legacy closed-vocab glyph — fallback for `iconId`. */
17549
- icon: EventKindIconSchema,
17550
- category: EventKindCategorySchema,
17551
- /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
17552
- parentKind: string().nullable(),
17553
- /** Derived from `parentKind`, explicit for the client tree. */
17554
- level: EventKindLevelSchema,
17555
- /** Which cap + device contributes this kind. For built-ins the camera
17556
- * itself; for sensor kinds the LINKED source device. */
17557
- source: object({
17558
- capName: string(),
17559
- deviceId: number()
17560
- })
17548
+ var PipelineEngineChoiceSchema = object({
17549
+ runtime: _enum(["node", "python"]),
17550
+ backend: string(),
17551
+ format: ModelFormatSchema$1,
17552
+ device: string().optional()
17561
17553
  });
17562
- /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
17563
- var EventKindsForDeviceSchema = object({
17564
- deviceId: number(),
17565
- kinds: array(EventKindDescriptorSchema).readonly()
17554
+ var AvailableEngineSchema = object({
17555
+ engine: PipelineEngineChoiceSchema,
17556
+ devices: array(object({
17557
+ id: string(),
17558
+ label: string(),
17559
+ description: string().optional()
17560
+ })).readonly(),
17561
+ defaultDevice: string()
17566
17562
  });
17567
- var SensorEventSchema = object({
17563
+ var PipelineDefaultStepSchema = lazy(() => object({
17564
+ addonId: string(),
17565
+ addonName: string(),
17566
+ slot: PipelineSlotSchema,
17567
+ inputClasses: array(string()).readonly(),
17568
+ outputClasses: array(string()).readonly(),
17569
+ enabled: boolean(),
17570
+ modelId: string(),
17571
+ children: array(PipelineDefaultStepSchema).readonly(),
17572
+ group: string().optional(),
17573
+ settings: record(string(), unknown()).optional()
17574
+ }));
17575
+ var PipelineTemplateStepSchema = lazy(() => object({
17576
+ addonId: string(),
17577
+ enabled: boolean(),
17578
+ modelId: string(),
17579
+ children: array(PipelineTemplateStepSchema).readonly(),
17580
+ settings: record(string(), unknown()).optional()
17581
+ }));
17582
+ var PipelineTemplateSchema$1 = object({
17568
17583
  id: string(),
17569
- /** The CAMERA the event is attributed to (a sensor linked to N cameras
17570
- * yields N rows, one per camera). */
17571
- deviceId: number(),
17572
- /** The linked sensor device whose state changed. */
17573
- sourceDeviceId: number(),
17574
- /** Event kind id — matches an `EventKindDescriptor.kind`. */
17575
- kind: string(),
17576
- /** Snapshot of the sensor cap's runtime-state slice at the change. */
17577
- value: record(string(), unknown()).nullable(),
17578
- timestamp: number()
17584
+ name: string(),
17585
+ createdAt: string(),
17586
+ updatedAt: string(),
17587
+ engine: PipelineEngineChoiceSchema,
17588
+ steps: array(PipelineTemplateStepSchema).readonly()
17579
17589
  });
17580
- var TrackPositionSchema = object({
17581
- x: number(),
17582
- y: number(),
17583
- timestamp: number(),
17584
- bbox: BoundingBoxSchema
17590
+ var PipelineModelOptionSchema = object({
17591
+ id: string(),
17592
+ name: string(),
17593
+ formats: record(string(), object({
17594
+ downloaded: boolean(),
17595
+ sizeMB: number()
17596
+ })),
17597
+ group: ModelVariantGroupSchema.optional(),
17598
+ legacy: boolean().optional(),
17599
+ provider: ModelProviderIdSchema.optional()
17585
17600
  });
17586
- var TrackSnapshotSchema = object({
17587
- timestamp: number(),
17588
- position: TrackPositionSchema,
17589
- /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
17590
- mediaKey: string()
17601
+ var ConfigFieldBridge = custom();
17602
+ var PipelineAddonSchemaSchema = object({
17603
+ id: string(),
17604
+ name: string(),
17605
+ slot: PipelineSlotSchema,
17606
+ inputClasses: array(string()).readonly(),
17607
+ outputClasses: array(string()).readonly(),
17608
+ childSlots: array(PipelineSlotSchema).readonly(),
17609
+ models: array(PipelineModelOptionSchema).readonly(),
17610
+ defaultModelId: string(),
17611
+ defaultModelIdByFormat: record(string(), string()).optional(),
17612
+ enabledByDefault: boolean().optional(),
17613
+ backfillIntoExistingOverrides: boolean().optional(),
17614
+ defaultConfidence: number(),
17615
+ group: string().optional(),
17616
+ configSchema: array(ConfigFieldBridge).readonly().optional()
17591
17617
  });
17592
- /**
17593
- * Normalized 0..1 trajectory envelope (min/max over every position bbox,
17594
- * divided by the track's detection-frame dims), computed at persist time.
17595
- * Absent when the frame dims were unknown when the track was persisted
17596
- * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
17597
- */
17598
- var TrackEnvelopeSchema = object({
17599
- minX: number(),
17600
- minY: number(),
17601
- maxX: number(),
17602
- maxY: number()
17618
+ var PipelineSlotSchemaSchema = object({
17619
+ id: PipelineSlotSchema,
17620
+ label: string(),
17621
+ priority: number(),
17622
+ parentSlot: PipelineSlotSchema.nullable(),
17623
+ addons: array(PipelineAddonSchemaSchema).readonly()
17603
17624
  });
17604
- /**
17605
- * Row projection for track list queries. `full` (default) returns the
17606
- * complete Track including the frame-rate `positions[]` history and the
17607
- * `snapshots[]` references — megabytes across a page of tracks. `slim`
17608
- * keeps every scalar the list surfaces actually render (ids, class(es),
17609
- * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
17610
- * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
17611
- * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
17612
- * `getTrack`. Mirrors the event-store `projection` convention
17613
- * (`getObjectEvents` et al.).
17614
- */
17615
- var TrackProjectionSchema = _enum(["full", "slim"]);
17616
- /**
17617
- * One audio-classification label heard on the track's camera while the
17618
- * track was alive, aggregated per label. An "episode" is one persisted
17619
- * audio event (the confident-classification path: score ≥ the device's
17620
- * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
17621
- * one 32 ms inference chunk, so counts stay human-scaled.
17622
- */
17623
- var TrackAudioLabelSchema = object({
17624
- label: string(),
17625
- /** Highest classification score observed across the label's episodes. */
17626
- peakScore: number(),
17627
- /** Number of coalesced audio-event episodes carrying this label. */
17628
- count: number(),
17629
- firstAt: number(),
17630
- lastAt: number()
17625
+ var PipelineSchemaSchema = object({
17626
+ availableEngines: array(AvailableEngineSchema).readonly(),
17627
+ selectedEngine: PipelineEngineChoiceSchema,
17628
+ slots: array(PipelineSlotSchemaSchema).readonly()
17631
17629
  });
17632
- /**
17633
- * How a track was produced. `pipeline` (default / absent) = the spatial
17634
- * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
17635
- * no positions, a single snapshot, and no bbox trajectory at all:
17636
- *
17637
- * - `sensor` — a linked sensor/control device state change.
17638
- * - `audio` — an audio event on the camera itself that was anomalous for
17639
- * THAT camera, loud, and heard while nothing visual was happening (D62).
17640
- *
17641
- * The spatial subsystems (tracker association, occupancy count, re-id /
17642
- * embedding, resurrection) MUST skip every synthetic source. Test for that
17643
- * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
17644
- * check silently readmits every source added after it was written.
17645
- */
17646
- var TrackSourceSchema = _enum([
17647
- "pipeline",
17648
- "sensor",
17649
- "audio"
17650
- ]);
17651
- /**
17652
- * Where a track sits in the RETRAIN lifecycle (D81).
17653
- *
17654
- * - `none` never marked, or un-marked. Evictable.
17655
- * - `staging`the operator wants this track as training material and has not
17656
- * finished with it. **This is the only state retention holds**: the track and
17657
- * everything it owns (object events, crops, keyframes, CLIP vector) survive
17658
- * the device's age window.
17659
- * - `trained` — the retrain page has taken what it needed. The frames it chose
17660
- * were COPIED into the retrain dataset at selection time, so the dataset no
17661
- * longer depends on the track's media and the track becomes EVICTABLE again.
17662
- * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
17663
- * a deliberate action of the retrain page, not a side effect of a checkbox.
17664
- *
17665
- * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
17666
- * the store's filter language has only positive equality and `whereIn` — no
17667
- * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
17668
- * would make the entire pre-column history immortal in one deploy.
17669
- */
17670
- var RetrainStatusSchema = _enum([
17671
- "none",
17672
- "staging",
17673
- "trained"
17674
- ]);
17675
- /**
17676
- * Per-track OPERATOR flags — set by hand from the admin UI or the viewer, never
17677
- * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
17678
- * so the two surfaces cannot drift.
17679
- *
17680
- * **Absent ≠ false.** A track that has never been touched omits the field; an
17681
- * explicitly un-flagged track carries `false`. Legacy rows written before the
17682
- * columns existed read as absent, and a consumer that needs a boolean should say
17683
- * `flag === true`, not `flag !== false`.
17684
- *
17685
- * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
17686
- * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
17687
- * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
17688
- * `trained` track reports `false` while refusing both writes. The boolean is
17689
- * kept because three surfaces drive a toggle off it; anything that needs to tell
17690
- * "never marked" from "already trained" must read `retrainStatus`.
17691
- *
17692
- * `debug` does NOT pin; it is attention, not durability.
17693
- *
17694
- * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
17695
- * A favourited track is skipped by retention the same way `staging` is, but
17696
- * it does not enter `none|staging|trained` and has no staging budget.
17697
- */
17698
- var TrackFlagFields = {
17699
- /** Operator marked this track as training material — i.e. `retrainStatus` is
17700
- * `'staging'`. */
17701
- markForTrain: boolean().optional(),
17702
- /** Operator marked this track for diagnostic attention. */
17703
- debug: boolean().optional(),
17704
- /** Operator favourited this track. Pins it against pruning. */
17705
- favourited: boolean().optional()
17706
- };
17707
- /**
17708
- * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
17709
- * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
17710
- * write patch, and the status is not something the toggle sets — it is what the
17711
- * toggle's boolean is derived from. Absent on an in-RAM track never touched;
17712
- * always present on a persisted row (the column default materialises `'none'`).
17713
- */
17714
- var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
17715
- /**
17716
- * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
17717
- * one flag can never clear the other — the toggles are independent and are
17718
- * driven from three surfaces that do not know about each other.
17719
- */
17720
- var TrackFlagsPatchSchema = object(TrackFlagFields);
17721
- /**
17722
- * The resolved flag state after a write. Both fields are REQUIRED here (absent
17723
- * collapses to `false`) so a caller can drive a toggle's checked state off the
17724
- * mutation result without a re-fetch.
17725
- */
17726
- var TrackFlagsSchema = object({
17727
- trackId: string(),
17728
- markForTrain: boolean(),
17729
- debug: boolean(),
17730
- favourited: boolean(),
17731
- /** The lifecycle state the boolean was derived from. Required here (unlike on
17732
- * a track row) because this shape is only ever produced by the write body,
17733
- * which always knows it — and a surface that has just written needs to render
17734
- * `trained` without a re-fetch. */
17735
- retrainStatus: RetrainStatusSchema
17630
+ var EngineProvisioningSchema = object({
17631
+ runtimeId: _enum([
17632
+ "onnx",
17633
+ "openvino",
17634
+ "coreml",
17635
+ "edgetpu"
17636
+ ]).nullable(),
17637
+ device: string().nullable(),
17638
+ state: _enum([
17639
+ "idle",
17640
+ "installing",
17641
+ "verifying",
17642
+ "ready",
17643
+ "failed"
17644
+ ]),
17645
+ progress: number().optional(),
17646
+ error: string().optional(),
17647
+ nextRetryAt: number().optional(),
17648
+ /**
17649
+ * Gate A (config-correctness gate at engine change): human-readable
17650
+ * config issues surfaced EAGERLY when the node's engine changes — model
17651
+ * substitutions ("chose X, running Y") and zero-build steps ("no model
17652
+ * has a <format> build"). Additive/optional: informational only, never
17653
+ * enforced here `assertEngineReady` (readiness) still gates inference.
17654
+ * Absent/empty when the node-default tree resolves cleanly.
17655
+ */
17656
+ configIssues: array(string()).optional()
17736
17657
  });
17737
- union([literal(1), literal(2)]);
17738
- /**
17739
- * WHO decided a label, and when. Carried per tier so a value can be traced to
17740
- * the step and model that produced it — which is what makes the write rule
17741
- * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
17742
- * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
17743
- *
17744
- * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
17745
- * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
17746
- * `migration:4g` for a value the 4g migration moved from the single-slot era —
17747
- * that value has no provenance, and the write rule lets ANY properly-attributed
17748
- * write of the same tier replace it regardless of score.
17749
- */
17750
- var LabelAttributionSchema = object({
17751
- stepId: string(),
17658
+ var PipelineStepInputSchema = lazy(() => object({
17659
+ addonId: string(),
17752
17660
  modelId: string().optional(),
17753
- decidedAt: number(),
17661
+ enabled: boolean().default(true),
17662
+ children: array(PipelineStepInputSchema).optional(),
17663
+ settings: record(string(), unknown()).optional(),
17664
+ jumpDeviceKey: string().optional()
17665
+ }));
17666
+ var ModelSubstitutionSchema = object({
17667
+ addonId: string(),
17668
+ chosen: string(),
17669
+ running: string(),
17670
+ format: string()
17671
+ });
17672
+ var PipelineValidationIssueSchema = object({
17673
+ addonId: string(),
17674
+ kind: _enum(["unknown-addon", "no-format-build"]),
17675
+ detail: string()
17676
+ });
17677
+ var PipelineValidationResultSchema = object({
17678
+ ok: boolean(),
17679
+ issues: array(PipelineValidationIssueSchema).readonly(),
17680
+ substitutions: array(ModelSubstitutionSchema).readonly(),
17681
+ /** The node's `currentEngine.format` this validation ran against. */
17682
+ format: string()
17683
+ });
17684
+ var ReferenceImageEntrySchema = object({
17685
+ filename: string(),
17686
+ stepIds: array(string()).readonly().optional()
17687
+ });
17688
+ var ReferenceImageBodySchema = object({
17689
+ base64: string(),
17690
+ filename: string()
17691
+ });
17692
+ var ReferenceAudioEntrySchema = object({
17693
+ filename: string(),
17694
+ sizeKb: number()
17695
+ });
17696
+ var ReferenceAudioBodySchema = object({ base64: string() });
17697
+ var AudioBackendSchema = object({
17698
+ id: string(),
17699
+ name: string(),
17700
+ description: string(),
17701
+ available: boolean(),
17754
17702
  /**
17755
- * The GALLERY id behind a recognised tier-2 label — a face-gallery
17756
- * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
17757
- *
17758
- * The text alone is a DISPLAY NAME, and a display name is renameable: a
17759
- * notification rule authored on "Gianluca" stopped matching the moment the
17760
- * operator fixed the spelling in the gallery, and nothing said so. The id is
17761
- * the thing that does not move, so it is what a rule matches on
17762
- * (`NcConditions.identities`) and the text is what a human is shown.
17763
- *
17764
- * Absent when the label names no gallery row — a plate the OCR read but no
17765
- * vehicle claims, a sub-class, a species, any tier-1 value.
17703
+ * Raw classifier labels this backend can emit (e.g. YAMNet's
17704
+ * 521-class set or Apple SoundAnalysis's 303-class set). Used by
17705
+ * the benchmark UI to populate the `enabledMicroClasses` filter
17706
+ * specific to the selected backend without a separate fetch.
17766
17707
  */
17767
- identityId: string().optional()
17708
+ rawLabels: array(string()).readonly().optional()
17709
+ });
17710
+ var AudioCapabilitiesSchema = object({
17711
+ activeBackend: string(),
17712
+ availableBackends: array(AudioBackendSchema).readonly(),
17713
+ sampleRate: number(),
17714
+ chunkDurationMs: number()
17715
+ });
17716
+ var DownloadModelResultSchema = object({
17717
+ filePath: string(),
17718
+ sizeMB: number(),
17719
+ durationMs: number()
17768
17720
  });
17769
17721
  /**
17770
- * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
17771
- * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
17772
- * track and its events always answer the same question the same way.
17773
- *
17774
- * Two scalar columns, not an array: every consumer wants "the coarse one" or
17775
- * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
17776
- * is tier 2, and each carries its own score + attribution.
17777
- *
17778
- * **Reading it.** What a human should be shown is `subLabel ?? label` — the
17779
- * finest thing known. Before 4g the single `label` column held the finest
17780
- * value, so a consumer that has not been updated reads the tier-1 slot and
17781
- * shows nothing on a species-only row; that is why the migration puts every
17782
- * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
17783
- * and why the read surfaces were changed in the same train.
17784
- *
17785
- * **Writing it.** The slots are independent, which is the whole point: a
17786
- * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
17787
- * migratorius`), so fineness cannot regress by construction. Within a tier the
17788
- * higher score wins. One rule, one implementation — see
17789
- * `pipeline/label-tier.ts` in addon-post-analysis.
17790
- */
17791
- var TieredLabelFields = {
17792
- /** Tier 1 — the sub-class. See {@link LabelTierSchema}. */
17793
- label: string().optional(),
17794
- /** Confidence of the tier-1 value, as reported by the deciding step. */
17795
- labelScore: number().optional(),
17796
- /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
17797
- labelMeta: LabelAttributionSchema.optional(),
17798
- /** Tier 2 — the instance. See {@link LabelTierSchema}. */
17799
- subLabel: string().optional(),
17800
- /** Confidence of the tier-2 value, as reported by the deciding step. */
17801
- subLabelScore: number().optional(),
17802
- /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
17803
- subLabelMeta: LabelAttributionSchema.optional()
17804
- };
17805
- /** Per-camera slice of a training-export estimate. */
17806
- var TrainingExportDeviceTotalsSchema = object({
17807
- deviceId: number(),
17808
- tracks: number().int(),
17809
- files: number().int(),
17810
- bytes: number().int()
17811
- });
17812
- /**
17813
- * What a training export WOULD contain. Computed from media index rows only —
17814
- * no blob is read to produce this.
17722
+ * Wrapper carrying a single test run's result. Replaces the legacy
17723
+ * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
17724
+ * canonical `AudioResult` from the Phase 6 output rework: one
17725
+ * `AudioDetection` per class above `minScore`, top-N candidates in
17726
+ * `debug.alternateLabels['audio-classifier']`, per-source timings in
17727
+ * `debug.stepTimings`. The outer `success`/`error` fields stay so the
17728
+ * benchmark UI can still report a clean failure when the classifier
17729
+ * cap isn't available.
17815
17730
  */
17816
- var TrainingExportSummarySchema = object({
17817
- generatedAt: number(),
17818
- trackCount: number().int(),
17819
- fileCount: number().int(),
17820
- byteCount: number().int(),
17821
- /** More marked tracks exist than a single pass carries. */
17822
- truncated: boolean(),
17823
- devices: array(TrainingExportDeviceTotalsSchema).readonly()
17731
+ var AudioTestResultSchema = object({
17732
+ success: boolean(),
17733
+ error: string().optional(),
17734
+ frame: custom().optional()
17824
17735
  });
17825
- var TrackSchema = object({
17826
- trackId: string(),
17827
- deviceId: number(),
17828
- className: string(),
17829
- ...TieredLabelFields,
17830
- producingDeviceName: string().optional(),
17831
- /** Track provenance. Absent `pipeline` (legacy rows). */
17832
- source: TrackSourceSchema.optional(),
17833
- firstSeen: number(),
17834
- lastSeen: number(),
17835
- /** Frame-rate position history (subject to maxPositionHistory cap). */
17836
- positions: array(TrackPositionSchema).readonly(),
17837
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
17838
- * saveThumbnails policy). */
17839
- snapshots: array(TrackSnapshotSchema).readonly(),
17840
- /** Deduplicated zones the track has entered at least once. Zone IDS. */
17841
- zonesVisited: array(string()).readonly(),
17736
+ var PipelineConfigBridge = custom();
17737
+ var ConfigUISchemaBridge = custom();
17738
+ var ConfigUISchemaNullableBridge = custom();
17739
+ var InferenceCapabilitiesBridge = custom();
17740
+ var ModelAvailabilityListBridge = custom();
17741
+ var PipelineRunResultBridge = custom();
17742
+ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
17743
+ modelId: string(),
17744
+ settings: record(string(), unknown()).readonly()
17745
+ }))), method(object({ steps: record(string(), object({
17746
+ modelId: string(),
17747
+ settings: record(string(), unknown()).readonly()
17748
+ })) }), object({ success: literal(true) }), {
17749
+ kind: "mutation",
17750
+ auth: "admin"
17751
+ }), method(object({ nodeId: string() }), object({
17752
+ success: literal(true),
17753
+ clearedDevices: number()
17754
+ }), {
17755
+ kind: "mutation",
17756
+ auth: "admin"
17757
+ }), method(object({ nodeId: string() }), object({ unhealthy: array(object({
17758
+ /** `<backend>:<device>`, e.g. `openvino:gpu`. */
17759
+ deviceKey: string(),
17842
17760
  /**
17843
- * Human NAMES for {@link zonesVisited}, resolved at READ time against the
17844
- * `zones` capability.
17845
- *
17846
- * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
17847
- * and no card can render — so every free-text search surface was structurally
17848
- * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
17849
- * just returned nothing. Resolving here rather than in each client keeps ONE
17850
- * derivation and costs the clients no extra call (the `zones` cap is
17851
- * per-device, so a client-side resolve would be a per-camera fan-out on a
17852
- * surface built to avoid exactly that).
17853
- *
17854
- * Resolved, never invented: a zone deleted since the track was written has no
17855
- * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
17856
- * two are not positionally aligned. Absent when the track visited no zone, or
17857
- * when the zone catalogue could not be read.
17761
+ * `failed` the per-device restart budget is exhausted; no pool
17762
+ * will be spawned until an operator re-arms it or the runner
17763
+ * respawns. `backoff` — under budget, waiting out the backoff (or
17764
+ * a cached pool observed dead and not yet condemned).
17858
17765
  */
17859
- zoneNames: array(string()).readonly().optional(),
17860
- /** Deduplicated set of detector classes observed for this track over its
17861
- * life (a track may be reclassified, e.g. person→vehicle). Absent on
17862
- * legacy rows written before class accumulation shipped. */
17863
- classes: array(string()).readonly().optional(),
17864
- /** Cumulative normalized distance travelled (0..1 units = full frame width). */
17865
- totalDistance: number(),
17866
- state: TrackStateSchema,
17867
- active: boolean(),
17868
- /** Deterministic key-event importance score in [0,1] (server-computed at
17869
- * track expiry, recomputed on late label). Absent on legacy rows written
17870
- * before scoring shipped — consumers degrade to absence / compute-on-read. */
17871
- importance: number().optional(),
17872
- /** Id of the track's highest-confidence ObjectEvent (its representative
17873
- * "best" frame). Absent when the track produced no object events. */
17874
- bestEventId: string().optional(),
17875
- /** Tag of the importance sub-signal that dominated the score
17876
- * (identity|dwell|proximity|class|confidence|travel|zone). */
17877
- importanceReason: string().optional(),
17878
- /** Audio-classification labels heard on the camera during the track's
17879
- * life (score ≥ device `classificationMinScore`), aggregated per label.
17880
- * Absent on legacy rows / tracks with no confident audio. */
17881
- audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
17882
- /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
17883
- * Populated from the persisted envelope columns on historical reads;
17884
- * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
17885
- envelope: TrackEnvelopeSchema.optional(),
17766
+ state: _enum(["failed", "backoff"]),
17767
+ /** Epoch ms of the death that produced this state. */
17768
+ since: number(),
17769
+ /** Pool deaths inside the current window. */
17770
+ deaths: number(),
17771
+ /** The last death's message. */
17772
+ lastError: string()
17773
+ })).readonly() })), method(object({
17774
+ nodeId: string(),
17775
+ deviceKey: string()
17776
+ }), object({ rearmed: boolean() }), {
17777
+ kind: "mutation",
17778
+ auth: "admin"
17779
+ }), 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({
17780
+ name: string(),
17781
+ steps: array(PipelineTemplateStepSchema).readonly(),
17782
+ engine: PipelineEngineChoiceSchema
17783
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
17784
+ id: string(),
17785
+ name: string().optional(),
17786
+ steps: array(PipelineTemplateStepSchema).readonly().optional()
17787
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
17788
+ addonId: string(),
17789
+ modelId: string(),
17790
+ format: ModelFormatSchema$1
17791
+ }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
17792
+ addonId: string(),
17793
+ modelId: string(),
17794
+ format: ModelFormatSchema$1
17795
+ }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
17796
+ engine: PipelineEngineChoiceSchema.optional(),
17797
+ steps: array(PipelineStepInputSchema).min(1),
17798
+ frame: FrameInputSchema.optional(),
17886
17799
  /**
17887
- * A face DETECTOR found a face on this track — nothing more. It says the
17888
- * detail plane produced a `face` detail; it does NOT say the face was
17889
- * embedded, matched, above `minFacePx`, or that the recognizer was even
17890
- * enabled. Set once and never cleared.
17891
- *
17892
- * **This exists so "face present but not recognised" is expressible.** A
17893
- * recognised identity lands in `subLabel` (attributed to the face chain via
17894
- * `subLabelMeta.stepId`), so before this field a track with an unmatched face
17895
- * and a track with no face at all were byte-identical on the wire and no
17896
- * surface could tell them apart. The read is `hasFace === true && subLabel
17897
- * === undefined`.
17898
- *
17899
- * **Absent ≠ false.** Every row written before the column existed omits it,
17900
- * and so does every server that predates the field — a consumer must test
17901
- * `=== true` and render nothing otherwise, never infer "no face".
17800
+ * Process-local lazy frame. Valid only when caller and provider resolve
17801
+ * in the same execution-group process; split/cross-node callers use
17802
+ * `frame`/`image` inline compatibility instead.
17902
17803
  */
17903
- hasFace: boolean().optional(),
17804
+ frameRef: FrameRefSchema.optional(),
17904
17805
  /**
17905
- * This track has a face row IN THE GALLERY: a crop **and** an embedding a
17906
- * face an operator could ASSIGN to an identity.
17907
- *
17908
- * The STRICT twin of {@link hasFace}, and the pair only earns its keep
17909
- * because the two disagree. `hasFace` is stamped at the TOP of the face
17910
- * branch, before every gate, and means no more than "a face detector produced
17911
- * a face detail". This one is stamped at the single moment the gallery row
17912
- * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
17913
- * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
17914
- * candidate gate, the imageless-track drop (no crop was ever captured) and
17915
- * the crop-store drop. Everything between the detector and that insert can
17916
- * legitimately refuse the face, so a flag written any earlier promises the
17917
- * operator something to assign and delivers nothing.
17918
- *
17919
- * **Independent of recognition.** A face collected but never auto-matched is
17920
- * still assignable — it is in fact the face an operator most wants to reach —
17921
- * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
17922
- * `subLabel`; this says only that the raw material exists.
17923
- *
17924
- * **Set once, never cleared.** A track that produced a gallery row produced
17925
- * one; deleting the row later is the gallery's business, not this flag's.
17926
- *
17927
- * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
17928
- * before the column omits it, and so does every server that predates the
17929
- * field. A consumer must test `=== true` and render nothing otherwise —
17930
- * never infer "no assignable face".
17806
+ * CB5 shm passthrough a `FrameHandle` naming the same ring slot
17807
+ * the decoded pixels live in. One more member of the one-of
17808
+ * frame/frameHandle/image/imageBase64/referenceImage group.
17931
17809
  */
17932
- hasEmbeddedFace: boolean().optional(),
17810
+ frameHandle: FrameHandleSchema.optional(),
17811
+ imageBase64: string().optional(),
17933
17812
  /**
17934
- * This subject CONTAINS a folded rider a person the rider-pairing step
17935
- * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
17936
- * so the passage is tracked once and as a VEHICLE.
17937
- *
17938
- * It exists because the fold's record was dishonest. D34 and the code both
17939
- * said "the person is not lost — it is reported so both entities stay on the
17940
- * record"; in fact the pair went into a per-processor RAM field behind an
17941
- * accessor nobody called, and every durable surface said `vehicle`, full
17942
- * stop. This is the composition note that makes the row true.
17943
- *
17944
- * A COMPOSITION, never a class and never a label. "This vehicle contains a
17945
- * person" is not an answer to "what is this" — both label tiers would refuse
17946
- * a macro token anyway (D89), and correctly. Nothing here changes what the
17947
- * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
17948
- * and a `person` rule still does not fire for someone cycling past.
17949
- *
17950
- * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
17951
- * the column, and every hub that predates the field, omits it. Test
17952
- * `=== true` and render nothing otherwise — never infer "no rider".
17813
+ * Binary JPEG bytespreferred over `imageBase64` on internal
17814
+ * hops (hub forked worker via Moleculer MsgPack) because it
17815
+ * skips the 33% base64 overhead + the per-call base64 decode on
17816
+ * the detection-pipeline worker. Callers can pass either; exactly
17817
+ * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
17953
17818
  */
17954
- hasRider: boolean().optional(),
17955
- ...TrackFlagFields,
17956
- ...TrackRetrainFields
17957
- });
17958
- var BaseEventFields = {
17959
- id: string(),
17960
- deviceId: number(),
17961
- timestamp: number()
17962
- };
17963
- var MotionEventSchema = object({
17964
- ...BaseEventFields,
17965
- kind: literal("motion"),
17966
- regionCount: number(),
17967
- /** Heavy JSON array omitted in slim projection. */
17968
- regions: array(object({
17969
- bbox: BoundingBoxSchema,
17970
- pixelCount: number(),
17971
- intensity: number()
17972
- })).readonly().optional(),
17973
- /** Omitted in slim projection. */
17974
- frameWidth: number().optional(),
17975
- /** Omitted in slim projection. */
17976
- frameHeight: number().optional(),
17977
- /** Populated by B5 (recording playback URL for this event). */
17978
- mediaUrl: string().optional()
17979
- });
17819
+ image: _instanceof(Uint8Array).optional(),
17820
+ referenceImage: string().optional(),
17821
+ deviceId: number().optional(),
17822
+ sessionId: string().optional(),
17823
+ /**
17824
+ * Execution plane. 'full' (default) runs the whole tree — benchmark,
17825
+ * reference-image, and detail-subtree calls. 'frame' is the live
17826
+ * per-frame dispatch: ONLY root-plane steps run; crop children
17827
+ * (inputClasses ≠ null) are skipped and served per-track via
17828
+ * pipelineRunner.runDetailSubtree (two-plane design).
17829
+ */
17830
+ plane: _enum(["full", "frame"]).optional(),
17831
+ /**
17832
+ * Inference-device selector (Phase 2 multi-device). Format
17833
+ * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
17834
+ * Omitted ⇒ the runner's default device (current single-engine
17835
+ * behaviour). Selects WHICH device pool of the node runs the call.
17836
+ */
17837
+ deviceKey: string().optional(),
17838
+ /**
17839
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
17840
+ * when the parent crop was resolved from the frame's retained NATIVE
17841
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
17842
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
17843
+ * resolution from that surface — the SAME quality path faces already
17844
+ * had — instead of the downscaled parent tile. `handle` keys the native
17845
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
17846
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
17847
+ * the executor's crop-normalized child ROI back into frame-normalized
17848
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
17849
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
17850
+ * (today's behaviour on the fallback path).
17851
+ */
17852
+ nativeCropRef: NativeCropRefSchema.optional()
17853
+ }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
17854
+ engine: PipelineEngineChoiceSchema.optional(),
17855
+ steps: array(PipelineStepInputSchema).min(1),
17856
+ frames: array(FrameInputSchema).min(1).max(255),
17857
+ deviceId: number().optional(),
17858
+ sessionId: string().optional(),
17859
+ /**
17860
+ * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
17861
+ * the batch to the Python pool's bench preprocess cache
17862
+ * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
17863
+ * preprocessed ONCE and every later inference is a pure-inference cache
17864
+ * hit — the sustained-throughput run measures inference, not
17865
+ * decode+preprocess+infer. Omitted/0 for live frames (all different →
17866
+ * full preprocess every call, correct). Fresh per sustained run;
17867
+ * released via `uncacheFrame`.
17868
+ */
17869
+ frameId: number().int().nonnegative().optional(),
17870
+ /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
17871
+ deviceKey: string().optional()
17872
+ }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
17873
+ data: _instanceof(Uint8Array),
17874
+ width: number().int().positive(),
17875
+ height: number().int().positive(),
17876
+ format: _enum([
17877
+ "rgb",
17878
+ "bgr",
17879
+ "gray"
17880
+ ])
17881
+ }), object({
17882
+ frameId: number(),
17883
+ width: number(),
17884
+ height: number()
17885
+ }), { kind: "mutation" }), method(object({
17886
+ stepId: string(),
17887
+ frameId: number().int()
17888
+ }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
17889
+ batchMode: string(),
17890
+ windowMs: number(),
17891
+ maxBatchSize: number(),
17892
+ concurrency: number()
17893
+ })), method(_void(), array(object({
17894
+ engineKey: string(),
17895
+ engine: PipelineEngineChoiceSchema,
17896
+ modelsLoaded: array(string()).readonly(),
17897
+ inUseByCameras: array(number()).readonly(),
17898
+ /**
17899
+ * Origin of this resident factory.
17900
+ * - `runtime` — main camera-serving engine (no idle TTL).
17901
+ * - `warm-override` — benchmark/test override held in the warm
17902
+ * cache; auto-disposed after the idle TTL.
17903
+ * - `device-pool` — a concurrent per-device pool (Phase 2
17904
+ * multi-device, keyed by `deviceKey`) resolved
17905
+ * via `resolveDeviceFactory`. Runs alongside the
17906
+ * `runtime` engine on a DIFFERENT accelerator
17907
+ * (NPU / iGPU / Coral) — this is how the
17908
+ * Engines tab shows all pools running at once.
17909
+ */
17910
+ kind: _enum([
17911
+ "runtime",
17912
+ "warm-override",
17913
+ "device-pool"
17914
+ ]),
17915
+ /** Native pid of the underlying Python pool (null when no pool). */
17916
+ poolPid: number().nullable(),
17917
+ /** ms since this factory was last used (null when not warm-tracked). */
17918
+ idleMs: number().nullable(),
17919
+ /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
17920
+ idleTtlMs: number().nullable()
17921
+ })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
17922
+ kind: "mutation",
17923
+ auth: "admin"
17924
+ }), method(object({
17925
+ engine: PipelineEngineChoiceSchema,
17926
+ force: boolean().optional()
17927
+ }), object({
17928
+ success: boolean(),
17929
+ reason: string().optional()
17930
+ }), {
17931
+ kind: "mutation",
17932
+ auth: "admin"
17933
+ }), 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({
17934
+ addonId: string(),
17935
+ modelId: string(),
17936
+ filename: string().optional(),
17937
+ settings: record(string(), unknown()).optional()
17938
+ }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
17980
17939
  /**
17981
- * Which detection SOURCE produced an object event. `pipeline` = the ML
17982
- * detection pipeline (decoded-frame inference); `onboard` = the camera's
17983
- * native on-device AI. Both flow through the SAME analysis layers (zoning,
17984
- * tracking, per-kind persistence) but stay distinguishable so consumers
17985
- * (advanced-notifier, occupancy, …) can select which source(s) to act on.
17986
- * Absent on legacy rows treat as `pipeline`.
17940
+ * Per-stage gating mode applied to the zones a rule references.
17941
+ *
17942
+ * - `include`: the rule contributes to a **whitelist** for its stage.
17943
+ * When at least one `include` rule fires for a stage, only entities
17944
+ * inside one of those zones pass that stage.
17945
+ * - `exclude`: the rule contributes to a **blacklist** for its stage.
17946
+ * Entities inside one of those zones are dropped at that stage.
17947
+ *
17948
+ * `monitor`-style observation (count without filtering) is not a rule
17949
+ * mode — zones without any matching rule are observed naturally by
17950
+ * `zone-analytics` (live snapshot + history), so an "I just want to
17951
+ * count, not filter" use case needs no rule at all.
17987
17952
  */
17988
- var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
17953
+ var ZoneRuleModeEnum = _enum(["include", "exclude"]);
17989
17954
  /**
17990
- * The confirmed zone crossing that produced an object event. Present ONLY on
17991
- * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
17992
- * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
17993
- * appearance event carry none, so a rule asking for a direction fails closed
17994
- * on them.
17955
+ * Per-consumer rule that references existing zones (geometry) and
17956
+ * defines how a specific pipeline stage should treat them. Each
17957
+ * consumer addon owns its own `ZoneRule[]` array in its per-device
17958
+ * settings:
17995
17959
  *
17996
- * Exactly ONE crossing per event: the emitter turns each confirmed crossing
17997
- * into its own event, so a frame in which a track enters A while leaving B
17998
- * produces two events with two directions — never one ambiguous row.
17960
+ * - `addon-motion-wasm` `motionZoneRules: ZoneRule[]` (motion stage)
17961
+ * - `addon-detection-pipeline` `detectionZoneRules: ZoneRule[]` (detection stage)
17962
+ * - future: notification rules, audio gating, etc.
17999
17963
  *
18000
- * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
18001
- * membership the box has NOW, and by definition it no longer contains the zone
18002
- * that was just left. Without the id here, a zone-scoped rule could never match
18003
- * the exit it asked for.
17964
+ * One rule applies to N zones (`zoneIds[]`) so the operator can
17965
+ * express "ignore motion in ALL of {garden, street}" with a single
17966
+ * rule. `classFilter` narrows the rule to specific object classes
17967
+ * "drop person detections in the street, but keep cars" is one
17968
+ * `exclude` rule with `classFilter: ['person']`.
17969
+ *
17970
+ * `enabled` is a soft toggle — the operator can keep the rule
17971
+ * configured but inert without deleting it.
18004
17972
  */
18005
- var ZoneCrossingSchema = object({
18006
- direction: _enum(["enter", "exit"]),
18007
- /** Admin zone id crossed. */
18008
- zoneId: string(),
18009
- /** Zone display name at crossing time (falls back to the id). */
18010
- zoneName: string().optional()
18011
- });
18012
- var ObjectEventSchema = object({
18013
- ...BaseEventFields,
18014
- kind: literal("object"),
18015
- /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
18016
- source: DetectionSourceSchema.optional(),
17973
+ var ZoneRuleSchema = object({
17974
+ /** Stable rule id — survives edits, used by the UI for diffing. */
17975
+ id: string(),
17976
+ /** Optional human-readable label rendered in the rule editor. */
17977
+ name: string().optional(),
17978
+ /** Zones this rule targets. The rule's `mode` applies to ALL
17979
+ * listed zones (OR-set: a detection in any one of them counts).
17980
+ * At least one zone id required — a rule with no targets is a
17981
+ * configuration mistake and the form validator rejects it. */
17982
+ zoneIds: array(string()).min(1).readonly(),
17983
+ mode: ZoneRuleModeEnum,
18017
17984
  /**
18018
- * Inference-frame id shared by every object event emitted from the SAME frame
18019
- * the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
18020
- * 2 people + 1 dog) under one full frame, and link a track's frames over time
18021
- * (group by `trackId`, pick a representative `frameId` as the parent frame).
18022
- * Optional for backward-compat with pre-existing rows / the slim projection
18023
- * includes it (it is light). Absent on rows written before this field.
17985
+ * Class names this rule applies to. Empty / undefined rule
17986
+ * applies to every class. Class strings match the `macroClass`
17987
+ * field on detections (e.g. `person`, `car`, `dog`).
18024
17988
  */
18025
- frameId: string().optional(),
18026
- /** Omitted in slim projection. */
18027
- trackId: string().optional(),
18028
- className: string(),
18029
- ...TieredLabelFields,
18030
- /** Omitted in slim projection. */
18031
- confidence: number().optional(),
18032
- /** Heavy JSON — omitted in slim projection. */
18033
- bbox: BoundingBoxSchema.optional(),
18034
- /** Heavy JSON — omitted in slim projection. */
18035
- zones: array(string()).readonly().optional(),
18036
- /** Omitted in slim projection. */
18037
- state: TrackStateSchema.optional(),
17989
+ classFilter: array(string()).readonly().optional(),
18038
17990
  /**
18039
- * The zone crossing this event IS, when it is one. Absent on every other
18040
- * event kind (movement state, appearance, package) see
18041
- * {@link ZoneCrossingSchema}. Omitted in slim projection.
17991
+ * Minimum bbox/mask overlap (0–1) with any of the rule's zones
17992
+ * required to consider an entity "in the zone". Defaults to the
17993
+ * consumer's stage default when omitted. Kept for back-compat with
17994
+ * existing per-rule overrides; new operators pick the value via
17995
+ * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
17996
+ * set, the lower-level engine reads it as a 0–1 fraction.
18042
17997
  */
18043
- zoneCrossing: ZoneCrossingSchema.optional(),
18044
- /** Detection-frame dimensions in pixels — let consumers normalize the
18045
- * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
18046
- frameWidth: number().optional(),
18047
- frameHeight: number().optional(),
18048
- /** MediaStore key for the crop attached to this event (if any). */
18049
- mediaKey: string().optional(),
18050
- /** Design B: MediaStore key of the track's native-resolution key frame (the
18051
- * best-detection full frame). Resolve via the event-media data-plane
18052
- * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
18053
- * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
18054
- * sources — consumers fall back to `mediaKey` (the tight crop). */
18055
- keyFrameMediaKey: string().optional(),
18056
- /** Populated by B5 (recording playback URL for this event). */
18057
- mediaUrl: string().optional(),
18058
- /** The parent track's key-event importance [0,1], propagated to every object
18059
- * event of the track (so an event row can be sorted by importance without a
18060
- * track join). Absent on legacy rows / before the track was scored. */
18061
- importance: number().optional()
18062
- });
18063
- var AudioEventSchema = object({
18064
- ...BaseEventFields,
18065
- kind: literal("audio"),
18066
- rms: number(),
18067
- dbfs: number(),
18068
- classification: object({
18069
- className: string(),
18070
- originalClass: string().optional(),
18071
- score: number()
18072
- }).optional(),
18073
- /** Populated by B5 (recording playback URL for this event). */
18074
- mediaUrl: string().optional()
17998
+ overlapThreshold: number().min(0).max(1).optional(),
17999
+ /**
18000
+ * Operator-friendly version of `overlapThreshold` the percentage
18001
+ * of the detection's bbox that must lie inside the zone for the
18002
+ * rule to match. Documented default is 85%; the engine substitutes
18003
+ * that when the field is omitted (kept optional so existing rules
18004
+ * stored without it stay valid).
18005
+ *
18006
+ * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
18007
+ * rule, the engine prefers `bboxInclusionPct` because it's the
18008
+ * field exposed in the UI. Internally both feed the same gate.
18009
+ */
18010
+ bboxInclusionPct: number().min(0).max(100).optional(),
18011
+ /**
18012
+ * When `true` and a detection has a segmentation mask, use the
18013
+ * mask for overlap instead of the bbox. Detection-stage only;
18014
+ * motion rules ignore this field.
18015
+ */
18016
+ preferMask: boolean().optional(),
18017
+ /**
18018
+ * Soft-toggle: `false` disables the rule without deleting it.
18019
+ * Defaults to `true` so operators creating a rule via the UI
18020
+ * see it active immediately.
18021
+ */
18022
+ enabled: boolean().default(true)
18075
18023
  });
18076
- var MediaFileKindEnum = _enum([
18077
- "crop",
18078
- "thumbnail",
18079
- "snapshot",
18080
- "firstFrame",
18081
- "lastFrame",
18082
- "fullFrame",
18083
- "fullFrameBoxed",
18084
- "faceCrop",
18085
- "plateCrop",
18086
- "keyFrame",
18087
- "keyFrameSmall",
18088
- "thumbnailSmall"
18089
- ]);
18090
- var MediaFileSchema = object({
18091
- key: string(),
18092
- kind: MediaFileKindEnum,
18093
- base64: string(),
18094
- sizeBytes: number(),
18095
- timestamp: number()
18024
+ array(ZoneRuleSchema).readonly();
18025
+ /**
18026
+ * Zone — pure geometry + identity. NO filtering behaviour.
18027
+ *
18028
+ * Zones describe **where** in the frame the operator wants to flag
18029
+ * something; consumer-owned {@link ZoneRule} arrays describe **how**
18030
+ * each pipeline stage uses them. Splitting the two means a single
18031
+ * polygon "Driveway" can simultaneously back a motion-exclude rule,
18032
+ * a detection-include rule on `['car']`, and an occupancy aggregate
18033
+ * — without three duplicated polygons.
18034
+ *
18035
+ * Owned by the orchestrator addon (provider) and mirrored into the
18036
+ * `zones` device-state slice on every mutation. Consumers
18037
+ * (motion-wasm, pipeline-executor, analytics, admin UI) read either
18038
+ * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
18039
+ * mirror with `onChanged`).
18040
+ *
18041
+ * Coordinates are normalised fractions of the frame (0–1) so zones
18042
+ * survive resolution changes and stream profile switches.
18043
+ *
18044
+ * `kind` discriminates between full polygons (closed regions used
18045
+ * for intrusion / occupancy filters) and tripwires (open 2-point
18046
+ * line segments used for cross events). Onboard / firmware-reported
18047
+ * zones (Reolink, ONVIF) are out of scope for now — see the deferred
18048
+ * task list.
18049
+ */
18050
+ var ZoneKindEnum = _enum(["polygon", "tripwire"]);
18051
+ /** Polygon vertex in fraction-of-frame coordinates (0–1). */
18052
+ var PolygonPointSchema = object({
18053
+ x: number(),
18054
+ y: number()
18055
+ });
18056
+ /** A camera detection zone — pure geometry/identity. */
18057
+ var ZoneSchema = object({
18058
+ id: string(),
18059
+ name: string(),
18060
+ kind: ZoneKindEnum.default("polygon"),
18061
+ /** Polygon vertices, fraction of frame (0–1). */
18062
+ polygon: array(PolygonPointSchema).readonly(),
18063
+ /** Visual color for UI rendering. */
18064
+ color: string().default("#3b82f6")
18096
18065
  });
18097
18066
  /**
18098
- * One media row WITHOUT its bytes.
18067
+ * Zones capability per-camera CRUD over polygon detection zones.
18099
18068
  *
18100
- * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
18101
- * 140 s track), and a client that renders tiles from the media data plane needs
18102
- * to know only WHAT EXISTS the bytes then arrive per tile, lazily, over HTTP
18103
- * with an immutable cache, instead of all at once inside a tRPC response that
18104
- * blocks the whole view.
18069
+ * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
18070
+ * to per-device settings and mirrors into the `zones` device-state
18071
+ * slice on every mutation, so downstream consumers can subscribe via
18072
+ * `dev.state.zones.onChanged`.
18105
18073
  *
18106
- * `sizeBytes` is carried because it is what lets a client decide between the
18107
- * stored blob and a `?variant=thumb` rendering without fetching either.
18074
+ * The cap surface only handles geometry + identity; filtering
18075
+ * behaviour (per-class, include/exclude, threshold) lives in the
18076
+ * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
18077
+ * `capabilities/schemas/zone-rule.js`.
18108
18078
  */
18109
- var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
18079
+ var zonesCapability = {
18080
+ name: "zones",
18081
+ scope: "device",
18082
+ mode: "singleton",
18083
+ deviceTypes: [DeviceType.Camera],
18084
+ methods: {
18085
+ listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
18086
+ addZone: method(object({
18087
+ deviceId: number(),
18088
+ zone: ZoneSchema
18089
+ }), _void(), {
18090
+ kind: "mutation",
18091
+ auth: "admin"
18092
+ }),
18093
+ removeZone: method(object({
18094
+ deviceId: number(),
18095
+ zoneId: string()
18096
+ }), _void(), {
18097
+ kind: "mutation",
18098
+ auth: "admin"
18099
+ }),
18100
+ updateZone: method(object({
18101
+ deviceId: number(),
18102
+ zone: ZoneSchema
18103
+ }), _void(), {
18104
+ kind: "mutation",
18105
+ auth: "admin"
18106
+ })
18107
+ },
18108
+ /**
18109
+ * Runtime-state slice — the live zone catalogue mirrored by the
18110
+ * orchestrator on every CRUD mutation. Consumers read via
18111
+ * `device.state.zones.value` / `.watch(...)` without round-tripping
18112
+ * the cap, and the codegen DeviceProxy auto-wires the reactive
18113
+ * handle. Slice shape is `{ zones: Zone[] }` so future extensions
18114
+ * (e.g. zone groupings) can sit alongside the polygon list.
18115
+ */
18116
+ runtimeState: object({ zones: array(ZoneSchema).readonly() }),
18117
+ /**
18118
+ * 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.
18119
+ *
18120
+ * See `RuntimeStateDurability`. Enforced by
18121
+ * `scripts/check-runtime-state-durability.ts`.
18122
+ */
18123
+ durability: "restored"
18124
+ };
18110
18125
  /**
18111
- * The MACRO tier of an annotation — a CLOSED set.
18126
+ * pipeline-analytics device-scoped wrapper cap. Refines raw
18127
+ * per-frame detections emitted by the pipeline runner into tracked
18128
+ * objects, per-kind event collections (motion / object / audio), and
18129
+ * persisted media. Owns the post-detection domain end-to-end:
18112
18130
  *
18113
- * This is what the exported detector predicts, so a typo here is a new class
18114
- * with one example in it. `label` and `subLabel` are open strings by contrast:
18115
- * the whole point of the page is teaching the model things it does not know
18116
- * yet, and constraining that vocabulary would make it useless.
18131
+ * runner emits PipelineInferenceResult
18132
+ * (event bus)
18133
+ * pipeline-analytics subscriber
18134
+ * SORT tracker + zone engine + state analyzer + event emitter
18135
+ * → three DB collections (one per kind), one FS media tree, one
18136
+ * unified event emitter (FrameTracked + TrackStarted/Ended +
18137
+ * DetectionEvent on bus)
18117
18138
  *
18118
- * A macro class is NEVER a label. The provider refuses a write whose `label` or
18119
- * `subLabel` is one of these values, in any casing, because once `person`
18120
- * exists in both tiers "every person box" stops being answerable without
18121
- * knowing every string anyone ever typed — and the damage is retroactive.
18139
+ * Pure subscriber model. No `processFrame` cap method the runner
18140
+ * already publishes the raw frame on the bus. The cap surface is
18141
+ * only QUERIES + per-device settings, bound on/off via
18142
+ * `device-manager.setWrapperActive`. `defaultActive: true` because
18143
+ * every camera with a detection pipeline wants its raw detections
18144
+ * refined; operators opt out per-device via BindingsTab when needed.
18145
+ *
18146
+ * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
18147
+ * (per-device surface) and `track-trail` caps — see P11 cleanup.
18122
18148
  */
18123
- var RetrainMacroClassSchema = _enum([
18149
+ var TrackStateSchema = _enum([
18150
+ "new",
18151
+ "entered",
18152
+ "left",
18153
+ "moving",
18154
+ "idle"
18155
+ ]);
18156
+ var EventKindSchema = _enum([
18157
+ "motion",
18158
+ "object",
18159
+ "audio"
18160
+ ]);
18161
+ /**
18162
+ * Spatial filter for `listTracks` — the rect + polygon variants of the shared
18163
+ * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
18164
+ * of the camera frame (top-left origin), matching the drawing-plane editor.
18165
+ */
18166
+ var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
18167
+ /** Closed icon vocabulary so clients render a known glyph per kind. */
18168
+ var EventKindIconSchema = _enum([
18169
+ "motion",
18170
+ "audio",
18124
18171
  "person",
18125
18172
  "vehicle",
18126
18173
  "animal",
18174
+ "door",
18175
+ "pir",
18176
+ "smoke",
18177
+ "water",
18178
+ "button",
18127
18179
  "package",
18128
- "face",
18129
- "plate"
18180
+ "generic"
18130
18181
  ]);
18131
- /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
18132
- var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
18133
- /** Did a human draw this box, or did the assist propose it? */
18134
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
18135
- /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
18136
- var RetrainBboxSchema = object({
18137
- x: number(),
18138
- y: number(),
18139
- w: number(),
18140
- h: number()
18141
- });
18142
- /**
18143
- * One annotated subject.
18144
- *
18145
- * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
18146
- * (letterboxed root / zone-cropped package / subject-cropped classifier) are
18147
- * derived from it at export and never stored storing them is how one feature
18148
- * space ends up holding two crops of the same subject (D52).
18149
- */
18150
- var RetrainAnnotationSchema = object({
18151
- id: string(),
18152
- trackId: string(),
18153
- deviceId: number(),
18154
- /** The COPY in retrain storage — never the source track's media key. */
18155
- mediaKey: string(),
18156
- bbox: RetrainBboxSchema,
18157
- macroClass: RetrainMacroClassSchema,
18158
- label: string().optional(),
18159
- subLabel: string().optional(),
18160
- kind: RetrainAnnotationKindSchema,
18161
- source: RetrainAnnotationSourceSchema,
18162
- /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
18163
- assistModelId: string().optional(),
18164
- assistScore: number().optional(),
18165
- exportedInBatch: string().optional(),
18166
- createdAt: number()
18167
- });
18168
- /** The write form — the server owns `id`, `createdAt` and the frame binding. */
18169
- var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
18170
- id: true,
18171
- trackId: true,
18172
- deviceId: true,
18173
- mediaKey: true,
18174
- createdAt: true,
18175
- exportedInBatch: true
18182
+ var EventKindCategorySchema = _enum([
18183
+ "motion",
18184
+ "audio",
18185
+ "detection",
18186
+ "sensor",
18187
+ "control",
18188
+ "custom",
18189
+ "package"
18190
+ ]);
18191
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
18192
+ var EventKindLevelSchema = _enum(["macro", "sub"]);
18193
+ var EventKindDescriptorSchema = object({
18194
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
18195
+ kind: string(),
18196
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
18197
+ labelKey: string(),
18198
+ /** English fallback label (kept for clients that don't translate). */
18199
+ label: string(),
18200
+ /** Hex color for timeline/legend rendering. */
18201
+ color: string(),
18202
+ /** Dictionary id → lucide component on the UI side. */
18203
+ iconId: string(),
18204
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
18205
+ icon: EventKindIconSchema,
18206
+ category: EventKindCategorySchema,
18207
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
18208
+ parentKind: string().nullable(),
18209
+ /** Derived from `parentKind`, explicit for the client tree. */
18210
+ level: EventKindLevelSchema,
18211
+ /** Which cap + device contributes this kind. For built-ins the camera
18212
+ * itself; for sensor kinds the LINKED source device. */
18213
+ source: object({
18214
+ capName: string(),
18215
+ deviceId: number()
18216
+ })
18176
18217
  });
18177
- /** A track sitting in `staging`, with everything the worklist needs to rank it. */
18178
- var RetrainTrackSchema = object({
18179
- trackId: string(),
18218
+ /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
18219
+ var EventKindsForDeviceSchema = object({
18180
18220
  deviceId: number(),
18181
- className: string(),
18182
- label: string().optional(),
18183
- firstSeen: number(),
18184
- lastSeen: number(),
18185
- /** How many frames the dataset already holds from this track. */
18186
- frameCount: number().int(),
18187
- /** How many subjects have been annotated on those frames. `0` with
18188
- * `frameCount: 0` is exactly "staging, still to work". */
18189
- annotationCount: number().int()
18190
- });
18191
- /** A frame the picker may offer — an index row, no blob was read to produce it. */
18192
- var RetrainFrameCandidateSchema = object({
18193
- mediaKey: string(),
18194
- kind: MediaFileKindEnum,
18195
- timestamp: number(),
18196
- sizeBytes: number().int(),
18197
- /** A copy of this original already exists — selecting it is free and cannot
18198
- * fail, whatever became of the original. */
18199
- copied: boolean()
18221
+ kinds: array(EventKindDescriptorSchema).readonly()
18200
18222
  });
18201
- /** A frame the dataset OWNS: bytes copied at selection time. */
18202
- var RetrainFrameSchema = object({
18203
- frameId: string(),
18223
+ var SensorEventSchema = object({
18224
+ id: string(),
18225
+ /** The CAMERA the event is attributed to (a sensor linked to N cameras
18226
+ * yields N rows, one per camera). */
18204
18227
  deviceId: number(),
18205
- trackId: string(),
18206
- /** Provenance only. It may already point at nothing — that is expected. */
18207
- sourceMediaKey: string(),
18208
- sourceKind: MediaFileKindEnum,
18209
- sizeBytes: number().int(),
18210
- width: number().int(),
18211
- height: number().int(),
18212
- copiedAt: number()
18228
+ /** The linked sensor device whose state changed. */
18229
+ sourceDeviceId: number(),
18230
+ /** Event kind id — matches an `EventKindDescriptor.kind`. */
18231
+ kind: string(),
18232
+ /** Snapshot of the sensor cap's runtime-state slice at the change. */
18233
+ value: record(string(), unknown()).nullable(),
18234
+ timestamp: number()
18213
18235
  });
18214
- /** Why a copy-on-select could not be honoured — named, never a silent skip. */
18215
- var RetrainCopyRefusalSchema = _enum([
18216
- "source-missing",
18217
- "unreadable-image",
18218
- "write-failed"
18219
- ]);
18220
- var RetrainFrameSelectionSchema = object({
18221
- copied: array(RetrainFrameSchema).readonly(),
18222
- refused: array(object({
18223
- sourceMediaKey: string(),
18224
- reason: RetrainCopyRefusalSchema
18225
- })).readonly()
18236
+ var TrackPositionSchema = object({
18237
+ x: number(),
18238
+ y: number(),
18239
+ timestamp: number(),
18240
+ bbox: BoundingBoxSchema
18226
18241
  });
18227
- var RetrainFrameListSchema = object({
18228
- candidates: array(RetrainFrameCandidateSchema).readonly(),
18229
- copies: array(RetrainFrameSchema).readonly(),
18230
- /** What the page pre-selects the native key frame when one survives. */
18231
- autoPickMediaKey: string().optional()
18242
+ var TrackSnapshotSchema = object({
18243
+ timestamp: number(),
18244
+ position: TrackPositionSchema,
18245
+ /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
18246
+ mediaKey: string()
18232
18247
  });
18233
- /** What the operator asked the assist to look for. */
18234
- var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
18235
- kind: literal("package"),
18236
- zone: RetrainBboxSchema.optional()
18237
- }), object({
18238
- kind: literal("objects"),
18239
- modelId: string(),
18240
- minScore: number().optional()
18241
- })]);
18242
18248
  /**
18243
- * The assist's answer a discriminated union, because "the model saw nothing"
18244
- * and "this node cannot run that model" lead to different next moves and a
18245
- * nullable result cannot tell them apart.
18249
+ * Normalized 0..1 trajectory envelope (min/max over every position bbox,
18250
+ * divided by the track's detection-frame dims), computed at persist time.
18251
+ * Absent when the frame dims were unknown when the track was persisted
18252
+ * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
18246
18253
  */
18247
- var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
18248
- kind: literal("proposed"),
18249
- modelId: string(),
18250
- stepId: string(),
18251
- minScore: number(),
18252
- /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
18253
- proposals: array(RetrainAnnotationDraftSchema).readonly(),
18254
- /** Returned by the runner but removed by the threshold. */
18255
- belowThreshold: number().int()
18256
- }), object({
18257
- kind: literal("refused"),
18258
- /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
18259
- reason: string(),
18260
- detail: string().optional()
18261
- })]);
18262
- /** The outcome of a lifecycle move owned by the retrain page. */
18263
- var RetrainTransitionResultSchema = object({
18264
- trackId: string(),
18265
- /** Where the track ended up, whatever happened. */
18266
- retrainStatus: RetrainStatusSchema,
18267
- /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
18268
- changed: boolean(),
18269
- reason: _enum([
18270
- "unknown-track",
18271
- "no-frames-copied",
18272
- "not-staging",
18273
- "not-trained",
18274
- "unchanged"
18275
- ]).optional()
18276
- });
18277
- var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
18278
- var MAX_EVENT_QUERY_LIMIT = 5e3;
18279
- var DeviceEventQueryInput = object({
18280
- deviceId: number(),
18281
- since: number().optional(),
18282
- until: number().optional(),
18283
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
18284
- /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
18285
- * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
18286
- * exact behaviour. Callers may omit this field — the store defaults to
18287
- * `full` when not provided. */
18288
- projection: _enum(["full", "slim"]).optional()
18289
- });
18290
- var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
18291
- var RecentTracksQueryInput = object({
18292
- /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
18293
- deviceIds: array(number()),
18294
- /** Window lower bound on `lastSeen` (inclusive). */
18295
- since: number().optional(),
18296
- /** Window upper bound on `lastSeen` (inclusive). */
18297
- until: number().optional(),
18298
- /** Page size. Default 200, max 1000. */
18299
- limit: number().int().min(1).max(1e3).default(200),
18300
- /** Opaque continuation cursor from a previous page's `nextCursor`.
18301
- * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
18302
- cursor: string().optional(),
18303
- /** See {@link TrackProjectionSchema}. Default `full`. */
18304
- projection: TrackProjectionSchema.optional(),
18305
- /** Include stationary-promoted rows (parked objects). Default false: the
18306
- * feed lists passages; parking records live on the stationary registry. */
18307
- includeStationary: boolean().optional()
18308
- });
18309
- var RecentTracksPageSchema = object({
18310
- /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
18311
- tracks: array(TrackSchema).readonly(),
18312
- /** Cursor for the next page, or null when this page is the last. */
18313
- nextCursor: string().nullable()
18314
- });
18315
- var LIST_GROUPS_DEFAULT_LIMIT = 40;
18316
- var LIST_GROUPS_MAX_LIMIT = 100;
18317
- var AnalyticsGroupRecordSchema = object({
18318
- id: string(),
18319
- deviceId: number().int(),
18320
- openedAt: number().int(),
18321
- closedAt: number().int(),
18322
- timestamp: number().int(),
18323
- memberCount: number().int(),
18324
- memberTrackIds: array(string()).readonly(),
18325
- className: string(),
18326
- classes: array(string()).readonly(),
18327
- /** Relative event-media path, or null when the group has no picture yet. */
18328
- mediaUrl: string().nullable(),
18329
- singleton: boolean()
18254
+ var TrackEnvelopeSchema = object({
18255
+ minX: number(),
18256
+ minY: number(),
18257
+ maxX: number(),
18258
+ maxY: number()
18330
18259
  });
18331
- var AnalyticsGroupMemberSchema = object({
18332
- trackId: string(),
18333
- deviceId: number().int(),
18334
- className: string(),
18335
- firstSeen: number().int(),
18336
- lastSeen: number().int(),
18337
- mediaUrl: string().nullable()
18338
- });
18339
- var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
18340
- var ListGroupsQueryInput = object({
18341
- /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
18342
- deviceIds: array(number()),
18343
- /** Window lower bound on `closedAt` (inclusive). */
18344
- since: number().optional(),
18345
- /** Window upper bound on `openedAt` (inclusive). */
18346
- until: number().optional(),
18347
- limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
18348
- /** Opaque continuation cursor from a previous page's `nextCursor`. */
18349
- cursor: string().optional()
18350
- });
18351
- var ListGroupsPageSchema = object({
18352
- groups: array(AnalyticsGroupRecordSchema).readonly(),
18353
- nextCursor: string().nullable()
18354
- });
18355
- var KeyEventQueryInput = object({
18356
- deviceId: number(),
18357
- /** Window lower bound (track firstSeen ≥ since). */
18358
- since: number(),
18359
- /** Window upper bound (track firstSeen ≤ until). */
18360
- until: number(),
18361
- limit: number().int().min(1).max(200).default(50),
18362
- /** Drop tracks scoring below this importance. */
18363
- minImportance: number().min(0).max(1).optional(),
18364
- /** Restrict to a single class (e.g. 'person'). */
18365
- classFilter: string().optional()
18366
- });
18367
- var KeyEventSchema = object({
18368
- /** The representative event id (the track's best ObjectEvent, else its trackId). */
18369
- id: string(),
18370
- trackId: string(),
18371
- /** Track start time (firstSeen). */
18372
- timestamp: number(),
18373
- className: string(),
18374
- ...TieredLabelFields,
18375
- importance: number(),
18376
- /** Highest-confidence ObjectEvent id for the track (empty when none). */
18377
- bestEventId: string(),
18378
- /** Track lifetime in ms (lastSeen - firstSeen). */
18379
- windowMs: number().optional(),
18380
- ...TrackFlagFields,
18381
- ...TrackRetrainFields
18382
- });
18383
- object({
18384
- trackId: string(),
18385
- className: string(),
18386
- confidence: number(),
18387
- bbox: BoundingBoxSchema,
18388
- zones: array(string()).readonly(),
18389
- state: TrackStateSchema
18390
- });
18391
- var OverlayDetectionSchema = looseObject({
18392
- id: string(),
18393
- kind: _enum(["first-level", "detail"]),
18394
- macroClass: string(),
18395
- score: number(),
18396
- bbox: object({
18397
- x: number(),
18398
- y: number(),
18399
- width: number(),
18400
- height: number()
18401
- }),
18402
- labels: array(looseObject({
18403
- label: string(),
18404
- score: number()
18405
- })).readonly(),
18406
- parentId: string().optional()
18407
- });
18408
- var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
18409
- var SearchObjectEventsInput = object({
18410
- text: string(),
18411
- deviceId: number().optional(),
18412
- since: number().optional(),
18413
- until: number().optional(),
18414
- classFilter: string().optional(),
18415
- limit: number().default(50),
18416
- minScore: number().min(0).max(1).default(.2)
18417
- });
18418
- var TrackCascadeCountsSchema = object({
18419
- /** Persisted track roots deleted (authoritative). */
18420
- tracks: number().int(),
18421
- /** Object events removed with their tracks (best-effort; see note above). */
18422
- events: number().int(),
18423
- /** Track/face/plate-owned media removed (best-effort). Never identity media. */
18424
- media: number().int(),
18425
- /** Unassigned (non-enrolled) face reads removed (best-effort). */
18426
- faces: number().int(),
18427
- /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
18428
- plates: number().int(),
18429
- /** Per-track CLIP search vectors removed (best-effort). */
18430
- embeddings: number().int(),
18431
- /** Group membership + group rows removed with their last member (best-effort). */
18432
- groups: number().int()
18433
- });
18434
- /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
18435
- var DiskReconcileCountsSchema = object({
18436
- mediaDropped: number().int(),
18437
- tracks: number().int(),
18438
- events: number().int()
18439
- });
18440
- /** Event-store footprint for one camera. */
18441
- var EventStoreDeviceFootprintSchema = object({
18442
- deviceId: number(),
18443
- /** Persisted event rows (motion + object + audio) for the camera. */
18444
- rows: number().int(),
18445
- /** Event-owned media bytes on disk for the camera. */
18446
- bytes: number().int()
18447
- });
18448
- /** Aggregate event-store footprint: global totals + per-camera breakdown. */
18449
- var EventStoreFootprintSchema = object({
18450
- totalRows: number().int(),
18451
- totalBytes: number().int(),
18452
- devices: array(EventStoreDeviceFootprintSchema).readonly()
18453
- });
18454
- /** Per-kind counts returned by the event-prune / device-delete mutations. */
18455
- var EventPruneCountsSchema = object({
18456
- motion: number().int(),
18457
- object: number().int(),
18458
- audio: number().int()
18260
+ /**
18261
+ * Row projection for track list queries. `full` (default) returns the
18262
+ * complete Track including the frame-rate `positions[]` history and the
18263
+ * `snapshots[]` references — megabytes across a page of tracks. `slim`
18264
+ * keeps every scalar the list surfaces actually render (ids, class(es),
18265
+ * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
18266
+ * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
18267
+ * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
18268
+ * `getTrack`. Mirrors the event-store `projection` convention
18269
+ * (`getObjectEvents` et al.).
18270
+ */
18271
+ var TrackProjectionSchema = _enum(["full", "slim"]);
18272
+ /**
18273
+ * One audio-classification label heard on the track's camera while the
18274
+ * track was alive, aggregated per label. An "episode" is one persisted
18275
+ * audio event (the confident-classification path: score ≥ the device's
18276
+ * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
18277
+ * one 32 ms inference chunk, so counts stay human-scaled.
18278
+ */
18279
+ var TrackAudioLabelSchema = object({
18280
+ label: string(),
18281
+ /** Highest classification score observed across the label's episodes. */
18282
+ peakScore: number(),
18283
+ /** Number of coalesced audio-event episodes carrying this label. */
18284
+ count: number(),
18285
+ firstAt: number(),
18286
+ lastAt: number()
18459
18287
  });
18460
18288
  /**
18461
- * Re-embed stored tracks from their key frames.
18289
+ * How a track was produced. `pipeline` (default / absent) = the spatial
18290
+ * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
18291
+ * no positions, a single snapshot, and no bbox trajectory at all:
18462
18292
  *
18463
- * The reason this is an operator-callable method and not a migration script:
18464
- * every knob that decides what a vector MEANS encoder model, crop margin,
18465
- * squaring is only changeable if the existing vectors can be regenerated.
18466
- * Mixing feature spaces in one index makes cosine scores incomparable, and the
18467
- * symptom is a quality regression with no visible cause.
18293
+ * - `sensor` a linked sensor/control device state change.
18294
+ * - `audio` an audio event on the camera itself that was anomalous for
18295
+ * THAT camera, loud, and heard while nothing visual was happening (D62).
18296
+ *
18297
+ * The spatial subsystems (tracker association, occupancy count, re-id /
18298
+ * embedding, resurrection) MUST skip every synthetic source. Test for that
18299
+ * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
18300
+ * check silently readmits every source added after it was written.
18468
18301
  */
18469
- var RebuildObjectEmbeddingsInput = object({
18470
- /** Restrict to one camera. Omit for the whole fleet. */
18471
- deviceId: number().optional(),
18472
- since: number().optional(),
18473
- until: number().optional(),
18474
- /** Stop after this many tracks; the result reports whether more remain. */
18475
- maxTracks: number().int().positive().optional(),
18476
- /**
18477
- * Run every embedding on THIS node instead of round-robining the fleet.
18478
- *
18479
- * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
18480
- * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
18481
- * calling it that would pin the rebuild REQUEST itself to that node — the
18482
- * rebuild orchestration lives on the hub, and only the per-track step runs
18483
- * remotely. This field is data; the per-track pin is applied inside.
18484
- *
18485
- * Absent ⇒ round-robin over every online node whose runner can serve the
18486
- * pinned model.
18487
- */
18488
- executeOnNodeId: string().optional(),
18489
- /**
18490
- * Milliseconds to wait between tracks; omit for the built-in default, `0` to
18491
- * run flat out.
18492
- *
18493
- * A rebuild is bulk maintenance on hub-main's single thread. Measured
18494
- * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
18495
- * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
18496
- * force is logged at start and finish so a deliberately slow pass reads
18497
- * differently from a stalled one.
18498
- */
18499
- pacingMs: number().int().nonnegative().optional()
18500
- });
18302
+ var TrackSourceSchema = _enum([
18303
+ "pipeline",
18304
+ "sensor",
18305
+ "audio"
18306
+ ]);
18501
18307
  /**
18502
- * Result of emptying the CLIP index.
18308
+ * Where a track sits in the RETRAIN lifecycle (D81).
18503
18309
  *
18504
- * The clean slate before a policy change: a new crop margin or encoder model
18505
- * leaves two feature spaces in one index whose cosine scores are not
18506
- * comparable, so wiping and rebuilding is the only way to be sure every vector
18507
- * means the same thing.
18310
+ * - `none` never marked, or un-marked. Evictable.
18311
+ * - `staging` the operator wants this track as training material and has not
18312
+ * finished with it. **This is the only state retention holds**: the track and
18313
+ * everything it owns (object events, crops, keyframes, CLIP vector) survive
18314
+ * the device's age window.
18315
+ * - `trained` — the retrain page has taken what it needed. The frames it chose
18316
+ * were COPIED into the retrain dataset at selection time, so the dataset no
18317
+ * longer depends on the track's media and the track becomes EVICTABLE again.
18318
+ * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
18319
+ * a deliberate action of the retrain page, not a side effect of a checkbox.
18320
+ *
18321
+ * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
18322
+ * the store's filter language has only positive equality and `whereIn` — no
18323
+ * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
18324
+ * would make the entire pre-column history immortal in one deploy.
18508
18325
  */
18509
- var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
18326
+ var RetrainStatusSchema = _enum([
18327
+ "none",
18328
+ "staging",
18329
+ "trained"
18330
+ ]);
18510
18331
  /**
18511
- * Acknowledgement that a rebuild STARTED.
18332
+ * Per-track OPERATOR flags set by hand from the admin UI or the viewer, never
18333
+ * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
18334
+ * so the two surfaces cannot drift.
18512
18335
  *
18513
- * The pass costs ~1s per track 45 minutes for a 2,600-track fleet so it
18514
- * runs detached and this returns immediately. Waiting for it made the client
18515
- * time out while the work carried on server-side, which is the worst of both:
18516
- * no result and no way to know it was still going. Poll
18517
- * `getObjectEmbeddingRebuildStatus` for progress.
18336
+ * **Absent false.** A track that has never been touched omits the field; an
18337
+ * explicitly un-flagged track carries `false`. Legacy rows written before the
18338
+ * columns existed read as absent, and a consumer that needs a boolean should say
18339
+ * `flag === true`, not `flag !== false`.
18340
+ *
18341
+ * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
18342
+ * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
18343
+ * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
18344
+ * `trained` track reports `false` while refusing both writes. The boolean is
18345
+ * kept because three surfaces drive a toggle off it; anything that needs to tell
18346
+ * "never marked" from "already trained" must read `retrainStatus`.
18347
+ *
18348
+ * `debug` does NOT pin; it is attention, not durability.
18349
+ *
18350
+ * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
18351
+ * A favourited track is skipped by retention the same way `staging` is, but
18352
+ * it does not enter `none|staging|trained` and has no staging budget.
18518
18353
  */
18519
- var RebuildObjectEmbeddingsResultSchema = object({
18520
- started: boolean(),
18521
- /** True when a pass was already running; the new request is ignored. */
18522
- alreadyRunning: boolean()
18523
- });
18524
- var RebuildStatusSchema = object({
18525
- running: boolean(),
18526
- scanned: number(),
18527
- rebuilt: number(),
18528
- /** Tracks whose key frame is gone — nothing to re-embed from. */
18529
- missingKeyFrame: number(),
18530
- /** Tracks with no usable detection box. */
18531
- missingBbox: number(),
18532
- /**
18533
- * Tracks an executing node REFUSED rather than broke on an unreadable key
18534
- * frame, a step that threw. Separate from `failed` because the remedy is
18535
- * different, and because a whole camera silently contributing zero vectors
18536
- * is the shape of failure a rebuild must never hide.
18537
- */
18538
- notRunnable: number(),
18539
- /**
18540
- * The pass stopped because NO node could serve the pinned model.
18541
- *
18542
- * Distinct from `notRunnable` on purpose: that one says "this track was
18543
- * refused", this one says "the cluster cannot do this work at all" — every
18544
- * candidate node either lacks the `clip-embedding` step, lacks a build of the
18545
- * pinned model for its engine format, or dropped out. The remedy is a model /
18546
- * engine change, not a per-camera one. Non-zero here always comes with
18547
- * `complete: false`.
18548
- */
18549
- noCapableNode: number(),
18550
- failed: number(),
18551
- /** Set once a pass ends: true only when EVERYTHING was covered. */
18552
- complete: boolean().nullable(),
18553
- startedAtMs: number().nullable(),
18554
- finishedAtMs: number().nullable(),
18555
- /** Present when the pass ended by throwing. */
18556
- error: string().nullable()
18354
+ var TrackFlagFields = {
18355
+ /** Operator marked this track as training material — i.e. `retrainStatus` is
18356
+ * `'staging'`. */
18357
+ markForTrain: boolean().optional(),
18358
+ /** Operator marked this track for diagnostic attention. */
18359
+ debug: boolean().optional(),
18360
+ /** Operator favourited this track. Pins it against pruning. */
18361
+ favourited: boolean().optional()
18362
+ };
18363
+ /**
18364
+ * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
18365
+ * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
18366
+ * write patch, and the status is not something the toggle sets — it is what the
18367
+ * toggle's boolean is derived from. Absent on an in-RAM track never touched;
18368
+ * always present on a persisted row (the column default materialises `'none'`).
18369
+ */
18370
+ var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
18371
+ /**
18372
+ * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
18373
+ * one flag can never clear the other — the toggles are independent and are
18374
+ * driven from three surfaces that do not know about each other.
18375
+ */
18376
+ var TrackFlagsPatchSchema = object(TrackFlagFields);
18377
+ /**
18378
+ * The resolved flag state after a write. Both fields are REQUIRED here (absent
18379
+ * collapses to `false`) so a caller can drive a toggle's checked state off the
18380
+ * mutation result without a re-fetch.
18381
+ */
18382
+ var TrackFlagsSchema = object({
18383
+ trackId: string(),
18384
+ markForTrain: boolean(),
18385
+ debug: boolean(),
18386
+ favourited: boolean(),
18387
+ /** The lifecycle state the boolean was derived from. Required here (unlike on
18388
+ * a track row) because this shape is only ever produced by the write body,
18389
+ * which always knows it — and a surface that has just written needs to render
18390
+ * `trained` without a re-fetch. */
18391
+ retrainStatus: RetrainStatusSchema
18557
18392
  });
18558
- DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
18559
- deviceId: number(),
18560
- trackId: string()
18561
- }), TrackSchema.nullable()), method(object({
18562
- deviceId: number(),
18563
- since: number().optional(),
18564
- until: number().optional(),
18565
- limit: number().optional(),
18566
- /** Spatial filter only tracks whose trajectory intersects the zone
18567
- * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
18568
- * envelope columns, then precisely tested per position. Tracks with
18569
- * an unknown envelope (no frame dims at persist time) always match. */
18570
- zone: TrackZoneFilterSchema.optional(),
18571
- /** See {@link TrackProjectionSchema}. Default `full` (backward
18572
- * compatible — omitting the field keeps today's exact behaviour). */
18573
- projection: TrackProjectionSchema.optional(),
18574
- /** Include stationary-promoted rows (parked objects handed to the
18575
- * stationary registry). Default false: the timeline lists passages,
18576
- * not parking records (operator decision, 2026-08-15). */
18577
- includeStationary: boolean().optional()
18578
- }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
18579
- deviceId: number(),
18580
- groupId: string().min(1)
18581
- }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
18582
- kind: "mutation",
18583
- auth: "admin"
18584
- }), 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({
18585
- deviceId: number(),
18586
- since: number().optional(),
18587
- until: number().optional(),
18588
- kinds: array(string()).optional(),
18589
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
18590
- }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
18591
- deviceId: number(),
18592
- since: number(),
18593
- until: number(),
18594
- bucketMs: number().int().positive()
18595
- }), array(object({
18596
- bucketStart: number(),
18597
- motion: number().int(),
18598
- object: number().int(),
18599
- audio: number().int()
18600
- })).readonly()), method(object({
18601
- deviceId: number(),
18602
- cutoffMs: number()
18603
- }), object({
18604
- motion: number().int(),
18605
- object: number().int(),
18606
- audio: number().int()
18607
- }), {
18608
- kind: "mutation",
18609
- auth: "admin"
18610
- }), method(object({
18611
- deviceId: number(),
18612
- cutoffMs: number()
18613
- }), TrackCascadeCountsSchema, {
18614
- kind: "mutation",
18615
- auth: "admin"
18616
- }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
18617
- kind: "mutation",
18618
- auth: "admin"
18619
- }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
18620
- kind: "mutation",
18621
- auth: "admin"
18622
- }), method(object({
18623
- deviceId: number(),
18624
- trackIds: array(string()).min(1)
18625
- }), object({
18626
- deleted: number().int(),
18627
- failed: array(string()).readonly()
18628
- }), {
18629
- kind: "mutation",
18630
- auth: "admin"
18631
- }), method(object({
18632
- /** Log/audit scope only — the trackId is globally unique on its own. */
18393
+ union([literal(1), literal(2)]);
18394
+ /**
18395
+ * WHO decided a label, and when. Carried per tier so a value can be traced to
18396
+ * the step and model that produced it — which is what makes the write rule
18397
+ * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
18398
+ * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
18399
+ *
18400
+ * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
18401
+ * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
18402
+ * `migration:4g` for a value the 4g migration moved from the single-slot era —
18403
+ * that value has no provenance, and the write rule lets ANY properly-attributed
18404
+ * write of the same tier replace it regardless of score.
18405
+ */
18406
+ var LabelAttributionSchema = object({
18407
+ stepId: string(),
18408
+ modelId: string().optional(),
18409
+ decidedAt: number(),
18410
+ /**
18411
+ * The GALLERY id behind a recognised tier-2 label — a face-gallery
18412
+ * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
18413
+ *
18414
+ * The text alone is a DISPLAY NAME, and a display name is renameable: a
18415
+ * notification rule authored on "Gianluca" stopped matching the moment the
18416
+ * operator fixed the spelling in the gallery, and nothing said so. The id is
18417
+ * the thing that does not move, so it is what a rule matches on
18418
+ * (`NcConditions.identities`) and the text is what a human is shown.
18419
+ *
18420
+ * Absent when the label names no gallery row — a plate the OCR read but no
18421
+ * vehicle claims, a sub-class, a species, any tier-1 value.
18422
+ */
18423
+ identityId: string().optional()
18424
+ });
18425
+ /**
18426
+ * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
18427
+ * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
18428
+ * track and its events always answer the same question the same way.
18429
+ *
18430
+ * Two scalar columns, not an array: every consumer wants "the coarse one" or
18431
+ * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
18432
+ * is tier 2, and each carries its own score + attribution.
18433
+ *
18434
+ * **Reading it.** What a human should be shown is `subLabel ?? label` — the
18435
+ * finest thing known. Before 4g the single `label` column held the finest
18436
+ * value, so a consumer that has not been updated reads the tier-1 slot and
18437
+ * shows nothing on a species-only row; that is why the migration puts every
18438
+ * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
18439
+ * and why the read surfaces were changed in the same train.
18440
+ *
18441
+ * **Writing it.** The slots are independent, which is the whole point: a
18442
+ * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
18443
+ * migratorius`), so fineness cannot regress by construction. Within a tier the
18444
+ * higher score wins. One rule, one implementation — see
18445
+ * `pipeline/label-tier.ts` in addon-post-analysis.
18446
+ */
18447
+ var TieredLabelFields = {
18448
+ /** Tier 1 — the sub-class. See {@link LabelTierSchema}. */
18449
+ label: string().optional(),
18450
+ /** Confidence of the tier-1 value, as reported by the deciding step. */
18451
+ labelScore: number().optional(),
18452
+ /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
18453
+ labelMeta: LabelAttributionSchema.optional(),
18454
+ /** Tier 2 the instance. See {@link LabelTierSchema}. */
18455
+ subLabel: string().optional(),
18456
+ /** Confidence of the tier-2 value, as reported by the deciding step. */
18457
+ subLabelScore: number().optional(),
18458
+ /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
18459
+ subLabelMeta: LabelAttributionSchema.optional()
18460
+ };
18461
+ /** Per-camera slice of a training-export estimate. */
18462
+ var TrainingExportDeviceTotalsSchema = object({
18633
18463
  deviceId: number(),
18464
+ tracks: number().int(),
18465
+ files: number().int(),
18466
+ bytes: number().int()
18467
+ });
18468
+ /**
18469
+ * What a training export WOULD contain. Computed from media index rows only —
18470
+ * no blob is read to produce this.
18471
+ */
18472
+ var TrainingExportSummarySchema = object({
18473
+ generatedAt: number(),
18474
+ trackCount: number().int(),
18475
+ fileCount: number().int(),
18476
+ byteCount: number().int(),
18477
+ /** More marked tracks exist than a single pass carries. */
18478
+ truncated: boolean(),
18479
+ devices: array(TrainingExportDeviceTotalsSchema).readonly()
18480
+ });
18481
+ var TrackSchema = object({
18634
18482
  trackId: string(),
18635
- flags: TrackFlagsPatchSchema
18636
- }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
18637
- kind: "query",
18638
- auth: "admin"
18639
- }), method(object({
18640
- olderThanMs: number(),
18641
- reason: OpsLogReasonSchema.optional()
18642
- }), EventPruneCountsSchema, {
18643
- kind: "mutation",
18644
- auth: "admin"
18645
- }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
18646
- kind: "mutation",
18647
- auth: "admin"
18648
- }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
18649
- kind: "mutation",
18650
- auth: "admin"
18651
- }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
18652
- kind: "mutation",
18653
- auth: "admin"
18654
- }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
18655
- kind: "mutation",
18656
- auth: "admin"
18657
- }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
18658
- kind: "mutation",
18659
- auth: "admin"
18660
- }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18661
- kind: "mutation",
18662
- auth: "admin"
18663
- }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
18664
- kind: "mutation",
18665
- auth: "admin"
18666
- }), method(object({}), array(RelocateJobSchema).readonly(), {
18667
- kind: "query",
18668
- auth: "admin"
18669
- }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18670
- kind: "mutation",
18671
- auth: "admin"
18672
- }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
18673
- kind: "query",
18674
- auth: "admin"
18675
- }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
18676
- kind: "query",
18677
- auth: "admin"
18678
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18679
- kind: "query",
18680
- auth: "admin"
18681
- }), method(object({
18682
- /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
18683
- * `deviceId`, deliberately: `deviceId` would make this device-bound and
18684
- * route it at one camera's owner, and "every camera" would stop being
18685
- * expressible at all. */
18686
- deviceIds: array(number()).optional(),
18687
- limit: number().int().min(1).max(500).optional()
18688
- }), array(RetrainTrackSchema).readonly(), {
18689
- kind: "query",
18690
- auth: "admin"
18691
- }), method(object({ trackId: string() }), RetrainFrameListSchema, {
18692
- kind: "query",
18693
- auth: "admin"
18694
- }), method(object({
18695
18483
  deviceId: number(),
18696
- trackId: string(),
18697
- mediaKeys: array(string()).min(1)
18698
- }), RetrainFrameSelectionSchema, {
18699
- kind: "mutation",
18700
- auth: "admin"
18701
- }), method(object({
18484
+ className: string(),
18485
+ ...TieredLabelFields,
18486
+ producingDeviceName: string().optional(),
18487
+ /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
18488
+ source: TrackSourceSchema.optional(),
18489
+ firstSeen: number(),
18490
+ lastSeen: number(),
18491
+ /** Frame-rate position history (subject to maxPositionHistory cap). */
18492
+ positions: array(TrackPositionSchema).readonly(),
18493
+ /** Periodic snapshots at snapshotIntervalMs cadence (subject to
18494
+ * saveThumbnails policy). */
18495
+ snapshots: array(TrackSnapshotSchema).readonly(),
18496
+ /** Deduplicated zones the track has entered at least once. Zone IDS. */
18497
+ zonesVisited: array(string()).readonly(),
18498
+ /**
18499
+ * Human NAMES for {@link zonesVisited}, resolved at READ time against the
18500
+ * `zones` capability.
18501
+ *
18502
+ * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
18503
+ * and no card can render — so every free-text search surface was structurally
18504
+ * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
18505
+ * just returned nothing. Resolving here rather than in each client keeps ONE
18506
+ * derivation and costs the clients no extra call (the `zones` cap is
18507
+ * per-device, so a client-side resolve would be a per-camera fan-out on a
18508
+ * surface built to avoid exactly that).
18509
+ *
18510
+ * Resolved, never invented: a zone deleted since the track was written has no
18511
+ * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
18512
+ * two are not positionally aligned. Absent when the track visited no zone, or
18513
+ * when the zone catalogue could not be read.
18514
+ */
18515
+ zoneNames: array(string()).readonly().optional(),
18516
+ /** Deduplicated set of detector classes observed for this track over its
18517
+ * life (a track may be reclassified, e.g. person→vehicle). Absent on
18518
+ * legacy rows written before class accumulation shipped. */
18519
+ classes: array(string()).readonly().optional(),
18520
+ /** Cumulative normalized distance travelled (0..1 units = full frame width). */
18521
+ totalDistance: number(),
18522
+ state: TrackStateSchema,
18523
+ active: boolean(),
18524
+ /** Deterministic key-event importance score in [0,1] (server-computed at
18525
+ * track expiry, recomputed on late label). Absent on legacy rows written
18526
+ * before scoring shipped — consumers degrade to absence / compute-on-read. */
18527
+ importance: number().optional(),
18528
+ /** Id of the track's highest-confidence ObjectEvent (its representative
18529
+ * "best" frame). Absent when the track produced no object events. */
18530
+ bestEventId: string().optional(),
18531
+ /** Tag of the importance sub-signal that dominated the score
18532
+ * (identity|dwell|proximity|class|confidence|travel|zone). */
18533
+ importanceReason: string().optional(),
18534
+ /** Audio-classification labels heard on the camera during the track's
18535
+ * life (score ≥ device `classificationMinScore`), aggregated per label.
18536
+ * Absent on legacy rows / tracks with no confident audio. */
18537
+ audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
18538
+ /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
18539
+ * Populated from the persisted envelope columns on historical reads;
18540
+ * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
18541
+ envelope: TrackEnvelopeSchema.optional(),
18542
+ /**
18543
+ * A face DETECTOR found a face on this track — nothing more. It says the
18544
+ * detail plane produced a `face` detail; it does NOT say the face was
18545
+ * embedded, matched, above `minFacePx`, or that the recognizer was even
18546
+ * enabled. Set once and never cleared.
18547
+ *
18548
+ * **This exists so "face present but not recognised" is expressible.** A
18549
+ * recognised identity lands in `subLabel` (attributed to the face chain via
18550
+ * `subLabelMeta.stepId`), so before this field a track with an unmatched face
18551
+ * and a track with no face at all were byte-identical on the wire and no
18552
+ * surface could tell them apart. The read is `hasFace === true && subLabel
18553
+ * === undefined`.
18554
+ *
18555
+ * **Absent ≠ false.** Every row written before the column existed omits it,
18556
+ * and so does every server that predates the field — a consumer must test
18557
+ * `=== true` and render nothing otherwise, never infer "no face".
18558
+ */
18559
+ hasFace: boolean().optional(),
18560
+ /**
18561
+ * This track has a face row IN THE GALLERY: a crop **and** an embedding — a
18562
+ * face an operator could ASSIGN to an identity.
18563
+ *
18564
+ * The STRICT twin of {@link hasFace}, and the pair only earns its keep
18565
+ * because the two disagree. `hasFace` is stamped at the TOP of the face
18566
+ * branch, before every gate, and means no more than "a face detector produced
18567
+ * a face detail". This one is stamped at the single moment the gallery row
18568
+ * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
18569
+ * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
18570
+ * candidate gate, the imageless-track drop (no crop was ever captured) and
18571
+ * the crop-store drop. Everything between the detector and that insert can
18572
+ * legitimately refuse the face, so a flag written any earlier promises the
18573
+ * operator something to assign and delivers nothing.
18574
+ *
18575
+ * **Independent of recognition.** A face collected but never auto-matched is
18576
+ * still assignable — it is in fact the face an operator most wants to reach —
18577
+ * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
18578
+ * `subLabel`; this says only that the raw material exists.
18579
+ *
18580
+ * **Set once, never cleared.** A track that produced a gallery row produced
18581
+ * one; deleting the row later is the gallery's business, not this flag's.
18582
+ *
18583
+ * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
18584
+ * before the column omits it, and so does every server that predates the
18585
+ * field. A consumer must test `=== true` and render nothing otherwise —
18586
+ * never infer "no assignable face".
18587
+ */
18588
+ hasEmbeddedFace: boolean().optional(),
18589
+ /**
18590
+ * This subject CONTAINS a folded rider — a person the rider-pairing step
18591
+ * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
18592
+ * so the passage is tracked once and as a VEHICLE.
18593
+ *
18594
+ * It exists because the fold's record was dishonest. D34 and the code both
18595
+ * said "the person is not lost — it is reported so both entities stay on the
18596
+ * record"; in fact the pair went into a per-processor RAM field behind an
18597
+ * accessor nobody called, and every durable surface said `vehicle`, full
18598
+ * stop. This is the composition note that makes the row true.
18599
+ *
18600
+ * A COMPOSITION, never a class and never a label. "This vehicle contains a
18601
+ * person" is not an answer to "what is this" — both label tiers would refuse
18602
+ * a macro token anyway (D89), and correctly. Nothing here changes what the
18603
+ * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
18604
+ * and a `person` rule still does not fire for someone cycling past.
18605
+ *
18606
+ * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
18607
+ * the column, and every hub that predates the field, omits it. Test
18608
+ * `=== true` and render nothing otherwise — never infer "no rider".
18609
+ */
18610
+ hasRider: boolean().optional(),
18611
+ ...TrackFlagFields,
18612
+ ...TrackRetrainFields
18613
+ });
18614
+ var BaseEventFields = {
18615
+ id: string(),
18702
18616
  deviceId: number(),
18703
- trackId: string(),
18704
- frameId: string()
18705
- }), object({
18706
- removed: boolean(),
18707
- removedAnnotations: number().int()
18708
- }), {
18709
- kind: "mutation",
18710
- auth: "admin"
18711
- }), method(object({ frameId: string() }), object({
18617
+ timestamp: number()
18618
+ };
18619
+ var MotionEventSchema = object({
18620
+ ...BaseEventFields,
18621
+ kind: literal("motion"),
18622
+ regionCount: number(),
18623
+ /** Heavy JSON array — omitted in slim projection. */
18624
+ regions: array(object({
18625
+ bbox: BoundingBoxSchema,
18626
+ pixelCount: number(),
18627
+ intensity: number()
18628
+ })).readonly().optional(),
18629
+ /** Omitted in slim projection. */
18630
+ frameWidth: number().optional(),
18631
+ /** Omitted in slim projection. */
18632
+ frameHeight: number().optional(),
18633
+ /** Populated by B5 (recording playback URL for this event). */
18634
+ mediaUrl: string().optional()
18635
+ });
18636
+ /**
18637
+ * Which detection SOURCE produced an object event. `pipeline` = the ML
18638
+ * detection pipeline (decoded-frame inference); `onboard` = the camera's
18639
+ * native on-device AI. Both flow through the SAME analysis layers (zoning,
18640
+ * tracking, per-kind persistence) but stay distinguishable so consumers
18641
+ * (advanced-notifier, occupancy, …) can select which source(s) to act on.
18642
+ * Absent on legacy rows ⇒ treat as `pipeline`.
18643
+ */
18644
+ var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
18645
+ /**
18646
+ * The confirmed zone crossing that produced an object event. Present ONLY on
18647
+ * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
18648
+ * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
18649
+ * appearance event carry none, so a rule asking for a direction fails closed
18650
+ * on them.
18651
+ *
18652
+ * Exactly ONE crossing per event: the emitter turns each confirmed crossing
18653
+ * into its own event, so a frame in which a track enters A while leaving B
18654
+ * produces two events with two directions — never one ambiguous row.
18655
+ *
18656
+ * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
18657
+ * membership the box has NOW, and by definition it no longer contains the zone
18658
+ * that was just left. Without the id here, a zone-scoped rule could never match
18659
+ * the exit it asked for.
18660
+ */
18661
+ var ZoneCrossingSchema = object({
18662
+ direction: _enum(["enter", "exit"]),
18663
+ /** Admin zone id crossed. */
18664
+ zoneId: string(),
18665
+ /** Zone display name at crossing time (falls back to the id). */
18666
+ zoneName: string().optional()
18667
+ });
18668
+ var ObjectEventSchema = object({
18669
+ ...BaseEventFields,
18670
+ kind: literal("object"),
18671
+ /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
18672
+ source: DetectionSourceSchema.optional(),
18673
+ /**
18674
+ * Inference-frame id shared by every object event emitted from the SAME frame
18675
+ * — the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
18676
+ * 2 people + 1 dog) under one full frame, and link a track's frames over time
18677
+ * (group by `trackId`, pick a representative `frameId` as the parent frame).
18678
+ * Optional for backward-compat with pre-existing rows / the slim projection
18679
+ * includes it (it is light). Absent on rows written before this field.
18680
+ */
18681
+ frameId: string().optional(),
18682
+ /** Omitted in slim projection. */
18683
+ trackId: string().optional(),
18684
+ className: string(),
18685
+ ...TieredLabelFields,
18686
+ /** Omitted in slim projection. */
18687
+ confidence: number().optional(),
18688
+ /** Heavy JSON — omitted in slim projection. */
18689
+ bbox: BoundingBoxSchema.optional(),
18690
+ /** Heavy JSON — omitted in slim projection. */
18691
+ zones: array(string()).readonly().optional(),
18692
+ /** Omitted in slim projection. */
18693
+ state: TrackStateSchema.optional(),
18694
+ /**
18695
+ * The zone crossing this event IS, when it is one. Absent on every other
18696
+ * event kind (movement state, appearance, package) — see
18697
+ * {@link ZoneCrossingSchema}. Omitted in slim projection.
18698
+ */
18699
+ zoneCrossing: ZoneCrossingSchema.optional(),
18700
+ /** Detection-frame dimensions in pixels — let consumers normalize the
18701
+ * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
18702
+ frameWidth: number().optional(),
18703
+ frameHeight: number().optional(),
18704
+ /** MediaStore key for the crop attached to this event (if any). */
18705
+ mediaKey: string().optional(),
18706
+ /** Design B: MediaStore key of the track's native-resolution key frame (the
18707
+ * best-detection full frame). Resolve via the event-media data-plane
18708
+ * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
18709
+ * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
18710
+ * sources — consumers fall back to `mediaKey` (the tight crop). */
18711
+ keyFrameMediaKey: string().optional(),
18712
+ /** Populated by B5 (recording playback URL for this event). */
18713
+ mediaUrl: string().optional(),
18714
+ /** The parent track's key-event importance [0,1], propagated to every object
18715
+ * event of the track (so an event row can be sorted by importance without a
18716
+ * track join). Absent on legacy rows / before the track was scored. */
18717
+ importance: number().optional()
18718
+ });
18719
+ var AudioEventSchema = object({
18720
+ ...BaseEventFields,
18721
+ kind: literal("audio"),
18722
+ rms: number(),
18723
+ dbfs: number(),
18724
+ classification: object({
18725
+ className: string(),
18726
+ originalClass: string().optional(),
18727
+ score: number()
18728
+ }).optional(),
18729
+ /** Populated by B5 (recording playback URL for this event). */
18730
+ mediaUrl: string().optional()
18731
+ });
18732
+ var MediaFileKindEnum = _enum([
18733
+ "crop",
18734
+ "thumbnail",
18735
+ "snapshot",
18736
+ "firstFrame",
18737
+ "lastFrame",
18738
+ "fullFrame",
18739
+ "fullFrameBoxed",
18740
+ "faceCrop",
18741
+ "plateCrop",
18742
+ "keyFrame",
18743
+ "keyFrameSmall",
18744
+ "thumbnailSmall"
18745
+ ]);
18746
+ var MediaFileSchema = object({
18747
+ key: string(),
18748
+ kind: MediaFileKindEnum,
18712
18749
  base64: string(),
18713
- width: number().int(),
18714
- height: number().int()
18715
- }), {
18716
- kind: "query",
18717
- auth: "admin"
18718
- }), method(object({
18719
- deviceId: number(),
18720
- trackId: string(),
18721
- frameId: string(),
18722
- subject: RetrainAssistSubjectSchema,
18723
- /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
18724
- nodeId: string().optional()
18725
- }), RetrainAssistResultSchema, {
18726
- kind: "mutation",
18727
- auth: "admin"
18728
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
18729
- kind: "query",
18730
- auth: "admin"
18731
- }), method(object({
18732
- deviceId: number(),
18733
- trackId: string(),
18734
- frameId: string(),
18735
- annotations: array(RetrainAnnotationDraftSchema)
18736
- }), array(RetrainAnnotationSchema).readonly(), {
18737
- kind: "mutation",
18738
- auth: "admin"
18739
- }), method(object({
18740
- deviceId: number(),
18741
- trackId: string()
18742
- }), RetrainTransitionResultSchema, {
18743
- kind: "mutation",
18744
- auth: "admin"
18745
- }), method(object({
18746
- deviceId: number(),
18747
- trackId: string()
18748
- }), RetrainTransitionResultSchema, {
18749
- kind: "mutation",
18750
- auth: "admin"
18751
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18752
- kind: "query",
18753
- auth: "admin"
18754
- }), method(object({
18755
- eventId: string(),
18756
- kind: MediaFileKindEnum.optional(),
18757
- deviceId: number()
18758
- }), array(MediaFileSchema).readonly()), method(object({
18759
- trackId: string(),
18760
- kinds: array(MediaFileKindEnum).optional(),
18761
- deviceId: number()
18762
- }), array(MediaFileSchema).readonly()), method(object({
18750
+ sizeBytes: number(),
18751
+ timestamp: number()
18752
+ });
18753
+ /**
18754
+ * One media row WITHOUT its bytes.
18755
+ *
18756
+ * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
18757
+ * 140 s track), and a client that renders tiles from the media data plane needs
18758
+ * to know only WHAT EXISTS — the bytes then arrive per tile, lazily, over HTTP
18759
+ * with an immutable cache, instead of all at once inside a tRPC response that
18760
+ * blocks the whole view.
18761
+ *
18762
+ * `sizeBytes` is carried because it is what lets a client decide between the
18763
+ * stored blob and a `?variant=thumb` rendering without fetching either.
18764
+ */
18765
+ var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
18766
+ /**
18767
+ * The MACRO tier of an annotation — a CLOSED set.
18768
+ *
18769
+ * This is what the exported detector predicts, so a typo here is a new class
18770
+ * with one example in it. `label` and `subLabel` are open strings by contrast:
18771
+ * the whole point of the page is teaching the model things it does not know
18772
+ * yet, and constraining that vocabulary would make it useless.
18773
+ *
18774
+ * A macro class is NEVER a label. The provider refuses a write whose `label` or
18775
+ * `subLabel` is one of these values, in any casing, because once `person`
18776
+ * exists in both tiers "every person box" stops being answerable without
18777
+ * knowing every string anyone ever typed — and the damage is retroactive.
18778
+ */
18779
+ var RetrainMacroClassSchema = _enum([
18780
+ "person",
18781
+ "vehicle",
18782
+ "animal",
18783
+ "package",
18784
+ "face",
18785
+ "plate"
18786
+ ]);
18787
+ /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
18788
+ var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
18789
+ /** Did a human draw this box, or did the assist propose it? */
18790
+ var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
18791
+ /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
18792
+ var RetrainBboxSchema = object({
18793
+ x: number(),
18794
+ y: number(),
18795
+ w: number(),
18796
+ h: number()
18797
+ });
18798
+ /**
18799
+ * One annotated subject.
18800
+ *
18801
+ * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
18802
+ * (letterboxed root / zone-cropped package / subject-cropped classifier) are
18803
+ * derived from it at export and never stored — storing them is how one feature
18804
+ * space ends up holding two crops of the same subject (D52).
18805
+ */
18806
+ var RetrainAnnotationSchema = object({
18807
+ id: string(),
18763
18808
  trackId: string(),
18764
- deviceId: number()
18765
- }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
18766
- kind: "mutation",
18767
- auth: "admin"
18768
- }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
18769
- kind: "mutation",
18770
- auth: "admin"
18771
- }), method(object({}), RebuildStatusSchema), object({
18772
- deviceId: number(),
18773
- timestamp: number(),
18774
- frameWidth: number(),
18775
- frameHeight: number(),
18776
- detections: array(OverlayDetectionSchema).readonly()
18777
- }), object({
18778
18809
  deviceId: number(),
18810
+ /** The COPY in retrain storage — never the source track's media key. */
18811
+ mediaKey: string(),
18812
+ bbox: RetrainBboxSchema,
18813
+ macroClass: RetrainMacroClassSchema,
18814
+ label: string().optional(),
18815
+ subLabel: string().optional(),
18816
+ kind: RetrainAnnotationKindSchema,
18817
+ source: RetrainAnnotationSourceSchema,
18818
+ /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
18819
+ assistModelId: string().optional(),
18820
+ assistScore: number().optional(),
18821
+ exportedInBatch: string().optional(),
18822
+ createdAt: number()
18823
+ });
18824
+ /** The write form — the server owns `id`, `createdAt` and the frame binding. */
18825
+ var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
18826
+ id: true,
18827
+ trackId: true,
18828
+ deviceId: true,
18829
+ mediaKey: true,
18830
+ createdAt: true,
18831
+ exportedInBatch: true
18832
+ });
18833
+ /** A track sitting in `staging`, with everything the worklist needs to rank it. */
18834
+ var RetrainTrackSchema = object({
18779
18835
  trackId: string(),
18780
- className: string()
18781
- }), object({
18782
18836
  deviceId: number(),
18783
- trackId: string(),
18784
18837
  className: string(),
18785
- durationMs: number()
18786
- }), object({
18838
+ label: string().optional(),
18839
+ firstSeen: number(),
18840
+ lastSeen: number(),
18841
+ /** How many frames the dataset already holds from this track. */
18842
+ frameCount: number().int(),
18843
+ /** How many subjects have been annotated on those frames. `0` with
18844
+ * `frameCount: 0` is exactly "staging, still to work". */
18845
+ annotationCount: number().int()
18846
+ });
18847
+ /** A frame the picker may offer — an index row, no blob was read to produce it. */
18848
+ var RetrainFrameCandidateSchema = object({
18849
+ mediaKey: string(),
18850
+ kind: MediaFileKindEnum,
18851
+ timestamp: number(),
18852
+ sizeBytes: number().int(),
18853
+ /** A copy of this original already exists — selecting it is free and cannot
18854
+ * fail, whatever became of the original. */
18855
+ copied: boolean()
18856
+ });
18857
+ /** A frame the dataset OWNS: bytes copied at selection time. */
18858
+ var RetrainFrameSchema = object({
18859
+ frameId: string(),
18787
18860
  deviceId: number(),
18788
- kind: EventKindSchema,
18789
- eventId: string(),
18790
- timestamp: number()
18861
+ trackId: string(),
18862
+ /** Provenance only. It may already point at nothing — that is expected. */
18863
+ sourceMediaKey: string(),
18864
+ sourceKind: MediaFileKindEnum,
18865
+ sizeBytes: number().int(),
18866
+ width: number().int(),
18867
+ height: number().int(),
18868
+ copiedAt: number()
18791
18869
  });
18792
- /**
18793
- * Reference to the frame's retained NATIVE surface + the parent crop's placement
18794
- * within the frame, so the executor can re-cut a leaf child ROI at native
18795
- * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
18796
- */
18797
- var NativeCropRefSchema = object({
18798
- /** Handle keying the retained native surface (node-pinned to its owner). */
18799
- handle: FrameHandleSchema,
18800
- /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
18801
- cropFrameSpace: object({
18802
- x: number(),
18803
- y: number(),
18804
- w: number(),
18805
- h: number()
18806
- })
18870
+ /** Why a copy-on-select could not be honoured — named, never a silent skip. */
18871
+ var RetrainCopyRefusalSchema = _enum([
18872
+ "source-missing",
18873
+ "unreadable-image",
18874
+ "write-failed"
18875
+ ]);
18876
+ var RetrainFrameSelectionSchema = object({
18877
+ copied: array(RetrainFrameSchema).readonly(),
18878
+ refused: array(object({
18879
+ sourceMediaKey: string(),
18880
+ reason: RetrainCopyRefusalSchema
18881
+ })).readonly()
18807
18882
  });
18808
- object({
18809
- crop: object({
18810
- left: number(),
18811
- top: number(),
18812
- width: number().positive(),
18813
- height: number().positive()
18814
- }).optional(),
18815
- content: object({
18816
- width: number().int().positive(),
18817
- height: number().int().positive()
18818
- }),
18819
- fit: _enum(["stretch", "contain"]),
18820
- format: _enum([
18821
- "rgb",
18822
- "gray",
18823
- "jpeg"
18824
- ])
18883
+ var RetrainFrameListSchema = object({
18884
+ candidates: array(RetrainFrameCandidateSchema).readonly(),
18885
+ copies: array(RetrainFrameSchema).readonly(),
18886
+ /** What the page pre-selects — the native key frame when one survives. */
18887
+ autoPickMediaKey: string().optional()
18825
18888
  });
18889
+ /** What the operator asked the assist to look for. */
18890
+ var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
18891
+ kind: literal("package"),
18892
+ zone: RetrainBboxSchema.optional()
18893
+ }), object({
18894
+ kind: literal("objects"),
18895
+ modelId: string(),
18896
+ minScore: number().optional()
18897
+ })]);
18826
18898
  /**
18827
- * Process-local frame identity. It is serializable so it can ride an in-process
18828
- * capability call, but `registryId` deliberately prevents resolution in any
18829
- * other process or execution group.
18899
+ * The assist's answer a discriminated union, because "the model saw nothing"
18900
+ * and "this node cannot run that model" lead to different next moves and a
18901
+ * nullable result cannot tell them apart.
18830
18902
  */
18831
- var FrameRefSchema = object({
18832
- registryId: string().min(1),
18833
- id: string().min(1),
18834
- width: number().int().positive(),
18835
- height: number().int().positive(),
18836
- format: _enum(["rgb", "gray"]),
18837
- timestamp: number(),
18838
- capturedAt: number().optional()
18903
+ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
18904
+ kind: literal("proposed"),
18905
+ modelId: string(),
18906
+ stepId: string(),
18907
+ minScore: number(),
18908
+ /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
18909
+ proposals: array(RetrainAnnotationDraftSchema).readonly(),
18910
+ /** Returned by the runner but removed by the threshold. */
18911
+ belowThreshold: number().int()
18912
+ }), object({
18913
+ kind: literal("refused"),
18914
+ /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
18915
+ reason: string(),
18916
+ detail: string().optional()
18917
+ })]);
18918
+ /** The outcome of a lifecycle move owned by the retrain page. */
18919
+ var RetrainTransitionResultSchema = object({
18920
+ trackId: string(),
18921
+ /** Where the track ended up, whatever happened. */
18922
+ retrainStatus: RetrainStatusSchema,
18923
+ /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
18924
+ changed: boolean(),
18925
+ reason: _enum([
18926
+ "unknown-track",
18927
+ "no-frames-copied",
18928
+ "not-staging",
18929
+ "not-trained",
18930
+ "unchanged"
18931
+ ]).optional()
18839
18932
  });
18840
- var ModelFormatSchema$1 = _enum([
18841
- "onnx",
18842
- "coreml",
18843
- "openvino",
18844
- "tflite",
18845
- "pt",
18846
- "gguf"
18847
- ]);
18848
- var PipelineSlotSchema = _enum([
18849
- "detector",
18850
- "cropper",
18851
- "classifier",
18852
- "refiner",
18853
- "audio-classifier"
18854
- ]);
18855
- var PipelineEngineChoiceSchema = object({
18856
- runtime: _enum(["node", "python"]),
18857
- backend: string(),
18858
- format: ModelFormatSchema$1,
18859
- device: string().optional()
18933
+ var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
18934
+ var MAX_EVENT_QUERY_LIMIT = 5e3;
18935
+ var DeviceEventQueryInput = object({
18936
+ deviceId: number(),
18937
+ since: number().optional(),
18938
+ until: number().optional(),
18939
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
18940
+ /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
18941
+ * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
18942
+ * exact behaviour. Callers may omit this field — the store defaults to
18943
+ * `full` when not provided. */
18944
+ projection: _enum(["full", "slim"]).optional()
18860
18945
  });
18861
- var AvailableEngineSchema = object({
18862
- engine: PipelineEngineChoiceSchema,
18863
- devices: array(object({
18864
- id: string(),
18865
- label: string(),
18866
- description: string().optional()
18867
- })).readonly(),
18868
- defaultDevice: string()
18946
+ var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
18947
+ var RecentTracksQueryInput = object({
18948
+ /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
18949
+ deviceIds: array(number()),
18950
+ /** Window lower bound on `lastSeen` (inclusive). */
18951
+ since: number().optional(),
18952
+ /** Window upper bound on `lastSeen` (inclusive). */
18953
+ until: number().optional(),
18954
+ /** Page size. Default 200, max 1000. */
18955
+ limit: number().int().min(1).max(1e3).default(200),
18956
+ /** Opaque continuation cursor from a previous page's `nextCursor`.
18957
+ * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
18958
+ cursor: string().optional(),
18959
+ /** See {@link TrackProjectionSchema}. Default `full`. */
18960
+ projection: TrackProjectionSchema.optional(),
18961
+ /** Include stationary-promoted rows (parked objects). Default false: the
18962
+ * feed lists passages; parking records live on the stationary registry. */
18963
+ includeStationary: boolean().optional()
18964
+ });
18965
+ var RecentTracksPageSchema = object({
18966
+ /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
18967
+ tracks: array(TrackSchema).readonly(),
18968
+ /** Cursor for the next page, or null when this page is the last. */
18969
+ nextCursor: string().nullable()
18869
18970
  });
18870
- var PipelineDefaultStepSchema = lazy(() => object({
18871
- addonId: string(),
18872
- addonName: string(),
18873
- slot: PipelineSlotSchema,
18874
- inputClasses: array(string()).readonly(),
18875
- outputClasses: array(string()).readonly(),
18876
- enabled: boolean(),
18877
- modelId: string(),
18878
- children: array(PipelineDefaultStepSchema).readonly(),
18879
- group: string().optional(),
18880
- settings: record(string(), unknown()).optional()
18881
- }));
18882
- var PipelineTemplateStepSchema = lazy(() => object({
18883
- addonId: string(),
18884
- enabled: boolean(),
18885
- modelId: string(),
18886
- children: array(PipelineTemplateStepSchema).readonly(),
18887
- settings: record(string(), unknown()).optional()
18888
- }));
18889
- var PipelineTemplateSchema$1 = object({
18971
+ var LIST_GROUPS_DEFAULT_LIMIT = 40;
18972
+ var LIST_GROUPS_MAX_LIMIT = 100;
18973
+ var AnalyticsGroupRecordSchema = object({
18890
18974
  id: string(),
18891
- name: string(),
18892
- createdAt: string(),
18893
- updatedAt: string(),
18894
- engine: PipelineEngineChoiceSchema,
18895
- steps: array(PipelineTemplateStepSchema).readonly()
18975
+ deviceId: number().int(),
18976
+ openedAt: number().int(),
18977
+ closedAt: number().int(),
18978
+ timestamp: number().int(),
18979
+ memberCount: number().int(),
18980
+ memberTrackIds: array(string()).readonly(),
18981
+ className: string(),
18982
+ classes: array(string()).readonly(),
18983
+ /** Relative event-media path, or null when the group has no picture yet. */
18984
+ mediaUrl: string().nullable(),
18985
+ singleton: boolean()
18896
18986
  });
18897
- var PipelineModelOptionSchema = object({
18898
- id: string(),
18899
- name: string(),
18900
- formats: record(string(), object({
18901
- downloaded: boolean(),
18902
- sizeMB: number()
18903
- })),
18904
- group: ModelVariantGroupSchema.optional(),
18905
- legacy: boolean().optional(),
18906
- provider: ModelProviderIdSchema.optional()
18987
+ var AnalyticsGroupMemberSchema = object({
18988
+ trackId: string(),
18989
+ deviceId: number().int(),
18990
+ className: string(),
18991
+ firstSeen: number().int(),
18992
+ lastSeen: number().int(),
18993
+ mediaUrl: string().nullable()
18907
18994
  });
18908
- var ConfigFieldBridge = custom();
18909
- var PipelineAddonSchemaSchema = object({
18910
- id: string(),
18911
- name: string(),
18912
- slot: PipelineSlotSchema,
18913
- inputClasses: array(string()).readonly(),
18914
- outputClasses: array(string()).readonly(),
18915
- childSlots: array(PipelineSlotSchema).readonly(),
18916
- models: array(PipelineModelOptionSchema).readonly(),
18917
- defaultModelId: string(),
18918
- defaultModelIdByFormat: record(string(), string()).optional(),
18919
- enabledByDefault: boolean().optional(),
18920
- backfillIntoExistingOverrides: boolean().optional(),
18921
- defaultConfidence: number(),
18922
- group: string().optional(),
18923
- configSchema: array(ConfigFieldBridge).readonly().optional()
18995
+ var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
18996
+ var ListGroupsQueryInput = object({
18997
+ /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
18998
+ deviceIds: array(number()),
18999
+ /** Window lower bound on `closedAt` (inclusive). */
19000
+ since: number().optional(),
19001
+ /** Window upper bound on `openedAt` (inclusive). */
19002
+ until: number().optional(),
19003
+ limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
19004
+ /** Opaque continuation cursor from a previous page's `nextCursor`. */
19005
+ cursor: string().optional()
18924
19006
  });
18925
- var PipelineSlotSchemaSchema = object({
18926
- id: PipelineSlotSchema,
18927
- label: string(),
18928
- priority: number(),
18929
- parentSlot: PipelineSlotSchema.nullable(),
18930
- addons: array(PipelineAddonSchemaSchema).readonly()
19007
+ var ListGroupsPageSchema = object({
19008
+ groups: array(AnalyticsGroupRecordSchema).readonly(),
19009
+ nextCursor: string().nullable()
18931
19010
  });
18932
- var PipelineSchemaSchema = object({
18933
- availableEngines: array(AvailableEngineSchema).readonly(),
18934
- selectedEngine: PipelineEngineChoiceSchema,
18935
- slots: array(PipelineSlotSchemaSchema).readonly()
19011
+ var KeyEventQueryInput = object({
19012
+ deviceId: number(),
19013
+ /** Window lower bound (track firstSeen ≥ since). */
19014
+ since: number(),
19015
+ /** Window upper bound (track firstSeen ≤ until). */
19016
+ until: number(),
19017
+ limit: number().int().min(1).max(200).default(50),
19018
+ /** Drop tracks scoring below this importance. */
19019
+ minImportance: number().min(0).max(1).optional(),
19020
+ /** Restrict to a single class (e.g. 'person'). */
19021
+ classFilter: string().optional()
18936
19022
  });
18937
- var EngineProvisioningSchema = object({
18938
- runtimeId: _enum([
18939
- "onnx",
18940
- "openvino",
18941
- "coreml",
18942
- "edgetpu"
18943
- ]).nullable(),
18944
- device: string().nullable(),
18945
- state: _enum([
18946
- "idle",
18947
- "installing",
18948
- "verifying",
18949
- "ready",
18950
- "failed"
18951
- ]),
18952
- progress: number().optional(),
18953
- error: string().optional(),
18954
- nextRetryAt: number().optional(),
18955
- /**
18956
- * Gate A (config-correctness gate at engine change): human-readable
18957
- * config issues surfaced EAGERLY when the node's engine changes — model
18958
- * substitutions ("chose X, running Y") and zero-build steps ("no model
18959
- * has a <format> build"). Additive/optional: informational only, never
18960
- * enforced here — `assertEngineReady` (readiness) still gates inference.
18961
- * Absent/empty when the node-default tree resolves cleanly.
18962
- */
18963
- configIssues: array(string()).optional()
19023
+ var KeyEventSchema = object({
19024
+ /** The representative event id (the track's best ObjectEvent, else its trackId). */
19025
+ id: string(),
19026
+ trackId: string(),
19027
+ /** Track start time (firstSeen). */
19028
+ timestamp: number(),
19029
+ className: string(),
19030
+ ...TieredLabelFields,
19031
+ importance: number(),
19032
+ /** Highest-confidence ObjectEvent id for the track (empty when none). */
19033
+ bestEventId: string(),
19034
+ /** Track lifetime in ms (lastSeen - firstSeen). */
19035
+ windowMs: number().optional(),
19036
+ ...TrackFlagFields,
19037
+ ...TrackRetrainFields
18964
19038
  });
18965
- var PipelineStepInputSchema = lazy(() => object({
18966
- addonId: string(),
18967
- modelId: string().optional(),
18968
- enabled: boolean().default(true),
18969
- children: array(PipelineStepInputSchema).optional(),
18970
- settings: record(string(), unknown()).optional(),
18971
- jumpDeviceKey: string().optional()
18972
- }));
18973
- var ModelSubstitutionSchema = object({
18974
- addonId: string(),
18975
- chosen: string(),
18976
- running: string(),
18977
- format: string()
19039
+ object({
19040
+ trackId: string(),
19041
+ className: string(),
19042
+ confidence: number(),
19043
+ bbox: BoundingBoxSchema,
19044
+ zones: array(string()).readonly(),
19045
+ state: TrackStateSchema
18978
19046
  });
18979
- var PipelineValidationIssueSchema = object({
18980
- addonId: string(),
18981
- kind: _enum(["unknown-addon", "no-format-build"]),
18982
- detail: string()
19047
+ var OverlayDetectionSchema = looseObject({
19048
+ id: string(),
19049
+ kind: _enum(["first-level", "detail"]),
19050
+ macroClass: string(),
19051
+ score: number(),
19052
+ bbox: object({
19053
+ x: number(),
19054
+ y: number(),
19055
+ width: number(),
19056
+ height: number()
19057
+ }),
19058
+ labels: array(looseObject({
19059
+ label: string(),
19060
+ score: number()
19061
+ })).readonly(),
19062
+ parentId: string().optional()
18983
19063
  });
18984
- var PipelineValidationResultSchema = object({
18985
- ok: boolean(),
18986
- issues: array(PipelineValidationIssueSchema).readonly(),
18987
- substitutions: array(ModelSubstitutionSchema).readonly(),
18988
- /** The node's `currentEngine.format` this validation ran against. */
18989
- format: string()
19064
+ var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
19065
+ var SearchObjectEventsInput = object({
19066
+ text: string(),
19067
+ deviceId: number().optional(),
19068
+ since: number().optional(),
19069
+ until: number().optional(),
19070
+ classFilter: string().optional(),
19071
+ limit: number().default(50),
19072
+ minScore: number().min(0).max(1).default(.2)
18990
19073
  });
18991
- var ReferenceImageEntrySchema = object({
18992
- filename: string(),
18993
- stepIds: array(string()).readonly().optional()
19074
+ var TrackCascadeCountsSchema = object({
19075
+ /** Persisted track roots deleted (authoritative). */
19076
+ tracks: number().int(),
19077
+ /** Object events removed with their tracks (best-effort; see note above). */
19078
+ events: number().int(),
19079
+ /** Track/face/plate-owned media removed (best-effort). Never identity media. */
19080
+ media: number().int(),
19081
+ /** Unassigned (non-enrolled) face reads removed (best-effort). */
19082
+ faces: number().int(),
19083
+ /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
19084
+ plates: number().int(),
19085
+ /** Per-track CLIP search vectors removed (best-effort). */
19086
+ embeddings: number().int(),
19087
+ /** Group membership + group rows removed with their last member (best-effort). */
19088
+ groups: number().int()
18994
19089
  });
18995
- var ReferenceImageBodySchema = object({
18996
- base64: string(),
18997
- filename: string()
19090
+ /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
19091
+ var DiskReconcileCountsSchema = object({
19092
+ mediaDropped: number().int(),
19093
+ tracks: number().int(),
19094
+ events: number().int()
18998
19095
  });
18999
- var ReferenceAudioEntrySchema = object({
19000
- filename: string(),
19001
- sizeKb: number()
19096
+ /** Event-store footprint for one camera. */
19097
+ var EventStoreDeviceFootprintSchema = object({
19098
+ deviceId: number(),
19099
+ /** Persisted event rows (motion + object + audio) for the camera. */
19100
+ rows: number().int(),
19101
+ /** Event-owned media bytes on disk for the camera. */
19102
+ bytes: number().int()
19103
+ });
19104
+ /** Aggregate event-store footprint: global totals + per-camera breakdown. */
19105
+ var EventStoreFootprintSchema = object({
19106
+ totalRows: number().int(),
19107
+ totalBytes: number().int(),
19108
+ devices: array(EventStoreDeviceFootprintSchema).readonly()
19109
+ });
19110
+ /** Per-kind counts returned by the event-prune / device-delete mutations. */
19111
+ var EventPruneCountsSchema = object({
19112
+ motion: number().int(),
19113
+ object: number().int(),
19114
+ audio: number().int()
19002
19115
  });
19003
- var ReferenceAudioBodySchema = object({ base64: string() });
19004
- var AudioBackendSchema = object({
19005
- id: string(),
19006
- name: string(),
19007
- description: string(),
19008
- available: boolean(),
19116
+ /**
19117
+ * Re-embed stored tracks from their key frames.
19118
+ *
19119
+ * The reason this is an operator-callable method and not a migration script:
19120
+ * every knob that decides what a vector MEANS — encoder model, crop margin,
19121
+ * squaring — is only changeable if the existing vectors can be regenerated.
19122
+ * Mixing feature spaces in one index makes cosine scores incomparable, and the
19123
+ * symptom is a quality regression with no visible cause.
19124
+ */
19125
+ var RebuildObjectEmbeddingsInput = object({
19126
+ /** Restrict to one camera. Omit for the whole fleet. */
19127
+ deviceId: number().optional(),
19128
+ since: number().optional(),
19129
+ until: number().optional(),
19130
+ /** Stop after this many tracks; the result reports whether more remain. */
19131
+ maxTracks: number().int().positive().optional(),
19009
19132
  /**
19010
- * Raw classifier labels this backend can emit (e.g. YAMNet's
19011
- * 521-class set or Apple SoundAnalysis's 303-class set). Used by
19012
- * the benchmark UI to populate the `enabledMicroClasses` filter
19013
- * specific to the selected backend without a separate fetch.
19133
+ * Run every embedding on THIS node instead of round-robining the fleet.
19134
+ *
19135
+ * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
19136
+ * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
19137
+ * calling it that would pin the rebuild REQUEST itself to that node — the
19138
+ * rebuild orchestration lives on the hub, and only the per-track step runs
19139
+ * remotely. This field is data; the per-track pin is applied inside.
19140
+ *
19141
+ * Absent ⇒ round-robin over every online node whose runner can serve the
19142
+ * pinned model.
19014
19143
  */
19015
- rawLabels: array(string()).readonly().optional()
19016
- });
19017
- var AudioCapabilitiesSchema = object({
19018
- activeBackend: string(),
19019
- availableBackends: array(AudioBackendSchema).readonly(),
19020
- sampleRate: number(),
19021
- chunkDurationMs: number()
19022
- });
19023
- var DownloadModelResultSchema = object({
19024
- filePath: string(),
19025
- sizeMB: number(),
19026
- durationMs: number()
19144
+ executeOnNodeId: string().optional(),
19145
+ /**
19146
+ * Milliseconds to wait between tracks; omit for the built-in default, `0` to
19147
+ * run flat out.
19148
+ *
19149
+ * A rebuild is bulk maintenance on hub-main's single thread. Measured
19150
+ * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
19151
+ * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
19152
+ * force is logged at start and finish so a deliberately slow pass reads
19153
+ * differently from a stalled one.
19154
+ */
19155
+ pacingMs: number().int().nonnegative().optional()
19027
19156
  });
19028
19157
  /**
19029
- * Wrapper carrying a single test run's result. Replaces the legacy
19030
- * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
19031
- * canonical `AudioResult` from the Phase 6 output rework: one
19032
- * `AudioDetection` per class above `minScore`, top-N candidates in
19033
- * `debug.alternateLabels['audio-classifier']`, per-source timings in
19034
- * `debug.stepTimings`. The outer `success`/`error` fields stay so the
19035
- * benchmark UI can still report a clean failure when the classifier
19036
- * cap isn't available.
19158
+ * Result of emptying the CLIP index.
19159
+ *
19160
+ * The clean slate before a policy change: a new crop margin or encoder model
19161
+ * leaves two feature spaces in one index whose cosine scores are not
19162
+ * comparable, so wiping and rebuilding is the only way to be sure every vector
19163
+ * means the same thing.
19037
19164
  */
19038
- var AudioTestResultSchema = object({
19039
- success: boolean(),
19040
- error: string().optional(),
19041
- frame: custom().optional()
19165
+ var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
19166
+ /**
19167
+ * Acknowledgement that a rebuild STARTED.
19168
+ *
19169
+ * The pass costs ~1s per track — 45 minutes for a 2,600-track fleet — so it
19170
+ * runs detached and this returns immediately. Waiting for it made the client
19171
+ * time out while the work carried on server-side, which is the worst of both:
19172
+ * no result and no way to know it was still going. Poll
19173
+ * `getObjectEmbeddingRebuildStatus` for progress.
19174
+ */
19175
+ var RebuildObjectEmbeddingsResultSchema = object({
19176
+ started: boolean(),
19177
+ /** True when a pass was already running; the new request is ignored. */
19178
+ alreadyRunning: boolean()
19042
19179
  });
19043
- var PipelineConfigBridge = custom();
19044
- var ConfigUISchemaBridge = custom();
19045
- var ConfigUISchemaNullableBridge = custom();
19046
- var InferenceCapabilitiesBridge = custom();
19047
- var ModelAvailabilityListBridge = custom();
19048
- var PipelineRunResultBridge = custom();
19049
- method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
19050
- modelId: string(),
19051
- settings: record(string(), unknown()).readonly()
19052
- }))), method(object({ steps: record(string(), object({
19053
- modelId: string(),
19054
- settings: record(string(), unknown()).readonly()
19055
- })) }), object({ success: literal(true) }), {
19180
+ var RebuildStatusSchema = object({
19181
+ running: boolean(),
19182
+ scanned: number(),
19183
+ rebuilt: number(),
19184
+ /** Tracks whose key frame is gone — nothing to re-embed from. */
19185
+ missingKeyFrame: number(),
19186
+ /** Tracks with no usable detection box. */
19187
+ missingBbox: number(),
19188
+ /**
19189
+ * Tracks an executing node REFUSED rather than broke on — an unreadable key
19190
+ * frame, a step that threw. Separate from `failed` because the remedy is
19191
+ * different, and because a whole camera silently contributing zero vectors
19192
+ * is the shape of failure a rebuild must never hide.
19193
+ */
19194
+ notRunnable: number(),
19195
+ /**
19196
+ * The pass stopped because NO node could serve the pinned model.
19197
+ *
19198
+ * Distinct from `notRunnable` on purpose: that one says "this track was
19199
+ * refused", this one says "the cluster cannot do this work at all" — every
19200
+ * candidate node either lacks the `clip-embedding` step, lacks a build of the
19201
+ * pinned model for its engine format, or dropped out. The remedy is a model /
19202
+ * engine change, not a per-camera one. Non-zero here always comes with
19203
+ * `complete: false`.
19204
+ */
19205
+ noCapableNode: number(),
19206
+ failed: number(),
19207
+ /** Set once a pass ends: true only when EVERYTHING was covered. */
19208
+ complete: boolean().nullable(),
19209
+ startedAtMs: number().nullable(),
19210
+ finishedAtMs: number().nullable(),
19211
+ /** Present when the pass ended by throwing. */
19212
+ error: string().nullable()
19213
+ });
19214
+ var ReplayFrameInputSchema = object({
19215
+ timestamp: number(),
19216
+ frame: PipelineRunResultBridge
19217
+ });
19218
+ var RunReplayFrameProcessorResultSchema = object({ tracks: array(object({
19219
+ className: string(),
19220
+ firstSeenMs: number(),
19221
+ lastSeenMs: number(),
19222
+ /** Bbox of the track's FIRST matched detection, pixel-space in the clip's
19223
+ * frame — a representative box for the diff's `(className, window, IoU)`
19224
+ * pairing (`replay-diff.ts`). A replay does not need the full per-frame
19225
+ * trajectory production's `Track.positions` keeps. */
19226
+ bbox: BoundingBoxSchema,
19227
+ /** How many of the input frames this track matched a real detection on
19228
+ * (never a coasted/extrapolated frame) — the replay's own signal for "how
19229
+ * solid is this track", cheaper than re-deriving it from a trajectory. */
19230
+ framesMatched: number().int()
19231
+ })).readonly() });
19232
+ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
19233
+ deviceId: number(),
19234
+ trackId: string()
19235
+ }), TrackSchema.nullable()), method(object({
19236
+ deviceId: number(),
19237
+ since: number().optional(),
19238
+ until: number().optional(),
19239
+ limit: number().optional(),
19240
+ /** Spatial filter — only tracks whose trajectory intersects the zone
19241
+ * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
19242
+ * envelope columns, then precisely tested per position. Tracks with
19243
+ * an unknown envelope (no frame dims at persist time) always match. */
19244
+ zone: TrackZoneFilterSchema.optional(),
19245
+ /** See {@link TrackProjectionSchema}. Default `full` (backward
19246
+ * compatible — omitting the field keeps today's exact behaviour). */
19247
+ projection: TrackProjectionSchema.optional(),
19248
+ /** Include stationary-promoted rows (parked objects handed to the
19249
+ * stationary registry). Default false: the timeline lists passages,
19250
+ * not parking records (operator decision, 2026-08-15). */
19251
+ includeStationary: boolean().optional()
19252
+ }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
19253
+ deviceId: number(),
19254
+ groupId: string().min(1)
19255
+ }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
19256
+ kind: "mutation",
19257
+ auth: "admin"
19258
+ }), 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({
19259
+ deviceId: number(),
19260
+ since: number().optional(),
19261
+ until: number().optional(),
19262
+ kinds: array(string()).optional(),
19263
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
19264
+ }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
19265
+ deviceId: number(),
19266
+ since: number(),
19267
+ until: number(),
19268
+ bucketMs: number().int().positive()
19269
+ }), array(object({
19270
+ bucketStart: number(),
19271
+ motion: number().int(),
19272
+ object: number().int(),
19273
+ audio: number().int()
19274
+ })).readonly()), method(object({
19275
+ deviceId: number(),
19276
+ cutoffMs: number()
19277
+ }), object({
19278
+ motion: number().int(),
19279
+ object: number().int(),
19280
+ audio: number().int()
19281
+ }), {
19282
+ kind: "mutation",
19283
+ auth: "admin"
19284
+ }), method(object({
19285
+ deviceId: number(),
19286
+ cutoffMs: number()
19287
+ }), TrackCascadeCountsSchema, {
19288
+ kind: "mutation",
19289
+ auth: "admin"
19290
+ }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
19291
+ kind: "mutation",
19292
+ auth: "admin"
19293
+ }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
19294
+ kind: "mutation",
19295
+ auth: "admin"
19296
+ }), method(object({
19297
+ deviceId: number(),
19298
+ trackIds: array(string()).min(1)
19299
+ }), object({
19300
+ deleted: number().int(),
19301
+ failed: array(string()).readonly()
19302
+ }), {
19303
+ kind: "mutation",
19304
+ auth: "admin"
19305
+ }), method(object({
19306
+ /** Log/audit scope only — the trackId is globally unique on its own. */
19307
+ deviceId: number(),
19308
+ trackId: string(),
19309
+ flags: TrackFlagsPatchSchema
19310
+ }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
19311
+ kind: "query",
19312
+ auth: "admin"
19313
+ }), method(object({
19314
+ olderThanMs: number(),
19315
+ reason: OpsLogReasonSchema.optional()
19316
+ }), EventPruneCountsSchema, {
19317
+ kind: "mutation",
19318
+ auth: "admin"
19319
+ }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
19320
+ kind: "mutation",
19321
+ auth: "admin"
19322
+ }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
19323
+ kind: "mutation",
19324
+ auth: "admin"
19325
+ }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
19326
+ kind: "mutation",
19327
+ auth: "admin"
19328
+ }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
19329
+ kind: "mutation",
19330
+ auth: "admin"
19331
+ }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
19332
+ kind: "mutation",
19333
+ auth: "admin"
19334
+ }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
19335
+ kind: "mutation",
19336
+ auth: "admin"
19337
+ }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
19338
+ kind: "mutation",
19339
+ auth: "admin"
19340
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
19341
+ kind: "query",
19342
+ auth: "admin"
19343
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
19056
19344
  kind: "mutation",
19057
19345
  auth: "admin"
19058
- }), method(object({ nodeId: string() }), object({
19059
- success: literal(true),
19060
- clearedDevices: number()
19061
- }), {
19346
+ }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
19347
+ kind: "query",
19348
+ auth: "admin"
19349
+ }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
19350
+ kind: "query",
19351
+ auth: "admin"
19352
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
19353
+ kind: "query",
19354
+ auth: "admin"
19355
+ }), method(object({
19356
+ /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
19357
+ * `deviceId`, deliberately: `deviceId` would make this device-bound and
19358
+ * route it at one camera's owner, and "every camera" would stop being
19359
+ * expressible at all. */
19360
+ deviceIds: array(number()).optional(),
19361
+ limit: number().int().min(1).max(500).optional()
19362
+ }), array(RetrainTrackSchema).readonly(), {
19363
+ kind: "query",
19364
+ auth: "admin"
19365
+ }), method(object({ trackId: string() }), RetrainFrameListSchema, {
19366
+ kind: "query",
19367
+ auth: "admin"
19368
+ }), method(object({
19369
+ deviceId: number(),
19370
+ trackId: string(),
19371
+ mediaKeys: array(string()).min(1)
19372
+ }), RetrainFrameSelectionSchema, {
19062
19373
  kind: "mutation",
19063
19374
  auth: "admin"
19064
- }), 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({
19065
- name: string(),
19066
- steps: array(PipelineTemplateStepSchema).readonly(),
19067
- engine: PipelineEngineChoiceSchema
19068
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
19069
- id: string(),
19070
- name: string().optional(),
19071
- steps: array(PipelineTemplateStepSchema).readonly().optional()
19072
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
19073
- addonId: string(),
19074
- modelId: string(),
19075
- format: ModelFormatSchema$1
19076
- }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
19077
- addonId: string(),
19078
- modelId: string(),
19079
- format: ModelFormatSchema$1
19080
- }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
19081
- engine: PipelineEngineChoiceSchema.optional(),
19082
- steps: array(PipelineStepInputSchema).min(1),
19083
- frame: FrameInputSchema.optional(),
19084
- /**
19085
- * Process-local lazy frame. Valid only when caller and provider resolve
19086
- * in the same execution-group process; split/cross-node callers use
19087
- * `frame`/`image` inline compatibility instead.
19088
- */
19089
- frameRef: FrameRefSchema.optional(),
19090
- /**
19091
- * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
19092
- * the decoded pixels live in. One more member of the one-of
19093
- * frame/frameHandle/image/imageBase64/referenceImage group.
19094
- */
19095
- frameHandle: FrameHandleSchema.optional(),
19096
- imageBase64: string().optional(),
19097
- /**
19098
- * Binary JPEG bytes — preferred over `imageBase64` on internal
19099
- * hops (hub → forked worker via Moleculer MsgPack) because it
19100
- * skips the 33% base64 overhead + the per-call base64 decode on
19101
- * the detection-pipeline worker. Callers can pass either; exactly
19102
- * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
19103
- */
19104
- image: _instanceof(Uint8Array).optional(),
19105
- referenceImage: string().optional(),
19106
- deviceId: number().optional(),
19107
- sessionId: string().optional(),
19108
- /**
19109
- * Execution plane. 'full' (default) runs the whole tree — benchmark,
19110
- * reference-image, and detail-subtree calls. 'frame' is the live
19111
- * per-frame dispatch: ONLY root-plane steps run; crop children
19112
- * (inputClasses ≠ null) are skipped and served per-track via
19113
- * pipelineRunner.runDetailSubtree (two-plane design).
19114
- */
19115
- plane: _enum(["full", "frame"]).optional(),
19116
- /**
19117
- * Inference-device selector (Phase 2 multi-device). Format
19118
- * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
19119
- * Omitted ⇒ the runner's default device (current single-engine
19120
- * behaviour). Selects WHICH device pool of the node runs the call.
19121
- */
19122
- deviceKey: string().optional(),
19123
- /**
19124
- * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
19125
- * when the parent crop was resolved from the frame's retained NATIVE
19126
- * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
19127
- * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
19128
- * resolution from that surface — the SAME quality path faces already
19129
- * had — instead of the downscaled parent tile. `handle` keys the native
19130
- * surface (node-pinned to its owner); `cropFrameSpace` is the parent
19131
- * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
19132
- * the executor's crop-normalized child ROI back into frame-normalized
19133
- * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
19134
- * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
19135
- * (today's behaviour on the fallback path).
19136
- */
19137
- nativeCropRef: NativeCropRefSchema.optional()
19138
- }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
19139
- engine: PipelineEngineChoiceSchema.optional(),
19140
- steps: array(PipelineStepInputSchema).min(1),
19141
- frames: array(FrameInputSchema).min(1).max(255),
19142
- deviceId: number().optional(),
19143
- sessionId: string().optional(),
19144
- /**
19145
- * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
19146
- * the batch to the Python pool's bench preprocess cache
19147
- * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
19148
- * preprocessed ONCE and every later inference is a pure-inference cache
19149
- * hit — the sustained-throughput run measures inference, not
19150
- * decode+preprocess+infer. Omitted/0 for live frames (all different →
19151
- * full preprocess every call, correct). Fresh per sustained run;
19152
- * released via `uncacheFrame`.
19153
- */
19154
- frameId: number().int().nonnegative().optional(),
19155
- /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
19156
- deviceKey: string().optional()
19157
- }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
19158
- data: _instanceof(Uint8Array),
19159
- width: number().int().positive(),
19160
- height: number().int().positive(),
19161
- format: _enum([
19162
- "rgb",
19163
- "bgr",
19164
- "gray"
19165
- ])
19375
+ }), method(object({
19376
+ deviceId: number(),
19377
+ trackId: string(),
19378
+ frameId: string()
19166
19379
  }), object({
19167
- frameId: number(),
19168
- width: number(),
19169
- height: number()
19170
- }), { kind: "mutation" }), method(object({
19171
- stepId: string(),
19172
- frameId: number().int()
19173
- }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
19174
- batchMode: string(),
19175
- windowMs: number(),
19176
- maxBatchSize: number(),
19177
- concurrency: number()
19178
- })), method(_void(), array(object({
19179
- engineKey: string(),
19180
- engine: PipelineEngineChoiceSchema,
19181
- modelsLoaded: array(string()).readonly(),
19182
- inUseByCameras: array(number()).readonly(),
19183
- /**
19184
- * Origin of this resident factory.
19185
- * - `runtime` — main camera-serving engine (no idle TTL).
19186
- * - `warm-override` — benchmark/test override held in the warm
19187
- * cache; auto-disposed after the idle TTL.
19188
- * - `device-pool` — a concurrent per-device pool (Phase 2
19189
- * multi-device, keyed by `deviceKey`) resolved
19190
- * via `resolveDeviceFactory`. Runs alongside the
19191
- * `runtime` engine on a DIFFERENT accelerator
19192
- * (NPU / iGPU / Coral) — this is how the
19193
- * Engines tab shows all pools running at once.
19194
- */
19195
- kind: _enum([
19196
- "runtime",
19197
- "warm-override",
19198
- "device-pool"
19199
- ]),
19200
- /** Native pid of the underlying Python pool (null when no pool). */
19201
- poolPid: number().nullable(),
19202
- /** ms since this factory was last used (null when not warm-tracked). */
19203
- idleMs: number().nullable(),
19204
- /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
19205
- idleTtlMs: number().nullable()
19206
- })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
19380
+ removed: boolean(),
19381
+ removedAnnotations: number().int()
19382
+ }), {
19207
19383
  kind: "mutation",
19208
19384
  auth: "admin"
19385
+ }), method(object({ frameId: string() }), object({
19386
+ base64: string(),
19387
+ width: number().int(),
19388
+ height: number().int()
19389
+ }), {
19390
+ kind: "query",
19391
+ auth: "admin"
19209
19392
  }), method(object({
19210
- engine: PipelineEngineChoiceSchema,
19211
- force: boolean().optional()
19393
+ deviceId: number(),
19394
+ trackId: string(),
19395
+ frameId: string(),
19396
+ subject: RetrainAssistSubjectSchema,
19397
+ /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
19398
+ nodeId: string().optional()
19399
+ }), RetrainAssistResultSchema, {
19400
+ kind: "mutation",
19401
+ auth: "admin"
19402
+ }), method(object({
19403
+ deviceId: number(),
19404
+ source: DetectionSourceSchema,
19405
+ zones: array(ZoneSchema).readonly().optional(),
19406
+ detectionRules: array(ZoneRuleSchema).readonly().optional(),
19407
+ zoneMembershipMinOverlap: number().min(0).max(1).optional(),
19408
+ frames: array(ReplayFrameInputSchema).min(1)
19409
+ }), RunReplayFrameProcessorResultSchema, {
19410
+ kind: "mutation",
19411
+ auth: "admin"
19412
+ }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
19413
+ kind: "query",
19414
+ auth: "admin"
19415
+ }), method(object({
19416
+ deviceId: number(),
19417
+ trackId: string(),
19418
+ frameId: string(),
19419
+ annotations: array(RetrainAnnotationDraftSchema)
19420
+ }), array(RetrainAnnotationSchema).readonly(), {
19421
+ kind: "mutation",
19422
+ auth: "admin"
19423
+ }), method(object({
19424
+ deviceId: number(),
19425
+ trackId: string()
19426
+ }), RetrainTransitionResultSchema, {
19427
+ kind: "mutation",
19428
+ auth: "admin"
19429
+ }), method(object({
19430
+ deviceId: number(),
19431
+ trackId: string()
19432
+ }), RetrainTransitionResultSchema, {
19433
+ kind: "mutation",
19434
+ auth: "admin"
19435
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
19436
+ kind: "query",
19437
+ auth: "admin"
19438
+ }), method(object({
19439
+ eventId: string(),
19440
+ kind: MediaFileKindEnum.optional(),
19441
+ deviceId: number()
19442
+ }), array(MediaFileSchema).readonly()), method(object({
19443
+ trackId: string(),
19444
+ kinds: array(MediaFileKindEnum).optional(),
19445
+ deviceId: number()
19446
+ }), array(MediaFileSchema).readonly()), method(object({
19447
+ trackId: string(),
19448
+ deviceId: number()
19449
+ }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
19450
+ kind: "mutation",
19451
+ auth: "admin"
19452
+ }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
19453
+ kind: "mutation",
19454
+ auth: "admin"
19455
+ }), method(object({}), RebuildStatusSchema), object({
19456
+ deviceId: number(),
19457
+ timestamp: number(),
19458
+ frameWidth: number(),
19459
+ frameHeight: number(),
19460
+ detections: array(OverlayDetectionSchema).readonly()
19461
+ }), object({
19462
+ deviceId: number(),
19463
+ trackId: string(),
19464
+ className: string()
19212
19465
  }), object({
19213
- success: boolean(),
19214
- reason: string().optional()
19215
- }), {
19216
- kind: "mutation",
19217
- auth: "admin"
19218
- }), 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({
19219
- addonId: string(),
19220
- modelId: string(),
19221
- filename: string().optional(),
19222
- settings: record(string(), unknown()).optional()
19223
- }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
19466
+ deviceId: number(),
19467
+ trackId: string(),
19468
+ className: string(),
19469
+ durationMs: number()
19470
+ }), object({
19471
+ deviceId: number(),
19472
+ kind: EventKindSchema,
19473
+ eventId: string(),
19474
+ timestamp: number()
19475
+ });
19224
19476
  object({
19225
19477
  activeCameras: number(),
19226
19478
  throttledCameras: number(),
@@ -19246,106 +19498,6 @@ var CameraMetricsSchema = object({
19246
19498
  });
19247
19499
  var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
19248
19500
  /**
19249
- * Zone — pure geometry + identity. NO filtering behaviour.
19250
- *
19251
- * Zones describe **where** in the frame the operator wants to flag
19252
- * something; consumer-owned {@link ZoneRule} arrays describe **how**
19253
- * each pipeline stage uses them. Splitting the two means a single
19254
- * polygon "Driveway" can simultaneously back a motion-exclude rule,
19255
- * a detection-include rule on `['car']`, and an occupancy aggregate
19256
- * — without three duplicated polygons.
19257
- *
19258
- * Owned by the orchestrator addon (provider) and mirrored into the
19259
- * `zones` device-state slice on every mutation. Consumers
19260
- * (motion-wasm, pipeline-executor, analytics, admin UI) read either
19261
- * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
19262
- * mirror with `onChanged`).
19263
- *
19264
- * Coordinates are normalised fractions of the frame (0–1) so zones
19265
- * survive resolution changes and stream profile switches.
19266
- *
19267
- * `kind` discriminates between full polygons (closed regions used
19268
- * for intrusion / occupancy filters) and tripwires (open 2-point
19269
- * line segments used for cross events). Onboard / firmware-reported
19270
- * zones (Reolink, ONVIF) are out of scope for now — see the deferred
19271
- * task list.
19272
- */
19273
- var ZoneKindEnum = _enum(["polygon", "tripwire"]);
19274
- /** Polygon vertex in fraction-of-frame coordinates (0–1). */
19275
- var PolygonPointSchema = object({
19276
- x: number(),
19277
- y: number()
19278
- });
19279
- /** A camera detection zone — pure geometry/identity. */
19280
- var ZoneSchema = object({
19281
- id: string(),
19282
- name: string(),
19283
- kind: ZoneKindEnum.default("polygon"),
19284
- /** Polygon vertices, fraction of frame (0–1). */
19285
- polygon: array(PolygonPointSchema).readonly(),
19286
- /** Visual color for UI rendering. */
19287
- color: string().default("#3b82f6")
19288
- });
19289
- /**
19290
- * Zones capability — per-camera CRUD over polygon detection zones.
19291
- *
19292
- * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
19293
- * to per-device settings and mirrors into the `zones` device-state
19294
- * slice on every mutation, so downstream consumers can subscribe via
19295
- * `dev.state.zones.onChanged`.
19296
- *
19297
- * The cap surface only handles geometry + identity; filtering
19298
- * behaviour (per-class, include/exclude, threshold) lives in the
19299
- * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
19300
- * `capabilities/schemas/zone-rule.js`.
19301
- */
19302
- var zonesCapability = {
19303
- name: "zones",
19304
- scope: "device",
19305
- mode: "singleton",
19306
- deviceTypes: [DeviceType.Camera],
19307
- methods: {
19308
- listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
19309
- addZone: method(object({
19310
- deviceId: number(),
19311
- zone: ZoneSchema
19312
- }), _void(), {
19313
- kind: "mutation",
19314
- auth: "admin"
19315
- }),
19316
- removeZone: method(object({
19317
- deviceId: number(),
19318
- zoneId: string()
19319
- }), _void(), {
19320
- kind: "mutation",
19321
- auth: "admin"
19322
- }),
19323
- updateZone: method(object({
19324
- deviceId: number(),
19325
- zone: ZoneSchema
19326
- }), _void(), {
19327
- kind: "mutation",
19328
- auth: "admin"
19329
- })
19330
- },
19331
- /**
19332
- * Runtime-state slice — the live zone catalogue mirrored by the
19333
- * orchestrator on every CRUD mutation. Consumers read via
19334
- * `device.state.zones.value` / `.watch(...)` without round-tripping
19335
- * the cap, and the codegen DeviceProxy auto-wires the reactive
19336
- * handle. Slice shape is `{ zones: Zone[] }` so future extensions
19337
- * (e.g. zone groupings) can sit alongside the polygon list.
19338
- */
19339
- runtimeState: object({ zones: array(ZoneSchema).readonly() }),
19340
- /**
19341
- * 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.
19342
- *
19343
- * See `RuntimeStateDurability`. Enforced by
19344
- * `scripts/check-runtime-state-durability.ts`.
19345
- */
19346
- durability: "restored"
19347
- };
19348
- /**
19349
19501
  * A bounding box in NORMALIZED [0,1] frame coordinates for `getNativeCrop`. The
19350
19502
  * decode worker resolves it against the RETAINED native frame's real pixel dims,
19351
19503
  * so the caller supplies only the detection-res bbox divided by the detection
@@ -28019,6 +28171,39 @@ var ReadGopBytesResultSchema = object({
28019
28171
  /** Media ms the returned fragment covers. */
28020
28172
  gopDurMs: number()
28021
28173
  });
28174
+ /**
28175
+ * A time WINDOW of one finalized segment, cut by byte range — the multi-GOP
28176
+ * twin of {@link ReadGopBytesResultSchema}'s single instant. Built for the
28177
+ * replay clip's `recording` source (`docs/design/plans/2026-08-26-replay-clip-su-pipeline.md`):
28178
+ * a replay needs several seconds of native pixels, not one frame.
28179
+ *
28180
+ * `ok.data` is standalone-demuxable, same as a GOP read. `ok.reachesRequestedEnd`
28181
+ * is `false` when the returned bytes were cut short by the read's own safety
28182
+ * byte cap before covering `[fromMs, toMs)` — a truncation, reported, not a
28183
+ * silently shorter answer. `spans-multiple-segments` is a REFUSAL, not a
28184
+ * degradation: a window whose end falls past the covering segment would need
28185
+ * bytes stitched from a second segment file (its own `ftyp`+`moov`), which is
28186
+ * not one standalone-demuxable stream — the caller's answer is to request a
28187
+ * shorter window or one aligned to a single segment, not to receive spliced
28188
+ * bytes nothing has proven decodable.
28189
+ */
28190
+ var ReadWindowBytesResultSchema = discriminatedUnion("kind", [object({
28191
+ kind: literal("ok"),
28192
+ data: _instanceof(Uint8Array),
28193
+ /** Absolute epoch ms of the returned bytes' first sample — at or before
28194
+ * the requested `fromMs` (anchored on the nearest keyframe). */
28195
+ gopStartMs: number(),
28196
+ /** Media ms the returned bytes cover, from `gopStartMs`. */
28197
+ gopDurMs: number(),
28198
+ /** `false` ⇒ the safety byte cap cut the read short before it reached
28199
+ * the requested `toMs`; the caller got fewer frames than asked for. */
28200
+ reachesRequestedEnd: boolean()
28201
+ }), object({
28202
+ kind: literal("spans-multiple-segments"),
28203
+ /** Where the covering segment's own footage runs out — informational,
28204
+ * not a retry hint (retrying the same window would refuse again). */
28205
+ segmentEndMs: number()
28206
+ })]);
28022
28207
  method(object({
28023
28208
  deviceId: number(),
28024
28209
  fromMs: number(),
@@ -28069,6 +28254,15 @@ method(object({
28069
28254
  }), ReadGopBytesResultSchema, {
28070
28255
  kind: "query",
28071
28256
  auth: "admin"
28257
+ }), method(object({
28258
+ deviceId: number(),
28259
+ profile: string(),
28260
+ startMs: number(),
28261
+ fromMs: number(),
28262
+ toMs: number()
28263
+ }), ReadWindowBytesResultSchema, {
28264
+ kind: "query",
28265
+ auth: "admin"
28072
28266
  }), method(object({
28073
28267
  deviceId: number(),
28074
28268
  config: RecordingConfigSchema
@@ -28664,92 +28858,6 @@ var sceneMonitorCapability = {
28664
28858
  durability: "session"
28665
28859
  };
28666
28860
  /**
28667
- * Per-stage gating mode applied to the zones a rule references.
28668
- *
28669
- * - `include`: the rule contributes to a **whitelist** for its stage.
28670
- * When at least one `include` rule fires for a stage, only entities
28671
- * inside one of those zones pass that stage.
28672
- * - `exclude`: the rule contributes to a **blacklist** for its stage.
28673
- * Entities inside one of those zones are dropped at that stage.
28674
- *
28675
- * `monitor`-style observation (count without filtering) is not a rule
28676
- * mode — zones without any matching rule are observed naturally by
28677
- * `zone-analytics` (live snapshot + history), so an "I just want to
28678
- * count, not filter" use case needs no rule at all.
28679
- */
28680
- var ZoneRuleModeEnum = _enum(["include", "exclude"]);
28681
- /**
28682
- * Per-consumer rule that references existing zones (geometry) and
28683
- * defines how a specific pipeline stage should treat them. Each
28684
- * consumer addon owns its own `ZoneRule[]` array in its per-device
28685
- * settings:
28686
- *
28687
- * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
28688
- * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
28689
- * - future: notification rules, audio gating, etc.
28690
- *
28691
- * One rule applies to N zones (`zoneIds[]`) so the operator can
28692
- * express "ignore motion in ALL of {garden, street}" with a single
28693
- * rule. `classFilter` narrows the rule to specific object classes —
28694
- * "drop person detections in the street, but keep cars" is one
28695
- * `exclude` rule with `classFilter: ['person']`.
28696
- *
28697
- * `enabled` is a soft toggle — the operator can keep the rule
28698
- * configured but inert without deleting it.
28699
- */
28700
- var ZoneRuleSchema = object({
28701
- /** Stable rule id — survives edits, used by the UI for diffing. */
28702
- id: string(),
28703
- /** Optional human-readable label rendered in the rule editor. */
28704
- name: string().optional(),
28705
- /** Zones this rule targets. The rule's `mode` applies to ALL
28706
- * listed zones (OR-set: a detection in any one of them counts).
28707
- * At least one zone id required — a rule with no targets is a
28708
- * configuration mistake and the form validator rejects it. */
28709
- zoneIds: array(string()).min(1).readonly(),
28710
- mode: ZoneRuleModeEnum,
28711
- /**
28712
- * Class names this rule applies to. Empty / undefined ⇒ rule
28713
- * applies to every class. Class strings match the `macroClass`
28714
- * field on detections (e.g. `person`, `car`, `dog`).
28715
- */
28716
- classFilter: array(string()).readonly().optional(),
28717
- /**
28718
- * Minimum bbox/mask overlap (0–1) with any of the rule's zones
28719
- * required to consider an entity "in the zone". Defaults to the
28720
- * consumer's stage default when omitted. Kept for back-compat with
28721
- * existing per-rule overrides; new operators pick the value via
28722
- * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
28723
- * set, the lower-level engine reads it as a 0–1 fraction.
28724
- */
28725
- overlapThreshold: number().min(0).max(1).optional(),
28726
- /**
28727
- * Operator-friendly version of `overlapThreshold` — the percentage
28728
- * of the detection's bbox that must lie inside the zone for the
28729
- * rule to match. Documented default is 85%; the engine substitutes
28730
- * that when the field is omitted (kept optional so existing rules
28731
- * stored without it stay valid).
28732
- *
28733
- * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
28734
- * rule, the engine prefers `bboxInclusionPct` because it's the
28735
- * field exposed in the UI. Internally both feed the same gate.
28736
- */
28737
- bboxInclusionPct: number().min(0).max(100).optional(),
28738
- /**
28739
- * When `true` and a detection has a segmentation mask, use the
28740
- * mask for overlap instead of the bbox. Detection-stage only;
28741
- * motion rules ignore this field.
28742
- */
28743
- preferMask: boolean().optional(),
28744
- /**
28745
- * Soft-toggle: `false` disables the rule without deleting it.
28746
- * Defaults to `true` so operators creating a rule via the UI
28747
- * see it active immediately.
28748
- */
28749
- enabled: boolean().default(true)
28750
- });
28751
- array(ZoneRuleSchema).readonly();
28752
- /**
28753
28861
  * Script-runner cap. Models HA `script.*` entities on
28754
28862
  * `DeviceType.Script`. A Script is a pre-recorded action sequence
28755
28863
  * that can be invoked imperatively — optionally with a variables
@@ -34242,6 +34350,12 @@ Object.freeze({
34242
34350
  addonId: null,
34243
34351
  access: "view"
34244
34352
  },
34353
+ "notificationRules.resolveArtifactUrl": {
34354
+ capName: "notification-rules",
34355
+ capScope: "system",
34356
+ addonId: null,
34357
+ access: "view"
34358
+ },
34245
34359
  "notificationRules.setAlarmConfig": {
34246
34360
  capName: "notification-rules",
34247
34361
  capScope: "system",
@@ -34686,6 +34800,12 @@ Object.freeze({
34686
34800
  addonId: null,
34687
34801
  access: "create"
34688
34802
  },
34803
+ "pipelineAnalytics.runReplayFrameProcessor": {
34804
+ capName: "pipeline-analytics",
34805
+ capScope: "device",
34806
+ addonId: null,
34807
+ access: "create"
34808
+ },
34689
34809
  "pipelineAnalytics.saveRetrainAnnotations": {
34690
34810
  capName: "pipeline-analytics",
34691
34811
  capScope: "device",
@@ -34818,6 +34938,12 @@ Object.freeze({
34818
34938
  addonId: null,
34819
34939
  access: "view"
34820
34940
  },
34941
+ "pipelineExecutor.getInferenceDeviceHealth": {
34942
+ capName: "pipeline-executor",
34943
+ capScope: "system",
34944
+ addonId: null,
34945
+ access: "view"
34946
+ },
34821
34947
  "pipelineExecutor.getOrchestratorConfigSchema": {
34822
34948
  capName: "pipeline-executor",
34823
34949
  capScope: "system",
@@ -34890,6 +35016,12 @@ Object.freeze({
34890
35016
  addonId: null,
34891
35017
  access: "view"
34892
35018
  },
35019
+ "pipelineExecutor.rearmInferenceDevice": {
35020
+ capName: "pipeline-executor",
35021
+ capScope: "system",
35022
+ addonId: null,
35023
+ access: "create"
35024
+ },
34893
35025
  "pipelineExecutor.runAudioTest": {
34894
35026
  capName: "pipeline-executor",
34895
35027
  capScope: "system",
@@ -35628,6 +35760,12 @@ Object.freeze({
35628
35760
  addonId: null,
35629
35761
  access: "view"
35630
35762
  },
35763
+ "recording.readWindowBytes": {
35764
+ capName: "recording",
35765
+ capScope: "system",
35766
+ addonId: null,
35767
+ access: "view"
35768
+ },
35631
35769
  "recording.refreshStorageLocationsForMigration": {
35632
35770
  capName: "recording",
35633
35771
  capScope: "system",
@@ -38138,6 +38276,11 @@ Object.freeze({
38138
38276
  form: "single",
38139
38277
  optional: false
38140
38278
  }],
38279
+ "pipelineAnalytics.runReplayFrameProcessor": [{
38280
+ name: "deviceId",
38281
+ form: "single",
38282
+ optional: false
38283
+ }],
38141
38284
  "pipelineAnalytics.saveRetrainAnnotations": [{
38142
38285
  name: "deviceId",
38143
38286
  form: "single",
@@ -38453,6 +38596,11 @@ Object.freeze({
38453
38596
  form: "single",
38454
38597
  optional: false
38455
38598
  }],
38599
+ "recording.readWindowBytes": [{
38600
+ name: "deviceId",
38601
+ form: "single",
38602
+ optional: false
38603
+ }],
38456
38604
  "recording.relocateFootage": [{
38457
38605
  name: "deviceId",
38458
38606
  form: "single",