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