@camstack/addon-provider-hikvision 1.2.35 → 1.2.37

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