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