@camstack/addon-provider-dreo 0.2.29 → 0.2.31

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