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