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