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