@camstack/addon-provider-homematic 1.2.30 → 1.2.32

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