@camstack/addon-provider-gree 0.2.28 → 0.2.30

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