@camstack/addon-provider-rademacher 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
@@ -16766,7 +16766,23 @@ var NcHistoryEntrySchema = object({
16766
16766
  updatedAt: number(),
16767
16767
  /** Failure detail — present on a `dead` row. */
16768
16768
  error: string().optional(),
16769
- subject: NcHistorySubjectSchema
16769
+ subject: NcHistorySubjectSchema,
16770
+ /**
16771
+ * Ids of the artefacts (still, then gif, then clip) this row's successful
16772
+ * delivery indexed in the artefact library — a REFERENCE, never the bytes
16773
+ * (an artefact is often megabytes; this row is durable JSON rewritten on
16774
+ * every delivery attempt). Absent on a row still pending/dead, a row
16775
+ * delivered before this field shipped, or a wiring with no artefact index.
16776
+ *
16777
+ * Resolve one to a fetchable URL with `resolveArtifactUrl` — an id
16778
+ * outlives any one URL's TTL, so a caller mints a fresh link on demand
16779
+ * rather than trusting one frozen at delivery time. `resolveArtifactUrl`
16780
+ * also answers `null` for an id whose artefact has since expired past the
16781
+ * retained shelf's own age bound — the degrade a caller (the Home
16782
+ * Assistant export) must render as "no image right now", never as a
16783
+ * broken link.
16784
+ */
16785
+ artifactIds: array(string().min(1)).optional()
16770
16786
  });
16771
16787
  /**
16772
16788
  * Query filter for `getHistory` (spec §4.2). Every field is a narrowing
@@ -16993,7 +17009,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
16993
17009
  }), method(object({}), object({
16994
17010
  catalog: array(NcConditionDescriptorSchema),
16995
17011
  taxonomy: NcTaxonomySchema.optional()
16996
- })), 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 }), {
17012
+ })), 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 }), {
16997
17013
  kind: "mutation",
16998
17014
  caller: "required"
16999
17015
  }), method(object({ snoozeId: string() }), object({ success: literal(true) }), {
@@ -17333,1760 +17349,1996 @@ var OauthIntegrationDescriptorSchema = object({
17333
17349
  });
17334
17350
  method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
17335
17351
  /**
17336
- * pipeline-analytics device-scoped wrapper cap. Refines raw
17337
- * per-frame detections emitted by the pipeline runner into tracked
17338
- * objects, per-kind event collections (motion / object / audio), and
17339
- * persisted media. Owns the post-detection domain end-to-end:
17340
- *
17341
- * runner emits PipelineInferenceResult
17342
- * ↓ (event bus)
17343
- * pipeline-analytics subscriber
17344
- * ↓ SORT tracker + zone engine + state analyzer + event emitter
17345
- * → three DB collections (one per kind), one FS media tree, one
17346
- * unified event emitter (FrameTracked + TrackStarted/Ended +
17347
- * DetectionEvent on bus)
17348
- *
17349
- * Pure subscriber model. No `processFrame` cap method — the runner
17350
- * already publishes the raw frame on the bus. The cap surface is
17351
- * only QUERIES + per-device settings, bound on/off via
17352
- * `device-manager.setWrapperActive`. `defaultActive: true` because
17353
- * every camera with a detection pipeline wants its raw detections
17354
- * refined; operators opt out per-device via BindingsTab when needed.
17355
- *
17356
- * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
17357
- * (per-device surface) and `track-trail` caps — see P11 cleanup.
17352
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
17353
+ * within the frame, so the executor can re-cut a leaf child ROI at native
17354
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
17358
17355
  */
17359
- var TrackStateSchema = _enum([
17360
- "new",
17361
- "entered",
17362
- "left",
17363
- "moving",
17364
- "idle"
17365
- ]);
17366
- var EventKindSchema = _enum([
17367
- "motion",
17368
- "object",
17369
- "audio"
17370
- ]);
17356
+ var NativeCropRefSchema = object({
17357
+ /** Handle keying the retained native surface (node-pinned to its owner). */
17358
+ handle: FrameHandleSchema,
17359
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
17360
+ cropFrameSpace: object({
17361
+ x: number(),
17362
+ y: number(),
17363
+ w: number(),
17364
+ h: number()
17365
+ })
17366
+ });
17367
+ object({
17368
+ crop: object({
17369
+ left: number(),
17370
+ top: number(),
17371
+ width: number().positive(),
17372
+ height: number().positive()
17373
+ }).optional(),
17374
+ content: object({
17375
+ width: number().int().positive(),
17376
+ height: number().int().positive()
17377
+ }),
17378
+ fit: _enum(["stretch", "contain"]),
17379
+ format: _enum([
17380
+ "rgb",
17381
+ "gray",
17382
+ "jpeg"
17383
+ ])
17384
+ });
17371
17385
  /**
17372
- * Spatial filter for `listTracks` the rect + polygon variants of the shared
17373
- * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
17374
- * of the camera frame (top-left origin), matching the drawing-plane editor.
17386
+ * Process-local frame identity. It is serializable so it can ride an in-process
17387
+ * capability call, but `registryId` deliberately prevents resolution in any
17388
+ * other process or execution group.
17375
17389
  */
17376
- var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
17377
- /** Closed icon vocabulary so clients render a known glyph per kind. */
17378
- var EventKindIconSchema = _enum([
17379
- "motion",
17380
- "audio",
17381
- "person",
17382
- "vehicle",
17383
- "animal",
17384
- "door",
17385
- "pir",
17386
- "smoke",
17387
- "water",
17388
- "button",
17389
- "package",
17390
- "generic"
17390
+ var FrameRefSchema = object({
17391
+ registryId: string().min(1),
17392
+ id: string().min(1),
17393
+ width: number().int().positive(),
17394
+ height: number().int().positive(),
17395
+ format: _enum(["rgb", "gray"]),
17396
+ timestamp: number(),
17397
+ capturedAt: number().optional()
17398
+ });
17399
+ var ModelFormatSchema$1 = _enum([
17400
+ "onnx",
17401
+ "coreml",
17402
+ "openvino",
17403
+ "tflite",
17404
+ "pt",
17405
+ "gguf"
17391
17406
  ]);
17392
- var EventKindCategorySchema = _enum([
17393
- "motion",
17394
- "audio",
17395
- "detection",
17396
- "sensor",
17397
- "control",
17398
- "custom",
17399
- "package"
17407
+ var PipelineSlotSchema = _enum([
17408
+ "detector",
17409
+ "cropper",
17410
+ "classifier",
17411
+ "refiner",
17412
+ "audio-classifier"
17400
17413
  ]);
17401
- /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
17402
- var EventKindLevelSchema = _enum(["macro", "sub"]);
17403
- var EventKindDescriptorSchema = object({
17404
- /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
17405
- kind: string(),
17406
- /** i18n key resolved on the UI side; `label` is the English fallback. */
17407
- labelKey: string(),
17408
- /** English fallback label (kept for clients that don't translate). */
17409
- label: string(),
17410
- /** Hex color for timeline/legend rendering. */
17411
- color: string(),
17412
- /** Dictionary id → lucide component on the UI side. */
17413
- iconId: string(),
17414
- /** Legacy closed-vocab glyph — fallback for `iconId`. */
17415
- icon: EventKindIconSchema,
17416
- category: EventKindCategorySchema,
17417
- /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
17418
- parentKind: string().nullable(),
17419
- /** Derived from `parentKind`, explicit for the client tree. */
17420
- level: EventKindLevelSchema,
17421
- /** Which cap + device contributes this kind. For built-ins the camera
17422
- * itself; for sensor kinds the LINKED source device. */
17423
- source: object({
17424
- capName: string(),
17425
- deviceId: number()
17426
- })
17414
+ var PipelineEngineChoiceSchema = object({
17415
+ runtime: _enum(["node", "python"]),
17416
+ backend: string(),
17417
+ format: ModelFormatSchema$1,
17418
+ device: string().optional()
17427
17419
  });
17428
- /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
17429
- var EventKindsForDeviceSchema = object({
17430
- deviceId: number(),
17431
- kinds: array(EventKindDescriptorSchema).readonly()
17420
+ var AvailableEngineSchema = object({
17421
+ engine: PipelineEngineChoiceSchema,
17422
+ devices: array(object({
17423
+ id: string(),
17424
+ label: string(),
17425
+ description: string().optional()
17426
+ })).readonly(),
17427
+ defaultDevice: string()
17432
17428
  });
17433
- var SensorEventSchema = object({
17429
+ var PipelineDefaultStepSchema = lazy(() => object({
17430
+ addonId: string(),
17431
+ addonName: string(),
17432
+ slot: PipelineSlotSchema,
17433
+ inputClasses: array(string()).readonly(),
17434
+ outputClasses: array(string()).readonly(),
17435
+ enabled: boolean(),
17436
+ modelId: string(),
17437
+ children: array(PipelineDefaultStepSchema).readonly(),
17438
+ group: string().optional(),
17439
+ settings: record(string(), unknown()).optional()
17440
+ }));
17441
+ var PipelineTemplateStepSchema = lazy(() => object({
17442
+ addonId: string(),
17443
+ enabled: boolean(),
17444
+ modelId: string(),
17445
+ children: array(PipelineTemplateStepSchema).readonly(),
17446
+ settings: record(string(), unknown()).optional()
17447
+ }));
17448
+ var PipelineTemplateSchema$1 = object({
17434
17449
  id: string(),
17435
- /** The CAMERA the event is attributed to (a sensor linked to N cameras
17436
- * yields N rows, one per camera). */
17437
- deviceId: number(),
17438
- /** The linked sensor device whose state changed. */
17439
- sourceDeviceId: number(),
17440
- /** Event kind id — matches an `EventKindDescriptor.kind`. */
17441
- kind: string(),
17442
- /** Snapshot of the sensor cap's runtime-state slice at the change. */
17443
- value: record(string(), unknown()).nullable(),
17444
- timestamp: number()
17450
+ name: string(),
17451
+ createdAt: string(),
17452
+ updatedAt: string(),
17453
+ engine: PipelineEngineChoiceSchema,
17454
+ steps: array(PipelineTemplateStepSchema).readonly()
17445
17455
  });
17446
- var TrackPositionSchema = object({
17447
- x: number(),
17448
- y: number(),
17449
- timestamp: number(),
17450
- bbox: BoundingBoxSchema
17456
+ var PipelineModelOptionSchema = object({
17457
+ id: string(),
17458
+ name: string(),
17459
+ formats: record(string(), object({
17460
+ downloaded: boolean(),
17461
+ sizeMB: number()
17462
+ })),
17463
+ group: ModelVariantGroupSchema.optional(),
17464
+ legacy: boolean().optional(),
17465
+ provider: ModelProviderIdSchema.optional()
17451
17466
  });
17452
- var TrackSnapshotSchema = object({
17453
- timestamp: number(),
17454
- position: TrackPositionSchema,
17455
- /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
17456
- mediaKey: string()
17467
+ var ConfigFieldBridge = custom();
17468
+ var PipelineAddonSchemaSchema = object({
17469
+ id: string(),
17470
+ name: string(),
17471
+ slot: PipelineSlotSchema,
17472
+ inputClasses: array(string()).readonly(),
17473
+ outputClasses: array(string()).readonly(),
17474
+ childSlots: array(PipelineSlotSchema).readonly(),
17475
+ models: array(PipelineModelOptionSchema).readonly(),
17476
+ defaultModelId: string(),
17477
+ defaultModelIdByFormat: record(string(), string()).optional(),
17478
+ enabledByDefault: boolean().optional(),
17479
+ backfillIntoExistingOverrides: boolean().optional(),
17480
+ defaultConfidence: number(),
17481
+ group: string().optional(),
17482
+ configSchema: array(ConfigFieldBridge).readonly().optional()
17457
17483
  });
17458
- /**
17459
- * Normalized 0..1 trajectory envelope (min/max over every position bbox,
17460
- * divided by the track's detection-frame dims), computed at persist time.
17461
- * Absent when the frame dims were unknown when the track was persisted
17462
- * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
17463
- */
17464
- var TrackEnvelopeSchema = object({
17465
- minX: number(),
17466
- minY: number(),
17467
- maxX: number(),
17468
- maxY: number()
17484
+ var PipelineSlotSchemaSchema = object({
17485
+ id: PipelineSlotSchema,
17486
+ label: string(),
17487
+ priority: number(),
17488
+ parentSlot: PipelineSlotSchema.nullable(),
17489
+ addons: array(PipelineAddonSchemaSchema).readonly()
17469
17490
  });
17470
- /**
17471
- * Row projection for track list queries. `full` (default) returns the
17472
- * complete Track including the frame-rate `positions[]` history and the
17473
- * `snapshots[]` references — megabytes across a page of tracks. `slim`
17474
- * keeps every scalar the list surfaces actually render (ids, class(es),
17475
- * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
17476
- * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
17477
- * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
17478
- * `getTrack`. Mirrors the event-store `projection` convention
17479
- * (`getObjectEvents` et al.).
17480
- */
17481
- var TrackProjectionSchema = _enum(["full", "slim"]);
17482
- /**
17483
- * One audio-classification label heard on the track's camera while the
17484
- * track was alive, aggregated per label. An "episode" is one persisted
17485
- * audio event (the confident-classification path: score ≥ the device's
17486
- * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
17487
- * one 32 ms inference chunk, so counts stay human-scaled.
17488
- */
17489
- var TrackAudioLabelSchema = object({
17490
- label: string(),
17491
- /** Highest classification score observed across the label's episodes. */
17492
- peakScore: number(),
17493
- /** Number of coalesced audio-event episodes carrying this label. */
17494
- count: number(),
17495
- firstAt: number(),
17496
- lastAt: number()
17491
+ var PipelineSchemaSchema = object({
17492
+ availableEngines: array(AvailableEngineSchema).readonly(),
17493
+ selectedEngine: PipelineEngineChoiceSchema,
17494
+ slots: array(PipelineSlotSchemaSchema).readonly()
17497
17495
  });
17498
- /**
17499
- * How a track was produced. `pipeline` (default / absent) = the spatial
17500
- * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
17501
- * no positions, a single snapshot, and no bbox trajectory at all:
17502
- *
17503
- * - `sensor` — a linked sensor/control device state change.
17504
- * - `audio` — an audio event on the camera itself that was anomalous for
17505
- * THAT camera, loud, and heard while nothing visual was happening (D62).
17506
- *
17507
- * The spatial subsystems (tracker association, occupancy count, re-id /
17508
- * embedding, resurrection) MUST skip every synthetic source. Test for that
17509
- * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
17510
- * check silently readmits every source added after it was written.
17511
- */
17512
- var TrackSourceSchema = _enum([
17513
- "pipeline",
17514
- "sensor",
17515
- "audio"
17516
- ]);
17517
- /**
17518
- * Where a track sits in the RETRAIN lifecycle (D81).
17519
- *
17520
- * - `none` never marked, or un-marked. Evictable.
17521
- * - `staging`the operator wants this track as training material and has not
17522
- * finished with it. **This is the only state retention holds**: the track and
17523
- * everything it owns (object events, crops, keyframes, CLIP vector) survive
17524
- * the device's age window.
17525
- * - `trained` — the retrain page has taken what it needed. The frames it chose
17526
- * were COPIED into the retrain dataset at selection time, so the dataset no
17527
- * longer depends on the track's media and the track becomes EVICTABLE again.
17528
- * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
17529
- * a deliberate action of the retrain page, not a side effect of a checkbox.
17530
- *
17531
- * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
17532
- * the store's filter language has only positive equality and `whereIn` — no
17533
- * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
17534
- * would make the entire pre-column history immortal in one deploy.
17535
- */
17536
- var RetrainStatusSchema = _enum([
17537
- "none",
17538
- "staging",
17539
- "trained"
17540
- ]);
17541
- /**
17542
- * Per-track OPERATOR flags — set by hand from the admin UI or the viewer, never
17543
- * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
17544
- * so the two surfaces cannot drift.
17545
- *
17546
- * **Absent ≠ false.** A track that has never been touched omits the field; an
17547
- * explicitly un-flagged track carries `false`. Legacy rows written before the
17548
- * columns existed read as absent, and a consumer that needs a boolean should say
17549
- * `flag === true`, not `flag !== false`.
17550
- *
17551
- * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
17552
- * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
17553
- * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
17554
- * `trained` track reports `false` while refusing both writes. The boolean is
17555
- * kept because three surfaces drive a toggle off it; anything that needs to tell
17556
- * "never marked" from "already trained" must read `retrainStatus`.
17557
- *
17558
- * `debug` does NOT pin; it is attention, not durability.
17559
- *
17560
- * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
17561
- * A favourited track is skipped by retention the same way `staging` is, but
17562
- * it does not enter `none|staging|trained` and has no staging budget.
17563
- */
17564
- var TrackFlagFields = {
17565
- /** Operator marked this track as training material — i.e. `retrainStatus` is
17566
- * `'staging'`. */
17567
- markForTrain: boolean().optional(),
17568
- /** Operator marked this track for diagnostic attention. */
17569
- debug: boolean().optional(),
17570
- /** Operator favourited this track. Pins it against pruning. */
17571
- favourited: boolean().optional()
17572
- };
17573
- /**
17574
- * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
17575
- * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
17576
- * write patch, and the status is not something the toggle sets — it is what the
17577
- * toggle's boolean is derived from. Absent on an in-RAM track never touched;
17578
- * always present on a persisted row (the column default materialises `'none'`).
17579
- */
17580
- var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
17581
- /**
17582
- * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
17583
- * one flag can never clear the other — the toggles are independent and are
17584
- * driven from three surfaces that do not know about each other.
17585
- */
17586
- var TrackFlagsPatchSchema = object(TrackFlagFields);
17587
- /**
17588
- * The resolved flag state after a write. Both fields are REQUIRED here (absent
17589
- * collapses to `false`) so a caller can drive a toggle's checked state off the
17590
- * mutation result without a re-fetch.
17591
- */
17592
- var TrackFlagsSchema = object({
17593
- trackId: string(),
17594
- markForTrain: boolean(),
17595
- debug: boolean(),
17596
- favourited: boolean(),
17597
- /** The lifecycle state the boolean was derived from. Required here (unlike on
17598
- * a track row) because this shape is only ever produced by the write body,
17599
- * which always knows it — and a surface that has just written needs to render
17600
- * `trained` without a re-fetch. */
17601
- retrainStatus: RetrainStatusSchema
17496
+ var EngineProvisioningSchema = object({
17497
+ runtimeId: _enum([
17498
+ "onnx",
17499
+ "openvino",
17500
+ "coreml",
17501
+ "edgetpu"
17502
+ ]).nullable(),
17503
+ device: string().nullable(),
17504
+ state: _enum([
17505
+ "idle",
17506
+ "installing",
17507
+ "verifying",
17508
+ "ready",
17509
+ "failed"
17510
+ ]),
17511
+ progress: number().optional(),
17512
+ error: string().optional(),
17513
+ nextRetryAt: number().optional(),
17514
+ /**
17515
+ * Gate A (config-correctness gate at engine change): human-readable
17516
+ * config issues surfaced EAGERLY when the node's engine changes — model
17517
+ * substitutions ("chose X, running Y") and zero-build steps ("no model
17518
+ * has a <format> build"). Additive/optional: informational only, never
17519
+ * enforced here `assertEngineReady` (readiness) still gates inference.
17520
+ * Absent/empty when the node-default tree resolves cleanly.
17521
+ */
17522
+ configIssues: array(string()).optional()
17602
17523
  });
17603
- union([literal(1), literal(2)]);
17604
- /**
17605
- * WHO decided a label, and when. Carried per tier so a value can be traced to
17606
- * the step and model that produced it — which is what makes the write rule
17607
- * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
17608
- * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
17609
- *
17610
- * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
17611
- * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
17612
- * `migration:4g` for a value the 4g migration moved from the single-slot era —
17613
- * that value has no provenance, and the write rule lets ANY properly-attributed
17614
- * write of the same tier replace it regardless of score.
17615
- */
17616
- var LabelAttributionSchema = object({
17617
- stepId: string(),
17524
+ var PipelineStepInputSchema = lazy(() => object({
17525
+ addonId: string(),
17618
17526
  modelId: string().optional(),
17619
- decidedAt: number(),
17527
+ enabled: boolean().default(true),
17528
+ children: array(PipelineStepInputSchema).optional(),
17529
+ settings: record(string(), unknown()).optional(),
17530
+ jumpDeviceKey: string().optional()
17531
+ }));
17532
+ var ModelSubstitutionSchema = object({
17533
+ addonId: string(),
17534
+ chosen: string(),
17535
+ running: string(),
17536
+ format: string()
17537
+ });
17538
+ var PipelineValidationIssueSchema = object({
17539
+ addonId: string(),
17540
+ kind: _enum(["unknown-addon", "no-format-build"]),
17541
+ detail: string()
17542
+ });
17543
+ var PipelineValidationResultSchema = object({
17544
+ ok: boolean(),
17545
+ issues: array(PipelineValidationIssueSchema).readonly(),
17546
+ substitutions: array(ModelSubstitutionSchema).readonly(),
17547
+ /** The node's `currentEngine.format` this validation ran against. */
17548
+ format: string()
17549
+ });
17550
+ var ReferenceImageEntrySchema = object({
17551
+ filename: string(),
17552
+ stepIds: array(string()).readonly().optional()
17553
+ });
17554
+ var ReferenceImageBodySchema = object({
17555
+ base64: string(),
17556
+ filename: string()
17557
+ });
17558
+ var ReferenceAudioEntrySchema = object({
17559
+ filename: string(),
17560
+ sizeKb: number()
17561
+ });
17562
+ var ReferenceAudioBodySchema = object({ base64: string() });
17563
+ var AudioBackendSchema = object({
17564
+ id: string(),
17565
+ name: string(),
17566
+ description: string(),
17567
+ available: boolean(),
17620
17568
  /**
17621
- * The GALLERY id behind a recognised tier-2 label — a face-gallery
17622
- * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
17623
- *
17624
- * The text alone is a DISPLAY NAME, and a display name is renameable: a
17625
- * notification rule authored on "Gianluca" stopped matching the moment the
17626
- * operator fixed the spelling in the gallery, and nothing said so. The id is
17627
- * the thing that does not move, so it is what a rule matches on
17628
- * (`NcConditions.identities`) and the text is what a human is shown.
17629
- *
17630
- * Absent when the label names no gallery row — a plate the OCR read but no
17631
- * vehicle claims, a sub-class, a species, any tier-1 value.
17569
+ * Raw classifier labels this backend can emit (e.g. YAMNet's
17570
+ * 521-class set or Apple SoundAnalysis's 303-class set). Used by
17571
+ * the benchmark UI to populate the `enabledMicroClasses` filter
17572
+ * specific to the selected backend without a separate fetch.
17632
17573
  */
17633
- identityId: string().optional()
17574
+ rawLabels: array(string()).readonly().optional()
17575
+ });
17576
+ var AudioCapabilitiesSchema = object({
17577
+ activeBackend: string(),
17578
+ availableBackends: array(AudioBackendSchema).readonly(),
17579
+ sampleRate: number(),
17580
+ chunkDurationMs: number()
17581
+ });
17582
+ var DownloadModelResultSchema = object({
17583
+ filePath: string(),
17584
+ sizeMB: number(),
17585
+ durationMs: number()
17634
17586
  });
17635
17587
  /**
17636
- * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
17637
- * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
17638
- * track and its events always answer the same question the same way.
17639
- *
17640
- * Two scalar columns, not an array: every consumer wants "the coarse one" or
17641
- * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
17642
- * is tier 2, and each carries its own score + attribution.
17643
- *
17644
- * **Reading it.** What a human should be shown is `subLabel ?? label` — the
17645
- * finest thing known. Before 4g the single `label` column held the finest
17646
- * value, so a consumer that has not been updated reads the tier-1 slot and
17647
- * shows nothing on a species-only row; that is why the migration puts every
17648
- * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
17649
- * and why the read surfaces were changed in the same train.
17650
- *
17651
- * **Writing it.** The slots are independent, which is the whole point: a
17652
- * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
17653
- * migratorius`), so fineness cannot regress by construction. Within a tier the
17654
- * higher score wins. One rule, one implementation — see
17655
- * `pipeline/label-tier.ts` in addon-post-analysis.
17656
- */
17657
- var TieredLabelFields = {
17658
- /** Tier 1 — the sub-class. See {@link LabelTierSchema}. */
17659
- label: string().optional(),
17660
- /** Confidence of the tier-1 value, as reported by the deciding step. */
17661
- labelScore: number().optional(),
17662
- /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
17663
- labelMeta: LabelAttributionSchema.optional(),
17664
- /** Tier 2 — the instance. See {@link LabelTierSchema}. */
17665
- subLabel: string().optional(),
17666
- /** Confidence of the tier-2 value, as reported by the deciding step. */
17667
- subLabelScore: number().optional(),
17668
- /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
17669
- subLabelMeta: LabelAttributionSchema.optional()
17670
- };
17671
- /** Per-camera slice of a training-export estimate. */
17672
- var TrainingExportDeviceTotalsSchema = object({
17673
- deviceId: number(),
17674
- tracks: number().int(),
17675
- files: number().int(),
17676
- bytes: number().int()
17677
- });
17678
- /**
17679
- * What a training export WOULD contain. Computed from media index rows only —
17680
- * no blob is read to produce this.
17588
+ * Wrapper carrying a single test run's result. Replaces the legacy
17589
+ * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
17590
+ * canonical `AudioResult` from the Phase 6 output rework: one
17591
+ * `AudioDetection` per class above `minScore`, top-N candidates in
17592
+ * `debug.alternateLabels['audio-classifier']`, per-source timings in
17593
+ * `debug.stepTimings`. The outer `success`/`error` fields stay so the
17594
+ * benchmark UI can still report a clean failure when the classifier
17595
+ * cap isn't available.
17681
17596
  */
17682
- var TrainingExportSummarySchema = object({
17683
- generatedAt: number(),
17684
- trackCount: number().int(),
17685
- fileCount: number().int(),
17686
- byteCount: number().int(),
17687
- /** More marked tracks exist than a single pass carries. */
17688
- truncated: boolean(),
17689
- devices: array(TrainingExportDeviceTotalsSchema).readonly()
17597
+ var AudioTestResultSchema = object({
17598
+ success: boolean(),
17599
+ error: string().optional(),
17600
+ frame: custom().optional()
17690
17601
  });
17691
- var TrackSchema = object({
17692
- trackId: string(),
17693
- deviceId: number(),
17694
- className: string(),
17695
- ...TieredLabelFields,
17696
- producingDeviceName: string().optional(),
17697
- /** Track provenance. Absent `pipeline` (legacy rows). */
17698
- source: TrackSourceSchema.optional(),
17699
- firstSeen: number(),
17700
- lastSeen: number(),
17701
- /** Frame-rate position history (subject to maxPositionHistory cap). */
17702
- positions: array(TrackPositionSchema).readonly(),
17703
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
17704
- * saveThumbnails policy). */
17705
- snapshots: array(TrackSnapshotSchema).readonly(),
17706
- /** Deduplicated zones the track has entered at least once. Zone IDS. */
17707
- zonesVisited: array(string()).readonly(),
17602
+ var PipelineConfigBridge = custom();
17603
+ var ConfigUISchemaBridge = custom();
17604
+ var ConfigUISchemaNullableBridge = custom();
17605
+ var InferenceCapabilitiesBridge = custom();
17606
+ var ModelAvailabilityListBridge = custom();
17607
+ var PipelineRunResultBridge = custom();
17608
+ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
17609
+ modelId: string(),
17610
+ settings: record(string(), unknown()).readonly()
17611
+ }))), method(object({ steps: record(string(), object({
17612
+ modelId: string(),
17613
+ settings: record(string(), unknown()).readonly()
17614
+ })) }), object({ success: literal(true) }), {
17615
+ kind: "mutation",
17616
+ auth: "admin"
17617
+ }), method(object({ nodeId: string() }), object({
17618
+ success: literal(true),
17619
+ clearedDevices: number()
17620
+ }), {
17621
+ kind: "mutation",
17622
+ auth: "admin"
17623
+ }), method(object({ nodeId: string() }), object({ unhealthy: array(object({
17624
+ /** `<backend>:<device>`, e.g. `openvino:gpu`. */
17625
+ deviceKey: string(),
17708
17626
  /**
17709
- * Human NAMES for {@link zonesVisited}, resolved at READ time against the
17710
- * `zones` capability.
17711
- *
17712
- * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
17713
- * and no card can render — so every free-text search surface was structurally
17714
- * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
17715
- * just returned nothing. Resolving here rather than in each client keeps ONE
17716
- * derivation and costs the clients no extra call (the `zones` cap is
17717
- * per-device, so a client-side resolve would be a per-camera fan-out on a
17718
- * surface built to avoid exactly that).
17719
- *
17720
- * Resolved, never invented: a zone deleted since the track was written has no
17721
- * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
17722
- * two are not positionally aligned. Absent when the track visited no zone, or
17723
- * when the zone catalogue could not be read.
17627
+ * `failed` the per-device restart budget is exhausted; no pool
17628
+ * will be spawned until an operator re-arms it or the runner
17629
+ * respawns. `backoff` — under budget, waiting out the backoff (or
17630
+ * a cached pool observed dead and not yet condemned).
17724
17631
  */
17725
- zoneNames: array(string()).readonly().optional(),
17726
- /** Deduplicated set of detector classes observed for this track over its
17727
- * life (a track may be reclassified, e.g. person→vehicle). Absent on
17728
- * legacy rows written before class accumulation shipped. */
17729
- classes: array(string()).readonly().optional(),
17730
- /** Cumulative normalized distance travelled (0..1 units = full frame width). */
17731
- totalDistance: number(),
17732
- state: TrackStateSchema,
17733
- active: boolean(),
17734
- /** Deterministic key-event importance score in [0,1] (server-computed at
17735
- * track expiry, recomputed on late label). Absent on legacy rows written
17736
- * before scoring shipped — consumers degrade to absence / compute-on-read. */
17737
- importance: number().optional(),
17738
- /** Id of the track's highest-confidence ObjectEvent (its representative
17739
- * "best" frame). Absent when the track produced no object events. */
17740
- bestEventId: string().optional(),
17741
- /** Tag of the importance sub-signal that dominated the score
17742
- * (identity|dwell|proximity|class|confidence|travel|zone). */
17743
- importanceReason: string().optional(),
17744
- /** Audio-classification labels heard on the camera during the track's
17745
- * life (score ≥ device `classificationMinScore`), aggregated per label.
17746
- * Absent on legacy rows / tracks with no confident audio. */
17747
- audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
17748
- /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
17749
- * Populated from the persisted envelope columns on historical reads;
17750
- * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
17751
- envelope: TrackEnvelopeSchema.optional(),
17632
+ state: _enum(["failed", "backoff"]),
17633
+ /** Epoch ms of the death that produced this state. */
17634
+ since: number(),
17635
+ /** Pool deaths inside the current window. */
17636
+ deaths: number(),
17637
+ /** The last death's message. */
17638
+ lastError: string()
17639
+ })).readonly() })), method(object({
17640
+ nodeId: string(),
17641
+ deviceKey: string()
17642
+ }), object({ rearmed: boolean() }), {
17643
+ kind: "mutation",
17644
+ auth: "admin"
17645
+ }), 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({
17646
+ name: string(),
17647
+ steps: array(PipelineTemplateStepSchema).readonly(),
17648
+ engine: PipelineEngineChoiceSchema
17649
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
17650
+ id: string(),
17651
+ name: string().optional(),
17652
+ steps: array(PipelineTemplateStepSchema).readonly().optional()
17653
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
17654
+ addonId: string(),
17655
+ modelId: string(),
17656
+ format: ModelFormatSchema$1
17657
+ }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
17658
+ addonId: string(),
17659
+ modelId: string(),
17660
+ format: ModelFormatSchema$1
17661
+ }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
17662
+ engine: PipelineEngineChoiceSchema.optional(),
17663
+ steps: array(PipelineStepInputSchema).min(1),
17664
+ frame: FrameInputSchema.optional(),
17752
17665
  /**
17753
- * A face DETECTOR found a face on this track — nothing more. It says the
17754
- * detail plane produced a `face` detail; it does NOT say the face was
17755
- * embedded, matched, above `minFacePx`, or that the recognizer was even
17756
- * enabled. Set once and never cleared.
17757
- *
17758
- * **This exists so "face present but not recognised" is expressible.** A
17759
- * recognised identity lands in `subLabel` (attributed to the face chain via
17760
- * `subLabelMeta.stepId`), so before this field a track with an unmatched face
17761
- * and a track with no face at all were byte-identical on the wire and no
17762
- * surface could tell them apart. The read is `hasFace === true && subLabel
17763
- * === undefined`.
17764
- *
17765
- * **Absent ≠ false.** Every row written before the column existed omits it,
17766
- * and so does every server that predates the field — a consumer must test
17767
- * `=== true` and render nothing otherwise, never infer "no face".
17666
+ * Process-local lazy frame. Valid only when caller and provider resolve
17667
+ * in the same execution-group process; split/cross-node callers use
17668
+ * `frame`/`image` inline compatibility instead.
17768
17669
  */
17769
- hasFace: boolean().optional(),
17670
+ frameRef: FrameRefSchema.optional(),
17770
17671
  /**
17771
- * This track has a face row IN THE GALLERY: a crop **and** an embedding a
17772
- * face an operator could ASSIGN to an identity.
17773
- *
17774
- * The STRICT twin of {@link hasFace}, and the pair only earns its keep
17775
- * because the two disagree. `hasFace` is stamped at the TOP of the face
17776
- * branch, before every gate, and means no more than "a face detector produced
17777
- * a face detail". This one is stamped at the single moment the gallery row
17778
- * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
17779
- * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
17780
- * candidate gate, the imageless-track drop (no crop was ever captured) and
17781
- * the crop-store drop. Everything between the detector and that insert can
17782
- * legitimately refuse the face, so a flag written any earlier promises the
17783
- * operator something to assign and delivers nothing.
17784
- *
17785
- * **Independent of recognition.** A face collected but never auto-matched is
17786
- * still assignable — it is in fact the face an operator most wants to reach —
17787
- * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
17788
- * `subLabel`; this says only that the raw material exists.
17789
- *
17790
- * **Set once, never cleared.** A track that produced a gallery row produced
17791
- * one; deleting the row later is the gallery's business, not this flag's.
17792
- *
17793
- * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
17794
- * before the column omits it, and so does every server that predates the
17795
- * field. A consumer must test `=== true` and render nothing otherwise —
17796
- * never infer "no assignable face".
17672
+ * CB5 shm passthrough a `FrameHandle` naming the same ring slot
17673
+ * the decoded pixels live in. One more member of the one-of
17674
+ * frame/frameHandle/image/imageBase64/referenceImage group.
17797
17675
  */
17798
- hasEmbeddedFace: boolean().optional(),
17676
+ frameHandle: FrameHandleSchema.optional(),
17677
+ imageBase64: string().optional(),
17799
17678
  /**
17800
- * This subject CONTAINS a folded rider a person the rider-pairing step
17801
- * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
17802
- * so the passage is tracked once and as a VEHICLE.
17803
- *
17804
- * It exists because the fold's record was dishonest. D34 and the code both
17805
- * said "the person is not lost — it is reported so both entities stay on the
17806
- * record"; in fact the pair went into a per-processor RAM field behind an
17807
- * accessor nobody called, and every durable surface said `vehicle`, full
17808
- * stop. This is the composition note that makes the row true.
17809
- *
17810
- * A COMPOSITION, never a class and never a label. "This vehicle contains a
17811
- * person" is not an answer to "what is this" — both label tiers would refuse
17812
- * a macro token anyway (D89), and correctly. Nothing here changes what the
17813
- * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
17814
- * and a `person` rule still does not fire for someone cycling past.
17815
- *
17816
- * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
17817
- * the column, and every hub that predates the field, omits it. Test
17818
- * `=== true` and render nothing otherwise — never infer "no rider".
17679
+ * Binary JPEG bytespreferred over `imageBase64` on internal
17680
+ * hops (hub forked worker via Moleculer MsgPack) because it
17681
+ * skips the 33% base64 overhead + the per-call base64 decode on
17682
+ * the detection-pipeline worker. Callers can pass either; exactly
17683
+ * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
17819
17684
  */
17820
- hasRider: boolean().optional(),
17821
- ...TrackFlagFields,
17822
- ...TrackRetrainFields
17823
- });
17824
- var BaseEventFields = {
17825
- id: string(),
17826
- deviceId: number(),
17827
- timestamp: number()
17828
- };
17829
- var MotionEventSchema = object({
17830
- ...BaseEventFields,
17831
- kind: literal("motion"),
17832
- regionCount: number(),
17833
- /** Heavy JSON array omitted in slim projection. */
17834
- regions: array(object({
17835
- bbox: BoundingBoxSchema,
17836
- pixelCount: number(),
17837
- intensity: number()
17838
- })).readonly().optional(),
17839
- /** Omitted in slim projection. */
17840
- frameWidth: number().optional(),
17841
- /** Omitted in slim projection. */
17842
- frameHeight: number().optional(),
17843
- /** Populated by B5 (recording playback URL for this event). */
17844
- mediaUrl: string().optional()
17845
- });
17685
+ image: _instanceof(Uint8Array).optional(),
17686
+ referenceImage: string().optional(),
17687
+ deviceId: number().optional(),
17688
+ sessionId: string().optional(),
17689
+ /**
17690
+ * Execution plane. 'full' (default) runs the whole tree — benchmark,
17691
+ * reference-image, and detail-subtree calls. 'frame' is the live
17692
+ * per-frame dispatch: ONLY root-plane steps run; crop children
17693
+ * (inputClasses ≠ null) are skipped and served per-track via
17694
+ * pipelineRunner.runDetailSubtree (two-plane design).
17695
+ */
17696
+ plane: _enum(["full", "frame"]).optional(),
17697
+ /**
17698
+ * Inference-device selector (Phase 2 multi-device). Format
17699
+ * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
17700
+ * Omitted ⇒ the runner's default device (current single-engine
17701
+ * behaviour). Selects WHICH device pool of the node runs the call.
17702
+ */
17703
+ deviceKey: string().optional(),
17704
+ /**
17705
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
17706
+ * when the parent crop was resolved from the frame's retained NATIVE
17707
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
17708
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
17709
+ * resolution from that surface — the SAME quality path faces already
17710
+ * had — instead of the downscaled parent tile. `handle` keys the native
17711
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
17712
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
17713
+ * the executor's crop-normalized child ROI back into frame-normalized
17714
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
17715
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
17716
+ * (today's behaviour on the fallback path).
17717
+ */
17718
+ nativeCropRef: NativeCropRefSchema.optional()
17719
+ }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
17720
+ engine: PipelineEngineChoiceSchema.optional(),
17721
+ steps: array(PipelineStepInputSchema).min(1),
17722
+ frames: array(FrameInputSchema).min(1).max(255),
17723
+ deviceId: number().optional(),
17724
+ sessionId: string().optional(),
17725
+ /**
17726
+ * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
17727
+ * the batch to the Python pool's bench preprocess cache
17728
+ * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
17729
+ * preprocessed ONCE and every later inference is a pure-inference cache
17730
+ * hit — the sustained-throughput run measures inference, not
17731
+ * decode+preprocess+infer. Omitted/0 for live frames (all different →
17732
+ * full preprocess every call, correct). Fresh per sustained run;
17733
+ * released via `uncacheFrame`.
17734
+ */
17735
+ frameId: number().int().nonnegative().optional(),
17736
+ /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
17737
+ deviceKey: string().optional()
17738
+ }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
17739
+ data: _instanceof(Uint8Array),
17740
+ width: number().int().positive(),
17741
+ height: number().int().positive(),
17742
+ format: _enum([
17743
+ "rgb",
17744
+ "bgr",
17745
+ "gray"
17746
+ ])
17747
+ }), object({
17748
+ frameId: number(),
17749
+ width: number(),
17750
+ height: number()
17751
+ }), { kind: "mutation" }), method(object({
17752
+ stepId: string(),
17753
+ frameId: number().int()
17754
+ }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
17755
+ batchMode: string(),
17756
+ windowMs: number(),
17757
+ maxBatchSize: number(),
17758
+ concurrency: number()
17759
+ })), method(_void(), array(object({
17760
+ engineKey: string(),
17761
+ engine: PipelineEngineChoiceSchema,
17762
+ modelsLoaded: array(string()).readonly(),
17763
+ inUseByCameras: array(number()).readonly(),
17764
+ /**
17765
+ * Origin of this resident factory.
17766
+ * - `runtime` — main camera-serving engine (no idle TTL).
17767
+ * - `warm-override` — benchmark/test override held in the warm
17768
+ * cache; auto-disposed after the idle TTL.
17769
+ * - `device-pool` — a concurrent per-device pool (Phase 2
17770
+ * multi-device, keyed by `deviceKey`) resolved
17771
+ * via `resolveDeviceFactory`. Runs alongside the
17772
+ * `runtime` engine on a DIFFERENT accelerator
17773
+ * (NPU / iGPU / Coral) — this is how the
17774
+ * Engines tab shows all pools running at once.
17775
+ */
17776
+ kind: _enum([
17777
+ "runtime",
17778
+ "warm-override",
17779
+ "device-pool"
17780
+ ]),
17781
+ /** Native pid of the underlying Python pool (null when no pool). */
17782
+ poolPid: number().nullable(),
17783
+ /** ms since this factory was last used (null when not warm-tracked). */
17784
+ idleMs: number().nullable(),
17785
+ /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
17786
+ idleTtlMs: number().nullable()
17787
+ })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
17788
+ kind: "mutation",
17789
+ auth: "admin"
17790
+ }), method(object({
17791
+ engine: PipelineEngineChoiceSchema,
17792
+ force: boolean().optional()
17793
+ }), object({
17794
+ success: boolean(),
17795
+ reason: string().optional()
17796
+ }), {
17797
+ kind: "mutation",
17798
+ auth: "admin"
17799
+ }), 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({
17800
+ addonId: string(),
17801
+ modelId: string(),
17802
+ filename: string().optional(),
17803
+ settings: record(string(), unknown()).optional()
17804
+ }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
17846
17805
  /**
17847
- * Which detection SOURCE produced an object event. `pipeline` = the ML
17848
- * detection pipeline (decoded-frame inference); `onboard` = the camera's
17849
- * native on-device AI. Both flow through the SAME analysis layers (zoning,
17850
- * tracking, per-kind persistence) but stay distinguishable so consumers
17851
- * (advanced-notifier, occupancy, …) can select which source(s) to act on.
17852
- * Absent on legacy rows treat as `pipeline`.
17806
+ * Per-stage gating mode applied to the zones a rule references.
17807
+ *
17808
+ * - `include`: the rule contributes to a **whitelist** for its stage.
17809
+ * When at least one `include` rule fires for a stage, only entities
17810
+ * inside one of those zones pass that stage.
17811
+ * - `exclude`: the rule contributes to a **blacklist** for its stage.
17812
+ * Entities inside one of those zones are dropped at that stage.
17813
+ *
17814
+ * `monitor`-style observation (count without filtering) is not a rule
17815
+ * mode — zones without any matching rule are observed naturally by
17816
+ * `zone-analytics` (live snapshot + history), so an "I just want to
17817
+ * count, not filter" use case needs no rule at all.
17853
17818
  */
17854
- var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
17819
+ var ZoneRuleModeEnum = _enum(["include", "exclude"]);
17855
17820
  /**
17856
- * The confirmed zone crossing that produced an object event. Present ONLY on
17857
- * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
17858
- * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
17859
- * appearance event carry none, so a rule asking for a direction fails closed
17860
- * on them.
17821
+ * Per-consumer rule that references existing zones (geometry) and
17822
+ * defines how a specific pipeline stage should treat them. Each
17823
+ * consumer addon owns its own `ZoneRule[]` array in its per-device
17824
+ * settings:
17861
17825
  *
17862
- * Exactly ONE crossing per event: the emitter turns each confirmed crossing
17863
- * into its own event, so a frame in which a track enters A while leaving B
17864
- * produces two events with two directions — never one ambiguous row.
17826
+ * - `addon-motion-wasm` `motionZoneRules: ZoneRule[]` (motion stage)
17827
+ * - `addon-detection-pipeline` `detectionZoneRules: ZoneRule[]` (detection stage)
17828
+ * - future: notification rules, audio gating, etc.
17865
17829
  *
17866
- * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
17867
- * membership the box has NOW, and by definition it no longer contains the zone
17868
- * that was just left. Without the id here, a zone-scoped rule could never match
17869
- * the exit it asked for.
17830
+ * One rule applies to N zones (`zoneIds[]`) so the operator can
17831
+ * express "ignore motion in ALL of {garden, street}" with a single
17832
+ * rule. `classFilter` narrows the rule to specific object classes
17833
+ * "drop person detections in the street, but keep cars" is one
17834
+ * `exclude` rule with `classFilter: ['person']`.
17835
+ *
17836
+ * `enabled` is a soft toggle — the operator can keep the rule
17837
+ * configured but inert without deleting it.
17870
17838
  */
17871
- var ZoneCrossingSchema = object({
17872
- direction: _enum(["enter", "exit"]),
17873
- /** Admin zone id crossed. */
17874
- zoneId: string(),
17875
- /** Zone display name at crossing time (falls back to the id). */
17876
- zoneName: string().optional()
17877
- });
17878
- var ObjectEventSchema = object({
17879
- ...BaseEventFields,
17880
- kind: literal("object"),
17881
- /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
17882
- source: DetectionSourceSchema.optional(),
17839
+ var ZoneRuleSchema = object({
17840
+ /** Stable rule id — survives edits, used by the UI for diffing. */
17841
+ id: string(),
17842
+ /** Optional human-readable label rendered in the rule editor. */
17843
+ name: string().optional(),
17844
+ /** Zones this rule targets. The rule's `mode` applies to ALL
17845
+ * listed zones (OR-set: a detection in any one of them counts).
17846
+ * At least one zone id required — a rule with no targets is a
17847
+ * configuration mistake and the form validator rejects it. */
17848
+ zoneIds: array(string()).min(1).readonly(),
17849
+ mode: ZoneRuleModeEnum,
17883
17850
  /**
17884
- * Inference-frame id shared by every object event emitted from the SAME frame
17885
- * the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
17886
- * 2 people + 1 dog) under one full frame, and link a track's frames over time
17887
- * (group by `trackId`, pick a representative `frameId` as the parent frame).
17888
- * Optional for backward-compat with pre-existing rows / the slim projection
17889
- * includes it (it is light). Absent on rows written before this field.
17851
+ * Class names this rule applies to. Empty / undefined rule
17852
+ * applies to every class. Class strings match the `macroClass`
17853
+ * field on detections (e.g. `person`, `car`, `dog`).
17890
17854
  */
17891
- frameId: string().optional(),
17892
- /** Omitted in slim projection. */
17893
- trackId: string().optional(),
17894
- className: string(),
17895
- ...TieredLabelFields,
17896
- /** Omitted in slim projection. */
17897
- confidence: number().optional(),
17898
- /** Heavy JSON — omitted in slim projection. */
17899
- bbox: BoundingBoxSchema.optional(),
17900
- /** Heavy JSON — omitted in slim projection. */
17901
- zones: array(string()).readonly().optional(),
17902
- /** Omitted in slim projection. */
17903
- state: TrackStateSchema.optional(),
17855
+ classFilter: array(string()).readonly().optional(),
17904
17856
  /**
17905
- * The zone crossing this event IS, when it is one. Absent on every other
17906
- * event kind (movement state, appearance, package) see
17907
- * {@link ZoneCrossingSchema}. Omitted in slim projection.
17857
+ * Minimum bbox/mask overlap (0–1) with any of the rule's zones
17858
+ * required to consider an entity "in the zone". Defaults to the
17859
+ * consumer's stage default when omitted. Kept for back-compat with
17860
+ * existing per-rule overrides; new operators pick the value via
17861
+ * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
17862
+ * set, the lower-level engine reads it as a 0–1 fraction.
17908
17863
  */
17909
- zoneCrossing: ZoneCrossingSchema.optional(),
17910
- /** Detection-frame dimensions in pixels — let consumers normalize the
17911
- * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
17912
- frameWidth: number().optional(),
17913
- frameHeight: number().optional(),
17914
- /** MediaStore key for the crop attached to this event (if any). */
17915
- mediaKey: string().optional(),
17916
- /** Design B: MediaStore key of the track's native-resolution key frame (the
17917
- * best-detection full frame). Resolve via the event-media data-plane
17918
- * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
17919
- * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
17920
- * sources — consumers fall back to `mediaKey` (the tight crop). */
17921
- keyFrameMediaKey: string().optional(),
17922
- /** Populated by B5 (recording playback URL for this event). */
17923
- mediaUrl: string().optional(),
17924
- /** The parent track's key-event importance [0,1], propagated to every object
17925
- * event of the track (so an event row can be sorted by importance without a
17926
- * track join). Absent on legacy rows / before the track was scored. */
17927
- importance: number().optional()
17928
- });
17929
- var AudioEventSchema = object({
17930
- ...BaseEventFields,
17931
- kind: literal("audio"),
17932
- rms: number(),
17933
- dbfs: number(),
17934
- classification: object({
17935
- className: string(),
17936
- originalClass: string().optional(),
17937
- score: number()
17938
- }).optional(),
17939
- /** Populated by B5 (recording playback URL for this event). */
17940
- mediaUrl: string().optional()
17864
+ overlapThreshold: number().min(0).max(1).optional(),
17865
+ /**
17866
+ * Operator-friendly version of `overlapThreshold` the percentage
17867
+ * of the detection's bbox that must lie inside the zone for the
17868
+ * rule to match. Documented default is 85%; the engine substitutes
17869
+ * that when the field is omitted (kept optional so existing rules
17870
+ * stored without it stay valid).
17871
+ *
17872
+ * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
17873
+ * rule, the engine prefers `bboxInclusionPct` because it's the
17874
+ * field exposed in the UI. Internally both feed the same gate.
17875
+ */
17876
+ bboxInclusionPct: number().min(0).max(100).optional(),
17877
+ /**
17878
+ * When `true` and a detection has a segmentation mask, use the
17879
+ * mask for overlap instead of the bbox. Detection-stage only;
17880
+ * motion rules ignore this field.
17881
+ */
17882
+ preferMask: boolean().optional(),
17883
+ /**
17884
+ * Soft-toggle: `false` disables the rule without deleting it.
17885
+ * Defaults to `true` so operators creating a rule via the UI
17886
+ * see it active immediately.
17887
+ */
17888
+ enabled: boolean().default(true)
17941
17889
  });
17942
- var MediaFileKindEnum = _enum([
17943
- "crop",
17944
- "thumbnail",
17945
- "snapshot",
17946
- "firstFrame",
17947
- "lastFrame",
17948
- "fullFrame",
17949
- "fullFrameBoxed",
17950
- "faceCrop",
17951
- "plateCrop",
17952
- "keyFrame",
17953
- "keyFrameSmall",
17954
- "thumbnailSmall"
17955
- ]);
17956
- var MediaFileSchema = object({
17957
- key: string(),
17958
- kind: MediaFileKindEnum,
17959
- base64: string(),
17960
- sizeBytes: number(),
17961
- timestamp: number()
17890
+ array(ZoneRuleSchema).readonly();
17891
+ /**
17892
+ * Zone — pure geometry + identity. NO filtering behaviour.
17893
+ *
17894
+ * Zones describe **where** in the frame the operator wants to flag
17895
+ * something; consumer-owned {@link ZoneRule} arrays describe **how**
17896
+ * each pipeline stage uses them. Splitting the two means a single
17897
+ * polygon "Driveway" can simultaneously back a motion-exclude rule,
17898
+ * a detection-include rule on `['car']`, and an occupancy aggregate
17899
+ * — without three duplicated polygons.
17900
+ *
17901
+ * Owned by the orchestrator addon (provider) and mirrored into the
17902
+ * `zones` device-state slice on every mutation. Consumers
17903
+ * (motion-wasm, pipeline-executor, analytics, admin UI) read either
17904
+ * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
17905
+ * mirror with `onChanged`).
17906
+ *
17907
+ * Coordinates are normalised fractions of the frame (0–1) so zones
17908
+ * survive resolution changes and stream profile switches.
17909
+ *
17910
+ * `kind` discriminates between full polygons (closed regions used
17911
+ * for intrusion / occupancy filters) and tripwires (open 2-point
17912
+ * line segments used for cross events). Onboard / firmware-reported
17913
+ * zones (Reolink, ONVIF) are out of scope for now — see the deferred
17914
+ * task list.
17915
+ */
17916
+ var ZoneKindEnum = _enum(["polygon", "tripwire"]);
17917
+ /** Polygon vertex in fraction-of-frame coordinates (0–1). */
17918
+ var PolygonPointSchema = object({
17919
+ x: number(),
17920
+ y: number()
17921
+ });
17922
+ /** A camera detection zone — pure geometry/identity. */
17923
+ var ZoneSchema = object({
17924
+ id: string(),
17925
+ name: string(),
17926
+ kind: ZoneKindEnum.default("polygon"),
17927
+ /** Polygon vertices, fraction of frame (0–1). */
17928
+ polygon: array(PolygonPointSchema).readonly(),
17929
+ /** Visual color for UI rendering. */
17930
+ color: string().default("#3b82f6")
17962
17931
  });
17963
17932
  /**
17964
- * One media row WITHOUT its bytes.
17933
+ * Zones capability per-camera CRUD over polygon detection zones.
17965
17934
  *
17966
- * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
17967
- * 140 s track), and a client that renders tiles from the media data plane needs
17968
- * to know only WHAT EXISTS the bytes then arrive per tile, lazily, over HTTP
17969
- * with an immutable cache, instead of all at once inside a tRPC response that
17970
- * blocks the whole view.
17935
+ * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
17936
+ * to per-device settings and mirrors into the `zones` device-state
17937
+ * slice on every mutation, so downstream consumers can subscribe via
17938
+ * `dev.state.zones.onChanged`.
17971
17939
  *
17972
- * `sizeBytes` is carried because it is what lets a client decide between the
17973
- * stored blob and a `?variant=thumb` rendering without fetching either.
17940
+ * The cap surface only handles geometry + identity; filtering
17941
+ * behaviour (per-class, include/exclude, threshold) lives in the
17942
+ * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
17943
+ * `capabilities/schemas/zone-rule.js`.
17974
17944
  */
17975
- var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
17945
+ var zonesCapability = {
17946
+ name: "zones",
17947
+ scope: "device",
17948
+ mode: "singleton",
17949
+ deviceTypes: [DeviceType.Camera],
17950
+ methods: {
17951
+ listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
17952
+ addZone: method(object({
17953
+ deviceId: number(),
17954
+ zone: ZoneSchema
17955
+ }), _void(), {
17956
+ kind: "mutation",
17957
+ auth: "admin"
17958
+ }),
17959
+ removeZone: method(object({
17960
+ deviceId: number(),
17961
+ zoneId: string()
17962
+ }), _void(), {
17963
+ kind: "mutation",
17964
+ auth: "admin"
17965
+ }),
17966
+ updateZone: method(object({
17967
+ deviceId: number(),
17968
+ zone: ZoneSchema
17969
+ }), _void(), {
17970
+ kind: "mutation",
17971
+ auth: "admin"
17972
+ })
17973
+ },
17974
+ /**
17975
+ * Runtime-state slice — the live zone catalogue mirrored by the
17976
+ * orchestrator on every CRUD mutation. Consumers read via
17977
+ * `device.state.zones.value` / `.watch(...)` without round-tripping
17978
+ * the cap, and the codegen DeviceProxy auto-wires the reactive
17979
+ * handle. Slice shape is `{ zones: Zone[] }` so future extensions
17980
+ * (e.g. zone groupings) can sit alongside the polygon list.
17981
+ */
17982
+ runtimeState: object({ zones: array(ZoneSchema).readonly() }),
17983
+ /**
17984
+ * 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.
17985
+ *
17986
+ * See `RuntimeStateDurability`. Enforced by
17987
+ * `scripts/check-runtime-state-durability.ts`.
17988
+ */
17989
+ durability: "restored"
17990
+ };
17976
17991
  /**
17977
- * The MACRO tier of an annotation — a CLOSED set.
17992
+ * pipeline-analytics device-scoped wrapper cap. Refines raw
17993
+ * per-frame detections emitted by the pipeline runner into tracked
17994
+ * objects, per-kind event collections (motion / object / audio), and
17995
+ * persisted media. Owns the post-detection domain end-to-end:
17978
17996
  *
17979
- * This is what the exported detector predicts, so a typo here is a new class
17980
- * with one example in it. `label` and `subLabel` are open strings by contrast:
17981
- * the whole point of the page is teaching the model things it does not know
17982
- * yet, and constraining that vocabulary would make it useless.
17997
+ * runner emits PipelineInferenceResult
17998
+ * (event bus)
17999
+ * pipeline-analytics subscriber
18000
+ * SORT tracker + zone engine + state analyzer + event emitter
18001
+ * → three DB collections (one per kind), one FS media tree, one
18002
+ * unified event emitter (FrameTracked + TrackStarted/Ended +
18003
+ * DetectionEvent on bus)
17983
18004
  *
17984
- * A macro class is NEVER a label. The provider refuses a write whose `label` or
17985
- * `subLabel` is one of these values, in any casing, because once `person`
17986
- * exists in both tiers "every person box" stops being answerable without
17987
- * knowing every string anyone ever typed — and the damage is retroactive.
18005
+ * Pure subscriber model. No `processFrame` cap method the runner
18006
+ * already publishes the raw frame on the bus. The cap surface is
18007
+ * only QUERIES + per-device settings, bound on/off via
18008
+ * `device-manager.setWrapperActive`. `defaultActive: true` because
18009
+ * every camera with a detection pipeline wants its raw detections
18010
+ * refined; operators opt out per-device via BindingsTab when needed.
18011
+ *
18012
+ * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
18013
+ * (per-device surface) and `track-trail` caps — see P11 cleanup.
17988
18014
  */
17989
- var RetrainMacroClassSchema = _enum([
18015
+ var TrackStateSchema = _enum([
18016
+ "new",
18017
+ "entered",
18018
+ "left",
18019
+ "moving",
18020
+ "idle"
18021
+ ]);
18022
+ var EventKindSchema = _enum([
18023
+ "motion",
18024
+ "object",
18025
+ "audio"
18026
+ ]);
18027
+ /**
18028
+ * Spatial filter for `listTracks` — the rect + polygon variants of the shared
18029
+ * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
18030
+ * of the camera frame (top-left origin), matching the drawing-plane editor.
18031
+ */
18032
+ var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
18033
+ /** Closed icon vocabulary so clients render a known glyph per kind. */
18034
+ var EventKindIconSchema = _enum([
18035
+ "motion",
18036
+ "audio",
17990
18037
  "person",
17991
18038
  "vehicle",
17992
18039
  "animal",
18040
+ "door",
18041
+ "pir",
18042
+ "smoke",
18043
+ "water",
18044
+ "button",
17993
18045
  "package",
17994
- "face",
17995
- "plate"
18046
+ "generic"
17996
18047
  ]);
17997
- /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
17998
- var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
17999
- /** Did a human draw this box, or did the assist propose it? */
18000
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
18001
- /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
18002
- var RetrainBboxSchema = object({
18003
- x: number(),
18004
- y: number(),
18005
- w: number(),
18006
- h: number()
18007
- });
18008
- /**
18009
- * One annotated subject.
18010
- *
18011
- * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
18012
- * (letterboxed root / zone-cropped package / subject-cropped classifier) are
18013
- * derived from it at export and never stored storing them is how one feature
18014
- * space ends up holding two crops of the same subject (D52).
18015
- */
18016
- var RetrainAnnotationSchema = object({
18017
- id: string(),
18018
- trackId: string(),
18019
- deviceId: number(),
18020
- /** The COPY in retrain storage — never the source track's media key. */
18021
- mediaKey: string(),
18022
- bbox: RetrainBboxSchema,
18023
- macroClass: RetrainMacroClassSchema,
18024
- label: string().optional(),
18025
- subLabel: string().optional(),
18026
- kind: RetrainAnnotationKindSchema,
18027
- source: RetrainAnnotationSourceSchema,
18028
- /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
18029
- assistModelId: string().optional(),
18030
- assistScore: number().optional(),
18031
- exportedInBatch: string().optional(),
18032
- createdAt: number()
18033
- });
18034
- /** The write form — the server owns `id`, `createdAt` and the frame binding. */
18035
- var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
18036
- id: true,
18037
- trackId: true,
18038
- deviceId: true,
18039
- mediaKey: true,
18040
- createdAt: true,
18041
- exportedInBatch: true
18048
+ var EventKindCategorySchema = _enum([
18049
+ "motion",
18050
+ "audio",
18051
+ "detection",
18052
+ "sensor",
18053
+ "control",
18054
+ "custom",
18055
+ "package"
18056
+ ]);
18057
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
18058
+ var EventKindLevelSchema = _enum(["macro", "sub"]);
18059
+ var EventKindDescriptorSchema = object({
18060
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
18061
+ kind: string(),
18062
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
18063
+ labelKey: string(),
18064
+ /** English fallback label (kept for clients that don't translate). */
18065
+ label: string(),
18066
+ /** Hex color for timeline/legend rendering. */
18067
+ color: string(),
18068
+ /** Dictionary id → lucide component on the UI side. */
18069
+ iconId: string(),
18070
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
18071
+ icon: EventKindIconSchema,
18072
+ category: EventKindCategorySchema,
18073
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
18074
+ parentKind: string().nullable(),
18075
+ /** Derived from `parentKind`, explicit for the client tree. */
18076
+ level: EventKindLevelSchema,
18077
+ /** Which cap + device contributes this kind. For built-ins the camera
18078
+ * itself; for sensor kinds the LINKED source device. */
18079
+ source: object({
18080
+ capName: string(),
18081
+ deviceId: number()
18082
+ })
18042
18083
  });
18043
- /** A track sitting in `staging`, with everything the worklist needs to rank it. */
18044
- var RetrainTrackSchema = object({
18045
- trackId: string(),
18084
+ /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
18085
+ var EventKindsForDeviceSchema = object({
18046
18086
  deviceId: number(),
18047
- className: string(),
18048
- label: string().optional(),
18049
- firstSeen: number(),
18050
- lastSeen: number(),
18051
- /** How many frames the dataset already holds from this track. */
18052
- frameCount: number().int(),
18053
- /** How many subjects have been annotated on those frames. `0` with
18054
- * `frameCount: 0` is exactly "staging, still to work". */
18055
- annotationCount: number().int()
18056
- });
18057
- /** A frame the picker may offer — an index row, no blob was read to produce it. */
18058
- var RetrainFrameCandidateSchema = object({
18059
- mediaKey: string(),
18060
- kind: MediaFileKindEnum,
18061
- timestamp: number(),
18062
- sizeBytes: number().int(),
18063
- /** A copy of this original already exists — selecting it is free and cannot
18064
- * fail, whatever became of the original. */
18065
- copied: boolean()
18087
+ kinds: array(EventKindDescriptorSchema).readonly()
18066
18088
  });
18067
- /** A frame the dataset OWNS: bytes copied at selection time. */
18068
- var RetrainFrameSchema = object({
18069
- frameId: string(),
18089
+ var SensorEventSchema = object({
18090
+ id: string(),
18091
+ /** The CAMERA the event is attributed to (a sensor linked to N cameras
18092
+ * yields N rows, one per camera). */
18070
18093
  deviceId: number(),
18071
- trackId: string(),
18072
- /** Provenance only. It may already point at nothing — that is expected. */
18073
- sourceMediaKey: string(),
18074
- sourceKind: MediaFileKindEnum,
18075
- sizeBytes: number().int(),
18076
- width: number().int(),
18077
- height: number().int(),
18078
- copiedAt: number()
18094
+ /** The linked sensor device whose state changed. */
18095
+ sourceDeviceId: number(),
18096
+ /** Event kind id — matches an `EventKindDescriptor.kind`. */
18097
+ kind: string(),
18098
+ /** Snapshot of the sensor cap's runtime-state slice at the change. */
18099
+ value: record(string(), unknown()).nullable(),
18100
+ timestamp: number()
18079
18101
  });
18080
- /** Why a copy-on-select could not be honoured — named, never a silent skip. */
18081
- var RetrainCopyRefusalSchema = _enum([
18082
- "source-missing",
18083
- "unreadable-image",
18084
- "write-failed"
18085
- ]);
18086
- var RetrainFrameSelectionSchema = object({
18087
- copied: array(RetrainFrameSchema).readonly(),
18088
- refused: array(object({
18089
- sourceMediaKey: string(),
18090
- reason: RetrainCopyRefusalSchema
18091
- })).readonly()
18102
+ var TrackPositionSchema = object({
18103
+ x: number(),
18104
+ y: number(),
18105
+ timestamp: number(),
18106
+ bbox: BoundingBoxSchema
18092
18107
  });
18093
- var RetrainFrameListSchema = object({
18094
- candidates: array(RetrainFrameCandidateSchema).readonly(),
18095
- copies: array(RetrainFrameSchema).readonly(),
18096
- /** What the page pre-selects the native key frame when one survives. */
18097
- autoPickMediaKey: string().optional()
18108
+ var TrackSnapshotSchema = object({
18109
+ timestamp: number(),
18110
+ position: TrackPositionSchema,
18111
+ /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
18112
+ mediaKey: string()
18098
18113
  });
18099
- /** What the operator asked the assist to look for. */
18100
- var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
18101
- kind: literal("package"),
18102
- zone: RetrainBboxSchema.optional()
18103
- }), object({
18104
- kind: literal("objects"),
18105
- modelId: string(),
18106
- minScore: number().optional()
18107
- })]);
18108
18114
  /**
18109
- * The assist's answer a discriminated union, because "the model saw nothing"
18110
- * and "this node cannot run that model" lead to different next moves and a
18111
- * nullable result cannot tell them apart.
18115
+ * Normalized 0..1 trajectory envelope (min/max over every position bbox,
18116
+ * divided by the track's detection-frame dims), computed at persist time.
18117
+ * Absent when the frame dims were unknown when the track was persisted
18118
+ * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
18112
18119
  */
18113
- var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
18114
- kind: literal("proposed"),
18115
- modelId: string(),
18116
- stepId: string(),
18117
- minScore: number(),
18118
- /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
18119
- proposals: array(RetrainAnnotationDraftSchema).readonly(),
18120
- /** Returned by the runner but removed by the threshold. */
18121
- belowThreshold: number().int()
18122
- }), object({
18123
- kind: literal("refused"),
18124
- /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
18125
- reason: string(),
18126
- detail: string().optional()
18127
- })]);
18128
- /** The outcome of a lifecycle move owned by the retrain page. */
18129
- var RetrainTransitionResultSchema = object({
18130
- trackId: string(),
18131
- /** Where the track ended up, whatever happened. */
18132
- retrainStatus: RetrainStatusSchema,
18133
- /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
18134
- changed: boolean(),
18135
- reason: _enum([
18136
- "unknown-track",
18137
- "no-frames-copied",
18138
- "not-staging",
18139
- "not-trained",
18140
- "unchanged"
18141
- ]).optional()
18142
- });
18143
- var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
18144
- var MAX_EVENT_QUERY_LIMIT = 5e3;
18145
- var DeviceEventQueryInput = object({
18146
- deviceId: number(),
18147
- since: number().optional(),
18148
- until: number().optional(),
18149
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
18150
- /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
18151
- * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
18152
- * exact behaviour. Callers may omit this field — the store defaults to
18153
- * `full` when not provided. */
18154
- projection: _enum(["full", "slim"]).optional()
18155
- });
18156
- var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
18157
- var RecentTracksQueryInput = object({
18158
- /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
18159
- deviceIds: array(number()),
18160
- /** Window lower bound on `lastSeen` (inclusive). */
18161
- since: number().optional(),
18162
- /** Window upper bound on `lastSeen` (inclusive). */
18163
- until: number().optional(),
18164
- /** Page size. Default 200, max 1000. */
18165
- limit: number().int().min(1).max(1e3).default(200),
18166
- /** Opaque continuation cursor from a previous page's `nextCursor`.
18167
- * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
18168
- cursor: string().optional(),
18169
- /** See {@link TrackProjectionSchema}. Default `full`. */
18170
- projection: TrackProjectionSchema.optional(),
18171
- /** Include stationary-promoted rows (parked objects). Default false: the
18172
- * feed lists passages; parking records live on the stationary registry. */
18173
- includeStationary: boolean().optional()
18174
- });
18175
- var RecentTracksPageSchema = object({
18176
- /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
18177
- tracks: array(TrackSchema).readonly(),
18178
- /** Cursor for the next page, or null when this page is the last. */
18179
- nextCursor: string().nullable()
18180
- });
18181
- var LIST_GROUPS_DEFAULT_LIMIT = 40;
18182
- var LIST_GROUPS_MAX_LIMIT = 100;
18183
- var AnalyticsGroupRecordSchema = object({
18184
- id: string(),
18185
- deviceId: number().int(),
18186
- openedAt: number().int(),
18187
- closedAt: number().int(),
18188
- timestamp: number().int(),
18189
- memberCount: number().int(),
18190
- memberTrackIds: array(string()).readonly(),
18191
- className: string(),
18192
- classes: array(string()).readonly(),
18193
- /** Relative event-media path, or null when the group has no picture yet. */
18194
- mediaUrl: string().nullable(),
18195
- singleton: boolean()
18120
+ var TrackEnvelopeSchema = object({
18121
+ minX: number(),
18122
+ minY: number(),
18123
+ maxX: number(),
18124
+ maxY: number()
18196
18125
  });
18197
- var AnalyticsGroupMemberSchema = object({
18198
- trackId: string(),
18199
- deviceId: number().int(),
18200
- className: string(),
18201
- firstSeen: number().int(),
18202
- lastSeen: number().int(),
18203
- mediaUrl: string().nullable()
18204
- });
18205
- var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
18206
- var ListGroupsQueryInput = object({
18207
- /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
18208
- deviceIds: array(number()),
18209
- /** Window lower bound on `closedAt` (inclusive). */
18210
- since: number().optional(),
18211
- /** Window upper bound on `openedAt` (inclusive). */
18212
- until: number().optional(),
18213
- limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
18214
- /** Opaque continuation cursor from a previous page's `nextCursor`. */
18215
- cursor: string().optional()
18216
- });
18217
- var ListGroupsPageSchema = object({
18218
- groups: array(AnalyticsGroupRecordSchema).readonly(),
18219
- nextCursor: string().nullable()
18220
- });
18221
- var KeyEventQueryInput = object({
18222
- deviceId: number(),
18223
- /** Window lower bound (track firstSeen ≥ since). */
18224
- since: number(),
18225
- /** Window upper bound (track firstSeen ≤ until). */
18226
- until: number(),
18227
- limit: number().int().min(1).max(200).default(50),
18228
- /** Drop tracks scoring below this importance. */
18229
- minImportance: number().min(0).max(1).optional(),
18230
- /** Restrict to a single class (e.g. 'person'). */
18231
- classFilter: string().optional()
18232
- });
18233
- var KeyEventSchema = object({
18234
- /** The representative event id (the track's best ObjectEvent, else its trackId). */
18235
- id: string(),
18236
- trackId: string(),
18237
- /** Track start time (firstSeen). */
18238
- timestamp: number(),
18239
- className: string(),
18240
- ...TieredLabelFields,
18241
- importance: number(),
18242
- /** Highest-confidence ObjectEvent id for the track (empty when none). */
18243
- bestEventId: string(),
18244
- /** Track lifetime in ms (lastSeen - firstSeen). */
18245
- windowMs: number().optional(),
18246
- ...TrackFlagFields,
18247
- ...TrackRetrainFields
18248
- });
18249
- object({
18250
- trackId: string(),
18251
- className: string(),
18252
- confidence: number(),
18253
- bbox: BoundingBoxSchema,
18254
- zones: array(string()).readonly(),
18255
- state: TrackStateSchema
18256
- });
18257
- var OverlayDetectionSchema = looseObject({
18258
- id: string(),
18259
- kind: _enum(["first-level", "detail"]),
18260
- macroClass: string(),
18261
- score: number(),
18262
- bbox: object({
18263
- x: number(),
18264
- y: number(),
18265
- width: number(),
18266
- height: number()
18267
- }),
18268
- labels: array(looseObject({
18269
- label: string(),
18270
- score: number()
18271
- })).readonly(),
18272
- parentId: string().optional()
18273
- });
18274
- var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
18275
- var SearchObjectEventsInput = object({
18276
- text: string(),
18277
- deviceId: number().optional(),
18278
- since: number().optional(),
18279
- until: number().optional(),
18280
- classFilter: string().optional(),
18281
- limit: number().default(50),
18282
- minScore: number().min(0).max(1).default(.2)
18283
- });
18284
- var TrackCascadeCountsSchema = object({
18285
- /** Persisted track roots deleted (authoritative). */
18286
- tracks: number().int(),
18287
- /** Object events removed with their tracks (best-effort; see note above). */
18288
- events: number().int(),
18289
- /** Track/face/plate-owned media removed (best-effort). Never identity media. */
18290
- media: number().int(),
18291
- /** Unassigned (non-enrolled) face reads removed (best-effort). */
18292
- faces: number().int(),
18293
- /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
18294
- plates: number().int(),
18295
- /** Per-track CLIP search vectors removed (best-effort). */
18296
- embeddings: number().int(),
18297
- /** Group membership + group rows removed with their last member (best-effort). */
18298
- groups: number().int()
18299
- });
18300
- /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
18301
- var DiskReconcileCountsSchema = object({
18302
- mediaDropped: number().int(),
18303
- tracks: number().int(),
18304
- events: number().int()
18305
- });
18306
- /** Event-store footprint for one camera. */
18307
- var EventStoreDeviceFootprintSchema = object({
18308
- deviceId: number(),
18309
- /** Persisted event rows (motion + object + audio) for the camera. */
18310
- rows: number().int(),
18311
- /** Event-owned media bytes on disk for the camera. */
18312
- bytes: number().int()
18313
- });
18314
- /** Aggregate event-store footprint: global totals + per-camera breakdown. */
18315
- var EventStoreFootprintSchema = object({
18316
- totalRows: number().int(),
18317
- totalBytes: number().int(),
18318
- devices: array(EventStoreDeviceFootprintSchema).readonly()
18319
- });
18320
- /** Per-kind counts returned by the event-prune / device-delete mutations. */
18321
- var EventPruneCountsSchema = object({
18322
- motion: number().int(),
18323
- object: number().int(),
18324
- audio: number().int()
18126
+ /**
18127
+ * Row projection for track list queries. `full` (default) returns the
18128
+ * complete Track including the frame-rate `positions[]` history and the
18129
+ * `snapshots[]` references — megabytes across a page of tracks. `slim`
18130
+ * keeps every scalar the list surfaces actually render (ids, class(es),
18131
+ * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
18132
+ * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
18133
+ * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
18134
+ * `getTrack`. Mirrors the event-store `projection` convention
18135
+ * (`getObjectEvents` et al.).
18136
+ */
18137
+ var TrackProjectionSchema = _enum(["full", "slim"]);
18138
+ /**
18139
+ * One audio-classification label heard on the track's camera while the
18140
+ * track was alive, aggregated per label. An "episode" is one persisted
18141
+ * audio event (the confident-classification path: score ≥ the device's
18142
+ * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
18143
+ * one 32 ms inference chunk, so counts stay human-scaled.
18144
+ */
18145
+ var TrackAudioLabelSchema = object({
18146
+ label: string(),
18147
+ /** Highest classification score observed across the label's episodes. */
18148
+ peakScore: number(),
18149
+ /** Number of coalesced audio-event episodes carrying this label. */
18150
+ count: number(),
18151
+ firstAt: number(),
18152
+ lastAt: number()
18325
18153
  });
18326
18154
  /**
18327
- * Re-embed stored tracks from their key frames.
18155
+ * How a track was produced. `pipeline` (default / absent) = the spatial
18156
+ * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
18157
+ * no positions, a single snapshot, and no bbox trajectory at all:
18328
18158
  *
18329
- * The reason this is an operator-callable method and not a migration script:
18330
- * every knob that decides what a vector MEANS encoder model, crop margin,
18331
- * squaring is only changeable if the existing vectors can be regenerated.
18332
- * Mixing feature spaces in one index makes cosine scores incomparable, and the
18333
- * symptom is a quality regression with no visible cause.
18159
+ * - `sensor` a linked sensor/control device state change.
18160
+ * - `audio` an audio event on the camera itself that was anomalous for
18161
+ * THAT camera, loud, and heard while nothing visual was happening (D62).
18162
+ *
18163
+ * The spatial subsystems (tracker association, occupancy count, re-id /
18164
+ * embedding, resurrection) MUST skip every synthetic source. Test for that
18165
+ * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
18166
+ * check silently readmits every source added after it was written.
18334
18167
  */
18335
- var RebuildObjectEmbeddingsInput = object({
18336
- /** Restrict to one camera. Omit for the whole fleet. */
18337
- deviceId: number().optional(),
18338
- since: number().optional(),
18339
- until: number().optional(),
18340
- /** Stop after this many tracks; the result reports whether more remain. */
18341
- maxTracks: number().int().positive().optional(),
18342
- /**
18343
- * Run every embedding on THIS node instead of round-robining the fleet.
18344
- *
18345
- * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
18346
- * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
18347
- * calling it that would pin the rebuild REQUEST itself to that node — the
18348
- * rebuild orchestration lives on the hub, and only the per-track step runs
18349
- * remotely. This field is data; the per-track pin is applied inside.
18350
- *
18351
- * Absent ⇒ round-robin over every online node whose runner can serve the
18352
- * pinned model.
18353
- */
18354
- executeOnNodeId: string().optional(),
18355
- /**
18356
- * Milliseconds to wait between tracks; omit for the built-in default, `0` to
18357
- * run flat out.
18358
- *
18359
- * A rebuild is bulk maintenance on hub-main's single thread. Measured
18360
- * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
18361
- * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
18362
- * force is logged at start and finish so a deliberately slow pass reads
18363
- * differently from a stalled one.
18364
- */
18365
- pacingMs: number().int().nonnegative().optional()
18366
- });
18168
+ var TrackSourceSchema = _enum([
18169
+ "pipeline",
18170
+ "sensor",
18171
+ "audio"
18172
+ ]);
18367
18173
  /**
18368
- * Result of emptying the CLIP index.
18174
+ * Where a track sits in the RETRAIN lifecycle (D81).
18369
18175
  *
18370
- * The clean slate before a policy change: a new crop margin or encoder model
18371
- * leaves two feature spaces in one index whose cosine scores are not
18372
- * comparable, so wiping and rebuilding is the only way to be sure every vector
18373
- * means the same thing.
18176
+ * - `none` never marked, or un-marked. Evictable.
18177
+ * - `staging` the operator wants this track as training material and has not
18178
+ * finished with it. **This is the only state retention holds**: the track and
18179
+ * everything it owns (object events, crops, keyframes, CLIP vector) survive
18180
+ * the device's age window.
18181
+ * - `trained` — the retrain page has taken what it needed. The frames it chose
18182
+ * were COPIED into the retrain dataset at selection time, so the dataset no
18183
+ * longer depends on the track's media and the track becomes EVICTABLE again.
18184
+ * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
18185
+ * a deliberate action of the retrain page, not a side effect of a checkbox.
18186
+ *
18187
+ * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
18188
+ * the store's filter language has only positive equality and `whereIn` — no
18189
+ * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
18190
+ * would make the entire pre-column history immortal in one deploy.
18374
18191
  */
18375
- var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
18192
+ var RetrainStatusSchema = _enum([
18193
+ "none",
18194
+ "staging",
18195
+ "trained"
18196
+ ]);
18376
18197
  /**
18377
- * Acknowledgement that a rebuild STARTED.
18198
+ * Per-track OPERATOR flags set by hand from the admin UI or the viewer, never
18199
+ * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
18200
+ * so the two surfaces cannot drift.
18378
18201
  *
18379
- * The pass costs ~1s per track 45 minutes for a 2,600-track fleet so it
18380
- * runs detached and this returns immediately. Waiting for it made the client
18381
- * time out while the work carried on server-side, which is the worst of both:
18382
- * no result and no way to know it was still going. Poll
18383
- * `getObjectEmbeddingRebuildStatus` for progress.
18202
+ * **Absent false.** A track that has never been touched omits the field; an
18203
+ * explicitly un-flagged track carries `false`. Legacy rows written before the
18204
+ * columns existed read as absent, and a consumer that needs a boolean should say
18205
+ * `flag === true`, not `flag !== false`.
18206
+ *
18207
+ * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
18208
+ * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
18209
+ * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
18210
+ * `trained` track reports `false` while refusing both writes. The boolean is
18211
+ * kept because three surfaces drive a toggle off it; anything that needs to tell
18212
+ * "never marked" from "already trained" must read `retrainStatus`.
18213
+ *
18214
+ * `debug` does NOT pin; it is attention, not durability.
18215
+ *
18216
+ * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
18217
+ * A favourited track is skipped by retention the same way `staging` is, but
18218
+ * it does not enter `none|staging|trained` and has no staging budget.
18384
18219
  */
18385
- var RebuildObjectEmbeddingsResultSchema = object({
18386
- started: boolean(),
18387
- /** True when a pass was already running; the new request is ignored. */
18388
- alreadyRunning: boolean()
18389
- });
18390
- var RebuildStatusSchema = object({
18391
- running: boolean(),
18392
- scanned: number(),
18393
- rebuilt: number(),
18394
- /** Tracks whose key frame is gone — nothing to re-embed from. */
18395
- missingKeyFrame: number(),
18396
- /** Tracks with no usable detection box. */
18397
- missingBbox: number(),
18398
- /**
18399
- * Tracks an executing node REFUSED rather than broke on an unreadable key
18400
- * frame, a step that threw. Separate from `failed` because the remedy is
18401
- * different, and because a whole camera silently contributing zero vectors
18402
- * is the shape of failure a rebuild must never hide.
18403
- */
18404
- notRunnable: number(),
18405
- /**
18406
- * The pass stopped because NO node could serve the pinned model.
18407
- *
18408
- * Distinct from `notRunnable` on purpose: that one says "this track was
18409
- * refused", this one says "the cluster cannot do this work at all" — every
18410
- * candidate node either lacks the `clip-embedding` step, lacks a build of the
18411
- * pinned model for its engine format, or dropped out. The remedy is a model /
18412
- * engine change, not a per-camera one. Non-zero here always comes with
18413
- * `complete: false`.
18414
- */
18415
- noCapableNode: number(),
18416
- failed: number(),
18417
- /** Set once a pass ends: true only when EVERYTHING was covered. */
18418
- complete: boolean().nullable(),
18419
- startedAtMs: number().nullable(),
18420
- finishedAtMs: number().nullable(),
18421
- /** Present when the pass ended by throwing. */
18422
- error: string().nullable()
18220
+ var TrackFlagFields = {
18221
+ /** Operator marked this track as training material — i.e. `retrainStatus` is
18222
+ * `'staging'`. */
18223
+ markForTrain: boolean().optional(),
18224
+ /** Operator marked this track for diagnostic attention. */
18225
+ debug: boolean().optional(),
18226
+ /** Operator favourited this track. Pins it against pruning. */
18227
+ favourited: boolean().optional()
18228
+ };
18229
+ /**
18230
+ * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
18231
+ * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
18232
+ * write patch, and the status is not something the toggle sets — it is what the
18233
+ * toggle's boolean is derived from. Absent on an in-RAM track never touched;
18234
+ * always present on a persisted row (the column default materialises `'none'`).
18235
+ */
18236
+ var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
18237
+ /**
18238
+ * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
18239
+ * one flag can never clear the other — the toggles are independent and are
18240
+ * driven from three surfaces that do not know about each other.
18241
+ */
18242
+ var TrackFlagsPatchSchema = object(TrackFlagFields);
18243
+ /**
18244
+ * The resolved flag state after a write. Both fields are REQUIRED here (absent
18245
+ * collapses to `false`) so a caller can drive a toggle's checked state off the
18246
+ * mutation result without a re-fetch.
18247
+ */
18248
+ var TrackFlagsSchema = object({
18249
+ trackId: string(),
18250
+ markForTrain: boolean(),
18251
+ debug: boolean(),
18252
+ favourited: boolean(),
18253
+ /** The lifecycle state the boolean was derived from. Required here (unlike on
18254
+ * a track row) because this shape is only ever produced by the write body,
18255
+ * which always knows it — and a surface that has just written needs to render
18256
+ * `trained` without a re-fetch. */
18257
+ retrainStatus: RetrainStatusSchema
18423
18258
  });
18424
- DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
18425
- deviceId: number(),
18426
- trackId: string()
18427
- }), TrackSchema.nullable()), method(object({
18428
- deviceId: number(),
18429
- since: number().optional(),
18430
- until: number().optional(),
18431
- limit: number().optional(),
18432
- /** Spatial filter only tracks whose trajectory intersects the zone
18433
- * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
18434
- * envelope columns, then precisely tested per position. Tracks with
18435
- * an unknown envelope (no frame dims at persist time) always match. */
18436
- zone: TrackZoneFilterSchema.optional(),
18437
- /** See {@link TrackProjectionSchema}. Default `full` (backward
18438
- * compatible — omitting the field keeps today's exact behaviour). */
18439
- projection: TrackProjectionSchema.optional(),
18440
- /** Include stationary-promoted rows (parked objects handed to the
18441
- * stationary registry). Default false: the timeline lists passages,
18442
- * not parking records (operator decision, 2026-08-15). */
18443
- includeStationary: boolean().optional()
18444
- }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
18445
- deviceId: number(),
18446
- groupId: string().min(1)
18447
- }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
18448
- kind: "mutation",
18449
- auth: "admin"
18450
- }), 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({
18451
- deviceId: number(),
18452
- since: number().optional(),
18453
- until: number().optional(),
18454
- kinds: array(string()).optional(),
18455
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
18456
- }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
18457
- deviceId: number(),
18458
- since: number(),
18459
- until: number(),
18460
- bucketMs: number().int().positive()
18461
- }), array(object({
18462
- bucketStart: number(),
18463
- motion: number().int(),
18464
- object: number().int(),
18465
- audio: number().int()
18466
- })).readonly()), method(object({
18467
- deviceId: number(),
18468
- cutoffMs: number()
18469
- }), object({
18470
- motion: number().int(),
18471
- object: number().int(),
18472
- audio: number().int()
18473
- }), {
18474
- kind: "mutation",
18475
- auth: "admin"
18476
- }), method(object({
18477
- deviceId: number(),
18478
- cutoffMs: number()
18479
- }), TrackCascadeCountsSchema, {
18480
- kind: "mutation",
18481
- auth: "admin"
18482
- }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
18483
- kind: "mutation",
18484
- auth: "admin"
18485
- }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
18486
- kind: "mutation",
18487
- auth: "admin"
18488
- }), method(object({
18489
- deviceId: number(),
18490
- trackIds: array(string()).min(1)
18491
- }), object({
18492
- deleted: number().int(),
18493
- failed: array(string()).readonly()
18494
- }), {
18495
- kind: "mutation",
18496
- auth: "admin"
18497
- }), method(object({
18498
- /** Log/audit scope only — the trackId is globally unique on its own. */
18259
+ union([literal(1), literal(2)]);
18260
+ /**
18261
+ * WHO decided a label, and when. Carried per tier so a value can be traced to
18262
+ * the step and model that produced it — which is what makes the write rule
18263
+ * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
18264
+ * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
18265
+ *
18266
+ * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
18267
+ * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
18268
+ * `migration:4g` for a value the 4g migration moved from the single-slot era —
18269
+ * that value has no provenance, and the write rule lets ANY properly-attributed
18270
+ * write of the same tier replace it regardless of score.
18271
+ */
18272
+ var LabelAttributionSchema = object({
18273
+ stepId: string(),
18274
+ modelId: string().optional(),
18275
+ decidedAt: number(),
18276
+ /**
18277
+ * The GALLERY id behind a recognised tier-2 label — a face-gallery
18278
+ * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
18279
+ *
18280
+ * The text alone is a DISPLAY NAME, and a display name is renameable: a
18281
+ * notification rule authored on "Gianluca" stopped matching the moment the
18282
+ * operator fixed the spelling in the gallery, and nothing said so. The id is
18283
+ * the thing that does not move, so it is what a rule matches on
18284
+ * (`NcConditions.identities`) and the text is what a human is shown.
18285
+ *
18286
+ * Absent when the label names no gallery row — a plate the OCR read but no
18287
+ * vehicle claims, a sub-class, a species, any tier-1 value.
18288
+ */
18289
+ identityId: string().optional()
18290
+ });
18291
+ /**
18292
+ * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
18293
+ * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
18294
+ * track and its events always answer the same question the same way.
18295
+ *
18296
+ * Two scalar columns, not an array: every consumer wants "the coarse one" or
18297
+ * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
18298
+ * is tier 2, and each carries its own score + attribution.
18299
+ *
18300
+ * **Reading it.** What a human should be shown is `subLabel ?? label` — the
18301
+ * finest thing known. Before 4g the single `label` column held the finest
18302
+ * value, so a consumer that has not been updated reads the tier-1 slot and
18303
+ * shows nothing on a species-only row; that is why the migration puts every
18304
+ * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
18305
+ * and why the read surfaces were changed in the same train.
18306
+ *
18307
+ * **Writing it.** The slots are independent, which is the whole point: a
18308
+ * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
18309
+ * migratorius`), so fineness cannot regress by construction. Within a tier the
18310
+ * higher score wins. One rule, one implementation — see
18311
+ * `pipeline/label-tier.ts` in addon-post-analysis.
18312
+ */
18313
+ var TieredLabelFields = {
18314
+ /** Tier 1 — the sub-class. See {@link LabelTierSchema}. */
18315
+ label: string().optional(),
18316
+ /** Confidence of the tier-1 value, as reported by the deciding step. */
18317
+ labelScore: number().optional(),
18318
+ /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
18319
+ labelMeta: LabelAttributionSchema.optional(),
18320
+ /** Tier 2 the instance. See {@link LabelTierSchema}. */
18321
+ subLabel: string().optional(),
18322
+ /** Confidence of the tier-2 value, as reported by the deciding step. */
18323
+ subLabelScore: number().optional(),
18324
+ /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
18325
+ subLabelMeta: LabelAttributionSchema.optional()
18326
+ };
18327
+ /** Per-camera slice of a training-export estimate. */
18328
+ var TrainingExportDeviceTotalsSchema = object({
18499
18329
  deviceId: number(),
18330
+ tracks: number().int(),
18331
+ files: number().int(),
18332
+ bytes: number().int()
18333
+ });
18334
+ /**
18335
+ * What a training export WOULD contain. Computed from media index rows only —
18336
+ * no blob is read to produce this.
18337
+ */
18338
+ var TrainingExportSummarySchema = object({
18339
+ generatedAt: number(),
18340
+ trackCount: number().int(),
18341
+ fileCount: number().int(),
18342
+ byteCount: number().int(),
18343
+ /** More marked tracks exist than a single pass carries. */
18344
+ truncated: boolean(),
18345
+ devices: array(TrainingExportDeviceTotalsSchema).readonly()
18346
+ });
18347
+ var TrackSchema = object({
18500
18348
  trackId: string(),
18501
- flags: TrackFlagsPatchSchema
18502
- }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
18503
- kind: "query",
18504
- auth: "admin"
18505
- }), method(object({
18506
- olderThanMs: number(),
18507
- reason: OpsLogReasonSchema.optional()
18508
- }), EventPruneCountsSchema, {
18509
- kind: "mutation",
18510
- auth: "admin"
18511
- }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
18512
- kind: "mutation",
18513
- auth: "admin"
18514
- }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
18515
- kind: "mutation",
18516
- auth: "admin"
18517
- }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
18518
- kind: "mutation",
18519
- auth: "admin"
18520
- }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
18521
- kind: "mutation",
18522
- auth: "admin"
18523
- }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
18524
- kind: "mutation",
18525
- auth: "admin"
18526
- }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18527
- kind: "mutation",
18528
- auth: "admin"
18529
- }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
18530
- kind: "mutation",
18531
- auth: "admin"
18532
- }), method(object({}), array(RelocateJobSchema).readonly(), {
18533
- kind: "query",
18534
- auth: "admin"
18535
- }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18536
- kind: "mutation",
18537
- auth: "admin"
18538
- }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
18539
- kind: "query",
18540
- auth: "admin"
18541
- }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
18542
- kind: "query",
18543
- auth: "admin"
18544
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18545
- kind: "query",
18546
- auth: "admin"
18547
- }), method(object({
18548
- /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
18549
- * `deviceId`, deliberately: `deviceId` would make this device-bound and
18550
- * route it at one camera's owner, and "every camera" would stop being
18551
- * expressible at all. */
18552
- deviceIds: array(number()).optional(),
18553
- limit: number().int().min(1).max(500).optional()
18554
- }), array(RetrainTrackSchema).readonly(), {
18555
- kind: "query",
18556
- auth: "admin"
18557
- }), method(object({ trackId: string() }), RetrainFrameListSchema, {
18558
- kind: "query",
18559
- auth: "admin"
18560
- }), method(object({
18561
18349
  deviceId: number(),
18562
- trackId: string(),
18563
- mediaKeys: array(string()).min(1)
18564
- }), RetrainFrameSelectionSchema, {
18565
- kind: "mutation",
18566
- auth: "admin"
18567
- }), method(object({
18350
+ className: string(),
18351
+ ...TieredLabelFields,
18352
+ producingDeviceName: string().optional(),
18353
+ /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
18354
+ source: TrackSourceSchema.optional(),
18355
+ firstSeen: number(),
18356
+ lastSeen: number(),
18357
+ /** Frame-rate position history (subject to maxPositionHistory cap). */
18358
+ positions: array(TrackPositionSchema).readonly(),
18359
+ /** Periodic snapshots at snapshotIntervalMs cadence (subject to
18360
+ * saveThumbnails policy). */
18361
+ snapshots: array(TrackSnapshotSchema).readonly(),
18362
+ /** Deduplicated zones the track has entered at least once. Zone IDS. */
18363
+ zonesVisited: array(string()).readonly(),
18364
+ /**
18365
+ * Human NAMES for {@link zonesVisited}, resolved at READ time against the
18366
+ * `zones` capability.
18367
+ *
18368
+ * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
18369
+ * and no card can render — so every free-text search surface was structurally
18370
+ * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
18371
+ * just returned nothing. Resolving here rather than in each client keeps ONE
18372
+ * derivation and costs the clients no extra call (the `zones` cap is
18373
+ * per-device, so a client-side resolve would be a per-camera fan-out on a
18374
+ * surface built to avoid exactly that).
18375
+ *
18376
+ * Resolved, never invented: a zone deleted since the track was written has no
18377
+ * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
18378
+ * two are not positionally aligned. Absent when the track visited no zone, or
18379
+ * when the zone catalogue could not be read.
18380
+ */
18381
+ zoneNames: array(string()).readonly().optional(),
18382
+ /** Deduplicated set of detector classes observed for this track over its
18383
+ * life (a track may be reclassified, e.g. person→vehicle). Absent on
18384
+ * legacy rows written before class accumulation shipped. */
18385
+ classes: array(string()).readonly().optional(),
18386
+ /** Cumulative normalized distance travelled (0..1 units = full frame width). */
18387
+ totalDistance: number(),
18388
+ state: TrackStateSchema,
18389
+ active: boolean(),
18390
+ /** Deterministic key-event importance score in [0,1] (server-computed at
18391
+ * track expiry, recomputed on late label). Absent on legacy rows written
18392
+ * before scoring shipped — consumers degrade to absence / compute-on-read. */
18393
+ importance: number().optional(),
18394
+ /** Id of the track's highest-confidence ObjectEvent (its representative
18395
+ * "best" frame). Absent when the track produced no object events. */
18396
+ bestEventId: string().optional(),
18397
+ /** Tag of the importance sub-signal that dominated the score
18398
+ * (identity|dwell|proximity|class|confidence|travel|zone). */
18399
+ importanceReason: string().optional(),
18400
+ /** Audio-classification labels heard on the camera during the track's
18401
+ * life (score ≥ device `classificationMinScore`), aggregated per label.
18402
+ * Absent on legacy rows / tracks with no confident audio. */
18403
+ audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
18404
+ /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
18405
+ * Populated from the persisted envelope columns on historical reads;
18406
+ * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
18407
+ envelope: TrackEnvelopeSchema.optional(),
18408
+ /**
18409
+ * A face DETECTOR found a face on this track — nothing more. It says the
18410
+ * detail plane produced a `face` detail; it does NOT say the face was
18411
+ * embedded, matched, above `minFacePx`, or that the recognizer was even
18412
+ * enabled. Set once and never cleared.
18413
+ *
18414
+ * **This exists so "face present but not recognised" is expressible.** A
18415
+ * recognised identity lands in `subLabel` (attributed to the face chain via
18416
+ * `subLabelMeta.stepId`), so before this field a track with an unmatched face
18417
+ * and a track with no face at all were byte-identical on the wire and no
18418
+ * surface could tell them apart. The read is `hasFace === true && subLabel
18419
+ * === undefined`.
18420
+ *
18421
+ * **Absent ≠ false.** Every row written before the column existed omits it,
18422
+ * and so does every server that predates the field — a consumer must test
18423
+ * `=== true` and render nothing otherwise, never infer "no face".
18424
+ */
18425
+ hasFace: boolean().optional(),
18426
+ /**
18427
+ * This track has a face row IN THE GALLERY: a crop **and** an embedding — a
18428
+ * face an operator could ASSIGN to an identity.
18429
+ *
18430
+ * The STRICT twin of {@link hasFace}, and the pair only earns its keep
18431
+ * because the two disagree. `hasFace` is stamped at the TOP of the face
18432
+ * branch, before every gate, and means no more than "a face detector produced
18433
+ * a face detail". This one is stamped at the single moment the gallery row
18434
+ * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
18435
+ * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
18436
+ * candidate gate, the imageless-track drop (no crop was ever captured) and
18437
+ * the crop-store drop. Everything between the detector and that insert can
18438
+ * legitimately refuse the face, so a flag written any earlier promises the
18439
+ * operator something to assign and delivers nothing.
18440
+ *
18441
+ * **Independent of recognition.** A face collected but never auto-matched is
18442
+ * still assignable — it is in fact the face an operator most wants to reach —
18443
+ * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
18444
+ * `subLabel`; this says only that the raw material exists.
18445
+ *
18446
+ * **Set once, never cleared.** A track that produced a gallery row produced
18447
+ * one; deleting the row later is the gallery's business, not this flag's.
18448
+ *
18449
+ * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
18450
+ * before the column omits it, and so does every server that predates the
18451
+ * field. A consumer must test `=== true` and render nothing otherwise —
18452
+ * never infer "no assignable face".
18453
+ */
18454
+ hasEmbeddedFace: boolean().optional(),
18455
+ /**
18456
+ * This subject CONTAINS a folded rider — a person the rider-pairing step
18457
+ * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
18458
+ * so the passage is tracked once and as a VEHICLE.
18459
+ *
18460
+ * It exists because the fold's record was dishonest. D34 and the code both
18461
+ * said "the person is not lost — it is reported so both entities stay on the
18462
+ * record"; in fact the pair went into a per-processor RAM field behind an
18463
+ * accessor nobody called, and every durable surface said `vehicle`, full
18464
+ * stop. This is the composition note that makes the row true.
18465
+ *
18466
+ * A COMPOSITION, never a class and never a label. "This vehicle contains a
18467
+ * person" is not an answer to "what is this" — both label tiers would refuse
18468
+ * a macro token anyway (D89), and correctly. Nothing here changes what the
18469
+ * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
18470
+ * and a `person` rule still does not fire for someone cycling past.
18471
+ *
18472
+ * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
18473
+ * the column, and every hub that predates the field, omits it. Test
18474
+ * `=== true` and render nothing otherwise — never infer "no rider".
18475
+ */
18476
+ hasRider: boolean().optional(),
18477
+ ...TrackFlagFields,
18478
+ ...TrackRetrainFields
18479
+ });
18480
+ var BaseEventFields = {
18481
+ id: string(),
18568
18482
  deviceId: number(),
18569
- trackId: string(),
18570
- frameId: string()
18571
- }), object({
18572
- removed: boolean(),
18573
- removedAnnotations: number().int()
18574
- }), {
18575
- kind: "mutation",
18576
- auth: "admin"
18577
- }), method(object({ frameId: string() }), object({
18483
+ timestamp: number()
18484
+ };
18485
+ var MotionEventSchema = object({
18486
+ ...BaseEventFields,
18487
+ kind: literal("motion"),
18488
+ regionCount: number(),
18489
+ /** Heavy JSON array — omitted in slim projection. */
18490
+ regions: array(object({
18491
+ bbox: BoundingBoxSchema,
18492
+ pixelCount: number(),
18493
+ intensity: number()
18494
+ })).readonly().optional(),
18495
+ /** Omitted in slim projection. */
18496
+ frameWidth: number().optional(),
18497
+ /** Omitted in slim projection. */
18498
+ frameHeight: number().optional(),
18499
+ /** Populated by B5 (recording playback URL for this event). */
18500
+ mediaUrl: string().optional()
18501
+ });
18502
+ /**
18503
+ * Which detection SOURCE produced an object event. `pipeline` = the ML
18504
+ * detection pipeline (decoded-frame inference); `onboard` = the camera's
18505
+ * native on-device AI. Both flow through the SAME analysis layers (zoning,
18506
+ * tracking, per-kind persistence) but stay distinguishable so consumers
18507
+ * (advanced-notifier, occupancy, …) can select which source(s) to act on.
18508
+ * Absent on legacy rows ⇒ treat as `pipeline`.
18509
+ */
18510
+ var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
18511
+ /**
18512
+ * The confirmed zone crossing that produced an object event. Present ONLY on
18513
+ * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
18514
+ * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
18515
+ * appearance event carry none, so a rule asking for a direction fails closed
18516
+ * on them.
18517
+ *
18518
+ * Exactly ONE crossing per event: the emitter turns each confirmed crossing
18519
+ * into its own event, so a frame in which a track enters A while leaving B
18520
+ * produces two events with two directions — never one ambiguous row.
18521
+ *
18522
+ * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
18523
+ * membership the box has NOW, and by definition it no longer contains the zone
18524
+ * that was just left. Without the id here, a zone-scoped rule could never match
18525
+ * the exit it asked for.
18526
+ */
18527
+ var ZoneCrossingSchema = object({
18528
+ direction: _enum(["enter", "exit"]),
18529
+ /** Admin zone id crossed. */
18530
+ zoneId: string(),
18531
+ /** Zone display name at crossing time (falls back to the id). */
18532
+ zoneName: string().optional()
18533
+ });
18534
+ var ObjectEventSchema = object({
18535
+ ...BaseEventFields,
18536
+ kind: literal("object"),
18537
+ /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
18538
+ source: DetectionSourceSchema.optional(),
18539
+ /**
18540
+ * Inference-frame id shared by every object event emitted from the SAME frame
18541
+ * — the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
18542
+ * 2 people + 1 dog) under one full frame, and link a track's frames over time
18543
+ * (group by `trackId`, pick a representative `frameId` as the parent frame).
18544
+ * Optional for backward-compat with pre-existing rows / the slim projection
18545
+ * includes it (it is light). Absent on rows written before this field.
18546
+ */
18547
+ frameId: string().optional(),
18548
+ /** Omitted in slim projection. */
18549
+ trackId: string().optional(),
18550
+ className: string(),
18551
+ ...TieredLabelFields,
18552
+ /** Omitted in slim projection. */
18553
+ confidence: number().optional(),
18554
+ /** Heavy JSON — omitted in slim projection. */
18555
+ bbox: BoundingBoxSchema.optional(),
18556
+ /** Heavy JSON — omitted in slim projection. */
18557
+ zones: array(string()).readonly().optional(),
18558
+ /** Omitted in slim projection. */
18559
+ state: TrackStateSchema.optional(),
18560
+ /**
18561
+ * The zone crossing this event IS, when it is one. Absent on every other
18562
+ * event kind (movement state, appearance, package) — see
18563
+ * {@link ZoneCrossingSchema}. Omitted in slim projection.
18564
+ */
18565
+ zoneCrossing: ZoneCrossingSchema.optional(),
18566
+ /** Detection-frame dimensions in pixels — let consumers normalize the
18567
+ * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
18568
+ frameWidth: number().optional(),
18569
+ frameHeight: number().optional(),
18570
+ /** MediaStore key for the crop attached to this event (if any). */
18571
+ mediaKey: string().optional(),
18572
+ /** Design B: MediaStore key of the track's native-resolution key frame (the
18573
+ * best-detection full frame). Resolve via the event-media data-plane
18574
+ * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
18575
+ * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
18576
+ * sources — consumers fall back to `mediaKey` (the tight crop). */
18577
+ keyFrameMediaKey: string().optional(),
18578
+ /** Populated by B5 (recording playback URL for this event). */
18579
+ mediaUrl: string().optional(),
18580
+ /** The parent track's key-event importance [0,1], propagated to every object
18581
+ * event of the track (so an event row can be sorted by importance without a
18582
+ * track join). Absent on legacy rows / before the track was scored. */
18583
+ importance: number().optional()
18584
+ });
18585
+ var AudioEventSchema = object({
18586
+ ...BaseEventFields,
18587
+ kind: literal("audio"),
18588
+ rms: number(),
18589
+ dbfs: number(),
18590
+ classification: object({
18591
+ className: string(),
18592
+ originalClass: string().optional(),
18593
+ score: number()
18594
+ }).optional(),
18595
+ /** Populated by B5 (recording playback URL for this event). */
18596
+ mediaUrl: string().optional()
18597
+ });
18598
+ var MediaFileKindEnum = _enum([
18599
+ "crop",
18600
+ "thumbnail",
18601
+ "snapshot",
18602
+ "firstFrame",
18603
+ "lastFrame",
18604
+ "fullFrame",
18605
+ "fullFrameBoxed",
18606
+ "faceCrop",
18607
+ "plateCrop",
18608
+ "keyFrame",
18609
+ "keyFrameSmall",
18610
+ "thumbnailSmall"
18611
+ ]);
18612
+ var MediaFileSchema = object({
18613
+ key: string(),
18614
+ kind: MediaFileKindEnum,
18578
18615
  base64: string(),
18579
- width: number().int(),
18580
- height: number().int()
18581
- }), {
18582
- kind: "query",
18583
- auth: "admin"
18584
- }), method(object({
18585
- deviceId: number(),
18586
- trackId: string(),
18587
- frameId: string(),
18588
- subject: RetrainAssistSubjectSchema,
18589
- /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
18590
- nodeId: string().optional()
18591
- }), RetrainAssistResultSchema, {
18592
- kind: "mutation",
18593
- auth: "admin"
18594
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
18595
- kind: "query",
18596
- auth: "admin"
18597
- }), method(object({
18598
- deviceId: number(),
18599
- trackId: string(),
18600
- frameId: string(),
18601
- annotations: array(RetrainAnnotationDraftSchema)
18602
- }), array(RetrainAnnotationSchema).readonly(), {
18603
- kind: "mutation",
18604
- auth: "admin"
18605
- }), method(object({
18606
- deviceId: number(),
18607
- trackId: string()
18608
- }), RetrainTransitionResultSchema, {
18609
- kind: "mutation",
18610
- auth: "admin"
18611
- }), method(object({
18612
- deviceId: number(),
18613
- trackId: string()
18614
- }), RetrainTransitionResultSchema, {
18615
- kind: "mutation",
18616
- auth: "admin"
18617
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18618
- kind: "query",
18619
- auth: "admin"
18620
- }), method(object({
18621
- eventId: string(),
18622
- kind: MediaFileKindEnum.optional(),
18623
- deviceId: number()
18624
- }), array(MediaFileSchema).readonly()), method(object({
18625
- trackId: string(),
18626
- kinds: array(MediaFileKindEnum).optional(),
18627
- deviceId: number()
18628
- }), array(MediaFileSchema).readonly()), method(object({
18616
+ sizeBytes: number(),
18617
+ timestamp: number()
18618
+ });
18619
+ /**
18620
+ * One media row WITHOUT its bytes.
18621
+ *
18622
+ * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
18623
+ * 140 s track), and a client that renders tiles from the media data plane needs
18624
+ * to know only WHAT EXISTS — the bytes then arrive per tile, lazily, over HTTP
18625
+ * with an immutable cache, instead of all at once inside a tRPC response that
18626
+ * blocks the whole view.
18627
+ *
18628
+ * `sizeBytes` is carried because it is what lets a client decide between the
18629
+ * stored blob and a `?variant=thumb` rendering without fetching either.
18630
+ */
18631
+ var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
18632
+ /**
18633
+ * The MACRO tier of an annotation — a CLOSED set.
18634
+ *
18635
+ * This is what the exported detector predicts, so a typo here is a new class
18636
+ * with one example in it. `label` and `subLabel` are open strings by contrast:
18637
+ * the whole point of the page is teaching the model things it does not know
18638
+ * yet, and constraining that vocabulary would make it useless.
18639
+ *
18640
+ * A macro class is NEVER a label. The provider refuses a write whose `label` or
18641
+ * `subLabel` is one of these values, in any casing, because once `person`
18642
+ * exists in both tiers "every person box" stops being answerable without
18643
+ * knowing every string anyone ever typed — and the damage is retroactive.
18644
+ */
18645
+ var RetrainMacroClassSchema = _enum([
18646
+ "person",
18647
+ "vehicle",
18648
+ "animal",
18649
+ "package",
18650
+ "face",
18651
+ "plate"
18652
+ ]);
18653
+ /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
18654
+ var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
18655
+ /** Did a human draw this box, or did the assist propose it? */
18656
+ var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
18657
+ /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
18658
+ var RetrainBboxSchema = object({
18659
+ x: number(),
18660
+ y: number(),
18661
+ w: number(),
18662
+ h: number()
18663
+ });
18664
+ /**
18665
+ * One annotated subject.
18666
+ *
18667
+ * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
18668
+ * (letterboxed root / zone-cropped package / subject-cropped classifier) are
18669
+ * derived from it at export and never stored — storing them is how one feature
18670
+ * space ends up holding two crops of the same subject (D52).
18671
+ */
18672
+ var RetrainAnnotationSchema = object({
18673
+ id: string(),
18629
18674
  trackId: string(),
18630
- deviceId: number()
18631
- }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
18632
- kind: "mutation",
18633
- auth: "admin"
18634
- }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
18635
- kind: "mutation",
18636
- auth: "admin"
18637
- }), method(object({}), RebuildStatusSchema), object({
18638
- deviceId: number(),
18639
- timestamp: number(),
18640
- frameWidth: number(),
18641
- frameHeight: number(),
18642
- detections: array(OverlayDetectionSchema).readonly()
18643
- }), object({
18644
18675
  deviceId: number(),
18676
+ /** The COPY in retrain storage — never the source track's media key. */
18677
+ mediaKey: string(),
18678
+ bbox: RetrainBboxSchema,
18679
+ macroClass: RetrainMacroClassSchema,
18680
+ label: string().optional(),
18681
+ subLabel: string().optional(),
18682
+ kind: RetrainAnnotationKindSchema,
18683
+ source: RetrainAnnotationSourceSchema,
18684
+ /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
18685
+ assistModelId: string().optional(),
18686
+ assistScore: number().optional(),
18687
+ exportedInBatch: string().optional(),
18688
+ createdAt: number()
18689
+ });
18690
+ /** The write form — the server owns `id`, `createdAt` and the frame binding. */
18691
+ var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
18692
+ id: true,
18693
+ trackId: true,
18694
+ deviceId: true,
18695
+ mediaKey: true,
18696
+ createdAt: true,
18697
+ exportedInBatch: true
18698
+ });
18699
+ /** A track sitting in `staging`, with everything the worklist needs to rank it. */
18700
+ var RetrainTrackSchema = object({
18645
18701
  trackId: string(),
18646
- className: string()
18647
- }), object({
18648
18702
  deviceId: number(),
18649
- trackId: string(),
18650
18703
  className: string(),
18651
- durationMs: number()
18652
- }), object({
18704
+ label: string().optional(),
18705
+ firstSeen: number(),
18706
+ lastSeen: number(),
18707
+ /** How many frames the dataset already holds from this track. */
18708
+ frameCount: number().int(),
18709
+ /** How many subjects have been annotated on those frames. `0` with
18710
+ * `frameCount: 0` is exactly "staging, still to work". */
18711
+ annotationCount: number().int()
18712
+ });
18713
+ /** A frame the picker may offer — an index row, no blob was read to produce it. */
18714
+ var RetrainFrameCandidateSchema = object({
18715
+ mediaKey: string(),
18716
+ kind: MediaFileKindEnum,
18717
+ timestamp: number(),
18718
+ sizeBytes: number().int(),
18719
+ /** A copy of this original already exists — selecting it is free and cannot
18720
+ * fail, whatever became of the original. */
18721
+ copied: boolean()
18722
+ });
18723
+ /** A frame the dataset OWNS: bytes copied at selection time. */
18724
+ var RetrainFrameSchema = object({
18725
+ frameId: string(),
18653
18726
  deviceId: number(),
18654
- kind: EventKindSchema,
18655
- eventId: string(),
18656
- timestamp: number()
18727
+ trackId: string(),
18728
+ /** Provenance only. It may already point at nothing — that is expected. */
18729
+ sourceMediaKey: string(),
18730
+ sourceKind: MediaFileKindEnum,
18731
+ sizeBytes: number().int(),
18732
+ width: number().int(),
18733
+ height: number().int(),
18734
+ copiedAt: number()
18657
18735
  });
18658
- /**
18659
- * Reference to the frame's retained NATIVE surface + the parent crop's placement
18660
- * within the frame, so the executor can re-cut a leaf child ROI at native
18661
- * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
18662
- */
18663
- var NativeCropRefSchema = object({
18664
- /** Handle keying the retained native surface (node-pinned to its owner). */
18665
- handle: FrameHandleSchema,
18666
- /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
18667
- cropFrameSpace: object({
18668
- x: number(),
18669
- y: number(),
18670
- w: number(),
18671
- h: number()
18672
- })
18736
+ /** Why a copy-on-select could not be honoured — named, never a silent skip. */
18737
+ var RetrainCopyRefusalSchema = _enum([
18738
+ "source-missing",
18739
+ "unreadable-image",
18740
+ "write-failed"
18741
+ ]);
18742
+ var RetrainFrameSelectionSchema = object({
18743
+ copied: array(RetrainFrameSchema).readonly(),
18744
+ refused: array(object({
18745
+ sourceMediaKey: string(),
18746
+ reason: RetrainCopyRefusalSchema
18747
+ })).readonly()
18673
18748
  });
18674
- object({
18675
- crop: object({
18676
- left: number(),
18677
- top: number(),
18678
- width: number().positive(),
18679
- height: number().positive()
18680
- }).optional(),
18681
- content: object({
18682
- width: number().int().positive(),
18683
- height: number().int().positive()
18684
- }),
18685
- fit: _enum(["stretch", "contain"]),
18686
- format: _enum([
18687
- "rgb",
18688
- "gray",
18689
- "jpeg"
18690
- ])
18749
+ var RetrainFrameListSchema = object({
18750
+ candidates: array(RetrainFrameCandidateSchema).readonly(),
18751
+ copies: array(RetrainFrameSchema).readonly(),
18752
+ /** What the page pre-selects — the native key frame when one survives. */
18753
+ autoPickMediaKey: string().optional()
18691
18754
  });
18755
+ /** What the operator asked the assist to look for. */
18756
+ var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
18757
+ kind: literal("package"),
18758
+ zone: RetrainBboxSchema.optional()
18759
+ }), object({
18760
+ kind: literal("objects"),
18761
+ modelId: string(),
18762
+ minScore: number().optional()
18763
+ })]);
18692
18764
  /**
18693
- * Process-local frame identity. It is serializable so it can ride an in-process
18694
- * capability call, but `registryId` deliberately prevents resolution in any
18695
- * other process or execution group.
18765
+ * The assist's answer a discriminated union, because "the model saw nothing"
18766
+ * and "this node cannot run that model" lead to different next moves and a
18767
+ * nullable result cannot tell them apart.
18696
18768
  */
18697
- var FrameRefSchema = object({
18698
- registryId: string().min(1),
18699
- id: string().min(1),
18700
- width: number().int().positive(),
18701
- height: number().int().positive(),
18702
- format: _enum(["rgb", "gray"]),
18703
- timestamp: number(),
18704
- capturedAt: number().optional()
18769
+ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
18770
+ kind: literal("proposed"),
18771
+ modelId: string(),
18772
+ stepId: string(),
18773
+ minScore: number(),
18774
+ /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
18775
+ proposals: array(RetrainAnnotationDraftSchema).readonly(),
18776
+ /** Returned by the runner but removed by the threshold. */
18777
+ belowThreshold: number().int()
18778
+ }), object({
18779
+ kind: literal("refused"),
18780
+ /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
18781
+ reason: string(),
18782
+ detail: string().optional()
18783
+ })]);
18784
+ /** The outcome of a lifecycle move owned by the retrain page. */
18785
+ var RetrainTransitionResultSchema = object({
18786
+ trackId: string(),
18787
+ /** Where the track ended up, whatever happened. */
18788
+ retrainStatus: RetrainStatusSchema,
18789
+ /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
18790
+ changed: boolean(),
18791
+ reason: _enum([
18792
+ "unknown-track",
18793
+ "no-frames-copied",
18794
+ "not-staging",
18795
+ "not-trained",
18796
+ "unchanged"
18797
+ ]).optional()
18705
18798
  });
18706
- var ModelFormatSchema$1 = _enum([
18707
- "onnx",
18708
- "coreml",
18709
- "openvino",
18710
- "tflite",
18711
- "pt",
18712
- "gguf"
18713
- ]);
18714
- var PipelineSlotSchema = _enum([
18715
- "detector",
18716
- "cropper",
18717
- "classifier",
18718
- "refiner",
18719
- "audio-classifier"
18720
- ]);
18721
- var PipelineEngineChoiceSchema = object({
18722
- runtime: _enum(["node", "python"]),
18723
- backend: string(),
18724
- format: ModelFormatSchema$1,
18725
- device: string().optional()
18799
+ var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
18800
+ var MAX_EVENT_QUERY_LIMIT = 5e3;
18801
+ var DeviceEventQueryInput = object({
18802
+ deviceId: number(),
18803
+ since: number().optional(),
18804
+ until: number().optional(),
18805
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
18806
+ /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
18807
+ * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
18808
+ * exact behaviour. Callers may omit this field — the store defaults to
18809
+ * `full` when not provided. */
18810
+ projection: _enum(["full", "slim"]).optional()
18726
18811
  });
18727
- var AvailableEngineSchema = object({
18728
- engine: PipelineEngineChoiceSchema,
18729
- devices: array(object({
18730
- id: string(),
18731
- label: string(),
18732
- description: string().optional()
18733
- })).readonly(),
18734
- defaultDevice: string()
18812
+ var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
18813
+ var RecentTracksQueryInput = object({
18814
+ /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
18815
+ deviceIds: array(number()),
18816
+ /** Window lower bound on `lastSeen` (inclusive). */
18817
+ since: number().optional(),
18818
+ /** Window upper bound on `lastSeen` (inclusive). */
18819
+ until: number().optional(),
18820
+ /** Page size. Default 200, max 1000. */
18821
+ limit: number().int().min(1).max(1e3).default(200),
18822
+ /** Opaque continuation cursor from a previous page's `nextCursor`.
18823
+ * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
18824
+ cursor: string().optional(),
18825
+ /** See {@link TrackProjectionSchema}. Default `full`. */
18826
+ projection: TrackProjectionSchema.optional(),
18827
+ /** Include stationary-promoted rows (parked objects). Default false: the
18828
+ * feed lists passages; parking records live on the stationary registry. */
18829
+ includeStationary: boolean().optional()
18830
+ });
18831
+ var RecentTracksPageSchema = object({
18832
+ /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
18833
+ tracks: array(TrackSchema).readonly(),
18834
+ /** Cursor for the next page, or null when this page is the last. */
18835
+ nextCursor: string().nullable()
18735
18836
  });
18736
- var PipelineDefaultStepSchema = lazy(() => object({
18737
- addonId: string(),
18738
- addonName: string(),
18739
- slot: PipelineSlotSchema,
18740
- inputClasses: array(string()).readonly(),
18741
- outputClasses: array(string()).readonly(),
18742
- enabled: boolean(),
18743
- modelId: string(),
18744
- children: array(PipelineDefaultStepSchema).readonly(),
18745
- group: string().optional(),
18746
- settings: record(string(), unknown()).optional()
18747
- }));
18748
- var PipelineTemplateStepSchema = lazy(() => object({
18749
- addonId: string(),
18750
- enabled: boolean(),
18751
- modelId: string(),
18752
- children: array(PipelineTemplateStepSchema).readonly(),
18753
- settings: record(string(), unknown()).optional()
18754
- }));
18755
- var PipelineTemplateSchema$1 = object({
18837
+ var LIST_GROUPS_DEFAULT_LIMIT = 40;
18838
+ var LIST_GROUPS_MAX_LIMIT = 100;
18839
+ var AnalyticsGroupRecordSchema = object({
18756
18840
  id: string(),
18757
- name: string(),
18758
- createdAt: string(),
18759
- updatedAt: string(),
18760
- engine: PipelineEngineChoiceSchema,
18761
- steps: array(PipelineTemplateStepSchema).readonly()
18841
+ deviceId: number().int(),
18842
+ openedAt: number().int(),
18843
+ closedAt: number().int(),
18844
+ timestamp: number().int(),
18845
+ memberCount: number().int(),
18846
+ memberTrackIds: array(string()).readonly(),
18847
+ className: string(),
18848
+ classes: array(string()).readonly(),
18849
+ /** Relative event-media path, or null when the group has no picture yet. */
18850
+ mediaUrl: string().nullable(),
18851
+ singleton: boolean()
18762
18852
  });
18763
- var PipelineModelOptionSchema = object({
18764
- id: string(),
18765
- name: string(),
18766
- formats: record(string(), object({
18767
- downloaded: boolean(),
18768
- sizeMB: number()
18769
- })),
18770
- group: ModelVariantGroupSchema.optional(),
18771
- legacy: boolean().optional(),
18772
- provider: ModelProviderIdSchema.optional()
18853
+ var AnalyticsGroupMemberSchema = object({
18854
+ trackId: string(),
18855
+ deviceId: number().int(),
18856
+ className: string(),
18857
+ firstSeen: number().int(),
18858
+ lastSeen: number().int(),
18859
+ mediaUrl: string().nullable()
18773
18860
  });
18774
- var ConfigFieldBridge = custom();
18775
- var PipelineAddonSchemaSchema = object({
18776
- id: string(),
18777
- name: string(),
18778
- slot: PipelineSlotSchema,
18779
- inputClasses: array(string()).readonly(),
18780
- outputClasses: array(string()).readonly(),
18781
- childSlots: array(PipelineSlotSchema).readonly(),
18782
- models: array(PipelineModelOptionSchema).readonly(),
18783
- defaultModelId: string(),
18784
- defaultModelIdByFormat: record(string(), string()).optional(),
18785
- enabledByDefault: boolean().optional(),
18786
- backfillIntoExistingOverrides: boolean().optional(),
18787
- defaultConfidence: number(),
18788
- group: string().optional(),
18789
- configSchema: array(ConfigFieldBridge).readonly().optional()
18861
+ var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
18862
+ var ListGroupsQueryInput = object({
18863
+ /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
18864
+ deviceIds: array(number()),
18865
+ /** Window lower bound on `closedAt` (inclusive). */
18866
+ since: number().optional(),
18867
+ /** Window upper bound on `openedAt` (inclusive). */
18868
+ until: number().optional(),
18869
+ limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
18870
+ /** Opaque continuation cursor from a previous page's `nextCursor`. */
18871
+ cursor: string().optional()
18790
18872
  });
18791
- var PipelineSlotSchemaSchema = object({
18792
- id: PipelineSlotSchema,
18793
- label: string(),
18794
- priority: number(),
18795
- parentSlot: PipelineSlotSchema.nullable(),
18796
- addons: array(PipelineAddonSchemaSchema).readonly()
18873
+ var ListGroupsPageSchema = object({
18874
+ groups: array(AnalyticsGroupRecordSchema).readonly(),
18875
+ nextCursor: string().nullable()
18797
18876
  });
18798
- var PipelineSchemaSchema = object({
18799
- availableEngines: array(AvailableEngineSchema).readonly(),
18800
- selectedEngine: PipelineEngineChoiceSchema,
18801
- slots: array(PipelineSlotSchemaSchema).readonly()
18877
+ var KeyEventQueryInput = object({
18878
+ deviceId: number(),
18879
+ /** Window lower bound (track firstSeen ≥ since). */
18880
+ since: number(),
18881
+ /** Window upper bound (track firstSeen ≤ until). */
18882
+ until: number(),
18883
+ limit: number().int().min(1).max(200).default(50),
18884
+ /** Drop tracks scoring below this importance. */
18885
+ minImportance: number().min(0).max(1).optional(),
18886
+ /** Restrict to a single class (e.g. 'person'). */
18887
+ classFilter: string().optional()
18802
18888
  });
18803
- var EngineProvisioningSchema = object({
18804
- runtimeId: _enum([
18805
- "onnx",
18806
- "openvino",
18807
- "coreml",
18808
- "edgetpu"
18809
- ]).nullable(),
18810
- device: string().nullable(),
18811
- state: _enum([
18812
- "idle",
18813
- "installing",
18814
- "verifying",
18815
- "ready",
18816
- "failed"
18817
- ]),
18818
- progress: number().optional(),
18819
- error: string().optional(),
18820
- nextRetryAt: number().optional(),
18821
- /**
18822
- * Gate A (config-correctness gate at engine change): human-readable
18823
- * config issues surfaced EAGERLY when the node's engine changes — model
18824
- * substitutions ("chose X, running Y") and zero-build steps ("no model
18825
- * has a <format> build"). Additive/optional: informational only, never
18826
- * enforced here — `assertEngineReady` (readiness) still gates inference.
18827
- * Absent/empty when the node-default tree resolves cleanly.
18828
- */
18829
- configIssues: array(string()).optional()
18889
+ var KeyEventSchema = object({
18890
+ /** The representative event id (the track's best ObjectEvent, else its trackId). */
18891
+ id: string(),
18892
+ trackId: string(),
18893
+ /** Track start time (firstSeen). */
18894
+ timestamp: number(),
18895
+ className: string(),
18896
+ ...TieredLabelFields,
18897
+ importance: number(),
18898
+ /** Highest-confidence ObjectEvent id for the track (empty when none). */
18899
+ bestEventId: string(),
18900
+ /** Track lifetime in ms (lastSeen - firstSeen). */
18901
+ windowMs: number().optional(),
18902
+ ...TrackFlagFields,
18903
+ ...TrackRetrainFields
18830
18904
  });
18831
- var PipelineStepInputSchema = lazy(() => object({
18832
- addonId: string(),
18833
- modelId: string().optional(),
18834
- enabled: boolean().default(true),
18835
- children: array(PipelineStepInputSchema).optional(),
18836
- settings: record(string(), unknown()).optional(),
18837
- jumpDeviceKey: string().optional()
18838
- }));
18839
- var ModelSubstitutionSchema = object({
18840
- addonId: string(),
18841
- chosen: string(),
18842
- running: string(),
18843
- format: string()
18905
+ object({
18906
+ trackId: string(),
18907
+ className: string(),
18908
+ confidence: number(),
18909
+ bbox: BoundingBoxSchema,
18910
+ zones: array(string()).readonly(),
18911
+ state: TrackStateSchema
18844
18912
  });
18845
- var PipelineValidationIssueSchema = object({
18846
- addonId: string(),
18847
- kind: _enum(["unknown-addon", "no-format-build"]),
18848
- detail: string()
18913
+ var OverlayDetectionSchema = looseObject({
18914
+ id: string(),
18915
+ kind: _enum(["first-level", "detail"]),
18916
+ macroClass: string(),
18917
+ score: number(),
18918
+ bbox: object({
18919
+ x: number(),
18920
+ y: number(),
18921
+ width: number(),
18922
+ height: number()
18923
+ }),
18924
+ labels: array(looseObject({
18925
+ label: string(),
18926
+ score: number()
18927
+ })).readonly(),
18928
+ parentId: string().optional()
18849
18929
  });
18850
- var PipelineValidationResultSchema = object({
18851
- ok: boolean(),
18852
- issues: array(PipelineValidationIssueSchema).readonly(),
18853
- substitutions: array(ModelSubstitutionSchema).readonly(),
18854
- /** The node's `currentEngine.format` this validation ran against. */
18855
- format: string()
18930
+ var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
18931
+ var SearchObjectEventsInput = object({
18932
+ text: string(),
18933
+ deviceId: number().optional(),
18934
+ since: number().optional(),
18935
+ until: number().optional(),
18936
+ classFilter: string().optional(),
18937
+ limit: number().default(50),
18938
+ minScore: number().min(0).max(1).default(.2)
18856
18939
  });
18857
- var ReferenceImageEntrySchema = object({
18858
- filename: string(),
18859
- stepIds: array(string()).readonly().optional()
18940
+ var TrackCascadeCountsSchema = object({
18941
+ /** Persisted track roots deleted (authoritative). */
18942
+ tracks: number().int(),
18943
+ /** Object events removed with their tracks (best-effort; see note above). */
18944
+ events: number().int(),
18945
+ /** Track/face/plate-owned media removed (best-effort). Never identity media. */
18946
+ media: number().int(),
18947
+ /** Unassigned (non-enrolled) face reads removed (best-effort). */
18948
+ faces: number().int(),
18949
+ /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
18950
+ plates: number().int(),
18951
+ /** Per-track CLIP search vectors removed (best-effort). */
18952
+ embeddings: number().int(),
18953
+ /** Group membership + group rows removed with their last member (best-effort). */
18954
+ groups: number().int()
18860
18955
  });
18861
- var ReferenceImageBodySchema = object({
18862
- base64: string(),
18863
- filename: string()
18956
+ /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
18957
+ var DiskReconcileCountsSchema = object({
18958
+ mediaDropped: number().int(),
18959
+ tracks: number().int(),
18960
+ events: number().int()
18864
18961
  });
18865
- var ReferenceAudioEntrySchema = object({
18866
- filename: string(),
18867
- sizeKb: number()
18962
+ /** Event-store footprint for one camera. */
18963
+ var EventStoreDeviceFootprintSchema = object({
18964
+ deviceId: number(),
18965
+ /** Persisted event rows (motion + object + audio) for the camera. */
18966
+ rows: number().int(),
18967
+ /** Event-owned media bytes on disk for the camera. */
18968
+ bytes: number().int()
18969
+ });
18970
+ /** Aggregate event-store footprint: global totals + per-camera breakdown. */
18971
+ var EventStoreFootprintSchema = object({
18972
+ totalRows: number().int(),
18973
+ totalBytes: number().int(),
18974
+ devices: array(EventStoreDeviceFootprintSchema).readonly()
18975
+ });
18976
+ /** Per-kind counts returned by the event-prune / device-delete mutations. */
18977
+ var EventPruneCountsSchema = object({
18978
+ motion: number().int(),
18979
+ object: number().int(),
18980
+ audio: number().int()
18868
18981
  });
18869
- var ReferenceAudioBodySchema = object({ base64: string() });
18870
- var AudioBackendSchema = object({
18871
- id: string(),
18872
- name: string(),
18873
- description: string(),
18874
- available: boolean(),
18982
+ /**
18983
+ * Re-embed stored tracks from their key frames.
18984
+ *
18985
+ * The reason this is an operator-callable method and not a migration script:
18986
+ * every knob that decides what a vector MEANS — encoder model, crop margin,
18987
+ * squaring — is only changeable if the existing vectors can be regenerated.
18988
+ * Mixing feature spaces in one index makes cosine scores incomparable, and the
18989
+ * symptom is a quality regression with no visible cause.
18990
+ */
18991
+ var RebuildObjectEmbeddingsInput = object({
18992
+ /** Restrict to one camera. Omit for the whole fleet. */
18993
+ deviceId: number().optional(),
18994
+ since: number().optional(),
18995
+ until: number().optional(),
18996
+ /** Stop after this many tracks; the result reports whether more remain. */
18997
+ maxTracks: number().int().positive().optional(),
18875
18998
  /**
18876
- * Raw classifier labels this backend can emit (e.g. YAMNet's
18877
- * 521-class set or Apple SoundAnalysis's 303-class set). Used by
18878
- * the benchmark UI to populate the `enabledMicroClasses` filter
18879
- * specific to the selected backend without a separate fetch.
18999
+ * Run every embedding on THIS node instead of round-robining the fleet.
19000
+ *
19001
+ * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
19002
+ * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
19003
+ * calling it that would pin the rebuild REQUEST itself to that node — the
19004
+ * rebuild orchestration lives on the hub, and only the per-track step runs
19005
+ * remotely. This field is data; the per-track pin is applied inside.
19006
+ *
19007
+ * Absent ⇒ round-robin over every online node whose runner can serve the
19008
+ * pinned model.
18880
19009
  */
18881
- rawLabels: array(string()).readonly().optional()
18882
- });
18883
- var AudioCapabilitiesSchema = object({
18884
- activeBackend: string(),
18885
- availableBackends: array(AudioBackendSchema).readonly(),
18886
- sampleRate: number(),
18887
- chunkDurationMs: number()
18888
- });
18889
- var DownloadModelResultSchema = object({
18890
- filePath: string(),
18891
- sizeMB: number(),
18892
- durationMs: number()
19010
+ executeOnNodeId: string().optional(),
19011
+ /**
19012
+ * Milliseconds to wait between tracks; omit for the built-in default, `0` to
19013
+ * run flat out.
19014
+ *
19015
+ * A rebuild is bulk maintenance on hub-main's single thread. Measured
19016
+ * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
19017
+ * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
19018
+ * force is logged at start and finish so a deliberately slow pass reads
19019
+ * differently from a stalled one.
19020
+ */
19021
+ pacingMs: number().int().nonnegative().optional()
18893
19022
  });
18894
19023
  /**
18895
- * Wrapper carrying a single test run's result. Replaces the legacy
18896
- * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
18897
- * canonical `AudioResult` from the Phase 6 output rework: one
18898
- * `AudioDetection` per class above `minScore`, top-N candidates in
18899
- * `debug.alternateLabels['audio-classifier']`, per-source timings in
18900
- * `debug.stepTimings`. The outer `success`/`error` fields stay so the
18901
- * benchmark UI can still report a clean failure when the classifier
18902
- * cap isn't available.
19024
+ * Result of emptying the CLIP index.
19025
+ *
19026
+ * The clean slate before a policy change: a new crop margin or encoder model
19027
+ * leaves two feature spaces in one index whose cosine scores are not
19028
+ * comparable, so wiping and rebuilding is the only way to be sure every vector
19029
+ * means the same thing.
18903
19030
  */
18904
- var AudioTestResultSchema = object({
18905
- success: boolean(),
18906
- error: string().optional(),
18907
- frame: custom().optional()
19031
+ var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
19032
+ /**
19033
+ * Acknowledgement that a rebuild STARTED.
19034
+ *
19035
+ * The pass costs ~1s per track — 45 minutes for a 2,600-track fleet — so it
19036
+ * runs detached and this returns immediately. Waiting for it made the client
19037
+ * time out while the work carried on server-side, which is the worst of both:
19038
+ * no result and no way to know it was still going. Poll
19039
+ * `getObjectEmbeddingRebuildStatus` for progress.
19040
+ */
19041
+ var RebuildObjectEmbeddingsResultSchema = object({
19042
+ started: boolean(),
19043
+ /** True when a pass was already running; the new request is ignored. */
19044
+ alreadyRunning: boolean()
18908
19045
  });
18909
- var PipelineConfigBridge = custom();
18910
- var ConfigUISchemaBridge = custom();
18911
- var ConfigUISchemaNullableBridge = custom();
18912
- var InferenceCapabilitiesBridge = custom();
18913
- var ModelAvailabilityListBridge = custom();
18914
- var PipelineRunResultBridge = custom();
18915
- method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
18916
- modelId: string(),
18917
- settings: record(string(), unknown()).readonly()
18918
- }))), method(object({ steps: record(string(), object({
18919
- modelId: string(),
18920
- settings: record(string(), unknown()).readonly()
18921
- })) }), object({ success: literal(true) }), {
19046
+ var RebuildStatusSchema = object({
19047
+ running: boolean(),
19048
+ scanned: number(),
19049
+ rebuilt: number(),
19050
+ /** Tracks whose key frame is gone — nothing to re-embed from. */
19051
+ missingKeyFrame: number(),
19052
+ /** Tracks with no usable detection box. */
19053
+ missingBbox: number(),
19054
+ /**
19055
+ * Tracks an executing node REFUSED rather than broke on — an unreadable key
19056
+ * frame, a step that threw. Separate from `failed` because the remedy is
19057
+ * different, and because a whole camera silently contributing zero vectors
19058
+ * is the shape of failure a rebuild must never hide.
19059
+ */
19060
+ notRunnable: number(),
19061
+ /**
19062
+ * The pass stopped because NO node could serve the pinned model.
19063
+ *
19064
+ * Distinct from `notRunnable` on purpose: that one says "this track was
19065
+ * refused", this one says "the cluster cannot do this work at all" — every
19066
+ * candidate node either lacks the `clip-embedding` step, lacks a build of the
19067
+ * pinned model for its engine format, or dropped out. The remedy is a model /
19068
+ * engine change, not a per-camera one. Non-zero here always comes with
19069
+ * `complete: false`.
19070
+ */
19071
+ noCapableNode: number(),
19072
+ failed: number(),
19073
+ /** Set once a pass ends: true only when EVERYTHING was covered. */
19074
+ complete: boolean().nullable(),
19075
+ startedAtMs: number().nullable(),
19076
+ finishedAtMs: number().nullable(),
19077
+ /** Present when the pass ended by throwing. */
19078
+ error: string().nullable()
19079
+ });
19080
+ var ReplayFrameInputSchema = object({
19081
+ timestamp: number(),
19082
+ frame: PipelineRunResultBridge
19083
+ });
19084
+ var RunReplayFrameProcessorResultSchema = object({ tracks: array(object({
19085
+ className: string(),
19086
+ firstSeenMs: number(),
19087
+ lastSeenMs: number(),
19088
+ /** Bbox of the track's FIRST matched detection, pixel-space in the clip's
19089
+ * frame — a representative box for the diff's `(className, window, IoU)`
19090
+ * pairing (`replay-diff.ts`). A replay does not need the full per-frame
19091
+ * trajectory production's `Track.positions` keeps. */
19092
+ bbox: BoundingBoxSchema,
19093
+ /** How many of the input frames this track matched a real detection on
19094
+ * (never a coasted/extrapolated frame) — the replay's own signal for "how
19095
+ * solid is this track", cheaper than re-deriving it from a trajectory. */
19096
+ framesMatched: number().int()
19097
+ })).readonly() });
19098
+ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
19099
+ deviceId: number(),
19100
+ trackId: string()
19101
+ }), TrackSchema.nullable()), method(object({
19102
+ deviceId: number(),
19103
+ since: number().optional(),
19104
+ until: number().optional(),
19105
+ limit: number().optional(),
19106
+ /** Spatial filter — only tracks whose trajectory intersects the zone
19107
+ * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
19108
+ * envelope columns, then precisely tested per position. Tracks with
19109
+ * an unknown envelope (no frame dims at persist time) always match. */
19110
+ zone: TrackZoneFilterSchema.optional(),
19111
+ /** See {@link TrackProjectionSchema}. Default `full` (backward
19112
+ * compatible — omitting the field keeps today's exact behaviour). */
19113
+ projection: TrackProjectionSchema.optional(),
19114
+ /** Include stationary-promoted rows (parked objects handed to the
19115
+ * stationary registry). Default false: the timeline lists passages,
19116
+ * not parking records (operator decision, 2026-08-15). */
19117
+ includeStationary: boolean().optional()
19118
+ }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
19119
+ deviceId: number(),
19120
+ groupId: string().min(1)
19121
+ }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
19122
+ kind: "mutation",
19123
+ auth: "admin"
19124
+ }), 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({
19125
+ deviceId: number(),
19126
+ since: number().optional(),
19127
+ until: number().optional(),
19128
+ kinds: array(string()).optional(),
19129
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
19130
+ }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
19131
+ deviceId: number(),
19132
+ since: number(),
19133
+ until: number(),
19134
+ bucketMs: number().int().positive()
19135
+ }), array(object({
19136
+ bucketStart: number(),
19137
+ motion: number().int(),
19138
+ object: number().int(),
19139
+ audio: number().int()
19140
+ })).readonly()), method(object({
19141
+ deviceId: number(),
19142
+ cutoffMs: number()
19143
+ }), object({
19144
+ motion: number().int(),
19145
+ object: number().int(),
19146
+ audio: number().int()
19147
+ }), {
19148
+ kind: "mutation",
19149
+ auth: "admin"
19150
+ }), method(object({
19151
+ deviceId: number(),
19152
+ cutoffMs: number()
19153
+ }), TrackCascadeCountsSchema, {
19154
+ kind: "mutation",
19155
+ auth: "admin"
19156
+ }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
19157
+ kind: "mutation",
19158
+ auth: "admin"
19159
+ }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
19160
+ kind: "mutation",
19161
+ auth: "admin"
19162
+ }), method(object({
19163
+ deviceId: number(),
19164
+ trackIds: array(string()).min(1)
19165
+ }), object({
19166
+ deleted: number().int(),
19167
+ failed: array(string()).readonly()
19168
+ }), {
19169
+ kind: "mutation",
19170
+ auth: "admin"
19171
+ }), method(object({
19172
+ /** Log/audit scope only — the trackId is globally unique on its own. */
19173
+ deviceId: number(),
19174
+ trackId: string(),
19175
+ flags: TrackFlagsPatchSchema
19176
+ }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
19177
+ kind: "query",
19178
+ auth: "admin"
19179
+ }), method(object({
19180
+ olderThanMs: number(),
19181
+ reason: OpsLogReasonSchema.optional()
19182
+ }), EventPruneCountsSchema, {
19183
+ kind: "mutation",
19184
+ auth: "admin"
19185
+ }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
19186
+ kind: "mutation",
19187
+ auth: "admin"
19188
+ }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
19189
+ kind: "mutation",
19190
+ auth: "admin"
19191
+ }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
19192
+ kind: "mutation",
19193
+ auth: "admin"
19194
+ }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
19195
+ kind: "mutation",
19196
+ auth: "admin"
19197
+ }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
19198
+ kind: "mutation",
19199
+ auth: "admin"
19200
+ }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
19201
+ kind: "mutation",
19202
+ auth: "admin"
19203
+ }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
19204
+ kind: "mutation",
19205
+ auth: "admin"
19206
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
19207
+ kind: "query",
19208
+ auth: "admin"
19209
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18922
19210
  kind: "mutation",
18923
19211
  auth: "admin"
18924
- }), method(object({ nodeId: string() }), object({
18925
- success: literal(true),
18926
- clearedDevices: number()
18927
- }), {
19212
+ }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
19213
+ kind: "query",
19214
+ auth: "admin"
19215
+ }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
19216
+ kind: "query",
19217
+ auth: "admin"
19218
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
19219
+ kind: "query",
19220
+ auth: "admin"
19221
+ }), method(object({
19222
+ /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
19223
+ * `deviceId`, deliberately: `deviceId` would make this device-bound and
19224
+ * route it at one camera's owner, and "every camera" would stop being
19225
+ * expressible at all. */
19226
+ deviceIds: array(number()).optional(),
19227
+ limit: number().int().min(1).max(500).optional()
19228
+ }), array(RetrainTrackSchema).readonly(), {
19229
+ kind: "query",
19230
+ auth: "admin"
19231
+ }), method(object({ trackId: string() }), RetrainFrameListSchema, {
19232
+ kind: "query",
19233
+ auth: "admin"
19234
+ }), method(object({
19235
+ deviceId: number(),
19236
+ trackId: string(),
19237
+ mediaKeys: array(string()).min(1)
19238
+ }), RetrainFrameSelectionSchema, {
18928
19239
  kind: "mutation",
18929
19240
  auth: "admin"
18930
- }), 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({
18931
- name: string(),
18932
- steps: array(PipelineTemplateStepSchema).readonly(),
18933
- engine: PipelineEngineChoiceSchema
18934
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
18935
- id: string(),
18936
- name: string().optional(),
18937
- steps: array(PipelineTemplateStepSchema).readonly().optional()
18938
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
18939
- addonId: string(),
18940
- modelId: string(),
18941
- format: ModelFormatSchema$1
18942
- }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
18943
- addonId: string(),
18944
- modelId: string(),
18945
- format: ModelFormatSchema$1
18946
- }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
18947
- engine: PipelineEngineChoiceSchema.optional(),
18948
- steps: array(PipelineStepInputSchema).min(1),
18949
- frame: FrameInputSchema.optional(),
18950
- /**
18951
- * Process-local lazy frame. Valid only when caller and provider resolve
18952
- * in the same execution-group process; split/cross-node callers use
18953
- * `frame`/`image` inline compatibility instead.
18954
- */
18955
- frameRef: FrameRefSchema.optional(),
18956
- /**
18957
- * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
18958
- * the decoded pixels live in. One more member of the one-of
18959
- * frame/frameHandle/image/imageBase64/referenceImage group.
18960
- */
18961
- frameHandle: FrameHandleSchema.optional(),
18962
- imageBase64: string().optional(),
18963
- /**
18964
- * Binary JPEG bytes — preferred over `imageBase64` on internal
18965
- * hops (hub → forked worker via Moleculer MsgPack) because it
18966
- * skips the 33% base64 overhead + the per-call base64 decode on
18967
- * the detection-pipeline worker. Callers can pass either; exactly
18968
- * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
18969
- */
18970
- image: _instanceof(Uint8Array).optional(),
18971
- referenceImage: string().optional(),
18972
- deviceId: number().optional(),
18973
- sessionId: string().optional(),
18974
- /**
18975
- * Execution plane. 'full' (default) runs the whole tree — benchmark,
18976
- * reference-image, and detail-subtree calls. 'frame' is the live
18977
- * per-frame dispatch: ONLY root-plane steps run; crop children
18978
- * (inputClasses ≠ null) are skipped and served per-track via
18979
- * pipelineRunner.runDetailSubtree (two-plane design).
18980
- */
18981
- plane: _enum(["full", "frame"]).optional(),
18982
- /**
18983
- * Inference-device selector (Phase 2 multi-device). Format
18984
- * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
18985
- * Omitted ⇒ the runner's default device (current single-engine
18986
- * behaviour). Selects WHICH device pool of the node runs the call.
18987
- */
18988
- deviceKey: string().optional(),
18989
- /**
18990
- * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
18991
- * when the parent crop was resolved from the frame's retained NATIVE
18992
- * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
18993
- * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
18994
- * resolution from that surface — the SAME quality path faces already
18995
- * had — instead of the downscaled parent tile. `handle` keys the native
18996
- * surface (node-pinned to its owner); `cropFrameSpace` is the parent
18997
- * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
18998
- * the executor's crop-normalized child ROI back into frame-normalized
18999
- * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
19000
- * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
19001
- * (today's behaviour on the fallback path).
19002
- */
19003
- nativeCropRef: NativeCropRefSchema.optional()
19004
- }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
19005
- engine: PipelineEngineChoiceSchema.optional(),
19006
- steps: array(PipelineStepInputSchema).min(1),
19007
- frames: array(FrameInputSchema).min(1).max(255),
19008
- deviceId: number().optional(),
19009
- sessionId: string().optional(),
19010
- /**
19011
- * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
19012
- * the batch to the Python pool's bench preprocess cache
19013
- * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
19014
- * preprocessed ONCE and every later inference is a pure-inference cache
19015
- * hit — the sustained-throughput run measures inference, not
19016
- * decode+preprocess+infer. Omitted/0 for live frames (all different →
19017
- * full preprocess every call, correct). Fresh per sustained run;
19018
- * released via `uncacheFrame`.
19019
- */
19020
- frameId: number().int().nonnegative().optional(),
19021
- /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
19022
- deviceKey: string().optional()
19023
- }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
19024
- data: _instanceof(Uint8Array),
19025
- width: number().int().positive(),
19026
- height: number().int().positive(),
19027
- format: _enum([
19028
- "rgb",
19029
- "bgr",
19030
- "gray"
19031
- ])
19241
+ }), method(object({
19242
+ deviceId: number(),
19243
+ trackId: string(),
19244
+ frameId: string()
19032
19245
  }), object({
19033
- frameId: number(),
19034
- width: number(),
19035
- height: number()
19036
- }), { kind: "mutation" }), method(object({
19037
- stepId: string(),
19038
- frameId: number().int()
19039
- }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
19040
- batchMode: string(),
19041
- windowMs: number(),
19042
- maxBatchSize: number(),
19043
- concurrency: number()
19044
- })), method(_void(), array(object({
19045
- engineKey: string(),
19046
- engine: PipelineEngineChoiceSchema,
19047
- modelsLoaded: array(string()).readonly(),
19048
- inUseByCameras: array(number()).readonly(),
19049
- /**
19050
- * Origin of this resident factory.
19051
- * - `runtime` — main camera-serving engine (no idle TTL).
19052
- * - `warm-override` — benchmark/test override held in the warm
19053
- * cache; auto-disposed after the idle TTL.
19054
- * - `device-pool` — a concurrent per-device pool (Phase 2
19055
- * multi-device, keyed by `deviceKey`) resolved
19056
- * via `resolveDeviceFactory`. Runs alongside the
19057
- * `runtime` engine on a DIFFERENT accelerator
19058
- * (NPU / iGPU / Coral) — this is how the
19059
- * Engines tab shows all pools running at once.
19060
- */
19061
- kind: _enum([
19062
- "runtime",
19063
- "warm-override",
19064
- "device-pool"
19065
- ]),
19066
- /** Native pid of the underlying Python pool (null when no pool). */
19067
- poolPid: number().nullable(),
19068
- /** ms since this factory was last used (null when not warm-tracked). */
19069
- idleMs: number().nullable(),
19070
- /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
19071
- idleTtlMs: number().nullable()
19072
- })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
19246
+ removed: boolean(),
19247
+ removedAnnotations: number().int()
19248
+ }), {
19073
19249
  kind: "mutation",
19074
19250
  auth: "admin"
19251
+ }), method(object({ frameId: string() }), object({
19252
+ base64: string(),
19253
+ width: number().int(),
19254
+ height: number().int()
19255
+ }), {
19256
+ kind: "query",
19257
+ auth: "admin"
19075
19258
  }), method(object({
19076
- engine: PipelineEngineChoiceSchema,
19077
- force: boolean().optional()
19259
+ deviceId: number(),
19260
+ trackId: string(),
19261
+ frameId: string(),
19262
+ subject: RetrainAssistSubjectSchema,
19263
+ /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
19264
+ nodeId: string().optional()
19265
+ }), RetrainAssistResultSchema, {
19266
+ kind: "mutation",
19267
+ auth: "admin"
19268
+ }), method(object({
19269
+ deviceId: number(),
19270
+ source: DetectionSourceSchema,
19271
+ zones: array(ZoneSchema).readonly().optional(),
19272
+ detectionRules: array(ZoneRuleSchema).readonly().optional(),
19273
+ zoneMembershipMinOverlap: number().min(0).max(1).optional(),
19274
+ frames: array(ReplayFrameInputSchema).min(1)
19275
+ }), RunReplayFrameProcessorResultSchema, {
19276
+ kind: "mutation",
19277
+ auth: "admin"
19278
+ }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
19279
+ kind: "query",
19280
+ auth: "admin"
19281
+ }), method(object({
19282
+ deviceId: number(),
19283
+ trackId: string(),
19284
+ frameId: string(),
19285
+ annotations: array(RetrainAnnotationDraftSchema)
19286
+ }), array(RetrainAnnotationSchema).readonly(), {
19287
+ kind: "mutation",
19288
+ auth: "admin"
19289
+ }), method(object({
19290
+ deviceId: number(),
19291
+ trackId: string()
19292
+ }), RetrainTransitionResultSchema, {
19293
+ kind: "mutation",
19294
+ auth: "admin"
19295
+ }), method(object({
19296
+ deviceId: number(),
19297
+ trackId: string()
19298
+ }), RetrainTransitionResultSchema, {
19299
+ kind: "mutation",
19300
+ auth: "admin"
19301
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
19302
+ kind: "query",
19303
+ auth: "admin"
19304
+ }), method(object({
19305
+ eventId: string(),
19306
+ kind: MediaFileKindEnum.optional(),
19307
+ deviceId: number()
19308
+ }), array(MediaFileSchema).readonly()), method(object({
19309
+ trackId: string(),
19310
+ kinds: array(MediaFileKindEnum).optional(),
19311
+ deviceId: number()
19312
+ }), array(MediaFileSchema).readonly()), method(object({
19313
+ trackId: string(),
19314
+ deviceId: number()
19315
+ }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
19316
+ kind: "mutation",
19317
+ auth: "admin"
19318
+ }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
19319
+ kind: "mutation",
19320
+ auth: "admin"
19321
+ }), method(object({}), RebuildStatusSchema), object({
19322
+ deviceId: number(),
19323
+ timestamp: number(),
19324
+ frameWidth: number(),
19325
+ frameHeight: number(),
19326
+ detections: array(OverlayDetectionSchema).readonly()
19327
+ }), object({
19328
+ deviceId: number(),
19329
+ trackId: string(),
19330
+ className: string()
19078
19331
  }), object({
19079
- success: boolean(),
19080
- reason: string().optional()
19081
- }), {
19082
- kind: "mutation",
19083
- auth: "admin"
19084
- }), 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({
19085
- addonId: string(),
19086
- modelId: string(),
19087
- filename: string().optional(),
19088
- settings: record(string(), unknown()).optional()
19089
- }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
19332
+ deviceId: number(),
19333
+ trackId: string(),
19334
+ className: string(),
19335
+ durationMs: number()
19336
+ }), object({
19337
+ deviceId: number(),
19338
+ kind: EventKindSchema,
19339
+ eventId: string(),
19340
+ timestamp: number()
19341
+ });
19090
19342
  object({
19091
19343
  activeCameras: number(),
19092
19344
  throttledCameras: number(),
@@ -19112,106 +19364,6 @@ var CameraMetricsSchema = object({
19112
19364
  });
19113
19365
  var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
19114
19366
  /**
19115
- * Zone — pure geometry + identity. NO filtering behaviour.
19116
- *
19117
- * Zones describe **where** in the frame the operator wants to flag
19118
- * something; consumer-owned {@link ZoneRule} arrays describe **how**
19119
- * each pipeline stage uses them. Splitting the two means a single
19120
- * polygon "Driveway" can simultaneously back a motion-exclude rule,
19121
- * a detection-include rule on `['car']`, and an occupancy aggregate
19122
- * — without three duplicated polygons.
19123
- *
19124
- * Owned by the orchestrator addon (provider) and mirrored into the
19125
- * `zones` device-state slice on every mutation. Consumers
19126
- * (motion-wasm, pipeline-executor, analytics, admin UI) read either
19127
- * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
19128
- * mirror with `onChanged`).
19129
- *
19130
- * Coordinates are normalised fractions of the frame (0–1) so zones
19131
- * survive resolution changes and stream profile switches.
19132
- *
19133
- * `kind` discriminates between full polygons (closed regions used
19134
- * for intrusion / occupancy filters) and tripwires (open 2-point
19135
- * line segments used for cross events). Onboard / firmware-reported
19136
- * zones (Reolink, ONVIF) are out of scope for now — see the deferred
19137
- * task list.
19138
- */
19139
- var ZoneKindEnum = _enum(["polygon", "tripwire"]);
19140
- /** Polygon vertex in fraction-of-frame coordinates (0–1). */
19141
- var PolygonPointSchema = object({
19142
- x: number(),
19143
- y: number()
19144
- });
19145
- /** A camera detection zone — pure geometry/identity. */
19146
- var ZoneSchema = object({
19147
- id: string(),
19148
- name: string(),
19149
- kind: ZoneKindEnum.default("polygon"),
19150
- /** Polygon vertices, fraction of frame (0–1). */
19151
- polygon: array(PolygonPointSchema).readonly(),
19152
- /** Visual color for UI rendering. */
19153
- color: string().default("#3b82f6")
19154
- });
19155
- /**
19156
- * Zones capability — per-camera CRUD over polygon detection zones.
19157
- *
19158
- * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
19159
- * to per-device settings and mirrors into the `zones` device-state
19160
- * slice on every mutation, so downstream consumers can subscribe via
19161
- * `dev.state.zones.onChanged`.
19162
- *
19163
- * The cap surface only handles geometry + identity; filtering
19164
- * behaviour (per-class, include/exclude, threshold) lives in the
19165
- * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
19166
- * `capabilities/schemas/zone-rule.js`.
19167
- */
19168
- var zonesCapability = {
19169
- name: "zones",
19170
- scope: "device",
19171
- mode: "singleton",
19172
- deviceTypes: [DeviceType.Camera],
19173
- methods: {
19174
- listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
19175
- addZone: method(object({
19176
- deviceId: number(),
19177
- zone: ZoneSchema
19178
- }), _void(), {
19179
- kind: "mutation",
19180
- auth: "admin"
19181
- }),
19182
- removeZone: method(object({
19183
- deviceId: number(),
19184
- zoneId: string()
19185
- }), _void(), {
19186
- kind: "mutation",
19187
- auth: "admin"
19188
- }),
19189
- updateZone: method(object({
19190
- deviceId: number(),
19191
- zone: ZoneSchema
19192
- }), _void(), {
19193
- kind: "mutation",
19194
- auth: "admin"
19195
- })
19196
- },
19197
- /**
19198
- * Runtime-state slice — the live zone catalogue mirrored by the
19199
- * orchestrator on every CRUD mutation. Consumers read via
19200
- * `device.state.zones.value` / `.watch(...)` without round-tripping
19201
- * the cap, and the codegen DeviceProxy auto-wires the reactive
19202
- * handle. Slice shape is `{ zones: Zone[] }` so future extensions
19203
- * (e.g. zone groupings) can sit alongside the polygon list.
19204
- */
19205
- runtimeState: object({ zones: array(ZoneSchema).readonly() }),
19206
- /**
19207
- * 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.
19208
- *
19209
- * See `RuntimeStateDurability`. Enforced by
19210
- * `scripts/check-runtime-state-durability.ts`.
19211
- */
19212
- durability: "restored"
19213
- };
19214
- /**
19215
19367
  * A bounding box in NORMALIZED [0,1] frame coordinates for `getNativeCrop`. The
19216
19368
  * decode worker resolves it against the RETAINED native frame's real pixel dims,
19217
19369
  * so the caller supplies only the detection-res bbox divided by the detection
@@ -27877,6 +28029,39 @@ var ReadGopBytesResultSchema = object({
27877
28029
  /** Media ms the returned fragment covers. */
27878
28030
  gopDurMs: number()
27879
28031
  });
28032
+ /**
28033
+ * A time WINDOW of one finalized segment, cut by byte range — the multi-GOP
28034
+ * twin of {@link ReadGopBytesResultSchema}'s single instant. Built for the
28035
+ * replay clip's `recording` source (`docs/design/plans/2026-08-26-replay-clip-su-pipeline.md`):
28036
+ * a replay needs several seconds of native pixels, not one frame.
28037
+ *
28038
+ * `ok.data` is standalone-demuxable, same as a GOP read. `ok.reachesRequestedEnd`
28039
+ * is `false` when the returned bytes were cut short by the read's own safety
28040
+ * byte cap before covering `[fromMs, toMs)` — a truncation, reported, not a
28041
+ * silently shorter answer. `spans-multiple-segments` is a REFUSAL, not a
28042
+ * degradation: a window whose end falls past the covering segment would need
28043
+ * bytes stitched from a second segment file (its own `ftyp`+`moov`), which is
28044
+ * not one standalone-demuxable stream — the caller's answer is to request a
28045
+ * shorter window or one aligned to a single segment, not to receive spliced
28046
+ * bytes nothing has proven decodable.
28047
+ */
28048
+ var ReadWindowBytesResultSchema = discriminatedUnion("kind", [object({
28049
+ kind: literal("ok"),
28050
+ data: _instanceof(Uint8Array),
28051
+ /** Absolute epoch ms of the returned bytes' first sample — at or before
28052
+ * the requested `fromMs` (anchored on the nearest keyframe). */
28053
+ gopStartMs: number(),
28054
+ /** Media ms the returned bytes cover, from `gopStartMs`. */
28055
+ gopDurMs: number(),
28056
+ /** `false` ⇒ the safety byte cap cut the read short before it reached
28057
+ * the requested `toMs`; the caller got fewer frames than asked for. */
28058
+ reachesRequestedEnd: boolean()
28059
+ }), object({
28060
+ kind: literal("spans-multiple-segments"),
28061
+ /** Where the covering segment's own footage runs out — informational,
28062
+ * not a retry hint (retrying the same window would refuse again). */
28063
+ segmentEndMs: number()
28064
+ })]);
27880
28065
  method(object({
27881
28066
  deviceId: number(),
27882
28067
  fromMs: number(),
@@ -27927,6 +28112,15 @@ method(object({
27927
28112
  }), ReadGopBytesResultSchema, {
27928
28113
  kind: "query",
27929
28114
  auth: "admin"
28115
+ }), method(object({
28116
+ deviceId: number(),
28117
+ profile: string(),
28118
+ startMs: number(),
28119
+ fromMs: number(),
28120
+ toMs: number()
28121
+ }), ReadWindowBytesResultSchema, {
28122
+ kind: "query",
28123
+ auth: "admin"
27930
28124
  }), method(object({
27931
28125
  deviceId: number(),
27932
28126
  config: RecordingConfigSchema
@@ -28522,92 +28716,6 @@ var sceneMonitorCapability = {
28522
28716
  durability: "session"
28523
28717
  };
28524
28718
  /**
28525
- * Per-stage gating mode applied to the zones a rule references.
28526
- *
28527
- * - `include`: the rule contributes to a **whitelist** for its stage.
28528
- * When at least one `include` rule fires for a stage, only entities
28529
- * inside one of those zones pass that stage.
28530
- * - `exclude`: the rule contributes to a **blacklist** for its stage.
28531
- * Entities inside one of those zones are dropped at that stage.
28532
- *
28533
- * `monitor`-style observation (count without filtering) is not a rule
28534
- * mode — zones without any matching rule are observed naturally by
28535
- * `zone-analytics` (live snapshot + history), so an "I just want to
28536
- * count, not filter" use case needs no rule at all.
28537
- */
28538
- var ZoneRuleModeEnum = _enum(["include", "exclude"]);
28539
- /**
28540
- * Per-consumer rule that references existing zones (geometry) and
28541
- * defines how a specific pipeline stage should treat them. Each
28542
- * consumer addon owns its own `ZoneRule[]` array in its per-device
28543
- * settings:
28544
- *
28545
- * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
28546
- * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
28547
- * - future: notification rules, audio gating, etc.
28548
- *
28549
- * One rule applies to N zones (`zoneIds[]`) so the operator can
28550
- * express "ignore motion in ALL of {garden, street}" with a single
28551
- * rule. `classFilter` narrows the rule to specific object classes —
28552
- * "drop person detections in the street, but keep cars" is one
28553
- * `exclude` rule with `classFilter: ['person']`.
28554
- *
28555
- * `enabled` is a soft toggle — the operator can keep the rule
28556
- * configured but inert without deleting it.
28557
- */
28558
- var ZoneRuleSchema = object({
28559
- /** Stable rule id — survives edits, used by the UI for diffing. */
28560
- id: string(),
28561
- /** Optional human-readable label rendered in the rule editor. */
28562
- name: string().optional(),
28563
- /** Zones this rule targets. The rule's `mode` applies to ALL
28564
- * listed zones (OR-set: a detection in any one of them counts).
28565
- * At least one zone id required — a rule with no targets is a
28566
- * configuration mistake and the form validator rejects it. */
28567
- zoneIds: array(string()).min(1).readonly(),
28568
- mode: ZoneRuleModeEnum,
28569
- /**
28570
- * Class names this rule applies to. Empty / undefined ⇒ rule
28571
- * applies to every class. Class strings match the `macroClass`
28572
- * field on detections (e.g. `person`, `car`, `dog`).
28573
- */
28574
- classFilter: array(string()).readonly().optional(),
28575
- /**
28576
- * Minimum bbox/mask overlap (0–1) with any of the rule's zones
28577
- * required to consider an entity "in the zone". Defaults to the
28578
- * consumer's stage default when omitted. Kept for back-compat with
28579
- * existing per-rule overrides; new operators pick the value via
28580
- * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
28581
- * set, the lower-level engine reads it as a 0–1 fraction.
28582
- */
28583
- overlapThreshold: number().min(0).max(1).optional(),
28584
- /**
28585
- * Operator-friendly version of `overlapThreshold` — the percentage
28586
- * of the detection's bbox that must lie inside the zone for the
28587
- * rule to match. Documented default is 85%; the engine substitutes
28588
- * that when the field is omitted (kept optional so existing rules
28589
- * stored without it stay valid).
28590
- *
28591
- * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
28592
- * rule, the engine prefers `bboxInclusionPct` because it's the
28593
- * field exposed in the UI. Internally both feed the same gate.
28594
- */
28595
- bboxInclusionPct: number().min(0).max(100).optional(),
28596
- /**
28597
- * When `true` and a detection has a segmentation mask, use the
28598
- * mask for overlap instead of the bbox. Detection-stage only;
28599
- * motion rules ignore this field.
28600
- */
28601
- preferMask: boolean().optional(),
28602
- /**
28603
- * Soft-toggle: `false` disables the rule without deleting it.
28604
- * Defaults to `true` so operators creating a rule via the UI
28605
- * see it active immediately.
28606
- */
28607
- enabled: boolean().default(true)
28608
- });
28609
- array(ZoneRuleSchema).readonly();
28610
- /**
28611
28719
  * Script-runner cap. Models HA `script.*` entities on
28612
28720
  * `DeviceType.Script`. A Script is a pre-recorded action sequence
28613
28721
  * that can be invoked imperatively — optionally with a variables
@@ -34100,6 +34208,12 @@ Object.freeze({
34100
34208
  addonId: null,
34101
34209
  access: "view"
34102
34210
  },
34211
+ "notificationRules.resolveArtifactUrl": {
34212
+ capName: "notification-rules",
34213
+ capScope: "system",
34214
+ addonId: null,
34215
+ access: "view"
34216
+ },
34103
34217
  "notificationRules.setAlarmConfig": {
34104
34218
  capName: "notification-rules",
34105
34219
  capScope: "system",
@@ -34544,6 +34658,12 @@ Object.freeze({
34544
34658
  addonId: null,
34545
34659
  access: "create"
34546
34660
  },
34661
+ "pipelineAnalytics.runReplayFrameProcessor": {
34662
+ capName: "pipeline-analytics",
34663
+ capScope: "device",
34664
+ addonId: null,
34665
+ access: "create"
34666
+ },
34547
34667
  "pipelineAnalytics.saveRetrainAnnotations": {
34548
34668
  capName: "pipeline-analytics",
34549
34669
  capScope: "device",
@@ -34676,6 +34796,12 @@ Object.freeze({
34676
34796
  addonId: null,
34677
34797
  access: "view"
34678
34798
  },
34799
+ "pipelineExecutor.getInferenceDeviceHealth": {
34800
+ capName: "pipeline-executor",
34801
+ capScope: "system",
34802
+ addonId: null,
34803
+ access: "view"
34804
+ },
34679
34805
  "pipelineExecutor.getOrchestratorConfigSchema": {
34680
34806
  capName: "pipeline-executor",
34681
34807
  capScope: "system",
@@ -34748,6 +34874,12 @@ Object.freeze({
34748
34874
  addonId: null,
34749
34875
  access: "view"
34750
34876
  },
34877
+ "pipelineExecutor.rearmInferenceDevice": {
34878
+ capName: "pipeline-executor",
34879
+ capScope: "system",
34880
+ addonId: null,
34881
+ access: "create"
34882
+ },
34751
34883
  "pipelineExecutor.runAudioTest": {
34752
34884
  capName: "pipeline-executor",
34753
34885
  capScope: "system",
@@ -35486,6 +35618,12 @@ Object.freeze({
35486
35618
  addonId: null,
35487
35619
  access: "view"
35488
35620
  },
35621
+ "recording.readWindowBytes": {
35622
+ capName: "recording",
35623
+ capScope: "system",
35624
+ addonId: null,
35625
+ access: "view"
35626
+ },
35489
35627
  "recording.refreshStorageLocationsForMigration": {
35490
35628
  capName: "recording",
35491
35629
  capScope: "system",
@@ -37996,6 +38134,11 @@ Object.freeze({
37996
38134
  form: "single",
37997
38135
  optional: false
37998
38136
  }],
38137
+ "pipelineAnalytics.runReplayFrameProcessor": [{
38138
+ name: "deviceId",
38139
+ form: "single",
38140
+ optional: false
38141
+ }],
37999
38142
  "pipelineAnalytics.saveRetrainAnnotations": [{
38000
38143
  name: "deviceId",
38001
38144
  form: "single",
@@ -38311,6 +38454,11 @@ Object.freeze({
38311
38454
  form: "single",
38312
38455
  optional: false
38313
38456
  }],
38457
+ "recording.readWindowBytes": [{
38458
+ name: "deviceId",
38459
+ form: "single",
38460
+ optional: false
38461
+ }],
38314
38462
  "recording.relocateFootage": [{
38315
38463
  name: "deviceId",
38316
38464
  form: "single",