@camstack/addon-provider-gree 0.2.27 → 0.2.29

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