@camstack/addon-matter-broker 0.2.27 → 0.2.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/addon.js +2135 -1892
  2. package/dist/addon.mjs +2135 -1892
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -6644,7 +6644,7 @@ function method(input, output, options) {
6644
6644
  input,
6645
6645
  output,
6646
6646
  kind: options?.kind ?? "query",
6647
- auth: options?.auth ?? "protected",
6647
+ ...options?.auth !== void 0 ? { auth: options.auth } : {},
6648
6648
  ...options?.access !== void 0 ? { access: options.access } : {},
6649
6649
  ...options?.caller !== void 0 ? { caller: options.caller } : {},
6650
6650
  timeoutMs: options?.timeoutMs
@@ -6668,7 +6668,7 @@ function event$1(data) {
6668
6668
  }
6669
6669
  var StaticDirOutputSchema$1 = object({ staticDir: string$2() });
6670
6670
  var VersionOutputSchema$1 = object({ version: string$2() });
6671
- method(_void(), StaticDirOutputSchema$1), method(_void(), VersionOutputSchema$1);
6671
+ method(_void(), StaticDirOutputSchema$1, { auth: "admin" }), method(_void(), VersionOutputSchema$1, { auth: "admin" });
6672
6672
  var DeviceType = /* @__PURE__ */ function(DeviceType) {
6673
6673
  DeviceType["Camera"] = "camera";
6674
6674
  DeviceType["Hub"] = "hub";
@@ -6989,7 +6989,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
6989
6989
  }({});
6990
6990
  var StaticDirOutputSchema = object({ staticDir: string$2() });
6991
6991
  var VersionOutputSchema = object({ version: string$2() });
6992
- method(_void(), StaticDirOutputSchema), method(_void(), VersionOutputSchema);
6992
+ method(_void(), StaticDirOutputSchema, { auth: "admin" }), method(_void(), VersionOutputSchema, { auth: "admin" });
6993
6993
  /**
6994
6994
  * device-ops — device-scoped cap that unifies the per-IDevice operations
6995
6995
  * previously routed through the `.device-ops` Moleculer bridge service.
@@ -7615,24 +7615,6 @@ var RecordingRetentionSchema = object({
7615
7615
  maxSizeGb: number().min(0).optional()
7616
7616
  });
7617
7617
  /**
7618
- * Scrub-thumbnail fidelity preset — the single per-camera selector bundling the
7619
- * sprite tile RESOLUTION + JPEG QUALITY the recorder packs timeline-scrub
7620
- * previews at. Five graduated steps; absent on a config = `standard` (the
7621
- * shipped default, matching `sheet-geometry`/`sheet-composer`).
7622
- *
7623
- * Existing sheets are IMMUTABLE — a changed preset applies to NEW windows only.
7624
- * Each window's index sidecar carries its own tile dims, so a camera whose
7625
- * preset changed over time renders every historical window at the dims it was
7626
- * written with.
7627
- */
7628
- var ScrubThumbnailPresetSchema = _enum([
7629
- "minimal",
7630
- "low",
7631
- "standard",
7632
- "high",
7633
- "max"
7634
- ]);
7635
- /**
7636
7618
  * The full per-camera recording intent — the wire shape of a RecordingTarget.
7637
7619
  *
7638
7620
  * `bands` is the ONLY authored recording intent: what to record, when, and on
@@ -7640,7 +7622,11 @@ var ScrubThumbnailPresetSchema = _enum([
7640
7622
  * other field is a storage knob (profiles, segment length, retention, scrub).
7641
7623
  *
7642
7624
  * STRICT on purpose: the legacy authoring surface (`schedule`/`schedules`/
7643
- * `triggers`/`preBufferSec`/`postBufferSec`/`rules`) was retired 2026-07-30.
7625
+ * `triggers`/`preBufferSec`/`postBufferSec`/`rules`) was retired 2026-07-30,
7626
+ * and `scrubThumbnails` — a five-step fidelity knob for a sprite tier that was
7627
+ * deleted on 2026-07-24 and had ZERO consumers in the recorder — on 2026-08-25
7628
+ * (D62: a switch that writes a store nobody reads is worse than no switch).
7629
+ * Stored rows keep loading: the READ schema is `.strip()` (config-store.ts).
7644
7630
  * A stale caller must fail loudly — silently stripping its legacy intent would
7645
7631
  * persist a band-less config, i.e. silently stop recording the camera.
7646
7632
  */
@@ -7663,14 +7649,7 @@ var RecordingConfigSchema = object({
7663
7649
  * "off" is the absence of a covering band, never a band value.
7664
7650
  */
7665
7651
  bands: array(RecordingBandSchema).default([]),
7666
- retention: RecordingRetentionSchema.optional(),
7667
- /**
7668
- * Per-camera scrub-thumbnail fidelity preset (resolution + JPEG quality for
7669
- * timeline-scrub sprite previews). Absent = `standard`. Applies to NEW
7670
- * windows only — existing sheets are immutable, and each window's index
7671
- * carries its own tile dims so mixed-preset history renders correctly.
7672
- */
7673
- scrubThumbnails: ScrubThumbnailPresetSchema.optional()
7652
+ retention: RecordingRetentionSchema.optional()
7674
7653
  }).strict();
7675
7654
  /**
7676
7655
  * Entity-relocation job state (storage entity-routing spec, Phase 4).
@@ -7746,10 +7725,11 @@ var RelocateFootageInputSchema = object({
7746
7725
  * `RecordingConfig.enabled` or camera wrapper bindings. */
7747
7726
  var StorageMigrationLeaseInputSchema = object({ leaseId: string$2().min(1) });
7748
7727
  var StorageMigrationFootageMoveInputSchema = RelocateFootageInputSchema.extend({ leaseId: string$2().min(1) });
7749
- var StorageMigrationMediaMoveInputSchema = object({
7728
+ var RelocateMediaInputSchema = object({
7750
7729
  toLocationId: string$2(),
7751
7730
  throttleMbps: number().min(1).max(1e3).optional()
7752
- }).extend({ leaseId: string$2().min(1) });
7731
+ });
7732
+ var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string$2().min(1) });
7753
7733
  /** The independently selectable logical storage classes. `recordings`
7754
7734
  * encompasses the high and mid segment profiles; `recordingsLow` is low
7755
7735
  * segments; `eventMedia` is post-analysis blobs. */
@@ -8044,7 +8024,26 @@ var LabelDefinitionSchema = object({
8044
8024
  description: string$2().optional(),
8045
8025
  icon: string$2().optional()
8046
8026
  });
8047
- var ClassMapDefinitionSchema = object({
8027
+ /**
8028
+ * Wire schema for a per-model CATALOG classMap override
8029
+ * (`ModelCatalogEntry.classMap` / `ModelConvertMetadata.classMap`) —
8030
+ * restricted to {@link CLASS_MAP_MACRO_TARGETS}, the only macros the
8031
+ * detection pipeline executor actually routes.
8032
+ *
8033
+ * This is deliberately a DIFFERENT, narrower shape than the general-purpose
8034
+ * `ClassMapDefinition` interface above (e.g. `IDetectionAddon.getClassMap()`
8035
+ * and the audio `YAMNET_TO_MACRO` catalog both use macro targets outside this
8036
+ * enum) — the two used to share the name `ClassMapDefinition`/
8037
+ * `ClassMapDefinitionSchema`, which made the schema-type-twin guard
8038
+ * (`scripts/check-schema-type-twins.ts`) flag them as a duplicated shape. They
8039
+ * are not: it is two different concepts colliding on a name. Keep this type
8040
+ * under its own name rather than reusing `ClassMapDefinition` — reusing it
8041
+ * would either narrow every `ClassMapDefinition` consumer to the four
8042
+ * detection macros (breaking `YAMNET_TO_MACRO`) or drop the validation this
8043
+ * schema exists for (see the "rejects a classMap whose target is not a
8044
+ * detection macro" test in `model-catalog-schema.test.ts`).
8045
+ */
8046
+ var DetectionCatalogClassMapSchema = object({
8048
8047
  mapping: record(string$2(), _enum([
8049
8048
  "person",
8050
8049
  "vehicle",
@@ -8249,7 +8248,7 @@ var ModelCatalogEntrySchema = object({
8249
8248
  * applies (Frigate / COCO public catalog). Set on a custom model whose raw
8250
8249
  * labels already ARE the CamStack macros (Scrypted identity map).
8251
8250
  */
8252
- classMap: ClassMapDefinitionSchema.optional()
8251
+ classMap: DetectionCatalogClassMapSchema.optional()
8253
8252
  });
8254
8253
  var ConvertTargetSchema = discriminatedUnion("format", [object({
8255
8254
  format: literal("openvino"),
@@ -8279,7 +8278,7 @@ var ModelConvertMetadataSchema = object({
8279
8278
  "segmentation"
8280
8279
  ]),
8281
8280
  faceAlignment: boolean().optional(),
8282
- classMap: ClassMapDefinitionSchema.optional()
8281
+ classMap: DetectionCatalogClassMapSchema.optional()
8283
8282
  });
8284
8283
  var ConvertResultSchema = object({
8285
8284
  entry: ModelCatalogEntrySchema,
@@ -9142,7 +9141,7 @@ var AddonPageDeclarationSchema = object({
9142
9141
  /** Display label for a CUSTOM `section` id (ignored for well-known ids). */
9143
9142
  sectionLabel: string$2().optional()
9144
9143
  });
9145
- method(_void(), array(AddonPageDeclarationSchema).readonly());
9144
+ method(_void(), array(AddonPageDeclarationSchema).readonly(), { auth: "admin" });
9146
9145
  var AddonHttpRouteSchema = object({
9147
9146
  method: _enum([
9148
9147
  "GET",
@@ -9377,7 +9376,7 @@ var WidgetMetadataSchema = object({
9377
9376
  defaultColumns: number().int().min(1).max(12).default(6),
9378
9377
  defaultRows: number().int().min(1).max(12).default(1)
9379
9378
  });
9380
- method(_void(), array(WidgetMetadataSchema).readonly());
9379
+ method(_void(), array(WidgetMetadataSchema).readonly(), { auth: "admin" });
9381
9380
  /**
9382
9381
  * `addon-widgets` — system-scoped singleton aggregator cap. Public-facing
9383
9382
  * surface that admin-ui consumes through `useAddonWidgetsListWidgets()`.
@@ -11050,7 +11049,7 @@ var CustomModelDescriptorSchema = object({
11050
11049
  stepId: string$2(),
11051
11050
  entry: ModelCatalogEntrySchema
11052
11051
  });
11053
- method(_void(), array(CustomModelDescriptorSchema).readonly());
11052
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
11054
11053
  /**
11055
11054
  * Query filter for settings-store collections.
11056
11055
  */
@@ -11137,7 +11136,8 @@ method(object({
11137
11136
  }), _void(), { kind: "mutation" }), method(object({
11138
11137
  namespace: string$2().optional(),
11139
11138
  collection: string$2(),
11140
- filter: QueryFilterSchema.optional()
11139
+ filter: QueryFilterSchema.optional(),
11140
+ columns: array(string$2()).readonly().optional()
11141
11141
  }), array(SettingsRecordSchema).readonly()), method(object({
11142
11142
  namespace: string$2().optional(),
11143
11143
  collection: string$2(),
@@ -11200,46 +11200,87 @@ var EngineInfoSchema = object({
11200
11200
  kind: _enum(["relational", "vector"]),
11201
11201
  displayName: string$2()
11202
11202
  });
11203
- method(_void(), EngineInfoSchema), method(object({
11203
+ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
11204
11204
  namespace: string$2().optional(),
11205
11205
  collection: string$2(),
11206
11206
  key: string$2()
11207
- }), unknown()), method(object({
11207
+ }), unknown(), { auth: "admin" }), method(object({
11208
11208
  namespace: string$2().optional(),
11209
11209
  collection: string$2(),
11210
11210
  key: string$2(),
11211
11211
  value: unknown()
11212
- }), _void(), { kind: "mutation" }), method(object({
11212
+ }), _void(), {
11213
+ kind: "mutation",
11214
+ auth: "admin"
11215
+ }), method(object({
11213
11216
  namespace: string$2().optional(),
11214
11217
  collection: string$2(),
11215
- filter: QueryFilterSchema.optional()
11216
- }), array(SettingsRecordSchema).readonly()), method(object({
11218
+ filter: QueryFilterSchema.optional(),
11219
+ /**
11220
+ * SQL-level column projection — MUST mirror `settings-store.query`.
11221
+ *
11222
+ * ⚠ An earlier version of this comment blamed Zod stripping, and that
11223
+ * was wrong — corrected 2026-08-26 after the hop map
11224
+ * (`docs/design/2026-08-26-mappa-hop-argomenti.md`) traced the path.
11225
+ * There is **no Zod parse at all** between the door and the engine: the
11226
+ * dispatcher forwards the payload verbatim and UDS carries it whole. A
11227
+ * field declared here reaches `SqliteSettingsBackend` either way.
11228
+ *
11229
+ * What actually lost `columns` was the THIRD declaration of this shape:
11230
+ * `SettingsQueryInput` in `interfaces/storage.ts`, a hand-written TS
11231
+ * interface the engine destructures from. The field existed on both
11232
+ * schemas and the engine still never read it, because nothing checks a
11233
+ * registered provider against `InferProvider<cap>` —
11234
+ * `ProviderRegistration.provider` is typed `object`.
11235
+ *
11236
+ * It is declared here anyway, and must stay in step with
11237
+ * `settings-store.query`: a caller reading only the cap definitions has
11238
+ * to be able to see that this call carries a projection.
11239
+ * `data-door-schema-parity.spec.ts` keeps the two aligned.
11240
+ */
11241
+ columns: array(string$2()).readonly().optional()
11242
+ }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
11217
11243
  namespace: string$2().optional(),
11218
11244
  collection: string$2(),
11219
11245
  record: SettingsRecordSchema
11220
- }), _void(), { kind: "mutation" }), method(object({
11246
+ }), _void(), {
11247
+ kind: "mutation",
11248
+ auth: "admin"
11249
+ }), method(object({
11221
11250
  namespace: string$2().optional(),
11222
11251
  collection: string$2(),
11223
11252
  id: string$2(),
11224
11253
  data: record(string$2(), unknown())
11225
- }), _void(), { kind: "mutation" }), method(object({
11254
+ }), _void(), {
11255
+ kind: "mutation",
11256
+ auth: "admin"
11257
+ }), method(object({
11226
11258
  namespace: string$2().optional(),
11227
11259
  collection: string$2(),
11228
11260
  key: string$2()
11229
- }), _void(), { kind: "mutation" }), method(object({
11261
+ }), _void(), {
11262
+ kind: "mutation",
11263
+ auth: "admin"
11264
+ }), method(object({
11230
11265
  namespace: string$2().optional(),
11231
11266
  collection: string$2(),
11232
11267
  filter: MutationFilterSchema
11233
- }), object({ deleted: number().int() }), { kind: "mutation" }), method(object({
11268
+ }), object({ deleted: number().int() }), {
11269
+ kind: "mutation",
11270
+ auth: "admin"
11271
+ }), method(object({
11234
11272
  namespace: string$2().optional(),
11235
11273
  collection: string$2(),
11236
11274
  filter: MutationFilterSchema,
11237
11275
  data: record(string$2(), unknown())
11238
- }), object({ updated: number().int() }), { kind: "mutation" }), method(object({
11276
+ }), object({ updated: number().int() }), {
11277
+ kind: "mutation",
11278
+ auth: "admin"
11279
+ }), method(object({
11239
11280
  namespace: string$2().optional(),
11240
11281
  collection: string$2(),
11241
11282
  filter: QueryFilterSchema.optional()
11242
- }), number()), method(object({
11283
+ }), number(), { auth: "admin" }), method(object({
11243
11284
  namespace: string$2().optional(),
11244
11285
  collection: string$2(),
11245
11286
  field: string$2(),
@@ -11249,15 +11290,18 @@ method(_void(), EngineInfoSchema), method(object({
11249
11290
  }), array(object({
11250
11291
  bucket: number().int(),
11251
11292
  count: number().int()
11252
- })).readonly()), method(object({
11293
+ })).readonly(), { auth: "admin" }), method(object({
11253
11294
  namespace: string$2().optional(),
11254
11295
  collection: string$2()
11255
- }), boolean()), method(object({
11296
+ }), boolean(), { auth: "admin" }), method(object({
11256
11297
  namespace: string$2().optional(),
11257
11298
  collection: string$2(),
11258
11299
  columns: array(CollectionColumnSchema).readonly(),
11259
11300
  indexes: array(CollectionIndexSchema).readonly().optional()
11260
- }), _void(), { kind: "mutation" });
11301
+ }), _void(), {
11302
+ kind: "mutation",
11303
+ auth: "admin"
11304
+ });
11261
11305
  /**
11262
11306
  * shm ring usage stats for a `frameSink: 'shm'` decoder session —
11263
11307
  * exposed via `decoder.getShmStats` so downstream consumers can
@@ -12564,7 +12608,7 @@ method(object({
12564
12608
  crop: _instanceof(Uint8Array),
12565
12609
  width: number(),
12566
12610
  height: number()
12567
- }), EmbeddingResultSchema), method(object({ text: string$2() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
12611
+ }), EmbeddingResultSchema, { auth: "admin" }), method(object({ text: string$2() }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" });
12568
12612
  /**
12569
12613
  * filesystem-browse — per-node capability for browsing the node's local
12570
12614
  * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
@@ -12857,19 +12901,22 @@ method(LlmGenerateBaseInputSchema.extend({
12857
12901
  runtime: ManagedRuntimeConfigSchema,
12858
12902
  /** The managed profile's timeout, threaded by the hub provider. */
12859
12903
  timeoutMs: number().int().positive().optional()
12860
- }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
12904
+ }), LlmGenerateResultSchema, {
12905
+ kind: "mutation",
12906
+ auth: "admin"
12907
+ }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
12861
12908
  kind: "mutation",
12862
12909
  auth: "admin"
12863
12910
  }), method(object({}), _void(), {
12864
12911
  kind: "mutation",
12865
12912
  auth: "admin"
12866
- }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
12913
+ }), method(object({}), LlmRuntimeStatusSchema, { auth: "admin" }), method(object({ model: ManagedModelRefSchema }), _void(), {
12867
12914
  kind: "mutation",
12868
12915
  auth: "admin"
12869
12916
  }), method(object({ file: string$2() }), _void(), {
12870
12917
  kind: "mutation",
12871
12918
  auth: "admin"
12872
- }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
12919
+ }), method(object({}), array(LlmNodeModelSchema), { auth: "admin" }), method(object({}), LlmRuntimeDiskUsageSchema, { auth: "admin" });
12873
12920
  /**
12874
12921
  * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
12875
12922
  * methods concat-fan across providers; single-row methods route to ONE
@@ -16380,1748 +16427,1998 @@ var OauthIntegrationDescriptorSchema = object({
16380
16427
  */
16381
16428
  refreshTokenTtlSec: union([number().int().positive(), literal("never")]).optional()
16382
16429
  });
16383
- method(_void(), OauthIntegrationDescriptorSchema);
16430
+ method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
16384
16431
  /**
16385
- * pipeline-analytics device-scoped wrapper cap. Refines raw
16386
- * per-frame detections emitted by the pipeline runner into tracked
16387
- * objects, per-kind event collections (motion / object / audio), and
16388
- * persisted media. Owns the post-detection domain end-to-end:
16389
- *
16390
- * runner emits PipelineInferenceResult
16391
- * ↓ (event bus)
16392
- * pipeline-analytics subscriber
16393
- * ↓ SORT tracker + zone engine + state analyzer + event emitter
16394
- * → three DB collections (one per kind), one FS media tree, one
16395
- * unified event emitter (FrameTracked + TrackStarted/Ended +
16396
- * DetectionEvent on bus)
16397
- *
16398
- * Pure subscriber model. No `processFrame` cap method — the runner
16399
- * already publishes the raw frame on the bus. The cap surface is
16400
- * only QUERIES + per-device settings, bound on/off via
16401
- * `device-manager.setWrapperActive`. `defaultActive: true` because
16402
- * every camera with a detection pipeline wants its raw detections
16403
- * refined; operators opt out per-device via BindingsTab when needed.
16404
- *
16405
- * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
16406
- * (per-device surface) and `track-trail` caps — see P11 cleanup.
16432
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
16433
+ * within the frame, so the executor can re-cut a leaf child ROI at native
16434
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
16407
16435
  */
16408
- var TrackStateSchema = _enum([
16409
- "new",
16410
- "entered",
16411
- "left",
16412
- "moving",
16413
- "idle"
16414
- ]);
16415
- var EventKindSchema = _enum([
16416
- "motion",
16417
- "object",
16418
- "audio"
16419
- ]);
16436
+ var NativeCropRefSchema = object({
16437
+ /** Handle keying the retained native surface (node-pinned to its owner). */
16438
+ handle: FrameHandleSchema,
16439
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
16440
+ cropFrameSpace: object({
16441
+ x: number(),
16442
+ y: number(),
16443
+ w: number(),
16444
+ h: number()
16445
+ })
16446
+ });
16447
+ object({
16448
+ crop: object({
16449
+ left: number(),
16450
+ top: number(),
16451
+ width: number().positive(),
16452
+ height: number().positive()
16453
+ }).optional(),
16454
+ content: object({
16455
+ width: number().int().positive(),
16456
+ height: number().int().positive()
16457
+ }),
16458
+ fit: _enum(["stretch", "contain"]),
16459
+ format: _enum([
16460
+ "rgb",
16461
+ "gray",
16462
+ "jpeg"
16463
+ ])
16464
+ });
16420
16465
  /**
16421
- * Spatial filter for `listTracks` the rect + polygon variants of the shared
16422
- * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
16423
- * of the camera frame (top-left origin), matching the drawing-plane editor.
16466
+ * Process-local frame identity. It is serializable so it can ride an in-process
16467
+ * capability call, but `registryId` deliberately prevents resolution in any
16468
+ * other process or execution group.
16424
16469
  */
16425
- var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
16426
- /** Closed icon vocabulary so clients render a known glyph per kind. */
16427
- var EventKindIconSchema = _enum([
16428
- "motion",
16429
- "audio",
16430
- "person",
16431
- "vehicle",
16432
- "animal",
16433
- "door",
16434
- "pir",
16435
- "smoke",
16436
- "water",
16437
- "button",
16438
- "package",
16439
- "generic"
16470
+ var FrameRefSchema = object({
16471
+ registryId: string$2().min(1),
16472
+ id: string$2().min(1),
16473
+ width: number().int().positive(),
16474
+ height: number().int().positive(),
16475
+ format: _enum(["rgb", "gray"]),
16476
+ timestamp: number(),
16477
+ capturedAt: number().optional()
16478
+ });
16479
+ var ModelFormatSchema$1 = _enum([
16480
+ "onnx",
16481
+ "coreml",
16482
+ "openvino",
16483
+ "tflite",
16484
+ "pt",
16485
+ "gguf"
16440
16486
  ]);
16441
- var EventKindCategorySchema = _enum([
16442
- "motion",
16443
- "audio",
16444
- "detection",
16445
- "sensor",
16446
- "control",
16447
- "custom",
16448
- "package"
16487
+ var PipelineSlotSchema = _enum([
16488
+ "detector",
16489
+ "cropper",
16490
+ "classifier",
16491
+ "refiner",
16492
+ "audio-classifier"
16449
16493
  ]);
16450
- /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
16451
- var EventKindLevelSchema = _enum(["macro", "sub"]);
16452
- var EventKindDescriptorSchema = object({
16453
- /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
16454
- kind: string$2(),
16455
- /** i18n key resolved on the UI side; `label` is the English fallback. */
16456
- labelKey: string$2(),
16457
- /** English fallback label (kept for clients that don't translate). */
16458
- label: string$2(),
16459
- /** Hex color for timeline/legend rendering. */
16460
- color: string$2(),
16461
- /** Dictionary id → lucide component on the UI side. */
16462
- iconId: string$2(),
16463
- /** Legacy closed-vocab glyph — fallback for `iconId`. */
16464
- icon: EventKindIconSchema,
16465
- category: EventKindCategorySchema,
16466
- /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
16467
- parentKind: string$2().nullable(),
16468
- /** Derived from `parentKind`, explicit for the client tree. */
16469
- level: EventKindLevelSchema,
16470
- /** Which cap + device contributes this kind. For built-ins the camera
16471
- * itself; for sensor kinds the LINKED source device. */
16472
- source: object({
16473
- capName: string$2(),
16474
- deviceId: number()
16475
- })
16494
+ var PipelineEngineChoiceSchema = object({
16495
+ runtime: _enum(["node", "python"]),
16496
+ backend: string$2(),
16497
+ format: ModelFormatSchema$1,
16498
+ device: string$2().optional()
16476
16499
  });
16477
- /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
16478
- var EventKindsForDeviceSchema = object({
16479
- deviceId: number(),
16480
- kinds: array(EventKindDescriptorSchema).readonly()
16500
+ var AvailableEngineSchema = object({
16501
+ engine: PipelineEngineChoiceSchema,
16502
+ devices: array(object({
16503
+ id: string$2(),
16504
+ label: string$2(),
16505
+ description: string$2().optional()
16506
+ })).readonly(),
16507
+ defaultDevice: string$2()
16481
16508
  });
16482
- var SensorEventSchema = object({
16509
+ var PipelineDefaultStepSchema = lazy(() => object({
16510
+ addonId: string$2(),
16511
+ addonName: string$2(),
16512
+ slot: PipelineSlotSchema,
16513
+ inputClasses: array(string$2()).readonly(),
16514
+ outputClasses: array(string$2()).readonly(),
16515
+ enabled: boolean(),
16516
+ modelId: string$2(),
16517
+ children: array(PipelineDefaultStepSchema).readonly(),
16518
+ group: string$2().optional(),
16519
+ settings: record(string$2(), unknown()).optional()
16520
+ }));
16521
+ var PipelineTemplateStepSchema = lazy(() => object({
16522
+ addonId: string$2(),
16523
+ enabled: boolean(),
16524
+ modelId: string$2(),
16525
+ children: array(PipelineTemplateStepSchema).readonly(),
16526
+ settings: record(string$2(), unknown()).optional()
16527
+ }));
16528
+ var PipelineTemplateSchema$1 = object({
16483
16529
  id: string$2(),
16484
- /** The CAMERA the event is attributed to (a sensor linked to N cameras
16485
- * yields N rows, one per camera). */
16486
- deviceId: number(),
16487
- /** The linked sensor device whose state changed. */
16488
- sourceDeviceId: number(),
16489
- /** Event kind id — matches an `EventKindDescriptor.kind`. */
16490
- kind: string$2(),
16491
- /** Snapshot of the sensor cap's runtime-state slice at the change. */
16492
- value: record(string$2(), unknown()).nullable(),
16493
- timestamp: number()
16494
- });
16495
- var TrackPositionSchema = object({
16496
- x: number(),
16497
- y: number(),
16498
- timestamp: number(),
16499
- bbox: BoundingBoxSchema
16530
+ name: string$2(),
16531
+ createdAt: string$2(),
16532
+ updatedAt: string$2(),
16533
+ engine: PipelineEngineChoiceSchema,
16534
+ steps: array(PipelineTemplateStepSchema).readonly()
16500
16535
  });
16501
- var TrackSnapshotSchema = object({
16502
- timestamp: number(),
16503
- position: TrackPositionSchema,
16504
- /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
16505
- mediaKey: string$2()
16536
+ var PipelineModelOptionSchema = object({
16537
+ id: string$2(),
16538
+ name: string$2(),
16539
+ formats: record(string$2(), object({
16540
+ downloaded: boolean(),
16541
+ sizeMB: number()
16542
+ })),
16543
+ group: ModelVariantGroupSchema.optional(),
16544
+ legacy: boolean().optional(),
16545
+ provider: ModelProviderIdSchema.optional()
16506
16546
  });
16507
- /**
16508
- * Normalized 0..1 trajectory envelope (min/max over every position bbox,
16509
- * divided by the track's detection-frame dims), computed at persist time.
16510
- * Absent when the frame dims were unknown when the track was persisted
16511
- * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
16512
- */
16513
- var TrackEnvelopeSchema = object({
16514
- minX: number(),
16515
- minY: number(),
16516
- maxX: number(),
16517
- maxY: number()
16547
+ var ConfigFieldBridge = custom();
16548
+ var PipelineAddonSchemaSchema = object({
16549
+ id: string$2(),
16550
+ name: string$2(),
16551
+ slot: PipelineSlotSchema,
16552
+ inputClasses: array(string$2()).readonly(),
16553
+ outputClasses: array(string$2()).readonly(),
16554
+ childSlots: array(PipelineSlotSchema).readonly(),
16555
+ models: array(PipelineModelOptionSchema).readonly(),
16556
+ defaultModelId: string$2(),
16557
+ defaultModelIdByFormat: record(string$2(), string$2()).optional(),
16558
+ enabledByDefault: boolean().optional(),
16559
+ backfillIntoExistingOverrides: boolean().optional(),
16560
+ defaultConfidence: number(),
16561
+ group: string$2().optional(),
16562
+ configSchema: array(ConfigFieldBridge).readonly().optional()
16518
16563
  });
16519
- /**
16520
- * Row projection for track list queries. `full` (default) returns the
16521
- * complete Track including the frame-rate `positions[]` history and the
16522
- * `snapshots[]` references — megabytes across a page of tracks. `slim`
16523
- * keeps every scalar the list surfaces actually render (ids, class(es),
16524
- * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
16525
- * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
16526
- * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
16527
- * `getTrack`. Mirrors the event-store `projection` convention
16528
- * (`getObjectEvents` et al.).
16529
- */
16530
- var TrackProjectionSchema = _enum(["full", "slim"]);
16531
- /**
16532
- * One audio-classification label heard on the track's camera while the
16533
- * track was alive, aggregated per label. An "episode" is one persisted
16534
- * audio event (the confident-classification path: score ≥ the device's
16535
- * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
16536
- * one 32 ms inference chunk, so counts stay human-scaled.
16537
- */
16538
- var TrackAudioLabelSchema = object({
16564
+ var PipelineSlotSchemaSchema = object({
16565
+ id: PipelineSlotSchema,
16539
16566
  label: string$2(),
16540
- /** Highest classification score observed across the label's episodes. */
16541
- peakScore: number(),
16542
- /** Number of coalesced audio-event episodes carrying this label. */
16543
- count: number(),
16544
- firstAt: number(),
16545
- lastAt: number()
16567
+ priority: number(),
16568
+ parentSlot: PipelineSlotSchema.nullable(),
16569
+ addons: array(PipelineAddonSchemaSchema).readonly()
16546
16570
  });
16547
- /**
16548
- * How a track was produced. `pipeline` (default / absent) = the spatial
16549
- * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
16550
- * no positions, a single snapshot, and no bbox trajectory at all:
16551
- *
16552
- * - `sensor` — a linked sensor/control device state change.
16553
- * - `audio` — an audio event on the camera itself that was anomalous for
16554
- * THAT camera, loud, and heard while nothing visual was happening (D62).
16555
- *
16556
- * The spatial subsystems (tracker association, occupancy count, re-id /
16557
- * embedding, resurrection) MUST skip every synthetic source. Test for that
16558
- * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
16559
- * check silently readmits every source added after it was written.
16560
- */
16561
- var TrackSourceSchema = _enum([
16562
- "pipeline",
16563
- "sensor",
16564
- "audio"
16565
- ]);
16566
- /**
16567
- * Where a track sits in the RETRAIN lifecycle (D81).
16568
- *
16569
- * - `none` — never marked, or un-marked. Evictable.
16570
- * - `staging` — the operator wants this track as training material and has not
16571
- * finished with it. **This is the only state retention holds**: the track and
16572
- * everything it owns (object events, crops, keyframes, CLIP vector) survive
16573
- * the device's age window.
16574
- * - `trained` — the retrain page has taken what it needed. The frames it chose
16575
- * were COPIED into the retrain dataset at selection time, so the dataset no
16576
- * longer depends on the track's media and the track becomes EVICTABLE again.
16577
- * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
16578
- * a deliberate action of the retrain page, not a side effect of a checkbox.
16579
- *
16580
- * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
16581
- * the store's filter language has only positive equality and `whereIn` — no
16582
- * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
16583
- * would make the entire pre-column history immortal in one deploy.
16584
- */
16585
- var RetrainStatusSchema = _enum([
16586
- "none",
16587
- "staging",
16588
- "trained"
16589
- ]);
16590
- /**
16591
- * Per-track OPERATOR flags — set by hand from the admin UI or the viewer, never
16592
- * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
16593
- * so the two surfaces cannot drift.
16594
- *
16595
- * **Absent ≠ false.** A track that has never been touched omits the field; an
16596
- * explicitly un-flagged track carries `false`. Legacy rows written before the
16597
- * columns existed read as absent, and a consumer that needs a boolean should say
16598
- * `flag === true`, not `flag !== false`.
16599
- *
16600
- * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
16601
- * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
16602
- * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
16603
- * `trained` track reports `false` while refusing both writes. The boolean is
16604
- * kept because three surfaces drive a toggle off it; anything that needs to tell
16605
- * "never marked" from "already trained" must read `retrainStatus`.
16606
- *
16607
- * `debug` does NOT pin; it is attention, not durability.
16608
- *
16609
- * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
16610
- * A favourited track is skipped by retention the same way `staging` is, but
16611
- * it does not enter `none|staging|trained` and has no staging budget.
16612
- */
16613
- var TrackFlagFields = {
16614
- /** Operator marked this track as training material — i.e. `retrainStatus` is
16615
- * `'staging'`. */
16616
- markForTrain: boolean().optional(),
16617
- /** Operator marked this track for diagnostic attention. */
16618
- debug: boolean().optional(),
16619
- /** Operator favourited this track. Pins it against pruning. */
16620
- favourited: boolean().optional()
16621
- };
16622
- /**
16623
- * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
16624
- * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
16625
- * write patch, and the status is not something the toggle sets — it is what the
16626
- * toggle's boolean is derived from. Absent on an in-RAM track never touched;
16627
- * always present on a persisted row (the column default materialises `'none'`).
16628
- */
16629
- var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
16630
- /**
16631
- * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
16632
- * one flag can never clear the other — the toggles are independent and are
16633
- * driven from three surfaces that do not know about each other.
16634
- */
16635
- var TrackFlagsPatchSchema = object(TrackFlagFields);
16636
- /**
16637
- * The resolved flag state after a write. Both fields are REQUIRED here (absent
16638
- * collapses to `false`) so a caller can drive a toggle's checked state off the
16639
- * mutation result without a re-fetch.
16640
- */
16641
- var TrackFlagsSchema = object({
16642
- trackId: string$2(),
16643
- markForTrain: boolean(),
16644
- debug: boolean(),
16645
- favourited: boolean(),
16646
- /** The lifecycle state the boolean was derived from. Required here (unlike on
16647
- * a track row) because this shape is only ever produced by the write body,
16648
- * which always knows it — and a surface that has just written needs to render
16649
- * `trained` without a re-fetch. */
16650
- retrainStatus: RetrainStatusSchema
16571
+ var PipelineSchemaSchema = object({
16572
+ availableEngines: array(AvailableEngineSchema).readonly(),
16573
+ selectedEngine: PipelineEngineChoiceSchema,
16574
+ slots: array(PipelineSlotSchemaSchema).readonly()
16651
16575
  });
16652
- union([literal(1), literal(2)]);
16653
- /**
16654
- * WHO decided a label, and when. Carried per tier so a value can be traced to
16655
- * the step and model that produced it — which is what makes the write rule
16656
- * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
16657
- * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
16658
- *
16659
- * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
16660
- * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
16661
- * `migration:4g` for a value the 4g migration moved from the single-slot era —
16662
- * that value has no provenance, and the write rule lets ANY properly-attributed
16663
- * write of the same tier replace it regardless of score.
16664
- */
16665
- var LabelAttributionSchema = object({
16666
- stepId: string$2(),
16667
- modelId: string$2().optional(),
16668
- decidedAt: number(),
16576
+ var EngineProvisioningSchema = object({
16577
+ runtimeId: _enum([
16578
+ "onnx",
16579
+ "openvino",
16580
+ "coreml",
16581
+ "edgetpu"
16582
+ ]).nullable(),
16583
+ device: string$2().nullable(),
16584
+ state: _enum([
16585
+ "idle",
16586
+ "installing",
16587
+ "verifying",
16588
+ "ready",
16589
+ "failed"
16590
+ ]),
16591
+ progress: number().optional(),
16592
+ error: string$2().optional(),
16593
+ nextRetryAt: number().optional(),
16669
16594
  /**
16670
- * The GALLERY id behind a recognised tier-2 label — a face-gallery
16671
- * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
16672
- *
16673
- * The text alone is a DISPLAY NAME, and a display name is renameable: a
16674
- * notification rule authored on "Gianluca" stopped matching the moment the
16675
- * operator fixed the spelling in the gallery, and nothing said so. The id is
16676
- * the thing that does not move, so it is what a rule matches on
16677
- * (`NcConditions.identities`) and the text is what a human is shown.
16678
- *
16679
- * Absent when the label names no gallery row — a plate the OCR read but no
16680
- * vehicle claims, a sub-class, a species, any tier-1 value.
16595
+ * Gate A (config-correctness gate at engine change): human-readable
16596
+ * config issues surfaced EAGERLY when the node's engine changes — model
16597
+ * substitutions ("chose X, running Y") and zero-build steps ("no model
16598
+ * has a <format> build"). Additive/optional: informational only, never
16599
+ * enforced here `assertEngineReady` (readiness) still gates inference.
16600
+ * Absent/empty when the node-default tree resolves cleanly.
16681
16601
  */
16682
- identityId: string$2().optional()
16602
+ configIssues: array(string$2()).optional()
16683
16603
  });
16684
- /**
16685
- * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
16686
- * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
16687
- * track and its events always answer the same question the same way.
16688
- *
16689
- * Two scalar columns, not an array: every consumer wants "the coarse one" or
16690
- * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
16691
- * is tier 2, and each carries its own score + attribution.
16692
- *
16693
- * **Reading it.** What a human should be shown is `subLabel ?? label` — the
16694
- * finest thing known. Before 4g the single `label` column held the finest
16695
- * value, so a consumer that has not been updated reads the tier-1 slot and
16696
- * shows nothing on a species-only row; that is why the migration puts every
16697
- * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
16698
- * and why the read surfaces were changed in the same train.
16699
- *
16700
- * **Writing it.** The slots are independent, which is the whole point: a
16701
- * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
16702
- * migratorius`), so fineness cannot regress by construction. Within a tier the
16703
- * higher score wins. One rule, one implementation — see
16704
- * `pipeline/label-tier.ts` in addon-post-analysis.
16705
- */
16706
- var TieredLabelFields = {
16707
- /** Tier 1 the sub-class. See {@link LabelTierSchema}. */
16708
- label: string$2().optional(),
16709
- /** Confidence of the tier-1 value, as reported by the deciding step. */
16710
- labelScore: number().optional(),
16711
- /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
16712
- labelMeta: LabelAttributionSchema.optional(),
16713
- /** Tier 2 — the instance. See {@link LabelTierSchema}. */
16714
- subLabel: string$2().optional(),
16715
- /** Confidence of the tier-2 value, as reported by the deciding step. */
16716
- subLabelScore: number().optional(),
16717
- /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
16718
- subLabelMeta: LabelAttributionSchema.optional()
16719
- };
16720
- /** Per-camera slice of a training-export estimate. */
16721
- var TrainingExportDeviceTotalsSchema = object({
16722
- deviceId: number(),
16723
- tracks: number().int(),
16724
- files: number().int(),
16725
- bytes: number().int()
16604
+ var PipelineStepInputSchema = lazy(() => object({
16605
+ addonId: string$2(),
16606
+ modelId: string$2().optional(),
16607
+ enabled: boolean().default(true),
16608
+ children: array(PipelineStepInputSchema).optional(),
16609
+ settings: record(string$2(), unknown()).optional(),
16610
+ jumpDeviceKey: string$2().optional()
16611
+ }));
16612
+ var ModelSubstitutionSchema = object({
16613
+ addonId: string$2(),
16614
+ chosen: string$2(),
16615
+ running: string$2(),
16616
+ format: string$2()
16617
+ });
16618
+ var PipelineValidationIssueSchema = object({
16619
+ addonId: string$2(),
16620
+ kind: _enum(["unknown-addon", "no-format-build"]),
16621
+ detail: string$2()
16622
+ });
16623
+ var PipelineValidationResultSchema = object({
16624
+ ok: boolean(),
16625
+ issues: array(PipelineValidationIssueSchema).readonly(),
16626
+ substitutions: array(ModelSubstitutionSchema).readonly(),
16627
+ /** The node's `currentEngine.format` this validation ran against. */
16628
+ format: string$2()
16629
+ });
16630
+ var ReferenceImageEntrySchema = object({
16631
+ filename: string$2(),
16632
+ stepIds: array(string$2()).readonly().optional()
16633
+ });
16634
+ var ReferenceImageBodySchema = object({
16635
+ base64: string$2(),
16636
+ filename: string$2()
16637
+ });
16638
+ var ReferenceAudioEntrySchema = object({
16639
+ filename: string$2(),
16640
+ sizeKb: number()
16641
+ });
16642
+ var ReferenceAudioBodySchema = object({ base64: string$2() });
16643
+ var AudioBackendSchema = object({
16644
+ id: string$2(),
16645
+ name: string$2(),
16646
+ description: string$2(),
16647
+ available: boolean(),
16648
+ /**
16649
+ * Raw classifier labels this backend can emit (e.g. YAMNet's
16650
+ * 521-class set or Apple SoundAnalysis's 303-class set). Used by
16651
+ * the benchmark UI to populate the `enabledMicroClasses` filter
16652
+ * specific to the selected backend without a separate fetch.
16653
+ */
16654
+ rawLabels: array(string$2()).readonly().optional()
16655
+ });
16656
+ var AudioCapabilitiesSchema = object({
16657
+ activeBackend: string$2(),
16658
+ availableBackends: array(AudioBackendSchema).readonly(),
16659
+ sampleRate: number(),
16660
+ chunkDurationMs: number()
16661
+ });
16662
+ var DownloadModelResultSchema = object({
16663
+ filePath: string$2(),
16664
+ sizeMB: number(),
16665
+ durationMs: number()
16726
16666
  });
16727
16667
  /**
16728
- * What a training export WOULD contain. Computed from media index rows only —
16729
- * no blob is read to produce this.
16668
+ * Wrapper carrying a single test run's result. Replaces the legacy
16669
+ * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
16670
+ * canonical `AudioResult` from the Phase 6 output rework: one
16671
+ * `AudioDetection` per class above `minScore`, top-N candidates in
16672
+ * `debug.alternateLabels['audio-classifier']`, per-source timings in
16673
+ * `debug.stepTimings`. The outer `success`/`error` fields stay so the
16674
+ * benchmark UI can still report a clean failure when the classifier
16675
+ * cap isn't available.
16730
16676
  */
16731
- var TrainingExportSummarySchema = object({
16732
- generatedAt: number(),
16733
- trackCount: number().int(),
16734
- fileCount: number().int(),
16735
- byteCount: number().int(),
16736
- /** More marked tracks exist than a single pass carries. */
16737
- truncated: boolean(),
16738
- devices: array(TrainingExportDeviceTotalsSchema).readonly()
16677
+ var AudioTestResultSchema = object({
16678
+ success: boolean(),
16679
+ error: string$2().optional(),
16680
+ frame: custom().optional()
16739
16681
  });
16740
- var TrackSchema = object({
16741
- trackId: string$2(),
16742
- deviceId: number(),
16743
- className: string$2(),
16744
- ...TieredLabelFields,
16745
- producingDeviceName: string$2().optional(),
16746
- /** Track provenance. Absent `pipeline` (legacy rows). */
16747
- source: TrackSourceSchema.optional(),
16748
- firstSeen: number(),
16749
- lastSeen: number(),
16750
- /** Frame-rate position history (subject to maxPositionHistory cap). */
16751
- positions: array(TrackPositionSchema).readonly(),
16752
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
16753
- * saveThumbnails policy). */
16754
- snapshots: array(TrackSnapshotSchema).readonly(),
16755
- /** Deduplicated zones the track has entered at least once. Zone IDS. */
16756
- zonesVisited: array(string$2()).readonly(),
16682
+ var PipelineConfigBridge = custom();
16683
+ var ConfigUISchemaBridge = custom();
16684
+ var ConfigUISchemaNullableBridge = custom();
16685
+ var InferenceCapabilitiesBridge = custom();
16686
+ var ModelAvailabilityListBridge = custom();
16687
+ var PipelineRunResultBridge = custom();
16688
+ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string$2() }), EngineProvisioningSchema), method(_void(), record(string$2(), object({
16689
+ modelId: string$2(),
16690
+ settings: record(string$2(), unknown()).readonly()
16691
+ }))), method(object({ steps: record(string$2(), object({
16692
+ modelId: string$2(),
16693
+ settings: record(string$2(), unknown()).readonly()
16694
+ })) }), object({ success: literal(true) }), {
16695
+ kind: "mutation",
16696
+ auth: "admin"
16697
+ }), method(object({ nodeId: string$2() }), object({
16698
+ success: literal(true),
16699
+ clearedDevices: number()
16700
+ }), {
16701
+ kind: "mutation",
16702
+ auth: "admin"
16703
+ }), method(object({ nodeId: string$2() }), object({ unhealthy: array(object({
16704
+ /** `<backend>:<device>`, e.g. `openvino:gpu`. */
16705
+ deviceKey: string$2(),
16757
16706
  /**
16758
- * Human NAMES for {@link zonesVisited}, resolved at READ time against the
16759
- * `zones` capability.
16760
- *
16761
- * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
16762
- * and no card can render — so every free-text search surface was structurally
16763
- * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
16764
- * just returned nothing. Resolving here rather than in each client keeps ONE
16765
- * derivation and costs the clients no extra call (the `zones` cap is
16766
- * per-device, so a client-side resolve would be a per-camera fan-out on a
16767
- * surface built to avoid exactly that).
16768
- *
16769
- * Resolved, never invented: a zone deleted since the track was written has no
16770
- * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
16771
- * two are not positionally aligned. Absent when the track visited no zone, or
16772
- * when the zone catalogue could not be read.
16707
+ * `failed` the per-device restart budget is exhausted; no pool
16708
+ * will be spawned until an operator re-arms it or the runner
16709
+ * respawns. `backoff` — under budget, waiting out the backoff (or
16710
+ * a cached pool observed dead and not yet condemned).
16773
16711
  */
16774
- zoneNames: array(string$2()).readonly().optional(),
16775
- /** Deduplicated set of detector classes observed for this track over its
16776
- * life (a track may be reclassified, e.g. person→vehicle). Absent on
16777
- * legacy rows written before class accumulation shipped. */
16778
- classes: array(string$2()).readonly().optional(),
16779
- /** Cumulative normalized distance travelled (0..1 units = full frame width). */
16780
- totalDistance: number(),
16781
- state: TrackStateSchema,
16782
- active: boolean(),
16783
- /** Deterministic key-event importance score in [0,1] (server-computed at
16784
- * track expiry, recomputed on late label). Absent on legacy rows written
16785
- * before scoring shipped — consumers degrade to absence / compute-on-read. */
16786
- importance: number().optional(),
16787
- /** Id of the track's highest-confidence ObjectEvent (its representative
16788
- * "best" frame). Absent when the track produced no object events. */
16789
- bestEventId: string$2().optional(),
16790
- /** Tag of the importance sub-signal that dominated the score
16791
- * (identity|dwell|proximity|class|confidence|travel|zone). */
16792
- importanceReason: string$2().optional(),
16793
- /** Audio-classification labels heard on the camera during the track's
16794
- * life (score ≥ device `classificationMinScore`), aggregated per label.
16795
- * Absent on legacy rows / tracks with no confident audio. */
16796
- audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
16797
- /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
16798
- * Populated from the persisted envelope columns on historical reads;
16799
- * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
16800
- envelope: TrackEnvelopeSchema.optional(),
16712
+ state: _enum(["failed", "backoff"]),
16713
+ /** Epoch ms of the death that produced this state. */
16714
+ since: number(),
16715
+ /** Pool deaths inside the current window. */
16716
+ deaths: number(),
16717
+ /** The last death's message. */
16718
+ lastError: string$2()
16719
+ })).readonly() })), method(object({
16720
+ nodeId: string$2(),
16721
+ deviceKey: string$2()
16722
+ }), object({ rearmed: boolean() }), {
16723
+ kind: "mutation",
16724
+ auth: "admin"
16725
+ }), 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({
16726
+ name: string$2(),
16727
+ steps: array(PipelineTemplateStepSchema).readonly(),
16728
+ engine: PipelineEngineChoiceSchema
16729
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
16730
+ id: string$2(),
16731
+ name: string$2().optional(),
16732
+ steps: array(PipelineTemplateStepSchema).readonly().optional()
16733
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string$2() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string$2() }), ModelAvailabilityListBridge), method(object({
16734
+ addonId: string$2(),
16735
+ modelId: string$2(),
16736
+ format: ModelFormatSchema$1
16737
+ }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
16738
+ addonId: string$2(),
16739
+ modelId: string$2(),
16740
+ format: ModelFormatSchema$1
16741
+ }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
16742
+ engine: PipelineEngineChoiceSchema.optional(),
16743
+ steps: array(PipelineStepInputSchema).min(1),
16744
+ frame: FrameInputSchema.optional(),
16801
16745
  /**
16802
- * A face DETECTOR found a face on this track — nothing more. It says the
16803
- * detail plane produced a `face` detail; it does NOT say the face was
16804
- * embedded, matched, above `minFacePx`, or that the recognizer was even
16805
- * enabled. Set once and never cleared.
16806
- *
16807
- * **This exists so "face present but not recognised" is expressible.** A
16808
- * recognised identity lands in `subLabel` (attributed to the face chain via
16809
- * `subLabelMeta.stepId`), so before this field a track with an unmatched face
16810
- * and a track with no face at all were byte-identical on the wire and no
16811
- * surface could tell them apart. The read is `hasFace === true && subLabel
16812
- * === undefined`.
16813
- *
16814
- * **Absent ≠ false.** Every row written before the column existed omits it,
16815
- * and so does every server that predates the field — a consumer must test
16816
- * `=== true` and render nothing otherwise, never infer "no face".
16746
+ * Process-local lazy frame. Valid only when caller and provider resolve
16747
+ * in the same execution-group process; split/cross-node callers use
16748
+ * `frame`/`image` inline compatibility instead.
16817
16749
  */
16818
- hasFace: boolean().optional(),
16750
+ frameRef: FrameRefSchema.optional(),
16819
16751
  /**
16820
- * This track has a face row IN THE GALLERY: a crop **and** an embedding a
16821
- * face an operator could ASSIGN to an identity.
16822
- *
16823
- * The STRICT twin of {@link hasFace}, and the pair only earns its keep
16824
- * because the two disagree. `hasFace` is stamped at the TOP of the face
16825
- * branch, before every gate, and means no more than "a face detector produced
16826
- * a face detail". This one is stamped at the single moment the gallery row
16827
- * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
16828
- * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
16829
- * candidate gate, the imageless-track drop (no crop was ever captured) and
16830
- * the crop-store drop. Everything between the detector and that insert can
16831
- * legitimately refuse the face, so a flag written any earlier promises the
16832
- * operator something to assign and delivers nothing.
16833
- *
16834
- * **Independent of recognition.** A face collected but never auto-matched is
16835
- * still assignable — it is in fact the face an operator most wants to reach —
16836
- * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
16837
- * `subLabel`; this says only that the raw material exists.
16838
- *
16839
- * **Set once, never cleared.** A track that produced a gallery row produced
16840
- * one; deleting the row later is the gallery's business, not this flag's.
16841
- *
16842
- * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
16843
- * before the column omits it, and so does every server that predates the
16844
- * field. A consumer must test `=== true` and render nothing otherwise —
16845
- * never infer "no assignable face".
16752
+ * CB5 shm passthrough a `FrameHandle` naming the same ring slot
16753
+ * the decoded pixels live in. One more member of the one-of
16754
+ * frame/frameHandle/image/imageBase64/referenceImage group.
16846
16755
  */
16847
- hasEmbeddedFace: boolean().optional(),
16756
+ frameHandle: FrameHandleSchema.optional(),
16757
+ imageBase64: string$2().optional(),
16848
16758
  /**
16849
- * This subject CONTAINS a folded rider a person the rider-pairing step
16850
- * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
16851
- * so the passage is tracked once and as a VEHICLE.
16852
- *
16853
- * It exists because the fold's record was dishonest. D34 and the code both
16854
- * said "the person is not lost — it is reported so both entities stay on the
16855
- * record"; in fact the pair went into a per-processor RAM field behind an
16856
- * accessor nobody called, and every durable surface said `vehicle`, full
16857
- * stop. This is the composition note that makes the row true.
16858
- *
16859
- * A COMPOSITION, never a class and never a label. "This vehicle contains a
16860
- * person" is not an answer to "what is this" — both label tiers would refuse
16861
- * a macro token anyway (D89), and correctly. Nothing here changes what the
16862
- * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
16863
- * and a `person` rule still does not fire for someone cycling past.
16864
- *
16865
- * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
16866
- * the column, and every hub that predates the field, omits it. Test
16867
- * `=== true` and render nothing otherwise — never infer "no rider".
16759
+ * Binary JPEG bytespreferred over `imageBase64` on internal
16760
+ * hops (hub forked worker via Moleculer MsgPack) because it
16761
+ * skips the 33% base64 overhead + the per-call base64 decode on
16762
+ * the detection-pipeline worker. Callers can pass either; exactly
16763
+ * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
16868
16764
  */
16869
- hasRider: boolean().optional(),
16870
- ...TrackFlagFields,
16871
- ...TrackRetrainFields
16872
- });
16873
- var BaseEventFields = {
16874
- id: string$2(),
16875
- deviceId: number(),
16876
- timestamp: number()
16877
- };
16878
- var MotionEventSchema = object({
16879
- ...BaseEventFields,
16880
- kind: literal("motion"),
16881
- regionCount: number(),
16882
- /** Heavy JSON array omitted in slim projection. */
16883
- regions: array(object({
16884
- bbox: BoundingBoxSchema,
16885
- pixelCount: number(),
16886
- intensity: number()
16887
- })).readonly().optional(),
16888
- /** Omitted in slim projection. */
16889
- frameWidth: number().optional(),
16890
- /** Omitted in slim projection. */
16891
- frameHeight: number().optional(),
16892
- /** Populated by B5 (recording playback URL for this event). */
16893
- mediaUrl: string$2().optional()
16894
- });
16765
+ image: _instanceof(Uint8Array).optional(),
16766
+ referenceImage: string$2().optional(),
16767
+ deviceId: number().optional(),
16768
+ sessionId: string$2().optional(),
16769
+ /**
16770
+ * Execution plane. 'full' (default) runs the whole tree — benchmark,
16771
+ * reference-image, and detail-subtree calls. 'frame' is the live
16772
+ * per-frame dispatch: ONLY root-plane steps run; crop children
16773
+ * (inputClasses ≠ null) are skipped and served per-track via
16774
+ * pipelineRunner.runDetailSubtree (two-plane design).
16775
+ */
16776
+ plane: _enum(["full", "frame"]).optional(),
16777
+ /**
16778
+ * Inference-device selector (Phase 2 multi-device). Format
16779
+ * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
16780
+ * Omitted ⇒ the runner's default device (current single-engine
16781
+ * behaviour). Selects WHICH device pool of the node runs the call.
16782
+ */
16783
+ deviceKey: string$2().optional(),
16784
+ /**
16785
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
16786
+ * when the parent crop was resolved from the frame's retained NATIVE
16787
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
16788
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
16789
+ * resolution from that surface — the SAME quality path faces already
16790
+ * had — instead of the downscaled parent tile. `handle` keys the native
16791
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
16792
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
16793
+ * the executor's crop-normalized child ROI back into frame-normalized
16794
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
16795
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
16796
+ * (today's behaviour on the fallback path).
16797
+ */
16798
+ nativeCropRef: NativeCropRefSchema.optional()
16799
+ }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
16800
+ engine: PipelineEngineChoiceSchema.optional(),
16801
+ steps: array(PipelineStepInputSchema).min(1),
16802
+ frames: array(FrameInputSchema).min(1).max(255),
16803
+ deviceId: number().optional(),
16804
+ sessionId: string$2().optional(),
16805
+ /**
16806
+ * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
16807
+ * the batch to the Python pool's bench preprocess cache
16808
+ * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
16809
+ * preprocessed ONCE and every later inference is a pure-inference cache
16810
+ * hit — the sustained-throughput run measures inference, not
16811
+ * decode+preprocess+infer. Omitted/0 for live frames (all different →
16812
+ * full preprocess every call, correct). Fresh per sustained run;
16813
+ * released via `uncacheFrame`.
16814
+ */
16815
+ frameId: number().int().nonnegative().optional(),
16816
+ /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
16817
+ deviceKey: string$2().optional()
16818
+ }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
16819
+ data: _instanceof(Uint8Array),
16820
+ width: number().int().positive(),
16821
+ height: number().int().positive(),
16822
+ format: _enum([
16823
+ "rgb",
16824
+ "bgr",
16825
+ "gray"
16826
+ ])
16827
+ }), object({
16828
+ frameId: number(),
16829
+ width: number(),
16830
+ height: number()
16831
+ }), { kind: "mutation" }), method(object({
16832
+ stepId: string$2(),
16833
+ frameId: number().int()
16834
+ }), record(string$2(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
16835
+ batchMode: string$2(),
16836
+ windowMs: number(),
16837
+ maxBatchSize: number(),
16838
+ concurrency: number()
16839
+ })), method(_void(), array(object({
16840
+ engineKey: string$2(),
16841
+ engine: PipelineEngineChoiceSchema,
16842
+ modelsLoaded: array(string$2()).readonly(),
16843
+ inUseByCameras: array(number()).readonly(),
16844
+ /**
16845
+ * Origin of this resident factory.
16846
+ * - `runtime` — main camera-serving engine (no idle TTL).
16847
+ * - `warm-override` — benchmark/test override held in the warm
16848
+ * cache; auto-disposed after the idle TTL.
16849
+ * - `device-pool` — a concurrent per-device pool (Phase 2
16850
+ * multi-device, keyed by `deviceKey`) resolved
16851
+ * via `resolveDeviceFactory`. Runs alongside the
16852
+ * `runtime` engine on a DIFFERENT accelerator
16853
+ * (NPU / iGPU / Coral) — this is how the
16854
+ * Engines tab shows all pools running at once.
16855
+ */
16856
+ kind: _enum([
16857
+ "runtime",
16858
+ "warm-override",
16859
+ "device-pool"
16860
+ ]),
16861
+ /** Native pid of the underlying Python pool (null when no pool). */
16862
+ poolPid: number().nullable(),
16863
+ /** ms since this factory was last used (null when not warm-tracked). */
16864
+ idleMs: number().nullable(),
16865
+ /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
16866
+ idleTtlMs: number().nullable()
16867
+ })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
16868
+ kind: "mutation",
16869
+ auth: "admin"
16870
+ }), method(object({
16871
+ engine: PipelineEngineChoiceSchema,
16872
+ force: boolean().optional()
16873
+ }), object({
16874
+ success: boolean(),
16875
+ reason: string$2().optional()
16876
+ }), {
16877
+ kind: "mutation",
16878
+ auth: "admin"
16879
+ }), method(_void(), array(ReferenceImageEntrySchema).readonly()), method(object({ filename: string$2() }), ReferenceImageBodySchema.nullable()), method(_void(), array(ReferenceAudioEntrySchema).readonly()), method(object({ filename: string$2() }), ReferenceAudioBodySchema.nullable()), method(_void(), AudioCapabilitiesSchema), method(object({
16880
+ addonId: string$2(),
16881
+ modelId: string$2(),
16882
+ filename: string$2().optional(),
16883
+ settings: record(string$2(), unknown()).optional()
16884
+ }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
16895
16885
  /**
16896
- * Which detection SOURCE produced an object event. `pipeline` = the ML
16897
- * detection pipeline (decoded-frame inference); `onboard` = the camera's
16898
- * native on-device AI. Both flow through the SAME analysis layers (zoning,
16899
- * tracking, per-kind persistence) but stay distinguishable so consumers
16900
- * (advanced-notifier, occupancy, …) can select which source(s) to act on.
16901
- * Absent on legacy rows treat as `pipeline`.
16886
+ * Per-stage gating mode applied to the zones a rule references.
16887
+ *
16888
+ * - `include`: the rule contributes to a **whitelist** for its stage.
16889
+ * When at least one `include` rule fires for a stage, only entities
16890
+ * inside one of those zones pass that stage.
16891
+ * - `exclude`: the rule contributes to a **blacklist** for its stage.
16892
+ * Entities inside one of those zones are dropped at that stage.
16893
+ *
16894
+ * `monitor`-style observation (count without filtering) is not a rule
16895
+ * mode — zones without any matching rule are observed naturally by
16896
+ * `zone-analytics` (live snapshot + history), so an "I just want to
16897
+ * count, not filter" use case needs no rule at all.
16902
16898
  */
16903
- var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
16899
+ var ZoneRuleModeEnum = _enum(["include", "exclude"]);
16904
16900
  /**
16905
- * The confirmed zone crossing that produced an object event. Present ONLY on
16906
- * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
16907
- * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
16908
- * appearance event carry none, so a rule asking for a direction fails closed
16909
- * on them.
16901
+ * Per-consumer rule that references existing zones (geometry) and
16902
+ * defines how a specific pipeline stage should treat them. Each
16903
+ * consumer addon owns its own `ZoneRule[]` array in its per-device
16904
+ * settings:
16910
16905
  *
16911
- * Exactly ONE crossing per event: the emitter turns each confirmed crossing
16912
- * into its own event, so a frame in which a track enters A while leaving B
16913
- * produces two events with two directions — never one ambiguous row.
16906
+ * - `addon-motion-wasm` `motionZoneRules: ZoneRule[]` (motion stage)
16907
+ * - `addon-detection-pipeline` `detectionZoneRules: ZoneRule[]` (detection stage)
16908
+ * - future: notification rules, audio gating, etc.
16914
16909
  *
16915
- * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
16916
- * membership the box has NOW, and by definition it no longer contains the zone
16917
- * that was just left. Without the id here, a zone-scoped rule could never match
16918
- * the exit it asked for.
16910
+ * One rule applies to N zones (`zoneIds[]`) so the operator can
16911
+ * express "ignore motion in ALL of {garden, street}" with a single
16912
+ * rule. `classFilter` narrows the rule to specific object classes
16913
+ * "drop person detections in the street, but keep cars" is one
16914
+ * `exclude` rule with `classFilter: ['person']`.
16915
+ *
16916
+ * `enabled` is a soft toggle — the operator can keep the rule
16917
+ * configured but inert without deleting it.
16919
16918
  */
16920
- var ZoneCrossingSchema = object({
16921
- direction: _enum(["enter", "exit"]),
16922
- /** Admin zone id crossed. */
16923
- zoneId: string$2(),
16924
- /** Zone display name at crossing time (falls back to the id). */
16925
- zoneName: string$2().optional()
16926
- });
16927
- var ObjectEventSchema = object({
16928
- ...BaseEventFields,
16929
- kind: literal("object"),
16930
- /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
16931
- source: DetectionSourceSchema.optional(),
16919
+ var ZoneRuleSchema = object({
16920
+ /** Stable rule id — survives edits, used by the UI for diffing. */
16921
+ id: string$2(),
16922
+ /** Optional human-readable label rendered in the rule editor. */
16923
+ name: string$2().optional(),
16924
+ /** Zones this rule targets. The rule's `mode` applies to ALL
16925
+ * listed zones (OR-set: a detection in any one of them counts).
16926
+ * At least one zone id required — a rule with no targets is a
16927
+ * configuration mistake and the form validator rejects it. */
16928
+ zoneIds: array(string$2()).min(1).readonly(),
16929
+ mode: ZoneRuleModeEnum,
16932
16930
  /**
16933
- * Inference-frame id shared by every object event emitted from the SAME frame
16934
- * the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
16935
- * 2 people + 1 dog) under one full frame, and link a track's frames over time
16936
- * (group by `trackId`, pick a representative `frameId` as the parent frame).
16937
- * Optional for backward-compat with pre-existing rows / the slim projection
16938
- * includes it (it is light). Absent on rows written before this field.
16931
+ * Class names this rule applies to. Empty / undefined rule
16932
+ * applies to every class. Class strings match the `macroClass`
16933
+ * field on detections (e.g. `person`, `car`, `dog`).
16939
16934
  */
16940
- frameId: string$2().optional(),
16941
- /** Omitted in slim projection. */
16942
- trackId: string$2().optional(),
16943
- className: string$2(),
16944
- ...TieredLabelFields,
16945
- /** Omitted in slim projection. */
16946
- confidence: number().optional(),
16947
- /** Heavy JSON — omitted in slim projection. */
16948
- bbox: BoundingBoxSchema.optional(),
16949
- /** Heavy JSON — omitted in slim projection. */
16950
- zones: array(string$2()).readonly().optional(),
16951
- /** Omitted in slim projection. */
16952
- state: TrackStateSchema.optional(),
16935
+ classFilter: array(string$2()).readonly().optional(),
16953
16936
  /**
16954
- * The zone crossing this event IS, when it is one. Absent on every other
16955
- * event kind (movement state, appearance, package) see
16956
- * {@link ZoneCrossingSchema}. Omitted in slim projection.
16937
+ * Minimum bbox/mask overlap (0–1) with any of the rule's zones
16938
+ * required to consider an entity "in the zone". Defaults to the
16939
+ * consumer's stage default when omitted. Kept for back-compat with
16940
+ * existing per-rule overrides; new operators pick the value via
16941
+ * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
16942
+ * set, the lower-level engine reads it as a 0–1 fraction.
16957
16943
  */
16958
- zoneCrossing: ZoneCrossingSchema.optional(),
16959
- /** Detection-frame dimensions in pixels — let consumers normalize the
16960
- * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
16961
- frameWidth: number().optional(),
16962
- frameHeight: number().optional(),
16963
- /** MediaStore key for the crop attached to this event (if any). */
16964
- mediaKey: string$2().optional(),
16965
- /** Design B: MediaStore key of the track's native-resolution key frame (the
16966
- * best-detection full frame). Resolve via the event-media data-plane
16967
- * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
16968
- * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
16969
- * sources — consumers fall back to `mediaKey` (the tight crop). */
16970
- keyFrameMediaKey: string$2().optional(),
16971
- /** Populated by B5 (recording playback URL for this event). */
16972
- mediaUrl: string$2().optional(),
16973
- /** The parent track's key-event importance [0,1], propagated to every object
16974
- * event of the track (so an event row can be sorted by importance without a
16975
- * track join). Absent on legacy rows / before the track was scored. */
16976
- importance: number().optional()
16944
+ overlapThreshold: number().min(0).max(1).optional(),
16945
+ /**
16946
+ * Operator-friendly version of `overlapThreshold` the percentage
16947
+ * of the detection's bbox that must lie inside the zone for the
16948
+ * rule to match. Documented default is 85%; the engine substitutes
16949
+ * that when the field is omitted (kept optional so existing rules
16950
+ * stored without it stay valid).
16951
+ *
16952
+ * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
16953
+ * rule, the engine prefers `bboxInclusionPct` because it's the
16954
+ * field exposed in the UI. Internally both feed the same gate.
16955
+ */
16956
+ bboxInclusionPct: number().min(0).max(100).optional(),
16957
+ /**
16958
+ * When `true` and a detection has a segmentation mask, use the
16959
+ * mask for overlap instead of the bbox. Detection-stage only;
16960
+ * motion rules ignore this field.
16961
+ */
16962
+ preferMask: boolean().optional(),
16963
+ /**
16964
+ * Soft-toggle: `false` disables the rule without deleting it.
16965
+ * Defaults to `true` so operators creating a rule via the UI
16966
+ * see it active immediately.
16967
+ */
16968
+ enabled: boolean().default(true)
16977
16969
  });
16978
- var AudioEventSchema = object({
16979
- ...BaseEventFields,
16980
- kind: literal("audio"),
16981
- rms: number(),
16982
- dbfs: number(),
16983
- classification: object({
16984
- className: string$2(),
16985
- originalClass: string$2().optional(),
16986
- score: number()
16987
- }).optional(),
16988
- /** Populated by B5 (recording playback URL for this event). */
16989
- mediaUrl: string$2().optional()
16970
+ array(ZoneRuleSchema).readonly();
16971
+ /**
16972
+ * Zone — pure geometry + identity. NO filtering behaviour.
16973
+ *
16974
+ * Zones describe **where** in the frame the operator wants to flag
16975
+ * something; consumer-owned {@link ZoneRule} arrays describe **how**
16976
+ * each pipeline stage uses them. Splitting the two means a single
16977
+ * polygon "Driveway" can simultaneously back a motion-exclude rule,
16978
+ * a detection-include rule on `['car']`, and an occupancy aggregate
16979
+ * — without three duplicated polygons.
16980
+ *
16981
+ * Owned by the orchestrator addon (provider) and mirrored into the
16982
+ * `zones` device-state slice on every mutation. Consumers
16983
+ * (motion-wasm, pipeline-executor, analytics, admin UI) read either
16984
+ * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
16985
+ * mirror with `onChanged`).
16986
+ *
16987
+ * Coordinates are normalised fractions of the frame (0–1) so zones
16988
+ * survive resolution changes and stream profile switches.
16989
+ *
16990
+ * `kind` discriminates between full polygons (closed regions used
16991
+ * for intrusion / occupancy filters) and tripwires (open 2-point
16992
+ * line segments used for cross events). Onboard / firmware-reported
16993
+ * zones (Reolink, ONVIF) are out of scope for now — see the deferred
16994
+ * task list.
16995
+ */
16996
+ var ZoneKindEnum = _enum(["polygon", "tripwire"]);
16997
+ /** Polygon vertex in fraction-of-frame coordinates (0–1). */
16998
+ var PolygonPointSchema = object({
16999
+ x: number(),
17000
+ y: number()
16990
17001
  });
16991
- var MediaFileKindEnum = _enum([
16992
- "crop",
16993
- "thumbnail",
16994
- "snapshot",
16995
- "firstFrame",
16996
- "lastFrame",
16997
- "fullFrame",
16998
- "fullFrameBoxed",
16999
- "faceCrop",
17000
- "plateCrop",
17001
- "keyFrame",
17002
- "keyFrameSmall",
17003
- "thumbnailSmall"
17004
- ]);
17005
- var MediaFileSchema = object({
17006
- key: string$2(),
17007
- kind: MediaFileKindEnum,
17008
- base64: string$2(),
17009
- sizeBytes: number(),
17010
- timestamp: number()
17002
+ /** A camera detection zone — pure geometry/identity. */
17003
+ var ZoneSchema = object({
17004
+ id: string$2(),
17005
+ name: string$2(),
17006
+ kind: ZoneKindEnum.default("polygon"),
17007
+ /** Polygon vertices, fraction of frame (0–1). */
17008
+ polygon: array(PolygonPointSchema).readonly(),
17009
+ /** Visual color for UI rendering. */
17010
+ color: string$2().default("#3b82f6")
17011
17011
  });
17012
17012
  /**
17013
- * One media row WITHOUT its bytes.
17013
+ * Zones capability per-camera CRUD over polygon detection zones.
17014
17014
  *
17015
- * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
17016
- * 140 s track), and a client that renders tiles from the media data plane needs
17017
- * to know only WHAT EXISTS the bytes then arrive per tile, lazily, over HTTP
17018
- * with an immutable cache, instead of all at once inside a tRPC response that
17019
- * blocks the whole view.
17015
+ * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
17016
+ * to per-device settings and mirrors into the `zones` device-state
17017
+ * slice on every mutation, so downstream consumers can subscribe via
17018
+ * `dev.state.zones.onChanged`.
17020
17019
  *
17021
- * `sizeBytes` is carried because it is what lets a client decide between the
17022
- * stored blob and a `?variant=thumb` rendering without fetching either.
17020
+ * The cap surface only handles geometry + identity; filtering
17021
+ * behaviour (per-class, include/exclude, threshold) lives in the
17022
+ * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
17023
+ * `capabilities/schemas/zone-rule.js`.
17023
17024
  */
17024
- var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
17025
+ var zonesCapability = {
17026
+ name: "zones",
17027
+ scope: "device",
17028
+ mode: "singleton",
17029
+ deviceTypes: [DeviceType.Camera],
17030
+ methods: {
17031
+ listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
17032
+ addZone: method(object({
17033
+ deviceId: number(),
17034
+ zone: ZoneSchema
17035
+ }), _void(), {
17036
+ kind: "mutation",
17037
+ auth: "admin"
17038
+ }),
17039
+ removeZone: method(object({
17040
+ deviceId: number(),
17041
+ zoneId: string$2()
17042
+ }), _void(), {
17043
+ kind: "mutation",
17044
+ auth: "admin"
17045
+ }),
17046
+ updateZone: method(object({
17047
+ deviceId: number(),
17048
+ zone: ZoneSchema
17049
+ }), _void(), {
17050
+ kind: "mutation",
17051
+ auth: "admin"
17052
+ })
17053
+ },
17054
+ /**
17055
+ * Runtime-state slice — the live zone catalogue mirrored by the
17056
+ * orchestrator on every CRUD mutation. Consumers read via
17057
+ * `device.state.zones.value` / `.watch(...)` without round-tripping
17058
+ * the cap, and the codegen DeviceProxy auto-wires the reactive
17059
+ * handle. Slice shape is `{ zones: Zone[] }` so future extensions
17060
+ * (e.g. zone groupings) can sit alongside the polygon list.
17061
+ */
17062
+ runtimeState: object({ zones: array(ZoneSchema).readonly() }),
17063
+ /**
17064
+ * 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.
17065
+ *
17066
+ * See `RuntimeStateDurability`. Enforced by
17067
+ * `scripts/check-runtime-state-durability.ts`.
17068
+ */
17069
+ durability: "restored"
17070
+ };
17025
17071
  /**
17026
- * The MACRO tier of an annotation — a CLOSED set.
17072
+ * pipeline-analytics device-scoped wrapper cap. Refines raw
17073
+ * per-frame detections emitted by the pipeline runner into tracked
17074
+ * objects, per-kind event collections (motion / object / audio), and
17075
+ * persisted media. Owns the post-detection domain end-to-end:
17027
17076
  *
17028
- * This is what the exported detector predicts, so a typo here is a new class
17029
- * with one example in it. `label` and `subLabel` are open strings by contrast:
17030
- * the whole point of the page is teaching the model things it does not know
17031
- * yet, and constraining that vocabulary would make it useless.
17077
+ * runner emits PipelineInferenceResult
17078
+ * (event bus)
17079
+ * pipeline-analytics subscriber
17080
+ * SORT tracker + zone engine + state analyzer + event emitter
17081
+ * → three DB collections (one per kind), one FS media tree, one
17082
+ * unified event emitter (FrameTracked + TrackStarted/Ended +
17083
+ * DetectionEvent on bus)
17032
17084
  *
17033
- * A macro class is NEVER a label. The provider refuses a write whose `label` or
17034
- * `subLabel` is one of these values, in any casing, because once `person`
17035
- * exists in both tiers "every person box" stops being answerable without
17036
- * knowing every string anyone ever typed — and the damage is retroactive.
17085
+ * Pure subscriber model. No `processFrame` cap method the runner
17086
+ * already publishes the raw frame on the bus. The cap surface is
17087
+ * only QUERIES + per-device settings, bound on/off via
17088
+ * `device-manager.setWrapperActive`. `defaultActive: true` because
17089
+ * every camera with a detection pipeline wants its raw detections
17090
+ * refined; operators opt out per-device via BindingsTab when needed.
17091
+ *
17092
+ * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
17093
+ * (per-device surface) and `track-trail` caps — see P11 cleanup.
17037
17094
  */
17038
- var RetrainMacroClassSchema = _enum([
17095
+ var TrackStateSchema = _enum([
17096
+ "new",
17097
+ "entered",
17098
+ "left",
17099
+ "moving",
17100
+ "idle"
17101
+ ]);
17102
+ var EventKindSchema = _enum([
17103
+ "motion",
17104
+ "object",
17105
+ "audio"
17106
+ ]);
17107
+ /**
17108
+ * Spatial filter for `listTracks` — the rect + polygon variants of the shared
17109
+ * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
17110
+ * of the camera frame (top-left origin), matching the drawing-plane editor.
17111
+ */
17112
+ var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
17113
+ /** Closed icon vocabulary so clients render a known glyph per kind. */
17114
+ var EventKindIconSchema = _enum([
17115
+ "motion",
17116
+ "audio",
17039
17117
  "person",
17040
17118
  "vehicle",
17041
17119
  "animal",
17120
+ "door",
17121
+ "pir",
17122
+ "smoke",
17123
+ "water",
17124
+ "button",
17042
17125
  "package",
17043
- "face",
17044
- "plate"
17126
+ "generic"
17045
17127
  ]);
17046
- /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
17047
- var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
17048
- /** Did a human draw this box, or did the assist propose it? */
17049
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
17050
- /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
17051
- var RetrainBboxSchema = object({
17052
- x: number(),
17053
- y: number(),
17054
- w: number(),
17055
- h: number()
17128
+ var EventKindCategorySchema = _enum([
17129
+ "motion",
17130
+ "audio",
17131
+ "detection",
17132
+ "sensor",
17133
+ "control",
17134
+ "custom",
17135
+ "package"
17136
+ ]);
17137
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
17138
+ var EventKindLevelSchema = _enum(["macro", "sub"]);
17139
+ var EventKindDescriptorSchema = object({
17140
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
17141
+ kind: string$2(),
17142
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
17143
+ labelKey: string$2(),
17144
+ /** English fallback label (kept for clients that don't translate). */
17145
+ label: string$2(),
17146
+ /** Hex color for timeline/legend rendering. */
17147
+ color: string$2(),
17148
+ /** Dictionary id → lucide component on the UI side. */
17149
+ iconId: string$2(),
17150
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
17151
+ icon: EventKindIconSchema,
17152
+ category: EventKindCategorySchema,
17153
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
17154
+ parentKind: string$2().nullable(),
17155
+ /** Derived from `parentKind`, explicit for the client tree. */
17156
+ level: EventKindLevelSchema,
17157
+ /** Which cap + device contributes this kind. For built-ins the camera
17158
+ * itself; for sensor kinds the LINKED source device. */
17159
+ source: object({
17160
+ capName: string$2(),
17161
+ deviceId: number()
17162
+ })
17056
17163
  });
17057
- /**
17058
- * One annotated subject.
17059
- *
17060
- * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
17061
- * (letterboxed root / zone-cropped package / subject-cropped classifier) are
17062
- * derived from it at export and never stored — storing them is how one feature
17063
- * space ends up holding two crops of the same subject (D52).
17064
- */
17065
- var RetrainAnnotationSchema = object({
17066
- id: string$2(),
17067
- trackId: string$2(),
17164
+ /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
17165
+ var EventKindsForDeviceSchema = object({
17068
17166
  deviceId: number(),
17069
- /** The COPY in retrain storage — never the source track's media key. */
17070
- mediaKey: string$2(),
17071
- bbox: RetrainBboxSchema,
17072
- macroClass: RetrainMacroClassSchema,
17073
- label: string$2().optional(),
17074
- subLabel: string$2().optional(),
17075
- kind: RetrainAnnotationKindSchema,
17076
- source: RetrainAnnotationSourceSchema,
17077
- /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
17078
- assistModelId: string$2().optional(),
17079
- assistScore: number().optional(),
17080
- exportedInBatch: string$2().optional(),
17081
- createdAt: number()
17082
- });
17083
- /** The write form — the server owns `id`, `createdAt` and the frame binding. */
17084
- var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
17085
- id: true,
17086
- trackId: true,
17087
- deviceId: true,
17088
- mediaKey: true,
17089
- createdAt: true,
17090
- exportedInBatch: true
17167
+ kinds: array(EventKindDescriptorSchema).readonly()
17091
17168
  });
17092
- /** A track sitting in `staging`, with everything the worklist needs to rank it. */
17093
- var RetrainTrackSchema = object({
17094
- trackId: string$2(),
17169
+ var SensorEventSchema = object({
17170
+ id: string$2(),
17171
+ /** The CAMERA the event is attributed to (a sensor linked to N cameras
17172
+ * yields N rows, one per camera). */
17095
17173
  deviceId: number(),
17096
- className: string$2(),
17097
- label: string$2().optional(),
17098
- firstSeen: number(),
17099
- lastSeen: number(),
17100
- /** How many frames the dataset already holds from this track. */
17101
- frameCount: number().int(),
17102
- /** How many subjects have been annotated on those frames. `0` with
17103
- * `frameCount: 0` is exactly "staging, still to work". */
17104
- annotationCount: number().int()
17174
+ /** The linked sensor device whose state changed. */
17175
+ sourceDeviceId: number(),
17176
+ /** Event kind id — matches an `EventKindDescriptor.kind`. */
17177
+ kind: string$2(),
17178
+ /** Snapshot of the sensor cap's runtime-state slice at the change. */
17179
+ value: record(string$2(), unknown()).nullable(),
17180
+ timestamp: number()
17105
17181
  });
17106
- /** A frame the picker may offer — an index row, no blob was read to produce it. */
17107
- var RetrainFrameCandidateSchema = object({
17108
- mediaKey: string$2(),
17109
- kind: MediaFileKindEnum,
17182
+ var TrackPositionSchema = object({
17183
+ x: number(),
17184
+ y: number(),
17110
17185
  timestamp: number(),
17111
- sizeBytes: number().int(),
17112
- /** A copy of this original already exists — selecting it is free and cannot
17113
- * fail, whatever became of the original. */
17114
- copied: boolean()
17115
- });
17116
- /** A frame the dataset OWNS: bytes copied at selection time. */
17117
- var RetrainFrameSchema = object({
17118
- frameId: string$2(),
17119
- deviceId: number(),
17120
- trackId: string$2(),
17121
- /** Provenance only. It may already point at nothing — that is expected. */
17122
- sourceMediaKey: string$2(),
17123
- sourceKind: MediaFileKindEnum,
17124
- sizeBytes: number().int(),
17125
- width: number().int(),
17126
- height: number().int(),
17127
- copiedAt: number()
17128
- });
17129
- /** Why a copy-on-select could not be honoured — named, never a silent skip. */
17130
- var RetrainCopyRefusalSchema = _enum([
17131
- "source-missing",
17132
- "unreadable-image",
17133
- "write-failed"
17134
- ]);
17135
- var RetrainFrameSelectionSchema = object({
17136
- copied: array(RetrainFrameSchema).readonly(),
17137
- refused: array(object({
17138
- sourceMediaKey: string$2(),
17139
- reason: RetrainCopyRefusalSchema
17140
- })).readonly()
17186
+ bbox: BoundingBoxSchema
17141
17187
  });
17142
- var RetrainFrameListSchema = object({
17143
- candidates: array(RetrainFrameCandidateSchema).readonly(),
17144
- copies: array(RetrainFrameSchema).readonly(),
17145
- /** What the page pre-selects the native key frame when one survives. */
17146
- autoPickMediaKey: string$2().optional()
17188
+ var TrackSnapshotSchema = object({
17189
+ timestamp: number(),
17190
+ position: TrackPositionSchema,
17191
+ /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
17192
+ mediaKey: string$2()
17147
17193
  });
17148
- /** What the operator asked the assist to look for. */
17149
- var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
17150
- kind: literal("package"),
17151
- zone: RetrainBboxSchema.optional()
17152
- }), object({
17153
- kind: literal("objects"),
17154
- modelId: string$2(),
17155
- minScore: number().optional()
17156
- })]);
17157
17194
  /**
17158
- * The assist's answer a discriminated union, because "the model saw nothing"
17159
- * and "this node cannot run that model" lead to different next moves and a
17160
- * nullable result cannot tell them apart.
17195
+ * Normalized 0..1 trajectory envelope (min/max over every position bbox,
17196
+ * divided by the track's detection-frame dims), computed at persist time.
17197
+ * Absent when the frame dims were unknown when the track was persisted
17198
+ * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
17161
17199
  */
17162
- var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
17163
- kind: literal("proposed"),
17164
- modelId: string$2(),
17165
- stepId: string$2(),
17166
- minScore: number(),
17167
- /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
17168
- proposals: array(RetrainAnnotationDraftSchema).readonly(),
17169
- /** Returned by the runner but removed by the threshold. */
17170
- belowThreshold: number().int()
17171
- }), object({
17172
- kind: literal("refused"),
17173
- /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
17174
- reason: string$2(),
17175
- detail: string$2().optional()
17176
- })]);
17177
- /** The outcome of a lifecycle move owned by the retrain page. */
17178
- var RetrainTransitionResultSchema = object({
17179
- trackId: string$2(),
17180
- /** Where the track ended up, whatever happened. */
17181
- retrainStatus: RetrainStatusSchema,
17182
- /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
17183
- changed: boolean(),
17184
- reason: _enum([
17185
- "unknown-track",
17186
- "no-frames-copied",
17187
- "not-staging",
17188
- "not-trained",
17189
- "unchanged"
17190
- ]).optional()
17200
+ var TrackEnvelopeSchema = object({
17201
+ minX: number(),
17202
+ minY: number(),
17203
+ maxX: number(),
17204
+ maxY: number()
17191
17205
  });
17192
- var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
17193
- var MAX_EVENT_QUERY_LIMIT = 5e3;
17194
- var DeviceEventQueryInput = object({
17195
- deviceId: number(),
17196
- since: number().optional(),
17197
- until: number().optional(),
17198
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
17199
- /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
17200
- * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
17201
- * exact behaviour. Callers may omit this field — the store defaults to
17202
- * `full` when not provided. */
17203
- projection: _enum(["full", "slim"]).optional()
17204
- });
17205
- var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string$2().optional() });
17206
- var RecentTracksQueryInput = object({
17207
- /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
17208
- deviceIds: array(number()),
17209
- /** Window lower bound on `lastSeen` (inclusive). */
17210
- since: number().optional(),
17211
- /** Window upper bound on `lastSeen` (inclusive). */
17212
- until: number().optional(),
17213
- /** Page size. Default 200, max 1000. */
17214
- limit: number().int().min(1).max(1e3).default(200),
17215
- /** Opaque continuation cursor from a previous page's `nextCursor`.
17216
- * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
17217
- cursor: string$2().optional(),
17218
- /** See {@link TrackProjectionSchema}. Default `full`. */
17219
- projection: TrackProjectionSchema.optional(),
17220
- /** Include stationary-promoted rows (parked objects). Default false: the
17221
- * feed lists passages; parking records live on the stationary registry. */
17222
- includeStationary: boolean().optional()
17223
- });
17224
- var RecentTracksPageSchema = object({
17225
- /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
17226
- tracks: array(TrackSchema).readonly(),
17227
- /** Cursor for the next page, or null when this page is the last. */
17228
- nextCursor: string$2().nullable()
17229
- });
17230
- var LIST_GROUPS_DEFAULT_LIMIT = 40;
17231
- var LIST_GROUPS_MAX_LIMIT = 100;
17232
- var AnalyticsGroupRecordSchema = object({
17233
- id: string$2(),
17234
- deviceId: number().int(),
17235
- openedAt: number().int(),
17236
- closedAt: number().int(),
17237
- timestamp: number().int(),
17238
- memberCount: number().int(),
17239
- memberTrackIds: array(string$2()).readonly(),
17240
- className: string$2(),
17241
- classes: array(string$2()).readonly(),
17242
- /** Relative event-media path, or null when the group has no picture yet. */
17243
- mediaUrl: string$2().nullable(),
17244
- singleton: boolean()
17245
- });
17246
- var AnalyticsGroupMemberSchema = object({
17247
- trackId: string$2(),
17248
- deviceId: number().int(),
17249
- className: string$2(),
17250
- firstSeen: number().int(),
17251
- lastSeen: number().int(),
17252
- mediaUrl: string$2().nullable()
17253
- });
17254
- var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
17255
- var ListGroupsQueryInput = object({
17256
- /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
17257
- deviceIds: array(number()),
17258
- /** Window lower bound on `closedAt` (inclusive). */
17259
- since: number().optional(),
17260
- /** Window upper bound on `openedAt` (inclusive). */
17261
- until: number().optional(),
17262
- limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
17263
- /** Opaque continuation cursor from a previous page's `nextCursor`. */
17264
- cursor: string$2().optional()
17265
- });
17266
- var ListGroupsPageSchema = object({
17267
- groups: array(AnalyticsGroupRecordSchema).readonly(),
17268
- nextCursor: string$2().nullable()
17269
- });
17270
- var KeyEventQueryInput = object({
17271
- deviceId: number(),
17272
- /** Window lower bound (track firstSeen ≥ since). */
17273
- since: number(),
17274
- /** Window upper bound (track firstSeen ≤ until). */
17275
- until: number(),
17276
- limit: number().int().min(1).max(200).default(50),
17277
- /** Drop tracks scoring below this importance. */
17278
- minImportance: number().min(0).max(1).optional(),
17279
- /** Restrict to a single class (e.g. 'person'). */
17280
- classFilter: string$2().optional()
17281
- });
17282
- var KeyEventSchema = object({
17283
- /** The representative event id (the track's best ObjectEvent, else its trackId). */
17284
- id: string$2(),
17285
- trackId: string$2(),
17286
- /** Track start time (firstSeen). */
17287
- timestamp: number(),
17288
- className: string$2(),
17289
- ...TieredLabelFields,
17290
- importance: number(),
17291
- /** Highest-confidence ObjectEvent id for the track (empty when none). */
17292
- bestEventId: string$2(),
17293
- /** Track lifetime in ms (lastSeen - firstSeen). */
17294
- windowMs: number().optional(),
17295
- ...TrackFlagFields,
17296
- ...TrackRetrainFields
17297
- });
17298
- object({
17299
- trackId: string$2(),
17300
- className: string$2(),
17301
- confidence: number(),
17302
- bbox: BoundingBoxSchema,
17303
- zones: array(string$2()).readonly(),
17304
- state: TrackStateSchema
17305
- });
17306
- var OverlayDetectionSchema = looseObject({
17307
- id: string$2(),
17308
- kind: _enum(["first-level", "detail"]),
17309
- macroClass: string$2(),
17310
- score: number(),
17311
- bbox: object({
17312
- x: number(),
17313
- y: number(),
17314
- width: number(),
17315
- height: number()
17316
- }),
17317
- labels: array(looseObject({
17318
- label: string$2(),
17319
- score: number()
17320
- })).readonly(),
17321
- parentId: string$2().optional()
17322
- });
17323
- var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
17324
- var SearchObjectEventsInput = object({
17325
- text: string$2(),
17326
- deviceId: number().optional(),
17327
- since: number().optional(),
17328
- until: number().optional(),
17329
- classFilter: string$2().optional(),
17330
- limit: number().default(50),
17331
- minScore: number().min(0).max(1).default(.2)
17332
- });
17333
- var TrackCascadeCountsSchema = object({
17334
- /** Persisted track roots deleted (authoritative). */
17335
- tracks: number().int(),
17336
- /** Object events removed with their tracks (best-effort; see note above). */
17337
- events: number().int(),
17338
- /** Track/face/plate-owned media removed (best-effort). Never identity media. */
17339
- media: number().int(),
17340
- /** Unassigned (non-enrolled) face reads removed (best-effort). */
17341
- faces: number().int(),
17342
- /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
17343
- plates: number().int(),
17344
- /** Per-track CLIP search vectors removed (best-effort). */
17345
- embeddings: number().int(),
17346
- /** Group membership + group rows removed with their last member (best-effort). */
17347
- groups: number().int()
17348
- });
17349
- /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
17350
- var DiskReconcileCountsSchema = object({
17351
- mediaDropped: number().int(),
17352
- tracks: number().int(),
17353
- events: number().int()
17354
- });
17355
- /** Event-store footprint for one camera. */
17356
- var EventStoreDeviceFootprintSchema = object({
17357
- deviceId: number(),
17358
- /** Persisted event rows (motion + object + audio) for the camera. */
17359
- rows: number().int(),
17360
- /** Event-owned media bytes on disk for the camera. */
17361
- bytes: number().int()
17362
- });
17363
- /** Aggregate event-store footprint: global totals + per-camera breakdown. */
17364
- var EventStoreFootprintSchema = object({
17365
- totalRows: number().int(),
17366
- totalBytes: number().int(),
17367
- devices: array(EventStoreDeviceFootprintSchema).readonly()
17368
- });
17369
- /** Per-kind counts returned by the event-prune / device-delete mutations. */
17370
- var EventPruneCountsSchema = object({
17371
- motion: number().int(),
17372
- object: number().int(),
17373
- audio: number().int()
17206
+ /**
17207
+ * Row projection for track list queries. `full` (default) returns the
17208
+ * complete Track including the frame-rate `positions[]` history and the
17209
+ * `snapshots[]` references — megabytes across a page of tracks. `slim`
17210
+ * keeps every scalar the list surfaces actually render (ids, class(es),
17211
+ * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
17212
+ * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
17213
+ * `snapshots` as EMPTY arrays detail views re-fetch the full row via
17214
+ * `getTrack`. Mirrors the event-store `projection` convention
17215
+ * (`getObjectEvents` et al.).
17216
+ */
17217
+ var TrackProjectionSchema = _enum(["full", "slim"]);
17218
+ /**
17219
+ * One audio-classification label heard on the track's camera while the
17220
+ * track was alive, aggregated per label. An "episode" is one persisted
17221
+ * audio event (the confident-classification path: score the device's
17222
+ * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
17223
+ * one 32 ms inference chunk, so counts stay human-scaled.
17224
+ */
17225
+ var TrackAudioLabelSchema = object({
17226
+ label: string$2(),
17227
+ /** Highest classification score observed across the label's episodes. */
17228
+ peakScore: number(),
17229
+ /** Number of coalesced audio-event episodes carrying this label. */
17230
+ count: number(),
17231
+ firstAt: number(),
17232
+ lastAt: number()
17374
17233
  });
17375
17234
  /**
17376
- * Re-embed stored tracks from their key frames.
17235
+ * How a track was produced. `pipeline` (default / absent) = the spatial
17236
+ * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
17237
+ * no positions, a single snapshot, and no bbox trajectory at all:
17377
17238
  *
17378
- * The reason this is an operator-callable method and not a migration script:
17379
- * every knob that decides what a vector MEANS encoder model, crop margin,
17380
- * squaring is only changeable if the existing vectors can be regenerated.
17381
- * Mixing feature spaces in one index makes cosine scores incomparable, and the
17382
- * symptom is a quality regression with no visible cause.
17239
+ * - `sensor` a linked sensor/control device state change.
17240
+ * - `audio` an audio event on the camera itself that was anomalous for
17241
+ * THAT camera, loud, and heard while nothing visual was happening (D62).
17242
+ *
17243
+ * The spatial subsystems (tracker association, occupancy count, re-id /
17244
+ * embedding, resurrection) MUST skip every synthetic source. Test for that
17245
+ * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
17246
+ * check silently readmits every source added after it was written.
17383
17247
  */
17384
- var RebuildObjectEmbeddingsInput = object({
17385
- /** Restrict to one camera. Omit for the whole fleet. */
17386
- deviceId: number().optional(),
17387
- since: number().optional(),
17388
- until: number().optional(),
17389
- /** Stop after this many tracks; the result reports whether more remain. */
17390
- maxTracks: number().int().positive().optional(),
17391
- /**
17392
- * Run every embedding on THIS node instead of round-robining the fleet.
17393
- *
17394
- * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
17395
- * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
17396
- * calling it that would pin the rebuild REQUEST itself to that node — the
17397
- * rebuild orchestration lives on the hub, and only the per-track step runs
17398
- * remotely. This field is data; the per-track pin is applied inside.
17399
- *
17400
- * Absent ⇒ round-robin over every online node whose runner can serve the
17401
- * pinned model.
17402
- */
17403
- executeOnNodeId: string$2().optional(),
17404
- /**
17405
- * Milliseconds to wait between tracks; omit for the built-in default, `0` to
17406
- * run flat out.
17407
- *
17408
- * A rebuild is bulk maintenance on hub-main's single thread. Measured
17409
- * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
17410
- * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
17411
- * force is logged at start and finish so a deliberately slow pass reads
17412
- * differently from a stalled one.
17413
- */
17414
- pacingMs: number().int().nonnegative().optional()
17415
- });
17248
+ var TrackSourceSchema = _enum([
17249
+ "pipeline",
17250
+ "sensor",
17251
+ "audio"
17252
+ ]);
17416
17253
  /**
17417
- * Result of emptying the CLIP index.
17254
+ * Where a track sits in the RETRAIN lifecycle (D81).
17418
17255
  *
17419
- * The clean slate before a policy change: a new crop margin or encoder model
17420
- * leaves two feature spaces in one index whose cosine scores are not
17421
- * comparable, so wiping and rebuilding is the only way to be sure every vector
17422
- * means the same thing.
17256
+ * - `none` never marked, or un-marked. Evictable.
17257
+ * - `staging` the operator wants this track as training material and has not
17258
+ * finished with it. **This is the only state retention holds**: the track and
17259
+ * everything it owns (object events, crops, keyframes, CLIP vector) survive
17260
+ * the device's age window.
17261
+ * - `trained` — the retrain page has taken what it needed. The frames it chose
17262
+ * were COPIED into the retrain dataset at selection time, so the dataset no
17263
+ * longer depends on the track's media and the track becomes EVICTABLE again.
17264
+ * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
17265
+ * a deliberate action of the retrain page, not a side effect of a checkbox.
17266
+ *
17267
+ * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
17268
+ * the store's filter language has only positive equality and `whereIn` — no
17269
+ * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
17270
+ * would make the entire pre-column history immortal in one deploy.
17423
17271
  */
17424
- var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
17272
+ var RetrainStatusSchema = _enum([
17273
+ "none",
17274
+ "staging",
17275
+ "trained"
17276
+ ]);
17425
17277
  /**
17426
- * Acknowledgement that a rebuild STARTED.
17278
+ * Per-track OPERATOR flags set by hand from the admin UI or the viewer, never
17279
+ * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
17280
+ * so the two surfaces cannot drift.
17427
17281
  *
17428
- * The pass costs ~1s per track 45 minutes for a 2,600-track fleet so it
17429
- * runs detached and this returns immediately. Waiting for it made the client
17430
- * time out while the work carried on server-side, which is the worst of both:
17431
- * no result and no way to know it was still going. Poll
17432
- * `getObjectEmbeddingRebuildStatus` for progress.
17433
- */
17434
- var RebuildObjectEmbeddingsResultSchema = object({
17435
- started: boolean(),
17436
- /** True when a pass was already running; the new request is ignored. */
17437
- alreadyRunning: boolean()
17438
- });
17439
- var RebuildStatusSchema = object({
17440
- running: boolean(),
17441
- scanned: number(),
17442
- rebuilt: number(),
17443
- /** Tracks whose key frame is gone nothing to re-embed from. */
17444
- missingKeyFrame: number(),
17445
- /** Tracks with no usable detection box. */
17446
- missingBbox: number(),
17447
- /**
17448
- * Tracks an executing node REFUSED rather than broke on — an unreadable key
17449
- * frame, a step that threw. Separate from `failed` because the remedy is
17450
- * different, and because a whole camera silently contributing zero vectors
17451
- * is the shape of failure a rebuild must never hide.
17452
- */
17453
- notRunnable: number(),
17282
+ * **Absent false.** A track that has never been touched omits the field; an
17283
+ * explicitly un-flagged track carries `false`. Legacy rows written before the
17284
+ * columns existed read as absent, and a consumer that needs a boolean should say
17285
+ * `flag === true`, not `flag !== false`.
17286
+ *
17287
+ * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
17288
+ * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
17289
+ * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
17290
+ * `trained` track reports `false` while refusing both writes. The boolean is
17291
+ * kept because three surfaces drive a toggle off it; anything that needs to tell
17292
+ * "never marked" from "already trained" must read `retrainStatus`.
17293
+ *
17294
+ * `debug` does NOT pin; it is attention, not durability.
17295
+ *
17296
+ * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
17297
+ * A favourited track is skipped by retention the same way `staging` is, but
17298
+ * it does not enter `none|staging|trained` and has no staging budget.
17299
+ */
17300
+ var TrackFlagFields = {
17301
+ /** Operator marked this track as training material — i.e. `retrainStatus` is
17302
+ * `'staging'`. */
17303
+ markForTrain: boolean().optional(),
17304
+ /** Operator marked this track for diagnostic attention. */
17305
+ debug: boolean().optional(),
17306
+ /** Operator favourited this track. Pins it against pruning. */
17307
+ favourited: boolean().optional()
17308
+ };
17309
+ /**
17310
+ * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
17311
+ * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
17312
+ * write patch, and the status is not something the toggle sets — it is what the
17313
+ * toggle's boolean is derived from. Absent on an in-RAM track never touched;
17314
+ * always present on a persisted row (the column default materialises `'none'`).
17315
+ */
17316
+ var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
17317
+ /**
17318
+ * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
17319
+ * one flag can never clear the other — the toggles are independent and are
17320
+ * driven from three surfaces that do not know about each other.
17321
+ */
17322
+ var TrackFlagsPatchSchema = object(TrackFlagFields);
17323
+ /**
17324
+ * The resolved flag state after a write. Both fields are REQUIRED here (absent
17325
+ * collapses to `false`) so a caller can drive a toggle's checked state off the
17326
+ * mutation result without a re-fetch.
17327
+ */
17328
+ var TrackFlagsSchema = object({
17329
+ trackId: string$2(),
17330
+ markForTrain: boolean(),
17331
+ debug: boolean(),
17332
+ favourited: boolean(),
17333
+ /** The lifecycle state the boolean was derived from. Required here (unlike on
17334
+ * a track row) because this shape is only ever produced by the write body,
17335
+ * which always knows it — and a surface that has just written needs to render
17336
+ * `trained` without a re-fetch. */
17337
+ retrainStatus: RetrainStatusSchema
17338
+ });
17339
+ union([literal(1), literal(2)]);
17340
+ /**
17341
+ * WHO decided a label, and when. Carried per tier so a value can be traced to
17342
+ * the step and model that produced it — which is what makes the write rule
17343
+ * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
17344
+ * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
17345
+ *
17346
+ * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
17347
+ * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
17348
+ * `migration:4g` for a value the 4g migration moved from the single-slot era —
17349
+ * that value has no provenance, and the write rule lets ANY properly-attributed
17350
+ * write of the same tier replace it regardless of score.
17351
+ */
17352
+ var LabelAttributionSchema = object({
17353
+ stepId: string$2(),
17354
+ modelId: string$2().optional(),
17355
+ decidedAt: number(),
17454
17356
  /**
17455
- * The pass stopped because NO node could serve the pinned model.
17357
+ * The GALLERY id behind a recognised tier-2 label a face-gallery
17358
+ * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
17456
17359
  *
17457
- * Distinct from `notRunnable` on purpose: that one says "this track was
17458
- * refused", this one says "the cluster cannot do this work at all" — every
17459
- * candidate node either lacks the `clip-embedding` step, lacks a build of the
17460
- * pinned model for its engine format, or dropped out. The remedy is a model /
17461
- * engine change, not a per-camera one. Non-zero here always comes with
17462
- * `complete: false`.
17360
+ * The text alone is a DISPLAY NAME, and a display name is renameable: a
17361
+ * notification rule authored on "Gianluca" stopped matching the moment the
17362
+ * operator fixed the spelling in the gallery, and nothing said so. The id is
17363
+ * the thing that does not move, so it is what a rule matches on
17364
+ * (`NcConditions.identities`) and the text is what a human is shown.
17365
+ *
17366
+ * Absent when the label names no gallery row — a plate the OCR read but no
17367
+ * vehicle claims, a sub-class, a species, any tier-1 value.
17463
17368
  */
17464
- noCapableNode: number(),
17465
- failed: number(),
17466
- /** Set once a pass ends: true only when EVERYTHING was covered. */
17467
- complete: boolean().nullable(),
17468
- startedAtMs: number().nullable(),
17469
- finishedAtMs: number().nullable(),
17470
- /** Present when the pass ended by throwing. */
17471
- error: string$2().nullable()
17369
+ identityId: string$2().optional()
17472
17370
  });
17473
- DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
17474
- deviceId: number(),
17475
- trackId: string$2()
17476
- }), TrackSchema.nullable()), method(object({
17477
- deviceId: number(),
17478
- since: number().optional(),
17479
- until: number().optional(),
17480
- limit: number().optional(),
17481
- /** Spatial filter — only tracks whose trajectory intersects the zone
17482
- * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
17483
- * envelope columns, then precisely tested per position. Tracks with
17484
- * an unknown envelope (no frame dims at persist time) always match. */
17485
- zone: TrackZoneFilterSchema.optional(),
17486
- /** See {@link TrackProjectionSchema}. Default `full` (backward
17487
- * compatible omitting the field keeps today's exact behaviour). */
17488
- projection: TrackProjectionSchema.optional(),
17489
- /** Include stationary-promoted rows (parked objects handed to the
17490
- * stationary registry). Default false: the timeline lists passages,
17491
- * not parking records (operator decision, 2026-08-15). */
17492
- includeStationary: boolean().optional()
17493
- }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
17494
- deviceId: number(),
17495
- groupId: string$2().min(1)
17496
- }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
17497
- kind: "mutation",
17498
- auth: "admin"
17499
- }), 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({
17500
- deviceId: number(),
17501
- since: number().optional(),
17502
- until: number().optional(),
17503
- kinds: array(string$2()).optional(),
17504
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
17505
- }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
17506
- deviceId: number(),
17507
- since: number(),
17508
- until: number(),
17509
- bucketMs: number().int().positive()
17510
- }), array(object({
17511
- bucketStart: number(),
17512
- motion: number().int(),
17513
- object: number().int(),
17514
- audio: number().int()
17515
- })).readonly()), method(object({
17516
- deviceId: number(),
17517
- cutoffMs: number()
17518
- }), object({
17519
- motion: number().int(),
17520
- object: number().int(),
17521
- audio: number().int()
17522
- }), {
17523
- kind: "mutation",
17524
- auth: "admin"
17525
- }), method(object({
17526
- deviceId: number(),
17527
- cutoffMs: number()
17528
- }), TrackCascadeCountsSchema, {
17529
- kind: "mutation",
17530
- auth: "admin"
17531
- }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
17532
- kind: "mutation",
17533
- auth: "admin"
17534
- }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
17535
- kind: "mutation",
17536
- auth: "admin"
17537
- }), method(object({
17538
- deviceId: number(),
17539
- trackIds: array(string$2()).min(1)
17540
- }), object({
17541
- deleted: number().int(),
17542
- failed: array(string$2()).readonly()
17543
- }), {
17544
- kind: "mutation",
17545
- auth: "admin"
17546
- }), method(object({
17547
- /** Log/audit scope only — the trackId is globally unique on its own. */
17371
+ /**
17372
+ * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
17373
+ * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
17374
+ * track and its events always answer the same question the same way.
17375
+ *
17376
+ * Two scalar columns, not an array: every consumer wants "the coarse one" or
17377
+ * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
17378
+ * is tier 2, and each carries its own score + attribution.
17379
+ *
17380
+ * **Reading it.** What a human should be shown is `subLabel ?? label` — the
17381
+ * finest thing known. Before 4g the single `label` column held the finest
17382
+ * value, so a consumer that has not been updated reads the tier-1 slot and
17383
+ * shows nothing on a species-only row; that is why the migration puts every
17384
+ * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
17385
+ * and why the read surfaces were changed in the same train.
17386
+ *
17387
+ * **Writing it.** The slots are independent, which is the whole point: a
17388
+ * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
17389
+ * migratorius`), so fineness cannot regress by construction. Within a tier the
17390
+ * higher score wins. One rule, one implementation — see
17391
+ * `pipeline/label-tier.ts` in addon-post-analysis.
17392
+ */
17393
+ var TieredLabelFields = {
17394
+ /** Tier 1 the sub-class. See {@link LabelTierSchema}. */
17395
+ label: string$2().optional(),
17396
+ /** Confidence of the tier-1 value, as reported by the deciding step. */
17397
+ labelScore: number().optional(),
17398
+ /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
17399
+ labelMeta: LabelAttributionSchema.optional(),
17400
+ /** Tier 2 — the instance. See {@link LabelTierSchema}. */
17401
+ subLabel: string$2().optional(),
17402
+ /** Confidence of the tier-2 value, as reported by the deciding step. */
17403
+ subLabelScore: number().optional(),
17404
+ /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
17405
+ subLabelMeta: LabelAttributionSchema.optional()
17406
+ };
17407
+ /** Per-camera slice of a training-export estimate. */
17408
+ var TrainingExportDeviceTotalsSchema = object({
17548
17409
  deviceId: number(),
17410
+ tracks: number().int(),
17411
+ files: number().int(),
17412
+ bytes: number().int()
17413
+ });
17414
+ /**
17415
+ * What a training export WOULD contain. Computed from media index rows only —
17416
+ * no blob is read to produce this.
17417
+ */
17418
+ var TrainingExportSummarySchema = object({
17419
+ generatedAt: number(),
17420
+ trackCount: number().int(),
17421
+ fileCount: number().int(),
17422
+ byteCount: number().int(),
17423
+ /** More marked tracks exist than a single pass carries. */
17424
+ truncated: boolean(),
17425
+ devices: array(TrainingExportDeviceTotalsSchema).readonly()
17426
+ });
17427
+ var TrackSchema = object({
17549
17428
  trackId: string$2(),
17550
- flags: TrackFlagsPatchSchema
17551
- }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
17552
- kind: "query",
17553
- auth: "admin"
17554
- }), method(object({
17555
- olderThanMs: number(),
17556
- reason: OpsLogReasonSchema.optional()
17557
- }), EventPruneCountsSchema, {
17558
- kind: "mutation",
17559
- auth: "admin"
17560
- }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
17561
- kind: "mutation",
17562
- auth: "admin"
17563
- }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
17564
- kind: "mutation",
17565
- auth: "admin"
17566
- }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
17567
- kind: "mutation",
17568
- auth: "admin"
17569
- }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
17570
- kind: "mutation",
17571
- auth: "admin"
17572
- }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string$2() }), {
17573
- kind: "mutation",
17574
- auth: "admin"
17575
- }), method(object({ jobId: string$2() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string$2() }), object({ cancelled: boolean() }), {
17576
- kind: "mutation",
17577
- auth: "admin"
17578
- }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
17579
- kind: "query",
17580
- auth: "admin"
17581
- }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
17582
- kind: "query",
17583
- auth: "admin"
17584
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string$2() }), {
17585
- kind: "query",
17586
- auth: "admin"
17587
- }), method(object({
17588
- /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
17589
- * `deviceId`, deliberately: `deviceId` would make this device-bound and
17590
- * route it at one camera's owner, and "every camera" would stop being
17591
- * expressible at all. */
17592
- deviceIds: array(number()).optional(),
17593
- limit: number().int().min(1).max(500).optional()
17594
- }), array(RetrainTrackSchema).readonly(), {
17595
- kind: "query",
17596
- auth: "admin"
17597
- }), method(object({ trackId: string$2() }), RetrainFrameListSchema, {
17598
- kind: "query",
17599
- auth: "admin"
17600
- }), method(object({
17601
17429
  deviceId: number(),
17602
- trackId: string$2(),
17603
- mediaKeys: array(string$2()).min(1)
17604
- }), RetrainFrameSelectionSchema, {
17605
- kind: "mutation",
17606
- auth: "admin"
17607
- }), method(object({
17430
+ className: string$2(),
17431
+ ...TieredLabelFields,
17432
+ producingDeviceName: string$2().optional(),
17433
+ /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
17434
+ source: TrackSourceSchema.optional(),
17435
+ firstSeen: number(),
17436
+ lastSeen: number(),
17437
+ /** Frame-rate position history (subject to maxPositionHistory cap). */
17438
+ positions: array(TrackPositionSchema).readonly(),
17439
+ /** Periodic snapshots at snapshotIntervalMs cadence (subject to
17440
+ * saveThumbnails policy). */
17441
+ snapshots: array(TrackSnapshotSchema).readonly(),
17442
+ /** Deduplicated zones the track has entered at least once. Zone IDS. */
17443
+ zonesVisited: array(string$2()).readonly(),
17444
+ /**
17445
+ * Human NAMES for {@link zonesVisited}, resolved at READ time against the
17446
+ * `zones` capability.
17447
+ *
17448
+ * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
17449
+ * and no card can render — so every free-text search surface was structurally
17450
+ * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
17451
+ * just returned nothing. Resolving here rather than in each client keeps ONE
17452
+ * derivation and costs the clients no extra call (the `zones` cap is
17453
+ * per-device, so a client-side resolve would be a per-camera fan-out on a
17454
+ * surface built to avoid exactly that).
17455
+ *
17456
+ * Resolved, never invented: a zone deleted since the track was written has no
17457
+ * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
17458
+ * two are not positionally aligned. Absent when the track visited no zone, or
17459
+ * when the zone catalogue could not be read.
17460
+ */
17461
+ zoneNames: array(string$2()).readonly().optional(),
17462
+ /** Deduplicated set of detector classes observed for this track over its
17463
+ * life (a track may be reclassified, e.g. person→vehicle). Absent on
17464
+ * legacy rows written before class accumulation shipped. */
17465
+ classes: array(string$2()).readonly().optional(),
17466
+ /** Cumulative normalized distance travelled (0..1 units = full frame width). */
17467
+ totalDistance: number(),
17468
+ state: TrackStateSchema,
17469
+ active: boolean(),
17470
+ /** Deterministic key-event importance score in [0,1] (server-computed at
17471
+ * track expiry, recomputed on late label). Absent on legacy rows written
17472
+ * before scoring shipped — consumers degrade to absence / compute-on-read. */
17473
+ importance: number().optional(),
17474
+ /** Id of the track's highest-confidence ObjectEvent (its representative
17475
+ * "best" frame). Absent when the track produced no object events. */
17476
+ bestEventId: string$2().optional(),
17477
+ /** Tag of the importance sub-signal that dominated the score
17478
+ * (identity|dwell|proximity|class|confidence|travel|zone). */
17479
+ importanceReason: string$2().optional(),
17480
+ /** Audio-classification labels heard on the camera during the track's
17481
+ * life (score ≥ device `classificationMinScore`), aggregated per label.
17482
+ * Absent on legacy rows / tracks with no confident audio. */
17483
+ audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
17484
+ /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
17485
+ * Populated from the persisted envelope columns on historical reads;
17486
+ * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
17487
+ envelope: TrackEnvelopeSchema.optional(),
17488
+ /**
17489
+ * A face DETECTOR found a face on this track — nothing more. It says the
17490
+ * detail plane produced a `face` detail; it does NOT say the face was
17491
+ * embedded, matched, above `minFacePx`, or that the recognizer was even
17492
+ * enabled. Set once and never cleared.
17493
+ *
17494
+ * **This exists so "face present but not recognised" is expressible.** A
17495
+ * recognised identity lands in `subLabel` (attributed to the face chain via
17496
+ * `subLabelMeta.stepId`), so before this field a track with an unmatched face
17497
+ * and a track with no face at all were byte-identical on the wire and no
17498
+ * surface could tell them apart. The read is `hasFace === true && subLabel
17499
+ * === undefined`.
17500
+ *
17501
+ * **Absent ≠ false.** Every row written before the column existed omits it,
17502
+ * and so does every server that predates the field — a consumer must test
17503
+ * `=== true` and render nothing otherwise, never infer "no face".
17504
+ */
17505
+ hasFace: boolean().optional(),
17506
+ /**
17507
+ * This track has a face row IN THE GALLERY: a crop **and** an embedding — a
17508
+ * face an operator could ASSIGN to an identity.
17509
+ *
17510
+ * The STRICT twin of {@link hasFace}, and the pair only earns its keep
17511
+ * because the two disagree. `hasFace` is stamped at the TOP of the face
17512
+ * branch, before every gate, and means no more than "a face detector produced
17513
+ * a face detail". This one is stamped at the single moment the gallery row
17514
+ * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
17515
+ * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
17516
+ * candidate gate, the imageless-track drop (no crop was ever captured) and
17517
+ * the crop-store drop. Everything between the detector and that insert can
17518
+ * legitimately refuse the face, so a flag written any earlier promises the
17519
+ * operator something to assign and delivers nothing.
17520
+ *
17521
+ * **Independent of recognition.** A face collected but never auto-matched is
17522
+ * still assignable — it is in fact the face an operator most wants to reach —
17523
+ * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
17524
+ * `subLabel`; this says only that the raw material exists.
17525
+ *
17526
+ * **Set once, never cleared.** A track that produced a gallery row produced
17527
+ * one; deleting the row later is the gallery's business, not this flag's.
17528
+ *
17529
+ * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
17530
+ * before the column omits it, and so does every server that predates the
17531
+ * field. A consumer must test `=== true` and render nothing otherwise —
17532
+ * never infer "no assignable face".
17533
+ */
17534
+ hasEmbeddedFace: boolean().optional(),
17535
+ /**
17536
+ * This subject CONTAINS a folded rider — a person the rider-pairing step
17537
+ * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
17538
+ * so the passage is tracked once and as a VEHICLE.
17539
+ *
17540
+ * It exists because the fold's record was dishonest. D34 and the code both
17541
+ * said "the person is not lost — it is reported so both entities stay on the
17542
+ * record"; in fact the pair went into a per-processor RAM field behind an
17543
+ * accessor nobody called, and every durable surface said `vehicle`, full
17544
+ * stop. This is the composition note that makes the row true.
17545
+ *
17546
+ * A COMPOSITION, never a class and never a label. "This vehicle contains a
17547
+ * person" is not an answer to "what is this" — both label tiers would refuse
17548
+ * a macro token anyway (D89), and correctly. Nothing here changes what the
17549
+ * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
17550
+ * and a `person` rule still does not fire for someone cycling past.
17551
+ *
17552
+ * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
17553
+ * the column, and every hub that predates the field, omits it. Test
17554
+ * `=== true` and render nothing otherwise — never infer "no rider".
17555
+ */
17556
+ hasRider: boolean().optional(),
17557
+ ...TrackFlagFields,
17558
+ ...TrackRetrainFields
17559
+ });
17560
+ var BaseEventFields = {
17561
+ id: string$2(),
17608
17562
  deviceId: number(),
17609
- trackId: string$2(),
17610
- frameId: string$2()
17611
- }), object({
17612
- removed: boolean(),
17613
- removedAnnotations: number().int()
17614
- }), {
17615
- kind: "mutation",
17616
- auth: "admin"
17617
- }), method(object({ frameId: string$2() }), object({
17563
+ timestamp: number()
17564
+ };
17565
+ var MotionEventSchema = object({
17566
+ ...BaseEventFields,
17567
+ kind: literal("motion"),
17568
+ regionCount: number(),
17569
+ /** Heavy JSON array — omitted in slim projection. */
17570
+ regions: array(object({
17571
+ bbox: BoundingBoxSchema,
17572
+ pixelCount: number(),
17573
+ intensity: number()
17574
+ })).readonly().optional(),
17575
+ /** Omitted in slim projection. */
17576
+ frameWidth: number().optional(),
17577
+ /** Omitted in slim projection. */
17578
+ frameHeight: number().optional(),
17579
+ /** Populated by B5 (recording playback URL for this event). */
17580
+ mediaUrl: string$2().optional()
17581
+ });
17582
+ /**
17583
+ * Which detection SOURCE produced an object event. `pipeline` = the ML
17584
+ * detection pipeline (decoded-frame inference); `onboard` = the camera's
17585
+ * native on-device AI. Both flow through the SAME analysis layers (zoning,
17586
+ * tracking, per-kind persistence) but stay distinguishable so consumers
17587
+ * (advanced-notifier, occupancy, …) can select which source(s) to act on.
17588
+ * Absent on legacy rows ⇒ treat as `pipeline`.
17589
+ */
17590
+ var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
17591
+ /**
17592
+ * The confirmed zone crossing that produced an object event. Present ONLY on
17593
+ * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
17594
+ * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
17595
+ * appearance event carry none, so a rule asking for a direction fails closed
17596
+ * on them.
17597
+ *
17598
+ * Exactly ONE crossing per event: the emitter turns each confirmed crossing
17599
+ * into its own event, so a frame in which a track enters A while leaving B
17600
+ * produces two events with two directions — never one ambiguous row.
17601
+ *
17602
+ * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
17603
+ * membership the box has NOW, and by definition it no longer contains the zone
17604
+ * that was just left. Without the id here, a zone-scoped rule could never match
17605
+ * the exit it asked for.
17606
+ */
17607
+ var ZoneCrossingSchema = object({
17608
+ direction: _enum(["enter", "exit"]),
17609
+ /** Admin zone id crossed. */
17610
+ zoneId: string$2(),
17611
+ /** Zone display name at crossing time (falls back to the id). */
17612
+ zoneName: string$2().optional()
17613
+ });
17614
+ var ObjectEventSchema = object({
17615
+ ...BaseEventFields,
17616
+ kind: literal("object"),
17617
+ /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
17618
+ source: DetectionSourceSchema.optional(),
17619
+ /**
17620
+ * Inference-frame id shared by every object event emitted from the SAME frame
17621
+ * — the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
17622
+ * 2 people + 1 dog) under one full frame, and link a track's frames over time
17623
+ * (group by `trackId`, pick a representative `frameId` as the parent frame).
17624
+ * Optional for backward-compat with pre-existing rows / the slim projection
17625
+ * includes it (it is light). Absent on rows written before this field.
17626
+ */
17627
+ frameId: string$2().optional(),
17628
+ /** Omitted in slim projection. */
17629
+ trackId: string$2().optional(),
17630
+ className: string$2(),
17631
+ ...TieredLabelFields,
17632
+ /** Omitted in slim projection. */
17633
+ confidence: number().optional(),
17634
+ /** Heavy JSON — omitted in slim projection. */
17635
+ bbox: BoundingBoxSchema.optional(),
17636
+ /** Heavy JSON — omitted in slim projection. */
17637
+ zones: array(string$2()).readonly().optional(),
17638
+ /** Omitted in slim projection. */
17639
+ state: TrackStateSchema.optional(),
17640
+ /**
17641
+ * The zone crossing this event IS, when it is one. Absent on every other
17642
+ * event kind (movement state, appearance, package) — see
17643
+ * {@link ZoneCrossingSchema}. Omitted in slim projection.
17644
+ */
17645
+ zoneCrossing: ZoneCrossingSchema.optional(),
17646
+ /** Detection-frame dimensions in pixels — let consumers normalize the
17647
+ * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
17648
+ frameWidth: number().optional(),
17649
+ frameHeight: number().optional(),
17650
+ /** MediaStore key for the crop attached to this event (if any). */
17651
+ mediaKey: string$2().optional(),
17652
+ /** Design B: MediaStore key of the track's native-resolution key frame (the
17653
+ * best-detection full frame). Resolve via the event-media data-plane
17654
+ * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
17655
+ * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
17656
+ * sources — consumers fall back to `mediaKey` (the tight crop). */
17657
+ keyFrameMediaKey: string$2().optional(),
17658
+ /** Populated by B5 (recording playback URL for this event). */
17659
+ mediaUrl: string$2().optional(),
17660
+ /** The parent track's key-event importance [0,1], propagated to every object
17661
+ * event of the track (so an event row can be sorted by importance without a
17662
+ * track join). Absent on legacy rows / before the track was scored. */
17663
+ importance: number().optional()
17664
+ });
17665
+ var AudioEventSchema = object({
17666
+ ...BaseEventFields,
17667
+ kind: literal("audio"),
17668
+ rms: number(),
17669
+ dbfs: number(),
17670
+ classification: object({
17671
+ className: string$2(),
17672
+ originalClass: string$2().optional(),
17673
+ score: number()
17674
+ }).optional(),
17675
+ /** Populated by B5 (recording playback URL for this event). */
17676
+ mediaUrl: string$2().optional()
17677
+ });
17678
+ var MediaFileKindEnum = _enum([
17679
+ "crop",
17680
+ "thumbnail",
17681
+ "snapshot",
17682
+ "firstFrame",
17683
+ "lastFrame",
17684
+ "fullFrame",
17685
+ "fullFrameBoxed",
17686
+ "faceCrop",
17687
+ "plateCrop",
17688
+ "keyFrame",
17689
+ "keyFrameSmall",
17690
+ "thumbnailSmall"
17691
+ ]);
17692
+ var MediaFileSchema = object({
17693
+ key: string$2(),
17694
+ kind: MediaFileKindEnum,
17618
17695
  base64: string$2(),
17619
- width: number().int(),
17620
- height: number().int()
17621
- }), {
17622
- kind: "query",
17623
- auth: "admin"
17624
- }), method(object({
17625
- deviceId: number(),
17626
- trackId: string$2(),
17627
- frameId: string$2(),
17628
- subject: RetrainAssistSubjectSchema,
17629
- /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
17630
- nodeId: string$2().optional()
17631
- }), RetrainAssistResultSchema, {
17632
- kind: "mutation",
17633
- auth: "admin"
17634
- }), method(object({ trackId: string$2() }), array(RetrainAnnotationSchema).readonly(), {
17635
- kind: "query",
17636
- auth: "admin"
17637
- }), method(object({
17638
- deviceId: number(),
17696
+ sizeBytes: number(),
17697
+ timestamp: number()
17698
+ });
17699
+ /**
17700
+ * One media row WITHOUT its bytes.
17701
+ *
17702
+ * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
17703
+ * 140 s track), and a client that renders tiles from the media data plane needs
17704
+ * to know only WHAT EXISTS — the bytes then arrive per tile, lazily, over HTTP
17705
+ * with an immutable cache, instead of all at once inside a tRPC response that
17706
+ * blocks the whole view.
17707
+ *
17708
+ * `sizeBytes` is carried because it is what lets a client decide between the
17709
+ * stored blob and a `?variant=thumb` rendering without fetching either.
17710
+ */
17711
+ var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
17712
+ /**
17713
+ * The MACRO tier of an annotation — a CLOSED set.
17714
+ *
17715
+ * This is what the exported detector predicts, so a typo here is a new class
17716
+ * with one example in it. `label` and `subLabel` are open strings by contrast:
17717
+ * the whole point of the page is teaching the model things it does not know
17718
+ * yet, and constraining that vocabulary would make it useless.
17719
+ *
17720
+ * A macro class is NEVER a label. The provider refuses a write whose `label` or
17721
+ * `subLabel` is one of these values, in any casing, because once `person`
17722
+ * exists in both tiers "every person box" stops being answerable without
17723
+ * knowing every string anyone ever typed — and the damage is retroactive.
17724
+ */
17725
+ var RetrainMacroClassSchema = _enum([
17726
+ "person",
17727
+ "vehicle",
17728
+ "animal",
17729
+ "package",
17730
+ "face",
17731
+ "plate"
17732
+ ]);
17733
+ /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
17734
+ var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
17735
+ /** Did a human draw this box, or did the assist propose it? */
17736
+ var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
17737
+ /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
17738
+ var RetrainBboxSchema = object({
17739
+ x: number(),
17740
+ y: number(),
17741
+ w: number(),
17742
+ h: number()
17743
+ });
17744
+ /**
17745
+ * One annotated subject.
17746
+ *
17747
+ * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
17748
+ * (letterboxed root / zone-cropped package / subject-cropped classifier) are
17749
+ * derived from it at export and never stored — storing them is how one feature
17750
+ * space ends up holding two crops of the same subject (D52).
17751
+ */
17752
+ var RetrainAnnotationSchema = object({
17753
+ id: string$2(),
17639
17754
  trackId: string$2(),
17640
- frameId: string$2(),
17641
- annotations: array(RetrainAnnotationDraftSchema)
17642
- }), array(RetrainAnnotationSchema).readonly(), {
17643
- kind: "mutation",
17644
- auth: "admin"
17645
- }), method(object({
17646
- deviceId: number(),
17647
- trackId: string$2()
17648
- }), RetrainTransitionResultSchema, {
17649
- kind: "mutation",
17650
- auth: "admin"
17651
- }), method(object({
17652
17755
  deviceId: number(),
17653
- trackId: string$2()
17654
- }), RetrainTransitionResultSchema, {
17655
- kind: "mutation",
17656
- auth: "admin"
17657
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string$2() }), {
17658
- kind: "query",
17659
- auth: "admin"
17660
- }), method(object({
17661
- eventId: string$2(),
17662
- kind: MediaFileKindEnum.optional(),
17663
- deviceId: number()
17664
- }), array(MediaFileSchema).readonly()), method(object({
17665
- trackId: string$2(),
17666
- kinds: array(MediaFileKindEnum).optional(),
17667
- deviceId: number()
17668
- }), array(MediaFileSchema).readonly()), method(object({
17756
+ /** The COPY in retrain storage — never the source track's media key. */
17757
+ mediaKey: string$2(),
17758
+ bbox: RetrainBboxSchema,
17759
+ macroClass: RetrainMacroClassSchema,
17760
+ label: string$2().optional(),
17761
+ subLabel: string$2().optional(),
17762
+ kind: RetrainAnnotationKindSchema,
17763
+ source: RetrainAnnotationSourceSchema,
17764
+ /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
17765
+ assistModelId: string$2().optional(),
17766
+ assistScore: number().optional(),
17767
+ exportedInBatch: string$2().optional(),
17768
+ createdAt: number()
17769
+ });
17770
+ /** The write form — the server owns `id`, `createdAt` and the frame binding. */
17771
+ var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
17772
+ id: true,
17773
+ trackId: true,
17774
+ deviceId: true,
17775
+ mediaKey: true,
17776
+ createdAt: true,
17777
+ exportedInBatch: true
17778
+ });
17779
+ /** A track sitting in `staging`, with everything the worklist needs to rank it. */
17780
+ var RetrainTrackSchema = object({
17669
17781
  trackId: string$2(),
17670
- deviceId: number()
17671
- }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
17672
- kind: "mutation",
17673
- auth: "admin"
17674
- }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
17675
- kind: "mutation",
17676
- auth: "admin"
17677
- }), method(object({}), RebuildStatusSchema), object({
17678
17782
  deviceId: number(),
17783
+ className: string$2(),
17784
+ label: string$2().optional(),
17785
+ firstSeen: number(),
17786
+ lastSeen: number(),
17787
+ /** How many frames the dataset already holds from this track. */
17788
+ frameCount: number().int(),
17789
+ /** How many subjects have been annotated on those frames. `0` with
17790
+ * `frameCount: 0` is exactly "staging, still to work". */
17791
+ annotationCount: number().int()
17792
+ });
17793
+ /** A frame the picker may offer — an index row, no blob was read to produce it. */
17794
+ var RetrainFrameCandidateSchema = object({
17795
+ mediaKey: string$2(),
17796
+ kind: MediaFileKindEnum,
17679
17797
  timestamp: number(),
17680
- frameWidth: number(),
17681
- frameHeight: number(),
17682
- detections: array(OverlayDetectionSchema).readonly()
17683
- }), object({
17798
+ sizeBytes: number().int(),
17799
+ /** A copy of this original already exists — selecting it is free and cannot
17800
+ * fail, whatever became of the original. */
17801
+ copied: boolean()
17802
+ });
17803
+ /** A frame the dataset OWNS: bytes copied at selection time. */
17804
+ var RetrainFrameSchema = object({
17805
+ frameId: string$2(),
17684
17806
  deviceId: number(),
17685
17807
  trackId: string$2(),
17686
- className: string$2()
17808
+ /** Provenance only. It may already point at nothing — that is expected. */
17809
+ sourceMediaKey: string$2(),
17810
+ sourceKind: MediaFileKindEnum,
17811
+ sizeBytes: number().int(),
17812
+ width: number().int(),
17813
+ height: number().int(),
17814
+ copiedAt: number()
17815
+ });
17816
+ /** Why a copy-on-select could not be honoured — named, never a silent skip. */
17817
+ var RetrainCopyRefusalSchema = _enum([
17818
+ "source-missing",
17819
+ "unreadable-image",
17820
+ "write-failed"
17821
+ ]);
17822
+ var RetrainFrameSelectionSchema = object({
17823
+ copied: array(RetrainFrameSchema).readonly(),
17824
+ refused: array(object({
17825
+ sourceMediaKey: string$2(),
17826
+ reason: RetrainCopyRefusalSchema
17827
+ })).readonly()
17828
+ });
17829
+ var RetrainFrameListSchema = object({
17830
+ candidates: array(RetrainFrameCandidateSchema).readonly(),
17831
+ copies: array(RetrainFrameSchema).readonly(),
17832
+ /** What the page pre-selects — the native key frame when one survives. */
17833
+ autoPickMediaKey: string$2().optional()
17834
+ });
17835
+ /** What the operator asked the assist to look for. */
17836
+ var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
17837
+ kind: literal("package"),
17838
+ zone: RetrainBboxSchema.optional()
17687
17839
  }), object({
17688
- deviceId: number(),
17689
- trackId: string$2(),
17690
- className: string$2(),
17691
- durationMs: number()
17840
+ kind: literal("objects"),
17841
+ modelId: string$2(),
17842
+ minScore: number().optional()
17843
+ })]);
17844
+ /**
17845
+ * The assist's answer — a discriminated union, because "the model saw nothing"
17846
+ * and "this node cannot run that model" lead to different next moves and a
17847
+ * nullable result cannot tell them apart.
17848
+ */
17849
+ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
17850
+ kind: literal("proposed"),
17851
+ modelId: string$2(),
17852
+ stepId: string$2(),
17853
+ minScore: number(),
17854
+ /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
17855
+ proposals: array(RetrainAnnotationDraftSchema).readonly(),
17856
+ /** Returned by the runner but removed by the threshold. */
17857
+ belowThreshold: number().int()
17692
17858
  }), object({
17859
+ kind: literal("refused"),
17860
+ /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
17861
+ reason: string$2(),
17862
+ detail: string$2().optional()
17863
+ })]);
17864
+ /** The outcome of a lifecycle move owned by the retrain page. */
17865
+ var RetrainTransitionResultSchema = object({
17866
+ trackId: string$2(),
17867
+ /** Where the track ended up, whatever happened. */
17868
+ retrainStatus: RetrainStatusSchema,
17869
+ /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
17870
+ changed: boolean(),
17871
+ reason: _enum([
17872
+ "unknown-track",
17873
+ "no-frames-copied",
17874
+ "not-staging",
17875
+ "not-trained",
17876
+ "unchanged"
17877
+ ]).optional()
17878
+ });
17879
+ var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
17880
+ var MAX_EVENT_QUERY_LIMIT = 5e3;
17881
+ var DeviceEventQueryInput = object({
17693
17882
  deviceId: number(),
17694
- kind: EventKindSchema,
17695
- eventId: string$2(),
17696
- timestamp: number()
17883
+ since: number().optional(),
17884
+ until: number().optional(),
17885
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
17886
+ /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
17887
+ * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
17888
+ * exact behaviour. Callers may omit this field — the store defaults to
17889
+ * `full` when not provided. */
17890
+ projection: _enum(["full", "slim"]).optional()
17697
17891
  });
17698
- /**
17699
- * Reference to the frame's retained NATIVE surface + the parent crop's placement
17700
- * within the frame, so the executor can re-cut a leaf child ROI at native
17701
- * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
17702
- */
17703
- var NativeCropRefSchema = object({
17704
- /** Handle keying the retained native surface (node-pinned to its owner). */
17705
- handle: FrameHandleSchema,
17706
- /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
17707
- cropFrameSpace: object({
17708
- x: number(),
17709
- y: number(),
17710
- w: number(),
17711
- h: number()
17712
- })
17892
+ var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string$2().optional() });
17893
+ var RecentTracksQueryInput = object({
17894
+ /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
17895
+ deviceIds: array(number()),
17896
+ /** Window lower bound on `lastSeen` (inclusive). */
17897
+ since: number().optional(),
17898
+ /** Window upper bound on `lastSeen` (inclusive). */
17899
+ until: number().optional(),
17900
+ /** Page size. Default 200, max 1000. */
17901
+ limit: number().int().min(1).max(1e3).default(200),
17902
+ /** Opaque continuation cursor from a previous page's `nextCursor`.
17903
+ * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
17904
+ cursor: string$2().optional(),
17905
+ /** See {@link TrackProjectionSchema}. Default `full`. */
17906
+ projection: TrackProjectionSchema.optional(),
17907
+ /** Include stationary-promoted rows (parked objects). Default false: the
17908
+ * feed lists passages; parking records live on the stationary registry. */
17909
+ includeStationary: boolean().optional()
17713
17910
  });
17714
- object({
17715
- crop: object({
17716
- left: number(),
17717
- top: number(),
17718
- width: number().positive(),
17719
- height: number().positive()
17720
- }).optional(),
17721
- content: object({
17722
- width: number().int().positive(),
17723
- height: number().int().positive()
17724
- }),
17725
- fit: _enum(["stretch", "contain"]),
17726
- format: _enum([
17727
- "rgb",
17728
- "gray",
17729
- "jpeg"
17730
- ])
17911
+ var RecentTracksPageSchema = object({
17912
+ /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
17913
+ tracks: array(TrackSchema).readonly(),
17914
+ /** Cursor for the next page, or null when this page is the last. */
17915
+ nextCursor: string$2().nullable()
17731
17916
  });
17732
- var FrameRefSchema = object({
17733
- registryId: string$2().min(1),
17734
- id: string$2().min(1),
17735
- width: number().int().positive(),
17736
- height: number().int().positive(),
17737
- format: _enum(["rgb", "gray"]),
17738
- timestamp: number(),
17739
- capturedAt: number().optional()
17917
+ var LIST_GROUPS_DEFAULT_LIMIT = 40;
17918
+ var LIST_GROUPS_MAX_LIMIT = 100;
17919
+ var AnalyticsGroupRecordSchema = object({
17920
+ id: string$2(),
17921
+ deviceId: number().int(),
17922
+ openedAt: number().int(),
17923
+ closedAt: number().int(),
17924
+ timestamp: number().int(),
17925
+ memberCount: number().int(),
17926
+ memberTrackIds: array(string$2()).readonly(),
17927
+ className: string$2(),
17928
+ classes: array(string$2()).readonly(),
17929
+ /** Relative event-media path, or null when the group has no picture yet. */
17930
+ mediaUrl: string$2().nullable(),
17931
+ singleton: boolean()
17740
17932
  });
17741
- var ModelFormatSchema$1 = _enum([
17742
- "onnx",
17743
- "coreml",
17744
- "openvino",
17745
- "tflite",
17746
- "pt",
17747
- "gguf"
17748
- ]);
17749
- var PipelineSlotSchema = _enum([
17750
- "detector",
17751
- "cropper",
17752
- "classifier",
17753
- "refiner",
17754
- "audio-classifier"
17755
- ]);
17756
- var PipelineEngineChoiceSchema = object({
17757
- runtime: _enum(["node", "python"]),
17758
- backend: string$2(),
17759
- format: ModelFormatSchema$1,
17760
- device: string$2().optional()
17933
+ var AnalyticsGroupMemberSchema = object({
17934
+ trackId: string$2(),
17935
+ deviceId: number().int(),
17936
+ className: string$2(),
17937
+ firstSeen: number().int(),
17938
+ lastSeen: number().int(),
17939
+ mediaUrl: string$2().nullable()
17761
17940
  });
17762
- var AvailableEngineSchema = object({
17763
- engine: PipelineEngineChoiceSchema,
17764
- devices: array(object({
17765
- id: string$2(),
17766
- label: string$2(),
17767
- description: string$2().optional()
17768
- })).readonly(),
17769
- defaultDevice: string$2()
17941
+ var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
17942
+ var ListGroupsQueryInput = object({
17943
+ /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
17944
+ deviceIds: array(number()),
17945
+ /** Window lower bound on `closedAt` (inclusive). */
17946
+ since: number().optional(),
17947
+ /** Window upper bound on `openedAt` (inclusive). */
17948
+ until: number().optional(),
17949
+ limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
17950
+ /** Opaque continuation cursor from a previous page's `nextCursor`. */
17951
+ cursor: string$2().optional()
17770
17952
  });
17771
- var PipelineDefaultStepSchema = lazy(() => object({
17772
- addonId: string$2(),
17773
- addonName: string$2(),
17774
- slot: PipelineSlotSchema,
17775
- inputClasses: array(string$2()).readonly(),
17776
- outputClasses: array(string$2()).readonly(),
17777
- enabled: boolean(),
17778
- modelId: string$2(),
17779
- children: array(PipelineDefaultStepSchema).readonly(),
17780
- group: string$2().optional(),
17781
- settings: record(string$2(), unknown()).optional()
17782
- }));
17783
- var PipelineTemplateStepSchema = lazy(() => object({
17784
- addonId: string$2(),
17785
- enabled: boolean(),
17786
- modelId: string$2(),
17787
- children: array(PipelineTemplateStepSchema).readonly(),
17788
- settings: record(string$2(), unknown()).optional()
17789
- }));
17790
- var PipelineTemplateSchema$1 = object({
17791
- id: string$2(),
17792
- name: string$2(),
17793
- createdAt: string$2(),
17794
- updatedAt: string$2(),
17795
- engine: PipelineEngineChoiceSchema,
17796
- steps: array(PipelineTemplateStepSchema).readonly()
17953
+ var ListGroupsPageSchema = object({
17954
+ groups: array(AnalyticsGroupRecordSchema).readonly(),
17955
+ nextCursor: string$2().nullable()
17956
+ });
17957
+ var KeyEventQueryInput = object({
17958
+ deviceId: number(),
17959
+ /** Window lower bound (track firstSeen ≥ since). */
17960
+ since: number(),
17961
+ /** Window upper bound (track firstSeen ≤ until). */
17962
+ until: number(),
17963
+ limit: number().int().min(1).max(200).default(50),
17964
+ /** Drop tracks scoring below this importance. */
17965
+ minImportance: number().min(0).max(1).optional(),
17966
+ /** Restrict to a single class (e.g. 'person'). */
17967
+ classFilter: string$2().optional()
17797
17968
  });
17798
- var PipelineModelOptionSchema = object({
17969
+ var KeyEventSchema = object({
17970
+ /** The representative event id (the track's best ObjectEvent, else its trackId). */
17799
17971
  id: string$2(),
17800
- name: string$2(),
17801
- formats: record(string$2(), object({
17802
- downloaded: boolean(),
17803
- sizeMB: number()
17804
- })),
17805
- group: ModelVariantGroupSchema.optional(),
17806
- legacy: boolean().optional(),
17807
- provider: ModelProviderIdSchema.optional()
17972
+ trackId: string$2(),
17973
+ /** Track start time (firstSeen). */
17974
+ timestamp: number(),
17975
+ className: string$2(),
17976
+ ...TieredLabelFields,
17977
+ importance: number(),
17978
+ /** Highest-confidence ObjectEvent id for the track (empty when none). */
17979
+ bestEventId: string$2(),
17980
+ /** Track lifetime in ms (lastSeen - firstSeen). */
17981
+ windowMs: number().optional(),
17982
+ ...TrackFlagFields,
17983
+ ...TrackRetrainFields
17808
17984
  });
17809
- var ConfigFieldBridge = custom();
17810
- var PipelineAddonSchemaSchema = object({
17811
- id: string$2(),
17812
- name: string$2(),
17813
- slot: PipelineSlotSchema,
17814
- inputClasses: array(string$2()).readonly(),
17815
- outputClasses: array(string$2()).readonly(),
17816
- childSlots: array(PipelineSlotSchema).readonly(),
17817
- models: array(PipelineModelOptionSchema).readonly(),
17818
- defaultModelId: string$2(),
17819
- defaultModelIdByFormat: record(string$2(), string$2()).optional(),
17820
- enabledByDefault: boolean().optional(),
17821
- backfillIntoExistingOverrides: boolean().optional(),
17822
- defaultConfidence: number(),
17823
- group: string$2().optional(),
17824
- configSchema: array(ConfigFieldBridge).readonly().optional()
17985
+ object({
17986
+ trackId: string$2(),
17987
+ className: string$2(),
17988
+ confidence: number(),
17989
+ bbox: BoundingBoxSchema,
17990
+ zones: array(string$2()).readonly(),
17991
+ state: TrackStateSchema
17825
17992
  });
17826
- var PipelineSlotSchemaSchema = object({
17827
- id: PipelineSlotSchema,
17828
- label: string$2(),
17829
- priority: number(),
17830
- parentSlot: PipelineSlotSchema.nullable(),
17831
- addons: array(PipelineAddonSchemaSchema).readonly()
17993
+ var OverlayDetectionSchema = looseObject({
17994
+ id: string$2(),
17995
+ kind: _enum(["first-level", "detail"]),
17996
+ macroClass: string$2(),
17997
+ score: number(),
17998
+ bbox: object({
17999
+ x: number(),
18000
+ y: number(),
18001
+ width: number(),
18002
+ height: number()
18003
+ }),
18004
+ labels: array(looseObject({
18005
+ label: string$2(),
18006
+ score: number()
18007
+ })).readonly(),
18008
+ parentId: string$2().optional()
17832
18009
  });
17833
- var PipelineSchemaSchema = object({
17834
- availableEngines: array(AvailableEngineSchema).readonly(),
17835
- selectedEngine: PipelineEngineChoiceSchema,
17836
- slots: array(PipelineSlotSchemaSchema).readonly()
18010
+ var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
18011
+ var SearchObjectEventsInput = object({
18012
+ text: string$2(),
18013
+ deviceId: number().optional(),
18014
+ since: number().optional(),
18015
+ until: number().optional(),
18016
+ classFilter: string$2().optional(),
18017
+ limit: number().default(50),
18018
+ minScore: number().min(0).max(1).default(.2)
17837
18019
  });
17838
- var EngineProvisioningSchema = object({
17839
- runtimeId: _enum([
17840
- "onnx",
17841
- "openvino",
17842
- "coreml",
17843
- "edgetpu"
17844
- ]).nullable(),
17845
- device: string$2().nullable(),
17846
- state: _enum([
17847
- "idle",
17848
- "installing",
17849
- "verifying",
17850
- "ready",
17851
- "failed"
17852
- ]),
17853
- progress: number().optional(),
17854
- error: string$2().optional(),
17855
- nextRetryAt: number().optional(),
17856
- /**
17857
- * Gate A (config-correctness gate at engine change): human-readable
17858
- * config issues surfaced EAGERLY when the node's engine changes — model
17859
- * substitutions ("chose X, running Y") and zero-build steps ("no model
17860
- * has a <format> build"). Additive/optional: informational only, never
17861
- * enforced here — `assertEngineReady` (readiness) still gates inference.
17862
- * Absent/empty when the node-default tree resolves cleanly.
17863
- */
17864
- configIssues: array(string$2()).optional()
18020
+ var TrackCascadeCountsSchema = object({
18021
+ /** Persisted track roots deleted (authoritative). */
18022
+ tracks: number().int(),
18023
+ /** Object events removed with their tracks (best-effort; see note above). */
18024
+ events: number().int(),
18025
+ /** Track/face/plate-owned media removed (best-effort). Never identity media. */
18026
+ media: number().int(),
18027
+ /** Unassigned (non-enrolled) face reads removed (best-effort). */
18028
+ faces: number().int(),
18029
+ /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
18030
+ plates: number().int(),
18031
+ /** Per-track CLIP search vectors removed (best-effort). */
18032
+ embeddings: number().int(),
18033
+ /** Group membership + group rows removed with their last member (best-effort). */
18034
+ groups: number().int()
17865
18035
  });
17866
- var PipelineStepInputSchema = lazy(() => object({
17867
- addonId: string$2(),
17868
- modelId: string$2().optional(),
17869
- enabled: boolean().default(true),
17870
- children: array(PipelineStepInputSchema).optional(),
17871
- settings: record(string$2(), unknown()).optional(),
17872
- jumpDeviceKey: string$2().optional()
17873
- }));
17874
- var ModelSubstitutionSchema = object({
17875
- addonId: string$2(),
17876
- chosen: string$2(),
17877
- running: string$2(),
17878
- format: string$2()
18036
+ /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
18037
+ var DiskReconcileCountsSchema = object({
18038
+ mediaDropped: number().int(),
18039
+ tracks: number().int(),
18040
+ events: number().int()
17879
18041
  });
17880
- var PipelineValidationIssueSchema = object({
17881
- addonId: string$2(),
17882
- kind: _enum(["unknown-addon", "no-format-build"]),
17883
- detail: string$2()
18042
+ /** Event-store footprint for one camera. */
18043
+ var EventStoreDeviceFootprintSchema = object({
18044
+ deviceId: number(),
18045
+ /** Persisted event rows (motion + object + audio) for the camera. */
18046
+ rows: number().int(),
18047
+ /** Event-owned media bytes on disk for the camera. */
18048
+ bytes: number().int()
17884
18049
  });
17885
- var PipelineValidationResultSchema = object({
17886
- ok: boolean(),
17887
- issues: array(PipelineValidationIssueSchema).readonly(),
17888
- substitutions: array(ModelSubstitutionSchema).readonly(),
17889
- /** The node's `currentEngine.format` this validation ran against. */
17890
- format: string$2()
18050
+ /** Aggregate event-store footprint: global totals + per-camera breakdown. */
18051
+ var EventStoreFootprintSchema = object({
18052
+ totalRows: number().int(),
18053
+ totalBytes: number().int(),
18054
+ devices: array(EventStoreDeviceFootprintSchema).readonly()
17891
18055
  });
17892
- var ReferenceImageEntrySchema = object({
17893
- filename: string$2(),
17894
- stepIds: array(string$2()).readonly().optional()
18056
+ /** Per-kind counts returned by the event-prune / device-delete mutations. */
18057
+ var EventPruneCountsSchema = object({
18058
+ motion: number().int(),
18059
+ object: number().int(),
18060
+ audio: number().int()
17895
18061
  });
17896
- var ReferenceImageBodySchema = object({
17897
- base64: string$2(),
17898
- filename: string$2()
18062
+ /**
18063
+ * Re-embed stored tracks from their key frames.
18064
+ *
18065
+ * The reason this is an operator-callable method and not a migration script:
18066
+ * every knob that decides what a vector MEANS — encoder model, crop margin,
18067
+ * squaring — is only changeable if the existing vectors can be regenerated.
18068
+ * Mixing feature spaces in one index makes cosine scores incomparable, and the
18069
+ * symptom is a quality regression with no visible cause.
18070
+ */
18071
+ var RebuildObjectEmbeddingsInput = object({
18072
+ /** Restrict to one camera. Omit for the whole fleet. */
18073
+ deviceId: number().optional(),
18074
+ since: number().optional(),
18075
+ until: number().optional(),
18076
+ /** Stop after this many tracks; the result reports whether more remain. */
18077
+ maxTracks: number().int().positive().optional(),
18078
+ /**
18079
+ * Run every embedding on THIS node instead of round-robining the fleet.
18080
+ *
18081
+ * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
18082
+ * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
18083
+ * calling it that would pin the rebuild REQUEST itself to that node — the
18084
+ * rebuild orchestration lives on the hub, and only the per-track step runs
18085
+ * remotely. This field is data; the per-track pin is applied inside.
18086
+ *
18087
+ * Absent ⇒ round-robin over every online node whose runner can serve the
18088
+ * pinned model.
18089
+ */
18090
+ executeOnNodeId: string$2().optional(),
18091
+ /**
18092
+ * Milliseconds to wait between tracks; omit for the built-in default, `0` to
18093
+ * run flat out.
18094
+ *
18095
+ * A rebuild is bulk maintenance on hub-main's single thread. Measured
18096
+ * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
18097
+ * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
18098
+ * force is logged at start and finish so a deliberately slow pass reads
18099
+ * differently from a stalled one.
18100
+ */
18101
+ pacingMs: number().int().nonnegative().optional()
17899
18102
  });
17900
- var ReferenceAudioEntrySchema = object({
17901
- filename: string$2(),
17902
- sizeKb: number()
18103
+ /**
18104
+ * Result of emptying the CLIP index.
18105
+ *
18106
+ * The clean slate before a policy change: a new crop margin or encoder model
18107
+ * leaves two feature spaces in one index whose cosine scores are not
18108
+ * comparable, so wiping and rebuilding is the only way to be sure every vector
18109
+ * means the same thing.
18110
+ */
18111
+ var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
18112
+ /**
18113
+ * Acknowledgement that a rebuild STARTED.
18114
+ *
18115
+ * The pass costs ~1s per track — 45 minutes for a 2,600-track fleet — so it
18116
+ * runs detached and this returns immediately. Waiting for it made the client
18117
+ * time out while the work carried on server-side, which is the worst of both:
18118
+ * no result and no way to know it was still going. Poll
18119
+ * `getObjectEmbeddingRebuildStatus` for progress.
18120
+ */
18121
+ var RebuildObjectEmbeddingsResultSchema = object({
18122
+ started: boolean(),
18123
+ /** True when a pass was already running; the new request is ignored. */
18124
+ alreadyRunning: boolean()
17903
18125
  });
17904
- var ReferenceAudioBodySchema = object({ base64: string$2() });
17905
- var AudioBackendSchema = object({
17906
- id: string$2(),
17907
- name: string$2(),
17908
- description: string$2(),
17909
- available: boolean(),
18126
+ var RebuildStatusSchema = object({
18127
+ running: boolean(),
18128
+ scanned: number(),
18129
+ rebuilt: number(),
18130
+ /** Tracks whose key frame is gone — nothing to re-embed from. */
18131
+ missingKeyFrame: number(),
18132
+ /** Tracks with no usable detection box. */
18133
+ missingBbox: number(),
18134
+ /**
18135
+ * Tracks an executing node REFUSED rather than broke on — an unreadable key
18136
+ * frame, a step that threw. Separate from `failed` because the remedy is
18137
+ * different, and because a whole camera silently contributing zero vectors
18138
+ * is the shape of failure a rebuild must never hide.
18139
+ */
18140
+ notRunnable: number(),
17910
18141
  /**
17911
- * Raw classifier labels this backend can emit (e.g. YAMNet's
17912
- * 521-class set or Apple SoundAnalysis's 303-class set). Used by
17913
- * the benchmark UI to populate the `enabledMicroClasses` filter
17914
- * specific to the selected backend without a separate fetch.
18142
+ * The pass stopped because NO node could serve the pinned model.
18143
+ *
18144
+ * Distinct from `notRunnable` on purpose: that one says "this track was
18145
+ * refused", this one says "the cluster cannot do this work at all" — every
18146
+ * candidate node either lacks the `clip-embedding` step, lacks a build of the
18147
+ * pinned model for its engine format, or dropped out. The remedy is a model /
18148
+ * engine change, not a per-camera one. Non-zero here always comes with
18149
+ * `complete: false`.
17915
18150
  */
17916
- rawLabels: array(string$2()).readonly().optional()
17917
- });
17918
- var AudioCapabilitiesSchema = object({
17919
- activeBackend: string$2(),
17920
- availableBackends: array(AudioBackendSchema).readonly(),
17921
- sampleRate: number(),
17922
- chunkDurationMs: number()
17923
- });
17924
- var DownloadModelResultSchema = object({
17925
- filePath: string$2(),
17926
- sizeMB: number(),
17927
- durationMs: number()
18151
+ noCapableNode: number(),
18152
+ failed: number(),
18153
+ /** Set once a pass ends: true only when EVERYTHING was covered. */
18154
+ complete: boolean().nullable(),
18155
+ startedAtMs: number().nullable(),
18156
+ finishedAtMs: number().nullable(),
18157
+ /** Present when the pass ended by throwing. */
18158
+ error: string$2().nullable()
17928
18159
  });
17929
- /**
17930
- * Wrapper carrying a single test run's result. Replaces the legacy
17931
- * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
17932
- * canonical `AudioResult` from the Phase 6 output rework: one
17933
- * `AudioDetection` per class above `minScore`, top-N candidates in
17934
- * `debug.alternateLabels['audio-classifier']`, per-source timings in
17935
- * `debug.stepTimings`. The outer `success`/`error` fields stay so the
17936
- * benchmark UI can still report a clean failure when the classifier
17937
- * cap isn't available.
17938
- */
17939
- var AudioTestResultSchema = object({
17940
- success: boolean(),
17941
- error: string$2().optional(),
17942
- frame: custom().optional()
18160
+ var ReplayFrameInputSchema = object({
18161
+ timestamp: number(),
18162
+ frame: PipelineRunResultBridge
17943
18163
  });
17944
- var PipelineConfigBridge = custom();
17945
- var ConfigUISchemaBridge = custom();
17946
- var ConfigUISchemaNullableBridge = custom();
17947
- var InferenceCapabilitiesBridge = custom();
17948
- var ModelAvailabilityListBridge = custom();
17949
- var PipelineRunResultBridge = custom();
17950
- method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string$2() }), EngineProvisioningSchema), method(_void(), record(string$2(), object({
17951
- modelId: string$2(),
17952
- settings: record(string$2(), unknown()).readonly()
17953
- }))), method(object({ steps: record(string$2(), object({
17954
- modelId: string$2(),
17955
- settings: record(string$2(), unknown()).readonly()
17956
- })) }), object({ success: literal(true) }), {
18164
+ var RunReplayFrameProcessorResultSchema = object({ tracks: array(object({
18165
+ className: string$2(),
18166
+ firstSeenMs: number(),
18167
+ lastSeenMs: number(),
18168
+ /** Bbox of the track's FIRST matched detection, pixel-space in the clip's
18169
+ * frame a representative box for the diff's `(className, window, IoU)`
18170
+ * pairing (`replay-diff.ts`). A replay does not need the full per-frame
18171
+ * trajectory production's `Track.positions` keeps. */
18172
+ bbox: BoundingBoxSchema,
18173
+ /** How many of the input frames this track matched a real detection on
18174
+ * (never a coasted/extrapolated frame) — the replay's own signal for "how
18175
+ * solid is this track", cheaper than re-deriving it from a trajectory. */
18176
+ framesMatched: number().int()
18177
+ })).readonly() });
18178
+ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
18179
+ deviceId: number(),
18180
+ trackId: string$2()
18181
+ }), TrackSchema.nullable()), method(object({
18182
+ deviceId: number(),
18183
+ since: number().optional(),
18184
+ until: number().optional(),
18185
+ limit: number().optional(),
18186
+ /** Spatial filter — only tracks whose trajectory intersects the zone
18187
+ * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
18188
+ * envelope columns, then precisely tested per position. Tracks with
18189
+ * an unknown envelope (no frame dims at persist time) always match. */
18190
+ zone: TrackZoneFilterSchema.optional(),
18191
+ /** See {@link TrackProjectionSchema}. Default `full` (backward
18192
+ * compatible — omitting the field keeps today's exact behaviour). */
18193
+ projection: TrackProjectionSchema.optional(),
18194
+ /** Include stationary-promoted rows (parked objects handed to the
18195
+ * stationary registry). Default false: the timeline lists passages,
18196
+ * not parking records (operator decision, 2026-08-15). */
18197
+ includeStationary: boolean().optional()
18198
+ }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
18199
+ deviceId: number(),
18200
+ groupId: string$2().min(1)
18201
+ }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
18202
+ kind: "mutation",
18203
+ auth: "admin"
18204
+ }), 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({
18205
+ deviceId: number(),
18206
+ since: number().optional(),
18207
+ until: number().optional(),
18208
+ kinds: array(string$2()).optional(),
18209
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
18210
+ }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
18211
+ deviceId: number(),
18212
+ since: number(),
18213
+ until: number(),
18214
+ bucketMs: number().int().positive()
18215
+ }), array(object({
18216
+ bucketStart: number(),
18217
+ motion: number().int(),
18218
+ object: number().int(),
18219
+ audio: number().int()
18220
+ })).readonly()), method(object({
18221
+ deviceId: number(),
18222
+ cutoffMs: number()
18223
+ }), object({
18224
+ motion: number().int(),
18225
+ object: number().int(),
18226
+ audio: number().int()
18227
+ }), {
18228
+ kind: "mutation",
18229
+ auth: "admin"
18230
+ }), method(object({
18231
+ deviceId: number(),
18232
+ cutoffMs: number()
18233
+ }), TrackCascadeCountsSchema, {
18234
+ kind: "mutation",
18235
+ auth: "admin"
18236
+ }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
18237
+ kind: "mutation",
18238
+ auth: "admin"
18239
+ }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
18240
+ kind: "mutation",
18241
+ auth: "admin"
18242
+ }), method(object({
18243
+ deviceId: number(),
18244
+ trackIds: array(string$2()).min(1)
18245
+ }), object({
18246
+ deleted: number().int(),
18247
+ failed: array(string$2()).readonly()
18248
+ }), {
18249
+ kind: "mutation",
18250
+ auth: "admin"
18251
+ }), method(object({
18252
+ /** Log/audit scope only — the trackId is globally unique on its own. */
18253
+ deviceId: number(),
18254
+ trackId: string$2(),
18255
+ flags: TrackFlagsPatchSchema
18256
+ }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
18257
+ kind: "query",
18258
+ auth: "admin"
18259
+ }), method(object({
18260
+ olderThanMs: number(),
18261
+ reason: OpsLogReasonSchema.optional()
18262
+ }), EventPruneCountsSchema, {
18263
+ kind: "mutation",
18264
+ auth: "admin"
18265
+ }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
18266
+ kind: "mutation",
18267
+ auth: "admin"
18268
+ }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
18269
+ kind: "mutation",
18270
+ auth: "admin"
18271
+ }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
18272
+ kind: "mutation",
18273
+ auth: "admin"
18274
+ }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
18275
+ kind: "mutation",
18276
+ auth: "admin"
18277
+ }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string$2() }), {
18278
+ kind: "mutation",
18279
+ auth: "admin"
18280
+ }), method(object({ jobId: string$2() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string$2() }), object({ cancelled: boolean() }), {
18281
+ kind: "mutation",
18282
+ auth: "admin"
18283
+ }), method(RelocateMediaInputSchema, object({ jobId: string$2() }), {
18284
+ kind: "mutation",
18285
+ auth: "admin"
18286
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
18287
+ kind: "query",
18288
+ auth: "admin"
18289
+ }), method(object({ jobId: string$2() }), object({ cancelled: boolean() }), {
18290
+ kind: "mutation",
18291
+ auth: "admin"
18292
+ }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
18293
+ kind: "query",
18294
+ auth: "admin"
18295
+ }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
18296
+ kind: "query",
18297
+ auth: "admin"
18298
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string$2() }), {
18299
+ kind: "query",
18300
+ auth: "admin"
18301
+ }), method(object({
18302
+ /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
18303
+ * `deviceId`, deliberately: `deviceId` would make this device-bound and
18304
+ * route it at one camera's owner, and "every camera" would stop being
18305
+ * expressible at all. */
18306
+ deviceIds: array(number()).optional(),
18307
+ limit: number().int().min(1).max(500).optional()
18308
+ }), array(RetrainTrackSchema).readonly(), {
18309
+ kind: "query",
18310
+ auth: "admin"
18311
+ }), method(object({ trackId: string$2() }), RetrainFrameListSchema, {
18312
+ kind: "query",
18313
+ auth: "admin"
18314
+ }), method(object({
18315
+ deviceId: number(),
18316
+ trackId: string$2(),
18317
+ mediaKeys: array(string$2()).min(1)
18318
+ }), RetrainFrameSelectionSchema, {
18319
+ kind: "mutation",
18320
+ auth: "admin"
18321
+ }), method(object({
18322
+ deviceId: number(),
18323
+ trackId: string$2(),
18324
+ frameId: string$2()
18325
+ }), object({
18326
+ removed: boolean(),
18327
+ removedAnnotations: number().int()
18328
+ }), {
18329
+ kind: "mutation",
18330
+ auth: "admin"
18331
+ }), method(object({ frameId: string$2() }), object({
18332
+ base64: string$2(),
18333
+ width: number().int(),
18334
+ height: number().int()
18335
+ }), {
18336
+ kind: "query",
18337
+ auth: "admin"
18338
+ }), method(object({
18339
+ deviceId: number(),
18340
+ trackId: string$2(),
18341
+ frameId: string$2(),
18342
+ subject: RetrainAssistSubjectSchema,
18343
+ /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
18344
+ nodeId: string$2().optional()
18345
+ }), RetrainAssistResultSchema, {
18346
+ kind: "mutation",
18347
+ auth: "admin"
18348
+ }), method(object({
18349
+ deviceId: number(),
18350
+ source: DetectionSourceSchema,
18351
+ zones: array(ZoneSchema).readonly().optional(),
18352
+ detectionRules: array(ZoneRuleSchema).readonly().optional(),
18353
+ zoneMembershipMinOverlap: number().min(0).max(1).optional(),
18354
+ frames: array(ReplayFrameInputSchema).min(1)
18355
+ }), RunReplayFrameProcessorResultSchema, {
18356
+ kind: "mutation",
18357
+ auth: "admin"
18358
+ }), method(object({ trackId: string$2() }), array(RetrainAnnotationSchema).readonly(), {
18359
+ kind: "query",
18360
+ auth: "admin"
18361
+ }), method(object({
18362
+ deviceId: number(),
18363
+ trackId: string$2(),
18364
+ frameId: string$2(),
18365
+ annotations: array(RetrainAnnotationDraftSchema)
18366
+ }), array(RetrainAnnotationSchema).readonly(), {
18367
+ kind: "mutation",
18368
+ auth: "admin"
18369
+ }), method(object({
18370
+ deviceId: number(),
18371
+ trackId: string$2()
18372
+ }), RetrainTransitionResultSchema, {
17957
18373
  kind: "mutation",
17958
18374
  auth: "admin"
17959
- }), method(object({ nodeId: string$2() }), object({
17960
- success: literal(true),
17961
- clearedDevices: number()
17962
- }), {
18375
+ }), method(object({
18376
+ deviceId: number(),
18377
+ trackId: string$2()
18378
+ }), RetrainTransitionResultSchema, {
17963
18379
  kind: "mutation",
17964
18380
  auth: "admin"
17965
- }), 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({
17966
- name: string$2(),
17967
- steps: array(PipelineTemplateStepSchema).readonly(),
17968
- engine: PipelineEngineChoiceSchema
17969
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
17970
- id: string$2(),
17971
- name: string$2().optional(),
17972
- steps: array(PipelineTemplateStepSchema).readonly().optional()
17973
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string$2() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string$2() }), ModelAvailabilityListBridge), method(object({
17974
- addonId: string$2(),
17975
- modelId: string$2(),
17976
- format: ModelFormatSchema$1
17977
- }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
17978
- addonId: string$2(),
17979
- modelId: string$2(),
17980
- format: ModelFormatSchema$1
17981
- }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
17982
- engine: PipelineEngineChoiceSchema.optional(),
17983
- steps: array(PipelineStepInputSchema).min(1),
17984
- frame: FrameInputSchema.optional(),
17985
- /**
17986
- * Process-local lazy frame. Valid only when caller and provider resolve
17987
- * in the same execution-group process; split/cross-node callers use
17988
- * `frame`/`image` inline compatibility instead.
17989
- */
17990
- frameRef: FrameRefSchema.optional(),
17991
- /**
17992
- * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
17993
- * the decoded pixels live in. One more member of the one-of
17994
- * frame/frameHandle/image/imageBase64/referenceImage group.
17995
- */
17996
- frameHandle: FrameHandleSchema.optional(),
17997
- imageBase64: string$2().optional(),
17998
- /**
17999
- * Binary JPEG bytes — preferred over `imageBase64` on internal
18000
- * hops (hub → forked worker via Moleculer MsgPack) because it
18001
- * skips the 33% base64 overhead + the per-call base64 decode on
18002
- * the detection-pipeline worker. Callers can pass either; exactly
18003
- * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
18004
- */
18005
- image: _instanceof(Uint8Array).optional(),
18006
- referenceImage: string$2().optional(),
18007
- deviceId: number().optional(),
18008
- sessionId: string$2().optional(),
18009
- /**
18010
- * Execution plane. 'full' (default) runs the whole tree — benchmark,
18011
- * reference-image, and detail-subtree calls. 'frame' is the live
18012
- * per-frame dispatch: ONLY root-plane steps run; crop children
18013
- * (inputClasses ≠ null) are skipped and served per-track via
18014
- * pipelineRunner.runDetailSubtree (two-plane design).
18015
- */
18016
- plane: _enum(["full", "frame"]).optional(),
18017
- /**
18018
- * Inference-device selector (Phase 2 multi-device). Format
18019
- * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
18020
- * Omitted ⇒ the runner's default device (current single-engine
18021
- * behaviour). Selects WHICH device pool of the node runs the call.
18022
- */
18023
- deviceKey: string$2().optional(),
18024
- /**
18025
- * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
18026
- * when the parent crop was resolved from the frame's retained NATIVE
18027
- * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
18028
- * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
18029
- * resolution from that surface — the SAME quality path faces already
18030
- * had — instead of the downscaled parent tile. `handle` keys the native
18031
- * surface (node-pinned to its owner); `cropFrameSpace` is the parent
18032
- * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
18033
- * the executor's crop-normalized child ROI back into frame-normalized
18034
- * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
18035
- * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
18036
- * (today's behaviour on the fallback path).
18037
- */
18038
- nativeCropRef: NativeCropRefSchema.optional()
18039
- }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
18040
- engine: PipelineEngineChoiceSchema.optional(),
18041
- steps: array(PipelineStepInputSchema).min(1),
18042
- frames: array(FrameInputSchema).min(1).max(255),
18043
- deviceId: number().optional(),
18044
- sessionId: string$2().optional(),
18045
- /**
18046
- * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
18047
- * the batch to the Python pool's bench preprocess cache
18048
- * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
18049
- * preprocessed ONCE and every later inference is a pure-inference cache
18050
- * hit — the sustained-throughput run measures inference, not
18051
- * decode+preprocess+infer. Omitted/0 for live frames (all different →
18052
- * full preprocess every call, correct). Fresh per sustained run;
18053
- * released via `uncacheFrame`.
18054
- */
18055
- frameId: number().int().nonnegative().optional(),
18056
- /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
18057
- deviceKey: string$2().optional()
18058
- }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
18059
- data: _instanceof(Uint8Array),
18060
- width: number().int().positive(),
18061
- height: number().int().positive(),
18062
- format: _enum([
18063
- "rgb",
18064
- "bgr",
18065
- "gray"
18066
- ])
18067
- }), object({
18068
- frameId: number(),
18069
- width: number(),
18070
- height: number()
18071
- }), { kind: "mutation" }), method(object({
18072
- stepId: string$2(),
18073
- frameId: number().int()
18074
- }), record(string$2(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
18075
- batchMode: string$2(),
18076
- windowMs: number(),
18077
- maxBatchSize: number(),
18078
- concurrency: number()
18079
- })), method(_void(), array(object({
18080
- engineKey: string$2(),
18081
- engine: PipelineEngineChoiceSchema,
18082
- modelsLoaded: array(string$2()).readonly(),
18083
- inUseByCameras: array(number()).readonly(),
18084
- /**
18085
- * Origin of this resident factory.
18086
- * - `runtime` — main camera-serving engine (no idle TTL).
18087
- * - `warm-override` — benchmark/test override held in the warm
18088
- * cache; auto-disposed after the idle TTL.
18089
- * - `device-pool` — a concurrent per-device pool (Phase 2
18090
- * multi-device, keyed by `deviceKey`) resolved
18091
- * via `resolveDeviceFactory`. Runs alongside the
18092
- * `runtime` engine on a DIFFERENT accelerator
18093
- * (NPU / iGPU / Coral) — this is how the
18094
- * Engines tab shows all pools running at once.
18095
- */
18096
- kind: _enum([
18097
- "runtime",
18098
- "warm-override",
18099
- "device-pool"
18100
- ]),
18101
- /** Native pid of the underlying Python pool (null when no pool). */
18102
- poolPid: number().nullable(),
18103
- /** ms since this factory was last used (null when not warm-tracked). */
18104
- idleMs: number().nullable(),
18105
- /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
18106
- idleTtlMs: number().nullable()
18107
- })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
18108
- kind: "mutation",
18381
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string$2() }), {
18382
+ kind: "query",
18109
18383
  auth: "admin"
18110
18384
  }), method(object({
18111
- engine: PipelineEngineChoiceSchema,
18112
- force: boolean().optional()
18113
- }), object({
18114
- success: boolean(),
18115
- reason: string$2().optional()
18116
- }), {
18385
+ eventId: string$2(),
18386
+ kind: MediaFileKindEnum.optional(),
18387
+ deviceId: number()
18388
+ }), array(MediaFileSchema).readonly()), method(object({
18389
+ trackId: string$2(),
18390
+ kinds: array(MediaFileKindEnum).optional(),
18391
+ deviceId: number()
18392
+ }), array(MediaFileSchema).readonly()), method(object({
18393
+ trackId: string$2(),
18394
+ deviceId: number()
18395
+ }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
18117
18396
  kind: "mutation",
18118
18397
  auth: "admin"
18119
- }), method(_void(), array(ReferenceImageEntrySchema).readonly()), method(object({ filename: string$2() }), ReferenceImageBodySchema.nullable()), method(_void(), array(ReferenceAudioEntrySchema).readonly()), method(object({ filename: string$2() }), ReferenceAudioBodySchema.nullable()), method(_void(), AudioCapabilitiesSchema), method(object({
18120
- addonId: string$2(),
18121
- modelId: string$2(),
18122
- filename: string$2().optional(),
18123
- settings: record(string$2(), unknown()).optional()
18124
- }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
18398
+ }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
18399
+ kind: "mutation",
18400
+ auth: "admin"
18401
+ }), method(object({}), RebuildStatusSchema), object({
18402
+ deviceId: number(),
18403
+ timestamp: number(),
18404
+ frameWidth: number(),
18405
+ frameHeight: number(),
18406
+ detections: array(OverlayDetectionSchema).readonly()
18407
+ }), object({
18408
+ deviceId: number(),
18409
+ trackId: string$2(),
18410
+ className: string$2()
18411
+ }), object({
18412
+ deviceId: number(),
18413
+ trackId: string$2(),
18414
+ className: string$2(),
18415
+ durationMs: number()
18416
+ }), object({
18417
+ deviceId: number(),
18418
+ kind: EventKindSchema,
18419
+ eventId: string$2(),
18420
+ timestamp: number()
18421
+ });
18125
18422
  object({
18126
18423
  activeCameras: number(),
18127
18424
  throttledCameras: number(),
@@ -18133,119 +18430,19 @@ var CameraMetricsSchema = object({
18133
18430
  "disabled",
18134
18431
  "always-on",
18135
18432
  "on-motion"
18136
- ]),
18137
- configuredFps: number(),
18138
- actualFps: number(),
18139
- queueDepth: number(),
18140
- avgInferenceTimeMs: number(),
18141
- droppedFrames: number(),
18142
- phase: _enum([
18143
- "idle",
18144
- "watching",
18145
- "active"
18146
- ])
18147
- });
18148
- var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
18149
- /**
18150
- * Zone — pure geometry + identity. NO filtering behaviour.
18151
- *
18152
- * Zones describe **where** in the frame the operator wants to flag
18153
- * something; consumer-owned {@link ZoneRule} arrays describe **how**
18154
- * each pipeline stage uses them. Splitting the two means a single
18155
- * polygon "Driveway" can simultaneously back a motion-exclude rule,
18156
- * a detection-include rule on `['car']`, and an occupancy aggregate
18157
- * — without three duplicated polygons.
18158
- *
18159
- * Owned by the orchestrator addon (provider) and mirrored into the
18160
- * `zones` device-state slice on every mutation. Consumers
18161
- * (motion-wasm, pipeline-executor, analytics, admin UI) read either
18162
- * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
18163
- * mirror with `onChanged`).
18164
- *
18165
- * Coordinates are normalised fractions of the frame (0–1) so zones
18166
- * survive resolution changes and stream profile switches.
18167
- *
18168
- * `kind` discriminates between full polygons (closed regions used
18169
- * for intrusion / occupancy filters) and tripwires (open 2-point
18170
- * line segments used for cross events). Onboard / firmware-reported
18171
- * zones (Reolink, ONVIF) are out of scope for now — see the deferred
18172
- * task list.
18173
- */
18174
- var ZoneKindEnum = _enum(["polygon", "tripwire"]);
18175
- /** Polygon vertex in fraction-of-frame coordinates (0–1). */
18176
- var PolygonPointSchema = object({
18177
- x: number(),
18178
- y: number()
18179
- });
18180
- /** A camera detection zone — pure geometry/identity. */
18181
- var ZoneSchema = object({
18182
- id: string$2(),
18183
- name: string$2(),
18184
- kind: ZoneKindEnum.default("polygon"),
18185
- /** Polygon vertices, fraction of frame (0–1). */
18186
- polygon: array(PolygonPointSchema).readonly(),
18187
- /** Visual color for UI rendering. */
18188
- color: string$2().default("#3b82f6")
18433
+ ]),
18434
+ configuredFps: number(),
18435
+ actualFps: number(),
18436
+ queueDepth: number(),
18437
+ avgInferenceTimeMs: number(),
18438
+ droppedFrames: number(),
18439
+ phase: _enum([
18440
+ "idle",
18441
+ "watching",
18442
+ "active"
18443
+ ])
18189
18444
  });
18190
- /**
18191
- * Zones capability — per-camera CRUD over polygon detection zones.
18192
- *
18193
- * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
18194
- * to per-device settings and mirrors into the `zones` device-state
18195
- * slice on every mutation, so downstream consumers can subscribe via
18196
- * `dev.state.zones.onChanged`.
18197
- *
18198
- * The cap surface only handles geometry + identity; filtering
18199
- * behaviour (per-class, include/exclude, threshold) lives in the
18200
- * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
18201
- * `capabilities/schemas/zone-rule.js`.
18202
- */
18203
- var zonesCapability = {
18204
- name: "zones",
18205
- scope: "device",
18206
- mode: "singleton",
18207
- deviceTypes: [DeviceType.Camera],
18208
- methods: {
18209
- listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
18210
- addZone: method(object({
18211
- deviceId: number(),
18212
- zone: ZoneSchema
18213
- }), _void(), {
18214
- kind: "mutation",
18215
- auth: "admin"
18216
- }),
18217
- removeZone: method(object({
18218
- deviceId: number(),
18219
- zoneId: string$2()
18220
- }), _void(), {
18221
- kind: "mutation",
18222
- auth: "admin"
18223
- }),
18224
- updateZone: method(object({
18225
- deviceId: number(),
18226
- zone: ZoneSchema
18227
- }), _void(), {
18228
- kind: "mutation",
18229
- auth: "admin"
18230
- })
18231
- },
18232
- /**
18233
- * Runtime-state slice — the live zone catalogue mirrored by the
18234
- * orchestrator on every CRUD mutation. Consumers read via
18235
- * `device.state.zones.value` / `.watch(...)` without round-tripping
18236
- * the cap, and the codegen DeviceProxy auto-wires the reactive
18237
- * handle. Slice shape is `{ zones: Zone[] }` so future extensions
18238
- * (e.g. zone groupings) can sit alongside the polygon list.
18239
- */
18240
- runtimeState: object({ zones: array(ZoneSchema).readonly() }),
18241
- /**
18242
- * 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.
18243
- *
18244
- * See `RuntimeStateDurability`. Enforced by
18245
- * `scripts/check-runtime-state-durability.ts`.
18246
- */
18247
- durability: "restored"
18248
- };
18445
+ var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
18249
18446
  /**
18250
18447
  * A bounding box in NORMALIZED [0,1] frame coordinates for `getNativeCrop`. The
18251
18448
  * decode worker resolves it against the RETAINED native frame's real pixel dims,
@@ -19934,7 +20131,7 @@ method(object({
19934
20131
  * linking rather than produce an eternal token.
19935
20132
  */
19936
20133
  ttlSec: union([number().int().positive(), literal("never")]).optional()
19937
- }), object({ token: string$2() })), method(object({ token: string$2() }), SsoBridgeClaimsSchema.nullable());
20134
+ }), object({ token: string$2() }), { auth: "admin" }), method(object({ token: string$2() }), SsoBridgeClaimsSchema.nullable(), { auth: "admin" });
19938
20135
  var ProviderListEntrySchema = discriminatedUnion("shouldSaveDiskSpace", [object({
19939
20136
  providerId: string$2().min(1),
19940
20137
  displayName: string$2().min(1),
@@ -20029,10 +20226,13 @@ var EvictResultSchema = object({
20029
20226
  /** True when the provider has nothing left it is willing to drop on this location. */
20030
20227
  exhausted: boolean()
20031
20228
  });
20032
- method(object({ locationId: string$2() }), EvictableUsageSchema), method(object({
20229
+ method(object({ locationId: string$2() }), EvictableUsageSchema, { auth: "admin" }), method(object({
20033
20230
  locationId: string$2(),
20034
20231
  targetBytes: number().int().positive()
20035
- }), EvictResultSchema, { kind: "mutation" });
20232
+ }), EvictResultSchema, {
20233
+ kind: "mutation",
20234
+ auth: "admin"
20235
+ });
20036
20236
  method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin" }), method(StorageMigrationInputSchema, object({ jobId: string$2() }), {
20037
20237
  kind: "mutation",
20038
20238
  auth: "admin"
@@ -20092,26 +20292,50 @@ var ReadChunkInputSchema = object({
20092
20292
  length: number()
20093
20293
  });
20094
20294
  var EndDownloadInputSchema = object({ downloadId: string$2() });
20095
- method(_void(), ProviderInfoSchema), method(object({ config: record(string$2(), unknown()) }), TestLocationResultSchema, { auth: "admin" }), method(object({
20295
+ method(_void(), ProviderInfoSchema, { auth: "admin" }), method(object({ config: record(string$2(), unknown()) }), TestLocationResultSchema, { auth: "admin" }), method(object({
20096
20296
  location: StorageLocationSchema,
20097
20297
  relativePath: string$2()
20098
- }), string$2()), method(object({
20298
+ }), string$2(), { auth: "admin" }), method(object({
20099
20299
  location: StorageLocationSchema,
20100
20300
  relativePath: string$2(),
20101
20301
  data: _instanceof(Uint8Array)
20102
- }), _void(), { kind: "mutation" }), method(object({
20302
+ }), _void(), {
20303
+ kind: "mutation",
20304
+ auth: "admin"
20305
+ }), method(object({
20103
20306
  location: StorageLocationSchema,
20104
20307
  relativePath: string$2()
20105
- }), _instanceof(Uint8Array)), method(object({
20308
+ }), _instanceof(Uint8Array), { auth: "admin" }), method(object({
20106
20309
  location: StorageLocationSchema,
20107
20310
  relativePath: string$2()
20108
- }), boolean()), method(object({
20311
+ }), boolean(), { auth: "admin" }), method(object({
20109
20312
  location: StorageLocationSchema,
20110
20313
  prefix: string$2().optional()
20111
- }), array(string$2()).readonly()), method(object({
20314
+ }), array(string$2()).readonly(), { auth: "admin" }), method(object({
20112
20315
  location: StorageLocationSchema,
20113
20316
  relativePath: string$2()
20114
- }), _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" });
20317
+ }), _void(), {
20318
+ kind: "mutation",
20319
+ auth: "admin"
20320
+ }), method(object({ location: StorageLocationSchema }), number().nullable(), { auth: "admin" }), method(BeginUploadInputSchema, BeginUploadResultSchema, {
20321
+ kind: "mutation",
20322
+ auth: "admin"
20323
+ }), method(WriteChunkInputSchema, _void(), {
20324
+ kind: "mutation",
20325
+ auth: "admin"
20326
+ }), method(FinalizeUploadInputSchema, _void(), {
20327
+ kind: "mutation",
20328
+ auth: "admin"
20329
+ }), method(AbortUploadInputSchema, _void(), {
20330
+ kind: "mutation",
20331
+ auth: "admin"
20332
+ }), method(BeginDownloadInputSchema, BeginDownloadResultSchema, {
20333
+ kind: "mutation",
20334
+ auth: "admin"
20335
+ }), method(ReadChunkInputSchema, _instanceof(Uint8Array), { auth: "admin" }), method(EndDownloadInputSchema, _void(), {
20336
+ kind: "mutation",
20337
+ auth: "admin"
20338
+ });
20115
20339
  /** Profile-exported FormBuilder schema. Shape is ConfigUISchema at the UI. */
20116
20340
  var ProfileSettingsSchemaBridge = unknown().nullable();
20117
20341
  var ProfileSettingsBagSchema = record(string$2(), unknown());
@@ -20369,7 +20593,8 @@ method(object({
20369
20593
  access: "create"
20370
20594
  }), method(object({ userId: string$2().optional() }), object({ optionsJSON: record(string$2(), unknown()) }), {
20371
20595
  kind: "mutation",
20372
- access: "view"
20596
+ access: "view",
20597
+ auth: "admin"
20373
20598
  }), method(object({
20374
20599
  /** Required — the user the assertion belongs to (verified). */
20375
20600
  userId: string$2(),
@@ -20377,10 +20602,12 @@ method(object({
20377
20602
  response: record(string$2(), unknown())
20378
20603
  }), object({ verified: boolean() }), {
20379
20604
  kind: "mutation",
20380
- access: "view"
20605
+ access: "view",
20606
+ auth: "admin"
20381
20607
  }), method(object({}), object({ optionsJSON: record(string$2(), unknown()) }), {
20382
20608
  kind: "mutation",
20383
- access: "view"
20609
+ access: "view",
20610
+ auth: "admin"
20384
20611
  }), method(object({
20385
20612
  /** AuthenticationResponseJSON from the browser. */
20386
20613
  response: record(string$2(), unknown()) }), object({
@@ -20388,7 +20615,8 @@ response: record(string$2(), unknown()) }), object({
20388
20615
  userId: string$2().nullable()
20389
20616
  }), {
20390
20617
  kind: "mutation",
20391
- access: "view"
20618
+ access: "view",
20619
+ auth: "admin"
20392
20620
  }), method(object({ userId: string$2() }), array(PasskeySummarySchema), { auth: "admin" }), method(object({
20393
20621
  userId: string$2(),
20394
20622
  credentialId: string$2()
@@ -20560,7 +20788,19 @@ var VectorStatsResultSchema = object({
20560
20788
  /** False when the backend ranks approximately. */
20561
20789
  exact: boolean()
20562
20790
  });
20563
- 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);
20791
+ method(VectorDeclareIndexInputSchema, _void(), {
20792
+ kind: "mutation",
20793
+ auth: "admin"
20794
+ }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
20795
+ kind: "mutation",
20796
+ auth: "admin"
20797
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
20798
+ kind: "mutation",
20799
+ auth: "admin"
20800
+ }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
20801
+ kind: "mutation",
20802
+ auth: "admin"
20803
+ }), method(VectorStatsInputSchema, VectorStatsResultSchema, { auth: "admin" });
20564
20804
  var ClipSchema = object({
20565
20805
  /** Opaque, provider-namespaced id. The default provider encodes the time
20566
20806
  * window so `getClipPlayback` is self-contained (no event re-query). */
@@ -23030,7 +23270,27 @@ var MediaFileLiteSchema$1 = object({
23030
23270
  sizeBytes: number(),
23031
23271
  timestamp: number()
23032
23272
  });
23033
- method(_void(), array(IdentitySchema).readonly()), method(object({ name: string$2().min(1) }), IdentitySchema, {
23273
+ method(object({
23274
+ /**
23275
+ * Inline {@link IdentitySchema.coverBase64} on every row.
23276
+ *
23277
+ * Default `false`, the same inversion `listRecentFaces` and
23278
+ * `listPlates` took on 2026-08-25 (see `include-crops-default.ts` for
23279
+ * why the burden belongs on the caller that WANTS the bytes). Measured
23280
+ * on the live hub the same day: four identities cost 40,979 B with the
23281
+ * covers inline, ~10 KB of base64 per row, on a query this UI mounts
23282
+ * four times and the viewer holds at `staleTime: 30_000`.
23283
+ *
23284
+ * Nothing loses its avatar: `coverMediaKey` is already on every row and
23285
+ * the `event-media` plane serves that key `immutable` with an ETag.
23286
+ *
23287
+ * **This is an INPUT field, so it does not reach the addon until the
23288
+ * next train** — the hub router validates cap inputs against its own
23289
+ * compiled Zod and strips a key it does not know. Until then the
23290
+ * provider sees `undefined`, which resolves to `false`: the cheap shape
23291
+ * is what ships, and the opt-in becomes reachable when the train lands.
23292
+ */
23293
+ includeCrops: boolean().optional() }).optional(), array(IdentitySchema).readonly()), method(object({ name: string$2().min(1) }), IdentitySchema, {
23034
23294
  kind: "mutation",
23035
23295
  auth: "admin"
23036
23296
  }), method(object({
@@ -25920,8 +26180,10 @@ var PlateInfoSchema = object({
25920
26180
  keyFrameMediaKey: string$2().optional(),
25921
26181
  base64: string$2().optional(),
25922
26182
  /**
25923
- * Same crop as a data-plane URL. `getPlateByTrack` returns this and
25924
- * never inlines JPEG; `listPlates` still inlines for the admin-ui.
26183
+ * Same crop as a data-plane URL, always present when the plate has a stored
26184
+ * crop. `getPlateByTrack` returns this and never inlines JPEG; `listPlates`
26185
+ * and `searchPlates` inline the crop only when their `includeCrops` input is
26186
+ * left at its `true` default.
25925
26187
  */
25926
26188
  cropUrl: string$2().optional()
25927
26189
  });
@@ -25941,14 +26203,34 @@ var PlateClusterSchema = object({
25941
26203
  });
25942
26204
  method(object({
25943
26205
  deviceId: number().int().optional(),
25944
- limit: number().int().positive().optional()
26206
+ limit: number().int().positive().optional(),
26207
+ /**
26208
+ * Inline the base64 crop on every row. Default `true` — the existing
26209
+ * behaviour, kept so no caller breaks.
26210
+ *
26211
+ * Set `false` once the caller renders {@link PlateInfo.cropUrl}.
26212
+ * Measured on the live hub at the 500 rows the Plates view asks for:
26213
+ * 879,403 B and 27.7 s with the crops inline, against a few KiB of
26214
+ * metadata without them — and the browser then caches the images.
26215
+ *
26216
+ * This is the plate twin of `faceGallery.listRecentFaces`'s option;
26217
+ * plates were the one gallery list left without it.
26218
+ *
26219
+ * **This is an INPUT field, so it does not reach the addon until the
26220
+ * next train.** The hub router validates cap inputs against its own
26221
+ * compiled Zod and strips a key it does not know. Until the train
26222
+ * ships, sending `false` is harmless and keeps the crops inline.
26223
+ */
26224
+ includeCrops: boolean().optional()
25945
26225
  }).optional(), array(PlateInfoSchema).readonly()), method(object({
25946
26226
  deviceId: number().int(),
25947
26227
  trackId: string$2()
25948
26228
  }), PlateInfoSchema.nullable()), method(object({ plateId: string$2() }), array(MediaFileLiteSchema).readonly()), method(object({
25949
26229
  text: string$2().min(1),
25950
26230
  maxDistance: number().int().min(0).optional(),
25951
- limit: number().int().positive().optional()
26231
+ limit: number().int().positive().optional(),
26232
+ /** See `listPlates.includeCrops`. Default `true`. */
26233
+ includeCrops: boolean().optional()
25952
26234
  }), array(PlateInfoSchema).readonly()), method(object({
25953
26235
  maxDistance: number().int().min(0).optional(),
25954
26236
  minClusterSize: number().int().min(2).optional(),
@@ -25962,7 +26244,13 @@ method(object({
25962
26244
  }), method(object({ plateId: string$2() }), _void(), {
25963
26245
  kind: "mutation",
25964
26246
  auth: "admin"
25965
- }), method(_void(), array(VehicleSchema).readonly()), method(object({ name: string$2().min(1) }), VehicleSchema, {
26247
+ }), method(object({
26248
+ /** Inline {@link VehicleSchema.coverBase64} on every row. Default
26249
+ * `false` — the vehicle twin of `faceGallery.listIdentities`'s
26250
+ * option; `coverMediaKey` + the `event-media` plane carry the picture.
26251
+ * INPUT field: stripped by the hub router until the train ships, which
26252
+ * resolves to `false` and is exactly the intended default. */
26253
+ includeCrops: boolean().optional() }).optional(), array(VehicleSchema).readonly()), method(object({ name: string$2().min(1) }), VehicleSchema, {
25966
26254
  kind: "mutation",
25967
26255
  auth: "admin"
25968
26256
  }), method(object({
@@ -27483,92 +27771,6 @@ var sceneMonitorCapability = {
27483
27771
  durability: "session"
27484
27772
  };
27485
27773
  /**
27486
- * Per-stage gating mode applied to the zones a rule references.
27487
- *
27488
- * - `include`: the rule contributes to a **whitelist** for its stage.
27489
- * When at least one `include` rule fires for a stage, only entities
27490
- * inside one of those zones pass that stage.
27491
- * - `exclude`: the rule contributes to a **blacklist** for its stage.
27492
- * Entities inside one of those zones are dropped at that stage.
27493
- *
27494
- * `monitor`-style observation (count without filtering) is not a rule
27495
- * mode — zones without any matching rule are observed naturally by
27496
- * `zone-analytics` (live snapshot + history), so an "I just want to
27497
- * count, not filter" use case needs no rule at all.
27498
- */
27499
- var ZoneRuleModeEnum = _enum(["include", "exclude"]);
27500
- /**
27501
- * Per-consumer rule that references existing zones (geometry) and
27502
- * defines how a specific pipeline stage should treat them. Each
27503
- * consumer addon owns its own `ZoneRule[]` array in its per-device
27504
- * settings:
27505
- *
27506
- * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
27507
- * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
27508
- * - future: notification rules, audio gating, etc.
27509
- *
27510
- * One rule applies to N zones (`zoneIds[]`) so the operator can
27511
- * express "ignore motion in ALL of {garden, street}" with a single
27512
- * rule. `classFilter` narrows the rule to specific object classes —
27513
- * "drop person detections in the street, but keep cars" is one
27514
- * `exclude` rule with `classFilter: ['person']`.
27515
- *
27516
- * `enabled` is a soft toggle — the operator can keep the rule
27517
- * configured but inert without deleting it.
27518
- */
27519
- var ZoneRuleSchema = object({
27520
- /** Stable rule id — survives edits, used by the UI for diffing. */
27521
- id: string$2(),
27522
- /** Optional human-readable label rendered in the rule editor. */
27523
- name: string$2().optional(),
27524
- /** Zones this rule targets. The rule's `mode` applies to ALL
27525
- * listed zones (OR-set: a detection in any one of them counts).
27526
- * At least one zone id required — a rule with no targets is a
27527
- * configuration mistake and the form validator rejects it. */
27528
- zoneIds: array(string$2()).min(1).readonly(),
27529
- mode: ZoneRuleModeEnum,
27530
- /**
27531
- * Class names this rule applies to. Empty / undefined ⇒ rule
27532
- * applies to every class. Class strings match the `macroClass`
27533
- * field on detections (e.g. `person`, `car`, `dog`).
27534
- */
27535
- classFilter: array(string$2()).readonly().optional(),
27536
- /**
27537
- * Minimum bbox/mask overlap (0–1) with any of the rule's zones
27538
- * required to consider an entity "in the zone". Defaults to the
27539
- * consumer's stage default when omitted. Kept for back-compat with
27540
- * existing per-rule overrides; new operators pick the value via
27541
- * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
27542
- * set, the lower-level engine reads it as a 0–1 fraction.
27543
- */
27544
- overlapThreshold: number().min(0).max(1).optional(),
27545
- /**
27546
- * Operator-friendly version of `overlapThreshold` — the percentage
27547
- * of the detection's bbox that must lie inside the zone for the
27548
- * rule to match. Documented default is 85%; the engine substitutes
27549
- * that when the field is omitted (kept optional so existing rules
27550
- * stored without it stay valid).
27551
- *
27552
- * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
27553
- * rule, the engine prefers `bboxInclusionPct` because it's the
27554
- * field exposed in the UI. Internally both feed the same gate.
27555
- */
27556
- bboxInclusionPct: number().min(0).max(100).optional(),
27557
- /**
27558
- * When `true` and a detection has a segmentation mask, use the
27559
- * mask for overlap instead of the bbox. Detection-stage only;
27560
- * motion rules ignore this field.
27561
- */
27562
- preferMask: boolean().optional(),
27563
- /**
27564
- * Soft-toggle: `false` disables the rule without deleting it.
27565
- * Defaults to `true` so operators creating a rule via the UI
27566
- * see it active immediately.
27567
- */
27568
- enabled: boolean().default(true)
27569
- });
27570
- array(ZoneRuleSchema).readonly();
27571
- /**
27572
27774
  * Script-runner cap. Models HA `script.*` entities on
27573
27775
  * `DeviceType.Script`. A Script is a pre-recorded action sequence
27574
27776
  * that can be invoked imperatively — optionally with a variables
@@ -33223,6 +33425,12 @@ Object.freeze({
33223
33425
  addonId: null,
33224
33426
  access: "create"
33225
33427
  },
33428
+ "pipelineAnalytics.cancelRelocateMedia": {
33429
+ capName: "pipeline-analytics",
33430
+ capScope: "device",
33431
+ addonId: null,
33432
+ access: "create"
33433
+ },
33226
33434
  "pipelineAnalytics.cancelStorageMigrationMove": {
33227
33435
  capName: "pipeline-analytics",
33228
33436
  capScope: "device",
@@ -33397,6 +33605,12 @@ Object.freeze({
33397
33605
  addonId: null,
33398
33606
  access: "view"
33399
33607
  },
33608
+ "pipelineAnalytics.listRelocateMediaJobs": {
33609
+ capName: "pipeline-analytics",
33610
+ capScope: "device",
33611
+ addonId: null,
33612
+ access: "view"
33613
+ },
33400
33614
  "pipelineAnalytics.listRetrainAnnotations": {
33401
33615
  capName: "pipeline-analytics",
33402
33616
  capScope: "device",
@@ -33475,6 +33689,12 @@ Object.freeze({
33475
33689
  addonId: null,
33476
33690
  access: "create"
33477
33691
  },
33692
+ "pipelineAnalytics.relocateMedia": {
33693
+ capName: "pipeline-analytics",
33694
+ capScope: "device",
33695
+ addonId: null,
33696
+ access: "create"
33697
+ },
33478
33698
  "pipelineAnalytics.restageRetrainTrack": {
33479
33699
  capName: "pipeline-analytics",
33480
33700
  capScope: "device",
@@ -33487,6 +33707,12 @@ Object.freeze({
33487
33707
  addonId: null,
33488
33708
  access: "create"
33489
33709
  },
33710
+ "pipelineAnalytics.runReplayFrameProcessor": {
33711
+ capName: "pipeline-analytics",
33712
+ capScope: "device",
33713
+ addonId: null,
33714
+ access: "create"
33715
+ },
33490
33716
  "pipelineAnalytics.saveRetrainAnnotations": {
33491
33717
  capName: "pipeline-analytics",
33492
33718
  capScope: "device",
@@ -33619,6 +33845,12 @@ Object.freeze({
33619
33845
  addonId: null,
33620
33846
  access: "view"
33621
33847
  },
33848
+ "pipelineExecutor.getInferenceDeviceHealth": {
33849
+ capName: "pipeline-executor",
33850
+ capScope: "system",
33851
+ addonId: null,
33852
+ access: "view"
33853
+ },
33622
33854
  "pipelineExecutor.getOrchestratorConfigSchema": {
33623
33855
  capName: "pipeline-executor",
33624
33856
  capScope: "system",
@@ -33691,6 +33923,12 @@ Object.freeze({
33691
33923
  addonId: null,
33692
33924
  access: "view"
33693
33925
  },
33926
+ "pipelineExecutor.rearmInferenceDevice": {
33927
+ capName: "pipeline-executor",
33928
+ capScope: "system",
33929
+ addonId: null,
33930
+ access: "create"
33931
+ },
33694
33932
  "pipelineExecutor.runAudioTest": {
33695
33933
  capName: "pipeline-executor",
33696
33934
  capScope: "system",
@@ -36939,6 +37177,11 @@ Object.freeze({
36939
37177
  form: "single",
36940
37178
  optional: false
36941
37179
  }],
37180
+ "pipelineAnalytics.runReplayFrameProcessor": [{
37181
+ name: "deviceId",
37182
+ form: "single",
37183
+ optional: false
37184
+ }],
36942
37185
  "pipelineAnalytics.saveRetrainAnnotations": [{
36943
37186
  name: "deviceId",
36944
37187
  form: "single",