@camstack/addon-provider-wyze 0.2.33 → 0.2.35

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