@camstack/addon-provider-unifi 0.2.28 → 0.2.30

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