@camstack/addon-provider-homematic 1.2.29 → 1.2.31

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