@camstack/addon-provider-amcrest 0.2.29 → 0.2.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/addon.js +2135 -1892
  2. package/dist/addon.mjs +2135 -1892
  3. package/package.json +1 -1
package/dist/addon.mjs CHANGED
@@ -6636,7 +6636,7 @@ function method(input, output, options) {
6636
6636
  input,
6637
6637
  output,
6638
6638
  kind: options?.kind ?? "query",
6639
- auth: options?.auth ?? "protected",
6639
+ ...options?.auth !== void 0 ? { auth: options.auth } : {},
6640
6640
  ...options?.access !== void 0 ? { access: options.access } : {},
6641
6641
  ...options?.caller !== void 0 ? { caller: options.caller } : {},
6642
6642
  timeoutMs: options?.timeoutMs
@@ -6660,7 +6660,7 @@ function event(data) {
6660
6660
  }
6661
6661
  var StaticDirOutputSchema$1 = object({ staticDir: string() });
6662
6662
  var VersionOutputSchema$1 = object({ version: string() });
6663
- method(_void(), StaticDirOutputSchema$1), method(_void(), VersionOutputSchema$1);
6663
+ method(_void(), StaticDirOutputSchema$1, { auth: "admin" }), method(_void(), VersionOutputSchema$1, { auth: "admin" });
6664
6664
  var DeviceType = /* @__PURE__ */ function(DeviceType) {
6665
6665
  DeviceType["Camera"] = "camera";
6666
6666
  DeviceType["Hub"] = "hub";
@@ -6981,7 +6981,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
6981
6981
  }({});
6982
6982
  var StaticDirOutputSchema = object({ staticDir: string() });
6983
6983
  var VersionOutputSchema = object({ version: string() });
6984
- method(_void(), StaticDirOutputSchema), method(_void(), VersionOutputSchema);
6984
+ method(_void(), StaticDirOutputSchema, { auth: "admin" }), method(_void(), VersionOutputSchema, { auth: "admin" });
6985
6985
  /**
6986
6986
  * device-ops — device-scoped cap that unifies the per-IDevice operations
6987
6987
  * previously routed through the `.device-ops` Moleculer bridge service.
@@ -7595,24 +7595,6 @@ var RecordingRetentionSchema = object({
7595
7595
  maxSizeGb: number().min(0).optional()
7596
7596
  });
7597
7597
  /**
7598
- * Scrub-thumbnail fidelity preset — the single per-camera selector bundling the
7599
- * sprite tile RESOLUTION + JPEG QUALITY the recorder packs timeline-scrub
7600
- * previews at. Five graduated steps; absent on a config = `standard` (the
7601
- * shipped default, matching `sheet-geometry`/`sheet-composer`).
7602
- *
7603
- * Existing sheets are IMMUTABLE — a changed preset applies to NEW windows only.
7604
- * Each window's index sidecar carries its own tile dims, so a camera whose
7605
- * preset changed over time renders every historical window at the dims it was
7606
- * written with.
7607
- */
7608
- var ScrubThumbnailPresetSchema = _enum([
7609
- "minimal",
7610
- "low",
7611
- "standard",
7612
- "high",
7613
- "max"
7614
- ]);
7615
- /**
7616
7598
  * The full per-camera recording intent — the wire shape of a RecordingTarget.
7617
7599
  *
7618
7600
  * `bands` is the ONLY authored recording intent: what to record, when, and on
@@ -7620,7 +7602,11 @@ var ScrubThumbnailPresetSchema = _enum([
7620
7602
  * other field is a storage knob (profiles, segment length, retention, scrub).
7621
7603
  *
7622
7604
  * STRICT on purpose: the legacy authoring surface (`schedule`/`schedules`/
7623
- * `triggers`/`preBufferSec`/`postBufferSec`/`rules`) was retired 2026-07-30.
7605
+ * `triggers`/`preBufferSec`/`postBufferSec`/`rules`) was retired 2026-07-30,
7606
+ * and `scrubThumbnails` — a five-step fidelity knob for a sprite tier that was
7607
+ * deleted on 2026-07-24 and had ZERO consumers in the recorder — on 2026-08-25
7608
+ * (D62: a switch that writes a store nobody reads is worse than no switch).
7609
+ * Stored rows keep loading: the READ schema is `.strip()` (config-store.ts).
7624
7610
  * A stale caller must fail loudly — silently stripping its legacy intent would
7625
7611
  * persist a band-less config, i.e. silently stop recording the camera.
7626
7612
  */
@@ -7643,14 +7629,7 @@ var RecordingConfigSchema = object({
7643
7629
  * "off" is the absence of a covering band, never a band value.
7644
7630
  */
7645
7631
  bands: array(RecordingBandSchema).default([]),
7646
- retention: RecordingRetentionSchema.optional(),
7647
- /**
7648
- * Per-camera scrub-thumbnail fidelity preset (resolution + JPEG quality for
7649
- * timeline-scrub sprite previews). Absent = `standard`. Applies to NEW
7650
- * windows only — existing sheets are immutable, and each window's index
7651
- * carries its own tile dims so mixed-preset history renders correctly.
7652
- */
7653
- scrubThumbnails: ScrubThumbnailPresetSchema.optional()
7632
+ retention: RecordingRetentionSchema.optional()
7654
7633
  }).strict();
7655
7634
  /**
7656
7635
  * Entity-relocation job state (storage entity-routing spec, Phase 4).
@@ -7726,10 +7705,11 @@ var RelocateFootageInputSchema = object({
7726
7705
  * `RecordingConfig.enabled` or camera wrapper bindings. */
7727
7706
  var StorageMigrationLeaseInputSchema = object({ leaseId: string().min(1) });
7728
7707
  var StorageMigrationFootageMoveInputSchema = RelocateFootageInputSchema.extend({ leaseId: string().min(1) });
7729
- var StorageMigrationMediaMoveInputSchema = object({
7708
+ var RelocateMediaInputSchema = object({
7730
7709
  toLocationId: string(),
7731
7710
  throttleMbps: number().min(1).max(1e3).optional()
7732
- }).extend({ leaseId: string().min(1) });
7711
+ });
7712
+ var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
7733
7713
  /** The independently selectable logical storage classes. `recordings`
7734
7714
  * encompasses the high and mid segment profiles; `recordingsLow` is low
7735
7715
  * segments; `eventMedia` is post-analysis blobs. */
@@ -8024,7 +8004,26 @@ var LabelDefinitionSchema = object({
8024
8004
  description: string().optional(),
8025
8005
  icon: string().optional()
8026
8006
  });
8027
- var ClassMapDefinitionSchema = object({
8007
+ /**
8008
+ * Wire schema for a per-model CATALOG classMap override
8009
+ * (`ModelCatalogEntry.classMap` / `ModelConvertMetadata.classMap`) —
8010
+ * restricted to {@link CLASS_MAP_MACRO_TARGETS}, the only macros the
8011
+ * detection pipeline executor actually routes.
8012
+ *
8013
+ * This is deliberately a DIFFERENT, narrower shape than the general-purpose
8014
+ * `ClassMapDefinition` interface above (e.g. `IDetectionAddon.getClassMap()`
8015
+ * and the audio `YAMNET_TO_MACRO` catalog both use macro targets outside this
8016
+ * enum) — the two used to share the name `ClassMapDefinition`/
8017
+ * `ClassMapDefinitionSchema`, which made the schema-type-twin guard
8018
+ * (`scripts/check-schema-type-twins.ts`) flag them as a duplicated shape. They
8019
+ * are not: it is two different concepts colliding on a name. Keep this type
8020
+ * under its own name rather than reusing `ClassMapDefinition` — reusing it
8021
+ * would either narrow every `ClassMapDefinition` consumer to the four
8022
+ * detection macros (breaking `YAMNET_TO_MACRO`) or drop the validation this
8023
+ * schema exists for (see the "rejects a classMap whose target is not a
8024
+ * detection macro" test in `model-catalog-schema.test.ts`).
8025
+ */
8026
+ var DetectionCatalogClassMapSchema = object({
8028
8027
  mapping: record(string(), _enum([
8029
8028
  "person",
8030
8029
  "vehicle",
@@ -8229,7 +8228,7 @@ var ModelCatalogEntrySchema = object({
8229
8228
  * applies (Frigate / COCO public catalog). Set on a custom model whose raw
8230
8229
  * labels already ARE the CamStack macros (Scrypted identity map).
8231
8230
  */
8232
- classMap: ClassMapDefinitionSchema.optional()
8231
+ classMap: DetectionCatalogClassMapSchema.optional()
8233
8232
  });
8234
8233
  var ConvertTargetSchema = discriminatedUnion("format", [object({
8235
8234
  format: literal("openvino"),
@@ -8259,7 +8258,7 @@ var ModelConvertMetadataSchema = object({
8259
8258
  "segmentation"
8260
8259
  ]),
8261
8260
  faceAlignment: boolean().optional(),
8262
- classMap: ClassMapDefinitionSchema.optional()
8261
+ classMap: DetectionCatalogClassMapSchema.optional()
8263
8262
  });
8264
8263
  var ConvertResultSchema = object({
8265
8264
  entry: ModelCatalogEntrySchema,
@@ -9122,7 +9121,7 @@ var AddonPageDeclarationSchema = object({
9122
9121
  /** Display label for a CUSTOM `section` id (ignored for well-known ids). */
9123
9122
  sectionLabel: string().optional()
9124
9123
  });
9125
- method(_void(), array(AddonPageDeclarationSchema).readonly());
9124
+ method(_void(), array(AddonPageDeclarationSchema).readonly(), { auth: "admin" });
9126
9125
  var AddonHttpRouteSchema = object({
9127
9126
  method: _enum([
9128
9127
  "GET",
@@ -9357,7 +9356,7 @@ var WidgetMetadataSchema = object({
9357
9356
  defaultColumns: number().int().min(1).max(12).default(6),
9358
9357
  defaultRows: number().int().min(1).max(12).default(1)
9359
9358
  });
9360
- method(_void(), array(WidgetMetadataSchema).readonly());
9359
+ method(_void(), array(WidgetMetadataSchema).readonly(), { auth: "admin" });
9361
9360
  /**
9362
9361
  * `addon-widgets` — system-scoped singleton aggregator cap. Public-facing
9363
9362
  * surface that admin-ui consumes through `useAddonWidgetsListWidgets()`.
@@ -10981,7 +10980,7 @@ var CustomModelDescriptorSchema = object({
10981
10980
  stepId: string(),
10982
10981
  entry: ModelCatalogEntrySchema
10983
10982
  });
10984
- method(_void(), array(CustomModelDescriptorSchema).readonly());
10983
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
10985
10984
  /**
10986
10985
  * Query filter for settings-store collections.
10987
10986
  */
@@ -11068,7 +11067,8 @@ method(object({
11068
11067
  }), _void(), { kind: "mutation" }), method(object({
11069
11068
  namespace: string().optional(),
11070
11069
  collection: string(),
11071
- filter: QueryFilterSchema.optional()
11070
+ filter: QueryFilterSchema.optional(),
11071
+ columns: array(string()).readonly().optional()
11072
11072
  }), array(SettingsRecordSchema).readonly()), method(object({
11073
11073
  namespace: string().optional(),
11074
11074
  collection: string(),
@@ -11131,46 +11131,87 @@ var EngineInfoSchema = object({
11131
11131
  kind: _enum(["relational", "vector"]),
11132
11132
  displayName: string()
11133
11133
  });
11134
- method(_void(), EngineInfoSchema), method(object({
11134
+ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
11135
11135
  namespace: string().optional(),
11136
11136
  collection: string(),
11137
11137
  key: string()
11138
- }), unknown()), method(object({
11138
+ }), unknown(), { auth: "admin" }), method(object({
11139
11139
  namespace: string().optional(),
11140
11140
  collection: string(),
11141
11141
  key: string(),
11142
11142
  value: unknown()
11143
- }), _void(), { kind: "mutation" }), method(object({
11143
+ }), _void(), {
11144
+ kind: "mutation",
11145
+ auth: "admin"
11146
+ }), method(object({
11144
11147
  namespace: string().optional(),
11145
11148
  collection: string(),
11146
- filter: QueryFilterSchema.optional()
11147
- }), array(SettingsRecordSchema).readonly()), method(object({
11149
+ filter: QueryFilterSchema.optional(),
11150
+ /**
11151
+ * SQL-level column projection — MUST mirror `settings-store.query`.
11152
+ *
11153
+ * ⚠ An earlier version of this comment blamed Zod stripping, and that
11154
+ * was wrong — corrected 2026-08-26 after the hop map
11155
+ * (`docs/design/2026-08-26-mappa-hop-argomenti.md`) traced the path.
11156
+ * There is **no Zod parse at all** between the door and the engine: the
11157
+ * dispatcher forwards the payload verbatim and UDS carries it whole. A
11158
+ * field declared here reaches `SqliteSettingsBackend` either way.
11159
+ *
11160
+ * What actually lost `columns` was the THIRD declaration of this shape:
11161
+ * `SettingsQueryInput` in `interfaces/storage.ts`, a hand-written TS
11162
+ * interface the engine destructures from. The field existed on both
11163
+ * schemas and the engine still never read it, because nothing checks a
11164
+ * registered provider against `InferProvider<cap>` —
11165
+ * `ProviderRegistration.provider` is typed `object`.
11166
+ *
11167
+ * It is declared here anyway, and must stay in step with
11168
+ * `settings-store.query`: a caller reading only the cap definitions has
11169
+ * to be able to see that this call carries a projection.
11170
+ * `data-door-schema-parity.spec.ts` keeps the two aligned.
11171
+ */
11172
+ columns: array(string()).readonly().optional()
11173
+ }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
11148
11174
  namespace: string().optional(),
11149
11175
  collection: string(),
11150
11176
  record: SettingsRecordSchema
11151
- }), _void(), { kind: "mutation" }), method(object({
11177
+ }), _void(), {
11178
+ kind: "mutation",
11179
+ auth: "admin"
11180
+ }), method(object({
11152
11181
  namespace: string().optional(),
11153
11182
  collection: string(),
11154
11183
  id: string(),
11155
11184
  data: record(string(), unknown())
11156
- }), _void(), { kind: "mutation" }), method(object({
11185
+ }), _void(), {
11186
+ kind: "mutation",
11187
+ auth: "admin"
11188
+ }), method(object({
11157
11189
  namespace: string().optional(),
11158
11190
  collection: string(),
11159
11191
  key: string()
11160
- }), _void(), { kind: "mutation" }), method(object({
11192
+ }), _void(), {
11193
+ kind: "mutation",
11194
+ auth: "admin"
11195
+ }), method(object({
11161
11196
  namespace: string().optional(),
11162
11197
  collection: string(),
11163
11198
  filter: MutationFilterSchema
11164
- }), object({ deleted: number().int() }), { kind: "mutation" }), method(object({
11199
+ }), object({ deleted: number().int() }), {
11200
+ kind: "mutation",
11201
+ auth: "admin"
11202
+ }), method(object({
11165
11203
  namespace: string().optional(),
11166
11204
  collection: string(),
11167
11205
  filter: MutationFilterSchema,
11168
11206
  data: record(string(), unknown())
11169
- }), object({ updated: number().int() }), { kind: "mutation" }), method(object({
11207
+ }), object({ updated: number().int() }), {
11208
+ kind: "mutation",
11209
+ auth: "admin"
11210
+ }), method(object({
11170
11211
  namespace: string().optional(),
11171
11212
  collection: string(),
11172
11213
  filter: QueryFilterSchema.optional()
11173
- }), number()), method(object({
11214
+ }), number(), { auth: "admin" }), method(object({
11174
11215
  namespace: string().optional(),
11175
11216
  collection: string(),
11176
11217
  field: string(),
@@ -11180,15 +11221,18 @@ method(_void(), EngineInfoSchema), method(object({
11180
11221
  }), array(object({
11181
11222
  bucket: number().int(),
11182
11223
  count: number().int()
11183
- })).readonly()), method(object({
11224
+ })).readonly(), { auth: "admin" }), method(object({
11184
11225
  namespace: string().optional(),
11185
11226
  collection: string()
11186
- }), boolean()), method(object({
11227
+ }), boolean(), { auth: "admin" }), method(object({
11187
11228
  namespace: string().optional(),
11188
11229
  collection: string(),
11189
11230
  columns: array(CollectionColumnSchema).readonly(),
11190
11231
  indexes: array(CollectionIndexSchema).readonly().optional()
11191
- }), _void(), { kind: "mutation" });
11232
+ }), _void(), {
11233
+ kind: "mutation",
11234
+ auth: "admin"
11235
+ });
11192
11236
  /**
11193
11237
  * shm ring usage stats for a `frameSink: 'shm'` decoder session —
11194
11238
  * exposed via `decoder.getShmStats` so downstream consumers can
@@ -12478,7 +12522,7 @@ method(object({
12478
12522
  crop: _instanceof(Uint8Array),
12479
12523
  width: number(),
12480
12524
  height: number()
12481
- }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
12525
+ }), EmbeddingResultSchema, { auth: "admin" }), method(object({ text: string() }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" });
12482
12526
  /**
12483
12527
  * filesystem-browse — per-node capability for browsing the node's local
12484
12528
  * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
@@ -12771,19 +12815,22 @@ method(LlmGenerateBaseInputSchema.extend({
12771
12815
  runtime: ManagedRuntimeConfigSchema,
12772
12816
  /** The managed profile's timeout, threaded by the hub provider. */
12773
12817
  timeoutMs: number().int().positive().optional()
12774
- }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
12818
+ }), LlmGenerateResultSchema, {
12819
+ kind: "mutation",
12820
+ auth: "admin"
12821
+ }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
12775
12822
  kind: "mutation",
12776
12823
  auth: "admin"
12777
12824
  }), method(object({}), _void(), {
12778
12825
  kind: "mutation",
12779
12826
  auth: "admin"
12780
- }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
12827
+ }), method(object({}), LlmRuntimeStatusSchema, { auth: "admin" }), method(object({ model: ManagedModelRefSchema }), _void(), {
12781
12828
  kind: "mutation",
12782
12829
  auth: "admin"
12783
12830
  }), method(object({ file: string() }), _void(), {
12784
12831
  kind: "mutation",
12785
12832
  auth: "admin"
12786
- }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
12833
+ }), method(object({}), array(LlmNodeModelSchema), { auth: "admin" }), method(object({}), LlmRuntimeDiskUsageSchema, { auth: "admin" });
12787
12834
  /**
12788
12835
  * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
12789
12836
  * methods concat-fan across providers; single-row methods route to ONE
@@ -16294,1748 +16341,1998 @@ var OauthIntegrationDescriptorSchema = object({
16294
16341
  */
16295
16342
  refreshTokenTtlSec: union([number().int().positive(), literal("never")]).optional()
16296
16343
  });
16297
- method(_void(), OauthIntegrationDescriptorSchema);
16344
+ method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
16298
16345
  /**
16299
- * pipeline-analytics device-scoped wrapper cap. Refines raw
16300
- * per-frame detections emitted by the pipeline runner into tracked
16301
- * objects, per-kind event collections (motion / object / audio), and
16302
- * persisted media. Owns the post-detection domain end-to-end:
16303
- *
16304
- * runner emits PipelineInferenceResult
16305
- * ↓ (event bus)
16306
- * pipeline-analytics subscriber
16307
- * ↓ SORT tracker + zone engine + state analyzer + event emitter
16308
- * → three DB collections (one per kind), one FS media tree, one
16309
- * unified event emitter (FrameTracked + TrackStarted/Ended +
16310
- * DetectionEvent on bus)
16311
- *
16312
- * Pure subscriber model. No `processFrame` cap method — the runner
16313
- * already publishes the raw frame on the bus. The cap surface is
16314
- * only QUERIES + per-device settings, bound on/off via
16315
- * `device-manager.setWrapperActive`. `defaultActive: true` because
16316
- * every camera with a detection pipeline wants its raw detections
16317
- * refined; operators opt out per-device via BindingsTab when needed.
16318
- *
16319
- * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
16320
- * (per-device surface) and `track-trail` caps — see P11 cleanup.
16346
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
16347
+ * within the frame, so the executor can re-cut a leaf child ROI at native
16348
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
16321
16349
  */
16322
- var TrackStateSchema = _enum([
16323
- "new",
16324
- "entered",
16325
- "left",
16326
- "moving",
16327
- "idle"
16328
- ]);
16329
- var EventKindSchema = _enum([
16330
- "motion",
16331
- "object",
16332
- "audio"
16333
- ]);
16350
+ var NativeCropRefSchema = object({
16351
+ /** Handle keying the retained native surface (node-pinned to its owner). */
16352
+ handle: FrameHandleSchema,
16353
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
16354
+ cropFrameSpace: object({
16355
+ x: number(),
16356
+ y: number(),
16357
+ w: number(),
16358
+ h: number()
16359
+ })
16360
+ });
16361
+ object({
16362
+ crop: object({
16363
+ left: number(),
16364
+ top: number(),
16365
+ width: number().positive(),
16366
+ height: number().positive()
16367
+ }).optional(),
16368
+ content: object({
16369
+ width: number().int().positive(),
16370
+ height: number().int().positive()
16371
+ }),
16372
+ fit: _enum(["stretch", "contain"]),
16373
+ format: _enum([
16374
+ "rgb",
16375
+ "gray",
16376
+ "jpeg"
16377
+ ])
16378
+ });
16334
16379
  /**
16335
- * Spatial filter for `listTracks` the rect + polygon variants of the shared
16336
- * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
16337
- * of the camera frame (top-left origin), matching the drawing-plane editor.
16380
+ * Process-local frame identity. It is serializable so it can ride an in-process
16381
+ * capability call, but `registryId` deliberately prevents resolution in any
16382
+ * other process or execution group.
16338
16383
  */
16339
- var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
16340
- /** Closed icon vocabulary so clients render a known glyph per kind. */
16341
- var EventKindIconSchema = _enum([
16342
- "motion",
16343
- "audio",
16344
- "person",
16345
- "vehicle",
16346
- "animal",
16347
- "door",
16348
- "pir",
16349
- "smoke",
16350
- "water",
16351
- "button",
16352
- "package",
16353
- "generic"
16384
+ var FrameRefSchema = object({
16385
+ registryId: string().min(1),
16386
+ id: string().min(1),
16387
+ width: number().int().positive(),
16388
+ height: number().int().positive(),
16389
+ format: _enum(["rgb", "gray"]),
16390
+ timestamp: number(),
16391
+ capturedAt: number().optional()
16392
+ });
16393
+ var ModelFormatSchema$1 = _enum([
16394
+ "onnx",
16395
+ "coreml",
16396
+ "openvino",
16397
+ "tflite",
16398
+ "pt",
16399
+ "gguf"
16354
16400
  ]);
16355
- var EventKindCategorySchema = _enum([
16356
- "motion",
16357
- "audio",
16358
- "detection",
16359
- "sensor",
16360
- "control",
16361
- "custom",
16362
- "package"
16401
+ var PipelineSlotSchema = _enum([
16402
+ "detector",
16403
+ "cropper",
16404
+ "classifier",
16405
+ "refiner",
16406
+ "audio-classifier"
16363
16407
  ]);
16364
- /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
16365
- var EventKindLevelSchema = _enum(["macro", "sub"]);
16366
- var EventKindDescriptorSchema = object({
16367
- /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
16368
- kind: string(),
16369
- /** i18n key resolved on the UI side; `label` is the English fallback. */
16370
- labelKey: string(),
16371
- /** English fallback label (kept for clients that don't translate). */
16372
- label: string(),
16373
- /** Hex color for timeline/legend rendering. */
16374
- color: string(),
16375
- /** Dictionary id → lucide component on the UI side. */
16376
- iconId: string(),
16377
- /** Legacy closed-vocab glyph — fallback for `iconId`. */
16378
- icon: EventKindIconSchema,
16379
- category: EventKindCategorySchema,
16380
- /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
16381
- parentKind: string().nullable(),
16382
- /** Derived from `parentKind`, explicit for the client tree. */
16383
- level: EventKindLevelSchema,
16384
- /** Which cap + device contributes this kind. For built-ins the camera
16385
- * itself; for sensor kinds the LINKED source device. */
16386
- source: object({
16387
- capName: string(),
16388
- deviceId: number()
16389
- })
16408
+ var PipelineEngineChoiceSchema = object({
16409
+ runtime: _enum(["node", "python"]),
16410
+ backend: string(),
16411
+ format: ModelFormatSchema$1,
16412
+ device: string().optional()
16390
16413
  });
16391
- /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
16392
- var EventKindsForDeviceSchema = object({
16393
- deviceId: number(),
16394
- kinds: array(EventKindDescriptorSchema).readonly()
16414
+ var AvailableEngineSchema = object({
16415
+ engine: PipelineEngineChoiceSchema,
16416
+ devices: array(object({
16417
+ id: string(),
16418
+ label: string(),
16419
+ description: string().optional()
16420
+ })).readonly(),
16421
+ defaultDevice: string()
16395
16422
  });
16396
- var SensorEventSchema = object({
16423
+ var PipelineDefaultStepSchema = lazy(() => object({
16424
+ addonId: string(),
16425
+ addonName: string(),
16426
+ slot: PipelineSlotSchema,
16427
+ inputClasses: array(string()).readonly(),
16428
+ outputClasses: array(string()).readonly(),
16429
+ enabled: boolean(),
16430
+ modelId: string(),
16431
+ children: array(PipelineDefaultStepSchema).readonly(),
16432
+ group: string().optional(),
16433
+ settings: record(string(), unknown()).optional()
16434
+ }));
16435
+ var PipelineTemplateStepSchema = lazy(() => object({
16436
+ addonId: string(),
16437
+ enabled: boolean(),
16438
+ modelId: string(),
16439
+ children: array(PipelineTemplateStepSchema).readonly(),
16440
+ settings: record(string(), unknown()).optional()
16441
+ }));
16442
+ var PipelineTemplateSchema$1 = object({
16397
16443
  id: string(),
16398
- /** The CAMERA the event is attributed to (a sensor linked to N cameras
16399
- * yields N rows, one per camera). */
16400
- deviceId: number(),
16401
- /** The linked sensor device whose state changed. */
16402
- sourceDeviceId: number(),
16403
- /** Event kind id — matches an `EventKindDescriptor.kind`. */
16404
- kind: string(),
16405
- /** Snapshot of the sensor cap's runtime-state slice at the change. */
16406
- value: record(string(), unknown()).nullable(),
16407
- timestamp: number()
16408
- });
16409
- var TrackPositionSchema = object({
16410
- x: number(),
16411
- y: number(),
16412
- timestamp: number(),
16413
- bbox: BoundingBoxSchema
16444
+ name: string(),
16445
+ createdAt: string(),
16446
+ updatedAt: string(),
16447
+ engine: PipelineEngineChoiceSchema,
16448
+ steps: array(PipelineTemplateStepSchema).readonly()
16414
16449
  });
16415
- var TrackSnapshotSchema = object({
16416
- timestamp: number(),
16417
- position: TrackPositionSchema,
16418
- /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
16419
- mediaKey: string()
16450
+ var PipelineModelOptionSchema = object({
16451
+ id: string(),
16452
+ name: string(),
16453
+ formats: record(string(), object({
16454
+ downloaded: boolean(),
16455
+ sizeMB: number()
16456
+ })),
16457
+ group: ModelVariantGroupSchema.optional(),
16458
+ legacy: boolean().optional(),
16459
+ provider: ModelProviderIdSchema.optional()
16420
16460
  });
16421
- /**
16422
- * Normalized 0..1 trajectory envelope (min/max over every position bbox,
16423
- * divided by the track's detection-frame dims), computed at persist time.
16424
- * Absent when the frame dims were unknown when the track was persisted
16425
- * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
16426
- */
16427
- var TrackEnvelopeSchema = object({
16428
- minX: number(),
16429
- minY: number(),
16430
- maxX: number(),
16431
- maxY: number()
16461
+ var ConfigFieldBridge = custom();
16462
+ var PipelineAddonSchemaSchema = object({
16463
+ id: string(),
16464
+ name: string(),
16465
+ slot: PipelineSlotSchema,
16466
+ inputClasses: array(string()).readonly(),
16467
+ outputClasses: array(string()).readonly(),
16468
+ childSlots: array(PipelineSlotSchema).readonly(),
16469
+ models: array(PipelineModelOptionSchema).readonly(),
16470
+ defaultModelId: string(),
16471
+ defaultModelIdByFormat: record(string(), string()).optional(),
16472
+ enabledByDefault: boolean().optional(),
16473
+ backfillIntoExistingOverrides: boolean().optional(),
16474
+ defaultConfidence: number(),
16475
+ group: string().optional(),
16476
+ configSchema: array(ConfigFieldBridge).readonly().optional()
16432
16477
  });
16433
- /**
16434
- * Row projection for track list queries. `full` (default) returns the
16435
- * complete Track including the frame-rate `positions[]` history and the
16436
- * `snapshots[]` references — megabytes across a page of tracks. `slim`
16437
- * keeps every scalar the list surfaces actually render (ids, class(es),
16438
- * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
16439
- * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
16440
- * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
16441
- * `getTrack`. Mirrors the event-store `projection` convention
16442
- * (`getObjectEvents` et al.).
16443
- */
16444
- var TrackProjectionSchema = _enum(["full", "slim"]);
16445
- /**
16446
- * One audio-classification label heard on the track's camera while the
16447
- * track was alive, aggregated per label. An "episode" is one persisted
16448
- * audio event (the confident-classification path: score ≥ the device's
16449
- * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
16450
- * one 32 ms inference chunk, so counts stay human-scaled.
16451
- */
16452
- var TrackAudioLabelSchema = object({
16478
+ var PipelineSlotSchemaSchema = object({
16479
+ id: PipelineSlotSchema,
16453
16480
  label: string(),
16454
- /** Highest classification score observed across the label's episodes. */
16455
- peakScore: number(),
16456
- /** Number of coalesced audio-event episodes carrying this label. */
16457
- count: number(),
16458
- firstAt: number(),
16459
- lastAt: number()
16481
+ priority: number(),
16482
+ parentSlot: PipelineSlotSchema.nullable(),
16483
+ addons: array(PipelineAddonSchemaSchema).readonly()
16460
16484
  });
16461
- /**
16462
- * How a track was produced. `pipeline` (default / absent) = the spatial
16463
- * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
16464
- * no positions, a single snapshot, and no bbox trajectory at all:
16465
- *
16466
- * - `sensor` — a linked sensor/control device state change.
16467
- * - `audio` — an audio event on the camera itself that was anomalous for
16468
- * THAT camera, loud, and heard while nothing visual was happening (D62).
16469
- *
16470
- * The spatial subsystems (tracker association, occupancy count, re-id /
16471
- * embedding, resurrection) MUST skip every synthetic source. Test for that
16472
- * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
16473
- * check silently readmits every source added after it was written.
16474
- */
16475
- var TrackSourceSchema = _enum([
16476
- "pipeline",
16477
- "sensor",
16478
- "audio"
16479
- ]);
16480
- /**
16481
- * Where a track sits in the RETRAIN lifecycle (D81).
16482
- *
16483
- * - `none` — never marked, or un-marked. Evictable.
16484
- * - `staging` — the operator wants this track as training material and has not
16485
- * finished with it. **This is the only state retention holds**: the track and
16486
- * everything it owns (object events, crops, keyframes, CLIP vector) survive
16487
- * the device's age window.
16488
- * - `trained` — the retrain page has taken what it needed. The frames it chose
16489
- * were COPIED into the retrain dataset at selection time, so the dataset no
16490
- * longer depends on the track's media and the track becomes EVICTABLE again.
16491
- * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
16492
- * a deliberate action of the retrain page, not a side effect of a checkbox.
16493
- *
16494
- * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
16495
- * the store's filter language has only positive equality and `whereIn` — no
16496
- * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
16497
- * would make the entire pre-column history immortal in one deploy.
16498
- */
16499
- var RetrainStatusSchema = _enum([
16500
- "none",
16501
- "staging",
16502
- "trained"
16503
- ]);
16504
- /**
16505
- * Per-track OPERATOR flags — set by hand from the admin UI or the viewer, never
16506
- * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
16507
- * so the two surfaces cannot drift.
16508
- *
16509
- * **Absent ≠ false.** A track that has never been touched omits the field; an
16510
- * explicitly un-flagged track carries `false`. Legacy rows written before the
16511
- * columns existed read as absent, and a consumer that needs a boolean should say
16512
- * `flag === true`, not `flag !== false`.
16513
- *
16514
- * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
16515
- * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
16516
- * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
16517
- * `trained` track reports `false` while refusing both writes. The boolean is
16518
- * kept because three surfaces drive a toggle off it; anything that needs to tell
16519
- * "never marked" from "already trained" must read `retrainStatus`.
16520
- *
16521
- * `debug` does NOT pin; it is attention, not durability.
16522
- *
16523
- * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
16524
- * A favourited track is skipped by retention the same way `staging` is, but
16525
- * it does not enter `none|staging|trained` and has no staging budget.
16526
- */
16527
- var TrackFlagFields = {
16528
- /** Operator marked this track as training material — i.e. `retrainStatus` is
16529
- * `'staging'`. */
16530
- markForTrain: boolean().optional(),
16531
- /** Operator marked this track for diagnostic attention. */
16532
- debug: boolean().optional(),
16533
- /** Operator favourited this track. Pins it against pruning. */
16534
- favourited: boolean().optional()
16535
- };
16536
- /**
16537
- * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
16538
- * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
16539
- * write patch, and the status is not something the toggle sets — it is what the
16540
- * toggle's boolean is derived from. Absent on an in-RAM track never touched;
16541
- * always present on a persisted row (the column default materialises `'none'`).
16542
- */
16543
- var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
16544
- /**
16545
- * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
16546
- * one flag can never clear the other — the toggles are independent and are
16547
- * driven from three surfaces that do not know about each other.
16548
- */
16549
- var TrackFlagsPatchSchema = object(TrackFlagFields);
16550
- /**
16551
- * The resolved flag state after a write. Both fields are REQUIRED here (absent
16552
- * collapses to `false`) so a caller can drive a toggle's checked state off the
16553
- * mutation result without a re-fetch.
16554
- */
16555
- var TrackFlagsSchema = object({
16556
- trackId: string(),
16557
- markForTrain: boolean(),
16558
- debug: boolean(),
16559
- favourited: boolean(),
16560
- /** The lifecycle state the boolean was derived from. Required here (unlike on
16561
- * a track row) because this shape is only ever produced by the write body,
16562
- * which always knows it — and a surface that has just written needs to render
16563
- * `trained` without a re-fetch. */
16564
- retrainStatus: RetrainStatusSchema
16485
+ var PipelineSchemaSchema = object({
16486
+ availableEngines: array(AvailableEngineSchema).readonly(),
16487
+ selectedEngine: PipelineEngineChoiceSchema,
16488
+ slots: array(PipelineSlotSchemaSchema).readonly()
16565
16489
  });
16566
- union([literal(1), literal(2)]);
16567
- /**
16568
- * WHO decided a label, and when. Carried per tier so a value can be traced to
16569
- * the step and model that produced it — which is what makes the write rule
16570
- * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
16571
- * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
16572
- *
16573
- * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
16574
- * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
16575
- * `migration:4g` for a value the 4g migration moved from the single-slot era —
16576
- * that value has no provenance, and the write rule lets ANY properly-attributed
16577
- * write of the same tier replace it regardless of score.
16578
- */
16579
- var LabelAttributionSchema = object({
16580
- stepId: string(),
16581
- modelId: string().optional(),
16582
- decidedAt: number(),
16490
+ var EngineProvisioningSchema = object({
16491
+ runtimeId: _enum([
16492
+ "onnx",
16493
+ "openvino",
16494
+ "coreml",
16495
+ "edgetpu"
16496
+ ]).nullable(),
16497
+ device: string().nullable(),
16498
+ state: _enum([
16499
+ "idle",
16500
+ "installing",
16501
+ "verifying",
16502
+ "ready",
16503
+ "failed"
16504
+ ]),
16505
+ progress: number().optional(),
16506
+ error: string().optional(),
16507
+ nextRetryAt: number().optional(),
16583
16508
  /**
16584
- * The GALLERY id behind a recognised tier-2 label — a face-gallery
16585
- * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
16586
- *
16587
- * The text alone is a DISPLAY NAME, and a display name is renameable: a
16588
- * notification rule authored on "Gianluca" stopped matching the moment the
16589
- * operator fixed the spelling in the gallery, and nothing said so. The id is
16590
- * the thing that does not move, so it is what a rule matches on
16591
- * (`NcConditions.identities`) and the text is what a human is shown.
16592
- *
16593
- * Absent when the label names no gallery row — a plate the OCR read but no
16594
- * vehicle claims, a sub-class, a species, any tier-1 value.
16509
+ * Gate A (config-correctness gate at engine change): human-readable
16510
+ * config issues surfaced EAGERLY when the node's engine changes — model
16511
+ * substitutions ("chose X, running Y") and zero-build steps ("no model
16512
+ * has a <format> build"). Additive/optional: informational only, never
16513
+ * enforced here `assertEngineReady` (readiness) still gates inference.
16514
+ * Absent/empty when the node-default tree resolves cleanly.
16595
16515
  */
16596
- identityId: string().optional()
16516
+ configIssues: array(string()).optional()
16597
16517
  });
16598
- /**
16599
- * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
16600
- * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
16601
- * track and its events always answer the same question the same way.
16602
- *
16603
- * Two scalar columns, not an array: every consumer wants "the coarse one" or
16604
- * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
16605
- * is tier 2, and each carries its own score + attribution.
16606
- *
16607
- * **Reading it.** What a human should be shown is `subLabel ?? label` — the
16608
- * finest thing known. Before 4g the single `label` column held the finest
16609
- * value, so a consumer that has not been updated reads the tier-1 slot and
16610
- * shows nothing on a species-only row; that is why the migration puts every
16611
- * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
16612
- * and why the read surfaces were changed in the same train.
16613
- *
16614
- * **Writing it.** The slots are independent, which is the whole point: a
16615
- * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
16616
- * migratorius`), so fineness cannot regress by construction. Within a tier the
16617
- * higher score wins. One rule, one implementation — see
16618
- * `pipeline/label-tier.ts` in addon-post-analysis.
16619
- */
16620
- var TieredLabelFields = {
16621
- /** Tier 1 the sub-class. See {@link LabelTierSchema}. */
16622
- label: string().optional(),
16623
- /** Confidence of the tier-1 value, as reported by the deciding step. */
16624
- labelScore: number().optional(),
16625
- /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
16626
- labelMeta: LabelAttributionSchema.optional(),
16627
- /** Tier 2 — the instance. See {@link LabelTierSchema}. */
16628
- subLabel: string().optional(),
16629
- /** Confidence of the tier-2 value, as reported by the deciding step. */
16630
- subLabelScore: number().optional(),
16631
- /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
16632
- subLabelMeta: LabelAttributionSchema.optional()
16633
- };
16634
- /** Per-camera slice of a training-export estimate. */
16635
- var TrainingExportDeviceTotalsSchema = object({
16636
- deviceId: number(),
16637
- tracks: number().int(),
16638
- files: number().int(),
16639
- bytes: number().int()
16518
+ var PipelineStepInputSchema = lazy(() => object({
16519
+ addonId: string(),
16520
+ modelId: string().optional(),
16521
+ enabled: boolean().default(true),
16522
+ children: array(PipelineStepInputSchema).optional(),
16523
+ settings: record(string(), unknown()).optional(),
16524
+ jumpDeviceKey: string().optional()
16525
+ }));
16526
+ var ModelSubstitutionSchema = object({
16527
+ addonId: string(),
16528
+ chosen: string(),
16529
+ running: string(),
16530
+ format: string()
16531
+ });
16532
+ var PipelineValidationIssueSchema = object({
16533
+ addonId: string(),
16534
+ kind: _enum(["unknown-addon", "no-format-build"]),
16535
+ detail: string()
16536
+ });
16537
+ var PipelineValidationResultSchema = object({
16538
+ ok: boolean(),
16539
+ issues: array(PipelineValidationIssueSchema).readonly(),
16540
+ substitutions: array(ModelSubstitutionSchema).readonly(),
16541
+ /** The node's `currentEngine.format` this validation ran against. */
16542
+ format: string()
16543
+ });
16544
+ var ReferenceImageEntrySchema = object({
16545
+ filename: string(),
16546
+ stepIds: array(string()).readonly().optional()
16547
+ });
16548
+ var ReferenceImageBodySchema = object({
16549
+ base64: string(),
16550
+ filename: string()
16551
+ });
16552
+ var ReferenceAudioEntrySchema = object({
16553
+ filename: string(),
16554
+ sizeKb: number()
16555
+ });
16556
+ var ReferenceAudioBodySchema = object({ base64: string() });
16557
+ var AudioBackendSchema = object({
16558
+ id: string(),
16559
+ name: string(),
16560
+ description: string(),
16561
+ available: boolean(),
16562
+ /**
16563
+ * Raw classifier labels this backend can emit (e.g. YAMNet's
16564
+ * 521-class set or Apple SoundAnalysis's 303-class set). Used by
16565
+ * the benchmark UI to populate the `enabledMicroClasses` filter
16566
+ * specific to the selected backend without a separate fetch.
16567
+ */
16568
+ rawLabels: array(string()).readonly().optional()
16569
+ });
16570
+ var AudioCapabilitiesSchema = object({
16571
+ activeBackend: string(),
16572
+ availableBackends: array(AudioBackendSchema).readonly(),
16573
+ sampleRate: number(),
16574
+ chunkDurationMs: number()
16575
+ });
16576
+ var DownloadModelResultSchema = object({
16577
+ filePath: string(),
16578
+ sizeMB: number(),
16579
+ durationMs: number()
16640
16580
  });
16641
16581
  /**
16642
- * What a training export WOULD contain. Computed from media index rows only —
16643
- * no blob is read to produce this.
16582
+ * Wrapper carrying a single test run's result. Replaces the legacy
16583
+ * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
16584
+ * canonical `AudioResult` from the Phase 6 output rework: one
16585
+ * `AudioDetection` per class above `minScore`, top-N candidates in
16586
+ * `debug.alternateLabels['audio-classifier']`, per-source timings in
16587
+ * `debug.stepTimings`. The outer `success`/`error` fields stay so the
16588
+ * benchmark UI can still report a clean failure when the classifier
16589
+ * cap isn't available.
16644
16590
  */
16645
- var TrainingExportSummarySchema = object({
16646
- generatedAt: number(),
16647
- trackCount: number().int(),
16648
- fileCount: number().int(),
16649
- byteCount: number().int(),
16650
- /** More marked tracks exist than a single pass carries. */
16651
- truncated: boolean(),
16652
- devices: array(TrainingExportDeviceTotalsSchema).readonly()
16591
+ var AudioTestResultSchema = object({
16592
+ success: boolean(),
16593
+ error: string().optional(),
16594
+ frame: custom().optional()
16653
16595
  });
16654
- var TrackSchema = object({
16655
- trackId: string(),
16656
- deviceId: number(),
16657
- className: string(),
16658
- ...TieredLabelFields,
16659
- producingDeviceName: string().optional(),
16660
- /** Track provenance. Absent `pipeline` (legacy rows). */
16661
- source: TrackSourceSchema.optional(),
16662
- firstSeen: number(),
16663
- lastSeen: number(),
16664
- /** Frame-rate position history (subject to maxPositionHistory cap). */
16665
- positions: array(TrackPositionSchema).readonly(),
16666
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
16667
- * saveThumbnails policy). */
16668
- snapshots: array(TrackSnapshotSchema).readonly(),
16669
- /** Deduplicated zones the track has entered at least once. Zone IDS. */
16670
- zonesVisited: array(string()).readonly(),
16596
+ var PipelineConfigBridge = custom();
16597
+ var ConfigUISchemaBridge = custom();
16598
+ var ConfigUISchemaNullableBridge = custom();
16599
+ var InferenceCapabilitiesBridge = custom();
16600
+ var ModelAvailabilityListBridge = custom();
16601
+ var PipelineRunResultBridge = custom();
16602
+ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
16603
+ modelId: string(),
16604
+ settings: record(string(), unknown()).readonly()
16605
+ }))), method(object({ steps: record(string(), object({
16606
+ modelId: string(),
16607
+ settings: record(string(), unknown()).readonly()
16608
+ })) }), object({ success: literal(true) }), {
16609
+ kind: "mutation",
16610
+ auth: "admin"
16611
+ }), method(object({ nodeId: string() }), object({
16612
+ success: literal(true),
16613
+ clearedDevices: number()
16614
+ }), {
16615
+ kind: "mutation",
16616
+ auth: "admin"
16617
+ }), method(object({ nodeId: string() }), object({ unhealthy: array(object({
16618
+ /** `<backend>:<device>`, e.g. `openvino:gpu`. */
16619
+ deviceKey: string(),
16671
16620
  /**
16672
- * Human NAMES for {@link zonesVisited}, resolved at READ time against the
16673
- * `zones` capability.
16674
- *
16675
- * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
16676
- * and no card can render — so every free-text search surface was structurally
16677
- * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
16678
- * just returned nothing. Resolving here rather than in each client keeps ONE
16679
- * derivation and costs the clients no extra call (the `zones` cap is
16680
- * per-device, so a client-side resolve would be a per-camera fan-out on a
16681
- * surface built to avoid exactly that).
16682
- *
16683
- * Resolved, never invented: a zone deleted since the track was written has no
16684
- * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
16685
- * two are not positionally aligned. Absent when the track visited no zone, or
16686
- * when the zone catalogue could not be read.
16621
+ * `failed` the per-device restart budget is exhausted; no pool
16622
+ * will be spawned until an operator re-arms it or the runner
16623
+ * respawns. `backoff` — under budget, waiting out the backoff (or
16624
+ * a cached pool observed dead and not yet condemned).
16687
16625
  */
16688
- zoneNames: array(string()).readonly().optional(),
16689
- /** Deduplicated set of detector classes observed for this track over its
16690
- * life (a track may be reclassified, e.g. person→vehicle). Absent on
16691
- * legacy rows written before class accumulation shipped. */
16692
- classes: array(string()).readonly().optional(),
16693
- /** Cumulative normalized distance travelled (0..1 units = full frame width). */
16694
- totalDistance: number(),
16695
- state: TrackStateSchema,
16696
- active: boolean(),
16697
- /** Deterministic key-event importance score in [0,1] (server-computed at
16698
- * track expiry, recomputed on late label). Absent on legacy rows written
16699
- * before scoring shipped — consumers degrade to absence / compute-on-read. */
16700
- importance: number().optional(),
16701
- /** Id of the track's highest-confidence ObjectEvent (its representative
16702
- * "best" frame). Absent when the track produced no object events. */
16703
- bestEventId: string().optional(),
16704
- /** Tag of the importance sub-signal that dominated the score
16705
- * (identity|dwell|proximity|class|confidence|travel|zone). */
16706
- importanceReason: string().optional(),
16707
- /** Audio-classification labels heard on the camera during the track's
16708
- * life (score ≥ device `classificationMinScore`), aggregated per label.
16709
- * Absent on legacy rows / tracks with no confident audio. */
16710
- audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
16711
- /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
16712
- * Populated from the persisted envelope columns on historical reads;
16713
- * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
16714
- envelope: TrackEnvelopeSchema.optional(),
16626
+ state: _enum(["failed", "backoff"]),
16627
+ /** Epoch ms of the death that produced this state. */
16628
+ since: number(),
16629
+ /** Pool deaths inside the current window. */
16630
+ deaths: number(),
16631
+ /** The last death's message. */
16632
+ lastError: string()
16633
+ })).readonly() })), method(object({
16634
+ nodeId: string(),
16635
+ deviceKey: string()
16636
+ }), object({ rearmed: boolean() }), {
16637
+ kind: "mutation",
16638
+ auth: "admin"
16639
+ }), 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({
16640
+ name: string(),
16641
+ steps: array(PipelineTemplateStepSchema).readonly(),
16642
+ engine: PipelineEngineChoiceSchema
16643
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
16644
+ id: string(),
16645
+ name: string().optional(),
16646
+ steps: array(PipelineTemplateStepSchema).readonly().optional()
16647
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
16648
+ addonId: string(),
16649
+ modelId: string(),
16650
+ format: ModelFormatSchema$1
16651
+ }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
16652
+ addonId: string(),
16653
+ modelId: string(),
16654
+ format: ModelFormatSchema$1
16655
+ }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
16656
+ engine: PipelineEngineChoiceSchema.optional(),
16657
+ steps: array(PipelineStepInputSchema).min(1),
16658
+ frame: FrameInputSchema.optional(),
16715
16659
  /**
16716
- * A face DETECTOR found a face on this track — nothing more. It says the
16717
- * detail plane produced a `face` detail; it does NOT say the face was
16718
- * embedded, matched, above `minFacePx`, or that the recognizer was even
16719
- * enabled. Set once and never cleared.
16720
- *
16721
- * **This exists so "face present but not recognised" is expressible.** A
16722
- * recognised identity lands in `subLabel` (attributed to the face chain via
16723
- * `subLabelMeta.stepId`), so before this field a track with an unmatched face
16724
- * and a track with no face at all were byte-identical on the wire and no
16725
- * surface could tell them apart. The read is `hasFace === true && subLabel
16726
- * === undefined`.
16727
- *
16728
- * **Absent ≠ false.** Every row written before the column existed omits it,
16729
- * and so does every server that predates the field — a consumer must test
16730
- * `=== true` and render nothing otherwise, never infer "no face".
16660
+ * Process-local lazy frame. Valid only when caller and provider resolve
16661
+ * in the same execution-group process; split/cross-node callers use
16662
+ * `frame`/`image` inline compatibility instead.
16731
16663
  */
16732
- hasFace: boolean().optional(),
16664
+ frameRef: FrameRefSchema.optional(),
16733
16665
  /**
16734
- * This track has a face row IN THE GALLERY: a crop **and** an embedding a
16735
- * face an operator could ASSIGN to an identity.
16736
- *
16737
- * The STRICT twin of {@link hasFace}, and the pair only earns its keep
16738
- * because the two disagree. `hasFace` is stamped at the TOP of the face
16739
- * branch, before every gate, and means no more than "a face detector produced
16740
- * a face detail". This one is stamped at the single moment the gallery row
16741
- * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
16742
- * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
16743
- * candidate gate, the imageless-track drop (no crop was ever captured) and
16744
- * the crop-store drop. Everything between the detector and that insert can
16745
- * legitimately refuse the face, so a flag written any earlier promises the
16746
- * operator something to assign and delivers nothing.
16747
- *
16748
- * **Independent of recognition.** A face collected but never auto-matched is
16749
- * still assignable — it is in fact the face an operator most wants to reach —
16750
- * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
16751
- * `subLabel`; this says only that the raw material exists.
16752
- *
16753
- * **Set once, never cleared.** A track that produced a gallery row produced
16754
- * one; deleting the row later is the gallery's business, not this flag's.
16755
- *
16756
- * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
16757
- * before the column omits it, and so does every server that predates the
16758
- * field. A consumer must test `=== true` and render nothing otherwise —
16759
- * never infer "no assignable face".
16666
+ * CB5 shm passthrough a `FrameHandle` naming the same ring slot
16667
+ * the decoded pixels live in. One more member of the one-of
16668
+ * frame/frameHandle/image/imageBase64/referenceImage group.
16760
16669
  */
16761
- hasEmbeddedFace: boolean().optional(),
16670
+ frameHandle: FrameHandleSchema.optional(),
16671
+ imageBase64: string().optional(),
16762
16672
  /**
16763
- * This subject CONTAINS a folded rider a person the rider-pairing step
16764
- * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
16765
- * so the passage is tracked once and as a VEHICLE.
16766
- *
16767
- * It exists because the fold's record was dishonest. D34 and the code both
16768
- * said "the person is not lost — it is reported so both entities stay on the
16769
- * record"; in fact the pair went into a per-processor RAM field behind an
16770
- * accessor nobody called, and every durable surface said `vehicle`, full
16771
- * stop. This is the composition note that makes the row true.
16772
- *
16773
- * A COMPOSITION, never a class and never a label. "This vehicle contains a
16774
- * person" is not an answer to "what is this" — both label tiers would refuse
16775
- * a macro token anyway (D89), and correctly. Nothing here changes what the
16776
- * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
16777
- * and a `person` rule still does not fire for someone cycling past.
16778
- *
16779
- * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
16780
- * the column, and every hub that predates the field, omits it. Test
16781
- * `=== true` and render nothing otherwise — never infer "no rider".
16673
+ * Binary JPEG bytespreferred over `imageBase64` on internal
16674
+ * hops (hub forked worker via Moleculer MsgPack) because it
16675
+ * skips the 33% base64 overhead + the per-call base64 decode on
16676
+ * the detection-pipeline worker. Callers can pass either; exactly
16677
+ * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
16782
16678
  */
16783
- hasRider: boolean().optional(),
16784
- ...TrackFlagFields,
16785
- ...TrackRetrainFields
16786
- });
16787
- var BaseEventFields = {
16788
- id: string(),
16789
- deviceId: number(),
16790
- timestamp: number()
16791
- };
16792
- var MotionEventSchema = object({
16793
- ...BaseEventFields,
16794
- kind: literal("motion"),
16795
- regionCount: number(),
16796
- /** Heavy JSON array omitted in slim projection. */
16797
- regions: array(object({
16798
- bbox: BoundingBoxSchema,
16799
- pixelCount: number(),
16800
- intensity: number()
16801
- })).readonly().optional(),
16802
- /** Omitted in slim projection. */
16803
- frameWidth: number().optional(),
16804
- /** Omitted in slim projection. */
16805
- frameHeight: number().optional(),
16806
- /** Populated by B5 (recording playback URL for this event). */
16807
- mediaUrl: string().optional()
16808
- });
16679
+ image: _instanceof(Uint8Array).optional(),
16680
+ referenceImage: string().optional(),
16681
+ deviceId: number().optional(),
16682
+ sessionId: string().optional(),
16683
+ /**
16684
+ * Execution plane. 'full' (default) runs the whole tree — benchmark,
16685
+ * reference-image, and detail-subtree calls. 'frame' is the live
16686
+ * per-frame dispatch: ONLY root-plane steps run; crop children
16687
+ * (inputClasses ≠ null) are skipped and served per-track via
16688
+ * pipelineRunner.runDetailSubtree (two-plane design).
16689
+ */
16690
+ plane: _enum(["full", "frame"]).optional(),
16691
+ /**
16692
+ * Inference-device selector (Phase 2 multi-device). Format
16693
+ * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
16694
+ * Omitted ⇒ the runner's default device (current single-engine
16695
+ * behaviour). Selects WHICH device pool of the node runs the call.
16696
+ */
16697
+ deviceKey: string().optional(),
16698
+ /**
16699
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
16700
+ * when the parent crop was resolved from the frame's retained NATIVE
16701
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
16702
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
16703
+ * resolution from that surface — the SAME quality path faces already
16704
+ * had — instead of the downscaled parent tile. `handle` keys the native
16705
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
16706
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
16707
+ * the executor's crop-normalized child ROI back into frame-normalized
16708
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
16709
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
16710
+ * (today's behaviour on the fallback path).
16711
+ */
16712
+ nativeCropRef: NativeCropRefSchema.optional()
16713
+ }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
16714
+ engine: PipelineEngineChoiceSchema.optional(),
16715
+ steps: array(PipelineStepInputSchema).min(1),
16716
+ frames: array(FrameInputSchema).min(1).max(255),
16717
+ deviceId: number().optional(),
16718
+ sessionId: string().optional(),
16719
+ /**
16720
+ * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
16721
+ * the batch to the Python pool's bench preprocess cache
16722
+ * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
16723
+ * preprocessed ONCE and every later inference is a pure-inference cache
16724
+ * hit — the sustained-throughput run measures inference, not
16725
+ * decode+preprocess+infer. Omitted/0 for live frames (all different →
16726
+ * full preprocess every call, correct). Fresh per sustained run;
16727
+ * released via `uncacheFrame`.
16728
+ */
16729
+ frameId: number().int().nonnegative().optional(),
16730
+ /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
16731
+ deviceKey: string().optional()
16732
+ }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
16733
+ data: _instanceof(Uint8Array),
16734
+ width: number().int().positive(),
16735
+ height: number().int().positive(),
16736
+ format: _enum([
16737
+ "rgb",
16738
+ "bgr",
16739
+ "gray"
16740
+ ])
16741
+ }), object({
16742
+ frameId: number(),
16743
+ width: number(),
16744
+ height: number()
16745
+ }), { kind: "mutation" }), method(object({
16746
+ stepId: string(),
16747
+ frameId: number().int()
16748
+ }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
16749
+ batchMode: string(),
16750
+ windowMs: number(),
16751
+ maxBatchSize: number(),
16752
+ concurrency: number()
16753
+ })), method(_void(), array(object({
16754
+ engineKey: string(),
16755
+ engine: PipelineEngineChoiceSchema,
16756
+ modelsLoaded: array(string()).readonly(),
16757
+ inUseByCameras: array(number()).readonly(),
16758
+ /**
16759
+ * Origin of this resident factory.
16760
+ * - `runtime` — main camera-serving engine (no idle TTL).
16761
+ * - `warm-override` — benchmark/test override held in the warm
16762
+ * cache; auto-disposed after the idle TTL.
16763
+ * - `device-pool` — a concurrent per-device pool (Phase 2
16764
+ * multi-device, keyed by `deviceKey`) resolved
16765
+ * via `resolveDeviceFactory`. Runs alongside the
16766
+ * `runtime` engine on a DIFFERENT accelerator
16767
+ * (NPU / iGPU / Coral) — this is how the
16768
+ * Engines tab shows all pools running at once.
16769
+ */
16770
+ kind: _enum([
16771
+ "runtime",
16772
+ "warm-override",
16773
+ "device-pool"
16774
+ ]),
16775
+ /** Native pid of the underlying Python pool (null when no pool). */
16776
+ poolPid: number().nullable(),
16777
+ /** ms since this factory was last used (null when not warm-tracked). */
16778
+ idleMs: number().nullable(),
16779
+ /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
16780
+ idleTtlMs: number().nullable()
16781
+ })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
16782
+ kind: "mutation",
16783
+ auth: "admin"
16784
+ }), method(object({
16785
+ engine: PipelineEngineChoiceSchema,
16786
+ force: boolean().optional()
16787
+ }), object({
16788
+ success: boolean(),
16789
+ reason: string().optional()
16790
+ }), {
16791
+ kind: "mutation",
16792
+ auth: "admin"
16793
+ }), 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({
16794
+ addonId: string(),
16795
+ modelId: string(),
16796
+ filename: string().optional(),
16797
+ settings: record(string(), unknown()).optional()
16798
+ }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
16809
16799
  /**
16810
- * Which detection SOURCE produced an object event. `pipeline` = the ML
16811
- * detection pipeline (decoded-frame inference); `onboard` = the camera's
16812
- * native on-device AI. Both flow through the SAME analysis layers (zoning,
16813
- * tracking, per-kind persistence) but stay distinguishable so consumers
16814
- * (advanced-notifier, occupancy, …) can select which source(s) to act on.
16815
- * Absent on legacy rows treat as `pipeline`.
16800
+ * Per-stage gating mode applied to the zones a rule references.
16801
+ *
16802
+ * - `include`: the rule contributes to a **whitelist** for its stage.
16803
+ * When at least one `include` rule fires for a stage, only entities
16804
+ * inside one of those zones pass that stage.
16805
+ * - `exclude`: the rule contributes to a **blacklist** for its stage.
16806
+ * Entities inside one of those zones are dropped at that stage.
16807
+ *
16808
+ * `monitor`-style observation (count without filtering) is not a rule
16809
+ * mode — zones without any matching rule are observed naturally by
16810
+ * `zone-analytics` (live snapshot + history), so an "I just want to
16811
+ * count, not filter" use case needs no rule at all.
16816
16812
  */
16817
- var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
16813
+ var ZoneRuleModeEnum = _enum(["include", "exclude"]);
16818
16814
  /**
16819
- * The confirmed zone crossing that produced an object event. Present ONLY on
16820
- * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
16821
- * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
16822
- * appearance event carry none, so a rule asking for a direction fails closed
16823
- * on them.
16815
+ * Per-consumer rule that references existing zones (geometry) and
16816
+ * defines how a specific pipeline stage should treat them. Each
16817
+ * consumer addon owns its own `ZoneRule[]` array in its per-device
16818
+ * settings:
16824
16819
  *
16825
- * Exactly ONE crossing per event: the emitter turns each confirmed crossing
16826
- * into its own event, so a frame in which a track enters A while leaving B
16827
- * produces two events with two directions — never one ambiguous row.
16820
+ * - `addon-motion-wasm` `motionZoneRules: ZoneRule[]` (motion stage)
16821
+ * - `addon-detection-pipeline` `detectionZoneRules: ZoneRule[]` (detection stage)
16822
+ * - future: notification rules, audio gating, etc.
16828
16823
  *
16829
- * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
16830
- * membership the box has NOW, and by definition it no longer contains the zone
16831
- * that was just left. Without the id here, a zone-scoped rule could never match
16832
- * the exit it asked for.
16824
+ * One rule applies to N zones (`zoneIds[]`) so the operator can
16825
+ * express "ignore motion in ALL of {garden, street}" with a single
16826
+ * rule. `classFilter` narrows the rule to specific object classes
16827
+ * "drop person detections in the street, but keep cars" is one
16828
+ * `exclude` rule with `classFilter: ['person']`.
16829
+ *
16830
+ * `enabled` is a soft toggle — the operator can keep the rule
16831
+ * configured but inert without deleting it.
16833
16832
  */
16834
- var ZoneCrossingSchema = object({
16835
- direction: _enum(["enter", "exit"]),
16836
- /** Admin zone id crossed. */
16837
- zoneId: string(),
16838
- /** Zone display name at crossing time (falls back to the id). */
16839
- zoneName: string().optional()
16840
- });
16841
- var ObjectEventSchema = object({
16842
- ...BaseEventFields,
16843
- kind: literal("object"),
16844
- /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
16845
- source: DetectionSourceSchema.optional(),
16833
+ var ZoneRuleSchema = object({
16834
+ /** Stable rule id — survives edits, used by the UI for diffing. */
16835
+ id: string(),
16836
+ /** Optional human-readable label rendered in the rule editor. */
16837
+ name: string().optional(),
16838
+ /** Zones this rule targets. The rule's `mode` applies to ALL
16839
+ * listed zones (OR-set: a detection in any one of them counts).
16840
+ * At least one zone id required — a rule with no targets is a
16841
+ * configuration mistake and the form validator rejects it. */
16842
+ zoneIds: array(string()).min(1).readonly(),
16843
+ mode: ZoneRuleModeEnum,
16846
16844
  /**
16847
- * Inference-frame id shared by every object event emitted from the SAME frame
16848
- * the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
16849
- * 2 people + 1 dog) under one full frame, and link a track's frames over time
16850
- * (group by `trackId`, pick a representative `frameId` as the parent frame).
16851
- * Optional for backward-compat with pre-existing rows / the slim projection
16852
- * includes it (it is light). Absent on rows written before this field.
16845
+ * Class names this rule applies to. Empty / undefined rule
16846
+ * applies to every class. Class strings match the `macroClass`
16847
+ * field on detections (e.g. `person`, `car`, `dog`).
16853
16848
  */
16854
- frameId: string().optional(),
16855
- /** Omitted in slim projection. */
16856
- trackId: string().optional(),
16857
- className: string(),
16858
- ...TieredLabelFields,
16859
- /** Omitted in slim projection. */
16860
- confidence: number().optional(),
16861
- /** Heavy JSON — omitted in slim projection. */
16862
- bbox: BoundingBoxSchema.optional(),
16863
- /** Heavy JSON — omitted in slim projection. */
16864
- zones: array(string()).readonly().optional(),
16865
- /** Omitted in slim projection. */
16866
- state: TrackStateSchema.optional(),
16849
+ classFilter: array(string()).readonly().optional(),
16867
16850
  /**
16868
- * The zone crossing this event IS, when it is one. Absent on every other
16869
- * event kind (movement state, appearance, package) see
16870
- * {@link ZoneCrossingSchema}. Omitted in slim projection.
16851
+ * Minimum bbox/mask overlap (0–1) with any of the rule's zones
16852
+ * required to consider an entity "in the zone". Defaults to the
16853
+ * consumer's stage default when omitted. Kept for back-compat with
16854
+ * existing per-rule overrides; new operators pick the value via
16855
+ * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
16856
+ * set, the lower-level engine reads it as a 0–1 fraction.
16871
16857
  */
16872
- zoneCrossing: ZoneCrossingSchema.optional(),
16873
- /** Detection-frame dimensions in pixels — let consumers normalize the
16874
- * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
16875
- frameWidth: number().optional(),
16876
- frameHeight: number().optional(),
16877
- /** MediaStore key for the crop attached to this event (if any). */
16878
- mediaKey: string().optional(),
16879
- /** Design B: MediaStore key of the track's native-resolution key frame (the
16880
- * best-detection full frame). Resolve via the event-media data-plane
16881
- * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
16882
- * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
16883
- * sources — consumers fall back to `mediaKey` (the tight crop). */
16884
- keyFrameMediaKey: string().optional(),
16885
- /** Populated by B5 (recording playback URL for this event). */
16886
- mediaUrl: string().optional(),
16887
- /** The parent track's key-event importance [0,1], propagated to every object
16888
- * event of the track (so an event row can be sorted by importance without a
16889
- * track join). Absent on legacy rows / before the track was scored. */
16890
- importance: number().optional()
16858
+ overlapThreshold: number().min(0).max(1).optional(),
16859
+ /**
16860
+ * Operator-friendly version of `overlapThreshold` the percentage
16861
+ * of the detection's bbox that must lie inside the zone for the
16862
+ * rule to match. Documented default is 85%; the engine substitutes
16863
+ * that when the field is omitted (kept optional so existing rules
16864
+ * stored without it stay valid).
16865
+ *
16866
+ * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
16867
+ * rule, the engine prefers `bboxInclusionPct` because it's the
16868
+ * field exposed in the UI. Internally both feed the same gate.
16869
+ */
16870
+ bboxInclusionPct: number().min(0).max(100).optional(),
16871
+ /**
16872
+ * When `true` and a detection has a segmentation mask, use the
16873
+ * mask for overlap instead of the bbox. Detection-stage only;
16874
+ * motion rules ignore this field.
16875
+ */
16876
+ preferMask: boolean().optional(),
16877
+ /**
16878
+ * Soft-toggle: `false` disables the rule without deleting it.
16879
+ * Defaults to `true` so operators creating a rule via the UI
16880
+ * see it active immediately.
16881
+ */
16882
+ enabled: boolean().default(true)
16891
16883
  });
16892
- var AudioEventSchema = object({
16893
- ...BaseEventFields,
16894
- kind: literal("audio"),
16895
- rms: number(),
16896
- dbfs: number(),
16897
- classification: object({
16898
- className: string(),
16899
- originalClass: string().optional(),
16900
- score: number()
16901
- }).optional(),
16902
- /** Populated by B5 (recording playback URL for this event). */
16903
- mediaUrl: string().optional()
16884
+ array(ZoneRuleSchema).readonly();
16885
+ /**
16886
+ * Zone — pure geometry + identity. NO filtering behaviour.
16887
+ *
16888
+ * Zones describe **where** in the frame the operator wants to flag
16889
+ * something; consumer-owned {@link ZoneRule} arrays describe **how**
16890
+ * each pipeline stage uses them. Splitting the two means a single
16891
+ * polygon "Driveway" can simultaneously back a motion-exclude rule,
16892
+ * a detection-include rule on `['car']`, and an occupancy aggregate
16893
+ * — without three duplicated polygons.
16894
+ *
16895
+ * Owned by the orchestrator addon (provider) and mirrored into the
16896
+ * `zones` device-state slice on every mutation. Consumers
16897
+ * (motion-wasm, pipeline-executor, analytics, admin UI) read either
16898
+ * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
16899
+ * mirror with `onChanged`).
16900
+ *
16901
+ * Coordinates are normalised fractions of the frame (0–1) so zones
16902
+ * survive resolution changes and stream profile switches.
16903
+ *
16904
+ * `kind` discriminates between full polygons (closed regions used
16905
+ * for intrusion / occupancy filters) and tripwires (open 2-point
16906
+ * line segments used for cross events). Onboard / firmware-reported
16907
+ * zones (Reolink, ONVIF) are out of scope for now — see the deferred
16908
+ * task list.
16909
+ */
16910
+ var ZoneKindEnum = _enum(["polygon", "tripwire"]);
16911
+ /** Polygon vertex in fraction-of-frame coordinates (0–1). */
16912
+ var PolygonPointSchema = object({
16913
+ x: number(),
16914
+ y: number()
16904
16915
  });
16905
- var MediaFileKindEnum = _enum([
16906
- "crop",
16907
- "thumbnail",
16908
- "snapshot",
16909
- "firstFrame",
16910
- "lastFrame",
16911
- "fullFrame",
16912
- "fullFrameBoxed",
16913
- "faceCrop",
16914
- "plateCrop",
16915
- "keyFrame",
16916
- "keyFrameSmall",
16917
- "thumbnailSmall"
16918
- ]);
16919
- var MediaFileSchema = object({
16920
- key: string(),
16921
- kind: MediaFileKindEnum,
16922
- base64: string(),
16923
- sizeBytes: number(),
16924
- timestamp: number()
16916
+ /** A camera detection zone — pure geometry/identity. */
16917
+ var ZoneSchema = object({
16918
+ id: string(),
16919
+ name: string(),
16920
+ kind: ZoneKindEnum.default("polygon"),
16921
+ /** Polygon vertices, fraction of frame (0–1). */
16922
+ polygon: array(PolygonPointSchema).readonly(),
16923
+ /** Visual color for UI rendering. */
16924
+ color: string().default("#3b82f6")
16925
16925
  });
16926
16926
  /**
16927
- * One media row WITHOUT its bytes.
16927
+ * Zones capability per-camera CRUD over polygon detection zones.
16928
16928
  *
16929
- * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
16930
- * 140 s track), and a client that renders tiles from the media data plane needs
16931
- * to know only WHAT EXISTS the bytes then arrive per tile, lazily, over HTTP
16932
- * with an immutable cache, instead of all at once inside a tRPC response that
16933
- * blocks the whole view.
16929
+ * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
16930
+ * to per-device settings and mirrors into the `zones` device-state
16931
+ * slice on every mutation, so downstream consumers can subscribe via
16932
+ * `dev.state.zones.onChanged`.
16934
16933
  *
16935
- * `sizeBytes` is carried because it is what lets a client decide between the
16936
- * stored blob and a `?variant=thumb` rendering without fetching either.
16934
+ * The cap surface only handles geometry + identity; filtering
16935
+ * behaviour (per-class, include/exclude, threshold) lives in the
16936
+ * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
16937
+ * `capabilities/schemas/zone-rule.js`.
16937
16938
  */
16938
- var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
16939
+ var zonesCapability = {
16940
+ name: "zones",
16941
+ scope: "device",
16942
+ mode: "singleton",
16943
+ deviceTypes: [DeviceType.Camera],
16944
+ methods: {
16945
+ listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
16946
+ addZone: method(object({
16947
+ deviceId: number(),
16948
+ zone: ZoneSchema
16949
+ }), _void(), {
16950
+ kind: "mutation",
16951
+ auth: "admin"
16952
+ }),
16953
+ removeZone: method(object({
16954
+ deviceId: number(),
16955
+ zoneId: string()
16956
+ }), _void(), {
16957
+ kind: "mutation",
16958
+ auth: "admin"
16959
+ }),
16960
+ updateZone: method(object({
16961
+ deviceId: number(),
16962
+ zone: ZoneSchema
16963
+ }), _void(), {
16964
+ kind: "mutation",
16965
+ auth: "admin"
16966
+ })
16967
+ },
16968
+ /**
16969
+ * Runtime-state slice — the live zone catalogue mirrored by the
16970
+ * orchestrator on every CRUD mutation. Consumers read via
16971
+ * `device.state.zones.value` / `.watch(...)` without round-tripping
16972
+ * the cap, and the codegen DeviceProxy auto-wires the reactive
16973
+ * handle. Slice shape is `{ zones: Zone[] }` so future extensions
16974
+ * (e.g. zone groupings) can sit alongside the polygon list.
16975
+ */
16976
+ runtimeState: object({ zones: array(ZoneSchema).readonly() }),
16977
+ /**
16978
+ * 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.
16979
+ *
16980
+ * See `RuntimeStateDurability`. Enforced by
16981
+ * `scripts/check-runtime-state-durability.ts`.
16982
+ */
16983
+ durability: "restored"
16984
+ };
16939
16985
  /**
16940
- * The MACRO tier of an annotation — a CLOSED set.
16986
+ * pipeline-analytics device-scoped wrapper cap. Refines raw
16987
+ * per-frame detections emitted by the pipeline runner into tracked
16988
+ * objects, per-kind event collections (motion / object / audio), and
16989
+ * persisted media. Owns the post-detection domain end-to-end:
16941
16990
  *
16942
- * This is what the exported detector predicts, so a typo here is a new class
16943
- * with one example in it. `label` and `subLabel` are open strings by contrast:
16944
- * the whole point of the page is teaching the model things it does not know
16945
- * yet, and constraining that vocabulary would make it useless.
16991
+ * runner emits PipelineInferenceResult
16992
+ * (event bus)
16993
+ * pipeline-analytics subscriber
16994
+ * SORT tracker + zone engine + state analyzer + event emitter
16995
+ * → three DB collections (one per kind), one FS media tree, one
16996
+ * unified event emitter (FrameTracked + TrackStarted/Ended +
16997
+ * DetectionEvent on bus)
16946
16998
  *
16947
- * A macro class is NEVER a label. The provider refuses a write whose `label` or
16948
- * `subLabel` is one of these values, in any casing, because once `person`
16949
- * exists in both tiers "every person box" stops being answerable without
16950
- * knowing every string anyone ever typed — and the damage is retroactive.
16999
+ * Pure subscriber model. No `processFrame` cap method the runner
17000
+ * already publishes the raw frame on the bus. The cap surface is
17001
+ * only QUERIES + per-device settings, bound on/off via
17002
+ * `device-manager.setWrapperActive`. `defaultActive: true` because
17003
+ * every camera with a detection pipeline wants its raw detections
17004
+ * refined; operators opt out per-device via BindingsTab when needed.
17005
+ *
17006
+ * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
17007
+ * (per-device surface) and `track-trail` caps — see P11 cleanup.
16951
17008
  */
16952
- var RetrainMacroClassSchema = _enum([
17009
+ var TrackStateSchema = _enum([
17010
+ "new",
17011
+ "entered",
17012
+ "left",
17013
+ "moving",
17014
+ "idle"
17015
+ ]);
17016
+ var EventKindSchema = _enum([
17017
+ "motion",
17018
+ "object",
17019
+ "audio"
17020
+ ]);
17021
+ /**
17022
+ * Spatial filter for `listTracks` — the rect + polygon variants of the shared
17023
+ * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
17024
+ * of the camera frame (top-left origin), matching the drawing-plane editor.
17025
+ */
17026
+ var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
17027
+ /** Closed icon vocabulary so clients render a known glyph per kind. */
17028
+ var EventKindIconSchema = _enum([
17029
+ "motion",
17030
+ "audio",
16953
17031
  "person",
16954
17032
  "vehicle",
16955
17033
  "animal",
17034
+ "door",
17035
+ "pir",
17036
+ "smoke",
17037
+ "water",
17038
+ "button",
16956
17039
  "package",
16957
- "face",
16958
- "plate"
17040
+ "generic"
16959
17041
  ]);
16960
- /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
16961
- var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
16962
- /** Did a human draw this box, or did the assist propose it? */
16963
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
16964
- /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
16965
- var RetrainBboxSchema = object({
16966
- x: number(),
16967
- y: number(),
16968
- w: number(),
16969
- h: number()
17042
+ var EventKindCategorySchema = _enum([
17043
+ "motion",
17044
+ "audio",
17045
+ "detection",
17046
+ "sensor",
17047
+ "control",
17048
+ "custom",
17049
+ "package"
17050
+ ]);
17051
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
17052
+ var EventKindLevelSchema = _enum(["macro", "sub"]);
17053
+ var EventKindDescriptorSchema = object({
17054
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
17055
+ kind: string(),
17056
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
17057
+ labelKey: string(),
17058
+ /** English fallback label (kept for clients that don't translate). */
17059
+ label: string(),
17060
+ /** Hex color for timeline/legend rendering. */
17061
+ color: string(),
17062
+ /** Dictionary id → lucide component on the UI side. */
17063
+ iconId: string(),
17064
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
17065
+ icon: EventKindIconSchema,
17066
+ category: EventKindCategorySchema,
17067
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
17068
+ parentKind: string().nullable(),
17069
+ /** Derived from `parentKind`, explicit for the client tree. */
17070
+ level: EventKindLevelSchema,
17071
+ /** Which cap + device contributes this kind. For built-ins the camera
17072
+ * itself; for sensor kinds the LINKED source device. */
17073
+ source: object({
17074
+ capName: string(),
17075
+ deviceId: number()
17076
+ })
16970
17077
  });
16971
- /**
16972
- * One annotated subject.
16973
- *
16974
- * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
16975
- * (letterboxed root / zone-cropped package / subject-cropped classifier) are
16976
- * derived from it at export and never stored — storing them is how one feature
16977
- * space ends up holding two crops of the same subject (D52).
16978
- */
16979
- var RetrainAnnotationSchema = object({
16980
- id: string(),
16981
- trackId: string(),
17078
+ /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
17079
+ var EventKindsForDeviceSchema = object({
16982
17080
  deviceId: number(),
16983
- /** The COPY in retrain storage — never the source track's media key. */
16984
- mediaKey: string(),
16985
- bbox: RetrainBboxSchema,
16986
- macroClass: RetrainMacroClassSchema,
16987
- label: string().optional(),
16988
- subLabel: string().optional(),
16989
- kind: RetrainAnnotationKindSchema,
16990
- source: RetrainAnnotationSourceSchema,
16991
- /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
16992
- assistModelId: string().optional(),
16993
- assistScore: number().optional(),
16994
- exportedInBatch: string().optional(),
16995
- createdAt: number()
16996
- });
16997
- /** The write form — the server owns `id`, `createdAt` and the frame binding. */
16998
- var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
16999
- id: true,
17000
- trackId: true,
17001
- deviceId: true,
17002
- mediaKey: true,
17003
- createdAt: true,
17004
- exportedInBatch: true
17081
+ kinds: array(EventKindDescriptorSchema).readonly()
17005
17082
  });
17006
- /** A track sitting in `staging`, with everything the worklist needs to rank it. */
17007
- var RetrainTrackSchema = object({
17008
- trackId: string(),
17083
+ var SensorEventSchema = object({
17084
+ id: string(),
17085
+ /** The CAMERA the event is attributed to (a sensor linked to N cameras
17086
+ * yields N rows, one per camera). */
17009
17087
  deviceId: number(),
17010
- className: string(),
17011
- label: string().optional(),
17012
- firstSeen: number(),
17013
- lastSeen: number(),
17014
- /** How many frames the dataset already holds from this track. */
17015
- frameCount: number().int(),
17016
- /** How many subjects have been annotated on those frames. `0` with
17017
- * `frameCount: 0` is exactly "staging, still to work". */
17018
- annotationCount: number().int()
17088
+ /** The linked sensor device whose state changed. */
17089
+ sourceDeviceId: number(),
17090
+ /** Event kind id — matches an `EventKindDescriptor.kind`. */
17091
+ kind: string(),
17092
+ /** Snapshot of the sensor cap's runtime-state slice at the change. */
17093
+ value: record(string(), unknown()).nullable(),
17094
+ timestamp: number()
17019
17095
  });
17020
- /** A frame the picker may offer — an index row, no blob was read to produce it. */
17021
- var RetrainFrameCandidateSchema = object({
17022
- mediaKey: string(),
17023
- kind: MediaFileKindEnum,
17096
+ var TrackPositionSchema = object({
17097
+ x: number(),
17098
+ y: number(),
17024
17099
  timestamp: number(),
17025
- sizeBytes: number().int(),
17026
- /** A copy of this original already exists — selecting it is free and cannot
17027
- * fail, whatever became of the original. */
17028
- copied: boolean()
17029
- });
17030
- /** A frame the dataset OWNS: bytes copied at selection time. */
17031
- var RetrainFrameSchema = object({
17032
- frameId: string(),
17033
- deviceId: number(),
17034
- trackId: string(),
17035
- /** Provenance only. It may already point at nothing — that is expected. */
17036
- sourceMediaKey: string(),
17037
- sourceKind: MediaFileKindEnum,
17038
- sizeBytes: number().int(),
17039
- width: number().int(),
17040
- height: number().int(),
17041
- copiedAt: number()
17042
- });
17043
- /** Why a copy-on-select could not be honoured — named, never a silent skip. */
17044
- var RetrainCopyRefusalSchema = _enum([
17045
- "source-missing",
17046
- "unreadable-image",
17047
- "write-failed"
17048
- ]);
17049
- var RetrainFrameSelectionSchema = object({
17050
- copied: array(RetrainFrameSchema).readonly(),
17051
- refused: array(object({
17052
- sourceMediaKey: string(),
17053
- reason: RetrainCopyRefusalSchema
17054
- })).readonly()
17100
+ bbox: BoundingBoxSchema
17055
17101
  });
17056
- var RetrainFrameListSchema = object({
17057
- candidates: array(RetrainFrameCandidateSchema).readonly(),
17058
- copies: array(RetrainFrameSchema).readonly(),
17059
- /** What the page pre-selects the native key frame when one survives. */
17060
- autoPickMediaKey: string().optional()
17102
+ var TrackSnapshotSchema = object({
17103
+ timestamp: number(),
17104
+ position: TrackPositionSchema,
17105
+ /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
17106
+ mediaKey: string()
17061
17107
  });
17062
- /** What the operator asked the assist to look for. */
17063
- var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
17064
- kind: literal("package"),
17065
- zone: RetrainBboxSchema.optional()
17066
- }), object({
17067
- kind: literal("objects"),
17068
- modelId: string(),
17069
- minScore: number().optional()
17070
- })]);
17071
17108
  /**
17072
- * The assist's answer a discriminated union, because "the model saw nothing"
17073
- * and "this node cannot run that model" lead to different next moves and a
17074
- * nullable result cannot tell them apart.
17109
+ * Normalized 0..1 trajectory envelope (min/max over every position bbox,
17110
+ * divided by the track's detection-frame dims), computed at persist time.
17111
+ * Absent when the frame dims were unknown when the track was persisted
17112
+ * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
17075
17113
  */
17076
- var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
17077
- kind: literal("proposed"),
17078
- modelId: string(),
17079
- stepId: string(),
17080
- minScore: number(),
17081
- /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
17082
- proposals: array(RetrainAnnotationDraftSchema).readonly(),
17083
- /** Returned by the runner but removed by the threshold. */
17084
- belowThreshold: number().int()
17085
- }), object({
17086
- kind: literal("refused"),
17087
- /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
17088
- reason: string(),
17089
- detail: string().optional()
17090
- })]);
17091
- /** The outcome of a lifecycle move owned by the retrain page. */
17092
- var RetrainTransitionResultSchema = object({
17093
- trackId: string(),
17094
- /** Where the track ended up, whatever happened. */
17095
- retrainStatus: RetrainStatusSchema,
17096
- /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
17097
- changed: boolean(),
17098
- reason: _enum([
17099
- "unknown-track",
17100
- "no-frames-copied",
17101
- "not-staging",
17102
- "not-trained",
17103
- "unchanged"
17104
- ]).optional()
17114
+ var TrackEnvelopeSchema = object({
17115
+ minX: number(),
17116
+ minY: number(),
17117
+ maxX: number(),
17118
+ maxY: number()
17105
17119
  });
17106
- var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
17107
- var MAX_EVENT_QUERY_LIMIT = 5e3;
17108
- var DeviceEventQueryInput = object({
17109
- deviceId: number(),
17110
- since: number().optional(),
17111
- until: number().optional(),
17112
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
17113
- /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
17114
- * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
17115
- * exact behaviour. Callers may omit this field — the store defaults to
17116
- * `full` when not provided. */
17117
- projection: _enum(["full", "slim"]).optional()
17118
- });
17119
- var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
17120
- var RecentTracksQueryInput = object({
17121
- /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
17122
- deviceIds: array(number()),
17123
- /** Window lower bound on `lastSeen` (inclusive). */
17124
- since: number().optional(),
17125
- /** Window upper bound on `lastSeen` (inclusive). */
17126
- until: number().optional(),
17127
- /** Page size. Default 200, max 1000. */
17128
- limit: number().int().min(1).max(1e3).default(200),
17129
- /** Opaque continuation cursor from a previous page's `nextCursor`.
17130
- * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
17131
- cursor: string().optional(),
17132
- /** See {@link TrackProjectionSchema}. Default `full`. */
17133
- projection: TrackProjectionSchema.optional(),
17134
- /** Include stationary-promoted rows (parked objects). Default false: the
17135
- * feed lists passages; parking records live on the stationary registry. */
17136
- includeStationary: boolean().optional()
17137
- });
17138
- var RecentTracksPageSchema = object({
17139
- /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
17140
- tracks: array(TrackSchema).readonly(),
17141
- /** Cursor for the next page, or null when this page is the last. */
17142
- nextCursor: string().nullable()
17143
- });
17144
- var LIST_GROUPS_DEFAULT_LIMIT = 40;
17145
- var LIST_GROUPS_MAX_LIMIT = 100;
17146
- var AnalyticsGroupRecordSchema = object({
17147
- id: string(),
17148
- deviceId: number().int(),
17149
- openedAt: number().int(),
17150
- closedAt: number().int(),
17151
- timestamp: number().int(),
17152
- memberCount: number().int(),
17153
- memberTrackIds: array(string()).readonly(),
17154
- className: string(),
17155
- classes: array(string()).readonly(),
17156
- /** Relative event-media path, or null when the group has no picture yet. */
17157
- mediaUrl: string().nullable(),
17158
- singleton: boolean()
17159
- });
17160
- var AnalyticsGroupMemberSchema = object({
17161
- trackId: string(),
17162
- deviceId: number().int(),
17163
- className: string(),
17164
- firstSeen: number().int(),
17165
- lastSeen: number().int(),
17166
- mediaUrl: string().nullable()
17167
- });
17168
- var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
17169
- var ListGroupsQueryInput = object({
17170
- /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
17171
- deviceIds: array(number()),
17172
- /** Window lower bound on `closedAt` (inclusive). */
17173
- since: number().optional(),
17174
- /** Window upper bound on `openedAt` (inclusive). */
17175
- until: number().optional(),
17176
- limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
17177
- /** Opaque continuation cursor from a previous page's `nextCursor`. */
17178
- cursor: string().optional()
17179
- });
17180
- var ListGroupsPageSchema = object({
17181
- groups: array(AnalyticsGroupRecordSchema).readonly(),
17182
- nextCursor: string().nullable()
17183
- });
17184
- var KeyEventQueryInput = object({
17185
- deviceId: number(),
17186
- /** Window lower bound (track firstSeen ≥ since). */
17187
- since: number(),
17188
- /** Window upper bound (track firstSeen ≤ until). */
17189
- until: number(),
17190
- limit: number().int().min(1).max(200).default(50),
17191
- /** Drop tracks scoring below this importance. */
17192
- minImportance: number().min(0).max(1).optional(),
17193
- /** Restrict to a single class (e.g. 'person'). */
17194
- classFilter: string().optional()
17195
- });
17196
- var KeyEventSchema = object({
17197
- /** The representative event id (the track's best ObjectEvent, else its trackId). */
17198
- id: string(),
17199
- trackId: string(),
17200
- /** Track start time (firstSeen). */
17201
- timestamp: number(),
17202
- className: string(),
17203
- ...TieredLabelFields,
17204
- importance: number(),
17205
- /** Highest-confidence ObjectEvent id for the track (empty when none). */
17206
- bestEventId: string(),
17207
- /** Track lifetime in ms (lastSeen - firstSeen). */
17208
- windowMs: number().optional(),
17209
- ...TrackFlagFields,
17210
- ...TrackRetrainFields
17211
- });
17212
- object({
17213
- trackId: string(),
17214
- className: string(),
17215
- confidence: number(),
17216
- bbox: BoundingBoxSchema,
17217
- zones: array(string()).readonly(),
17218
- state: TrackStateSchema
17219
- });
17220
- var OverlayDetectionSchema = looseObject({
17221
- id: string(),
17222
- kind: _enum(["first-level", "detail"]),
17223
- macroClass: string(),
17224
- score: number(),
17225
- bbox: object({
17226
- x: number(),
17227
- y: number(),
17228
- width: number(),
17229
- height: number()
17230
- }),
17231
- labels: array(looseObject({
17232
- label: string(),
17233
- score: number()
17234
- })).readonly(),
17235
- parentId: string().optional()
17236
- });
17237
- var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
17238
- var SearchObjectEventsInput = object({
17239
- text: string(),
17240
- deviceId: number().optional(),
17241
- since: number().optional(),
17242
- until: number().optional(),
17243
- classFilter: string().optional(),
17244
- limit: number().default(50),
17245
- minScore: number().min(0).max(1).default(.2)
17246
- });
17247
- var TrackCascadeCountsSchema = object({
17248
- /** Persisted track roots deleted (authoritative). */
17249
- tracks: number().int(),
17250
- /** Object events removed with their tracks (best-effort; see note above). */
17251
- events: number().int(),
17252
- /** Track/face/plate-owned media removed (best-effort). Never identity media. */
17253
- media: number().int(),
17254
- /** Unassigned (non-enrolled) face reads removed (best-effort). */
17255
- faces: number().int(),
17256
- /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
17257
- plates: number().int(),
17258
- /** Per-track CLIP search vectors removed (best-effort). */
17259
- embeddings: number().int(),
17260
- /** Group membership + group rows removed with their last member (best-effort). */
17261
- groups: number().int()
17262
- });
17263
- /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
17264
- var DiskReconcileCountsSchema = object({
17265
- mediaDropped: number().int(),
17266
- tracks: number().int(),
17267
- events: number().int()
17268
- });
17269
- /** Event-store footprint for one camera. */
17270
- var EventStoreDeviceFootprintSchema = object({
17271
- deviceId: number(),
17272
- /** Persisted event rows (motion + object + audio) for the camera. */
17273
- rows: number().int(),
17274
- /** Event-owned media bytes on disk for the camera. */
17275
- bytes: number().int()
17276
- });
17277
- /** Aggregate event-store footprint: global totals + per-camera breakdown. */
17278
- var EventStoreFootprintSchema = object({
17279
- totalRows: number().int(),
17280
- totalBytes: number().int(),
17281
- devices: array(EventStoreDeviceFootprintSchema).readonly()
17282
- });
17283
- /** Per-kind counts returned by the event-prune / device-delete mutations. */
17284
- var EventPruneCountsSchema = object({
17285
- motion: number().int(),
17286
- object: number().int(),
17287
- audio: number().int()
17120
+ /**
17121
+ * Row projection for track list queries. `full` (default) returns the
17122
+ * complete Track including the frame-rate `positions[]` history and the
17123
+ * `snapshots[]` references — megabytes across a page of tracks. `slim`
17124
+ * keeps every scalar the list surfaces actually render (ids, class(es),
17125
+ * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
17126
+ * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
17127
+ * `snapshots` as EMPTY arrays detail views re-fetch the full row via
17128
+ * `getTrack`. Mirrors the event-store `projection` convention
17129
+ * (`getObjectEvents` et al.).
17130
+ */
17131
+ var TrackProjectionSchema = _enum(["full", "slim"]);
17132
+ /**
17133
+ * One audio-classification label heard on the track's camera while the
17134
+ * track was alive, aggregated per label. An "episode" is one persisted
17135
+ * audio event (the confident-classification path: score the device's
17136
+ * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
17137
+ * one 32 ms inference chunk, so counts stay human-scaled.
17138
+ */
17139
+ var TrackAudioLabelSchema = object({
17140
+ label: string(),
17141
+ /** Highest classification score observed across the label's episodes. */
17142
+ peakScore: number(),
17143
+ /** Number of coalesced audio-event episodes carrying this label. */
17144
+ count: number(),
17145
+ firstAt: number(),
17146
+ lastAt: number()
17288
17147
  });
17289
17148
  /**
17290
- * Re-embed stored tracks from their key frames.
17149
+ * How a track was produced. `pipeline` (default / absent) = the spatial
17150
+ * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
17151
+ * no positions, a single snapshot, and no bbox trajectory at all:
17291
17152
  *
17292
- * The reason this is an operator-callable method and not a migration script:
17293
- * every knob that decides what a vector MEANS encoder model, crop margin,
17294
- * squaring is only changeable if the existing vectors can be regenerated.
17295
- * Mixing feature spaces in one index makes cosine scores incomparable, and the
17296
- * symptom is a quality regression with no visible cause.
17153
+ * - `sensor` a linked sensor/control device state change.
17154
+ * - `audio` an audio event on the camera itself that was anomalous for
17155
+ * THAT camera, loud, and heard while nothing visual was happening (D62).
17156
+ *
17157
+ * The spatial subsystems (tracker association, occupancy count, re-id /
17158
+ * embedding, resurrection) MUST skip every synthetic source. Test for that
17159
+ * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
17160
+ * check silently readmits every source added after it was written.
17297
17161
  */
17298
- var RebuildObjectEmbeddingsInput = object({
17299
- /** Restrict to one camera. Omit for the whole fleet. */
17300
- deviceId: number().optional(),
17301
- since: number().optional(),
17302
- until: number().optional(),
17303
- /** Stop after this many tracks; the result reports whether more remain. */
17304
- maxTracks: number().int().positive().optional(),
17305
- /**
17306
- * Run every embedding on THIS node instead of round-robining the fleet.
17307
- *
17308
- * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
17309
- * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
17310
- * calling it that would pin the rebuild REQUEST itself to that node — the
17311
- * rebuild orchestration lives on the hub, and only the per-track step runs
17312
- * remotely. This field is data; the per-track pin is applied inside.
17313
- *
17314
- * Absent ⇒ round-robin over every online node whose runner can serve the
17315
- * pinned model.
17316
- */
17317
- executeOnNodeId: string().optional(),
17318
- /**
17319
- * Milliseconds to wait between tracks; omit for the built-in default, `0` to
17320
- * run flat out.
17321
- *
17322
- * A rebuild is bulk maintenance on hub-main's single thread. Measured
17323
- * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
17324
- * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
17325
- * force is logged at start and finish so a deliberately slow pass reads
17326
- * differently from a stalled one.
17327
- */
17328
- pacingMs: number().int().nonnegative().optional()
17329
- });
17162
+ var TrackSourceSchema = _enum([
17163
+ "pipeline",
17164
+ "sensor",
17165
+ "audio"
17166
+ ]);
17330
17167
  /**
17331
- * Result of emptying the CLIP index.
17168
+ * Where a track sits in the RETRAIN lifecycle (D81).
17332
17169
  *
17333
- * The clean slate before a policy change: a new crop margin or encoder model
17334
- * leaves two feature spaces in one index whose cosine scores are not
17335
- * comparable, so wiping and rebuilding is the only way to be sure every vector
17336
- * means the same thing.
17170
+ * - `none` never marked, or un-marked. Evictable.
17171
+ * - `staging` the operator wants this track as training material and has not
17172
+ * finished with it. **This is the only state retention holds**: the track and
17173
+ * everything it owns (object events, crops, keyframes, CLIP vector) survive
17174
+ * the device's age window.
17175
+ * - `trained` — the retrain page has taken what it needed. The frames it chose
17176
+ * were COPIED into the retrain dataset at selection time, so the dataset no
17177
+ * longer depends on the track's media and the track becomes EVICTABLE again.
17178
+ * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
17179
+ * a deliberate action of the retrain page, not a side effect of a checkbox.
17180
+ *
17181
+ * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
17182
+ * the store's filter language has only positive equality and `whereIn` — no
17183
+ * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
17184
+ * would make the entire pre-column history immortal in one deploy.
17337
17185
  */
17338
- var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
17186
+ var RetrainStatusSchema = _enum([
17187
+ "none",
17188
+ "staging",
17189
+ "trained"
17190
+ ]);
17339
17191
  /**
17340
- * Acknowledgement that a rebuild STARTED.
17192
+ * Per-track OPERATOR flags set by hand from the admin UI or the viewer, never
17193
+ * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
17194
+ * so the two surfaces cannot drift.
17341
17195
  *
17342
- * The pass costs ~1s per track 45 minutes for a 2,600-track fleet so it
17343
- * runs detached and this returns immediately. Waiting for it made the client
17344
- * time out while the work carried on server-side, which is the worst of both:
17345
- * no result and no way to know it was still going. Poll
17346
- * `getObjectEmbeddingRebuildStatus` for progress.
17347
- */
17348
- var RebuildObjectEmbeddingsResultSchema = object({
17349
- started: boolean(),
17350
- /** True when a pass was already running; the new request is ignored. */
17351
- alreadyRunning: boolean()
17352
- });
17353
- var RebuildStatusSchema = object({
17354
- running: boolean(),
17355
- scanned: number(),
17356
- rebuilt: number(),
17357
- /** Tracks whose key frame is gone nothing to re-embed from. */
17358
- missingKeyFrame: number(),
17359
- /** Tracks with no usable detection box. */
17360
- missingBbox: number(),
17361
- /**
17362
- * Tracks an executing node REFUSED rather than broke on — an unreadable key
17363
- * frame, a step that threw. Separate from `failed` because the remedy is
17364
- * different, and because a whole camera silently contributing zero vectors
17365
- * is the shape of failure a rebuild must never hide.
17366
- */
17367
- notRunnable: number(),
17196
+ * **Absent false.** A track that has never been touched omits the field; an
17197
+ * explicitly un-flagged track carries `false`. Legacy rows written before the
17198
+ * columns existed read as absent, and a consumer that needs a boolean should say
17199
+ * `flag === true`, not `flag !== false`.
17200
+ *
17201
+ * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
17202
+ * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
17203
+ * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
17204
+ * `trained` track reports `false` while refusing both writes. The boolean is
17205
+ * kept because three surfaces drive a toggle off it; anything that needs to tell
17206
+ * "never marked" from "already trained" must read `retrainStatus`.
17207
+ *
17208
+ * `debug` does NOT pin; it is attention, not durability.
17209
+ *
17210
+ * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
17211
+ * A favourited track is skipped by retention the same way `staging` is, but
17212
+ * it does not enter `none|staging|trained` and has no staging budget.
17213
+ */
17214
+ var TrackFlagFields = {
17215
+ /** Operator marked this track as training material — i.e. `retrainStatus` is
17216
+ * `'staging'`. */
17217
+ markForTrain: boolean().optional(),
17218
+ /** Operator marked this track for diagnostic attention. */
17219
+ debug: boolean().optional(),
17220
+ /** Operator favourited this track. Pins it against pruning. */
17221
+ favourited: boolean().optional()
17222
+ };
17223
+ /**
17224
+ * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
17225
+ * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
17226
+ * write patch, and the status is not something the toggle sets — it is what the
17227
+ * toggle's boolean is derived from. Absent on an in-RAM track never touched;
17228
+ * always present on a persisted row (the column default materialises `'none'`).
17229
+ */
17230
+ var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
17231
+ /**
17232
+ * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
17233
+ * one flag can never clear the other — the toggles are independent and are
17234
+ * driven from three surfaces that do not know about each other.
17235
+ */
17236
+ var TrackFlagsPatchSchema = object(TrackFlagFields);
17237
+ /**
17238
+ * The resolved flag state after a write. Both fields are REQUIRED here (absent
17239
+ * collapses to `false`) so a caller can drive a toggle's checked state off the
17240
+ * mutation result without a re-fetch.
17241
+ */
17242
+ var TrackFlagsSchema = object({
17243
+ trackId: string(),
17244
+ markForTrain: boolean(),
17245
+ debug: boolean(),
17246
+ favourited: boolean(),
17247
+ /** The lifecycle state the boolean was derived from. Required here (unlike on
17248
+ * a track row) because this shape is only ever produced by the write body,
17249
+ * which always knows it — and a surface that has just written needs to render
17250
+ * `trained` without a re-fetch. */
17251
+ retrainStatus: RetrainStatusSchema
17252
+ });
17253
+ union([literal(1), literal(2)]);
17254
+ /**
17255
+ * WHO decided a label, and when. Carried per tier so a value can be traced to
17256
+ * the step and model that produced it — which is what makes the write rule
17257
+ * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
17258
+ * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
17259
+ *
17260
+ * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
17261
+ * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
17262
+ * `migration:4g` for a value the 4g migration moved from the single-slot era —
17263
+ * that value has no provenance, and the write rule lets ANY properly-attributed
17264
+ * write of the same tier replace it regardless of score.
17265
+ */
17266
+ var LabelAttributionSchema = object({
17267
+ stepId: string(),
17268
+ modelId: string().optional(),
17269
+ decidedAt: number(),
17368
17270
  /**
17369
- * The pass stopped because NO node could serve the pinned model.
17271
+ * The GALLERY id behind a recognised tier-2 label a face-gallery
17272
+ * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
17370
17273
  *
17371
- * Distinct from `notRunnable` on purpose: that one says "this track was
17372
- * refused", this one says "the cluster cannot do this work at all" — every
17373
- * candidate node either lacks the `clip-embedding` step, lacks a build of the
17374
- * pinned model for its engine format, or dropped out. The remedy is a model /
17375
- * engine change, not a per-camera one. Non-zero here always comes with
17376
- * `complete: false`.
17274
+ * The text alone is a DISPLAY NAME, and a display name is renameable: a
17275
+ * notification rule authored on "Gianluca" stopped matching the moment the
17276
+ * operator fixed the spelling in the gallery, and nothing said so. The id is
17277
+ * the thing that does not move, so it is what a rule matches on
17278
+ * (`NcConditions.identities`) and the text is what a human is shown.
17279
+ *
17280
+ * Absent when the label names no gallery row — a plate the OCR read but no
17281
+ * vehicle claims, a sub-class, a species, any tier-1 value.
17377
17282
  */
17378
- noCapableNode: number(),
17379
- failed: number(),
17380
- /** Set once a pass ends: true only when EVERYTHING was covered. */
17381
- complete: boolean().nullable(),
17382
- startedAtMs: number().nullable(),
17383
- finishedAtMs: number().nullable(),
17384
- /** Present when the pass ended by throwing. */
17385
- error: string().nullable()
17283
+ identityId: string().optional()
17386
17284
  });
17387
- DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
17388
- deviceId: number(),
17389
- trackId: string()
17390
- }), TrackSchema.nullable()), method(object({
17391
- deviceId: number(),
17392
- since: number().optional(),
17393
- until: number().optional(),
17394
- limit: number().optional(),
17395
- /** Spatial filter — only tracks whose trajectory intersects the zone
17396
- * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
17397
- * envelope columns, then precisely tested per position. Tracks with
17398
- * an unknown envelope (no frame dims at persist time) always match. */
17399
- zone: TrackZoneFilterSchema.optional(),
17400
- /** See {@link TrackProjectionSchema}. Default `full` (backward
17401
- * compatible omitting the field keeps today's exact behaviour). */
17402
- projection: TrackProjectionSchema.optional(),
17403
- /** Include stationary-promoted rows (parked objects handed to the
17404
- * stationary registry). Default false: the timeline lists passages,
17405
- * not parking records (operator decision, 2026-08-15). */
17406
- includeStationary: boolean().optional()
17407
- }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
17408
- deviceId: number(),
17409
- groupId: string().min(1)
17410
- }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
17411
- kind: "mutation",
17412
- auth: "admin"
17413
- }), 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({
17414
- deviceId: number(),
17415
- since: number().optional(),
17416
- until: number().optional(),
17417
- kinds: array(string()).optional(),
17418
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
17419
- }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
17420
- deviceId: number(),
17421
- since: number(),
17422
- until: number(),
17423
- bucketMs: number().int().positive()
17424
- }), array(object({
17425
- bucketStart: number(),
17426
- motion: number().int(),
17427
- object: number().int(),
17428
- audio: number().int()
17429
- })).readonly()), method(object({
17430
- deviceId: number(),
17431
- cutoffMs: number()
17432
- }), object({
17433
- motion: number().int(),
17434
- object: number().int(),
17435
- audio: number().int()
17436
- }), {
17437
- kind: "mutation",
17438
- auth: "admin"
17439
- }), method(object({
17440
- deviceId: number(),
17441
- cutoffMs: number()
17442
- }), TrackCascadeCountsSchema, {
17443
- kind: "mutation",
17444
- auth: "admin"
17445
- }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
17446
- kind: "mutation",
17447
- auth: "admin"
17448
- }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
17449
- kind: "mutation",
17450
- auth: "admin"
17451
- }), method(object({
17452
- deviceId: number(),
17453
- trackIds: array(string()).min(1)
17454
- }), object({
17455
- deleted: number().int(),
17456
- failed: array(string()).readonly()
17457
- }), {
17458
- kind: "mutation",
17459
- auth: "admin"
17460
- }), method(object({
17461
- /** Log/audit scope only — the trackId is globally unique on its own. */
17285
+ /**
17286
+ * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
17287
+ * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
17288
+ * track and its events always answer the same question the same way.
17289
+ *
17290
+ * Two scalar columns, not an array: every consumer wants "the coarse one" or
17291
+ * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
17292
+ * is tier 2, and each carries its own score + attribution.
17293
+ *
17294
+ * **Reading it.** What a human should be shown is `subLabel ?? label` — the
17295
+ * finest thing known. Before 4g the single `label` column held the finest
17296
+ * value, so a consumer that has not been updated reads the tier-1 slot and
17297
+ * shows nothing on a species-only row; that is why the migration puts every
17298
+ * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
17299
+ * and why the read surfaces were changed in the same train.
17300
+ *
17301
+ * **Writing it.** The slots are independent, which is the whole point: a
17302
+ * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
17303
+ * migratorius`), so fineness cannot regress by construction. Within a tier the
17304
+ * higher score wins. One rule, one implementation — see
17305
+ * `pipeline/label-tier.ts` in addon-post-analysis.
17306
+ */
17307
+ var TieredLabelFields = {
17308
+ /** Tier 1 the sub-class. See {@link LabelTierSchema}. */
17309
+ label: string().optional(),
17310
+ /** Confidence of the tier-1 value, as reported by the deciding step. */
17311
+ labelScore: number().optional(),
17312
+ /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
17313
+ labelMeta: LabelAttributionSchema.optional(),
17314
+ /** Tier 2 — the instance. See {@link LabelTierSchema}. */
17315
+ subLabel: string().optional(),
17316
+ /** Confidence of the tier-2 value, as reported by the deciding step. */
17317
+ subLabelScore: number().optional(),
17318
+ /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
17319
+ subLabelMeta: LabelAttributionSchema.optional()
17320
+ };
17321
+ /** Per-camera slice of a training-export estimate. */
17322
+ var TrainingExportDeviceTotalsSchema = object({
17462
17323
  deviceId: number(),
17324
+ tracks: number().int(),
17325
+ files: number().int(),
17326
+ bytes: number().int()
17327
+ });
17328
+ /**
17329
+ * What a training export WOULD contain. Computed from media index rows only —
17330
+ * no blob is read to produce this.
17331
+ */
17332
+ var TrainingExportSummarySchema = object({
17333
+ generatedAt: number(),
17334
+ trackCount: number().int(),
17335
+ fileCount: number().int(),
17336
+ byteCount: number().int(),
17337
+ /** More marked tracks exist than a single pass carries. */
17338
+ truncated: boolean(),
17339
+ devices: array(TrainingExportDeviceTotalsSchema).readonly()
17340
+ });
17341
+ var TrackSchema = object({
17463
17342
  trackId: string(),
17464
- flags: TrackFlagsPatchSchema
17465
- }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
17466
- kind: "query",
17467
- auth: "admin"
17468
- }), method(object({
17469
- olderThanMs: number(),
17470
- reason: OpsLogReasonSchema.optional()
17471
- }), EventPruneCountsSchema, {
17472
- kind: "mutation",
17473
- auth: "admin"
17474
- }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
17475
- kind: "mutation",
17476
- auth: "admin"
17477
- }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
17478
- kind: "mutation",
17479
- auth: "admin"
17480
- }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
17481
- kind: "mutation",
17482
- auth: "admin"
17483
- }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
17484
- kind: "mutation",
17485
- auth: "admin"
17486
- }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
17487
- kind: "mutation",
17488
- auth: "admin"
17489
- }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
17490
- kind: "mutation",
17491
- auth: "admin"
17492
- }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
17493
- kind: "query",
17494
- auth: "admin"
17495
- }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
17496
- kind: "query",
17497
- auth: "admin"
17498
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
17499
- kind: "query",
17500
- auth: "admin"
17501
- }), method(object({
17502
- /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
17503
- * `deviceId`, deliberately: `deviceId` would make this device-bound and
17504
- * route it at one camera's owner, and "every camera" would stop being
17505
- * expressible at all. */
17506
- deviceIds: array(number()).optional(),
17507
- limit: number().int().min(1).max(500).optional()
17508
- }), array(RetrainTrackSchema).readonly(), {
17509
- kind: "query",
17510
- auth: "admin"
17511
- }), method(object({ trackId: string() }), RetrainFrameListSchema, {
17512
- kind: "query",
17513
- auth: "admin"
17514
- }), method(object({
17515
17343
  deviceId: number(),
17516
- trackId: string(),
17517
- mediaKeys: array(string()).min(1)
17518
- }), RetrainFrameSelectionSchema, {
17519
- kind: "mutation",
17520
- auth: "admin"
17521
- }), method(object({
17344
+ className: string(),
17345
+ ...TieredLabelFields,
17346
+ producingDeviceName: string().optional(),
17347
+ /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
17348
+ source: TrackSourceSchema.optional(),
17349
+ firstSeen: number(),
17350
+ lastSeen: number(),
17351
+ /** Frame-rate position history (subject to maxPositionHistory cap). */
17352
+ positions: array(TrackPositionSchema).readonly(),
17353
+ /** Periodic snapshots at snapshotIntervalMs cadence (subject to
17354
+ * saveThumbnails policy). */
17355
+ snapshots: array(TrackSnapshotSchema).readonly(),
17356
+ /** Deduplicated zones the track has entered at least once. Zone IDS. */
17357
+ zonesVisited: array(string()).readonly(),
17358
+ /**
17359
+ * Human NAMES for {@link zonesVisited}, resolved at READ time against the
17360
+ * `zones` capability.
17361
+ *
17362
+ * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
17363
+ * and no card can render — so every free-text search surface was structurally
17364
+ * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
17365
+ * just returned nothing. Resolving here rather than in each client keeps ONE
17366
+ * derivation and costs the clients no extra call (the `zones` cap is
17367
+ * per-device, so a client-side resolve would be a per-camera fan-out on a
17368
+ * surface built to avoid exactly that).
17369
+ *
17370
+ * Resolved, never invented: a zone deleted since the track was written has no
17371
+ * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
17372
+ * two are not positionally aligned. Absent when the track visited no zone, or
17373
+ * when the zone catalogue could not be read.
17374
+ */
17375
+ zoneNames: array(string()).readonly().optional(),
17376
+ /** Deduplicated set of detector classes observed for this track over its
17377
+ * life (a track may be reclassified, e.g. person→vehicle). Absent on
17378
+ * legacy rows written before class accumulation shipped. */
17379
+ classes: array(string()).readonly().optional(),
17380
+ /** Cumulative normalized distance travelled (0..1 units = full frame width). */
17381
+ totalDistance: number(),
17382
+ state: TrackStateSchema,
17383
+ active: boolean(),
17384
+ /** Deterministic key-event importance score in [0,1] (server-computed at
17385
+ * track expiry, recomputed on late label). Absent on legacy rows written
17386
+ * before scoring shipped — consumers degrade to absence / compute-on-read. */
17387
+ importance: number().optional(),
17388
+ /** Id of the track's highest-confidence ObjectEvent (its representative
17389
+ * "best" frame). Absent when the track produced no object events. */
17390
+ bestEventId: string().optional(),
17391
+ /** Tag of the importance sub-signal that dominated the score
17392
+ * (identity|dwell|proximity|class|confidence|travel|zone). */
17393
+ importanceReason: string().optional(),
17394
+ /** Audio-classification labels heard on the camera during the track's
17395
+ * life (score ≥ device `classificationMinScore`), aggregated per label.
17396
+ * Absent on legacy rows / tracks with no confident audio. */
17397
+ audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
17398
+ /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
17399
+ * Populated from the persisted envelope columns on historical reads;
17400
+ * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
17401
+ envelope: TrackEnvelopeSchema.optional(),
17402
+ /**
17403
+ * A face DETECTOR found a face on this track — nothing more. It says the
17404
+ * detail plane produced a `face` detail; it does NOT say the face was
17405
+ * embedded, matched, above `minFacePx`, or that the recognizer was even
17406
+ * enabled. Set once and never cleared.
17407
+ *
17408
+ * **This exists so "face present but not recognised" is expressible.** A
17409
+ * recognised identity lands in `subLabel` (attributed to the face chain via
17410
+ * `subLabelMeta.stepId`), so before this field a track with an unmatched face
17411
+ * and a track with no face at all were byte-identical on the wire and no
17412
+ * surface could tell them apart. The read is `hasFace === true && subLabel
17413
+ * === undefined`.
17414
+ *
17415
+ * **Absent ≠ false.** Every row written before the column existed omits it,
17416
+ * and so does every server that predates the field — a consumer must test
17417
+ * `=== true` and render nothing otherwise, never infer "no face".
17418
+ */
17419
+ hasFace: boolean().optional(),
17420
+ /**
17421
+ * This track has a face row IN THE GALLERY: a crop **and** an embedding — a
17422
+ * face an operator could ASSIGN to an identity.
17423
+ *
17424
+ * The STRICT twin of {@link hasFace}, and the pair only earns its keep
17425
+ * because the two disagree. `hasFace` is stamped at the TOP of the face
17426
+ * branch, before every gate, and means no more than "a face detector produced
17427
+ * a face detail". This one is stamped at the single moment the gallery row
17428
+ * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
17429
+ * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
17430
+ * candidate gate, the imageless-track drop (no crop was ever captured) and
17431
+ * the crop-store drop. Everything between the detector and that insert can
17432
+ * legitimately refuse the face, so a flag written any earlier promises the
17433
+ * operator something to assign and delivers nothing.
17434
+ *
17435
+ * **Independent of recognition.** A face collected but never auto-matched is
17436
+ * still assignable — it is in fact the face an operator most wants to reach —
17437
+ * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
17438
+ * `subLabel`; this says only that the raw material exists.
17439
+ *
17440
+ * **Set once, never cleared.** A track that produced a gallery row produced
17441
+ * one; deleting the row later is the gallery's business, not this flag's.
17442
+ *
17443
+ * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
17444
+ * before the column omits it, and so does every server that predates the
17445
+ * field. A consumer must test `=== true` and render nothing otherwise —
17446
+ * never infer "no assignable face".
17447
+ */
17448
+ hasEmbeddedFace: boolean().optional(),
17449
+ /**
17450
+ * This subject CONTAINS a folded rider — a person the rider-pairing step
17451
+ * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
17452
+ * so the passage is tracked once and as a VEHICLE.
17453
+ *
17454
+ * It exists because the fold's record was dishonest. D34 and the code both
17455
+ * said "the person is not lost — it is reported so both entities stay on the
17456
+ * record"; in fact the pair went into a per-processor RAM field behind an
17457
+ * accessor nobody called, and every durable surface said `vehicle`, full
17458
+ * stop. This is the composition note that makes the row true.
17459
+ *
17460
+ * A COMPOSITION, never a class and never a label. "This vehicle contains a
17461
+ * person" is not an answer to "what is this" — both label tiers would refuse
17462
+ * a macro token anyway (D89), and correctly. Nothing here changes what the
17463
+ * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
17464
+ * and a `person` rule still does not fire for someone cycling past.
17465
+ *
17466
+ * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
17467
+ * the column, and every hub that predates the field, omits it. Test
17468
+ * `=== true` and render nothing otherwise — never infer "no rider".
17469
+ */
17470
+ hasRider: boolean().optional(),
17471
+ ...TrackFlagFields,
17472
+ ...TrackRetrainFields
17473
+ });
17474
+ var BaseEventFields = {
17475
+ id: string(),
17522
17476
  deviceId: number(),
17523
- trackId: string(),
17524
- frameId: string()
17525
- }), object({
17526
- removed: boolean(),
17527
- removedAnnotations: number().int()
17528
- }), {
17529
- kind: "mutation",
17530
- auth: "admin"
17531
- }), method(object({ frameId: string() }), object({
17477
+ timestamp: number()
17478
+ };
17479
+ var MotionEventSchema = object({
17480
+ ...BaseEventFields,
17481
+ kind: literal("motion"),
17482
+ regionCount: number(),
17483
+ /** Heavy JSON array — omitted in slim projection. */
17484
+ regions: array(object({
17485
+ bbox: BoundingBoxSchema,
17486
+ pixelCount: number(),
17487
+ intensity: number()
17488
+ })).readonly().optional(),
17489
+ /** Omitted in slim projection. */
17490
+ frameWidth: number().optional(),
17491
+ /** Omitted in slim projection. */
17492
+ frameHeight: number().optional(),
17493
+ /** Populated by B5 (recording playback URL for this event). */
17494
+ mediaUrl: string().optional()
17495
+ });
17496
+ /**
17497
+ * Which detection SOURCE produced an object event. `pipeline` = the ML
17498
+ * detection pipeline (decoded-frame inference); `onboard` = the camera's
17499
+ * native on-device AI. Both flow through the SAME analysis layers (zoning,
17500
+ * tracking, per-kind persistence) but stay distinguishable so consumers
17501
+ * (advanced-notifier, occupancy, …) can select which source(s) to act on.
17502
+ * Absent on legacy rows ⇒ treat as `pipeline`.
17503
+ */
17504
+ var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
17505
+ /**
17506
+ * The confirmed zone crossing that produced an object event. Present ONLY on
17507
+ * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
17508
+ * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
17509
+ * appearance event carry none, so a rule asking for a direction fails closed
17510
+ * on them.
17511
+ *
17512
+ * Exactly ONE crossing per event: the emitter turns each confirmed crossing
17513
+ * into its own event, so a frame in which a track enters A while leaving B
17514
+ * produces two events with two directions — never one ambiguous row.
17515
+ *
17516
+ * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
17517
+ * membership the box has NOW, and by definition it no longer contains the zone
17518
+ * that was just left. Without the id here, a zone-scoped rule could never match
17519
+ * the exit it asked for.
17520
+ */
17521
+ var ZoneCrossingSchema = object({
17522
+ direction: _enum(["enter", "exit"]),
17523
+ /** Admin zone id crossed. */
17524
+ zoneId: string(),
17525
+ /** Zone display name at crossing time (falls back to the id). */
17526
+ zoneName: string().optional()
17527
+ });
17528
+ var ObjectEventSchema = object({
17529
+ ...BaseEventFields,
17530
+ kind: literal("object"),
17531
+ /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
17532
+ source: DetectionSourceSchema.optional(),
17533
+ /**
17534
+ * Inference-frame id shared by every object event emitted from the SAME frame
17535
+ * — the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
17536
+ * 2 people + 1 dog) under one full frame, and link a track's frames over time
17537
+ * (group by `trackId`, pick a representative `frameId` as the parent frame).
17538
+ * Optional for backward-compat with pre-existing rows / the slim projection
17539
+ * includes it (it is light). Absent on rows written before this field.
17540
+ */
17541
+ frameId: string().optional(),
17542
+ /** Omitted in slim projection. */
17543
+ trackId: string().optional(),
17544
+ className: string(),
17545
+ ...TieredLabelFields,
17546
+ /** Omitted in slim projection. */
17547
+ confidence: number().optional(),
17548
+ /** Heavy JSON — omitted in slim projection. */
17549
+ bbox: BoundingBoxSchema.optional(),
17550
+ /** Heavy JSON — omitted in slim projection. */
17551
+ zones: array(string()).readonly().optional(),
17552
+ /** Omitted in slim projection. */
17553
+ state: TrackStateSchema.optional(),
17554
+ /**
17555
+ * The zone crossing this event IS, when it is one. Absent on every other
17556
+ * event kind (movement state, appearance, package) — see
17557
+ * {@link ZoneCrossingSchema}. Omitted in slim projection.
17558
+ */
17559
+ zoneCrossing: ZoneCrossingSchema.optional(),
17560
+ /** Detection-frame dimensions in pixels — let consumers normalize the
17561
+ * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
17562
+ frameWidth: number().optional(),
17563
+ frameHeight: number().optional(),
17564
+ /** MediaStore key for the crop attached to this event (if any). */
17565
+ mediaKey: string().optional(),
17566
+ /** Design B: MediaStore key of the track's native-resolution key frame (the
17567
+ * best-detection full frame). Resolve via the event-media data-plane
17568
+ * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
17569
+ * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
17570
+ * sources — consumers fall back to `mediaKey` (the tight crop). */
17571
+ keyFrameMediaKey: string().optional(),
17572
+ /** Populated by B5 (recording playback URL for this event). */
17573
+ mediaUrl: string().optional(),
17574
+ /** The parent track's key-event importance [0,1], propagated to every object
17575
+ * event of the track (so an event row can be sorted by importance without a
17576
+ * track join). Absent on legacy rows / before the track was scored. */
17577
+ importance: number().optional()
17578
+ });
17579
+ var AudioEventSchema = object({
17580
+ ...BaseEventFields,
17581
+ kind: literal("audio"),
17582
+ rms: number(),
17583
+ dbfs: number(),
17584
+ classification: object({
17585
+ className: string(),
17586
+ originalClass: string().optional(),
17587
+ score: number()
17588
+ }).optional(),
17589
+ /** Populated by B5 (recording playback URL for this event). */
17590
+ mediaUrl: string().optional()
17591
+ });
17592
+ var MediaFileKindEnum = _enum([
17593
+ "crop",
17594
+ "thumbnail",
17595
+ "snapshot",
17596
+ "firstFrame",
17597
+ "lastFrame",
17598
+ "fullFrame",
17599
+ "fullFrameBoxed",
17600
+ "faceCrop",
17601
+ "plateCrop",
17602
+ "keyFrame",
17603
+ "keyFrameSmall",
17604
+ "thumbnailSmall"
17605
+ ]);
17606
+ var MediaFileSchema = object({
17607
+ key: string(),
17608
+ kind: MediaFileKindEnum,
17532
17609
  base64: string(),
17533
- width: number().int(),
17534
- height: number().int()
17535
- }), {
17536
- kind: "query",
17537
- auth: "admin"
17538
- }), method(object({
17539
- deviceId: number(),
17540
- trackId: string(),
17541
- frameId: string(),
17542
- subject: RetrainAssistSubjectSchema,
17543
- /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
17544
- nodeId: string().optional()
17545
- }), RetrainAssistResultSchema, {
17546
- kind: "mutation",
17547
- auth: "admin"
17548
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
17549
- kind: "query",
17550
- auth: "admin"
17551
- }), method(object({
17552
- deviceId: number(),
17610
+ sizeBytes: number(),
17611
+ timestamp: number()
17612
+ });
17613
+ /**
17614
+ * One media row WITHOUT its bytes.
17615
+ *
17616
+ * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
17617
+ * 140 s track), and a client that renders tiles from the media data plane needs
17618
+ * to know only WHAT EXISTS — the bytes then arrive per tile, lazily, over HTTP
17619
+ * with an immutable cache, instead of all at once inside a tRPC response that
17620
+ * blocks the whole view.
17621
+ *
17622
+ * `sizeBytes` is carried because it is what lets a client decide between the
17623
+ * stored blob and a `?variant=thumb` rendering without fetching either.
17624
+ */
17625
+ var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
17626
+ /**
17627
+ * The MACRO tier of an annotation — a CLOSED set.
17628
+ *
17629
+ * This is what the exported detector predicts, so a typo here is a new class
17630
+ * with one example in it. `label` and `subLabel` are open strings by contrast:
17631
+ * the whole point of the page is teaching the model things it does not know
17632
+ * yet, and constraining that vocabulary would make it useless.
17633
+ *
17634
+ * A macro class is NEVER a label. The provider refuses a write whose `label` or
17635
+ * `subLabel` is one of these values, in any casing, because once `person`
17636
+ * exists in both tiers "every person box" stops being answerable without
17637
+ * knowing every string anyone ever typed — and the damage is retroactive.
17638
+ */
17639
+ var RetrainMacroClassSchema = _enum([
17640
+ "person",
17641
+ "vehicle",
17642
+ "animal",
17643
+ "package",
17644
+ "face",
17645
+ "plate"
17646
+ ]);
17647
+ /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
17648
+ var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
17649
+ /** Did a human draw this box, or did the assist propose it? */
17650
+ var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
17651
+ /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
17652
+ var RetrainBboxSchema = object({
17653
+ x: number(),
17654
+ y: number(),
17655
+ w: number(),
17656
+ h: number()
17657
+ });
17658
+ /**
17659
+ * One annotated subject.
17660
+ *
17661
+ * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
17662
+ * (letterboxed root / zone-cropped package / subject-cropped classifier) are
17663
+ * derived from it at export and never stored — storing them is how one feature
17664
+ * space ends up holding two crops of the same subject (D52).
17665
+ */
17666
+ var RetrainAnnotationSchema = object({
17667
+ id: string(),
17553
17668
  trackId: string(),
17554
- frameId: string(),
17555
- annotations: array(RetrainAnnotationDraftSchema)
17556
- }), array(RetrainAnnotationSchema).readonly(), {
17557
- kind: "mutation",
17558
- auth: "admin"
17559
- }), method(object({
17560
- deviceId: number(),
17561
- trackId: string()
17562
- }), RetrainTransitionResultSchema, {
17563
- kind: "mutation",
17564
- auth: "admin"
17565
- }), method(object({
17566
17669
  deviceId: number(),
17567
- trackId: string()
17568
- }), RetrainTransitionResultSchema, {
17569
- kind: "mutation",
17570
- auth: "admin"
17571
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
17572
- kind: "query",
17573
- auth: "admin"
17574
- }), method(object({
17575
- eventId: string(),
17576
- kind: MediaFileKindEnum.optional(),
17577
- deviceId: number()
17578
- }), array(MediaFileSchema).readonly()), method(object({
17579
- trackId: string(),
17580
- kinds: array(MediaFileKindEnum).optional(),
17581
- deviceId: number()
17582
- }), array(MediaFileSchema).readonly()), method(object({
17670
+ /** The COPY in retrain storage — never the source track's media key. */
17671
+ mediaKey: string(),
17672
+ bbox: RetrainBboxSchema,
17673
+ macroClass: RetrainMacroClassSchema,
17674
+ label: string().optional(),
17675
+ subLabel: string().optional(),
17676
+ kind: RetrainAnnotationKindSchema,
17677
+ source: RetrainAnnotationSourceSchema,
17678
+ /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
17679
+ assistModelId: string().optional(),
17680
+ assistScore: number().optional(),
17681
+ exportedInBatch: string().optional(),
17682
+ createdAt: number()
17683
+ });
17684
+ /** The write form — the server owns `id`, `createdAt` and the frame binding. */
17685
+ var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
17686
+ id: true,
17687
+ trackId: true,
17688
+ deviceId: true,
17689
+ mediaKey: true,
17690
+ createdAt: true,
17691
+ exportedInBatch: true
17692
+ });
17693
+ /** A track sitting in `staging`, with everything the worklist needs to rank it. */
17694
+ var RetrainTrackSchema = object({
17583
17695
  trackId: string(),
17584
- deviceId: number()
17585
- }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
17586
- kind: "mutation",
17587
- auth: "admin"
17588
- }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
17589
- kind: "mutation",
17590
- auth: "admin"
17591
- }), method(object({}), RebuildStatusSchema), object({
17592
17696
  deviceId: number(),
17697
+ className: string(),
17698
+ label: string().optional(),
17699
+ firstSeen: number(),
17700
+ lastSeen: number(),
17701
+ /** How many frames the dataset already holds from this track. */
17702
+ frameCount: number().int(),
17703
+ /** How many subjects have been annotated on those frames. `0` with
17704
+ * `frameCount: 0` is exactly "staging, still to work". */
17705
+ annotationCount: number().int()
17706
+ });
17707
+ /** A frame the picker may offer — an index row, no blob was read to produce it. */
17708
+ var RetrainFrameCandidateSchema = object({
17709
+ mediaKey: string(),
17710
+ kind: MediaFileKindEnum,
17593
17711
  timestamp: number(),
17594
- frameWidth: number(),
17595
- frameHeight: number(),
17596
- detections: array(OverlayDetectionSchema).readonly()
17597
- }), object({
17712
+ sizeBytes: number().int(),
17713
+ /** A copy of this original already exists — selecting it is free and cannot
17714
+ * fail, whatever became of the original. */
17715
+ copied: boolean()
17716
+ });
17717
+ /** A frame the dataset OWNS: bytes copied at selection time. */
17718
+ var RetrainFrameSchema = object({
17719
+ frameId: string(),
17598
17720
  deviceId: number(),
17599
17721
  trackId: string(),
17600
- className: string()
17722
+ /** Provenance only. It may already point at nothing — that is expected. */
17723
+ sourceMediaKey: string(),
17724
+ sourceKind: MediaFileKindEnum,
17725
+ sizeBytes: number().int(),
17726
+ width: number().int(),
17727
+ height: number().int(),
17728
+ copiedAt: number()
17729
+ });
17730
+ /** Why a copy-on-select could not be honoured — named, never a silent skip. */
17731
+ var RetrainCopyRefusalSchema = _enum([
17732
+ "source-missing",
17733
+ "unreadable-image",
17734
+ "write-failed"
17735
+ ]);
17736
+ var RetrainFrameSelectionSchema = object({
17737
+ copied: array(RetrainFrameSchema).readonly(),
17738
+ refused: array(object({
17739
+ sourceMediaKey: string(),
17740
+ reason: RetrainCopyRefusalSchema
17741
+ })).readonly()
17742
+ });
17743
+ var RetrainFrameListSchema = object({
17744
+ candidates: array(RetrainFrameCandidateSchema).readonly(),
17745
+ copies: array(RetrainFrameSchema).readonly(),
17746
+ /** What the page pre-selects — the native key frame when one survives. */
17747
+ autoPickMediaKey: string().optional()
17748
+ });
17749
+ /** What the operator asked the assist to look for. */
17750
+ var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
17751
+ kind: literal("package"),
17752
+ zone: RetrainBboxSchema.optional()
17601
17753
  }), object({
17602
- deviceId: number(),
17603
- trackId: string(),
17604
- className: string(),
17605
- durationMs: number()
17754
+ kind: literal("objects"),
17755
+ modelId: string(),
17756
+ minScore: number().optional()
17757
+ })]);
17758
+ /**
17759
+ * The assist's answer — a discriminated union, because "the model saw nothing"
17760
+ * and "this node cannot run that model" lead to different next moves and a
17761
+ * nullable result cannot tell them apart.
17762
+ */
17763
+ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
17764
+ kind: literal("proposed"),
17765
+ modelId: string(),
17766
+ stepId: string(),
17767
+ minScore: number(),
17768
+ /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
17769
+ proposals: array(RetrainAnnotationDraftSchema).readonly(),
17770
+ /** Returned by the runner but removed by the threshold. */
17771
+ belowThreshold: number().int()
17606
17772
  }), object({
17773
+ kind: literal("refused"),
17774
+ /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
17775
+ reason: string(),
17776
+ detail: string().optional()
17777
+ })]);
17778
+ /** The outcome of a lifecycle move owned by the retrain page. */
17779
+ var RetrainTransitionResultSchema = object({
17780
+ trackId: string(),
17781
+ /** Where the track ended up, whatever happened. */
17782
+ retrainStatus: RetrainStatusSchema,
17783
+ /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
17784
+ changed: boolean(),
17785
+ reason: _enum([
17786
+ "unknown-track",
17787
+ "no-frames-copied",
17788
+ "not-staging",
17789
+ "not-trained",
17790
+ "unchanged"
17791
+ ]).optional()
17792
+ });
17793
+ var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
17794
+ var MAX_EVENT_QUERY_LIMIT = 5e3;
17795
+ var DeviceEventQueryInput = object({
17607
17796
  deviceId: number(),
17608
- kind: EventKindSchema,
17609
- eventId: string(),
17610
- timestamp: number()
17797
+ since: number().optional(),
17798
+ until: number().optional(),
17799
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
17800
+ /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
17801
+ * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
17802
+ * exact behaviour. Callers may omit this field — the store defaults to
17803
+ * `full` when not provided. */
17804
+ projection: _enum(["full", "slim"]).optional()
17611
17805
  });
17612
- /**
17613
- * Reference to the frame's retained NATIVE surface + the parent crop's placement
17614
- * within the frame, so the executor can re-cut a leaf child ROI at native
17615
- * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
17616
- */
17617
- var NativeCropRefSchema = object({
17618
- /** Handle keying the retained native surface (node-pinned to its owner). */
17619
- handle: FrameHandleSchema,
17620
- /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
17621
- cropFrameSpace: object({
17622
- x: number(),
17623
- y: number(),
17624
- w: number(),
17625
- h: number()
17626
- })
17806
+ var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
17807
+ var RecentTracksQueryInput = object({
17808
+ /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
17809
+ deviceIds: array(number()),
17810
+ /** Window lower bound on `lastSeen` (inclusive). */
17811
+ since: number().optional(),
17812
+ /** Window upper bound on `lastSeen` (inclusive). */
17813
+ until: number().optional(),
17814
+ /** Page size. Default 200, max 1000. */
17815
+ limit: number().int().min(1).max(1e3).default(200),
17816
+ /** Opaque continuation cursor from a previous page's `nextCursor`.
17817
+ * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
17818
+ cursor: string().optional(),
17819
+ /** See {@link TrackProjectionSchema}. Default `full`. */
17820
+ projection: TrackProjectionSchema.optional(),
17821
+ /** Include stationary-promoted rows (parked objects). Default false: the
17822
+ * feed lists passages; parking records live on the stationary registry. */
17823
+ includeStationary: boolean().optional()
17627
17824
  });
17628
- object({
17629
- crop: object({
17630
- left: number(),
17631
- top: number(),
17632
- width: number().positive(),
17633
- height: number().positive()
17634
- }).optional(),
17635
- content: object({
17636
- width: number().int().positive(),
17637
- height: number().int().positive()
17638
- }),
17639
- fit: _enum(["stretch", "contain"]),
17640
- format: _enum([
17641
- "rgb",
17642
- "gray",
17643
- "jpeg"
17644
- ])
17825
+ var RecentTracksPageSchema = object({
17826
+ /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
17827
+ tracks: array(TrackSchema).readonly(),
17828
+ /** Cursor for the next page, or null when this page is the last. */
17829
+ nextCursor: string().nullable()
17645
17830
  });
17646
- var FrameRefSchema = object({
17647
- registryId: string().min(1),
17648
- id: string().min(1),
17649
- width: number().int().positive(),
17650
- height: number().int().positive(),
17651
- format: _enum(["rgb", "gray"]),
17652
- timestamp: number(),
17653
- capturedAt: number().optional()
17831
+ var LIST_GROUPS_DEFAULT_LIMIT = 40;
17832
+ var LIST_GROUPS_MAX_LIMIT = 100;
17833
+ var AnalyticsGroupRecordSchema = object({
17834
+ id: string(),
17835
+ deviceId: number().int(),
17836
+ openedAt: number().int(),
17837
+ closedAt: number().int(),
17838
+ timestamp: number().int(),
17839
+ memberCount: number().int(),
17840
+ memberTrackIds: array(string()).readonly(),
17841
+ className: string(),
17842
+ classes: array(string()).readonly(),
17843
+ /** Relative event-media path, or null when the group has no picture yet. */
17844
+ mediaUrl: string().nullable(),
17845
+ singleton: boolean()
17654
17846
  });
17655
- var ModelFormatSchema$1 = _enum([
17656
- "onnx",
17657
- "coreml",
17658
- "openvino",
17659
- "tflite",
17660
- "pt",
17661
- "gguf"
17662
- ]);
17663
- var PipelineSlotSchema = _enum([
17664
- "detector",
17665
- "cropper",
17666
- "classifier",
17667
- "refiner",
17668
- "audio-classifier"
17669
- ]);
17670
- var PipelineEngineChoiceSchema = object({
17671
- runtime: _enum(["node", "python"]),
17672
- backend: string(),
17673
- format: ModelFormatSchema$1,
17674
- device: string().optional()
17847
+ var AnalyticsGroupMemberSchema = object({
17848
+ trackId: string(),
17849
+ deviceId: number().int(),
17850
+ className: string(),
17851
+ firstSeen: number().int(),
17852
+ lastSeen: number().int(),
17853
+ mediaUrl: string().nullable()
17675
17854
  });
17676
- var AvailableEngineSchema = object({
17677
- engine: PipelineEngineChoiceSchema,
17678
- devices: array(object({
17679
- id: string(),
17680
- label: string(),
17681
- description: string().optional()
17682
- })).readonly(),
17683
- defaultDevice: string()
17855
+ var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
17856
+ var ListGroupsQueryInput = object({
17857
+ /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
17858
+ deviceIds: array(number()),
17859
+ /** Window lower bound on `closedAt` (inclusive). */
17860
+ since: number().optional(),
17861
+ /** Window upper bound on `openedAt` (inclusive). */
17862
+ until: number().optional(),
17863
+ limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
17864
+ /** Opaque continuation cursor from a previous page's `nextCursor`. */
17865
+ cursor: string().optional()
17684
17866
  });
17685
- var PipelineDefaultStepSchema = lazy(() => object({
17686
- addonId: string(),
17687
- addonName: string(),
17688
- slot: PipelineSlotSchema,
17689
- inputClasses: array(string()).readonly(),
17690
- outputClasses: array(string()).readonly(),
17691
- enabled: boolean(),
17692
- modelId: string(),
17693
- children: array(PipelineDefaultStepSchema).readonly(),
17694
- group: string().optional(),
17695
- settings: record(string(), unknown()).optional()
17696
- }));
17697
- var PipelineTemplateStepSchema = lazy(() => object({
17698
- addonId: string(),
17699
- enabled: boolean(),
17700
- modelId: string(),
17701
- children: array(PipelineTemplateStepSchema).readonly(),
17702
- settings: record(string(), unknown()).optional()
17703
- }));
17704
- var PipelineTemplateSchema$1 = object({
17705
- id: string(),
17706
- name: string(),
17707
- createdAt: string(),
17708
- updatedAt: string(),
17709
- engine: PipelineEngineChoiceSchema,
17710
- steps: array(PipelineTemplateStepSchema).readonly()
17867
+ var ListGroupsPageSchema = object({
17868
+ groups: array(AnalyticsGroupRecordSchema).readonly(),
17869
+ nextCursor: string().nullable()
17870
+ });
17871
+ var KeyEventQueryInput = object({
17872
+ deviceId: number(),
17873
+ /** Window lower bound (track firstSeen ≥ since). */
17874
+ since: number(),
17875
+ /** Window upper bound (track firstSeen ≤ until). */
17876
+ until: number(),
17877
+ limit: number().int().min(1).max(200).default(50),
17878
+ /** Drop tracks scoring below this importance. */
17879
+ minImportance: number().min(0).max(1).optional(),
17880
+ /** Restrict to a single class (e.g. 'person'). */
17881
+ classFilter: string().optional()
17711
17882
  });
17712
- var PipelineModelOptionSchema = object({
17883
+ var KeyEventSchema = object({
17884
+ /** The representative event id (the track's best ObjectEvent, else its trackId). */
17713
17885
  id: string(),
17714
- name: string(),
17715
- formats: record(string(), object({
17716
- downloaded: boolean(),
17717
- sizeMB: number()
17718
- })),
17719
- group: ModelVariantGroupSchema.optional(),
17720
- legacy: boolean().optional(),
17721
- provider: ModelProviderIdSchema.optional()
17886
+ trackId: string(),
17887
+ /** Track start time (firstSeen). */
17888
+ timestamp: number(),
17889
+ className: string(),
17890
+ ...TieredLabelFields,
17891
+ importance: number(),
17892
+ /** Highest-confidence ObjectEvent id for the track (empty when none). */
17893
+ bestEventId: string(),
17894
+ /** Track lifetime in ms (lastSeen - firstSeen). */
17895
+ windowMs: number().optional(),
17896
+ ...TrackFlagFields,
17897
+ ...TrackRetrainFields
17722
17898
  });
17723
- var ConfigFieldBridge = custom();
17724
- var PipelineAddonSchemaSchema = object({
17725
- id: string(),
17726
- name: string(),
17727
- slot: PipelineSlotSchema,
17728
- inputClasses: array(string()).readonly(),
17729
- outputClasses: array(string()).readonly(),
17730
- childSlots: array(PipelineSlotSchema).readonly(),
17731
- models: array(PipelineModelOptionSchema).readonly(),
17732
- defaultModelId: string(),
17733
- defaultModelIdByFormat: record(string(), string()).optional(),
17734
- enabledByDefault: boolean().optional(),
17735
- backfillIntoExistingOverrides: boolean().optional(),
17736
- defaultConfidence: number(),
17737
- group: string().optional(),
17738
- configSchema: array(ConfigFieldBridge).readonly().optional()
17899
+ object({
17900
+ trackId: string(),
17901
+ className: string(),
17902
+ confidence: number(),
17903
+ bbox: BoundingBoxSchema,
17904
+ zones: array(string()).readonly(),
17905
+ state: TrackStateSchema
17739
17906
  });
17740
- var PipelineSlotSchemaSchema = object({
17741
- id: PipelineSlotSchema,
17742
- label: string(),
17743
- priority: number(),
17744
- parentSlot: PipelineSlotSchema.nullable(),
17745
- addons: array(PipelineAddonSchemaSchema).readonly()
17907
+ var OverlayDetectionSchema = looseObject({
17908
+ id: string(),
17909
+ kind: _enum(["first-level", "detail"]),
17910
+ macroClass: string(),
17911
+ score: number(),
17912
+ bbox: object({
17913
+ x: number(),
17914
+ y: number(),
17915
+ width: number(),
17916
+ height: number()
17917
+ }),
17918
+ labels: array(looseObject({
17919
+ label: string(),
17920
+ score: number()
17921
+ })).readonly(),
17922
+ parentId: string().optional()
17746
17923
  });
17747
- var PipelineSchemaSchema = object({
17748
- availableEngines: array(AvailableEngineSchema).readonly(),
17749
- selectedEngine: PipelineEngineChoiceSchema,
17750
- slots: array(PipelineSlotSchemaSchema).readonly()
17924
+ var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
17925
+ var SearchObjectEventsInput = object({
17926
+ text: string(),
17927
+ deviceId: number().optional(),
17928
+ since: number().optional(),
17929
+ until: number().optional(),
17930
+ classFilter: string().optional(),
17931
+ limit: number().default(50),
17932
+ minScore: number().min(0).max(1).default(.2)
17751
17933
  });
17752
- var EngineProvisioningSchema = object({
17753
- runtimeId: _enum([
17754
- "onnx",
17755
- "openvino",
17756
- "coreml",
17757
- "edgetpu"
17758
- ]).nullable(),
17759
- device: string().nullable(),
17760
- state: _enum([
17761
- "idle",
17762
- "installing",
17763
- "verifying",
17764
- "ready",
17765
- "failed"
17766
- ]),
17767
- progress: number().optional(),
17768
- error: string().optional(),
17769
- nextRetryAt: number().optional(),
17770
- /**
17771
- * Gate A (config-correctness gate at engine change): human-readable
17772
- * config issues surfaced EAGERLY when the node's engine changes — model
17773
- * substitutions ("chose X, running Y") and zero-build steps ("no model
17774
- * has a <format> build"). Additive/optional: informational only, never
17775
- * enforced here — `assertEngineReady` (readiness) still gates inference.
17776
- * Absent/empty when the node-default tree resolves cleanly.
17777
- */
17778
- configIssues: array(string()).optional()
17934
+ var TrackCascadeCountsSchema = object({
17935
+ /** Persisted track roots deleted (authoritative). */
17936
+ tracks: number().int(),
17937
+ /** Object events removed with their tracks (best-effort; see note above). */
17938
+ events: number().int(),
17939
+ /** Track/face/plate-owned media removed (best-effort). Never identity media. */
17940
+ media: number().int(),
17941
+ /** Unassigned (non-enrolled) face reads removed (best-effort). */
17942
+ faces: number().int(),
17943
+ /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
17944
+ plates: number().int(),
17945
+ /** Per-track CLIP search vectors removed (best-effort). */
17946
+ embeddings: number().int(),
17947
+ /** Group membership + group rows removed with their last member (best-effort). */
17948
+ groups: number().int()
17779
17949
  });
17780
- var PipelineStepInputSchema = lazy(() => object({
17781
- addonId: string(),
17782
- modelId: string().optional(),
17783
- enabled: boolean().default(true),
17784
- children: array(PipelineStepInputSchema).optional(),
17785
- settings: record(string(), unknown()).optional(),
17786
- jumpDeviceKey: string().optional()
17787
- }));
17788
- var ModelSubstitutionSchema = object({
17789
- addonId: string(),
17790
- chosen: string(),
17791
- running: string(),
17792
- format: string()
17950
+ /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
17951
+ var DiskReconcileCountsSchema = object({
17952
+ mediaDropped: number().int(),
17953
+ tracks: number().int(),
17954
+ events: number().int()
17793
17955
  });
17794
- var PipelineValidationIssueSchema = object({
17795
- addonId: string(),
17796
- kind: _enum(["unknown-addon", "no-format-build"]),
17797
- detail: string()
17956
+ /** Event-store footprint for one camera. */
17957
+ var EventStoreDeviceFootprintSchema = object({
17958
+ deviceId: number(),
17959
+ /** Persisted event rows (motion + object + audio) for the camera. */
17960
+ rows: number().int(),
17961
+ /** Event-owned media bytes on disk for the camera. */
17962
+ bytes: number().int()
17798
17963
  });
17799
- var PipelineValidationResultSchema = object({
17800
- ok: boolean(),
17801
- issues: array(PipelineValidationIssueSchema).readonly(),
17802
- substitutions: array(ModelSubstitutionSchema).readonly(),
17803
- /** The node's `currentEngine.format` this validation ran against. */
17804
- format: string()
17964
+ /** Aggregate event-store footprint: global totals + per-camera breakdown. */
17965
+ var EventStoreFootprintSchema = object({
17966
+ totalRows: number().int(),
17967
+ totalBytes: number().int(),
17968
+ devices: array(EventStoreDeviceFootprintSchema).readonly()
17805
17969
  });
17806
- var ReferenceImageEntrySchema = object({
17807
- filename: string(),
17808
- stepIds: array(string()).readonly().optional()
17970
+ /** Per-kind counts returned by the event-prune / device-delete mutations. */
17971
+ var EventPruneCountsSchema = object({
17972
+ motion: number().int(),
17973
+ object: number().int(),
17974
+ audio: number().int()
17809
17975
  });
17810
- var ReferenceImageBodySchema = object({
17811
- base64: string(),
17812
- filename: string()
17976
+ /**
17977
+ * Re-embed stored tracks from their key frames.
17978
+ *
17979
+ * The reason this is an operator-callable method and not a migration script:
17980
+ * every knob that decides what a vector MEANS — encoder model, crop margin,
17981
+ * squaring — is only changeable if the existing vectors can be regenerated.
17982
+ * Mixing feature spaces in one index makes cosine scores incomparable, and the
17983
+ * symptom is a quality regression with no visible cause.
17984
+ */
17985
+ var RebuildObjectEmbeddingsInput = object({
17986
+ /** Restrict to one camera. Omit for the whole fleet. */
17987
+ deviceId: number().optional(),
17988
+ since: number().optional(),
17989
+ until: number().optional(),
17990
+ /** Stop after this many tracks; the result reports whether more remain. */
17991
+ maxTracks: number().int().positive().optional(),
17992
+ /**
17993
+ * Run every embedding on THIS node instead of round-robining the fleet.
17994
+ *
17995
+ * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
17996
+ * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
17997
+ * calling it that would pin the rebuild REQUEST itself to that node — the
17998
+ * rebuild orchestration lives on the hub, and only the per-track step runs
17999
+ * remotely. This field is data; the per-track pin is applied inside.
18000
+ *
18001
+ * Absent ⇒ round-robin over every online node whose runner can serve the
18002
+ * pinned model.
18003
+ */
18004
+ executeOnNodeId: string().optional(),
18005
+ /**
18006
+ * Milliseconds to wait between tracks; omit for the built-in default, `0` to
18007
+ * run flat out.
18008
+ *
18009
+ * A rebuild is bulk maintenance on hub-main's single thread. Measured
18010
+ * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
18011
+ * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
18012
+ * force is logged at start and finish so a deliberately slow pass reads
18013
+ * differently from a stalled one.
18014
+ */
18015
+ pacingMs: number().int().nonnegative().optional()
17813
18016
  });
17814
- var ReferenceAudioEntrySchema = object({
17815
- filename: string(),
17816
- sizeKb: number()
18017
+ /**
18018
+ * Result of emptying the CLIP index.
18019
+ *
18020
+ * The clean slate before a policy change: a new crop margin or encoder model
18021
+ * leaves two feature spaces in one index whose cosine scores are not
18022
+ * comparable, so wiping and rebuilding is the only way to be sure every vector
18023
+ * means the same thing.
18024
+ */
18025
+ var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
18026
+ /**
18027
+ * Acknowledgement that a rebuild STARTED.
18028
+ *
18029
+ * The pass costs ~1s per track — 45 minutes for a 2,600-track fleet — so it
18030
+ * runs detached and this returns immediately. Waiting for it made the client
18031
+ * time out while the work carried on server-side, which is the worst of both:
18032
+ * no result and no way to know it was still going. Poll
18033
+ * `getObjectEmbeddingRebuildStatus` for progress.
18034
+ */
18035
+ var RebuildObjectEmbeddingsResultSchema = object({
18036
+ started: boolean(),
18037
+ /** True when a pass was already running; the new request is ignored. */
18038
+ alreadyRunning: boolean()
17817
18039
  });
17818
- var ReferenceAudioBodySchema = object({ base64: string() });
17819
- var AudioBackendSchema = object({
17820
- id: string(),
17821
- name: string(),
17822
- description: string(),
17823
- available: boolean(),
18040
+ var RebuildStatusSchema = object({
18041
+ running: boolean(),
18042
+ scanned: number(),
18043
+ rebuilt: number(),
18044
+ /** Tracks whose key frame is gone — nothing to re-embed from. */
18045
+ missingKeyFrame: number(),
18046
+ /** Tracks with no usable detection box. */
18047
+ missingBbox: number(),
18048
+ /**
18049
+ * Tracks an executing node REFUSED rather than broke on — an unreadable key
18050
+ * frame, a step that threw. Separate from `failed` because the remedy is
18051
+ * different, and because a whole camera silently contributing zero vectors
18052
+ * is the shape of failure a rebuild must never hide.
18053
+ */
18054
+ notRunnable: number(),
17824
18055
  /**
17825
- * Raw classifier labels this backend can emit (e.g. YAMNet's
17826
- * 521-class set or Apple SoundAnalysis's 303-class set). Used by
17827
- * the benchmark UI to populate the `enabledMicroClasses` filter
17828
- * specific to the selected backend without a separate fetch.
18056
+ * The pass stopped because NO node could serve the pinned model.
18057
+ *
18058
+ * Distinct from `notRunnable` on purpose: that one says "this track was
18059
+ * refused", this one says "the cluster cannot do this work at all" — every
18060
+ * candidate node either lacks the `clip-embedding` step, lacks a build of the
18061
+ * pinned model for its engine format, or dropped out. The remedy is a model /
18062
+ * engine change, not a per-camera one. Non-zero here always comes with
18063
+ * `complete: false`.
17829
18064
  */
17830
- rawLabels: array(string()).readonly().optional()
17831
- });
17832
- var AudioCapabilitiesSchema = object({
17833
- activeBackend: string(),
17834
- availableBackends: array(AudioBackendSchema).readonly(),
17835
- sampleRate: number(),
17836
- chunkDurationMs: number()
17837
- });
17838
- var DownloadModelResultSchema = object({
17839
- filePath: string(),
17840
- sizeMB: number(),
17841
- durationMs: number()
18065
+ noCapableNode: number(),
18066
+ failed: number(),
18067
+ /** Set once a pass ends: true only when EVERYTHING was covered. */
18068
+ complete: boolean().nullable(),
18069
+ startedAtMs: number().nullable(),
18070
+ finishedAtMs: number().nullable(),
18071
+ /** Present when the pass ended by throwing. */
18072
+ error: string().nullable()
17842
18073
  });
17843
- /**
17844
- * Wrapper carrying a single test run's result. Replaces the legacy
17845
- * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
17846
- * canonical `AudioResult` from the Phase 6 output rework: one
17847
- * `AudioDetection` per class above `minScore`, top-N candidates in
17848
- * `debug.alternateLabels['audio-classifier']`, per-source timings in
17849
- * `debug.stepTimings`. The outer `success`/`error` fields stay so the
17850
- * benchmark UI can still report a clean failure when the classifier
17851
- * cap isn't available.
17852
- */
17853
- var AudioTestResultSchema = object({
17854
- success: boolean(),
17855
- error: string().optional(),
17856
- frame: custom().optional()
18074
+ var ReplayFrameInputSchema = object({
18075
+ timestamp: number(),
18076
+ frame: PipelineRunResultBridge
17857
18077
  });
17858
- var PipelineConfigBridge = custom();
17859
- var ConfigUISchemaBridge = custom();
17860
- var ConfigUISchemaNullableBridge = custom();
17861
- var InferenceCapabilitiesBridge = custom();
17862
- var ModelAvailabilityListBridge = custom();
17863
- var PipelineRunResultBridge = custom();
17864
- method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
17865
- modelId: string(),
17866
- settings: record(string(), unknown()).readonly()
17867
- }))), method(object({ steps: record(string(), object({
17868
- modelId: string(),
17869
- settings: record(string(), unknown()).readonly()
17870
- })) }), object({ success: literal(true) }), {
18078
+ var RunReplayFrameProcessorResultSchema = object({ tracks: array(object({
18079
+ className: string(),
18080
+ firstSeenMs: number(),
18081
+ lastSeenMs: number(),
18082
+ /** Bbox of the track's FIRST matched detection, pixel-space in the clip's
18083
+ * frame a representative box for the diff's `(className, window, IoU)`
18084
+ * pairing (`replay-diff.ts`). A replay does not need the full per-frame
18085
+ * trajectory production's `Track.positions` keeps. */
18086
+ bbox: BoundingBoxSchema,
18087
+ /** How many of the input frames this track matched a real detection on
18088
+ * (never a coasted/extrapolated frame) — the replay's own signal for "how
18089
+ * solid is this track", cheaper than re-deriving it from a trajectory. */
18090
+ framesMatched: number().int()
18091
+ })).readonly() });
18092
+ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
18093
+ deviceId: number(),
18094
+ trackId: string()
18095
+ }), TrackSchema.nullable()), method(object({
18096
+ deviceId: number(),
18097
+ since: number().optional(),
18098
+ until: number().optional(),
18099
+ limit: number().optional(),
18100
+ /** Spatial filter — only tracks whose trajectory intersects the zone
18101
+ * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
18102
+ * envelope columns, then precisely tested per position. Tracks with
18103
+ * an unknown envelope (no frame dims at persist time) always match. */
18104
+ zone: TrackZoneFilterSchema.optional(),
18105
+ /** See {@link TrackProjectionSchema}. Default `full` (backward
18106
+ * compatible — omitting the field keeps today's exact behaviour). */
18107
+ projection: TrackProjectionSchema.optional(),
18108
+ /** Include stationary-promoted rows (parked objects handed to the
18109
+ * stationary registry). Default false: the timeline lists passages,
18110
+ * not parking records (operator decision, 2026-08-15). */
18111
+ includeStationary: boolean().optional()
18112
+ }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
18113
+ deviceId: number(),
18114
+ groupId: string().min(1)
18115
+ }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
18116
+ kind: "mutation",
18117
+ auth: "admin"
18118
+ }), 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({
18119
+ deviceId: number(),
18120
+ since: number().optional(),
18121
+ until: number().optional(),
18122
+ kinds: array(string()).optional(),
18123
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
18124
+ }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
18125
+ deviceId: number(),
18126
+ since: number(),
18127
+ until: number(),
18128
+ bucketMs: number().int().positive()
18129
+ }), array(object({
18130
+ bucketStart: number(),
18131
+ motion: number().int(),
18132
+ object: number().int(),
18133
+ audio: number().int()
18134
+ })).readonly()), method(object({
18135
+ deviceId: number(),
18136
+ cutoffMs: number()
18137
+ }), object({
18138
+ motion: number().int(),
18139
+ object: number().int(),
18140
+ audio: number().int()
18141
+ }), {
18142
+ kind: "mutation",
18143
+ auth: "admin"
18144
+ }), method(object({
18145
+ deviceId: number(),
18146
+ cutoffMs: number()
18147
+ }), TrackCascadeCountsSchema, {
18148
+ kind: "mutation",
18149
+ auth: "admin"
18150
+ }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
18151
+ kind: "mutation",
18152
+ auth: "admin"
18153
+ }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
18154
+ kind: "mutation",
18155
+ auth: "admin"
18156
+ }), method(object({
18157
+ deviceId: number(),
18158
+ trackIds: array(string()).min(1)
18159
+ }), object({
18160
+ deleted: number().int(),
18161
+ failed: array(string()).readonly()
18162
+ }), {
18163
+ kind: "mutation",
18164
+ auth: "admin"
18165
+ }), method(object({
18166
+ /** Log/audit scope only — the trackId is globally unique on its own. */
18167
+ deviceId: number(),
18168
+ trackId: string(),
18169
+ flags: TrackFlagsPatchSchema
18170
+ }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
18171
+ kind: "query",
18172
+ auth: "admin"
18173
+ }), method(object({
18174
+ olderThanMs: number(),
18175
+ reason: OpsLogReasonSchema.optional()
18176
+ }), EventPruneCountsSchema, {
18177
+ kind: "mutation",
18178
+ auth: "admin"
18179
+ }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
18180
+ kind: "mutation",
18181
+ auth: "admin"
18182
+ }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
18183
+ kind: "mutation",
18184
+ auth: "admin"
18185
+ }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
18186
+ kind: "mutation",
18187
+ auth: "admin"
18188
+ }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
18189
+ kind: "mutation",
18190
+ auth: "admin"
18191
+ }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
18192
+ kind: "mutation",
18193
+ auth: "admin"
18194
+ }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18195
+ kind: "mutation",
18196
+ auth: "admin"
18197
+ }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
18198
+ kind: "mutation",
18199
+ auth: "admin"
18200
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
18201
+ kind: "query",
18202
+ auth: "admin"
18203
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18204
+ kind: "mutation",
18205
+ auth: "admin"
18206
+ }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
18207
+ kind: "query",
18208
+ auth: "admin"
18209
+ }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
18210
+ kind: "query",
18211
+ auth: "admin"
18212
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18213
+ kind: "query",
18214
+ auth: "admin"
18215
+ }), method(object({
18216
+ /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
18217
+ * `deviceId`, deliberately: `deviceId` would make this device-bound and
18218
+ * route it at one camera's owner, and "every camera" would stop being
18219
+ * expressible at all. */
18220
+ deviceIds: array(number()).optional(),
18221
+ limit: number().int().min(1).max(500).optional()
18222
+ }), array(RetrainTrackSchema).readonly(), {
18223
+ kind: "query",
18224
+ auth: "admin"
18225
+ }), method(object({ trackId: string() }), RetrainFrameListSchema, {
18226
+ kind: "query",
18227
+ auth: "admin"
18228
+ }), method(object({
18229
+ deviceId: number(),
18230
+ trackId: string(),
18231
+ mediaKeys: array(string()).min(1)
18232
+ }), RetrainFrameSelectionSchema, {
18233
+ kind: "mutation",
18234
+ auth: "admin"
18235
+ }), method(object({
18236
+ deviceId: number(),
18237
+ trackId: string(),
18238
+ frameId: string()
18239
+ }), object({
18240
+ removed: boolean(),
18241
+ removedAnnotations: number().int()
18242
+ }), {
18243
+ kind: "mutation",
18244
+ auth: "admin"
18245
+ }), method(object({ frameId: string() }), object({
18246
+ base64: string(),
18247
+ width: number().int(),
18248
+ height: number().int()
18249
+ }), {
18250
+ kind: "query",
18251
+ auth: "admin"
18252
+ }), method(object({
18253
+ deviceId: number(),
18254
+ trackId: string(),
18255
+ frameId: string(),
18256
+ subject: RetrainAssistSubjectSchema,
18257
+ /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
18258
+ nodeId: string().optional()
18259
+ }), RetrainAssistResultSchema, {
18260
+ kind: "mutation",
18261
+ auth: "admin"
18262
+ }), method(object({
18263
+ deviceId: number(),
18264
+ source: DetectionSourceSchema,
18265
+ zones: array(ZoneSchema).readonly().optional(),
18266
+ detectionRules: array(ZoneRuleSchema).readonly().optional(),
18267
+ zoneMembershipMinOverlap: number().min(0).max(1).optional(),
18268
+ frames: array(ReplayFrameInputSchema).min(1)
18269
+ }), RunReplayFrameProcessorResultSchema, {
18270
+ kind: "mutation",
18271
+ auth: "admin"
18272
+ }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
18273
+ kind: "query",
18274
+ auth: "admin"
18275
+ }), method(object({
18276
+ deviceId: number(),
18277
+ trackId: string(),
18278
+ frameId: string(),
18279
+ annotations: array(RetrainAnnotationDraftSchema)
18280
+ }), array(RetrainAnnotationSchema).readonly(), {
18281
+ kind: "mutation",
18282
+ auth: "admin"
18283
+ }), method(object({
18284
+ deviceId: number(),
18285
+ trackId: string()
18286
+ }), RetrainTransitionResultSchema, {
17871
18287
  kind: "mutation",
17872
18288
  auth: "admin"
17873
- }), method(object({ nodeId: string() }), object({
17874
- success: literal(true),
17875
- clearedDevices: number()
17876
- }), {
18289
+ }), method(object({
18290
+ deviceId: number(),
18291
+ trackId: string()
18292
+ }), RetrainTransitionResultSchema, {
17877
18293
  kind: "mutation",
17878
18294
  auth: "admin"
17879
- }), 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({
17880
- name: string(),
17881
- steps: array(PipelineTemplateStepSchema).readonly(),
17882
- engine: PipelineEngineChoiceSchema
17883
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
17884
- id: string(),
17885
- name: string().optional(),
17886
- steps: array(PipelineTemplateStepSchema).readonly().optional()
17887
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
17888
- addonId: string(),
17889
- modelId: string(),
17890
- format: ModelFormatSchema$1
17891
- }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
17892
- addonId: string(),
17893
- modelId: string(),
17894
- format: ModelFormatSchema$1
17895
- }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
17896
- engine: PipelineEngineChoiceSchema.optional(),
17897
- steps: array(PipelineStepInputSchema).min(1),
17898
- frame: FrameInputSchema.optional(),
17899
- /**
17900
- * Process-local lazy frame. Valid only when caller and provider resolve
17901
- * in the same execution-group process; split/cross-node callers use
17902
- * `frame`/`image` inline compatibility instead.
17903
- */
17904
- frameRef: FrameRefSchema.optional(),
17905
- /**
17906
- * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
17907
- * the decoded pixels live in. One more member of the one-of
17908
- * frame/frameHandle/image/imageBase64/referenceImage group.
17909
- */
17910
- frameHandle: FrameHandleSchema.optional(),
17911
- imageBase64: string().optional(),
17912
- /**
17913
- * Binary JPEG bytes — preferred over `imageBase64` on internal
17914
- * hops (hub → forked worker via Moleculer MsgPack) because it
17915
- * skips the 33% base64 overhead + the per-call base64 decode on
17916
- * the detection-pipeline worker. Callers can pass either; exactly
17917
- * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
17918
- */
17919
- image: _instanceof(Uint8Array).optional(),
17920
- referenceImage: string().optional(),
17921
- deviceId: number().optional(),
17922
- sessionId: string().optional(),
17923
- /**
17924
- * Execution plane. 'full' (default) runs the whole tree — benchmark,
17925
- * reference-image, and detail-subtree calls. 'frame' is the live
17926
- * per-frame dispatch: ONLY root-plane steps run; crop children
17927
- * (inputClasses ≠ null) are skipped and served per-track via
17928
- * pipelineRunner.runDetailSubtree (two-plane design).
17929
- */
17930
- plane: _enum(["full", "frame"]).optional(),
17931
- /**
17932
- * Inference-device selector (Phase 2 multi-device). Format
17933
- * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
17934
- * Omitted ⇒ the runner's default device (current single-engine
17935
- * behaviour). Selects WHICH device pool of the node runs the call.
17936
- */
17937
- deviceKey: string().optional(),
17938
- /**
17939
- * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
17940
- * when the parent crop was resolved from the frame's retained NATIVE
17941
- * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
17942
- * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
17943
- * resolution from that surface — the SAME quality path faces already
17944
- * had — instead of the downscaled parent tile. `handle` keys the native
17945
- * surface (node-pinned to its owner); `cropFrameSpace` is the parent
17946
- * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
17947
- * the executor's crop-normalized child ROI back into frame-normalized
17948
- * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
17949
- * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
17950
- * (today's behaviour on the fallback path).
17951
- */
17952
- nativeCropRef: NativeCropRefSchema.optional()
17953
- }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
17954
- engine: PipelineEngineChoiceSchema.optional(),
17955
- steps: array(PipelineStepInputSchema).min(1),
17956
- frames: array(FrameInputSchema).min(1).max(255),
17957
- deviceId: number().optional(),
17958
- sessionId: string().optional(),
17959
- /**
17960
- * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
17961
- * the batch to the Python pool's bench preprocess cache
17962
- * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
17963
- * preprocessed ONCE and every later inference is a pure-inference cache
17964
- * hit — the sustained-throughput run measures inference, not
17965
- * decode+preprocess+infer. Omitted/0 for live frames (all different →
17966
- * full preprocess every call, correct). Fresh per sustained run;
17967
- * released via `uncacheFrame`.
17968
- */
17969
- frameId: number().int().nonnegative().optional(),
17970
- /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
17971
- deviceKey: string().optional()
17972
- }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
17973
- data: _instanceof(Uint8Array),
17974
- width: number().int().positive(),
17975
- height: number().int().positive(),
17976
- format: _enum([
17977
- "rgb",
17978
- "bgr",
17979
- "gray"
17980
- ])
17981
- }), object({
17982
- frameId: number(),
17983
- width: number(),
17984
- height: number()
17985
- }), { kind: "mutation" }), method(object({
17986
- stepId: string(),
17987
- frameId: number().int()
17988
- }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
17989
- batchMode: string(),
17990
- windowMs: number(),
17991
- maxBatchSize: number(),
17992
- concurrency: number()
17993
- })), method(_void(), array(object({
17994
- engineKey: string(),
17995
- engine: PipelineEngineChoiceSchema,
17996
- modelsLoaded: array(string()).readonly(),
17997
- inUseByCameras: array(number()).readonly(),
17998
- /**
17999
- * Origin of this resident factory.
18000
- * - `runtime` — main camera-serving engine (no idle TTL).
18001
- * - `warm-override` — benchmark/test override held in the warm
18002
- * cache; auto-disposed after the idle TTL.
18003
- * - `device-pool` — a concurrent per-device pool (Phase 2
18004
- * multi-device, keyed by `deviceKey`) resolved
18005
- * via `resolveDeviceFactory`. Runs alongside the
18006
- * `runtime` engine on a DIFFERENT accelerator
18007
- * (NPU / iGPU / Coral) — this is how the
18008
- * Engines tab shows all pools running at once.
18009
- */
18010
- kind: _enum([
18011
- "runtime",
18012
- "warm-override",
18013
- "device-pool"
18014
- ]),
18015
- /** Native pid of the underlying Python pool (null when no pool). */
18016
- poolPid: number().nullable(),
18017
- /** ms since this factory was last used (null when not warm-tracked). */
18018
- idleMs: number().nullable(),
18019
- /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
18020
- idleTtlMs: number().nullable()
18021
- })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
18022
- kind: "mutation",
18295
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18296
+ kind: "query",
18023
18297
  auth: "admin"
18024
18298
  }), method(object({
18025
- engine: PipelineEngineChoiceSchema,
18026
- force: boolean().optional()
18027
- }), object({
18028
- success: boolean(),
18029
- reason: string().optional()
18030
- }), {
18299
+ eventId: string(),
18300
+ kind: MediaFileKindEnum.optional(),
18301
+ deviceId: number()
18302
+ }), array(MediaFileSchema).readonly()), method(object({
18303
+ trackId: string(),
18304
+ kinds: array(MediaFileKindEnum).optional(),
18305
+ deviceId: number()
18306
+ }), array(MediaFileSchema).readonly()), method(object({
18307
+ trackId: string(),
18308
+ deviceId: number()
18309
+ }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
18031
18310
  kind: "mutation",
18032
18311
  auth: "admin"
18033
- }), 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({
18034
- addonId: string(),
18035
- modelId: string(),
18036
- filename: string().optional(),
18037
- settings: record(string(), unknown()).optional()
18038
- }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
18312
+ }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
18313
+ kind: "mutation",
18314
+ auth: "admin"
18315
+ }), method(object({}), RebuildStatusSchema), object({
18316
+ deviceId: number(),
18317
+ timestamp: number(),
18318
+ frameWidth: number(),
18319
+ frameHeight: number(),
18320
+ detections: array(OverlayDetectionSchema).readonly()
18321
+ }), object({
18322
+ deviceId: number(),
18323
+ trackId: string(),
18324
+ className: string()
18325
+ }), object({
18326
+ deviceId: number(),
18327
+ trackId: string(),
18328
+ className: string(),
18329
+ durationMs: number()
18330
+ }), object({
18331
+ deviceId: number(),
18332
+ kind: EventKindSchema,
18333
+ eventId: string(),
18334
+ timestamp: number()
18335
+ });
18039
18336
  object({
18040
18337
  activeCameras: number(),
18041
18338
  throttledCameras: number(),
@@ -18047,119 +18344,19 @@ var CameraMetricsSchema = object({
18047
18344
  "disabled",
18048
18345
  "always-on",
18049
18346
  "on-motion"
18050
- ]),
18051
- configuredFps: number(),
18052
- actualFps: number(),
18053
- queueDepth: number(),
18054
- avgInferenceTimeMs: number(),
18055
- droppedFrames: number(),
18056
- phase: _enum([
18057
- "idle",
18058
- "watching",
18059
- "active"
18060
- ])
18061
- });
18062
- var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
18063
- /**
18064
- * Zone — pure geometry + identity. NO filtering behaviour.
18065
- *
18066
- * Zones describe **where** in the frame the operator wants to flag
18067
- * something; consumer-owned {@link ZoneRule} arrays describe **how**
18068
- * each pipeline stage uses them. Splitting the two means a single
18069
- * polygon "Driveway" can simultaneously back a motion-exclude rule,
18070
- * a detection-include rule on `['car']`, and an occupancy aggregate
18071
- * — without three duplicated polygons.
18072
- *
18073
- * Owned by the orchestrator addon (provider) and mirrored into the
18074
- * `zones` device-state slice on every mutation. Consumers
18075
- * (motion-wasm, pipeline-executor, analytics, admin UI) read either
18076
- * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
18077
- * mirror with `onChanged`).
18078
- *
18079
- * Coordinates are normalised fractions of the frame (0–1) so zones
18080
- * survive resolution changes and stream profile switches.
18081
- *
18082
- * `kind` discriminates between full polygons (closed regions used
18083
- * for intrusion / occupancy filters) and tripwires (open 2-point
18084
- * line segments used for cross events). Onboard / firmware-reported
18085
- * zones (Reolink, ONVIF) are out of scope for now — see the deferred
18086
- * task list.
18087
- */
18088
- var ZoneKindEnum = _enum(["polygon", "tripwire"]);
18089
- /** Polygon vertex in fraction-of-frame coordinates (0–1). */
18090
- var PolygonPointSchema = object({
18091
- x: number(),
18092
- y: number()
18093
- });
18094
- /** A camera detection zone — pure geometry/identity. */
18095
- var ZoneSchema = object({
18096
- id: string(),
18097
- name: string(),
18098
- kind: ZoneKindEnum.default("polygon"),
18099
- /** Polygon vertices, fraction of frame (0–1). */
18100
- polygon: array(PolygonPointSchema).readonly(),
18101
- /** Visual color for UI rendering. */
18102
- color: string().default("#3b82f6")
18347
+ ]),
18348
+ configuredFps: number(),
18349
+ actualFps: number(),
18350
+ queueDepth: number(),
18351
+ avgInferenceTimeMs: number(),
18352
+ droppedFrames: number(),
18353
+ phase: _enum([
18354
+ "idle",
18355
+ "watching",
18356
+ "active"
18357
+ ])
18103
18358
  });
18104
- /**
18105
- * Zones capability — per-camera CRUD over polygon detection zones.
18106
- *
18107
- * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
18108
- * to per-device settings and mirrors into the `zones` device-state
18109
- * slice on every mutation, so downstream consumers can subscribe via
18110
- * `dev.state.zones.onChanged`.
18111
- *
18112
- * The cap surface only handles geometry + identity; filtering
18113
- * behaviour (per-class, include/exclude, threshold) lives in the
18114
- * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
18115
- * `capabilities/schemas/zone-rule.js`.
18116
- */
18117
- var zonesCapability = {
18118
- name: "zones",
18119
- scope: "device",
18120
- mode: "singleton",
18121
- deviceTypes: [DeviceType.Camera],
18122
- methods: {
18123
- listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
18124
- addZone: method(object({
18125
- deviceId: number(),
18126
- zone: ZoneSchema
18127
- }), _void(), {
18128
- kind: "mutation",
18129
- auth: "admin"
18130
- }),
18131
- removeZone: method(object({
18132
- deviceId: number(),
18133
- zoneId: string()
18134
- }), _void(), {
18135
- kind: "mutation",
18136
- auth: "admin"
18137
- }),
18138
- updateZone: method(object({
18139
- deviceId: number(),
18140
- zone: ZoneSchema
18141
- }), _void(), {
18142
- kind: "mutation",
18143
- auth: "admin"
18144
- })
18145
- },
18146
- /**
18147
- * Runtime-state slice — the live zone catalogue mirrored by the
18148
- * orchestrator on every CRUD mutation. Consumers read via
18149
- * `device.state.zones.value` / `.watch(...)` without round-tripping
18150
- * the cap, and the codegen DeviceProxy auto-wires the reactive
18151
- * handle. Slice shape is `{ zones: Zone[] }` so future extensions
18152
- * (e.g. zone groupings) can sit alongside the polygon list.
18153
- */
18154
- runtimeState: object({ zones: array(ZoneSchema).readonly() }),
18155
- /**
18156
- * 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.
18157
- *
18158
- * See `RuntimeStateDurability`. Enforced by
18159
- * `scripts/check-runtime-state-durability.ts`.
18160
- */
18161
- durability: "restored"
18162
- };
18359
+ var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
18163
18360
  /**
18164
18361
  * A bounding box in NORMALIZED [0,1] frame coordinates for `getNativeCrop`. The
18165
18362
  * decode worker resolves it against the RETAINED native frame's real pixel dims,
@@ -19952,7 +20149,7 @@ method(object({
19952
20149
  * linking rather than produce an eternal token.
19953
20150
  */
19954
20151
  ttlSec: union([number().int().positive(), literal("never")]).optional()
19955
- }), object({ token: string() })), method(object({ token: string() }), SsoBridgeClaimsSchema.nullable());
20152
+ }), object({ token: string() }), { auth: "admin" }), method(object({ token: string() }), SsoBridgeClaimsSchema.nullable(), { auth: "admin" });
19956
20153
  var ProviderListEntrySchema = discriminatedUnion("shouldSaveDiskSpace", [object({
19957
20154
  providerId: string().min(1),
19958
20155
  displayName: string().min(1),
@@ -20047,10 +20244,13 @@ var EvictResultSchema = object({
20047
20244
  /** True when the provider has nothing left it is willing to drop on this location. */
20048
20245
  exhausted: boolean()
20049
20246
  });
20050
- method(object({ locationId: string() }), EvictableUsageSchema), method(object({
20247
+ method(object({ locationId: string() }), EvictableUsageSchema, { auth: "admin" }), method(object({
20051
20248
  locationId: string(),
20052
20249
  targetBytes: number().int().positive()
20053
- }), EvictResultSchema, { kind: "mutation" });
20250
+ }), EvictResultSchema, {
20251
+ kind: "mutation",
20252
+ auth: "admin"
20253
+ });
20054
20254
  method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin" }), method(StorageMigrationInputSchema, object({ jobId: string() }), {
20055
20255
  kind: "mutation",
20056
20256
  auth: "admin"
@@ -20110,26 +20310,50 @@ var ReadChunkInputSchema = object({
20110
20310
  length: number()
20111
20311
  });
20112
20312
  var EndDownloadInputSchema = object({ downloadId: string() });
20113
- method(_void(), ProviderInfoSchema), method(object({ config: record(string(), unknown()) }), TestLocationResultSchema, { auth: "admin" }), method(object({
20313
+ method(_void(), ProviderInfoSchema, { auth: "admin" }), method(object({ config: record(string(), unknown()) }), TestLocationResultSchema, { auth: "admin" }), method(object({
20114
20314
  location: StorageLocationSchema,
20115
20315
  relativePath: string()
20116
- }), string()), method(object({
20316
+ }), string(), { auth: "admin" }), method(object({
20117
20317
  location: StorageLocationSchema,
20118
20318
  relativePath: string(),
20119
20319
  data: _instanceof(Uint8Array)
20120
- }), _void(), { kind: "mutation" }), method(object({
20320
+ }), _void(), {
20321
+ kind: "mutation",
20322
+ auth: "admin"
20323
+ }), method(object({
20121
20324
  location: StorageLocationSchema,
20122
20325
  relativePath: string()
20123
- }), _instanceof(Uint8Array)), method(object({
20326
+ }), _instanceof(Uint8Array), { auth: "admin" }), method(object({
20124
20327
  location: StorageLocationSchema,
20125
20328
  relativePath: string()
20126
- }), boolean()), method(object({
20329
+ }), boolean(), { auth: "admin" }), method(object({
20127
20330
  location: StorageLocationSchema,
20128
20331
  prefix: string().optional()
20129
- }), array(string()).readonly()), method(object({
20332
+ }), array(string()).readonly(), { auth: "admin" }), method(object({
20130
20333
  location: StorageLocationSchema,
20131
20334
  relativePath: string()
20132
- }), _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" });
20335
+ }), _void(), {
20336
+ kind: "mutation",
20337
+ auth: "admin"
20338
+ }), method(object({ location: StorageLocationSchema }), number().nullable(), { auth: "admin" }), method(BeginUploadInputSchema, BeginUploadResultSchema, {
20339
+ kind: "mutation",
20340
+ auth: "admin"
20341
+ }), method(WriteChunkInputSchema, _void(), {
20342
+ kind: "mutation",
20343
+ auth: "admin"
20344
+ }), method(FinalizeUploadInputSchema, _void(), {
20345
+ kind: "mutation",
20346
+ auth: "admin"
20347
+ }), method(AbortUploadInputSchema, _void(), {
20348
+ kind: "mutation",
20349
+ auth: "admin"
20350
+ }), method(BeginDownloadInputSchema, BeginDownloadResultSchema, {
20351
+ kind: "mutation",
20352
+ auth: "admin"
20353
+ }), method(ReadChunkInputSchema, _instanceof(Uint8Array), { auth: "admin" }), method(EndDownloadInputSchema, _void(), {
20354
+ kind: "mutation",
20355
+ auth: "admin"
20356
+ });
20133
20357
  /** Profile-exported FormBuilder schema. Shape is ConfigUISchema at the UI. */
20134
20358
  var ProfileSettingsSchemaBridge = unknown().nullable();
20135
20359
  var ProfileSettingsBagSchema = record(string(), unknown());
@@ -20387,7 +20611,8 @@ method(object({
20387
20611
  access: "create"
20388
20612
  }), method(object({ userId: string().optional() }), object({ optionsJSON: record(string(), unknown()) }), {
20389
20613
  kind: "mutation",
20390
- access: "view"
20614
+ access: "view",
20615
+ auth: "admin"
20391
20616
  }), method(object({
20392
20617
  /** Required — the user the assertion belongs to (verified). */
20393
20618
  userId: string(),
@@ -20395,10 +20620,12 @@ method(object({
20395
20620
  response: record(string(), unknown())
20396
20621
  }), object({ verified: boolean() }), {
20397
20622
  kind: "mutation",
20398
- access: "view"
20623
+ access: "view",
20624
+ auth: "admin"
20399
20625
  }), method(object({}), object({ optionsJSON: record(string(), unknown()) }), {
20400
20626
  kind: "mutation",
20401
- access: "view"
20627
+ access: "view",
20628
+ auth: "admin"
20402
20629
  }), method(object({
20403
20630
  /** AuthenticationResponseJSON from the browser. */
20404
20631
  response: record(string(), unknown()) }), object({
@@ -20406,7 +20633,8 @@ response: record(string(), unknown()) }), object({
20406
20633
  userId: string().nullable()
20407
20634
  }), {
20408
20635
  kind: "mutation",
20409
- access: "view"
20636
+ access: "view",
20637
+ auth: "admin"
20410
20638
  }), method(object({ userId: string() }), array(PasskeySummarySchema), { auth: "admin" }), method(object({
20411
20639
  userId: string(),
20412
20640
  credentialId: string()
@@ -20578,7 +20806,19 @@ var VectorStatsResultSchema = object({
20578
20806
  /** False when the backend ranks approximately. */
20579
20807
  exact: boolean()
20580
20808
  });
20581
- 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);
20809
+ method(VectorDeclareIndexInputSchema, _void(), {
20810
+ kind: "mutation",
20811
+ auth: "admin"
20812
+ }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
20813
+ kind: "mutation",
20814
+ auth: "admin"
20815
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
20816
+ kind: "mutation",
20817
+ auth: "admin"
20818
+ }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
20819
+ kind: "mutation",
20820
+ auth: "admin"
20821
+ }), method(VectorStatsInputSchema, VectorStatsResultSchema, { auth: "admin" });
20582
20822
  var ClipSchema = object({
20583
20823
  /** Opaque, provider-namespaced id. The default provider encodes the time
20584
20824
  * window so `getClipPlayback` is self-contained (no event re-query). */
@@ -23031,7 +23271,27 @@ var MediaFileLiteSchema$1 = object({
23031
23271
  sizeBytes: number(),
23032
23272
  timestamp: number()
23033
23273
  });
23034
- method(_void(), array(IdentitySchema).readonly()), method(object({ name: string().min(1) }), IdentitySchema, {
23274
+ method(object({
23275
+ /**
23276
+ * Inline {@link IdentitySchema.coverBase64} on every row.
23277
+ *
23278
+ * Default `false`, the same inversion `listRecentFaces` and
23279
+ * `listPlates` took on 2026-08-25 (see `include-crops-default.ts` for
23280
+ * why the burden belongs on the caller that WANTS the bytes). Measured
23281
+ * on the live hub the same day: four identities cost 40,979 B with the
23282
+ * covers inline, ~10 KB of base64 per row, on a query this UI mounts
23283
+ * four times and the viewer holds at `staleTime: 30_000`.
23284
+ *
23285
+ * Nothing loses its avatar: `coverMediaKey` is already on every row and
23286
+ * the `event-media` plane serves that key `immutable` with an ETag.
23287
+ *
23288
+ * **This is an INPUT field, so it does not reach the addon until the
23289
+ * next train** — the hub router validates cap inputs against its own
23290
+ * compiled Zod and strips a key it does not know. Until then the
23291
+ * provider sees `undefined`, which resolves to `false`: the cheap shape
23292
+ * is what ships, and the opt-in becomes reachable when the train lands.
23293
+ */
23294
+ includeCrops: boolean().optional() }).optional(), array(IdentitySchema).readonly()), method(object({ name: string().min(1) }), IdentitySchema, {
23035
23295
  kind: "mutation",
23036
23296
  auth: "admin"
23037
23297
  }), method(object({
@@ -25967,8 +26227,10 @@ var PlateInfoSchema = object({
25967
26227
  keyFrameMediaKey: string().optional(),
25968
26228
  base64: string().optional(),
25969
26229
  /**
25970
- * Same crop as a data-plane URL. `getPlateByTrack` returns this and
25971
- * never inlines JPEG; `listPlates` still inlines for the admin-ui.
26230
+ * Same crop as a data-plane URL, always present when the plate has a stored
26231
+ * crop. `getPlateByTrack` returns this and never inlines JPEG; `listPlates`
26232
+ * and `searchPlates` inline the crop only when their `includeCrops` input is
26233
+ * left at its `true` default.
25972
26234
  */
25973
26235
  cropUrl: string().optional()
25974
26236
  });
@@ -25988,14 +26250,34 @@ var PlateClusterSchema = object({
25988
26250
  });
25989
26251
  method(object({
25990
26252
  deviceId: number().int().optional(),
25991
- limit: number().int().positive().optional()
26253
+ limit: number().int().positive().optional(),
26254
+ /**
26255
+ * Inline the base64 crop on every row. Default `true` — the existing
26256
+ * behaviour, kept so no caller breaks.
26257
+ *
26258
+ * Set `false` once the caller renders {@link PlateInfo.cropUrl}.
26259
+ * Measured on the live hub at the 500 rows the Plates view asks for:
26260
+ * 879,403 B and 27.7 s with the crops inline, against a few KiB of
26261
+ * metadata without them — and the browser then caches the images.
26262
+ *
26263
+ * This is the plate twin of `faceGallery.listRecentFaces`'s option;
26264
+ * plates were the one gallery list left without it.
26265
+ *
26266
+ * **This is an INPUT field, so it does not reach the addon until the
26267
+ * next train.** The hub router validates cap inputs against its own
26268
+ * compiled Zod and strips a key it does not know. Until the train
26269
+ * ships, sending `false` is harmless and keeps the crops inline.
26270
+ */
26271
+ includeCrops: boolean().optional()
25992
26272
  }).optional(), array(PlateInfoSchema).readonly()), method(object({
25993
26273
  deviceId: number().int(),
25994
26274
  trackId: string()
25995
26275
  }), PlateInfoSchema.nullable()), method(object({ plateId: string() }), array(MediaFileLiteSchema).readonly()), method(object({
25996
26276
  text: string().min(1),
25997
26277
  maxDistance: number().int().min(0).optional(),
25998
- limit: number().int().positive().optional()
26278
+ limit: number().int().positive().optional(),
26279
+ /** See `listPlates.includeCrops`. Default `true`. */
26280
+ includeCrops: boolean().optional()
25999
26281
  }), array(PlateInfoSchema).readonly()), method(object({
26000
26282
  maxDistance: number().int().min(0).optional(),
26001
26283
  minClusterSize: number().int().min(2).optional(),
@@ -26009,7 +26291,13 @@ method(object({
26009
26291
  }), method(object({ plateId: string() }), _void(), {
26010
26292
  kind: "mutation",
26011
26293
  auth: "admin"
26012
- }), method(_void(), array(VehicleSchema).readonly()), method(object({ name: string().min(1) }), VehicleSchema, {
26294
+ }), method(object({
26295
+ /** Inline {@link VehicleSchema.coverBase64} on every row. Default
26296
+ * `false` — the vehicle twin of `faceGallery.listIdentities`'s
26297
+ * option; `coverMediaKey` + the `event-media` plane carry the picture.
26298
+ * INPUT field: stripped by the hub router until the train ships, which
26299
+ * resolves to `false` and is exactly the intended default. */
26300
+ includeCrops: boolean().optional() }).optional(), array(VehicleSchema).readonly()), method(object({ name: string().min(1) }), VehicleSchema, {
26013
26301
  kind: "mutation",
26014
26302
  auth: "admin"
26015
26303
  }), method(object({
@@ -27572,92 +27860,6 @@ var sceneMonitorCapability = {
27572
27860
  durability: "session"
27573
27861
  };
27574
27862
  /**
27575
- * Per-stage gating mode applied to the zones a rule references.
27576
- *
27577
- * - `include`: the rule contributes to a **whitelist** for its stage.
27578
- * When at least one `include` rule fires for a stage, only entities
27579
- * inside one of those zones pass that stage.
27580
- * - `exclude`: the rule contributes to a **blacklist** for its stage.
27581
- * Entities inside one of those zones are dropped at that stage.
27582
- *
27583
- * `monitor`-style observation (count without filtering) is not a rule
27584
- * mode — zones without any matching rule are observed naturally by
27585
- * `zone-analytics` (live snapshot + history), so an "I just want to
27586
- * count, not filter" use case needs no rule at all.
27587
- */
27588
- var ZoneRuleModeEnum = _enum(["include", "exclude"]);
27589
- /**
27590
- * Per-consumer rule that references existing zones (geometry) and
27591
- * defines how a specific pipeline stage should treat them. Each
27592
- * consumer addon owns its own `ZoneRule[]` array in its per-device
27593
- * settings:
27594
- *
27595
- * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
27596
- * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
27597
- * - future: notification rules, audio gating, etc.
27598
- *
27599
- * One rule applies to N zones (`zoneIds[]`) so the operator can
27600
- * express "ignore motion in ALL of {garden, street}" with a single
27601
- * rule. `classFilter` narrows the rule to specific object classes —
27602
- * "drop person detections in the street, but keep cars" is one
27603
- * `exclude` rule with `classFilter: ['person']`.
27604
- *
27605
- * `enabled` is a soft toggle — the operator can keep the rule
27606
- * configured but inert without deleting it.
27607
- */
27608
- var ZoneRuleSchema = object({
27609
- /** Stable rule id — survives edits, used by the UI for diffing. */
27610
- id: string(),
27611
- /** Optional human-readable label rendered in the rule editor. */
27612
- name: string().optional(),
27613
- /** Zones this rule targets. The rule's `mode` applies to ALL
27614
- * listed zones (OR-set: a detection in any one of them counts).
27615
- * At least one zone id required — a rule with no targets is a
27616
- * configuration mistake and the form validator rejects it. */
27617
- zoneIds: array(string()).min(1).readonly(),
27618
- mode: ZoneRuleModeEnum,
27619
- /**
27620
- * Class names this rule applies to. Empty / undefined ⇒ rule
27621
- * applies to every class. Class strings match the `macroClass`
27622
- * field on detections (e.g. `person`, `car`, `dog`).
27623
- */
27624
- classFilter: array(string()).readonly().optional(),
27625
- /**
27626
- * Minimum bbox/mask overlap (0–1) with any of the rule's zones
27627
- * required to consider an entity "in the zone". Defaults to the
27628
- * consumer's stage default when omitted. Kept for back-compat with
27629
- * existing per-rule overrides; new operators pick the value via
27630
- * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
27631
- * set, the lower-level engine reads it as a 0–1 fraction.
27632
- */
27633
- overlapThreshold: number().min(0).max(1).optional(),
27634
- /**
27635
- * Operator-friendly version of `overlapThreshold` — the percentage
27636
- * of the detection's bbox that must lie inside the zone for the
27637
- * rule to match. Documented default is 85%; the engine substitutes
27638
- * that when the field is omitted (kept optional so existing rules
27639
- * stored without it stay valid).
27640
- *
27641
- * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
27642
- * rule, the engine prefers `bboxInclusionPct` because it's the
27643
- * field exposed in the UI. Internally both feed the same gate.
27644
- */
27645
- bboxInclusionPct: number().min(0).max(100).optional(),
27646
- /**
27647
- * When `true` and a detection has a segmentation mask, use the
27648
- * mask for overlap instead of the bbox. Detection-stage only;
27649
- * motion rules ignore this field.
27650
- */
27651
- preferMask: boolean().optional(),
27652
- /**
27653
- * Soft-toggle: `false` disables the rule without deleting it.
27654
- * Defaults to `true` so operators creating a rule via the UI
27655
- * see it active immediately.
27656
- */
27657
- enabled: boolean().default(true)
27658
- });
27659
- array(ZoneRuleSchema).readonly();
27660
- /**
27661
27863
  * Script-runner cap. Models HA `script.*` entities on
27662
27864
  * `DeviceType.Script`. A Script is a pre-recorded action sequence
27663
27865
  * that can be invoked imperatively — optionally with a variables
@@ -33716,6 +33918,12 @@ Object.freeze({
33716
33918
  addonId: null,
33717
33919
  access: "create"
33718
33920
  },
33921
+ "pipelineAnalytics.cancelRelocateMedia": {
33922
+ capName: "pipeline-analytics",
33923
+ capScope: "device",
33924
+ addonId: null,
33925
+ access: "create"
33926
+ },
33719
33927
  "pipelineAnalytics.cancelStorageMigrationMove": {
33720
33928
  capName: "pipeline-analytics",
33721
33929
  capScope: "device",
@@ -33890,6 +34098,12 @@ Object.freeze({
33890
34098
  addonId: null,
33891
34099
  access: "view"
33892
34100
  },
34101
+ "pipelineAnalytics.listRelocateMediaJobs": {
34102
+ capName: "pipeline-analytics",
34103
+ capScope: "device",
34104
+ addonId: null,
34105
+ access: "view"
34106
+ },
33893
34107
  "pipelineAnalytics.listRetrainAnnotations": {
33894
34108
  capName: "pipeline-analytics",
33895
34109
  capScope: "device",
@@ -33968,6 +34182,12 @@ Object.freeze({
33968
34182
  addonId: null,
33969
34183
  access: "create"
33970
34184
  },
34185
+ "pipelineAnalytics.relocateMedia": {
34186
+ capName: "pipeline-analytics",
34187
+ capScope: "device",
34188
+ addonId: null,
34189
+ access: "create"
34190
+ },
33971
34191
  "pipelineAnalytics.restageRetrainTrack": {
33972
34192
  capName: "pipeline-analytics",
33973
34193
  capScope: "device",
@@ -33980,6 +34200,12 @@ Object.freeze({
33980
34200
  addonId: null,
33981
34201
  access: "create"
33982
34202
  },
34203
+ "pipelineAnalytics.runReplayFrameProcessor": {
34204
+ capName: "pipeline-analytics",
34205
+ capScope: "device",
34206
+ addonId: null,
34207
+ access: "create"
34208
+ },
33983
34209
  "pipelineAnalytics.saveRetrainAnnotations": {
33984
34210
  capName: "pipeline-analytics",
33985
34211
  capScope: "device",
@@ -34112,6 +34338,12 @@ Object.freeze({
34112
34338
  addonId: null,
34113
34339
  access: "view"
34114
34340
  },
34341
+ "pipelineExecutor.getInferenceDeviceHealth": {
34342
+ capName: "pipeline-executor",
34343
+ capScope: "system",
34344
+ addonId: null,
34345
+ access: "view"
34346
+ },
34115
34347
  "pipelineExecutor.getOrchestratorConfigSchema": {
34116
34348
  capName: "pipeline-executor",
34117
34349
  capScope: "system",
@@ -34184,6 +34416,12 @@ Object.freeze({
34184
34416
  addonId: null,
34185
34417
  access: "view"
34186
34418
  },
34419
+ "pipelineExecutor.rearmInferenceDevice": {
34420
+ capName: "pipeline-executor",
34421
+ capScope: "system",
34422
+ addonId: null,
34423
+ access: "create"
34424
+ },
34187
34425
  "pipelineExecutor.runAudioTest": {
34188
34426
  capName: "pipeline-executor",
34189
34427
  capScope: "system",
@@ -37432,6 +37670,11 @@ Object.freeze({
37432
37670
  form: "single",
37433
37671
  optional: false
37434
37672
  }],
37673
+ "pipelineAnalytics.runReplayFrameProcessor": [{
37674
+ name: "deviceId",
37675
+ form: "single",
37676
+ optional: false
37677
+ }],
37435
37678
  "pipelineAnalytics.saveRetrainAnnotations": [{
37436
37679
  name: "deviceId",
37437
37680
  form: "single",