@camstack/addon-provider-unifi 0.2.29 → 0.2.31

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