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