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