@camstack/addon-provider-petkit 0.2.28 → 0.2.30

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
@@ -7732,7 +7732,7 @@ function method(input, output, options) {
7732
7732
  input,
7733
7733
  output,
7734
7734
  kind: options?.kind ?? "query",
7735
- auth: options?.auth ?? "protected",
7735
+ ...options?.auth !== void 0 ? { auth: options.auth } : {},
7736
7736
  ...options?.access !== void 0 ? { access: options.access } : {},
7737
7737
  ...options?.caller !== void 0 ? { caller: options.caller } : {},
7738
7738
  timeoutMs: options?.timeoutMs
@@ -7756,7 +7756,7 @@ function event(data) {
7756
7756
  }
7757
7757
  var StaticDirOutputSchema$1 = object({ staticDir: string() });
7758
7758
  var VersionOutputSchema$1 = object({ version: string() });
7759
- method(_void(), StaticDirOutputSchema$1), method(_void(), VersionOutputSchema$1);
7759
+ method(_void(), StaticDirOutputSchema$1, { auth: "admin" }), method(_void(), VersionOutputSchema$1, { auth: "admin" });
7760
7760
  var DeviceType = /* @__PURE__ */ function(DeviceType) {
7761
7761
  DeviceType["Camera"] = "camera";
7762
7762
  DeviceType["Hub"] = "hub";
@@ -8077,7 +8077,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
8077
8077
  }({});
8078
8078
  var StaticDirOutputSchema = object({ staticDir: string() });
8079
8079
  var VersionOutputSchema = object({ version: string() });
8080
- method(_void(), StaticDirOutputSchema), method(_void(), VersionOutputSchema);
8080
+ method(_void(), StaticDirOutputSchema, { auth: "admin" }), method(_void(), VersionOutputSchema, { auth: "admin" });
8081
8081
  /**
8082
8082
  * device-ops — device-scoped cap that unifies the per-IDevice operations
8083
8083
  * previously routed through the `.device-ops` Moleculer bridge service.
@@ -8703,24 +8703,6 @@ var RecordingRetentionSchema = object({
8703
8703
  maxSizeGb: number().min(0).optional()
8704
8704
  });
8705
8705
  /**
8706
- * Scrub-thumbnail fidelity preset — the single per-camera selector bundling the
8707
- * sprite tile RESOLUTION + JPEG QUALITY the recorder packs timeline-scrub
8708
- * previews at. Five graduated steps; absent on a config = `standard` (the
8709
- * shipped default, matching `sheet-geometry`/`sheet-composer`).
8710
- *
8711
- * Existing sheets are IMMUTABLE — a changed preset applies to NEW windows only.
8712
- * Each window's index sidecar carries its own tile dims, so a camera whose
8713
- * preset changed over time renders every historical window at the dims it was
8714
- * written with.
8715
- */
8716
- var ScrubThumbnailPresetSchema = _enum([
8717
- "minimal",
8718
- "low",
8719
- "standard",
8720
- "high",
8721
- "max"
8722
- ]);
8723
- /**
8724
8706
  * The full per-camera recording intent — the wire shape of a RecordingTarget.
8725
8707
  *
8726
8708
  * `bands` is the ONLY authored recording intent: what to record, when, and on
@@ -8728,7 +8710,11 @@ var ScrubThumbnailPresetSchema = _enum([
8728
8710
  * other field is a storage knob (profiles, segment length, retention, scrub).
8729
8711
  *
8730
8712
  * STRICT on purpose: the legacy authoring surface (`schedule`/`schedules`/
8731
- * `triggers`/`preBufferSec`/`postBufferSec`/`rules`) was retired 2026-07-30.
8713
+ * `triggers`/`preBufferSec`/`postBufferSec`/`rules`) was retired 2026-07-30,
8714
+ * and `scrubThumbnails` — a five-step fidelity knob for a sprite tier that was
8715
+ * deleted on 2026-07-24 and had ZERO consumers in the recorder — on 2026-08-25
8716
+ * (D62: a switch that writes a store nobody reads is worse than no switch).
8717
+ * Stored rows keep loading: the READ schema is `.strip()` (config-store.ts).
8732
8718
  * A stale caller must fail loudly — silently stripping its legacy intent would
8733
8719
  * persist a band-less config, i.e. silently stop recording the camera.
8734
8720
  */
@@ -8751,14 +8737,7 @@ var RecordingConfigSchema = object({
8751
8737
  * "off" is the absence of a covering band, never a band value.
8752
8738
  */
8753
8739
  bands: array(RecordingBandSchema).default([]),
8754
- retention: RecordingRetentionSchema.optional(),
8755
- /**
8756
- * Per-camera scrub-thumbnail fidelity preset (resolution + JPEG quality for
8757
- * timeline-scrub sprite previews). Absent = `standard`. Applies to NEW
8758
- * windows only — existing sheets are immutable, and each window's index
8759
- * carries its own tile dims so mixed-preset history renders correctly.
8760
- */
8761
- scrubThumbnails: ScrubThumbnailPresetSchema.optional()
8740
+ retention: RecordingRetentionSchema.optional()
8762
8741
  }).strict();
8763
8742
  /**
8764
8743
  * Entity-relocation job state (storage entity-routing spec, Phase 4).
@@ -8834,10 +8813,11 @@ var RelocateFootageInputSchema = object({
8834
8813
  * `RecordingConfig.enabled` or camera wrapper bindings. */
8835
8814
  var StorageMigrationLeaseInputSchema = object({ leaseId: string().min(1) });
8836
8815
  var StorageMigrationFootageMoveInputSchema = RelocateFootageInputSchema.extend({ leaseId: string().min(1) });
8837
- var StorageMigrationMediaMoveInputSchema = object({
8816
+ var RelocateMediaInputSchema = object({
8838
8817
  toLocationId: string(),
8839
8818
  throttleMbps: number().min(1).max(1e3).optional()
8840
- }).extend({ leaseId: string().min(1) });
8819
+ });
8820
+ var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
8841
8821
  /** The independently selectable logical storage classes. `recordings`
8842
8822
  * encompasses the high and mid segment profiles; `recordingsLow` is low
8843
8823
  * segments; `eventMedia` is post-analysis blobs. */
@@ -9132,7 +9112,26 @@ var LabelDefinitionSchema = object({
9132
9112
  description: string().optional(),
9133
9113
  icon: string().optional()
9134
9114
  });
9135
- var ClassMapDefinitionSchema = object({
9115
+ /**
9116
+ * Wire schema for a per-model CATALOG classMap override
9117
+ * (`ModelCatalogEntry.classMap` / `ModelConvertMetadata.classMap`) —
9118
+ * restricted to {@link CLASS_MAP_MACRO_TARGETS}, the only macros the
9119
+ * detection pipeline executor actually routes.
9120
+ *
9121
+ * This is deliberately a DIFFERENT, narrower shape than the general-purpose
9122
+ * `ClassMapDefinition` interface above (e.g. `IDetectionAddon.getClassMap()`
9123
+ * and the audio `YAMNET_TO_MACRO` catalog both use macro targets outside this
9124
+ * enum) — the two used to share the name `ClassMapDefinition`/
9125
+ * `ClassMapDefinitionSchema`, which made the schema-type-twin guard
9126
+ * (`scripts/check-schema-type-twins.ts`) flag them as a duplicated shape. They
9127
+ * are not: it is two different concepts colliding on a name. Keep this type
9128
+ * under its own name rather than reusing `ClassMapDefinition` — reusing it
9129
+ * would either narrow every `ClassMapDefinition` consumer to the four
9130
+ * detection macros (breaking `YAMNET_TO_MACRO`) or drop the validation this
9131
+ * schema exists for (see the "rejects a classMap whose target is not a
9132
+ * detection macro" test in `model-catalog-schema.test.ts`).
9133
+ */
9134
+ var DetectionCatalogClassMapSchema = object({
9136
9135
  mapping: record(string(), _enum([
9137
9136
  "person",
9138
9137
  "vehicle",
@@ -9337,7 +9336,7 @@ var ModelCatalogEntrySchema = object({
9337
9336
  * applies (Frigate / COCO public catalog). Set on a custom model whose raw
9338
9337
  * labels already ARE the CamStack macros (Scrypted identity map).
9339
9338
  */
9340
- classMap: ClassMapDefinitionSchema.optional()
9339
+ classMap: DetectionCatalogClassMapSchema.optional()
9341
9340
  });
9342
9341
  var ConvertTargetSchema = discriminatedUnion("format", [object({
9343
9342
  format: literal("openvino"),
@@ -9367,7 +9366,7 @@ var ModelConvertMetadataSchema = object({
9367
9366
  "segmentation"
9368
9367
  ]),
9369
9368
  faceAlignment: boolean().optional(),
9370
- classMap: ClassMapDefinitionSchema.optional()
9369
+ classMap: DetectionCatalogClassMapSchema.optional()
9371
9370
  });
9372
9371
  var ConvertResultSchema = object({
9373
9372
  entry: ModelCatalogEntrySchema,
@@ -10230,7 +10229,7 @@ var AddonPageDeclarationSchema = object({
10230
10229
  /** Display label for a CUSTOM `section` id (ignored for well-known ids). */
10231
10230
  sectionLabel: string().optional()
10232
10231
  });
10233
- method(_void(), array(AddonPageDeclarationSchema).readonly());
10232
+ method(_void(), array(AddonPageDeclarationSchema).readonly(), { auth: "admin" });
10234
10233
  var AddonHttpRouteSchema = object({
10235
10234
  method: _enum([
10236
10235
  "GET",
@@ -10465,7 +10464,7 @@ var WidgetMetadataSchema = object({
10465
10464
  defaultColumns: number().int().min(1).max(12).default(6),
10466
10465
  defaultRows: number().int().min(1).max(12).default(1)
10467
10466
  });
10468
- method(_void(), array(WidgetMetadataSchema).readonly());
10467
+ method(_void(), array(WidgetMetadataSchema).readonly(), { auth: "admin" });
10469
10468
  /**
10470
10469
  * `addon-widgets` — system-scoped singleton aggregator cap. Public-facing
10471
10470
  * surface that admin-ui consumes through `useAddonWidgetsListWidgets()`.
@@ -12089,7 +12088,7 @@ var CustomModelDescriptorSchema = object({
12089
12088
  stepId: string(),
12090
12089
  entry: ModelCatalogEntrySchema
12091
12090
  });
12092
- method(_void(), array(CustomModelDescriptorSchema).readonly());
12091
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
12093
12092
  /**
12094
12093
  * Query filter for settings-store collections.
12095
12094
  */
@@ -12176,7 +12175,8 @@ method(object({
12176
12175
  }), _void(), { kind: "mutation" }), method(object({
12177
12176
  namespace: string().optional(),
12178
12177
  collection: string(),
12179
- filter: QueryFilterSchema.optional()
12178
+ filter: QueryFilterSchema.optional(),
12179
+ columns: array(string()).readonly().optional()
12180
12180
  }), array(SettingsRecordSchema).readonly()), method(object({
12181
12181
  namespace: string().optional(),
12182
12182
  collection: string(),
@@ -12239,46 +12239,87 @@ var EngineInfoSchema = object({
12239
12239
  kind: _enum(["relational", "vector"]),
12240
12240
  displayName: string()
12241
12241
  });
12242
- method(_void(), EngineInfoSchema), method(object({
12242
+ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
12243
12243
  namespace: string().optional(),
12244
12244
  collection: string(),
12245
12245
  key: string()
12246
- }), unknown()), method(object({
12246
+ }), unknown(), { auth: "admin" }), method(object({
12247
12247
  namespace: string().optional(),
12248
12248
  collection: string(),
12249
12249
  key: string(),
12250
12250
  value: unknown()
12251
- }), _void(), { kind: "mutation" }), method(object({
12251
+ }), _void(), {
12252
+ kind: "mutation",
12253
+ auth: "admin"
12254
+ }), method(object({
12252
12255
  namespace: string().optional(),
12253
12256
  collection: string(),
12254
- filter: QueryFilterSchema.optional()
12255
- }), array(SettingsRecordSchema).readonly()), method(object({
12257
+ filter: QueryFilterSchema.optional(),
12258
+ /**
12259
+ * SQL-level column projection — MUST mirror `settings-store.query`.
12260
+ *
12261
+ * ⚠ An earlier version of this comment blamed Zod stripping, and that
12262
+ * was wrong — corrected 2026-08-26 after the hop map
12263
+ * (`docs/design/2026-08-26-mappa-hop-argomenti.md`) traced the path.
12264
+ * There is **no Zod parse at all** between the door and the engine: the
12265
+ * dispatcher forwards the payload verbatim and UDS carries it whole. A
12266
+ * field declared here reaches `SqliteSettingsBackend` either way.
12267
+ *
12268
+ * What actually lost `columns` was the THIRD declaration of this shape:
12269
+ * `SettingsQueryInput` in `interfaces/storage.ts`, a hand-written TS
12270
+ * interface the engine destructures from. The field existed on both
12271
+ * schemas and the engine still never read it, because nothing checks a
12272
+ * registered provider against `InferProvider<cap>` —
12273
+ * `ProviderRegistration.provider` is typed `object`.
12274
+ *
12275
+ * It is declared here anyway, and must stay in step with
12276
+ * `settings-store.query`: a caller reading only the cap definitions has
12277
+ * to be able to see that this call carries a projection.
12278
+ * `data-door-schema-parity.spec.ts` keeps the two aligned.
12279
+ */
12280
+ columns: array(string()).readonly().optional()
12281
+ }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
12256
12282
  namespace: string().optional(),
12257
12283
  collection: string(),
12258
12284
  record: SettingsRecordSchema
12259
- }), _void(), { kind: "mutation" }), method(object({
12285
+ }), _void(), {
12286
+ kind: "mutation",
12287
+ auth: "admin"
12288
+ }), method(object({
12260
12289
  namespace: string().optional(),
12261
12290
  collection: string(),
12262
12291
  id: string(),
12263
12292
  data: record(string(), unknown())
12264
- }), _void(), { kind: "mutation" }), method(object({
12293
+ }), _void(), {
12294
+ kind: "mutation",
12295
+ auth: "admin"
12296
+ }), method(object({
12265
12297
  namespace: string().optional(),
12266
12298
  collection: string(),
12267
12299
  key: string()
12268
- }), _void(), { kind: "mutation" }), method(object({
12300
+ }), _void(), {
12301
+ kind: "mutation",
12302
+ auth: "admin"
12303
+ }), method(object({
12269
12304
  namespace: string().optional(),
12270
12305
  collection: string(),
12271
12306
  filter: MutationFilterSchema
12272
- }), object({ deleted: number().int() }), { kind: "mutation" }), method(object({
12307
+ }), object({ deleted: number().int() }), {
12308
+ kind: "mutation",
12309
+ auth: "admin"
12310
+ }), method(object({
12273
12311
  namespace: string().optional(),
12274
12312
  collection: string(),
12275
12313
  filter: MutationFilterSchema,
12276
12314
  data: record(string(), unknown())
12277
- }), object({ updated: number().int() }), { kind: "mutation" }), method(object({
12315
+ }), object({ updated: number().int() }), {
12316
+ kind: "mutation",
12317
+ auth: "admin"
12318
+ }), method(object({
12278
12319
  namespace: string().optional(),
12279
12320
  collection: string(),
12280
12321
  filter: QueryFilterSchema.optional()
12281
- }), number()), method(object({
12322
+ }), number(), { auth: "admin" }), method(object({
12282
12323
  namespace: string().optional(),
12283
12324
  collection: string(),
12284
12325
  field: string(),
@@ -12288,15 +12329,18 @@ method(_void(), EngineInfoSchema), method(object({
12288
12329
  }), array(object({
12289
12330
  bucket: number().int(),
12290
12331
  count: number().int()
12291
- })).readonly()), method(object({
12332
+ })).readonly(), { auth: "admin" }), method(object({
12292
12333
  namespace: string().optional(),
12293
12334
  collection: string()
12294
- }), boolean()), method(object({
12335
+ }), boolean(), { auth: "admin" }), method(object({
12295
12336
  namespace: string().optional(),
12296
12337
  collection: string(),
12297
12338
  columns: array(CollectionColumnSchema).readonly(),
12298
12339
  indexes: array(CollectionIndexSchema).readonly().optional()
12299
- }), _void(), { kind: "mutation" });
12340
+ }), _void(), {
12341
+ kind: "mutation",
12342
+ auth: "admin"
12343
+ });
12300
12344
  /**
12301
12345
  * shm ring usage stats for a `frameSink: 'shm'` decoder session —
12302
12346
  * exposed via `decoder.getShmStats` so downstream consumers can
@@ -13603,7 +13647,7 @@ method(object({
13603
13647
  crop: _instanceof(Uint8Array),
13604
13648
  width: number(),
13605
13649
  height: number()
13606
- }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
13650
+ }), EmbeddingResultSchema, { auth: "admin" }), method(object({ text: string() }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" });
13607
13651
  /**
13608
13652
  * filesystem-browse — per-node capability for browsing the node's local
13609
13653
  * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
@@ -13896,19 +13940,22 @@ method(LlmGenerateBaseInputSchema.extend({
13896
13940
  runtime: ManagedRuntimeConfigSchema,
13897
13941
  /** The managed profile's timeout, threaded by the hub provider. */
13898
13942
  timeoutMs: number().int().positive().optional()
13899
- }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
13943
+ }), LlmGenerateResultSchema, {
13944
+ kind: "mutation",
13945
+ auth: "admin"
13946
+ }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
13900
13947
  kind: "mutation",
13901
13948
  auth: "admin"
13902
13949
  }), method(object({}), _void(), {
13903
13950
  kind: "mutation",
13904
13951
  auth: "admin"
13905
- }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
13952
+ }), method(object({}), LlmRuntimeStatusSchema, { auth: "admin" }), method(object({ model: ManagedModelRefSchema }), _void(), {
13906
13953
  kind: "mutation",
13907
13954
  auth: "admin"
13908
13955
  }), method(object({ file: string() }), _void(), {
13909
13956
  kind: "mutation",
13910
13957
  auth: "admin"
13911
- }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
13958
+ }), method(object({}), array(LlmNodeModelSchema), { auth: "admin" }), method(object({}), LlmRuntimeDiskUsageSchema, { auth: "admin" });
13912
13959
  /**
13913
13960
  * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
13914
13961
  * methods concat-fan across providers; single-row methods route to ONE
@@ -17419,1748 +17466,1998 @@ var OauthIntegrationDescriptorSchema = object({
17419
17466
  */
17420
17467
  refreshTokenTtlSec: union([number().int().positive(), literal("never")]).optional()
17421
17468
  });
17422
- method(_void(), OauthIntegrationDescriptorSchema);
17469
+ method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
17423
17470
  /**
17424
- * pipeline-analytics device-scoped wrapper cap. Refines raw
17425
- * per-frame detections emitted by the pipeline runner into tracked
17426
- * objects, per-kind event collections (motion / object / audio), and
17427
- * persisted media. Owns the post-detection domain end-to-end:
17428
- *
17429
- * runner emits PipelineInferenceResult
17430
- * ↓ (event bus)
17431
- * pipeline-analytics subscriber
17432
- * ↓ SORT tracker + zone engine + state analyzer + event emitter
17433
- * → three DB collections (one per kind), one FS media tree, one
17434
- * unified event emitter (FrameTracked + TrackStarted/Ended +
17435
- * DetectionEvent on bus)
17436
- *
17437
- * Pure subscriber model. No `processFrame` cap method — the runner
17438
- * already publishes the raw frame on the bus. The cap surface is
17439
- * only QUERIES + per-device settings, bound on/off via
17440
- * `device-manager.setWrapperActive`. `defaultActive: true` because
17441
- * every camera with a detection pipeline wants its raw detections
17442
- * refined; operators opt out per-device via BindingsTab when needed.
17443
- *
17444
- * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
17445
- * (per-device surface) and `track-trail` caps — see P11 cleanup.
17471
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
17472
+ * within the frame, so the executor can re-cut a leaf child ROI at native
17473
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
17446
17474
  */
17447
- var TrackStateSchema = _enum([
17448
- "new",
17449
- "entered",
17450
- "left",
17451
- "moving",
17452
- "idle"
17453
- ]);
17454
- var EventKindSchema = _enum([
17455
- "motion",
17456
- "object",
17457
- "audio"
17458
- ]);
17475
+ var NativeCropRefSchema = object({
17476
+ /** Handle keying the retained native surface (node-pinned to its owner). */
17477
+ handle: FrameHandleSchema,
17478
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
17479
+ cropFrameSpace: object({
17480
+ x: number(),
17481
+ y: number(),
17482
+ w: number(),
17483
+ h: number()
17484
+ })
17485
+ });
17486
+ object({
17487
+ crop: object({
17488
+ left: number(),
17489
+ top: number(),
17490
+ width: number().positive(),
17491
+ height: number().positive()
17492
+ }).optional(),
17493
+ content: object({
17494
+ width: number().int().positive(),
17495
+ height: number().int().positive()
17496
+ }),
17497
+ fit: _enum(["stretch", "contain"]),
17498
+ format: _enum([
17499
+ "rgb",
17500
+ "gray",
17501
+ "jpeg"
17502
+ ])
17503
+ });
17459
17504
  /**
17460
- * Spatial filter for `listTracks` the rect + polygon variants of the shared
17461
- * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
17462
- * of the camera frame (top-left origin), matching the drawing-plane editor.
17505
+ * Process-local frame identity. It is serializable so it can ride an in-process
17506
+ * capability call, but `registryId` deliberately prevents resolution in any
17507
+ * other process or execution group.
17463
17508
  */
17464
- var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
17465
- /** Closed icon vocabulary so clients render a known glyph per kind. */
17466
- var EventKindIconSchema = _enum([
17467
- "motion",
17468
- "audio",
17469
- "person",
17470
- "vehicle",
17471
- "animal",
17472
- "door",
17473
- "pir",
17474
- "smoke",
17475
- "water",
17476
- "button",
17477
- "package",
17478
- "generic"
17509
+ var FrameRefSchema = object({
17510
+ registryId: string().min(1),
17511
+ id: string().min(1),
17512
+ width: number().int().positive(),
17513
+ height: number().int().positive(),
17514
+ format: _enum(["rgb", "gray"]),
17515
+ timestamp: number(),
17516
+ capturedAt: number().optional()
17517
+ });
17518
+ var ModelFormatSchema$1 = _enum([
17519
+ "onnx",
17520
+ "coreml",
17521
+ "openvino",
17522
+ "tflite",
17523
+ "pt",
17524
+ "gguf"
17479
17525
  ]);
17480
- var EventKindCategorySchema = _enum([
17481
- "motion",
17482
- "audio",
17483
- "detection",
17484
- "sensor",
17485
- "control",
17486
- "custom",
17487
- "package"
17526
+ var PipelineSlotSchema = _enum([
17527
+ "detector",
17528
+ "cropper",
17529
+ "classifier",
17530
+ "refiner",
17531
+ "audio-classifier"
17488
17532
  ]);
17489
- /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
17490
- var EventKindLevelSchema = _enum(["macro", "sub"]);
17491
- var EventKindDescriptorSchema = object({
17492
- /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
17493
- kind: string(),
17494
- /** i18n key resolved on the UI side; `label` is the English fallback. */
17495
- labelKey: string(),
17496
- /** English fallback label (kept for clients that don't translate). */
17497
- label: string(),
17498
- /** Hex color for timeline/legend rendering. */
17499
- color: string(),
17500
- /** Dictionary id → lucide component on the UI side. */
17501
- iconId: string(),
17502
- /** Legacy closed-vocab glyph — fallback for `iconId`. */
17503
- icon: EventKindIconSchema,
17504
- category: EventKindCategorySchema,
17505
- /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
17506
- parentKind: string().nullable(),
17507
- /** Derived from `parentKind`, explicit for the client tree. */
17508
- level: EventKindLevelSchema,
17509
- /** Which cap + device contributes this kind. For built-ins the camera
17510
- * itself; for sensor kinds the LINKED source device. */
17511
- source: object({
17512
- capName: string(),
17513
- deviceId: number()
17514
- })
17533
+ var PipelineEngineChoiceSchema = object({
17534
+ runtime: _enum(["node", "python"]),
17535
+ backend: string(),
17536
+ format: ModelFormatSchema$1,
17537
+ device: string().optional()
17515
17538
  });
17516
- /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
17517
- var EventKindsForDeviceSchema = object({
17518
- deviceId: number(),
17519
- kinds: array(EventKindDescriptorSchema).readonly()
17539
+ var AvailableEngineSchema = object({
17540
+ engine: PipelineEngineChoiceSchema,
17541
+ devices: array(object({
17542
+ id: string(),
17543
+ label: string(),
17544
+ description: string().optional()
17545
+ })).readonly(),
17546
+ defaultDevice: string()
17520
17547
  });
17521
- var SensorEventSchema = object({
17548
+ var PipelineDefaultStepSchema = lazy(() => object({
17549
+ addonId: string(),
17550
+ addonName: string(),
17551
+ slot: PipelineSlotSchema,
17552
+ inputClasses: array(string()).readonly(),
17553
+ outputClasses: array(string()).readonly(),
17554
+ enabled: boolean(),
17555
+ modelId: string(),
17556
+ children: array(PipelineDefaultStepSchema).readonly(),
17557
+ group: string().optional(),
17558
+ settings: record(string(), unknown()).optional()
17559
+ }));
17560
+ var PipelineTemplateStepSchema = lazy(() => object({
17561
+ addonId: string(),
17562
+ enabled: boolean(),
17563
+ modelId: string(),
17564
+ children: array(PipelineTemplateStepSchema).readonly(),
17565
+ settings: record(string(), unknown()).optional()
17566
+ }));
17567
+ var PipelineTemplateSchema$1 = object({
17522
17568
  id: string(),
17523
- /** The CAMERA the event is attributed to (a sensor linked to N cameras
17524
- * yields N rows, one per camera). */
17525
- deviceId: number(),
17526
- /** The linked sensor device whose state changed. */
17527
- sourceDeviceId: number(),
17528
- /** Event kind id — matches an `EventKindDescriptor.kind`. */
17529
- kind: string(),
17530
- /** Snapshot of the sensor cap's runtime-state slice at the change. */
17531
- value: record(string(), unknown()).nullable(),
17532
- timestamp: number()
17533
- });
17534
- var TrackPositionSchema = object({
17535
- x: number(),
17536
- y: number(),
17537
- timestamp: number(),
17538
- bbox: BoundingBoxSchema
17569
+ name: string(),
17570
+ createdAt: string(),
17571
+ updatedAt: string(),
17572
+ engine: PipelineEngineChoiceSchema,
17573
+ steps: array(PipelineTemplateStepSchema).readonly()
17539
17574
  });
17540
- var TrackSnapshotSchema = object({
17541
- timestamp: number(),
17542
- position: TrackPositionSchema,
17543
- /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
17544
- mediaKey: string()
17575
+ var PipelineModelOptionSchema = object({
17576
+ id: string(),
17577
+ name: string(),
17578
+ formats: record(string(), object({
17579
+ downloaded: boolean(),
17580
+ sizeMB: number()
17581
+ })),
17582
+ group: ModelVariantGroupSchema.optional(),
17583
+ legacy: boolean().optional(),
17584
+ provider: ModelProviderIdSchema.optional()
17545
17585
  });
17546
- /**
17547
- * Normalized 0..1 trajectory envelope (min/max over every position bbox,
17548
- * divided by the track's detection-frame dims), computed at persist time.
17549
- * Absent when the frame dims were unknown when the track was persisted
17550
- * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
17551
- */
17552
- var TrackEnvelopeSchema = object({
17553
- minX: number(),
17554
- minY: number(),
17555
- maxX: number(),
17556
- maxY: number()
17586
+ var ConfigFieldBridge = custom();
17587
+ var PipelineAddonSchemaSchema = object({
17588
+ id: string(),
17589
+ name: string(),
17590
+ slot: PipelineSlotSchema,
17591
+ inputClasses: array(string()).readonly(),
17592
+ outputClasses: array(string()).readonly(),
17593
+ childSlots: array(PipelineSlotSchema).readonly(),
17594
+ models: array(PipelineModelOptionSchema).readonly(),
17595
+ defaultModelId: string(),
17596
+ defaultModelIdByFormat: record(string(), string()).optional(),
17597
+ enabledByDefault: boolean().optional(),
17598
+ backfillIntoExistingOverrides: boolean().optional(),
17599
+ defaultConfidence: number(),
17600
+ group: string().optional(),
17601
+ configSchema: array(ConfigFieldBridge).readonly().optional()
17557
17602
  });
17558
- /**
17559
- * Row projection for track list queries. `full` (default) returns the
17560
- * complete Track including the frame-rate `positions[]` history and the
17561
- * `snapshots[]` references — megabytes across a page of tracks. `slim`
17562
- * keeps every scalar the list surfaces actually render (ids, class(es),
17563
- * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
17564
- * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
17565
- * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
17566
- * `getTrack`. Mirrors the event-store `projection` convention
17567
- * (`getObjectEvents` et al.).
17568
- */
17569
- var TrackProjectionSchema = _enum(["full", "slim"]);
17570
- /**
17571
- * One audio-classification label heard on the track's camera while the
17572
- * track was alive, aggregated per label. An "episode" is one persisted
17573
- * audio event (the confident-classification path: score ≥ the device's
17574
- * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
17575
- * one 32 ms inference chunk, so counts stay human-scaled.
17576
- */
17577
- var TrackAudioLabelSchema = object({
17603
+ var PipelineSlotSchemaSchema = object({
17604
+ id: PipelineSlotSchema,
17578
17605
  label: string(),
17579
- /** Highest classification score observed across the label's episodes. */
17580
- peakScore: number(),
17581
- /** Number of coalesced audio-event episodes carrying this label. */
17582
- count: number(),
17583
- firstAt: number(),
17584
- lastAt: number()
17606
+ priority: number(),
17607
+ parentSlot: PipelineSlotSchema.nullable(),
17608
+ addons: array(PipelineAddonSchemaSchema).readonly()
17585
17609
  });
17586
- /**
17587
- * How a track was produced. `pipeline` (default / absent) = the spatial
17588
- * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
17589
- * no positions, a single snapshot, and no bbox trajectory at all:
17590
- *
17591
- * - `sensor` — a linked sensor/control device state change.
17592
- * - `audio` — an audio event on the camera itself that was anomalous for
17593
- * THAT camera, loud, and heard while nothing visual was happening (D62).
17594
- *
17595
- * The spatial subsystems (tracker association, occupancy count, re-id /
17596
- * embedding, resurrection) MUST skip every synthetic source. Test for that
17597
- * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
17598
- * check silently readmits every source added after it was written.
17599
- */
17600
- var TrackSourceSchema = _enum([
17601
- "pipeline",
17602
- "sensor",
17603
- "audio"
17604
- ]);
17605
- /**
17606
- * Where a track sits in the RETRAIN lifecycle (D81).
17607
- *
17608
- * - `none` — never marked, or un-marked. Evictable.
17609
- * - `staging` — the operator wants this track as training material and has not
17610
- * finished with it. **This is the only state retention holds**: the track and
17611
- * everything it owns (object events, crops, keyframes, CLIP vector) survive
17612
- * the device's age window.
17613
- * - `trained` — the retrain page has taken what it needed. The frames it chose
17614
- * were COPIED into the retrain dataset at selection time, so the dataset no
17615
- * longer depends on the track's media and the track becomes EVICTABLE again.
17616
- * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
17617
- * a deliberate action of the retrain page, not a side effect of a checkbox.
17618
- *
17619
- * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
17620
- * the store's filter language has only positive equality and `whereIn` — no
17621
- * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
17622
- * would make the entire pre-column history immortal in one deploy.
17623
- */
17624
- var RetrainStatusSchema = _enum([
17625
- "none",
17626
- "staging",
17627
- "trained"
17628
- ]);
17629
- /**
17630
- * Per-track OPERATOR flags — set by hand from the admin UI or the viewer, never
17631
- * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
17632
- * so the two surfaces cannot drift.
17633
- *
17634
- * **Absent ≠ false.** A track that has never been touched omits the field; an
17635
- * explicitly un-flagged track carries `false`. Legacy rows written before the
17636
- * columns existed read as absent, and a consumer that needs a boolean should say
17637
- * `flag === true`, not `flag !== false`.
17638
- *
17639
- * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
17640
- * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
17641
- * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
17642
- * `trained` track reports `false` while refusing both writes. The boolean is
17643
- * kept because three surfaces drive a toggle off it; anything that needs to tell
17644
- * "never marked" from "already trained" must read `retrainStatus`.
17645
- *
17646
- * `debug` does NOT pin; it is attention, not durability.
17647
- *
17648
- * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
17649
- * A favourited track is skipped by retention the same way `staging` is, but
17650
- * it does not enter `none|staging|trained` and has no staging budget.
17651
- */
17652
- var TrackFlagFields = {
17653
- /** Operator marked this track as training material — i.e. `retrainStatus` is
17654
- * `'staging'`. */
17655
- markForTrain: boolean().optional(),
17656
- /** Operator marked this track for diagnostic attention. */
17657
- debug: boolean().optional(),
17658
- /** Operator favourited this track. Pins it against pruning. */
17659
- favourited: boolean().optional()
17660
- };
17661
- /**
17662
- * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
17663
- * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
17664
- * write patch, and the status is not something the toggle sets — it is what the
17665
- * toggle's boolean is derived from. Absent on an in-RAM track never touched;
17666
- * always present on a persisted row (the column default materialises `'none'`).
17667
- */
17668
- var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
17669
- /**
17670
- * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
17671
- * one flag can never clear the other — the toggles are independent and are
17672
- * driven from three surfaces that do not know about each other.
17673
- */
17674
- var TrackFlagsPatchSchema = object(TrackFlagFields);
17675
- /**
17676
- * The resolved flag state after a write. Both fields are REQUIRED here (absent
17677
- * collapses to `false`) so a caller can drive a toggle's checked state off the
17678
- * mutation result without a re-fetch.
17679
- */
17680
- var TrackFlagsSchema = object({
17681
- trackId: string(),
17682
- markForTrain: boolean(),
17683
- debug: boolean(),
17684
- favourited: boolean(),
17685
- /** The lifecycle state the boolean was derived from. Required here (unlike on
17686
- * a track row) because this shape is only ever produced by the write body,
17687
- * which always knows it — and a surface that has just written needs to render
17688
- * `trained` without a re-fetch. */
17689
- retrainStatus: RetrainStatusSchema
17610
+ var PipelineSchemaSchema = object({
17611
+ availableEngines: array(AvailableEngineSchema).readonly(),
17612
+ selectedEngine: PipelineEngineChoiceSchema,
17613
+ slots: array(PipelineSlotSchemaSchema).readonly()
17690
17614
  });
17691
- union([literal(1), literal(2)]);
17692
- /**
17693
- * WHO decided a label, and when. Carried per tier so a value can be traced to
17694
- * the step and model that produced it — which is what makes the write rule
17695
- * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
17696
- * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
17697
- *
17698
- * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
17699
- * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
17700
- * `migration:4g` for a value the 4g migration moved from the single-slot era —
17701
- * that value has no provenance, and the write rule lets ANY properly-attributed
17702
- * write of the same tier replace it regardless of score.
17703
- */
17704
- var LabelAttributionSchema = object({
17705
- stepId: string(),
17706
- modelId: string().optional(),
17707
- decidedAt: number(),
17615
+ var EngineProvisioningSchema = object({
17616
+ runtimeId: _enum([
17617
+ "onnx",
17618
+ "openvino",
17619
+ "coreml",
17620
+ "edgetpu"
17621
+ ]).nullable(),
17622
+ device: string().nullable(),
17623
+ state: _enum([
17624
+ "idle",
17625
+ "installing",
17626
+ "verifying",
17627
+ "ready",
17628
+ "failed"
17629
+ ]),
17630
+ progress: number().optional(),
17631
+ error: string().optional(),
17632
+ nextRetryAt: number().optional(),
17708
17633
  /**
17709
- * The GALLERY id behind a recognised tier-2 label — a face-gallery
17710
- * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
17711
- *
17712
- * The text alone is a DISPLAY NAME, and a display name is renameable: a
17713
- * notification rule authored on "Gianluca" stopped matching the moment the
17714
- * operator fixed the spelling in the gallery, and nothing said so. The id is
17715
- * the thing that does not move, so it is what a rule matches on
17716
- * (`NcConditions.identities`) and the text is what a human is shown.
17717
- *
17718
- * Absent when the label names no gallery row — a plate the OCR read but no
17719
- * vehicle claims, a sub-class, a species, any tier-1 value.
17634
+ * Gate A (config-correctness gate at engine change): human-readable
17635
+ * config issues surfaced EAGERLY when the node's engine changes — model
17636
+ * substitutions ("chose X, running Y") and zero-build steps ("no model
17637
+ * has a <format> build"). Additive/optional: informational only, never
17638
+ * enforced here `assertEngineReady` (readiness) still gates inference.
17639
+ * Absent/empty when the node-default tree resolves cleanly.
17720
17640
  */
17721
- identityId: string().optional()
17641
+ configIssues: array(string()).optional()
17722
17642
  });
17723
- /**
17724
- * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
17725
- * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
17726
- * track and its events always answer the same question the same way.
17727
- *
17728
- * Two scalar columns, not an array: every consumer wants "the coarse one" or
17729
- * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
17730
- * is tier 2, and each carries its own score + attribution.
17731
- *
17732
- * **Reading it.** What a human should be shown is `subLabel ?? label` — the
17733
- * finest thing known. Before 4g the single `label` column held the finest
17734
- * value, so a consumer that has not been updated reads the tier-1 slot and
17735
- * shows nothing on a species-only row; that is why the migration puts every
17736
- * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
17737
- * and why the read surfaces were changed in the same train.
17738
- *
17739
- * **Writing it.** The slots are independent, which is the whole point: a
17740
- * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
17741
- * migratorius`), so fineness cannot regress by construction. Within a tier the
17742
- * higher score wins. One rule, one implementation — see
17743
- * `pipeline/label-tier.ts` in addon-post-analysis.
17744
- */
17745
- var TieredLabelFields = {
17746
- /** Tier 1 the sub-class. See {@link LabelTierSchema}. */
17747
- label: string().optional(),
17748
- /** Confidence of the tier-1 value, as reported by the deciding step. */
17749
- labelScore: number().optional(),
17750
- /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
17751
- labelMeta: LabelAttributionSchema.optional(),
17752
- /** Tier 2 — the instance. See {@link LabelTierSchema}. */
17753
- subLabel: string().optional(),
17754
- /** Confidence of the tier-2 value, as reported by the deciding step. */
17755
- subLabelScore: number().optional(),
17756
- /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
17757
- subLabelMeta: LabelAttributionSchema.optional()
17758
- };
17759
- /** Per-camera slice of a training-export estimate. */
17760
- var TrainingExportDeviceTotalsSchema = object({
17761
- deviceId: number(),
17762
- tracks: number().int(),
17763
- files: number().int(),
17764
- bytes: number().int()
17643
+ var PipelineStepInputSchema = lazy(() => object({
17644
+ addonId: string(),
17645
+ modelId: string().optional(),
17646
+ enabled: boolean().default(true),
17647
+ children: array(PipelineStepInputSchema).optional(),
17648
+ settings: record(string(), unknown()).optional(),
17649
+ jumpDeviceKey: string().optional()
17650
+ }));
17651
+ var ModelSubstitutionSchema = object({
17652
+ addonId: string(),
17653
+ chosen: string(),
17654
+ running: string(),
17655
+ format: string()
17656
+ });
17657
+ var PipelineValidationIssueSchema = object({
17658
+ addonId: string(),
17659
+ kind: _enum(["unknown-addon", "no-format-build"]),
17660
+ detail: string()
17661
+ });
17662
+ var PipelineValidationResultSchema = object({
17663
+ ok: boolean(),
17664
+ issues: array(PipelineValidationIssueSchema).readonly(),
17665
+ substitutions: array(ModelSubstitutionSchema).readonly(),
17666
+ /** The node's `currentEngine.format` this validation ran against. */
17667
+ format: string()
17668
+ });
17669
+ var ReferenceImageEntrySchema = object({
17670
+ filename: string(),
17671
+ stepIds: array(string()).readonly().optional()
17672
+ });
17673
+ var ReferenceImageBodySchema = object({
17674
+ base64: string(),
17675
+ filename: string()
17676
+ });
17677
+ var ReferenceAudioEntrySchema = object({
17678
+ filename: string(),
17679
+ sizeKb: number()
17680
+ });
17681
+ var ReferenceAudioBodySchema = object({ base64: string() });
17682
+ var AudioBackendSchema = object({
17683
+ id: string(),
17684
+ name: string(),
17685
+ description: string(),
17686
+ available: boolean(),
17687
+ /**
17688
+ * Raw classifier labels this backend can emit (e.g. YAMNet's
17689
+ * 521-class set or Apple SoundAnalysis's 303-class set). Used by
17690
+ * the benchmark UI to populate the `enabledMicroClasses` filter
17691
+ * specific to the selected backend without a separate fetch.
17692
+ */
17693
+ rawLabels: array(string()).readonly().optional()
17694
+ });
17695
+ var AudioCapabilitiesSchema = object({
17696
+ activeBackend: string(),
17697
+ availableBackends: array(AudioBackendSchema).readonly(),
17698
+ sampleRate: number(),
17699
+ chunkDurationMs: number()
17700
+ });
17701
+ var DownloadModelResultSchema = object({
17702
+ filePath: string(),
17703
+ sizeMB: number(),
17704
+ durationMs: number()
17765
17705
  });
17766
17706
  /**
17767
- * What a training export WOULD contain. Computed from media index rows only —
17768
- * no blob is read to produce this.
17707
+ * Wrapper carrying a single test run's result. Replaces the legacy
17708
+ * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
17709
+ * canonical `AudioResult` from the Phase 6 output rework: one
17710
+ * `AudioDetection` per class above `minScore`, top-N candidates in
17711
+ * `debug.alternateLabels['audio-classifier']`, per-source timings in
17712
+ * `debug.stepTimings`. The outer `success`/`error` fields stay so the
17713
+ * benchmark UI can still report a clean failure when the classifier
17714
+ * cap isn't available.
17769
17715
  */
17770
- var TrainingExportSummarySchema = object({
17771
- generatedAt: number(),
17772
- trackCount: number().int(),
17773
- fileCount: number().int(),
17774
- byteCount: number().int(),
17775
- /** More marked tracks exist than a single pass carries. */
17776
- truncated: boolean(),
17777
- devices: array(TrainingExportDeviceTotalsSchema).readonly()
17716
+ var AudioTestResultSchema = object({
17717
+ success: boolean(),
17718
+ error: string().optional(),
17719
+ frame: custom().optional()
17778
17720
  });
17779
- var TrackSchema = object({
17780
- trackId: string(),
17781
- deviceId: number(),
17782
- className: string(),
17783
- ...TieredLabelFields,
17784
- producingDeviceName: string().optional(),
17785
- /** Track provenance. Absent `pipeline` (legacy rows). */
17786
- source: TrackSourceSchema.optional(),
17787
- firstSeen: number(),
17788
- lastSeen: number(),
17789
- /** Frame-rate position history (subject to maxPositionHistory cap). */
17790
- positions: array(TrackPositionSchema).readonly(),
17791
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
17792
- * saveThumbnails policy). */
17793
- snapshots: array(TrackSnapshotSchema).readonly(),
17794
- /** Deduplicated zones the track has entered at least once. Zone IDS. */
17795
- zonesVisited: array(string()).readonly(),
17721
+ var PipelineConfigBridge = custom();
17722
+ var ConfigUISchemaBridge = custom();
17723
+ var ConfigUISchemaNullableBridge = custom();
17724
+ var InferenceCapabilitiesBridge = custom();
17725
+ var ModelAvailabilityListBridge = custom();
17726
+ var PipelineRunResultBridge = custom();
17727
+ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
17728
+ modelId: string(),
17729
+ settings: record(string(), unknown()).readonly()
17730
+ }))), method(object({ steps: record(string(), object({
17731
+ modelId: string(),
17732
+ settings: record(string(), unknown()).readonly()
17733
+ })) }), object({ success: literal(true) }), {
17734
+ kind: "mutation",
17735
+ auth: "admin"
17736
+ }), method(object({ nodeId: string() }), object({
17737
+ success: literal(true),
17738
+ clearedDevices: number()
17739
+ }), {
17740
+ kind: "mutation",
17741
+ auth: "admin"
17742
+ }), method(object({ nodeId: string() }), object({ unhealthy: array(object({
17743
+ /** `<backend>:<device>`, e.g. `openvino:gpu`. */
17744
+ deviceKey: string(),
17796
17745
  /**
17797
- * Human NAMES for {@link zonesVisited}, resolved at READ time against the
17798
- * `zones` capability.
17799
- *
17800
- * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
17801
- * and no card can render — so every free-text search surface was structurally
17802
- * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
17803
- * just returned nothing. Resolving here rather than in each client keeps ONE
17804
- * derivation and costs the clients no extra call (the `zones` cap is
17805
- * per-device, so a client-side resolve would be a per-camera fan-out on a
17806
- * surface built to avoid exactly that).
17807
- *
17808
- * Resolved, never invented: a zone deleted since the track was written has no
17809
- * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
17810
- * two are not positionally aligned. Absent when the track visited no zone, or
17811
- * when the zone catalogue could not be read.
17746
+ * `failed` the per-device restart budget is exhausted; no pool
17747
+ * will be spawned until an operator re-arms it or the runner
17748
+ * respawns. `backoff` — under budget, waiting out the backoff (or
17749
+ * a cached pool observed dead and not yet condemned).
17812
17750
  */
17813
- zoneNames: array(string()).readonly().optional(),
17814
- /** Deduplicated set of detector classes observed for this track over its
17815
- * life (a track may be reclassified, e.g. person→vehicle). Absent on
17816
- * legacy rows written before class accumulation shipped. */
17817
- classes: array(string()).readonly().optional(),
17818
- /** Cumulative normalized distance travelled (0..1 units = full frame width). */
17819
- totalDistance: number(),
17820
- state: TrackStateSchema,
17821
- active: boolean(),
17822
- /** Deterministic key-event importance score in [0,1] (server-computed at
17823
- * track expiry, recomputed on late label). Absent on legacy rows written
17824
- * before scoring shipped — consumers degrade to absence / compute-on-read. */
17825
- importance: number().optional(),
17826
- /** Id of the track's highest-confidence ObjectEvent (its representative
17827
- * "best" frame). Absent when the track produced no object events. */
17828
- bestEventId: string().optional(),
17829
- /** Tag of the importance sub-signal that dominated the score
17830
- * (identity|dwell|proximity|class|confidence|travel|zone). */
17831
- importanceReason: string().optional(),
17832
- /** Audio-classification labels heard on the camera during the track's
17833
- * life (score ≥ device `classificationMinScore`), aggregated per label.
17834
- * Absent on legacy rows / tracks with no confident audio. */
17835
- audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
17836
- /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
17837
- * Populated from the persisted envelope columns on historical reads;
17838
- * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
17839
- envelope: TrackEnvelopeSchema.optional(),
17751
+ state: _enum(["failed", "backoff"]),
17752
+ /** Epoch ms of the death that produced this state. */
17753
+ since: number(),
17754
+ /** Pool deaths inside the current window. */
17755
+ deaths: number(),
17756
+ /** The last death's message. */
17757
+ lastError: string()
17758
+ })).readonly() })), method(object({
17759
+ nodeId: string(),
17760
+ deviceKey: string()
17761
+ }), object({ rearmed: boolean() }), {
17762
+ kind: "mutation",
17763
+ auth: "admin"
17764
+ }), 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({
17765
+ name: string(),
17766
+ steps: array(PipelineTemplateStepSchema).readonly(),
17767
+ engine: PipelineEngineChoiceSchema
17768
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
17769
+ id: string(),
17770
+ name: string().optional(),
17771
+ steps: array(PipelineTemplateStepSchema).readonly().optional()
17772
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
17773
+ addonId: string(),
17774
+ modelId: string(),
17775
+ format: ModelFormatSchema$1
17776
+ }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
17777
+ addonId: string(),
17778
+ modelId: string(),
17779
+ format: ModelFormatSchema$1
17780
+ }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
17781
+ engine: PipelineEngineChoiceSchema.optional(),
17782
+ steps: array(PipelineStepInputSchema).min(1),
17783
+ frame: FrameInputSchema.optional(),
17840
17784
  /**
17841
- * A face DETECTOR found a face on this track — nothing more. It says the
17842
- * detail plane produced a `face` detail; it does NOT say the face was
17843
- * embedded, matched, above `minFacePx`, or that the recognizer was even
17844
- * enabled. Set once and never cleared.
17845
- *
17846
- * **This exists so "face present but not recognised" is expressible.** A
17847
- * recognised identity lands in `subLabel` (attributed to the face chain via
17848
- * `subLabelMeta.stepId`), so before this field a track with an unmatched face
17849
- * and a track with no face at all were byte-identical on the wire and no
17850
- * surface could tell them apart. The read is `hasFace === true && subLabel
17851
- * === undefined`.
17852
- *
17853
- * **Absent ≠ false.** Every row written before the column existed omits it,
17854
- * and so does every server that predates the field — a consumer must test
17855
- * `=== true` and render nothing otherwise, never infer "no face".
17785
+ * Process-local lazy frame. Valid only when caller and provider resolve
17786
+ * in the same execution-group process; split/cross-node callers use
17787
+ * `frame`/`image` inline compatibility instead.
17856
17788
  */
17857
- hasFace: boolean().optional(),
17789
+ frameRef: FrameRefSchema.optional(),
17858
17790
  /**
17859
- * This track has a face row IN THE GALLERY: a crop **and** an embedding a
17860
- * face an operator could ASSIGN to an identity.
17861
- *
17862
- * The STRICT twin of {@link hasFace}, and the pair only earns its keep
17863
- * because the two disagree. `hasFace` is stamped at the TOP of the face
17864
- * branch, before every gate, and means no more than "a face detector produced
17865
- * a face detail". This one is stamped at the single moment the gallery row
17866
- * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
17867
- * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
17868
- * candidate gate, the imageless-track drop (no crop was ever captured) and
17869
- * the crop-store drop. Everything between the detector and that insert can
17870
- * legitimately refuse the face, so a flag written any earlier promises the
17871
- * operator something to assign and delivers nothing.
17872
- *
17873
- * **Independent of recognition.** A face collected but never auto-matched is
17874
- * still assignable — it is in fact the face an operator most wants to reach —
17875
- * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
17876
- * `subLabel`; this says only that the raw material exists.
17877
- *
17878
- * **Set once, never cleared.** A track that produced a gallery row produced
17879
- * one; deleting the row later is the gallery's business, not this flag's.
17880
- *
17881
- * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
17882
- * before the column omits it, and so does every server that predates the
17883
- * field. A consumer must test `=== true` and render nothing otherwise —
17884
- * never infer "no assignable face".
17791
+ * CB5 shm passthrough a `FrameHandle` naming the same ring slot
17792
+ * the decoded pixels live in. One more member of the one-of
17793
+ * frame/frameHandle/image/imageBase64/referenceImage group.
17885
17794
  */
17886
- hasEmbeddedFace: boolean().optional(),
17795
+ frameHandle: FrameHandleSchema.optional(),
17796
+ imageBase64: string().optional(),
17887
17797
  /**
17888
- * This subject CONTAINS a folded rider a person the rider-pairing step
17889
- * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
17890
- * so the passage is tracked once and as a VEHICLE.
17891
- *
17892
- * It exists because the fold's record was dishonest. D34 and the code both
17893
- * said "the person is not lost — it is reported so both entities stay on the
17894
- * record"; in fact the pair went into a per-processor RAM field behind an
17895
- * accessor nobody called, and every durable surface said `vehicle`, full
17896
- * stop. This is the composition note that makes the row true.
17897
- *
17898
- * A COMPOSITION, never a class and never a label. "This vehicle contains a
17899
- * person" is not an answer to "what is this" — both label tiers would refuse
17900
- * a macro token anyway (D89), and correctly. Nothing here changes what the
17901
- * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
17902
- * and a `person` rule still does not fire for someone cycling past.
17903
- *
17904
- * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
17905
- * the column, and every hub that predates the field, omits it. Test
17906
- * `=== true` and render nothing otherwise — never infer "no rider".
17798
+ * Binary JPEG bytespreferred over `imageBase64` on internal
17799
+ * hops (hub forked worker via Moleculer MsgPack) because it
17800
+ * skips the 33% base64 overhead + the per-call base64 decode on
17801
+ * the detection-pipeline worker. Callers can pass either; exactly
17802
+ * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
17907
17803
  */
17908
- hasRider: boolean().optional(),
17909
- ...TrackFlagFields,
17910
- ...TrackRetrainFields
17911
- });
17912
- var BaseEventFields = {
17913
- id: string(),
17914
- deviceId: number(),
17915
- timestamp: number()
17916
- };
17917
- var MotionEventSchema = object({
17918
- ...BaseEventFields,
17919
- kind: literal("motion"),
17920
- regionCount: number(),
17921
- /** Heavy JSON array omitted in slim projection. */
17922
- regions: array(object({
17923
- bbox: BoundingBoxSchema,
17924
- pixelCount: number(),
17925
- intensity: number()
17926
- })).readonly().optional(),
17927
- /** Omitted in slim projection. */
17928
- frameWidth: number().optional(),
17929
- /** Omitted in slim projection. */
17930
- frameHeight: number().optional(),
17931
- /** Populated by B5 (recording playback URL for this event). */
17932
- mediaUrl: string().optional()
17933
- });
17804
+ image: _instanceof(Uint8Array).optional(),
17805
+ referenceImage: string().optional(),
17806
+ deviceId: number().optional(),
17807
+ sessionId: string().optional(),
17808
+ /**
17809
+ * Execution plane. 'full' (default) runs the whole tree — benchmark,
17810
+ * reference-image, and detail-subtree calls. 'frame' is the live
17811
+ * per-frame dispatch: ONLY root-plane steps run; crop children
17812
+ * (inputClasses ≠ null) are skipped and served per-track via
17813
+ * pipelineRunner.runDetailSubtree (two-plane design).
17814
+ */
17815
+ plane: _enum(["full", "frame"]).optional(),
17816
+ /**
17817
+ * Inference-device selector (Phase 2 multi-device). Format
17818
+ * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
17819
+ * Omitted ⇒ the runner's default device (current single-engine
17820
+ * behaviour). Selects WHICH device pool of the node runs the call.
17821
+ */
17822
+ deviceKey: string().optional(),
17823
+ /**
17824
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
17825
+ * when the parent crop was resolved from the frame's retained NATIVE
17826
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
17827
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
17828
+ * resolution from that surface — the SAME quality path faces already
17829
+ * had — instead of the downscaled parent tile. `handle` keys the native
17830
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
17831
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
17832
+ * the executor's crop-normalized child ROI back into frame-normalized
17833
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
17834
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
17835
+ * (today's behaviour on the fallback path).
17836
+ */
17837
+ nativeCropRef: NativeCropRefSchema.optional()
17838
+ }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
17839
+ engine: PipelineEngineChoiceSchema.optional(),
17840
+ steps: array(PipelineStepInputSchema).min(1),
17841
+ frames: array(FrameInputSchema).min(1).max(255),
17842
+ deviceId: number().optional(),
17843
+ sessionId: string().optional(),
17844
+ /**
17845
+ * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
17846
+ * the batch to the Python pool's bench preprocess cache
17847
+ * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
17848
+ * preprocessed ONCE and every later inference is a pure-inference cache
17849
+ * hit — the sustained-throughput run measures inference, not
17850
+ * decode+preprocess+infer. Omitted/0 for live frames (all different →
17851
+ * full preprocess every call, correct). Fresh per sustained run;
17852
+ * released via `uncacheFrame`.
17853
+ */
17854
+ frameId: number().int().nonnegative().optional(),
17855
+ /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
17856
+ deviceKey: string().optional()
17857
+ }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
17858
+ data: _instanceof(Uint8Array),
17859
+ width: number().int().positive(),
17860
+ height: number().int().positive(),
17861
+ format: _enum([
17862
+ "rgb",
17863
+ "bgr",
17864
+ "gray"
17865
+ ])
17866
+ }), object({
17867
+ frameId: number(),
17868
+ width: number(),
17869
+ height: number()
17870
+ }), { kind: "mutation" }), method(object({
17871
+ stepId: string(),
17872
+ frameId: number().int()
17873
+ }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
17874
+ batchMode: string(),
17875
+ windowMs: number(),
17876
+ maxBatchSize: number(),
17877
+ concurrency: number()
17878
+ })), method(_void(), array(object({
17879
+ engineKey: string(),
17880
+ engine: PipelineEngineChoiceSchema,
17881
+ modelsLoaded: array(string()).readonly(),
17882
+ inUseByCameras: array(number()).readonly(),
17883
+ /**
17884
+ * Origin of this resident factory.
17885
+ * - `runtime` — main camera-serving engine (no idle TTL).
17886
+ * - `warm-override` — benchmark/test override held in the warm
17887
+ * cache; auto-disposed after the idle TTL.
17888
+ * - `device-pool` — a concurrent per-device pool (Phase 2
17889
+ * multi-device, keyed by `deviceKey`) resolved
17890
+ * via `resolveDeviceFactory`. Runs alongside the
17891
+ * `runtime` engine on a DIFFERENT accelerator
17892
+ * (NPU / iGPU / Coral) — this is how the
17893
+ * Engines tab shows all pools running at once.
17894
+ */
17895
+ kind: _enum([
17896
+ "runtime",
17897
+ "warm-override",
17898
+ "device-pool"
17899
+ ]),
17900
+ /** Native pid of the underlying Python pool (null when no pool). */
17901
+ poolPid: number().nullable(),
17902
+ /** ms since this factory was last used (null when not warm-tracked). */
17903
+ idleMs: number().nullable(),
17904
+ /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
17905
+ idleTtlMs: number().nullable()
17906
+ })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
17907
+ kind: "mutation",
17908
+ auth: "admin"
17909
+ }), method(object({
17910
+ engine: PipelineEngineChoiceSchema,
17911
+ force: boolean().optional()
17912
+ }), object({
17913
+ success: boolean(),
17914
+ reason: string().optional()
17915
+ }), {
17916
+ kind: "mutation",
17917
+ auth: "admin"
17918
+ }), 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({
17919
+ addonId: string(),
17920
+ modelId: string(),
17921
+ filename: string().optional(),
17922
+ settings: record(string(), unknown()).optional()
17923
+ }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
17934
17924
  /**
17935
- * Which detection SOURCE produced an object event. `pipeline` = the ML
17936
- * detection pipeline (decoded-frame inference); `onboard` = the camera's
17937
- * native on-device AI. Both flow through the SAME analysis layers (zoning,
17938
- * tracking, per-kind persistence) but stay distinguishable so consumers
17939
- * (advanced-notifier, occupancy, …) can select which source(s) to act on.
17940
- * Absent on legacy rows treat as `pipeline`.
17925
+ * Per-stage gating mode applied to the zones a rule references.
17926
+ *
17927
+ * - `include`: the rule contributes to a **whitelist** for its stage.
17928
+ * When at least one `include` rule fires for a stage, only entities
17929
+ * inside one of those zones pass that stage.
17930
+ * - `exclude`: the rule contributes to a **blacklist** for its stage.
17931
+ * Entities inside one of those zones are dropped at that stage.
17932
+ *
17933
+ * `monitor`-style observation (count without filtering) is not a rule
17934
+ * mode — zones without any matching rule are observed naturally by
17935
+ * `zone-analytics` (live snapshot + history), so an "I just want to
17936
+ * count, not filter" use case needs no rule at all.
17941
17937
  */
17942
- var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
17938
+ var ZoneRuleModeEnum = _enum(["include", "exclude"]);
17943
17939
  /**
17944
- * The confirmed zone crossing that produced an object event. Present ONLY on
17945
- * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
17946
- * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
17947
- * appearance event carry none, so a rule asking for a direction fails closed
17948
- * on them.
17940
+ * Per-consumer rule that references existing zones (geometry) and
17941
+ * defines how a specific pipeline stage should treat them. Each
17942
+ * consumer addon owns its own `ZoneRule[]` array in its per-device
17943
+ * settings:
17949
17944
  *
17950
- * Exactly ONE crossing per event: the emitter turns each confirmed crossing
17951
- * into its own event, so a frame in which a track enters A while leaving B
17952
- * produces two events with two directions — never one ambiguous row.
17945
+ * - `addon-motion-wasm` `motionZoneRules: ZoneRule[]` (motion stage)
17946
+ * - `addon-detection-pipeline` `detectionZoneRules: ZoneRule[]` (detection stage)
17947
+ * - future: notification rules, audio gating, etc.
17953
17948
  *
17954
- * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
17955
- * membership the box has NOW, and by definition it no longer contains the zone
17956
- * that was just left. Without the id here, a zone-scoped rule could never match
17957
- * the exit it asked for.
17949
+ * One rule applies to N zones (`zoneIds[]`) so the operator can
17950
+ * express "ignore motion in ALL of {garden, street}" with a single
17951
+ * rule. `classFilter` narrows the rule to specific object classes
17952
+ * "drop person detections in the street, but keep cars" is one
17953
+ * `exclude` rule with `classFilter: ['person']`.
17954
+ *
17955
+ * `enabled` is a soft toggle — the operator can keep the rule
17956
+ * configured but inert without deleting it.
17958
17957
  */
17959
- var ZoneCrossingSchema = object({
17960
- direction: _enum(["enter", "exit"]),
17961
- /** Admin zone id crossed. */
17962
- zoneId: string(),
17963
- /** Zone display name at crossing time (falls back to the id). */
17964
- zoneName: string().optional()
17965
- });
17966
- var ObjectEventSchema = object({
17967
- ...BaseEventFields,
17968
- kind: literal("object"),
17969
- /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
17970
- source: DetectionSourceSchema.optional(),
17958
+ var ZoneRuleSchema = object({
17959
+ /** Stable rule id — survives edits, used by the UI for diffing. */
17960
+ id: string(),
17961
+ /** Optional human-readable label rendered in the rule editor. */
17962
+ name: string().optional(),
17963
+ /** Zones this rule targets. The rule's `mode` applies to ALL
17964
+ * listed zones (OR-set: a detection in any one of them counts).
17965
+ * At least one zone id required — a rule with no targets is a
17966
+ * configuration mistake and the form validator rejects it. */
17967
+ zoneIds: array(string()).min(1).readonly(),
17968
+ mode: ZoneRuleModeEnum,
17971
17969
  /**
17972
- * Inference-frame id shared by every object event emitted from the SAME frame
17973
- * the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
17974
- * 2 people + 1 dog) under one full frame, and link a track's frames over time
17975
- * (group by `trackId`, pick a representative `frameId` as the parent frame).
17976
- * Optional for backward-compat with pre-existing rows / the slim projection
17977
- * includes it (it is light). Absent on rows written before this field.
17970
+ * Class names this rule applies to. Empty / undefined rule
17971
+ * applies to every class. Class strings match the `macroClass`
17972
+ * field on detections (e.g. `person`, `car`, `dog`).
17978
17973
  */
17979
- frameId: string().optional(),
17980
- /** Omitted in slim projection. */
17981
- trackId: string().optional(),
17982
- className: string(),
17983
- ...TieredLabelFields,
17984
- /** Omitted in slim projection. */
17985
- confidence: number().optional(),
17986
- /** Heavy JSON — omitted in slim projection. */
17987
- bbox: BoundingBoxSchema.optional(),
17988
- /** Heavy JSON — omitted in slim projection. */
17989
- zones: array(string()).readonly().optional(),
17990
- /** Omitted in slim projection. */
17991
- state: TrackStateSchema.optional(),
17974
+ classFilter: array(string()).readonly().optional(),
17992
17975
  /**
17993
- * The zone crossing this event IS, when it is one. Absent on every other
17994
- * event kind (movement state, appearance, package) see
17995
- * {@link ZoneCrossingSchema}. Omitted in slim projection.
17976
+ * Minimum bbox/mask overlap (0–1) with any of the rule's zones
17977
+ * required to consider an entity "in the zone". Defaults to the
17978
+ * consumer's stage default when omitted. Kept for back-compat with
17979
+ * existing per-rule overrides; new operators pick the value via
17980
+ * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
17981
+ * set, the lower-level engine reads it as a 0–1 fraction.
17996
17982
  */
17997
- zoneCrossing: ZoneCrossingSchema.optional(),
17998
- /** Detection-frame dimensions in pixels — let consumers normalize the
17999
- * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
18000
- frameWidth: number().optional(),
18001
- frameHeight: number().optional(),
18002
- /** MediaStore key for the crop attached to this event (if any). */
18003
- mediaKey: string().optional(),
18004
- /** Design B: MediaStore key of the track's native-resolution key frame (the
18005
- * best-detection full frame). Resolve via the event-media data-plane
18006
- * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
18007
- * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
18008
- * sources — consumers fall back to `mediaKey` (the tight crop). */
18009
- keyFrameMediaKey: string().optional(),
18010
- /** Populated by B5 (recording playback URL for this event). */
18011
- mediaUrl: string().optional(),
18012
- /** The parent track's key-event importance [0,1], propagated to every object
18013
- * event of the track (so an event row can be sorted by importance without a
18014
- * track join). Absent on legacy rows / before the track was scored. */
18015
- importance: number().optional()
17983
+ overlapThreshold: number().min(0).max(1).optional(),
17984
+ /**
17985
+ * Operator-friendly version of `overlapThreshold` the percentage
17986
+ * of the detection's bbox that must lie inside the zone for the
17987
+ * rule to match. Documented default is 85%; the engine substitutes
17988
+ * that when the field is omitted (kept optional so existing rules
17989
+ * stored without it stay valid).
17990
+ *
17991
+ * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
17992
+ * rule, the engine prefers `bboxInclusionPct` because it's the
17993
+ * field exposed in the UI. Internally both feed the same gate.
17994
+ */
17995
+ bboxInclusionPct: number().min(0).max(100).optional(),
17996
+ /**
17997
+ * When `true` and a detection has a segmentation mask, use the
17998
+ * mask for overlap instead of the bbox. Detection-stage only;
17999
+ * motion rules ignore this field.
18000
+ */
18001
+ preferMask: boolean().optional(),
18002
+ /**
18003
+ * Soft-toggle: `false` disables the rule without deleting it.
18004
+ * Defaults to `true` so operators creating a rule via the UI
18005
+ * see it active immediately.
18006
+ */
18007
+ enabled: boolean().default(true)
18016
18008
  });
18017
- var AudioEventSchema = object({
18018
- ...BaseEventFields,
18019
- kind: literal("audio"),
18020
- rms: number(),
18021
- dbfs: number(),
18022
- classification: object({
18023
- className: string(),
18024
- originalClass: string().optional(),
18025
- score: number()
18026
- }).optional(),
18027
- /** Populated by B5 (recording playback URL for this event). */
18028
- mediaUrl: string().optional()
18009
+ array(ZoneRuleSchema).readonly();
18010
+ /**
18011
+ * Zone — pure geometry + identity. NO filtering behaviour.
18012
+ *
18013
+ * Zones describe **where** in the frame the operator wants to flag
18014
+ * something; consumer-owned {@link ZoneRule} arrays describe **how**
18015
+ * each pipeline stage uses them. Splitting the two means a single
18016
+ * polygon "Driveway" can simultaneously back a motion-exclude rule,
18017
+ * a detection-include rule on `['car']`, and an occupancy aggregate
18018
+ * — without three duplicated polygons.
18019
+ *
18020
+ * Owned by the orchestrator addon (provider) and mirrored into the
18021
+ * `zones` device-state slice on every mutation. Consumers
18022
+ * (motion-wasm, pipeline-executor, analytics, admin UI) read either
18023
+ * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
18024
+ * mirror with `onChanged`).
18025
+ *
18026
+ * Coordinates are normalised fractions of the frame (0–1) so zones
18027
+ * survive resolution changes and stream profile switches.
18028
+ *
18029
+ * `kind` discriminates between full polygons (closed regions used
18030
+ * for intrusion / occupancy filters) and tripwires (open 2-point
18031
+ * line segments used for cross events). Onboard / firmware-reported
18032
+ * zones (Reolink, ONVIF) are out of scope for now — see the deferred
18033
+ * task list.
18034
+ */
18035
+ var ZoneKindEnum = _enum(["polygon", "tripwire"]);
18036
+ /** Polygon vertex in fraction-of-frame coordinates (0–1). */
18037
+ var PolygonPointSchema = object({
18038
+ x: number(),
18039
+ y: number()
18029
18040
  });
18030
- var MediaFileKindEnum = _enum([
18031
- "crop",
18032
- "thumbnail",
18033
- "snapshot",
18034
- "firstFrame",
18035
- "lastFrame",
18036
- "fullFrame",
18037
- "fullFrameBoxed",
18038
- "faceCrop",
18039
- "plateCrop",
18040
- "keyFrame",
18041
- "keyFrameSmall",
18042
- "thumbnailSmall"
18043
- ]);
18044
- var MediaFileSchema = object({
18045
- key: string(),
18046
- kind: MediaFileKindEnum,
18047
- base64: string(),
18048
- sizeBytes: number(),
18049
- timestamp: number()
18041
+ /** A camera detection zone — pure geometry/identity. */
18042
+ var ZoneSchema = object({
18043
+ id: string(),
18044
+ name: string(),
18045
+ kind: ZoneKindEnum.default("polygon"),
18046
+ /** Polygon vertices, fraction of frame (0–1). */
18047
+ polygon: array(PolygonPointSchema).readonly(),
18048
+ /** Visual color for UI rendering. */
18049
+ color: string().default("#3b82f6")
18050
18050
  });
18051
18051
  /**
18052
- * One media row WITHOUT its bytes.
18052
+ * Zones capability per-camera CRUD over polygon detection zones.
18053
18053
  *
18054
- * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
18055
- * 140 s track), and a client that renders tiles from the media data plane needs
18056
- * to know only WHAT EXISTS the bytes then arrive per tile, lazily, over HTTP
18057
- * with an immutable cache, instead of all at once inside a tRPC response that
18058
- * blocks the whole view.
18054
+ * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
18055
+ * to per-device settings and mirrors into the `zones` device-state
18056
+ * slice on every mutation, so downstream consumers can subscribe via
18057
+ * `dev.state.zones.onChanged`.
18059
18058
  *
18060
- * `sizeBytes` is carried because it is what lets a client decide between the
18061
- * stored blob and a `?variant=thumb` rendering without fetching either.
18059
+ * The cap surface only handles geometry + identity; filtering
18060
+ * behaviour (per-class, include/exclude, threshold) lives in the
18061
+ * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
18062
+ * `capabilities/schemas/zone-rule.js`.
18062
18063
  */
18063
- var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
18064
+ var zonesCapability = {
18065
+ name: "zones",
18066
+ scope: "device",
18067
+ mode: "singleton",
18068
+ deviceTypes: [DeviceType.Camera],
18069
+ methods: {
18070
+ listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
18071
+ addZone: method(object({
18072
+ deviceId: number(),
18073
+ zone: ZoneSchema
18074
+ }), _void(), {
18075
+ kind: "mutation",
18076
+ auth: "admin"
18077
+ }),
18078
+ removeZone: method(object({
18079
+ deviceId: number(),
18080
+ zoneId: string()
18081
+ }), _void(), {
18082
+ kind: "mutation",
18083
+ auth: "admin"
18084
+ }),
18085
+ updateZone: method(object({
18086
+ deviceId: number(),
18087
+ zone: ZoneSchema
18088
+ }), _void(), {
18089
+ kind: "mutation",
18090
+ auth: "admin"
18091
+ })
18092
+ },
18093
+ /**
18094
+ * Runtime-state slice — the live zone catalogue mirrored by the
18095
+ * orchestrator on every CRUD mutation. Consumers read via
18096
+ * `device.state.zones.value` / `.watch(...)` without round-tripping
18097
+ * the cap, and the codegen DeviceProxy auto-wires the reactive
18098
+ * handle. Slice shape is `{ zones: Zone[] }` so future extensions
18099
+ * (e.g. zone groupings) can sit alongside the polygon list.
18100
+ */
18101
+ runtimeState: object({ zones: array(ZoneSchema).readonly() }),
18102
+ /**
18103
+ * 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.
18104
+ *
18105
+ * See `RuntimeStateDurability`. Enforced by
18106
+ * `scripts/check-runtime-state-durability.ts`.
18107
+ */
18108
+ durability: "restored"
18109
+ };
18064
18110
  /**
18065
- * The MACRO tier of an annotation — a CLOSED set.
18111
+ * pipeline-analytics device-scoped wrapper cap. Refines raw
18112
+ * per-frame detections emitted by the pipeline runner into tracked
18113
+ * objects, per-kind event collections (motion / object / audio), and
18114
+ * persisted media. Owns the post-detection domain end-to-end:
18066
18115
  *
18067
- * This is what the exported detector predicts, so a typo here is a new class
18068
- * with one example in it. `label` and `subLabel` are open strings by contrast:
18069
- * the whole point of the page is teaching the model things it does not know
18070
- * yet, and constraining that vocabulary would make it useless.
18116
+ * runner emits PipelineInferenceResult
18117
+ * (event bus)
18118
+ * pipeline-analytics subscriber
18119
+ * SORT tracker + zone engine + state analyzer + event emitter
18120
+ * → three DB collections (one per kind), one FS media tree, one
18121
+ * unified event emitter (FrameTracked + TrackStarted/Ended +
18122
+ * DetectionEvent on bus)
18071
18123
  *
18072
- * A macro class is NEVER a label. The provider refuses a write whose `label` or
18073
- * `subLabel` is one of these values, in any casing, because once `person`
18074
- * exists in both tiers "every person box" stops being answerable without
18075
- * knowing every string anyone ever typed — and the damage is retroactive.
18124
+ * Pure subscriber model. No `processFrame` cap method the runner
18125
+ * already publishes the raw frame on the bus. The cap surface is
18126
+ * only QUERIES + per-device settings, bound on/off via
18127
+ * `device-manager.setWrapperActive`. `defaultActive: true` because
18128
+ * every camera with a detection pipeline wants its raw detections
18129
+ * refined; operators opt out per-device via BindingsTab when needed.
18130
+ *
18131
+ * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
18132
+ * (per-device surface) and `track-trail` caps — see P11 cleanup.
18076
18133
  */
18077
- var RetrainMacroClassSchema = _enum([
18134
+ var TrackStateSchema = _enum([
18135
+ "new",
18136
+ "entered",
18137
+ "left",
18138
+ "moving",
18139
+ "idle"
18140
+ ]);
18141
+ var EventKindSchema = _enum([
18142
+ "motion",
18143
+ "object",
18144
+ "audio"
18145
+ ]);
18146
+ /**
18147
+ * Spatial filter for `listTracks` — the rect + polygon variants of the shared
18148
+ * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
18149
+ * of the camera frame (top-left origin), matching the drawing-plane editor.
18150
+ */
18151
+ var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
18152
+ /** Closed icon vocabulary so clients render a known glyph per kind. */
18153
+ var EventKindIconSchema = _enum([
18154
+ "motion",
18155
+ "audio",
18078
18156
  "person",
18079
18157
  "vehicle",
18080
18158
  "animal",
18159
+ "door",
18160
+ "pir",
18161
+ "smoke",
18162
+ "water",
18163
+ "button",
18081
18164
  "package",
18082
- "face",
18083
- "plate"
18165
+ "generic"
18084
18166
  ]);
18085
- /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
18086
- var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
18087
- /** Did a human draw this box, or did the assist propose it? */
18088
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
18089
- /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
18090
- var RetrainBboxSchema = object({
18091
- x: number(),
18092
- y: number(),
18093
- w: number(),
18094
- h: number()
18167
+ var EventKindCategorySchema = _enum([
18168
+ "motion",
18169
+ "audio",
18170
+ "detection",
18171
+ "sensor",
18172
+ "control",
18173
+ "custom",
18174
+ "package"
18175
+ ]);
18176
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
18177
+ var EventKindLevelSchema = _enum(["macro", "sub"]);
18178
+ var EventKindDescriptorSchema = object({
18179
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
18180
+ kind: string(),
18181
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
18182
+ labelKey: string(),
18183
+ /** English fallback label (kept for clients that don't translate). */
18184
+ label: string(),
18185
+ /** Hex color for timeline/legend rendering. */
18186
+ color: string(),
18187
+ /** Dictionary id → lucide component on the UI side. */
18188
+ iconId: string(),
18189
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
18190
+ icon: EventKindIconSchema,
18191
+ category: EventKindCategorySchema,
18192
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
18193
+ parentKind: string().nullable(),
18194
+ /** Derived from `parentKind`, explicit for the client tree. */
18195
+ level: EventKindLevelSchema,
18196
+ /** Which cap + device contributes this kind. For built-ins the camera
18197
+ * itself; for sensor kinds the LINKED source device. */
18198
+ source: object({
18199
+ capName: string(),
18200
+ deviceId: number()
18201
+ })
18095
18202
  });
18096
- /**
18097
- * One annotated subject.
18098
- *
18099
- * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
18100
- * (letterboxed root / zone-cropped package / subject-cropped classifier) are
18101
- * derived from it at export and never stored — storing them is how one feature
18102
- * space ends up holding two crops of the same subject (D52).
18103
- */
18104
- var RetrainAnnotationSchema = object({
18105
- id: string(),
18106
- trackId: string(),
18203
+ /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
18204
+ var EventKindsForDeviceSchema = object({
18107
18205
  deviceId: number(),
18108
- /** The COPY in retrain storage — never the source track's media key. */
18109
- mediaKey: string(),
18110
- bbox: RetrainBboxSchema,
18111
- macroClass: RetrainMacroClassSchema,
18112
- label: string().optional(),
18113
- subLabel: string().optional(),
18114
- kind: RetrainAnnotationKindSchema,
18115
- source: RetrainAnnotationSourceSchema,
18116
- /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
18117
- assistModelId: string().optional(),
18118
- assistScore: number().optional(),
18119
- exportedInBatch: string().optional(),
18120
- createdAt: number()
18121
- });
18122
- /** The write form — the server owns `id`, `createdAt` and the frame binding. */
18123
- var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
18124
- id: true,
18125
- trackId: true,
18126
- deviceId: true,
18127
- mediaKey: true,
18128
- createdAt: true,
18129
- exportedInBatch: true
18206
+ kinds: array(EventKindDescriptorSchema).readonly()
18130
18207
  });
18131
- /** A track sitting in `staging`, with everything the worklist needs to rank it. */
18132
- var RetrainTrackSchema = object({
18133
- trackId: string(),
18208
+ var SensorEventSchema = object({
18209
+ id: string(),
18210
+ /** The CAMERA the event is attributed to (a sensor linked to N cameras
18211
+ * yields N rows, one per camera). */
18134
18212
  deviceId: number(),
18135
- className: string(),
18136
- label: string().optional(),
18137
- firstSeen: number(),
18138
- lastSeen: number(),
18139
- /** How many frames the dataset already holds from this track. */
18140
- frameCount: number().int(),
18141
- /** How many subjects have been annotated on those frames. `0` with
18142
- * `frameCount: 0` is exactly "staging, still to work". */
18143
- annotationCount: number().int()
18213
+ /** The linked sensor device whose state changed. */
18214
+ sourceDeviceId: number(),
18215
+ /** Event kind id — matches an `EventKindDescriptor.kind`. */
18216
+ kind: string(),
18217
+ /** Snapshot of the sensor cap's runtime-state slice at the change. */
18218
+ value: record(string(), unknown()).nullable(),
18219
+ timestamp: number()
18144
18220
  });
18145
- /** A frame the picker may offer — an index row, no blob was read to produce it. */
18146
- var RetrainFrameCandidateSchema = object({
18147
- mediaKey: string(),
18148
- kind: MediaFileKindEnum,
18221
+ var TrackPositionSchema = object({
18222
+ x: number(),
18223
+ y: number(),
18149
18224
  timestamp: number(),
18150
- sizeBytes: number().int(),
18151
- /** A copy of this original already exists — selecting it is free and cannot
18152
- * fail, whatever became of the original. */
18153
- copied: boolean()
18154
- });
18155
- /** A frame the dataset OWNS: bytes copied at selection time. */
18156
- var RetrainFrameSchema = object({
18157
- frameId: string(),
18158
- deviceId: number(),
18159
- trackId: string(),
18160
- /** Provenance only. It may already point at nothing — that is expected. */
18161
- sourceMediaKey: string(),
18162
- sourceKind: MediaFileKindEnum,
18163
- sizeBytes: number().int(),
18164
- width: number().int(),
18165
- height: number().int(),
18166
- copiedAt: number()
18167
- });
18168
- /** Why a copy-on-select could not be honoured — named, never a silent skip. */
18169
- var RetrainCopyRefusalSchema = _enum([
18170
- "source-missing",
18171
- "unreadable-image",
18172
- "write-failed"
18173
- ]);
18174
- var RetrainFrameSelectionSchema = object({
18175
- copied: array(RetrainFrameSchema).readonly(),
18176
- refused: array(object({
18177
- sourceMediaKey: string(),
18178
- reason: RetrainCopyRefusalSchema
18179
- })).readonly()
18225
+ bbox: BoundingBoxSchema
18180
18226
  });
18181
- var RetrainFrameListSchema = object({
18182
- candidates: array(RetrainFrameCandidateSchema).readonly(),
18183
- copies: array(RetrainFrameSchema).readonly(),
18184
- /** What the page pre-selects the native key frame when one survives. */
18185
- autoPickMediaKey: string().optional()
18227
+ var TrackSnapshotSchema = object({
18228
+ timestamp: number(),
18229
+ position: TrackPositionSchema,
18230
+ /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
18231
+ mediaKey: string()
18186
18232
  });
18187
- /** What the operator asked the assist to look for. */
18188
- var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
18189
- kind: literal("package"),
18190
- zone: RetrainBboxSchema.optional()
18191
- }), object({
18192
- kind: literal("objects"),
18193
- modelId: string(),
18194
- minScore: number().optional()
18195
- })]);
18196
18233
  /**
18197
- * The assist's answer a discriminated union, because "the model saw nothing"
18198
- * and "this node cannot run that model" lead to different next moves and a
18199
- * nullable result cannot tell them apart.
18234
+ * Normalized 0..1 trajectory envelope (min/max over every position bbox,
18235
+ * divided by the track's detection-frame dims), computed at persist time.
18236
+ * Absent when the frame dims were unknown when the track was persisted
18237
+ * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
18200
18238
  */
18201
- var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
18202
- kind: literal("proposed"),
18203
- modelId: string(),
18204
- stepId: string(),
18205
- minScore: number(),
18206
- /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
18207
- proposals: array(RetrainAnnotationDraftSchema).readonly(),
18208
- /** Returned by the runner but removed by the threshold. */
18209
- belowThreshold: number().int()
18210
- }), object({
18211
- kind: literal("refused"),
18212
- /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
18213
- reason: string(),
18214
- detail: string().optional()
18215
- })]);
18216
- /** The outcome of a lifecycle move owned by the retrain page. */
18217
- var RetrainTransitionResultSchema = object({
18218
- trackId: string(),
18219
- /** Where the track ended up, whatever happened. */
18220
- retrainStatus: RetrainStatusSchema,
18221
- /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
18222
- changed: boolean(),
18223
- reason: _enum([
18224
- "unknown-track",
18225
- "no-frames-copied",
18226
- "not-staging",
18227
- "not-trained",
18228
- "unchanged"
18229
- ]).optional()
18239
+ var TrackEnvelopeSchema = object({
18240
+ minX: number(),
18241
+ minY: number(),
18242
+ maxX: number(),
18243
+ maxY: number()
18230
18244
  });
18231
- var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
18232
- var MAX_EVENT_QUERY_LIMIT = 5e3;
18233
- var DeviceEventQueryInput = object({
18234
- deviceId: number(),
18235
- since: number().optional(),
18236
- until: number().optional(),
18237
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
18238
- /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
18239
- * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
18240
- * exact behaviour. Callers may omit this field — the store defaults to
18241
- * `full` when not provided. */
18242
- projection: _enum(["full", "slim"]).optional()
18243
- });
18244
- var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
18245
- var RecentTracksQueryInput = object({
18246
- /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
18247
- deviceIds: array(number()),
18248
- /** Window lower bound on `lastSeen` (inclusive). */
18249
- since: number().optional(),
18250
- /** Window upper bound on `lastSeen` (inclusive). */
18251
- until: number().optional(),
18252
- /** Page size. Default 200, max 1000. */
18253
- limit: number().int().min(1).max(1e3).default(200),
18254
- /** Opaque continuation cursor from a previous page's `nextCursor`.
18255
- * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
18256
- cursor: string().optional(),
18257
- /** See {@link TrackProjectionSchema}. Default `full`. */
18258
- projection: TrackProjectionSchema.optional(),
18259
- /** Include stationary-promoted rows (parked objects). Default false: the
18260
- * feed lists passages; parking records live on the stationary registry. */
18261
- includeStationary: boolean().optional()
18262
- });
18263
- var RecentTracksPageSchema = object({
18264
- /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
18265
- tracks: array(TrackSchema).readonly(),
18266
- /** Cursor for the next page, or null when this page is the last. */
18267
- nextCursor: string().nullable()
18268
- });
18269
- var LIST_GROUPS_DEFAULT_LIMIT = 40;
18270
- var LIST_GROUPS_MAX_LIMIT = 100;
18271
- var AnalyticsGroupRecordSchema = object({
18272
- id: string(),
18273
- deviceId: number().int(),
18274
- openedAt: number().int(),
18275
- closedAt: number().int(),
18276
- timestamp: number().int(),
18277
- memberCount: number().int(),
18278
- memberTrackIds: array(string()).readonly(),
18279
- className: string(),
18280
- classes: array(string()).readonly(),
18281
- /** Relative event-media path, or null when the group has no picture yet. */
18282
- mediaUrl: string().nullable(),
18283
- singleton: boolean()
18284
- });
18285
- var AnalyticsGroupMemberSchema = object({
18286
- trackId: string(),
18287
- deviceId: number().int(),
18288
- className: string(),
18289
- firstSeen: number().int(),
18290
- lastSeen: number().int(),
18291
- mediaUrl: string().nullable()
18292
- });
18293
- var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
18294
- var ListGroupsQueryInput = object({
18295
- /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
18296
- deviceIds: array(number()),
18297
- /** Window lower bound on `closedAt` (inclusive). */
18298
- since: number().optional(),
18299
- /** Window upper bound on `openedAt` (inclusive). */
18300
- until: number().optional(),
18301
- limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
18302
- /** Opaque continuation cursor from a previous page's `nextCursor`. */
18303
- cursor: string().optional()
18304
- });
18305
- var ListGroupsPageSchema = object({
18306
- groups: array(AnalyticsGroupRecordSchema).readonly(),
18307
- nextCursor: string().nullable()
18308
- });
18309
- var KeyEventQueryInput = object({
18310
- deviceId: number(),
18311
- /** Window lower bound (track firstSeen ≥ since). */
18312
- since: number(),
18313
- /** Window upper bound (track firstSeen ≤ until). */
18314
- until: number(),
18315
- limit: number().int().min(1).max(200).default(50),
18316
- /** Drop tracks scoring below this importance. */
18317
- minImportance: number().min(0).max(1).optional(),
18318
- /** Restrict to a single class (e.g. 'person'). */
18319
- classFilter: string().optional()
18320
- });
18321
- var KeyEventSchema = object({
18322
- /** The representative event id (the track's best ObjectEvent, else its trackId). */
18323
- id: string(),
18324
- trackId: string(),
18325
- /** Track start time (firstSeen). */
18326
- timestamp: number(),
18327
- className: string(),
18328
- ...TieredLabelFields,
18329
- importance: number(),
18330
- /** Highest-confidence ObjectEvent id for the track (empty when none). */
18331
- bestEventId: string(),
18332
- /** Track lifetime in ms (lastSeen - firstSeen). */
18333
- windowMs: number().optional(),
18334
- ...TrackFlagFields,
18335
- ...TrackRetrainFields
18336
- });
18337
- object({
18338
- trackId: string(),
18339
- className: string(),
18340
- confidence: number(),
18341
- bbox: BoundingBoxSchema,
18342
- zones: array(string()).readonly(),
18343
- state: TrackStateSchema
18344
- });
18345
- var OverlayDetectionSchema = looseObject({
18346
- id: string(),
18347
- kind: _enum(["first-level", "detail"]),
18348
- macroClass: string(),
18349
- score: number(),
18350
- bbox: object({
18351
- x: number(),
18352
- y: number(),
18353
- width: number(),
18354
- height: number()
18355
- }),
18356
- labels: array(looseObject({
18357
- label: string(),
18358
- score: number()
18359
- })).readonly(),
18360
- parentId: string().optional()
18361
- });
18362
- var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
18363
- var SearchObjectEventsInput = object({
18364
- text: string(),
18365
- deviceId: number().optional(),
18366
- since: number().optional(),
18367
- until: number().optional(),
18368
- classFilter: string().optional(),
18369
- limit: number().default(50),
18370
- minScore: number().min(0).max(1).default(.2)
18371
- });
18372
- var TrackCascadeCountsSchema = object({
18373
- /** Persisted track roots deleted (authoritative). */
18374
- tracks: number().int(),
18375
- /** Object events removed with their tracks (best-effort; see note above). */
18376
- events: number().int(),
18377
- /** Track/face/plate-owned media removed (best-effort). Never identity media. */
18378
- media: number().int(),
18379
- /** Unassigned (non-enrolled) face reads removed (best-effort). */
18380
- faces: number().int(),
18381
- /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
18382
- plates: number().int(),
18383
- /** Per-track CLIP search vectors removed (best-effort). */
18384
- embeddings: number().int(),
18385
- /** Group membership + group rows removed with their last member (best-effort). */
18386
- groups: number().int()
18387
- });
18388
- /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
18389
- var DiskReconcileCountsSchema = object({
18390
- mediaDropped: number().int(),
18391
- tracks: number().int(),
18392
- events: number().int()
18393
- });
18394
- /** Event-store footprint for one camera. */
18395
- var EventStoreDeviceFootprintSchema = object({
18396
- deviceId: number(),
18397
- /** Persisted event rows (motion + object + audio) for the camera. */
18398
- rows: number().int(),
18399
- /** Event-owned media bytes on disk for the camera. */
18400
- bytes: number().int()
18401
- });
18402
- /** Aggregate event-store footprint: global totals + per-camera breakdown. */
18403
- var EventStoreFootprintSchema = object({
18404
- totalRows: number().int(),
18405
- totalBytes: number().int(),
18406
- devices: array(EventStoreDeviceFootprintSchema).readonly()
18407
- });
18408
- /** Per-kind counts returned by the event-prune / device-delete mutations. */
18409
- var EventPruneCountsSchema = object({
18410
- motion: number().int(),
18411
- object: number().int(),
18412
- audio: number().int()
18245
+ /**
18246
+ * Row projection for track list queries. `full` (default) returns the
18247
+ * complete Track including the frame-rate `positions[]` history and the
18248
+ * `snapshots[]` references — megabytes across a page of tracks. `slim`
18249
+ * keeps every scalar the list surfaces actually render (ids, class(es),
18250
+ * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
18251
+ * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
18252
+ * `snapshots` as EMPTY arrays detail views re-fetch the full row via
18253
+ * `getTrack`. Mirrors the event-store `projection` convention
18254
+ * (`getObjectEvents` et al.).
18255
+ */
18256
+ var TrackProjectionSchema = _enum(["full", "slim"]);
18257
+ /**
18258
+ * One audio-classification label heard on the track's camera while the
18259
+ * track was alive, aggregated per label. An "episode" is one persisted
18260
+ * audio event (the confident-classification path: score the device's
18261
+ * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
18262
+ * one 32 ms inference chunk, so counts stay human-scaled.
18263
+ */
18264
+ var TrackAudioLabelSchema = object({
18265
+ label: string(),
18266
+ /** Highest classification score observed across the label's episodes. */
18267
+ peakScore: number(),
18268
+ /** Number of coalesced audio-event episodes carrying this label. */
18269
+ count: number(),
18270
+ firstAt: number(),
18271
+ lastAt: number()
18413
18272
  });
18414
18273
  /**
18415
- * Re-embed stored tracks from their key frames.
18274
+ * How a track was produced. `pipeline` (default / absent) = the spatial
18275
+ * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
18276
+ * no positions, a single snapshot, and no bbox trajectory at all:
18416
18277
  *
18417
- * The reason this is an operator-callable method and not a migration script:
18418
- * every knob that decides what a vector MEANS encoder model, crop margin,
18419
- * squaring is only changeable if the existing vectors can be regenerated.
18420
- * Mixing feature spaces in one index makes cosine scores incomparable, and the
18421
- * symptom is a quality regression with no visible cause.
18278
+ * - `sensor` a linked sensor/control device state change.
18279
+ * - `audio` an audio event on the camera itself that was anomalous for
18280
+ * THAT camera, loud, and heard while nothing visual was happening (D62).
18281
+ *
18282
+ * The spatial subsystems (tracker association, occupancy count, re-id /
18283
+ * embedding, resurrection) MUST skip every synthetic source. Test for that
18284
+ * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
18285
+ * check silently readmits every source added after it was written.
18422
18286
  */
18423
- var RebuildObjectEmbeddingsInput = object({
18424
- /** Restrict to one camera. Omit for the whole fleet. */
18425
- deviceId: number().optional(),
18426
- since: number().optional(),
18427
- until: number().optional(),
18428
- /** Stop after this many tracks; the result reports whether more remain. */
18429
- maxTracks: number().int().positive().optional(),
18430
- /**
18431
- * Run every embedding on THIS node instead of round-robining the fleet.
18432
- *
18433
- * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
18434
- * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
18435
- * calling it that would pin the rebuild REQUEST itself to that node — the
18436
- * rebuild orchestration lives on the hub, and only the per-track step runs
18437
- * remotely. This field is data; the per-track pin is applied inside.
18438
- *
18439
- * Absent ⇒ round-robin over every online node whose runner can serve the
18440
- * pinned model.
18441
- */
18442
- executeOnNodeId: string().optional(),
18443
- /**
18444
- * Milliseconds to wait between tracks; omit for the built-in default, `0` to
18445
- * run flat out.
18446
- *
18447
- * A rebuild is bulk maintenance on hub-main's single thread. Measured
18448
- * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
18449
- * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
18450
- * force is logged at start and finish so a deliberately slow pass reads
18451
- * differently from a stalled one.
18452
- */
18453
- pacingMs: number().int().nonnegative().optional()
18454
- });
18287
+ var TrackSourceSchema = _enum([
18288
+ "pipeline",
18289
+ "sensor",
18290
+ "audio"
18291
+ ]);
18455
18292
  /**
18456
- * Result of emptying the CLIP index.
18293
+ * Where a track sits in the RETRAIN lifecycle (D81).
18457
18294
  *
18458
- * The clean slate before a policy change: a new crop margin or encoder model
18459
- * leaves two feature spaces in one index whose cosine scores are not
18460
- * comparable, so wiping and rebuilding is the only way to be sure every vector
18461
- * means the same thing.
18295
+ * - `none` never marked, or un-marked. Evictable.
18296
+ * - `staging` the operator wants this track as training material and has not
18297
+ * finished with it. **This is the only state retention holds**: the track and
18298
+ * everything it owns (object events, crops, keyframes, CLIP vector) survive
18299
+ * the device's age window.
18300
+ * - `trained` — the retrain page has taken what it needed. The frames it chose
18301
+ * were COPIED into the retrain dataset at selection time, so the dataset no
18302
+ * longer depends on the track's media and the track becomes EVICTABLE again.
18303
+ * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
18304
+ * a deliberate action of the retrain page, not a side effect of a checkbox.
18305
+ *
18306
+ * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
18307
+ * the store's filter language has only positive equality and `whereIn` — no
18308
+ * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
18309
+ * would make the entire pre-column history immortal in one deploy.
18462
18310
  */
18463
- var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
18311
+ var RetrainStatusSchema = _enum([
18312
+ "none",
18313
+ "staging",
18314
+ "trained"
18315
+ ]);
18464
18316
  /**
18465
- * Acknowledgement that a rebuild STARTED.
18317
+ * Per-track OPERATOR flags set by hand from the admin UI or the viewer, never
18318
+ * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
18319
+ * so the two surfaces cannot drift.
18466
18320
  *
18467
- * The pass costs ~1s per track 45 minutes for a 2,600-track fleet so it
18468
- * runs detached and this returns immediately. Waiting for it made the client
18469
- * time out while the work carried on server-side, which is the worst of both:
18470
- * no result and no way to know it was still going. Poll
18471
- * `getObjectEmbeddingRebuildStatus` for progress.
18472
- */
18473
- var RebuildObjectEmbeddingsResultSchema = object({
18474
- started: boolean(),
18475
- /** True when a pass was already running; the new request is ignored. */
18476
- alreadyRunning: boolean()
18477
- });
18478
- var RebuildStatusSchema = object({
18479
- running: boolean(),
18480
- scanned: number(),
18481
- rebuilt: number(),
18482
- /** Tracks whose key frame is gone nothing to re-embed from. */
18483
- missingKeyFrame: number(),
18484
- /** Tracks with no usable detection box. */
18485
- missingBbox: number(),
18486
- /**
18487
- * Tracks an executing node REFUSED rather than broke on — an unreadable key
18488
- * frame, a step that threw. Separate from `failed` because the remedy is
18489
- * different, and because a whole camera silently contributing zero vectors
18490
- * is the shape of failure a rebuild must never hide.
18491
- */
18492
- notRunnable: number(),
18321
+ * **Absent false.** A track that has never been touched omits the field; an
18322
+ * explicitly un-flagged track carries `false`. Legacy rows written before the
18323
+ * columns existed read as absent, and a consumer that needs a boolean should say
18324
+ * `flag === true`, not `flag !== false`.
18325
+ *
18326
+ * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
18327
+ * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
18328
+ * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
18329
+ * `trained` track reports `false` while refusing both writes. The boolean is
18330
+ * kept because three surfaces drive a toggle off it; anything that needs to tell
18331
+ * "never marked" from "already trained" must read `retrainStatus`.
18332
+ *
18333
+ * `debug` does NOT pin; it is attention, not durability.
18334
+ *
18335
+ * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
18336
+ * A favourited track is skipped by retention the same way `staging` is, but
18337
+ * it does not enter `none|staging|trained` and has no staging budget.
18338
+ */
18339
+ var TrackFlagFields = {
18340
+ /** Operator marked this track as training material — i.e. `retrainStatus` is
18341
+ * `'staging'`. */
18342
+ markForTrain: boolean().optional(),
18343
+ /** Operator marked this track for diagnostic attention. */
18344
+ debug: boolean().optional(),
18345
+ /** Operator favourited this track. Pins it against pruning. */
18346
+ favourited: boolean().optional()
18347
+ };
18348
+ /**
18349
+ * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
18350
+ * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
18351
+ * write patch, and the status is not something the toggle sets — it is what the
18352
+ * toggle's boolean is derived from. Absent on an in-RAM track never touched;
18353
+ * always present on a persisted row (the column default materialises `'none'`).
18354
+ */
18355
+ var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
18356
+ /**
18357
+ * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
18358
+ * one flag can never clear the other — the toggles are independent and are
18359
+ * driven from three surfaces that do not know about each other.
18360
+ */
18361
+ var TrackFlagsPatchSchema = object(TrackFlagFields);
18362
+ /**
18363
+ * The resolved flag state after a write. Both fields are REQUIRED here (absent
18364
+ * collapses to `false`) so a caller can drive a toggle's checked state off the
18365
+ * mutation result without a re-fetch.
18366
+ */
18367
+ var TrackFlagsSchema = object({
18368
+ trackId: string(),
18369
+ markForTrain: boolean(),
18370
+ debug: boolean(),
18371
+ favourited: boolean(),
18372
+ /** The lifecycle state the boolean was derived from. Required here (unlike on
18373
+ * a track row) because this shape is only ever produced by the write body,
18374
+ * which always knows it — and a surface that has just written needs to render
18375
+ * `trained` without a re-fetch. */
18376
+ retrainStatus: RetrainStatusSchema
18377
+ });
18378
+ union([literal(1), literal(2)]);
18379
+ /**
18380
+ * WHO decided a label, and when. Carried per tier so a value can be traced to
18381
+ * the step and model that produced it — which is what makes the write rule
18382
+ * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
18383
+ * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
18384
+ *
18385
+ * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
18386
+ * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
18387
+ * `migration:4g` for a value the 4g migration moved from the single-slot era —
18388
+ * that value has no provenance, and the write rule lets ANY properly-attributed
18389
+ * write of the same tier replace it regardless of score.
18390
+ */
18391
+ var LabelAttributionSchema = object({
18392
+ stepId: string(),
18393
+ modelId: string().optional(),
18394
+ decidedAt: number(),
18493
18395
  /**
18494
- * The pass stopped because NO node could serve the pinned model.
18396
+ * The GALLERY id behind a recognised tier-2 label a face-gallery
18397
+ * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
18495
18398
  *
18496
- * Distinct from `notRunnable` on purpose: that one says "this track was
18497
- * refused", this one says "the cluster cannot do this work at all" — every
18498
- * candidate node either lacks the `clip-embedding` step, lacks a build of the
18499
- * pinned model for its engine format, or dropped out. The remedy is a model /
18500
- * engine change, not a per-camera one. Non-zero here always comes with
18501
- * `complete: false`.
18399
+ * The text alone is a DISPLAY NAME, and a display name is renameable: a
18400
+ * notification rule authored on "Gianluca" stopped matching the moment the
18401
+ * operator fixed the spelling in the gallery, and nothing said so. The id is
18402
+ * the thing that does not move, so it is what a rule matches on
18403
+ * (`NcConditions.identities`) and the text is what a human is shown.
18404
+ *
18405
+ * Absent when the label names no gallery row — a plate the OCR read but no
18406
+ * vehicle claims, a sub-class, a species, any tier-1 value.
18502
18407
  */
18503
- noCapableNode: number(),
18504
- failed: number(),
18505
- /** Set once a pass ends: true only when EVERYTHING was covered. */
18506
- complete: boolean().nullable(),
18507
- startedAtMs: number().nullable(),
18508
- finishedAtMs: number().nullable(),
18509
- /** Present when the pass ended by throwing. */
18510
- error: string().nullable()
18408
+ identityId: string().optional()
18511
18409
  });
18512
- DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
18513
- deviceId: number(),
18514
- trackId: string()
18515
- }), TrackSchema.nullable()), method(object({
18516
- deviceId: number(),
18517
- since: number().optional(),
18518
- until: number().optional(),
18519
- limit: number().optional(),
18520
- /** Spatial filter — only tracks whose trajectory intersects the zone
18521
- * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
18522
- * envelope columns, then precisely tested per position. Tracks with
18523
- * an unknown envelope (no frame dims at persist time) always match. */
18524
- zone: TrackZoneFilterSchema.optional(),
18525
- /** See {@link TrackProjectionSchema}. Default `full` (backward
18526
- * compatible omitting the field keeps today's exact behaviour). */
18527
- projection: TrackProjectionSchema.optional(),
18528
- /** Include stationary-promoted rows (parked objects handed to the
18529
- * stationary registry). Default false: the timeline lists passages,
18530
- * not parking records (operator decision, 2026-08-15). */
18531
- includeStationary: boolean().optional()
18532
- }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
18533
- deviceId: number(),
18534
- groupId: string().min(1)
18535
- }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
18536
- kind: "mutation",
18537
- auth: "admin"
18538
- }), 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({
18539
- deviceId: number(),
18540
- since: number().optional(),
18541
- until: number().optional(),
18542
- kinds: array(string()).optional(),
18543
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
18544
- }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
18545
- deviceId: number(),
18546
- since: number(),
18547
- until: number(),
18548
- bucketMs: number().int().positive()
18549
- }), array(object({
18550
- bucketStart: number(),
18551
- motion: number().int(),
18552
- object: number().int(),
18553
- audio: number().int()
18554
- })).readonly()), method(object({
18555
- deviceId: number(),
18556
- cutoffMs: number()
18557
- }), object({
18558
- motion: number().int(),
18559
- object: number().int(),
18560
- audio: number().int()
18561
- }), {
18562
- kind: "mutation",
18563
- auth: "admin"
18564
- }), method(object({
18565
- deviceId: number(),
18566
- cutoffMs: number()
18567
- }), TrackCascadeCountsSchema, {
18568
- kind: "mutation",
18569
- auth: "admin"
18570
- }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
18571
- kind: "mutation",
18572
- auth: "admin"
18573
- }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
18574
- kind: "mutation",
18575
- auth: "admin"
18576
- }), method(object({
18577
- deviceId: number(),
18578
- trackIds: array(string()).min(1)
18579
- }), object({
18580
- deleted: number().int(),
18581
- failed: array(string()).readonly()
18582
- }), {
18583
- kind: "mutation",
18584
- auth: "admin"
18585
- }), method(object({
18586
- /** Log/audit scope only — the trackId is globally unique on its own. */
18410
+ /**
18411
+ * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
18412
+ * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
18413
+ * track and its events always answer the same question the same way.
18414
+ *
18415
+ * Two scalar columns, not an array: every consumer wants "the coarse one" or
18416
+ * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
18417
+ * is tier 2, and each carries its own score + attribution.
18418
+ *
18419
+ * **Reading it.** What a human should be shown is `subLabel ?? label` — the
18420
+ * finest thing known. Before 4g the single `label` column held the finest
18421
+ * value, so a consumer that has not been updated reads the tier-1 slot and
18422
+ * shows nothing on a species-only row; that is why the migration puts every
18423
+ * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
18424
+ * and why the read surfaces were changed in the same train.
18425
+ *
18426
+ * **Writing it.** The slots are independent, which is the whole point: a
18427
+ * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
18428
+ * migratorius`), so fineness cannot regress by construction. Within a tier the
18429
+ * higher score wins. One rule, one implementation — see
18430
+ * `pipeline/label-tier.ts` in addon-post-analysis.
18431
+ */
18432
+ var TieredLabelFields = {
18433
+ /** Tier 1 the sub-class. See {@link LabelTierSchema}. */
18434
+ label: string().optional(),
18435
+ /** Confidence of the tier-1 value, as reported by the deciding step. */
18436
+ labelScore: number().optional(),
18437
+ /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
18438
+ labelMeta: LabelAttributionSchema.optional(),
18439
+ /** Tier 2 — the instance. See {@link LabelTierSchema}. */
18440
+ subLabel: string().optional(),
18441
+ /** Confidence of the tier-2 value, as reported by the deciding step. */
18442
+ subLabelScore: number().optional(),
18443
+ /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
18444
+ subLabelMeta: LabelAttributionSchema.optional()
18445
+ };
18446
+ /** Per-camera slice of a training-export estimate. */
18447
+ var TrainingExportDeviceTotalsSchema = object({
18587
18448
  deviceId: number(),
18449
+ tracks: number().int(),
18450
+ files: number().int(),
18451
+ bytes: number().int()
18452
+ });
18453
+ /**
18454
+ * What a training export WOULD contain. Computed from media index rows only —
18455
+ * no blob is read to produce this.
18456
+ */
18457
+ var TrainingExportSummarySchema = object({
18458
+ generatedAt: number(),
18459
+ trackCount: number().int(),
18460
+ fileCount: number().int(),
18461
+ byteCount: number().int(),
18462
+ /** More marked tracks exist than a single pass carries. */
18463
+ truncated: boolean(),
18464
+ devices: array(TrainingExportDeviceTotalsSchema).readonly()
18465
+ });
18466
+ var TrackSchema = object({
18588
18467
  trackId: string(),
18589
- flags: TrackFlagsPatchSchema
18590
- }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
18591
- kind: "query",
18592
- auth: "admin"
18593
- }), method(object({
18594
- olderThanMs: number(),
18595
- reason: OpsLogReasonSchema.optional()
18596
- }), EventPruneCountsSchema, {
18597
- kind: "mutation",
18598
- auth: "admin"
18599
- }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
18600
- kind: "mutation",
18601
- auth: "admin"
18602
- }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
18603
- kind: "mutation",
18604
- auth: "admin"
18605
- }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
18606
- kind: "mutation",
18607
- auth: "admin"
18608
- }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
18609
- kind: "mutation",
18610
- auth: "admin"
18611
- }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
18612
- kind: "mutation",
18613
- auth: "admin"
18614
- }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18615
- kind: "mutation",
18616
- auth: "admin"
18617
- }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
18618
- kind: "query",
18619
- auth: "admin"
18620
- }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
18621
- kind: "query",
18622
- auth: "admin"
18623
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18624
- kind: "query",
18625
- auth: "admin"
18626
- }), method(object({
18627
- /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
18628
- * `deviceId`, deliberately: `deviceId` would make this device-bound and
18629
- * route it at one camera's owner, and "every camera" would stop being
18630
- * expressible at all. */
18631
- deviceIds: array(number()).optional(),
18632
- limit: number().int().min(1).max(500).optional()
18633
- }), array(RetrainTrackSchema).readonly(), {
18634
- kind: "query",
18635
- auth: "admin"
18636
- }), method(object({ trackId: string() }), RetrainFrameListSchema, {
18637
- kind: "query",
18638
- auth: "admin"
18639
- }), method(object({
18640
18468
  deviceId: number(),
18641
- trackId: string(),
18642
- mediaKeys: array(string()).min(1)
18643
- }), RetrainFrameSelectionSchema, {
18644
- kind: "mutation",
18645
- auth: "admin"
18646
- }), method(object({
18469
+ className: string(),
18470
+ ...TieredLabelFields,
18471
+ producingDeviceName: string().optional(),
18472
+ /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
18473
+ source: TrackSourceSchema.optional(),
18474
+ firstSeen: number(),
18475
+ lastSeen: number(),
18476
+ /** Frame-rate position history (subject to maxPositionHistory cap). */
18477
+ positions: array(TrackPositionSchema).readonly(),
18478
+ /** Periodic snapshots at snapshotIntervalMs cadence (subject to
18479
+ * saveThumbnails policy). */
18480
+ snapshots: array(TrackSnapshotSchema).readonly(),
18481
+ /** Deduplicated zones the track has entered at least once. Zone IDS. */
18482
+ zonesVisited: array(string()).readonly(),
18483
+ /**
18484
+ * Human NAMES for {@link zonesVisited}, resolved at READ time against the
18485
+ * `zones` capability.
18486
+ *
18487
+ * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
18488
+ * and no card can render — so every free-text search surface was structurally
18489
+ * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
18490
+ * just returned nothing. Resolving here rather than in each client keeps ONE
18491
+ * derivation and costs the clients no extra call (the `zones` cap is
18492
+ * per-device, so a client-side resolve would be a per-camera fan-out on a
18493
+ * surface built to avoid exactly that).
18494
+ *
18495
+ * Resolved, never invented: a zone deleted since the track was written has no
18496
+ * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
18497
+ * two are not positionally aligned. Absent when the track visited no zone, or
18498
+ * when the zone catalogue could not be read.
18499
+ */
18500
+ zoneNames: array(string()).readonly().optional(),
18501
+ /** Deduplicated set of detector classes observed for this track over its
18502
+ * life (a track may be reclassified, e.g. person→vehicle). Absent on
18503
+ * legacy rows written before class accumulation shipped. */
18504
+ classes: array(string()).readonly().optional(),
18505
+ /** Cumulative normalized distance travelled (0..1 units = full frame width). */
18506
+ totalDistance: number(),
18507
+ state: TrackStateSchema,
18508
+ active: boolean(),
18509
+ /** Deterministic key-event importance score in [0,1] (server-computed at
18510
+ * track expiry, recomputed on late label). Absent on legacy rows written
18511
+ * before scoring shipped — consumers degrade to absence / compute-on-read. */
18512
+ importance: number().optional(),
18513
+ /** Id of the track's highest-confidence ObjectEvent (its representative
18514
+ * "best" frame). Absent when the track produced no object events. */
18515
+ bestEventId: string().optional(),
18516
+ /** Tag of the importance sub-signal that dominated the score
18517
+ * (identity|dwell|proximity|class|confidence|travel|zone). */
18518
+ importanceReason: string().optional(),
18519
+ /** Audio-classification labels heard on the camera during the track's
18520
+ * life (score ≥ device `classificationMinScore`), aggregated per label.
18521
+ * Absent on legacy rows / tracks with no confident audio. */
18522
+ audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
18523
+ /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
18524
+ * Populated from the persisted envelope columns on historical reads;
18525
+ * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
18526
+ envelope: TrackEnvelopeSchema.optional(),
18527
+ /**
18528
+ * A face DETECTOR found a face on this track — nothing more. It says the
18529
+ * detail plane produced a `face` detail; it does NOT say the face was
18530
+ * embedded, matched, above `minFacePx`, or that the recognizer was even
18531
+ * enabled. Set once and never cleared.
18532
+ *
18533
+ * **This exists so "face present but not recognised" is expressible.** A
18534
+ * recognised identity lands in `subLabel` (attributed to the face chain via
18535
+ * `subLabelMeta.stepId`), so before this field a track with an unmatched face
18536
+ * and a track with no face at all were byte-identical on the wire and no
18537
+ * surface could tell them apart. The read is `hasFace === true && subLabel
18538
+ * === undefined`.
18539
+ *
18540
+ * **Absent ≠ false.** Every row written before the column existed omits it,
18541
+ * and so does every server that predates the field — a consumer must test
18542
+ * `=== true` and render nothing otherwise, never infer "no face".
18543
+ */
18544
+ hasFace: boolean().optional(),
18545
+ /**
18546
+ * This track has a face row IN THE GALLERY: a crop **and** an embedding — a
18547
+ * face an operator could ASSIGN to an identity.
18548
+ *
18549
+ * The STRICT twin of {@link hasFace}, and the pair only earns its keep
18550
+ * because the two disagree. `hasFace` is stamped at the TOP of the face
18551
+ * branch, before every gate, and means no more than "a face detector produced
18552
+ * a face detail". This one is stamped at the single moment the gallery row
18553
+ * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
18554
+ * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
18555
+ * candidate gate, the imageless-track drop (no crop was ever captured) and
18556
+ * the crop-store drop. Everything between the detector and that insert can
18557
+ * legitimately refuse the face, so a flag written any earlier promises the
18558
+ * operator something to assign and delivers nothing.
18559
+ *
18560
+ * **Independent of recognition.** A face collected but never auto-matched is
18561
+ * still assignable — it is in fact the face an operator most wants to reach —
18562
+ * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
18563
+ * `subLabel`; this says only that the raw material exists.
18564
+ *
18565
+ * **Set once, never cleared.** A track that produced a gallery row produced
18566
+ * one; deleting the row later is the gallery's business, not this flag's.
18567
+ *
18568
+ * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
18569
+ * before the column omits it, and so does every server that predates the
18570
+ * field. A consumer must test `=== true` and render nothing otherwise —
18571
+ * never infer "no assignable face".
18572
+ */
18573
+ hasEmbeddedFace: boolean().optional(),
18574
+ /**
18575
+ * This subject CONTAINS a folded rider — a person the rider-pairing step
18576
+ * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
18577
+ * so the passage is tracked once and as a VEHICLE.
18578
+ *
18579
+ * It exists because the fold's record was dishonest. D34 and the code both
18580
+ * said "the person is not lost — it is reported so both entities stay on the
18581
+ * record"; in fact the pair went into a per-processor RAM field behind an
18582
+ * accessor nobody called, and every durable surface said `vehicle`, full
18583
+ * stop. This is the composition note that makes the row true.
18584
+ *
18585
+ * A COMPOSITION, never a class and never a label. "This vehicle contains a
18586
+ * person" is not an answer to "what is this" — both label tiers would refuse
18587
+ * a macro token anyway (D89), and correctly. Nothing here changes what the
18588
+ * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
18589
+ * and a `person` rule still does not fire for someone cycling past.
18590
+ *
18591
+ * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
18592
+ * the column, and every hub that predates the field, omits it. Test
18593
+ * `=== true` and render nothing otherwise — never infer "no rider".
18594
+ */
18595
+ hasRider: boolean().optional(),
18596
+ ...TrackFlagFields,
18597
+ ...TrackRetrainFields
18598
+ });
18599
+ var BaseEventFields = {
18600
+ id: string(),
18647
18601
  deviceId: number(),
18648
- trackId: string(),
18649
- frameId: string()
18650
- }), object({
18651
- removed: boolean(),
18652
- removedAnnotations: number().int()
18653
- }), {
18654
- kind: "mutation",
18655
- auth: "admin"
18656
- }), method(object({ frameId: string() }), object({
18602
+ timestamp: number()
18603
+ };
18604
+ var MotionEventSchema = object({
18605
+ ...BaseEventFields,
18606
+ kind: literal("motion"),
18607
+ regionCount: number(),
18608
+ /** Heavy JSON array — omitted in slim projection. */
18609
+ regions: array(object({
18610
+ bbox: BoundingBoxSchema,
18611
+ pixelCount: number(),
18612
+ intensity: number()
18613
+ })).readonly().optional(),
18614
+ /** Omitted in slim projection. */
18615
+ frameWidth: number().optional(),
18616
+ /** Omitted in slim projection. */
18617
+ frameHeight: number().optional(),
18618
+ /** Populated by B5 (recording playback URL for this event). */
18619
+ mediaUrl: string().optional()
18620
+ });
18621
+ /**
18622
+ * Which detection SOURCE produced an object event. `pipeline` = the ML
18623
+ * detection pipeline (decoded-frame inference); `onboard` = the camera's
18624
+ * native on-device AI. Both flow through the SAME analysis layers (zoning,
18625
+ * tracking, per-kind persistence) but stay distinguishable so consumers
18626
+ * (advanced-notifier, occupancy, …) can select which source(s) to act on.
18627
+ * Absent on legacy rows ⇒ treat as `pipeline`.
18628
+ */
18629
+ var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
18630
+ /**
18631
+ * The confirmed zone crossing that produced an object event. Present ONLY on
18632
+ * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
18633
+ * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
18634
+ * appearance event carry none, so a rule asking for a direction fails closed
18635
+ * on them.
18636
+ *
18637
+ * Exactly ONE crossing per event: the emitter turns each confirmed crossing
18638
+ * into its own event, so a frame in which a track enters A while leaving B
18639
+ * produces two events with two directions — never one ambiguous row.
18640
+ *
18641
+ * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
18642
+ * membership the box has NOW, and by definition it no longer contains the zone
18643
+ * that was just left. Without the id here, a zone-scoped rule could never match
18644
+ * the exit it asked for.
18645
+ */
18646
+ var ZoneCrossingSchema = object({
18647
+ direction: _enum(["enter", "exit"]),
18648
+ /** Admin zone id crossed. */
18649
+ zoneId: string(),
18650
+ /** Zone display name at crossing time (falls back to the id). */
18651
+ zoneName: string().optional()
18652
+ });
18653
+ var ObjectEventSchema = object({
18654
+ ...BaseEventFields,
18655
+ kind: literal("object"),
18656
+ /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
18657
+ source: DetectionSourceSchema.optional(),
18658
+ /**
18659
+ * Inference-frame id shared by every object event emitted from the SAME frame
18660
+ * — the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
18661
+ * 2 people + 1 dog) under one full frame, and link a track's frames over time
18662
+ * (group by `trackId`, pick a representative `frameId` as the parent frame).
18663
+ * Optional for backward-compat with pre-existing rows / the slim projection
18664
+ * includes it (it is light). Absent on rows written before this field.
18665
+ */
18666
+ frameId: string().optional(),
18667
+ /** Omitted in slim projection. */
18668
+ trackId: string().optional(),
18669
+ className: string(),
18670
+ ...TieredLabelFields,
18671
+ /** Omitted in slim projection. */
18672
+ confidence: number().optional(),
18673
+ /** Heavy JSON — omitted in slim projection. */
18674
+ bbox: BoundingBoxSchema.optional(),
18675
+ /** Heavy JSON — omitted in slim projection. */
18676
+ zones: array(string()).readonly().optional(),
18677
+ /** Omitted in slim projection. */
18678
+ state: TrackStateSchema.optional(),
18679
+ /**
18680
+ * The zone crossing this event IS, when it is one. Absent on every other
18681
+ * event kind (movement state, appearance, package) — see
18682
+ * {@link ZoneCrossingSchema}. Omitted in slim projection.
18683
+ */
18684
+ zoneCrossing: ZoneCrossingSchema.optional(),
18685
+ /** Detection-frame dimensions in pixels — let consumers normalize the
18686
+ * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
18687
+ frameWidth: number().optional(),
18688
+ frameHeight: number().optional(),
18689
+ /** MediaStore key for the crop attached to this event (if any). */
18690
+ mediaKey: string().optional(),
18691
+ /** Design B: MediaStore key of the track's native-resolution key frame (the
18692
+ * best-detection full frame). Resolve via the event-media data-plane
18693
+ * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
18694
+ * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
18695
+ * sources — consumers fall back to `mediaKey` (the tight crop). */
18696
+ keyFrameMediaKey: string().optional(),
18697
+ /** Populated by B5 (recording playback URL for this event). */
18698
+ mediaUrl: string().optional(),
18699
+ /** The parent track's key-event importance [0,1], propagated to every object
18700
+ * event of the track (so an event row can be sorted by importance without a
18701
+ * track join). Absent on legacy rows / before the track was scored. */
18702
+ importance: number().optional()
18703
+ });
18704
+ var AudioEventSchema = object({
18705
+ ...BaseEventFields,
18706
+ kind: literal("audio"),
18707
+ rms: number(),
18708
+ dbfs: number(),
18709
+ classification: object({
18710
+ className: string(),
18711
+ originalClass: string().optional(),
18712
+ score: number()
18713
+ }).optional(),
18714
+ /** Populated by B5 (recording playback URL for this event). */
18715
+ mediaUrl: string().optional()
18716
+ });
18717
+ var MediaFileKindEnum = _enum([
18718
+ "crop",
18719
+ "thumbnail",
18720
+ "snapshot",
18721
+ "firstFrame",
18722
+ "lastFrame",
18723
+ "fullFrame",
18724
+ "fullFrameBoxed",
18725
+ "faceCrop",
18726
+ "plateCrop",
18727
+ "keyFrame",
18728
+ "keyFrameSmall",
18729
+ "thumbnailSmall"
18730
+ ]);
18731
+ var MediaFileSchema = object({
18732
+ key: string(),
18733
+ kind: MediaFileKindEnum,
18657
18734
  base64: string(),
18658
- width: number().int(),
18659
- height: number().int()
18660
- }), {
18661
- kind: "query",
18662
- auth: "admin"
18663
- }), method(object({
18664
- deviceId: number(),
18665
- trackId: string(),
18666
- frameId: string(),
18667
- subject: RetrainAssistSubjectSchema,
18668
- /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
18669
- nodeId: string().optional()
18670
- }), RetrainAssistResultSchema, {
18671
- kind: "mutation",
18672
- auth: "admin"
18673
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
18674
- kind: "query",
18675
- auth: "admin"
18676
- }), method(object({
18677
- deviceId: number(),
18735
+ sizeBytes: number(),
18736
+ timestamp: number()
18737
+ });
18738
+ /**
18739
+ * One media row WITHOUT its bytes.
18740
+ *
18741
+ * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
18742
+ * 140 s track), and a client that renders tiles from the media data plane needs
18743
+ * to know only WHAT EXISTS — the bytes then arrive per tile, lazily, over HTTP
18744
+ * with an immutable cache, instead of all at once inside a tRPC response that
18745
+ * blocks the whole view.
18746
+ *
18747
+ * `sizeBytes` is carried because it is what lets a client decide between the
18748
+ * stored blob and a `?variant=thumb` rendering without fetching either.
18749
+ */
18750
+ var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
18751
+ /**
18752
+ * The MACRO tier of an annotation — a CLOSED set.
18753
+ *
18754
+ * This is what the exported detector predicts, so a typo here is a new class
18755
+ * with one example in it. `label` and `subLabel` are open strings by contrast:
18756
+ * the whole point of the page is teaching the model things it does not know
18757
+ * yet, and constraining that vocabulary would make it useless.
18758
+ *
18759
+ * A macro class is NEVER a label. The provider refuses a write whose `label` or
18760
+ * `subLabel` is one of these values, in any casing, because once `person`
18761
+ * exists in both tiers "every person box" stops being answerable without
18762
+ * knowing every string anyone ever typed — and the damage is retroactive.
18763
+ */
18764
+ var RetrainMacroClassSchema = _enum([
18765
+ "person",
18766
+ "vehicle",
18767
+ "animal",
18768
+ "package",
18769
+ "face",
18770
+ "plate"
18771
+ ]);
18772
+ /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
18773
+ var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
18774
+ /** Did a human draw this box, or did the assist propose it? */
18775
+ var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
18776
+ /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
18777
+ var RetrainBboxSchema = object({
18778
+ x: number(),
18779
+ y: number(),
18780
+ w: number(),
18781
+ h: number()
18782
+ });
18783
+ /**
18784
+ * One annotated subject.
18785
+ *
18786
+ * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
18787
+ * (letterboxed root / zone-cropped package / subject-cropped classifier) are
18788
+ * derived from it at export and never stored — storing them is how one feature
18789
+ * space ends up holding two crops of the same subject (D52).
18790
+ */
18791
+ var RetrainAnnotationSchema = object({
18792
+ id: string(),
18678
18793
  trackId: string(),
18679
- frameId: string(),
18680
- annotations: array(RetrainAnnotationDraftSchema)
18681
- }), array(RetrainAnnotationSchema).readonly(), {
18682
- kind: "mutation",
18683
- auth: "admin"
18684
- }), method(object({
18685
- deviceId: number(),
18686
- trackId: string()
18687
- }), RetrainTransitionResultSchema, {
18688
- kind: "mutation",
18689
- auth: "admin"
18690
- }), method(object({
18691
18794
  deviceId: number(),
18692
- trackId: string()
18693
- }), RetrainTransitionResultSchema, {
18694
- kind: "mutation",
18695
- auth: "admin"
18696
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18697
- kind: "query",
18698
- auth: "admin"
18699
- }), method(object({
18700
- eventId: string(),
18701
- kind: MediaFileKindEnum.optional(),
18702
- deviceId: number()
18703
- }), array(MediaFileSchema).readonly()), method(object({
18704
- trackId: string(),
18705
- kinds: array(MediaFileKindEnum).optional(),
18706
- deviceId: number()
18707
- }), array(MediaFileSchema).readonly()), method(object({
18795
+ /** The COPY in retrain storage — never the source track's media key. */
18796
+ mediaKey: string(),
18797
+ bbox: RetrainBboxSchema,
18798
+ macroClass: RetrainMacroClassSchema,
18799
+ label: string().optional(),
18800
+ subLabel: string().optional(),
18801
+ kind: RetrainAnnotationKindSchema,
18802
+ source: RetrainAnnotationSourceSchema,
18803
+ /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
18804
+ assistModelId: string().optional(),
18805
+ assistScore: number().optional(),
18806
+ exportedInBatch: string().optional(),
18807
+ createdAt: number()
18808
+ });
18809
+ /** The write form — the server owns `id`, `createdAt` and the frame binding. */
18810
+ var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
18811
+ id: true,
18812
+ trackId: true,
18813
+ deviceId: true,
18814
+ mediaKey: true,
18815
+ createdAt: true,
18816
+ exportedInBatch: true
18817
+ });
18818
+ /** A track sitting in `staging`, with everything the worklist needs to rank it. */
18819
+ var RetrainTrackSchema = object({
18708
18820
  trackId: string(),
18709
- deviceId: number()
18710
- }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
18711
- kind: "mutation",
18712
- auth: "admin"
18713
- }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
18714
- kind: "mutation",
18715
- auth: "admin"
18716
- }), method(object({}), RebuildStatusSchema), object({
18717
18821
  deviceId: number(),
18822
+ className: string(),
18823
+ label: string().optional(),
18824
+ firstSeen: number(),
18825
+ lastSeen: number(),
18826
+ /** How many frames the dataset already holds from this track. */
18827
+ frameCount: number().int(),
18828
+ /** How many subjects have been annotated on those frames. `0` with
18829
+ * `frameCount: 0` is exactly "staging, still to work". */
18830
+ annotationCount: number().int()
18831
+ });
18832
+ /** A frame the picker may offer — an index row, no blob was read to produce it. */
18833
+ var RetrainFrameCandidateSchema = object({
18834
+ mediaKey: string(),
18835
+ kind: MediaFileKindEnum,
18718
18836
  timestamp: number(),
18719
- frameWidth: number(),
18720
- frameHeight: number(),
18721
- detections: array(OverlayDetectionSchema).readonly()
18722
- }), object({
18837
+ sizeBytes: number().int(),
18838
+ /** A copy of this original already exists — selecting it is free and cannot
18839
+ * fail, whatever became of the original. */
18840
+ copied: boolean()
18841
+ });
18842
+ /** A frame the dataset OWNS: bytes copied at selection time. */
18843
+ var RetrainFrameSchema = object({
18844
+ frameId: string(),
18723
18845
  deviceId: number(),
18724
18846
  trackId: string(),
18725
- className: string()
18847
+ /** Provenance only. It may already point at nothing — that is expected. */
18848
+ sourceMediaKey: string(),
18849
+ sourceKind: MediaFileKindEnum,
18850
+ sizeBytes: number().int(),
18851
+ width: number().int(),
18852
+ height: number().int(),
18853
+ copiedAt: number()
18854
+ });
18855
+ /** Why a copy-on-select could not be honoured — named, never a silent skip. */
18856
+ var RetrainCopyRefusalSchema = _enum([
18857
+ "source-missing",
18858
+ "unreadable-image",
18859
+ "write-failed"
18860
+ ]);
18861
+ var RetrainFrameSelectionSchema = object({
18862
+ copied: array(RetrainFrameSchema).readonly(),
18863
+ refused: array(object({
18864
+ sourceMediaKey: string(),
18865
+ reason: RetrainCopyRefusalSchema
18866
+ })).readonly()
18867
+ });
18868
+ var RetrainFrameListSchema = object({
18869
+ candidates: array(RetrainFrameCandidateSchema).readonly(),
18870
+ copies: array(RetrainFrameSchema).readonly(),
18871
+ /** What the page pre-selects — the native key frame when one survives. */
18872
+ autoPickMediaKey: string().optional()
18873
+ });
18874
+ /** What the operator asked the assist to look for. */
18875
+ var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
18876
+ kind: literal("package"),
18877
+ zone: RetrainBboxSchema.optional()
18726
18878
  }), object({
18727
- deviceId: number(),
18728
- trackId: string(),
18729
- className: string(),
18730
- durationMs: number()
18879
+ kind: literal("objects"),
18880
+ modelId: string(),
18881
+ minScore: number().optional()
18882
+ })]);
18883
+ /**
18884
+ * The assist's answer — a discriminated union, because "the model saw nothing"
18885
+ * and "this node cannot run that model" lead to different next moves and a
18886
+ * nullable result cannot tell them apart.
18887
+ */
18888
+ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
18889
+ kind: literal("proposed"),
18890
+ modelId: string(),
18891
+ stepId: string(),
18892
+ minScore: number(),
18893
+ /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
18894
+ proposals: array(RetrainAnnotationDraftSchema).readonly(),
18895
+ /** Returned by the runner but removed by the threshold. */
18896
+ belowThreshold: number().int()
18731
18897
  }), object({
18898
+ kind: literal("refused"),
18899
+ /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
18900
+ reason: string(),
18901
+ detail: string().optional()
18902
+ })]);
18903
+ /** The outcome of a lifecycle move owned by the retrain page. */
18904
+ var RetrainTransitionResultSchema = object({
18905
+ trackId: string(),
18906
+ /** Where the track ended up, whatever happened. */
18907
+ retrainStatus: RetrainStatusSchema,
18908
+ /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
18909
+ changed: boolean(),
18910
+ reason: _enum([
18911
+ "unknown-track",
18912
+ "no-frames-copied",
18913
+ "not-staging",
18914
+ "not-trained",
18915
+ "unchanged"
18916
+ ]).optional()
18917
+ });
18918
+ var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
18919
+ var MAX_EVENT_QUERY_LIMIT = 5e3;
18920
+ var DeviceEventQueryInput = object({
18732
18921
  deviceId: number(),
18733
- kind: EventKindSchema,
18734
- eventId: string(),
18735
- timestamp: number()
18922
+ since: number().optional(),
18923
+ until: number().optional(),
18924
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
18925
+ /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
18926
+ * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
18927
+ * exact behaviour. Callers may omit this field — the store defaults to
18928
+ * `full` when not provided. */
18929
+ projection: _enum(["full", "slim"]).optional()
18736
18930
  });
18737
- /**
18738
- * Reference to the frame's retained NATIVE surface + the parent crop's placement
18739
- * within the frame, so the executor can re-cut a leaf child ROI at native
18740
- * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
18741
- */
18742
- var NativeCropRefSchema = object({
18743
- /** Handle keying the retained native surface (node-pinned to its owner). */
18744
- handle: FrameHandleSchema,
18745
- /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
18746
- cropFrameSpace: object({
18747
- x: number(),
18748
- y: number(),
18749
- w: number(),
18750
- h: number()
18751
- })
18931
+ var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
18932
+ var RecentTracksQueryInput = object({
18933
+ /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
18934
+ deviceIds: array(number()),
18935
+ /** Window lower bound on `lastSeen` (inclusive). */
18936
+ since: number().optional(),
18937
+ /** Window upper bound on `lastSeen` (inclusive). */
18938
+ until: number().optional(),
18939
+ /** Page size. Default 200, max 1000. */
18940
+ limit: number().int().min(1).max(1e3).default(200),
18941
+ /** Opaque continuation cursor from a previous page's `nextCursor`.
18942
+ * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
18943
+ cursor: string().optional(),
18944
+ /** See {@link TrackProjectionSchema}. Default `full`. */
18945
+ projection: TrackProjectionSchema.optional(),
18946
+ /** Include stationary-promoted rows (parked objects). Default false: the
18947
+ * feed lists passages; parking records live on the stationary registry. */
18948
+ includeStationary: boolean().optional()
18752
18949
  });
18753
- object({
18754
- crop: object({
18755
- left: number(),
18756
- top: number(),
18757
- width: number().positive(),
18758
- height: number().positive()
18759
- }).optional(),
18760
- content: object({
18761
- width: number().int().positive(),
18762
- height: number().int().positive()
18763
- }),
18764
- fit: _enum(["stretch", "contain"]),
18765
- format: _enum([
18766
- "rgb",
18767
- "gray",
18768
- "jpeg"
18769
- ])
18950
+ var RecentTracksPageSchema = object({
18951
+ /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
18952
+ tracks: array(TrackSchema).readonly(),
18953
+ /** Cursor for the next page, or null when this page is the last. */
18954
+ nextCursor: string().nullable()
18770
18955
  });
18771
- var FrameRefSchema = object({
18772
- registryId: string().min(1),
18773
- id: string().min(1),
18774
- width: number().int().positive(),
18775
- height: number().int().positive(),
18776
- format: _enum(["rgb", "gray"]),
18777
- timestamp: number(),
18778
- capturedAt: number().optional()
18956
+ var LIST_GROUPS_DEFAULT_LIMIT = 40;
18957
+ var LIST_GROUPS_MAX_LIMIT = 100;
18958
+ var AnalyticsGroupRecordSchema = object({
18959
+ id: string(),
18960
+ deviceId: number().int(),
18961
+ openedAt: number().int(),
18962
+ closedAt: number().int(),
18963
+ timestamp: number().int(),
18964
+ memberCount: number().int(),
18965
+ memberTrackIds: array(string()).readonly(),
18966
+ className: string(),
18967
+ classes: array(string()).readonly(),
18968
+ /** Relative event-media path, or null when the group has no picture yet. */
18969
+ mediaUrl: string().nullable(),
18970
+ singleton: boolean()
18779
18971
  });
18780
- var ModelFormatSchema$1 = _enum([
18781
- "onnx",
18782
- "coreml",
18783
- "openvino",
18784
- "tflite",
18785
- "pt",
18786
- "gguf"
18787
- ]);
18788
- var PipelineSlotSchema = _enum([
18789
- "detector",
18790
- "cropper",
18791
- "classifier",
18792
- "refiner",
18793
- "audio-classifier"
18794
- ]);
18795
- var PipelineEngineChoiceSchema = object({
18796
- runtime: _enum(["node", "python"]),
18797
- backend: string(),
18798
- format: ModelFormatSchema$1,
18799
- device: string().optional()
18972
+ var AnalyticsGroupMemberSchema = object({
18973
+ trackId: string(),
18974
+ deviceId: number().int(),
18975
+ className: string(),
18976
+ firstSeen: number().int(),
18977
+ lastSeen: number().int(),
18978
+ mediaUrl: string().nullable()
18800
18979
  });
18801
- var AvailableEngineSchema = object({
18802
- engine: PipelineEngineChoiceSchema,
18803
- devices: array(object({
18804
- id: string(),
18805
- label: string(),
18806
- description: string().optional()
18807
- })).readonly(),
18808
- defaultDevice: string()
18980
+ var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
18981
+ var ListGroupsQueryInput = object({
18982
+ /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
18983
+ deviceIds: array(number()),
18984
+ /** Window lower bound on `closedAt` (inclusive). */
18985
+ since: number().optional(),
18986
+ /** Window upper bound on `openedAt` (inclusive). */
18987
+ until: number().optional(),
18988
+ limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
18989
+ /** Opaque continuation cursor from a previous page's `nextCursor`. */
18990
+ cursor: string().optional()
18809
18991
  });
18810
- var PipelineDefaultStepSchema = lazy(() => object({
18811
- addonId: string(),
18812
- addonName: string(),
18813
- slot: PipelineSlotSchema,
18814
- inputClasses: array(string()).readonly(),
18815
- outputClasses: array(string()).readonly(),
18816
- enabled: boolean(),
18817
- modelId: string(),
18818
- children: array(PipelineDefaultStepSchema).readonly(),
18819
- group: string().optional(),
18820
- settings: record(string(), unknown()).optional()
18821
- }));
18822
- var PipelineTemplateStepSchema = lazy(() => object({
18823
- addonId: string(),
18824
- enabled: boolean(),
18825
- modelId: string(),
18826
- children: array(PipelineTemplateStepSchema).readonly(),
18827
- settings: record(string(), unknown()).optional()
18828
- }));
18829
- var PipelineTemplateSchema$1 = object({
18830
- id: string(),
18831
- name: string(),
18832
- createdAt: string(),
18833
- updatedAt: string(),
18834
- engine: PipelineEngineChoiceSchema,
18835
- steps: array(PipelineTemplateStepSchema).readonly()
18992
+ var ListGroupsPageSchema = object({
18993
+ groups: array(AnalyticsGroupRecordSchema).readonly(),
18994
+ nextCursor: string().nullable()
18995
+ });
18996
+ var KeyEventQueryInput = object({
18997
+ deviceId: number(),
18998
+ /** Window lower bound (track firstSeen ≥ since). */
18999
+ since: number(),
19000
+ /** Window upper bound (track firstSeen ≤ until). */
19001
+ until: number(),
19002
+ limit: number().int().min(1).max(200).default(50),
19003
+ /** Drop tracks scoring below this importance. */
19004
+ minImportance: number().min(0).max(1).optional(),
19005
+ /** Restrict to a single class (e.g. 'person'). */
19006
+ classFilter: string().optional()
18836
19007
  });
18837
- var PipelineModelOptionSchema = object({
19008
+ var KeyEventSchema = object({
19009
+ /** The representative event id (the track's best ObjectEvent, else its trackId). */
18838
19010
  id: string(),
18839
- name: string(),
18840
- formats: record(string(), object({
18841
- downloaded: boolean(),
18842
- sizeMB: number()
18843
- })),
18844
- group: ModelVariantGroupSchema.optional(),
18845
- legacy: boolean().optional(),
18846
- provider: ModelProviderIdSchema.optional()
19011
+ trackId: string(),
19012
+ /** Track start time (firstSeen). */
19013
+ timestamp: number(),
19014
+ className: string(),
19015
+ ...TieredLabelFields,
19016
+ importance: number(),
19017
+ /** Highest-confidence ObjectEvent id for the track (empty when none). */
19018
+ bestEventId: string(),
19019
+ /** Track lifetime in ms (lastSeen - firstSeen). */
19020
+ windowMs: number().optional(),
19021
+ ...TrackFlagFields,
19022
+ ...TrackRetrainFields
18847
19023
  });
18848
- var ConfigFieldBridge = custom();
18849
- var PipelineAddonSchemaSchema = object({
18850
- id: string(),
18851
- name: string(),
18852
- slot: PipelineSlotSchema,
18853
- inputClasses: array(string()).readonly(),
18854
- outputClasses: array(string()).readonly(),
18855
- childSlots: array(PipelineSlotSchema).readonly(),
18856
- models: array(PipelineModelOptionSchema).readonly(),
18857
- defaultModelId: string(),
18858
- defaultModelIdByFormat: record(string(), string()).optional(),
18859
- enabledByDefault: boolean().optional(),
18860
- backfillIntoExistingOverrides: boolean().optional(),
18861
- defaultConfidence: number(),
18862
- group: string().optional(),
18863
- configSchema: array(ConfigFieldBridge).readonly().optional()
19024
+ object({
19025
+ trackId: string(),
19026
+ className: string(),
19027
+ confidence: number(),
19028
+ bbox: BoundingBoxSchema,
19029
+ zones: array(string()).readonly(),
19030
+ state: TrackStateSchema
18864
19031
  });
18865
- var PipelineSlotSchemaSchema = object({
18866
- id: PipelineSlotSchema,
18867
- label: string(),
18868
- priority: number(),
18869
- parentSlot: PipelineSlotSchema.nullable(),
18870
- addons: array(PipelineAddonSchemaSchema).readonly()
19032
+ var OverlayDetectionSchema = looseObject({
19033
+ id: string(),
19034
+ kind: _enum(["first-level", "detail"]),
19035
+ macroClass: string(),
19036
+ score: number(),
19037
+ bbox: object({
19038
+ x: number(),
19039
+ y: number(),
19040
+ width: number(),
19041
+ height: number()
19042
+ }),
19043
+ labels: array(looseObject({
19044
+ label: string(),
19045
+ score: number()
19046
+ })).readonly(),
19047
+ parentId: string().optional()
18871
19048
  });
18872
- var PipelineSchemaSchema = object({
18873
- availableEngines: array(AvailableEngineSchema).readonly(),
18874
- selectedEngine: PipelineEngineChoiceSchema,
18875
- slots: array(PipelineSlotSchemaSchema).readonly()
19049
+ var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
19050
+ var SearchObjectEventsInput = object({
19051
+ text: string(),
19052
+ deviceId: number().optional(),
19053
+ since: number().optional(),
19054
+ until: number().optional(),
19055
+ classFilter: string().optional(),
19056
+ limit: number().default(50),
19057
+ minScore: number().min(0).max(1).default(.2)
18876
19058
  });
18877
- var EngineProvisioningSchema = object({
18878
- runtimeId: _enum([
18879
- "onnx",
18880
- "openvino",
18881
- "coreml",
18882
- "edgetpu"
18883
- ]).nullable(),
18884
- device: string().nullable(),
18885
- state: _enum([
18886
- "idle",
18887
- "installing",
18888
- "verifying",
18889
- "ready",
18890
- "failed"
18891
- ]),
18892
- progress: number().optional(),
18893
- error: string().optional(),
18894
- nextRetryAt: number().optional(),
18895
- /**
18896
- * Gate A (config-correctness gate at engine change): human-readable
18897
- * config issues surfaced EAGERLY when the node's engine changes — model
18898
- * substitutions ("chose X, running Y") and zero-build steps ("no model
18899
- * has a <format> build"). Additive/optional: informational only, never
18900
- * enforced here — `assertEngineReady` (readiness) still gates inference.
18901
- * Absent/empty when the node-default tree resolves cleanly.
18902
- */
18903
- configIssues: array(string()).optional()
19059
+ var TrackCascadeCountsSchema = object({
19060
+ /** Persisted track roots deleted (authoritative). */
19061
+ tracks: number().int(),
19062
+ /** Object events removed with their tracks (best-effort; see note above). */
19063
+ events: number().int(),
19064
+ /** Track/face/plate-owned media removed (best-effort). Never identity media. */
19065
+ media: number().int(),
19066
+ /** Unassigned (non-enrolled) face reads removed (best-effort). */
19067
+ faces: number().int(),
19068
+ /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
19069
+ plates: number().int(),
19070
+ /** Per-track CLIP search vectors removed (best-effort). */
19071
+ embeddings: number().int(),
19072
+ /** Group membership + group rows removed with their last member (best-effort). */
19073
+ groups: number().int()
18904
19074
  });
18905
- var PipelineStepInputSchema = lazy(() => object({
18906
- addonId: string(),
18907
- modelId: string().optional(),
18908
- enabled: boolean().default(true),
18909
- children: array(PipelineStepInputSchema).optional(),
18910
- settings: record(string(), unknown()).optional(),
18911
- jumpDeviceKey: string().optional()
18912
- }));
18913
- var ModelSubstitutionSchema = object({
18914
- addonId: string(),
18915
- chosen: string(),
18916
- running: string(),
18917
- format: string()
19075
+ /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
19076
+ var DiskReconcileCountsSchema = object({
19077
+ mediaDropped: number().int(),
19078
+ tracks: number().int(),
19079
+ events: number().int()
18918
19080
  });
18919
- var PipelineValidationIssueSchema = object({
18920
- addonId: string(),
18921
- kind: _enum(["unknown-addon", "no-format-build"]),
18922
- detail: string()
19081
+ /** Event-store footprint for one camera. */
19082
+ var EventStoreDeviceFootprintSchema = object({
19083
+ deviceId: number(),
19084
+ /** Persisted event rows (motion + object + audio) for the camera. */
19085
+ rows: number().int(),
19086
+ /** Event-owned media bytes on disk for the camera. */
19087
+ bytes: number().int()
18923
19088
  });
18924
- var PipelineValidationResultSchema = object({
18925
- ok: boolean(),
18926
- issues: array(PipelineValidationIssueSchema).readonly(),
18927
- substitutions: array(ModelSubstitutionSchema).readonly(),
18928
- /** The node's `currentEngine.format` this validation ran against. */
18929
- format: string()
19089
+ /** Aggregate event-store footprint: global totals + per-camera breakdown. */
19090
+ var EventStoreFootprintSchema = object({
19091
+ totalRows: number().int(),
19092
+ totalBytes: number().int(),
19093
+ devices: array(EventStoreDeviceFootprintSchema).readonly()
18930
19094
  });
18931
- var ReferenceImageEntrySchema = object({
18932
- filename: string(),
18933
- stepIds: array(string()).readonly().optional()
19095
+ /** Per-kind counts returned by the event-prune / device-delete mutations. */
19096
+ var EventPruneCountsSchema = object({
19097
+ motion: number().int(),
19098
+ object: number().int(),
19099
+ audio: number().int()
18934
19100
  });
18935
- var ReferenceImageBodySchema = object({
18936
- base64: string(),
18937
- filename: string()
19101
+ /**
19102
+ * Re-embed stored tracks from their key frames.
19103
+ *
19104
+ * The reason this is an operator-callable method and not a migration script:
19105
+ * every knob that decides what a vector MEANS — encoder model, crop margin,
19106
+ * squaring — is only changeable if the existing vectors can be regenerated.
19107
+ * Mixing feature spaces in one index makes cosine scores incomparable, and the
19108
+ * symptom is a quality regression with no visible cause.
19109
+ */
19110
+ var RebuildObjectEmbeddingsInput = object({
19111
+ /** Restrict to one camera. Omit for the whole fleet. */
19112
+ deviceId: number().optional(),
19113
+ since: number().optional(),
19114
+ until: number().optional(),
19115
+ /** Stop after this many tracks; the result reports whether more remain. */
19116
+ maxTracks: number().int().positive().optional(),
19117
+ /**
19118
+ * Run every embedding on THIS node instead of round-robining the fleet.
19119
+ *
19120
+ * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
19121
+ * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
19122
+ * calling it that would pin the rebuild REQUEST itself to that node — the
19123
+ * rebuild orchestration lives on the hub, and only the per-track step runs
19124
+ * remotely. This field is data; the per-track pin is applied inside.
19125
+ *
19126
+ * Absent ⇒ round-robin over every online node whose runner can serve the
19127
+ * pinned model.
19128
+ */
19129
+ executeOnNodeId: string().optional(),
19130
+ /**
19131
+ * Milliseconds to wait between tracks; omit for the built-in default, `0` to
19132
+ * run flat out.
19133
+ *
19134
+ * A rebuild is bulk maintenance on hub-main's single thread. Measured
19135
+ * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
19136
+ * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
19137
+ * force is logged at start and finish so a deliberately slow pass reads
19138
+ * differently from a stalled one.
19139
+ */
19140
+ pacingMs: number().int().nonnegative().optional()
18938
19141
  });
18939
- var ReferenceAudioEntrySchema = object({
18940
- filename: string(),
18941
- sizeKb: number()
19142
+ /**
19143
+ * Result of emptying the CLIP index.
19144
+ *
19145
+ * The clean slate before a policy change: a new crop margin or encoder model
19146
+ * leaves two feature spaces in one index whose cosine scores are not
19147
+ * comparable, so wiping and rebuilding is the only way to be sure every vector
19148
+ * means the same thing.
19149
+ */
19150
+ var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
19151
+ /**
19152
+ * Acknowledgement that a rebuild STARTED.
19153
+ *
19154
+ * The pass costs ~1s per track — 45 minutes for a 2,600-track fleet — so it
19155
+ * runs detached and this returns immediately. Waiting for it made the client
19156
+ * time out while the work carried on server-side, which is the worst of both:
19157
+ * no result and no way to know it was still going. Poll
19158
+ * `getObjectEmbeddingRebuildStatus` for progress.
19159
+ */
19160
+ var RebuildObjectEmbeddingsResultSchema = object({
19161
+ started: boolean(),
19162
+ /** True when a pass was already running; the new request is ignored. */
19163
+ alreadyRunning: boolean()
18942
19164
  });
18943
- var ReferenceAudioBodySchema = object({ base64: string() });
18944
- var AudioBackendSchema = object({
18945
- id: string(),
18946
- name: string(),
18947
- description: string(),
18948
- available: boolean(),
19165
+ var RebuildStatusSchema = object({
19166
+ running: boolean(),
19167
+ scanned: number(),
19168
+ rebuilt: number(),
19169
+ /** Tracks whose key frame is gone — nothing to re-embed from. */
19170
+ missingKeyFrame: number(),
19171
+ /** Tracks with no usable detection box. */
19172
+ missingBbox: number(),
19173
+ /**
19174
+ * Tracks an executing node REFUSED rather than broke on — an unreadable key
19175
+ * frame, a step that threw. Separate from `failed` because the remedy is
19176
+ * different, and because a whole camera silently contributing zero vectors
19177
+ * is the shape of failure a rebuild must never hide.
19178
+ */
19179
+ notRunnable: number(),
18949
19180
  /**
18950
- * Raw classifier labels this backend can emit (e.g. YAMNet's
18951
- * 521-class set or Apple SoundAnalysis's 303-class set). Used by
18952
- * the benchmark UI to populate the `enabledMicroClasses` filter
18953
- * specific to the selected backend without a separate fetch.
19181
+ * The pass stopped because NO node could serve the pinned model.
19182
+ *
19183
+ * Distinct from `notRunnable` on purpose: that one says "this track was
19184
+ * refused", this one says "the cluster cannot do this work at all" — every
19185
+ * candidate node either lacks the `clip-embedding` step, lacks a build of the
19186
+ * pinned model for its engine format, or dropped out. The remedy is a model /
19187
+ * engine change, not a per-camera one. Non-zero here always comes with
19188
+ * `complete: false`.
18954
19189
  */
18955
- rawLabels: array(string()).readonly().optional()
18956
- });
18957
- var AudioCapabilitiesSchema = object({
18958
- activeBackend: string(),
18959
- availableBackends: array(AudioBackendSchema).readonly(),
18960
- sampleRate: number(),
18961
- chunkDurationMs: number()
18962
- });
18963
- var DownloadModelResultSchema = object({
18964
- filePath: string(),
18965
- sizeMB: number(),
18966
- durationMs: number()
19190
+ noCapableNode: number(),
19191
+ failed: number(),
19192
+ /** Set once a pass ends: true only when EVERYTHING was covered. */
19193
+ complete: boolean().nullable(),
19194
+ startedAtMs: number().nullable(),
19195
+ finishedAtMs: number().nullable(),
19196
+ /** Present when the pass ended by throwing. */
19197
+ error: string().nullable()
18967
19198
  });
18968
- /**
18969
- * Wrapper carrying a single test run's result. Replaces the legacy
18970
- * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
18971
- * canonical `AudioResult` from the Phase 6 output rework: one
18972
- * `AudioDetection` per class above `minScore`, top-N candidates in
18973
- * `debug.alternateLabels['audio-classifier']`, per-source timings in
18974
- * `debug.stepTimings`. The outer `success`/`error` fields stay so the
18975
- * benchmark UI can still report a clean failure when the classifier
18976
- * cap isn't available.
18977
- */
18978
- var AudioTestResultSchema = object({
18979
- success: boolean(),
18980
- error: string().optional(),
18981
- frame: custom().optional()
19199
+ var ReplayFrameInputSchema = object({
19200
+ timestamp: number(),
19201
+ frame: PipelineRunResultBridge
18982
19202
  });
18983
- var PipelineConfigBridge = custom();
18984
- var ConfigUISchemaBridge = custom();
18985
- var ConfigUISchemaNullableBridge = custom();
18986
- var InferenceCapabilitiesBridge = custom();
18987
- var ModelAvailabilityListBridge = custom();
18988
- var PipelineRunResultBridge = custom();
18989
- method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
18990
- modelId: string(),
18991
- settings: record(string(), unknown()).readonly()
18992
- }))), method(object({ steps: record(string(), object({
18993
- modelId: string(),
18994
- settings: record(string(), unknown()).readonly()
18995
- })) }), object({ success: literal(true) }), {
19203
+ var RunReplayFrameProcessorResultSchema = object({ tracks: array(object({
19204
+ className: string(),
19205
+ firstSeenMs: number(),
19206
+ lastSeenMs: number(),
19207
+ /** Bbox of the track's FIRST matched detection, pixel-space in the clip's
19208
+ * frame a representative box for the diff's `(className, window, IoU)`
19209
+ * pairing (`replay-diff.ts`). A replay does not need the full per-frame
19210
+ * trajectory production's `Track.positions` keeps. */
19211
+ bbox: BoundingBoxSchema,
19212
+ /** How many of the input frames this track matched a real detection on
19213
+ * (never a coasted/extrapolated frame) — the replay's own signal for "how
19214
+ * solid is this track", cheaper than re-deriving it from a trajectory. */
19215
+ framesMatched: number().int()
19216
+ })).readonly() });
19217
+ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
19218
+ deviceId: number(),
19219
+ trackId: string()
19220
+ }), TrackSchema.nullable()), method(object({
19221
+ deviceId: number(),
19222
+ since: number().optional(),
19223
+ until: number().optional(),
19224
+ limit: number().optional(),
19225
+ /** Spatial filter — only tracks whose trajectory intersects the zone
19226
+ * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
19227
+ * envelope columns, then precisely tested per position. Tracks with
19228
+ * an unknown envelope (no frame dims at persist time) always match. */
19229
+ zone: TrackZoneFilterSchema.optional(),
19230
+ /** See {@link TrackProjectionSchema}. Default `full` (backward
19231
+ * compatible — omitting the field keeps today's exact behaviour). */
19232
+ projection: TrackProjectionSchema.optional(),
19233
+ /** Include stationary-promoted rows (parked objects handed to the
19234
+ * stationary registry). Default false: the timeline lists passages,
19235
+ * not parking records (operator decision, 2026-08-15). */
19236
+ includeStationary: boolean().optional()
19237
+ }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
19238
+ deviceId: number(),
19239
+ groupId: string().min(1)
19240
+ }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
19241
+ kind: "mutation",
19242
+ auth: "admin"
19243
+ }), 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({
19244
+ deviceId: number(),
19245
+ since: number().optional(),
19246
+ until: number().optional(),
19247
+ kinds: array(string()).optional(),
19248
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
19249
+ }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
19250
+ deviceId: number(),
19251
+ since: number(),
19252
+ until: number(),
19253
+ bucketMs: number().int().positive()
19254
+ }), array(object({
19255
+ bucketStart: number(),
19256
+ motion: number().int(),
19257
+ object: number().int(),
19258
+ audio: number().int()
19259
+ })).readonly()), method(object({
19260
+ deviceId: number(),
19261
+ cutoffMs: number()
19262
+ }), object({
19263
+ motion: number().int(),
19264
+ object: number().int(),
19265
+ audio: number().int()
19266
+ }), {
19267
+ kind: "mutation",
19268
+ auth: "admin"
19269
+ }), method(object({
19270
+ deviceId: number(),
19271
+ cutoffMs: number()
19272
+ }), TrackCascadeCountsSchema, {
19273
+ kind: "mutation",
19274
+ auth: "admin"
19275
+ }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
19276
+ kind: "mutation",
19277
+ auth: "admin"
19278
+ }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
19279
+ kind: "mutation",
19280
+ auth: "admin"
19281
+ }), method(object({
19282
+ deviceId: number(),
19283
+ trackIds: array(string()).min(1)
19284
+ }), object({
19285
+ deleted: number().int(),
19286
+ failed: array(string()).readonly()
19287
+ }), {
19288
+ kind: "mutation",
19289
+ auth: "admin"
19290
+ }), method(object({
19291
+ /** Log/audit scope only — the trackId is globally unique on its own. */
19292
+ deviceId: number(),
19293
+ trackId: string(),
19294
+ flags: TrackFlagsPatchSchema
19295
+ }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
19296
+ kind: "query",
19297
+ auth: "admin"
19298
+ }), method(object({
19299
+ olderThanMs: number(),
19300
+ reason: OpsLogReasonSchema.optional()
19301
+ }), EventPruneCountsSchema, {
19302
+ kind: "mutation",
19303
+ auth: "admin"
19304
+ }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
19305
+ kind: "mutation",
19306
+ auth: "admin"
19307
+ }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
19308
+ kind: "mutation",
19309
+ auth: "admin"
19310
+ }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
19311
+ kind: "mutation",
19312
+ auth: "admin"
19313
+ }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
19314
+ kind: "mutation",
19315
+ auth: "admin"
19316
+ }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
19317
+ kind: "mutation",
19318
+ auth: "admin"
19319
+ }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
19320
+ kind: "mutation",
19321
+ auth: "admin"
19322
+ }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
19323
+ kind: "mutation",
19324
+ auth: "admin"
19325
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
19326
+ kind: "query",
19327
+ auth: "admin"
19328
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
19329
+ kind: "mutation",
19330
+ auth: "admin"
19331
+ }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
19332
+ kind: "query",
19333
+ auth: "admin"
19334
+ }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
19335
+ kind: "query",
19336
+ auth: "admin"
19337
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
19338
+ kind: "query",
19339
+ auth: "admin"
19340
+ }), method(object({
19341
+ /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
19342
+ * `deviceId`, deliberately: `deviceId` would make this device-bound and
19343
+ * route it at one camera's owner, and "every camera" would stop being
19344
+ * expressible at all. */
19345
+ deviceIds: array(number()).optional(),
19346
+ limit: number().int().min(1).max(500).optional()
19347
+ }), array(RetrainTrackSchema).readonly(), {
19348
+ kind: "query",
19349
+ auth: "admin"
19350
+ }), method(object({ trackId: string() }), RetrainFrameListSchema, {
19351
+ kind: "query",
19352
+ auth: "admin"
19353
+ }), method(object({
19354
+ deviceId: number(),
19355
+ trackId: string(),
19356
+ mediaKeys: array(string()).min(1)
19357
+ }), RetrainFrameSelectionSchema, {
19358
+ kind: "mutation",
19359
+ auth: "admin"
19360
+ }), method(object({
19361
+ deviceId: number(),
19362
+ trackId: string(),
19363
+ frameId: string()
19364
+ }), object({
19365
+ removed: boolean(),
19366
+ removedAnnotations: number().int()
19367
+ }), {
19368
+ kind: "mutation",
19369
+ auth: "admin"
19370
+ }), method(object({ frameId: string() }), object({
19371
+ base64: string(),
19372
+ width: number().int(),
19373
+ height: number().int()
19374
+ }), {
19375
+ kind: "query",
19376
+ auth: "admin"
19377
+ }), method(object({
19378
+ deviceId: number(),
19379
+ trackId: string(),
19380
+ frameId: string(),
19381
+ subject: RetrainAssistSubjectSchema,
19382
+ /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
19383
+ nodeId: string().optional()
19384
+ }), RetrainAssistResultSchema, {
19385
+ kind: "mutation",
19386
+ auth: "admin"
19387
+ }), method(object({
19388
+ deviceId: number(),
19389
+ source: DetectionSourceSchema,
19390
+ zones: array(ZoneSchema).readonly().optional(),
19391
+ detectionRules: array(ZoneRuleSchema).readonly().optional(),
19392
+ zoneMembershipMinOverlap: number().min(0).max(1).optional(),
19393
+ frames: array(ReplayFrameInputSchema).min(1)
19394
+ }), RunReplayFrameProcessorResultSchema, {
19395
+ kind: "mutation",
19396
+ auth: "admin"
19397
+ }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
19398
+ kind: "query",
19399
+ auth: "admin"
19400
+ }), method(object({
19401
+ deviceId: number(),
19402
+ trackId: string(),
19403
+ frameId: string(),
19404
+ annotations: array(RetrainAnnotationDraftSchema)
19405
+ }), array(RetrainAnnotationSchema).readonly(), {
19406
+ kind: "mutation",
19407
+ auth: "admin"
19408
+ }), method(object({
19409
+ deviceId: number(),
19410
+ trackId: string()
19411
+ }), RetrainTransitionResultSchema, {
18996
19412
  kind: "mutation",
18997
19413
  auth: "admin"
18998
- }), method(object({ nodeId: string() }), object({
18999
- success: literal(true),
19000
- clearedDevices: number()
19001
- }), {
19414
+ }), method(object({
19415
+ deviceId: number(),
19416
+ trackId: string()
19417
+ }), RetrainTransitionResultSchema, {
19002
19418
  kind: "mutation",
19003
19419
  auth: "admin"
19004
- }), 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({
19005
- name: string(),
19006
- steps: array(PipelineTemplateStepSchema).readonly(),
19007
- engine: PipelineEngineChoiceSchema
19008
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
19009
- id: string(),
19010
- name: string().optional(),
19011
- steps: array(PipelineTemplateStepSchema).readonly().optional()
19012
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
19013
- addonId: string(),
19014
- modelId: string(),
19015
- format: ModelFormatSchema$1
19016
- }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
19017
- addonId: string(),
19018
- modelId: string(),
19019
- format: ModelFormatSchema$1
19020
- }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
19021
- engine: PipelineEngineChoiceSchema.optional(),
19022
- steps: array(PipelineStepInputSchema).min(1),
19023
- frame: FrameInputSchema.optional(),
19024
- /**
19025
- * Process-local lazy frame. Valid only when caller and provider resolve
19026
- * in the same execution-group process; split/cross-node callers use
19027
- * `frame`/`image` inline compatibility instead.
19028
- */
19029
- frameRef: FrameRefSchema.optional(),
19030
- /**
19031
- * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
19032
- * the decoded pixels live in. One more member of the one-of
19033
- * frame/frameHandle/image/imageBase64/referenceImage group.
19034
- */
19035
- frameHandle: FrameHandleSchema.optional(),
19036
- imageBase64: string().optional(),
19037
- /**
19038
- * Binary JPEG bytes — preferred over `imageBase64` on internal
19039
- * hops (hub → forked worker via Moleculer MsgPack) because it
19040
- * skips the 33% base64 overhead + the per-call base64 decode on
19041
- * the detection-pipeline worker. Callers can pass either; exactly
19042
- * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
19043
- */
19044
- image: _instanceof(Uint8Array).optional(),
19045
- referenceImage: string().optional(),
19046
- deviceId: number().optional(),
19047
- sessionId: string().optional(),
19048
- /**
19049
- * Execution plane. 'full' (default) runs the whole tree — benchmark,
19050
- * reference-image, and detail-subtree calls. 'frame' is the live
19051
- * per-frame dispatch: ONLY root-plane steps run; crop children
19052
- * (inputClasses ≠ null) are skipped and served per-track via
19053
- * pipelineRunner.runDetailSubtree (two-plane design).
19054
- */
19055
- plane: _enum(["full", "frame"]).optional(),
19056
- /**
19057
- * Inference-device selector (Phase 2 multi-device). Format
19058
- * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
19059
- * Omitted ⇒ the runner's default device (current single-engine
19060
- * behaviour). Selects WHICH device pool of the node runs the call.
19061
- */
19062
- deviceKey: string().optional(),
19063
- /**
19064
- * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
19065
- * when the parent crop was resolved from the frame's retained NATIVE
19066
- * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
19067
- * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
19068
- * resolution from that surface — the SAME quality path faces already
19069
- * had — instead of the downscaled parent tile. `handle` keys the native
19070
- * surface (node-pinned to its owner); `cropFrameSpace` is the parent
19071
- * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
19072
- * the executor's crop-normalized child ROI back into frame-normalized
19073
- * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
19074
- * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
19075
- * (today's behaviour on the fallback path).
19076
- */
19077
- nativeCropRef: NativeCropRefSchema.optional()
19078
- }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
19079
- engine: PipelineEngineChoiceSchema.optional(),
19080
- steps: array(PipelineStepInputSchema).min(1),
19081
- frames: array(FrameInputSchema).min(1).max(255),
19082
- deviceId: number().optional(),
19083
- sessionId: string().optional(),
19084
- /**
19085
- * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
19086
- * the batch to the Python pool's bench preprocess cache
19087
- * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
19088
- * preprocessed ONCE and every later inference is a pure-inference cache
19089
- * hit — the sustained-throughput run measures inference, not
19090
- * decode+preprocess+infer. Omitted/0 for live frames (all different →
19091
- * full preprocess every call, correct). Fresh per sustained run;
19092
- * released via `uncacheFrame`.
19093
- */
19094
- frameId: number().int().nonnegative().optional(),
19095
- /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
19096
- deviceKey: string().optional()
19097
- }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
19098
- data: _instanceof(Uint8Array),
19099
- width: number().int().positive(),
19100
- height: number().int().positive(),
19101
- format: _enum([
19102
- "rgb",
19103
- "bgr",
19104
- "gray"
19105
- ])
19106
- }), object({
19107
- frameId: number(),
19108
- width: number(),
19109
- height: number()
19110
- }), { kind: "mutation" }), method(object({
19111
- stepId: string(),
19112
- frameId: number().int()
19113
- }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
19114
- batchMode: string(),
19115
- windowMs: number(),
19116
- maxBatchSize: number(),
19117
- concurrency: number()
19118
- })), method(_void(), array(object({
19119
- engineKey: string(),
19120
- engine: PipelineEngineChoiceSchema,
19121
- modelsLoaded: array(string()).readonly(),
19122
- inUseByCameras: array(number()).readonly(),
19123
- /**
19124
- * Origin of this resident factory.
19125
- * - `runtime` — main camera-serving engine (no idle TTL).
19126
- * - `warm-override` — benchmark/test override held in the warm
19127
- * cache; auto-disposed after the idle TTL.
19128
- * - `device-pool` — a concurrent per-device pool (Phase 2
19129
- * multi-device, keyed by `deviceKey`) resolved
19130
- * via `resolveDeviceFactory`. Runs alongside the
19131
- * `runtime` engine on a DIFFERENT accelerator
19132
- * (NPU / iGPU / Coral) — this is how the
19133
- * Engines tab shows all pools running at once.
19134
- */
19135
- kind: _enum([
19136
- "runtime",
19137
- "warm-override",
19138
- "device-pool"
19139
- ]),
19140
- /** Native pid of the underlying Python pool (null when no pool). */
19141
- poolPid: number().nullable(),
19142
- /** ms since this factory was last used (null when not warm-tracked). */
19143
- idleMs: number().nullable(),
19144
- /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
19145
- idleTtlMs: number().nullable()
19146
- })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
19147
- kind: "mutation",
19420
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
19421
+ kind: "query",
19148
19422
  auth: "admin"
19149
19423
  }), method(object({
19150
- engine: PipelineEngineChoiceSchema,
19151
- force: boolean().optional()
19152
- }), object({
19153
- success: boolean(),
19154
- reason: string().optional()
19155
- }), {
19424
+ eventId: string(),
19425
+ kind: MediaFileKindEnum.optional(),
19426
+ deviceId: number()
19427
+ }), array(MediaFileSchema).readonly()), method(object({
19428
+ trackId: string(),
19429
+ kinds: array(MediaFileKindEnum).optional(),
19430
+ deviceId: number()
19431
+ }), array(MediaFileSchema).readonly()), method(object({
19432
+ trackId: string(),
19433
+ deviceId: number()
19434
+ }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
19156
19435
  kind: "mutation",
19157
19436
  auth: "admin"
19158
- }), 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({
19159
- addonId: string(),
19160
- modelId: string(),
19161
- filename: string().optional(),
19162
- settings: record(string(), unknown()).optional()
19163
- }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
19437
+ }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
19438
+ kind: "mutation",
19439
+ auth: "admin"
19440
+ }), method(object({}), RebuildStatusSchema), object({
19441
+ deviceId: number(),
19442
+ timestamp: number(),
19443
+ frameWidth: number(),
19444
+ frameHeight: number(),
19445
+ detections: array(OverlayDetectionSchema).readonly()
19446
+ }), object({
19447
+ deviceId: number(),
19448
+ trackId: string(),
19449
+ className: string()
19450
+ }), object({
19451
+ deviceId: number(),
19452
+ trackId: string(),
19453
+ className: string(),
19454
+ durationMs: number()
19455
+ }), object({
19456
+ deviceId: number(),
19457
+ kind: EventKindSchema,
19458
+ eventId: string(),
19459
+ timestamp: number()
19460
+ });
19164
19461
  object({
19165
19462
  activeCameras: number(),
19166
19463
  throttledCameras: number(),
@@ -19172,119 +19469,19 @@ var CameraMetricsSchema = object({
19172
19469
  "disabled",
19173
19470
  "always-on",
19174
19471
  "on-motion"
19175
- ]),
19176
- configuredFps: number(),
19177
- actualFps: number(),
19178
- queueDepth: number(),
19179
- avgInferenceTimeMs: number(),
19180
- droppedFrames: number(),
19181
- phase: _enum([
19182
- "idle",
19183
- "watching",
19184
- "active"
19185
- ])
19186
- });
19187
- var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
19188
- /**
19189
- * Zone — pure geometry + identity. NO filtering behaviour.
19190
- *
19191
- * Zones describe **where** in the frame the operator wants to flag
19192
- * something; consumer-owned {@link ZoneRule} arrays describe **how**
19193
- * each pipeline stage uses them. Splitting the two means a single
19194
- * polygon "Driveway" can simultaneously back a motion-exclude rule,
19195
- * a detection-include rule on `['car']`, and an occupancy aggregate
19196
- * — without three duplicated polygons.
19197
- *
19198
- * Owned by the orchestrator addon (provider) and mirrored into the
19199
- * `zones` device-state slice on every mutation. Consumers
19200
- * (motion-wasm, pipeline-executor, analytics, admin UI) read either
19201
- * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
19202
- * mirror with `onChanged`).
19203
- *
19204
- * Coordinates are normalised fractions of the frame (0–1) so zones
19205
- * survive resolution changes and stream profile switches.
19206
- *
19207
- * `kind` discriminates between full polygons (closed regions used
19208
- * for intrusion / occupancy filters) and tripwires (open 2-point
19209
- * line segments used for cross events). Onboard / firmware-reported
19210
- * zones (Reolink, ONVIF) are out of scope for now — see the deferred
19211
- * task list.
19212
- */
19213
- var ZoneKindEnum = _enum(["polygon", "tripwire"]);
19214
- /** Polygon vertex in fraction-of-frame coordinates (0–1). */
19215
- var PolygonPointSchema = object({
19216
- x: number(),
19217
- y: number()
19218
- });
19219
- /** A camera detection zone — pure geometry/identity. */
19220
- var ZoneSchema = object({
19221
- id: string(),
19222
- name: string(),
19223
- kind: ZoneKindEnum.default("polygon"),
19224
- /** Polygon vertices, fraction of frame (0–1). */
19225
- polygon: array(PolygonPointSchema).readonly(),
19226
- /** Visual color for UI rendering. */
19227
- color: string().default("#3b82f6")
19472
+ ]),
19473
+ configuredFps: number(),
19474
+ actualFps: number(),
19475
+ queueDepth: number(),
19476
+ avgInferenceTimeMs: number(),
19477
+ droppedFrames: number(),
19478
+ phase: _enum([
19479
+ "idle",
19480
+ "watching",
19481
+ "active"
19482
+ ])
19228
19483
  });
19229
- /**
19230
- * Zones capability — per-camera CRUD over polygon detection zones.
19231
- *
19232
- * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
19233
- * to per-device settings and mirrors into the `zones` device-state
19234
- * slice on every mutation, so downstream consumers can subscribe via
19235
- * `dev.state.zones.onChanged`.
19236
- *
19237
- * The cap surface only handles geometry + identity; filtering
19238
- * behaviour (per-class, include/exclude, threshold) lives in the
19239
- * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
19240
- * `capabilities/schemas/zone-rule.js`.
19241
- */
19242
- var zonesCapability = {
19243
- name: "zones",
19244
- scope: "device",
19245
- mode: "singleton",
19246
- deviceTypes: [DeviceType.Camera],
19247
- methods: {
19248
- listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
19249
- addZone: method(object({
19250
- deviceId: number(),
19251
- zone: ZoneSchema
19252
- }), _void(), {
19253
- kind: "mutation",
19254
- auth: "admin"
19255
- }),
19256
- removeZone: method(object({
19257
- deviceId: number(),
19258
- zoneId: string()
19259
- }), _void(), {
19260
- kind: "mutation",
19261
- auth: "admin"
19262
- }),
19263
- updateZone: method(object({
19264
- deviceId: number(),
19265
- zone: ZoneSchema
19266
- }), _void(), {
19267
- kind: "mutation",
19268
- auth: "admin"
19269
- })
19270
- },
19271
- /**
19272
- * Runtime-state slice — the live zone catalogue mirrored by the
19273
- * orchestrator on every CRUD mutation. Consumers read via
19274
- * `device.state.zones.value` / `.watch(...)` without round-tripping
19275
- * the cap, and the codegen DeviceProxy auto-wires the reactive
19276
- * handle. Slice shape is `{ zones: Zone[] }` so future extensions
19277
- * (e.g. zone groupings) can sit alongside the polygon list.
19278
- */
19279
- runtimeState: object({ zones: array(ZoneSchema).readonly() }),
19280
- /**
19281
- * 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.
19282
- *
19283
- * See `RuntimeStateDurability`. Enforced by
19284
- * `scripts/check-runtime-state-durability.ts`.
19285
- */
19286
- durability: "restored"
19287
- };
19484
+ var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
19288
19485
  /**
19289
19486
  * A bounding box in NORMALIZED [0,1] frame coordinates for `getNativeCrop`. The
19290
19487
  * decode worker resolves it against the RETAINED native frame's real pixel dims,
@@ -20973,7 +21170,7 @@ method(object({
20973
21170
  * linking rather than produce an eternal token.
20974
21171
  */
20975
21172
  ttlSec: union([number().int().positive(), literal("never")]).optional()
20976
- }), object({ token: string() })), method(object({ token: string() }), SsoBridgeClaimsSchema.nullable());
21173
+ }), object({ token: string() }), { auth: "admin" }), method(object({ token: string() }), SsoBridgeClaimsSchema.nullable(), { auth: "admin" });
20977
21174
  var ProviderListEntrySchema = discriminatedUnion("shouldSaveDiskSpace", [object({
20978
21175
  providerId: string().min(1),
20979
21176
  displayName: string().min(1),
@@ -21068,10 +21265,13 @@ var EvictResultSchema = object({
21068
21265
  /** True when the provider has nothing left it is willing to drop on this location. */
21069
21266
  exhausted: boolean()
21070
21267
  });
21071
- method(object({ locationId: string() }), EvictableUsageSchema), method(object({
21268
+ method(object({ locationId: string() }), EvictableUsageSchema, { auth: "admin" }), method(object({
21072
21269
  locationId: string(),
21073
21270
  targetBytes: number().int().positive()
21074
- }), EvictResultSchema, { kind: "mutation" });
21271
+ }), EvictResultSchema, {
21272
+ kind: "mutation",
21273
+ auth: "admin"
21274
+ });
21075
21275
  method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin" }), method(StorageMigrationInputSchema, object({ jobId: string() }), {
21076
21276
  kind: "mutation",
21077
21277
  auth: "admin"
@@ -21131,26 +21331,50 @@ var ReadChunkInputSchema = object({
21131
21331
  length: number()
21132
21332
  });
21133
21333
  var EndDownloadInputSchema = object({ downloadId: string() });
21134
- method(_void(), ProviderInfoSchema), method(object({ config: record(string(), unknown()) }), TestLocationResultSchema, { auth: "admin" }), method(object({
21334
+ method(_void(), ProviderInfoSchema, { auth: "admin" }), method(object({ config: record(string(), unknown()) }), TestLocationResultSchema, { auth: "admin" }), method(object({
21135
21335
  location: StorageLocationSchema,
21136
21336
  relativePath: string()
21137
- }), string()), method(object({
21337
+ }), string(), { auth: "admin" }), method(object({
21138
21338
  location: StorageLocationSchema,
21139
21339
  relativePath: string(),
21140
21340
  data: _instanceof(Uint8Array)
21141
- }), _void(), { kind: "mutation" }), method(object({
21341
+ }), _void(), {
21342
+ kind: "mutation",
21343
+ auth: "admin"
21344
+ }), method(object({
21142
21345
  location: StorageLocationSchema,
21143
21346
  relativePath: string()
21144
- }), _instanceof(Uint8Array)), method(object({
21347
+ }), _instanceof(Uint8Array), { auth: "admin" }), method(object({
21145
21348
  location: StorageLocationSchema,
21146
21349
  relativePath: string()
21147
- }), boolean()), method(object({
21350
+ }), boolean(), { auth: "admin" }), method(object({
21148
21351
  location: StorageLocationSchema,
21149
21352
  prefix: string().optional()
21150
- }), array(string()).readonly()), method(object({
21353
+ }), array(string()).readonly(), { auth: "admin" }), method(object({
21151
21354
  location: StorageLocationSchema,
21152
21355
  relativePath: string()
21153
- }), _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" });
21356
+ }), _void(), {
21357
+ kind: "mutation",
21358
+ auth: "admin"
21359
+ }), method(object({ location: StorageLocationSchema }), number().nullable(), { auth: "admin" }), method(BeginUploadInputSchema, BeginUploadResultSchema, {
21360
+ kind: "mutation",
21361
+ auth: "admin"
21362
+ }), method(WriteChunkInputSchema, _void(), {
21363
+ kind: "mutation",
21364
+ auth: "admin"
21365
+ }), method(FinalizeUploadInputSchema, _void(), {
21366
+ kind: "mutation",
21367
+ auth: "admin"
21368
+ }), method(AbortUploadInputSchema, _void(), {
21369
+ kind: "mutation",
21370
+ auth: "admin"
21371
+ }), method(BeginDownloadInputSchema, BeginDownloadResultSchema, {
21372
+ kind: "mutation",
21373
+ auth: "admin"
21374
+ }), method(ReadChunkInputSchema, _instanceof(Uint8Array), { auth: "admin" }), method(EndDownloadInputSchema, _void(), {
21375
+ kind: "mutation",
21376
+ auth: "admin"
21377
+ });
21154
21378
  /** Profile-exported FormBuilder schema. Shape is ConfigUISchema at the UI. */
21155
21379
  var ProfileSettingsSchemaBridge = unknown().nullable();
21156
21380
  var ProfileSettingsBagSchema = record(string(), unknown());
@@ -21408,7 +21632,8 @@ method(object({
21408
21632
  access: "create"
21409
21633
  }), method(object({ userId: string().optional() }), object({ optionsJSON: record(string(), unknown()) }), {
21410
21634
  kind: "mutation",
21411
- access: "view"
21635
+ access: "view",
21636
+ auth: "admin"
21412
21637
  }), method(object({
21413
21638
  /** Required — the user the assertion belongs to (verified). */
21414
21639
  userId: string(),
@@ -21416,10 +21641,12 @@ method(object({
21416
21641
  response: record(string(), unknown())
21417
21642
  }), object({ verified: boolean() }), {
21418
21643
  kind: "mutation",
21419
- access: "view"
21644
+ access: "view",
21645
+ auth: "admin"
21420
21646
  }), method(object({}), object({ optionsJSON: record(string(), unknown()) }), {
21421
21647
  kind: "mutation",
21422
- access: "view"
21648
+ access: "view",
21649
+ auth: "admin"
21423
21650
  }), method(object({
21424
21651
  /** AuthenticationResponseJSON from the browser. */
21425
21652
  response: record(string(), unknown()) }), object({
@@ -21427,7 +21654,8 @@ response: record(string(), unknown()) }), object({
21427
21654
  userId: string().nullable()
21428
21655
  }), {
21429
21656
  kind: "mutation",
21430
- access: "view"
21657
+ access: "view",
21658
+ auth: "admin"
21431
21659
  }), method(object({ userId: string() }), array(PasskeySummarySchema), { auth: "admin" }), method(object({
21432
21660
  userId: string(),
21433
21661
  credentialId: string()
@@ -21599,7 +21827,19 @@ var VectorStatsResultSchema = object({
21599
21827
  /** False when the backend ranks approximately. */
21600
21828
  exact: boolean()
21601
21829
  });
21602
- 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);
21830
+ method(VectorDeclareIndexInputSchema, _void(), {
21831
+ kind: "mutation",
21832
+ auth: "admin"
21833
+ }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
21834
+ kind: "mutation",
21835
+ auth: "admin"
21836
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
21837
+ kind: "mutation",
21838
+ auth: "admin"
21839
+ }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
21840
+ kind: "mutation",
21841
+ auth: "admin"
21842
+ }), method(VectorStatsInputSchema, VectorStatsResultSchema, { auth: "admin" });
21603
21843
  var ClipSchema = object({
21604
21844
  /** Opaque, provider-namespaced id. The default provider encodes the time
21605
21845
  * window so `getClipPlayback` is self-contained (no event re-query). */
@@ -24060,7 +24300,27 @@ var MediaFileLiteSchema$1 = object({
24060
24300
  sizeBytes: number(),
24061
24301
  timestamp: number()
24062
24302
  });
24063
- method(_void(), array(IdentitySchema).readonly()), method(object({ name: string().min(1) }), IdentitySchema, {
24303
+ method(object({
24304
+ /**
24305
+ * Inline {@link IdentitySchema.coverBase64} on every row.
24306
+ *
24307
+ * Default `false`, the same inversion `listRecentFaces` and
24308
+ * `listPlates` took on 2026-08-25 (see `include-crops-default.ts` for
24309
+ * why the burden belongs on the caller that WANTS the bytes). Measured
24310
+ * on the live hub the same day: four identities cost 40,979 B with the
24311
+ * covers inline, ~10 KB of base64 per row, on a query this UI mounts
24312
+ * four times and the viewer holds at `staleTime: 30_000`.
24313
+ *
24314
+ * Nothing loses its avatar: `coverMediaKey` is already on every row and
24315
+ * the `event-media` plane serves that key `immutable` with an ETag.
24316
+ *
24317
+ * **This is an INPUT field, so it does not reach the addon until the
24318
+ * next train** — the hub router validates cap inputs against its own
24319
+ * compiled Zod and strips a key it does not know. Until then the
24320
+ * provider sees `undefined`, which resolves to `false`: the cheap shape
24321
+ * is what ships, and the opt-in becomes reachable when the train lands.
24322
+ */
24323
+ includeCrops: boolean().optional() }).optional(), array(IdentitySchema).readonly()), method(object({ name: string().min(1) }), IdentitySchema, {
24064
24324
  kind: "mutation",
24065
24325
  auth: "admin"
24066
24326
  }), method(object({
@@ -26950,8 +27210,10 @@ var PlateInfoSchema = object({
26950
27210
  keyFrameMediaKey: string().optional(),
26951
27211
  base64: string().optional(),
26952
27212
  /**
26953
- * Same crop as a data-plane URL. `getPlateByTrack` returns this and
26954
- * never inlines JPEG; `listPlates` still inlines for the admin-ui.
27213
+ * Same crop as a data-plane URL, always present when the plate has a stored
27214
+ * crop. `getPlateByTrack` returns this and never inlines JPEG; `listPlates`
27215
+ * and `searchPlates` inline the crop only when their `includeCrops` input is
27216
+ * left at its `true` default.
26955
27217
  */
26956
27218
  cropUrl: string().optional()
26957
27219
  });
@@ -26971,14 +27233,34 @@ var PlateClusterSchema = object({
26971
27233
  });
26972
27234
  method(object({
26973
27235
  deviceId: number().int().optional(),
26974
- limit: number().int().positive().optional()
27236
+ limit: number().int().positive().optional(),
27237
+ /**
27238
+ * Inline the base64 crop on every row. Default `true` — the existing
27239
+ * behaviour, kept so no caller breaks.
27240
+ *
27241
+ * Set `false` once the caller renders {@link PlateInfo.cropUrl}.
27242
+ * Measured on the live hub at the 500 rows the Plates view asks for:
27243
+ * 879,403 B and 27.7 s with the crops inline, against a few KiB of
27244
+ * metadata without them — and the browser then caches the images.
27245
+ *
27246
+ * This is the plate twin of `faceGallery.listRecentFaces`'s option;
27247
+ * plates were the one gallery list left without it.
27248
+ *
27249
+ * **This is an INPUT field, so it does not reach the addon until the
27250
+ * next train.** The hub router validates cap inputs against its own
27251
+ * compiled Zod and strips a key it does not know. Until the train
27252
+ * ships, sending `false` is harmless and keeps the crops inline.
27253
+ */
27254
+ includeCrops: boolean().optional()
26975
27255
  }).optional(), array(PlateInfoSchema).readonly()), method(object({
26976
27256
  deviceId: number().int(),
26977
27257
  trackId: string()
26978
27258
  }), PlateInfoSchema.nullable()), method(object({ plateId: string() }), array(MediaFileLiteSchema).readonly()), method(object({
26979
27259
  text: string().min(1),
26980
27260
  maxDistance: number().int().min(0).optional(),
26981
- limit: number().int().positive().optional()
27261
+ limit: number().int().positive().optional(),
27262
+ /** See `listPlates.includeCrops`. Default `true`. */
27263
+ includeCrops: boolean().optional()
26982
27264
  }), array(PlateInfoSchema).readonly()), method(object({
26983
27265
  maxDistance: number().int().min(0).optional(),
26984
27266
  minClusterSize: number().int().min(2).optional(),
@@ -26992,7 +27274,13 @@ method(object({
26992
27274
  }), method(object({ plateId: string() }), _void(), {
26993
27275
  kind: "mutation",
26994
27276
  auth: "admin"
26995
- }), method(_void(), array(VehicleSchema).readonly()), method(object({ name: string().min(1) }), VehicleSchema, {
27277
+ }), method(object({
27278
+ /** Inline {@link VehicleSchema.coverBase64} on every row. Default
27279
+ * `false` — the vehicle twin of `faceGallery.listIdentities`'s
27280
+ * option; `coverMediaKey` + the `event-media` plane carry the picture.
27281
+ * INPUT field: stripped by the hub router until the train ships, which
27282
+ * resolves to `false` and is exactly the intended default. */
27283
+ includeCrops: boolean().optional() }).optional(), array(VehicleSchema).readonly()), method(object({ name: string().min(1) }), VehicleSchema, {
26996
27284
  kind: "mutation",
26997
27285
  auth: "admin"
26998
27286
  }), method(object({
@@ -28513,92 +28801,6 @@ var sceneMonitorCapability = {
28513
28801
  durability: "session"
28514
28802
  };
28515
28803
  /**
28516
- * Per-stage gating mode applied to the zones a rule references.
28517
- *
28518
- * - `include`: the rule contributes to a **whitelist** for its stage.
28519
- * When at least one `include` rule fires for a stage, only entities
28520
- * inside one of those zones pass that stage.
28521
- * - `exclude`: the rule contributes to a **blacklist** for its stage.
28522
- * Entities inside one of those zones are dropped at that stage.
28523
- *
28524
- * `monitor`-style observation (count without filtering) is not a rule
28525
- * mode — zones without any matching rule are observed naturally by
28526
- * `zone-analytics` (live snapshot + history), so an "I just want to
28527
- * count, not filter" use case needs no rule at all.
28528
- */
28529
- var ZoneRuleModeEnum = _enum(["include", "exclude"]);
28530
- /**
28531
- * Per-consumer rule that references existing zones (geometry) and
28532
- * defines how a specific pipeline stage should treat them. Each
28533
- * consumer addon owns its own `ZoneRule[]` array in its per-device
28534
- * settings:
28535
- *
28536
- * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
28537
- * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
28538
- * - future: notification rules, audio gating, etc.
28539
- *
28540
- * One rule applies to N zones (`zoneIds[]`) so the operator can
28541
- * express "ignore motion in ALL of {garden, street}" with a single
28542
- * rule. `classFilter` narrows the rule to specific object classes —
28543
- * "drop person detections in the street, but keep cars" is one
28544
- * `exclude` rule with `classFilter: ['person']`.
28545
- *
28546
- * `enabled` is a soft toggle — the operator can keep the rule
28547
- * configured but inert without deleting it.
28548
- */
28549
- var ZoneRuleSchema = object({
28550
- /** Stable rule id — survives edits, used by the UI for diffing. */
28551
- id: string(),
28552
- /** Optional human-readable label rendered in the rule editor. */
28553
- name: string().optional(),
28554
- /** Zones this rule targets. The rule's `mode` applies to ALL
28555
- * listed zones (OR-set: a detection in any one of them counts).
28556
- * At least one zone id required — a rule with no targets is a
28557
- * configuration mistake and the form validator rejects it. */
28558
- zoneIds: array(string()).min(1).readonly(),
28559
- mode: ZoneRuleModeEnum,
28560
- /**
28561
- * Class names this rule applies to. Empty / undefined ⇒ rule
28562
- * applies to every class. Class strings match the `macroClass`
28563
- * field on detections (e.g. `person`, `car`, `dog`).
28564
- */
28565
- classFilter: array(string()).readonly().optional(),
28566
- /**
28567
- * Minimum bbox/mask overlap (0–1) with any of the rule's zones
28568
- * required to consider an entity "in the zone". Defaults to the
28569
- * consumer's stage default when omitted. Kept for back-compat with
28570
- * existing per-rule overrides; new operators pick the value via
28571
- * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
28572
- * set, the lower-level engine reads it as a 0–1 fraction.
28573
- */
28574
- overlapThreshold: number().min(0).max(1).optional(),
28575
- /**
28576
- * Operator-friendly version of `overlapThreshold` — the percentage
28577
- * of the detection's bbox that must lie inside the zone for the
28578
- * rule to match. Documented default is 85%; the engine substitutes
28579
- * that when the field is omitted (kept optional so existing rules
28580
- * stored without it stay valid).
28581
- *
28582
- * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
28583
- * rule, the engine prefers `bboxInclusionPct` because it's the
28584
- * field exposed in the UI. Internally both feed the same gate.
28585
- */
28586
- bboxInclusionPct: number().min(0).max(100).optional(),
28587
- /**
28588
- * When `true` and a detection has a segmentation mask, use the
28589
- * mask for overlap instead of the bbox. Detection-stage only;
28590
- * motion rules ignore this field.
28591
- */
28592
- preferMask: boolean().optional(),
28593
- /**
28594
- * Soft-toggle: `false` disables the rule without deleting it.
28595
- * Defaults to `true` so operators creating a rule via the UI
28596
- * see it active immediately.
28597
- */
28598
- enabled: boolean().default(true)
28599
- });
28600
- array(ZoneRuleSchema).readonly();
28601
- /**
28602
28804
  * Script-runner cap. Models HA `script.*` entities on
28603
28805
  * `DeviceType.Script`. A Script is a pre-recorded action sequence
28604
28806
  * that can be invoked imperatively — optionally with a variables
@@ -34253,6 +34455,12 @@ Object.freeze({
34253
34455
  addonId: null,
34254
34456
  access: "create"
34255
34457
  },
34458
+ "pipelineAnalytics.cancelRelocateMedia": {
34459
+ capName: "pipeline-analytics",
34460
+ capScope: "device",
34461
+ addonId: null,
34462
+ access: "create"
34463
+ },
34256
34464
  "pipelineAnalytics.cancelStorageMigrationMove": {
34257
34465
  capName: "pipeline-analytics",
34258
34466
  capScope: "device",
@@ -34427,6 +34635,12 @@ Object.freeze({
34427
34635
  addonId: null,
34428
34636
  access: "view"
34429
34637
  },
34638
+ "pipelineAnalytics.listRelocateMediaJobs": {
34639
+ capName: "pipeline-analytics",
34640
+ capScope: "device",
34641
+ addonId: null,
34642
+ access: "view"
34643
+ },
34430
34644
  "pipelineAnalytics.listRetrainAnnotations": {
34431
34645
  capName: "pipeline-analytics",
34432
34646
  capScope: "device",
@@ -34505,6 +34719,12 @@ Object.freeze({
34505
34719
  addonId: null,
34506
34720
  access: "create"
34507
34721
  },
34722
+ "pipelineAnalytics.relocateMedia": {
34723
+ capName: "pipeline-analytics",
34724
+ capScope: "device",
34725
+ addonId: null,
34726
+ access: "create"
34727
+ },
34508
34728
  "pipelineAnalytics.restageRetrainTrack": {
34509
34729
  capName: "pipeline-analytics",
34510
34730
  capScope: "device",
@@ -34517,6 +34737,12 @@ Object.freeze({
34517
34737
  addonId: null,
34518
34738
  access: "create"
34519
34739
  },
34740
+ "pipelineAnalytics.runReplayFrameProcessor": {
34741
+ capName: "pipeline-analytics",
34742
+ capScope: "device",
34743
+ addonId: null,
34744
+ access: "create"
34745
+ },
34520
34746
  "pipelineAnalytics.saveRetrainAnnotations": {
34521
34747
  capName: "pipeline-analytics",
34522
34748
  capScope: "device",
@@ -34649,6 +34875,12 @@ Object.freeze({
34649
34875
  addonId: null,
34650
34876
  access: "view"
34651
34877
  },
34878
+ "pipelineExecutor.getInferenceDeviceHealth": {
34879
+ capName: "pipeline-executor",
34880
+ capScope: "system",
34881
+ addonId: null,
34882
+ access: "view"
34883
+ },
34652
34884
  "pipelineExecutor.getOrchestratorConfigSchema": {
34653
34885
  capName: "pipeline-executor",
34654
34886
  capScope: "system",
@@ -34721,6 +34953,12 @@ Object.freeze({
34721
34953
  addonId: null,
34722
34954
  access: "view"
34723
34955
  },
34956
+ "pipelineExecutor.rearmInferenceDevice": {
34957
+ capName: "pipeline-executor",
34958
+ capScope: "system",
34959
+ addonId: null,
34960
+ access: "create"
34961
+ },
34724
34962
  "pipelineExecutor.runAudioTest": {
34725
34963
  capName: "pipeline-executor",
34726
34964
  capScope: "system",
@@ -37969,6 +38207,11 @@ Object.freeze({
37969
38207
  form: "single",
37970
38208
  optional: false
37971
38209
  }],
38210
+ "pipelineAnalytics.runReplayFrameProcessor": [{
38211
+ name: "deviceId",
38212
+ form: "single",
38213
+ optional: false
38214
+ }],
37972
38215
  "pipelineAnalytics.saveRetrainAnnotations": [{
37973
38216
  name: "deviceId",
37974
38217
  form: "single",