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