@camstack/addon-provider-rtsp 1.2.28 → 1.2.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/addon.js +2135 -1892
  2. package/dist/addon.mjs +2135 -1892
  3. package/package.json +1 -1
package/dist/addon.mjs CHANGED
@@ -6630,7 +6630,7 @@ function method(input, output, options) {
6630
6630
  input,
6631
6631
  output,
6632
6632
  kind: options?.kind ?? "query",
6633
- auth: options?.auth ?? "protected",
6633
+ ...options?.auth !== void 0 ? { auth: options.auth } : {},
6634
6634
  ...options?.access !== void 0 ? { access: options.access } : {},
6635
6635
  ...options?.caller !== void 0 ? { caller: options.caller } : {},
6636
6636
  timeoutMs: options?.timeoutMs
@@ -6654,7 +6654,7 @@ function event(data) {
6654
6654
  }
6655
6655
  var StaticDirOutputSchema$1 = object({ staticDir: string() });
6656
6656
  var VersionOutputSchema$1 = object({ version: string() });
6657
- method(_void(), StaticDirOutputSchema$1), method(_void(), VersionOutputSchema$1);
6657
+ method(_void(), StaticDirOutputSchema$1, { auth: "admin" }), method(_void(), VersionOutputSchema$1, { auth: "admin" });
6658
6658
  var DeviceType = /* @__PURE__ */ function(DeviceType) {
6659
6659
  DeviceType["Camera"] = "camera";
6660
6660
  DeviceType["Hub"] = "hub";
@@ -6975,7 +6975,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
6975
6975
  }({});
6976
6976
  var StaticDirOutputSchema = object({ staticDir: string() });
6977
6977
  var VersionOutputSchema = object({ version: string() });
6978
- method(_void(), StaticDirOutputSchema), method(_void(), VersionOutputSchema);
6978
+ method(_void(), StaticDirOutputSchema, { auth: "admin" }), method(_void(), VersionOutputSchema, { auth: "admin" });
6979
6979
  /**
6980
6980
  * device-ops — device-scoped cap that unifies the per-IDevice operations
6981
6981
  * previously routed through the `.device-ops` Moleculer bridge service.
@@ -7633,24 +7633,6 @@ var RecordingRetentionSchema = object({
7633
7633
  maxSizeGb: number().min(0).optional()
7634
7634
  });
7635
7635
  /**
7636
- * Scrub-thumbnail fidelity preset — the single per-camera selector bundling the
7637
- * sprite tile RESOLUTION + JPEG QUALITY the recorder packs timeline-scrub
7638
- * previews at. Five graduated steps; absent on a config = `standard` (the
7639
- * shipped default, matching `sheet-geometry`/`sheet-composer`).
7640
- *
7641
- * Existing sheets are IMMUTABLE — a changed preset applies to NEW windows only.
7642
- * Each window's index sidecar carries its own tile dims, so a camera whose
7643
- * preset changed over time renders every historical window at the dims it was
7644
- * written with.
7645
- */
7646
- var ScrubThumbnailPresetSchema = _enum([
7647
- "minimal",
7648
- "low",
7649
- "standard",
7650
- "high",
7651
- "max"
7652
- ]);
7653
- /**
7654
7636
  * The full per-camera recording intent — the wire shape of a RecordingTarget.
7655
7637
  *
7656
7638
  * `bands` is the ONLY authored recording intent: what to record, when, and on
@@ -7658,7 +7640,11 @@ var ScrubThumbnailPresetSchema = _enum([
7658
7640
  * other field is a storage knob (profiles, segment length, retention, scrub).
7659
7641
  *
7660
7642
  * STRICT on purpose: the legacy authoring surface (`schedule`/`schedules`/
7661
- * `triggers`/`preBufferSec`/`postBufferSec`/`rules`) was retired 2026-07-30.
7643
+ * `triggers`/`preBufferSec`/`postBufferSec`/`rules`) was retired 2026-07-30,
7644
+ * and `scrubThumbnails` — a five-step fidelity knob for a sprite tier that was
7645
+ * deleted on 2026-07-24 and had ZERO consumers in the recorder — on 2026-08-25
7646
+ * (D62: a switch that writes a store nobody reads is worse than no switch).
7647
+ * Stored rows keep loading: the READ schema is `.strip()` (config-store.ts).
7662
7648
  * A stale caller must fail loudly — silently stripping its legacy intent would
7663
7649
  * persist a band-less config, i.e. silently stop recording the camera.
7664
7650
  */
@@ -7681,14 +7667,7 @@ var RecordingConfigSchema = object({
7681
7667
  * "off" is the absence of a covering band, never a band value.
7682
7668
  */
7683
7669
  bands: array(RecordingBandSchema).default([]),
7684
- retention: RecordingRetentionSchema.optional(),
7685
- /**
7686
- * Per-camera scrub-thumbnail fidelity preset (resolution + JPEG quality for
7687
- * timeline-scrub sprite previews). Absent = `standard`. Applies to NEW
7688
- * windows only — existing sheets are immutable, and each window's index
7689
- * carries its own tile dims so mixed-preset history renders correctly.
7690
- */
7691
- scrubThumbnails: ScrubThumbnailPresetSchema.optional()
7670
+ retention: RecordingRetentionSchema.optional()
7692
7671
  }).strict();
7693
7672
  /**
7694
7673
  * Entity-relocation job state (storage entity-routing spec, Phase 4).
@@ -7764,10 +7743,11 @@ var RelocateFootageInputSchema = object({
7764
7743
  * `RecordingConfig.enabled` or camera wrapper bindings. */
7765
7744
  var StorageMigrationLeaseInputSchema = object({ leaseId: string().min(1) });
7766
7745
  var StorageMigrationFootageMoveInputSchema = RelocateFootageInputSchema.extend({ leaseId: string().min(1) });
7767
- var StorageMigrationMediaMoveInputSchema = object({
7746
+ var RelocateMediaInputSchema = object({
7768
7747
  toLocationId: string(),
7769
7748
  throttleMbps: number().min(1).max(1e3).optional()
7770
- }).extend({ leaseId: string().min(1) });
7749
+ });
7750
+ var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
7771
7751
  /** The independently selectable logical storage classes. `recordings`
7772
7752
  * encompasses the high and mid segment profiles; `recordingsLow` is low
7773
7753
  * segments; `eventMedia` is post-analysis blobs. */
@@ -8062,7 +8042,26 @@ var LabelDefinitionSchema = object({
8062
8042
  description: string().optional(),
8063
8043
  icon: string().optional()
8064
8044
  });
8065
- var ClassMapDefinitionSchema = object({
8045
+ /**
8046
+ * Wire schema for a per-model CATALOG classMap override
8047
+ * (`ModelCatalogEntry.classMap` / `ModelConvertMetadata.classMap`) —
8048
+ * restricted to {@link CLASS_MAP_MACRO_TARGETS}, the only macros the
8049
+ * detection pipeline executor actually routes.
8050
+ *
8051
+ * This is deliberately a DIFFERENT, narrower shape than the general-purpose
8052
+ * `ClassMapDefinition` interface above (e.g. `IDetectionAddon.getClassMap()`
8053
+ * and the audio `YAMNET_TO_MACRO` catalog both use macro targets outside this
8054
+ * enum) — the two used to share the name `ClassMapDefinition`/
8055
+ * `ClassMapDefinitionSchema`, which made the schema-type-twin guard
8056
+ * (`scripts/check-schema-type-twins.ts`) flag them as a duplicated shape. They
8057
+ * are not: it is two different concepts colliding on a name. Keep this type
8058
+ * under its own name rather than reusing `ClassMapDefinition` — reusing it
8059
+ * would either narrow every `ClassMapDefinition` consumer to the four
8060
+ * detection macros (breaking `YAMNET_TO_MACRO`) or drop the validation this
8061
+ * schema exists for (see the "rejects a classMap whose target is not a
8062
+ * detection macro" test in `model-catalog-schema.test.ts`).
8063
+ */
8064
+ var DetectionCatalogClassMapSchema = object({
8066
8065
  mapping: record(string(), _enum([
8067
8066
  "person",
8068
8067
  "vehicle",
@@ -8267,7 +8266,7 @@ var ModelCatalogEntrySchema = object({
8267
8266
  * applies (Frigate / COCO public catalog). Set on a custom model whose raw
8268
8267
  * labels already ARE the CamStack macros (Scrypted identity map).
8269
8268
  */
8270
- classMap: ClassMapDefinitionSchema.optional()
8269
+ classMap: DetectionCatalogClassMapSchema.optional()
8271
8270
  });
8272
8271
  var ConvertTargetSchema = discriminatedUnion("format", [object({
8273
8272
  format: literal("openvino"),
@@ -8297,7 +8296,7 @@ var ModelConvertMetadataSchema = object({
8297
8296
  "segmentation"
8298
8297
  ]),
8299
8298
  faceAlignment: boolean().optional(),
8300
- classMap: ClassMapDefinitionSchema.optional()
8299
+ classMap: DetectionCatalogClassMapSchema.optional()
8301
8300
  });
8302
8301
  var ConvertResultSchema = object({
8303
8302
  entry: ModelCatalogEntrySchema,
@@ -9160,7 +9159,7 @@ var AddonPageDeclarationSchema = object({
9160
9159
  /** Display label for a CUSTOM `section` id (ignored for well-known ids). */
9161
9160
  sectionLabel: string().optional()
9162
9161
  });
9163
- method(_void(), array(AddonPageDeclarationSchema).readonly());
9162
+ method(_void(), array(AddonPageDeclarationSchema).readonly(), { auth: "admin" });
9164
9163
  var AddonHttpRouteSchema = object({
9165
9164
  method: _enum([
9166
9165
  "GET",
@@ -9395,7 +9394,7 @@ var WidgetMetadataSchema = object({
9395
9394
  defaultColumns: number().int().min(1).max(12).default(6),
9396
9395
  defaultRows: number().int().min(1).max(12).default(1)
9397
9396
  });
9398
- method(_void(), array(WidgetMetadataSchema).readonly());
9397
+ method(_void(), array(WidgetMetadataSchema).readonly(), { auth: "admin" });
9399
9398
  /**
9400
9399
  * `addon-widgets` — system-scoped singleton aggregator cap. Public-facing
9401
9400
  * surface that admin-ui consumes through `useAddonWidgetsListWidgets()`.
@@ -11019,7 +11018,7 @@ var CustomModelDescriptorSchema = object({
11019
11018
  stepId: string(),
11020
11019
  entry: ModelCatalogEntrySchema
11021
11020
  });
11022
- method(_void(), array(CustomModelDescriptorSchema).readonly());
11021
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
11023
11022
  /**
11024
11023
  * Query filter for settings-store collections.
11025
11024
  */
@@ -11106,7 +11105,8 @@ method(object({
11106
11105
  }), _void(), { kind: "mutation" }), method(object({
11107
11106
  namespace: string().optional(),
11108
11107
  collection: string(),
11109
- filter: QueryFilterSchema.optional()
11108
+ filter: QueryFilterSchema.optional(),
11109
+ columns: array(string()).readonly().optional()
11110
11110
  }), array(SettingsRecordSchema).readonly()), method(object({
11111
11111
  namespace: string().optional(),
11112
11112
  collection: string(),
@@ -11169,46 +11169,87 @@ var EngineInfoSchema = object({
11169
11169
  kind: _enum(["relational", "vector"]),
11170
11170
  displayName: string()
11171
11171
  });
11172
- method(_void(), EngineInfoSchema), method(object({
11172
+ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
11173
11173
  namespace: string().optional(),
11174
11174
  collection: string(),
11175
11175
  key: string()
11176
- }), unknown()), method(object({
11176
+ }), unknown(), { auth: "admin" }), method(object({
11177
11177
  namespace: string().optional(),
11178
11178
  collection: string(),
11179
11179
  key: string(),
11180
11180
  value: unknown()
11181
- }), _void(), { kind: "mutation" }), method(object({
11181
+ }), _void(), {
11182
+ kind: "mutation",
11183
+ auth: "admin"
11184
+ }), method(object({
11182
11185
  namespace: string().optional(),
11183
11186
  collection: string(),
11184
- filter: QueryFilterSchema.optional()
11185
- }), array(SettingsRecordSchema).readonly()), method(object({
11187
+ filter: QueryFilterSchema.optional(),
11188
+ /**
11189
+ * SQL-level column projection — MUST mirror `settings-store.query`.
11190
+ *
11191
+ * ⚠ An earlier version of this comment blamed Zod stripping, and that
11192
+ * was wrong — corrected 2026-08-26 after the hop map
11193
+ * (`docs/design/2026-08-26-mappa-hop-argomenti.md`) traced the path.
11194
+ * There is **no Zod parse at all** between the door and the engine: the
11195
+ * dispatcher forwards the payload verbatim and UDS carries it whole. A
11196
+ * field declared here reaches `SqliteSettingsBackend` either way.
11197
+ *
11198
+ * What actually lost `columns` was the THIRD declaration of this shape:
11199
+ * `SettingsQueryInput` in `interfaces/storage.ts`, a hand-written TS
11200
+ * interface the engine destructures from. The field existed on both
11201
+ * schemas and the engine still never read it, because nothing checks a
11202
+ * registered provider against `InferProvider<cap>` —
11203
+ * `ProviderRegistration.provider` is typed `object`.
11204
+ *
11205
+ * It is declared here anyway, and must stay in step with
11206
+ * `settings-store.query`: a caller reading only the cap definitions has
11207
+ * to be able to see that this call carries a projection.
11208
+ * `data-door-schema-parity.spec.ts` keeps the two aligned.
11209
+ */
11210
+ columns: array(string()).readonly().optional()
11211
+ }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
11186
11212
  namespace: string().optional(),
11187
11213
  collection: string(),
11188
11214
  record: SettingsRecordSchema
11189
- }), _void(), { kind: "mutation" }), method(object({
11215
+ }), _void(), {
11216
+ kind: "mutation",
11217
+ auth: "admin"
11218
+ }), method(object({
11190
11219
  namespace: string().optional(),
11191
11220
  collection: string(),
11192
11221
  id: string(),
11193
11222
  data: record(string(), unknown())
11194
- }), _void(), { kind: "mutation" }), method(object({
11223
+ }), _void(), {
11224
+ kind: "mutation",
11225
+ auth: "admin"
11226
+ }), method(object({
11195
11227
  namespace: string().optional(),
11196
11228
  collection: string(),
11197
11229
  key: string()
11198
- }), _void(), { kind: "mutation" }), method(object({
11230
+ }), _void(), {
11231
+ kind: "mutation",
11232
+ auth: "admin"
11233
+ }), method(object({
11199
11234
  namespace: string().optional(),
11200
11235
  collection: string(),
11201
11236
  filter: MutationFilterSchema
11202
- }), object({ deleted: number().int() }), { kind: "mutation" }), method(object({
11237
+ }), object({ deleted: number().int() }), {
11238
+ kind: "mutation",
11239
+ auth: "admin"
11240
+ }), method(object({
11203
11241
  namespace: string().optional(),
11204
11242
  collection: string(),
11205
11243
  filter: MutationFilterSchema,
11206
11244
  data: record(string(), unknown())
11207
- }), object({ updated: number().int() }), { kind: "mutation" }), method(object({
11245
+ }), object({ updated: number().int() }), {
11246
+ kind: "mutation",
11247
+ auth: "admin"
11248
+ }), method(object({
11208
11249
  namespace: string().optional(),
11209
11250
  collection: string(),
11210
11251
  filter: QueryFilterSchema.optional()
11211
- }), number()), method(object({
11252
+ }), number(), { auth: "admin" }), method(object({
11212
11253
  namespace: string().optional(),
11213
11254
  collection: string(),
11214
11255
  field: string(),
@@ -11218,15 +11259,18 @@ method(_void(), EngineInfoSchema), method(object({
11218
11259
  }), array(object({
11219
11260
  bucket: number().int(),
11220
11261
  count: number().int()
11221
- })).readonly()), method(object({
11262
+ })).readonly(), { auth: "admin" }), method(object({
11222
11263
  namespace: string().optional(),
11223
11264
  collection: string()
11224
- }), boolean()), method(object({
11265
+ }), boolean(), { auth: "admin" }), method(object({
11225
11266
  namespace: string().optional(),
11226
11267
  collection: string(),
11227
11268
  columns: array(CollectionColumnSchema).readonly(),
11228
11269
  indexes: array(CollectionIndexSchema).readonly().optional()
11229
- }), _void(), { kind: "mutation" });
11270
+ }), _void(), {
11271
+ kind: "mutation",
11272
+ auth: "admin"
11273
+ });
11230
11274
  /**
11231
11275
  * shm ring usage stats for a `frameSink: 'shm'` decoder session —
11232
11276
  * exposed via `decoder.getShmStats` so downstream consumers can
@@ -12516,7 +12560,7 @@ method(object({
12516
12560
  crop: _instanceof(Uint8Array),
12517
12561
  width: number(),
12518
12562
  height: number()
12519
- }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
12563
+ }), EmbeddingResultSchema, { auth: "admin" }), method(object({ text: string() }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" });
12520
12564
  /**
12521
12565
  * filesystem-browse — per-node capability for browsing the node's local
12522
12566
  * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
@@ -12809,19 +12853,22 @@ method(LlmGenerateBaseInputSchema.extend({
12809
12853
  runtime: ManagedRuntimeConfigSchema,
12810
12854
  /** The managed profile's timeout, threaded by the hub provider. */
12811
12855
  timeoutMs: number().int().positive().optional()
12812
- }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
12856
+ }), LlmGenerateResultSchema, {
12857
+ kind: "mutation",
12858
+ auth: "admin"
12859
+ }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
12813
12860
  kind: "mutation",
12814
12861
  auth: "admin"
12815
12862
  }), method(object({}), _void(), {
12816
12863
  kind: "mutation",
12817
12864
  auth: "admin"
12818
- }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
12865
+ }), method(object({}), LlmRuntimeStatusSchema, { auth: "admin" }), method(object({ model: ManagedModelRefSchema }), _void(), {
12819
12866
  kind: "mutation",
12820
12867
  auth: "admin"
12821
12868
  }), method(object({ file: string() }), _void(), {
12822
12869
  kind: "mutation",
12823
12870
  auth: "admin"
12824
- }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
12871
+ }), method(object({}), array(LlmNodeModelSchema), { auth: "admin" }), method(object({}), LlmRuntimeDiskUsageSchema, { auth: "admin" });
12825
12872
  /**
12826
12873
  * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
12827
12874
  * methods concat-fan across providers; single-row methods route to ONE
@@ -16332,1748 +16379,1998 @@ var OauthIntegrationDescriptorSchema = object({
16332
16379
  */
16333
16380
  refreshTokenTtlSec: union([number().int().positive(), literal("never")]).optional()
16334
16381
  });
16335
- method(_void(), OauthIntegrationDescriptorSchema);
16382
+ method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
16336
16383
  /**
16337
- * pipeline-analytics device-scoped wrapper cap. Refines raw
16338
- * per-frame detections emitted by the pipeline runner into tracked
16339
- * objects, per-kind event collections (motion / object / audio), and
16340
- * persisted media. Owns the post-detection domain end-to-end:
16341
- *
16342
- * runner emits PipelineInferenceResult
16343
- * ↓ (event bus)
16344
- * pipeline-analytics subscriber
16345
- * ↓ SORT tracker + zone engine + state analyzer + event emitter
16346
- * → three DB collections (one per kind), one FS media tree, one
16347
- * unified event emitter (FrameTracked + TrackStarted/Ended +
16348
- * DetectionEvent on bus)
16349
- *
16350
- * Pure subscriber model. No `processFrame` cap method — the runner
16351
- * already publishes the raw frame on the bus. The cap surface is
16352
- * only QUERIES + per-device settings, bound on/off via
16353
- * `device-manager.setWrapperActive`. `defaultActive: true` because
16354
- * every camera with a detection pipeline wants its raw detections
16355
- * refined; operators opt out per-device via BindingsTab when needed.
16356
- *
16357
- * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
16358
- * (per-device surface) and `track-trail` caps — see P11 cleanup.
16384
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
16385
+ * within the frame, so the executor can re-cut a leaf child ROI at native
16386
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
16359
16387
  */
16360
- var TrackStateSchema = _enum([
16361
- "new",
16362
- "entered",
16363
- "left",
16364
- "moving",
16365
- "idle"
16366
- ]);
16367
- var EventKindSchema = _enum([
16368
- "motion",
16369
- "object",
16370
- "audio"
16371
- ]);
16388
+ var NativeCropRefSchema = object({
16389
+ /** Handle keying the retained native surface (node-pinned to its owner). */
16390
+ handle: FrameHandleSchema,
16391
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
16392
+ cropFrameSpace: object({
16393
+ x: number(),
16394
+ y: number(),
16395
+ w: number(),
16396
+ h: number()
16397
+ })
16398
+ });
16399
+ object({
16400
+ crop: object({
16401
+ left: number(),
16402
+ top: number(),
16403
+ width: number().positive(),
16404
+ height: number().positive()
16405
+ }).optional(),
16406
+ content: object({
16407
+ width: number().int().positive(),
16408
+ height: number().int().positive()
16409
+ }),
16410
+ fit: _enum(["stretch", "contain"]),
16411
+ format: _enum([
16412
+ "rgb",
16413
+ "gray",
16414
+ "jpeg"
16415
+ ])
16416
+ });
16372
16417
  /**
16373
- * Spatial filter for `listTracks` the rect + polygon variants of the shared
16374
- * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
16375
- * of the camera frame (top-left origin), matching the drawing-plane editor.
16418
+ * Process-local frame identity. It is serializable so it can ride an in-process
16419
+ * capability call, but `registryId` deliberately prevents resolution in any
16420
+ * other process or execution group.
16376
16421
  */
16377
- var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
16378
- /** Closed icon vocabulary so clients render a known glyph per kind. */
16379
- var EventKindIconSchema = _enum([
16380
- "motion",
16381
- "audio",
16382
- "person",
16383
- "vehicle",
16384
- "animal",
16385
- "door",
16386
- "pir",
16387
- "smoke",
16388
- "water",
16389
- "button",
16390
- "package",
16391
- "generic"
16422
+ var FrameRefSchema = object({
16423
+ registryId: string().min(1),
16424
+ id: string().min(1),
16425
+ width: number().int().positive(),
16426
+ height: number().int().positive(),
16427
+ format: _enum(["rgb", "gray"]),
16428
+ timestamp: number(),
16429
+ capturedAt: number().optional()
16430
+ });
16431
+ var ModelFormatSchema$1 = _enum([
16432
+ "onnx",
16433
+ "coreml",
16434
+ "openvino",
16435
+ "tflite",
16436
+ "pt",
16437
+ "gguf"
16392
16438
  ]);
16393
- var EventKindCategorySchema = _enum([
16394
- "motion",
16395
- "audio",
16396
- "detection",
16397
- "sensor",
16398
- "control",
16399
- "custom",
16400
- "package"
16439
+ var PipelineSlotSchema = _enum([
16440
+ "detector",
16441
+ "cropper",
16442
+ "classifier",
16443
+ "refiner",
16444
+ "audio-classifier"
16401
16445
  ]);
16402
- /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
16403
- var EventKindLevelSchema = _enum(["macro", "sub"]);
16404
- var EventKindDescriptorSchema = object({
16405
- /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
16406
- kind: string(),
16407
- /** i18n key resolved on the UI side; `label` is the English fallback. */
16408
- labelKey: string(),
16409
- /** English fallback label (kept for clients that don't translate). */
16410
- label: string(),
16411
- /** Hex color for timeline/legend rendering. */
16412
- color: string(),
16413
- /** Dictionary id → lucide component on the UI side. */
16414
- iconId: string(),
16415
- /** Legacy closed-vocab glyph — fallback for `iconId`. */
16416
- icon: EventKindIconSchema,
16417
- category: EventKindCategorySchema,
16418
- /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
16419
- parentKind: string().nullable(),
16420
- /** Derived from `parentKind`, explicit for the client tree. */
16421
- level: EventKindLevelSchema,
16422
- /** Which cap + device contributes this kind. For built-ins the camera
16423
- * itself; for sensor kinds the LINKED source device. */
16424
- source: object({
16425
- capName: string(),
16426
- deviceId: number()
16427
- })
16446
+ var PipelineEngineChoiceSchema = object({
16447
+ runtime: _enum(["node", "python"]),
16448
+ backend: string(),
16449
+ format: ModelFormatSchema$1,
16450
+ device: string().optional()
16428
16451
  });
16429
- /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
16430
- var EventKindsForDeviceSchema = object({
16431
- deviceId: number(),
16432
- kinds: array(EventKindDescriptorSchema).readonly()
16452
+ var AvailableEngineSchema = object({
16453
+ engine: PipelineEngineChoiceSchema,
16454
+ devices: array(object({
16455
+ id: string(),
16456
+ label: string(),
16457
+ description: string().optional()
16458
+ })).readonly(),
16459
+ defaultDevice: string()
16433
16460
  });
16434
- var SensorEventSchema = object({
16461
+ var PipelineDefaultStepSchema = lazy(() => object({
16462
+ addonId: string(),
16463
+ addonName: string(),
16464
+ slot: PipelineSlotSchema,
16465
+ inputClasses: array(string()).readonly(),
16466
+ outputClasses: array(string()).readonly(),
16467
+ enabled: boolean(),
16468
+ modelId: string(),
16469
+ children: array(PipelineDefaultStepSchema).readonly(),
16470
+ group: string().optional(),
16471
+ settings: record(string(), unknown()).optional()
16472
+ }));
16473
+ var PipelineTemplateStepSchema = lazy(() => object({
16474
+ addonId: string(),
16475
+ enabled: boolean(),
16476
+ modelId: string(),
16477
+ children: array(PipelineTemplateStepSchema).readonly(),
16478
+ settings: record(string(), unknown()).optional()
16479
+ }));
16480
+ var PipelineTemplateSchema$1 = object({
16435
16481
  id: string(),
16436
- /** The CAMERA the event is attributed to (a sensor linked to N cameras
16437
- * yields N rows, one per camera). */
16438
- deviceId: number(),
16439
- /** The linked sensor device whose state changed. */
16440
- sourceDeviceId: number(),
16441
- /** Event kind id — matches an `EventKindDescriptor.kind`. */
16442
- kind: string(),
16443
- /** Snapshot of the sensor cap's runtime-state slice at the change. */
16444
- value: record(string(), unknown()).nullable(),
16445
- timestamp: number()
16446
- });
16447
- var TrackPositionSchema = object({
16448
- x: number(),
16449
- y: number(),
16450
- timestamp: number(),
16451
- bbox: BoundingBoxSchema
16482
+ name: string(),
16483
+ createdAt: string(),
16484
+ updatedAt: string(),
16485
+ engine: PipelineEngineChoiceSchema,
16486
+ steps: array(PipelineTemplateStepSchema).readonly()
16452
16487
  });
16453
- var TrackSnapshotSchema = object({
16454
- timestamp: number(),
16455
- position: TrackPositionSchema,
16456
- /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
16457
- mediaKey: string()
16488
+ var PipelineModelOptionSchema = object({
16489
+ id: string(),
16490
+ name: string(),
16491
+ formats: record(string(), object({
16492
+ downloaded: boolean(),
16493
+ sizeMB: number()
16494
+ })),
16495
+ group: ModelVariantGroupSchema.optional(),
16496
+ legacy: boolean().optional(),
16497
+ provider: ModelProviderIdSchema.optional()
16458
16498
  });
16459
- /**
16460
- * Normalized 0..1 trajectory envelope (min/max over every position bbox,
16461
- * divided by the track's detection-frame dims), computed at persist time.
16462
- * Absent when the frame dims were unknown when the track was persisted
16463
- * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
16464
- */
16465
- var TrackEnvelopeSchema = object({
16466
- minX: number(),
16467
- minY: number(),
16468
- maxX: number(),
16469
- maxY: number()
16499
+ var ConfigFieldBridge = custom();
16500
+ var PipelineAddonSchemaSchema = object({
16501
+ id: string(),
16502
+ name: string(),
16503
+ slot: PipelineSlotSchema,
16504
+ inputClasses: array(string()).readonly(),
16505
+ outputClasses: array(string()).readonly(),
16506
+ childSlots: array(PipelineSlotSchema).readonly(),
16507
+ models: array(PipelineModelOptionSchema).readonly(),
16508
+ defaultModelId: string(),
16509
+ defaultModelIdByFormat: record(string(), string()).optional(),
16510
+ enabledByDefault: boolean().optional(),
16511
+ backfillIntoExistingOverrides: boolean().optional(),
16512
+ defaultConfidence: number(),
16513
+ group: string().optional(),
16514
+ configSchema: array(ConfigFieldBridge).readonly().optional()
16470
16515
  });
16471
- /**
16472
- * Row projection for track list queries. `full` (default) returns the
16473
- * complete Track including the frame-rate `positions[]` history and the
16474
- * `snapshots[]` references — megabytes across a page of tracks. `slim`
16475
- * keeps every scalar the list surfaces actually render (ids, class(es),
16476
- * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
16477
- * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
16478
- * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
16479
- * `getTrack`. Mirrors the event-store `projection` convention
16480
- * (`getObjectEvents` et al.).
16481
- */
16482
- var TrackProjectionSchema = _enum(["full", "slim"]);
16483
- /**
16484
- * One audio-classification label heard on the track's camera while the
16485
- * track was alive, aggregated per label. An "episode" is one persisted
16486
- * audio event (the confident-classification path: score ≥ the device's
16487
- * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
16488
- * one 32 ms inference chunk, so counts stay human-scaled.
16489
- */
16490
- var TrackAudioLabelSchema = object({
16516
+ var PipelineSlotSchemaSchema = object({
16517
+ id: PipelineSlotSchema,
16491
16518
  label: string(),
16492
- /** Highest classification score observed across the label's episodes. */
16493
- peakScore: number(),
16494
- /** Number of coalesced audio-event episodes carrying this label. */
16495
- count: number(),
16496
- firstAt: number(),
16497
- lastAt: number()
16519
+ priority: number(),
16520
+ parentSlot: PipelineSlotSchema.nullable(),
16521
+ addons: array(PipelineAddonSchemaSchema).readonly()
16498
16522
  });
16499
- /**
16500
- * How a track was produced. `pipeline` (default / absent) = the spatial
16501
- * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
16502
- * no positions, a single snapshot, and no bbox trajectory at all:
16503
- *
16504
- * - `sensor` — a linked sensor/control device state change.
16505
- * - `audio` — an audio event on the camera itself that was anomalous for
16506
- * THAT camera, loud, and heard while nothing visual was happening (D62).
16507
- *
16508
- * The spatial subsystems (tracker association, occupancy count, re-id /
16509
- * embedding, resurrection) MUST skip every synthetic source. Test for that
16510
- * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
16511
- * check silently readmits every source added after it was written.
16512
- */
16513
- var TrackSourceSchema = _enum([
16514
- "pipeline",
16515
- "sensor",
16516
- "audio"
16517
- ]);
16518
- /**
16519
- * Where a track sits in the RETRAIN lifecycle (D81).
16520
- *
16521
- * - `none` — never marked, or un-marked. Evictable.
16522
- * - `staging` — the operator wants this track as training material and has not
16523
- * finished with it. **This is the only state retention holds**: the track and
16524
- * everything it owns (object events, crops, keyframes, CLIP vector) survive
16525
- * the device's age window.
16526
- * - `trained` — the retrain page has taken what it needed. The frames it chose
16527
- * were COPIED into the retrain dataset at selection time, so the dataset no
16528
- * longer depends on the track's media and the track becomes EVICTABLE again.
16529
- * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
16530
- * a deliberate action of the retrain page, not a side effect of a checkbox.
16531
- *
16532
- * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
16533
- * the store's filter language has only positive equality and `whereIn` — no
16534
- * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
16535
- * would make the entire pre-column history immortal in one deploy.
16536
- */
16537
- var RetrainStatusSchema = _enum([
16538
- "none",
16539
- "staging",
16540
- "trained"
16541
- ]);
16542
- /**
16543
- * Per-track OPERATOR flags — set by hand from the admin UI or the viewer, never
16544
- * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
16545
- * so the two surfaces cannot drift.
16546
- *
16547
- * **Absent ≠ false.** A track that has never been touched omits the field; an
16548
- * explicitly un-flagged track carries `false`. Legacy rows written before the
16549
- * columns existed read as absent, and a consumer that needs a boolean should say
16550
- * `flag === true`, not `flag !== false`.
16551
- *
16552
- * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
16553
- * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
16554
- * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
16555
- * `trained` track reports `false` while refusing both writes. The boolean is
16556
- * kept because three surfaces drive a toggle off it; anything that needs to tell
16557
- * "never marked" from "already trained" must read `retrainStatus`.
16558
- *
16559
- * `debug` does NOT pin; it is attention, not durability.
16560
- *
16561
- * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
16562
- * A favourited track is skipped by retention the same way `staging` is, but
16563
- * it does not enter `none|staging|trained` and has no staging budget.
16564
- */
16565
- var TrackFlagFields = {
16566
- /** Operator marked this track as training material — i.e. `retrainStatus` is
16567
- * `'staging'`. */
16568
- markForTrain: boolean().optional(),
16569
- /** Operator marked this track for diagnostic attention. */
16570
- debug: boolean().optional(),
16571
- /** Operator favourited this track. Pins it against pruning. */
16572
- favourited: boolean().optional()
16573
- };
16574
- /**
16575
- * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
16576
- * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
16577
- * write patch, and the status is not something the toggle sets — it is what the
16578
- * toggle's boolean is derived from. Absent on an in-RAM track never touched;
16579
- * always present on a persisted row (the column default materialises `'none'`).
16580
- */
16581
- var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
16582
- /**
16583
- * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
16584
- * one flag can never clear the other — the toggles are independent and are
16585
- * driven from three surfaces that do not know about each other.
16586
- */
16587
- var TrackFlagsPatchSchema = object(TrackFlagFields);
16588
- /**
16589
- * The resolved flag state after a write. Both fields are REQUIRED here (absent
16590
- * collapses to `false`) so a caller can drive a toggle's checked state off the
16591
- * mutation result without a re-fetch.
16592
- */
16593
- var TrackFlagsSchema = object({
16594
- trackId: string(),
16595
- markForTrain: boolean(),
16596
- debug: boolean(),
16597
- favourited: boolean(),
16598
- /** The lifecycle state the boolean was derived from. Required here (unlike on
16599
- * a track row) because this shape is only ever produced by the write body,
16600
- * which always knows it — and a surface that has just written needs to render
16601
- * `trained` without a re-fetch. */
16602
- retrainStatus: RetrainStatusSchema
16523
+ var PipelineSchemaSchema = object({
16524
+ availableEngines: array(AvailableEngineSchema).readonly(),
16525
+ selectedEngine: PipelineEngineChoiceSchema,
16526
+ slots: array(PipelineSlotSchemaSchema).readonly()
16603
16527
  });
16604
- union([literal(1), literal(2)]);
16605
- /**
16606
- * WHO decided a label, and when. Carried per tier so a value can be traced to
16607
- * the step and model that produced it — which is what makes the write rule
16608
- * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
16609
- * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
16610
- *
16611
- * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
16612
- * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
16613
- * `migration:4g` for a value the 4g migration moved from the single-slot era —
16614
- * that value has no provenance, and the write rule lets ANY properly-attributed
16615
- * write of the same tier replace it regardless of score.
16616
- */
16617
- var LabelAttributionSchema = object({
16618
- stepId: string(),
16619
- modelId: string().optional(),
16620
- decidedAt: number(),
16528
+ var EngineProvisioningSchema = object({
16529
+ runtimeId: _enum([
16530
+ "onnx",
16531
+ "openvino",
16532
+ "coreml",
16533
+ "edgetpu"
16534
+ ]).nullable(),
16535
+ device: string().nullable(),
16536
+ state: _enum([
16537
+ "idle",
16538
+ "installing",
16539
+ "verifying",
16540
+ "ready",
16541
+ "failed"
16542
+ ]),
16543
+ progress: number().optional(),
16544
+ error: string().optional(),
16545
+ nextRetryAt: number().optional(),
16621
16546
  /**
16622
- * The GALLERY id behind a recognised tier-2 label — a face-gallery
16623
- * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
16624
- *
16625
- * The text alone is a DISPLAY NAME, and a display name is renameable: a
16626
- * notification rule authored on "Gianluca" stopped matching the moment the
16627
- * operator fixed the spelling in the gallery, and nothing said so. The id is
16628
- * the thing that does not move, so it is what a rule matches on
16629
- * (`NcConditions.identities`) and the text is what a human is shown.
16630
- *
16631
- * Absent when the label names no gallery row — a plate the OCR read but no
16632
- * vehicle claims, a sub-class, a species, any tier-1 value.
16547
+ * Gate A (config-correctness gate at engine change): human-readable
16548
+ * config issues surfaced EAGERLY when the node's engine changes — model
16549
+ * substitutions ("chose X, running Y") and zero-build steps ("no model
16550
+ * has a <format> build"). Additive/optional: informational only, never
16551
+ * enforced here `assertEngineReady` (readiness) still gates inference.
16552
+ * Absent/empty when the node-default tree resolves cleanly.
16633
16553
  */
16634
- identityId: string().optional()
16554
+ configIssues: array(string()).optional()
16635
16555
  });
16636
- /**
16637
- * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
16638
- * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
16639
- * track and its events always answer the same question the same way.
16640
- *
16641
- * Two scalar columns, not an array: every consumer wants "the coarse one" or
16642
- * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
16643
- * is tier 2, and each carries its own score + attribution.
16644
- *
16645
- * **Reading it.** What a human should be shown is `subLabel ?? label` — the
16646
- * finest thing known. Before 4g the single `label` column held the finest
16647
- * value, so a consumer that has not been updated reads the tier-1 slot and
16648
- * shows nothing on a species-only row; that is why the migration puts every
16649
- * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
16650
- * and why the read surfaces were changed in the same train.
16651
- *
16652
- * **Writing it.** The slots are independent, which is the whole point: a
16653
- * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
16654
- * migratorius`), so fineness cannot regress by construction. Within a tier the
16655
- * higher score wins. One rule, one implementation — see
16656
- * `pipeline/label-tier.ts` in addon-post-analysis.
16657
- */
16658
- var TieredLabelFields = {
16659
- /** Tier 1 the sub-class. See {@link LabelTierSchema}. */
16660
- label: string().optional(),
16661
- /** Confidence of the tier-1 value, as reported by the deciding step. */
16662
- labelScore: number().optional(),
16663
- /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
16664
- labelMeta: LabelAttributionSchema.optional(),
16665
- /** Tier 2 — the instance. See {@link LabelTierSchema}. */
16666
- subLabel: string().optional(),
16667
- /** Confidence of the tier-2 value, as reported by the deciding step. */
16668
- subLabelScore: number().optional(),
16669
- /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
16670
- subLabelMeta: LabelAttributionSchema.optional()
16671
- };
16672
- /** Per-camera slice of a training-export estimate. */
16673
- var TrainingExportDeviceTotalsSchema = object({
16674
- deviceId: number(),
16675
- tracks: number().int(),
16676
- files: number().int(),
16677
- bytes: number().int()
16556
+ var PipelineStepInputSchema = lazy(() => object({
16557
+ addonId: string(),
16558
+ modelId: string().optional(),
16559
+ enabled: boolean().default(true),
16560
+ children: array(PipelineStepInputSchema).optional(),
16561
+ settings: record(string(), unknown()).optional(),
16562
+ jumpDeviceKey: string().optional()
16563
+ }));
16564
+ var ModelSubstitutionSchema = object({
16565
+ addonId: string(),
16566
+ chosen: string(),
16567
+ running: string(),
16568
+ format: string()
16569
+ });
16570
+ var PipelineValidationIssueSchema = object({
16571
+ addonId: string(),
16572
+ kind: _enum(["unknown-addon", "no-format-build"]),
16573
+ detail: string()
16574
+ });
16575
+ var PipelineValidationResultSchema = object({
16576
+ ok: boolean(),
16577
+ issues: array(PipelineValidationIssueSchema).readonly(),
16578
+ substitutions: array(ModelSubstitutionSchema).readonly(),
16579
+ /** The node's `currentEngine.format` this validation ran against. */
16580
+ format: string()
16581
+ });
16582
+ var ReferenceImageEntrySchema = object({
16583
+ filename: string(),
16584
+ stepIds: array(string()).readonly().optional()
16585
+ });
16586
+ var ReferenceImageBodySchema = object({
16587
+ base64: string(),
16588
+ filename: string()
16589
+ });
16590
+ var ReferenceAudioEntrySchema = object({
16591
+ filename: string(),
16592
+ sizeKb: number()
16593
+ });
16594
+ var ReferenceAudioBodySchema = object({ base64: string() });
16595
+ var AudioBackendSchema = object({
16596
+ id: string(),
16597
+ name: string(),
16598
+ description: string(),
16599
+ available: boolean(),
16600
+ /**
16601
+ * Raw classifier labels this backend can emit (e.g. YAMNet's
16602
+ * 521-class set or Apple SoundAnalysis's 303-class set). Used by
16603
+ * the benchmark UI to populate the `enabledMicroClasses` filter
16604
+ * specific to the selected backend without a separate fetch.
16605
+ */
16606
+ rawLabels: array(string()).readonly().optional()
16607
+ });
16608
+ var AudioCapabilitiesSchema = object({
16609
+ activeBackend: string(),
16610
+ availableBackends: array(AudioBackendSchema).readonly(),
16611
+ sampleRate: number(),
16612
+ chunkDurationMs: number()
16613
+ });
16614
+ var DownloadModelResultSchema = object({
16615
+ filePath: string(),
16616
+ sizeMB: number(),
16617
+ durationMs: number()
16678
16618
  });
16679
16619
  /**
16680
- * What a training export WOULD contain. Computed from media index rows only —
16681
- * no blob is read to produce this.
16620
+ * Wrapper carrying a single test run's result. Replaces the legacy
16621
+ * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
16622
+ * canonical `AudioResult` from the Phase 6 output rework: one
16623
+ * `AudioDetection` per class above `minScore`, top-N candidates in
16624
+ * `debug.alternateLabels['audio-classifier']`, per-source timings in
16625
+ * `debug.stepTimings`. The outer `success`/`error` fields stay so the
16626
+ * benchmark UI can still report a clean failure when the classifier
16627
+ * cap isn't available.
16682
16628
  */
16683
- var TrainingExportSummarySchema = object({
16684
- generatedAt: number(),
16685
- trackCount: number().int(),
16686
- fileCount: number().int(),
16687
- byteCount: number().int(),
16688
- /** More marked tracks exist than a single pass carries. */
16689
- truncated: boolean(),
16690
- devices: array(TrainingExportDeviceTotalsSchema).readonly()
16629
+ var AudioTestResultSchema = object({
16630
+ success: boolean(),
16631
+ error: string().optional(),
16632
+ frame: custom().optional()
16691
16633
  });
16692
- var TrackSchema = object({
16693
- trackId: string(),
16694
- deviceId: number(),
16695
- className: string(),
16696
- ...TieredLabelFields,
16697
- producingDeviceName: string().optional(),
16698
- /** Track provenance. Absent `pipeline` (legacy rows). */
16699
- source: TrackSourceSchema.optional(),
16700
- firstSeen: number(),
16701
- lastSeen: number(),
16702
- /** Frame-rate position history (subject to maxPositionHistory cap). */
16703
- positions: array(TrackPositionSchema).readonly(),
16704
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
16705
- * saveThumbnails policy). */
16706
- snapshots: array(TrackSnapshotSchema).readonly(),
16707
- /** Deduplicated zones the track has entered at least once. Zone IDS. */
16708
- zonesVisited: array(string()).readonly(),
16634
+ var PipelineConfigBridge = custom();
16635
+ var ConfigUISchemaBridge = custom();
16636
+ var ConfigUISchemaNullableBridge = custom();
16637
+ var InferenceCapabilitiesBridge = custom();
16638
+ var ModelAvailabilityListBridge = custom();
16639
+ var PipelineRunResultBridge = custom();
16640
+ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
16641
+ modelId: string(),
16642
+ settings: record(string(), unknown()).readonly()
16643
+ }))), method(object({ steps: record(string(), object({
16644
+ modelId: string(),
16645
+ settings: record(string(), unknown()).readonly()
16646
+ })) }), object({ success: literal(true) }), {
16647
+ kind: "mutation",
16648
+ auth: "admin"
16649
+ }), method(object({ nodeId: string() }), object({
16650
+ success: literal(true),
16651
+ clearedDevices: number()
16652
+ }), {
16653
+ kind: "mutation",
16654
+ auth: "admin"
16655
+ }), method(object({ nodeId: string() }), object({ unhealthy: array(object({
16656
+ /** `<backend>:<device>`, e.g. `openvino:gpu`. */
16657
+ deviceKey: string(),
16709
16658
  /**
16710
- * Human NAMES for {@link zonesVisited}, resolved at READ time against the
16711
- * `zones` capability.
16712
- *
16713
- * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
16714
- * and no card can render — so every free-text search surface was structurally
16715
- * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
16716
- * just returned nothing. Resolving here rather than in each client keeps ONE
16717
- * derivation and costs the clients no extra call (the `zones` cap is
16718
- * per-device, so a client-side resolve would be a per-camera fan-out on a
16719
- * surface built to avoid exactly that).
16720
- *
16721
- * Resolved, never invented: a zone deleted since the track was written has no
16722
- * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
16723
- * two are not positionally aligned. Absent when the track visited no zone, or
16724
- * when the zone catalogue could not be read.
16659
+ * `failed` the per-device restart budget is exhausted; no pool
16660
+ * will be spawned until an operator re-arms it or the runner
16661
+ * respawns. `backoff` — under budget, waiting out the backoff (or
16662
+ * a cached pool observed dead and not yet condemned).
16725
16663
  */
16726
- zoneNames: array(string()).readonly().optional(),
16727
- /** Deduplicated set of detector classes observed for this track over its
16728
- * life (a track may be reclassified, e.g. person→vehicle). Absent on
16729
- * legacy rows written before class accumulation shipped. */
16730
- classes: array(string()).readonly().optional(),
16731
- /** Cumulative normalized distance travelled (0..1 units = full frame width). */
16732
- totalDistance: number(),
16733
- state: TrackStateSchema,
16734
- active: boolean(),
16735
- /** Deterministic key-event importance score in [0,1] (server-computed at
16736
- * track expiry, recomputed on late label). Absent on legacy rows written
16737
- * before scoring shipped — consumers degrade to absence / compute-on-read. */
16738
- importance: number().optional(),
16739
- /** Id of the track's highest-confidence ObjectEvent (its representative
16740
- * "best" frame). Absent when the track produced no object events. */
16741
- bestEventId: string().optional(),
16742
- /** Tag of the importance sub-signal that dominated the score
16743
- * (identity|dwell|proximity|class|confidence|travel|zone). */
16744
- importanceReason: string().optional(),
16745
- /** Audio-classification labels heard on the camera during the track's
16746
- * life (score ≥ device `classificationMinScore`), aggregated per label.
16747
- * Absent on legacy rows / tracks with no confident audio. */
16748
- audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
16749
- /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
16750
- * Populated from the persisted envelope columns on historical reads;
16751
- * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
16752
- envelope: TrackEnvelopeSchema.optional(),
16664
+ state: _enum(["failed", "backoff"]),
16665
+ /** Epoch ms of the death that produced this state. */
16666
+ since: number(),
16667
+ /** Pool deaths inside the current window. */
16668
+ deaths: number(),
16669
+ /** The last death's message. */
16670
+ lastError: string()
16671
+ })).readonly() })), method(object({
16672
+ nodeId: string(),
16673
+ deviceKey: string()
16674
+ }), object({ rearmed: boolean() }), {
16675
+ kind: "mutation",
16676
+ auth: "admin"
16677
+ }), 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({
16678
+ name: string(),
16679
+ steps: array(PipelineTemplateStepSchema).readonly(),
16680
+ engine: PipelineEngineChoiceSchema
16681
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
16682
+ id: string(),
16683
+ name: string().optional(),
16684
+ steps: array(PipelineTemplateStepSchema).readonly().optional()
16685
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
16686
+ addonId: string(),
16687
+ modelId: string(),
16688
+ format: ModelFormatSchema$1
16689
+ }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
16690
+ addonId: string(),
16691
+ modelId: string(),
16692
+ format: ModelFormatSchema$1
16693
+ }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
16694
+ engine: PipelineEngineChoiceSchema.optional(),
16695
+ steps: array(PipelineStepInputSchema).min(1),
16696
+ frame: FrameInputSchema.optional(),
16753
16697
  /**
16754
- * A face DETECTOR found a face on this track — nothing more. It says the
16755
- * detail plane produced a `face` detail; it does NOT say the face was
16756
- * embedded, matched, above `minFacePx`, or that the recognizer was even
16757
- * enabled. Set once and never cleared.
16758
- *
16759
- * **This exists so "face present but not recognised" is expressible.** A
16760
- * recognised identity lands in `subLabel` (attributed to the face chain via
16761
- * `subLabelMeta.stepId`), so before this field a track with an unmatched face
16762
- * and a track with no face at all were byte-identical on the wire and no
16763
- * surface could tell them apart. The read is `hasFace === true && subLabel
16764
- * === undefined`.
16765
- *
16766
- * **Absent ≠ false.** Every row written before the column existed omits it,
16767
- * and so does every server that predates the field — a consumer must test
16768
- * `=== true` and render nothing otherwise, never infer "no face".
16698
+ * Process-local lazy frame. Valid only when caller and provider resolve
16699
+ * in the same execution-group process; split/cross-node callers use
16700
+ * `frame`/`image` inline compatibility instead.
16769
16701
  */
16770
- hasFace: boolean().optional(),
16702
+ frameRef: FrameRefSchema.optional(),
16771
16703
  /**
16772
- * This track has a face row IN THE GALLERY: a crop **and** an embedding a
16773
- * face an operator could ASSIGN to an identity.
16774
- *
16775
- * The STRICT twin of {@link hasFace}, and the pair only earns its keep
16776
- * because the two disagree. `hasFace` is stamped at the TOP of the face
16777
- * branch, before every gate, and means no more than "a face detector produced
16778
- * a face detail". This one is stamped at the single moment the gallery row
16779
- * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
16780
- * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
16781
- * candidate gate, the imageless-track drop (no crop was ever captured) and
16782
- * the crop-store drop. Everything between the detector and that insert can
16783
- * legitimately refuse the face, so a flag written any earlier promises the
16784
- * operator something to assign and delivers nothing.
16785
- *
16786
- * **Independent of recognition.** A face collected but never auto-matched is
16787
- * still assignable — it is in fact the face an operator most wants to reach —
16788
- * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
16789
- * `subLabel`; this says only that the raw material exists.
16790
- *
16791
- * **Set once, never cleared.** A track that produced a gallery row produced
16792
- * one; deleting the row later is the gallery's business, not this flag's.
16793
- *
16794
- * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
16795
- * before the column omits it, and so does every server that predates the
16796
- * field. A consumer must test `=== true` and render nothing otherwise —
16797
- * never infer "no assignable face".
16704
+ * CB5 shm passthrough a `FrameHandle` naming the same ring slot
16705
+ * the decoded pixels live in. One more member of the one-of
16706
+ * frame/frameHandle/image/imageBase64/referenceImage group.
16798
16707
  */
16799
- hasEmbeddedFace: boolean().optional(),
16708
+ frameHandle: FrameHandleSchema.optional(),
16709
+ imageBase64: string().optional(),
16800
16710
  /**
16801
- * This subject CONTAINS a folded rider a person the rider-pairing step
16802
- * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
16803
- * so the passage is tracked once and as a VEHICLE.
16804
- *
16805
- * It exists because the fold's record was dishonest. D34 and the code both
16806
- * said "the person is not lost — it is reported so both entities stay on the
16807
- * record"; in fact the pair went into a per-processor RAM field behind an
16808
- * accessor nobody called, and every durable surface said `vehicle`, full
16809
- * stop. This is the composition note that makes the row true.
16810
- *
16811
- * A COMPOSITION, never a class and never a label. "This vehicle contains a
16812
- * person" is not an answer to "what is this" — both label tiers would refuse
16813
- * a macro token anyway (D89), and correctly. Nothing here changes what the
16814
- * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
16815
- * and a `person` rule still does not fire for someone cycling past.
16816
- *
16817
- * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
16818
- * the column, and every hub that predates the field, omits it. Test
16819
- * `=== true` and render nothing otherwise — never infer "no rider".
16711
+ * Binary JPEG bytespreferred over `imageBase64` on internal
16712
+ * hops (hub forked worker via Moleculer MsgPack) because it
16713
+ * skips the 33% base64 overhead + the per-call base64 decode on
16714
+ * the detection-pipeline worker. Callers can pass either; exactly
16715
+ * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
16820
16716
  */
16821
- hasRider: boolean().optional(),
16822
- ...TrackFlagFields,
16823
- ...TrackRetrainFields
16824
- });
16825
- var BaseEventFields = {
16826
- id: string(),
16827
- deviceId: number(),
16828
- timestamp: number()
16829
- };
16830
- var MotionEventSchema = object({
16831
- ...BaseEventFields,
16832
- kind: literal("motion"),
16833
- regionCount: number(),
16834
- /** Heavy JSON array omitted in slim projection. */
16835
- regions: array(object({
16836
- bbox: BoundingBoxSchema,
16837
- pixelCount: number(),
16838
- intensity: number()
16839
- })).readonly().optional(),
16840
- /** Omitted in slim projection. */
16841
- frameWidth: number().optional(),
16842
- /** Omitted in slim projection. */
16843
- frameHeight: number().optional(),
16844
- /** Populated by B5 (recording playback URL for this event). */
16845
- mediaUrl: string().optional()
16846
- });
16717
+ image: _instanceof(Uint8Array).optional(),
16718
+ referenceImage: string().optional(),
16719
+ deviceId: number().optional(),
16720
+ sessionId: string().optional(),
16721
+ /**
16722
+ * Execution plane. 'full' (default) runs the whole tree — benchmark,
16723
+ * reference-image, and detail-subtree calls. 'frame' is the live
16724
+ * per-frame dispatch: ONLY root-plane steps run; crop children
16725
+ * (inputClasses ≠ null) are skipped and served per-track via
16726
+ * pipelineRunner.runDetailSubtree (two-plane design).
16727
+ */
16728
+ plane: _enum(["full", "frame"]).optional(),
16729
+ /**
16730
+ * Inference-device selector (Phase 2 multi-device). Format
16731
+ * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
16732
+ * Omitted ⇒ the runner's default device (current single-engine
16733
+ * behaviour). Selects WHICH device pool of the node runs the call.
16734
+ */
16735
+ deviceKey: string().optional(),
16736
+ /**
16737
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
16738
+ * when the parent crop was resolved from the frame's retained NATIVE
16739
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
16740
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
16741
+ * resolution from that surface — the SAME quality path faces already
16742
+ * had — instead of the downscaled parent tile. `handle` keys the native
16743
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
16744
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
16745
+ * the executor's crop-normalized child ROI back into frame-normalized
16746
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
16747
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
16748
+ * (today's behaviour on the fallback path).
16749
+ */
16750
+ nativeCropRef: NativeCropRefSchema.optional()
16751
+ }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
16752
+ engine: PipelineEngineChoiceSchema.optional(),
16753
+ steps: array(PipelineStepInputSchema).min(1),
16754
+ frames: array(FrameInputSchema).min(1).max(255),
16755
+ deviceId: number().optional(),
16756
+ sessionId: string().optional(),
16757
+ /**
16758
+ * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
16759
+ * the batch to the Python pool's bench preprocess cache
16760
+ * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
16761
+ * preprocessed ONCE and every later inference is a pure-inference cache
16762
+ * hit — the sustained-throughput run measures inference, not
16763
+ * decode+preprocess+infer. Omitted/0 for live frames (all different →
16764
+ * full preprocess every call, correct). Fresh per sustained run;
16765
+ * released via `uncacheFrame`.
16766
+ */
16767
+ frameId: number().int().nonnegative().optional(),
16768
+ /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
16769
+ deviceKey: string().optional()
16770
+ }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
16771
+ data: _instanceof(Uint8Array),
16772
+ width: number().int().positive(),
16773
+ height: number().int().positive(),
16774
+ format: _enum([
16775
+ "rgb",
16776
+ "bgr",
16777
+ "gray"
16778
+ ])
16779
+ }), object({
16780
+ frameId: number(),
16781
+ width: number(),
16782
+ height: number()
16783
+ }), { kind: "mutation" }), method(object({
16784
+ stepId: string(),
16785
+ frameId: number().int()
16786
+ }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
16787
+ batchMode: string(),
16788
+ windowMs: number(),
16789
+ maxBatchSize: number(),
16790
+ concurrency: number()
16791
+ })), method(_void(), array(object({
16792
+ engineKey: string(),
16793
+ engine: PipelineEngineChoiceSchema,
16794
+ modelsLoaded: array(string()).readonly(),
16795
+ inUseByCameras: array(number()).readonly(),
16796
+ /**
16797
+ * Origin of this resident factory.
16798
+ * - `runtime` — main camera-serving engine (no idle TTL).
16799
+ * - `warm-override` — benchmark/test override held in the warm
16800
+ * cache; auto-disposed after the idle TTL.
16801
+ * - `device-pool` — a concurrent per-device pool (Phase 2
16802
+ * multi-device, keyed by `deviceKey`) resolved
16803
+ * via `resolveDeviceFactory`. Runs alongside the
16804
+ * `runtime` engine on a DIFFERENT accelerator
16805
+ * (NPU / iGPU / Coral) — this is how the
16806
+ * Engines tab shows all pools running at once.
16807
+ */
16808
+ kind: _enum([
16809
+ "runtime",
16810
+ "warm-override",
16811
+ "device-pool"
16812
+ ]),
16813
+ /** Native pid of the underlying Python pool (null when no pool). */
16814
+ poolPid: number().nullable(),
16815
+ /** ms since this factory was last used (null when not warm-tracked). */
16816
+ idleMs: number().nullable(),
16817
+ /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
16818
+ idleTtlMs: number().nullable()
16819
+ })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
16820
+ kind: "mutation",
16821
+ auth: "admin"
16822
+ }), method(object({
16823
+ engine: PipelineEngineChoiceSchema,
16824
+ force: boolean().optional()
16825
+ }), object({
16826
+ success: boolean(),
16827
+ reason: string().optional()
16828
+ }), {
16829
+ kind: "mutation",
16830
+ auth: "admin"
16831
+ }), 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({
16832
+ addonId: string(),
16833
+ modelId: string(),
16834
+ filename: string().optional(),
16835
+ settings: record(string(), unknown()).optional()
16836
+ }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
16847
16837
  /**
16848
- * Which detection SOURCE produced an object event. `pipeline` = the ML
16849
- * detection pipeline (decoded-frame inference); `onboard` = the camera's
16850
- * native on-device AI. Both flow through the SAME analysis layers (zoning,
16851
- * tracking, per-kind persistence) but stay distinguishable so consumers
16852
- * (advanced-notifier, occupancy, …) can select which source(s) to act on.
16853
- * Absent on legacy rows treat as `pipeline`.
16838
+ * Per-stage gating mode applied to the zones a rule references.
16839
+ *
16840
+ * - `include`: the rule contributes to a **whitelist** for its stage.
16841
+ * When at least one `include` rule fires for a stage, only entities
16842
+ * inside one of those zones pass that stage.
16843
+ * - `exclude`: the rule contributes to a **blacklist** for its stage.
16844
+ * Entities inside one of those zones are dropped at that stage.
16845
+ *
16846
+ * `monitor`-style observation (count without filtering) is not a rule
16847
+ * mode — zones without any matching rule are observed naturally by
16848
+ * `zone-analytics` (live snapshot + history), so an "I just want to
16849
+ * count, not filter" use case needs no rule at all.
16854
16850
  */
16855
- var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
16851
+ var ZoneRuleModeEnum = _enum(["include", "exclude"]);
16856
16852
  /**
16857
- * The confirmed zone crossing that produced an object event. Present ONLY on
16858
- * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
16859
- * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
16860
- * appearance event carry none, so a rule asking for a direction fails closed
16861
- * on them.
16853
+ * Per-consumer rule that references existing zones (geometry) and
16854
+ * defines how a specific pipeline stage should treat them. Each
16855
+ * consumer addon owns its own `ZoneRule[]` array in its per-device
16856
+ * settings:
16862
16857
  *
16863
- * Exactly ONE crossing per event: the emitter turns each confirmed crossing
16864
- * into its own event, so a frame in which a track enters A while leaving B
16865
- * produces two events with two directions — never one ambiguous row.
16858
+ * - `addon-motion-wasm` `motionZoneRules: ZoneRule[]` (motion stage)
16859
+ * - `addon-detection-pipeline` `detectionZoneRules: ZoneRule[]` (detection stage)
16860
+ * - future: notification rules, audio gating, etc.
16866
16861
  *
16867
- * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
16868
- * membership the box has NOW, and by definition it no longer contains the zone
16869
- * that was just left. Without the id here, a zone-scoped rule could never match
16870
- * the exit it asked for.
16862
+ * One rule applies to N zones (`zoneIds[]`) so the operator can
16863
+ * express "ignore motion in ALL of {garden, street}" with a single
16864
+ * rule. `classFilter` narrows the rule to specific object classes
16865
+ * "drop person detections in the street, but keep cars" is one
16866
+ * `exclude` rule with `classFilter: ['person']`.
16867
+ *
16868
+ * `enabled` is a soft toggle — the operator can keep the rule
16869
+ * configured but inert without deleting it.
16871
16870
  */
16872
- var ZoneCrossingSchema = object({
16873
- direction: _enum(["enter", "exit"]),
16874
- /** Admin zone id crossed. */
16875
- zoneId: string(),
16876
- /** Zone display name at crossing time (falls back to the id). */
16877
- zoneName: string().optional()
16878
- });
16879
- var ObjectEventSchema = object({
16880
- ...BaseEventFields,
16881
- kind: literal("object"),
16882
- /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
16883
- source: DetectionSourceSchema.optional(),
16871
+ var ZoneRuleSchema = object({
16872
+ /** Stable rule id — survives edits, used by the UI for diffing. */
16873
+ id: string(),
16874
+ /** Optional human-readable label rendered in the rule editor. */
16875
+ name: string().optional(),
16876
+ /** Zones this rule targets. The rule's `mode` applies to ALL
16877
+ * listed zones (OR-set: a detection in any one of them counts).
16878
+ * At least one zone id required — a rule with no targets is a
16879
+ * configuration mistake and the form validator rejects it. */
16880
+ zoneIds: array(string()).min(1).readonly(),
16881
+ mode: ZoneRuleModeEnum,
16884
16882
  /**
16885
- * Inference-frame id shared by every object event emitted from the SAME frame
16886
- * the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
16887
- * 2 people + 1 dog) under one full frame, and link a track's frames over time
16888
- * (group by `trackId`, pick a representative `frameId` as the parent frame).
16889
- * Optional for backward-compat with pre-existing rows / the slim projection
16890
- * includes it (it is light). Absent on rows written before this field.
16883
+ * Class names this rule applies to. Empty / undefined rule
16884
+ * applies to every class. Class strings match the `macroClass`
16885
+ * field on detections (e.g. `person`, `car`, `dog`).
16891
16886
  */
16892
- frameId: string().optional(),
16893
- /** Omitted in slim projection. */
16894
- trackId: string().optional(),
16895
- className: string(),
16896
- ...TieredLabelFields,
16897
- /** Omitted in slim projection. */
16898
- confidence: number().optional(),
16899
- /** Heavy JSON — omitted in slim projection. */
16900
- bbox: BoundingBoxSchema.optional(),
16901
- /** Heavy JSON — omitted in slim projection. */
16902
- zones: array(string()).readonly().optional(),
16903
- /** Omitted in slim projection. */
16904
- state: TrackStateSchema.optional(),
16887
+ classFilter: array(string()).readonly().optional(),
16905
16888
  /**
16906
- * The zone crossing this event IS, when it is one. Absent on every other
16907
- * event kind (movement state, appearance, package) see
16908
- * {@link ZoneCrossingSchema}. Omitted in slim projection.
16889
+ * Minimum bbox/mask overlap (0–1) with any of the rule's zones
16890
+ * required to consider an entity "in the zone". Defaults to the
16891
+ * consumer's stage default when omitted. Kept for back-compat with
16892
+ * existing per-rule overrides; new operators pick the value via
16893
+ * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
16894
+ * set, the lower-level engine reads it as a 0–1 fraction.
16909
16895
  */
16910
- zoneCrossing: ZoneCrossingSchema.optional(),
16911
- /** Detection-frame dimensions in pixels — let consumers normalize the
16912
- * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
16913
- frameWidth: number().optional(),
16914
- frameHeight: number().optional(),
16915
- /** MediaStore key for the crop attached to this event (if any). */
16916
- mediaKey: string().optional(),
16917
- /** Design B: MediaStore key of the track's native-resolution key frame (the
16918
- * best-detection full frame). Resolve via the event-media data-plane
16919
- * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
16920
- * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
16921
- * sources — consumers fall back to `mediaKey` (the tight crop). */
16922
- keyFrameMediaKey: string().optional(),
16923
- /** Populated by B5 (recording playback URL for this event). */
16924
- mediaUrl: string().optional(),
16925
- /** The parent track's key-event importance [0,1], propagated to every object
16926
- * event of the track (so an event row can be sorted by importance without a
16927
- * track join). Absent on legacy rows / before the track was scored. */
16928
- importance: number().optional()
16896
+ overlapThreshold: number().min(0).max(1).optional(),
16897
+ /**
16898
+ * Operator-friendly version of `overlapThreshold` the percentage
16899
+ * of the detection's bbox that must lie inside the zone for the
16900
+ * rule to match. Documented default is 85%; the engine substitutes
16901
+ * that when the field is omitted (kept optional so existing rules
16902
+ * stored without it stay valid).
16903
+ *
16904
+ * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
16905
+ * rule, the engine prefers `bboxInclusionPct` because it's the
16906
+ * field exposed in the UI. Internally both feed the same gate.
16907
+ */
16908
+ bboxInclusionPct: number().min(0).max(100).optional(),
16909
+ /**
16910
+ * When `true` and a detection has a segmentation mask, use the
16911
+ * mask for overlap instead of the bbox. Detection-stage only;
16912
+ * motion rules ignore this field.
16913
+ */
16914
+ preferMask: boolean().optional(),
16915
+ /**
16916
+ * Soft-toggle: `false` disables the rule without deleting it.
16917
+ * Defaults to `true` so operators creating a rule via the UI
16918
+ * see it active immediately.
16919
+ */
16920
+ enabled: boolean().default(true)
16929
16921
  });
16930
- var AudioEventSchema = object({
16931
- ...BaseEventFields,
16932
- kind: literal("audio"),
16933
- rms: number(),
16934
- dbfs: number(),
16935
- classification: object({
16936
- className: string(),
16937
- originalClass: string().optional(),
16938
- score: number()
16939
- }).optional(),
16940
- /** Populated by B5 (recording playback URL for this event). */
16941
- mediaUrl: string().optional()
16922
+ array(ZoneRuleSchema).readonly();
16923
+ /**
16924
+ * Zone — pure geometry + identity. NO filtering behaviour.
16925
+ *
16926
+ * Zones describe **where** in the frame the operator wants to flag
16927
+ * something; consumer-owned {@link ZoneRule} arrays describe **how**
16928
+ * each pipeline stage uses them. Splitting the two means a single
16929
+ * polygon "Driveway" can simultaneously back a motion-exclude rule,
16930
+ * a detection-include rule on `['car']`, and an occupancy aggregate
16931
+ * — without three duplicated polygons.
16932
+ *
16933
+ * Owned by the orchestrator addon (provider) and mirrored into the
16934
+ * `zones` device-state slice on every mutation. Consumers
16935
+ * (motion-wasm, pipeline-executor, analytics, admin UI) read either
16936
+ * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
16937
+ * mirror with `onChanged`).
16938
+ *
16939
+ * Coordinates are normalised fractions of the frame (0–1) so zones
16940
+ * survive resolution changes and stream profile switches.
16941
+ *
16942
+ * `kind` discriminates between full polygons (closed regions used
16943
+ * for intrusion / occupancy filters) and tripwires (open 2-point
16944
+ * line segments used for cross events). Onboard / firmware-reported
16945
+ * zones (Reolink, ONVIF) are out of scope for now — see the deferred
16946
+ * task list.
16947
+ */
16948
+ var ZoneKindEnum = _enum(["polygon", "tripwire"]);
16949
+ /** Polygon vertex in fraction-of-frame coordinates (0–1). */
16950
+ var PolygonPointSchema = object({
16951
+ x: number(),
16952
+ y: number()
16942
16953
  });
16943
- var MediaFileKindEnum = _enum([
16944
- "crop",
16945
- "thumbnail",
16946
- "snapshot",
16947
- "firstFrame",
16948
- "lastFrame",
16949
- "fullFrame",
16950
- "fullFrameBoxed",
16951
- "faceCrop",
16952
- "plateCrop",
16953
- "keyFrame",
16954
- "keyFrameSmall",
16955
- "thumbnailSmall"
16956
- ]);
16957
- var MediaFileSchema = object({
16958
- key: string(),
16959
- kind: MediaFileKindEnum,
16960
- base64: string(),
16961
- sizeBytes: number(),
16962
- timestamp: number()
16954
+ /** A camera detection zone — pure geometry/identity. */
16955
+ var ZoneSchema = object({
16956
+ id: string(),
16957
+ name: string(),
16958
+ kind: ZoneKindEnum.default("polygon"),
16959
+ /** Polygon vertices, fraction of frame (0–1). */
16960
+ polygon: array(PolygonPointSchema).readonly(),
16961
+ /** Visual color for UI rendering. */
16962
+ color: string().default("#3b82f6")
16963
16963
  });
16964
16964
  /**
16965
- * One media row WITHOUT its bytes.
16965
+ * Zones capability per-camera CRUD over polygon detection zones.
16966
16966
  *
16967
- * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
16968
- * 140 s track), and a client that renders tiles from the media data plane needs
16969
- * to know only WHAT EXISTS the bytes then arrive per tile, lazily, over HTTP
16970
- * with an immutable cache, instead of all at once inside a tRPC response that
16971
- * blocks the whole view.
16967
+ * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
16968
+ * to per-device settings and mirrors into the `zones` device-state
16969
+ * slice on every mutation, so downstream consumers can subscribe via
16970
+ * `dev.state.zones.onChanged`.
16972
16971
  *
16973
- * `sizeBytes` is carried because it is what lets a client decide between the
16974
- * stored blob and a `?variant=thumb` rendering without fetching either.
16972
+ * The cap surface only handles geometry + identity; filtering
16973
+ * behaviour (per-class, include/exclude, threshold) lives in the
16974
+ * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
16975
+ * `capabilities/schemas/zone-rule.js`.
16975
16976
  */
16976
- var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
16977
+ var zonesCapability = {
16978
+ name: "zones",
16979
+ scope: "device",
16980
+ mode: "singleton",
16981
+ deviceTypes: [DeviceType.Camera],
16982
+ methods: {
16983
+ listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
16984
+ addZone: method(object({
16985
+ deviceId: number(),
16986
+ zone: ZoneSchema
16987
+ }), _void(), {
16988
+ kind: "mutation",
16989
+ auth: "admin"
16990
+ }),
16991
+ removeZone: method(object({
16992
+ deviceId: number(),
16993
+ zoneId: string()
16994
+ }), _void(), {
16995
+ kind: "mutation",
16996
+ auth: "admin"
16997
+ }),
16998
+ updateZone: method(object({
16999
+ deviceId: number(),
17000
+ zone: ZoneSchema
17001
+ }), _void(), {
17002
+ kind: "mutation",
17003
+ auth: "admin"
17004
+ })
17005
+ },
17006
+ /**
17007
+ * Runtime-state slice — the live zone catalogue mirrored by the
17008
+ * orchestrator on every CRUD mutation. Consumers read via
17009
+ * `device.state.zones.value` / `.watch(...)` without round-tripping
17010
+ * the cap, and the codegen DeviceProxy auto-wires the reactive
17011
+ * handle. Slice shape is `{ zones: Zone[] }` so future extensions
17012
+ * (e.g. zone groupings) can sit alongside the polygon list.
17013
+ */
17014
+ runtimeState: object({ zones: array(ZoneSchema).readonly() }),
17015
+ /**
17016
+ * 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.
17017
+ *
17018
+ * See `RuntimeStateDurability`. Enforced by
17019
+ * `scripts/check-runtime-state-durability.ts`.
17020
+ */
17021
+ durability: "restored"
17022
+ };
16977
17023
  /**
16978
- * The MACRO tier of an annotation — a CLOSED set.
17024
+ * pipeline-analytics device-scoped wrapper cap. Refines raw
17025
+ * per-frame detections emitted by the pipeline runner into tracked
17026
+ * objects, per-kind event collections (motion / object / audio), and
17027
+ * persisted media. Owns the post-detection domain end-to-end:
16979
17028
  *
16980
- * This is what the exported detector predicts, so a typo here is a new class
16981
- * with one example in it. `label` and `subLabel` are open strings by contrast:
16982
- * the whole point of the page is teaching the model things it does not know
16983
- * yet, and constraining that vocabulary would make it useless.
17029
+ * runner emits PipelineInferenceResult
17030
+ * (event bus)
17031
+ * pipeline-analytics subscriber
17032
+ * SORT tracker + zone engine + state analyzer + event emitter
17033
+ * → three DB collections (one per kind), one FS media tree, one
17034
+ * unified event emitter (FrameTracked + TrackStarted/Ended +
17035
+ * DetectionEvent on bus)
16984
17036
  *
16985
- * A macro class is NEVER a label. The provider refuses a write whose `label` or
16986
- * `subLabel` is one of these values, in any casing, because once `person`
16987
- * exists in both tiers "every person box" stops being answerable without
16988
- * knowing every string anyone ever typed — and the damage is retroactive.
17037
+ * Pure subscriber model. No `processFrame` cap method the runner
17038
+ * already publishes the raw frame on the bus. The cap surface is
17039
+ * only QUERIES + per-device settings, bound on/off via
17040
+ * `device-manager.setWrapperActive`. `defaultActive: true` because
17041
+ * every camera with a detection pipeline wants its raw detections
17042
+ * refined; operators opt out per-device via BindingsTab when needed.
17043
+ *
17044
+ * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
17045
+ * (per-device surface) and `track-trail` caps — see P11 cleanup.
16989
17046
  */
16990
- var RetrainMacroClassSchema = _enum([
17047
+ var TrackStateSchema = _enum([
17048
+ "new",
17049
+ "entered",
17050
+ "left",
17051
+ "moving",
17052
+ "idle"
17053
+ ]);
17054
+ var EventKindSchema = _enum([
17055
+ "motion",
17056
+ "object",
17057
+ "audio"
17058
+ ]);
17059
+ /**
17060
+ * Spatial filter for `listTracks` — the rect + polygon variants of the shared
17061
+ * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
17062
+ * of the camera frame (top-left origin), matching the drawing-plane editor.
17063
+ */
17064
+ var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
17065
+ /** Closed icon vocabulary so clients render a known glyph per kind. */
17066
+ var EventKindIconSchema = _enum([
17067
+ "motion",
17068
+ "audio",
16991
17069
  "person",
16992
17070
  "vehicle",
16993
17071
  "animal",
17072
+ "door",
17073
+ "pir",
17074
+ "smoke",
17075
+ "water",
17076
+ "button",
16994
17077
  "package",
16995
- "face",
16996
- "plate"
17078
+ "generic"
16997
17079
  ]);
16998
- /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
16999
- var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
17000
- /** Did a human draw this box, or did the assist propose it? */
17001
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
17002
- /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
17003
- var RetrainBboxSchema = object({
17004
- x: number(),
17005
- y: number(),
17006
- w: number(),
17007
- h: number()
17080
+ var EventKindCategorySchema = _enum([
17081
+ "motion",
17082
+ "audio",
17083
+ "detection",
17084
+ "sensor",
17085
+ "control",
17086
+ "custom",
17087
+ "package"
17088
+ ]);
17089
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
17090
+ var EventKindLevelSchema = _enum(["macro", "sub"]);
17091
+ var EventKindDescriptorSchema = object({
17092
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
17093
+ kind: string(),
17094
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
17095
+ labelKey: string(),
17096
+ /** English fallback label (kept for clients that don't translate). */
17097
+ label: string(),
17098
+ /** Hex color for timeline/legend rendering. */
17099
+ color: string(),
17100
+ /** Dictionary id → lucide component on the UI side. */
17101
+ iconId: string(),
17102
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
17103
+ icon: EventKindIconSchema,
17104
+ category: EventKindCategorySchema,
17105
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
17106
+ parentKind: string().nullable(),
17107
+ /** Derived from `parentKind`, explicit for the client tree. */
17108
+ level: EventKindLevelSchema,
17109
+ /** Which cap + device contributes this kind. For built-ins the camera
17110
+ * itself; for sensor kinds the LINKED source device. */
17111
+ source: object({
17112
+ capName: string(),
17113
+ deviceId: number()
17114
+ })
17008
17115
  });
17009
- /**
17010
- * One annotated subject.
17011
- *
17012
- * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
17013
- * (letterboxed root / zone-cropped package / subject-cropped classifier) are
17014
- * derived from it at export and never stored — storing them is how one feature
17015
- * space ends up holding two crops of the same subject (D52).
17016
- */
17017
- var RetrainAnnotationSchema = object({
17018
- id: string(),
17019
- trackId: string(),
17116
+ /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
17117
+ var EventKindsForDeviceSchema = object({
17020
17118
  deviceId: number(),
17021
- /** The COPY in retrain storage — never the source track's media key. */
17022
- mediaKey: string(),
17023
- bbox: RetrainBboxSchema,
17024
- macroClass: RetrainMacroClassSchema,
17025
- label: string().optional(),
17026
- subLabel: string().optional(),
17027
- kind: RetrainAnnotationKindSchema,
17028
- source: RetrainAnnotationSourceSchema,
17029
- /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
17030
- assistModelId: string().optional(),
17031
- assistScore: number().optional(),
17032
- exportedInBatch: string().optional(),
17033
- createdAt: number()
17034
- });
17035
- /** The write form — the server owns `id`, `createdAt` and the frame binding. */
17036
- var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
17037
- id: true,
17038
- trackId: true,
17039
- deviceId: true,
17040
- mediaKey: true,
17041
- createdAt: true,
17042
- exportedInBatch: true
17119
+ kinds: array(EventKindDescriptorSchema).readonly()
17043
17120
  });
17044
- /** A track sitting in `staging`, with everything the worklist needs to rank it. */
17045
- var RetrainTrackSchema = object({
17046
- trackId: string(),
17121
+ var SensorEventSchema = object({
17122
+ id: string(),
17123
+ /** The CAMERA the event is attributed to (a sensor linked to N cameras
17124
+ * yields N rows, one per camera). */
17047
17125
  deviceId: number(),
17048
- className: string(),
17049
- label: string().optional(),
17050
- firstSeen: number(),
17051
- lastSeen: number(),
17052
- /** How many frames the dataset already holds from this track. */
17053
- frameCount: number().int(),
17054
- /** How many subjects have been annotated on those frames. `0` with
17055
- * `frameCount: 0` is exactly "staging, still to work". */
17056
- annotationCount: number().int()
17126
+ /** The linked sensor device whose state changed. */
17127
+ sourceDeviceId: number(),
17128
+ /** Event kind id — matches an `EventKindDescriptor.kind`. */
17129
+ kind: string(),
17130
+ /** Snapshot of the sensor cap's runtime-state slice at the change. */
17131
+ value: record(string(), unknown()).nullable(),
17132
+ timestamp: number()
17057
17133
  });
17058
- /** A frame the picker may offer — an index row, no blob was read to produce it. */
17059
- var RetrainFrameCandidateSchema = object({
17060
- mediaKey: string(),
17061
- kind: MediaFileKindEnum,
17134
+ var TrackPositionSchema = object({
17135
+ x: number(),
17136
+ y: number(),
17062
17137
  timestamp: number(),
17063
- sizeBytes: number().int(),
17064
- /** A copy of this original already exists — selecting it is free and cannot
17065
- * fail, whatever became of the original. */
17066
- copied: boolean()
17067
- });
17068
- /** A frame the dataset OWNS: bytes copied at selection time. */
17069
- var RetrainFrameSchema = object({
17070
- frameId: string(),
17071
- deviceId: number(),
17072
- trackId: string(),
17073
- /** Provenance only. It may already point at nothing — that is expected. */
17074
- sourceMediaKey: string(),
17075
- sourceKind: MediaFileKindEnum,
17076
- sizeBytes: number().int(),
17077
- width: number().int(),
17078
- height: number().int(),
17079
- copiedAt: number()
17080
- });
17081
- /** Why a copy-on-select could not be honoured — named, never a silent skip. */
17082
- var RetrainCopyRefusalSchema = _enum([
17083
- "source-missing",
17084
- "unreadable-image",
17085
- "write-failed"
17086
- ]);
17087
- var RetrainFrameSelectionSchema = object({
17088
- copied: array(RetrainFrameSchema).readonly(),
17089
- refused: array(object({
17090
- sourceMediaKey: string(),
17091
- reason: RetrainCopyRefusalSchema
17092
- })).readonly()
17138
+ bbox: BoundingBoxSchema
17093
17139
  });
17094
- var RetrainFrameListSchema = object({
17095
- candidates: array(RetrainFrameCandidateSchema).readonly(),
17096
- copies: array(RetrainFrameSchema).readonly(),
17097
- /** What the page pre-selects the native key frame when one survives. */
17098
- autoPickMediaKey: string().optional()
17140
+ var TrackSnapshotSchema = object({
17141
+ timestamp: number(),
17142
+ position: TrackPositionSchema,
17143
+ /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
17144
+ mediaKey: string()
17099
17145
  });
17100
- /** What the operator asked the assist to look for. */
17101
- var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
17102
- kind: literal("package"),
17103
- zone: RetrainBboxSchema.optional()
17104
- }), object({
17105
- kind: literal("objects"),
17106
- modelId: string(),
17107
- minScore: number().optional()
17108
- })]);
17109
17146
  /**
17110
- * The assist's answer a discriminated union, because "the model saw nothing"
17111
- * and "this node cannot run that model" lead to different next moves and a
17112
- * nullable result cannot tell them apart.
17147
+ * Normalized 0..1 trajectory envelope (min/max over every position bbox,
17148
+ * divided by the track's detection-frame dims), computed at persist time.
17149
+ * Absent when the frame dims were unknown when the track was persisted
17150
+ * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
17113
17151
  */
17114
- var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
17115
- kind: literal("proposed"),
17116
- modelId: string(),
17117
- stepId: string(),
17118
- minScore: number(),
17119
- /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
17120
- proposals: array(RetrainAnnotationDraftSchema).readonly(),
17121
- /** Returned by the runner but removed by the threshold. */
17122
- belowThreshold: number().int()
17123
- }), object({
17124
- kind: literal("refused"),
17125
- /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
17126
- reason: string(),
17127
- detail: string().optional()
17128
- })]);
17129
- /** The outcome of a lifecycle move owned by the retrain page. */
17130
- var RetrainTransitionResultSchema = object({
17131
- trackId: string(),
17132
- /** Where the track ended up, whatever happened. */
17133
- retrainStatus: RetrainStatusSchema,
17134
- /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
17135
- changed: boolean(),
17136
- reason: _enum([
17137
- "unknown-track",
17138
- "no-frames-copied",
17139
- "not-staging",
17140
- "not-trained",
17141
- "unchanged"
17142
- ]).optional()
17152
+ var TrackEnvelopeSchema = object({
17153
+ minX: number(),
17154
+ minY: number(),
17155
+ maxX: number(),
17156
+ maxY: number()
17143
17157
  });
17144
- var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
17145
- var MAX_EVENT_QUERY_LIMIT = 5e3;
17146
- var DeviceEventQueryInput = object({
17147
- deviceId: number(),
17148
- since: number().optional(),
17149
- until: number().optional(),
17150
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
17151
- /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
17152
- * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
17153
- * exact behaviour. Callers may omit this field — the store defaults to
17154
- * `full` when not provided. */
17155
- projection: _enum(["full", "slim"]).optional()
17156
- });
17157
- var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
17158
- var RecentTracksQueryInput = object({
17159
- /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
17160
- deviceIds: array(number()),
17161
- /** Window lower bound on `lastSeen` (inclusive). */
17162
- since: number().optional(),
17163
- /** Window upper bound on `lastSeen` (inclusive). */
17164
- until: number().optional(),
17165
- /** Page size. Default 200, max 1000. */
17166
- limit: number().int().min(1).max(1e3).default(200),
17167
- /** Opaque continuation cursor from a previous page's `nextCursor`.
17168
- * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
17169
- cursor: string().optional(),
17170
- /** See {@link TrackProjectionSchema}. Default `full`. */
17171
- projection: TrackProjectionSchema.optional(),
17172
- /** Include stationary-promoted rows (parked objects). Default false: the
17173
- * feed lists passages; parking records live on the stationary registry. */
17174
- includeStationary: boolean().optional()
17175
- });
17176
- var RecentTracksPageSchema = object({
17177
- /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
17178
- tracks: array(TrackSchema).readonly(),
17179
- /** Cursor for the next page, or null when this page is the last. */
17180
- nextCursor: string().nullable()
17181
- });
17182
- var LIST_GROUPS_DEFAULT_LIMIT = 40;
17183
- var LIST_GROUPS_MAX_LIMIT = 100;
17184
- var AnalyticsGroupRecordSchema = object({
17185
- id: string(),
17186
- deviceId: number().int(),
17187
- openedAt: number().int(),
17188
- closedAt: number().int(),
17189
- timestamp: number().int(),
17190
- memberCount: number().int(),
17191
- memberTrackIds: array(string()).readonly(),
17192
- className: string(),
17193
- classes: array(string()).readonly(),
17194
- /** Relative event-media path, or null when the group has no picture yet. */
17195
- mediaUrl: string().nullable(),
17196
- singleton: boolean()
17197
- });
17198
- var AnalyticsGroupMemberSchema = object({
17199
- trackId: string(),
17200
- deviceId: number().int(),
17201
- className: string(),
17202
- firstSeen: number().int(),
17203
- lastSeen: number().int(),
17204
- mediaUrl: string().nullable()
17205
- });
17206
- var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
17207
- var ListGroupsQueryInput = object({
17208
- /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
17209
- deviceIds: array(number()),
17210
- /** Window lower bound on `closedAt` (inclusive). */
17211
- since: number().optional(),
17212
- /** Window upper bound on `openedAt` (inclusive). */
17213
- until: number().optional(),
17214
- limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
17215
- /** Opaque continuation cursor from a previous page's `nextCursor`. */
17216
- cursor: string().optional()
17217
- });
17218
- var ListGroupsPageSchema = object({
17219
- groups: array(AnalyticsGroupRecordSchema).readonly(),
17220
- nextCursor: string().nullable()
17221
- });
17222
- var KeyEventQueryInput = object({
17223
- deviceId: number(),
17224
- /** Window lower bound (track firstSeen ≥ since). */
17225
- since: number(),
17226
- /** Window upper bound (track firstSeen ≤ until). */
17227
- until: number(),
17228
- limit: number().int().min(1).max(200).default(50),
17229
- /** Drop tracks scoring below this importance. */
17230
- minImportance: number().min(0).max(1).optional(),
17231
- /** Restrict to a single class (e.g. 'person'). */
17232
- classFilter: string().optional()
17233
- });
17234
- var KeyEventSchema = object({
17235
- /** The representative event id (the track's best ObjectEvent, else its trackId). */
17236
- id: string(),
17237
- trackId: string(),
17238
- /** Track start time (firstSeen). */
17239
- timestamp: number(),
17240
- className: string(),
17241
- ...TieredLabelFields,
17242
- importance: number(),
17243
- /** Highest-confidence ObjectEvent id for the track (empty when none). */
17244
- bestEventId: string(),
17245
- /** Track lifetime in ms (lastSeen - firstSeen). */
17246
- windowMs: number().optional(),
17247
- ...TrackFlagFields,
17248
- ...TrackRetrainFields
17249
- });
17250
- object({
17251
- trackId: string(),
17252
- className: string(),
17253
- confidence: number(),
17254
- bbox: BoundingBoxSchema,
17255
- zones: array(string()).readonly(),
17256
- state: TrackStateSchema
17257
- });
17258
- var OverlayDetectionSchema = looseObject({
17259
- id: string(),
17260
- kind: _enum(["first-level", "detail"]),
17261
- macroClass: string(),
17262
- score: number(),
17263
- bbox: object({
17264
- x: number(),
17265
- y: number(),
17266
- width: number(),
17267
- height: number()
17268
- }),
17269
- labels: array(looseObject({
17270
- label: string(),
17271
- score: number()
17272
- })).readonly(),
17273
- parentId: string().optional()
17274
- });
17275
- var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
17276
- var SearchObjectEventsInput = object({
17277
- text: string(),
17278
- deviceId: number().optional(),
17279
- since: number().optional(),
17280
- until: number().optional(),
17281
- classFilter: string().optional(),
17282
- limit: number().default(50),
17283
- minScore: number().min(0).max(1).default(.2)
17284
- });
17285
- var TrackCascadeCountsSchema = object({
17286
- /** Persisted track roots deleted (authoritative). */
17287
- tracks: number().int(),
17288
- /** Object events removed with their tracks (best-effort; see note above). */
17289
- events: number().int(),
17290
- /** Track/face/plate-owned media removed (best-effort). Never identity media. */
17291
- media: number().int(),
17292
- /** Unassigned (non-enrolled) face reads removed (best-effort). */
17293
- faces: number().int(),
17294
- /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
17295
- plates: number().int(),
17296
- /** Per-track CLIP search vectors removed (best-effort). */
17297
- embeddings: number().int(),
17298
- /** Group membership + group rows removed with their last member (best-effort). */
17299
- groups: number().int()
17300
- });
17301
- /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
17302
- var DiskReconcileCountsSchema = object({
17303
- mediaDropped: number().int(),
17304
- tracks: number().int(),
17305
- events: number().int()
17306
- });
17307
- /** Event-store footprint for one camera. */
17308
- var EventStoreDeviceFootprintSchema = object({
17309
- deviceId: number(),
17310
- /** Persisted event rows (motion + object + audio) for the camera. */
17311
- rows: number().int(),
17312
- /** Event-owned media bytes on disk for the camera. */
17313
- bytes: number().int()
17314
- });
17315
- /** Aggregate event-store footprint: global totals + per-camera breakdown. */
17316
- var EventStoreFootprintSchema = object({
17317
- totalRows: number().int(),
17318
- totalBytes: number().int(),
17319
- devices: array(EventStoreDeviceFootprintSchema).readonly()
17320
- });
17321
- /** Per-kind counts returned by the event-prune / device-delete mutations. */
17322
- var EventPruneCountsSchema = object({
17323
- motion: number().int(),
17324
- object: number().int(),
17325
- audio: number().int()
17158
+ /**
17159
+ * Row projection for track list queries. `full` (default) returns the
17160
+ * complete Track including the frame-rate `positions[]` history and the
17161
+ * `snapshots[]` references — megabytes across a page of tracks. `slim`
17162
+ * keeps every scalar the list surfaces actually render (ids, class(es),
17163
+ * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
17164
+ * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
17165
+ * `snapshots` as EMPTY arrays detail views re-fetch the full row via
17166
+ * `getTrack`. Mirrors the event-store `projection` convention
17167
+ * (`getObjectEvents` et al.).
17168
+ */
17169
+ var TrackProjectionSchema = _enum(["full", "slim"]);
17170
+ /**
17171
+ * One audio-classification label heard on the track's camera while the
17172
+ * track was alive, aggregated per label. An "episode" is one persisted
17173
+ * audio event (the confident-classification path: score the device's
17174
+ * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
17175
+ * one 32 ms inference chunk, so counts stay human-scaled.
17176
+ */
17177
+ var TrackAudioLabelSchema = object({
17178
+ label: string(),
17179
+ /** Highest classification score observed across the label's episodes. */
17180
+ peakScore: number(),
17181
+ /** Number of coalesced audio-event episodes carrying this label. */
17182
+ count: number(),
17183
+ firstAt: number(),
17184
+ lastAt: number()
17326
17185
  });
17327
17186
  /**
17328
- * Re-embed stored tracks from their key frames.
17187
+ * How a track was produced. `pipeline` (default / absent) = the spatial
17188
+ * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
17189
+ * no positions, a single snapshot, and no bbox trajectory at all:
17329
17190
  *
17330
- * The reason this is an operator-callable method and not a migration script:
17331
- * every knob that decides what a vector MEANS encoder model, crop margin,
17332
- * squaring is only changeable if the existing vectors can be regenerated.
17333
- * Mixing feature spaces in one index makes cosine scores incomparable, and the
17334
- * symptom is a quality regression with no visible cause.
17191
+ * - `sensor` a linked sensor/control device state change.
17192
+ * - `audio` an audio event on the camera itself that was anomalous for
17193
+ * THAT camera, loud, and heard while nothing visual was happening (D62).
17194
+ *
17195
+ * The spatial subsystems (tracker association, occupancy count, re-id /
17196
+ * embedding, resurrection) MUST skip every synthetic source. Test for that
17197
+ * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
17198
+ * check silently readmits every source added after it was written.
17335
17199
  */
17336
- var RebuildObjectEmbeddingsInput = object({
17337
- /** Restrict to one camera. Omit for the whole fleet. */
17338
- deviceId: number().optional(),
17339
- since: number().optional(),
17340
- until: number().optional(),
17341
- /** Stop after this many tracks; the result reports whether more remain. */
17342
- maxTracks: number().int().positive().optional(),
17343
- /**
17344
- * Run every embedding on THIS node instead of round-robining the fleet.
17345
- *
17346
- * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
17347
- * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
17348
- * calling it that would pin the rebuild REQUEST itself to that node — the
17349
- * rebuild orchestration lives on the hub, and only the per-track step runs
17350
- * remotely. This field is data; the per-track pin is applied inside.
17351
- *
17352
- * Absent ⇒ round-robin over every online node whose runner can serve the
17353
- * pinned model.
17354
- */
17355
- executeOnNodeId: string().optional(),
17356
- /**
17357
- * Milliseconds to wait between tracks; omit for the built-in default, `0` to
17358
- * run flat out.
17359
- *
17360
- * A rebuild is bulk maintenance on hub-main's single thread. Measured
17361
- * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
17362
- * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
17363
- * force is logged at start and finish so a deliberately slow pass reads
17364
- * differently from a stalled one.
17365
- */
17366
- pacingMs: number().int().nonnegative().optional()
17367
- });
17200
+ var TrackSourceSchema = _enum([
17201
+ "pipeline",
17202
+ "sensor",
17203
+ "audio"
17204
+ ]);
17368
17205
  /**
17369
- * Result of emptying the CLIP index.
17206
+ * Where a track sits in the RETRAIN lifecycle (D81).
17370
17207
  *
17371
- * The clean slate before a policy change: a new crop margin or encoder model
17372
- * leaves two feature spaces in one index whose cosine scores are not
17373
- * comparable, so wiping and rebuilding is the only way to be sure every vector
17374
- * means the same thing.
17208
+ * - `none` never marked, or un-marked. Evictable.
17209
+ * - `staging` the operator wants this track as training material and has not
17210
+ * finished with it. **This is the only state retention holds**: the track and
17211
+ * everything it owns (object events, crops, keyframes, CLIP vector) survive
17212
+ * the device's age window.
17213
+ * - `trained` — the retrain page has taken what it needed. The frames it chose
17214
+ * were COPIED into the retrain dataset at selection time, so the dataset no
17215
+ * longer depends on the track's media and the track becomes EVICTABLE again.
17216
+ * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
17217
+ * a deliberate action of the retrain page, not a side effect of a checkbox.
17218
+ *
17219
+ * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
17220
+ * the store's filter language has only positive equality and `whereIn` — no
17221
+ * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
17222
+ * would make the entire pre-column history immortal in one deploy.
17375
17223
  */
17376
- var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
17224
+ var RetrainStatusSchema = _enum([
17225
+ "none",
17226
+ "staging",
17227
+ "trained"
17228
+ ]);
17377
17229
  /**
17378
- * Acknowledgement that a rebuild STARTED.
17230
+ * Per-track OPERATOR flags set by hand from the admin UI or the viewer, never
17231
+ * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
17232
+ * so the two surfaces cannot drift.
17379
17233
  *
17380
- * The pass costs ~1s per track 45 minutes for a 2,600-track fleet so it
17381
- * runs detached and this returns immediately. Waiting for it made the client
17382
- * time out while the work carried on server-side, which is the worst of both:
17383
- * no result and no way to know it was still going. Poll
17384
- * `getObjectEmbeddingRebuildStatus` for progress.
17385
- */
17386
- var RebuildObjectEmbeddingsResultSchema = object({
17387
- started: boolean(),
17388
- /** True when a pass was already running; the new request is ignored. */
17389
- alreadyRunning: boolean()
17390
- });
17391
- var RebuildStatusSchema = object({
17392
- running: boolean(),
17393
- scanned: number(),
17394
- rebuilt: number(),
17395
- /** Tracks whose key frame is gone nothing to re-embed from. */
17396
- missingKeyFrame: number(),
17397
- /** Tracks with no usable detection box. */
17398
- missingBbox: number(),
17399
- /**
17400
- * Tracks an executing node REFUSED rather than broke on — an unreadable key
17401
- * frame, a step that threw. Separate from `failed` because the remedy is
17402
- * different, and because a whole camera silently contributing zero vectors
17403
- * is the shape of failure a rebuild must never hide.
17404
- */
17405
- notRunnable: number(),
17234
+ * **Absent false.** A track that has never been touched omits the field; an
17235
+ * explicitly un-flagged track carries `false`. Legacy rows written before the
17236
+ * columns existed read as absent, and a consumer that needs a boolean should say
17237
+ * `flag === true`, not `flag !== false`.
17238
+ *
17239
+ * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
17240
+ * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
17241
+ * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
17242
+ * `trained` track reports `false` while refusing both writes. The boolean is
17243
+ * kept because three surfaces drive a toggle off it; anything that needs to tell
17244
+ * "never marked" from "already trained" must read `retrainStatus`.
17245
+ *
17246
+ * `debug` does NOT pin; it is attention, not durability.
17247
+ *
17248
+ * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
17249
+ * A favourited track is skipped by retention the same way `staging` is, but
17250
+ * it does not enter `none|staging|trained` and has no staging budget.
17251
+ */
17252
+ var TrackFlagFields = {
17253
+ /** Operator marked this track as training material — i.e. `retrainStatus` is
17254
+ * `'staging'`. */
17255
+ markForTrain: boolean().optional(),
17256
+ /** Operator marked this track for diagnostic attention. */
17257
+ debug: boolean().optional(),
17258
+ /** Operator favourited this track. Pins it against pruning. */
17259
+ favourited: boolean().optional()
17260
+ };
17261
+ /**
17262
+ * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
17263
+ * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
17264
+ * write patch, and the status is not something the toggle sets — it is what the
17265
+ * toggle's boolean is derived from. Absent on an in-RAM track never touched;
17266
+ * always present on a persisted row (the column default materialises `'none'`).
17267
+ */
17268
+ var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
17269
+ /**
17270
+ * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
17271
+ * one flag can never clear the other — the toggles are independent and are
17272
+ * driven from three surfaces that do not know about each other.
17273
+ */
17274
+ var TrackFlagsPatchSchema = object(TrackFlagFields);
17275
+ /**
17276
+ * The resolved flag state after a write. Both fields are REQUIRED here (absent
17277
+ * collapses to `false`) so a caller can drive a toggle's checked state off the
17278
+ * mutation result without a re-fetch.
17279
+ */
17280
+ var TrackFlagsSchema = object({
17281
+ trackId: string(),
17282
+ markForTrain: boolean(),
17283
+ debug: boolean(),
17284
+ favourited: boolean(),
17285
+ /** The lifecycle state the boolean was derived from. Required here (unlike on
17286
+ * a track row) because this shape is only ever produced by the write body,
17287
+ * which always knows it — and a surface that has just written needs to render
17288
+ * `trained` without a re-fetch. */
17289
+ retrainStatus: RetrainStatusSchema
17290
+ });
17291
+ union([literal(1), literal(2)]);
17292
+ /**
17293
+ * WHO decided a label, and when. Carried per tier so a value can be traced to
17294
+ * the step and model that produced it — which is what makes the write rule
17295
+ * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
17296
+ * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
17297
+ *
17298
+ * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
17299
+ * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
17300
+ * `migration:4g` for a value the 4g migration moved from the single-slot era —
17301
+ * that value has no provenance, and the write rule lets ANY properly-attributed
17302
+ * write of the same tier replace it regardless of score.
17303
+ */
17304
+ var LabelAttributionSchema = object({
17305
+ stepId: string(),
17306
+ modelId: string().optional(),
17307
+ decidedAt: number(),
17406
17308
  /**
17407
- * The pass stopped because NO node could serve the pinned model.
17309
+ * The GALLERY id behind a recognised tier-2 label a face-gallery
17310
+ * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
17408
17311
  *
17409
- * Distinct from `notRunnable` on purpose: that one says "this track was
17410
- * refused", this one says "the cluster cannot do this work at all" — every
17411
- * candidate node either lacks the `clip-embedding` step, lacks a build of the
17412
- * pinned model for its engine format, or dropped out. The remedy is a model /
17413
- * engine change, not a per-camera one. Non-zero here always comes with
17414
- * `complete: false`.
17312
+ * The text alone is a DISPLAY NAME, and a display name is renameable: a
17313
+ * notification rule authored on "Gianluca" stopped matching the moment the
17314
+ * operator fixed the spelling in the gallery, and nothing said so. The id is
17315
+ * the thing that does not move, so it is what a rule matches on
17316
+ * (`NcConditions.identities`) and the text is what a human is shown.
17317
+ *
17318
+ * Absent when the label names no gallery row — a plate the OCR read but no
17319
+ * vehicle claims, a sub-class, a species, any tier-1 value.
17415
17320
  */
17416
- noCapableNode: number(),
17417
- failed: number(),
17418
- /** Set once a pass ends: true only when EVERYTHING was covered. */
17419
- complete: boolean().nullable(),
17420
- startedAtMs: number().nullable(),
17421
- finishedAtMs: number().nullable(),
17422
- /** Present when the pass ended by throwing. */
17423
- error: string().nullable()
17321
+ identityId: string().optional()
17424
17322
  });
17425
- DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
17426
- deviceId: number(),
17427
- trackId: string()
17428
- }), TrackSchema.nullable()), method(object({
17429
- deviceId: number(),
17430
- since: number().optional(),
17431
- until: number().optional(),
17432
- limit: number().optional(),
17433
- /** Spatial filter — only tracks whose trajectory intersects the zone
17434
- * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
17435
- * envelope columns, then precisely tested per position. Tracks with
17436
- * an unknown envelope (no frame dims at persist time) always match. */
17437
- zone: TrackZoneFilterSchema.optional(),
17438
- /** See {@link TrackProjectionSchema}. Default `full` (backward
17439
- * compatible omitting the field keeps today's exact behaviour). */
17440
- projection: TrackProjectionSchema.optional(),
17441
- /** Include stationary-promoted rows (parked objects handed to the
17442
- * stationary registry). Default false: the timeline lists passages,
17443
- * not parking records (operator decision, 2026-08-15). */
17444
- includeStationary: boolean().optional()
17445
- }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
17446
- deviceId: number(),
17447
- groupId: string().min(1)
17448
- }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
17449
- kind: "mutation",
17450
- auth: "admin"
17451
- }), 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({
17452
- deviceId: number(),
17453
- since: number().optional(),
17454
- until: number().optional(),
17455
- kinds: array(string()).optional(),
17456
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
17457
- }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
17458
- deviceId: number(),
17459
- since: number(),
17460
- until: number(),
17461
- bucketMs: number().int().positive()
17462
- }), array(object({
17463
- bucketStart: number(),
17464
- motion: number().int(),
17465
- object: number().int(),
17466
- audio: number().int()
17467
- })).readonly()), method(object({
17468
- deviceId: number(),
17469
- cutoffMs: number()
17470
- }), object({
17471
- motion: number().int(),
17472
- object: number().int(),
17473
- audio: number().int()
17474
- }), {
17475
- kind: "mutation",
17476
- auth: "admin"
17477
- }), method(object({
17478
- deviceId: number(),
17479
- cutoffMs: number()
17480
- }), TrackCascadeCountsSchema, {
17481
- kind: "mutation",
17482
- auth: "admin"
17483
- }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
17484
- kind: "mutation",
17485
- auth: "admin"
17486
- }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
17487
- kind: "mutation",
17488
- auth: "admin"
17489
- }), method(object({
17490
- deviceId: number(),
17491
- trackIds: array(string()).min(1)
17492
- }), object({
17493
- deleted: number().int(),
17494
- failed: array(string()).readonly()
17495
- }), {
17496
- kind: "mutation",
17497
- auth: "admin"
17498
- }), method(object({
17499
- /** Log/audit scope only — the trackId is globally unique on its own. */
17323
+ /**
17324
+ * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
17325
+ * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
17326
+ * track and its events always answer the same question the same way.
17327
+ *
17328
+ * Two scalar columns, not an array: every consumer wants "the coarse one" or
17329
+ * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
17330
+ * is tier 2, and each carries its own score + attribution.
17331
+ *
17332
+ * **Reading it.** What a human should be shown is `subLabel ?? label` — the
17333
+ * finest thing known. Before 4g the single `label` column held the finest
17334
+ * value, so a consumer that has not been updated reads the tier-1 slot and
17335
+ * shows nothing on a species-only row; that is why the migration puts every
17336
+ * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
17337
+ * and why the read surfaces were changed in the same train.
17338
+ *
17339
+ * **Writing it.** The slots are independent, which is the whole point: a
17340
+ * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
17341
+ * migratorius`), so fineness cannot regress by construction. Within a tier the
17342
+ * higher score wins. One rule, one implementation — see
17343
+ * `pipeline/label-tier.ts` in addon-post-analysis.
17344
+ */
17345
+ var TieredLabelFields = {
17346
+ /** Tier 1 the sub-class. See {@link LabelTierSchema}. */
17347
+ label: string().optional(),
17348
+ /** Confidence of the tier-1 value, as reported by the deciding step. */
17349
+ labelScore: number().optional(),
17350
+ /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
17351
+ labelMeta: LabelAttributionSchema.optional(),
17352
+ /** Tier 2 — the instance. See {@link LabelTierSchema}. */
17353
+ subLabel: string().optional(),
17354
+ /** Confidence of the tier-2 value, as reported by the deciding step. */
17355
+ subLabelScore: number().optional(),
17356
+ /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
17357
+ subLabelMeta: LabelAttributionSchema.optional()
17358
+ };
17359
+ /** Per-camera slice of a training-export estimate. */
17360
+ var TrainingExportDeviceTotalsSchema = object({
17500
17361
  deviceId: number(),
17362
+ tracks: number().int(),
17363
+ files: number().int(),
17364
+ bytes: number().int()
17365
+ });
17366
+ /**
17367
+ * What a training export WOULD contain. Computed from media index rows only —
17368
+ * no blob is read to produce this.
17369
+ */
17370
+ var TrainingExportSummarySchema = object({
17371
+ generatedAt: number(),
17372
+ trackCount: number().int(),
17373
+ fileCount: number().int(),
17374
+ byteCount: number().int(),
17375
+ /** More marked tracks exist than a single pass carries. */
17376
+ truncated: boolean(),
17377
+ devices: array(TrainingExportDeviceTotalsSchema).readonly()
17378
+ });
17379
+ var TrackSchema = object({
17501
17380
  trackId: string(),
17502
- flags: TrackFlagsPatchSchema
17503
- }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
17504
- kind: "query",
17505
- auth: "admin"
17506
- }), method(object({
17507
- olderThanMs: number(),
17508
- reason: OpsLogReasonSchema.optional()
17509
- }), EventPruneCountsSchema, {
17510
- kind: "mutation",
17511
- auth: "admin"
17512
- }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
17513
- kind: "mutation",
17514
- auth: "admin"
17515
- }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
17516
- kind: "mutation",
17517
- auth: "admin"
17518
- }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
17519
- kind: "mutation",
17520
- auth: "admin"
17521
- }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
17522
- kind: "mutation",
17523
- auth: "admin"
17524
- }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
17525
- kind: "mutation",
17526
- auth: "admin"
17527
- }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
17528
- kind: "mutation",
17529
- auth: "admin"
17530
- }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
17531
- kind: "query",
17532
- auth: "admin"
17533
- }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
17534
- kind: "query",
17535
- auth: "admin"
17536
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
17537
- kind: "query",
17538
- auth: "admin"
17539
- }), method(object({
17540
- /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
17541
- * `deviceId`, deliberately: `deviceId` would make this device-bound and
17542
- * route it at one camera's owner, and "every camera" would stop being
17543
- * expressible at all. */
17544
- deviceIds: array(number()).optional(),
17545
- limit: number().int().min(1).max(500).optional()
17546
- }), array(RetrainTrackSchema).readonly(), {
17547
- kind: "query",
17548
- auth: "admin"
17549
- }), method(object({ trackId: string() }), RetrainFrameListSchema, {
17550
- kind: "query",
17551
- auth: "admin"
17552
- }), method(object({
17553
17381
  deviceId: number(),
17554
- trackId: string(),
17555
- mediaKeys: array(string()).min(1)
17556
- }), RetrainFrameSelectionSchema, {
17557
- kind: "mutation",
17558
- auth: "admin"
17559
- }), method(object({
17382
+ className: string(),
17383
+ ...TieredLabelFields,
17384
+ producingDeviceName: string().optional(),
17385
+ /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
17386
+ source: TrackSourceSchema.optional(),
17387
+ firstSeen: number(),
17388
+ lastSeen: number(),
17389
+ /** Frame-rate position history (subject to maxPositionHistory cap). */
17390
+ positions: array(TrackPositionSchema).readonly(),
17391
+ /** Periodic snapshots at snapshotIntervalMs cadence (subject to
17392
+ * saveThumbnails policy). */
17393
+ snapshots: array(TrackSnapshotSchema).readonly(),
17394
+ /** Deduplicated zones the track has entered at least once. Zone IDS. */
17395
+ zonesVisited: array(string()).readonly(),
17396
+ /**
17397
+ * Human NAMES for {@link zonesVisited}, resolved at READ time against the
17398
+ * `zones` capability.
17399
+ *
17400
+ * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
17401
+ * and no card can render — so every free-text search surface was structurally
17402
+ * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
17403
+ * just returned nothing. Resolving here rather than in each client keeps ONE
17404
+ * derivation and costs the clients no extra call (the `zones` cap is
17405
+ * per-device, so a client-side resolve would be a per-camera fan-out on a
17406
+ * surface built to avoid exactly that).
17407
+ *
17408
+ * Resolved, never invented: a zone deleted since the track was written has no
17409
+ * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
17410
+ * two are not positionally aligned. Absent when the track visited no zone, or
17411
+ * when the zone catalogue could not be read.
17412
+ */
17413
+ zoneNames: array(string()).readonly().optional(),
17414
+ /** Deduplicated set of detector classes observed for this track over its
17415
+ * life (a track may be reclassified, e.g. person→vehicle). Absent on
17416
+ * legacy rows written before class accumulation shipped. */
17417
+ classes: array(string()).readonly().optional(),
17418
+ /** Cumulative normalized distance travelled (0..1 units = full frame width). */
17419
+ totalDistance: number(),
17420
+ state: TrackStateSchema,
17421
+ active: boolean(),
17422
+ /** Deterministic key-event importance score in [0,1] (server-computed at
17423
+ * track expiry, recomputed on late label). Absent on legacy rows written
17424
+ * before scoring shipped — consumers degrade to absence / compute-on-read. */
17425
+ importance: number().optional(),
17426
+ /** Id of the track's highest-confidence ObjectEvent (its representative
17427
+ * "best" frame). Absent when the track produced no object events. */
17428
+ bestEventId: string().optional(),
17429
+ /** Tag of the importance sub-signal that dominated the score
17430
+ * (identity|dwell|proximity|class|confidence|travel|zone). */
17431
+ importanceReason: string().optional(),
17432
+ /** Audio-classification labels heard on the camera during the track's
17433
+ * life (score ≥ device `classificationMinScore`), aggregated per label.
17434
+ * Absent on legacy rows / tracks with no confident audio. */
17435
+ audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
17436
+ /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
17437
+ * Populated from the persisted envelope columns on historical reads;
17438
+ * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
17439
+ envelope: TrackEnvelopeSchema.optional(),
17440
+ /**
17441
+ * A face DETECTOR found a face on this track — nothing more. It says the
17442
+ * detail plane produced a `face` detail; it does NOT say the face was
17443
+ * embedded, matched, above `minFacePx`, or that the recognizer was even
17444
+ * enabled. Set once and never cleared.
17445
+ *
17446
+ * **This exists so "face present but not recognised" is expressible.** A
17447
+ * recognised identity lands in `subLabel` (attributed to the face chain via
17448
+ * `subLabelMeta.stepId`), so before this field a track with an unmatched face
17449
+ * and a track with no face at all were byte-identical on the wire and no
17450
+ * surface could tell them apart. The read is `hasFace === true && subLabel
17451
+ * === undefined`.
17452
+ *
17453
+ * **Absent ≠ false.** Every row written before the column existed omits it,
17454
+ * and so does every server that predates the field — a consumer must test
17455
+ * `=== true` and render nothing otherwise, never infer "no face".
17456
+ */
17457
+ hasFace: boolean().optional(),
17458
+ /**
17459
+ * This track has a face row IN THE GALLERY: a crop **and** an embedding — a
17460
+ * face an operator could ASSIGN to an identity.
17461
+ *
17462
+ * The STRICT twin of {@link hasFace}, and the pair only earns its keep
17463
+ * because the two disagree. `hasFace` is stamped at the TOP of the face
17464
+ * branch, before every gate, and means no more than "a face detector produced
17465
+ * a face detail". This one is stamped at the single moment the gallery row
17466
+ * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
17467
+ * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
17468
+ * candidate gate, the imageless-track drop (no crop was ever captured) and
17469
+ * the crop-store drop. Everything between the detector and that insert can
17470
+ * legitimately refuse the face, so a flag written any earlier promises the
17471
+ * operator something to assign and delivers nothing.
17472
+ *
17473
+ * **Independent of recognition.** A face collected but never auto-matched is
17474
+ * still assignable — it is in fact the face an operator most wants to reach —
17475
+ * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
17476
+ * `subLabel`; this says only that the raw material exists.
17477
+ *
17478
+ * **Set once, never cleared.** A track that produced a gallery row produced
17479
+ * one; deleting the row later is the gallery's business, not this flag's.
17480
+ *
17481
+ * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
17482
+ * before the column omits it, and so does every server that predates the
17483
+ * field. A consumer must test `=== true` and render nothing otherwise —
17484
+ * never infer "no assignable face".
17485
+ */
17486
+ hasEmbeddedFace: boolean().optional(),
17487
+ /**
17488
+ * This subject CONTAINS a folded rider — a person the rider-pairing step
17489
+ * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
17490
+ * so the passage is tracked once and as a VEHICLE.
17491
+ *
17492
+ * It exists because the fold's record was dishonest. D34 and the code both
17493
+ * said "the person is not lost — it is reported so both entities stay on the
17494
+ * record"; in fact the pair went into a per-processor RAM field behind an
17495
+ * accessor nobody called, and every durable surface said `vehicle`, full
17496
+ * stop. This is the composition note that makes the row true.
17497
+ *
17498
+ * A COMPOSITION, never a class and never a label. "This vehicle contains a
17499
+ * person" is not an answer to "what is this" — both label tiers would refuse
17500
+ * a macro token anyway (D89), and correctly. Nothing here changes what the
17501
+ * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
17502
+ * and a `person` rule still does not fire for someone cycling past.
17503
+ *
17504
+ * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
17505
+ * the column, and every hub that predates the field, omits it. Test
17506
+ * `=== true` and render nothing otherwise — never infer "no rider".
17507
+ */
17508
+ hasRider: boolean().optional(),
17509
+ ...TrackFlagFields,
17510
+ ...TrackRetrainFields
17511
+ });
17512
+ var BaseEventFields = {
17513
+ id: string(),
17560
17514
  deviceId: number(),
17561
- trackId: string(),
17562
- frameId: string()
17563
- }), object({
17564
- removed: boolean(),
17565
- removedAnnotations: number().int()
17566
- }), {
17567
- kind: "mutation",
17568
- auth: "admin"
17569
- }), method(object({ frameId: string() }), object({
17515
+ timestamp: number()
17516
+ };
17517
+ var MotionEventSchema = object({
17518
+ ...BaseEventFields,
17519
+ kind: literal("motion"),
17520
+ regionCount: number(),
17521
+ /** Heavy JSON array — omitted in slim projection. */
17522
+ regions: array(object({
17523
+ bbox: BoundingBoxSchema,
17524
+ pixelCount: number(),
17525
+ intensity: number()
17526
+ })).readonly().optional(),
17527
+ /** Omitted in slim projection. */
17528
+ frameWidth: number().optional(),
17529
+ /** Omitted in slim projection. */
17530
+ frameHeight: number().optional(),
17531
+ /** Populated by B5 (recording playback URL for this event). */
17532
+ mediaUrl: string().optional()
17533
+ });
17534
+ /**
17535
+ * Which detection SOURCE produced an object event. `pipeline` = the ML
17536
+ * detection pipeline (decoded-frame inference); `onboard` = the camera's
17537
+ * native on-device AI. Both flow through the SAME analysis layers (zoning,
17538
+ * tracking, per-kind persistence) but stay distinguishable so consumers
17539
+ * (advanced-notifier, occupancy, …) can select which source(s) to act on.
17540
+ * Absent on legacy rows ⇒ treat as `pipeline`.
17541
+ */
17542
+ var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
17543
+ /**
17544
+ * The confirmed zone crossing that produced an object event. Present ONLY on
17545
+ * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
17546
+ * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
17547
+ * appearance event carry none, so a rule asking for a direction fails closed
17548
+ * on them.
17549
+ *
17550
+ * Exactly ONE crossing per event: the emitter turns each confirmed crossing
17551
+ * into its own event, so a frame in which a track enters A while leaving B
17552
+ * produces two events with two directions — never one ambiguous row.
17553
+ *
17554
+ * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
17555
+ * membership the box has NOW, and by definition it no longer contains the zone
17556
+ * that was just left. Without the id here, a zone-scoped rule could never match
17557
+ * the exit it asked for.
17558
+ */
17559
+ var ZoneCrossingSchema = object({
17560
+ direction: _enum(["enter", "exit"]),
17561
+ /** Admin zone id crossed. */
17562
+ zoneId: string(),
17563
+ /** Zone display name at crossing time (falls back to the id). */
17564
+ zoneName: string().optional()
17565
+ });
17566
+ var ObjectEventSchema = object({
17567
+ ...BaseEventFields,
17568
+ kind: literal("object"),
17569
+ /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
17570
+ source: DetectionSourceSchema.optional(),
17571
+ /**
17572
+ * Inference-frame id shared by every object event emitted from the SAME frame
17573
+ * — the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
17574
+ * 2 people + 1 dog) under one full frame, and link a track's frames over time
17575
+ * (group by `trackId`, pick a representative `frameId` as the parent frame).
17576
+ * Optional for backward-compat with pre-existing rows / the slim projection
17577
+ * includes it (it is light). Absent on rows written before this field.
17578
+ */
17579
+ frameId: string().optional(),
17580
+ /** Omitted in slim projection. */
17581
+ trackId: string().optional(),
17582
+ className: string(),
17583
+ ...TieredLabelFields,
17584
+ /** Omitted in slim projection. */
17585
+ confidence: number().optional(),
17586
+ /** Heavy JSON — omitted in slim projection. */
17587
+ bbox: BoundingBoxSchema.optional(),
17588
+ /** Heavy JSON — omitted in slim projection. */
17589
+ zones: array(string()).readonly().optional(),
17590
+ /** Omitted in slim projection. */
17591
+ state: TrackStateSchema.optional(),
17592
+ /**
17593
+ * The zone crossing this event IS, when it is one. Absent on every other
17594
+ * event kind (movement state, appearance, package) — see
17595
+ * {@link ZoneCrossingSchema}. Omitted in slim projection.
17596
+ */
17597
+ zoneCrossing: ZoneCrossingSchema.optional(),
17598
+ /** Detection-frame dimensions in pixels — let consumers normalize the
17599
+ * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
17600
+ frameWidth: number().optional(),
17601
+ frameHeight: number().optional(),
17602
+ /** MediaStore key for the crop attached to this event (if any). */
17603
+ mediaKey: string().optional(),
17604
+ /** Design B: MediaStore key of the track's native-resolution key frame (the
17605
+ * best-detection full frame). Resolve via the event-media data-plane
17606
+ * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
17607
+ * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
17608
+ * sources — consumers fall back to `mediaKey` (the tight crop). */
17609
+ keyFrameMediaKey: string().optional(),
17610
+ /** Populated by B5 (recording playback URL for this event). */
17611
+ mediaUrl: string().optional(),
17612
+ /** The parent track's key-event importance [0,1], propagated to every object
17613
+ * event of the track (so an event row can be sorted by importance without a
17614
+ * track join). Absent on legacy rows / before the track was scored. */
17615
+ importance: number().optional()
17616
+ });
17617
+ var AudioEventSchema = object({
17618
+ ...BaseEventFields,
17619
+ kind: literal("audio"),
17620
+ rms: number(),
17621
+ dbfs: number(),
17622
+ classification: object({
17623
+ className: string(),
17624
+ originalClass: string().optional(),
17625
+ score: number()
17626
+ }).optional(),
17627
+ /** Populated by B5 (recording playback URL for this event). */
17628
+ mediaUrl: string().optional()
17629
+ });
17630
+ var MediaFileKindEnum = _enum([
17631
+ "crop",
17632
+ "thumbnail",
17633
+ "snapshot",
17634
+ "firstFrame",
17635
+ "lastFrame",
17636
+ "fullFrame",
17637
+ "fullFrameBoxed",
17638
+ "faceCrop",
17639
+ "plateCrop",
17640
+ "keyFrame",
17641
+ "keyFrameSmall",
17642
+ "thumbnailSmall"
17643
+ ]);
17644
+ var MediaFileSchema = object({
17645
+ key: string(),
17646
+ kind: MediaFileKindEnum,
17570
17647
  base64: string(),
17571
- width: number().int(),
17572
- height: number().int()
17573
- }), {
17574
- kind: "query",
17575
- auth: "admin"
17576
- }), method(object({
17577
- deviceId: number(),
17578
- trackId: string(),
17579
- frameId: string(),
17580
- subject: RetrainAssistSubjectSchema,
17581
- /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
17582
- nodeId: string().optional()
17583
- }), RetrainAssistResultSchema, {
17584
- kind: "mutation",
17585
- auth: "admin"
17586
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
17587
- kind: "query",
17588
- auth: "admin"
17589
- }), method(object({
17590
- deviceId: number(),
17648
+ sizeBytes: number(),
17649
+ timestamp: number()
17650
+ });
17651
+ /**
17652
+ * One media row WITHOUT its bytes.
17653
+ *
17654
+ * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
17655
+ * 140 s track), and a client that renders tiles from the media data plane needs
17656
+ * to know only WHAT EXISTS — the bytes then arrive per tile, lazily, over HTTP
17657
+ * with an immutable cache, instead of all at once inside a tRPC response that
17658
+ * blocks the whole view.
17659
+ *
17660
+ * `sizeBytes` is carried because it is what lets a client decide between the
17661
+ * stored blob and a `?variant=thumb` rendering without fetching either.
17662
+ */
17663
+ var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
17664
+ /**
17665
+ * The MACRO tier of an annotation — a CLOSED set.
17666
+ *
17667
+ * This is what the exported detector predicts, so a typo here is a new class
17668
+ * with one example in it. `label` and `subLabel` are open strings by contrast:
17669
+ * the whole point of the page is teaching the model things it does not know
17670
+ * yet, and constraining that vocabulary would make it useless.
17671
+ *
17672
+ * A macro class is NEVER a label. The provider refuses a write whose `label` or
17673
+ * `subLabel` is one of these values, in any casing, because once `person`
17674
+ * exists in both tiers "every person box" stops being answerable without
17675
+ * knowing every string anyone ever typed — and the damage is retroactive.
17676
+ */
17677
+ var RetrainMacroClassSchema = _enum([
17678
+ "person",
17679
+ "vehicle",
17680
+ "animal",
17681
+ "package",
17682
+ "face",
17683
+ "plate"
17684
+ ]);
17685
+ /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
17686
+ var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
17687
+ /** Did a human draw this box, or did the assist propose it? */
17688
+ var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
17689
+ /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
17690
+ var RetrainBboxSchema = object({
17691
+ x: number(),
17692
+ y: number(),
17693
+ w: number(),
17694
+ h: number()
17695
+ });
17696
+ /**
17697
+ * One annotated subject.
17698
+ *
17699
+ * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
17700
+ * (letterboxed root / zone-cropped package / subject-cropped classifier) are
17701
+ * derived from it at export and never stored — storing them is how one feature
17702
+ * space ends up holding two crops of the same subject (D52).
17703
+ */
17704
+ var RetrainAnnotationSchema = object({
17705
+ id: string(),
17591
17706
  trackId: string(),
17592
- frameId: string(),
17593
- annotations: array(RetrainAnnotationDraftSchema)
17594
- }), array(RetrainAnnotationSchema).readonly(), {
17595
- kind: "mutation",
17596
- auth: "admin"
17597
- }), method(object({
17598
- deviceId: number(),
17599
- trackId: string()
17600
- }), RetrainTransitionResultSchema, {
17601
- kind: "mutation",
17602
- auth: "admin"
17603
- }), method(object({
17604
17707
  deviceId: number(),
17605
- trackId: string()
17606
- }), RetrainTransitionResultSchema, {
17607
- kind: "mutation",
17608
- auth: "admin"
17609
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
17610
- kind: "query",
17611
- auth: "admin"
17612
- }), method(object({
17613
- eventId: string(),
17614
- kind: MediaFileKindEnum.optional(),
17615
- deviceId: number()
17616
- }), array(MediaFileSchema).readonly()), method(object({
17617
- trackId: string(),
17618
- kinds: array(MediaFileKindEnum).optional(),
17619
- deviceId: number()
17620
- }), array(MediaFileSchema).readonly()), method(object({
17708
+ /** The COPY in retrain storage — never the source track's media key. */
17709
+ mediaKey: string(),
17710
+ bbox: RetrainBboxSchema,
17711
+ macroClass: RetrainMacroClassSchema,
17712
+ label: string().optional(),
17713
+ subLabel: string().optional(),
17714
+ kind: RetrainAnnotationKindSchema,
17715
+ source: RetrainAnnotationSourceSchema,
17716
+ /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
17717
+ assistModelId: string().optional(),
17718
+ assistScore: number().optional(),
17719
+ exportedInBatch: string().optional(),
17720
+ createdAt: number()
17721
+ });
17722
+ /** The write form — the server owns `id`, `createdAt` and the frame binding. */
17723
+ var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
17724
+ id: true,
17725
+ trackId: true,
17726
+ deviceId: true,
17727
+ mediaKey: true,
17728
+ createdAt: true,
17729
+ exportedInBatch: true
17730
+ });
17731
+ /** A track sitting in `staging`, with everything the worklist needs to rank it. */
17732
+ var RetrainTrackSchema = object({
17621
17733
  trackId: string(),
17622
- deviceId: number()
17623
- }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
17624
- kind: "mutation",
17625
- auth: "admin"
17626
- }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
17627
- kind: "mutation",
17628
- auth: "admin"
17629
- }), method(object({}), RebuildStatusSchema), object({
17630
17734
  deviceId: number(),
17735
+ className: string(),
17736
+ label: string().optional(),
17737
+ firstSeen: number(),
17738
+ lastSeen: number(),
17739
+ /** How many frames the dataset already holds from this track. */
17740
+ frameCount: number().int(),
17741
+ /** How many subjects have been annotated on those frames. `0` with
17742
+ * `frameCount: 0` is exactly "staging, still to work". */
17743
+ annotationCount: number().int()
17744
+ });
17745
+ /** A frame the picker may offer — an index row, no blob was read to produce it. */
17746
+ var RetrainFrameCandidateSchema = object({
17747
+ mediaKey: string(),
17748
+ kind: MediaFileKindEnum,
17631
17749
  timestamp: number(),
17632
- frameWidth: number(),
17633
- frameHeight: number(),
17634
- detections: array(OverlayDetectionSchema).readonly()
17635
- }), object({
17750
+ sizeBytes: number().int(),
17751
+ /** A copy of this original already exists — selecting it is free and cannot
17752
+ * fail, whatever became of the original. */
17753
+ copied: boolean()
17754
+ });
17755
+ /** A frame the dataset OWNS: bytes copied at selection time. */
17756
+ var RetrainFrameSchema = object({
17757
+ frameId: string(),
17636
17758
  deviceId: number(),
17637
17759
  trackId: string(),
17638
- className: string()
17760
+ /** Provenance only. It may already point at nothing — that is expected. */
17761
+ sourceMediaKey: string(),
17762
+ sourceKind: MediaFileKindEnum,
17763
+ sizeBytes: number().int(),
17764
+ width: number().int(),
17765
+ height: number().int(),
17766
+ copiedAt: number()
17767
+ });
17768
+ /** Why a copy-on-select could not be honoured — named, never a silent skip. */
17769
+ var RetrainCopyRefusalSchema = _enum([
17770
+ "source-missing",
17771
+ "unreadable-image",
17772
+ "write-failed"
17773
+ ]);
17774
+ var RetrainFrameSelectionSchema = object({
17775
+ copied: array(RetrainFrameSchema).readonly(),
17776
+ refused: array(object({
17777
+ sourceMediaKey: string(),
17778
+ reason: RetrainCopyRefusalSchema
17779
+ })).readonly()
17780
+ });
17781
+ var RetrainFrameListSchema = object({
17782
+ candidates: array(RetrainFrameCandidateSchema).readonly(),
17783
+ copies: array(RetrainFrameSchema).readonly(),
17784
+ /** What the page pre-selects — the native key frame when one survives. */
17785
+ autoPickMediaKey: string().optional()
17786
+ });
17787
+ /** What the operator asked the assist to look for. */
17788
+ var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
17789
+ kind: literal("package"),
17790
+ zone: RetrainBboxSchema.optional()
17639
17791
  }), object({
17640
- deviceId: number(),
17641
- trackId: string(),
17642
- className: string(),
17643
- durationMs: number()
17792
+ kind: literal("objects"),
17793
+ modelId: string(),
17794
+ minScore: number().optional()
17795
+ })]);
17796
+ /**
17797
+ * The assist's answer — a discriminated union, because "the model saw nothing"
17798
+ * and "this node cannot run that model" lead to different next moves and a
17799
+ * nullable result cannot tell them apart.
17800
+ */
17801
+ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
17802
+ kind: literal("proposed"),
17803
+ modelId: string(),
17804
+ stepId: string(),
17805
+ minScore: number(),
17806
+ /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
17807
+ proposals: array(RetrainAnnotationDraftSchema).readonly(),
17808
+ /** Returned by the runner but removed by the threshold. */
17809
+ belowThreshold: number().int()
17644
17810
  }), object({
17811
+ kind: literal("refused"),
17812
+ /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
17813
+ reason: string(),
17814
+ detail: string().optional()
17815
+ })]);
17816
+ /** The outcome of a lifecycle move owned by the retrain page. */
17817
+ var RetrainTransitionResultSchema = object({
17818
+ trackId: string(),
17819
+ /** Where the track ended up, whatever happened. */
17820
+ retrainStatus: RetrainStatusSchema,
17821
+ /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
17822
+ changed: boolean(),
17823
+ reason: _enum([
17824
+ "unknown-track",
17825
+ "no-frames-copied",
17826
+ "not-staging",
17827
+ "not-trained",
17828
+ "unchanged"
17829
+ ]).optional()
17830
+ });
17831
+ var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
17832
+ var MAX_EVENT_QUERY_LIMIT = 5e3;
17833
+ var DeviceEventQueryInput = object({
17645
17834
  deviceId: number(),
17646
- kind: EventKindSchema,
17647
- eventId: string(),
17648
- timestamp: number()
17835
+ since: number().optional(),
17836
+ until: number().optional(),
17837
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
17838
+ /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
17839
+ * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
17840
+ * exact behaviour. Callers may omit this field — the store defaults to
17841
+ * `full` when not provided. */
17842
+ projection: _enum(["full", "slim"]).optional()
17649
17843
  });
17650
- /**
17651
- * Reference to the frame's retained NATIVE surface + the parent crop's placement
17652
- * within the frame, so the executor can re-cut a leaf child ROI at native
17653
- * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
17654
- */
17655
- var NativeCropRefSchema = object({
17656
- /** Handle keying the retained native surface (node-pinned to its owner). */
17657
- handle: FrameHandleSchema,
17658
- /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
17659
- cropFrameSpace: object({
17660
- x: number(),
17661
- y: number(),
17662
- w: number(),
17663
- h: number()
17664
- })
17844
+ var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
17845
+ var RecentTracksQueryInput = object({
17846
+ /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
17847
+ deviceIds: array(number()),
17848
+ /** Window lower bound on `lastSeen` (inclusive). */
17849
+ since: number().optional(),
17850
+ /** Window upper bound on `lastSeen` (inclusive). */
17851
+ until: number().optional(),
17852
+ /** Page size. Default 200, max 1000. */
17853
+ limit: number().int().min(1).max(1e3).default(200),
17854
+ /** Opaque continuation cursor from a previous page's `nextCursor`.
17855
+ * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
17856
+ cursor: string().optional(),
17857
+ /** See {@link TrackProjectionSchema}. Default `full`. */
17858
+ projection: TrackProjectionSchema.optional(),
17859
+ /** Include stationary-promoted rows (parked objects). Default false: the
17860
+ * feed lists passages; parking records live on the stationary registry. */
17861
+ includeStationary: boolean().optional()
17665
17862
  });
17666
- object({
17667
- crop: object({
17668
- left: number(),
17669
- top: number(),
17670
- width: number().positive(),
17671
- height: number().positive()
17672
- }).optional(),
17673
- content: object({
17674
- width: number().int().positive(),
17675
- height: number().int().positive()
17676
- }),
17677
- fit: _enum(["stretch", "contain"]),
17678
- format: _enum([
17679
- "rgb",
17680
- "gray",
17681
- "jpeg"
17682
- ])
17863
+ var RecentTracksPageSchema = object({
17864
+ /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
17865
+ tracks: array(TrackSchema).readonly(),
17866
+ /** Cursor for the next page, or null when this page is the last. */
17867
+ nextCursor: string().nullable()
17683
17868
  });
17684
- var FrameRefSchema = object({
17685
- registryId: string().min(1),
17686
- id: string().min(1),
17687
- width: number().int().positive(),
17688
- height: number().int().positive(),
17689
- format: _enum(["rgb", "gray"]),
17690
- timestamp: number(),
17691
- capturedAt: number().optional()
17869
+ var LIST_GROUPS_DEFAULT_LIMIT = 40;
17870
+ var LIST_GROUPS_MAX_LIMIT = 100;
17871
+ var AnalyticsGroupRecordSchema = object({
17872
+ id: string(),
17873
+ deviceId: number().int(),
17874
+ openedAt: number().int(),
17875
+ closedAt: number().int(),
17876
+ timestamp: number().int(),
17877
+ memberCount: number().int(),
17878
+ memberTrackIds: array(string()).readonly(),
17879
+ className: string(),
17880
+ classes: array(string()).readonly(),
17881
+ /** Relative event-media path, or null when the group has no picture yet. */
17882
+ mediaUrl: string().nullable(),
17883
+ singleton: boolean()
17692
17884
  });
17693
- var ModelFormatSchema$1 = _enum([
17694
- "onnx",
17695
- "coreml",
17696
- "openvino",
17697
- "tflite",
17698
- "pt",
17699
- "gguf"
17700
- ]);
17701
- var PipelineSlotSchema = _enum([
17702
- "detector",
17703
- "cropper",
17704
- "classifier",
17705
- "refiner",
17706
- "audio-classifier"
17707
- ]);
17708
- var PipelineEngineChoiceSchema = object({
17709
- runtime: _enum(["node", "python"]),
17710
- backend: string(),
17711
- format: ModelFormatSchema$1,
17712
- device: string().optional()
17885
+ var AnalyticsGroupMemberSchema = object({
17886
+ trackId: string(),
17887
+ deviceId: number().int(),
17888
+ className: string(),
17889
+ firstSeen: number().int(),
17890
+ lastSeen: number().int(),
17891
+ mediaUrl: string().nullable()
17713
17892
  });
17714
- var AvailableEngineSchema = object({
17715
- engine: PipelineEngineChoiceSchema,
17716
- devices: array(object({
17717
- id: string(),
17718
- label: string(),
17719
- description: string().optional()
17720
- })).readonly(),
17721
- defaultDevice: string()
17893
+ var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
17894
+ var ListGroupsQueryInput = object({
17895
+ /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
17896
+ deviceIds: array(number()),
17897
+ /** Window lower bound on `closedAt` (inclusive). */
17898
+ since: number().optional(),
17899
+ /** Window upper bound on `openedAt` (inclusive). */
17900
+ until: number().optional(),
17901
+ limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
17902
+ /** Opaque continuation cursor from a previous page's `nextCursor`. */
17903
+ cursor: string().optional()
17722
17904
  });
17723
- var PipelineDefaultStepSchema = lazy(() => object({
17724
- addonId: string(),
17725
- addonName: string(),
17726
- slot: PipelineSlotSchema,
17727
- inputClasses: array(string()).readonly(),
17728
- outputClasses: array(string()).readonly(),
17729
- enabled: boolean(),
17730
- modelId: string(),
17731
- children: array(PipelineDefaultStepSchema).readonly(),
17732
- group: string().optional(),
17733
- settings: record(string(), unknown()).optional()
17734
- }));
17735
- var PipelineTemplateStepSchema = lazy(() => object({
17736
- addonId: string(),
17737
- enabled: boolean(),
17738
- modelId: string(),
17739
- children: array(PipelineTemplateStepSchema).readonly(),
17740
- settings: record(string(), unknown()).optional()
17741
- }));
17742
- var PipelineTemplateSchema$1 = object({
17743
- id: string(),
17744
- name: string(),
17745
- createdAt: string(),
17746
- updatedAt: string(),
17747
- engine: PipelineEngineChoiceSchema,
17748
- steps: array(PipelineTemplateStepSchema).readonly()
17905
+ var ListGroupsPageSchema = object({
17906
+ groups: array(AnalyticsGroupRecordSchema).readonly(),
17907
+ nextCursor: string().nullable()
17908
+ });
17909
+ var KeyEventQueryInput = object({
17910
+ deviceId: number(),
17911
+ /** Window lower bound (track firstSeen ≥ since). */
17912
+ since: number(),
17913
+ /** Window upper bound (track firstSeen ≤ until). */
17914
+ until: number(),
17915
+ limit: number().int().min(1).max(200).default(50),
17916
+ /** Drop tracks scoring below this importance. */
17917
+ minImportance: number().min(0).max(1).optional(),
17918
+ /** Restrict to a single class (e.g. 'person'). */
17919
+ classFilter: string().optional()
17749
17920
  });
17750
- var PipelineModelOptionSchema = object({
17921
+ var KeyEventSchema = object({
17922
+ /** The representative event id (the track's best ObjectEvent, else its trackId). */
17751
17923
  id: string(),
17752
- name: string(),
17753
- formats: record(string(), object({
17754
- downloaded: boolean(),
17755
- sizeMB: number()
17756
- })),
17757
- group: ModelVariantGroupSchema.optional(),
17758
- legacy: boolean().optional(),
17759
- provider: ModelProviderIdSchema.optional()
17924
+ trackId: string(),
17925
+ /** Track start time (firstSeen). */
17926
+ timestamp: number(),
17927
+ className: string(),
17928
+ ...TieredLabelFields,
17929
+ importance: number(),
17930
+ /** Highest-confidence ObjectEvent id for the track (empty when none). */
17931
+ bestEventId: string(),
17932
+ /** Track lifetime in ms (lastSeen - firstSeen). */
17933
+ windowMs: number().optional(),
17934
+ ...TrackFlagFields,
17935
+ ...TrackRetrainFields
17760
17936
  });
17761
- var ConfigFieldBridge = custom();
17762
- var PipelineAddonSchemaSchema = object({
17763
- id: string(),
17764
- name: string(),
17765
- slot: PipelineSlotSchema,
17766
- inputClasses: array(string()).readonly(),
17767
- outputClasses: array(string()).readonly(),
17768
- childSlots: array(PipelineSlotSchema).readonly(),
17769
- models: array(PipelineModelOptionSchema).readonly(),
17770
- defaultModelId: string(),
17771
- defaultModelIdByFormat: record(string(), string()).optional(),
17772
- enabledByDefault: boolean().optional(),
17773
- backfillIntoExistingOverrides: boolean().optional(),
17774
- defaultConfidence: number(),
17775
- group: string().optional(),
17776
- configSchema: array(ConfigFieldBridge).readonly().optional()
17937
+ object({
17938
+ trackId: string(),
17939
+ className: string(),
17940
+ confidence: number(),
17941
+ bbox: BoundingBoxSchema,
17942
+ zones: array(string()).readonly(),
17943
+ state: TrackStateSchema
17777
17944
  });
17778
- var PipelineSlotSchemaSchema = object({
17779
- id: PipelineSlotSchema,
17780
- label: string(),
17781
- priority: number(),
17782
- parentSlot: PipelineSlotSchema.nullable(),
17783
- addons: array(PipelineAddonSchemaSchema).readonly()
17945
+ var OverlayDetectionSchema = looseObject({
17946
+ id: string(),
17947
+ kind: _enum(["first-level", "detail"]),
17948
+ macroClass: string(),
17949
+ score: number(),
17950
+ bbox: object({
17951
+ x: number(),
17952
+ y: number(),
17953
+ width: number(),
17954
+ height: number()
17955
+ }),
17956
+ labels: array(looseObject({
17957
+ label: string(),
17958
+ score: number()
17959
+ })).readonly(),
17960
+ parentId: string().optional()
17784
17961
  });
17785
- var PipelineSchemaSchema = object({
17786
- availableEngines: array(AvailableEngineSchema).readonly(),
17787
- selectedEngine: PipelineEngineChoiceSchema,
17788
- slots: array(PipelineSlotSchemaSchema).readonly()
17962
+ var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
17963
+ var SearchObjectEventsInput = object({
17964
+ text: string(),
17965
+ deviceId: number().optional(),
17966
+ since: number().optional(),
17967
+ until: number().optional(),
17968
+ classFilter: string().optional(),
17969
+ limit: number().default(50),
17970
+ minScore: number().min(0).max(1).default(.2)
17789
17971
  });
17790
- var EngineProvisioningSchema = object({
17791
- runtimeId: _enum([
17792
- "onnx",
17793
- "openvino",
17794
- "coreml",
17795
- "edgetpu"
17796
- ]).nullable(),
17797
- device: string().nullable(),
17798
- state: _enum([
17799
- "idle",
17800
- "installing",
17801
- "verifying",
17802
- "ready",
17803
- "failed"
17804
- ]),
17805
- progress: number().optional(),
17806
- error: string().optional(),
17807
- nextRetryAt: number().optional(),
17808
- /**
17809
- * Gate A (config-correctness gate at engine change): human-readable
17810
- * config issues surfaced EAGERLY when the node's engine changes — model
17811
- * substitutions ("chose X, running Y") and zero-build steps ("no model
17812
- * has a <format> build"). Additive/optional: informational only, never
17813
- * enforced here — `assertEngineReady` (readiness) still gates inference.
17814
- * Absent/empty when the node-default tree resolves cleanly.
17815
- */
17816
- configIssues: array(string()).optional()
17972
+ var TrackCascadeCountsSchema = object({
17973
+ /** Persisted track roots deleted (authoritative). */
17974
+ tracks: number().int(),
17975
+ /** Object events removed with their tracks (best-effort; see note above). */
17976
+ events: number().int(),
17977
+ /** Track/face/plate-owned media removed (best-effort). Never identity media. */
17978
+ media: number().int(),
17979
+ /** Unassigned (non-enrolled) face reads removed (best-effort). */
17980
+ faces: number().int(),
17981
+ /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
17982
+ plates: number().int(),
17983
+ /** Per-track CLIP search vectors removed (best-effort). */
17984
+ embeddings: number().int(),
17985
+ /** Group membership + group rows removed with their last member (best-effort). */
17986
+ groups: number().int()
17817
17987
  });
17818
- var PipelineStepInputSchema = lazy(() => object({
17819
- addonId: string(),
17820
- modelId: string().optional(),
17821
- enabled: boolean().default(true),
17822
- children: array(PipelineStepInputSchema).optional(),
17823
- settings: record(string(), unknown()).optional(),
17824
- jumpDeviceKey: string().optional()
17825
- }));
17826
- var ModelSubstitutionSchema = object({
17827
- addonId: string(),
17828
- chosen: string(),
17829
- running: string(),
17830
- format: string()
17988
+ /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
17989
+ var DiskReconcileCountsSchema = object({
17990
+ mediaDropped: number().int(),
17991
+ tracks: number().int(),
17992
+ events: number().int()
17831
17993
  });
17832
- var PipelineValidationIssueSchema = object({
17833
- addonId: string(),
17834
- kind: _enum(["unknown-addon", "no-format-build"]),
17835
- detail: string()
17994
+ /** Event-store footprint for one camera. */
17995
+ var EventStoreDeviceFootprintSchema = object({
17996
+ deviceId: number(),
17997
+ /** Persisted event rows (motion + object + audio) for the camera. */
17998
+ rows: number().int(),
17999
+ /** Event-owned media bytes on disk for the camera. */
18000
+ bytes: number().int()
17836
18001
  });
17837
- var PipelineValidationResultSchema = object({
17838
- ok: boolean(),
17839
- issues: array(PipelineValidationIssueSchema).readonly(),
17840
- substitutions: array(ModelSubstitutionSchema).readonly(),
17841
- /** The node's `currentEngine.format` this validation ran against. */
17842
- format: string()
18002
+ /** Aggregate event-store footprint: global totals + per-camera breakdown. */
18003
+ var EventStoreFootprintSchema = object({
18004
+ totalRows: number().int(),
18005
+ totalBytes: number().int(),
18006
+ devices: array(EventStoreDeviceFootprintSchema).readonly()
17843
18007
  });
17844
- var ReferenceImageEntrySchema = object({
17845
- filename: string(),
17846
- stepIds: array(string()).readonly().optional()
18008
+ /** Per-kind counts returned by the event-prune / device-delete mutations. */
18009
+ var EventPruneCountsSchema = object({
18010
+ motion: number().int(),
18011
+ object: number().int(),
18012
+ audio: number().int()
17847
18013
  });
17848
- var ReferenceImageBodySchema = object({
17849
- base64: string(),
17850
- filename: string()
18014
+ /**
18015
+ * Re-embed stored tracks from their key frames.
18016
+ *
18017
+ * The reason this is an operator-callable method and not a migration script:
18018
+ * every knob that decides what a vector MEANS — encoder model, crop margin,
18019
+ * squaring — is only changeable if the existing vectors can be regenerated.
18020
+ * Mixing feature spaces in one index makes cosine scores incomparable, and the
18021
+ * symptom is a quality regression with no visible cause.
18022
+ */
18023
+ var RebuildObjectEmbeddingsInput = object({
18024
+ /** Restrict to one camera. Omit for the whole fleet. */
18025
+ deviceId: number().optional(),
18026
+ since: number().optional(),
18027
+ until: number().optional(),
18028
+ /** Stop after this many tracks; the result reports whether more remain. */
18029
+ maxTracks: number().int().positive().optional(),
18030
+ /**
18031
+ * Run every embedding on THIS node instead of round-robining the fleet.
18032
+ *
18033
+ * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
18034
+ * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
18035
+ * calling it that would pin the rebuild REQUEST itself to that node — the
18036
+ * rebuild orchestration lives on the hub, and only the per-track step runs
18037
+ * remotely. This field is data; the per-track pin is applied inside.
18038
+ *
18039
+ * Absent ⇒ round-robin over every online node whose runner can serve the
18040
+ * pinned model.
18041
+ */
18042
+ executeOnNodeId: string().optional(),
18043
+ /**
18044
+ * Milliseconds to wait between tracks; omit for the built-in default, `0` to
18045
+ * run flat out.
18046
+ *
18047
+ * A rebuild is bulk maintenance on hub-main's single thread. Measured
18048
+ * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
18049
+ * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
18050
+ * force is logged at start and finish so a deliberately slow pass reads
18051
+ * differently from a stalled one.
18052
+ */
18053
+ pacingMs: number().int().nonnegative().optional()
17851
18054
  });
17852
- var ReferenceAudioEntrySchema = object({
17853
- filename: string(),
17854
- sizeKb: number()
18055
+ /**
18056
+ * Result of emptying the CLIP index.
18057
+ *
18058
+ * The clean slate before a policy change: a new crop margin or encoder model
18059
+ * leaves two feature spaces in one index whose cosine scores are not
18060
+ * comparable, so wiping and rebuilding is the only way to be sure every vector
18061
+ * means the same thing.
18062
+ */
18063
+ var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
18064
+ /**
18065
+ * Acknowledgement that a rebuild STARTED.
18066
+ *
18067
+ * The pass costs ~1s per track — 45 minutes for a 2,600-track fleet — so it
18068
+ * runs detached and this returns immediately. Waiting for it made the client
18069
+ * time out while the work carried on server-side, which is the worst of both:
18070
+ * no result and no way to know it was still going. Poll
18071
+ * `getObjectEmbeddingRebuildStatus` for progress.
18072
+ */
18073
+ var RebuildObjectEmbeddingsResultSchema = object({
18074
+ started: boolean(),
18075
+ /** True when a pass was already running; the new request is ignored. */
18076
+ alreadyRunning: boolean()
17855
18077
  });
17856
- var ReferenceAudioBodySchema = object({ base64: string() });
17857
- var AudioBackendSchema = object({
17858
- id: string(),
17859
- name: string(),
17860
- description: string(),
17861
- available: boolean(),
18078
+ var RebuildStatusSchema = object({
18079
+ running: boolean(),
18080
+ scanned: number(),
18081
+ rebuilt: number(),
18082
+ /** Tracks whose key frame is gone — nothing to re-embed from. */
18083
+ missingKeyFrame: number(),
18084
+ /** Tracks with no usable detection box. */
18085
+ missingBbox: number(),
18086
+ /**
18087
+ * Tracks an executing node REFUSED rather than broke on — an unreadable key
18088
+ * frame, a step that threw. Separate from `failed` because the remedy is
18089
+ * different, and because a whole camera silently contributing zero vectors
18090
+ * is the shape of failure a rebuild must never hide.
18091
+ */
18092
+ notRunnable: number(),
17862
18093
  /**
17863
- * Raw classifier labels this backend can emit (e.g. YAMNet's
17864
- * 521-class set or Apple SoundAnalysis's 303-class set). Used by
17865
- * the benchmark UI to populate the `enabledMicroClasses` filter
17866
- * specific to the selected backend without a separate fetch.
18094
+ * The pass stopped because NO node could serve the pinned model.
18095
+ *
18096
+ * Distinct from `notRunnable` on purpose: that one says "this track was
18097
+ * refused", this one says "the cluster cannot do this work at all" — every
18098
+ * candidate node either lacks the `clip-embedding` step, lacks a build of the
18099
+ * pinned model for its engine format, or dropped out. The remedy is a model /
18100
+ * engine change, not a per-camera one. Non-zero here always comes with
18101
+ * `complete: false`.
17867
18102
  */
17868
- rawLabels: array(string()).readonly().optional()
17869
- });
17870
- var AudioCapabilitiesSchema = object({
17871
- activeBackend: string(),
17872
- availableBackends: array(AudioBackendSchema).readonly(),
17873
- sampleRate: number(),
17874
- chunkDurationMs: number()
17875
- });
17876
- var DownloadModelResultSchema = object({
17877
- filePath: string(),
17878
- sizeMB: number(),
17879
- durationMs: number()
18103
+ noCapableNode: number(),
18104
+ failed: number(),
18105
+ /** Set once a pass ends: true only when EVERYTHING was covered. */
18106
+ complete: boolean().nullable(),
18107
+ startedAtMs: number().nullable(),
18108
+ finishedAtMs: number().nullable(),
18109
+ /** Present when the pass ended by throwing. */
18110
+ error: string().nullable()
17880
18111
  });
17881
- /**
17882
- * Wrapper carrying a single test run's result. Replaces the legacy
17883
- * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
17884
- * canonical `AudioResult` from the Phase 6 output rework: one
17885
- * `AudioDetection` per class above `minScore`, top-N candidates in
17886
- * `debug.alternateLabels['audio-classifier']`, per-source timings in
17887
- * `debug.stepTimings`. The outer `success`/`error` fields stay so the
17888
- * benchmark UI can still report a clean failure when the classifier
17889
- * cap isn't available.
17890
- */
17891
- var AudioTestResultSchema = object({
17892
- success: boolean(),
17893
- error: string().optional(),
17894
- frame: custom().optional()
18112
+ var ReplayFrameInputSchema = object({
18113
+ timestamp: number(),
18114
+ frame: PipelineRunResultBridge
17895
18115
  });
17896
- var PipelineConfigBridge = custom();
17897
- var ConfigUISchemaBridge = custom();
17898
- var ConfigUISchemaNullableBridge = custom();
17899
- var InferenceCapabilitiesBridge = custom();
17900
- var ModelAvailabilityListBridge = custom();
17901
- var PipelineRunResultBridge = custom();
17902
- method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
17903
- modelId: string(),
17904
- settings: record(string(), unknown()).readonly()
17905
- }))), method(object({ steps: record(string(), object({
17906
- modelId: string(),
17907
- settings: record(string(), unknown()).readonly()
17908
- })) }), object({ success: literal(true) }), {
18116
+ var RunReplayFrameProcessorResultSchema = object({ tracks: array(object({
18117
+ className: string(),
18118
+ firstSeenMs: number(),
18119
+ lastSeenMs: number(),
18120
+ /** Bbox of the track's FIRST matched detection, pixel-space in the clip's
18121
+ * frame a representative box for the diff's `(className, window, IoU)`
18122
+ * pairing (`replay-diff.ts`). A replay does not need the full per-frame
18123
+ * trajectory production's `Track.positions` keeps. */
18124
+ bbox: BoundingBoxSchema,
18125
+ /** How many of the input frames this track matched a real detection on
18126
+ * (never a coasted/extrapolated frame) — the replay's own signal for "how
18127
+ * solid is this track", cheaper than re-deriving it from a trajectory. */
18128
+ framesMatched: number().int()
18129
+ })).readonly() });
18130
+ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
18131
+ deviceId: number(),
18132
+ trackId: string()
18133
+ }), TrackSchema.nullable()), method(object({
18134
+ deviceId: number(),
18135
+ since: number().optional(),
18136
+ until: number().optional(),
18137
+ limit: number().optional(),
18138
+ /** Spatial filter — only tracks whose trajectory intersects the zone
18139
+ * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
18140
+ * envelope columns, then precisely tested per position. Tracks with
18141
+ * an unknown envelope (no frame dims at persist time) always match. */
18142
+ zone: TrackZoneFilterSchema.optional(),
18143
+ /** See {@link TrackProjectionSchema}. Default `full` (backward
18144
+ * compatible — omitting the field keeps today's exact behaviour). */
18145
+ projection: TrackProjectionSchema.optional(),
18146
+ /** Include stationary-promoted rows (parked objects handed to the
18147
+ * stationary registry). Default false: the timeline lists passages,
18148
+ * not parking records (operator decision, 2026-08-15). */
18149
+ includeStationary: boolean().optional()
18150
+ }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
18151
+ deviceId: number(),
18152
+ groupId: string().min(1)
18153
+ }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
18154
+ kind: "mutation",
18155
+ auth: "admin"
18156
+ }), 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({
18157
+ deviceId: number(),
18158
+ since: number().optional(),
18159
+ until: number().optional(),
18160
+ kinds: array(string()).optional(),
18161
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
18162
+ }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
18163
+ deviceId: number(),
18164
+ since: number(),
18165
+ until: number(),
18166
+ bucketMs: number().int().positive()
18167
+ }), array(object({
18168
+ bucketStart: number(),
18169
+ motion: number().int(),
18170
+ object: number().int(),
18171
+ audio: number().int()
18172
+ })).readonly()), method(object({
18173
+ deviceId: number(),
18174
+ cutoffMs: number()
18175
+ }), object({
18176
+ motion: number().int(),
18177
+ object: number().int(),
18178
+ audio: number().int()
18179
+ }), {
18180
+ kind: "mutation",
18181
+ auth: "admin"
18182
+ }), method(object({
18183
+ deviceId: number(),
18184
+ cutoffMs: number()
18185
+ }), TrackCascadeCountsSchema, {
18186
+ kind: "mutation",
18187
+ auth: "admin"
18188
+ }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
18189
+ kind: "mutation",
18190
+ auth: "admin"
18191
+ }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
18192
+ kind: "mutation",
18193
+ auth: "admin"
18194
+ }), method(object({
18195
+ deviceId: number(),
18196
+ trackIds: array(string()).min(1)
18197
+ }), object({
18198
+ deleted: number().int(),
18199
+ failed: array(string()).readonly()
18200
+ }), {
18201
+ kind: "mutation",
18202
+ auth: "admin"
18203
+ }), method(object({
18204
+ /** Log/audit scope only — the trackId is globally unique on its own. */
18205
+ deviceId: number(),
18206
+ trackId: string(),
18207
+ flags: TrackFlagsPatchSchema
18208
+ }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
18209
+ kind: "query",
18210
+ auth: "admin"
18211
+ }), method(object({
18212
+ olderThanMs: number(),
18213
+ reason: OpsLogReasonSchema.optional()
18214
+ }), EventPruneCountsSchema, {
18215
+ kind: "mutation",
18216
+ auth: "admin"
18217
+ }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
18218
+ kind: "mutation",
18219
+ auth: "admin"
18220
+ }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
18221
+ kind: "mutation",
18222
+ auth: "admin"
18223
+ }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
18224
+ kind: "mutation",
18225
+ auth: "admin"
18226
+ }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
18227
+ kind: "mutation",
18228
+ auth: "admin"
18229
+ }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
18230
+ kind: "mutation",
18231
+ auth: "admin"
18232
+ }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18233
+ kind: "mutation",
18234
+ auth: "admin"
18235
+ }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
18236
+ kind: "mutation",
18237
+ auth: "admin"
18238
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
18239
+ kind: "query",
18240
+ auth: "admin"
18241
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18242
+ kind: "mutation",
18243
+ auth: "admin"
18244
+ }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
18245
+ kind: "query",
18246
+ auth: "admin"
18247
+ }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
18248
+ kind: "query",
18249
+ auth: "admin"
18250
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18251
+ kind: "query",
18252
+ auth: "admin"
18253
+ }), method(object({
18254
+ /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
18255
+ * `deviceId`, deliberately: `deviceId` would make this device-bound and
18256
+ * route it at one camera's owner, and "every camera" would stop being
18257
+ * expressible at all. */
18258
+ deviceIds: array(number()).optional(),
18259
+ limit: number().int().min(1).max(500).optional()
18260
+ }), array(RetrainTrackSchema).readonly(), {
18261
+ kind: "query",
18262
+ auth: "admin"
18263
+ }), method(object({ trackId: string() }), RetrainFrameListSchema, {
18264
+ kind: "query",
18265
+ auth: "admin"
18266
+ }), method(object({
18267
+ deviceId: number(),
18268
+ trackId: string(),
18269
+ mediaKeys: array(string()).min(1)
18270
+ }), RetrainFrameSelectionSchema, {
18271
+ kind: "mutation",
18272
+ auth: "admin"
18273
+ }), method(object({
18274
+ deviceId: number(),
18275
+ trackId: string(),
18276
+ frameId: string()
18277
+ }), object({
18278
+ removed: boolean(),
18279
+ removedAnnotations: number().int()
18280
+ }), {
18281
+ kind: "mutation",
18282
+ auth: "admin"
18283
+ }), method(object({ frameId: string() }), object({
18284
+ base64: string(),
18285
+ width: number().int(),
18286
+ height: number().int()
18287
+ }), {
18288
+ kind: "query",
18289
+ auth: "admin"
18290
+ }), method(object({
18291
+ deviceId: number(),
18292
+ trackId: string(),
18293
+ frameId: string(),
18294
+ subject: RetrainAssistSubjectSchema,
18295
+ /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
18296
+ nodeId: string().optional()
18297
+ }), RetrainAssistResultSchema, {
18298
+ kind: "mutation",
18299
+ auth: "admin"
18300
+ }), method(object({
18301
+ deviceId: number(),
18302
+ source: DetectionSourceSchema,
18303
+ zones: array(ZoneSchema).readonly().optional(),
18304
+ detectionRules: array(ZoneRuleSchema).readonly().optional(),
18305
+ zoneMembershipMinOverlap: number().min(0).max(1).optional(),
18306
+ frames: array(ReplayFrameInputSchema).min(1)
18307
+ }), RunReplayFrameProcessorResultSchema, {
18308
+ kind: "mutation",
18309
+ auth: "admin"
18310
+ }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
18311
+ kind: "query",
18312
+ auth: "admin"
18313
+ }), method(object({
18314
+ deviceId: number(),
18315
+ trackId: string(),
18316
+ frameId: string(),
18317
+ annotations: array(RetrainAnnotationDraftSchema)
18318
+ }), array(RetrainAnnotationSchema).readonly(), {
18319
+ kind: "mutation",
18320
+ auth: "admin"
18321
+ }), method(object({
18322
+ deviceId: number(),
18323
+ trackId: string()
18324
+ }), RetrainTransitionResultSchema, {
17909
18325
  kind: "mutation",
17910
18326
  auth: "admin"
17911
- }), method(object({ nodeId: string() }), object({
17912
- success: literal(true),
17913
- clearedDevices: number()
17914
- }), {
18327
+ }), method(object({
18328
+ deviceId: number(),
18329
+ trackId: string()
18330
+ }), RetrainTransitionResultSchema, {
17915
18331
  kind: "mutation",
17916
18332
  auth: "admin"
17917
- }), 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({
17918
- name: string(),
17919
- steps: array(PipelineTemplateStepSchema).readonly(),
17920
- engine: PipelineEngineChoiceSchema
17921
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
17922
- id: string(),
17923
- name: string().optional(),
17924
- steps: array(PipelineTemplateStepSchema).readonly().optional()
17925
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
17926
- addonId: string(),
17927
- modelId: string(),
17928
- format: ModelFormatSchema$1
17929
- }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
17930
- addonId: string(),
17931
- modelId: string(),
17932
- format: ModelFormatSchema$1
17933
- }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
17934
- engine: PipelineEngineChoiceSchema.optional(),
17935
- steps: array(PipelineStepInputSchema).min(1),
17936
- frame: FrameInputSchema.optional(),
17937
- /**
17938
- * Process-local lazy frame. Valid only when caller and provider resolve
17939
- * in the same execution-group process; split/cross-node callers use
17940
- * `frame`/`image` inline compatibility instead.
17941
- */
17942
- frameRef: FrameRefSchema.optional(),
17943
- /**
17944
- * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
17945
- * the decoded pixels live in. One more member of the one-of
17946
- * frame/frameHandle/image/imageBase64/referenceImage group.
17947
- */
17948
- frameHandle: FrameHandleSchema.optional(),
17949
- imageBase64: string().optional(),
17950
- /**
17951
- * Binary JPEG bytes — preferred over `imageBase64` on internal
17952
- * hops (hub → forked worker via Moleculer MsgPack) because it
17953
- * skips the 33% base64 overhead + the per-call base64 decode on
17954
- * the detection-pipeline worker. Callers can pass either; exactly
17955
- * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
17956
- */
17957
- image: _instanceof(Uint8Array).optional(),
17958
- referenceImage: string().optional(),
17959
- deviceId: number().optional(),
17960
- sessionId: string().optional(),
17961
- /**
17962
- * Execution plane. 'full' (default) runs the whole tree — benchmark,
17963
- * reference-image, and detail-subtree calls. 'frame' is the live
17964
- * per-frame dispatch: ONLY root-plane steps run; crop children
17965
- * (inputClasses ≠ null) are skipped and served per-track via
17966
- * pipelineRunner.runDetailSubtree (two-plane design).
17967
- */
17968
- plane: _enum(["full", "frame"]).optional(),
17969
- /**
17970
- * Inference-device selector (Phase 2 multi-device). Format
17971
- * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
17972
- * Omitted ⇒ the runner's default device (current single-engine
17973
- * behaviour). Selects WHICH device pool of the node runs the call.
17974
- */
17975
- deviceKey: string().optional(),
17976
- /**
17977
- * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
17978
- * when the parent crop was resolved from the frame's retained NATIVE
17979
- * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
17980
- * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
17981
- * resolution from that surface — the SAME quality path faces already
17982
- * had — instead of the downscaled parent tile. `handle` keys the native
17983
- * surface (node-pinned to its owner); `cropFrameSpace` is the parent
17984
- * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
17985
- * the executor's crop-normalized child ROI back into frame-normalized
17986
- * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
17987
- * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
17988
- * (today's behaviour on the fallback path).
17989
- */
17990
- nativeCropRef: NativeCropRefSchema.optional()
17991
- }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
17992
- engine: PipelineEngineChoiceSchema.optional(),
17993
- steps: array(PipelineStepInputSchema).min(1),
17994
- frames: array(FrameInputSchema).min(1).max(255),
17995
- deviceId: number().optional(),
17996
- sessionId: string().optional(),
17997
- /**
17998
- * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
17999
- * the batch to the Python pool's bench preprocess cache
18000
- * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
18001
- * preprocessed ONCE and every later inference is a pure-inference cache
18002
- * hit — the sustained-throughput run measures inference, not
18003
- * decode+preprocess+infer. Omitted/0 for live frames (all different →
18004
- * full preprocess every call, correct). Fresh per sustained run;
18005
- * released via `uncacheFrame`.
18006
- */
18007
- frameId: number().int().nonnegative().optional(),
18008
- /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
18009
- deviceKey: string().optional()
18010
- }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
18011
- data: _instanceof(Uint8Array),
18012
- width: number().int().positive(),
18013
- height: number().int().positive(),
18014
- format: _enum([
18015
- "rgb",
18016
- "bgr",
18017
- "gray"
18018
- ])
18019
- }), object({
18020
- frameId: number(),
18021
- width: number(),
18022
- height: number()
18023
- }), { kind: "mutation" }), method(object({
18024
- stepId: string(),
18025
- frameId: number().int()
18026
- }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
18027
- batchMode: string(),
18028
- windowMs: number(),
18029
- maxBatchSize: number(),
18030
- concurrency: number()
18031
- })), method(_void(), array(object({
18032
- engineKey: string(),
18033
- engine: PipelineEngineChoiceSchema,
18034
- modelsLoaded: array(string()).readonly(),
18035
- inUseByCameras: array(number()).readonly(),
18036
- /**
18037
- * Origin of this resident factory.
18038
- * - `runtime` — main camera-serving engine (no idle TTL).
18039
- * - `warm-override` — benchmark/test override held in the warm
18040
- * cache; auto-disposed after the idle TTL.
18041
- * - `device-pool` — a concurrent per-device pool (Phase 2
18042
- * multi-device, keyed by `deviceKey`) resolved
18043
- * via `resolveDeviceFactory`. Runs alongside the
18044
- * `runtime` engine on a DIFFERENT accelerator
18045
- * (NPU / iGPU / Coral) — this is how the
18046
- * Engines tab shows all pools running at once.
18047
- */
18048
- kind: _enum([
18049
- "runtime",
18050
- "warm-override",
18051
- "device-pool"
18052
- ]),
18053
- /** Native pid of the underlying Python pool (null when no pool). */
18054
- poolPid: number().nullable(),
18055
- /** ms since this factory was last used (null when not warm-tracked). */
18056
- idleMs: number().nullable(),
18057
- /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
18058
- idleTtlMs: number().nullable()
18059
- })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
18060
- kind: "mutation",
18333
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18334
+ kind: "query",
18061
18335
  auth: "admin"
18062
18336
  }), method(object({
18063
- engine: PipelineEngineChoiceSchema,
18064
- force: boolean().optional()
18065
- }), object({
18066
- success: boolean(),
18067
- reason: string().optional()
18068
- }), {
18337
+ eventId: string(),
18338
+ kind: MediaFileKindEnum.optional(),
18339
+ deviceId: number()
18340
+ }), array(MediaFileSchema).readonly()), method(object({
18341
+ trackId: string(),
18342
+ kinds: array(MediaFileKindEnum).optional(),
18343
+ deviceId: number()
18344
+ }), array(MediaFileSchema).readonly()), method(object({
18345
+ trackId: string(),
18346
+ deviceId: number()
18347
+ }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
18069
18348
  kind: "mutation",
18070
18349
  auth: "admin"
18071
- }), 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({
18072
- addonId: string(),
18073
- modelId: string(),
18074
- filename: string().optional(),
18075
- settings: record(string(), unknown()).optional()
18076
- }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
18350
+ }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
18351
+ kind: "mutation",
18352
+ auth: "admin"
18353
+ }), method(object({}), RebuildStatusSchema), object({
18354
+ deviceId: number(),
18355
+ timestamp: number(),
18356
+ frameWidth: number(),
18357
+ frameHeight: number(),
18358
+ detections: array(OverlayDetectionSchema).readonly()
18359
+ }), object({
18360
+ deviceId: number(),
18361
+ trackId: string(),
18362
+ className: string()
18363
+ }), object({
18364
+ deviceId: number(),
18365
+ trackId: string(),
18366
+ className: string(),
18367
+ durationMs: number()
18368
+ }), object({
18369
+ deviceId: number(),
18370
+ kind: EventKindSchema,
18371
+ eventId: string(),
18372
+ timestamp: number()
18373
+ });
18077
18374
  object({
18078
18375
  activeCameras: number(),
18079
18376
  throttledCameras: number(),
@@ -18085,119 +18382,19 @@ var CameraMetricsSchema = object({
18085
18382
  "disabled",
18086
18383
  "always-on",
18087
18384
  "on-motion"
18088
- ]),
18089
- configuredFps: number(),
18090
- actualFps: number(),
18091
- queueDepth: number(),
18092
- avgInferenceTimeMs: number(),
18093
- droppedFrames: number(),
18094
- phase: _enum([
18095
- "idle",
18096
- "watching",
18097
- "active"
18098
- ])
18099
- });
18100
- var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
18101
- /**
18102
- * Zone — pure geometry + identity. NO filtering behaviour.
18103
- *
18104
- * Zones describe **where** in the frame the operator wants to flag
18105
- * something; consumer-owned {@link ZoneRule} arrays describe **how**
18106
- * each pipeline stage uses them. Splitting the two means a single
18107
- * polygon "Driveway" can simultaneously back a motion-exclude rule,
18108
- * a detection-include rule on `['car']`, and an occupancy aggregate
18109
- * — without three duplicated polygons.
18110
- *
18111
- * Owned by the orchestrator addon (provider) and mirrored into the
18112
- * `zones` device-state slice on every mutation. Consumers
18113
- * (motion-wasm, pipeline-executor, analytics, admin UI) read either
18114
- * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
18115
- * mirror with `onChanged`).
18116
- *
18117
- * Coordinates are normalised fractions of the frame (0–1) so zones
18118
- * survive resolution changes and stream profile switches.
18119
- *
18120
- * `kind` discriminates between full polygons (closed regions used
18121
- * for intrusion / occupancy filters) and tripwires (open 2-point
18122
- * line segments used for cross events). Onboard / firmware-reported
18123
- * zones (Reolink, ONVIF) are out of scope for now — see the deferred
18124
- * task list.
18125
- */
18126
- var ZoneKindEnum = _enum(["polygon", "tripwire"]);
18127
- /** Polygon vertex in fraction-of-frame coordinates (0–1). */
18128
- var PolygonPointSchema = object({
18129
- x: number(),
18130
- y: number()
18131
- });
18132
- /** A camera detection zone — pure geometry/identity. */
18133
- var ZoneSchema = object({
18134
- id: string(),
18135
- name: string(),
18136
- kind: ZoneKindEnum.default("polygon"),
18137
- /** Polygon vertices, fraction of frame (0–1). */
18138
- polygon: array(PolygonPointSchema).readonly(),
18139
- /** Visual color for UI rendering. */
18140
- color: string().default("#3b82f6")
18385
+ ]),
18386
+ configuredFps: number(),
18387
+ actualFps: number(),
18388
+ queueDepth: number(),
18389
+ avgInferenceTimeMs: number(),
18390
+ droppedFrames: number(),
18391
+ phase: _enum([
18392
+ "idle",
18393
+ "watching",
18394
+ "active"
18395
+ ])
18141
18396
  });
18142
- /**
18143
- * Zones capability — per-camera CRUD over polygon detection zones.
18144
- *
18145
- * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
18146
- * to per-device settings and mirrors into the `zones` device-state
18147
- * slice on every mutation, so downstream consumers can subscribe via
18148
- * `dev.state.zones.onChanged`.
18149
- *
18150
- * The cap surface only handles geometry + identity; filtering
18151
- * behaviour (per-class, include/exclude, threshold) lives in the
18152
- * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
18153
- * `capabilities/schemas/zone-rule.js`.
18154
- */
18155
- var zonesCapability = {
18156
- name: "zones",
18157
- scope: "device",
18158
- mode: "singleton",
18159
- deviceTypes: [DeviceType.Camera],
18160
- methods: {
18161
- listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
18162
- addZone: method(object({
18163
- deviceId: number(),
18164
- zone: ZoneSchema
18165
- }), _void(), {
18166
- kind: "mutation",
18167
- auth: "admin"
18168
- }),
18169
- removeZone: method(object({
18170
- deviceId: number(),
18171
- zoneId: string()
18172
- }), _void(), {
18173
- kind: "mutation",
18174
- auth: "admin"
18175
- }),
18176
- updateZone: method(object({
18177
- deviceId: number(),
18178
- zone: ZoneSchema
18179
- }), _void(), {
18180
- kind: "mutation",
18181
- auth: "admin"
18182
- })
18183
- },
18184
- /**
18185
- * Runtime-state slice — the live zone catalogue mirrored by the
18186
- * orchestrator on every CRUD mutation. Consumers read via
18187
- * `device.state.zones.value` / `.watch(...)` without round-tripping
18188
- * the cap, and the codegen DeviceProxy auto-wires the reactive
18189
- * handle. Slice shape is `{ zones: Zone[] }` so future extensions
18190
- * (e.g. zone groupings) can sit alongside the polygon list.
18191
- */
18192
- runtimeState: object({ zones: array(ZoneSchema).readonly() }),
18193
- /**
18194
- * 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.
18195
- *
18196
- * See `RuntimeStateDurability`. Enforced by
18197
- * `scripts/check-runtime-state-durability.ts`.
18198
- */
18199
- durability: "restored"
18200
- };
18397
+ var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
18201
18398
  /**
18202
18399
  * A bounding box in NORMALIZED [0,1] frame coordinates for `getNativeCrop`. The
18203
18400
  * decode worker resolves it against the RETAINED native frame's real pixel dims,
@@ -19990,7 +20187,7 @@ method(object({
19990
20187
  * linking rather than produce an eternal token.
19991
20188
  */
19992
20189
  ttlSec: union([number().int().positive(), literal("never")]).optional()
19993
- }), object({ token: string() })), method(object({ token: string() }), SsoBridgeClaimsSchema.nullable());
20190
+ }), object({ token: string() }), { auth: "admin" }), method(object({ token: string() }), SsoBridgeClaimsSchema.nullable(), { auth: "admin" });
19994
20191
  var ProviderListEntrySchema = discriminatedUnion("shouldSaveDiskSpace", [object({
19995
20192
  providerId: string().min(1),
19996
20193
  displayName: string().min(1),
@@ -20085,10 +20282,13 @@ var EvictResultSchema = object({
20085
20282
  /** True when the provider has nothing left it is willing to drop on this location. */
20086
20283
  exhausted: boolean()
20087
20284
  });
20088
- method(object({ locationId: string() }), EvictableUsageSchema), method(object({
20285
+ method(object({ locationId: string() }), EvictableUsageSchema, { auth: "admin" }), method(object({
20089
20286
  locationId: string(),
20090
20287
  targetBytes: number().int().positive()
20091
- }), EvictResultSchema, { kind: "mutation" });
20288
+ }), EvictResultSchema, {
20289
+ kind: "mutation",
20290
+ auth: "admin"
20291
+ });
20092
20292
  method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin" }), method(StorageMigrationInputSchema, object({ jobId: string() }), {
20093
20293
  kind: "mutation",
20094
20294
  auth: "admin"
@@ -20148,26 +20348,50 @@ var ReadChunkInputSchema = object({
20148
20348
  length: number()
20149
20349
  });
20150
20350
  var EndDownloadInputSchema = object({ downloadId: string() });
20151
- method(_void(), ProviderInfoSchema), method(object({ config: record(string(), unknown()) }), TestLocationResultSchema, { auth: "admin" }), method(object({
20351
+ method(_void(), ProviderInfoSchema, { auth: "admin" }), method(object({ config: record(string(), unknown()) }), TestLocationResultSchema, { auth: "admin" }), method(object({
20152
20352
  location: StorageLocationSchema,
20153
20353
  relativePath: string()
20154
- }), string()), method(object({
20354
+ }), string(), { auth: "admin" }), method(object({
20155
20355
  location: StorageLocationSchema,
20156
20356
  relativePath: string(),
20157
20357
  data: _instanceof(Uint8Array)
20158
- }), _void(), { kind: "mutation" }), method(object({
20358
+ }), _void(), {
20359
+ kind: "mutation",
20360
+ auth: "admin"
20361
+ }), method(object({
20159
20362
  location: StorageLocationSchema,
20160
20363
  relativePath: string()
20161
- }), _instanceof(Uint8Array)), method(object({
20364
+ }), _instanceof(Uint8Array), { auth: "admin" }), method(object({
20162
20365
  location: StorageLocationSchema,
20163
20366
  relativePath: string()
20164
- }), boolean()), method(object({
20367
+ }), boolean(), { auth: "admin" }), method(object({
20165
20368
  location: StorageLocationSchema,
20166
20369
  prefix: string().optional()
20167
- }), array(string()).readonly()), method(object({
20370
+ }), array(string()).readonly(), { auth: "admin" }), method(object({
20168
20371
  location: StorageLocationSchema,
20169
20372
  relativePath: string()
20170
- }), _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" });
20373
+ }), _void(), {
20374
+ kind: "mutation",
20375
+ auth: "admin"
20376
+ }), method(object({ location: StorageLocationSchema }), number().nullable(), { auth: "admin" }), method(BeginUploadInputSchema, BeginUploadResultSchema, {
20377
+ kind: "mutation",
20378
+ auth: "admin"
20379
+ }), method(WriteChunkInputSchema, _void(), {
20380
+ kind: "mutation",
20381
+ auth: "admin"
20382
+ }), method(FinalizeUploadInputSchema, _void(), {
20383
+ kind: "mutation",
20384
+ auth: "admin"
20385
+ }), method(AbortUploadInputSchema, _void(), {
20386
+ kind: "mutation",
20387
+ auth: "admin"
20388
+ }), method(BeginDownloadInputSchema, BeginDownloadResultSchema, {
20389
+ kind: "mutation",
20390
+ auth: "admin"
20391
+ }), method(ReadChunkInputSchema, _instanceof(Uint8Array), { auth: "admin" }), method(EndDownloadInputSchema, _void(), {
20392
+ kind: "mutation",
20393
+ auth: "admin"
20394
+ });
20171
20395
  /** Profile-exported FormBuilder schema. Shape is ConfigUISchema at the UI. */
20172
20396
  var ProfileSettingsSchemaBridge = unknown().nullable();
20173
20397
  var ProfileSettingsBagSchema = record(string(), unknown());
@@ -20425,7 +20649,8 @@ method(object({
20425
20649
  access: "create"
20426
20650
  }), method(object({ userId: string().optional() }), object({ optionsJSON: record(string(), unknown()) }), {
20427
20651
  kind: "mutation",
20428
- access: "view"
20652
+ access: "view",
20653
+ auth: "admin"
20429
20654
  }), method(object({
20430
20655
  /** Required — the user the assertion belongs to (verified). */
20431
20656
  userId: string(),
@@ -20433,10 +20658,12 @@ method(object({
20433
20658
  response: record(string(), unknown())
20434
20659
  }), object({ verified: boolean() }), {
20435
20660
  kind: "mutation",
20436
- access: "view"
20661
+ access: "view",
20662
+ auth: "admin"
20437
20663
  }), method(object({}), object({ optionsJSON: record(string(), unknown()) }), {
20438
20664
  kind: "mutation",
20439
- access: "view"
20665
+ access: "view",
20666
+ auth: "admin"
20440
20667
  }), method(object({
20441
20668
  /** AuthenticationResponseJSON from the browser. */
20442
20669
  response: record(string(), unknown()) }), object({
@@ -20444,7 +20671,8 @@ response: record(string(), unknown()) }), object({
20444
20671
  userId: string().nullable()
20445
20672
  }), {
20446
20673
  kind: "mutation",
20447
- access: "view"
20674
+ access: "view",
20675
+ auth: "admin"
20448
20676
  }), method(object({ userId: string() }), array(PasskeySummarySchema), { auth: "admin" }), method(object({
20449
20677
  userId: string(),
20450
20678
  credentialId: string()
@@ -20616,7 +20844,19 @@ var VectorStatsResultSchema = object({
20616
20844
  /** False when the backend ranks approximately. */
20617
20845
  exact: boolean()
20618
20846
  });
20619
- 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);
20847
+ method(VectorDeclareIndexInputSchema, _void(), {
20848
+ kind: "mutation",
20849
+ auth: "admin"
20850
+ }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
20851
+ kind: "mutation",
20852
+ auth: "admin"
20853
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
20854
+ kind: "mutation",
20855
+ auth: "admin"
20856
+ }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
20857
+ kind: "mutation",
20858
+ auth: "admin"
20859
+ }), method(VectorStatsInputSchema, VectorStatsResultSchema, { auth: "admin" });
20620
20860
  var ClipSchema = object({
20621
20861
  /** Opaque, provider-namespaced id. The default provider encodes the time
20622
20862
  * window so `getClipPlayback` is self-contained (no event re-query). */
@@ -23077,7 +23317,27 @@ var MediaFileLiteSchema$1 = object({
23077
23317
  sizeBytes: number(),
23078
23318
  timestamp: number()
23079
23319
  });
23080
- method(_void(), array(IdentitySchema).readonly()), method(object({ name: string().min(1) }), IdentitySchema, {
23320
+ method(object({
23321
+ /**
23322
+ * Inline {@link IdentitySchema.coverBase64} on every row.
23323
+ *
23324
+ * Default `false`, the same inversion `listRecentFaces` and
23325
+ * `listPlates` took on 2026-08-25 (see `include-crops-default.ts` for
23326
+ * why the burden belongs on the caller that WANTS the bytes). Measured
23327
+ * on the live hub the same day: four identities cost 40,979 B with the
23328
+ * covers inline, ~10 KB of base64 per row, on a query this UI mounts
23329
+ * four times and the viewer holds at `staleTime: 30_000`.
23330
+ *
23331
+ * Nothing loses its avatar: `coverMediaKey` is already on every row and
23332
+ * the `event-media` plane serves that key `immutable` with an ETag.
23333
+ *
23334
+ * **This is an INPUT field, so it does not reach the addon until the
23335
+ * next train** — the hub router validates cap inputs against its own
23336
+ * compiled Zod and strips a key it does not know. Until then the
23337
+ * provider sees `undefined`, which resolves to `false`: the cheap shape
23338
+ * is what ships, and the opt-in becomes reachable when the train lands.
23339
+ */
23340
+ includeCrops: boolean().optional() }).optional(), array(IdentitySchema).readonly()), method(object({ name: string().min(1) }), IdentitySchema, {
23081
23341
  kind: "mutation",
23082
23342
  auth: "admin"
23083
23343
  }), method(object({
@@ -25967,8 +26227,10 @@ var PlateInfoSchema = object({
25967
26227
  keyFrameMediaKey: string().optional(),
25968
26228
  base64: string().optional(),
25969
26229
  /**
25970
- * Same crop as a data-plane URL. `getPlateByTrack` returns this and
25971
- * never inlines JPEG; `listPlates` still inlines for the admin-ui.
26230
+ * Same crop as a data-plane URL, always present when the plate has a stored
26231
+ * crop. `getPlateByTrack` returns this and never inlines JPEG; `listPlates`
26232
+ * and `searchPlates` inline the crop only when their `includeCrops` input is
26233
+ * left at its `true` default.
25972
26234
  */
25973
26235
  cropUrl: string().optional()
25974
26236
  });
@@ -25988,14 +26250,34 @@ var PlateClusterSchema = object({
25988
26250
  });
25989
26251
  method(object({
25990
26252
  deviceId: number().int().optional(),
25991
- limit: number().int().positive().optional()
26253
+ limit: number().int().positive().optional(),
26254
+ /**
26255
+ * Inline the base64 crop on every row. Default `true` — the existing
26256
+ * behaviour, kept so no caller breaks.
26257
+ *
26258
+ * Set `false` once the caller renders {@link PlateInfo.cropUrl}.
26259
+ * Measured on the live hub at the 500 rows the Plates view asks for:
26260
+ * 879,403 B and 27.7 s with the crops inline, against a few KiB of
26261
+ * metadata without them — and the browser then caches the images.
26262
+ *
26263
+ * This is the plate twin of `faceGallery.listRecentFaces`'s option;
26264
+ * plates were the one gallery list left without it.
26265
+ *
26266
+ * **This is an INPUT field, so it does not reach the addon until the
26267
+ * next train.** The hub router validates cap inputs against its own
26268
+ * compiled Zod and strips a key it does not know. Until the train
26269
+ * ships, sending `false` is harmless and keeps the crops inline.
26270
+ */
26271
+ includeCrops: boolean().optional()
25992
26272
  }).optional(), array(PlateInfoSchema).readonly()), method(object({
25993
26273
  deviceId: number().int(),
25994
26274
  trackId: string()
25995
26275
  }), PlateInfoSchema.nullable()), method(object({ plateId: string() }), array(MediaFileLiteSchema).readonly()), method(object({
25996
26276
  text: string().min(1),
25997
26277
  maxDistance: number().int().min(0).optional(),
25998
- limit: number().int().positive().optional()
26278
+ limit: number().int().positive().optional(),
26279
+ /** See `listPlates.includeCrops`. Default `true`. */
26280
+ includeCrops: boolean().optional()
25999
26281
  }), array(PlateInfoSchema).readonly()), method(object({
26000
26282
  maxDistance: number().int().min(0).optional(),
26001
26283
  minClusterSize: number().int().min(2).optional(),
@@ -26009,7 +26291,13 @@ method(object({
26009
26291
  }), method(object({ plateId: string() }), _void(), {
26010
26292
  kind: "mutation",
26011
26293
  auth: "admin"
26012
- }), method(_void(), array(VehicleSchema).readonly()), method(object({ name: string().min(1) }), VehicleSchema, {
26294
+ }), method(object({
26295
+ /** Inline {@link VehicleSchema.coverBase64} on every row. Default
26296
+ * `false` — the vehicle twin of `faceGallery.listIdentities`'s
26297
+ * option; `coverMediaKey` + the `event-media` plane carry the picture.
26298
+ * INPUT field: stripped by the hub router until the train ships, which
26299
+ * resolves to `false` and is exactly the intended default. */
26300
+ includeCrops: boolean().optional() }).optional(), array(VehicleSchema).readonly()), method(object({ name: string().min(1) }), VehicleSchema, {
26013
26301
  kind: "mutation",
26014
26302
  auth: "admin"
26015
26303
  }), method(object({
@@ -27530,92 +27818,6 @@ var sceneMonitorCapability = {
27530
27818
  durability: "session"
27531
27819
  };
27532
27820
  /**
27533
- * Per-stage gating mode applied to the zones a rule references.
27534
- *
27535
- * - `include`: the rule contributes to a **whitelist** for its stage.
27536
- * When at least one `include` rule fires for a stage, only entities
27537
- * inside one of those zones pass that stage.
27538
- * - `exclude`: the rule contributes to a **blacklist** for its stage.
27539
- * Entities inside one of those zones are dropped at that stage.
27540
- *
27541
- * `monitor`-style observation (count without filtering) is not a rule
27542
- * mode — zones without any matching rule are observed naturally by
27543
- * `zone-analytics` (live snapshot + history), so an "I just want to
27544
- * count, not filter" use case needs no rule at all.
27545
- */
27546
- var ZoneRuleModeEnum = _enum(["include", "exclude"]);
27547
- /**
27548
- * Per-consumer rule that references existing zones (geometry) and
27549
- * defines how a specific pipeline stage should treat them. Each
27550
- * consumer addon owns its own `ZoneRule[]` array in its per-device
27551
- * settings:
27552
- *
27553
- * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
27554
- * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
27555
- * - future: notification rules, audio gating, etc.
27556
- *
27557
- * One rule applies to N zones (`zoneIds[]`) so the operator can
27558
- * express "ignore motion in ALL of {garden, street}" with a single
27559
- * rule. `classFilter` narrows the rule to specific object classes —
27560
- * "drop person detections in the street, but keep cars" is one
27561
- * `exclude` rule with `classFilter: ['person']`.
27562
- *
27563
- * `enabled` is a soft toggle — the operator can keep the rule
27564
- * configured but inert without deleting it.
27565
- */
27566
- var ZoneRuleSchema = object({
27567
- /** Stable rule id — survives edits, used by the UI for diffing. */
27568
- id: string(),
27569
- /** Optional human-readable label rendered in the rule editor. */
27570
- name: string().optional(),
27571
- /** Zones this rule targets. The rule's `mode` applies to ALL
27572
- * listed zones (OR-set: a detection in any one of them counts).
27573
- * At least one zone id required — a rule with no targets is a
27574
- * configuration mistake and the form validator rejects it. */
27575
- zoneIds: array(string()).min(1).readonly(),
27576
- mode: ZoneRuleModeEnum,
27577
- /**
27578
- * Class names this rule applies to. Empty / undefined ⇒ rule
27579
- * applies to every class. Class strings match the `macroClass`
27580
- * field on detections (e.g. `person`, `car`, `dog`).
27581
- */
27582
- classFilter: array(string()).readonly().optional(),
27583
- /**
27584
- * Minimum bbox/mask overlap (0–1) with any of the rule's zones
27585
- * required to consider an entity "in the zone". Defaults to the
27586
- * consumer's stage default when omitted. Kept for back-compat with
27587
- * existing per-rule overrides; new operators pick the value via
27588
- * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
27589
- * set, the lower-level engine reads it as a 0–1 fraction.
27590
- */
27591
- overlapThreshold: number().min(0).max(1).optional(),
27592
- /**
27593
- * Operator-friendly version of `overlapThreshold` — the percentage
27594
- * of the detection's bbox that must lie inside the zone for the
27595
- * rule to match. Documented default is 85%; the engine substitutes
27596
- * that when the field is omitted (kept optional so existing rules
27597
- * stored without it stay valid).
27598
- *
27599
- * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
27600
- * rule, the engine prefers `bboxInclusionPct` because it's the
27601
- * field exposed in the UI. Internally both feed the same gate.
27602
- */
27603
- bboxInclusionPct: number().min(0).max(100).optional(),
27604
- /**
27605
- * When `true` and a detection has a segmentation mask, use the
27606
- * mask for overlap instead of the bbox. Detection-stage only;
27607
- * motion rules ignore this field.
27608
- */
27609
- preferMask: boolean().optional(),
27610
- /**
27611
- * Soft-toggle: `false` disables the rule without deleting it.
27612
- * Defaults to `true` so operators creating a rule via the UI
27613
- * see it active immediately.
27614
- */
27615
- enabled: boolean().default(true)
27616
- });
27617
- array(ZoneRuleSchema).readonly();
27618
- /**
27619
27821
  * Script-runner cap. Models HA `script.*` entities on
27620
27822
  * `DeviceType.Script`. A Script is a pre-recorded action sequence
27621
27823
  * that can be invoked imperatively — optionally with a variables
@@ -33336,6 +33538,12 @@ Object.freeze({
33336
33538
  addonId: null,
33337
33539
  access: "create"
33338
33540
  },
33541
+ "pipelineAnalytics.cancelRelocateMedia": {
33542
+ capName: "pipeline-analytics",
33543
+ capScope: "device",
33544
+ addonId: null,
33545
+ access: "create"
33546
+ },
33339
33547
  "pipelineAnalytics.cancelStorageMigrationMove": {
33340
33548
  capName: "pipeline-analytics",
33341
33549
  capScope: "device",
@@ -33510,6 +33718,12 @@ Object.freeze({
33510
33718
  addonId: null,
33511
33719
  access: "view"
33512
33720
  },
33721
+ "pipelineAnalytics.listRelocateMediaJobs": {
33722
+ capName: "pipeline-analytics",
33723
+ capScope: "device",
33724
+ addonId: null,
33725
+ access: "view"
33726
+ },
33513
33727
  "pipelineAnalytics.listRetrainAnnotations": {
33514
33728
  capName: "pipeline-analytics",
33515
33729
  capScope: "device",
@@ -33588,6 +33802,12 @@ Object.freeze({
33588
33802
  addonId: null,
33589
33803
  access: "create"
33590
33804
  },
33805
+ "pipelineAnalytics.relocateMedia": {
33806
+ capName: "pipeline-analytics",
33807
+ capScope: "device",
33808
+ addonId: null,
33809
+ access: "create"
33810
+ },
33591
33811
  "pipelineAnalytics.restageRetrainTrack": {
33592
33812
  capName: "pipeline-analytics",
33593
33813
  capScope: "device",
@@ -33600,6 +33820,12 @@ Object.freeze({
33600
33820
  addonId: null,
33601
33821
  access: "create"
33602
33822
  },
33823
+ "pipelineAnalytics.runReplayFrameProcessor": {
33824
+ capName: "pipeline-analytics",
33825
+ capScope: "device",
33826
+ addonId: null,
33827
+ access: "create"
33828
+ },
33603
33829
  "pipelineAnalytics.saveRetrainAnnotations": {
33604
33830
  capName: "pipeline-analytics",
33605
33831
  capScope: "device",
@@ -33732,6 +33958,12 @@ Object.freeze({
33732
33958
  addonId: null,
33733
33959
  access: "view"
33734
33960
  },
33961
+ "pipelineExecutor.getInferenceDeviceHealth": {
33962
+ capName: "pipeline-executor",
33963
+ capScope: "system",
33964
+ addonId: null,
33965
+ access: "view"
33966
+ },
33735
33967
  "pipelineExecutor.getOrchestratorConfigSchema": {
33736
33968
  capName: "pipeline-executor",
33737
33969
  capScope: "system",
@@ -33804,6 +34036,12 @@ Object.freeze({
33804
34036
  addonId: null,
33805
34037
  access: "view"
33806
34038
  },
34039
+ "pipelineExecutor.rearmInferenceDevice": {
34040
+ capName: "pipeline-executor",
34041
+ capScope: "system",
34042
+ addonId: null,
34043
+ access: "create"
34044
+ },
33807
34045
  "pipelineExecutor.runAudioTest": {
33808
34046
  capName: "pipeline-executor",
33809
34047
  capScope: "system",
@@ -37052,6 +37290,11 @@ Object.freeze({
37052
37290
  form: "single",
37053
37291
  optional: false
37054
37292
  }],
37293
+ "pipelineAnalytics.runReplayFrameProcessor": [{
37294
+ name: "deviceId",
37295
+ form: "single",
37296
+ optional: false
37297
+ }],
37055
37298
  "pipelineAnalytics.saveRetrainAnnotations": [{
37056
37299
  name: "deviceId",
37057
37300
  form: "single",