@camstack/addon-provider-wyze 0.2.33 → 0.2.35

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