@camstack/addon-provider-tuya 0.2.29 → 0.2.31

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