@camstack/addon-provider-rademacher 0.2.27 → 0.2.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/addon.js +2135 -1892
  2. package/dist/addon.mjs +2135 -1892
  3. package/package.json +1 -1
package/dist/addon.mjs CHANGED
@@ -7614,7 +7614,7 @@ function method(input, output, options) {
7614
7614
  input,
7615
7615
  output,
7616
7616
  kind: options?.kind ?? "query",
7617
- auth: options?.auth ?? "protected",
7617
+ ...options?.auth !== void 0 ? { auth: options.auth } : {},
7618
7618
  ...options?.access !== void 0 ? { access: options.access } : {},
7619
7619
  ...options?.caller !== void 0 ? { caller: options.caller } : {},
7620
7620
  timeoutMs: options?.timeoutMs
@@ -7638,7 +7638,7 @@ function event(data) {
7638
7638
  }
7639
7639
  var StaticDirOutputSchema$1 = object({ staticDir: string() });
7640
7640
  var VersionOutputSchema$1 = object({ version: string() });
7641
- method(_void(), StaticDirOutputSchema$1), method(_void(), VersionOutputSchema$1);
7641
+ method(_void(), StaticDirOutputSchema$1, { auth: "admin" }), method(_void(), VersionOutputSchema$1, { auth: "admin" });
7642
7642
  var DeviceType = /* @__PURE__ */ function(DeviceType) {
7643
7643
  DeviceType["Camera"] = "camera";
7644
7644
  DeviceType["Hub"] = "hub";
@@ -7959,7 +7959,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
7959
7959
  }({});
7960
7960
  var StaticDirOutputSchema = object({ staticDir: string() });
7961
7961
  var VersionOutputSchema = object({ version: string() });
7962
- method(_void(), StaticDirOutputSchema), method(_void(), VersionOutputSchema);
7962
+ method(_void(), StaticDirOutputSchema, { auth: "admin" }), method(_void(), VersionOutputSchema, { auth: "admin" });
7963
7963
  /**
7964
7964
  * device-ops — device-scoped cap that unifies the per-IDevice operations
7965
7965
  * previously routed through the `.device-ops` Moleculer bridge service.
@@ -8585,24 +8585,6 @@ var RecordingRetentionSchema = object({
8585
8585
  maxSizeGb: number().min(0).optional()
8586
8586
  });
8587
8587
  /**
8588
- * Scrub-thumbnail fidelity preset — the single per-camera selector bundling the
8589
- * sprite tile RESOLUTION + JPEG QUALITY the recorder packs timeline-scrub
8590
- * previews at. Five graduated steps; absent on a config = `standard` (the
8591
- * shipped default, matching `sheet-geometry`/`sheet-composer`).
8592
- *
8593
- * Existing sheets are IMMUTABLE — a changed preset applies to NEW windows only.
8594
- * Each window's index sidecar carries its own tile dims, so a camera whose
8595
- * preset changed over time renders every historical window at the dims it was
8596
- * written with.
8597
- */
8598
- var ScrubThumbnailPresetSchema = _enum([
8599
- "minimal",
8600
- "low",
8601
- "standard",
8602
- "high",
8603
- "max"
8604
- ]);
8605
- /**
8606
8588
  * The full per-camera recording intent — the wire shape of a RecordingTarget.
8607
8589
  *
8608
8590
  * `bands` is the ONLY authored recording intent: what to record, when, and on
@@ -8610,7 +8592,11 @@ var ScrubThumbnailPresetSchema = _enum([
8610
8592
  * other field is a storage knob (profiles, segment length, retention, scrub).
8611
8593
  *
8612
8594
  * STRICT on purpose: the legacy authoring surface (`schedule`/`schedules`/
8613
- * `triggers`/`preBufferSec`/`postBufferSec`/`rules`) was retired 2026-07-30.
8595
+ * `triggers`/`preBufferSec`/`postBufferSec`/`rules`) was retired 2026-07-30,
8596
+ * and `scrubThumbnails` — a five-step fidelity knob for a sprite tier that was
8597
+ * deleted on 2026-07-24 and had ZERO consumers in the recorder — on 2026-08-25
8598
+ * (D62: a switch that writes a store nobody reads is worse than no switch).
8599
+ * Stored rows keep loading: the READ schema is `.strip()` (config-store.ts).
8614
8600
  * A stale caller must fail loudly — silently stripping its legacy intent would
8615
8601
  * persist a band-less config, i.e. silently stop recording the camera.
8616
8602
  */
@@ -8633,14 +8619,7 @@ var RecordingConfigSchema = object({
8633
8619
  * "off" is the absence of a covering band, never a band value.
8634
8620
  */
8635
8621
  bands: array(RecordingBandSchema).default([]),
8636
- retention: RecordingRetentionSchema.optional(),
8637
- /**
8638
- * Per-camera scrub-thumbnail fidelity preset (resolution + JPEG quality for
8639
- * timeline-scrub sprite previews). Absent = `standard`. Applies to NEW
8640
- * windows only — existing sheets are immutable, and each window's index
8641
- * carries its own tile dims so mixed-preset history renders correctly.
8642
- */
8643
- scrubThumbnails: ScrubThumbnailPresetSchema.optional()
8622
+ retention: RecordingRetentionSchema.optional()
8644
8623
  }).strict();
8645
8624
  /**
8646
8625
  * Entity-relocation job state (storage entity-routing spec, Phase 4).
@@ -8716,10 +8695,11 @@ var RelocateFootageInputSchema = object({
8716
8695
  * `RecordingConfig.enabled` or camera wrapper bindings. */
8717
8696
  var StorageMigrationLeaseInputSchema = object({ leaseId: string().min(1) });
8718
8697
  var StorageMigrationFootageMoveInputSchema = RelocateFootageInputSchema.extend({ leaseId: string().min(1) });
8719
- var StorageMigrationMediaMoveInputSchema = object({
8698
+ var RelocateMediaInputSchema = object({
8720
8699
  toLocationId: string(),
8721
8700
  throttleMbps: number().min(1).max(1e3).optional()
8722
- }).extend({ leaseId: string().min(1) });
8701
+ });
8702
+ var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
8723
8703
  /** The independently selectable logical storage classes. `recordings`
8724
8704
  * encompasses the high and mid segment profiles; `recordingsLow` is low
8725
8705
  * segments; `eventMedia` is post-analysis blobs. */
@@ -9014,7 +8994,26 @@ var LabelDefinitionSchema = object({
9014
8994
  description: string().optional(),
9015
8995
  icon: string().optional()
9016
8996
  });
9017
- var ClassMapDefinitionSchema = object({
8997
+ /**
8998
+ * Wire schema for a per-model CATALOG classMap override
8999
+ * (`ModelCatalogEntry.classMap` / `ModelConvertMetadata.classMap`) —
9000
+ * restricted to {@link CLASS_MAP_MACRO_TARGETS}, the only macros the
9001
+ * detection pipeline executor actually routes.
9002
+ *
9003
+ * This is deliberately a DIFFERENT, narrower shape than the general-purpose
9004
+ * `ClassMapDefinition` interface above (e.g. `IDetectionAddon.getClassMap()`
9005
+ * and the audio `YAMNET_TO_MACRO` catalog both use macro targets outside this
9006
+ * enum) — the two used to share the name `ClassMapDefinition`/
9007
+ * `ClassMapDefinitionSchema`, which made the schema-type-twin guard
9008
+ * (`scripts/check-schema-type-twins.ts`) flag them as a duplicated shape. They
9009
+ * are not: it is two different concepts colliding on a name. Keep this type
9010
+ * under its own name rather than reusing `ClassMapDefinition` — reusing it
9011
+ * would either narrow every `ClassMapDefinition` consumer to the four
9012
+ * detection macros (breaking `YAMNET_TO_MACRO`) or drop the validation this
9013
+ * schema exists for (see the "rejects a classMap whose target is not a
9014
+ * detection macro" test in `model-catalog-schema.test.ts`).
9015
+ */
9016
+ var DetectionCatalogClassMapSchema = object({
9018
9017
  mapping: record(string(), _enum([
9019
9018
  "person",
9020
9019
  "vehicle",
@@ -9219,7 +9218,7 @@ var ModelCatalogEntrySchema = object({
9219
9218
  * applies (Frigate / COCO public catalog). Set on a custom model whose raw
9220
9219
  * labels already ARE the CamStack macros (Scrypted identity map).
9221
9220
  */
9222
- classMap: ClassMapDefinitionSchema.optional()
9221
+ classMap: DetectionCatalogClassMapSchema.optional()
9223
9222
  });
9224
9223
  var ConvertTargetSchema = discriminatedUnion("format", [object({
9225
9224
  format: literal("openvino"),
@@ -9249,7 +9248,7 @@ var ModelConvertMetadataSchema = object({
9249
9248
  "segmentation"
9250
9249
  ]),
9251
9250
  faceAlignment: boolean().optional(),
9252
- classMap: ClassMapDefinitionSchema.optional()
9251
+ classMap: DetectionCatalogClassMapSchema.optional()
9253
9252
  });
9254
9253
  var ConvertResultSchema = object({
9255
9254
  entry: ModelCatalogEntrySchema,
@@ -10112,7 +10111,7 @@ var AddonPageDeclarationSchema = object({
10112
10111
  /** Display label for a CUSTOM `section` id (ignored for well-known ids). */
10113
10112
  sectionLabel: string().optional()
10114
10113
  });
10115
- method(_void(), array(AddonPageDeclarationSchema).readonly());
10114
+ method(_void(), array(AddonPageDeclarationSchema).readonly(), { auth: "admin" });
10116
10115
  var AddonHttpRouteSchema = object({
10117
10116
  method: _enum([
10118
10117
  "GET",
@@ -10347,7 +10346,7 @@ var WidgetMetadataSchema = object({
10347
10346
  defaultColumns: number().int().min(1).max(12).default(6),
10348
10347
  defaultRows: number().int().min(1).max(12).default(1)
10349
10348
  });
10350
- method(_void(), array(WidgetMetadataSchema).readonly());
10349
+ method(_void(), array(WidgetMetadataSchema).readonly(), { auth: "admin" });
10351
10350
  /**
10352
10351
  * `addon-widgets` — system-scoped singleton aggregator cap. Public-facing
10353
10352
  * surface that admin-ui consumes through `useAddonWidgetsListWidgets()`.
@@ -11971,7 +11970,7 @@ var CustomModelDescriptorSchema = object({
11971
11970
  stepId: string(),
11972
11971
  entry: ModelCatalogEntrySchema
11973
11972
  });
11974
- method(_void(), array(CustomModelDescriptorSchema).readonly());
11973
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
11975
11974
  /**
11976
11975
  * Query filter for settings-store collections.
11977
11976
  */
@@ -12058,7 +12057,8 @@ method(object({
12058
12057
  }), _void(), { kind: "mutation" }), method(object({
12059
12058
  namespace: string().optional(),
12060
12059
  collection: string(),
12061
- filter: QueryFilterSchema.optional()
12060
+ filter: QueryFilterSchema.optional(),
12061
+ columns: array(string()).readonly().optional()
12062
12062
  }), array(SettingsRecordSchema).readonly()), method(object({
12063
12063
  namespace: string().optional(),
12064
12064
  collection: string(),
@@ -12121,46 +12121,87 @@ var EngineInfoSchema = object({
12121
12121
  kind: _enum(["relational", "vector"]),
12122
12122
  displayName: string()
12123
12123
  });
12124
- method(_void(), EngineInfoSchema), method(object({
12124
+ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
12125
12125
  namespace: string().optional(),
12126
12126
  collection: string(),
12127
12127
  key: string()
12128
- }), unknown()), method(object({
12128
+ }), unknown(), { auth: "admin" }), method(object({
12129
12129
  namespace: string().optional(),
12130
12130
  collection: string(),
12131
12131
  key: string(),
12132
12132
  value: unknown()
12133
- }), _void(), { kind: "mutation" }), method(object({
12133
+ }), _void(), {
12134
+ kind: "mutation",
12135
+ auth: "admin"
12136
+ }), method(object({
12134
12137
  namespace: string().optional(),
12135
12138
  collection: string(),
12136
- filter: QueryFilterSchema.optional()
12137
- }), array(SettingsRecordSchema).readonly()), method(object({
12139
+ filter: QueryFilterSchema.optional(),
12140
+ /**
12141
+ * SQL-level column projection — MUST mirror `settings-store.query`.
12142
+ *
12143
+ * ⚠ An earlier version of this comment blamed Zod stripping, and that
12144
+ * was wrong — corrected 2026-08-26 after the hop map
12145
+ * (`docs/design/2026-08-26-mappa-hop-argomenti.md`) traced the path.
12146
+ * There is **no Zod parse at all** between the door and the engine: the
12147
+ * dispatcher forwards the payload verbatim and UDS carries it whole. A
12148
+ * field declared here reaches `SqliteSettingsBackend` either way.
12149
+ *
12150
+ * What actually lost `columns` was the THIRD declaration of this shape:
12151
+ * `SettingsQueryInput` in `interfaces/storage.ts`, a hand-written TS
12152
+ * interface the engine destructures from. The field existed on both
12153
+ * schemas and the engine still never read it, because nothing checks a
12154
+ * registered provider against `InferProvider<cap>` —
12155
+ * `ProviderRegistration.provider` is typed `object`.
12156
+ *
12157
+ * It is declared here anyway, and must stay in step with
12158
+ * `settings-store.query`: a caller reading only the cap definitions has
12159
+ * to be able to see that this call carries a projection.
12160
+ * `data-door-schema-parity.spec.ts` keeps the two aligned.
12161
+ */
12162
+ columns: array(string()).readonly().optional()
12163
+ }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
12138
12164
  namespace: string().optional(),
12139
12165
  collection: string(),
12140
12166
  record: SettingsRecordSchema
12141
- }), _void(), { kind: "mutation" }), method(object({
12167
+ }), _void(), {
12168
+ kind: "mutation",
12169
+ auth: "admin"
12170
+ }), method(object({
12142
12171
  namespace: string().optional(),
12143
12172
  collection: string(),
12144
12173
  id: string(),
12145
12174
  data: record(string(), unknown())
12146
- }), _void(), { kind: "mutation" }), method(object({
12175
+ }), _void(), {
12176
+ kind: "mutation",
12177
+ auth: "admin"
12178
+ }), method(object({
12147
12179
  namespace: string().optional(),
12148
12180
  collection: string(),
12149
12181
  key: string()
12150
- }), _void(), { kind: "mutation" }), method(object({
12182
+ }), _void(), {
12183
+ kind: "mutation",
12184
+ auth: "admin"
12185
+ }), method(object({
12151
12186
  namespace: string().optional(),
12152
12187
  collection: string(),
12153
12188
  filter: MutationFilterSchema
12154
- }), object({ deleted: number().int() }), { kind: "mutation" }), method(object({
12189
+ }), object({ deleted: number().int() }), {
12190
+ kind: "mutation",
12191
+ auth: "admin"
12192
+ }), method(object({
12155
12193
  namespace: string().optional(),
12156
12194
  collection: string(),
12157
12195
  filter: MutationFilterSchema,
12158
12196
  data: record(string(), unknown())
12159
- }), object({ updated: number().int() }), { kind: "mutation" }), method(object({
12197
+ }), object({ updated: number().int() }), {
12198
+ kind: "mutation",
12199
+ auth: "admin"
12200
+ }), method(object({
12160
12201
  namespace: string().optional(),
12161
12202
  collection: string(),
12162
12203
  filter: QueryFilterSchema.optional()
12163
- }), number()), method(object({
12204
+ }), number(), { auth: "admin" }), method(object({
12164
12205
  namespace: string().optional(),
12165
12206
  collection: string(),
12166
12207
  field: string(),
@@ -12170,15 +12211,18 @@ method(_void(), EngineInfoSchema), method(object({
12170
12211
  }), array(object({
12171
12212
  bucket: number().int(),
12172
12213
  count: number().int()
12173
- })).readonly()), method(object({
12214
+ })).readonly(), { auth: "admin" }), method(object({
12174
12215
  namespace: string().optional(),
12175
12216
  collection: string()
12176
- }), boolean()), method(object({
12217
+ }), boolean(), { auth: "admin" }), method(object({
12177
12218
  namespace: string().optional(),
12178
12219
  collection: string(),
12179
12220
  columns: array(CollectionColumnSchema).readonly(),
12180
12221
  indexes: array(CollectionIndexSchema).readonly().optional()
12181
- }), _void(), { kind: "mutation" });
12222
+ }), _void(), {
12223
+ kind: "mutation",
12224
+ auth: "admin"
12225
+ });
12182
12226
  /**
12183
12227
  * shm ring usage stats for a `frameSink: 'shm'` decoder session —
12184
12228
  * exposed via `decoder.getShmStats` so downstream consumers can
@@ -13468,7 +13512,7 @@ method(object({
13468
13512
  crop: _instanceof(Uint8Array),
13469
13513
  width: number(),
13470
13514
  height: number()
13471
- }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
13515
+ }), EmbeddingResultSchema, { auth: "admin" }), method(object({ text: string() }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" });
13472
13516
  /**
13473
13517
  * filesystem-browse — per-node capability for browsing the node's local
13474
13518
  * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
@@ -13761,19 +13805,22 @@ method(LlmGenerateBaseInputSchema.extend({
13761
13805
  runtime: ManagedRuntimeConfigSchema,
13762
13806
  /** The managed profile's timeout, threaded by the hub provider. */
13763
13807
  timeoutMs: number().int().positive().optional()
13764
- }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
13808
+ }), LlmGenerateResultSchema, {
13809
+ kind: "mutation",
13810
+ auth: "admin"
13811
+ }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
13765
13812
  kind: "mutation",
13766
13813
  auth: "admin"
13767
13814
  }), method(object({}), _void(), {
13768
13815
  kind: "mutation",
13769
13816
  auth: "admin"
13770
- }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
13817
+ }), method(object({}), LlmRuntimeStatusSchema, { auth: "admin" }), method(object({ model: ManagedModelRefSchema }), _void(), {
13771
13818
  kind: "mutation",
13772
13819
  auth: "admin"
13773
13820
  }), method(object({ file: string() }), _void(), {
13774
13821
  kind: "mutation",
13775
13822
  auth: "admin"
13776
- }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
13823
+ }), method(object({}), array(LlmNodeModelSchema), { auth: "admin" }), method(object({}), LlmRuntimeDiskUsageSchema, { auth: "admin" });
13777
13824
  /**
13778
13825
  * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
13779
13826
  * methods concat-fan across providers; single-row methods route to ONE
@@ -17284,1748 +17331,1998 @@ var OauthIntegrationDescriptorSchema = object({
17284
17331
  */
17285
17332
  refreshTokenTtlSec: union([number().int().positive(), literal("never")]).optional()
17286
17333
  });
17287
- method(_void(), OauthIntegrationDescriptorSchema);
17334
+ method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
17288
17335
  /**
17289
- * pipeline-analytics device-scoped wrapper cap. Refines raw
17290
- * per-frame detections emitted by the pipeline runner into tracked
17291
- * objects, per-kind event collections (motion / object / audio), and
17292
- * persisted media. Owns the post-detection domain end-to-end:
17293
- *
17294
- * runner emits PipelineInferenceResult
17295
- * ↓ (event bus)
17296
- * pipeline-analytics subscriber
17297
- * ↓ SORT tracker + zone engine + state analyzer + event emitter
17298
- * → three DB collections (one per kind), one FS media tree, one
17299
- * unified event emitter (FrameTracked + TrackStarted/Ended +
17300
- * DetectionEvent on bus)
17301
- *
17302
- * Pure subscriber model. No `processFrame` cap method — the runner
17303
- * already publishes the raw frame on the bus. The cap surface is
17304
- * only QUERIES + per-device settings, bound on/off via
17305
- * `device-manager.setWrapperActive`. `defaultActive: true` because
17306
- * every camera with a detection pipeline wants its raw detections
17307
- * refined; operators opt out per-device via BindingsTab when needed.
17308
- *
17309
- * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
17310
- * (per-device surface) and `track-trail` caps — see P11 cleanup.
17336
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
17337
+ * within the frame, so the executor can re-cut a leaf child ROI at native
17338
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
17311
17339
  */
17312
- var TrackStateSchema = _enum([
17313
- "new",
17314
- "entered",
17315
- "left",
17316
- "moving",
17317
- "idle"
17318
- ]);
17319
- var EventKindSchema = _enum([
17320
- "motion",
17321
- "object",
17322
- "audio"
17323
- ]);
17340
+ var NativeCropRefSchema = object({
17341
+ /** Handle keying the retained native surface (node-pinned to its owner). */
17342
+ handle: FrameHandleSchema,
17343
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
17344
+ cropFrameSpace: object({
17345
+ x: number(),
17346
+ y: number(),
17347
+ w: number(),
17348
+ h: number()
17349
+ })
17350
+ });
17351
+ object({
17352
+ crop: object({
17353
+ left: number(),
17354
+ top: number(),
17355
+ width: number().positive(),
17356
+ height: number().positive()
17357
+ }).optional(),
17358
+ content: object({
17359
+ width: number().int().positive(),
17360
+ height: number().int().positive()
17361
+ }),
17362
+ fit: _enum(["stretch", "contain"]),
17363
+ format: _enum([
17364
+ "rgb",
17365
+ "gray",
17366
+ "jpeg"
17367
+ ])
17368
+ });
17324
17369
  /**
17325
- * Spatial filter for `listTracks` the rect + polygon variants of the shared
17326
- * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
17327
- * of the camera frame (top-left origin), matching the drawing-plane editor.
17370
+ * Process-local frame identity. It is serializable so it can ride an in-process
17371
+ * capability call, but `registryId` deliberately prevents resolution in any
17372
+ * other process or execution group.
17328
17373
  */
17329
- var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
17330
- /** Closed icon vocabulary so clients render a known glyph per kind. */
17331
- var EventKindIconSchema = _enum([
17332
- "motion",
17333
- "audio",
17334
- "person",
17335
- "vehicle",
17336
- "animal",
17337
- "door",
17338
- "pir",
17339
- "smoke",
17340
- "water",
17341
- "button",
17342
- "package",
17343
- "generic"
17374
+ var FrameRefSchema = object({
17375
+ registryId: string().min(1),
17376
+ id: string().min(1),
17377
+ width: number().int().positive(),
17378
+ height: number().int().positive(),
17379
+ format: _enum(["rgb", "gray"]),
17380
+ timestamp: number(),
17381
+ capturedAt: number().optional()
17382
+ });
17383
+ var ModelFormatSchema$1 = _enum([
17384
+ "onnx",
17385
+ "coreml",
17386
+ "openvino",
17387
+ "tflite",
17388
+ "pt",
17389
+ "gguf"
17344
17390
  ]);
17345
- var EventKindCategorySchema = _enum([
17346
- "motion",
17347
- "audio",
17348
- "detection",
17349
- "sensor",
17350
- "control",
17351
- "custom",
17352
- "package"
17391
+ var PipelineSlotSchema = _enum([
17392
+ "detector",
17393
+ "cropper",
17394
+ "classifier",
17395
+ "refiner",
17396
+ "audio-classifier"
17353
17397
  ]);
17354
- /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
17355
- var EventKindLevelSchema = _enum(["macro", "sub"]);
17356
- var EventKindDescriptorSchema = object({
17357
- /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
17358
- kind: string(),
17359
- /** i18n key resolved on the UI side; `label` is the English fallback. */
17360
- labelKey: string(),
17361
- /** English fallback label (kept for clients that don't translate). */
17362
- label: string(),
17363
- /** Hex color for timeline/legend rendering. */
17364
- color: string(),
17365
- /** Dictionary id → lucide component on the UI side. */
17366
- iconId: string(),
17367
- /** Legacy closed-vocab glyph — fallback for `iconId`. */
17368
- icon: EventKindIconSchema,
17369
- category: EventKindCategorySchema,
17370
- /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
17371
- parentKind: string().nullable(),
17372
- /** Derived from `parentKind`, explicit for the client tree. */
17373
- level: EventKindLevelSchema,
17374
- /** Which cap + device contributes this kind. For built-ins the camera
17375
- * itself; for sensor kinds the LINKED source device. */
17376
- source: object({
17377
- capName: string(),
17378
- deviceId: number()
17379
- })
17398
+ var PipelineEngineChoiceSchema = object({
17399
+ runtime: _enum(["node", "python"]),
17400
+ backend: string(),
17401
+ format: ModelFormatSchema$1,
17402
+ device: string().optional()
17380
17403
  });
17381
- /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
17382
- var EventKindsForDeviceSchema = object({
17383
- deviceId: number(),
17384
- kinds: array(EventKindDescriptorSchema).readonly()
17404
+ var AvailableEngineSchema = object({
17405
+ engine: PipelineEngineChoiceSchema,
17406
+ devices: array(object({
17407
+ id: string(),
17408
+ label: string(),
17409
+ description: string().optional()
17410
+ })).readonly(),
17411
+ defaultDevice: string()
17385
17412
  });
17386
- var SensorEventSchema = object({
17413
+ var PipelineDefaultStepSchema = lazy(() => object({
17414
+ addonId: string(),
17415
+ addonName: string(),
17416
+ slot: PipelineSlotSchema,
17417
+ inputClasses: array(string()).readonly(),
17418
+ outputClasses: array(string()).readonly(),
17419
+ enabled: boolean(),
17420
+ modelId: string(),
17421
+ children: array(PipelineDefaultStepSchema).readonly(),
17422
+ group: string().optional(),
17423
+ settings: record(string(), unknown()).optional()
17424
+ }));
17425
+ var PipelineTemplateStepSchema = lazy(() => object({
17426
+ addonId: string(),
17427
+ enabled: boolean(),
17428
+ modelId: string(),
17429
+ children: array(PipelineTemplateStepSchema).readonly(),
17430
+ settings: record(string(), unknown()).optional()
17431
+ }));
17432
+ var PipelineTemplateSchema$1 = object({
17387
17433
  id: string(),
17388
- /** The CAMERA the event is attributed to (a sensor linked to N cameras
17389
- * yields N rows, one per camera). */
17390
- deviceId: number(),
17391
- /** The linked sensor device whose state changed. */
17392
- sourceDeviceId: number(),
17393
- /** Event kind id — matches an `EventKindDescriptor.kind`. */
17394
- kind: string(),
17395
- /** Snapshot of the sensor cap's runtime-state slice at the change. */
17396
- value: record(string(), unknown()).nullable(),
17397
- timestamp: number()
17398
- });
17399
- var TrackPositionSchema = object({
17400
- x: number(),
17401
- y: number(),
17402
- timestamp: number(),
17403
- bbox: BoundingBoxSchema
17434
+ name: string(),
17435
+ createdAt: string(),
17436
+ updatedAt: string(),
17437
+ engine: PipelineEngineChoiceSchema,
17438
+ steps: array(PipelineTemplateStepSchema).readonly()
17404
17439
  });
17405
- var TrackSnapshotSchema = object({
17406
- timestamp: number(),
17407
- position: TrackPositionSchema,
17408
- /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
17409
- mediaKey: string()
17440
+ var PipelineModelOptionSchema = object({
17441
+ id: string(),
17442
+ name: string(),
17443
+ formats: record(string(), object({
17444
+ downloaded: boolean(),
17445
+ sizeMB: number()
17446
+ })),
17447
+ group: ModelVariantGroupSchema.optional(),
17448
+ legacy: boolean().optional(),
17449
+ provider: ModelProviderIdSchema.optional()
17410
17450
  });
17411
- /**
17412
- * Normalized 0..1 trajectory envelope (min/max over every position bbox,
17413
- * divided by the track's detection-frame dims), computed at persist time.
17414
- * Absent when the frame dims were unknown when the track was persisted
17415
- * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
17416
- */
17417
- var TrackEnvelopeSchema = object({
17418
- minX: number(),
17419
- minY: number(),
17420
- maxX: number(),
17421
- maxY: number()
17451
+ var ConfigFieldBridge = custom();
17452
+ var PipelineAddonSchemaSchema = object({
17453
+ id: string(),
17454
+ name: string(),
17455
+ slot: PipelineSlotSchema,
17456
+ inputClasses: array(string()).readonly(),
17457
+ outputClasses: array(string()).readonly(),
17458
+ childSlots: array(PipelineSlotSchema).readonly(),
17459
+ models: array(PipelineModelOptionSchema).readonly(),
17460
+ defaultModelId: string(),
17461
+ defaultModelIdByFormat: record(string(), string()).optional(),
17462
+ enabledByDefault: boolean().optional(),
17463
+ backfillIntoExistingOverrides: boolean().optional(),
17464
+ defaultConfidence: number(),
17465
+ group: string().optional(),
17466
+ configSchema: array(ConfigFieldBridge).readonly().optional()
17422
17467
  });
17423
- /**
17424
- * Row projection for track list queries. `full` (default) returns the
17425
- * complete Track including the frame-rate `positions[]` history and the
17426
- * `snapshots[]` references — megabytes across a page of tracks. `slim`
17427
- * keeps every scalar the list surfaces actually render (ids, class(es),
17428
- * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
17429
- * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
17430
- * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
17431
- * `getTrack`. Mirrors the event-store `projection` convention
17432
- * (`getObjectEvents` et al.).
17433
- */
17434
- var TrackProjectionSchema = _enum(["full", "slim"]);
17435
- /**
17436
- * One audio-classification label heard on the track's camera while the
17437
- * track was alive, aggregated per label. An "episode" is one persisted
17438
- * audio event (the confident-classification path: score ≥ the device's
17439
- * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
17440
- * one 32 ms inference chunk, so counts stay human-scaled.
17441
- */
17442
- var TrackAudioLabelSchema = object({
17468
+ var PipelineSlotSchemaSchema = object({
17469
+ id: PipelineSlotSchema,
17443
17470
  label: string(),
17444
- /** Highest classification score observed across the label's episodes. */
17445
- peakScore: number(),
17446
- /** Number of coalesced audio-event episodes carrying this label. */
17447
- count: number(),
17448
- firstAt: number(),
17449
- lastAt: number()
17471
+ priority: number(),
17472
+ parentSlot: PipelineSlotSchema.nullable(),
17473
+ addons: array(PipelineAddonSchemaSchema).readonly()
17450
17474
  });
17451
- /**
17452
- * How a track was produced. `pipeline` (default / absent) = the spatial
17453
- * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
17454
- * no positions, a single snapshot, and no bbox trajectory at all:
17455
- *
17456
- * - `sensor` — a linked sensor/control device state change.
17457
- * - `audio` — an audio event on the camera itself that was anomalous for
17458
- * THAT camera, loud, and heard while nothing visual was happening (D62).
17459
- *
17460
- * The spatial subsystems (tracker association, occupancy count, re-id /
17461
- * embedding, resurrection) MUST skip every synthetic source. Test for that
17462
- * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
17463
- * check silently readmits every source added after it was written.
17464
- */
17465
- var TrackSourceSchema = _enum([
17466
- "pipeline",
17467
- "sensor",
17468
- "audio"
17469
- ]);
17470
- /**
17471
- * Where a track sits in the RETRAIN lifecycle (D81).
17472
- *
17473
- * - `none` — never marked, or un-marked. Evictable.
17474
- * - `staging` — the operator wants this track as training material and has not
17475
- * finished with it. **This is the only state retention holds**: the track and
17476
- * everything it owns (object events, crops, keyframes, CLIP vector) survive
17477
- * the device's age window.
17478
- * - `trained` — the retrain page has taken what it needed. The frames it chose
17479
- * were COPIED into the retrain dataset at selection time, so the dataset no
17480
- * longer depends on the track's media and the track becomes EVICTABLE again.
17481
- * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
17482
- * a deliberate action of the retrain page, not a side effect of a checkbox.
17483
- *
17484
- * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
17485
- * the store's filter language has only positive equality and `whereIn` — no
17486
- * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
17487
- * would make the entire pre-column history immortal in one deploy.
17488
- */
17489
- var RetrainStatusSchema = _enum([
17490
- "none",
17491
- "staging",
17492
- "trained"
17493
- ]);
17494
- /**
17495
- * Per-track OPERATOR flags — set by hand from the admin UI or the viewer, never
17496
- * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
17497
- * so the two surfaces cannot drift.
17498
- *
17499
- * **Absent ≠ false.** A track that has never been touched omits the field; an
17500
- * explicitly un-flagged track carries `false`. Legacy rows written before the
17501
- * columns existed read as absent, and a consumer that needs a boolean should say
17502
- * `flag === true`, not `flag !== false`.
17503
- *
17504
- * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
17505
- * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
17506
- * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
17507
- * `trained` track reports `false` while refusing both writes. The boolean is
17508
- * kept because three surfaces drive a toggle off it; anything that needs to tell
17509
- * "never marked" from "already trained" must read `retrainStatus`.
17510
- *
17511
- * `debug` does NOT pin; it is attention, not durability.
17512
- *
17513
- * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
17514
- * A favourited track is skipped by retention the same way `staging` is, but
17515
- * it does not enter `none|staging|trained` and has no staging budget.
17516
- */
17517
- var TrackFlagFields = {
17518
- /** Operator marked this track as training material — i.e. `retrainStatus` is
17519
- * `'staging'`. */
17520
- markForTrain: boolean().optional(),
17521
- /** Operator marked this track for diagnostic attention. */
17522
- debug: boolean().optional(),
17523
- /** Operator favourited this track. Pins it against pruning. */
17524
- favourited: boolean().optional()
17525
- };
17526
- /**
17527
- * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
17528
- * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
17529
- * write patch, and the status is not something the toggle sets — it is what the
17530
- * toggle's boolean is derived from. Absent on an in-RAM track never touched;
17531
- * always present on a persisted row (the column default materialises `'none'`).
17532
- */
17533
- var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
17534
- /**
17535
- * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
17536
- * one flag can never clear the other — the toggles are independent and are
17537
- * driven from three surfaces that do not know about each other.
17538
- */
17539
- var TrackFlagsPatchSchema = object(TrackFlagFields);
17540
- /**
17541
- * The resolved flag state after a write. Both fields are REQUIRED here (absent
17542
- * collapses to `false`) so a caller can drive a toggle's checked state off the
17543
- * mutation result without a re-fetch.
17544
- */
17545
- var TrackFlagsSchema = object({
17546
- trackId: string(),
17547
- markForTrain: boolean(),
17548
- debug: boolean(),
17549
- favourited: boolean(),
17550
- /** The lifecycle state the boolean was derived from. Required here (unlike on
17551
- * a track row) because this shape is only ever produced by the write body,
17552
- * which always knows it — and a surface that has just written needs to render
17553
- * `trained` without a re-fetch. */
17554
- retrainStatus: RetrainStatusSchema
17475
+ var PipelineSchemaSchema = object({
17476
+ availableEngines: array(AvailableEngineSchema).readonly(),
17477
+ selectedEngine: PipelineEngineChoiceSchema,
17478
+ slots: array(PipelineSlotSchemaSchema).readonly()
17555
17479
  });
17556
- union([literal(1), literal(2)]);
17557
- /**
17558
- * WHO decided a label, and when. Carried per tier so a value can be traced to
17559
- * the step and model that produced it — which is what makes the write rule
17560
- * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
17561
- * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
17562
- *
17563
- * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
17564
- * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
17565
- * `migration:4g` for a value the 4g migration moved from the single-slot era —
17566
- * that value has no provenance, and the write rule lets ANY properly-attributed
17567
- * write of the same tier replace it regardless of score.
17568
- */
17569
- var LabelAttributionSchema = object({
17570
- stepId: string(),
17571
- modelId: string().optional(),
17572
- decidedAt: number(),
17480
+ var EngineProvisioningSchema = object({
17481
+ runtimeId: _enum([
17482
+ "onnx",
17483
+ "openvino",
17484
+ "coreml",
17485
+ "edgetpu"
17486
+ ]).nullable(),
17487
+ device: string().nullable(),
17488
+ state: _enum([
17489
+ "idle",
17490
+ "installing",
17491
+ "verifying",
17492
+ "ready",
17493
+ "failed"
17494
+ ]),
17495
+ progress: number().optional(),
17496
+ error: string().optional(),
17497
+ nextRetryAt: number().optional(),
17573
17498
  /**
17574
- * The GALLERY id behind a recognised tier-2 label — a face-gallery
17575
- * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
17576
- *
17577
- * The text alone is a DISPLAY NAME, and a display name is renameable: a
17578
- * notification rule authored on "Gianluca" stopped matching the moment the
17579
- * operator fixed the spelling in the gallery, and nothing said so. The id is
17580
- * the thing that does not move, so it is what a rule matches on
17581
- * (`NcConditions.identities`) and the text is what a human is shown.
17582
- *
17583
- * Absent when the label names no gallery row — a plate the OCR read but no
17584
- * vehicle claims, a sub-class, a species, any tier-1 value.
17499
+ * Gate A (config-correctness gate at engine change): human-readable
17500
+ * config issues surfaced EAGERLY when the node's engine changes — model
17501
+ * substitutions ("chose X, running Y") and zero-build steps ("no model
17502
+ * has a <format> build"). Additive/optional: informational only, never
17503
+ * enforced here `assertEngineReady` (readiness) still gates inference.
17504
+ * Absent/empty when the node-default tree resolves cleanly.
17585
17505
  */
17586
- identityId: string().optional()
17506
+ configIssues: array(string()).optional()
17587
17507
  });
17588
- /**
17589
- * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
17590
- * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
17591
- * track and its events always answer the same question the same way.
17592
- *
17593
- * Two scalar columns, not an array: every consumer wants "the coarse one" or
17594
- * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
17595
- * is tier 2, and each carries its own score + attribution.
17596
- *
17597
- * **Reading it.** What a human should be shown is `subLabel ?? label` — the
17598
- * finest thing known. Before 4g the single `label` column held the finest
17599
- * value, so a consumer that has not been updated reads the tier-1 slot and
17600
- * shows nothing on a species-only row; that is why the migration puts every
17601
- * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
17602
- * and why the read surfaces were changed in the same train.
17603
- *
17604
- * **Writing it.** The slots are independent, which is the whole point: a
17605
- * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
17606
- * migratorius`), so fineness cannot regress by construction. Within a tier the
17607
- * higher score wins. One rule, one implementation — see
17608
- * `pipeline/label-tier.ts` in addon-post-analysis.
17609
- */
17610
- var TieredLabelFields = {
17611
- /** Tier 1 the sub-class. See {@link LabelTierSchema}. */
17612
- label: string().optional(),
17613
- /** Confidence of the tier-1 value, as reported by the deciding step. */
17614
- labelScore: number().optional(),
17615
- /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
17616
- labelMeta: LabelAttributionSchema.optional(),
17617
- /** Tier 2 — the instance. See {@link LabelTierSchema}. */
17618
- subLabel: string().optional(),
17619
- /** Confidence of the tier-2 value, as reported by the deciding step. */
17620
- subLabelScore: number().optional(),
17621
- /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
17622
- subLabelMeta: LabelAttributionSchema.optional()
17623
- };
17624
- /** Per-camera slice of a training-export estimate. */
17625
- var TrainingExportDeviceTotalsSchema = object({
17626
- deviceId: number(),
17627
- tracks: number().int(),
17628
- files: number().int(),
17629
- bytes: number().int()
17508
+ var PipelineStepInputSchema = lazy(() => object({
17509
+ addonId: string(),
17510
+ modelId: string().optional(),
17511
+ enabled: boolean().default(true),
17512
+ children: array(PipelineStepInputSchema).optional(),
17513
+ settings: record(string(), unknown()).optional(),
17514
+ jumpDeviceKey: string().optional()
17515
+ }));
17516
+ var ModelSubstitutionSchema = object({
17517
+ addonId: string(),
17518
+ chosen: string(),
17519
+ running: string(),
17520
+ format: string()
17521
+ });
17522
+ var PipelineValidationIssueSchema = object({
17523
+ addonId: string(),
17524
+ kind: _enum(["unknown-addon", "no-format-build"]),
17525
+ detail: string()
17526
+ });
17527
+ var PipelineValidationResultSchema = object({
17528
+ ok: boolean(),
17529
+ issues: array(PipelineValidationIssueSchema).readonly(),
17530
+ substitutions: array(ModelSubstitutionSchema).readonly(),
17531
+ /** The node's `currentEngine.format` this validation ran against. */
17532
+ format: string()
17533
+ });
17534
+ var ReferenceImageEntrySchema = object({
17535
+ filename: string(),
17536
+ stepIds: array(string()).readonly().optional()
17537
+ });
17538
+ var ReferenceImageBodySchema = object({
17539
+ base64: string(),
17540
+ filename: string()
17541
+ });
17542
+ var ReferenceAudioEntrySchema = object({
17543
+ filename: string(),
17544
+ sizeKb: number()
17545
+ });
17546
+ var ReferenceAudioBodySchema = object({ base64: string() });
17547
+ var AudioBackendSchema = object({
17548
+ id: string(),
17549
+ name: string(),
17550
+ description: string(),
17551
+ available: boolean(),
17552
+ /**
17553
+ * Raw classifier labels this backend can emit (e.g. YAMNet's
17554
+ * 521-class set or Apple SoundAnalysis's 303-class set). Used by
17555
+ * the benchmark UI to populate the `enabledMicroClasses` filter
17556
+ * specific to the selected backend without a separate fetch.
17557
+ */
17558
+ rawLabels: array(string()).readonly().optional()
17559
+ });
17560
+ var AudioCapabilitiesSchema = object({
17561
+ activeBackend: string(),
17562
+ availableBackends: array(AudioBackendSchema).readonly(),
17563
+ sampleRate: number(),
17564
+ chunkDurationMs: number()
17565
+ });
17566
+ var DownloadModelResultSchema = object({
17567
+ filePath: string(),
17568
+ sizeMB: number(),
17569
+ durationMs: number()
17630
17570
  });
17631
17571
  /**
17632
- * What a training export WOULD contain. Computed from media index rows only —
17633
- * no blob is read to produce this.
17572
+ * Wrapper carrying a single test run's result. Replaces the legacy
17573
+ * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
17574
+ * canonical `AudioResult` from the Phase 6 output rework: one
17575
+ * `AudioDetection` per class above `minScore`, top-N candidates in
17576
+ * `debug.alternateLabels['audio-classifier']`, per-source timings in
17577
+ * `debug.stepTimings`. The outer `success`/`error` fields stay so the
17578
+ * benchmark UI can still report a clean failure when the classifier
17579
+ * cap isn't available.
17634
17580
  */
17635
- var TrainingExportSummarySchema = object({
17636
- generatedAt: number(),
17637
- trackCount: number().int(),
17638
- fileCount: number().int(),
17639
- byteCount: number().int(),
17640
- /** More marked tracks exist than a single pass carries. */
17641
- truncated: boolean(),
17642
- devices: array(TrainingExportDeviceTotalsSchema).readonly()
17581
+ var AudioTestResultSchema = object({
17582
+ success: boolean(),
17583
+ error: string().optional(),
17584
+ frame: custom().optional()
17643
17585
  });
17644
- var TrackSchema = object({
17645
- trackId: string(),
17646
- deviceId: number(),
17647
- className: string(),
17648
- ...TieredLabelFields,
17649
- producingDeviceName: string().optional(),
17650
- /** Track provenance. Absent `pipeline` (legacy rows). */
17651
- source: TrackSourceSchema.optional(),
17652
- firstSeen: number(),
17653
- lastSeen: number(),
17654
- /** Frame-rate position history (subject to maxPositionHistory cap). */
17655
- positions: array(TrackPositionSchema).readonly(),
17656
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
17657
- * saveThumbnails policy). */
17658
- snapshots: array(TrackSnapshotSchema).readonly(),
17659
- /** Deduplicated zones the track has entered at least once. Zone IDS. */
17660
- zonesVisited: array(string()).readonly(),
17586
+ var PipelineConfigBridge = custom();
17587
+ var ConfigUISchemaBridge = custom();
17588
+ var ConfigUISchemaNullableBridge = custom();
17589
+ var InferenceCapabilitiesBridge = custom();
17590
+ var ModelAvailabilityListBridge = custom();
17591
+ var PipelineRunResultBridge = custom();
17592
+ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
17593
+ modelId: string(),
17594
+ settings: record(string(), unknown()).readonly()
17595
+ }))), method(object({ steps: record(string(), object({
17596
+ modelId: string(),
17597
+ settings: record(string(), unknown()).readonly()
17598
+ })) }), object({ success: literal(true) }), {
17599
+ kind: "mutation",
17600
+ auth: "admin"
17601
+ }), method(object({ nodeId: string() }), object({
17602
+ success: literal(true),
17603
+ clearedDevices: number()
17604
+ }), {
17605
+ kind: "mutation",
17606
+ auth: "admin"
17607
+ }), method(object({ nodeId: string() }), object({ unhealthy: array(object({
17608
+ /** `<backend>:<device>`, e.g. `openvino:gpu`. */
17609
+ deviceKey: string(),
17661
17610
  /**
17662
- * Human NAMES for {@link zonesVisited}, resolved at READ time against the
17663
- * `zones` capability.
17664
- *
17665
- * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
17666
- * and no card can render — so every free-text search surface was structurally
17667
- * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
17668
- * just returned nothing. Resolving here rather than in each client keeps ONE
17669
- * derivation and costs the clients no extra call (the `zones` cap is
17670
- * per-device, so a client-side resolve would be a per-camera fan-out on a
17671
- * surface built to avoid exactly that).
17672
- *
17673
- * Resolved, never invented: a zone deleted since the track was written has no
17674
- * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
17675
- * two are not positionally aligned. Absent when the track visited no zone, or
17676
- * when the zone catalogue could not be read.
17611
+ * `failed` the per-device restart budget is exhausted; no pool
17612
+ * will be spawned until an operator re-arms it or the runner
17613
+ * respawns. `backoff` — under budget, waiting out the backoff (or
17614
+ * a cached pool observed dead and not yet condemned).
17677
17615
  */
17678
- zoneNames: array(string()).readonly().optional(),
17679
- /** Deduplicated set of detector classes observed for this track over its
17680
- * life (a track may be reclassified, e.g. person→vehicle). Absent on
17681
- * legacy rows written before class accumulation shipped. */
17682
- classes: array(string()).readonly().optional(),
17683
- /** Cumulative normalized distance travelled (0..1 units = full frame width). */
17684
- totalDistance: number(),
17685
- state: TrackStateSchema,
17686
- active: boolean(),
17687
- /** Deterministic key-event importance score in [0,1] (server-computed at
17688
- * track expiry, recomputed on late label). Absent on legacy rows written
17689
- * before scoring shipped — consumers degrade to absence / compute-on-read. */
17690
- importance: number().optional(),
17691
- /** Id of the track's highest-confidence ObjectEvent (its representative
17692
- * "best" frame). Absent when the track produced no object events. */
17693
- bestEventId: string().optional(),
17694
- /** Tag of the importance sub-signal that dominated the score
17695
- * (identity|dwell|proximity|class|confidence|travel|zone). */
17696
- importanceReason: string().optional(),
17697
- /** Audio-classification labels heard on the camera during the track's
17698
- * life (score ≥ device `classificationMinScore`), aggregated per label.
17699
- * Absent on legacy rows / tracks with no confident audio. */
17700
- audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
17701
- /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
17702
- * Populated from the persisted envelope columns on historical reads;
17703
- * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
17704
- envelope: TrackEnvelopeSchema.optional(),
17616
+ state: _enum(["failed", "backoff"]),
17617
+ /** Epoch ms of the death that produced this state. */
17618
+ since: number(),
17619
+ /** Pool deaths inside the current window. */
17620
+ deaths: number(),
17621
+ /** The last death's message. */
17622
+ lastError: string()
17623
+ })).readonly() })), method(object({
17624
+ nodeId: string(),
17625
+ deviceKey: string()
17626
+ }), object({ rearmed: boolean() }), {
17627
+ kind: "mutation",
17628
+ auth: "admin"
17629
+ }), 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({
17630
+ name: string(),
17631
+ steps: array(PipelineTemplateStepSchema).readonly(),
17632
+ engine: PipelineEngineChoiceSchema
17633
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
17634
+ id: string(),
17635
+ name: string().optional(),
17636
+ steps: array(PipelineTemplateStepSchema).readonly().optional()
17637
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
17638
+ addonId: string(),
17639
+ modelId: string(),
17640
+ format: ModelFormatSchema$1
17641
+ }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
17642
+ addonId: string(),
17643
+ modelId: string(),
17644
+ format: ModelFormatSchema$1
17645
+ }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
17646
+ engine: PipelineEngineChoiceSchema.optional(),
17647
+ steps: array(PipelineStepInputSchema).min(1),
17648
+ frame: FrameInputSchema.optional(),
17705
17649
  /**
17706
- * A face DETECTOR found a face on this track — nothing more. It says the
17707
- * detail plane produced a `face` detail; it does NOT say the face was
17708
- * embedded, matched, above `minFacePx`, or that the recognizer was even
17709
- * enabled. Set once and never cleared.
17710
- *
17711
- * **This exists so "face present but not recognised" is expressible.** A
17712
- * recognised identity lands in `subLabel` (attributed to the face chain via
17713
- * `subLabelMeta.stepId`), so before this field a track with an unmatched face
17714
- * and a track with no face at all were byte-identical on the wire and no
17715
- * surface could tell them apart. The read is `hasFace === true && subLabel
17716
- * === undefined`.
17717
- *
17718
- * **Absent ≠ false.** Every row written before the column existed omits it,
17719
- * and so does every server that predates the field — a consumer must test
17720
- * `=== true` and render nothing otherwise, never infer "no face".
17650
+ * Process-local lazy frame. Valid only when caller and provider resolve
17651
+ * in the same execution-group process; split/cross-node callers use
17652
+ * `frame`/`image` inline compatibility instead.
17721
17653
  */
17722
- hasFace: boolean().optional(),
17654
+ frameRef: FrameRefSchema.optional(),
17723
17655
  /**
17724
- * This track has a face row IN THE GALLERY: a crop **and** an embedding a
17725
- * face an operator could ASSIGN to an identity.
17726
- *
17727
- * The STRICT twin of {@link hasFace}, and the pair only earns its keep
17728
- * because the two disagree. `hasFace` is stamped at the TOP of the face
17729
- * branch, before every gate, and means no more than "a face detector produced
17730
- * a face detail". This one is stamped at the single moment the gallery row
17731
- * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
17732
- * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
17733
- * candidate gate, the imageless-track drop (no crop was ever captured) and
17734
- * the crop-store drop. Everything between the detector and that insert can
17735
- * legitimately refuse the face, so a flag written any earlier promises the
17736
- * operator something to assign and delivers nothing.
17737
- *
17738
- * **Independent of recognition.** A face collected but never auto-matched is
17739
- * still assignable — it is in fact the face an operator most wants to reach —
17740
- * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
17741
- * `subLabel`; this says only that the raw material exists.
17742
- *
17743
- * **Set once, never cleared.** A track that produced a gallery row produced
17744
- * one; deleting the row later is the gallery's business, not this flag's.
17745
- *
17746
- * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
17747
- * before the column omits it, and so does every server that predates the
17748
- * field. A consumer must test `=== true` and render nothing otherwise —
17749
- * never infer "no assignable face".
17656
+ * CB5 shm passthrough a `FrameHandle` naming the same ring slot
17657
+ * the decoded pixels live in. One more member of the one-of
17658
+ * frame/frameHandle/image/imageBase64/referenceImage group.
17750
17659
  */
17751
- hasEmbeddedFace: boolean().optional(),
17660
+ frameHandle: FrameHandleSchema.optional(),
17661
+ imageBase64: string().optional(),
17752
17662
  /**
17753
- * This subject CONTAINS a folded rider a person the rider-pairing step
17754
- * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
17755
- * so the passage is tracked once and as a VEHICLE.
17756
- *
17757
- * It exists because the fold's record was dishonest. D34 and the code both
17758
- * said "the person is not lost — it is reported so both entities stay on the
17759
- * record"; in fact the pair went into a per-processor RAM field behind an
17760
- * accessor nobody called, and every durable surface said `vehicle`, full
17761
- * stop. This is the composition note that makes the row true.
17762
- *
17763
- * A COMPOSITION, never a class and never a label. "This vehicle contains a
17764
- * person" is not an answer to "what is this" — both label tiers would refuse
17765
- * a macro token anyway (D89), and correctly. Nothing here changes what the
17766
- * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
17767
- * and a `person` rule still does not fire for someone cycling past.
17768
- *
17769
- * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
17770
- * the column, and every hub that predates the field, omits it. Test
17771
- * `=== true` and render nothing otherwise — never infer "no rider".
17663
+ * Binary JPEG bytespreferred over `imageBase64` on internal
17664
+ * hops (hub forked worker via Moleculer MsgPack) because it
17665
+ * skips the 33% base64 overhead + the per-call base64 decode on
17666
+ * the detection-pipeline worker. Callers can pass either; exactly
17667
+ * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
17772
17668
  */
17773
- hasRider: boolean().optional(),
17774
- ...TrackFlagFields,
17775
- ...TrackRetrainFields
17776
- });
17777
- var BaseEventFields = {
17778
- id: string(),
17779
- deviceId: number(),
17780
- timestamp: number()
17781
- };
17782
- var MotionEventSchema = object({
17783
- ...BaseEventFields,
17784
- kind: literal("motion"),
17785
- regionCount: number(),
17786
- /** Heavy JSON array omitted in slim projection. */
17787
- regions: array(object({
17788
- bbox: BoundingBoxSchema,
17789
- pixelCount: number(),
17790
- intensity: number()
17791
- })).readonly().optional(),
17792
- /** Omitted in slim projection. */
17793
- frameWidth: number().optional(),
17794
- /** Omitted in slim projection. */
17795
- frameHeight: number().optional(),
17796
- /** Populated by B5 (recording playback URL for this event). */
17797
- mediaUrl: string().optional()
17798
- });
17669
+ image: _instanceof(Uint8Array).optional(),
17670
+ referenceImage: string().optional(),
17671
+ deviceId: number().optional(),
17672
+ sessionId: string().optional(),
17673
+ /**
17674
+ * Execution plane. 'full' (default) runs the whole tree — benchmark,
17675
+ * reference-image, and detail-subtree calls. 'frame' is the live
17676
+ * per-frame dispatch: ONLY root-plane steps run; crop children
17677
+ * (inputClasses ≠ null) are skipped and served per-track via
17678
+ * pipelineRunner.runDetailSubtree (two-plane design).
17679
+ */
17680
+ plane: _enum(["full", "frame"]).optional(),
17681
+ /**
17682
+ * Inference-device selector (Phase 2 multi-device). Format
17683
+ * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
17684
+ * Omitted ⇒ the runner's default device (current single-engine
17685
+ * behaviour). Selects WHICH device pool of the node runs the call.
17686
+ */
17687
+ deviceKey: string().optional(),
17688
+ /**
17689
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
17690
+ * when the parent crop was resolved from the frame's retained NATIVE
17691
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
17692
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
17693
+ * resolution from that surface — the SAME quality path faces already
17694
+ * had — instead of the downscaled parent tile. `handle` keys the native
17695
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
17696
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
17697
+ * the executor's crop-normalized child ROI back into frame-normalized
17698
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
17699
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
17700
+ * (today's behaviour on the fallback path).
17701
+ */
17702
+ nativeCropRef: NativeCropRefSchema.optional()
17703
+ }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
17704
+ engine: PipelineEngineChoiceSchema.optional(),
17705
+ steps: array(PipelineStepInputSchema).min(1),
17706
+ frames: array(FrameInputSchema).min(1).max(255),
17707
+ deviceId: number().optional(),
17708
+ sessionId: string().optional(),
17709
+ /**
17710
+ * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
17711
+ * the batch to the Python pool's bench preprocess cache
17712
+ * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
17713
+ * preprocessed ONCE and every later inference is a pure-inference cache
17714
+ * hit — the sustained-throughput run measures inference, not
17715
+ * decode+preprocess+infer. Omitted/0 for live frames (all different →
17716
+ * full preprocess every call, correct). Fresh per sustained run;
17717
+ * released via `uncacheFrame`.
17718
+ */
17719
+ frameId: number().int().nonnegative().optional(),
17720
+ /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
17721
+ deviceKey: string().optional()
17722
+ }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
17723
+ data: _instanceof(Uint8Array),
17724
+ width: number().int().positive(),
17725
+ height: number().int().positive(),
17726
+ format: _enum([
17727
+ "rgb",
17728
+ "bgr",
17729
+ "gray"
17730
+ ])
17731
+ }), object({
17732
+ frameId: number(),
17733
+ width: number(),
17734
+ height: number()
17735
+ }), { kind: "mutation" }), method(object({
17736
+ stepId: string(),
17737
+ frameId: number().int()
17738
+ }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
17739
+ batchMode: string(),
17740
+ windowMs: number(),
17741
+ maxBatchSize: number(),
17742
+ concurrency: number()
17743
+ })), method(_void(), array(object({
17744
+ engineKey: string(),
17745
+ engine: PipelineEngineChoiceSchema,
17746
+ modelsLoaded: array(string()).readonly(),
17747
+ inUseByCameras: array(number()).readonly(),
17748
+ /**
17749
+ * Origin of this resident factory.
17750
+ * - `runtime` — main camera-serving engine (no idle TTL).
17751
+ * - `warm-override` — benchmark/test override held in the warm
17752
+ * cache; auto-disposed after the idle TTL.
17753
+ * - `device-pool` — a concurrent per-device pool (Phase 2
17754
+ * multi-device, keyed by `deviceKey`) resolved
17755
+ * via `resolveDeviceFactory`. Runs alongside the
17756
+ * `runtime` engine on a DIFFERENT accelerator
17757
+ * (NPU / iGPU / Coral) — this is how the
17758
+ * Engines tab shows all pools running at once.
17759
+ */
17760
+ kind: _enum([
17761
+ "runtime",
17762
+ "warm-override",
17763
+ "device-pool"
17764
+ ]),
17765
+ /** Native pid of the underlying Python pool (null when no pool). */
17766
+ poolPid: number().nullable(),
17767
+ /** ms since this factory was last used (null when not warm-tracked). */
17768
+ idleMs: number().nullable(),
17769
+ /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
17770
+ idleTtlMs: number().nullable()
17771
+ })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
17772
+ kind: "mutation",
17773
+ auth: "admin"
17774
+ }), method(object({
17775
+ engine: PipelineEngineChoiceSchema,
17776
+ force: boolean().optional()
17777
+ }), object({
17778
+ success: boolean(),
17779
+ reason: string().optional()
17780
+ }), {
17781
+ kind: "mutation",
17782
+ auth: "admin"
17783
+ }), 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({
17784
+ addonId: string(),
17785
+ modelId: string(),
17786
+ filename: string().optional(),
17787
+ settings: record(string(), unknown()).optional()
17788
+ }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
17799
17789
  /**
17800
- * Which detection SOURCE produced an object event. `pipeline` = the ML
17801
- * detection pipeline (decoded-frame inference); `onboard` = the camera's
17802
- * native on-device AI. Both flow through the SAME analysis layers (zoning,
17803
- * tracking, per-kind persistence) but stay distinguishable so consumers
17804
- * (advanced-notifier, occupancy, …) can select which source(s) to act on.
17805
- * Absent on legacy rows treat as `pipeline`.
17790
+ * Per-stage gating mode applied to the zones a rule references.
17791
+ *
17792
+ * - `include`: the rule contributes to a **whitelist** for its stage.
17793
+ * When at least one `include` rule fires for a stage, only entities
17794
+ * inside one of those zones pass that stage.
17795
+ * - `exclude`: the rule contributes to a **blacklist** for its stage.
17796
+ * Entities inside one of those zones are dropped at that stage.
17797
+ *
17798
+ * `monitor`-style observation (count without filtering) is not a rule
17799
+ * mode — zones without any matching rule are observed naturally by
17800
+ * `zone-analytics` (live snapshot + history), so an "I just want to
17801
+ * count, not filter" use case needs no rule at all.
17806
17802
  */
17807
- var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
17803
+ var ZoneRuleModeEnum = _enum(["include", "exclude"]);
17808
17804
  /**
17809
- * The confirmed zone crossing that produced an object event. Present ONLY on
17810
- * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
17811
- * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
17812
- * appearance event carry none, so a rule asking for a direction fails closed
17813
- * on them.
17805
+ * Per-consumer rule that references existing zones (geometry) and
17806
+ * defines how a specific pipeline stage should treat them. Each
17807
+ * consumer addon owns its own `ZoneRule[]` array in its per-device
17808
+ * settings:
17814
17809
  *
17815
- * Exactly ONE crossing per event: the emitter turns each confirmed crossing
17816
- * into its own event, so a frame in which a track enters A while leaving B
17817
- * produces two events with two directions — never one ambiguous row.
17810
+ * - `addon-motion-wasm` `motionZoneRules: ZoneRule[]` (motion stage)
17811
+ * - `addon-detection-pipeline` `detectionZoneRules: ZoneRule[]` (detection stage)
17812
+ * - future: notification rules, audio gating, etc.
17818
17813
  *
17819
- * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
17820
- * membership the box has NOW, and by definition it no longer contains the zone
17821
- * that was just left. Without the id here, a zone-scoped rule could never match
17822
- * the exit it asked for.
17814
+ * One rule applies to N zones (`zoneIds[]`) so the operator can
17815
+ * express "ignore motion in ALL of {garden, street}" with a single
17816
+ * rule. `classFilter` narrows the rule to specific object classes
17817
+ * "drop person detections in the street, but keep cars" is one
17818
+ * `exclude` rule with `classFilter: ['person']`.
17819
+ *
17820
+ * `enabled` is a soft toggle — the operator can keep the rule
17821
+ * configured but inert without deleting it.
17823
17822
  */
17824
- var ZoneCrossingSchema = object({
17825
- direction: _enum(["enter", "exit"]),
17826
- /** Admin zone id crossed. */
17827
- zoneId: string(),
17828
- /** Zone display name at crossing time (falls back to the id). */
17829
- zoneName: string().optional()
17830
- });
17831
- var ObjectEventSchema = object({
17832
- ...BaseEventFields,
17833
- kind: literal("object"),
17834
- /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
17835
- source: DetectionSourceSchema.optional(),
17823
+ var ZoneRuleSchema = object({
17824
+ /** Stable rule id — survives edits, used by the UI for diffing. */
17825
+ id: string(),
17826
+ /** Optional human-readable label rendered in the rule editor. */
17827
+ name: string().optional(),
17828
+ /** Zones this rule targets. The rule's `mode` applies to ALL
17829
+ * listed zones (OR-set: a detection in any one of them counts).
17830
+ * At least one zone id required — a rule with no targets is a
17831
+ * configuration mistake and the form validator rejects it. */
17832
+ zoneIds: array(string()).min(1).readonly(),
17833
+ mode: ZoneRuleModeEnum,
17836
17834
  /**
17837
- * Inference-frame id shared by every object event emitted from the SAME frame
17838
- * the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
17839
- * 2 people + 1 dog) under one full frame, and link a track's frames over time
17840
- * (group by `trackId`, pick a representative `frameId` as the parent frame).
17841
- * Optional for backward-compat with pre-existing rows / the slim projection
17842
- * includes it (it is light). Absent on rows written before this field.
17835
+ * Class names this rule applies to. Empty / undefined rule
17836
+ * applies to every class. Class strings match the `macroClass`
17837
+ * field on detections (e.g. `person`, `car`, `dog`).
17843
17838
  */
17844
- frameId: string().optional(),
17845
- /** Omitted in slim projection. */
17846
- trackId: string().optional(),
17847
- className: string(),
17848
- ...TieredLabelFields,
17849
- /** Omitted in slim projection. */
17850
- confidence: number().optional(),
17851
- /** Heavy JSON — omitted in slim projection. */
17852
- bbox: BoundingBoxSchema.optional(),
17853
- /** Heavy JSON — omitted in slim projection. */
17854
- zones: array(string()).readonly().optional(),
17855
- /** Omitted in slim projection. */
17856
- state: TrackStateSchema.optional(),
17839
+ classFilter: array(string()).readonly().optional(),
17857
17840
  /**
17858
- * The zone crossing this event IS, when it is one. Absent on every other
17859
- * event kind (movement state, appearance, package) see
17860
- * {@link ZoneCrossingSchema}. Omitted in slim projection.
17841
+ * Minimum bbox/mask overlap (0–1) with any of the rule's zones
17842
+ * required to consider an entity "in the zone". Defaults to the
17843
+ * consumer's stage default when omitted. Kept for back-compat with
17844
+ * existing per-rule overrides; new operators pick the value via
17845
+ * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
17846
+ * set, the lower-level engine reads it as a 0–1 fraction.
17861
17847
  */
17862
- zoneCrossing: ZoneCrossingSchema.optional(),
17863
- /** Detection-frame dimensions in pixels — let consumers normalize the
17864
- * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
17865
- frameWidth: number().optional(),
17866
- frameHeight: number().optional(),
17867
- /** MediaStore key for the crop attached to this event (if any). */
17868
- mediaKey: string().optional(),
17869
- /** Design B: MediaStore key of the track's native-resolution key frame (the
17870
- * best-detection full frame). Resolve via the event-media data-plane
17871
- * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
17872
- * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
17873
- * sources — consumers fall back to `mediaKey` (the tight crop). */
17874
- keyFrameMediaKey: string().optional(),
17875
- /** Populated by B5 (recording playback URL for this event). */
17876
- mediaUrl: string().optional(),
17877
- /** The parent track's key-event importance [0,1], propagated to every object
17878
- * event of the track (so an event row can be sorted by importance without a
17879
- * track join). Absent on legacy rows / before the track was scored. */
17880
- importance: number().optional()
17848
+ overlapThreshold: number().min(0).max(1).optional(),
17849
+ /**
17850
+ * Operator-friendly version of `overlapThreshold` the percentage
17851
+ * of the detection's bbox that must lie inside the zone for the
17852
+ * rule to match. Documented default is 85%; the engine substitutes
17853
+ * that when the field is omitted (kept optional so existing rules
17854
+ * stored without it stay valid).
17855
+ *
17856
+ * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
17857
+ * rule, the engine prefers `bboxInclusionPct` because it's the
17858
+ * field exposed in the UI. Internally both feed the same gate.
17859
+ */
17860
+ bboxInclusionPct: number().min(0).max(100).optional(),
17861
+ /**
17862
+ * When `true` and a detection has a segmentation mask, use the
17863
+ * mask for overlap instead of the bbox. Detection-stage only;
17864
+ * motion rules ignore this field.
17865
+ */
17866
+ preferMask: boolean().optional(),
17867
+ /**
17868
+ * Soft-toggle: `false` disables the rule without deleting it.
17869
+ * Defaults to `true` so operators creating a rule via the UI
17870
+ * see it active immediately.
17871
+ */
17872
+ enabled: boolean().default(true)
17881
17873
  });
17882
- var AudioEventSchema = object({
17883
- ...BaseEventFields,
17884
- kind: literal("audio"),
17885
- rms: number(),
17886
- dbfs: number(),
17887
- classification: object({
17888
- className: string(),
17889
- originalClass: string().optional(),
17890
- score: number()
17891
- }).optional(),
17892
- /** Populated by B5 (recording playback URL for this event). */
17893
- mediaUrl: string().optional()
17874
+ array(ZoneRuleSchema).readonly();
17875
+ /**
17876
+ * Zone — pure geometry + identity. NO filtering behaviour.
17877
+ *
17878
+ * Zones describe **where** in the frame the operator wants to flag
17879
+ * something; consumer-owned {@link ZoneRule} arrays describe **how**
17880
+ * each pipeline stage uses them. Splitting the two means a single
17881
+ * polygon "Driveway" can simultaneously back a motion-exclude rule,
17882
+ * a detection-include rule on `['car']`, and an occupancy aggregate
17883
+ * — without three duplicated polygons.
17884
+ *
17885
+ * Owned by the orchestrator addon (provider) and mirrored into the
17886
+ * `zones` device-state slice on every mutation. Consumers
17887
+ * (motion-wasm, pipeline-executor, analytics, admin UI) read either
17888
+ * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
17889
+ * mirror with `onChanged`).
17890
+ *
17891
+ * Coordinates are normalised fractions of the frame (0–1) so zones
17892
+ * survive resolution changes and stream profile switches.
17893
+ *
17894
+ * `kind` discriminates between full polygons (closed regions used
17895
+ * for intrusion / occupancy filters) and tripwires (open 2-point
17896
+ * line segments used for cross events). Onboard / firmware-reported
17897
+ * zones (Reolink, ONVIF) are out of scope for now — see the deferred
17898
+ * task list.
17899
+ */
17900
+ var ZoneKindEnum = _enum(["polygon", "tripwire"]);
17901
+ /** Polygon vertex in fraction-of-frame coordinates (0–1). */
17902
+ var PolygonPointSchema = object({
17903
+ x: number(),
17904
+ y: number()
17894
17905
  });
17895
- var MediaFileKindEnum = _enum([
17896
- "crop",
17897
- "thumbnail",
17898
- "snapshot",
17899
- "firstFrame",
17900
- "lastFrame",
17901
- "fullFrame",
17902
- "fullFrameBoxed",
17903
- "faceCrop",
17904
- "plateCrop",
17905
- "keyFrame",
17906
- "keyFrameSmall",
17907
- "thumbnailSmall"
17908
- ]);
17909
- var MediaFileSchema = object({
17910
- key: string(),
17911
- kind: MediaFileKindEnum,
17912
- base64: string(),
17913
- sizeBytes: number(),
17914
- timestamp: number()
17906
+ /** A camera detection zone — pure geometry/identity. */
17907
+ var ZoneSchema = object({
17908
+ id: string(),
17909
+ name: string(),
17910
+ kind: ZoneKindEnum.default("polygon"),
17911
+ /** Polygon vertices, fraction of frame (0–1). */
17912
+ polygon: array(PolygonPointSchema).readonly(),
17913
+ /** Visual color for UI rendering. */
17914
+ color: string().default("#3b82f6")
17915
17915
  });
17916
17916
  /**
17917
- * One media row WITHOUT its bytes.
17917
+ * Zones capability per-camera CRUD over polygon detection zones.
17918
17918
  *
17919
- * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
17920
- * 140 s track), and a client that renders tiles from the media data plane needs
17921
- * to know only WHAT EXISTS the bytes then arrive per tile, lazily, over HTTP
17922
- * with an immutable cache, instead of all at once inside a tRPC response that
17923
- * blocks the whole view.
17919
+ * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
17920
+ * to per-device settings and mirrors into the `zones` device-state
17921
+ * slice on every mutation, so downstream consumers can subscribe via
17922
+ * `dev.state.zones.onChanged`.
17924
17923
  *
17925
- * `sizeBytes` is carried because it is what lets a client decide between the
17926
- * stored blob and a `?variant=thumb` rendering without fetching either.
17924
+ * The cap surface only handles geometry + identity; filtering
17925
+ * behaviour (per-class, include/exclude, threshold) lives in the
17926
+ * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
17927
+ * `capabilities/schemas/zone-rule.js`.
17927
17928
  */
17928
- var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
17929
+ var zonesCapability = {
17930
+ name: "zones",
17931
+ scope: "device",
17932
+ mode: "singleton",
17933
+ deviceTypes: [DeviceType.Camera],
17934
+ methods: {
17935
+ listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
17936
+ addZone: method(object({
17937
+ deviceId: number(),
17938
+ zone: ZoneSchema
17939
+ }), _void(), {
17940
+ kind: "mutation",
17941
+ auth: "admin"
17942
+ }),
17943
+ removeZone: method(object({
17944
+ deviceId: number(),
17945
+ zoneId: string()
17946
+ }), _void(), {
17947
+ kind: "mutation",
17948
+ auth: "admin"
17949
+ }),
17950
+ updateZone: method(object({
17951
+ deviceId: number(),
17952
+ zone: ZoneSchema
17953
+ }), _void(), {
17954
+ kind: "mutation",
17955
+ auth: "admin"
17956
+ })
17957
+ },
17958
+ /**
17959
+ * Runtime-state slice — the live zone catalogue mirrored by the
17960
+ * orchestrator on every CRUD mutation. Consumers read via
17961
+ * `device.state.zones.value` / `.watch(...)` without round-tripping
17962
+ * the cap, and the codegen DeviceProxy auto-wires the reactive
17963
+ * handle. Slice shape is `{ zones: Zone[] }` so future extensions
17964
+ * (e.g. zone groupings) can sit alongside the polygon list.
17965
+ */
17966
+ runtimeState: object({ zones: array(ZoneSchema).readonly() }),
17967
+ /**
17968
+ * 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.
17969
+ *
17970
+ * See `RuntimeStateDurability`. Enforced by
17971
+ * `scripts/check-runtime-state-durability.ts`.
17972
+ */
17973
+ durability: "restored"
17974
+ };
17929
17975
  /**
17930
- * The MACRO tier of an annotation — a CLOSED set.
17976
+ * pipeline-analytics device-scoped wrapper cap. Refines raw
17977
+ * per-frame detections emitted by the pipeline runner into tracked
17978
+ * objects, per-kind event collections (motion / object / audio), and
17979
+ * persisted media. Owns the post-detection domain end-to-end:
17931
17980
  *
17932
- * This is what the exported detector predicts, so a typo here is a new class
17933
- * with one example in it. `label` and `subLabel` are open strings by contrast:
17934
- * the whole point of the page is teaching the model things it does not know
17935
- * yet, and constraining that vocabulary would make it useless.
17981
+ * runner emits PipelineInferenceResult
17982
+ * (event bus)
17983
+ * pipeline-analytics subscriber
17984
+ * SORT tracker + zone engine + state analyzer + event emitter
17985
+ * → three DB collections (one per kind), one FS media tree, one
17986
+ * unified event emitter (FrameTracked + TrackStarted/Ended +
17987
+ * DetectionEvent on bus)
17936
17988
  *
17937
- * A macro class is NEVER a label. The provider refuses a write whose `label` or
17938
- * `subLabel` is one of these values, in any casing, because once `person`
17939
- * exists in both tiers "every person box" stops being answerable without
17940
- * knowing every string anyone ever typed — and the damage is retroactive.
17989
+ * Pure subscriber model. No `processFrame` cap method the runner
17990
+ * already publishes the raw frame on the bus. The cap surface is
17991
+ * only QUERIES + per-device settings, bound on/off via
17992
+ * `device-manager.setWrapperActive`. `defaultActive: true` because
17993
+ * every camera with a detection pipeline wants its raw detections
17994
+ * refined; operators opt out per-device via BindingsTab when needed.
17995
+ *
17996
+ * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
17997
+ * (per-device surface) and `track-trail` caps — see P11 cleanup.
17941
17998
  */
17942
- var RetrainMacroClassSchema = _enum([
17999
+ var TrackStateSchema = _enum([
18000
+ "new",
18001
+ "entered",
18002
+ "left",
18003
+ "moving",
18004
+ "idle"
18005
+ ]);
18006
+ var EventKindSchema = _enum([
18007
+ "motion",
18008
+ "object",
18009
+ "audio"
18010
+ ]);
18011
+ /**
18012
+ * Spatial filter for `listTracks` — the rect + polygon variants of the shared
18013
+ * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
18014
+ * of the camera frame (top-left origin), matching the drawing-plane editor.
18015
+ */
18016
+ var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
18017
+ /** Closed icon vocabulary so clients render a known glyph per kind. */
18018
+ var EventKindIconSchema = _enum([
18019
+ "motion",
18020
+ "audio",
17943
18021
  "person",
17944
18022
  "vehicle",
17945
18023
  "animal",
18024
+ "door",
18025
+ "pir",
18026
+ "smoke",
18027
+ "water",
18028
+ "button",
17946
18029
  "package",
17947
- "face",
17948
- "plate"
18030
+ "generic"
17949
18031
  ]);
17950
- /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
17951
- var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
17952
- /** Did a human draw this box, or did the assist propose it? */
17953
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
17954
- /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
17955
- var RetrainBboxSchema = object({
17956
- x: number(),
17957
- y: number(),
17958
- w: number(),
17959
- h: number()
18032
+ var EventKindCategorySchema = _enum([
18033
+ "motion",
18034
+ "audio",
18035
+ "detection",
18036
+ "sensor",
18037
+ "control",
18038
+ "custom",
18039
+ "package"
18040
+ ]);
18041
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
18042
+ var EventKindLevelSchema = _enum(["macro", "sub"]);
18043
+ var EventKindDescriptorSchema = object({
18044
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
18045
+ kind: string(),
18046
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
18047
+ labelKey: string(),
18048
+ /** English fallback label (kept for clients that don't translate). */
18049
+ label: string(),
18050
+ /** Hex color for timeline/legend rendering. */
18051
+ color: string(),
18052
+ /** Dictionary id → lucide component on the UI side. */
18053
+ iconId: string(),
18054
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
18055
+ icon: EventKindIconSchema,
18056
+ category: EventKindCategorySchema,
18057
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
18058
+ parentKind: string().nullable(),
18059
+ /** Derived from `parentKind`, explicit for the client tree. */
18060
+ level: EventKindLevelSchema,
18061
+ /** Which cap + device contributes this kind. For built-ins the camera
18062
+ * itself; for sensor kinds the LINKED source device. */
18063
+ source: object({
18064
+ capName: string(),
18065
+ deviceId: number()
18066
+ })
17960
18067
  });
17961
- /**
17962
- * One annotated subject.
17963
- *
17964
- * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
17965
- * (letterboxed root / zone-cropped package / subject-cropped classifier) are
17966
- * derived from it at export and never stored — storing them is how one feature
17967
- * space ends up holding two crops of the same subject (D52).
17968
- */
17969
- var RetrainAnnotationSchema = object({
17970
- id: string(),
17971
- trackId: string(),
18068
+ /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
18069
+ var EventKindsForDeviceSchema = object({
17972
18070
  deviceId: number(),
17973
- /** The COPY in retrain storage — never the source track's media key. */
17974
- mediaKey: string(),
17975
- bbox: RetrainBboxSchema,
17976
- macroClass: RetrainMacroClassSchema,
17977
- label: string().optional(),
17978
- subLabel: string().optional(),
17979
- kind: RetrainAnnotationKindSchema,
17980
- source: RetrainAnnotationSourceSchema,
17981
- /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
17982
- assistModelId: string().optional(),
17983
- assistScore: number().optional(),
17984
- exportedInBatch: string().optional(),
17985
- createdAt: number()
17986
- });
17987
- /** The write form — the server owns `id`, `createdAt` and the frame binding. */
17988
- var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
17989
- id: true,
17990
- trackId: true,
17991
- deviceId: true,
17992
- mediaKey: true,
17993
- createdAt: true,
17994
- exportedInBatch: true
18071
+ kinds: array(EventKindDescriptorSchema).readonly()
17995
18072
  });
17996
- /** A track sitting in `staging`, with everything the worklist needs to rank it. */
17997
- var RetrainTrackSchema = object({
17998
- trackId: string(),
18073
+ var SensorEventSchema = object({
18074
+ id: string(),
18075
+ /** The CAMERA the event is attributed to (a sensor linked to N cameras
18076
+ * yields N rows, one per camera). */
17999
18077
  deviceId: number(),
18000
- className: string(),
18001
- label: string().optional(),
18002
- firstSeen: number(),
18003
- lastSeen: number(),
18004
- /** How many frames the dataset already holds from this track. */
18005
- frameCount: number().int(),
18006
- /** How many subjects have been annotated on those frames. `0` with
18007
- * `frameCount: 0` is exactly "staging, still to work". */
18008
- annotationCount: number().int()
18078
+ /** The linked sensor device whose state changed. */
18079
+ sourceDeviceId: number(),
18080
+ /** Event kind id — matches an `EventKindDescriptor.kind`. */
18081
+ kind: string(),
18082
+ /** Snapshot of the sensor cap's runtime-state slice at the change. */
18083
+ value: record(string(), unknown()).nullable(),
18084
+ timestamp: number()
18009
18085
  });
18010
- /** A frame the picker may offer — an index row, no blob was read to produce it. */
18011
- var RetrainFrameCandidateSchema = object({
18012
- mediaKey: string(),
18013
- kind: MediaFileKindEnum,
18086
+ var TrackPositionSchema = object({
18087
+ x: number(),
18088
+ y: number(),
18014
18089
  timestamp: number(),
18015
- sizeBytes: number().int(),
18016
- /** A copy of this original already exists — selecting it is free and cannot
18017
- * fail, whatever became of the original. */
18018
- copied: boolean()
18019
- });
18020
- /** A frame the dataset OWNS: bytes copied at selection time. */
18021
- var RetrainFrameSchema = object({
18022
- frameId: string(),
18023
- deviceId: number(),
18024
- trackId: string(),
18025
- /** Provenance only. It may already point at nothing — that is expected. */
18026
- sourceMediaKey: string(),
18027
- sourceKind: MediaFileKindEnum,
18028
- sizeBytes: number().int(),
18029
- width: number().int(),
18030
- height: number().int(),
18031
- copiedAt: number()
18032
- });
18033
- /** Why a copy-on-select could not be honoured — named, never a silent skip. */
18034
- var RetrainCopyRefusalSchema = _enum([
18035
- "source-missing",
18036
- "unreadable-image",
18037
- "write-failed"
18038
- ]);
18039
- var RetrainFrameSelectionSchema = object({
18040
- copied: array(RetrainFrameSchema).readonly(),
18041
- refused: array(object({
18042
- sourceMediaKey: string(),
18043
- reason: RetrainCopyRefusalSchema
18044
- })).readonly()
18090
+ bbox: BoundingBoxSchema
18045
18091
  });
18046
- var RetrainFrameListSchema = object({
18047
- candidates: array(RetrainFrameCandidateSchema).readonly(),
18048
- copies: array(RetrainFrameSchema).readonly(),
18049
- /** What the page pre-selects the native key frame when one survives. */
18050
- autoPickMediaKey: string().optional()
18092
+ var TrackSnapshotSchema = object({
18093
+ timestamp: number(),
18094
+ position: TrackPositionSchema,
18095
+ /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
18096
+ mediaKey: string()
18051
18097
  });
18052
- /** What the operator asked the assist to look for. */
18053
- var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
18054
- kind: literal("package"),
18055
- zone: RetrainBboxSchema.optional()
18056
- }), object({
18057
- kind: literal("objects"),
18058
- modelId: string(),
18059
- minScore: number().optional()
18060
- })]);
18061
18098
  /**
18062
- * The assist's answer a discriminated union, because "the model saw nothing"
18063
- * and "this node cannot run that model" lead to different next moves and a
18064
- * nullable result cannot tell them apart.
18099
+ * Normalized 0..1 trajectory envelope (min/max over every position bbox,
18100
+ * divided by the track's detection-frame dims), computed at persist time.
18101
+ * Absent when the frame dims were unknown when the track was persisted
18102
+ * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
18065
18103
  */
18066
- var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
18067
- kind: literal("proposed"),
18068
- modelId: string(),
18069
- stepId: string(),
18070
- minScore: number(),
18071
- /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
18072
- proposals: array(RetrainAnnotationDraftSchema).readonly(),
18073
- /** Returned by the runner but removed by the threshold. */
18074
- belowThreshold: number().int()
18075
- }), object({
18076
- kind: literal("refused"),
18077
- /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
18078
- reason: string(),
18079
- detail: string().optional()
18080
- })]);
18081
- /** The outcome of a lifecycle move owned by the retrain page. */
18082
- var RetrainTransitionResultSchema = object({
18083
- trackId: string(),
18084
- /** Where the track ended up, whatever happened. */
18085
- retrainStatus: RetrainStatusSchema,
18086
- /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
18087
- changed: boolean(),
18088
- reason: _enum([
18089
- "unknown-track",
18090
- "no-frames-copied",
18091
- "not-staging",
18092
- "not-trained",
18093
- "unchanged"
18094
- ]).optional()
18104
+ var TrackEnvelopeSchema = object({
18105
+ minX: number(),
18106
+ minY: number(),
18107
+ maxX: number(),
18108
+ maxY: number()
18095
18109
  });
18096
- var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
18097
- var MAX_EVENT_QUERY_LIMIT = 5e3;
18098
- var DeviceEventQueryInput = object({
18099
- deviceId: number(),
18100
- since: number().optional(),
18101
- until: number().optional(),
18102
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
18103
- /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
18104
- * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
18105
- * exact behaviour. Callers may omit this field — the store defaults to
18106
- * `full` when not provided. */
18107
- projection: _enum(["full", "slim"]).optional()
18108
- });
18109
- var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
18110
- var RecentTracksQueryInput = object({
18111
- /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
18112
- deviceIds: array(number()),
18113
- /** Window lower bound on `lastSeen` (inclusive). */
18114
- since: number().optional(),
18115
- /** Window upper bound on `lastSeen` (inclusive). */
18116
- until: number().optional(),
18117
- /** Page size. Default 200, max 1000. */
18118
- limit: number().int().min(1).max(1e3).default(200),
18119
- /** Opaque continuation cursor from a previous page's `nextCursor`.
18120
- * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
18121
- cursor: string().optional(),
18122
- /** See {@link TrackProjectionSchema}. Default `full`. */
18123
- projection: TrackProjectionSchema.optional(),
18124
- /** Include stationary-promoted rows (parked objects). Default false: the
18125
- * feed lists passages; parking records live on the stationary registry. */
18126
- includeStationary: boolean().optional()
18127
- });
18128
- var RecentTracksPageSchema = object({
18129
- /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
18130
- tracks: array(TrackSchema).readonly(),
18131
- /** Cursor for the next page, or null when this page is the last. */
18132
- nextCursor: string().nullable()
18133
- });
18134
- var LIST_GROUPS_DEFAULT_LIMIT = 40;
18135
- var LIST_GROUPS_MAX_LIMIT = 100;
18136
- var AnalyticsGroupRecordSchema = object({
18137
- id: string(),
18138
- deviceId: number().int(),
18139
- openedAt: number().int(),
18140
- closedAt: number().int(),
18141
- timestamp: number().int(),
18142
- memberCount: number().int(),
18143
- memberTrackIds: array(string()).readonly(),
18144
- className: string(),
18145
- classes: array(string()).readonly(),
18146
- /** Relative event-media path, or null when the group has no picture yet. */
18147
- mediaUrl: string().nullable(),
18148
- singleton: boolean()
18149
- });
18150
- var AnalyticsGroupMemberSchema = object({
18151
- trackId: string(),
18152
- deviceId: number().int(),
18153
- className: string(),
18154
- firstSeen: number().int(),
18155
- lastSeen: number().int(),
18156
- mediaUrl: string().nullable()
18157
- });
18158
- var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
18159
- var ListGroupsQueryInput = object({
18160
- /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
18161
- deviceIds: array(number()),
18162
- /** Window lower bound on `closedAt` (inclusive). */
18163
- since: number().optional(),
18164
- /** Window upper bound on `openedAt` (inclusive). */
18165
- until: number().optional(),
18166
- limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
18167
- /** Opaque continuation cursor from a previous page's `nextCursor`. */
18168
- cursor: string().optional()
18169
- });
18170
- var ListGroupsPageSchema = object({
18171
- groups: array(AnalyticsGroupRecordSchema).readonly(),
18172
- nextCursor: string().nullable()
18173
- });
18174
- var KeyEventQueryInput = object({
18175
- deviceId: number(),
18176
- /** Window lower bound (track firstSeen ≥ since). */
18177
- since: number(),
18178
- /** Window upper bound (track firstSeen ≤ until). */
18179
- until: number(),
18180
- limit: number().int().min(1).max(200).default(50),
18181
- /** Drop tracks scoring below this importance. */
18182
- minImportance: number().min(0).max(1).optional(),
18183
- /** Restrict to a single class (e.g. 'person'). */
18184
- classFilter: string().optional()
18185
- });
18186
- var KeyEventSchema = object({
18187
- /** The representative event id (the track's best ObjectEvent, else its trackId). */
18188
- id: string(),
18189
- trackId: string(),
18190
- /** Track start time (firstSeen). */
18191
- timestamp: number(),
18192
- className: string(),
18193
- ...TieredLabelFields,
18194
- importance: number(),
18195
- /** Highest-confidence ObjectEvent id for the track (empty when none). */
18196
- bestEventId: string(),
18197
- /** Track lifetime in ms (lastSeen - firstSeen). */
18198
- windowMs: number().optional(),
18199
- ...TrackFlagFields,
18200
- ...TrackRetrainFields
18201
- });
18202
- object({
18203
- trackId: string(),
18204
- className: string(),
18205
- confidence: number(),
18206
- bbox: BoundingBoxSchema,
18207
- zones: array(string()).readonly(),
18208
- state: TrackStateSchema
18209
- });
18210
- var OverlayDetectionSchema = looseObject({
18211
- id: string(),
18212
- kind: _enum(["first-level", "detail"]),
18213
- macroClass: string(),
18214
- score: number(),
18215
- bbox: object({
18216
- x: number(),
18217
- y: number(),
18218
- width: number(),
18219
- height: number()
18220
- }),
18221
- labels: array(looseObject({
18222
- label: string(),
18223
- score: number()
18224
- })).readonly(),
18225
- parentId: string().optional()
18226
- });
18227
- var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
18228
- var SearchObjectEventsInput = object({
18229
- text: string(),
18230
- deviceId: number().optional(),
18231
- since: number().optional(),
18232
- until: number().optional(),
18233
- classFilter: string().optional(),
18234
- limit: number().default(50),
18235
- minScore: number().min(0).max(1).default(.2)
18236
- });
18237
- var TrackCascadeCountsSchema = object({
18238
- /** Persisted track roots deleted (authoritative). */
18239
- tracks: number().int(),
18240
- /** Object events removed with their tracks (best-effort; see note above). */
18241
- events: number().int(),
18242
- /** Track/face/plate-owned media removed (best-effort). Never identity media. */
18243
- media: number().int(),
18244
- /** Unassigned (non-enrolled) face reads removed (best-effort). */
18245
- faces: number().int(),
18246
- /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
18247
- plates: number().int(),
18248
- /** Per-track CLIP search vectors removed (best-effort). */
18249
- embeddings: number().int(),
18250
- /** Group membership + group rows removed with their last member (best-effort). */
18251
- groups: number().int()
18252
- });
18253
- /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
18254
- var DiskReconcileCountsSchema = object({
18255
- mediaDropped: number().int(),
18256
- tracks: number().int(),
18257
- events: number().int()
18258
- });
18259
- /** Event-store footprint for one camera. */
18260
- var EventStoreDeviceFootprintSchema = object({
18261
- deviceId: number(),
18262
- /** Persisted event rows (motion + object + audio) for the camera. */
18263
- rows: number().int(),
18264
- /** Event-owned media bytes on disk for the camera. */
18265
- bytes: number().int()
18266
- });
18267
- /** Aggregate event-store footprint: global totals + per-camera breakdown. */
18268
- var EventStoreFootprintSchema = object({
18269
- totalRows: number().int(),
18270
- totalBytes: number().int(),
18271
- devices: array(EventStoreDeviceFootprintSchema).readonly()
18272
- });
18273
- /** Per-kind counts returned by the event-prune / device-delete mutations. */
18274
- var EventPruneCountsSchema = object({
18275
- motion: number().int(),
18276
- object: number().int(),
18277
- audio: number().int()
18110
+ /**
18111
+ * Row projection for track list queries. `full` (default) returns the
18112
+ * complete Track including the frame-rate `positions[]` history and the
18113
+ * `snapshots[]` references — megabytes across a page of tracks. `slim`
18114
+ * keeps every scalar the list surfaces actually render (ids, class(es),
18115
+ * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
18116
+ * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
18117
+ * `snapshots` as EMPTY arrays detail views re-fetch the full row via
18118
+ * `getTrack`. Mirrors the event-store `projection` convention
18119
+ * (`getObjectEvents` et al.).
18120
+ */
18121
+ var TrackProjectionSchema = _enum(["full", "slim"]);
18122
+ /**
18123
+ * One audio-classification label heard on the track's camera while the
18124
+ * track was alive, aggregated per label. An "episode" is one persisted
18125
+ * audio event (the confident-classification path: score the device's
18126
+ * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
18127
+ * one 32 ms inference chunk, so counts stay human-scaled.
18128
+ */
18129
+ var TrackAudioLabelSchema = object({
18130
+ label: string(),
18131
+ /** Highest classification score observed across the label's episodes. */
18132
+ peakScore: number(),
18133
+ /** Number of coalesced audio-event episodes carrying this label. */
18134
+ count: number(),
18135
+ firstAt: number(),
18136
+ lastAt: number()
18278
18137
  });
18279
18138
  /**
18280
- * Re-embed stored tracks from their key frames.
18139
+ * How a track was produced. `pipeline` (default / absent) = the spatial
18140
+ * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
18141
+ * no positions, a single snapshot, and no bbox trajectory at all:
18281
18142
  *
18282
- * The reason this is an operator-callable method and not a migration script:
18283
- * every knob that decides what a vector MEANS encoder model, crop margin,
18284
- * squaring is only changeable if the existing vectors can be regenerated.
18285
- * Mixing feature spaces in one index makes cosine scores incomparable, and the
18286
- * symptom is a quality regression with no visible cause.
18143
+ * - `sensor` a linked sensor/control device state change.
18144
+ * - `audio` an audio event on the camera itself that was anomalous for
18145
+ * THAT camera, loud, and heard while nothing visual was happening (D62).
18146
+ *
18147
+ * The spatial subsystems (tracker association, occupancy count, re-id /
18148
+ * embedding, resurrection) MUST skip every synthetic source. Test for that
18149
+ * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
18150
+ * check silently readmits every source added after it was written.
18287
18151
  */
18288
- var RebuildObjectEmbeddingsInput = object({
18289
- /** Restrict to one camera. Omit for the whole fleet. */
18290
- deviceId: number().optional(),
18291
- since: number().optional(),
18292
- until: number().optional(),
18293
- /** Stop after this many tracks; the result reports whether more remain. */
18294
- maxTracks: number().int().positive().optional(),
18295
- /**
18296
- * Run every embedding on THIS node instead of round-robining the fleet.
18297
- *
18298
- * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
18299
- * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
18300
- * calling it that would pin the rebuild REQUEST itself to that node — the
18301
- * rebuild orchestration lives on the hub, and only the per-track step runs
18302
- * remotely. This field is data; the per-track pin is applied inside.
18303
- *
18304
- * Absent ⇒ round-robin over every online node whose runner can serve the
18305
- * pinned model.
18306
- */
18307
- executeOnNodeId: string().optional(),
18308
- /**
18309
- * Milliseconds to wait between tracks; omit for the built-in default, `0` to
18310
- * run flat out.
18311
- *
18312
- * A rebuild is bulk maintenance on hub-main's single thread. Measured
18313
- * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
18314
- * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
18315
- * force is logged at start and finish so a deliberately slow pass reads
18316
- * differently from a stalled one.
18317
- */
18318
- pacingMs: number().int().nonnegative().optional()
18319
- });
18152
+ var TrackSourceSchema = _enum([
18153
+ "pipeline",
18154
+ "sensor",
18155
+ "audio"
18156
+ ]);
18320
18157
  /**
18321
- * Result of emptying the CLIP index.
18158
+ * Where a track sits in the RETRAIN lifecycle (D81).
18322
18159
  *
18323
- * The clean slate before a policy change: a new crop margin or encoder model
18324
- * leaves two feature spaces in one index whose cosine scores are not
18325
- * comparable, so wiping and rebuilding is the only way to be sure every vector
18326
- * means the same thing.
18160
+ * - `none` never marked, or un-marked. Evictable.
18161
+ * - `staging` the operator wants this track as training material and has not
18162
+ * finished with it. **This is the only state retention holds**: the track and
18163
+ * everything it owns (object events, crops, keyframes, CLIP vector) survive
18164
+ * the device's age window.
18165
+ * - `trained` — the retrain page has taken what it needed. The frames it chose
18166
+ * were COPIED into the retrain dataset at selection time, so the dataset no
18167
+ * longer depends on the track's media and the track becomes EVICTABLE again.
18168
+ * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
18169
+ * a deliberate action of the retrain page, not a side effect of a checkbox.
18170
+ *
18171
+ * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
18172
+ * the store's filter language has only positive equality and `whereIn` — no
18173
+ * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
18174
+ * would make the entire pre-column history immortal in one deploy.
18327
18175
  */
18328
- var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
18176
+ var RetrainStatusSchema = _enum([
18177
+ "none",
18178
+ "staging",
18179
+ "trained"
18180
+ ]);
18329
18181
  /**
18330
- * Acknowledgement that a rebuild STARTED.
18182
+ * Per-track OPERATOR flags set by hand from the admin UI or the viewer, never
18183
+ * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
18184
+ * so the two surfaces cannot drift.
18331
18185
  *
18332
- * The pass costs ~1s per track 45 minutes for a 2,600-track fleet so it
18333
- * runs detached and this returns immediately. Waiting for it made the client
18334
- * time out while the work carried on server-side, which is the worst of both:
18335
- * no result and no way to know it was still going. Poll
18336
- * `getObjectEmbeddingRebuildStatus` for progress.
18337
- */
18338
- var RebuildObjectEmbeddingsResultSchema = object({
18339
- started: boolean(),
18340
- /** True when a pass was already running; the new request is ignored. */
18341
- alreadyRunning: boolean()
18342
- });
18343
- var RebuildStatusSchema = object({
18344
- running: boolean(),
18345
- scanned: number(),
18346
- rebuilt: number(),
18347
- /** Tracks whose key frame is gone nothing to re-embed from. */
18348
- missingKeyFrame: number(),
18349
- /** Tracks with no usable detection box. */
18350
- missingBbox: number(),
18351
- /**
18352
- * Tracks an executing node REFUSED rather than broke on — an unreadable key
18353
- * frame, a step that threw. Separate from `failed` because the remedy is
18354
- * different, and because a whole camera silently contributing zero vectors
18355
- * is the shape of failure a rebuild must never hide.
18356
- */
18357
- notRunnable: number(),
18186
+ * **Absent false.** A track that has never been touched omits the field; an
18187
+ * explicitly un-flagged track carries `false`. Legacy rows written before the
18188
+ * columns existed read as absent, and a consumer that needs a boolean should say
18189
+ * `flag === true`, not `flag !== false`.
18190
+ *
18191
+ * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
18192
+ * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
18193
+ * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
18194
+ * `trained` track reports `false` while refusing both writes. The boolean is
18195
+ * kept because three surfaces drive a toggle off it; anything that needs to tell
18196
+ * "never marked" from "already trained" must read `retrainStatus`.
18197
+ *
18198
+ * `debug` does NOT pin; it is attention, not durability.
18199
+ *
18200
+ * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
18201
+ * A favourited track is skipped by retention the same way `staging` is, but
18202
+ * it does not enter `none|staging|trained` and has no staging budget.
18203
+ */
18204
+ var TrackFlagFields = {
18205
+ /** Operator marked this track as training material — i.e. `retrainStatus` is
18206
+ * `'staging'`. */
18207
+ markForTrain: boolean().optional(),
18208
+ /** Operator marked this track for diagnostic attention. */
18209
+ debug: boolean().optional(),
18210
+ /** Operator favourited this track. Pins it against pruning. */
18211
+ favourited: boolean().optional()
18212
+ };
18213
+ /**
18214
+ * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
18215
+ * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
18216
+ * write patch, and the status is not something the toggle sets — it is what the
18217
+ * toggle's boolean is derived from. Absent on an in-RAM track never touched;
18218
+ * always present on a persisted row (the column default materialises `'none'`).
18219
+ */
18220
+ var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
18221
+ /**
18222
+ * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
18223
+ * one flag can never clear the other — the toggles are independent and are
18224
+ * driven from three surfaces that do not know about each other.
18225
+ */
18226
+ var TrackFlagsPatchSchema = object(TrackFlagFields);
18227
+ /**
18228
+ * The resolved flag state after a write. Both fields are REQUIRED here (absent
18229
+ * collapses to `false`) so a caller can drive a toggle's checked state off the
18230
+ * mutation result without a re-fetch.
18231
+ */
18232
+ var TrackFlagsSchema = object({
18233
+ trackId: string(),
18234
+ markForTrain: boolean(),
18235
+ debug: boolean(),
18236
+ favourited: boolean(),
18237
+ /** The lifecycle state the boolean was derived from. Required here (unlike on
18238
+ * a track row) because this shape is only ever produced by the write body,
18239
+ * which always knows it — and a surface that has just written needs to render
18240
+ * `trained` without a re-fetch. */
18241
+ retrainStatus: RetrainStatusSchema
18242
+ });
18243
+ union([literal(1), literal(2)]);
18244
+ /**
18245
+ * WHO decided a label, and when. Carried per tier so a value can be traced to
18246
+ * the step and model that produced it — which is what makes the write rule
18247
+ * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
18248
+ * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
18249
+ *
18250
+ * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
18251
+ * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
18252
+ * `migration:4g` for a value the 4g migration moved from the single-slot era —
18253
+ * that value has no provenance, and the write rule lets ANY properly-attributed
18254
+ * write of the same tier replace it regardless of score.
18255
+ */
18256
+ var LabelAttributionSchema = object({
18257
+ stepId: string(),
18258
+ modelId: string().optional(),
18259
+ decidedAt: number(),
18358
18260
  /**
18359
- * The pass stopped because NO node could serve the pinned model.
18261
+ * The GALLERY id behind a recognised tier-2 label a face-gallery
18262
+ * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
18360
18263
  *
18361
- * Distinct from `notRunnable` on purpose: that one says "this track was
18362
- * refused", this one says "the cluster cannot do this work at all" — every
18363
- * candidate node either lacks the `clip-embedding` step, lacks a build of the
18364
- * pinned model for its engine format, or dropped out. The remedy is a model /
18365
- * engine change, not a per-camera one. Non-zero here always comes with
18366
- * `complete: false`.
18264
+ * The text alone is a DISPLAY NAME, and a display name is renameable: a
18265
+ * notification rule authored on "Gianluca" stopped matching the moment the
18266
+ * operator fixed the spelling in the gallery, and nothing said so. The id is
18267
+ * the thing that does not move, so it is what a rule matches on
18268
+ * (`NcConditions.identities`) and the text is what a human is shown.
18269
+ *
18270
+ * Absent when the label names no gallery row — a plate the OCR read but no
18271
+ * vehicle claims, a sub-class, a species, any tier-1 value.
18367
18272
  */
18368
- noCapableNode: number(),
18369
- failed: number(),
18370
- /** Set once a pass ends: true only when EVERYTHING was covered. */
18371
- complete: boolean().nullable(),
18372
- startedAtMs: number().nullable(),
18373
- finishedAtMs: number().nullable(),
18374
- /** Present when the pass ended by throwing. */
18375
- error: string().nullable()
18273
+ identityId: string().optional()
18376
18274
  });
18377
- DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
18378
- deviceId: number(),
18379
- trackId: string()
18380
- }), TrackSchema.nullable()), method(object({
18381
- deviceId: number(),
18382
- since: number().optional(),
18383
- until: number().optional(),
18384
- limit: number().optional(),
18385
- /** Spatial filter — only tracks whose trajectory intersects the zone
18386
- * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
18387
- * envelope columns, then precisely tested per position. Tracks with
18388
- * an unknown envelope (no frame dims at persist time) always match. */
18389
- zone: TrackZoneFilterSchema.optional(),
18390
- /** See {@link TrackProjectionSchema}. Default `full` (backward
18391
- * compatible omitting the field keeps today's exact behaviour). */
18392
- projection: TrackProjectionSchema.optional(),
18393
- /** Include stationary-promoted rows (parked objects handed to the
18394
- * stationary registry). Default false: the timeline lists passages,
18395
- * not parking records (operator decision, 2026-08-15). */
18396
- includeStationary: boolean().optional()
18397
- }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
18398
- deviceId: number(),
18399
- groupId: string().min(1)
18400
- }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
18401
- kind: "mutation",
18402
- auth: "admin"
18403
- }), 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({
18404
- deviceId: number(),
18405
- since: number().optional(),
18406
- until: number().optional(),
18407
- kinds: array(string()).optional(),
18408
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
18409
- }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
18410
- deviceId: number(),
18411
- since: number(),
18412
- until: number(),
18413
- bucketMs: number().int().positive()
18414
- }), array(object({
18415
- bucketStart: number(),
18416
- motion: number().int(),
18417
- object: number().int(),
18418
- audio: number().int()
18419
- })).readonly()), method(object({
18420
- deviceId: number(),
18421
- cutoffMs: number()
18422
- }), object({
18423
- motion: number().int(),
18424
- object: number().int(),
18425
- audio: number().int()
18426
- }), {
18427
- kind: "mutation",
18428
- auth: "admin"
18429
- }), method(object({
18430
- deviceId: number(),
18431
- cutoffMs: number()
18432
- }), TrackCascadeCountsSchema, {
18433
- kind: "mutation",
18434
- auth: "admin"
18435
- }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
18436
- kind: "mutation",
18437
- auth: "admin"
18438
- }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
18439
- kind: "mutation",
18440
- auth: "admin"
18441
- }), method(object({
18442
- deviceId: number(),
18443
- trackIds: array(string()).min(1)
18444
- }), object({
18445
- deleted: number().int(),
18446
- failed: array(string()).readonly()
18447
- }), {
18448
- kind: "mutation",
18449
- auth: "admin"
18450
- }), method(object({
18451
- /** Log/audit scope only — the trackId is globally unique on its own. */
18275
+ /**
18276
+ * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
18277
+ * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
18278
+ * track and its events always answer the same question the same way.
18279
+ *
18280
+ * Two scalar columns, not an array: every consumer wants "the coarse one" or
18281
+ * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
18282
+ * is tier 2, and each carries its own score + attribution.
18283
+ *
18284
+ * **Reading it.** What a human should be shown is `subLabel ?? label` — the
18285
+ * finest thing known. Before 4g the single `label` column held the finest
18286
+ * value, so a consumer that has not been updated reads the tier-1 slot and
18287
+ * shows nothing on a species-only row; that is why the migration puts every
18288
+ * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
18289
+ * and why the read surfaces were changed in the same train.
18290
+ *
18291
+ * **Writing it.** The slots are independent, which is the whole point: a
18292
+ * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
18293
+ * migratorius`), so fineness cannot regress by construction. Within a tier the
18294
+ * higher score wins. One rule, one implementation — see
18295
+ * `pipeline/label-tier.ts` in addon-post-analysis.
18296
+ */
18297
+ var TieredLabelFields = {
18298
+ /** Tier 1 the sub-class. See {@link LabelTierSchema}. */
18299
+ label: string().optional(),
18300
+ /** Confidence of the tier-1 value, as reported by the deciding step. */
18301
+ labelScore: number().optional(),
18302
+ /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
18303
+ labelMeta: LabelAttributionSchema.optional(),
18304
+ /** Tier 2 — the instance. See {@link LabelTierSchema}. */
18305
+ subLabel: string().optional(),
18306
+ /** Confidence of the tier-2 value, as reported by the deciding step. */
18307
+ subLabelScore: number().optional(),
18308
+ /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
18309
+ subLabelMeta: LabelAttributionSchema.optional()
18310
+ };
18311
+ /** Per-camera slice of a training-export estimate. */
18312
+ var TrainingExportDeviceTotalsSchema = object({
18452
18313
  deviceId: number(),
18314
+ tracks: number().int(),
18315
+ files: number().int(),
18316
+ bytes: number().int()
18317
+ });
18318
+ /**
18319
+ * What a training export WOULD contain. Computed from media index rows only —
18320
+ * no blob is read to produce this.
18321
+ */
18322
+ var TrainingExportSummarySchema = object({
18323
+ generatedAt: number(),
18324
+ trackCount: number().int(),
18325
+ fileCount: number().int(),
18326
+ byteCount: number().int(),
18327
+ /** More marked tracks exist than a single pass carries. */
18328
+ truncated: boolean(),
18329
+ devices: array(TrainingExportDeviceTotalsSchema).readonly()
18330
+ });
18331
+ var TrackSchema = object({
18453
18332
  trackId: string(),
18454
- flags: TrackFlagsPatchSchema
18455
- }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
18456
- kind: "query",
18457
- auth: "admin"
18458
- }), method(object({
18459
- olderThanMs: number(),
18460
- reason: OpsLogReasonSchema.optional()
18461
- }), EventPruneCountsSchema, {
18462
- kind: "mutation",
18463
- auth: "admin"
18464
- }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
18465
- kind: "mutation",
18466
- auth: "admin"
18467
- }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
18468
- kind: "mutation",
18469
- auth: "admin"
18470
- }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
18471
- kind: "mutation",
18472
- auth: "admin"
18473
- }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
18474
- kind: "mutation",
18475
- auth: "admin"
18476
- }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
18477
- kind: "mutation",
18478
- auth: "admin"
18479
- }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18480
- kind: "mutation",
18481
- auth: "admin"
18482
- }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
18483
- kind: "query",
18484
- auth: "admin"
18485
- }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
18486
- kind: "query",
18487
- auth: "admin"
18488
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18489
- kind: "query",
18490
- auth: "admin"
18491
- }), method(object({
18492
- /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
18493
- * `deviceId`, deliberately: `deviceId` would make this device-bound and
18494
- * route it at one camera's owner, and "every camera" would stop being
18495
- * expressible at all. */
18496
- deviceIds: array(number()).optional(),
18497
- limit: number().int().min(1).max(500).optional()
18498
- }), array(RetrainTrackSchema).readonly(), {
18499
- kind: "query",
18500
- auth: "admin"
18501
- }), method(object({ trackId: string() }), RetrainFrameListSchema, {
18502
- kind: "query",
18503
- auth: "admin"
18504
- }), method(object({
18505
18333
  deviceId: number(),
18506
- trackId: string(),
18507
- mediaKeys: array(string()).min(1)
18508
- }), RetrainFrameSelectionSchema, {
18509
- kind: "mutation",
18510
- auth: "admin"
18511
- }), method(object({
18334
+ className: string(),
18335
+ ...TieredLabelFields,
18336
+ producingDeviceName: string().optional(),
18337
+ /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
18338
+ source: TrackSourceSchema.optional(),
18339
+ firstSeen: number(),
18340
+ lastSeen: number(),
18341
+ /** Frame-rate position history (subject to maxPositionHistory cap). */
18342
+ positions: array(TrackPositionSchema).readonly(),
18343
+ /** Periodic snapshots at snapshotIntervalMs cadence (subject to
18344
+ * saveThumbnails policy). */
18345
+ snapshots: array(TrackSnapshotSchema).readonly(),
18346
+ /** Deduplicated zones the track has entered at least once. Zone IDS. */
18347
+ zonesVisited: array(string()).readonly(),
18348
+ /**
18349
+ * Human NAMES for {@link zonesVisited}, resolved at READ time against the
18350
+ * `zones` capability.
18351
+ *
18352
+ * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
18353
+ * and no card can render — so every free-text search surface was structurally
18354
+ * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
18355
+ * just returned nothing. Resolving here rather than in each client keeps ONE
18356
+ * derivation and costs the clients no extra call (the `zones` cap is
18357
+ * per-device, so a client-side resolve would be a per-camera fan-out on a
18358
+ * surface built to avoid exactly that).
18359
+ *
18360
+ * Resolved, never invented: a zone deleted since the track was written has no
18361
+ * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
18362
+ * two are not positionally aligned. Absent when the track visited no zone, or
18363
+ * when the zone catalogue could not be read.
18364
+ */
18365
+ zoneNames: array(string()).readonly().optional(),
18366
+ /** Deduplicated set of detector classes observed for this track over its
18367
+ * life (a track may be reclassified, e.g. person→vehicle). Absent on
18368
+ * legacy rows written before class accumulation shipped. */
18369
+ classes: array(string()).readonly().optional(),
18370
+ /** Cumulative normalized distance travelled (0..1 units = full frame width). */
18371
+ totalDistance: number(),
18372
+ state: TrackStateSchema,
18373
+ active: boolean(),
18374
+ /** Deterministic key-event importance score in [0,1] (server-computed at
18375
+ * track expiry, recomputed on late label). Absent on legacy rows written
18376
+ * before scoring shipped — consumers degrade to absence / compute-on-read. */
18377
+ importance: number().optional(),
18378
+ /** Id of the track's highest-confidence ObjectEvent (its representative
18379
+ * "best" frame). Absent when the track produced no object events. */
18380
+ bestEventId: string().optional(),
18381
+ /** Tag of the importance sub-signal that dominated the score
18382
+ * (identity|dwell|proximity|class|confidence|travel|zone). */
18383
+ importanceReason: string().optional(),
18384
+ /** Audio-classification labels heard on the camera during the track's
18385
+ * life (score ≥ device `classificationMinScore`), aggregated per label.
18386
+ * Absent on legacy rows / tracks with no confident audio. */
18387
+ audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
18388
+ /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
18389
+ * Populated from the persisted envelope columns on historical reads;
18390
+ * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
18391
+ envelope: TrackEnvelopeSchema.optional(),
18392
+ /**
18393
+ * A face DETECTOR found a face on this track — nothing more. It says the
18394
+ * detail plane produced a `face` detail; it does NOT say the face was
18395
+ * embedded, matched, above `minFacePx`, or that the recognizer was even
18396
+ * enabled. Set once and never cleared.
18397
+ *
18398
+ * **This exists so "face present but not recognised" is expressible.** A
18399
+ * recognised identity lands in `subLabel` (attributed to the face chain via
18400
+ * `subLabelMeta.stepId`), so before this field a track with an unmatched face
18401
+ * and a track with no face at all were byte-identical on the wire and no
18402
+ * surface could tell them apart. The read is `hasFace === true && subLabel
18403
+ * === undefined`.
18404
+ *
18405
+ * **Absent ≠ false.** Every row written before the column existed omits it,
18406
+ * and so does every server that predates the field — a consumer must test
18407
+ * `=== true` and render nothing otherwise, never infer "no face".
18408
+ */
18409
+ hasFace: boolean().optional(),
18410
+ /**
18411
+ * This track has a face row IN THE GALLERY: a crop **and** an embedding — a
18412
+ * face an operator could ASSIGN to an identity.
18413
+ *
18414
+ * The STRICT twin of {@link hasFace}, and the pair only earns its keep
18415
+ * because the two disagree. `hasFace` is stamped at the TOP of the face
18416
+ * branch, before every gate, and means no more than "a face detector produced
18417
+ * a face detail". This one is stamped at the single moment the gallery row
18418
+ * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
18419
+ * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
18420
+ * candidate gate, the imageless-track drop (no crop was ever captured) and
18421
+ * the crop-store drop. Everything between the detector and that insert can
18422
+ * legitimately refuse the face, so a flag written any earlier promises the
18423
+ * operator something to assign and delivers nothing.
18424
+ *
18425
+ * **Independent of recognition.** A face collected but never auto-matched is
18426
+ * still assignable — it is in fact the face an operator most wants to reach —
18427
+ * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
18428
+ * `subLabel`; this says only that the raw material exists.
18429
+ *
18430
+ * **Set once, never cleared.** A track that produced a gallery row produced
18431
+ * one; deleting the row later is the gallery's business, not this flag's.
18432
+ *
18433
+ * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
18434
+ * before the column omits it, and so does every server that predates the
18435
+ * field. A consumer must test `=== true` and render nothing otherwise —
18436
+ * never infer "no assignable face".
18437
+ */
18438
+ hasEmbeddedFace: boolean().optional(),
18439
+ /**
18440
+ * This subject CONTAINS a folded rider — a person the rider-pairing step
18441
+ * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
18442
+ * so the passage is tracked once and as a VEHICLE.
18443
+ *
18444
+ * It exists because the fold's record was dishonest. D34 and the code both
18445
+ * said "the person is not lost — it is reported so both entities stay on the
18446
+ * record"; in fact the pair went into a per-processor RAM field behind an
18447
+ * accessor nobody called, and every durable surface said `vehicle`, full
18448
+ * stop. This is the composition note that makes the row true.
18449
+ *
18450
+ * A COMPOSITION, never a class and never a label. "This vehicle contains a
18451
+ * person" is not an answer to "what is this" — both label tiers would refuse
18452
+ * a macro token anyway (D89), and correctly. Nothing here changes what the
18453
+ * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
18454
+ * and a `person` rule still does not fire for someone cycling past.
18455
+ *
18456
+ * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
18457
+ * the column, and every hub that predates the field, omits it. Test
18458
+ * `=== true` and render nothing otherwise — never infer "no rider".
18459
+ */
18460
+ hasRider: boolean().optional(),
18461
+ ...TrackFlagFields,
18462
+ ...TrackRetrainFields
18463
+ });
18464
+ var BaseEventFields = {
18465
+ id: string(),
18512
18466
  deviceId: number(),
18513
- trackId: string(),
18514
- frameId: string()
18515
- }), object({
18516
- removed: boolean(),
18517
- removedAnnotations: number().int()
18518
- }), {
18519
- kind: "mutation",
18520
- auth: "admin"
18521
- }), method(object({ frameId: string() }), object({
18467
+ timestamp: number()
18468
+ };
18469
+ var MotionEventSchema = object({
18470
+ ...BaseEventFields,
18471
+ kind: literal("motion"),
18472
+ regionCount: number(),
18473
+ /** Heavy JSON array — omitted in slim projection. */
18474
+ regions: array(object({
18475
+ bbox: BoundingBoxSchema,
18476
+ pixelCount: number(),
18477
+ intensity: number()
18478
+ })).readonly().optional(),
18479
+ /** Omitted in slim projection. */
18480
+ frameWidth: number().optional(),
18481
+ /** Omitted in slim projection. */
18482
+ frameHeight: number().optional(),
18483
+ /** Populated by B5 (recording playback URL for this event). */
18484
+ mediaUrl: string().optional()
18485
+ });
18486
+ /**
18487
+ * Which detection SOURCE produced an object event. `pipeline` = the ML
18488
+ * detection pipeline (decoded-frame inference); `onboard` = the camera's
18489
+ * native on-device AI. Both flow through the SAME analysis layers (zoning,
18490
+ * tracking, per-kind persistence) but stay distinguishable so consumers
18491
+ * (advanced-notifier, occupancy, …) can select which source(s) to act on.
18492
+ * Absent on legacy rows ⇒ treat as `pipeline`.
18493
+ */
18494
+ var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
18495
+ /**
18496
+ * The confirmed zone crossing that produced an object event. Present ONLY on
18497
+ * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
18498
+ * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
18499
+ * appearance event carry none, so a rule asking for a direction fails closed
18500
+ * on them.
18501
+ *
18502
+ * Exactly ONE crossing per event: the emitter turns each confirmed crossing
18503
+ * into its own event, so a frame in which a track enters A while leaving B
18504
+ * produces two events with two directions — never one ambiguous row.
18505
+ *
18506
+ * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
18507
+ * membership the box has NOW, and by definition it no longer contains the zone
18508
+ * that was just left. Without the id here, a zone-scoped rule could never match
18509
+ * the exit it asked for.
18510
+ */
18511
+ var ZoneCrossingSchema = object({
18512
+ direction: _enum(["enter", "exit"]),
18513
+ /** Admin zone id crossed. */
18514
+ zoneId: string(),
18515
+ /** Zone display name at crossing time (falls back to the id). */
18516
+ zoneName: string().optional()
18517
+ });
18518
+ var ObjectEventSchema = object({
18519
+ ...BaseEventFields,
18520
+ kind: literal("object"),
18521
+ /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
18522
+ source: DetectionSourceSchema.optional(),
18523
+ /**
18524
+ * Inference-frame id shared by every object event emitted from the SAME frame
18525
+ * — the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
18526
+ * 2 people + 1 dog) under one full frame, and link a track's frames over time
18527
+ * (group by `trackId`, pick a representative `frameId` as the parent frame).
18528
+ * Optional for backward-compat with pre-existing rows / the slim projection
18529
+ * includes it (it is light). Absent on rows written before this field.
18530
+ */
18531
+ frameId: string().optional(),
18532
+ /** Omitted in slim projection. */
18533
+ trackId: string().optional(),
18534
+ className: string(),
18535
+ ...TieredLabelFields,
18536
+ /** Omitted in slim projection. */
18537
+ confidence: number().optional(),
18538
+ /** Heavy JSON — omitted in slim projection. */
18539
+ bbox: BoundingBoxSchema.optional(),
18540
+ /** Heavy JSON — omitted in slim projection. */
18541
+ zones: array(string()).readonly().optional(),
18542
+ /** Omitted in slim projection. */
18543
+ state: TrackStateSchema.optional(),
18544
+ /**
18545
+ * The zone crossing this event IS, when it is one. Absent on every other
18546
+ * event kind (movement state, appearance, package) — see
18547
+ * {@link ZoneCrossingSchema}. Omitted in slim projection.
18548
+ */
18549
+ zoneCrossing: ZoneCrossingSchema.optional(),
18550
+ /** Detection-frame dimensions in pixels — let consumers normalize the
18551
+ * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
18552
+ frameWidth: number().optional(),
18553
+ frameHeight: number().optional(),
18554
+ /** MediaStore key for the crop attached to this event (if any). */
18555
+ mediaKey: string().optional(),
18556
+ /** Design B: MediaStore key of the track's native-resolution key frame (the
18557
+ * best-detection full frame). Resolve via the event-media data-plane
18558
+ * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
18559
+ * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
18560
+ * sources — consumers fall back to `mediaKey` (the tight crop). */
18561
+ keyFrameMediaKey: string().optional(),
18562
+ /** Populated by B5 (recording playback URL for this event). */
18563
+ mediaUrl: string().optional(),
18564
+ /** The parent track's key-event importance [0,1], propagated to every object
18565
+ * event of the track (so an event row can be sorted by importance without a
18566
+ * track join). Absent on legacy rows / before the track was scored. */
18567
+ importance: number().optional()
18568
+ });
18569
+ var AudioEventSchema = object({
18570
+ ...BaseEventFields,
18571
+ kind: literal("audio"),
18572
+ rms: number(),
18573
+ dbfs: number(),
18574
+ classification: object({
18575
+ className: string(),
18576
+ originalClass: string().optional(),
18577
+ score: number()
18578
+ }).optional(),
18579
+ /** Populated by B5 (recording playback URL for this event). */
18580
+ mediaUrl: string().optional()
18581
+ });
18582
+ var MediaFileKindEnum = _enum([
18583
+ "crop",
18584
+ "thumbnail",
18585
+ "snapshot",
18586
+ "firstFrame",
18587
+ "lastFrame",
18588
+ "fullFrame",
18589
+ "fullFrameBoxed",
18590
+ "faceCrop",
18591
+ "plateCrop",
18592
+ "keyFrame",
18593
+ "keyFrameSmall",
18594
+ "thumbnailSmall"
18595
+ ]);
18596
+ var MediaFileSchema = object({
18597
+ key: string(),
18598
+ kind: MediaFileKindEnum,
18522
18599
  base64: string(),
18523
- width: number().int(),
18524
- height: number().int()
18525
- }), {
18526
- kind: "query",
18527
- auth: "admin"
18528
- }), method(object({
18529
- deviceId: number(),
18530
- trackId: string(),
18531
- frameId: string(),
18532
- subject: RetrainAssistSubjectSchema,
18533
- /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
18534
- nodeId: string().optional()
18535
- }), RetrainAssistResultSchema, {
18536
- kind: "mutation",
18537
- auth: "admin"
18538
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
18539
- kind: "query",
18540
- auth: "admin"
18541
- }), method(object({
18542
- deviceId: number(),
18600
+ sizeBytes: number(),
18601
+ timestamp: number()
18602
+ });
18603
+ /**
18604
+ * One media row WITHOUT its bytes.
18605
+ *
18606
+ * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
18607
+ * 140 s track), and a client that renders tiles from the media data plane needs
18608
+ * to know only WHAT EXISTS — the bytes then arrive per tile, lazily, over HTTP
18609
+ * with an immutable cache, instead of all at once inside a tRPC response that
18610
+ * blocks the whole view.
18611
+ *
18612
+ * `sizeBytes` is carried because it is what lets a client decide between the
18613
+ * stored blob and a `?variant=thumb` rendering without fetching either.
18614
+ */
18615
+ var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
18616
+ /**
18617
+ * The MACRO tier of an annotation — a CLOSED set.
18618
+ *
18619
+ * This is what the exported detector predicts, so a typo here is a new class
18620
+ * with one example in it. `label` and `subLabel` are open strings by contrast:
18621
+ * the whole point of the page is teaching the model things it does not know
18622
+ * yet, and constraining that vocabulary would make it useless.
18623
+ *
18624
+ * A macro class is NEVER a label. The provider refuses a write whose `label` or
18625
+ * `subLabel` is one of these values, in any casing, because once `person`
18626
+ * exists in both tiers "every person box" stops being answerable without
18627
+ * knowing every string anyone ever typed — and the damage is retroactive.
18628
+ */
18629
+ var RetrainMacroClassSchema = _enum([
18630
+ "person",
18631
+ "vehicle",
18632
+ "animal",
18633
+ "package",
18634
+ "face",
18635
+ "plate"
18636
+ ]);
18637
+ /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
18638
+ var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
18639
+ /** Did a human draw this box, or did the assist propose it? */
18640
+ var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
18641
+ /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
18642
+ var RetrainBboxSchema = object({
18643
+ x: number(),
18644
+ y: number(),
18645
+ w: number(),
18646
+ h: number()
18647
+ });
18648
+ /**
18649
+ * One annotated subject.
18650
+ *
18651
+ * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
18652
+ * (letterboxed root / zone-cropped package / subject-cropped classifier) are
18653
+ * derived from it at export and never stored — storing them is how one feature
18654
+ * space ends up holding two crops of the same subject (D52).
18655
+ */
18656
+ var RetrainAnnotationSchema = object({
18657
+ id: string(),
18543
18658
  trackId: string(),
18544
- frameId: string(),
18545
- annotations: array(RetrainAnnotationDraftSchema)
18546
- }), array(RetrainAnnotationSchema).readonly(), {
18547
- kind: "mutation",
18548
- auth: "admin"
18549
- }), method(object({
18550
- deviceId: number(),
18551
- trackId: string()
18552
- }), RetrainTransitionResultSchema, {
18553
- kind: "mutation",
18554
- auth: "admin"
18555
- }), method(object({
18556
18659
  deviceId: number(),
18557
- trackId: string()
18558
- }), RetrainTransitionResultSchema, {
18559
- kind: "mutation",
18560
- auth: "admin"
18561
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18562
- kind: "query",
18563
- auth: "admin"
18564
- }), method(object({
18565
- eventId: string(),
18566
- kind: MediaFileKindEnum.optional(),
18567
- deviceId: number()
18568
- }), array(MediaFileSchema).readonly()), method(object({
18569
- trackId: string(),
18570
- kinds: array(MediaFileKindEnum).optional(),
18571
- deviceId: number()
18572
- }), array(MediaFileSchema).readonly()), method(object({
18660
+ /** The COPY in retrain storage — never the source track's media key. */
18661
+ mediaKey: string(),
18662
+ bbox: RetrainBboxSchema,
18663
+ macroClass: RetrainMacroClassSchema,
18664
+ label: string().optional(),
18665
+ subLabel: string().optional(),
18666
+ kind: RetrainAnnotationKindSchema,
18667
+ source: RetrainAnnotationSourceSchema,
18668
+ /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
18669
+ assistModelId: string().optional(),
18670
+ assistScore: number().optional(),
18671
+ exportedInBatch: string().optional(),
18672
+ createdAt: number()
18673
+ });
18674
+ /** The write form — the server owns `id`, `createdAt` and the frame binding. */
18675
+ var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
18676
+ id: true,
18677
+ trackId: true,
18678
+ deviceId: true,
18679
+ mediaKey: true,
18680
+ createdAt: true,
18681
+ exportedInBatch: true
18682
+ });
18683
+ /** A track sitting in `staging`, with everything the worklist needs to rank it. */
18684
+ var RetrainTrackSchema = object({
18573
18685
  trackId: string(),
18574
- deviceId: number()
18575
- }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
18576
- kind: "mutation",
18577
- auth: "admin"
18578
- }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
18579
- kind: "mutation",
18580
- auth: "admin"
18581
- }), method(object({}), RebuildStatusSchema), object({
18582
18686
  deviceId: number(),
18687
+ className: string(),
18688
+ label: string().optional(),
18689
+ firstSeen: number(),
18690
+ lastSeen: number(),
18691
+ /** How many frames the dataset already holds from this track. */
18692
+ frameCount: number().int(),
18693
+ /** How many subjects have been annotated on those frames. `0` with
18694
+ * `frameCount: 0` is exactly "staging, still to work". */
18695
+ annotationCount: number().int()
18696
+ });
18697
+ /** A frame the picker may offer — an index row, no blob was read to produce it. */
18698
+ var RetrainFrameCandidateSchema = object({
18699
+ mediaKey: string(),
18700
+ kind: MediaFileKindEnum,
18583
18701
  timestamp: number(),
18584
- frameWidth: number(),
18585
- frameHeight: number(),
18586
- detections: array(OverlayDetectionSchema).readonly()
18587
- }), object({
18702
+ sizeBytes: number().int(),
18703
+ /** A copy of this original already exists — selecting it is free and cannot
18704
+ * fail, whatever became of the original. */
18705
+ copied: boolean()
18706
+ });
18707
+ /** A frame the dataset OWNS: bytes copied at selection time. */
18708
+ var RetrainFrameSchema = object({
18709
+ frameId: string(),
18588
18710
  deviceId: number(),
18589
18711
  trackId: string(),
18590
- className: string()
18712
+ /** Provenance only. It may already point at nothing — that is expected. */
18713
+ sourceMediaKey: string(),
18714
+ sourceKind: MediaFileKindEnum,
18715
+ sizeBytes: number().int(),
18716
+ width: number().int(),
18717
+ height: number().int(),
18718
+ copiedAt: number()
18719
+ });
18720
+ /** Why a copy-on-select could not be honoured — named, never a silent skip. */
18721
+ var RetrainCopyRefusalSchema = _enum([
18722
+ "source-missing",
18723
+ "unreadable-image",
18724
+ "write-failed"
18725
+ ]);
18726
+ var RetrainFrameSelectionSchema = object({
18727
+ copied: array(RetrainFrameSchema).readonly(),
18728
+ refused: array(object({
18729
+ sourceMediaKey: string(),
18730
+ reason: RetrainCopyRefusalSchema
18731
+ })).readonly()
18732
+ });
18733
+ var RetrainFrameListSchema = object({
18734
+ candidates: array(RetrainFrameCandidateSchema).readonly(),
18735
+ copies: array(RetrainFrameSchema).readonly(),
18736
+ /** What the page pre-selects — the native key frame when one survives. */
18737
+ autoPickMediaKey: string().optional()
18738
+ });
18739
+ /** What the operator asked the assist to look for. */
18740
+ var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
18741
+ kind: literal("package"),
18742
+ zone: RetrainBboxSchema.optional()
18591
18743
  }), object({
18592
- deviceId: number(),
18593
- trackId: string(),
18594
- className: string(),
18595
- durationMs: number()
18744
+ kind: literal("objects"),
18745
+ modelId: string(),
18746
+ minScore: number().optional()
18747
+ })]);
18748
+ /**
18749
+ * The assist's answer — a discriminated union, because "the model saw nothing"
18750
+ * and "this node cannot run that model" lead to different next moves and a
18751
+ * nullable result cannot tell them apart.
18752
+ */
18753
+ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
18754
+ kind: literal("proposed"),
18755
+ modelId: string(),
18756
+ stepId: string(),
18757
+ minScore: number(),
18758
+ /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
18759
+ proposals: array(RetrainAnnotationDraftSchema).readonly(),
18760
+ /** Returned by the runner but removed by the threshold. */
18761
+ belowThreshold: number().int()
18596
18762
  }), object({
18763
+ kind: literal("refused"),
18764
+ /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
18765
+ reason: string(),
18766
+ detail: string().optional()
18767
+ })]);
18768
+ /** The outcome of a lifecycle move owned by the retrain page. */
18769
+ var RetrainTransitionResultSchema = object({
18770
+ trackId: string(),
18771
+ /** Where the track ended up, whatever happened. */
18772
+ retrainStatus: RetrainStatusSchema,
18773
+ /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
18774
+ changed: boolean(),
18775
+ reason: _enum([
18776
+ "unknown-track",
18777
+ "no-frames-copied",
18778
+ "not-staging",
18779
+ "not-trained",
18780
+ "unchanged"
18781
+ ]).optional()
18782
+ });
18783
+ var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
18784
+ var MAX_EVENT_QUERY_LIMIT = 5e3;
18785
+ var DeviceEventQueryInput = object({
18597
18786
  deviceId: number(),
18598
- kind: EventKindSchema,
18599
- eventId: string(),
18600
- timestamp: number()
18787
+ since: number().optional(),
18788
+ until: number().optional(),
18789
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
18790
+ /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
18791
+ * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
18792
+ * exact behaviour. Callers may omit this field — the store defaults to
18793
+ * `full` when not provided. */
18794
+ projection: _enum(["full", "slim"]).optional()
18601
18795
  });
18602
- /**
18603
- * Reference to the frame's retained NATIVE surface + the parent crop's placement
18604
- * within the frame, so the executor can re-cut a leaf child ROI at native
18605
- * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
18606
- */
18607
- var NativeCropRefSchema = object({
18608
- /** Handle keying the retained native surface (node-pinned to its owner). */
18609
- handle: FrameHandleSchema,
18610
- /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
18611
- cropFrameSpace: object({
18612
- x: number(),
18613
- y: number(),
18614
- w: number(),
18615
- h: number()
18616
- })
18796
+ var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
18797
+ var RecentTracksQueryInput = object({
18798
+ /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
18799
+ deviceIds: array(number()),
18800
+ /** Window lower bound on `lastSeen` (inclusive). */
18801
+ since: number().optional(),
18802
+ /** Window upper bound on `lastSeen` (inclusive). */
18803
+ until: number().optional(),
18804
+ /** Page size. Default 200, max 1000. */
18805
+ limit: number().int().min(1).max(1e3).default(200),
18806
+ /** Opaque continuation cursor from a previous page's `nextCursor`.
18807
+ * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
18808
+ cursor: string().optional(),
18809
+ /** See {@link TrackProjectionSchema}. Default `full`. */
18810
+ projection: TrackProjectionSchema.optional(),
18811
+ /** Include stationary-promoted rows (parked objects). Default false: the
18812
+ * feed lists passages; parking records live on the stationary registry. */
18813
+ includeStationary: boolean().optional()
18617
18814
  });
18618
- object({
18619
- crop: object({
18620
- left: number(),
18621
- top: number(),
18622
- width: number().positive(),
18623
- height: number().positive()
18624
- }).optional(),
18625
- content: object({
18626
- width: number().int().positive(),
18627
- height: number().int().positive()
18628
- }),
18629
- fit: _enum(["stretch", "contain"]),
18630
- format: _enum([
18631
- "rgb",
18632
- "gray",
18633
- "jpeg"
18634
- ])
18815
+ var RecentTracksPageSchema = object({
18816
+ /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
18817
+ tracks: array(TrackSchema).readonly(),
18818
+ /** Cursor for the next page, or null when this page is the last. */
18819
+ nextCursor: string().nullable()
18635
18820
  });
18636
- var FrameRefSchema = object({
18637
- registryId: string().min(1),
18638
- id: string().min(1),
18639
- width: number().int().positive(),
18640
- height: number().int().positive(),
18641
- format: _enum(["rgb", "gray"]),
18642
- timestamp: number(),
18643
- capturedAt: number().optional()
18821
+ var LIST_GROUPS_DEFAULT_LIMIT = 40;
18822
+ var LIST_GROUPS_MAX_LIMIT = 100;
18823
+ var AnalyticsGroupRecordSchema = object({
18824
+ id: string(),
18825
+ deviceId: number().int(),
18826
+ openedAt: number().int(),
18827
+ closedAt: number().int(),
18828
+ timestamp: number().int(),
18829
+ memberCount: number().int(),
18830
+ memberTrackIds: array(string()).readonly(),
18831
+ className: string(),
18832
+ classes: array(string()).readonly(),
18833
+ /** Relative event-media path, or null when the group has no picture yet. */
18834
+ mediaUrl: string().nullable(),
18835
+ singleton: boolean()
18644
18836
  });
18645
- var ModelFormatSchema$1 = _enum([
18646
- "onnx",
18647
- "coreml",
18648
- "openvino",
18649
- "tflite",
18650
- "pt",
18651
- "gguf"
18652
- ]);
18653
- var PipelineSlotSchema = _enum([
18654
- "detector",
18655
- "cropper",
18656
- "classifier",
18657
- "refiner",
18658
- "audio-classifier"
18659
- ]);
18660
- var PipelineEngineChoiceSchema = object({
18661
- runtime: _enum(["node", "python"]),
18662
- backend: string(),
18663
- format: ModelFormatSchema$1,
18664
- device: string().optional()
18837
+ var AnalyticsGroupMemberSchema = object({
18838
+ trackId: string(),
18839
+ deviceId: number().int(),
18840
+ className: string(),
18841
+ firstSeen: number().int(),
18842
+ lastSeen: number().int(),
18843
+ mediaUrl: string().nullable()
18665
18844
  });
18666
- var AvailableEngineSchema = object({
18667
- engine: PipelineEngineChoiceSchema,
18668
- devices: array(object({
18669
- id: string(),
18670
- label: string(),
18671
- description: string().optional()
18672
- })).readonly(),
18673
- defaultDevice: string()
18845
+ var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
18846
+ var ListGroupsQueryInput = object({
18847
+ /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
18848
+ deviceIds: array(number()),
18849
+ /** Window lower bound on `closedAt` (inclusive). */
18850
+ since: number().optional(),
18851
+ /** Window upper bound on `openedAt` (inclusive). */
18852
+ until: number().optional(),
18853
+ limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
18854
+ /** Opaque continuation cursor from a previous page's `nextCursor`. */
18855
+ cursor: string().optional()
18674
18856
  });
18675
- var PipelineDefaultStepSchema = lazy(() => object({
18676
- addonId: string(),
18677
- addonName: string(),
18678
- slot: PipelineSlotSchema,
18679
- inputClasses: array(string()).readonly(),
18680
- outputClasses: array(string()).readonly(),
18681
- enabled: boolean(),
18682
- modelId: string(),
18683
- children: array(PipelineDefaultStepSchema).readonly(),
18684
- group: string().optional(),
18685
- settings: record(string(), unknown()).optional()
18686
- }));
18687
- var PipelineTemplateStepSchema = lazy(() => object({
18688
- addonId: string(),
18689
- enabled: boolean(),
18690
- modelId: string(),
18691
- children: array(PipelineTemplateStepSchema).readonly(),
18692
- settings: record(string(), unknown()).optional()
18693
- }));
18694
- var PipelineTemplateSchema$1 = object({
18695
- id: string(),
18696
- name: string(),
18697
- createdAt: string(),
18698
- updatedAt: string(),
18699
- engine: PipelineEngineChoiceSchema,
18700
- steps: array(PipelineTemplateStepSchema).readonly()
18857
+ var ListGroupsPageSchema = object({
18858
+ groups: array(AnalyticsGroupRecordSchema).readonly(),
18859
+ nextCursor: string().nullable()
18860
+ });
18861
+ var KeyEventQueryInput = object({
18862
+ deviceId: number(),
18863
+ /** Window lower bound (track firstSeen ≥ since). */
18864
+ since: number(),
18865
+ /** Window upper bound (track firstSeen ≤ until). */
18866
+ until: number(),
18867
+ limit: number().int().min(1).max(200).default(50),
18868
+ /** Drop tracks scoring below this importance. */
18869
+ minImportance: number().min(0).max(1).optional(),
18870
+ /** Restrict to a single class (e.g. 'person'). */
18871
+ classFilter: string().optional()
18701
18872
  });
18702
- var PipelineModelOptionSchema = object({
18873
+ var KeyEventSchema = object({
18874
+ /** The representative event id (the track's best ObjectEvent, else its trackId). */
18703
18875
  id: string(),
18704
- name: string(),
18705
- formats: record(string(), object({
18706
- downloaded: boolean(),
18707
- sizeMB: number()
18708
- })),
18709
- group: ModelVariantGroupSchema.optional(),
18710
- legacy: boolean().optional(),
18711
- provider: ModelProviderIdSchema.optional()
18876
+ trackId: string(),
18877
+ /** Track start time (firstSeen). */
18878
+ timestamp: number(),
18879
+ className: string(),
18880
+ ...TieredLabelFields,
18881
+ importance: number(),
18882
+ /** Highest-confidence ObjectEvent id for the track (empty when none). */
18883
+ bestEventId: string(),
18884
+ /** Track lifetime in ms (lastSeen - firstSeen). */
18885
+ windowMs: number().optional(),
18886
+ ...TrackFlagFields,
18887
+ ...TrackRetrainFields
18712
18888
  });
18713
- var ConfigFieldBridge = custom();
18714
- var PipelineAddonSchemaSchema = object({
18715
- id: string(),
18716
- name: string(),
18717
- slot: PipelineSlotSchema,
18718
- inputClasses: array(string()).readonly(),
18719
- outputClasses: array(string()).readonly(),
18720
- childSlots: array(PipelineSlotSchema).readonly(),
18721
- models: array(PipelineModelOptionSchema).readonly(),
18722
- defaultModelId: string(),
18723
- defaultModelIdByFormat: record(string(), string()).optional(),
18724
- enabledByDefault: boolean().optional(),
18725
- backfillIntoExistingOverrides: boolean().optional(),
18726
- defaultConfidence: number(),
18727
- group: string().optional(),
18728
- configSchema: array(ConfigFieldBridge).readonly().optional()
18889
+ object({
18890
+ trackId: string(),
18891
+ className: string(),
18892
+ confidence: number(),
18893
+ bbox: BoundingBoxSchema,
18894
+ zones: array(string()).readonly(),
18895
+ state: TrackStateSchema
18729
18896
  });
18730
- var PipelineSlotSchemaSchema = object({
18731
- id: PipelineSlotSchema,
18732
- label: string(),
18733
- priority: number(),
18734
- parentSlot: PipelineSlotSchema.nullable(),
18735
- addons: array(PipelineAddonSchemaSchema).readonly()
18897
+ var OverlayDetectionSchema = looseObject({
18898
+ id: string(),
18899
+ kind: _enum(["first-level", "detail"]),
18900
+ macroClass: string(),
18901
+ score: number(),
18902
+ bbox: object({
18903
+ x: number(),
18904
+ y: number(),
18905
+ width: number(),
18906
+ height: number()
18907
+ }),
18908
+ labels: array(looseObject({
18909
+ label: string(),
18910
+ score: number()
18911
+ })).readonly(),
18912
+ parentId: string().optional()
18736
18913
  });
18737
- var PipelineSchemaSchema = object({
18738
- availableEngines: array(AvailableEngineSchema).readonly(),
18739
- selectedEngine: PipelineEngineChoiceSchema,
18740
- slots: array(PipelineSlotSchemaSchema).readonly()
18914
+ var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
18915
+ var SearchObjectEventsInput = object({
18916
+ text: string(),
18917
+ deviceId: number().optional(),
18918
+ since: number().optional(),
18919
+ until: number().optional(),
18920
+ classFilter: string().optional(),
18921
+ limit: number().default(50),
18922
+ minScore: number().min(0).max(1).default(.2)
18741
18923
  });
18742
- var EngineProvisioningSchema = object({
18743
- runtimeId: _enum([
18744
- "onnx",
18745
- "openvino",
18746
- "coreml",
18747
- "edgetpu"
18748
- ]).nullable(),
18749
- device: string().nullable(),
18750
- state: _enum([
18751
- "idle",
18752
- "installing",
18753
- "verifying",
18754
- "ready",
18755
- "failed"
18756
- ]),
18757
- progress: number().optional(),
18758
- error: string().optional(),
18759
- nextRetryAt: number().optional(),
18760
- /**
18761
- * Gate A (config-correctness gate at engine change): human-readable
18762
- * config issues surfaced EAGERLY when the node's engine changes — model
18763
- * substitutions ("chose X, running Y") and zero-build steps ("no model
18764
- * has a <format> build"). Additive/optional: informational only, never
18765
- * enforced here — `assertEngineReady` (readiness) still gates inference.
18766
- * Absent/empty when the node-default tree resolves cleanly.
18767
- */
18768
- configIssues: array(string()).optional()
18924
+ var TrackCascadeCountsSchema = object({
18925
+ /** Persisted track roots deleted (authoritative). */
18926
+ tracks: number().int(),
18927
+ /** Object events removed with their tracks (best-effort; see note above). */
18928
+ events: number().int(),
18929
+ /** Track/face/plate-owned media removed (best-effort). Never identity media. */
18930
+ media: number().int(),
18931
+ /** Unassigned (non-enrolled) face reads removed (best-effort). */
18932
+ faces: number().int(),
18933
+ /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
18934
+ plates: number().int(),
18935
+ /** Per-track CLIP search vectors removed (best-effort). */
18936
+ embeddings: number().int(),
18937
+ /** Group membership + group rows removed with their last member (best-effort). */
18938
+ groups: number().int()
18769
18939
  });
18770
- var PipelineStepInputSchema = lazy(() => object({
18771
- addonId: string(),
18772
- modelId: string().optional(),
18773
- enabled: boolean().default(true),
18774
- children: array(PipelineStepInputSchema).optional(),
18775
- settings: record(string(), unknown()).optional(),
18776
- jumpDeviceKey: string().optional()
18777
- }));
18778
- var ModelSubstitutionSchema = object({
18779
- addonId: string(),
18780
- chosen: string(),
18781
- running: string(),
18782
- format: string()
18940
+ /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
18941
+ var DiskReconcileCountsSchema = object({
18942
+ mediaDropped: number().int(),
18943
+ tracks: number().int(),
18944
+ events: number().int()
18783
18945
  });
18784
- var PipelineValidationIssueSchema = object({
18785
- addonId: string(),
18786
- kind: _enum(["unknown-addon", "no-format-build"]),
18787
- detail: string()
18946
+ /** Event-store footprint for one camera. */
18947
+ var EventStoreDeviceFootprintSchema = object({
18948
+ deviceId: number(),
18949
+ /** Persisted event rows (motion + object + audio) for the camera. */
18950
+ rows: number().int(),
18951
+ /** Event-owned media bytes on disk for the camera. */
18952
+ bytes: number().int()
18788
18953
  });
18789
- var PipelineValidationResultSchema = object({
18790
- ok: boolean(),
18791
- issues: array(PipelineValidationIssueSchema).readonly(),
18792
- substitutions: array(ModelSubstitutionSchema).readonly(),
18793
- /** The node's `currentEngine.format` this validation ran against. */
18794
- format: string()
18954
+ /** Aggregate event-store footprint: global totals + per-camera breakdown. */
18955
+ var EventStoreFootprintSchema = object({
18956
+ totalRows: number().int(),
18957
+ totalBytes: number().int(),
18958
+ devices: array(EventStoreDeviceFootprintSchema).readonly()
18795
18959
  });
18796
- var ReferenceImageEntrySchema = object({
18797
- filename: string(),
18798
- stepIds: array(string()).readonly().optional()
18960
+ /** Per-kind counts returned by the event-prune / device-delete mutations. */
18961
+ var EventPruneCountsSchema = object({
18962
+ motion: number().int(),
18963
+ object: number().int(),
18964
+ audio: number().int()
18799
18965
  });
18800
- var ReferenceImageBodySchema = object({
18801
- base64: string(),
18802
- filename: string()
18966
+ /**
18967
+ * Re-embed stored tracks from their key frames.
18968
+ *
18969
+ * The reason this is an operator-callable method and not a migration script:
18970
+ * every knob that decides what a vector MEANS — encoder model, crop margin,
18971
+ * squaring — is only changeable if the existing vectors can be regenerated.
18972
+ * Mixing feature spaces in one index makes cosine scores incomparable, and the
18973
+ * symptom is a quality regression with no visible cause.
18974
+ */
18975
+ var RebuildObjectEmbeddingsInput = object({
18976
+ /** Restrict to one camera. Omit for the whole fleet. */
18977
+ deviceId: number().optional(),
18978
+ since: number().optional(),
18979
+ until: number().optional(),
18980
+ /** Stop after this many tracks; the result reports whether more remain. */
18981
+ maxTracks: number().int().positive().optional(),
18982
+ /**
18983
+ * Run every embedding on THIS node instead of round-robining the fleet.
18984
+ *
18985
+ * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
18986
+ * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
18987
+ * calling it that would pin the rebuild REQUEST itself to that node — the
18988
+ * rebuild orchestration lives on the hub, and only the per-track step runs
18989
+ * remotely. This field is data; the per-track pin is applied inside.
18990
+ *
18991
+ * Absent ⇒ round-robin over every online node whose runner can serve the
18992
+ * pinned model.
18993
+ */
18994
+ executeOnNodeId: string().optional(),
18995
+ /**
18996
+ * Milliseconds to wait between tracks; omit for the built-in default, `0` to
18997
+ * run flat out.
18998
+ *
18999
+ * A rebuild is bulk maintenance on hub-main's single thread. Measured
19000
+ * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
19001
+ * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
19002
+ * force is logged at start and finish so a deliberately slow pass reads
19003
+ * differently from a stalled one.
19004
+ */
19005
+ pacingMs: number().int().nonnegative().optional()
18803
19006
  });
18804
- var ReferenceAudioEntrySchema = object({
18805
- filename: string(),
18806
- sizeKb: number()
19007
+ /**
19008
+ * Result of emptying the CLIP index.
19009
+ *
19010
+ * The clean slate before a policy change: a new crop margin or encoder model
19011
+ * leaves two feature spaces in one index whose cosine scores are not
19012
+ * comparable, so wiping and rebuilding is the only way to be sure every vector
19013
+ * means the same thing.
19014
+ */
19015
+ var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
19016
+ /**
19017
+ * Acknowledgement that a rebuild STARTED.
19018
+ *
19019
+ * The pass costs ~1s per track — 45 minutes for a 2,600-track fleet — so it
19020
+ * runs detached and this returns immediately. Waiting for it made the client
19021
+ * time out while the work carried on server-side, which is the worst of both:
19022
+ * no result and no way to know it was still going. Poll
19023
+ * `getObjectEmbeddingRebuildStatus` for progress.
19024
+ */
19025
+ var RebuildObjectEmbeddingsResultSchema = object({
19026
+ started: boolean(),
19027
+ /** True when a pass was already running; the new request is ignored. */
19028
+ alreadyRunning: boolean()
18807
19029
  });
18808
- var ReferenceAudioBodySchema = object({ base64: string() });
18809
- var AudioBackendSchema = object({
18810
- id: string(),
18811
- name: string(),
18812
- description: string(),
18813
- available: boolean(),
19030
+ var RebuildStatusSchema = object({
19031
+ running: boolean(),
19032
+ scanned: number(),
19033
+ rebuilt: number(),
19034
+ /** Tracks whose key frame is gone — nothing to re-embed from. */
19035
+ missingKeyFrame: number(),
19036
+ /** Tracks with no usable detection box. */
19037
+ missingBbox: number(),
19038
+ /**
19039
+ * Tracks an executing node REFUSED rather than broke on — an unreadable key
19040
+ * frame, a step that threw. Separate from `failed` because the remedy is
19041
+ * different, and because a whole camera silently contributing zero vectors
19042
+ * is the shape of failure a rebuild must never hide.
19043
+ */
19044
+ notRunnable: number(),
18814
19045
  /**
18815
- * Raw classifier labels this backend can emit (e.g. YAMNet's
18816
- * 521-class set or Apple SoundAnalysis's 303-class set). Used by
18817
- * the benchmark UI to populate the `enabledMicroClasses` filter
18818
- * specific to the selected backend without a separate fetch.
19046
+ * The pass stopped because NO node could serve the pinned model.
19047
+ *
19048
+ * Distinct from `notRunnable` on purpose: that one says "this track was
19049
+ * refused", this one says "the cluster cannot do this work at all" — every
19050
+ * candidate node either lacks the `clip-embedding` step, lacks a build of the
19051
+ * pinned model for its engine format, or dropped out. The remedy is a model /
19052
+ * engine change, not a per-camera one. Non-zero here always comes with
19053
+ * `complete: false`.
18819
19054
  */
18820
- rawLabels: array(string()).readonly().optional()
18821
- });
18822
- var AudioCapabilitiesSchema = object({
18823
- activeBackend: string(),
18824
- availableBackends: array(AudioBackendSchema).readonly(),
18825
- sampleRate: number(),
18826
- chunkDurationMs: number()
18827
- });
18828
- var DownloadModelResultSchema = object({
18829
- filePath: string(),
18830
- sizeMB: number(),
18831
- durationMs: number()
19055
+ noCapableNode: number(),
19056
+ failed: number(),
19057
+ /** Set once a pass ends: true only when EVERYTHING was covered. */
19058
+ complete: boolean().nullable(),
19059
+ startedAtMs: number().nullable(),
19060
+ finishedAtMs: number().nullable(),
19061
+ /** Present when the pass ended by throwing. */
19062
+ error: string().nullable()
18832
19063
  });
18833
- /**
18834
- * Wrapper carrying a single test run's result. Replaces the legacy
18835
- * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
18836
- * canonical `AudioResult` from the Phase 6 output rework: one
18837
- * `AudioDetection` per class above `minScore`, top-N candidates in
18838
- * `debug.alternateLabels['audio-classifier']`, per-source timings in
18839
- * `debug.stepTimings`. The outer `success`/`error` fields stay so the
18840
- * benchmark UI can still report a clean failure when the classifier
18841
- * cap isn't available.
18842
- */
18843
- var AudioTestResultSchema = object({
18844
- success: boolean(),
18845
- error: string().optional(),
18846
- frame: custom().optional()
19064
+ var ReplayFrameInputSchema = object({
19065
+ timestamp: number(),
19066
+ frame: PipelineRunResultBridge
18847
19067
  });
18848
- var PipelineConfigBridge = custom();
18849
- var ConfigUISchemaBridge = custom();
18850
- var ConfigUISchemaNullableBridge = custom();
18851
- var InferenceCapabilitiesBridge = custom();
18852
- var ModelAvailabilityListBridge = custom();
18853
- var PipelineRunResultBridge = custom();
18854
- method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
18855
- modelId: string(),
18856
- settings: record(string(), unknown()).readonly()
18857
- }))), method(object({ steps: record(string(), object({
18858
- modelId: string(),
18859
- settings: record(string(), unknown()).readonly()
18860
- })) }), object({ success: literal(true) }), {
19068
+ var RunReplayFrameProcessorResultSchema = object({ tracks: array(object({
19069
+ className: string(),
19070
+ firstSeenMs: number(),
19071
+ lastSeenMs: number(),
19072
+ /** Bbox of the track's FIRST matched detection, pixel-space in the clip's
19073
+ * frame a representative box for the diff's `(className, window, IoU)`
19074
+ * pairing (`replay-diff.ts`). A replay does not need the full per-frame
19075
+ * trajectory production's `Track.positions` keeps. */
19076
+ bbox: BoundingBoxSchema,
19077
+ /** How many of the input frames this track matched a real detection on
19078
+ * (never a coasted/extrapolated frame) — the replay's own signal for "how
19079
+ * solid is this track", cheaper than re-deriving it from a trajectory. */
19080
+ framesMatched: number().int()
19081
+ })).readonly() });
19082
+ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
19083
+ deviceId: number(),
19084
+ trackId: string()
19085
+ }), TrackSchema.nullable()), method(object({
19086
+ deviceId: number(),
19087
+ since: number().optional(),
19088
+ until: number().optional(),
19089
+ limit: number().optional(),
19090
+ /** Spatial filter — only tracks whose trajectory intersects the zone
19091
+ * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
19092
+ * envelope columns, then precisely tested per position. Tracks with
19093
+ * an unknown envelope (no frame dims at persist time) always match. */
19094
+ zone: TrackZoneFilterSchema.optional(),
19095
+ /** See {@link TrackProjectionSchema}. Default `full` (backward
19096
+ * compatible — omitting the field keeps today's exact behaviour). */
19097
+ projection: TrackProjectionSchema.optional(),
19098
+ /** Include stationary-promoted rows (parked objects handed to the
19099
+ * stationary registry). Default false: the timeline lists passages,
19100
+ * not parking records (operator decision, 2026-08-15). */
19101
+ includeStationary: boolean().optional()
19102
+ }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
19103
+ deviceId: number(),
19104
+ groupId: string().min(1)
19105
+ }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
19106
+ kind: "mutation",
19107
+ auth: "admin"
19108
+ }), 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({
19109
+ deviceId: number(),
19110
+ since: number().optional(),
19111
+ until: number().optional(),
19112
+ kinds: array(string()).optional(),
19113
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
19114
+ }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
19115
+ deviceId: number(),
19116
+ since: number(),
19117
+ until: number(),
19118
+ bucketMs: number().int().positive()
19119
+ }), array(object({
19120
+ bucketStart: number(),
19121
+ motion: number().int(),
19122
+ object: number().int(),
19123
+ audio: number().int()
19124
+ })).readonly()), method(object({
19125
+ deviceId: number(),
19126
+ cutoffMs: number()
19127
+ }), object({
19128
+ motion: number().int(),
19129
+ object: number().int(),
19130
+ audio: number().int()
19131
+ }), {
19132
+ kind: "mutation",
19133
+ auth: "admin"
19134
+ }), method(object({
19135
+ deviceId: number(),
19136
+ cutoffMs: number()
19137
+ }), TrackCascadeCountsSchema, {
19138
+ kind: "mutation",
19139
+ auth: "admin"
19140
+ }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
19141
+ kind: "mutation",
19142
+ auth: "admin"
19143
+ }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
19144
+ kind: "mutation",
19145
+ auth: "admin"
19146
+ }), method(object({
19147
+ deviceId: number(),
19148
+ trackIds: array(string()).min(1)
19149
+ }), object({
19150
+ deleted: number().int(),
19151
+ failed: array(string()).readonly()
19152
+ }), {
19153
+ kind: "mutation",
19154
+ auth: "admin"
19155
+ }), method(object({
19156
+ /** Log/audit scope only — the trackId is globally unique on its own. */
19157
+ deviceId: number(),
19158
+ trackId: string(),
19159
+ flags: TrackFlagsPatchSchema
19160
+ }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
19161
+ kind: "query",
19162
+ auth: "admin"
19163
+ }), method(object({
19164
+ olderThanMs: number(),
19165
+ reason: OpsLogReasonSchema.optional()
19166
+ }), EventPruneCountsSchema, {
19167
+ kind: "mutation",
19168
+ auth: "admin"
19169
+ }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
19170
+ kind: "mutation",
19171
+ auth: "admin"
19172
+ }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
19173
+ kind: "mutation",
19174
+ auth: "admin"
19175
+ }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
19176
+ kind: "mutation",
19177
+ auth: "admin"
19178
+ }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
19179
+ kind: "mutation",
19180
+ auth: "admin"
19181
+ }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
19182
+ kind: "mutation",
19183
+ auth: "admin"
19184
+ }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
19185
+ kind: "mutation",
19186
+ auth: "admin"
19187
+ }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
19188
+ kind: "mutation",
19189
+ auth: "admin"
19190
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
19191
+ kind: "query",
19192
+ auth: "admin"
19193
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
19194
+ kind: "mutation",
19195
+ auth: "admin"
19196
+ }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
19197
+ kind: "query",
19198
+ auth: "admin"
19199
+ }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
19200
+ kind: "query",
19201
+ auth: "admin"
19202
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
19203
+ kind: "query",
19204
+ auth: "admin"
19205
+ }), method(object({
19206
+ /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
19207
+ * `deviceId`, deliberately: `deviceId` would make this device-bound and
19208
+ * route it at one camera's owner, and "every camera" would stop being
19209
+ * expressible at all. */
19210
+ deviceIds: array(number()).optional(),
19211
+ limit: number().int().min(1).max(500).optional()
19212
+ }), array(RetrainTrackSchema).readonly(), {
19213
+ kind: "query",
19214
+ auth: "admin"
19215
+ }), method(object({ trackId: string() }), RetrainFrameListSchema, {
19216
+ kind: "query",
19217
+ auth: "admin"
19218
+ }), method(object({
19219
+ deviceId: number(),
19220
+ trackId: string(),
19221
+ mediaKeys: array(string()).min(1)
19222
+ }), RetrainFrameSelectionSchema, {
19223
+ kind: "mutation",
19224
+ auth: "admin"
19225
+ }), method(object({
19226
+ deviceId: number(),
19227
+ trackId: string(),
19228
+ frameId: string()
19229
+ }), object({
19230
+ removed: boolean(),
19231
+ removedAnnotations: number().int()
19232
+ }), {
19233
+ kind: "mutation",
19234
+ auth: "admin"
19235
+ }), method(object({ frameId: string() }), object({
19236
+ base64: string(),
19237
+ width: number().int(),
19238
+ height: number().int()
19239
+ }), {
19240
+ kind: "query",
19241
+ auth: "admin"
19242
+ }), method(object({
19243
+ deviceId: number(),
19244
+ trackId: string(),
19245
+ frameId: string(),
19246
+ subject: RetrainAssistSubjectSchema,
19247
+ /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
19248
+ nodeId: string().optional()
19249
+ }), RetrainAssistResultSchema, {
19250
+ kind: "mutation",
19251
+ auth: "admin"
19252
+ }), method(object({
19253
+ deviceId: number(),
19254
+ source: DetectionSourceSchema,
19255
+ zones: array(ZoneSchema).readonly().optional(),
19256
+ detectionRules: array(ZoneRuleSchema).readonly().optional(),
19257
+ zoneMembershipMinOverlap: number().min(0).max(1).optional(),
19258
+ frames: array(ReplayFrameInputSchema).min(1)
19259
+ }), RunReplayFrameProcessorResultSchema, {
19260
+ kind: "mutation",
19261
+ auth: "admin"
19262
+ }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
19263
+ kind: "query",
19264
+ auth: "admin"
19265
+ }), method(object({
19266
+ deviceId: number(),
19267
+ trackId: string(),
19268
+ frameId: string(),
19269
+ annotations: array(RetrainAnnotationDraftSchema)
19270
+ }), array(RetrainAnnotationSchema).readonly(), {
19271
+ kind: "mutation",
19272
+ auth: "admin"
19273
+ }), method(object({
19274
+ deviceId: number(),
19275
+ trackId: string()
19276
+ }), RetrainTransitionResultSchema, {
18861
19277
  kind: "mutation",
18862
19278
  auth: "admin"
18863
- }), method(object({ nodeId: string() }), object({
18864
- success: literal(true),
18865
- clearedDevices: number()
18866
- }), {
19279
+ }), method(object({
19280
+ deviceId: number(),
19281
+ trackId: string()
19282
+ }), RetrainTransitionResultSchema, {
18867
19283
  kind: "mutation",
18868
19284
  auth: "admin"
18869
- }), 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({
18870
- name: string(),
18871
- steps: array(PipelineTemplateStepSchema).readonly(),
18872
- engine: PipelineEngineChoiceSchema
18873
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
18874
- id: string(),
18875
- name: string().optional(),
18876
- steps: array(PipelineTemplateStepSchema).readonly().optional()
18877
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
18878
- addonId: string(),
18879
- modelId: string(),
18880
- format: ModelFormatSchema$1
18881
- }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
18882
- addonId: string(),
18883
- modelId: string(),
18884
- format: ModelFormatSchema$1
18885
- }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
18886
- engine: PipelineEngineChoiceSchema.optional(),
18887
- steps: array(PipelineStepInputSchema).min(1),
18888
- frame: FrameInputSchema.optional(),
18889
- /**
18890
- * Process-local lazy frame. Valid only when caller and provider resolve
18891
- * in the same execution-group process; split/cross-node callers use
18892
- * `frame`/`image` inline compatibility instead.
18893
- */
18894
- frameRef: FrameRefSchema.optional(),
18895
- /**
18896
- * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
18897
- * the decoded pixels live in. One more member of the one-of
18898
- * frame/frameHandle/image/imageBase64/referenceImage group.
18899
- */
18900
- frameHandle: FrameHandleSchema.optional(),
18901
- imageBase64: string().optional(),
18902
- /**
18903
- * Binary JPEG bytes — preferred over `imageBase64` on internal
18904
- * hops (hub → forked worker via Moleculer MsgPack) because it
18905
- * skips the 33% base64 overhead + the per-call base64 decode on
18906
- * the detection-pipeline worker. Callers can pass either; exactly
18907
- * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
18908
- */
18909
- image: _instanceof(Uint8Array).optional(),
18910
- referenceImage: string().optional(),
18911
- deviceId: number().optional(),
18912
- sessionId: string().optional(),
18913
- /**
18914
- * Execution plane. 'full' (default) runs the whole tree — benchmark,
18915
- * reference-image, and detail-subtree calls. 'frame' is the live
18916
- * per-frame dispatch: ONLY root-plane steps run; crop children
18917
- * (inputClasses ≠ null) are skipped and served per-track via
18918
- * pipelineRunner.runDetailSubtree (two-plane design).
18919
- */
18920
- plane: _enum(["full", "frame"]).optional(),
18921
- /**
18922
- * Inference-device selector (Phase 2 multi-device). Format
18923
- * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
18924
- * Omitted ⇒ the runner's default device (current single-engine
18925
- * behaviour). Selects WHICH device pool of the node runs the call.
18926
- */
18927
- deviceKey: string().optional(),
18928
- /**
18929
- * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
18930
- * when the parent crop was resolved from the frame's retained NATIVE
18931
- * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
18932
- * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
18933
- * resolution from that surface — the SAME quality path faces already
18934
- * had — instead of the downscaled parent tile. `handle` keys the native
18935
- * surface (node-pinned to its owner); `cropFrameSpace` is the parent
18936
- * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
18937
- * the executor's crop-normalized child ROI back into frame-normalized
18938
- * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
18939
- * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
18940
- * (today's behaviour on the fallback path).
18941
- */
18942
- nativeCropRef: NativeCropRefSchema.optional()
18943
- }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
18944
- engine: PipelineEngineChoiceSchema.optional(),
18945
- steps: array(PipelineStepInputSchema).min(1),
18946
- frames: array(FrameInputSchema).min(1).max(255),
18947
- deviceId: number().optional(),
18948
- sessionId: string().optional(),
18949
- /**
18950
- * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
18951
- * the batch to the Python pool's bench preprocess cache
18952
- * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
18953
- * preprocessed ONCE and every later inference is a pure-inference cache
18954
- * hit — the sustained-throughput run measures inference, not
18955
- * decode+preprocess+infer. Omitted/0 for live frames (all different →
18956
- * full preprocess every call, correct). Fresh per sustained run;
18957
- * released via `uncacheFrame`.
18958
- */
18959
- frameId: number().int().nonnegative().optional(),
18960
- /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
18961
- deviceKey: string().optional()
18962
- }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
18963
- data: _instanceof(Uint8Array),
18964
- width: number().int().positive(),
18965
- height: number().int().positive(),
18966
- format: _enum([
18967
- "rgb",
18968
- "bgr",
18969
- "gray"
18970
- ])
18971
- }), object({
18972
- frameId: number(),
18973
- width: number(),
18974
- height: number()
18975
- }), { kind: "mutation" }), method(object({
18976
- stepId: string(),
18977
- frameId: number().int()
18978
- }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
18979
- batchMode: string(),
18980
- windowMs: number(),
18981
- maxBatchSize: number(),
18982
- concurrency: number()
18983
- })), method(_void(), array(object({
18984
- engineKey: string(),
18985
- engine: PipelineEngineChoiceSchema,
18986
- modelsLoaded: array(string()).readonly(),
18987
- inUseByCameras: array(number()).readonly(),
18988
- /**
18989
- * Origin of this resident factory.
18990
- * - `runtime` — main camera-serving engine (no idle TTL).
18991
- * - `warm-override` — benchmark/test override held in the warm
18992
- * cache; auto-disposed after the idle TTL.
18993
- * - `device-pool` — a concurrent per-device pool (Phase 2
18994
- * multi-device, keyed by `deviceKey`) resolved
18995
- * via `resolveDeviceFactory`. Runs alongside the
18996
- * `runtime` engine on a DIFFERENT accelerator
18997
- * (NPU / iGPU / Coral) — this is how the
18998
- * Engines tab shows all pools running at once.
18999
- */
19000
- kind: _enum([
19001
- "runtime",
19002
- "warm-override",
19003
- "device-pool"
19004
- ]),
19005
- /** Native pid of the underlying Python pool (null when no pool). */
19006
- poolPid: number().nullable(),
19007
- /** ms since this factory was last used (null when not warm-tracked). */
19008
- idleMs: number().nullable(),
19009
- /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
19010
- idleTtlMs: number().nullable()
19011
- })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
19012
- kind: "mutation",
19285
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
19286
+ kind: "query",
19013
19287
  auth: "admin"
19014
19288
  }), method(object({
19015
- engine: PipelineEngineChoiceSchema,
19016
- force: boolean().optional()
19017
- }), object({
19018
- success: boolean(),
19019
- reason: string().optional()
19020
- }), {
19289
+ eventId: string(),
19290
+ kind: MediaFileKindEnum.optional(),
19291
+ deviceId: number()
19292
+ }), array(MediaFileSchema).readonly()), method(object({
19293
+ trackId: string(),
19294
+ kinds: array(MediaFileKindEnum).optional(),
19295
+ deviceId: number()
19296
+ }), array(MediaFileSchema).readonly()), method(object({
19297
+ trackId: string(),
19298
+ deviceId: number()
19299
+ }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
19021
19300
  kind: "mutation",
19022
19301
  auth: "admin"
19023
- }), 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({
19024
- addonId: string(),
19025
- modelId: string(),
19026
- filename: string().optional(),
19027
- settings: record(string(), unknown()).optional()
19028
- }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
19302
+ }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
19303
+ kind: "mutation",
19304
+ auth: "admin"
19305
+ }), method(object({}), RebuildStatusSchema), object({
19306
+ deviceId: number(),
19307
+ timestamp: number(),
19308
+ frameWidth: number(),
19309
+ frameHeight: number(),
19310
+ detections: array(OverlayDetectionSchema).readonly()
19311
+ }), object({
19312
+ deviceId: number(),
19313
+ trackId: string(),
19314
+ className: string()
19315
+ }), object({
19316
+ deviceId: number(),
19317
+ trackId: string(),
19318
+ className: string(),
19319
+ durationMs: number()
19320
+ }), object({
19321
+ deviceId: number(),
19322
+ kind: EventKindSchema,
19323
+ eventId: string(),
19324
+ timestamp: number()
19325
+ });
19029
19326
  object({
19030
19327
  activeCameras: number(),
19031
19328
  throttledCameras: number(),
@@ -19037,119 +19334,19 @@ var CameraMetricsSchema = object({
19037
19334
  "disabled",
19038
19335
  "always-on",
19039
19336
  "on-motion"
19040
- ]),
19041
- configuredFps: number(),
19042
- actualFps: number(),
19043
- queueDepth: number(),
19044
- avgInferenceTimeMs: number(),
19045
- droppedFrames: number(),
19046
- phase: _enum([
19047
- "idle",
19048
- "watching",
19049
- "active"
19050
- ])
19051
- });
19052
- var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
19053
- /**
19054
- * Zone — pure geometry + identity. NO filtering behaviour.
19055
- *
19056
- * Zones describe **where** in the frame the operator wants to flag
19057
- * something; consumer-owned {@link ZoneRule} arrays describe **how**
19058
- * each pipeline stage uses them. Splitting the two means a single
19059
- * polygon "Driveway" can simultaneously back a motion-exclude rule,
19060
- * a detection-include rule on `['car']`, and an occupancy aggregate
19061
- * — without three duplicated polygons.
19062
- *
19063
- * Owned by the orchestrator addon (provider) and mirrored into the
19064
- * `zones` device-state slice on every mutation. Consumers
19065
- * (motion-wasm, pipeline-executor, analytics, admin UI) read either
19066
- * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
19067
- * mirror with `onChanged`).
19068
- *
19069
- * Coordinates are normalised fractions of the frame (0–1) so zones
19070
- * survive resolution changes and stream profile switches.
19071
- *
19072
- * `kind` discriminates between full polygons (closed regions used
19073
- * for intrusion / occupancy filters) and tripwires (open 2-point
19074
- * line segments used for cross events). Onboard / firmware-reported
19075
- * zones (Reolink, ONVIF) are out of scope for now — see the deferred
19076
- * task list.
19077
- */
19078
- var ZoneKindEnum = _enum(["polygon", "tripwire"]);
19079
- /** Polygon vertex in fraction-of-frame coordinates (0–1). */
19080
- var PolygonPointSchema = object({
19081
- x: number(),
19082
- y: number()
19083
- });
19084
- /** A camera detection zone — pure geometry/identity. */
19085
- var ZoneSchema = object({
19086
- id: string(),
19087
- name: string(),
19088
- kind: ZoneKindEnum.default("polygon"),
19089
- /** Polygon vertices, fraction of frame (0–1). */
19090
- polygon: array(PolygonPointSchema).readonly(),
19091
- /** Visual color for UI rendering. */
19092
- color: string().default("#3b82f6")
19337
+ ]),
19338
+ configuredFps: number(),
19339
+ actualFps: number(),
19340
+ queueDepth: number(),
19341
+ avgInferenceTimeMs: number(),
19342
+ droppedFrames: number(),
19343
+ phase: _enum([
19344
+ "idle",
19345
+ "watching",
19346
+ "active"
19347
+ ])
19093
19348
  });
19094
- /**
19095
- * Zones capability — per-camera CRUD over polygon detection zones.
19096
- *
19097
- * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
19098
- * to per-device settings and mirrors into the `zones` device-state
19099
- * slice on every mutation, so downstream consumers can subscribe via
19100
- * `dev.state.zones.onChanged`.
19101
- *
19102
- * The cap surface only handles geometry + identity; filtering
19103
- * behaviour (per-class, include/exclude, threshold) lives in the
19104
- * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
19105
- * `capabilities/schemas/zone-rule.js`.
19106
- */
19107
- var zonesCapability = {
19108
- name: "zones",
19109
- scope: "device",
19110
- mode: "singleton",
19111
- deviceTypes: [DeviceType.Camera],
19112
- methods: {
19113
- listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
19114
- addZone: method(object({
19115
- deviceId: number(),
19116
- zone: ZoneSchema
19117
- }), _void(), {
19118
- kind: "mutation",
19119
- auth: "admin"
19120
- }),
19121
- removeZone: method(object({
19122
- deviceId: number(),
19123
- zoneId: string()
19124
- }), _void(), {
19125
- kind: "mutation",
19126
- auth: "admin"
19127
- }),
19128
- updateZone: method(object({
19129
- deviceId: number(),
19130
- zone: ZoneSchema
19131
- }), _void(), {
19132
- kind: "mutation",
19133
- auth: "admin"
19134
- })
19135
- },
19136
- /**
19137
- * Runtime-state slice — the live zone catalogue mirrored by the
19138
- * orchestrator on every CRUD mutation. Consumers read via
19139
- * `device.state.zones.value` / `.watch(...)` without round-tripping
19140
- * the cap, and the codegen DeviceProxy auto-wires the reactive
19141
- * handle. Slice shape is `{ zones: Zone[] }` so future extensions
19142
- * (e.g. zone groupings) can sit alongside the polygon list.
19143
- */
19144
- runtimeState: object({ zones: array(ZoneSchema).readonly() }),
19145
- /**
19146
- * 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.
19147
- *
19148
- * See `RuntimeStateDurability`. Enforced by
19149
- * `scripts/check-runtime-state-durability.ts`.
19150
- */
19151
- durability: "restored"
19152
- };
19349
+ var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
19153
19350
  /**
19154
19351
  * A bounding box in NORMALIZED [0,1] frame coordinates for `getNativeCrop`. The
19155
19352
  * decode worker resolves it against the RETAINED native frame's real pixel dims,
@@ -20838,7 +21035,7 @@ method(object({
20838
21035
  * linking rather than produce an eternal token.
20839
21036
  */
20840
21037
  ttlSec: union([number().int().positive(), literal("never")]).optional()
20841
- }), object({ token: string() })), method(object({ token: string() }), SsoBridgeClaimsSchema.nullable());
21038
+ }), object({ token: string() }), { auth: "admin" }), method(object({ token: string() }), SsoBridgeClaimsSchema.nullable(), { auth: "admin" });
20842
21039
  var ProviderListEntrySchema = discriminatedUnion("shouldSaveDiskSpace", [object({
20843
21040
  providerId: string().min(1),
20844
21041
  displayName: string().min(1),
@@ -20933,10 +21130,13 @@ var EvictResultSchema = object({
20933
21130
  /** True when the provider has nothing left it is willing to drop on this location. */
20934
21131
  exhausted: boolean()
20935
21132
  });
20936
- method(object({ locationId: string() }), EvictableUsageSchema), method(object({
21133
+ method(object({ locationId: string() }), EvictableUsageSchema, { auth: "admin" }), method(object({
20937
21134
  locationId: string(),
20938
21135
  targetBytes: number().int().positive()
20939
- }), EvictResultSchema, { kind: "mutation" });
21136
+ }), EvictResultSchema, {
21137
+ kind: "mutation",
21138
+ auth: "admin"
21139
+ });
20940
21140
  method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin" }), method(StorageMigrationInputSchema, object({ jobId: string() }), {
20941
21141
  kind: "mutation",
20942
21142
  auth: "admin"
@@ -20996,26 +21196,50 @@ var ReadChunkInputSchema = object({
20996
21196
  length: number()
20997
21197
  });
20998
21198
  var EndDownloadInputSchema = object({ downloadId: string() });
20999
- method(_void(), ProviderInfoSchema), method(object({ config: record(string(), unknown()) }), TestLocationResultSchema, { auth: "admin" }), method(object({
21199
+ method(_void(), ProviderInfoSchema, { auth: "admin" }), method(object({ config: record(string(), unknown()) }), TestLocationResultSchema, { auth: "admin" }), method(object({
21000
21200
  location: StorageLocationSchema,
21001
21201
  relativePath: string()
21002
- }), string()), method(object({
21202
+ }), string(), { auth: "admin" }), method(object({
21003
21203
  location: StorageLocationSchema,
21004
21204
  relativePath: string(),
21005
21205
  data: _instanceof(Uint8Array)
21006
- }), _void(), { kind: "mutation" }), method(object({
21206
+ }), _void(), {
21207
+ kind: "mutation",
21208
+ auth: "admin"
21209
+ }), method(object({
21007
21210
  location: StorageLocationSchema,
21008
21211
  relativePath: string()
21009
- }), _instanceof(Uint8Array)), method(object({
21212
+ }), _instanceof(Uint8Array), { auth: "admin" }), method(object({
21010
21213
  location: StorageLocationSchema,
21011
21214
  relativePath: string()
21012
- }), boolean()), method(object({
21215
+ }), boolean(), { auth: "admin" }), method(object({
21013
21216
  location: StorageLocationSchema,
21014
21217
  prefix: string().optional()
21015
- }), array(string()).readonly()), method(object({
21218
+ }), array(string()).readonly(), { auth: "admin" }), method(object({
21016
21219
  location: StorageLocationSchema,
21017
21220
  relativePath: string()
21018
- }), _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" });
21221
+ }), _void(), {
21222
+ kind: "mutation",
21223
+ auth: "admin"
21224
+ }), method(object({ location: StorageLocationSchema }), number().nullable(), { auth: "admin" }), method(BeginUploadInputSchema, BeginUploadResultSchema, {
21225
+ kind: "mutation",
21226
+ auth: "admin"
21227
+ }), method(WriteChunkInputSchema, _void(), {
21228
+ kind: "mutation",
21229
+ auth: "admin"
21230
+ }), method(FinalizeUploadInputSchema, _void(), {
21231
+ kind: "mutation",
21232
+ auth: "admin"
21233
+ }), method(AbortUploadInputSchema, _void(), {
21234
+ kind: "mutation",
21235
+ auth: "admin"
21236
+ }), method(BeginDownloadInputSchema, BeginDownloadResultSchema, {
21237
+ kind: "mutation",
21238
+ auth: "admin"
21239
+ }), method(ReadChunkInputSchema, _instanceof(Uint8Array), { auth: "admin" }), method(EndDownloadInputSchema, _void(), {
21240
+ kind: "mutation",
21241
+ auth: "admin"
21242
+ });
21019
21243
  /** Profile-exported FormBuilder schema. Shape is ConfigUISchema at the UI. */
21020
21244
  var ProfileSettingsSchemaBridge = unknown().nullable();
21021
21245
  var ProfileSettingsBagSchema = record(string(), unknown());
@@ -21273,7 +21497,8 @@ method(object({
21273
21497
  access: "create"
21274
21498
  }), method(object({ userId: string().optional() }), object({ optionsJSON: record(string(), unknown()) }), {
21275
21499
  kind: "mutation",
21276
- access: "view"
21500
+ access: "view",
21501
+ auth: "admin"
21277
21502
  }), method(object({
21278
21503
  /** Required — the user the assertion belongs to (verified). */
21279
21504
  userId: string(),
@@ -21281,10 +21506,12 @@ method(object({
21281
21506
  response: record(string(), unknown())
21282
21507
  }), object({ verified: boolean() }), {
21283
21508
  kind: "mutation",
21284
- access: "view"
21509
+ access: "view",
21510
+ auth: "admin"
21285
21511
  }), method(object({}), object({ optionsJSON: record(string(), unknown()) }), {
21286
21512
  kind: "mutation",
21287
- access: "view"
21513
+ access: "view",
21514
+ auth: "admin"
21288
21515
  }), method(object({
21289
21516
  /** AuthenticationResponseJSON from the browser. */
21290
21517
  response: record(string(), unknown()) }), object({
@@ -21292,7 +21519,8 @@ response: record(string(), unknown()) }), object({
21292
21519
  userId: string().nullable()
21293
21520
  }), {
21294
21521
  kind: "mutation",
21295
- access: "view"
21522
+ access: "view",
21523
+ auth: "admin"
21296
21524
  }), method(object({ userId: string() }), array(PasskeySummarySchema), { auth: "admin" }), method(object({
21297
21525
  userId: string(),
21298
21526
  credentialId: string()
@@ -21464,7 +21692,19 @@ var VectorStatsResultSchema = object({
21464
21692
  /** False when the backend ranks approximately. */
21465
21693
  exact: boolean()
21466
21694
  });
21467
- 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);
21695
+ method(VectorDeclareIndexInputSchema, _void(), {
21696
+ kind: "mutation",
21697
+ auth: "admin"
21698
+ }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
21699
+ kind: "mutation",
21700
+ auth: "admin"
21701
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
21702
+ kind: "mutation",
21703
+ auth: "admin"
21704
+ }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
21705
+ kind: "mutation",
21706
+ auth: "admin"
21707
+ }), method(VectorStatsInputSchema, VectorStatsResultSchema, { auth: "admin" });
21468
21708
  var ClipSchema = object({
21469
21709
  /** Opaque, provider-namespaced id. The default provider encodes the time
21470
21710
  * window so `getClipPlayback` is self-contained (no event re-query). */
@@ -23917,7 +24157,27 @@ var MediaFileLiteSchema$1 = object({
23917
24157
  sizeBytes: number(),
23918
24158
  timestamp: number()
23919
24159
  });
23920
- method(_void(), array(IdentitySchema).readonly()), method(object({ name: string().min(1) }), IdentitySchema, {
24160
+ method(object({
24161
+ /**
24162
+ * Inline {@link IdentitySchema.coverBase64} on every row.
24163
+ *
24164
+ * Default `false`, the same inversion `listRecentFaces` and
24165
+ * `listPlates` took on 2026-08-25 (see `include-crops-default.ts` for
24166
+ * why the burden belongs on the caller that WANTS the bytes). Measured
24167
+ * on the live hub the same day: four identities cost 40,979 B with the
24168
+ * covers inline, ~10 KB of base64 per row, on a query this UI mounts
24169
+ * four times and the viewer holds at `staleTime: 30_000`.
24170
+ *
24171
+ * Nothing loses its avatar: `coverMediaKey` is already on every row and
24172
+ * the `event-media` plane serves that key `immutable` with an ETag.
24173
+ *
24174
+ * **This is an INPUT field, so it does not reach the addon until the
24175
+ * next train** — the hub router validates cap inputs against its own
24176
+ * compiled Zod and strips a key it does not know. Until then the
24177
+ * provider sees `undefined`, which resolves to `false`: the cheap shape
24178
+ * is what ships, and the opt-in becomes reachable when the train lands.
24179
+ */
24180
+ includeCrops: boolean().optional() }).optional(), array(IdentitySchema).readonly()), method(object({ name: string().min(1) }), IdentitySchema, {
23921
24181
  kind: "mutation",
23922
24182
  auth: "admin"
23923
24183
  }), method(object({
@@ -26807,8 +27067,10 @@ var PlateInfoSchema = object({
26807
27067
  keyFrameMediaKey: string().optional(),
26808
27068
  base64: string().optional(),
26809
27069
  /**
26810
- * Same crop as a data-plane URL. `getPlateByTrack` returns this and
26811
- * never inlines JPEG; `listPlates` still inlines for the admin-ui.
27070
+ * Same crop as a data-plane URL, always present when the plate has a stored
27071
+ * crop. `getPlateByTrack` returns this and never inlines JPEG; `listPlates`
27072
+ * and `searchPlates` inline the crop only when their `includeCrops` input is
27073
+ * left at its `true` default.
26812
27074
  */
26813
27075
  cropUrl: string().optional()
26814
27076
  });
@@ -26828,14 +27090,34 @@ var PlateClusterSchema = object({
26828
27090
  });
26829
27091
  method(object({
26830
27092
  deviceId: number().int().optional(),
26831
- limit: number().int().positive().optional()
27093
+ limit: number().int().positive().optional(),
27094
+ /**
27095
+ * Inline the base64 crop on every row. Default `true` — the existing
27096
+ * behaviour, kept so no caller breaks.
27097
+ *
27098
+ * Set `false` once the caller renders {@link PlateInfo.cropUrl}.
27099
+ * Measured on the live hub at the 500 rows the Plates view asks for:
27100
+ * 879,403 B and 27.7 s with the crops inline, against a few KiB of
27101
+ * metadata without them — and the browser then caches the images.
27102
+ *
27103
+ * This is the plate twin of `faceGallery.listRecentFaces`'s option;
27104
+ * plates were the one gallery list left without it.
27105
+ *
27106
+ * **This is an INPUT field, so it does not reach the addon until the
27107
+ * next train.** The hub router validates cap inputs against its own
27108
+ * compiled Zod and strips a key it does not know. Until the train
27109
+ * ships, sending `false` is harmless and keeps the crops inline.
27110
+ */
27111
+ includeCrops: boolean().optional()
26832
27112
  }).optional(), array(PlateInfoSchema).readonly()), method(object({
26833
27113
  deviceId: number().int(),
26834
27114
  trackId: string()
26835
27115
  }), PlateInfoSchema.nullable()), method(object({ plateId: string() }), array(MediaFileLiteSchema).readonly()), method(object({
26836
27116
  text: string().min(1),
26837
27117
  maxDistance: number().int().min(0).optional(),
26838
- limit: number().int().positive().optional()
27118
+ limit: number().int().positive().optional(),
27119
+ /** See `listPlates.includeCrops`. Default `true`. */
27120
+ includeCrops: boolean().optional()
26839
27121
  }), array(PlateInfoSchema).readonly()), method(object({
26840
27122
  maxDistance: number().int().min(0).optional(),
26841
27123
  minClusterSize: number().int().min(2).optional(),
@@ -26849,7 +27131,13 @@ method(object({
26849
27131
  }), method(object({ plateId: string() }), _void(), {
26850
27132
  kind: "mutation",
26851
27133
  auth: "admin"
26852
- }), method(_void(), array(VehicleSchema).readonly()), method(object({ name: string().min(1) }), VehicleSchema, {
27134
+ }), method(object({
27135
+ /** Inline {@link VehicleSchema.coverBase64} on every row. Default
27136
+ * `false` — the vehicle twin of `faceGallery.listIdentities`'s
27137
+ * option; `coverMediaKey` + the `event-media` plane carry the picture.
27138
+ * INPUT field: stripped by the hub router until the train ships, which
27139
+ * resolves to `false` and is exactly the intended default. */
27140
+ includeCrops: boolean().optional() }).optional(), array(VehicleSchema).readonly()), method(object({ name: string().min(1) }), VehicleSchema, {
26853
27141
  kind: "mutation",
26854
27142
  auth: "admin"
26855
27143
  }), method(object({
@@ -28370,92 +28658,6 @@ var sceneMonitorCapability = {
28370
28658
  durability: "session"
28371
28659
  };
28372
28660
  /**
28373
- * Per-stage gating mode applied to the zones a rule references.
28374
- *
28375
- * - `include`: the rule contributes to a **whitelist** for its stage.
28376
- * When at least one `include` rule fires for a stage, only entities
28377
- * inside one of those zones pass that stage.
28378
- * - `exclude`: the rule contributes to a **blacklist** for its stage.
28379
- * Entities inside one of those zones are dropped at that stage.
28380
- *
28381
- * `monitor`-style observation (count without filtering) is not a rule
28382
- * mode — zones without any matching rule are observed naturally by
28383
- * `zone-analytics` (live snapshot + history), so an "I just want to
28384
- * count, not filter" use case needs no rule at all.
28385
- */
28386
- var ZoneRuleModeEnum = _enum(["include", "exclude"]);
28387
- /**
28388
- * Per-consumer rule that references existing zones (geometry) and
28389
- * defines how a specific pipeline stage should treat them. Each
28390
- * consumer addon owns its own `ZoneRule[]` array in its per-device
28391
- * settings:
28392
- *
28393
- * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
28394
- * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
28395
- * - future: notification rules, audio gating, etc.
28396
- *
28397
- * One rule applies to N zones (`zoneIds[]`) so the operator can
28398
- * express "ignore motion in ALL of {garden, street}" with a single
28399
- * rule. `classFilter` narrows the rule to specific object classes —
28400
- * "drop person detections in the street, but keep cars" is one
28401
- * `exclude` rule with `classFilter: ['person']`.
28402
- *
28403
- * `enabled` is a soft toggle — the operator can keep the rule
28404
- * configured but inert without deleting it.
28405
- */
28406
- var ZoneRuleSchema = object({
28407
- /** Stable rule id — survives edits, used by the UI for diffing. */
28408
- id: string(),
28409
- /** Optional human-readable label rendered in the rule editor. */
28410
- name: string().optional(),
28411
- /** Zones this rule targets. The rule's `mode` applies to ALL
28412
- * listed zones (OR-set: a detection in any one of them counts).
28413
- * At least one zone id required — a rule with no targets is a
28414
- * configuration mistake and the form validator rejects it. */
28415
- zoneIds: array(string()).min(1).readonly(),
28416
- mode: ZoneRuleModeEnum,
28417
- /**
28418
- * Class names this rule applies to. Empty / undefined ⇒ rule
28419
- * applies to every class. Class strings match the `macroClass`
28420
- * field on detections (e.g. `person`, `car`, `dog`).
28421
- */
28422
- classFilter: array(string()).readonly().optional(),
28423
- /**
28424
- * Minimum bbox/mask overlap (0–1) with any of the rule's zones
28425
- * required to consider an entity "in the zone". Defaults to the
28426
- * consumer's stage default when omitted. Kept for back-compat with
28427
- * existing per-rule overrides; new operators pick the value via
28428
- * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
28429
- * set, the lower-level engine reads it as a 0–1 fraction.
28430
- */
28431
- overlapThreshold: number().min(0).max(1).optional(),
28432
- /**
28433
- * Operator-friendly version of `overlapThreshold` — the percentage
28434
- * of the detection's bbox that must lie inside the zone for the
28435
- * rule to match. Documented default is 85%; the engine substitutes
28436
- * that when the field is omitted (kept optional so existing rules
28437
- * stored without it stay valid).
28438
- *
28439
- * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
28440
- * rule, the engine prefers `bboxInclusionPct` because it's the
28441
- * field exposed in the UI. Internally both feed the same gate.
28442
- */
28443
- bboxInclusionPct: number().min(0).max(100).optional(),
28444
- /**
28445
- * When `true` and a detection has a segmentation mask, use the
28446
- * mask for overlap instead of the bbox. Detection-stage only;
28447
- * motion rules ignore this field.
28448
- */
28449
- preferMask: boolean().optional(),
28450
- /**
28451
- * Soft-toggle: `false` disables the rule without deleting it.
28452
- * Defaults to `true` so operators creating a rule via the UI
28453
- * see it active immediately.
28454
- */
28455
- enabled: boolean().default(true)
28456
- });
28457
- array(ZoneRuleSchema).readonly();
28458
- /**
28459
28661
  * Script-runner cap. Models HA `script.*` entities on
28460
28662
  * `DeviceType.Script`. A Script is a pre-recorded action sequence
28461
28663
  * that can be invoked imperatively — optionally with a variables
@@ -34110,6 +34312,12 @@ Object.freeze({
34110
34312
  addonId: null,
34111
34313
  access: "create"
34112
34314
  },
34315
+ "pipelineAnalytics.cancelRelocateMedia": {
34316
+ capName: "pipeline-analytics",
34317
+ capScope: "device",
34318
+ addonId: null,
34319
+ access: "create"
34320
+ },
34113
34321
  "pipelineAnalytics.cancelStorageMigrationMove": {
34114
34322
  capName: "pipeline-analytics",
34115
34323
  capScope: "device",
@@ -34284,6 +34492,12 @@ Object.freeze({
34284
34492
  addonId: null,
34285
34493
  access: "view"
34286
34494
  },
34495
+ "pipelineAnalytics.listRelocateMediaJobs": {
34496
+ capName: "pipeline-analytics",
34497
+ capScope: "device",
34498
+ addonId: null,
34499
+ access: "view"
34500
+ },
34287
34501
  "pipelineAnalytics.listRetrainAnnotations": {
34288
34502
  capName: "pipeline-analytics",
34289
34503
  capScope: "device",
@@ -34362,6 +34576,12 @@ Object.freeze({
34362
34576
  addonId: null,
34363
34577
  access: "create"
34364
34578
  },
34579
+ "pipelineAnalytics.relocateMedia": {
34580
+ capName: "pipeline-analytics",
34581
+ capScope: "device",
34582
+ addonId: null,
34583
+ access: "create"
34584
+ },
34365
34585
  "pipelineAnalytics.restageRetrainTrack": {
34366
34586
  capName: "pipeline-analytics",
34367
34587
  capScope: "device",
@@ -34374,6 +34594,12 @@ Object.freeze({
34374
34594
  addonId: null,
34375
34595
  access: "create"
34376
34596
  },
34597
+ "pipelineAnalytics.runReplayFrameProcessor": {
34598
+ capName: "pipeline-analytics",
34599
+ capScope: "device",
34600
+ addonId: null,
34601
+ access: "create"
34602
+ },
34377
34603
  "pipelineAnalytics.saveRetrainAnnotations": {
34378
34604
  capName: "pipeline-analytics",
34379
34605
  capScope: "device",
@@ -34506,6 +34732,12 @@ Object.freeze({
34506
34732
  addonId: null,
34507
34733
  access: "view"
34508
34734
  },
34735
+ "pipelineExecutor.getInferenceDeviceHealth": {
34736
+ capName: "pipeline-executor",
34737
+ capScope: "system",
34738
+ addonId: null,
34739
+ access: "view"
34740
+ },
34509
34741
  "pipelineExecutor.getOrchestratorConfigSchema": {
34510
34742
  capName: "pipeline-executor",
34511
34743
  capScope: "system",
@@ -34578,6 +34810,12 @@ Object.freeze({
34578
34810
  addonId: null,
34579
34811
  access: "view"
34580
34812
  },
34813
+ "pipelineExecutor.rearmInferenceDevice": {
34814
+ capName: "pipeline-executor",
34815
+ capScope: "system",
34816
+ addonId: null,
34817
+ access: "create"
34818
+ },
34581
34819
  "pipelineExecutor.runAudioTest": {
34582
34820
  capName: "pipeline-executor",
34583
34821
  capScope: "system",
@@ -37826,6 +38064,11 @@ Object.freeze({
37826
38064
  form: "single",
37827
38065
  optional: false
37828
38066
  }],
38067
+ "pipelineAnalytics.runReplayFrameProcessor": [{
38068
+ name: "deviceId",
38069
+ form: "single",
38070
+ optional: false
38071
+ }],
37829
38072
  "pipelineAnalytics.saveRetrainAnnotations": [{
37830
38073
  name: "deviceId",
37831
38074
  form: "single",