@camstack/addon-provider-dreo 0.2.29 → 0.2.31

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