@camstack/addon-provider-hikvision 1.2.35 → 1.2.37

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 +2135 -1892
  2. package/dist/addon.mjs +2135 -1892
  3. package/package.json +1 -1
package/dist/addon.mjs CHANGED
@@ -6638,7 +6638,7 @@ function method(input, output, options) {
6638
6638
  input,
6639
6639
  output,
6640
6640
  kind: options?.kind ?? "query",
6641
- auth: options?.auth ?? "protected",
6641
+ ...options?.auth !== void 0 ? { auth: options.auth } : {},
6642
6642
  ...options?.access !== void 0 ? { access: options.access } : {},
6643
6643
  ...options?.caller !== void 0 ? { caller: options.caller } : {},
6644
6644
  timeoutMs: options?.timeoutMs
@@ -6662,7 +6662,7 @@ function event(data) {
6662
6662
  }
6663
6663
  var StaticDirOutputSchema$1 = object({ staticDir: string() });
6664
6664
  var VersionOutputSchema$1 = object({ version: string() });
6665
- method(_void(), StaticDirOutputSchema$1), method(_void(), VersionOutputSchema$1);
6665
+ method(_void(), StaticDirOutputSchema$1, { auth: "admin" }), method(_void(), VersionOutputSchema$1, { auth: "admin" });
6666
6666
  var DeviceType = /* @__PURE__ */ function(DeviceType) {
6667
6667
  DeviceType["Camera"] = "camera";
6668
6668
  DeviceType["Hub"] = "hub";
@@ -6983,7 +6983,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
6983
6983
  }({});
6984
6984
  var StaticDirOutputSchema = object({ staticDir: string() });
6985
6985
  var VersionOutputSchema = object({ version: string() });
6986
- method(_void(), StaticDirOutputSchema), method(_void(), VersionOutputSchema);
6986
+ method(_void(), StaticDirOutputSchema, { auth: "admin" }), method(_void(), VersionOutputSchema, { auth: "admin" });
6987
6987
  /**
6988
6988
  * device-ops — device-scoped cap that unifies the per-IDevice operations
6989
6989
  * previously routed through the `.device-ops` Moleculer bridge service.
@@ -7597,24 +7597,6 @@ var RecordingRetentionSchema = object({
7597
7597
  maxSizeGb: number().min(0).optional()
7598
7598
  });
7599
7599
  /**
7600
- * Scrub-thumbnail fidelity preset — the single per-camera selector bundling the
7601
- * sprite tile RESOLUTION + JPEG QUALITY the recorder packs timeline-scrub
7602
- * previews at. Five graduated steps; absent on a config = `standard` (the
7603
- * shipped default, matching `sheet-geometry`/`sheet-composer`).
7604
- *
7605
- * Existing sheets are IMMUTABLE — a changed preset applies to NEW windows only.
7606
- * Each window's index sidecar carries its own tile dims, so a camera whose
7607
- * preset changed over time renders every historical window at the dims it was
7608
- * written with.
7609
- */
7610
- var ScrubThumbnailPresetSchema = _enum([
7611
- "minimal",
7612
- "low",
7613
- "standard",
7614
- "high",
7615
- "max"
7616
- ]);
7617
- /**
7618
7600
  * The full per-camera recording intent — the wire shape of a RecordingTarget.
7619
7601
  *
7620
7602
  * `bands` is the ONLY authored recording intent: what to record, when, and on
@@ -7622,7 +7604,11 @@ var ScrubThumbnailPresetSchema = _enum([
7622
7604
  * other field is a storage knob (profiles, segment length, retention, scrub).
7623
7605
  *
7624
7606
  * STRICT on purpose: the legacy authoring surface (`schedule`/`schedules`/
7625
- * `triggers`/`preBufferSec`/`postBufferSec`/`rules`) was retired 2026-07-30.
7607
+ * `triggers`/`preBufferSec`/`postBufferSec`/`rules`) was retired 2026-07-30,
7608
+ * and `scrubThumbnails` — a five-step fidelity knob for a sprite tier that was
7609
+ * deleted on 2026-07-24 and had ZERO consumers in the recorder — on 2026-08-25
7610
+ * (D62: a switch that writes a store nobody reads is worse than no switch).
7611
+ * Stored rows keep loading: the READ schema is `.strip()` (config-store.ts).
7626
7612
  * A stale caller must fail loudly — silently stripping its legacy intent would
7627
7613
  * persist a band-less config, i.e. silently stop recording the camera.
7628
7614
  */
@@ -7645,14 +7631,7 @@ var RecordingConfigSchema = object({
7645
7631
  * "off" is the absence of a covering band, never a band value.
7646
7632
  */
7647
7633
  bands: array(RecordingBandSchema).default([]),
7648
- retention: RecordingRetentionSchema.optional(),
7649
- /**
7650
- * Per-camera scrub-thumbnail fidelity preset (resolution + JPEG quality for
7651
- * timeline-scrub sprite previews). Absent = `standard`. Applies to NEW
7652
- * windows only — existing sheets are immutable, and each window's index
7653
- * carries its own tile dims so mixed-preset history renders correctly.
7654
- */
7655
- scrubThumbnails: ScrubThumbnailPresetSchema.optional()
7634
+ retention: RecordingRetentionSchema.optional()
7656
7635
  }).strict();
7657
7636
  /**
7658
7637
  * Entity-relocation job state (storage entity-routing spec, Phase 4).
@@ -7728,10 +7707,11 @@ var RelocateFootageInputSchema = object({
7728
7707
  * `RecordingConfig.enabled` or camera wrapper bindings. */
7729
7708
  var StorageMigrationLeaseInputSchema = object({ leaseId: string().min(1) });
7730
7709
  var StorageMigrationFootageMoveInputSchema = RelocateFootageInputSchema.extend({ leaseId: string().min(1) });
7731
- var StorageMigrationMediaMoveInputSchema = object({
7710
+ var RelocateMediaInputSchema = object({
7732
7711
  toLocationId: string(),
7733
7712
  throttleMbps: number().min(1).max(1e3).optional()
7734
- }).extend({ leaseId: string().min(1) });
7713
+ });
7714
+ var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
7735
7715
  /** The independently selectable logical storage classes. `recordings`
7736
7716
  * encompasses the high and mid segment profiles; `recordingsLow` is low
7737
7717
  * segments; `eventMedia` is post-analysis blobs. */
@@ -8201,7 +8181,26 @@ var LabelDefinitionSchema = object({
8201
8181
  description: string().optional(),
8202
8182
  icon: string().optional()
8203
8183
  });
8204
- var ClassMapDefinitionSchema = object({
8184
+ /**
8185
+ * Wire schema for a per-model CATALOG classMap override
8186
+ * (`ModelCatalogEntry.classMap` / `ModelConvertMetadata.classMap`) —
8187
+ * restricted to {@link CLASS_MAP_MACRO_TARGETS}, the only macros the
8188
+ * detection pipeline executor actually routes.
8189
+ *
8190
+ * This is deliberately a DIFFERENT, narrower shape than the general-purpose
8191
+ * `ClassMapDefinition` interface above (e.g. `IDetectionAddon.getClassMap()`
8192
+ * and the audio `YAMNET_TO_MACRO` catalog both use macro targets outside this
8193
+ * enum) — the two used to share the name `ClassMapDefinition`/
8194
+ * `ClassMapDefinitionSchema`, which made the schema-type-twin guard
8195
+ * (`scripts/check-schema-type-twins.ts`) flag them as a duplicated shape. They
8196
+ * are not: it is two different concepts colliding on a name. Keep this type
8197
+ * under its own name rather than reusing `ClassMapDefinition` — reusing it
8198
+ * would either narrow every `ClassMapDefinition` consumer to the four
8199
+ * detection macros (breaking `YAMNET_TO_MACRO`) or drop the validation this
8200
+ * schema exists for (see the "rejects a classMap whose target is not a
8201
+ * detection macro" test in `model-catalog-schema.test.ts`).
8202
+ */
8203
+ var DetectionCatalogClassMapSchema = object({
8205
8204
  mapping: record(string(), _enum([
8206
8205
  "person",
8207
8206
  "vehicle",
@@ -8406,7 +8405,7 @@ var ModelCatalogEntrySchema = object({
8406
8405
  * applies (Frigate / COCO public catalog). Set on a custom model whose raw
8407
8406
  * labels already ARE the CamStack macros (Scrypted identity map).
8408
8407
  */
8409
- classMap: ClassMapDefinitionSchema.optional()
8408
+ classMap: DetectionCatalogClassMapSchema.optional()
8410
8409
  });
8411
8410
  var ConvertTargetSchema = discriminatedUnion("format", [object({
8412
8411
  format: literal("openvino"),
@@ -8436,7 +8435,7 @@ var ModelConvertMetadataSchema = object({
8436
8435
  "segmentation"
8437
8436
  ]),
8438
8437
  faceAlignment: boolean().optional(),
8439
- classMap: ClassMapDefinitionSchema.optional()
8438
+ classMap: DetectionCatalogClassMapSchema.optional()
8440
8439
  });
8441
8440
  var ConvertResultSchema = object({
8442
8441
  entry: ModelCatalogEntrySchema,
@@ -9299,7 +9298,7 @@ var AddonPageDeclarationSchema = object({
9299
9298
  /** Display label for a CUSTOM `section` id (ignored for well-known ids). */
9300
9299
  sectionLabel: string().optional()
9301
9300
  });
9302
- method(_void(), array(AddonPageDeclarationSchema).readonly());
9301
+ method(_void(), array(AddonPageDeclarationSchema).readonly(), { auth: "admin" });
9303
9302
  var AddonHttpRouteSchema = object({
9304
9303
  method: _enum([
9305
9304
  "GET",
@@ -9534,7 +9533,7 @@ var WidgetMetadataSchema = object({
9534
9533
  defaultColumns: number().int().min(1).max(12).default(6),
9535
9534
  defaultRows: number().int().min(1).max(12).default(1)
9536
9535
  });
9537
- method(_void(), array(WidgetMetadataSchema).readonly());
9536
+ method(_void(), array(WidgetMetadataSchema).readonly(), { auth: "admin" });
9538
9537
  /**
9539
9538
  * `addon-widgets` — system-scoped singleton aggregator cap. Public-facing
9540
9539
  * surface that admin-ui consumes through `useAddonWidgetsListWidgets()`.
@@ -11170,7 +11169,7 @@ var CustomModelDescriptorSchema = object({
11170
11169
  stepId: string(),
11171
11170
  entry: ModelCatalogEntrySchema
11172
11171
  });
11173
- method(_void(), array(CustomModelDescriptorSchema).readonly());
11172
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
11174
11173
  /**
11175
11174
  * Query filter for settings-store collections.
11176
11175
  */
@@ -11257,7 +11256,8 @@ method(object({
11257
11256
  }), _void(), { kind: "mutation" }), method(object({
11258
11257
  namespace: string().optional(),
11259
11258
  collection: string(),
11260
- filter: QueryFilterSchema.optional()
11259
+ filter: QueryFilterSchema.optional(),
11260
+ columns: array(string()).readonly().optional()
11261
11261
  }), array(SettingsRecordSchema).readonly()), method(object({
11262
11262
  namespace: string().optional(),
11263
11263
  collection: string(),
@@ -11320,46 +11320,87 @@ var EngineInfoSchema = object({
11320
11320
  kind: _enum(["relational", "vector"]),
11321
11321
  displayName: string()
11322
11322
  });
11323
- method(_void(), EngineInfoSchema), method(object({
11323
+ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
11324
11324
  namespace: string().optional(),
11325
11325
  collection: string(),
11326
11326
  key: string()
11327
- }), unknown()), method(object({
11327
+ }), unknown(), { auth: "admin" }), method(object({
11328
11328
  namespace: string().optional(),
11329
11329
  collection: string(),
11330
11330
  key: string(),
11331
11331
  value: unknown()
11332
- }), _void(), { kind: "mutation" }), method(object({
11332
+ }), _void(), {
11333
+ kind: "mutation",
11334
+ auth: "admin"
11335
+ }), method(object({
11333
11336
  namespace: string().optional(),
11334
11337
  collection: string(),
11335
- filter: QueryFilterSchema.optional()
11336
- }), array(SettingsRecordSchema).readonly()), method(object({
11338
+ filter: QueryFilterSchema.optional(),
11339
+ /**
11340
+ * SQL-level column projection — MUST mirror `settings-store.query`.
11341
+ *
11342
+ * ⚠ An earlier version of this comment blamed Zod stripping, and that
11343
+ * was wrong — corrected 2026-08-26 after the hop map
11344
+ * (`docs/design/2026-08-26-mappa-hop-argomenti.md`) traced the path.
11345
+ * There is **no Zod parse at all** between the door and the engine: the
11346
+ * dispatcher forwards the payload verbatim and UDS carries it whole. A
11347
+ * field declared here reaches `SqliteSettingsBackend` either way.
11348
+ *
11349
+ * What actually lost `columns` was the THIRD declaration of this shape:
11350
+ * `SettingsQueryInput` in `interfaces/storage.ts`, a hand-written TS
11351
+ * interface the engine destructures from. The field existed on both
11352
+ * schemas and the engine still never read it, because nothing checks a
11353
+ * registered provider against `InferProvider<cap>` —
11354
+ * `ProviderRegistration.provider` is typed `object`.
11355
+ *
11356
+ * It is declared here anyway, and must stay in step with
11357
+ * `settings-store.query`: a caller reading only the cap definitions has
11358
+ * to be able to see that this call carries a projection.
11359
+ * `data-door-schema-parity.spec.ts` keeps the two aligned.
11360
+ */
11361
+ columns: array(string()).readonly().optional()
11362
+ }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
11337
11363
  namespace: string().optional(),
11338
11364
  collection: string(),
11339
11365
  record: SettingsRecordSchema
11340
- }), _void(), { kind: "mutation" }), method(object({
11366
+ }), _void(), {
11367
+ kind: "mutation",
11368
+ auth: "admin"
11369
+ }), method(object({
11341
11370
  namespace: string().optional(),
11342
11371
  collection: string(),
11343
11372
  id: string(),
11344
11373
  data: record(string(), unknown())
11345
- }), _void(), { kind: "mutation" }), method(object({
11374
+ }), _void(), {
11375
+ kind: "mutation",
11376
+ auth: "admin"
11377
+ }), method(object({
11346
11378
  namespace: string().optional(),
11347
11379
  collection: string(),
11348
11380
  key: string()
11349
- }), _void(), { kind: "mutation" }), method(object({
11381
+ }), _void(), {
11382
+ kind: "mutation",
11383
+ auth: "admin"
11384
+ }), method(object({
11350
11385
  namespace: string().optional(),
11351
11386
  collection: string(),
11352
11387
  filter: MutationFilterSchema
11353
- }), object({ deleted: number().int() }), { kind: "mutation" }), method(object({
11388
+ }), object({ deleted: number().int() }), {
11389
+ kind: "mutation",
11390
+ auth: "admin"
11391
+ }), method(object({
11354
11392
  namespace: string().optional(),
11355
11393
  collection: string(),
11356
11394
  filter: MutationFilterSchema,
11357
11395
  data: record(string(), unknown())
11358
- }), object({ updated: number().int() }), { kind: "mutation" }), method(object({
11396
+ }), object({ updated: number().int() }), {
11397
+ kind: "mutation",
11398
+ auth: "admin"
11399
+ }), method(object({
11359
11400
  namespace: string().optional(),
11360
11401
  collection: string(),
11361
11402
  filter: QueryFilterSchema.optional()
11362
- }), number()), method(object({
11403
+ }), number(), { auth: "admin" }), method(object({
11363
11404
  namespace: string().optional(),
11364
11405
  collection: string(),
11365
11406
  field: string(),
@@ -11369,15 +11410,18 @@ method(_void(), EngineInfoSchema), method(object({
11369
11410
  }), array(object({
11370
11411
  bucket: number().int(),
11371
11412
  count: number().int()
11372
- })).readonly()), method(object({
11413
+ })).readonly(), { auth: "admin" }), method(object({
11373
11414
  namespace: string().optional(),
11374
11415
  collection: string()
11375
- }), boolean()), method(object({
11416
+ }), boolean(), { auth: "admin" }), method(object({
11376
11417
  namespace: string().optional(),
11377
11418
  collection: string(),
11378
11419
  columns: array(CollectionColumnSchema).readonly(),
11379
11420
  indexes: array(CollectionIndexSchema).readonly().optional()
11380
- }), _void(), { kind: "mutation" });
11421
+ }), _void(), {
11422
+ kind: "mutation",
11423
+ auth: "admin"
11424
+ });
11381
11425
  /**
11382
11426
  * shm ring usage stats for a `frameSink: 'shm'` decoder session —
11383
11427
  * exposed via `decoder.getShmStats` so downstream consumers can
@@ -12667,7 +12711,7 @@ method(object({
12667
12711
  crop: _instanceof(Uint8Array),
12668
12712
  width: number(),
12669
12713
  height: number()
12670
- }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
12714
+ }), EmbeddingResultSchema, { auth: "admin" }), method(object({ text: string() }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" });
12671
12715
  /**
12672
12716
  * filesystem-browse — per-node capability for browsing the node's local
12673
12717
  * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
@@ -12960,19 +13004,22 @@ method(LlmGenerateBaseInputSchema.extend({
12960
13004
  runtime: ManagedRuntimeConfigSchema,
12961
13005
  /** The managed profile's timeout, threaded by the hub provider. */
12962
13006
  timeoutMs: number().int().positive().optional()
12963
- }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
13007
+ }), LlmGenerateResultSchema, {
13008
+ kind: "mutation",
13009
+ auth: "admin"
13010
+ }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
12964
13011
  kind: "mutation",
12965
13012
  auth: "admin"
12966
13013
  }), method(object({}), _void(), {
12967
13014
  kind: "mutation",
12968
13015
  auth: "admin"
12969
- }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
13016
+ }), method(object({}), LlmRuntimeStatusSchema, { auth: "admin" }), method(object({ model: ManagedModelRefSchema }), _void(), {
12970
13017
  kind: "mutation",
12971
13018
  auth: "admin"
12972
13019
  }), method(object({ file: string() }), _void(), {
12973
13020
  kind: "mutation",
12974
13021
  auth: "admin"
12975
- }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
13022
+ }), method(object({}), array(LlmNodeModelSchema), { auth: "admin" }), method(object({}), LlmRuntimeDiskUsageSchema, { auth: "admin" });
12976
13023
  /**
12977
13024
  * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
12978
13025
  * methods concat-fan across providers; single-row methods route to ONE
@@ -16483,1748 +16530,1998 @@ var OauthIntegrationDescriptorSchema = object({
16483
16530
  */
16484
16531
  refreshTokenTtlSec: union([number().int().positive(), literal("never")]).optional()
16485
16532
  });
16486
- method(_void(), OauthIntegrationDescriptorSchema);
16533
+ method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
16487
16534
  /**
16488
- * pipeline-analytics device-scoped wrapper cap. Refines raw
16489
- * per-frame detections emitted by the pipeline runner into tracked
16490
- * objects, per-kind event collections (motion / object / audio), and
16491
- * persisted media. Owns the post-detection domain end-to-end:
16492
- *
16493
- * runner emits PipelineInferenceResult
16494
- * ↓ (event bus)
16495
- * pipeline-analytics subscriber
16496
- * ↓ SORT tracker + zone engine + state analyzer + event emitter
16497
- * → three DB collections (one per kind), one FS media tree, one
16498
- * unified event emitter (FrameTracked + TrackStarted/Ended +
16499
- * DetectionEvent on bus)
16500
- *
16501
- * Pure subscriber model. No `processFrame` cap method — the runner
16502
- * already publishes the raw frame on the bus. The cap surface is
16503
- * only QUERIES + per-device settings, bound on/off via
16504
- * `device-manager.setWrapperActive`. `defaultActive: true` because
16505
- * every camera with a detection pipeline wants its raw detections
16506
- * refined; operators opt out per-device via BindingsTab when needed.
16507
- *
16508
- * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
16509
- * (per-device surface) and `track-trail` caps — see P11 cleanup.
16535
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
16536
+ * within the frame, so the executor can re-cut a leaf child ROI at native
16537
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
16510
16538
  */
16511
- var TrackStateSchema = _enum([
16512
- "new",
16513
- "entered",
16514
- "left",
16515
- "moving",
16516
- "idle"
16517
- ]);
16518
- var EventKindSchema = _enum([
16519
- "motion",
16520
- "object",
16521
- "audio"
16522
- ]);
16539
+ var NativeCropRefSchema = object({
16540
+ /** Handle keying the retained native surface (node-pinned to its owner). */
16541
+ handle: FrameHandleSchema,
16542
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
16543
+ cropFrameSpace: object({
16544
+ x: number(),
16545
+ y: number(),
16546
+ w: number(),
16547
+ h: number()
16548
+ })
16549
+ });
16550
+ object({
16551
+ crop: object({
16552
+ left: number(),
16553
+ top: number(),
16554
+ width: number().positive(),
16555
+ height: number().positive()
16556
+ }).optional(),
16557
+ content: object({
16558
+ width: number().int().positive(),
16559
+ height: number().int().positive()
16560
+ }),
16561
+ fit: _enum(["stretch", "contain"]),
16562
+ format: _enum([
16563
+ "rgb",
16564
+ "gray",
16565
+ "jpeg"
16566
+ ])
16567
+ });
16523
16568
  /**
16524
- * Spatial filter for `listTracks` the rect + polygon variants of the shared
16525
- * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
16526
- * of the camera frame (top-left origin), matching the drawing-plane editor.
16569
+ * Process-local frame identity. It is serializable so it can ride an in-process
16570
+ * capability call, but `registryId` deliberately prevents resolution in any
16571
+ * other process or execution group.
16527
16572
  */
16528
- var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
16529
- /** Closed icon vocabulary so clients render a known glyph per kind. */
16530
- var EventKindIconSchema = _enum([
16531
- "motion",
16532
- "audio",
16533
- "person",
16534
- "vehicle",
16535
- "animal",
16536
- "door",
16537
- "pir",
16538
- "smoke",
16539
- "water",
16540
- "button",
16541
- "package",
16542
- "generic"
16573
+ var FrameRefSchema = object({
16574
+ registryId: string().min(1),
16575
+ id: string().min(1),
16576
+ width: number().int().positive(),
16577
+ height: number().int().positive(),
16578
+ format: _enum(["rgb", "gray"]),
16579
+ timestamp: number(),
16580
+ capturedAt: number().optional()
16581
+ });
16582
+ var ModelFormatSchema$1 = _enum([
16583
+ "onnx",
16584
+ "coreml",
16585
+ "openvino",
16586
+ "tflite",
16587
+ "pt",
16588
+ "gguf"
16543
16589
  ]);
16544
- var EventKindCategorySchema = _enum([
16545
- "motion",
16546
- "audio",
16547
- "detection",
16548
- "sensor",
16549
- "control",
16550
- "custom",
16551
- "package"
16590
+ var PipelineSlotSchema = _enum([
16591
+ "detector",
16592
+ "cropper",
16593
+ "classifier",
16594
+ "refiner",
16595
+ "audio-classifier"
16552
16596
  ]);
16553
- /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
16554
- var EventKindLevelSchema = _enum(["macro", "sub"]);
16555
- var EventKindDescriptorSchema = object({
16556
- /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
16557
- kind: string(),
16558
- /** i18n key resolved on the UI side; `label` is the English fallback. */
16559
- labelKey: string(),
16560
- /** English fallback label (kept for clients that don't translate). */
16561
- label: string(),
16562
- /** Hex color for timeline/legend rendering. */
16563
- color: string(),
16564
- /** Dictionary id → lucide component on the UI side. */
16565
- iconId: string(),
16566
- /** Legacy closed-vocab glyph — fallback for `iconId`. */
16567
- icon: EventKindIconSchema,
16568
- category: EventKindCategorySchema,
16569
- /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
16570
- parentKind: string().nullable(),
16571
- /** Derived from `parentKind`, explicit for the client tree. */
16572
- level: EventKindLevelSchema,
16573
- /** Which cap + device contributes this kind. For built-ins the camera
16574
- * itself; for sensor kinds the LINKED source device. */
16575
- source: object({
16576
- capName: string(),
16577
- deviceId: number()
16578
- })
16597
+ var PipelineEngineChoiceSchema = object({
16598
+ runtime: _enum(["node", "python"]),
16599
+ backend: string(),
16600
+ format: ModelFormatSchema$1,
16601
+ device: string().optional()
16579
16602
  });
16580
- /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
16581
- var EventKindsForDeviceSchema = object({
16582
- deviceId: number(),
16583
- kinds: array(EventKindDescriptorSchema).readonly()
16603
+ var AvailableEngineSchema = object({
16604
+ engine: PipelineEngineChoiceSchema,
16605
+ devices: array(object({
16606
+ id: string(),
16607
+ label: string(),
16608
+ description: string().optional()
16609
+ })).readonly(),
16610
+ defaultDevice: string()
16584
16611
  });
16585
- var SensorEventSchema = object({
16612
+ var PipelineDefaultStepSchema = lazy(() => object({
16613
+ addonId: string(),
16614
+ addonName: string(),
16615
+ slot: PipelineSlotSchema,
16616
+ inputClasses: array(string()).readonly(),
16617
+ outputClasses: array(string()).readonly(),
16618
+ enabled: boolean(),
16619
+ modelId: string(),
16620
+ children: array(PipelineDefaultStepSchema).readonly(),
16621
+ group: string().optional(),
16622
+ settings: record(string(), unknown()).optional()
16623
+ }));
16624
+ var PipelineTemplateStepSchema = lazy(() => object({
16625
+ addonId: string(),
16626
+ enabled: boolean(),
16627
+ modelId: string(),
16628
+ children: array(PipelineTemplateStepSchema).readonly(),
16629
+ settings: record(string(), unknown()).optional()
16630
+ }));
16631
+ var PipelineTemplateSchema$1 = object({
16586
16632
  id: string(),
16587
- /** The CAMERA the event is attributed to (a sensor linked to N cameras
16588
- * yields N rows, one per camera). */
16589
- deviceId: number(),
16590
- /** The linked sensor device whose state changed. */
16591
- sourceDeviceId: number(),
16592
- /** Event kind id — matches an `EventKindDescriptor.kind`. */
16593
- kind: string(),
16594
- /** Snapshot of the sensor cap's runtime-state slice at the change. */
16595
- value: record(string(), unknown()).nullable(),
16596
- timestamp: number()
16597
- });
16598
- var TrackPositionSchema = object({
16599
- x: number(),
16600
- y: number(),
16601
- timestamp: number(),
16602
- bbox: BoundingBoxSchema
16633
+ name: string(),
16634
+ createdAt: string(),
16635
+ updatedAt: string(),
16636
+ engine: PipelineEngineChoiceSchema,
16637
+ steps: array(PipelineTemplateStepSchema).readonly()
16603
16638
  });
16604
- var TrackSnapshotSchema = object({
16605
- timestamp: number(),
16606
- position: TrackPositionSchema,
16607
- /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
16608
- mediaKey: string()
16639
+ var PipelineModelOptionSchema = object({
16640
+ id: string(),
16641
+ name: string(),
16642
+ formats: record(string(), object({
16643
+ downloaded: boolean(),
16644
+ sizeMB: number()
16645
+ })),
16646
+ group: ModelVariantGroupSchema.optional(),
16647
+ legacy: boolean().optional(),
16648
+ provider: ModelProviderIdSchema.optional()
16609
16649
  });
16610
- /**
16611
- * Normalized 0..1 trajectory envelope (min/max over every position bbox,
16612
- * divided by the track's detection-frame dims), computed at persist time.
16613
- * Absent when the frame dims were unknown when the track was persisted
16614
- * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
16615
- */
16616
- var TrackEnvelopeSchema = object({
16617
- minX: number(),
16618
- minY: number(),
16619
- maxX: number(),
16620
- maxY: number()
16650
+ var ConfigFieldBridge = custom();
16651
+ var PipelineAddonSchemaSchema = object({
16652
+ id: string(),
16653
+ name: string(),
16654
+ slot: PipelineSlotSchema,
16655
+ inputClasses: array(string()).readonly(),
16656
+ outputClasses: array(string()).readonly(),
16657
+ childSlots: array(PipelineSlotSchema).readonly(),
16658
+ models: array(PipelineModelOptionSchema).readonly(),
16659
+ defaultModelId: string(),
16660
+ defaultModelIdByFormat: record(string(), string()).optional(),
16661
+ enabledByDefault: boolean().optional(),
16662
+ backfillIntoExistingOverrides: boolean().optional(),
16663
+ defaultConfidence: number(),
16664
+ group: string().optional(),
16665
+ configSchema: array(ConfigFieldBridge).readonly().optional()
16621
16666
  });
16622
- /**
16623
- * Row projection for track list queries. `full` (default) returns the
16624
- * complete Track including the frame-rate `positions[]` history and the
16625
- * `snapshots[]` references — megabytes across a page of tracks. `slim`
16626
- * keeps every scalar the list surfaces actually render (ids, class(es),
16627
- * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
16628
- * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
16629
- * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
16630
- * `getTrack`. Mirrors the event-store `projection` convention
16631
- * (`getObjectEvents` et al.).
16632
- */
16633
- var TrackProjectionSchema = _enum(["full", "slim"]);
16634
- /**
16635
- * One audio-classification label heard on the track's camera while the
16636
- * track was alive, aggregated per label. An "episode" is one persisted
16637
- * audio event (the confident-classification path: score ≥ the device's
16638
- * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
16639
- * one 32 ms inference chunk, so counts stay human-scaled.
16640
- */
16641
- var TrackAudioLabelSchema = object({
16667
+ var PipelineSlotSchemaSchema = object({
16668
+ id: PipelineSlotSchema,
16642
16669
  label: string(),
16643
- /** Highest classification score observed across the label's episodes. */
16644
- peakScore: number(),
16645
- /** Number of coalesced audio-event episodes carrying this label. */
16646
- count: number(),
16647
- firstAt: number(),
16648
- lastAt: number()
16670
+ priority: number(),
16671
+ parentSlot: PipelineSlotSchema.nullable(),
16672
+ addons: array(PipelineAddonSchemaSchema).readonly()
16649
16673
  });
16650
- /**
16651
- * How a track was produced. `pipeline` (default / absent) = the spatial
16652
- * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
16653
- * no positions, a single snapshot, and no bbox trajectory at all:
16654
- *
16655
- * - `sensor` — a linked sensor/control device state change.
16656
- * - `audio` — an audio event on the camera itself that was anomalous for
16657
- * THAT camera, loud, and heard while nothing visual was happening (D62).
16658
- *
16659
- * The spatial subsystems (tracker association, occupancy count, re-id /
16660
- * embedding, resurrection) MUST skip every synthetic source. Test for that
16661
- * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
16662
- * check silently readmits every source added after it was written.
16663
- */
16664
- var TrackSourceSchema = _enum([
16665
- "pipeline",
16666
- "sensor",
16667
- "audio"
16668
- ]);
16669
- /**
16670
- * Where a track sits in the RETRAIN lifecycle (D81).
16671
- *
16672
- * - `none` — never marked, or un-marked. Evictable.
16673
- * - `staging` — the operator wants this track as training material and has not
16674
- * finished with it. **This is the only state retention holds**: the track and
16675
- * everything it owns (object events, crops, keyframes, CLIP vector) survive
16676
- * the device's age window.
16677
- * - `trained` — the retrain page has taken what it needed. The frames it chose
16678
- * were COPIED into the retrain dataset at selection time, so the dataset no
16679
- * longer depends on the track's media and the track becomes EVICTABLE again.
16680
- * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
16681
- * a deliberate action of the retrain page, not a side effect of a checkbox.
16682
- *
16683
- * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
16684
- * the store's filter language has only positive equality and `whereIn` — no
16685
- * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
16686
- * would make the entire pre-column history immortal in one deploy.
16687
- */
16688
- var RetrainStatusSchema = _enum([
16689
- "none",
16690
- "staging",
16691
- "trained"
16692
- ]);
16693
- /**
16694
- * Per-track OPERATOR flags — set by hand from the admin UI or the viewer, never
16695
- * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
16696
- * so the two surfaces cannot drift.
16697
- *
16698
- * **Absent ≠ false.** A track that has never been touched omits the field; an
16699
- * explicitly un-flagged track carries `false`. Legacy rows written before the
16700
- * columns existed read as absent, and a consumer that needs a boolean should say
16701
- * `flag === true`, not `flag !== false`.
16702
- *
16703
- * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
16704
- * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
16705
- * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
16706
- * `trained` track reports `false` while refusing both writes. The boolean is
16707
- * kept because three surfaces drive a toggle off it; anything that needs to tell
16708
- * "never marked" from "already trained" must read `retrainStatus`.
16709
- *
16710
- * `debug` does NOT pin; it is attention, not durability.
16711
- *
16712
- * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
16713
- * A favourited track is skipped by retention the same way `staging` is, but
16714
- * it does not enter `none|staging|trained` and has no staging budget.
16715
- */
16716
- var TrackFlagFields = {
16717
- /** Operator marked this track as training material — i.e. `retrainStatus` is
16718
- * `'staging'`. */
16719
- markForTrain: boolean().optional(),
16720
- /** Operator marked this track for diagnostic attention. */
16721
- debug: boolean().optional(),
16722
- /** Operator favourited this track. Pins it against pruning. */
16723
- favourited: boolean().optional()
16724
- };
16725
- /**
16726
- * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
16727
- * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
16728
- * write patch, and the status is not something the toggle sets — it is what the
16729
- * toggle's boolean is derived from. Absent on an in-RAM track never touched;
16730
- * always present on a persisted row (the column default materialises `'none'`).
16731
- */
16732
- var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
16733
- /**
16734
- * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
16735
- * one flag can never clear the other — the toggles are independent and are
16736
- * driven from three surfaces that do not know about each other.
16737
- */
16738
- var TrackFlagsPatchSchema = object(TrackFlagFields);
16739
- /**
16740
- * The resolved flag state after a write. Both fields are REQUIRED here (absent
16741
- * collapses to `false`) so a caller can drive a toggle's checked state off the
16742
- * mutation result without a re-fetch.
16743
- */
16744
- var TrackFlagsSchema = object({
16745
- trackId: string(),
16746
- markForTrain: boolean(),
16747
- debug: boolean(),
16748
- favourited: boolean(),
16749
- /** The lifecycle state the boolean was derived from. Required here (unlike on
16750
- * a track row) because this shape is only ever produced by the write body,
16751
- * which always knows it — and a surface that has just written needs to render
16752
- * `trained` without a re-fetch. */
16753
- retrainStatus: RetrainStatusSchema
16674
+ var PipelineSchemaSchema = object({
16675
+ availableEngines: array(AvailableEngineSchema).readonly(),
16676
+ selectedEngine: PipelineEngineChoiceSchema,
16677
+ slots: array(PipelineSlotSchemaSchema).readonly()
16754
16678
  });
16755
- union([literal(1), literal(2)]);
16756
- /**
16757
- * WHO decided a label, and when. Carried per tier so a value can be traced to
16758
- * the step and model that produced it — which is what makes the write rule
16759
- * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
16760
- * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
16761
- *
16762
- * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
16763
- * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
16764
- * `migration:4g` for a value the 4g migration moved from the single-slot era —
16765
- * that value has no provenance, and the write rule lets ANY properly-attributed
16766
- * write of the same tier replace it regardless of score.
16767
- */
16768
- var LabelAttributionSchema = object({
16769
- stepId: string(),
16770
- modelId: string().optional(),
16771
- decidedAt: number(),
16679
+ var EngineProvisioningSchema = object({
16680
+ runtimeId: _enum([
16681
+ "onnx",
16682
+ "openvino",
16683
+ "coreml",
16684
+ "edgetpu"
16685
+ ]).nullable(),
16686
+ device: string().nullable(),
16687
+ state: _enum([
16688
+ "idle",
16689
+ "installing",
16690
+ "verifying",
16691
+ "ready",
16692
+ "failed"
16693
+ ]),
16694
+ progress: number().optional(),
16695
+ error: string().optional(),
16696
+ nextRetryAt: number().optional(),
16772
16697
  /**
16773
- * The GALLERY id behind a recognised tier-2 label — a face-gallery
16774
- * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
16775
- *
16776
- * The text alone is a DISPLAY NAME, and a display name is renameable: a
16777
- * notification rule authored on "Gianluca" stopped matching the moment the
16778
- * operator fixed the spelling in the gallery, and nothing said so. The id is
16779
- * the thing that does not move, so it is what a rule matches on
16780
- * (`NcConditions.identities`) and the text is what a human is shown.
16781
- *
16782
- * Absent when the label names no gallery row — a plate the OCR read but no
16783
- * vehicle claims, a sub-class, a species, any tier-1 value.
16698
+ * Gate A (config-correctness gate at engine change): human-readable
16699
+ * config issues surfaced EAGERLY when the node's engine changes — model
16700
+ * substitutions ("chose X, running Y") and zero-build steps ("no model
16701
+ * has a <format> build"). Additive/optional: informational only, never
16702
+ * enforced here `assertEngineReady` (readiness) still gates inference.
16703
+ * Absent/empty when the node-default tree resolves cleanly.
16784
16704
  */
16785
- identityId: string().optional()
16705
+ configIssues: array(string()).optional()
16786
16706
  });
16787
- /**
16788
- * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
16789
- * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
16790
- * track and its events always answer the same question the same way.
16791
- *
16792
- * Two scalar columns, not an array: every consumer wants "the coarse one" or
16793
- * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
16794
- * is tier 2, and each carries its own score + attribution.
16795
- *
16796
- * **Reading it.** What a human should be shown is `subLabel ?? label` — the
16797
- * finest thing known. Before 4g the single `label` column held the finest
16798
- * value, so a consumer that has not been updated reads the tier-1 slot and
16799
- * shows nothing on a species-only row; that is why the migration puts every
16800
- * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
16801
- * and why the read surfaces were changed in the same train.
16802
- *
16803
- * **Writing it.** The slots are independent, which is the whole point: a
16804
- * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
16805
- * migratorius`), so fineness cannot regress by construction. Within a tier the
16806
- * higher score wins. One rule, one implementation — see
16807
- * `pipeline/label-tier.ts` in addon-post-analysis.
16808
- */
16809
- var TieredLabelFields = {
16810
- /** Tier 1 the sub-class. See {@link LabelTierSchema}. */
16811
- label: string().optional(),
16812
- /** Confidence of the tier-1 value, as reported by the deciding step. */
16813
- labelScore: number().optional(),
16814
- /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
16815
- labelMeta: LabelAttributionSchema.optional(),
16816
- /** Tier 2 — the instance. See {@link LabelTierSchema}. */
16817
- subLabel: string().optional(),
16818
- /** Confidence of the tier-2 value, as reported by the deciding step. */
16819
- subLabelScore: number().optional(),
16820
- /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
16821
- subLabelMeta: LabelAttributionSchema.optional()
16822
- };
16823
- /** Per-camera slice of a training-export estimate. */
16824
- var TrainingExportDeviceTotalsSchema = object({
16825
- deviceId: number(),
16826
- tracks: number().int(),
16827
- files: number().int(),
16828
- bytes: number().int()
16707
+ var PipelineStepInputSchema = lazy(() => object({
16708
+ addonId: string(),
16709
+ modelId: string().optional(),
16710
+ enabled: boolean().default(true),
16711
+ children: array(PipelineStepInputSchema).optional(),
16712
+ settings: record(string(), unknown()).optional(),
16713
+ jumpDeviceKey: string().optional()
16714
+ }));
16715
+ var ModelSubstitutionSchema = object({
16716
+ addonId: string(),
16717
+ chosen: string(),
16718
+ running: string(),
16719
+ format: string()
16720
+ });
16721
+ var PipelineValidationIssueSchema = object({
16722
+ addonId: string(),
16723
+ kind: _enum(["unknown-addon", "no-format-build"]),
16724
+ detail: string()
16725
+ });
16726
+ var PipelineValidationResultSchema = object({
16727
+ ok: boolean(),
16728
+ issues: array(PipelineValidationIssueSchema).readonly(),
16729
+ substitutions: array(ModelSubstitutionSchema).readonly(),
16730
+ /** The node's `currentEngine.format` this validation ran against. */
16731
+ format: string()
16732
+ });
16733
+ var ReferenceImageEntrySchema = object({
16734
+ filename: string(),
16735
+ stepIds: array(string()).readonly().optional()
16736
+ });
16737
+ var ReferenceImageBodySchema = object({
16738
+ base64: string(),
16739
+ filename: string()
16740
+ });
16741
+ var ReferenceAudioEntrySchema = object({
16742
+ filename: string(),
16743
+ sizeKb: number()
16744
+ });
16745
+ var ReferenceAudioBodySchema = object({ base64: string() });
16746
+ var AudioBackendSchema = object({
16747
+ id: string(),
16748
+ name: string(),
16749
+ description: string(),
16750
+ available: boolean(),
16751
+ /**
16752
+ * Raw classifier labels this backend can emit (e.g. YAMNet's
16753
+ * 521-class set or Apple SoundAnalysis's 303-class set). Used by
16754
+ * the benchmark UI to populate the `enabledMicroClasses` filter
16755
+ * specific to the selected backend without a separate fetch.
16756
+ */
16757
+ rawLabels: array(string()).readonly().optional()
16758
+ });
16759
+ var AudioCapabilitiesSchema = object({
16760
+ activeBackend: string(),
16761
+ availableBackends: array(AudioBackendSchema).readonly(),
16762
+ sampleRate: number(),
16763
+ chunkDurationMs: number()
16764
+ });
16765
+ var DownloadModelResultSchema = object({
16766
+ filePath: string(),
16767
+ sizeMB: number(),
16768
+ durationMs: number()
16829
16769
  });
16830
16770
  /**
16831
- * What a training export WOULD contain. Computed from media index rows only —
16832
- * no blob is read to produce this.
16771
+ * Wrapper carrying a single test run's result. Replaces the legacy
16772
+ * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
16773
+ * canonical `AudioResult` from the Phase 6 output rework: one
16774
+ * `AudioDetection` per class above `minScore`, top-N candidates in
16775
+ * `debug.alternateLabels['audio-classifier']`, per-source timings in
16776
+ * `debug.stepTimings`. The outer `success`/`error` fields stay so the
16777
+ * benchmark UI can still report a clean failure when the classifier
16778
+ * cap isn't available.
16833
16779
  */
16834
- var TrainingExportSummarySchema = object({
16835
- generatedAt: number(),
16836
- trackCount: number().int(),
16837
- fileCount: number().int(),
16838
- byteCount: number().int(),
16839
- /** More marked tracks exist than a single pass carries. */
16840
- truncated: boolean(),
16841
- devices: array(TrainingExportDeviceTotalsSchema).readonly()
16780
+ var AudioTestResultSchema = object({
16781
+ success: boolean(),
16782
+ error: string().optional(),
16783
+ frame: custom().optional()
16842
16784
  });
16843
- var TrackSchema = object({
16844
- trackId: string(),
16845
- deviceId: number(),
16846
- className: string(),
16847
- ...TieredLabelFields,
16848
- producingDeviceName: string().optional(),
16849
- /** Track provenance. Absent `pipeline` (legacy rows). */
16850
- source: TrackSourceSchema.optional(),
16851
- firstSeen: number(),
16852
- lastSeen: number(),
16853
- /** Frame-rate position history (subject to maxPositionHistory cap). */
16854
- positions: array(TrackPositionSchema).readonly(),
16855
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
16856
- * saveThumbnails policy). */
16857
- snapshots: array(TrackSnapshotSchema).readonly(),
16858
- /** Deduplicated zones the track has entered at least once. Zone IDS. */
16859
- zonesVisited: array(string()).readonly(),
16785
+ var PipelineConfigBridge = custom();
16786
+ var ConfigUISchemaBridge = custom();
16787
+ var ConfigUISchemaNullableBridge = custom();
16788
+ var InferenceCapabilitiesBridge = custom();
16789
+ var ModelAvailabilityListBridge = custom();
16790
+ var PipelineRunResultBridge = custom();
16791
+ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
16792
+ modelId: string(),
16793
+ settings: record(string(), unknown()).readonly()
16794
+ }))), method(object({ steps: record(string(), object({
16795
+ modelId: string(),
16796
+ settings: record(string(), unknown()).readonly()
16797
+ })) }), object({ success: literal(true) }), {
16798
+ kind: "mutation",
16799
+ auth: "admin"
16800
+ }), method(object({ nodeId: string() }), object({
16801
+ success: literal(true),
16802
+ clearedDevices: number()
16803
+ }), {
16804
+ kind: "mutation",
16805
+ auth: "admin"
16806
+ }), method(object({ nodeId: string() }), object({ unhealthy: array(object({
16807
+ /** `<backend>:<device>`, e.g. `openvino:gpu`. */
16808
+ deviceKey: string(),
16860
16809
  /**
16861
- * Human NAMES for {@link zonesVisited}, resolved at READ time against the
16862
- * `zones` capability.
16863
- *
16864
- * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
16865
- * and no card can render — so every free-text search surface was structurally
16866
- * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
16867
- * just returned nothing. Resolving here rather than in each client keeps ONE
16868
- * derivation and costs the clients no extra call (the `zones` cap is
16869
- * per-device, so a client-side resolve would be a per-camera fan-out on a
16870
- * surface built to avoid exactly that).
16871
- *
16872
- * Resolved, never invented: a zone deleted since the track was written has no
16873
- * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
16874
- * two are not positionally aligned. Absent when the track visited no zone, or
16875
- * when the zone catalogue could not be read.
16810
+ * `failed` the per-device restart budget is exhausted; no pool
16811
+ * will be spawned until an operator re-arms it or the runner
16812
+ * respawns. `backoff` — under budget, waiting out the backoff (or
16813
+ * a cached pool observed dead and not yet condemned).
16876
16814
  */
16877
- zoneNames: array(string()).readonly().optional(),
16878
- /** Deduplicated set of detector classes observed for this track over its
16879
- * life (a track may be reclassified, e.g. person→vehicle). Absent on
16880
- * legacy rows written before class accumulation shipped. */
16881
- classes: array(string()).readonly().optional(),
16882
- /** Cumulative normalized distance travelled (0..1 units = full frame width). */
16883
- totalDistance: number(),
16884
- state: TrackStateSchema,
16885
- active: boolean(),
16886
- /** Deterministic key-event importance score in [0,1] (server-computed at
16887
- * track expiry, recomputed on late label). Absent on legacy rows written
16888
- * before scoring shipped — consumers degrade to absence / compute-on-read. */
16889
- importance: number().optional(),
16890
- /** Id of the track's highest-confidence ObjectEvent (its representative
16891
- * "best" frame). Absent when the track produced no object events. */
16892
- bestEventId: string().optional(),
16893
- /** Tag of the importance sub-signal that dominated the score
16894
- * (identity|dwell|proximity|class|confidence|travel|zone). */
16895
- importanceReason: string().optional(),
16896
- /** Audio-classification labels heard on the camera during the track's
16897
- * life (score ≥ device `classificationMinScore`), aggregated per label.
16898
- * Absent on legacy rows / tracks with no confident audio. */
16899
- audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
16900
- /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
16901
- * Populated from the persisted envelope columns on historical reads;
16902
- * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
16903
- envelope: TrackEnvelopeSchema.optional(),
16815
+ state: _enum(["failed", "backoff"]),
16816
+ /** Epoch ms of the death that produced this state. */
16817
+ since: number(),
16818
+ /** Pool deaths inside the current window. */
16819
+ deaths: number(),
16820
+ /** The last death's message. */
16821
+ lastError: string()
16822
+ })).readonly() })), method(object({
16823
+ nodeId: string(),
16824
+ deviceKey: string()
16825
+ }), object({ rearmed: boolean() }), {
16826
+ kind: "mutation",
16827
+ auth: "admin"
16828
+ }), 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({
16829
+ name: string(),
16830
+ steps: array(PipelineTemplateStepSchema).readonly(),
16831
+ engine: PipelineEngineChoiceSchema
16832
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
16833
+ id: string(),
16834
+ name: string().optional(),
16835
+ steps: array(PipelineTemplateStepSchema).readonly().optional()
16836
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
16837
+ addonId: string(),
16838
+ modelId: string(),
16839
+ format: ModelFormatSchema$1
16840
+ }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
16841
+ addonId: string(),
16842
+ modelId: string(),
16843
+ format: ModelFormatSchema$1
16844
+ }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
16845
+ engine: PipelineEngineChoiceSchema.optional(),
16846
+ steps: array(PipelineStepInputSchema).min(1),
16847
+ frame: FrameInputSchema.optional(),
16904
16848
  /**
16905
- * A face DETECTOR found a face on this track — nothing more. It says the
16906
- * detail plane produced a `face` detail; it does NOT say the face was
16907
- * embedded, matched, above `minFacePx`, or that the recognizer was even
16908
- * enabled. Set once and never cleared.
16909
- *
16910
- * **This exists so "face present but not recognised" is expressible.** A
16911
- * recognised identity lands in `subLabel` (attributed to the face chain via
16912
- * `subLabelMeta.stepId`), so before this field a track with an unmatched face
16913
- * and a track with no face at all were byte-identical on the wire and no
16914
- * surface could tell them apart. The read is `hasFace === true && subLabel
16915
- * === undefined`.
16916
- *
16917
- * **Absent ≠ false.** Every row written before the column existed omits it,
16918
- * and so does every server that predates the field — a consumer must test
16919
- * `=== true` and render nothing otherwise, never infer "no face".
16849
+ * Process-local lazy frame. Valid only when caller and provider resolve
16850
+ * in the same execution-group process; split/cross-node callers use
16851
+ * `frame`/`image` inline compatibility instead.
16920
16852
  */
16921
- hasFace: boolean().optional(),
16853
+ frameRef: FrameRefSchema.optional(),
16922
16854
  /**
16923
- * This track has a face row IN THE GALLERY: a crop **and** an embedding a
16924
- * face an operator could ASSIGN to an identity.
16925
- *
16926
- * The STRICT twin of {@link hasFace}, and the pair only earns its keep
16927
- * because the two disagree. `hasFace` is stamped at the TOP of the face
16928
- * branch, before every gate, and means no more than "a face detector produced
16929
- * a face detail". This one is stamped at the single moment the gallery row
16930
- * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
16931
- * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
16932
- * candidate gate, the imageless-track drop (no crop was ever captured) and
16933
- * the crop-store drop. Everything between the detector and that insert can
16934
- * legitimately refuse the face, so a flag written any earlier promises the
16935
- * operator something to assign and delivers nothing.
16936
- *
16937
- * **Independent of recognition.** A face collected but never auto-matched is
16938
- * still assignable — it is in fact the face an operator most wants to reach —
16939
- * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
16940
- * `subLabel`; this says only that the raw material exists.
16941
- *
16942
- * **Set once, never cleared.** A track that produced a gallery row produced
16943
- * one; deleting the row later is the gallery's business, not this flag's.
16944
- *
16945
- * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
16946
- * before the column omits it, and so does every server that predates the
16947
- * field. A consumer must test `=== true` and render nothing otherwise —
16948
- * never infer "no assignable face".
16855
+ * CB5 shm passthrough a `FrameHandle` naming the same ring slot
16856
+ * the decoded pixels live in. One more member of the one-of
16857
+ * frame/frameHandle/image/imageBase64/referenceImage group.
16949
16858
  */
16950
- hasEmbeddedFace: boolean().optional(),
16859
+ frameHandle: FrameHandleSchema.optional(),
16860
+ imageBase64: string().optional(),
16951
16861
  /**
16952
- * This subject CONTAINS a folded rider a person the rider-pairing step
16953
- * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
16954
- * so the passage is tracked once and as a VEHICLE.
16955
- *
16956
- * It exists because the fold's record was dishonest. D34 and the code both
16957
- * said "the person is not lost — it is reported so both entities stay on the
16958
- * record"; in fact the pair went into a per-processor RAM field behind an
16959
- * accessor nobody called, and every durable surface said `vehicle`, full
16960
- * stop. This is the composition note that makes the row true.
16961
- *
16962
- * A COMPOSITION, never a class and never a label. "This vehicle contains a
16963
- * person" is not an answer to "what is this" — both label tiers would refuse
16964
- * a macro token anyway (D89), and correctly. Nothing here changes what the
16965
- * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
16966
- * and a `person` rule still does not fire for someone cycling past.
16967
- *
16968
- * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
16969
- * the column, and every hub that predates the field, omits it. Test
16970
- * `=== true` and render nothing otherwise — never infer "no rider".
16862
+ * Binary JPEG bytespreferred over `imageBase64` on internal
16863
+ * hops (hub forked worker via Moleculer MsgPack) because it
16864
+ * skips the 33% base64 overhead + the per-call base64 decode on
16865
+ * the detection-pipeline worker. Callers can pass either; exactly
16866
+ * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
16971
16867
  */
16972
- hasRider: boolean().optional(),
16973
- ...TrackFlagFields,
16974
- ...TrackRetrainFields
16975
- });
16976
- var BaseEventFields = {
16977
- id: string(),
16978
- deviceId: number(),
16979
- timestamp: number()
16980
- };
16981
- var MotionEventSchema = object({
16982
- ...BaseEventFields,
16983
- kind: literal("motion"),
16984
- regionCount: number(),
16985
- /** Heavy JSON array omitted in slim projection. */
16986
- regions: array(object({
16987
- bbox: BoundingBoxSchema,
16988
- pixelCount: number(),
16989
- intensity: number()
16990
- })).readonly().optional(),
16991
- /** Omitted in slim projection. */
16992
- frameWidth: number().optional(),
16993
- /** Omitted in slim projection. */
16994
- frameHeight: number().optional(),
16995
- /** Populated by B5 (recording playback URL for this event). */
16996
- mediaUrl: string().optional()
16997
- });
16868
+ image: _instanceof(Uint8Array).optional(),
16869
+ referenceImage: string().optional(),
16870
+ deviceId: number().optional(),
16871
+ sessionId: string().optional(),
16872
+ /**
16873
+ * Execution plane. 'full' (default) runs the whole tree — benchmark,
16874
+ * reference-image, and detail-subtree calls. 'frame' is the live
16875
+ * per-frame dispatch: ONLY root-plane steps run; crop children
16876
+ * (inputClasses ≠ null) are skipped and served per-track via
16877
+ * pipelineRunner.runDetailSubtree (two-plane design).
16878
+ */
16879
+ plane: _enum(["full", "frame"]).optional(),
16880
+ /**
16881
+ * Inference-device selector (Phase 2 multi-device). Format
16882
+ * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
16883
+ * Omitted ⇒ the runner's default device (current single-engine
16884
+ * behaviour). Selects WHICH device pool of the node runs the call.
16885
+ */
16886
+ deviceKey: string().optional(),
16887
+ /**
16888
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
16889
+ * when the parent crop was resolved from the frame's retained NATIVE
16890
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
16891
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
16892
+ * resolution from that surface — the SAME quality path faces already
16893
+ * had — instead of the downscaled parent tile. `handle` keys the native
16894
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
16895
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
16896
+ * the executor's crop-normalized child ROI back into frame-normalized
16897
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
16898
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
16899
+ * (today's behaviour on the fallback path).
16900
+ */
16901
+ nativeCropRef: NativeCropRefSchema.optional()
16902
+ }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
16903
+ engine: PipelineEngineChoiceSchema.optional(),
16904
+ steps: array(PipelineStepInputSchema).min(1),
16905
+ frames: array(FrameInputSchema).min(1).max(255),
16906
+ deviceId: number().optional(),
16907
+ sessionId: string().optional(),
16908
+ /**
16909
+ * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
16910
+ * the batch to the Python pool's bench preprocess cache
16911
+ * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
16912
+ * preprocessed ONCE and every later inference is a pure-inference cache
16913
+ * hit — the sustained-throughput run measures inference, not
16914
+ * decode+preprocess+infer. Omitted/0 for live frames (all different →
16915
+ * full preprocess every call, correct). Fresh per sustained run;
16916
+ * released via `uncacheFrame`.
16917
+ */
16918
+ frameId: number().int().nonnegative().optional(),
16919
+ /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
16920
+ deviceKey: string().optional()
16921
+ }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
16922
+ data: _instanceof(Uint8Array),
16923
+ width: number().int().positive(),
16924
+ height: number().int().positive(),
16925
+ format: _enum([
16926
+ "rgb",
16927
+ "bgr",
16928
+ "gray"
16929
+ ])
16930
+ }), object({
16931
+ frameId: number(),
16932
+ width: number(),
16933
+ height: number()
16934
+ }), { kind: "mutation" }), method(object({
16935
+ stepId: string(),
16936
+ frameId: number().int()
16937
+ }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
16938
+ batchMode: string(),
16939
+ windowMs: number(),
16940
+ maxBatchSize: number(),
16941
+ concurrency: number()
16942
+ })), method(_void(), array(object({
16943
+ engineKey: string(),
16944
+ engine: PipelineEngineChoiceSchema,
16945
+ modelsLoaded: array(string()).readonly(),
16946
+ inUseByCameras: array(number()).readonly(),
16947
+ /**
16948
+ * Origin of this resident factory.
16949
+ * - `runtime` — main camera-serving engine (no idle TTL).
16950
+ * - `warm-override` — benchmark/test override held in the warm
16951
+ * cache; auto-disposed after the idle TTL.
16952
+ * - `device-pool` — a concurrent per-device pool (Phase 2
16953
+ * multi-device, keyed by `deviceKey`) resolved
16954
+ * via `resolveDeviceFactory`. Runs alongside the
16955
+ * `runtime` engine on a DIFFERENT accelerator
16956
+ * (NPU / iGPU / Coral) — this is how the
16957
+ * Engines tab shows all pools running at once.
16958
+ */
16959
+ kind: _enum([
16960
+ "runtime",
16961
+ "warm-override",
16962
+ "device-pool"
16963
+ ]),
16964
+ /** Native pid of the underlying Python pool (null when no pool). */
16965
+ poolPid: number().nullable(),
16966
+ /** ms since this factory was last used (null when not warm-tracked). */
16967
+ idleMs: number().nullable(),
16968
+ /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
16969
+ idleTtlMs: number().nullable()
16970
+ })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
16971
+ kind: "mutation",
16972
+ auth: "admin"
16973
+ }), method(object({
16974
+ engine: PipelineEngineChoiceSchema,
16975
+ force: boolean().optional()
16976
+ }), object({
16977
+ success: boolean(),
16978
+ reason: string().optional()
16979
+ }), {
16980
+ kind: "mutation",
16981
+ auth: "admin"
16982
+ }), 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({
16983
+ addonId: string(),
16984
+ modelId: string(),
16985
+ filename: string().optional(),
16986
+ settings: record(string(), unknown()).optional()
16987
+ }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
16998
16988
  /**
16999
- * Which detection SOURCE produced an object event. `pipeline` = the ML
17000
- * detection pipeline (decoded-frame inference); `onboard` = the camera's
17001
- * native on-device AI. Both flow through the SAME analysis layers (zoning,
17002
- * tracking, per-kind persistence) but stay distinguishable so consumers
17003
- * (advanced-notifier, occupancy, …) can select which source(s) to act on.
17004
- * Absent on legacy rows treat as `pipeline`.
16989
+ * Per-stage gating mode applied to the zones a rule references.
16990
+ *
16991
+ * - `include`: the rule contributes to a **whitelist** for its stage.
16992
+ * When at least one `include` rule fires for a stage, only entities
16993
+ * inside one of those zones pass that stage.
16994
+ * - `exclude`: the rule contributes to a **blacklist** for its stage.
16995
+ * Entities inside one of those zones are dropped at that stage.
16996
+ *
16997
+ * `monitor`-style observation (count without filtering) is not a rule
16998
+ * mode — zones without any matching rule are observed naturally by
16999
+ * `zone-analytics` (live snapshot + history), so an "I just want to
17000
+ * count, not filter" use case needs no rule at all.
17005
17001
  */
17006
- var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
17002
+ var ZoneRuleModeEnum = _enum(["include", "exclude"]);
17007
17003
  /**
17008
- * The confirmed zone crossing that produced an object event. Present ONLY on
17009
- * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
17010
- * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
17011
- * appearance event carry none, so a rule asking for a direction fails closed
17012
- * on them.
17004
+ * Per-consumer rule that references existing zones (geometry) and
17005
+ * defines how a specific pipeline stage should treat them. Each
17006
+ * consumer addon owns its own `ZoneRule[]` array in its per-device
17007
+ * settings:
17013
17008
  *
17014
- * Exactly ONE crossing per event: the emitter turns each confirmed crossing
17015
- * into its own event, so a frame in which a track enters A while leaving B
17016
- * produces two events with two directions — never one ambiguous row.
17009
+ * - `addon-motion-wasm` `motionZoneRules: ZoneRule[]` (motion stage)
17010
+ * - `addon-detection-pipeline` `detectionZoneRules: ZoneRule[]` (detection stage)
17011
+ * - future: notification rules, audio gating, etc.
17017
17012
  *
17018
- * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
17019
- * membership the box has NOW, and by definition it no longer contains the zone
17020
- * that was just left. Without the id here, a zone-scoped rule could never match
17021
- * the exit it asked for.
17013
+ * One rule applies to N zones (`zoneIds[]`) so the operator can
17014
+ * express "ignore motion in ALL of {garden, street}" with a single
17015
+ * rule. `classFilter` narrows the rule to specific object classes
17016
+ * "drop person detections in the street, but keep cars" is one
17017
+ * `exclude` rule with `classFilter: ['person']`.
17018
+ *
17019
+ * `enabled` is a soft toggle — the operator can keep the rule
17020
+ * configured but inert without deleting it.
17022
17021
  */
17023
- var ZoneCrossingSchema = object({
17024
- direction: _enum(["enter", "exit"]),
17025
- /** Admin zone id crossed. */
17026
- zoneId: string(),
17027
- /** Zone display name at crossing time (falls back to the id). */
17028
- zoneName: string().optional()
17029
- });
17030
- var ObjectEventSchema = object({
17031
- ...BaseEventFields,
17032
- kind: literal("object"),
17033
- /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
17034
- source: DetectionSourceSchema.optional(),
17022
+ var ZoneRuleSchema = object({
17023
+ /** Stable rule id — survives edits, used by the UI for diffing. */
17024
+ id: string(),
17025
+ /** Optional human-readable label rendered in the rule editor. */
17026
+ name: string().optional(),
17027
+ /** Zones this rule targets. The rule's `mode` applies to ALL
17028
+ * listed zones (OR-set: a detection in any one of them counts).
17029
+ * At least one zone id required — a rule with no targets is a
17030
+ * configuration mistake and the form validator rejects it. */
17031
+ zoneIds: array(string()).min(1).readonly(),
17032
+ mode: ZoneRuleModeEnum,
17035
17033
  /**
17036
- * Inference-frame id shared by every object event emitted from the SAME frame
17037
- * the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
17038
- * 2 people + 1 dog) under one full frame, and link a track's frames over time
17039
- * (group by `trackId`, pick a representative `frameId` as the parent frame).
17040
- * Optional for backward-compat with pre-existing rows / the slim projection
17041
- * includes it (it is light). Absent on rows written before this field.
17034
+ * Class names this rule applies to. Empty / undefined rule
17035
+ * applies to every class. Class strings match the `macroClass`
17036
+ * field on detections (e.g. `person`, `car`, `dog`).
17042
17037
  */
17043
- frameId: string().optional(),
17044
- /** Omitted in slim projection. */
17045
- trackId: string().optional(),
17046
- className: string(),
17047
- ...TieredLabelFields,
17048
- /** Omitted in slim projection. */
17049
- confidence: number().optional(),
17050
- /** Heavy JSON — omitted in slim projection. */
17051
- bbox: BoundingBoxSchema.optional(),
17052
- /** Heavy JSON — omitted in slim projection. */
17053
- zones: array(string()).readonly().optional(),
17054
- /** Omitted in slim projection. */
17055
- state: TrackStateSchema.optional(),
17038
+ classFilter: array(string()).readonly().optional(),
17056
17039
  /**
17057
- * The zone crossing this event IS, when it is one. Absent on every other
17058
- * event kind (movement state, appearance, package) see
17059
- * {@link ZoneCrossingSchema}. Omitted in slim projection.
17040
+ * Minimum bbox/mask overlap (0–1) with any of the rule's zones
17041
+ * required to consider an entity "in the zone". Defaults to the
17042
+ * consumer's stage default when omitted. Kept for back-compat with
17043
+ * existing per-rule overrides; new operators pick the value via
17044
+ * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
17045
+ * set, the lower-level engine reads it as a 0–1 fraction.
17060
17046
  */
17061
- zoneCrossing: ZoneCrossingSchema.optional(),
17062
- /** Detection-frame dimensions in pixels — let consumers normalize the
17063
- * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
17064
- frameWidth: number().optional(),
17065
- frameHeight: number().optional(),
17066
- /** MediaStore key for the crop attached to this event (if any). */
17067
- mediaKey: string().optional(),
17068
- /** Design B: MediaStore key of the track's native-resolution key frame (the
17069
- * best-detection full frame). Resolve via the event-media data-plane
17070
- * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
17071
- * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
17072
- * sources — consumers fall back to `mediaKey` (the tight crop). */
17073
- keyFrameMediaKey: string().optional(),
17074
- /** Populated by B5 (recording playback URL for this event). */
17075
- mediaUrl: string().optional(),
17076
- /** The parent track's key-event importance [0,1], propagated to every object
17077
- * event of the track (so an event row can be sorted by importance without a
17078
- * track join). Absent on legacy rows / before the track was scored. */
17079
- importance: number().optional()
17047
+ overlapThreshold: number().min(0).max(1).optional(),
17048
+ /**
17049
+ * Operator-friendly version of `overlapThreshold` the percentage
17050
+ * of the detection's bbox that must lie inside the zone for the
17051
+ * rule to match. Documented default is 85%; the engine substitutes
17052
+ * that when the field is omitted (kept optional so existing rules
17053
+ * stored without it stay valid).
17054
+ *
17055
+ * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
17056
+ * rule, the engine prefers `bboxInclusionPct` because it's the
17057
+ * field exposed in the UI. Internally both feed the same gate.
17058
+ */
17059
+ bboxInclusionPct: number().min(0).max(100).optional(),
17060
+ /**
17061
+ * When `true` and a detection has a segmentation mask, use the
17062
+ * mask for overlap instead of the bbox. Detection-stage only;
17063
+ * motion rules ignore this field.
17064
+ */
17065
+ preferMask: boolean().optional(),
17066
+ /**
17067
+ * Soft-toggle: `false` disables the rule without deleting it.
17068
+ * Defaults to `true` so operators creating a rule via the UI
17069
+ * see it active immediately.
17070
+ */
17071
+ enabled: boolean().default(true)
17080
17072
  });
17081
- var AudioEventSchema = object({
17082
- ...BaseEventFields,
17083
- kind: literal("audio"),
17084
- rms: number(),
17085
- dbfs: number(),
17086
- classification: object({
17087
- className: string(),
17088
- originalClass: string().optional(),
17089
- score: number()
17090
- }).optional(),
17091
- /** Populated by B5 (recording playback URL for this event). */
17092
- mediaUrl: string().optional()
17073
+ array(ZoneRuleSchema).readonly();
17074
+ /**
17075
+ * Zone — pure geometry + identity. NO filtering behaviour.
17076
+ *
17077
+ * Zones describe **where** in the frame the operator wants to flag
17078
+ * something; consumer-owned {@link ZoneRule} arrays describe **how**
17079
+ * each pipeline stage uses them. Splitting the two means a single
17080
+ * polygon "Driveway" can simultaneously back a motion-exclude rule,
17081
+ * a detection-include rule on `['car']`, and an occupancy aggregate
17082
+ * — without three duplicated polygons.
17083
+ *
17084
+ * Owned by the orchestrator addon (provider) and mirrored into the
17085
+ * `zones` device-state slice on every mutation. Consumers
17086
+ * (motion-wasm, pipeline-executor, analytics, admin UI) read either
17087
+ * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
17088
+ * mirror with `onChanged`).
17089
+ *
17090
+ * Coordinates are normalised fractions of the frame (0–1) so zones
17091
+ * survive resolution changes and stream profile switches.
17092
+ *
17093
+ * `kind` discriminates between full polygons (closed regions used
17094
+ * for intrusion / occupancy filters) and tripwires (open 2-point
17095
+ * line segments used for cross events). Onboard / firmware-reported
17096
+ * zones (Reolink, ONVIF) are out of scope for now — see the deferred
17097
+ * task list.
17098
+ */
17099
+ var ZoneKindEnum = _enum(["polygon", "tripwire"]);
17100
+ /** Polygon vertex in fraction-of-frame coordinates (0–1). */
17101
+ var PolygonPointSchema = object({
17102
+ x: number(),
17103
+ y: number()
17093
17104
  });
17094
- var MediaFileKindEnum = _enum([
17095
- "crop",
17096
- "thumbnail",
17097
- "snapshot",
17098
- "firstFrame",
17099
- "lastFrame",
17100
- "fullFrame",
17101
- "fullFrameBoxed",
17102
- "faceCrop",
17103
- "plateCrop",
17104
- "keyFrame",
17105
- "keyFrameSmall",
17106
- "thumbnailSmall"
17107
- ]);
17108
- var MediaFileSchema = object({
17109
- key: string(),
17110
- kind: MediaFileKindEnum,
17111
- base64: string(),
17112
- sizeBytes: number(),
17113
- timestamp: number()
17105
+ /** A camera detection zone — pure geometry/identity. */
17106
+ var ZoneSchema = object({
17107
+ id: string(),
17108
+ name: string(),
17109
+ kind: ZoneKindEnum.default("polygon"),
17110
+ /** Polygon vertices, fraction of frame (0–1). */
17111
+ polygon: array(PolygonPointSchema).readonly(),
17112
+ /** Visual color for UI rendering. */
17113
+ color: string().default("#3b82f6")
17114
17114
  });
17115
17115
  /**
17116
- * One media row WITHOUT its bytes.
17116
+ * Zones capability per-camera CRUD over polygon detection zones.
17117
17117
  *
17118
- * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
17119
- * 140 s track), and a client that renders tiles from the media data plane needs
17120
- * to know only WHAT EXISTS the bytes then arrive per tile, lazily, over HTTP
17121
- * with an immutable cache, instead of all at once inside a tRPC response that
17122
- * blocks the whole view.
17118
+ * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
17119
+ * to per-device settings and mirrors into the `zones` device-state
17120
+ * slice on every mutation, so downstream consumers can subscribe via
17121
+ * `dev.state.zones.onChanged`.
17123
17122
  *
17124
- * `sizeBytes` is carried because it is what lets a client decide between the
17125
- * stored blob and a `?variant=thumb` rendering without fetching either.
17123
+ * The cap surface only handles geometry + identity; filtering
17124
+ * behaviour (per-class, include/exclude, threshold) lives in the
17125
+ * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
17126
+ * `capabilities/schemas/zone-rule.js`.
17126
17127
  */
17127
- var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
17128
+ var zonesCapability = {
17129
+ name: "zones",
17130
+ scope: "device",
17131
+ mode: "singleton",
17132
+ deviceTypes: [DeviceType.Camera],
17133
+ methods: {
17134
+ listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
17135
+ addZone: method(object({
17136
+ deviceId: number(),
17137
+ zone: ZoneSchema
17138
+ }), _void(), {
17139
+ kind: "mutation",
17140
+ auth: "admin"
17141
+ }),
17142
+ removeZone: method(object({
17143
+ deviceId: number(),
17144
+ zoneId: string()
17145
+ }), _void(), {
17146
+ kind: "mutation",
17147
+ auth: "admin"
17148
+ }),
17149
+ updateZone: method(object({
17150
+ deviceId: number(),
17151
+ zone: ZoneSchema
17152
+ }), _void(), {
17153
+ kind: "mutation",
17154
+ auth: "admin"
17155
+ })
17156
+ },
17157
+ /**
17158
+ * Runtime-state slice — the live zone catalogue mirrored by the
17159
+ * orchestrator on every CRUD mutation. Consumers read via
17160
+ * `device.state.zones.value` / `.watch(...)` without round-tripping
17161
+ * the cap, and the codegen DeviceProxy auto-wires the reactive
17162
+ * handle. Slice shape is `{ zones: Zone[] }` so future extensions
17163
+ * (e.g. zone groupings) can sit alongside the polygon list.
17164
+ */
17165
+ runtimeState: object({ zones: array(ZoneSchema).readonly() }),
17166
+ /**
17167
+ * 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.
17168
+ *
17169
+ * See `RuntimeStateDurability`. Enforced by
17170
+ * `scripts/check-runtime-state-durability.ts`.
17171
+ */
17172
+ durability: "restored"
17173
+ };
17128
17174
  /**
17129
- * The MACRO tier of an annotation — a CLOSED set.
17175
+ * pipeline-analytics device-scoped wrapper cap. Refines raw
17176
+ * per-frame detections emitted by the pipeline runner into tracked
17177
+ * objects, per-kind event collections (motion / object / audio), and
17178
+ * persisted media. Owns the post-detection domain end-to-end:
17130
17179
  *
17131
- * This is what the exported detector predicts, so a typo here is a new class
17132
- * with one example in it. `label` and `subLabel` are open strings by contrast:
17133
- * the whole point of the page is teaching the model things it does not know
17134
- * yet, and constraining that vocabulary would make it useless.
17180
+ * runner emits PipelineInferenceResult
17181
+ * (event bus)
17182
+ * pipeline-analytics subscriber
17183
+ * SORT tracker + zone engine + state analyzer + event emitter
17184
+ * → three DB collections (one per kind), one FS media tree, one
17185
+ * unified event emitter (FrameTracked + TrackStarted/Ended +
17186
+ * DetectionEvent on bus)
17135
17187
  *
17136
- * A macro class is NEVER a label. The provider refuses a write whose `label` or
17137
- * `subLabel` is one of these values, in any casing, because once `person`
17138
- * exists in both tiers "every person box" stops being answerable without
17139
- * knowing every string anyone ever typed — and the damage is retroactive.
17188
+ * Pure subscriber model. No `processFrame` cap method the runner
17189
+ * already publishes the raw frame on the bus. The cap surface is
17190
+ * only QUERIES + per-device settings, bound on/off via
17191
+ * `device-manager.setWrapperActive`. `defaultActive: true` because
17192
+ * every camera with a detection pipeline wants its raw detections
17193
+ * refined; operators opt out per-device via BindingsTab when needed.
17194
+ *
17195
+ * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
17196
+ * (per-device surface) and `track-trail` caps — see P11 cleanup.
17140
17197
  */
17141
- var RetrainMacroClassSchema = _enum([
17198
+ var TrackStateSchema = _enum([
17199
+ "new",
17200
+ "entered",
17201
+ "left",
17202
+ "moving",
17203
+ "idle"
17204
+ ]);
17205
+ var EventKindSchema = _enum([
17206
+ "motion",
17207
+ "object",
17208
+ "audio"
17209
+ ]);
17210
+ /**
17211
+ * Spatial filter for `listTracks` — the rect + polygon variants of the shared
17212
+ * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
17213
+ * of the camera frame (top-left origin), matching the drawing-plane editor.
17214
+ */
17215
+ var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
17216
+ /** Closed icon vocabulary so clients render a known glyph per kind. */
17217
+ var EventKindIconSchema = _enum([
17218
+ "motion",
17219
+ "audio",
17142
17220
  "person",
17143
17221
  "vehicle",
17144
17222
  "animal",
17223
+ "door",
17224
+ "pir",
17225
+ "smoke",
17226
+ "water",
17227
+ "button",
17145
17228
  "package",
17146
- "face",
17147
- "plate"
17229
+ "generic"
17148
17230
  ]);
17149
- /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
17150
- var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
17151
- /** Did a human draw this box, or did the assist propose it? */
17152
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
17153
- /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
17154
- var RetrainBboxSchema = object({
17155
- x: number(),
17156
- y: number(),
17157
- w: number(),
17158
- h: number()
17231
+ var EventKindCategorySchema = _enum([
17232
+ "motion",
17233
+ "audio",
17234
+ "detection",
17235
+ "sensor",
17236
+ "control",
17237
+ "custom",
17238
+ "package"
17239
+ ]);
17240
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
17241
+ var EventKindLevelSchema = _enum(["macro", "sub"]);
17242
+ var EventKindDescriptorSchema = object({
17243
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
17244
+ kind: string(),
17245
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
17246
+ labelKey: string(),
17247
+ /** English fallback label (kept for clients that don't translate). */
17248
+ label: string(),
17249
+ /** Hex color for timeline/legend rendering. */
17250
+ color: string(),
17251
+ /** Dictionary id → lucide component on the UI side. */
17252
+ iconId: string(),
17253
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
17254
+ icon: EventKindIconSchema,
17255
+ category: EventKindCategorySchema,
17256
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
17257
+ parentKind: string().nullable(),
17258
+ /** Derived from `parentKind`, explicit for the client tree. */
17259
+ level: EventKindLevelSchema,
17260
+ /** Which cap + device contributes this kind. For built-ins the camera
17261
+ * itself; for sensor kinds the LINKED source device. */
17262
+ source: object({
17263
+ capName: string(),
17264
+ deviceId: number()
17265
+ })
17159
17266
  });
17160
- /**
17161
- * One annotated subject.
17162
- *
17163
- * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
17164
- * (letterboxed root / zone-cropped package / subject-cropped classifier) are
17165
- * derived from it at export and never stored — storing them is how one feature
17166
- * space ends up holding two crops of the same subject (D52).
17167
- */
17168
- var RetrainAnnotationSchema = object({
17169
- id: string(),
17170
- trackId: string(),
17267
+ /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
17268
+ var EventKindsForDeviceSchema = object({
17171
17269
  deviceId: number(),
17172
- /** The COPY in retrain storage — never the source track's media key. */
17173
- mediaKey: string(),
17174
- bbox: RetrainBboxSchema,
17175
- macroClass: RetrainMacroClassSchema,
17176
- label: string().optional(),
17177
- subLabel: string().optional(),
17178
- kind: RetrainAnnotationKindSchema,
17179
- source: RetrainAnnotationSourceSchema,
17180
- /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
17181
- assistModelId: string().optional(),
17182
- assistScore: number().optional(),
17183
- exportedInBatch: string().optional(),
17184
- createdAt: number()
17185
- });
17186
- /** The write form — the server owns `id`, `createdAt` and the frame binding. */
17187
- var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
17188
- id: true,
17189
- trackId: true,
17190
- deviceId: true,
17191
- mediaKey: true,
17192
- createdAt: true,
17193
- exportedInBatch: true
17270
+ kinds: array(EventKindDescriptorSchema).readonly()
17194
17271
  });
17195
- /** A track sitting in `staging`, with everything the worklist needs to rank it. */
17196
- var RetrainTrackSchema = object({
17197
- trackId: string(),
17272
+ var SensorEventSchema = object({
17273
+ id: string(),
17274
+ /** The CAMERA the event is attributed to (a sensor linked to N cameras
17275
+ * yields N rows, one per camera). */
17198
17276
  deviceId: number(),
17199
- className: string(),
17200
- label: string().optional(),
17201
- firstSeen: number(),
17202
- lastSeen: number(),
17203
- /** How many frames the dataset already holds from this track. */
17204
- frameCount: number().int(),
17205
- /** How many subjects have been annotated on those frames. `0` with
17206
- * `frameCount: 0` is exactly "staging, still to work". */
17207
- annotationCount: number().int()
17277
+ /** The linked sensor device whose state changed. */
17278
+ sourceDeviceId: number(),
17279
+ /** Event kind id — matches an `EventKindDescriptor.kind`. */
17280
+ kind: string(),
17281
+ /** Snapshot of the sensor cap's runtime-state slice at the change. */
17282
+ value: record(string(), unknown()).nullable(),
17283
+ timestamp: number()
17208
17284
  });
17209
- /** A frame the picker may offer — an index row, no blob was read to produce it. */
17210
- var RetrainFrameCandidateSchema = object({
17211
- mediaKey: string(),
17212
- kind: MediaFileKindEnum,
17285
+ var TrackPositionSchema = object({
17286
+ x: number(),
17287
+ y: number(),
17213
17288
  timestamp: number(),
17214
- sizeBytes: number().int(),
17215
- /** A copy of this original already exists — selecting it is free and cannot
17216
- * fail, whatever became of the original. */
17217
- copied: boolean()
17218
- });
17219
- /** A frame the dataset OWNS: bytes copied at selection time. */
17220
- var RetrainFrameSchema = object({
17221
- frameId: string(),
17222
- deviceId: number(),
17223
- trackId: string(),
17224
- /** Provenance only. It may already point at nothing — that is expected. */
17225
- sourceMediaKey: string(),
17226
- sourceKind: MediaFileKindEnum,
17227
- sizeBytes: number().int(),
17228
- width: number().int(),
17229
- height: number().int(),
17230
- copiedAt: number()
17231
- });
17232
- /** Why a copy-on-select could not be honoured — named, never a silent skip. */
17233
- var RetrainCopyRefusalSchema = _enum([
17234
- "source-missing",
17235
- "unreadable-image",
17236
- "write-failed"
17237
- ]);
17238
- var RetrainFrameSelectionSchema = object({
17239
- copied: array(RetrainFrameSchema).readonly(),
17240
- refused: array(object({
17241
- sourceMediaKey: string(),
17242
- reason: RetrainCopyRefusalSchema
17243
- })).readonly()
17289
+ bbox: BoundingBoxSchema
17244
17290
  });
17245
- var RetrainFrameListSchema = object({
17246
- candidates: array(RetrainFrameCandidateSchema).readonly(),
17247
- copies: array(RetrainFrameSchema).readonly(),
17248
- /** What the page pre-selects the native key frame when one survives. */
17249
- autoPickMediaKey: string().optional()
17291
+ var TrackSnapshotSchema = object({
17292
+ timestamp: number(),
17293
+ position: TrackPositionSchema,
17294
+ /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
17295
+ mediaKey: string()
17250
17296
  });
17251
- /** What the operator asked the assist to look for. */
17252
- var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
17253
- kind: literal("package"),
17254
- zone: RetrainBboxSchema.optional()
17255
- }), object({
17256
- kind: literal("objects"),
17257
- modelId: string(),
17258
- minScore: number().optional()
17259
- })]);
17260
17297
  /**
17261
- * The assist's answer a discriminated union, because "the model saw nothing"
17262
- * and "this node cannot run that model" lead to different next moves and a
17263
- * nullable result cannot tell them apart.
17298
+ * Normalized 0..1 trajectory envelope (min/max over every position bbox,
17299
+ * divided by the track's detection-frame dims), computed at persist time.
17300
+ * Absent when the frame dims were unknown when the track was persisted
17301
+ * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
17264
17302
  */
17265
- var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
17266
- kind: literal("proposed"),
17267
- modelId: string(),
17268
- stepId: string(),
17269
- minScore: number(),
17270
- /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
17271
- proposals: array(RetrainAnnotationDraftSchema).readonly(),
17272
- /** Returned by the runner but removed by the threshold. */
17273
- belowThreshold: number().int()
17274
- }), object({
17275
- kind: literal("refused"),
17276
- /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
17277
- reason: string(),
17278
- detail: string().optional()
17279
- })]);
17280
- /** The outcome of a lifecycle move owned by the retrain page. */
17281
- var RetrainTransitionResultSchema = object({
17282
- trackId: string(),
17283
- /** Where the track ended up, whatever happened. */
17284
- retrainStatus: RetrainStatusSchema,
17285
- /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
17286
- changed: boolean(),
17287
- reason: _enum([
17288
- "unknown-track",
17289
- "no-frames-copied",
17290
- "not-staging",
17291
- "not-trained",
17292
- "unchanged"
17293
- ]).optional()
17303
+ var TrackEnvelopeSchema = object({
17304
+ minX: number(),
17305
+ minY: number(),
17306
+ maxX: number(),
17307
+ maxY: number()
17294
17308
  });
17295
- var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
17296
- var MAX_EVENT_QUERY_LIMIT = 5e3;
17297
- var DeviceEventQueryInput = object({
17298
- deviceId: number(),
17299
- since: number().optional(),
17300
- until: number().optional(),
17301
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
17302
- /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
17303
- * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
17304
- * exact behaviour. Callers may omit this field — the store defaults to
17305
- * `full` when not provided. */
17306
- projection: _enum(["full", "slim"]).optional()
17307
- });
17308
- var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
17309
- var RecentTracksQueryInput = object({
17310
- /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
17311
- deviceIds: array(number()),
17312
- /** Window lower bound on `lastSeen` (inclusive). */
17313
- since: number().optional(),
17314
- /** Window upper bound on `lastSeen` (inclusive). */
17315
- until: number().optional(),
17316
- /** Page size. Default 200, max 1000. */
17317
- limit: number().int().min(1).max(1e3).default(200),
17318
- /** Opaque continuation cursor from a previous page's `nextCursor`.
17319
- * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
17320
- cursor: string().optional(),
17321
- /** See {@link TrackProjectionSchema}. Default `full`. */
17322
- projection: TrackProjectionSchema.optional(),
17323
- /** Include stationary-promoted rows (parked objects). Default false: the
17324
- * feed lists passages; parking records live on the stationary registry. */
17325
- includeStationary: boolean().optional()
17326
- });
17327
- var RecentTracksPageSchema = object({
17328
- /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
17329
- tracks: array(TrackSchema).readonly(),
17330
- /** Cursor for the next page, or null when this page is the last. */
17331
- nextCursor: string().nullable()
17332
- });
17333
- var LIST_GROUPS_DEFAULT_LIMIT = 40;
17334
- var LIST_GROUPS_MAX_LIMIT = 100;
17335
- var AnalyticsGroupRecordSchema = object({
17336
- id: string(),
17337
- deviceId: number().int(),
17338
- openedAt: number().int(),
17339
- closedAt: number().int(),
17340
- timestamp: number().int(),
17341
- memberCount: number().int(),
17342
- memberTrackIds: array(string()).readonly(),
17343
- className: string(),
17344
- classes: array(string()).readonly(),
17345
- /** Relative event-media path, or null when the group has no picture yet. */
17346
- mediaUrl: string().nullable(),
17347
- singleton: boolean()
17348
- });
17349
- var AnalyticsGroupMemberSchema = object({
17350
- trackId: string(),
17351
- deviceId: number().int(),
17352
- className: string(),
17353
- firstSeen: number().int(),
17354
- lastSeen: number().int(),
17355
- mediaUrl: string().nullable()
17356
- });
17357
- var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
17358
- var ListGroupsQueryInput = object({
17359
- /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
17360
- deviceIds: array(number()),
17361
- /** Window lower bound on `closedAt` (inclusive). */
17362
- since: number().optional(),
17363
- /** Window upper bound on `openedAt` (inclusive). */
17364
- until: number().optional(),
17365
- limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
17366
- /** Opaque continuation cursor from a previous page's `nextCursor`. */
17367
- cursor: string().optional()
17368
- });
17369
- var ListGroupsPageSchema = object({
17370
- groups: array(AnalyticsGroupRecordSchema).readonly(),
17371
- nextCursor: string().nullable()
17372
- });
17373
- var KeyEventQueryInput = object({
17374
- deviceId: number(),
17375
- /** Window lower bound (track firstSeen ≥ since). */
17376
- since: number(),
17377
- /** Window upper bound (track firstSeen ≤ until). */
17378
- until: number(),
17379
- limit: number().int().min(1).max(200).default(50),
17380
- /** Drop tracks scoring below this importance. */
17381
- minImportance: number().min(0).max(1).optional(),
17382
- /** Restrict to a single class (e.g. 'person'). */
17383
- classFilter: string().optional()
17384
- });
17385
- var KeyEventSchema = object({
17386
- /** The representative event id (the track's best ObjectEvent, else its trackId). */
17387
- id: string(),
17388
- trackId: string(),
17389
- /** Track start time (firstSeen). */
17390
- timestamp: number(),
17391
- className: string(),
17392
- ...TieredLabelFields,
17393
- importance: number(),
17394
- /** Highest-confidence ObjectEvent id for the track (empty when none). */
17395
- bestEventId: string(),
17396
- /** Track lifetime in ms (lastSeen - firstSeen). */
17397
- windowMs: number().optional(),
17398
- ...TrackFlagFields,
17399
- ...TrackRetrainFields
17400
- });
17401
- object({
17402
- trackId: string(),
17403
- className: string(),
17404
- confidence: number(),
17405
- bbox: BoundingBoxSchema,
17406
- zones: array(string()).readonly(),
17407
- state: TrackStateSchema
17408
- });
17409
- var OverlayDetectionSchema = looseObject({
17410
- id: string(),
17411
- kind: _enum(["first-level", "detail"]),
17412
- macroClass: string(),
17413
- score: number(),
17414
- bbox: object({
17415
- x: number(),
17416
- y: number(),
17417
- width: number(),
17418
- height: number()
17419
- }),
17420
- labels: array(looseObject({
17421
- label: string(),
17422
- score: number()
17423
- })).readonly(),
17424
- parentId: string().optional()
17425
- });
17426
- var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
17427
- var SearchObjectEventsInput = object({
17428
- text: string(),
17429
- deviceId: number().optional(),
17430
- since: number().optional(),
17431
- until: number().optional(),
17432
- classFilter: string().optional(),
17433
- limit: number().default(50),
17434
- minScore: number().min(0).max(1).default(.2)
17435
- });
17436
- var TrackCascadeCountsSchema = object({
17437
- /** Persisted track roots deleted (authoritative). */
17438
- tracks: number().int(),
17439
- /** Object events removed with their tracks (best-effort; see note above). */
17440
- events: number().int(),
17441
- /** Track/face/plate-owned media removed (best-effort). Never identity media. */
17442
- media: number().int(),
17443
- /** Unassigned (non-enrolled) face reads removed (best-effort). */
17444
- faces: number().int(),
17445
- /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
17446
- plates: number().int(),
17447
- /** Per-track CLIP search vectors removed (best-effort). */
17448
- embeddings: number().int(),
17449
- /** Group membership + group rows removed with their last member (best-effort). */
17450
- groups: number().int()
17451
- });
17452
- /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
17453
- var DiskReconcileCountsSchema = object({
17454
- mediaDropped: number().int(),
17455
- tracks: number().int(),
17456
- events: number().int()
17457
- });
17458
- /** Event-store footprint for one camera. */
17459
- var EventStoreDeviceFootprintSchema = object({
17460
- deviceId: number(),
17461
- /** Persisted event rows (motion + object + audio) for the camera. */
17462
- rows: number().int(),
17463
- /** Event-owned media bytes on disk for the camera. */
17464
- bytes: number().int()
17465
- });
17466
- /** Aggregate event-store footprint: global totals + per-camera breakdown. */
17467
- var EventStoreFootprintSchema = object({
17468
- totalRows: number().int(),
17469
- totalBytes: number().int(),
17470
- devices: array(EventStoreDeviceFootprintSchema).readonly()
17471
- });
17472
- /** Per-kind counts returned by the event-prune / device-delete mutations. */
17473
- var EventPruneCountsSchema = object({
17474
- motion: number().int(),
17475
- object: number().int(),
17476
- audio: number().int()
17309
+ /**
17310
+ * Row projection for track list queries. `full` (default) returns the
17311
+ * complete Track including the frame-rate `positions[]` history and the
17312
+ * `snapshots[]` references — megabytes across a page of tracks. `slim`
17313
+ * keeps every scalar the list surfaces actually render (ids, class(es),
17314
+ * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
17315
+ * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
17316
+ * `snapshots` as EMPTY arrays detail views re-fetch the full row via
17317
+ * `getTrack`. Mirrors the event-store `projection` convention
17318
+ * (`getObjectEvents` et al.).
17319
+ */
17320
+ var TrackProjectionSchema = _enum(["full", "slim"]);
17321
+ /**
17322
+ * One audio-classification label heard on the track's camera while the
17323
+ * track was alive, aggregated per label. An "episode" is one persisted
17324
+ * audio event (the confident-classification path: score the device's
17325
+ * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
17326
+ * one 32 ms inference chunk, so counts stay human-scaled.
17327
+ */
17328
+ var TrackAudioLabelSchema = object({
17329
+ label: string(),
17330
+ /** Highest classification score observed across the label's episodes. */
17331
+ peakScore: number(),
17332
+ /** Number of coalesced audio-event episodes carrying this label. */
17333
+ count: number(),
17334
+ firstAt: number(),
17335
+ lastAt: number()
17477
17336
  });
17478
17337
  /**
17479
- * Re-embed stored tracks from their key frames.
17338
+ * How a track was produced. `pipeline` (default / absent) = the spatial
17339
+ * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
17340
+ * no positions, a single snapshot, and no bbox trajectory at all:
17480
17341
  *
17481
- * The reason this is an operator-callable method and not a migration script:
17482
- * every knob that decides what a vector MEANS encoder model, crop margin,
17483
- * squaring is only changeable if the existing vectors can be regenerated.
17484
- * Mixing feature spaces in one index makes cosine scores incomparable, and the
17485
- * symptom is a quality regression with no visible cause.
17342
+ * - `sensor` a linked sensor/control device state change.
17343
+ * - `audio` an audio event on the camera itself that was anomalous for
17344
+ * THAT camera, loud, and heard while nothing visual was happening (D62).
17345
+ *
17346
+ * The spatial subsystems (tracker association, occupancy count, re-id /
17347
+ * embedding, resurrection) MUST skip every synthetic source. Test for that
17348
+ * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
17349
+ * check silently readmits every source added after it was written.
17486
17350
  */
17487
- var RebuildObjectEmbeddingsInput = object({
17488
- /** Restrict to one camera. Omit for the whole fleet. */
17489
- deviceId: number().optional(),
17490
- since: number().optional(),
17491
- until: number().optional(),
17492
- /** Stop after this many tracks; the result reports whether more remain. */
17493
- maxTracks: number().int().positive().optional(),
17494
- /**
17495
- * Run every embedding on THIS node instead of round-robining the fleet.
17496
- *
17497
- * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
17498
- * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
17499
- * calling it that would pin the rebuild REQUEST itself to that node — the
17500
- * rebuild orchestration lives on the hub, and only the per-track step runs
17501
- * remotely. This field is data; the per-track pin is applied inside.
17502
- *
17503
- * Absent ⇒ round-robin over every online node whose runner can serve the
17504
- * pinned model.
17505
- */
17506
- executeOnNodeId: string().optional(),
17507
- /**
17508
- * Milliseconds to wait between tracks; omit for the built-in default, `0` to
17509
- * run flat out.
17510
- *
17511
- * A rebuild is bulk maintenance on hub-main's single thread. Measured
17512
- * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
17513
- * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
17514
- * force is logged at start and finish so a deliberately slow pass reads
17515
- * differently from a stalled one.
17516
- */
17517
- pacingMs: number().int().nonnegative().optional()
17518
- });
17351
+ var TrackSourceSchema = _enum([
17352
+ "pipeline",
17353
+ "sensor",
17354
+ "audio"
17355
+ ]);
17519
17356
  /**
17520
- * Result of emptying the CLIP index.
17357
+ * Where a track sits in the RETRAIN lifecycle (D81).
17521
17358
  *
17522
- * The clean slate before a policy change: a new crop margin or encoder model
17523
- * leaves two feature spaces in one index whose cosine scores are not
17524
- * comparable, so wiping and rebuilding is the only way to be sure every vector
17525
- * means the same thing.
17359
+ * - `none` never marked, or un-marked. Evictable.
17360
+ * - `staging` the operator wants this track as training material and has not
17361
+ * finished with it. **This is the only state retention holds**: the track and
17362
+ * everything it owns (object events, crops, keyframes, CLIP vector) survive
17363
+ * the device's age window.
17364
+ * - `trained` — the retrain page has taken what it needed. The frames it chose
17365
+ * were COPIED into the retrain dataset at selection time, so the dataset no
17366
+ * longer depends on the track's media and the track becomes EVICTABLE again.
17367
+ * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
17368
+ * a deliberate action of the retrain page, not a side effect of a checkbox.
17369
+ *
17370
+ * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
17371
+ * the store's filter language has only positive equality and `whereIn` — no
17372
+ * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
17373
+ * would make the entire pre-column history immortal in one deploy.
17526
17374
  */
17527
- var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
17375
+ var RetrainStatusSchema = _enum([
17376
+ "none",
17377
+ "staging",
17378
+ "trained"
17379
+ ]);
17528
17380
  /**
17529
- * Acknowledgement that a rebuild STARTED.
17381
+ * Per-track OPERATOR flags set by hand from the admin UI or the viewer, never
17382
+ * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
17383
+ * so the two surfaces cannot drift.
17530
17384
  *
17531
- * The pass costs ~1s per track 45 minutes for a 2,600-track fleet so it
17532
- * runs detached and this returns immediately. Waiting for it made the client
17533
- * time out while the work carried on server-side, which is the worst of both:
17534
- * no result and no way to know it was still going. Poll
17535
- * `getObjectEmbeddingRebuildStatus` for progress.
17536
- */
17537
- var RebuildObjectEmbeddingsResultSchema = object({
17538
- started: boolean(),
17539
- /** True when a pass was already running; the new request is ignored. */
17540
- alreadyRunning: boolean()
17541
- });
17542
- var RebuildStatusSchema = object({
17543
- running: boolean(),
17544
- scanned: number(),
17545
- rebuilt: number(),
17546
- /** Tracks whose key frame is gone nothing to re-embed from. */
17547
- missingKeyFrame: number(),
17548
- /** Tracks with no usable detection box. */
17549
- missingBbox: number(),
17550
- /**
17551
- * Tracks an executing node REFUSED rather than broke on — an unreadable key
17552
- * frame, a step that threw. Separate from `failed` because the remedy is
17553
- * different, and because a whole camera silently contributing zero vectors
17554
- * is the shape of failure a rebuild must never hide.
17555
- */
17556
- notRunnable: number(),
17385
+ * **Absent false.** A track that has never been touched omits the field; an
17386
+ * explicitly un-flagged track carries `false`. Legacy rows written before the
17387
+ * columns existed read as absent, and a consumer that needs a boolean should say
17388
+ * `flag === true`, not `flag !== false`.
17389
+ *
17390
+ * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
17391
+ * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
17392
+ * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
17393
+ * `trained` track reports `false` while refusing both writes. The boolean is
17394
+ * kept because three surfaces drive a toggle off it; anything that needs to tell
17395
+ * "never marked" from "already trained" must read `retrainStatus`.
17396
+ *
17397
+ * `debug` does NOT pin; it is attention, not durability.
17398
+ *
17399
+ * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
17400
+ * A favourited track is skipped by retention the same way `staging` is, but
17401
+ * it does not enter `none|staging|trained` and has no staging budget.
17402
+ */
17403
+ var TrackFlagFields = {
17404
+ /** Operator marked this track as training material — i.e. `retrainStatus` is
17405
+ * `'staging'`. */
17406
+ markForTrain: boolean().optional(),
17407
+ /** Operator marked this track for diagnostic attention. */
17408
+ debug: boolean().optional(),
17409
+ /** Operator favourited this track. Pins it against pruning. */
17410
+ favourited: boolean().optional()
17411
+ };
17412
+ /**
17413
+ * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
17414
+ * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
17415
+ * write patch, and the status is not something the toggle sets — it is what the
17416
+ * toggle's boolean is derived from. Absent on an in-RAM track never touched;
17417
+ * always present on a persisted row (the column default materialises `'none'`).
17418
+ */
17419
+ var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
17420
+ /**
17421
+ * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
17422
+ * one flag can never clear the other — the toggles are independent and are
17423
+ * driven from three surfaces that do not know about each other.
17424
+ */
17425
+ var TrackFlagsPatchSchema = object(TrackFlagFields);
17426
+ /**
17427
+ * The resolved flag state after a write. Both fields are REQUIRED here (absent
17428
+ * collapses to `false`) so a caller can drive a toggle's checked state off the
17429
+ * mutation result without a re-fetch.
17430
+ */
17431
+ var TrackFlagsSchema = object({
17432
+ trackId: string(),
17433
+ markForTrain: boolean(),
17434
+ debug: boolean(),
17435
+ favourited: boolean(),
17436
+ /** The lifecycle state the boolean was derived from. Required here (unlike on
17437
+ * a track row) because this shape is only ever produced by the write body,
17438
+ * which always knows it — and a surface that has just written needs to render
17439
+ * `trained` without a re-fetch. */
17440
+ retrainStatus: RetrainStatusSchema
17441
+ });
17442
+ union([literal(1), literal(2)]);
17443
+ /**
17444
+ * WHO decided a label, and when. Carried per tier so a value can be traced to
17445
+ * the step and model that produced it — which is what makes the write rule
17446
+ * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
17447
+ * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
17448
+ *
17449
+ * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
17450
+ * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
17451
+ * `migration:4g` for a value the 4g migration moved from the single-slot era —
17452
+ * that value has no provenance, and the write rule lets ANY properly-attributed
17453
+ * write of the same tier replace it regardless of score.
17454
+ */
17455
+ var LabelAttributionSchema = object({
17456
+ stepId: string(),
17457
+ modelId: string().optional(),
17458
+ decidedAt: number(),
17557
17459
  /**
17558
- * The pass stopped because NO node could serve the pinned model.
17460
+ * The GALLERY id behind a recognised tier-2 label a face-gallery
17461
+ * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
17559
17462
  *
17560
- * Distinct from `notRunnable` on purpose: that one says "this track was
17561
- * refused", this one says "the cluster cannot do this work at all" — every
17562
- * candidate node either lacks the `clip-embedding` step, lacks a build of the
17563
- * pinned model for its engine format, or dropped out. The remedy is a model /
17564
- * engine change, not a per-camera one. Non-zero here always comes with
17565
- * `complete: false`.
17463
+ * The text alone is a DISPLAY NAME, and a display name is renameable: a
17464
+ * notification rule authored on "Gianluca" stopped matching the moment the
17465
+ * operator fixed the spelling in the gallery, and nothing said so. The id is
17466
+ * the thing that does not move, so it is what a rule matches on
17467
+ * (`NcConditions.identities`) and the text is what a human is shown.
17468
+ *
17469
+ * Absent when the label names no gallery row — a plate the OCR read but no
17470
+ * vehicle claims, a sub-class, a species, any tier-1 value.
17566
17471
  */
17567
- noCapableNode: number(),
17568
- failed: number(),
17569
- /** Set once a pass ends: true only when EVERYTHING was covered. */
17570
- complete: boolean().nullable(),
17571
- startedAtMs: number().nullable(),
17572
- finishedAtMs: number().nullable(),
17573
- /** Present when the pass ended by throwing. */
17574
- error: string().nullable()
17472
+ identityId: string().optional()
17575
17473
  });
17576
- DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
17577
- deviceId: number(),
17578
- trackId: string()
17579
- }), TrackSchema.nullable()), method(object({
17580
- deviceId: number(),
17581
- since: number().optional(),
17582
- until: number().optional(),
17583
- limit: number().optional(),
17584
- /** Spatial filter — only tracks whose trajectory intersects the zone
17585
- * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
17586
- * envelope columns, then precisely tested per position. Tracks with
17587
- * an unknown envelope (no frame dims at persist time) always match. */
17588
- zone: TrackZoneFilterSchema.optional(),
17589
- /** See {@link TrackProjectionSchema}. Default `full` (backward
17590
- * compatible omitting the field keeps today's exact behaviour). */
17591
- projection: TrackProjectionSchema.optional(),
17592
- /** Include stationary-promoted rows (parked objects handed to the
17593
- * stationary registry). Default false: the timeline lists passages,
17594
- * not parking records (operator decision, 2026-08-15). */
17595
- includeStationary: boolean().optional()
17596
- }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
17597
- deviceId: number(),
17598
- groupId: string().min(1)
17599
- }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
17600
- kind: "mutation",
17601
- auth: "admin"
17602
- }), 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({
17603
- deviceId: number(),
17604
- since: number().optional(),
17605
- until: number().optional(),
17606
- kinds: array(string()).optional(),
17607
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
17608
- }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
17609
- deviceId: number(),
17610
- since: number(),
17611
- until: number(),
17612
- bucketMs: number().int().positive()
17613
- }), array(object({
17614
- bucketStart: number(),
17615
- motion: number().int(),
17616
- object: number().int(),
17617
- audio: number().int()
17618
- })).readonly()), method(object({
17619
- deviceId: number(),
17620
- cutoffMs: number()
17621
- }), object({
17622
- motion: number().int(),
17623
- object: number().int(),
17624
- audio: number().int()
17625
- }), {
17626
- kind: "mutation",
17627
- auth: "admin"
17628
- }), method(object({
17629
- deviceId: number(),
17630
- cutoffMs: number()
17631
- }), TrackCascadeCountsSchema, {
17632
- kind: "mutation",
17633
- auth: "admin"
17634
- }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
17635
- kind: "mutation",
17636
- auth: "admin"
17637
- }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
17638
- kind: "mutation",
17639
- auth: "admin"
17640
- }), method(object({
17641
- deviceId: number(),
17642
- trackIds: array(string()).min(1)
17643
- }), object({
17644
- deleted: number().int(),
17645
- failed: array(string()).readonly()
17646
- }), {
17647
- kind: "mutation",
17648
- auth: "admin"
17649
- }), method(object({
17650
- /** Log/audit scope only — the trackId is globally unique on its own. */
17474
+ /**
17475
+ * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
17476
+ * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
17477
+ * track and its events always answer the same question the same way.
17478
+ *
17479
+ * Two scalar columns, not an array: every consumer wants "the coarse one" or
17480
+ * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
17481
+ * is tier 2, and each carries its own score + attribution.
17482
+ *
17483
+ * **Reading it.** What a human should be shown is `subLabel ?? label` — the
17484
+ * finest thing known. Before 4g the single `label` column held the finest
17485
+ * value, so a consumer that has not been updated reads the tier-1 slot and
17486
+ * shows nothing on a species-only row; that is why the migration puts every
17487
+ * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
17488
+ * and why the read surfaces were changed in the same train.
17489
+ *
17490
+ * **Writing it.** The slots are independent, which is the whole point: a
17491
+ * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
17492
+ * migratorius`), so fineness cannot regress by construction. Within a tier the
17493
+ * higher score wins. One rule, one implementation — see
17494
+ * `pipeline/label-tier.ts` in addon-post-analysis.
17495
+ */
17496
+ var TieredLabelFields = {
17497
+ /** Tier 1 the sub-class. See {@link LabelTierSchema}. */
17498
+ label: string().optional(),
17499
+ /** Confidence of the tier-1 value, as reported by the deciding step. */
17500
+ labelScore: number().optional(),
17501
+ /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
17502
+ labelMeta: LabelAttributionSchema.optional(),
17503
+ /** Tier 2 — the instance. See {@link LabelTierSchema}. */
17504
+ subLabel: string().optional(),
17505
+ /** Confidence of the tier-2 value, as reported by the deciding step. */
17506
+ subLabelScore: number().optional(),
17507
+ /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
17508
+ subLabelMeta: LabelAttributionSchema.optional()
17509
+ };
17510
+ /** Per-camera slice of a training-export estimate. */
17511
+ var TrainingExportDeviceTotalsSchema = object({
17651
17512
  deviceId: number(),
17513
+ tracks: number().int(),
17514
+ files: number().int(),
17515
+ bytes: number().int()
17516
+ });
17517
+ /**
17518
+ * What a training export WOULD contain. Computed from media index rows only —
17519
+ * no blob is read to produce this.
17520
+ */
17521
+ var TrainingExportSummarySchema = object({
17522
+ generatedAt: number(),
17523
+ trackCount: number().int(),
17524
+ fileCount: number().int(),
17525
+ byteCount: number().int(),
17526
+ /** More marked tracks exist than a single pass carries. */
17527
+ truncated: boolean(),
17528
+ devices: array(TrainingExportDeviceTotalsSchema).readonly()
17529
+ });
17530
+ var TrackSchema = object({
17652
17531
  trackId: string(),
17653
- flags: TrackFlagsPatchSchema
17654
- }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
17655
- kind: "query",
17656
- auth: "admin"
17657
- }), method(object({
17658
- olderThanMs: number(),
17659
- reason: OpsLogReasonSchema.optional()
17660
- }), EventPruneCountsSchema, {
17661
- kind: "mutation",
17662
- auth: "admin"
17663
- }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
17664
- kind: "mutation",
17665
- auth: "admin"
17666
- }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
17667
- kind: "mutation",
17668
- auth: "admin"
17669
- }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
17670
- kind: "mutation",
17671
- auth: "admin"
17672
- }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
17673
- kind: "mutation",
17674
- auth: "admin"
17675
- }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
17676
- kind: "mutation",
17677
- auth: "admin"
17678
- }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
17679
- kind: "mutation",
17680
- auth: "admin"
17681
- }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
17682
- kind: "query",
17683
- auth: "admin"
17684
- }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
17685
- kind: "query",
17686
- auth: "admin"
17687
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
17688
- kind: "query",
17689
- auth: "admin"
17690
- }), method(object({
17691
- /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
17692
- * `deviceId`, deliberately: `deviceId` would make this device-bound and
17693
- * route it at one camera's owner, and "every camera" would stop being
17694
- * expressible at all. */
17695
- deviceIds: array(number()).optional(),
17696
- limit: number().int().min(1).max(500).optional()
17697
- }), array(RetrainTrackSchema).readonly(), {
17698
- kind: "query",
17699
- auth: "admin"
17700
- }), method(object({ trackId: string() }), RetrainFrameListSchema, {
17701
- kind: "query",
17702
- auth: "admin"
17703
- }), method(object({
17704
17532
  deviceId: number(),
17705
- trackId: string(),
17706
- mediaKeys: array(string()).min(1)
17707
- }), RetrainFrameSelectionSchema, {
17708
- kind: "mutation",
17709
- auth: "admin"
17710
- }), method(object({
17533
+ className: string(),
17534
+ ...TieredLabelFields,
17535
+ producingDeviceName: string().optional(),
17536
+ /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
17537
+ source: TrackSourceSchema.optional(),
17538
+ firstSeen: number(),
17539
+ lastSeen: number(),
17540
+ /** Frame-rate position history (subject to maxPositionHistory cap). */
17541
+ positions: array(TrackPositionSchema).readonly(),
17542
+ /** Periodic snapshots at snapshotIntervalMs cadence (subject to
17543
+ * saveThumbnails policy). */
17544
+ snapshots: array(TrackSnapshotSchema).readonly(),
17545
+ /** Deduplicated zones the track has entered at least once. Zone IDS. */
17546
+ zonesVisited: array(string()).readonly(),
17547
+ /**
17548
+ * Human NAMES for {@link zonesVisited}, resolved at READ time against the
17549
+ * `zones` capability.
17550
+ *
17551
+ * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
17552
+ * and no card can render — so every free-text search surface was structurally
17553
+ * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
17554
+ * just returned nothing. Resolving here rather than in each client keeps ONE
17555
+ * derivation and costs the clients no extra call (the `zones` cap is
17556
+ * per-device, so a client-side resolve would be a per-camera fan-out on a
17557
+ * surface built to avoid exactly that).
17558
+ *
17559
+ * Resolved, never invented: a zone deleted since the track was written has no
17560
+ * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
17561
+ * two are not positionally aligned. Absent when the track visited no zone, or
17562
+ * when the zone catalogue could not be read.
17563
+ */
17564
+ zoneNames: array(string()).readonly().optional(),
17565
+ /** Deduplicated set of detector classes observed for this track over its
17566
+ * life (a track may be reclassified, e.g. person→vehicle). Absent on
17567
+ * legacy rows written before class accumulation shipped. */
17568
+ classes: array(string()).readonly().optional(),
17569
+ /** Cumulative normalized distance travelled (0..1 units = full frame width). */
17570
+ totalDistance: number(),
17571
+ state: TrackStateSchema,
17572
+ active: boolean(),
17573
+ /** Deterministic key-event importance score in [0,1] (server-computed at
17574
+ * track expiry, recomputed on late label). Absent on legacy rows written
17575
+ * before scoring shipped — consumers degrade to absence / compute-on-read. */
17576
+ importance: number().optional(),
17577
+ /** Id of the track's highest-confidence ObjectEvent (its representative
17578
+ * "best" frame). Absent when the track produced no object events. */
17579
+ bestEventId: string().optional(),
17580
+ /** Tag of the importance sub-signal that dominated the score
17581
+ * (identity|dwell|proximity|class|confidence|travel|zone). */
17582
+ importanceReason: string().optional(),
17583
+ /** Audio-classification labels heard on the camera during the track's
17584
+ * life (score ≥ device `classificationMinScore`), aggregated per label.
17585
+ * Absent on legacy rows / tracks with no confident audio. */
17586
+ audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
17587
+ /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
17588
+ * Populated from the persisted envelope columns on historical reads;
17589
+ * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
17590
+ envelope: TrackEnvelopeSchema.optional(),
17591
+ /**
17592
+ * A face DETECTOR found a face on this track — nothing more. It says the
17593
+ * detail plane produced a `face` detail; it does NOT say the face was
17594
+ * embedded, matched, above `minFacePx`, or that the recognizer was even
17595
+ * enabled. Set once and never cleared.
17596
+ *
17597
+ * **This exists so "face present but not recognised" is expressible.** A
17598
+ * recognised identity lands in `subLabel` (attributed to the face chain via
17599
+ * `subLabelMeta.stepId`), so before this field a track with an unmatched face
17600
+ * and a track with no face at all were byte-identical on the wire and no
17601
+ * surface could tell them apart. The read is `hasFace === true && subLabel
17602
+ * === undefined`.
17603
+ *
17604
+ * **Absent ≠ false.** Every row written before the column existed omits it,
17605
+ * and so does every server that predates the field — a consumer must test
17606
+ * `=== true` and render nothing otherwise, never infer "no face".
17607
+ */
17608
+ hasFace: boolean().optional(),
17609
+ /**
17610
+ * This track has a face row IN THE GALLERY: a crop **and** an embedding — a
17611
+ * face an operator could ASSIGN to an identity.
17612
+ *
17613
+ * The STRICT twin of {@link hasFace}, and the pair only earns its keep
17614
+ * because the two disagree. `hasFace` is stamped at the TOP of the face
17615
+ * branch, before every gate, and means no more than "a face detector produced
17616
+ * a face detail". This one is stamped at the single moment the gallery row
17617
+ * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
17618
+ * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
17619
+ * candidate gate, the imageless-track drop (no crop was ever captured) and
17620
+ * the crop-store drop. Everything between the detector and that insert can
17621
+ * legitimately refuse the face, so a flag written any earlier promises the
17622
+ * operator something to assign and delivers nothing.
17623
+ *
17624
+ * **Independent of recognition.** A face collected but never auto-matched is
17625
+ * still assignable — it is in fact the face an operator most wants to reach —
17626
+ * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
17627
+ * `subLabel`; this says only that the raw material exists.
17628
+ *
17629
+ * **Set once, never cleared.** A track that produced a gallery row produced
17630
+ * one; deleting the row later is the gallery's business, not this flag's.
17631
+ *
17632
+ * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
17633
+ * before the column omits it, and so does every server that predates the
17634
+ * field. A consumer must test `=== true` and render nothing otherwise —
17635
+ * never infer "no assignable face".
17636
+ */
17637
+ hasEmbeddedFace: boolean().optional(),
17638
+ /**
17639
+ * This subject CONTAINS a folded rider — a person the rider-pairing step
17640
+ * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
17641
+ * so the passage is tracked once and as a VEHICLE.
17642
+ *
17643
+ * It exists because the fold's record was dishonest. D34 and the code both
17644
+ * said "the person is not lost — it is reported so both entities stay on the
17645
+ * record"; in fact the pair went into a per-processor RAM field behind an
17646
+ * accessor nobody called, and every durable surface said `vehicle`, full
17647
+ * stop. This is the composition note that makes the row true.
17648
+ *
17649
+ * A COMPOSITION, never a class and never a label. "This vehicle contains a
17650
+ * person" is not an answer to "what is this" — both label tiers would refuse
17651
+ * a macro token anyway (D89), and correctly. Nothing here changes what the
17652
+ * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
17653
+ * and a `person` rule still does not fire for someone cycling past.
17654
+ *
17655
+ * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
17656
+ * the column, and every hub that predates the field, omits it. Test
17657
+ * `=== true` and render nothing otherwise — never infer "no rider".
17658
+ */
17659
+ hasRider: boolean().optional(),
17660
+ ...TrackFlagFields,
17661
+ ...TrackRetrainFields
17662
+ });
17663
+ var BaseEventFields = {
17664
+ id: string(),
17711
17665
  deviceId: number(),
17712
- trackId: string(),
17713
- frameId: string()
17714
- }), object({
17715
- removed: boolean(),
17716
- removedAnnotations: number().int()
17717
- }), {
17718
- kind: "mutation",
17719
- auth: "admin"
17720
- }), method(object({ frameId: string() }), object({
17666
+ timestamp: number()
17667
+ };
17668
+ var MotionEventSchema = object({
17669
+ ...BaseEventFields,
17670
+ kind: literal("motion"),
17671
+ regionCount: number(),
17672
+ /** Heavy JSON array — omitted in slim projection. */
17673
+ regions: array(object({
17674
+ bbox: BoundingBoxSchema,
17675
+ pixelCount: number(),
17676
+ intensity: number()
17677
+ })).readonly().optional(),
17678
+ /** Omitted in slim projection. */
17679
+ frameWidth: number().optional(),
17680
+ /** Omitted in slim projection. */
17681
+ frameHeight: number().optional(),
17682
+ /** Populated by B5 (recording playback URL for this event). */
17683
+ mediaUrl: string().optional()
17684
+ });
17685
+ /**
17686
+ * Which detection SOURCE produced an object event. `pipeline` = the ML
17687
+ * detection pipeline (decoded-frame inference); `onboard` = the camera's
17688
+ * native on-device AI. Both flow through the SAME analysis layers (zoning,
17689
+ * tracking, per-kind persistence) but stay distinguishable so consumers
17690
+ * (advanced-notifier, occupancy, …) can select which source(s) to act on.
17691
+ * Absent on legacy rows ⇒ treat as `pipeline`.
17692
+ */
17693
+ var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
17694
+ /**
17695
+ * The confirmed zone crossing that produced an object event. Present ONLY on
17696
+ * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
17697
+ * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
17698
+ * appearance event carry none, so a rule asking for a direction fails closed
17699
+ * on them.
17700
+ *
17701
+ * Exactly ONE crossing per event: the emitter turns each confirmed crossing
17702
+ * into its own event, so a frame in which a track enters A while leaving B
17703
+ * produces two events with two directions — never one ambiguous row.
17704
+ *
17705
+ * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
17706
+ * membership the box has NOW, and by definition it no longer contains the zone
17707
+ * that was just left. Without the id here, a zone-scoped rule could never match
17708
+ * the exit it asked for.
17709
+ */
17710
+ var ZoneCrossingSchema = object({
17711
+ direction: _enum(["enter", "exit"]),
17712
+ /** Admin zone id crossed. */
17713
+ zoneId: string(),
17714
+ /** Zone display name at crossing time (falls back to the id). */
17715
+ zoneName: string().optional()
17716
+ });
17717
+ var ObjectEventSchema = object({
17718
+ ...BaseEventFields,
17719
+ kind: literal("object"),
17720
+ /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
17721
+ source: DetectionSourceSchema.optional(),
17722
+ /**
17723
+ * Inference-frame id shared by every object event emitted from the SAME frame
17724
+ * — the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
17725
+ * 2 people + 1 dog) under one full frame, and link a track's frames over time
17726
+ * (group by `trackId`, pick a representative `frameId` as the parent frame).
17727
+ * Optional for backward-compat with pre-existing rows / the slim projection
17728
+ * includes it (it is light). Absent on rows written before this field.
17729
+ */
17730
+ frameId: string().optional(),
17731
+ /** Omitted in slim projection. */
17732
+ trackId: string().optional(),
17733
+ className: string(),
17734
+ ...TieredLabelFields,
17735
+ /** Omitted in slim projection. */
17736
+ confidence: number().optional(),
17737
+ /** Heavy JSON — omitted in slim projection. */
17738
+ bbox: BoundingBoxSchema.optional(),
17739
+ /** Heavy JSON — omitted in slim projection. */
17740
+ zones: array(string()).readonly().optional(),
17741
+ /** Omitted in slim projection. */
17742
+ state: TrackStateSchema.optional(),
17743
+ /**
17744
+ * The zone crossing this event IS, when it is one. Absent on every other
17745
+ * event kind (movement state, appearance, package) — see
17746
+ * {@link ZoneCrossingSchema}. Omitted in slim projection.
17747
+ */
17748
+ zoneCrossing: ZoneCrossingSchema.optional(),
17749
+ /** Detection-frame dimensions in pixels — let consumers normalize the
17750
+ * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
17751
+ frameWidth: number().optional(),
17752
+ frameHeight: number().optional(),
17753
+ /** MediaStore key for the crop attached to this event (if any). */
17754
+ mediaKey: string().optional(),
17755
+ /** Design B: MediaStore key of the track's native-resolution key frame (the
17756
+ * best-detection full frame). Resolve via the event-media data-plane
17757
+ * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
17758
+ * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
17759
+ * sources — consumers fall back to `mediaKey` (the tight crop). */
17760
+ keyFrameMediaKey: string().optional(),
17761
+ /** Populated by B5 (recording playback URL for this event). */
17762
+ mediaUrl: string().optional(),
17763
+ /** The parent track's key-event importance [0,1], propagated to every object
17764
+ * event of the track (so an event row can be sorted by importance without a
17765
+ * track join). Absent on legacy rows / before the track was scored. */
17766
+ importance: number().optional()
17767
+ });
17768
+ var AudioEventSchema = object({
17769
+ ...BaseEventFields,
17770
+ kind: literal("audio"),
17771
+ rms: number(),
17772
+ dbfs: number(),
17773
+ classification: object({
17774
+ className: string(),
17775
+ originalClass: string().optional(),
17776
+ score: number()
17777
+ }).optional(),
17778
+ /** Populated by B5 (recording playback URL for this event). */
17779
+ mediaUrl: string().optional()
17780
+ });
17781
+ var MediaFileKindEnum = _enum([
17782
+ "crop",
17783
+ "thumbnail",
17784
+ "snapshot",
17785
+ "firstFrame",
17786
+ "lastFrame",
17787
+ "fullFrame",
17788
+ "fullFrameBoxed",
17789
+ "faceCrop",
17790
+ "plateCrop",
17791
+ "keyFrame",
17792
+ "keyFrameSmall",
17793
+ "thumbnailSmall"
17794
+ ]);
17795
+ var MediaFileSchema = object({
17796
+ key: string(),
17797
+ kind: MediaFileKindEnum,
17721
17798
  base64: string(),
17722
- width: number().int(),
17723
- height: number().int()
17724
- }), {
17725
- kind: "query",
17726
- auth: "admin"
17727
- }), method(object({
17728
- deviceId: number(),
17729
- trackId: string(),
17730
- frameId: string(),
17731
- subject: RetrainAssistSubjectSchema,
17732
- /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
17733
- nodeId: string().optional()
17734
- }), RetrainAssistResultSchema, {
17735
- kind: "mutation",
17736
- auth: "admin"
17737
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
17738
- kind: "query",
17739
- auth: "admin"
17740
- }), method(object({
17741
- deviceId: number(),
17799
+ sizeBytes: number(),
17800
+ timestamp: number()
17801
+ });
17802
+ /**
17803
+ * One media row WITHOUT its bytes.
17804
+ *
17805
+ * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
17806
+ * 140 s track), and a client that renders tiles from the media data plane needs
17807
+ * to know only WHAT EXISTS — the bytes then arrive per tile, lazily, over HTTP
17808
+ * with an immutable cache, instead of all at once inside a tRPC response that
17809
+ * blocks the whole view.
17810
+ *
17811
+ * `sizeBytes` is carried because it is what lets a client decide between the
17812
+ * stored blob and a `?variant=thumb` rendering without fetching either.
17813
+ */
17814
+ var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
17815
+ /**
17816
+ * The MACRO tier of an annotation — a CLOSED set.
17817
+ *
17818
+ * This is what the exported detector predicts, so a typo here is a new class
17819
+ * with one example in it. `label` and `subLabel` are open strings by contrast:
17820
+ * the whole point of the page is teaching the model things it does not know
17821
+ * yet, and constraining that vocabulary would make it useless.
17822
+ *
17823
+ * A macro class is NEVER a label. The provider refuses a write whose `label` or
17824
+ * `subLabel` is one of these values, in any casing, because once `person`
17825
+ * exists in both tiers "every person box" stops being answerable without
17826
+ * knowing every string anyone ever typed — and the damage is retroactive.
17827
+ */
17828
+ var RetrainMacroClassSchema = _enum([
17829
+ "person",
17830
+ "vehicle",
17831
+ "animal",
17832
+ "package",
17833
+ "face",
17834
+ "plate"
17835
+ ]);
17836
+ /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
17837
+ var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
17838
+ /** Did a human draw this box, or did the assist propose it? */
17839
+ var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
17840
+ /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
17841
+ var RetrainBboxSchema = object({
17842
+ x: number(),
17843
+ y: number(),
17844
+ w: number(),
17845
+ h: number()
17846
+ });
17847
+ /**
17848
+ * One annotated subject.
17849
+ *
17850
+ * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
17851
+ * (letterboxed root / zone-cropped package / subject-cropped classifier) are
17852
+ * derived from it at export and never stored — storing them is how one feature
17853
+ * space ends up holding two crops of the same subject (D52).
17854
+ */
17855
+ var RetrainAnnotationSchema = object({
17856
+ id: string(),
17742
17857
  trackId: string(),
17743
- frameId: string(),
17744
- annotations: array(RetrainAnnotationDraftSchema)
17745
- }), array(RetrainAnnotationSchema).readonly(), {
17746
- kind: "mutation",
17747
- auth: "admin"
17748
- }), method(object({
17749
- deviceId: number(),
17750
- trackId: string()
17751
- }), RetrainTransitionResultSchema, {
17752
- kind: "mutation",
17753
- auth: "admin"
17754
- }), method(object({
17755
17858
  deviceId: number(),
17756
- trackId: string()
17757
- }), RetrainTransitionResultSchema, {
17758
- kind: "mutation",
17759
- auth: "admin"
17760
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
17761
- kind: "query",
17762
- auth: "admin"
17763
- }), method(object({
17764
- eventId: string(),
17765
- kind: MediaFileKindEnum.optional(),
17766
- deviceId: number()
17767
- }), array(MediaFileSchema).readonly()), method(object({
17768
- trackId: string(),
17769
- kinds: array(MediaFileKindEnum).optional(),
17770
- deviceId: number()
17771
- }), array(MediaFileSchema).readonly()), method(object({
17859
+ /** The COPY in retrain storage — never the source track's media key. */
17860
+ mediaKey: string(),
17861
+ bbox: RetrainBboxSchema,
17862
+ macroClass: RetrainMacroClassSchema,
17863
+ label: string().optional(),
17864
+ subLabel: string().optional(),
17865
+ kind: RetrainAnnotationKindSchema,
17866
+ source: RetrainAnnotationSourceSchema,
17867
+ /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
17868
+ assistModelId: string().optional(),
17869
+ assistScore: number().optional(),
17870
+ exportedInBatch: string().optional(),
17871
+ createdAt: number()
17872
+ });
17873
+ /** The write form — the server owns `id`, `createdAt` and the frame binding. */
17874
+ var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
17875
+ id: true,
17876
+ trackId: true,
17877
+ deviceId: true,
17878
+ mediaKey: true,
17879
+ createdAt: true,
17880
+ exportedInBatch: true
17881
+ });
17882
+ /** A track sitting in `staging`, with everything the worklist needs to rank it. */
17883
+ var RetrainTrackSchema = object({
17772
17884
  trackId: string(),
17773
- deviceId: number()
17774
- }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
17775
- kind: "mutation",
17776
- auth: "admin"
17777
- }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
17778
- kind: "mutation",
17779
- auth: "admin"
17780
- }), method(object({}), RebuildStatusSchema), object({
17781
17885
  deviceId: number(),
17886
+ className: string(),
17887
+ label: string().optional(),
17888
+ firstSeen: number(),
17889
+ lastSeen: number(),
17890
+ /** How many frames the dataset already holds from this track. */
17891
+ frameCount: number().int(),
17892
+ /** How many subjects have been annotated on those frames. `0` with
17893
+ * `frameCount: 0` is exactly "staging, still to work". */
17894
+ annotationCount: number().int()
17895
+ });
17896
+ /** A frame the picker may offer — an index row, no blob was read to produce it. */
17897
+ var RetrainFrameCandidateSchema = object({
17898
+ mediaKey: string(),
17899
+ kind: MediaFileKindEnum,
17782
17900
  timestamp: number(),
17783
- frameWidth: number(),
17784
- frameHeight: number(),
17785
- detections: array(OverlayDetectionSchema).readonly()
17786
- }), object({
17901
+ sizeBytes: number().int(),
17902
+ /** A copy of this original already exists — selecting it is free and cannot
17903
+ * fail, whatever became of the original. */
17904
+ copied: boolean()
17905
+ });
17906
+ /** A frame the dataset OWNS: bytes copied at selection time. */
17907
+ var RetrainFrameSchema = object({
17908
+ frameId: string(),
17787
17909
  deviceId: number(),
17788
17910
  trackId: string(),
17789
- className: string()
17911
+ /** Provenance only. It may already point at nothing — that is expected. */
17912
+ sourceMediaKey: string(),
17913
+ sourceKind: MediaFileKindEnum,
17914
+ sizeBytes: number().int(),
17915
+ width: number().int(),
17916
+ height: number().int(),
17917
+ copiedAt: number()
17918
+ });
17919
+ /** Why a copy-on-select could not be honoured — named, never a silent skip. */
17920
+ var RetrainCopyRefusalSchema = _enum([
17921
+ "source-missing",
17922
+ "unreadable-image",
17923
+ "write-failed"
17924
+ ]);
17925
+ var RetrainFrameSelectionSchema = object({
17926
+ copied: array(RetrainFrameSchema).readonly(),
17927
+ refused: array(object({
17928
+ sourceMediaKey: string(),
17929
+ reason: RetrainCopyRefusalSchema
17930
+ })).readonly()
17931
+ });
17932
+ var RetrainFrameListSchema = object({
17933
+ candidates: array(RetrainFrameCandidateSchema).readonly(),
17934
+ copies: array(RetrainFrameSchema).readonly(),
17935
+ /** What the page pre-selects — the native key frame when one survives. */
17936
+ autoPickMediaKey: string().optional()
17937
+ });
17938
+ /** What the operator asked the assist to look for. */
17939
+ var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
17940
+ kind: literal("package"),
17941
+ zone: RetrainBboxSchema.optional()
17790
17942
  }), object({
17791
- deviceId: number(),
17792
- trackId: string(),
17793
- className: string(),
17794
- durationMs: number()
17943
+ kind: literal("objects"),
17944
+ modelId: string(),
17945
+ minScore: number().optional()
17946
+ })]);
17947
+ /**
17948
+ * The assist's answer — a discriminated union, because "the model saw nothing"
17949
+ * and "this node cannot run that model" lead to different next moves and a
17950
+ * nullable result cannot tell them apart.
17951
+ */
17952
+ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
17953
+ kind: literal("proposed"),
17954
+ modelId: string(),
17955
+ stepId: string(),
17956
+ minScore: number(),
17957
+ /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
17958
+ proposals: array(RetrainAnnotationDraftSchema).readonly(),
17959
+ /** Returned by the runner but removed by the threshold. */
17960
+ belowThreshold: number().int()
17795
17961
  }), object({
17962
+ kind: literal("refused"),
17963
+ /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
17964
+ reason: string(),
17965
+ detail: string().optional()
17966
+ })]);
17967
+ /** The outcome of a lifecycle move owned by the retrain page. */
17968
+ var RetrainTransitionResultSchema = object({
17969
+ trackId: string(),
17970
+ /** Where the track ended up, whatever happened. */
17971
+ retrainStatus: RetrainStatusSchema,
17972
+ /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
17973
+ changed: boolean(),
17974
+ reason: _enum([
17975
+ "unknown-track",
17976
+ "no-frames-copied",
17977
+ "not-staging",
17978
+ "not-trained",
17979
+ "unchanged"
17980
+ ]).optional()
17981
+ });
17982
+ var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
17983
+ var MAX_EVENT_QUERY_LIMIT = 5e3;
17984
+ var DeviceEventQueryInput = object({
17796
17985
  deviceId: number(),
17797
- kind: EventKindSchema,
17798
- eventId: string(),
17799
- timestamp: number()
17986
+ since: number().optional(),
17987
+ until: number().optional(),
17988
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
17989
+ /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
17990
+ * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
17991
+ * exact behaviour. Callers may omit this field — the store defaults to
17992
+ * `full` when not provided. */
17993
+ projection: _enum(["full", "slim"]).optional()
17800
17994
  });
17801
- /**
17802
- * Reference to the frame's retained NATIVE surface + the parent crop's placement
17803
- * within the frame, so the executor can re-cut a leaf child ROI at native
17804
- * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
17805
- */
17806
- var NativeCropRefSchema = object({
17807
- /** Handle keying the retained native surface (node-pinned to its owner). */
17808
- handle: FrameHandleSchema,
17809
- /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
17810
- cropFrameSpace: object({
17811
- x: number(),
17812
- y: number(),
17813
- w: number(),
17814
- h: number()
17815
- })
17995
+ var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
17996
+ var RecentTracksQueryInput = object({
17997
+ /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
17998
+ deviceIds: array(number()),
17999
+ /** Window lower bound on `lastSeen` (inclusive). */
18000
+ since: number().optional(),
18001
+ /** Window upper bound on `lastSeen` (inclusive). */
18002
+ until: number().optional(),
18003
+ /** Page size. Default 200, max 1000. */
18004
+ limit: number().int().min(1).max(1e3).default(200),
18005
+ /** Opaque continuation cursor from a previous page's `nextCursor`.
18006
+ * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
18007
+ cursor: string().optional(),
18008
+ /** See {@link TrackProjectionSchema}. Default `full`. */
18009
+ projection: TrackProjectionSchema.optional(),
18010
+ /** Include stationary-promoted rows (parked objects). Default false: the
18011
+ * feed lists passages; parking records live on the stationary registry. */
18012
+ includeStationary: boolean().optional()
17816
18013
  });
17817
- object({
17818
- crop: object({
17819
- left: number(),
17820
- top: number(),
17821
- width: number().positive(),
17822
- height: number().positive()
17823
- }).optional(),
17824
- content: object({
17825
- width: number().int().positive(),
17826
- height: number().int().positive()
17827
- }),
17828
- fit: _enum(["stretch", "contain"]),
17829
- format: _enum([
17830
- "rgb",
17831
- "gray",
17832
- "jpeg"
17833
- ])
18014
+ var RecentTracksPageSchema = object({
18015
+ /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
18016
+ tracks: array(TrackSchema).readonly(),
18017
+ /** Cursor for the next page, or null when this page is the last. */
18018
+ nextCursor: string().nullable()
17834
18019
  });
17835
- var FrameRefSchema = object({
17836
- registryId: string().min(1),
17837
- id: string().min(1),
17838
- width: number().int().positive(),
17839
- height: number().int().positive(),
17840
- format: _enum(["rgb", "gray"]),
17841
- timestamp: number(),
17842
- capturedAt: number().optional()
18020
+ var LIST_GROUPS_DEFAULT_LIMIT = 40;
18021
+ var LIST_GROUPS_MAX_LIMIT = 100;
18022
+ var AnalyticsGroupRecordSchema = object({
18023
+ id: string(),
18024
+ deviceId: number().int(),
18025
+ openedAt: number().int(),
18026
+ closedAt: number().int(),
18027
+ timestamp: number().int(),
18028
+ memberCount: number().int(),
18029
+ memberTrackIds: array(string()).readonly(),
18030
+ className: string(),
18031
+ classes: array(string()).readonly(),
18032
+ /** Relative event-media path, or null when the group has no picture yet. */
18033
+ mediaUrl: string().nullable(),
18034
+ singleton: boolean()
17843
18035
  });
17844
- var ModelFormatSchema$1 = _enum([
17845
- "onnx",
17846
- "coreml",
17847
- "openvino",
17848
- "tflite",
17849
- "pt",
17850
- "gguf"
17851
- ]);
17852
- var PipelineSlotSchema = _enum([
17853
- "detector",
17854
- "cropper",
17855
- "classifier",
17856
- "refiner",
17857
- "audio-classifier"
17858
- ]);
17859
- var PipelineEngineChoiceSchema = object({
17860
- runtime: _enum(["node", "python"]),
17861
- backend: string(),
17862
- format: ModelFormatSchema$1,
17863
- device: string().optional()
18036
+ var AnalyticsGroupMemberSchema = object({
18037
+ trackId: string(),
18038
+ deviceId: number().int(),
18039
+ className: string(),
18040
+ firstSeen: number().int(),
18041
+ lastSeen: number().int(),
18042
+ mediaUrl: string().nullable()
17864
18043
  });
17865
- var AvailableEngineSchema = object({
17866
- engine: PipelineEngineChoiceSchema,
17867
- devices: array(object({
17868
- id: string(),
17869
- label: string(),
17870
- description: string().optional()
17871
- })).readonly(),
17872
- defaultDevice: string()
18044
+ var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
18045
+ var ListGroupsQueryInput = object({
18046
+ /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
18047
+ deviceIds: array(number()),
18048
+ /** Window lower bound on `closedAt` (inclusive). */
18049
+ since: number().optional(),
18050
+ /** Window upper bound on `openedAt` (inclusive). */
18051
+ until: number().optional(),
18052
+ limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
18053
+ /** Opaque continuation cursor from a previous page's `nextCursor`. */
18054
+ cursor: string().optional()
17873
18055
  });
17874
- var PipelineDefaultStepSchema = lazy(() => object({
17875
- addonId: string(),
17876
- addonName: string(),
17877
- slot: PipelineSlotSchema,
17878
- inputClasses: array(string()).readonly(),
17879
- outputClasses: array(string()).readonly(),
17880
- enabled: boolean(),
17881
- modelId: string(),
17882
- children: array(PipelineDefaultStepSchema).readonly(),
17883
- group: string().optional(),
17884
- settings: record(string(), unknown()).optional()
17885
- }));
17886
- var PipelineTemplateStepSchema = lazy(() => object({
17887
- addonId: string(),
17888
- enabled: boolean(),
17889
- modelId: string(),
17890
- children: array(PipelineTemplateStepSchema).readonly(),
17891
- settings: record(string(), unknown()).optional()
17892
- }));
17893
- var PipelineTemplateSchema$1 = object({
17894
- id: string(),
17895
- name: string(),
17896
- createdAt: string(),
17897
- updatedAt: string(),
17898
- engine: PipelineEngineChoiceSchema,
17899
- steps: array(PipelineTemplateStepSchema).readonly()
18056
+ var ListGroupsPageSchema = object({
18057
+ groups: array(AnalyticsGroupRecordSchema).readonly(),
18058
+ nextCursor: string().nullable()
18059
+ });
18060
+ var KeyEventQueryInput = object({
18061
+ deviceId: number(),
18062
+ /** Window lower bound (track firstSeen ≥ since). */
18063
+ since: number(),
18064
+ /** Window upper bound (track firstSeen ≤ until). */
18065
+ until: number(),
18066
+ limit: number().int().min(1).max(200).default(50),
18067
+ /** Drop tracks scoring below this importance. */
18068
+ minImportance: number().min(0).max(1).optional(),
18069
+ /** Restrict to a single class (e.g. 'person'). */
18070
+ classFilter: string().optional()
17900
18071
  });
17901
- var PipelineModelOptionSchema = object({
18072
+ var KeyEventSchema = object({
18073
+ /** The representative event id (the track's best ObjectEvent, else its trackId). */
17902
18074
  id: string(),
17903
- name: string(),
17904
- formats: record(string(), object({
17905
- downloaded: boolean(),
17906
- sizeMB: number()
17907
- })),
17908
- group: ModelVariantGroupSchema.optional(),
17909
- legacy: boolean().optional(),
17910
- provider: ModelProviderIdSchema.optional()
18075
+ trackId: string(),
18076
+ /** Track start time (firstSeen). */
18077
+ timestamp: number(),
18078
+ className: string(),
18079
+ ...TieredLabelFields,
18080
+ importance: number(),
18081
+ /** Highest-confidence ObjectEvent id for the track (empty when none). */
18082
+ bestEventId: string(),
18083
+ /** Track lifetime in ms (lastSeen - firstSeen). */
18084
+ windowMs: number().optional(),
18085
+ ...TrackFlagFields,
18086
+ ...TrackRetrainFields
17911
18087
  });
17912
- var ConfigFieldBridge = custom();
17913
- var PipelineAddonSchemaSchema = object({
17914
- id: string(),
17915
- name: string(),
17916
- slot: PipelineSlotSchema,
17917
- inputClasses: array(string()).readonly(),
17918
- outputClasses: array(string()).readonly(),
17919
- childSlots: array(PipelineSlotSchema).readonly(),
17920
- models: array(PipelineModelOptionSchema).readonly(),
17921
- defaultModelId: string(),
17922
- defaultModelIdByFormat: record(string(), string()).optional(),
17923
- enabledByDefault: boolean().optional(),
17924
- backfillIntoExistingOverrides: boolean().optional(),
17925
- defaultConfidence: number(),
17926
- group: string().optional(),
17927
- configSchema: array(ConfigFieldBridge).readonly().optional()
18088
+ object({
18089
+ trackId: string(),
18090
+ className: string(),
18091
+ confidence: number(),
18092
+ bbox: BoundingBoxSchema,
18093
+ zones: array(string()).readonly(),
18094
+ state: TrackStateSchema
17928
18095
  });
17929
- var PipelineSlotSchemaSchema = object({
17930
- id: PipelineSlotSchema,
17931
- label: string(),
17932
- priority: number(),
17933
- parentSlot: PipelineSlotSchema.nullable(),
17934
- addons: array(PipelineAddonSchemaSchema).readonly()
18096
+ var OverlayDetectionSchema = looseObject({
18097
+ id: string(),
18098
+ kind: _enum(["first-level", "detail"]),
18099
+ macroClass: string(),
18100
+ score: number(),
18101
+ bbox: object({
18102
+ x: number(),
18103
+ y: number(),
18104
+ width: number(),
18105
+ height: number()
18106
+ }),
18107
+ labels: array(looseObject({
18108
+ label: string(),
18109
+ score: number()
18110
+ })).readonly(),
18111
+ parentId: string().optional()
17935
18112
  });
17936
- var PipelineSchemaSchema = object({
17937
- availableEngines: array(AvailableEngineSchema).readonly(),
17938
- selectedEngine: PipelineEngineChoiceSchema,
17939
- slots: array(PipelineSlotSchemaSchema).readonly()
18113
+ var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
18114
+ var SearchObjectEventsInput = object({
18115
+ text: string(),
18116
+ deviceId: number().optional(),
18117
+ since: number().optional(),
18118
+ until: number().optional(),
18119
+ classFilter: string().optional(),
18120
+ limit: number().default(50),
18121
+ minScore: number().min(0).max(1).default(.2)
17940
18122
  });
17941
- var EngineProvisioningSchema = object({
17942
- runtimeId: _enum([
17943
- "onnx",
17944
- "openvino",
17945
- "coreml",
17946
- "edgetpu"
17947
- ]).nullable(),
17948
- device: string().nullable(),
17949
- state: _enum([
17950
- "idle",
17951
- "installing",
17952
- "verifying",
17953
- "ready",
17954
- "failed"
17955
- ]),
17956
- progress: number().optional(),
17957
- error: string().optional(),
17958
- nextRetryAt: number().optional(),
17959
- /**
17960
- * Gate A (config-correctness gate at engine change): human-readable
17961
- * config issues surfaced EAGERLY when the node's engine changes — model
17962
- * substitutions ("chose X, running Y") and zero-build steps ("no model
17963
- * has a <format> build"). Additive/optional: informational only, never
17964
- * enforced here — `assertEngineReady` (readiness) still gates inference.
17965
- * Absent/empty when the node-default tree resolves cleanly.
17966
- */
17967
- configIssues: array(string()).optional()
18123
+ var TrackCascadeCountsSchema = object({
18124
+ /** Persisted track roots deleted (authoritative). */
18125
+ tracks: number().int(),
18126
+ /** Object events removed with their tracks (best-effort; see note above). */
18127
+ events: number().int(),
18128
+ /** Track/face/plate-owned media removed (best-effort). Never identity media. */
18129
+ media: number().int(),
18130
+ /** Unassigned (non-enrolled) face reads removed (best-effort). */
18131
+ faces: number().int(),
18132
+ /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
18133
+ plates: number().int(),
18134
+ /** Per-track CLIP search vectors removed (best-effort). */
18135
+ embeddings: number().int(),
18136
+ /** Group membership + group rows removed with their last member (best-effort). */
18137
+ groups: number().int()
17968
18138
  });
17969
- var PipelineStepInputSchema = lazy(() => object({
17970
- addonId: string(),
17971
- modelId: string().optional(),
17972
- enabled: boolean().default(true),
17973
- children: array(PipelineStepInputSchema).optional(),
17974
- settings: record(string(), unknown()).optional(),
17975
- jumpDeviceKey: string().optional()
17976
- }));
17977
- var ModelSubstitutionSchema = object({
17978
- addonId: string(),
17979
- chosen: string(),
17980
- running: string(),
17981
- format: string()
18139
+ /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
18140
+ var DiskReconcileCountsSchema = object({
18141
+ mediaDropped: number().int(),
18142
+ tracks: number().int(),
18143
+ events: number().int()
17982
18144
  });
17983
- var PipelineValidationIssueSchema = object({
17984
- addonId: string(),
17985
- kind: _enum(["unknown-addon", "no-format-build"]),
17986
- detail: string()
18145
+ /** Event-store footprint for one camera. */
18146
+ var EventStoreDeviceFootprintSchema = object({
18147
+ deviceId: number(),
18148
+ /** Persisted event rows (motion + object + audio) for the camera. */
18149
+ rows: number().int(),
18150
+ /** Event-owned media bytes on disk for the camera. */
18151
+ bytes: number().int()
17987
18152
  });
17988
- var PipelineValidationResultSchema = object({
17989
- ok: boolean(),
17990
- issues: array(PipelineValidationIssueSchema).readonly(),
17991
- substitutions: array(ModelSubstitutionSchema).readonly(),
17992
- /** The node's `currentEngine.format` this validation ran against. */
17993
- format: string()
18153
+ /** Aggregate event-store footprint: global totals + per-camera breakdown. */
18154
+ var EventStoreFootprintSchema = object({
18155
+ totalRows: number().int(),
18156
+ totalBytes: number().int(),
18157
+ devices: array(EventStoreDeviceFootprintSchema).readonly()
17994
18158
  });
17995
- var ReferenceImageEntrySchema = object({
17996
- filename: string(),
17997
- stepIds: array(string()).readonly().optional()
18159
+ /** Per-kind counts returned by the event-prune / device-delete mutations. */
18160
+ var EventPruneCountsSchema = object({
18161
+ motion: number().int(),
18162
+ object: number().int(),
18163
+ audio: number().int()
17998
18164
  });
17999
- var ReferenceImageBodySchema = object({
18000
- base64: string(),
18001
- filename: string()
18165
+ /**
18166
+ * Re-embed stored tracks from their key frames.
18167
+ *
18168
+ * The reason this is an operator-callable method and not a migration script:
18169
+ * every knob that decides what a vector MEANS — encoder model, crop margin,
18170
+ * squaring — is only changeable if the existing vectors can be regenerated.
18171
+ * Mixing feature spaces in one index makes cosine scores incomparable, and the
18172
+ * symptom is a quality regression with no visible cause.
18173
+ */
18174
+ var RebuildObjectEmbeddingsInput = object({
18175
+ /** Restrict to one camera. Omit for the whole fleet. */
18176
+ deviceId: number().optional(),
18177
+ since: number().optional(),
18178
+ until: number().optional(),
18179
+ /** Stop after this many tracks; the result reports whether more remain. */
18180
+ maxTracks: number().int().positive().optional(),
18181
+ /**
18182
+ * Run every embedding on THIS node instead of round-robining the fleet.
18183
+ *
18184
+ * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
18185
+ * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
18186
+ * calling it that would pin the rebuild REQUEST itself to that node — the
18187
+ * rebuild orchestration lives on the hub, and only the per-track step runs
18188
+ * remotely. This field is data; the per-track pin is applied inside.
18189
+ *
18190
+ * Absent ⇒ round-robin over every online node whose runner can serve the
18191
+ * pinned model.
18192
+ */
18193
+ executeOnNodeId: string().optional(),
18194
+ /**
18195
+ * Milliseconds to wait between tracks; omit for the built-in default, `0` to
18196
+ * run flat out.
18197
+ *
18198
+ * A rebuild is bulk maintenance on hub-main's single thread. Measured
18199
+ * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
18200
+ * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
18201
+ * force is logged at start and finish so a deliberately slow pass reads
18202
+ * differently from a stalled one.
18203
+ */
18204
+ pacingMs: number().int().nonnegative().optional()
18002
18205
  });
18003
- var ReferenceAudioEntrySchema = object({
18004
- filename: string(),
18005
- sizeKb: number()
18206
+ /**
18207
+ * Result of emptying the CLIP index.
18208
+ *
18209
+ * The clean slate before a policy change: a new crop margin or encoder model
18210
+ * leaves two feature spaces in one index whose cosine scores are not
18211
+ * comparable, so wiping and rebuilding is the only way to be sure every vector
18212
+ * means the same thing.
18213
+ */
18214
+ var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
18215
+ /**
18216
+ * Acknowledgement that a rebuild STARTED.
18217
+ *
18218
+ * The pass costs ~1s per track — 45 minutes for a 2,600-track fleet — so it
18219
+ * runs detached and this returns immediately. Waiting for it made the client
18220
+ * time out while the work carried on server-side, which is the worst of both:
18221
+ * no result and no way to know it was still going. Poll
18222
+ * `getObjectEmbeddingRebuildStatus` for progress.
18223
+ */
18224
+ var RebuildObjectEmbeddingsResultSchema = object({
18225
+ started: boolean(),
18226
+ /** True when a pass was already running; the new request is ignored. */
18227
+ alreadyRunning: boolean()
18006
18228
  });
18007
- var ReferenceAudioBodySchema = object({ base64: string() });
18008
- var AudioBackendSchema = object({
18009
- id: string(),
18010
- name: string(),
18011
- description: string(),
18012
- available: boolean(),
18229
+ var RebuildStatusSchema = object({
18230
+ running: boolean(),
18231
+ scanned: number(),
18232
+ rebuilt: number(),
18233
+ /** Tracks whose key frame is gone — nothing to re-embed from. */
18234
+ missingKeyFrame: number(),
18235
+ /** Tracks with no usable detection box. */
18236
+ missingBbox: number(),
18237
+ /**
18238
+ * Tracks an executing node REFUSED rather than broke on — an unreadable key
18239
+ * frame, a step that threw. Separate from `failed` because the remedy is
18240
+ * different, and because a whole camera silently contributing zero vectors
18241
+ * is the shape of failure a rebuild must never hide.
18242
+ */
18243
+ notRunnable: number(),
18013
18244
  /**
18014
- * Raw classifier labels this backend can emit (e.g. YAMNet's
18015
- * 521-class set or Apple SoundAnalysis's 303-class set). Used by
18016
- * the benchmark UI to populate the `enabledMicroClasses` filter
18017
- * specific to the selected backend without a separate fetch.
18245
+ * The pass stopped because NO node could serve the pinned model.
18246
+ *
18247
+ * Distinct from `notRunnable` on purpose: that one says "this track was
18248
+ * refused", this one says "the cluster cannot do this work at all" — every
18249
+ * candidate node either lacks the `clip-embedding` step, lacks a build of the
18250
+ * pinned model for its engine format, or dropped out. The remedy is a model /
18251
+ * engine change, not a per-camera one. Non-zero here always comes with
18252
+ * `complete: false`.
18018
18253
  */
18019
- rawLabels: array(string()).readonly().optional()
18020
- });
18021
- var AudioCapabilitiesSchema = object({
18022
- activeBackend: string(),
18023
- availableBackends: array(AudioBackendSchema).readonly(),
18024
- sampleRate: number(),
18025
- chunkDurationMs: number()
18026
- });
18027
- var DownloadModelResultSchema = object({
18028
- filePath: string(),
18029
- sizeMB: number(),
18030
- durationMs: number()
18254
+ noCapableNode: number(),
18255
+ failed: number(),
18256
+ /** Set once a pass ends: true only when EVERYTHING was covered. */
18257
+ complete: boolean().nullable(),
18258
+ startedAtMs: number().nullable(),
18259
+ finishedAtMs: number().nullable(),
18260
+ /** Present when the pass ended by throwing. */
18261
+ error: string().nullable()
18031
18262
  });
18032
- /**
18033
- * Wrapper carrying a single test run's result. Replaces the legacy
18034
- * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
18035
- * canonical `AudioResult` from the Phase 6 output rework: one
18036
- * `AudioDetection` per class above `minScore`, top-N candidates in
18037
- * `debug.alternateLabels['audio-classifier']`, per-source timings in
18038
- * `debug.stepTimings`. The outer `success`/`error` fields stay so the
18039
- * benchmark UI can still report a clean failure when the classifier
18040
- * cap isn't available.
18041
- */
18042
- var AudioTestResultSchema = object({
18043
- success: boolean(),
18044
- error: string().optional(),
18045
- frame: custom().optional()
18263
+ var ReplayFrameInputSchema = object({
18264
+ timestamp: number(),
18265
+ frame: PipelineRunResultBridge
18046
18266
  });
18047
- var PipelineConfigBridge = custom();
18048
- var ConfigUISchemaBridge = custom();
18049
- var ConfigUISchemaNullableBridge = custom();
18050
- var InferenceCapabilitiesBridge = custom();
18051
- var ModelAvailabilityListBridge = custom();
18052
- var PipelineRunResultBridge = custom();
18053
- method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
18054
- modelId: string(),
18055
- settings: record(string(), unknown()).readonly()
18056
- }))), method(object({ steps: record(string(), object({
18057
- modelId: string(),
18058
- settings: record(string(), unknown()).readonly()
18059
- })) }), object({ success: literal(true) }), {
18267
+ var RunReplayFrameProcessorResultSchema = object({ tracks: array(object({
18268
+ className: string(),
18269
+ firstSeenMs: number(),
18270
+ lastSeenMs: number(),
18271
+ /** Bbox of the track's FIRST matched detection, pixel-space in the clip's
18272
+ * frame a representative box for the diff's `(className, window, IoU)`
18273
+ * pairing (`replay-diff.ts`). A replay does not need the full per-frame
18274
+ * trajectory production's `Track.positions` keeps. */
18275
+ bbox: BoundingBoxSchema,
18276
+ /** How many of the input frames this track matched a real detection on
18277
+ * (never a coasted/extrapolated frame) — the replay's own signal for "how
18278
+ * solid is this track", cheaper than re-deriving it from a trajectory. */
18279
+ framesMatched: number().int()
18280
+ })).readonly() });
18281
+ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
18282
+ deviceId: number(),
18283
+ trackId: string()
18284
+ }), TrackSchema.nullable()), method(object({
18285
+ deviceId: number(),
18286
+ since: number().optional(),
18287
+ until: number().optional(),
18288
+ limit: number().optional(),
18289
+ /** Spatial filter — only tracks whose trajectory intersects the zone
18290
+ * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
18291
+ * envelope columns, then precisely tested per position. Tracks with
18292
+ * an unknown envelope (no frame dims at persist time) always match. */
18293
+ zone: TrackZoneFilterSchema.optional(),
18294
+ /** See {@link TrackProjectionSchema}. Default `full` (backward
18295
+ * compatible — omitting the field keeps today's exact behaviour). */
18296
+ projection: TrackProjectionSchema.optional(),
18297
+ /** Include stationary-promoted rows (parked objects handed to the
18298
+ * stationary registry). Default false: the timeline lists passages,
18299
+ * not parking records (operator decision, 2026-08-15). */
18300
+ includeStationary: boolean().optional()
18301
+ }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
18302
+ deviceId: number(),
18303
+ groupId: string().min(1)
18304
+ }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
18305
+ kind: "mutation",
18306
+ auth: "admin"
18307
+ }), 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({
18308
+ deviceId: number(),
18309
+ since: number().optional(),
18310
+ until: number().optional(),
18311
+ kinds: array(string()).optional(),
18312
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
18313
+ }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
18314
+ deviceId: number(),
18315
+ since: number(),
18316
+ until: number(),
18317
+ bucketMs: number().int().positive()
18318
+ }), array(object({
18319
+ bucketStart: number(),
18320
+ motion: number().int(),
18321
+ object: number().int(),
18322
+ audio: number().int()
18323
+ })).readonly()), method(object({
18324
+ deviceId: number(),
18325
+ cutoffMs: number()
18326
+ }), object({
18327
+ motion: number().int(),
18328
+ object: number().int(),
18329
+ audio: number().int()
18330
+ }), {
18331
+ kind: "mutation",
18332
+ auth: "admin"
18333
+ }), method(object({
18334
+ deviceId: number(),
18335
+ cutoffMs: number()
18336
+ }), TrackCascadeCountsSchema, {
18337
+ kind: "mutation",
18338
+ auth: "admin"
18339
+ }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
18340
+ kind: "mutation",
18341
+ auth: "admin"
18342
+ }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
18343
+ kind: "mutation",
18344
+ auth: "admin"
18345
+ }), method(object({
18346
+ deviceId: number(),
18347
+ trackIds: array(string()).min(1)
18348
+ }), object({
18349
+ deleted: number().int(),
18350
+ failed: array(string()).readonly()
18351
+ }), {
18352
+ kind: "mutation",
18353
+ auth: "admin"
18354
+ }), method(object({
18355
+ /** Log/audit scope only — the trackId is globally unique on its own. */
18356
+ deviceId: number(),
18357
+ trackId: string(),
18358
+ flags: TrackFlagsPatchSchema
18359
+ }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
18360
+ kind: "query",
18361
+ auth: "admin"
18362
+ }), method(object({
18363
+ olderThanMs: number(),
18364
+ reason: OpsLogReasonSchema.optional()
18365
+ }), EventPruneCountsSchema, {
18366
+ kind: "mutation",
18367
+ auth: "admin"
18368
+ }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
18369
+ kind: "mutation",
18370
+ auth: "admin"
18371
+ }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
18372
+ kind: "mutation",
18373
+ auth: "admin"
18374
+ }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
18375
+ kind: "mutation",
18376
+ auth: "admin"
18377
+ }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
18378
+ kind: "mutation",
18379
+ auth: "admin"
18380
+ }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
18381
+ kind: "mutation",
18382
+ auth: "admin"
18383
+ }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18384
+ kind: "mutation",
18385
+ auth: "admin"
18386
+ }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
18387
+ kind: "mutation",
18388
+ auth: "admin"
18389
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
18390
+ kind: "query",
18391
+ auth: "admin"
18392
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18393
+ kind: "mutation",
18394
+ auth: "admin"
18395
+ }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
18396
+ kind: "query",
18397
+ auth: "admin"
18398
+ }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
18399
+ kind: "query",
18400
+ auth: "admin"
18401
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18402
+ kind: "query",
18403
+ auth: "admin"
18404
+ }), method(object({
18405
+ /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
18406
+ * `deviceId`, deliberately: `deviceId` would make this device-bound and
18407
+ * route it at one camera's owner, and "every camera" would stop being
18408
+ * expressible at all. */
18409
+ deviceIds: array(number()).optional(),
18410
+ limit: number().int().min(1).max(500).optional()
18411
+ }), array(RetrainTrackSchema).readonly(), {
18412
+ kind: "query",
18413
+ auth: "admin"
18414
+ }), method(object({ trackId: string() }), RetrainFrameListSchema, {
18415
+ kind: "query",
18416
+ auth: "admin"
18417
+ }), method(object({
18418
+ deviceId: number(),
18419
+ trackId: string(),
18420
+ mediaKeys: array(string()).min(1)
18421
+ }), RetrainFrameSelectionSchema, {
18422
+ kind: "mutation",
18423
+ auth: "admin"
18424
+ }), method(object({
18425
+ deviceId: number(),
18426
+ trackId: string(),
18427
+ frameId: string()
18428
+ }), object({
18429
+ removed: boolean(),
18430
+ removedAnnotations: number().int()
18431
+ }), {
18432
+ kind: "mutation",
18433
+ auth: "admin"
18434
+ }), method(object({ frameId: string() }), object({
18435
+ base64: string(),
18436
+ width: number().int(),
18437
+ height: number().int()
18438
+ }), {
18439
+ kind: "query",
18440
+ auth: "admin"
18441
+ }), method(object({
18442
+ deviceId: number(),
18443
+ trackId: string(),
18444
+ frameId: string(),
18445
+ subject: RetrainAssistSubjectSchema,
18446
+ /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
18447
+ nodeId: string().optional()
18448
+ }), RetrainAssistResultSchema, {
18449
+ kind: "mutation",
18450
+ auth: "admin"
18451
+ }), method(object({
18452
+ deviceId: number(),
18453
+ source: DetectionSourceSchema,
18454
+ zones: array(ZoneSchema).readonly().optional(),
18455
+ detectionRules: array(ZoneRuleSchema).readonly().optional(),
18456
+ zoneMembershipMinOverlap: number().min(0).max(1).optional(),
18457
+ frames: array(ReplayFrameInputSchema).min(1)
18458
+ }), RunReplayFrameProcessorResultSchema, {
18459
+ kind: "mutation",
18460
+ auth: "admin"
18461
+ }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
18462
+ kind: "query",
18463
+ auth: "admin"
18464
+ }), method(object({
18465
+ deviceId: number(),
18466
+ trackId: string(),
18467
+ frameId: string(),
18468
+ annotations: array(RetrainAnnotationDraftSchema)
18469
+ }), array(RetrainAnnotationSchema).readonly(), {
18470
+ kind: "mutation",
18471
+ auth: "admin"
18472
+ }), method(object({
18473
+ deviceId: number(),
18474
+ trackId: string()
18475
+ }), RetrainTransitionResultSchema, {
18060
18476
  kind: "mutation",
18061
18477
  auth: "admin"
18062
- }), method(object({ nodeId: string() }), object({
18063
- success: literal(true),
18064
- clearedDevices: number()
18065
- }), {
18478
+ }), method(object({
18479
+ deviceId: number(),
18480
+ trackId: string()
18481
+ }), RetrainTransitionResultSchema, {
18066
18482
  kind: "mutation",
18067
18483
  auth: "admin"
18068
- }), 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({
18069
- name: string(),
18070
- steps: array(PipelineTemplateStepSchema).readonly(),
18071
- engine: PipelineEngineChoiceSchema
18072
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
18073
- id: string(),
18074
- name: string().optional(),
18075
- steps: array(PipelineTemplateStepSchema).readonly().optional()
18076
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
18077
- addonId: string(),
18078
- modelId: string(),
18079
- format: ModelFormatSchema$1
18080
- }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
18081
- addonId: string(),
18082
- modelId: string(),
18083
- format: ModelFormatSchema$1
18084
- }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
18085
- engine: PipelineEngineChoiceSchema.optional(),
18086
- steps: array(PipelineStepInputSchema).min(1),
18087
- frame: FrameInputSchema.optional(),
18088
- /**
18089
- * Process-local lazy frame. Valid only when caller and provider resolve
18090
- * in the same execution-group process; split/cross-node callers use
18091
- * `frame`/`image` inline compatibility instead.
18092
- */
18093
- frameRef: FrameRefSchema.optional(),
18094
- /**
18095
- * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
18096
- * the decoded pixels live in. One more member of the one-of
18097
- * frame/frameHandle/image/imageBase64/referenceImage group.
18098
- */
18099
- frameHandle: FrameHandleSchema.optional(),
18100
- imageBase64: string().optional(),
18101
- /**
18102
- * Binary JPEG bytes — preferred over `imageBase64` on internal
18103
- * hops (hub → forked worker via Moleculer MsgPack) because it
18104
- * skips the 33% base64 overhead + the per-call base64 decode on
18105
- * the detection-pipeline worker. Callers can pass either; exactly
18106
- * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
18107
- */
18108
- image: _instanceof(Uint8Array).optional(),
18109
- referenceImage: string().optional(),
18110
- deviceId: number().optional(),
18111
- sessionId: string().optional(),
18112
- /**
18113
- * Execution plane. 'full' (default) runs the whole tree — benchmark,
18114
- * reference-image, and detail-subtree calls. 'frame' is the live
18115
- * per-frame dispatch: ONLY root-plane steps run; crop children
18116
- * (inputClasses ≠ null) are skipped and served per-track via
18117
- * pipelineRunner.runDetailSubtree (two-plane design).
18118
- */
18119
- plane: _enum(["full", "frame"]).optional(),
18120
- /**
18121
- * Inference-device selector (Phase 2 multi-device). Format
18122
- * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
18123
- * Omitted ⇒ the runner's default device (current single-engine
18124
- * behaviour). Selects WHICH device pool of the node runs the call.
18125
- */
18126
- deviceKey: string().optional(),
18127
- /**
18128
- * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
18129
- * when the parent crop was resolved from the frame's retained NATIVE
18130
- * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
18131
- * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
18132
- * resolution from that surface — the SAME quality path faces already
18133
- * had — instead of the downscaled parent tile. `handle` keys the native
18134
- * surface (node-pinned to its owner); `cropFrameSpace` is the parent
18135
- * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
18136
- * the executor's crop-normalized child ROI back into frame-normalized
18137
- * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
18138
- * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
18139
- * (today's behaviour on the fallback path).
18140
- */
18141
- nativeCropRef: NativeCropRefSchema.optional()
18142
- }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
18143
- engine: PipelineEngineChoiceSchema.optional(),
18144
- steps: array(PipelineStepInputSchema).min(1),
18145
- frames: array(FrameInputSchema).min(1).max(255),
18146
- deviceId: number().optional(),
18147
- sessionId: string().optional(),
18148
- /**
18149
- * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
18150
- * the batch to the Python pool's bench preprocess cache
18151
- * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
18152
- * preprocessed ONCE and every later inference is a pure-inference cache
18153
- * hit — the sustained-throughput run measures inference, not
18154
- * decode+preprocess+infer. Omitted/0 for live frames (all different →
18155
- * full preprocess every call, correct). Fresh per sustained run;
18156
- * released via `uncacheFrame`.
18157
- */
18158
- frameId: number().int().nonnegative().optional(),
18159
- /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
18160
- deviceKey: string().optional()
18161
- }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
18162
- data: _instanceof(Uint8Array),
18163
- width: number().int().positive(),
18164
- height: number().int().positive(),
18165
- format: _enum([
18166
- "rgb",
18167
- "bgr",
18168
- "gray"
18169
- ])
18170
- }), object({
18171
- frameId: number(),
18172
- width: number(),
18173
- height: number()
18174
- }), { kind: "mutation" }), method(object({
18175
- stepId: string(),
18176
- frameId: number().int()
18177
- }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
18178
- batchMode: string(),
18179
- windowMs: number(),
18180
- maxBatchSize: number(),
18181
- concurrency: number()
18182
- })), method(_void(), array(object({
18183
- engineKey: string(),
18184
- engine: PipelineEngineChoiceSchema,
18185
- modelsLoaded: array(string()).readonly(),
18186
- inUseByCameras: array(number()).readonly(),
18187
- /**
18188
- * Origin of this resident factory.
18189
- * - `runtime` — main camera-serving engine (no idle TTL).
18190
- * - `warm-override` — benchmark/test override held in the warm
18191
- * cache; auto-disposed after the idle TTL.
18192
- * - `device-pool` — a concurrent per-device pool (Phase 2
18193
- * multi-device, keyed by `deviceKey`) resolved
18194
- * via `resolveDeviceFactory`. Runs alongside the
18195
- * `runtime` engine on a DIFFERENT accelerator
18196
- * (NPU / iGPU / Coral) — this is how the
18197
- * Engines tab shows all pools running at once.
18198
- */
18199
- kind: _enum([
18200
- "runtime",
18201
- "warm-override",
18202
- "device-pool"
18203
- ]),
18204
- /** Native pid of the underlying Python pool (null when no pool). */
18205
- poolPid: number().nullable(),
18206
- /** ms since this factory was last used (null when not warm-tracked). */
18207
- idleMs: number().nullable(),
18208
- /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
18209
- idleTtlMs: number().nullable()
18210
- })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
18211
- kind: "mutation",
18484
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18485
+ kind: "query",
18212
18486
  auth: "admin"
18213
18487
  }), method(object({
18214
- engine: PipelineEngineChoiceSchema,
18215
- force: boolean().optional()
18216
- }), object({
18217
- success: boolean(),
18218
- reason: string().optional()
18219
- }), {
18488
+ eventId: string(),
18489
+ kind: MediaFileKindEnum.optional(),
18490
+ deviceId: number()
18491
+ }), array(MediaFileSchema).readonly()), method(object({
18492
+ trackId: string(),
18493
+ kinds: array(MediaFileKindEnum).optional(),
18494
+ deviceId: number()
18495
+ }), array(MediaFileSchema).readonly()), method(object({
18496
+ trackId: string(),
18497
+ deviceId: number()
18498
+ }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
18220
18499
  kind: "mutation",
18221
18500
  auth: "admin"
18222
- }), 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({
18223
- addonId: string(),
18224
- modelId: string(),
18225
- filename: string().optional(),
18226
- settings: record(string(), unknown()).optional()
18227
- }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
18501
+ }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
18502
+ kind: "mutation",
18503
+ auth: "admin"
18504
+ }), method(object({}), RebuildStatusSchema), object({
18505
+ deviceId: number(),
18506
+ timestamp: number(),
18507
+ frameWidth: number(),
18508
+ frameHeight: number(),
18509
+ detections: array(OverlayDetectionSchema).readonly()
18510
+ }), object({
18511
+ deviceId: number(),
18512
+ trackId: string(),
18513
+ className: string()
18514
+ }), object({
18515
+ deviceId: number(),
18516
+ trackId: string(),
18517
+ className: string(),
18518
+ durationMs: number()
18519
+ }), object({
18520
+ deviceId: number(),
18521
+ kind: EventKindSchema,
18522
+ eventId: string(),
18523
+ timestamp: number()
18524
+ });
18228
18525
  object({
18229
18526
  activeCameras: number(),
18230
18527
  throttledCameras: number(),
@@ -18236,119 +18533,19 @@ var CameraMetricsSchema = object({
18236
18533
  "disabled",
18237
18534
  "always-on",
18238
18535
  "on-motion"
18239
- ]),
18240
- configuredFps: number(),
18241
- actualFps: number(),
18242
- queueDepth: number(),
18243
- avgInferenceTimeMs: number(),
18244
- droppedFrames: number(),
18245
- phase: _enum([
18246
- "idle",
18247
- "watching",
18248
- "active"
18249
- ])
18250
- });
18251
- var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
18252
- /**
18253
- * Zone — pure geometry + identity. NO filtering behaviour.
18254
- *
18255
- * Zones describe **where** in the frame the operator wants to flag
18256
- * something; consumer-owned {@link ZoneRule} arrays describe **how**
18257
- * each pipeline stage uses them. Splitting the two means a single
18258
- * polygon "Driveway" can simultaneously back a motion-exclude rule,
18259
- * a detection-include rule on `['car']`, and an occupancy aggregate
18260
- * — without three duplicated polygons.
18261
- *
18262
- * Owned by the orchestrator addon (provider) and mirrored into the
18263
- * `zones` device-state slice on every mutation. Consumers
18264
- * (motion-wasm, pipeline-executor, analytics, admin UI) read either
18265
- * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
18266
- * mirror with `onChanged`).
18267
- *
18268
- * Coordinates are normalised fractions of the frame (0–1) so zones
18269
- * survive resolution changes and stream profile switches.
18270
- *
18271
- * `kind` discriminates between full polygons (closed regions used
18272
- * for intrusion / occupancy filters) and tripwires (open 2-point
18273
- * line segments used for cross events). Onboard / firmware-reported
18274
- * zones (Reolink, ONVIF) are out of scope for now — see the deferred
18275
- * task list.
18276
- */
18277
- var ZoneKindEnum = _enum(["polygon", "tripwire"]);
18278
- /** Polygon vertex in fraction-of-frame coordinates (0–1). */
18279
- var PolygonPointSchema = object({
18280
- x: number(),
18281
- y: number()
18282
- });
18283
- /** A camera detection zone — pure geometry/identity. */
18284
- var ZoneSchema = object({
18285
- id: string(),
18286
- name: string(),
18287
- kind: ZoneKindEnum.default("polygon"),
18288
- /** Polygon vertices, fraction of frame (0–1). */
18289
- polygon: array(PolygonPointSchema).readonly(),
18290
- /** Visual color for UI rendering. */
18291
- color: string().default("#3b82f6")
18536
+ ]),
18537
+ configuredFps: number(),
18538
+ actualFps: number(),
18539
+ queueDepth: number(),
18540
+ avgInferenceTimeMs: number(),
18541
+ droppedFrames: number(),
18542
+ phase: _enum([
18543
+ "idle",
18544
+ "watching",
18545
+ "active"
18546
+ ])
18292
18547
  });
18293
- /**
18294
- * Zones capability — per-camera CRUD over polygon detection zones.
18295
- *
18296
- * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
18297
- * to per-device settings and mirrors into the `zones` device-state
18298
- * slice on every mutation, so downstream consumers can subscribe via
18299
- * `dev.state.zones.onChanged`.
18300
- *
18301
- * The cap surface only handles geometry + identity; filtering
18302
- * behaviour (per-class, include/exclude, threshold) lives in the
18303
- * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
18304
- * `capabilities/schemas/zone-rule.js`.
18305
- */
18306
- var zonesCapability = {
18307
- name: "zones",
18308
- scope: "device",
18309
- mode: "singleton",
18310
- deviceTypes: [DeviceType.Camera],
18311
- methods: {
18312
- listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
18313
- addZone: method(object({
18314
- deviceId: number(),
18315
- zone: ZoneSchema
18316
- }), _void(), {
18317
- kind: "mutation",
18318
- auth: "admin"
18319
- }),
18320
- removeZone: method(object({
18321
- deviceId: number(),
18322
- zoneId: string()
18323
- }), _void(), {
18324
- kind: "mutation",
18325
- auth: "admin"
18326
- }),
18327
- updateZone: method(object({
18328
- deviceId: number(),
18329
- zone: ZoneSchema
18330
- }), _void(), {
18331
- kind: "mutation",
18332
- auth: "admin"
18333
- })
18334
- },
18335
- /**
18336
- * Runtime-state slice — the live zone catalogue mirrored by the
18337
- * orchestrator on every CRUD mutation. Consumers read via
18338
- * `device.state.zones.value` / `.watch(...)` without round-tripping
18339
- * the cap, and the codegen DeviceProxy auto-wires the reactive
18340
- * handle. Slice shape is `{ zones: Zone[] }` so future extensions
18341
- * (e.g. zone groupings) can sit alongside the polygon list.
18342
- */
18343
- runtimeState: object({ zones: array(ZoneSchema).readonly() }),
18344
- /**
18345
- * 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.
18346
- *
18347
- * See `RuntimeStateDurability`. Enforced by
18348
- * `scripts/check-runtime-state-durability.ts`.
18349
- */
18350
- durability: "restored"
18351
- };
18548
+ var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
18352
18549
  /**
18353
18550
  * A bounding box in NORMALIZED [0,1] frame coordinates for `getNativeCrop`. The
18354
18551
  * decode worker resolves it against the RETAINED native frame's real pixel dims,
@@ -20141,7 +20338,7 @@ method(object({
20141
20338
  * linking rather than produce an eternal token.
20142
20339
  */
20143
20340
  ttlSec: union([number().int().positive(), literal("never")]).optional()
20144
- }), object({ token: string() })), method(object({ token: string() }), SsoBridgeClaimsSchema.nullable());
20341
+ }), object({ token: string() }), { auth: "admin" }), method(object({ token: string() }), SsoBridgeClaimsSchema.nullable(), { auth: "admin" });
20145
20342
  var ProviderListEntrySchema = discriminatedUnion("shouldSaveDiskSpace", [object({
20146
20343
  providerId: string().min(1),
20147
20344
  displayName: string().min(1),
@@ -20236,10 +20433,13 @@ var EvictResultSchema = object({
20236
20433
  /** True when the provider has nothing left it is willing to drop on this location. */
20237
20434
  exhausted: boolean()
20238
20435
  });
20239
- method(object({ locationId: string() }), EvictableUsageSchema), method(object({
20436
+ method(object({ locationId: string() }), EvictableUsageSchema, { auth: "admin" }), method(object({
20240
20437
  locationId: string(),
20241
20438
  targetBytes: number().int().positive()
20242
- }), EvictResultSchema, { kind: "mutation" });
20439
+ }), EvictResultSchema, {
20440
+ kind: "mutation",
20441
+ auth: "admin"
20442
+ });
20243
20443
  method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin" }), method(StorageMigrationInputSchema, object({ jobId: string() }), {
20244
20444
  kind: "mutation",
20245
20445
  auth: "admin"
@@ -20299,26 +20499,50 @@ var ReadChunkInputSchema = object({
20299
20499
  length: number()
20300
20500
  });
20301
20501
  var EndDownloadInputSchema = object({ downloadId: string() });
20302
- method(_void(), ProviderInfoSchema), method(object({ config: record(string(), unknown()) }), TestLocationResultSchema, { auth: "admin" }), method(object({
20502
+ method(_void(), ProviderInfoSchema, { auth: "admin" }), method(object({ config: record(string(), unknown()) }), TestLocationResultSchema, { auth: "admin" }), method(object({
20303
20503
  location: StorageLocationSchema,
20304
20504
  relativePath: string()
20305
- }), string()), method(object({
20505
+ }), string(), { auth: "admin" }), method(object({
20306
20506
  location: StorageLocationSchema,
20307
20507
  relativePath: string(),
20308
20508
  data: _instanceof(Uint8Array)
20309
- }), _void(), { kind: "mutation" }), method(object({
20509
+ }), _void(), {
20510
+ kind: "mutation",
20511
+ auth: "admin"
20512
+ }), method(object({
20310
20513
  location: StorageLocationSchema,
20311
20514
  relativePath: string()
20312
- }), _instanceof(Uint8Array)), method(object({
20515
+ }), _instanceof(Uint8Array), { auth: "admin" }), method(object({
20313
20516
  location: StorageLocationSchema,
20314
20517
  relativePath: string()
20315
- }), boolean()), method(object({
20518
+ }), boolean(), { auth: "admin" }), method(object({
20316
20519
  location: StorageLocationSchema,
20317
20520
  prefix: string().optional()
20318
- }), array(string()).readonly()), method(object({
20521
+ }), array(string()).readonly(), { auth: "admin" }), method(object({
20319
20522
  location: StorageLocationSchema,
20320
20523
  relativePath: string()
20321
- }), _void(), { kind: "mutation" }), method(object({ location: StorageLocationSchema }), number().nullable()), method(BeginUploadInputSchema, BeginUploadResultSchema, { kind: "mutation" }), method(WriteChunkInputSchema, _void(), { kind: "mutation" }), method(FinalizeUploadInputSchema, _void(), { kind: "mutation" }), method(AbortUploadInputSchema, _void(), { kind: "mutation" }), method(BeginDownloadInputSchema, BeginDownloadResultSchema, { kind: "mutation" }), method(ReadChunkInputSchema, _instanceof(Uint8Array)), method(EndDownloadInputSchema, _void(), { kind: "mutation" });
20524
+ }), _void(), {
20525
+ kind: "mutation",
20526
+ auth: "admin"
20527
+ }), method(object({ location: StorageLocationSchema }), number().nullable(), { auth: "admin" }), method(BeginUploadInputSchema, BeginUploadResultSchema, {
20528
+ kind: "mutation",
20529
+ auth: "admin"
20530
+ }), method(WriteChunkInputSchema, _void(), {
20531
+ kind: "mutation",
20532
+ auth: "admin"
20533
+ }), method(FinalizeUploadInputSchema, _void(), {
20534
+ kind: "mutation",
20535
+ auth: "admin"
20536
+ }), method(AbortUploadInputSchema, _void(), {
20537
+ kind: "mutation",
20538
+ auth: "admin"
20539
+ }), method(BeginDownloadInputSchema, BeginDownloadResultSchema, {
20540
+ kind: "mutation",
20541
+ auth: "admin"
20542
+ }), method(ReadChunkInputSchema, _instanceof(Uint8Array), { auth: "admin" }), method(EndDownloadInputSchema, _void(), {
20543
+ kind: "mutation",
20544
+ auth: "admin"
20545
+ });
20322
20546
  /** Profile-exported FormBuilder schema. Shape is ConfigUISchema at the UI. */
20323
20547
  var ProfileSettingsSchemaBridge = unknown().nullable();
20324
20548
  var ProfileSettingsBagSchema = record(string(), unknown());
@@ -20576,7 +20800,8 @@ method(object({
20576
20800
  access: "create"
20577
20801
  }), method(object({ userId: string().optional() }), object({ optionsJSON: record(string(), unknown()) }), {
20578
20802
  kind: "mutation",
20579
- access: "view"
20803
+ access: "view",
20804
+ auth: "admin"
20580
20805
  }), method(object({
20581
20806
  /** Required — the user the assertion belongs to (verified). */
20582
20807
  userId: string(),
@@ -20584,10 +20809,12 @@ method(object({
20584
20809
  response: record(string(), unknown())
20585
20810
  }), object({ verified: boolean() }), {
20586
20811
  kind: "mutation",
20587
- access: "view"
20812
+ access: "view",
20813
+ auth: "admin"
20588
20814
  }), method(object({}), object({ optionsJSON: record(string(), unknown()) }), {
20589
20815
  kind: "mutation",
20590
- access: "view"
20816
+ access: "view",
20817
+ auth: "admin"
20591
20818
  }), method(object({
20592
20819
  /** AuthenticationResponseJSON from the browser. */
20593
20820
  response: record(string(), unknown()) }), object({
@@ -20595,7 +20822,8 @@ response: record(string(), unknown()) }), object({
20595
20822
  userId: string().nullable()
20596
20823
  }), {
20597
20824
  kind: "mutation",
20598
- access: "view"
20825
+ access: "view",
20826
+ auth: "admin"
20599
20827
  }), method(object({ userId: string() }), array(PasskeySummarySchema), { auth: "admin" }), method(object({
20600
20828
  userId: string(),
20601
20829
  credentialId: string()
@@ -20767,7 +20995,19 @@ var VectorStatsResultSchema = object({
20767
20995
  /** False when the backend ranks approximately. */
20768
20996
  exact: boolean()
20769
20997
  });
20770
- method(VectorDeclareIndexInputSchema, _void(), { kind: "mutation" }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, { kind: "mutation" }), method(VectorQueryInputSchema, VectorQueryResultSchema), method(VectorGetInputSchema, VectorGetResultSchema), method(VectorDeleteInputSchema, VectorDeleteResultSchema, { kind: "mutation" }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, { kind: "mutation" }), method(VectorStatsInputSchema, VectorStatsResultSchema);
20998
+ method(VectorDeclareIndexInputSchema, _void(), {
20999
+ kind: "mutation",
21000
+ auth: "admin"
21001
+ }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
21002
+ kind: "mutation",
21003
+ auth: "admin"
21004
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
21005
+ kind: "mutation",
21006
+ auth: "admin"
21007
+ }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
21008
+ kind: "mutation",
21009
+ auth: "admin"
21010
+ }), method(VectorStatsInputSchema, VectorStatsResultSchema, { auth: "admin" });
20771
21011
  var ClipSchema = object({
20772
21012
  /** Opaque, provider-namespaced id. The default provider encodes the time
20773
21013
  * window so `getClipPlayback` is self-contained (no event re-query). */
@@ -23220,7 +23460,27 @@ var MediaFileLiteSchema$1 = object({
23220
23460
  sizeBytes: number(),
23221
23461
  timestamp: number()
23222
23462
  });
23223
- method(_void(), array(IdentitySchema).readonly()), method(object({ name: string().min(1) }), IdentitySchema, {
23463
+ method(object({
23464
+ /**
23465
+ * Inline {@link IdentitySchema.coverBase64} on every row.
23466
+ *
23467
+ * Default `false`, the same inversion `listRecentFaces` and
23468
+ * `listPlates` took on 2026-08-25 (see `include-crops-default.ts` for
23469
+ * why the burden belongs on the caller that WANTS the bytes). Measured
23470
+ * on the live hub the same day: four identities cost 40,979 B with the
23471
+ * covers inline, ~10 KB of base64 per row, on a query this UI mounts
23472
+ * four times and the viewer holds at `staleTime: 30_000`.
23473
+ *
23474
+ * Nothing loses its avatar: `coverMediaKey` is already on every row and
23475
+ * the `event-media` plane serves that key `immutable` with an ETag.
23476
+ *
23477
+ * **This is an INPUT field, so it does not reach the addon until the
23478
+ * next train** — the hub router validates cap inputs against its own
23479
+ * compiled Zod and strips a key it does not know. Until then the
23480
+ * provider sees `undefined`, which resolves to `false`: the cheap shape
23481
+ * is what ships, and the opt-in becomes reachable when the train lands.
23482
+ */
23483
+ includeCrops: boolean().optional() }).optional(), array(IdentitySchema).readonly()), method(object({ name: string().min(1) }), IdentitySchema, {
23224
23484
  kind: "mutation",
23225
23485
  auth: "admin"
23226
23486
  }), method(object({
@@ -26156,8 +26416,10 @@ var PlateInfoSchema = object({
26156
26416
  keyFrameMediaKey: string().optional(),
26157
26417
  base64: string().optional(),
26158
26418
  /**
26159
- * Same crop as a data-plane URL. `getPlateByTrack` returns this and
26160
- * never inlines JPEG; `listPlates` still inlines for the admin-ui.
26419
+ * Same crop as a data-plane URL, always present when the plate has a stored
26420
+ * crop. `getPlateByTrack` returns this and never inlines JPEG; `listPlates`
26421
+ * and `searchPlates` inline the crop only when their `includeCrops` input is
26422
+ * left at its `true` default.
26161
26423
  */
26162
26424
  cropUrl: string().optional()
26163
26425
  });
@@ -26177,14 +26439,34 @@ var PlateClusterSchema = object({
26177
26439
  });
26178
26440
  method(object({
26179
26441
  deviceId: number().int().optional(),
26180
- limit: number().int().positive().optional()
26442
+ limit: number().int().positive().optional(),
26443
+ /**
26444
+ * Inline the base64 crop on every row. Default `true` — the existing
26445
+ * behaviour, kept so no caller breaks.
26446
+ *
26447
+ * Set `false` once the caller renders {@link PlateInfo.cropUrl}.
26448
+ * Measured on the live hub at the 500 rows the Plates view asks for:
26449
+ * 879,403 B and 27.7 s with the crops inline, against a few KiB of
26450
+ * metadata without them — and the browser then caches the images.
26451
+ *
26452
+ * This is the plate twin of `faceGallery.listRecentFaces`'s option;
26453
+ * plates were the one gallery list left without it.
26454
+ *
26455
+ * **This is an INPUT field, so it does not reach the addon until the
26456
+ * next train.** The hub router validates cap inputs against its own
26457
+ * compiled Zod and strips a key it does not know. Until the train
26458
+ * ships, sending `false` is harmless and keeps the crops inline.
26459
+ */
26460
+ includeCrops: boolean().optional()
26181
26461
  }).optional(), array(PlateInfoSchema).readonly()), method(object({
26182
26462
  deviceId: number().int(),
26183
26463
  trackId: string()
26184
26464
  }), PlateInfoSchema.nullable()), method(object({ plateId: string() }), array(MediaFileLiteSchema).readonly()), method(object({
26185
26465
  text: string().min(1),
26186
26466
  maxDistance: number().int().min(0).optional(),
26187
- limit: number().int().positive().optional()
26467
+ limit: number().int().positive().optional(),
26468
+ /** See `listPlates.includeCrops`. Default `true`. */
26469
+ includeCrops: boolean().optional()
26188
26470
  }), array(PlateInfoSchema).readonly()), method(object({
26189
26471
  maxDistance: number().int().min(0).optional(),
26190
26472
  minClusterSize: number().int().min(2).optional(),
@@ -26198,7 +26480,13 @@ method(object({
26198
26480
  }), method(object({ plateId: string() }), _void(), {
26199
26481
  kind: "mutation",
26200
26482
  auth: "admin"
26201
- }), method(_void(), array(VehicleSchema).readonly()), method(object({ name: string().min(1) }), VehicleSchema, {
26483
+ }), method(object({
26484
+ /** Inline {@link VehicleSchema.coverBase64} on every row. Default
26485
+ * `false` — the vehicle twin of `faceGallery.listIdentities`'s
26486
+ * option; `coverMediaKey` + the `event-media` plane carry the picture.
26487
+ * INPUT field: stripped by the hub router until the train ships, which
26488
+ * resolves to `false` and is exactly the intended default. */
26489
+ includeCrops: boolean().optional() }).optional(), array(VehicleSchema).readonly()), method(object({ name: string().min(1) }), VehicleSchema, {
26202
26490
  kind: "mutation",
26203
26491
  auth: "admin"
26204
26492
  }), method(object({
@@ -27806,92 +28094,6 @@ var sceneMonitorCapability = {
27806
28094
  durability: "session"
27807
28095
  };
27808
28096
  /**
27809
- * Per-stage gating mode applied to the zones a rule references.
27810
- *
27811
- * - `include`: the rule contributes to a **whitelist** for its stage.
27812
- * When at least one `include` rule fires for a stage, only entities
27813
- * inside one of those zones pass that stage.
27814
- * - `exclude`: the rule contributes to a **blacklist** for its stage.
27815
- * Entities inside one of those zones are dropped at that stage.
27816
- *
27817
- * `monitor`-style observation (count without filtering) is not a rule
27818
- * mode — zones without any matching rule are observed naturally by
27819
- * `zone-analytics` (live snapshot + history), so an "I just want to
27820
- * count, not filter" use case needs no rule at all.
27821
- */
27822
- var ZoneRuleModeEnum = _enum(["include", "exclude"]);
27823
- /**
27824
- * Per-consumer rule that references existing zones (geometry) and
27825
- * defines how a specific pipeline stage should treat them. Each
27826
- * consumer addon owns its own `ZoneRule[]` array in its per-device
27827
- * settings:
27828
- *
27829
- * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
27830
- * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
27831
- * - future: notification rules, audio gating, etc.
27832
- *
27833
- * One rule applies to N zones (`zoneIds[]`) so the operator can
27834
- * express "ignore motion in ALL of {garden, street}" with a single
27835
- * rule. `classFilter` narrows the rule to specific object classes —
27836
- * "drop person detections in the street, but keep cars" is one
27837
- * `exclude` rule with `classFilter: ['person']`.
27838
- *
27839
- * `enabled` is a soft toggle — the operator can keep the rule
27840
- * configured but inert without deleting it.
27841
- */
27842
- var ZoneRuleSchema = object({
27843
- /** Stable rule id — survives edits, used by the UI for diffing. */
27844
- id: string(),
27845
- /** Optional human-readable label rendered in the rule editor. */
27846
- name: string().optional(),
27847
- /** Zones this rule targets. The rule's `mode` applies to ALL
27848
- * listed zones (OR-set: a detection in any one of them counts).
27849
- * At least one zone id required — a rule with no targets is a
27850
- * configuration mistake and the form validator rejects it. */
27851
- zoneIds: array(string()).min(1).readonly(),
27852
- mode: ZoneRuleModeEnum,
27853
- /**
27854
- * Class names this rule applies to. Empty / undefined ⇒ rule
27855
- * applies to every class. Class strings match the `macroClass`
27856
- * field on detections (e.g. `person`, `car`, `dog`).
27857
- */
27858
- classFilter: array(string()).readonly().optional(),
27859
- /**
27860
- * Minimum bbox/mask overlap (0–1) with any of the rule's zones
27861
- * required to consider an entity "in the zone". Defaults to the
27862
- * consumer's stage default when omitted. Kept for back-compat with
27863
- * existing per-rule overrides; new operators pick the value via
27864
- * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
27865
- * set, the lower-level engine reads it as a 0–1 fraction.
27866
- */
27867
- overlapThreshold: number().min(0).max(1).optional(),
27868
- /**
27869
- * Operator-friendly version of `overlapThreshold` — the percentage
27870
- * of the detection's bbox that must lie inside the zone for the
27871
- * rule to match. Documented default is 85%; the engine substitutes
27872
- * that when the field is omitted (kept optional so existing rules
27873
- * stored without it stay valid).
27874
- *
27875
- * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
27876
- * rule, the engine prefers `bboxInclusionPct` because it's the
27877
- * field exposed in the UI. Internally both feed the same gate.
27878
- */
27879
- bboxInclusionPct: number().min(0).max(100).optional(),
27880
- /**
27881
- * When `true` and a detection has a segmentation mask, use the
27882
- * mask for overlap instead of the bbox. Detection-stage only;
27883
- * motion rules ignore this field.
27884
- */
27885
- preferMask: boolean().optional(),
27886
- /**
27887
- * Soft-toggle: `false` disables the rule without deleting it.
27888
- * Defaults to `true` so operators creating a rule via the UI
27889
- * see it active immediately.
27890
- */
27891
- enabled: boolean().default(true)
27892
- });
27893
- array(ZoneRuleSchema).readonly();
27894
- /**
27895
28097
  * Script-runner cap. Models HA `script.*` entities on
27896
28098
  * `DeviceType.Script`. A Script is a pre-recorded action sequence
27897
28099
  * that can be invoked imperatively — optionally with a variables
@@ -33977,6 +34179,12 @@ Object.freeze({
33977
34179
  addonId: null,
33978
34180
  access: "create"
33979
34181
  },
34182
+ "pipelineAnalytics.cancelRelocateMedia": {
34183
+ capName: "pipeline-analytics",
34184
+ capScope: "device",
34185
+ addonId: null,
34186
+ access: "create"
34187
+ },
33980
34188
  "pipelineAnalytics.cancelStorageMigrationMove": {
33981
34189
  capName: "pipeline-analytics",
33982
34190
  capScope: "device",
@@ -34151,6 +34359,12 @@ Object.freeze({
34151
34359
  addonId: null,
34152
34360
  access: "view"
34153
34361
  },
34362
+ "pipelineAnalytics.listRelocateMediaJobs": {
34363
+ capName: "pipeline-analytics",
34364
+ capScope: "device",
34365
+ addonId: null,
34366
+ access: "view"
34367
+ },
34154
34368
  "pipelineAnalytics.listRetrainAnnotations": {
34155
34369
  capName: "pipeline-analytics",
34156
34370
  capScope: "device",
@@ -34229,6 +34443,12 @@ Object.freeze({
34229
34443
  addonId: null,
34230
34444
  access: "create"
34231
34445
  },
34446
+ "pipelineAnalytics.relocateMedia": {
34447
+ capName: "pipeline-analytics",
34448
+ capScope: "device",
34449
+ addonId: null,
34450
+ access: "create"
34451
+ },
34232
34452
  "pipelineAnalytics.restageRetrainTrack": {
34233
34453
  capName: "pipeline-analytics",
34234
34454
  capScope: "device",
@@ -34241,6 +34461,12 @@ Object.freeze({
34241
34461
  addonId: null,
34242
34462
  access: "create"
34243
34463
  },
34464
+ "pipelineAnalytics.runReplayFrameProcessor": {
34465
+ capName: "pipeline-analytics",
34466
+ capScope: "device",
34467
+ addonId: null,
34468
+ access: "create"
34469
+ },
34244
34470
  "pipelineAnalytics.saveRetrainAnnotations": {
34245
34471
  capName: "pipeline-analytics",
34246
34472
  capScope: "device",
@@ -34373,6 +34599,12 @@ Object.freeze({
34373
34599
  addonId: null,
34374
34600
  access: "view"
34375
34601
  },
34602
+ "pipelineExecutor.getInferenceDeviceHealth": {
34603
+ capName: "pipeline-executor",
34604
+ capScope: "system",
34605
+ addonId: null,
34606
+ access: "view"
34607
+ },
34376
34608
  "pipelineExecutor.getOrchestratorConfigSchema": {
34377
34609
  capName: "pipeline-executor",
34378
34610
  capScope: "system",
@@ -34445,6 +34677,12 @@ Object.freeze({
34445
34677
  addonId: null,
34446
34678
  access: "view"
34447
34679
  },
34680
+ "pipelineExecutor.rearmInferenceDevice": {
34681
+ capName: "pipeline-executor",
34682
+ capScope: "system",
34683
+ addonId: null,
34684
+ access: "create"
34685
+ },
34448
34686
  "pipelineExecutor.runAudioTest": {
34449
34687
  capName: "pipeline-executor",
34450
34688
  capScope: "system",
@@ -37693,6 +37931,11 @@ Object.freeze({
37693
37931
  form: "single",
37694
37932
  optional: false
37695
37933
  }],
37934
+ "pipelineAnalytics.runReplayFrameProcessor": [{
37935
+ name: "deviceId",
37936
+ form: "single",
37937
+ optional: false
37938
+ }],
37696
37939
  "pipelineAnalytics.saveRetrainAnnotations": [{
37697
37940
  name: "deviceId",
37698
37941
  form: "single",