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