@camstack/addon-provider-reolink 1.2.50 → 1.2.52

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