@camstack/addon-provider-wyze 0.2.32 → 0.2.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/addon.js +2135 -1892
  2. package/dist/addon.mjs +2135 -1892
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -6662,7 +6662,7 @@ function method(input, output, options) {
6662
6662
  input,
6663
6663
  output,
6664
6664
  kind: options?.kind ?? "query",
6665
- auth: options?.auth ?? "protected",
6665
+ ...options?.auth !== void 0 ? { auth: options.auth } : {},
6666
6666
  ...options?.access !== void 0 ? { access: options.access } : {},
6667
6667
  ...options?.caller !== void 0 ? { caller: options.caller } : {},
6668
6668
  timeoutMs: options?.timeoutMs
@@ -6686,7 +6686,7 @@ function event(data) {
6686
6686
  }
6687
6687
  var StaticDirOutputSchema$1 = object({ staticDir: string() });
6688
6688
  var VersionOutputSchema$1 = object({ version: string() });
6689
- method(_void(), StaticDirOutputSchema$1), method(_void(), VersionOutputSchema$1);
6689
+ method(_void(), StaticDirOutputSchema$1, { auth: "admin" }), method(_void(), VersionOutputSchema$1, { auth: "admin" });
6690
6690
  var DeviceType = /* @__PURE__ */ function(DeviceType) {
6691
6691
  DeviceType["Camera"] = "camera";
6692
6692
  DeviceType["Hub"] = "hub";
@@ -7007,7 +7007,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
7007
7007
  }({});
7008
7008
  var StaticDirOutputSchema = object({ staticDir: string() });
7009
7009
  var VersionOutputSchema = object({ version: string() });
7010
- method(_void(), StaticDirOutputSchema), method(_void(), VersionOutputSchema);
7010
+ method(_void(), StaticDirOutputSchema, { auth: "admin" }), method(_void(), VersionOutputSchema, { auth: "admin" });
7011
7011
  /**
7012
7012
  * device-ops — device-scoped cap that unifies the per-IDevice operations
7013
7013
  * previously routed through the `.device-ops` Moleculer bridge service.
@@ -7633,24 +7633,6 @@ var RecordingRetentionSchema = object({
7633
7633
  maxSizeGb: number().min(0).optional()
7634
7634
  });
7635
7635
  /**
7636
- * Scrub-thumbnail fidelity preset — the single per-camera selector bundling the
7637
- * sprite tile RESOLUTION + JPEG QUALITY the recorder packs timeline-scrub
7638
- * previews at. Five graduated steps; absent on a config = `standard` (the
7639
- * shipped default, matching `sheet-geometry`/`sheet-composer`).
7640
- *
7641
- * Existing sheets are IMMUTABLE — a changed preset applies to NEW windows only.
7642
- * Each window's index sidecar carries its own tile dims, so a camera whose
7643
- * preset changed over time renders every historical window at the dims it was
7644
- * written with.
7645
- */
7646
- var ScrubThumbnailPresetSchema = _enum([
7647
- "minimal",
7648
- "low",
7649
- "standard",
7650
- "high",
7651
- "max"
7652
- ]);
7653
- /**
7654
7636
  * The full per-camera recording intent — the wire shape of a RecordingTarget.
7655
7637
  *
7656
7638
  * `bands` is the ONLY authored recording intent: what to record, when, and on
@@ -7658,7 +7640,11 @@ var ScrubThumbnailPresetSchema = _enum([
7658
7640
  * other field is a storage knob (profiles, segment length, retention, scrub).
7659
7641
  *
7660
7642
  * STRICT on purpose: the legacy authoring surface (`schedule`/`schedules`/
7661
- * `triggers`/`preBufferSec`/`postBufferSec`/`rules`) was retired 2026-07-30.
7643
+ * `triggers`/`preBufferSec`/`postBufferSec`/`rules`) was retired 2026-07-30,
7644
+ * and `scrubThumbnails` — a five-step fidelity knob for a sprite tier that was
7645
+ * deleted on 2026-07-24 and had ZERO consumers in the recorder — on 2026-08-25
7646
+ * (D62: a switch that writes a store nobody reads is worse than no switch).
7647
+ * Stored rows keep loading: the READ schema is `.strip()` (config-store.ts).
7662
7648
  * A stale caller must fail loudly — silently stripping its legacy intent would
7663
7649
  * persist a band-less config, i.e. silently stop recording the camera.
7664
7650
  */
@@ -7681,14 +7667,7 @@ var RecordingConfigSchema = object({
7681
7667
  * "off" is the absence of a covering band, never a band value.
7682
7668
  */
7683
7669
  bands: array(RecordingBandSchema).default([]),
7684
- retention: RecordingRetentionSchema.optional(),
7685
- /**
7686
- * Per-camera scrub-thumbnail fidelity preset (resolution + JPEG quality for
7687
- * timeline-scrub sprite previews). Absent = `standard`. Applies to NEW
7688
- * windows only — existing sheets are immutable, and each window's index
7689
- * carries its own tile dims so mixed-preset history renders correctly.
7690
- */
7691
- scrubThumbnails: ScrubThumbnailPresetSchema.optional()
7670
+ retention: RecordingRetentionSchema.optional()
7692
7671
  }).strict();
7693
7672
  /**
7694
7673
  * Entity-relocation job state (storage entity-routing spec, Phase 4).
@@ -7764,10 +7743,11 @@ var RelocateFootageInputSchema = object({
7764
7743
  * `RecordingConfig.enabled` or camera wrapper bindings. */
7765
7744
  var StorageMigrationLeaseInputSchema = object({ leaseId: string().min(1) });
7766
7745
  var StorageMigrationFootageMoveInputSchema = RelocateFootageInputSchema.extend({ leaseId: string().min(1) });
7767
- var StorageMigrationMediaMoveInputSchema = object({
7746
+ var RelocateMediaInputSchema = object({
7768
7747
  toLocationId: string(),
7769
7748
  throttleMbps: number().min(1).max(1e3).optional()
7770
- }).extend({ leaseId: string().min(1) });
7749
+ });
7750
+ var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
7771
7751
  /** The independently selectable logical storage classes. `recordings`
7772
7752
  * encompasses the high and mid segment profiles; `recordingsLow` is low
7773
7753
  * segments; `eventMedia` is post-analysis blobs. */
@@ -8062,7 +8042,26 @@ var LabelDefinitionSchema = object({
8062
8042
  description: string().optional(),
8063
8043
  icon: string().optional()
8064
8044
  });
8065
- var ClassMapDefinitionSchema = object({
8045
+ /**
8046
+ * Wire schema for a per-model CATALOG classMap override
8047
+ * (`ModelCatalogEntry.classMap` / `ModelConvertMetadata.classMap`) —
8048
+ * restricted to {@link CLASS_MAP_MACRO_TARGETS}, the only macros the
8049
+ * detection pipeline executor actually routes.
8050
+ *
8051
+ * This is deliberately a DIFFERENT, narrower shape than the general-purpose
8052
+ * `ClassMapDefinition` interface above (e.g. `IDetectionAddon.getClassMap()`
8053
+ * and the audio `YAMNET_TO_MACRO` catalog both use macro targets outside this
8054
+ * enum) — the two used to share the name `ClassMapDefinition`/
8055
+ * `ClassMapDefinitionSchema`, which made the schema-type-twin guard
8056
+ * (`scripts/check-schema-type-twins.ts`) flag them as a duplicated shape. They
8057
+ * are not: it is two different concepts colliding on a name. Keep this type
8058
+ * under its own name rather than reusing `ClassMapDefinition` — reusing it
8059
+ * would either narrow every `ClassMapDefinition` consumer to the four
8060
+ * detection macros (breaking `YAMNET_TO_MACRO`) or drop the validation this
8061
+ * schema exists for (see the "rejects a classMap whose target is not a
8062
+ * detection macro" test in `model-catalog-schema.test.ts`).
8063
+ */
8064
+ var DetectionCatalogClassMapSchema = object({
8066
8065
  mapping: record(string(), _enum([
8067
8066
  "person",
8068
8067
  "vehicle",
@@ -8267,7 +8266,7 @@ var ModelCatalogEntrySchema = object({
8267
8266
  * applies (Frigate / COCO public catalog). Set on a custom model whose raw
8268
8267
  * labels already ARE the CamStack macros (Scrypted identity map).
8269
8268
  */
8270
- classMap: ClassMapDefinitionSchema.optional()
8269
+ classMap: DetectionCatalogClassMapSchema.optional()
8271
8270
  });
8272
8271
  var ConvertTargetSchema = discriminatedUnion("format", [object({
8273
8272
  format: literal("openvino"),
@@ -8297,7 +8296,7 @@ var ModelConvertMetadataSchema = object({
8297
8296
  "segmentation"
8298
8297
  ]),
8299
8298
  faceAlignment: boolean().optional(),
8300
- classMap: ClassMapDefinitionSchema.optional()
8299
+ classMap: DetectionCatalogClassMapSchema.optional()
8301
8300
  });
8302
8301
  var ConvertResultSchema = object({
8303
8302
  entry: ModelCatalogEntrySchema,
@@ -9160,7 +9159,7 @@ var AddonPageDeclarationSchema = object({
9160
9159
  /** Display label for a CUSTOM `section` id (ignored for well-known ids). */
9161
9160
  sectionLabel: string().optional()
9162
9161
  });
9163
- method(_void(), array(AddonPageDeclarationSchema).readonly());
9162
+ method(_void(), array(AddonPageDeclarationSchema).readonly(), { auth: "admin" });
9164
9163
  var AddonHttpRouteSchema = object({
9165
9164
  method: _enum([
9166
9165
  "GET",
@@ -9395,7 +9394,7 @@ var WidgetMetadataSchema = object({
9395
9394
  defaultColumns: number().int().min(1).max(12).default(6),
9396
9395
  defaultRows: number().int().min(1).max(12).default(1)
9397
9396
  });
9398
- method(_void(), array(WidgetMetadataSchema).readonly());
9397
+ method(_void(), array(WidgetMetadataSchema).readonly(), { auth: "admin" });
9399
9398
  /**
9400
9399
  * `addon-widgets` — system-scoped singleton aggregator cap. Public-facing
9401
9400
  * surface that admin-ui consumes through `useAddonWidgetsListWidgets()`.
@@ -11019,7 +11018,7 @@ var CustomModelDescriptorSchema = object({
11019
11018
  stepId: string(),
11020
11019
  entry: ModelCatalogEntrySchema
11021
11020
  });
11022
- method(_void(), array(CustomModelDescriptorSchema).readonly());
11021
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
11023
11022
  /**
11024
11023
  * Query filter for settings-store collections.
11025
11024
  */
@@ -11106,7 +11105,8 @@ method(object({
11106
11105
  }), _void(), { kind: "mutation" }), method(object({
11107
11106
  namespace: string().optional(),
11108
11107
  collection: string(),
11109
- filter: QueryFilterSchema.optional()
11108
+ filter: QueryFilterSchema.optional(),
11109
+ columns: array(string()).readonly().optional()
11110
11110
  }), array(SettingsRecordSchema).readonly()), method(object({
11111
11111
  namespace: string().optional(),
11112
11112
  collection: string(),
@@ -11169,46 +11169,87 @@ var EngineInfoSchema = object({
11169
11169
  kind: _enum(["relational", "vector"]),
11170
11170
  displayName: string()
11171
11171
  });
11172
- method(_void(), EngineInfoSchema), method(object({
11172
+ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
11173
11173
  namespace: string().optional(),
11174
11174
  collection: string(),
11175
11175
  key: string()
11176
- }), unknown()), method(object({
11176
+ }), unknown(), { auth: "admin" }), method(object({
11177
11177
  namespace: string().optional(),
11178
11178
  collection: string(),
11179
11179
  key: string(),
11180
11180
  value: unknown()
11181
- }), _void(), { kind: "mutation" }), method(object({
11181
+ }), _void(), {
11182
+ kind: "mutation",
11183
+ auth: "admin"
11184
+ }), method(object({
11182
11185
  namespace: string().optional(),
11183
11186
  collection: string(),
11184
- filter: QueryFilterSchema.optional()
11185
- }), array(SettingsRecordSchema).readonly()), method(object({
11187
+ filter: QueryFilterSchema.optional(),
11188
+ /**
11189
+ * SQL-level column projection — MUST mirror `settings-store.query`.
11190
+ *
11191
+ * ⚠ An earlier version of this comment blamed Zod stripping, and that
11192
+ * was wrong — corrected 2026-08-26 after the hop map
11193
+ * (`docs/design/2026-08-26-mappa-hop-argomenti.md`) traced the path.
11194
+ * There is **no Zod parse at all** between the door and the engine: the
11195
+ * dispatcher forwards the payload verbatim and UDS carries it whole. A
11196
+ * field declared here reaches `SqliteSettingsBackend` either way.
11197
+ *
11198
+ * What actually lost `columns` was the THIRD declaration of this shape:
11199
+ * `SettingsQueryInput` in `interfaces/storage.ts`, a hand-written TS
11200
+ * interface the engine destructures from. The field existed on both
11201
+ * schemas and the engine still never read it, because nothing checks a
11202
+ * registered provider against `InferProvider<cap>` —
11203
+ * `ProviderRegistration.provider` is typed `object`.
11204
+ *
11205
+ * It is declared here anyway, and must stay in step with
11206
+ * `settings-store.query`: a caller reading only the cap definitions has
11207
+ * to be able to see that this call carries a projection.
11208
+ * `data-door-schema-parity.spec.ts` keeps the two aligned.
11209
+ */
11210
+ columns: array(string()).readonly().optional()
11211
+ }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
11186
11212
  namespace: string().optional(),
11187
11213
  collection: string(),
11188
11214
  record: SettingsRecordSchema
11189
- }), _void(), { kind: "mutation" }), method(object({
11215
+ }), _void(), {
11216
+ kind: "mutation",
11217
+ auth: "admin"
11218
+ }), method(object({
11190
11219
  namespace: string().optional(),
11191
11220
  collection: string(),
11192
11221
  id: string(),
11193
11222
  data: record(string(), unknown())
11194
- }), _void(), { kind: "mutation" }), method(object({
11223
+ }), _void(), {
11224
+ kind: "mutation",
11225
+ auth: "admin"
11226
+ }), method(object({
11195
11227
  namespace: string().optional(),
11196
11228
  collection: string(),
11197
11229
  key: string()
11198
- }), _void(), { kind: "mutation" }), method(object({
11230
+ }), _void(), {
11231
+ kind: "mutation",
11232
+ auth: "admin"
11233
+ }), method(object({
11199
11234
  namespace: string().optional(),
11200
11235
  collection: string(),
11201
11236
  filter: MutationFilterSchema
11202
- }), object({ deleted: number().int() }), { kind: "mutation" }), method(object({
11237
+ }), object({ deleted: number().int() }), {
11238
+ kind: "mutation",
11239
+ auth: "admin"
11240
+ }), method(object({
11203
11241
  namespace: string().optional(),
11204
11242
  collection: string(),
11205
11243
  filter: MutationFilterSchema,
11206
11244
  data: record(string(), unknown())
11207
- }), object({ updated: number().int() }), { kind: "mutation" }), method(object({
11245
+ }), object({ updated: number().int() }), {
11246
+ kind: "mutation",
11247
+ auth: "admin"
11248
+ }), method(object({
11208
11249
  namespace: string().optional(),
11209
11250
  collection: string(),
11210
11251
  filter: QueryFilterSchema.optional()
11211
- }), number()), method(object({
11252
+ }), number(), { auth: "admin" }), method(object({
11212
11253
  namespace: string().optional(),
11213
11254
  collection: string(),
11214
11255
  field: string(),
@@ -11218,15 +11259,18 @@ method(_void(), EngineInfoSchema), method(object({
11218
11259
  }), array(object({
11219
11260
  bucket: number().int(),
11220
11261
  count: number().int()
11221
- })).readonly()), method(object({
11262
+ })).readonly(), { auth: "admin" }), method(object({
11222
11263
  namespace: string().optional(),
11223
11264
  collection: string()
11224
- }), boolean()), method(object({
11265
+ }), boolean(), { auth: "admin" }), method(object({
11225
11266
  namespace: string().optional(),
11226
11267
  collection: string(),
11227
11268
  columns: array(CollectionColumnSchema).readonly(),
11228
11269
  indexes: array(CollectionIndexSchema).readonly().optional()
11229
- }), _void(), { kind: "mutation" });
11270
+ }), _void(), {
11271
+ kind: "mutation",
11272
+ auth: "admin"
11273
+ });
11230
11274
  /**
11231
11275
  * shm ring usage stats for a `frameSink: 'shm'` decoder session —
11232
11276
  * exposed via `decoder.getShmStats` so downstream consumers can
@@ -12533,7 +12577,7 @@ method(object({
12533
12577
  crop: _instanceof(Uint8Array),
12534
12578
  width: number(),
12535
12579
  height: number()
12536
- }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
12580
+ }), EmbeddingResultSchema, { auth: "admin" }), method(object({ text: string() }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" });
12537
12581
  /**
12538
12582
  * filesystem-browse — per-node capability for browsing the node's local
12539
12583
  * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
@@ -12826,19 +12870,22 @@ method(LlmGenerateBaseInputSchema.extend({
12826
12870
  runtime: ManagedRuntimeConfigSchema,
12827
12871
  /** The managed profile's timeout, threaded by the hub provider. */
12828
12872
  timeoutMs: number().int().positive().optional()
12829
- }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
12873
+ }), LlmGenerateResultSchema, {
12874
+ kind: "mutation",
12875
+ auth: "admin"
12876
+ }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
12830
12877
  kind: "mutation",
12831
12878
  auth: "admin"
12832
12879
  }), method(object({}), _void(), {
12833
12880
  kind: "mutation",
12834
12881
  auth: "admin"
12835
- }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
12882
+ }), method(object({}), LlmRuntimeStatusSchema, { auth: "admin" }), method(object({ model: ManagedModelRefSchema }), _void(), {
12836
12883
  kind: "mutation",
12837
12884
  auth: "admin"
12838
12885
  }), method(object({ file: string() }), _void(), {
12839
12886
  kind: "mutation",
12840
12887
  auth: "admin"
12841
- }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
12888
+ }), method(object({}), array(LlmNodeModelSchema), { auth: "admin" }), method(object({}), LlmRuntimeDiskUsageSchema, { auth: "admin" });
12842
12889
  /**
12843
12890
  * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
12844
12891
  * methods concat-fan across providers; single-row methods route to ONE
@@ -16349,1748 +16396,1998 @@ var OauthIntegrationDescriptorSchema = object({
16349
16396
  */
16350
16397
  refreshTokenTtlSec: union([number().int().positive(), literal("never")]).optional()
16351
16398
  });
16352
- method(_void(), OauthIntegrationDescriptorSchema);
16399
+ method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
16353
16400
  /**
16354
- * pipeline-analytics — device-scoped wrapper cap. Refines raw
16355
- * per-frame detections emitted by the pipeline runner into tracked
16356
- * objects, per-kind event collections (motion / object / audio), and
16357
- * persisted media. Owns the post-detection domain end-to-end:
16358
- *
16359
- * runner emits PipelineInferenceResult
16360
- * ↓ (event bus)
16361
- * pipeline-analytics subscriber
16362
- * ↓ SORT tracker + zone engine + state analyzer + event emitter
16363
- * → three DB collections (one per kind), one FS media tree, one
16364
- * unified event emitter (FrameTracked + TrackStarted/Ended +
16365
- * DetectionEvent on bus)
16366
- *
16367
- * Pure subscriber model. No `processFrame` cap method — the runner
16368
- * already publishes the raw frame on the bus. The cap surface is
16369
- * only QUERIES + per-device settings, bound on/off via
16370
- * `device-manager.setWrapperActive`. `defaultActive: true` because
16371
- * every camera with a detection pipeline wants its raw detections
16372
- * refined; operators opt out per-device via BindingsTab when needed.
16373
- *
16374
- * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
16375
- * (per-device surface) and `track-trail` caps — see P11 cleanup.
16401
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
16402
+ * within the frame, so the executor can re-cut a leaf child ROI at native
16403
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
16376
16404
  */
16377
- var TrackStateSchema = _enum([
16378
- "new",
16379
- "entered",
16380
- "left",
16381
- "moving",
16382
- "idle"
16383
- ]);
16384
- var EventKindSchema = _enum([
16385
- "motion",
16386
- "object",
16387
- "audio"
16388
- ]);
16405
+ var NativeCropRefSchema = object({
16406
+ /** Handle keying the retained native surface (node-pinned to its owner). */
16407
+ handle: FrameHandleSchema,
16408
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
16409
+ cropFrameSpace: object({
16410
+ x: number(),
16411
+ y: number(),
16412
+ w: number(),
16413
+ h: number()
16414
+ })
16415
+ });
16416
+ object({
16417
+ crop: object({
16418
+ left: number(),
16419
+ top: number(),
16420
+ width: number().positive(),
16421
+ height: number().positive()
16422
+ }).optional(),
16423
+ content: object({
16424
+ width: number().int().positive(),
16425
+ height: number().int().positive()
16426
+ }),
16427
+ fit: _enum(["stretch", "contain"]),
16428
+ format: _enum([
16429
+ "rgb",
16430
+ "gray",
16431
+ "jpeg"
16432
+ ])
16433
+ });
16389
16434
  /**
16390
- * Spatial filter for `listTracks` — the rect + polygon variants of the shared
16391
- * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
16392
- * of the camera frame (top-left origin), matching the drawing-plane editor.
16435
+ * Process-local frame identity. It is serializable so it can ride an in-process
16436
+ * capability call, but `registryId` deliberately prevents resolution in any
16437
+ * other process or execution group.
16393
16438
  */
16394
- var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
16395
- /** Closed icon vocabulary so clients render a known glyph per kind. */
16396
- var EventKindIconSchema = _enum([
16397
- "motion",
16398
- "audio",
16399
- "person",
16400
- "vehicle",
16401
- "animal",
16402
- "door",
16403
- "pir",
16404
- "smoke",
16405
- "water",
16406
- "button",
16407
- "package",
16408
- "generic"
16439
+ var FrameRefSchema = object({
16440
+ registryId: string().min(1),
16441
+ id: string().min(1),
16442
+ width: number().int().positive(),
16443
+ height: number().int().positive(),
16444
+ format: _enum(["rgb", "gray"]),
16445
+ timestamp: number(),
16446
+ capturedAt: number().optional()
16447
+ });
16448
+ var ModelFormatSchema$1 = _enum([
16449
+ "onnx",
16450
+ "coreml",
16451
+ "openvino",
16452
+ "tflite",
16453
+ "pt",
16454
+ "gguf"
16409
16455
  ]);
16410
- var EventKindCategorySchema = _enum([
16411
- "motion",
16412
- "audio",
16413
- "detection",
16414
- "sensor",
16415
- "control",
16416
- "custom",
16417
- "package"
16456
+ var PipelineSlotSchema = _enum([
16457
+ "detector",
16458
+ "cropper",
16459
+ "classifier",
16460
+ "refiner",
16461
+ "audio-classifier"
16418
16462
  ]);
16419
- /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
16420
- var EventKindLevelSchema = _enum(["macro", "sub"]);
16421
- var EventKindDescriptorSchema = object({
16422
- /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
16423
- kind: string(),
16424
- /** i18n key resolved on the UI side; `label` is the English fallback. */
16425
- labelKey: string(),
16426
- /** English fallback label (kept for clients that don't translate). */
16427
- label: string(),
16428
- /** Hex color for timeline/legend rendering. */
16429
- color: string(),
16430
- /** Dictionary id → lucide component on the UI side. */
16431
- iconId: string(),
16432
- /** Legacy closed-vocab glyph — fallback for `iconId`. */
16433
- icon: EventKindIconSchema,
16434
- category: EventKindCategorySchema,
16435
- /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
16436
- parentKind: string().nullable(),
16437
- /** Derived from `parentKind`, explicit for the client tree. */
16438
- level: EventKindLevelSchema,
16439
- /** Which cap + device contributes this kind. For built-ins the camera
16440
- * itself; for sensor kinds the LINKED source device. */
16441
- source: object({
16442
- capName: string(),
16443
- deviceId: number()
16444
- })
16463
+ var PipelineEngineChoiceSchema = object({
16464
+ runtime: _enum(["node", "python"]),
16465
+ backend: string(),
16466
+ format: ModelFormatSchema$1,
16467
+ device: string().optional()
16445
16468
  });
16446
- /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
16447
- var EventKindsForDeviceSchema = object({
16448
- deviceId: number(),
16449
- kinds: array(EventKindDescriptorSchema).readonly()
16469
+ var AvailableEngineSchema = object({
16470
+ engine: PipelineEngineChoiceSchema,
16471
+ devices: array(object({
16472
+ id: string(),
16473
+ label: string(),
16474
+ description: string().optional()
16475
+ })).readonly(),
16476
+ defaultDevice: string()
16450
16477
  });
16451
- var SensorEventSchema = object({
16478
+ var PipelineDefaultStepSchema = lazy(() => object({
16479
+ addonId: string(),
16480
+ addonName: string(),
16481
+ slot: PipelineSlotSchema,
16482
+ inputClasses: array(string()).readonly(),
16483
+ outputClasses: array(string()).readonly(),
16484
+ enabled: boolean(),
16485
+ modelId: string(),
16486
+ children: array(PipelineDefaultStepSchema).readonly(),
16487
+ group: string().optional(),
16488
+ settings: record(string(), unknown()).optional()
16489
+ }));
16490
+ var PipelineTemplateStepSchema = lazy(() => object({
16491
+ addonId: string(),
16492
+ enabled: boolean(),
16493
+ modelId: string(),
16494
+ children: array(PipelineTemplateStepSchema).readonly(),
16495
+ settings: record(string(), unknown()).optional()
16496
+ }));
16497
+ var PipelineTemplateSchema$1 = object({
16452
16498
  id: string(),
16453
- /** The CAMERA the event is attributed to (a sensor linked to N cameras
16454
- * yields N rows, one per camera). */
16455
- deviceId: number(),
16456
- /** The linked sensor device whose state changed. */
16457
- sourceDeviceId: number(),
16458
- /** Event kind id — matches an `EventKindDescriptor.kind`. */
16459
- kind: string(),
16460
- /** Snapshot of the sensor cap's runtime-state slice at the change. */
16461
- value: record(string(), unknown()).nullable(),
16462
- timestamp: number()
16463
- });
16464
- var TrackPositionSchema = object({
16465
- x: number(),
16466
- y: number(),
16467
- timestamp: number(),
16468
- bbox: BoundingBoxSchema
16499
+ name: string(),
16500
+ createdAt: string(),
16501
+ updatedAt: string(),
16502
+ engine: PipelineEngineChoiceSchema,
16503
+ steps: array(PipelineTemplateStepSchema).readonly()
16469
16504
  });
16470
- var TrackSnapshotSchema = object({
16471
- timestamp: number(),
16472
- position: TrackPositionSchema,
16473
- /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
16474
- mediaKey: string()
16505
+ var PipelineModelOptionSchema = object({
16506
+ id: string(),
16507
+ name: string(),
16508
+ formats: record(string(), object({
16509
+ downloaded: boolean(),
16510
+ sizeMB: number()
16511
+ })),
16512
+ group: ModelVariantGroupSchema.optional(),
16513
+ legacy: boolean().optional(),
16514
+ provider: ModelProviderIdSchema.optional()
16475
16515
  });
16476
- /**
16477
- * Normalized 0..1 trajectory envelope (min/max over every position bbox,
16478
- * divided by the track's detection-frame dims), computed at persist time.
16479
- * Absent when the frame dims were unknown when the track was persisted
16480
- * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
16481
- */
16482
- var TrackEnvelopeSchema = object({
16483
- minX: number(),
16484
- minY: number(),
16485
- maxX: number(),
16486
- maxY: number()
16516
+ var ConfigFieldBridge = custom();
16517
+ var PipelineAddonSchemaSchema = object({
16518
+ id: string(),
16519
+ name: string(),
16520
+ slot: PipelineSlotSchema,
16521
+ inputClasses: array(string()).readonly(),
16522
+ outputClasses: array(string()).readonly(),
16523
+ childSlots: array(PipelineSlotSchema).readonly(),
16524
+ models: array(PipelineModelOptionSchema).readonly(),
16525
+ defaultModelId: string(),
16526
+ defaultModelIdByFormat: record(string(), string()).optional(),
16527
+ enabledByDefault: boolean().optional(),
16528
+ backfillIntoExistingOverrides: boolean().optional(),
16529
+ defaultConfidence: number(),
16530
+ group: string().optional(),
16531
+ configSchema: array(ConfigFieldBridge).readonly().optional()
16487
16532
  });
16488
- /**
16489
- * Row projection for track list queries. `full` (default) returns the
16490
- * complete Track including the frame-rate `positions[]` history and the
16491
- * `snapshots[]` references — megabytes across a page of tracks. `slim`
16492
- * keeps every scalar the list surfaces actually render (ids, class(es),
16493
- * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
16494
- * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
16495
- * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
16496
- * `getTrack`. Mirrors the event-store `projection` convention
16497
- * (`getObjectEvents` et al.).
16498
- */
16499
- var TrackProjectionSchema = _enum(["full", "slim"]);
16500
- /**
16501
- * One audio-classification label heard on the track's camera while the
16502
- * track was alive, aggregated per label. An "episode" is one persisted
16503
- * audio event (the confident-classification path: score ≥ the device's
16504
- * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
16505
- * one 32 ms inference chunk, so counts stay human-scaled.
16506
- */
16507
- var TrackAudioLabelSchema = object({
16533
+ var PipelineSlotSchemaSchema = object({
16534
+ id: PipelineSlotSchema,
16508
16535
  label: string(),
16509
- /** Highest classification score observed across the label's episodes. */
16510
- peakScore: number(),
16511
- /** Number of coalesced audio-event episodes carrying this label. */
16512
- count: number(),
16513
- firstAt: number(),
16514
- lastAt: number()
16536
+ priority: number(),
16537
+ parentSlot: PipelineSlotSchema.nullable(),
16538
+ addons: array(PipelineAddonSchemaSchema).readonly()
16515
16539
  });
16516
- /**
16517
- * How a track was produced. `pipeline` (default / absent) = the spatial
16518
- * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
16519
- * no positions, a single snapshot, and no bbox trajectory at all:
16520
- *
16521
- * - `sensor` — a linked sensor/control device state change.
16522
- * - `audio` — an audio event on the camera itself that was anomalous for
16523
- * THAT camera, loud, and heard while nothing visual was happening (D62).
16524
- *
16525
- * The spatial subsystems (tracker association, occupancy count, re-id /
16526
- * embedding, resurrection) MUST skip every synthetic source. Test for that
16527
- * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
16528
- * check silently readmits every source added after it was written.
16529
- */
16530
- var TrackSourceSchema = _enum([
16531
- "pipeline",
16532
- "sensor",
16533
- "audio"
16534
- ]);
16535
- /**
16536
- * Where a track sits in the RETRAIN lifecycle (D81).
16537
- *
16538
- * - `none` — never marked, or un-marked. Evictable.
16539
- * - `staging` — the operator wants this track as training material and has not
16540
- * finished with it. **This is the only state retention holds**: the track and
16541
- * everything it owns (object events, crops, keyframes, CLIP vector) survive
16542
- * the device's age window.
16543
- * - `trained` — the retrain page has taken what it needed. The frames it chose
16544
- * were COPIED into the retrain dataset at selection time, so the dataset no
16545
- * longer depends on the track's media and the track becomes EVICTABLE again.
16546
- * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
16547
- * a deliberate action of the retrain page, not a side effect of a checkbox.
16548
- *
16549
- * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
16550
- * the store's filter language has only positive equality and `whereIn` — no
16551
- * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
16552
- * would make the entire pre-column history immortal in one deploy.
16553
- */
16554
- var RetrainStatusSchema = _enum([
16555
- "none",
16556
- "staging",
16557
- "trained"
16558
- ]);
16559
- /**
16560
- * Per-track OPERATOR flags — set by hand from the admin UI or the viewer, never
16561
- * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
16562
- * so the two surfaces cannot drift.
16563
- *
16564
- * **Absent ≠ false.** A track that has never been touched omits the field; an
16565
- * explicitly un-flagged track carries `false`. Legacy rows written before the
16566
- * columns existed read as absent, and a consumer that needs a boolean should say
16567
- * `flag === true`, not `flag !== false`.
16568
- *
16569
- * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
16570
- * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
16571
- * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
16572
- * `trained` track reports `false` while refusing both writes. The boolean is
16573
- * kept because three surfaces drive a toggle off it; anything that needs to tell
16574
- * "never marked" from "already trained" must read `retrainStatus`.
16575
- *
16576
- * `debug` does NOT pin; it is attention, not durability.
16577
- *
16578
- * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
16579
- * A favourited track is skipped by retention the same way `staging` is, but
16580
- * it does not enter `none|staging|trained` and has no staging budget.
16581
- */
16582
- var TrackFlagFields = {
16583
- /** Operator marked this track as training material — i.e. `retrainStatus` is
16584
- * `'staging'`. */
16585
- markForTrain: boolean().optional(),
16586
- /** Operator marked this track for diagnostic attention. */
16587
- debug: boolean().optional(),
16588
- /** Operator favourited this track. Pins it against pruning. */
16589
- favourited: boolean().optional()
16590
- };
16591
- /**
16592
- * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
16593
- * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
16594
- * write patch, and the status is not something the toggle sets — it is what the
16595
- * toggle's boolean is derived from. Absent on an in-RAM track never touched;
16596
- * always present on a persisted row (the column default materialises `'none'`).
16597
- */
16598
- var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
16599
- /**
16600
- * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
16601
- * one flag can never clear the other — the toggles are independent and are
16602
- * driven from three surfaces that do not know about each other.
16603
- */
16604
- var TrackFlagsPatchSchema = object(TrackFlagFields);
16605
- /**
16606
- * The resolved flag state after a write. Both fields are REQUIRED here (absent
16607
- * collapses to `false`) so a caller can drive a toggle's checked state off the
16608
- * mutation result without a re-fetch.
16609
- */
16610
- var TrackFlagsSchema = object({
16611
- trackId: string(),
16612
- markForTrain: boolean(),
16613
- debug: boolean(),
16614
- favourited: boolean(),
16615
- /** The lifecycle state the boolean was derived from. Required here (unlike on
16616
- * a track row) because this shape is only ever produced by the write body,
16617
- * which always knows it — and a surface that has just written needs to render
16618
- * `trained` without a re-fetch. */
16619
- retrainStatus: RetrainStatusSchema
16540
+ var PipelineSchemaSchema = object({
16541
+ availableEngines: array(AvailableEngineSchema).readonly(),
16542
+ selectedEngine: PipelineEngineChoiceSchema,
16543
+ slots: array(PipelineSlotSchemaSchema).readonly()
16620
16544
  });
16621
- union([literal(1), literal(2)]);
16622
- /**
16623
- * WHO decided a label, and when. Carried per tier so a value can be traced to
16624
- * the step and model that produced it — which is what makes the write rule
16625
- * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
16626
- * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
16627
- *
16628
- * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
16629
- * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
16630
- * `migration:4g` for a value the 4g migration moved from the single-slot era —
16631
- * that value has no provenance, and the write rule lets ANY properly-attributed
16632
- * write of the same tier replace it regardless of score.
16633
- */
16634
- var LabelAttributionSchema = object({
16635
- stepId: string(),
16636
- modelId: string().optional(),
16637
- decidedAt: number(),
16545
+ var EngineProvisioningSchema = object({
16546
+ runtimeId: _enum([
16547
+ "onnx",
16548
+ "openvino",
16549
+ "coreml",
16550
+ "edgetpu"
16551
+ ]).nullable(),
16552
+ device: string().nullable(),
16553
+ state: _enum([
16554
+ "idle",
16555
+ "installing",
16556
+ "verifying",
16557
+ "ready",
16558
+ "failed"
16559
+ ]),
16560
+ progress: number().optional(),
16561
+ error: string().optional(),
16562
+ nextRetryAt: number().optional(),
16638
16563
  /**
16639
- * The GALLERY id behind a recognised tier-2 label — a face-gallery
16640
- * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
16641
- *
16642
- * The text alone is a DISPLAY NAME, and a display name is renameable: a
16643
- * notification rule authored on "Gianluca" stopped matching the moment the
16644
- * operator fixed the spelling in the gallery, and nothing said so. The id is
16645
- * the thing that does not move, so it is what a rule matches on
16646
- * (`NcConditions.identities`) and the text is what a human is shown.
16647
- *
16648
- * Absent when the label names no gallery row — a plate the OCR read but no
16649
- * vehicle claims, a sub-class, a species, any tier-1 value.
16564
+ * Gate A (config-correctness gate at engine change): human-readable
16565
+ * config issues surfaced EAGERLY when the node's engine changes — model
16566
+ * substitutions ("chose X, running Y") and zero-build steps ("no model
16567
+ * has a <format> build"). Additive/optional: informational only, never
16568
+ * enforced here — `assertEngineReady` (readiness) still gates inference.
16569
+ * Absent/empty when the node-default tree resolves cleanly.
16650
16570
  */
16651
- identityId: string().optional()
16571
+ configIssues: array(string()).optional()
16652
16572
  });
16653
- /**
16654
- * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
16655
- * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
16656
- * track and its events always answer the same question the same way.
16657
- *
16658
- * Two scalar columns, not an array: every consumer wants "the coarse one" or
16659
- * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
16660
- * is tier 2, and each carries its own score + attribution.
16661
- *
16662
- * **Reading it.** What a human should be shown is `subLabel ?? label` — the
16663
- * finest thing known. Before 4g the single `label` column held the finest
16664
- * value, so a consumer that has not been updated reads the tier-1 slot and
16665
- * shows nothing on a species-only row; that is why the migration puts every
16666
- * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
16667
- * and why the read surfaces were changed in the same train.
16668
- *
16669
- * **Writing it.** The slots are independent, which is the whole point: a
16670
- * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
16671
- * migratorius`), so fineness cannot regress by construction. Within a tier the
16672
- * higher score wins. One rule, one implementation — see
16673
- * `pipeline/label-tier.ts` in addon-post-analysis.
16674
- */
16675
- var TieredLabelFields = {
16676
- /** Tier 1 — the sub-class. See {@link LabelTierSchema}. */
16677
- label: string().optional(),
16678
- /** Confidence of the tier-1 value, as reported by the deciding step. */
16679
- labelScore: number().optional(),
16680
- /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
16681
- labelMeta: LabelAttributionSchema.optional(),
16682
- /** Tier 2 — the instance. See {@link LabelTierSchema}. */
16683
- subLabel: string().optional(),
16684
- /** Confidence of the tier-2 value, as reported by the deciding step. */
16685
- subLabelScore: number().optional(),
16686
- /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
16687
- subLabelMeta: LabelAttributionSchema.optional()
16688
- };
16689
- /** Per-camera slice of a training-export estimate. */
16690
- var TrainingExportDeviceTotalsSchema = object({
16691
- deviceId: number(),
16692
- tracks: number().int(),
16693
- files: number().int(),
16694
- bytes: number().int()
16573
+ var PipelineStepInputSchema = lazy(() => object({
16574
+ addonId: string(),
16575
+ modelId: string().optional(),
16576
+ enabled: boolean().default(true),
16577
+ children: array(PipelineStepInputSchema).optional(),
16578
+ settings: record(string(), unknown()).optional(),
16579
+ jumpDeviceKey: string().optional()
16580
+ }));
16581
+ var ModelSubstitutionSchema = object({
16582
+ addonId: string(),
16583
+ chosen: string(),
16584
+ running: string(),
16585
+ format: string()
16586
+ });
16587
+ var PipelineValidationIssueSchema = object({
16588
+ addonId: string(),
16589
+ kind: _enum(["unknown-addon", "no-format-build"]),
16590
+ detail: string()
16591
+ });
16592
+ var PipelineValidationResultSchema = object({
16593
+ ok: boolean(),
16594
+ issues: array(PipelineValidationIssueSchema).readonly(),
16595
+ substitutions: array(ModelSubstitutionSchema).readonly(),
16596
+ /** The node's `currentEngine.format` this validation ran against. */
16597
+ format: string()
16598
+ });
16599
+ var ReferenceImageEntrySchema = object({
16600
+ filename: string(),
16601
+ stepIds: array(string()).readonly().optional()
16602
+ });
16603
+ var ReferenceImageBodySchema = object({
16604
+ base64: string(),
16605
+ filename: string()
16606
+ });
16607
+ var ReferenceAudioEntrySchema = object({
16608
+ filename: string(),
16609
+ sizeKb: number()
16610
+ });
16611
+ var ReferenceAudioBodySchema = object({ base64: string() });
16612
+ var AudioBackendSchema = object({
16613
+ id: string(),
16614
+ name: string(),
16615
+ description: string(),
16616
+ available: boolean(),
16617
+ /**
16618
+ * Raw classifier labels this backend can emit (e.g. YAMNet's
16619
+ * 521-class set or Apple SoundAnalysis's 303-class set). Used by
16620
+ * the benchmark UI to populate the `enabledMicroClasses` filter
16621
+ * specific to the selected backend without a separate fetch.
16622
+ */
16623
+ rawLabels: array(string()).readonly().optional()
16624
+ });
16625
+ var AudioCapabilitiesSchema = object({
16626
+ activeBackend: string(),
16627
+ availableBackends: array(AudioBackendSchema).readonly(),
16628
+ sampleRate: number(),
16629
+ chunkDurationMs: number()
16630
+ });
16631
+ var DownloadModelResultSchema = object({
16632
+ filePath: string(),
16633
+ sizeMB: number(),
16634
+ durationMs: number()
16695
16635
  });
16696
16636
  /**
16697
- * What a training export WOULD contain. Computed from media index rows only —
16698
- * no blob is read to produce this.
16637
+ * Wrapper carrying a single test run's result. Replaces the legacy
16638
+ * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
16639
+ * canonical `AudioResult` from the Phase 6 output rework: one
16640
+ * `AudioDetection` per class above `minScore`, top-N candidates in
16641
+ * `debug.alternateLabels['audio-classifier']`, per-source timings in
16642
+ * `debug.stepTimings`. The outer `success`/`error` fields stay so the
16643
+ * benchmark UI can still report a clean failure when the classifier
16644
+ * cap isn't available.
16699
16645
  */
16700
- var TrainingExportSummarySchema = object({
16701
- generatedAt: number(),
16702
- trackCount: number().int(),
16703
- fileCount: number().int(),
16704
- byteCount: number().int(),
16705
- /** More marked tracks exist than a single pass carries. */
16706
- truncated: boolean(),
16707
- devices: array(TrainingExportDeviceTotalsSchema).readonly()
16646
+ var AudioTestResultSchema = object({
16647
+ success: boolean(),
16648
+ error: string().optional(),
16649
+ frame: custom().optional()
16708
16650
  });
16709
- var TrackSchema = object({
16710
- trackId: string(),
16711
- deviceId: number(),
16712
- className: string(),
16713
- ...TieredLabelFields,
16714
- producingDeviceName: string().optional(),
16715
- /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
16716
- source: TrackSourceSchema.optional(),
16717
- firstSeen: number(),
16718
- lastSeen: number(),
16719
- /** Frame-rate position history (subject to maxPositionHistory cap). */
16720
- positions: array(TrackPositionSchema).readonly(),
16721
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
16722
- * saveThumbnails policy). */
16723
- snapshots: array(TrackSnapshotSchema).readonly(),
16724
- /** Deduplicated zones the track has entered at least once. Zone IDS. */
16725
- zonesVisited: array(string()).readonly(),
16651
+ var PipelineConfigBridge = custom();
16652
+ var ConfigUISchemaBridge = custom();
16653
+ var ConfigUISchemaNullableBridge = custom();
16654
+ var InferenceCapabilitiesBridge = custom();
16655
+ var ModelAvailabilityListBridge = custom();
16656
+ var PipelineRunResultBridge = custom();
16657
+ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
16658
+ modelId: string(),
16659
+ settings: record(string(), unknown()).readonly()
16660
+ }))), method(object({ steps: record(string(), object({
16661
+ modelId: string(),
16662
+ settings: record(string(), unknown()).readonly()
16663
+ })) }), object({ success: literal(true) }), {
16664
+ kind: "mutation",
16665
+ auth: "admin"
16666
+ }), method(object({ nodeId: string() }), object({
16667
+ success: literal(true),
16668
+ clearedDevices: number()
16669
+ }), {
16670
+ kind: "mutation",
16671
+ auth: "admin"
16672
+ }), method(object({ nodeId: string() }), object({ unhealthy: array(object({
16673
+ /** `<backend>:<device>`, e.g. `openvino:gpu`. */
16674
+ deviceKey: string(),
16726
16675
  /**
16727
- * Human NAMES for {@link zonesVisited}, resolved at READ time against the
16728
- * `zones` capability.
16729
- *
16730
- * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
16731
- * and no card can render — so every free-text search surface was structurally
16732
- * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
16733
- * just returned nothing. Resolving here rather than in each client keeps ONE
16734
- * derivation and costs the clients no extra call (the `zones` cap is
16735
- * per-device, so a client-side resolve would be a per-camera fan-out on a
16736
- * surface built to avoid exactly that).
16737
- *
16738
- * Resolved, never invented: a zone deleted since the track was written has no
16739
- * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
16740
- * two are not positionally aligned. Absent when the track visited no zone, or
16741
- * when the zone catalogue could not be read.
16676
+ * `failed` — the per-device restart budget is exhausted; no pool
16677
+ * will be spawned until an operator re-arms it or the runner
16678
+ * respawns. `backoff` — under budget, waiting out the backoff (or
16679
+ * a cached pool observed dead and not yet condemned).
16742
16680
  */
16743
- zoneNames: array(string()).readonly().optional(),
16744
- /** Deduplicated set of detector classes observed for this track over its
16745
- * life (a track may be reclassified, e.g. person→vehicle). Absent on
16746
- * legacy rows written before class accumulation shipped. */
16747
- classes: array(string()).readonly().optional(),
16748
- /** Cumulative normalized distance travelled (0..1 units = full frame width). */
16749
- totalDistance: number(),
16750
- state: TrackStateSchema,
16751
- active: boolean(),
16752
- /** Deterministic key-event importance score in [0,1] (server-computed at
16753
- * track expiry, recomputed on late label). Absent on legacy rows written
16754
- * before scoring shipped — consumers degrade to absence / compute-on-read. */
16755
- importance: number().optional(),
16756
- /** Id of the track's highest-confidence ObjectEvent (its representative
16757
- * "best" frame). Absent when the track produced no object events. */
16758
- bestEventId: string().optional(),
16759
- /** Tag of the importance sub-signal that dominated the score
16760
- * (identity|dwell|proximity|class|confidence|travel|zone). */
16761
- importanceReason: string().optional(),
16762
- /** Audio-classification labels heard on the camera during the track's
16763
- * life (score ≥ device `classificationMinScore`), aggregated per label.
16764
- * Absent on legacy rows / tracks with no confident audio. */
16765
- audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
16766
- /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
16767
- * Populated from the persisted envelope columns on historical reads;
16768
- * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
16769
- envelope: TrackEnvelopeSchema.optional(),
16681
+ state: _enum(["failed", "backoff"]),
16682
+ /** Epoch ms of the death that produced this state. */
16683
+ since: number(),
16684
+ /** Pool deaths inside the current window. */
16685
+ deaths: number(),
16686
+ /** The last death's message. */
16687
+ lastError: string()
16688
+ })).readonly() })), method(object({
16689
+ nodeId: string(),
16690
+ deviceKey: string()
16691
+ }), object({ rearmed: boolean() }), {
16692
+ kind: "mutation",
16693
+ auth: "admin"
16694
+ }), 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({
16695
+ name: string(),
16696
+ steps: array(PipelineTemplateStepSchema).readonly(),
16697
+ engine: PipelineEngineChoiceSchema
16698
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
16699
+ id: string(),
16700
+ name: string().optional(),
16701
+ steps: array(PipelineTemplateStepSchema).readonly().optional()
16702
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
16703
+ addonId: string(),
16704
+ modelId: string(),
16705
+ format: ModelFormatSchema$1
16706
+ }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
16707
+ addonId: string(),
16708
+ modelId: string(),
16709
+ format: ModelFormatSchema$1
16710
+ }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
16711
+ engine: PipelineEngineChoiceSchema.optional(),
16712
+ steps: array(PipelineStepInputSchema).min(1),
16713
+ frame: FrameInputSchema.optional(),
16770
16714
  /**
16771
- * A face DETECTOR found a face on this track — nothing more. It says the
16772
- * detail plane produced a `face` detail; it does NOT say the face was
16773
- * embedded, matched, above `minFacePx`, or that the recognizer was even
16774
- * enabled. Set once and never cleared.
16775
- *
16776
- * **This exists so "face present but not recognised" is expressible.** A
16777
- * recognised identity lands in `subLabel` (attributed to the face chain via
16778
- * `subLabelMeta.stepId`), so before this field a track with an unmatched face
16779
- * and a track with no face at all were byte-identical on the wire and no
16780
- * surface could tell them apart. The read is `hasFace === true && subLabel
16781
- * === undefined`.
16782
- *
16783
- * **Absent ≠ false.** Every row written before the column existed omits it,
16784
- * and so does every server that predates the field — a consumer must test
16785
- * `=== true` and render nothing otherwise, never infer "no face".
16715
+ * Process-local lazy frame. Valid only when caller and provider resolve
16716
+ * in the same execution-group process; split/cross-node callers use
16717
+ * `frame`/`image` inline compatibility instead.
16786
16718
  */
16787
- hasFace: boolean().optional(),
16719
+ frameRef: FrameRefSchema.optional(),
16788
16720
  /**
16789
- * This track has a face row IN THE GALLERY: a crop **and** an embedding — a
16790
- * face an operator could ASSIGN to an identity.
16791
- *
16792
- * The STRICT twin of {@link hasFace}, and the pair only earns its keep
16793
- * because the two disagree. `hasFace` is stamped at the TOP of the face
16794
- * branch, before every gate, and means no more than "a face detector produced
16795
- * a face detail". This one is stamped at the single moment the gallery row
16796
- * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
16797
- * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
16798
- * candidate gate, the imageless-track drop (no crop was ever captured) and
16799
- * the crop-store drop. Everything between the detector and that insert can
16800
- * legitimately refuse the face, so a flag written any earlier promises the
16801
- * operator something to assign and delivers nothing.
16802
- *
16803
- * **Independent of recognition.** A face collected but never auto-matched is
16804
- * still assignable — it is in fact the face an operator most wants to reach —
16805
- * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
16806
- * `subLabel`; this says only that the raw material exists.
16807
- *
16808
- * **Set once, never cleared.** A track that produced a gallery row produced
16809
- * one; deleting the row later is the gallery's business, not this flag's.
16810
- *
16811
- * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
16812
- * before the column omits it, and so does every server that predates the
16813
- * field. A consumer must test `=== true` and render nothing otherwise —
16814
- * never infer "no assignable face".
16721
+ * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
16722
+ * the decoded pixels live in. One more member of the one-of
16723
+ * frame/frameHandle/image/imageBase64/referenceImage group.
16815
16724
  */
16816
- hasEmbeddedFace: boolean().optional(),
16725
+ frameHandle: FrameHandleSchema.optional(),
16726
+ imageBase64: string().optional(),
16817
16727
  /**
16818
- * This subject CONTAINS a folded rider — a person the rider-pairing step
16819
- * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
16820
- * so the passage is tracked once and as a VEHICLE.
16821
- *
16822
- * It exists because the fold's record was dishonest. D34 and the code both
16823
- * said "the person is not lost — it is reported so both entities stay on the
16824
- * record"; in fact the pair went into a per-processor RAM field behind an
16825
- * accessor nobody called, and every durable surface said `vehicle`, full
16826
- * stop. This is the composition note that makes the row true.
16827
- *
16828
- * A COMPOSITION, never a class and never a label. "This vehicle contains a
16829
- * person" is not an answer to "what is this" — both label tiers would refuse
16830
- * a macro token anyway (D89), and correctly. Nothing here changes what the
16831
- * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
16832
- * and a `person` rule still does not fire for someone cycling past.
16833
- *
16834
- * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
16835
- * the column, and every hub that predates the field, omits it. Test
16836
- * `=== true` and render nothing otherwise — never infer "no rider".
16728
+ * Binary JPEG bytes — preferred over `imageBase64` on internal
16729
+ * hops (hub → forked worker via Moleculer MsgPack) because it
16730
+ * skips the 33% base64 overhead + the per-call base64 decode on
16731
+ * the detection-pipeline worker. Callers can pass either; exactly
16732
+ * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
16837
16733
  */
16838
- hasRider: boolean().optional(),
16839
- ...TrackFlagFields,
16840
- ...TrackRetrainFields
16841
- });
16842
- var BaseEventFields = {
16843
- id: string(),
16844
- deviceId: number(),
16845
- timestamp: number()
16846
- };
16847
- var MotionEventSchema = object({
16848
- ...BaseEventFields,
16849
- kind: literal("motion"),
16850
- regionCount: number(),
16851
- /** Heavy JSON array — omitted in slim projection. */
16852
- regions: array(object({
16853
- bbox: BoundingBoxSchema,
16854
- pixelCount: number(),
16855
- intensity: number()
16856
- })).readonly().optional(),
16857
- /** Omitted in slim projection. */
16858
- frameWidth: number().optional(),
16859
- /** Omitted in slim projection. */
16860
- frameHeight: number().optional(),
16861
- /** Populated by B5 (recording playback URL for this event). */
16862
- mediaUrl: string().optional()
16863
- });
16734
+ image: _instanceof(Uint8Array).optional(),
16735
+ referenceImage: string().optional(),
16736
+ deviceId: number().optional(),
16737
+ sessionId: string().optional(),
16738
+ /**
16739
+ * Execution plane. 'full' (default) runs the whole tree — benchmark,
16740
+ * reference-image, and detail-subtree calls. 'frame' is the live
16741
+ * per-frame dispatch: ONLY root-plane steps run; crop children
16742
+ * (inputClasses ≠ null) are skipped and served per-track via
16743
+ * pipelineRunner.runDetailSubtree (two-plane design).
16744
+ */
16745
+ plane: _enum(["full", "frame"]).optional(),
16746
+ /**
16747
+ * Inference-device selector (Phase 2 multi-device). Format
16748
+ * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
16749
+ * Omitted ⇒ the runner's default device (current single-engine
16750
+ * behaviour). Selects WHICH device pool of the node runs the call.
16751
+ */
16752
+ deviceKey: string().optional(),
16753
+ /**
16754
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
16755
+ * when the parent crop was resolved from the frame's retained NATIVE
16756
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
16757
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
16758
+ * resolution from that surface — the SAME quality path faces already
16759
+ * had — instead of the downscaled parent tile. `handle` keys the native
16760
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
16761
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
16762
+ * the executor's crop-normalized child ROI back into frame-normalized
16763
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
16764
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
16765
+ * (today's behaviour on the fallback path).
16766
+ */
16767
+ nativeCropRef: NativeCropRefSchema.optional()
16768
+ }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
16769
+ engine: PipelineEngineChoiceSchema.optional(),
16770
+ steps: array(PipelineStepInputSchema).min(1),
16771
+ frames: array(FrameInputSchema).min(1).max(255),
16772
+ deviceId: number().optional(),
16773
+ sessionId: string().optional(),
16774
+ /**
16775
+ * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
16776
+ * the batch to the Python pool's bench preprocess cache
16777
+ * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
16778
+ * preprocessed ONCE and every later inference is a pure-inference cache
16779
+ * hit — the sustained-throughput run measures inference, not
16780
+ * decode+preprocess+infer. Omitted/0 for live frames (all different →
16781
+ * full preprocess every call, correct). Fresh per sustained run;
16782
+ * released via `uncacheFrame`.
16783
+ */
16784
+ frameId: number().int().nonnegative().optional(),
16785
+ /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
16786
+ deviceKey: string().optional()
16787
+ }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
16788
+ data: _instanceof(Uint8Array),
16789
+ width: number().int().positive(),
16790
+ height: number().int().positive(),
16791
+ format: _enum([
16792
+ "rgb",
16793
+ "bgr",
16794
+ "gray"
16795
+ ])
16796
+ }), object({
16797
+ frameId: number(),
16798
+ width: number(),
16799
+ height: number()
16800
+ }), { kind: "mutation" }), method(object({
16801
+ stepId: string(),
16802
+ frameId: number().int()
16803
+ }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
16804
+ batchMode: string(),
16805
+ windowMs: number(),
16806
+ maxBatchSize: number(),
16807
+ concurrency: number()
16808
+ })), method(_void(), array(object({
16809
+ engineKey: string(),
16810
+ engine: PipelineEngineChoiceSchema,
16811
+ modelsLoaded: array(string()).readonly(),
16812
+ inUseByCameras: array(number()).readonly(),
16813
+ /**
16814
+ * Origin of this resident factory.
16815
+ * - `runtime` — main camera-serving engine (no idle TTL).
16816
+ * - `warm-override` — benchmark/test override held in the warm
16817
+ * cache; auto-disposed after the idle TTL.
16818
+ * - `device-pool` — a concurrent per-device pool (Phase 2
16819
+ * multi-device, keyed by `deviceKey`) resolved
16820
+ * via `resolveDeviceFactory`. Runs alongside the
16821
+ * `runtime` engine on a DIFFERENT accelerator
16822
+ * (NPU / iGPU / Coral) — this is how the
16823
+ * Engines tab shows all pools running at once.
16824
+ */
16825
+ kind: _enum([
16826
+ "runtime",
16827
+ "warm-override",
16828
+ "device-pool"
16829
+ ]),
16830
+ /** Native pid of the underlying Python pool (null when no pool). */
16831
+ poolPid: number().nullable(),
16832
+ /** ms since this factory was last used (null when not warm-tracked). */
16833
+ idleMs: number().nullable(),
16834
+ /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
16835
+ idleTtlMs: number().nullable()
16836
+ })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
16837
+ kind: "mutation",
16838
+ auth: "admin"
16839
+ }), method(object({
16840
+ engine: PipelineEngineChoiceSchema,
16841
+ force: boolean().optional()
16842
+ }), object({
16843
+ success: boolean(),
16844
+ reason: string().optional()
16845
+ }), {
16846
+ kind: "mutation",
16847
+ auth: "admin"
16848
+ }), 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({
16849
+ addonId: string(),
16850
+ modelId: string(),
16851
+ filename: string().optional(),
16852
+ settings: record(string(), unknown()).optional()
16853
+ }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
16864
16854
  /**
16865
- * Which detection SOURCE produced an object event. `pipeline` = the ML
16866
- * detection pipeline (decoded-frame inference); `onboard` = the camera's
16867
- * native on-device AI. Both flow through the SAME analysis layers (zoning,
16868
- * tracking, per-kind persistence) but stay distinguishable so consumers
16869
- * (advanced-notifier, occupancy, …) can select which source(s) to act on.
16870
- * Absent on legacy rows ⇒ treat as `pipeline`.
16855
+ * Per-stage gating mode applied to the zones a rule references.
16856
+ *
16857
+ * - `include`: the rule contributes to a **whitelist** for its stage.
16858
+ * When at least one `include` rule fires for a stage, only entities
16859
+ * inside one of those zones pass that stage.
16860
+ * - `exclude`: the rule contributes to a **blacklist** for its stage.
16861
+ * Entities inside one of those zones are dropped at that stage.
16862
+ *
16863
+ * `monitor`-style observation (count without filtering) is not a rule
16864
+ * mode — zones without any matching rule are observed naturally by
16865
+ * `zone-analytics` (live snapshot + history), so an "I just want to
16866
+ * count, not filter" use case needs no rule at all.
16871
16867
  */
16872
- var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
16868
+ var ZoneRuleModeEnum = _enum(["include", "exclude"]);
16873
16869
  /**
16874
- * The confirmed zone crossing that produced an object event. Present ONLY on
16875
- * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
16876
- * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
16877
- * appearance event carry none, so a rule asking for a direction fails closed
16878
- * on them.
16870
+ * Per-consumer rule that references existing zones (geometry) and
16871
+ * defines how a specific pipeline stage should treat them. Each
16872
+ * consumer addon owns its own `ZoneRule[]` array in its per-device
16873
+ * settings:
16879
16874
  *
16880
- * Exactly ONE crossing per event: the emitter turns each confirmed crossing
16881
- * into its own event, so a frame in which a track enters A while leaving B
16882
- * produces two events with two directions — never one ambiguous row.
16875
+ * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
16876
+ * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
16877
+ * - future: notification rules, audio gating, etc.
16883
16878
  *
16884
- * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
16885
- * membership the box has NOW, and by definition it no longer contains the zone
16886
- * that was just left. Without the id here, a zone-scoped rule could never match
16887
- * the exit it asked for.
16879
+ * One rule applies to N zones (`zoneIds[]`) so the operator can
16880
+ * express "ignore motion in ALL of {garden, street}" with a single
16881
+ * rule. `classFilter` narrows the rule to specific object classes —
16882
+ * "drop person detections in the street, but keep cars" is one
16883
+ * `exclude` rule with `classFilter: ['person']`.
16884
+ *
16885
+ * `enabled` is a soft toggle — the operator can keep the rule
16886
+ * configured but inert without deleting it.
16888
16887
  */
16889
- var ZoneCrossingSchema = object({
16890
- direction: _enum(["enter", "exit"]),
16891
- /** Admin zone id crossed. */
16892
- zoneId: string(),
16893
- /** Zone display name at crossing time (falls back to the id). */
16894
- zoneName: string().optional()
16895
- });
16896
- var ObjectEventSchema = object({
16897
- ...BaseEventFields,
16898
- kind: literal("object"),
16899
- /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
16900
- source: DetectionSourceSchema.optional(),
16888
+ var ZoneRuleSchema = object({
16889
+ /** Stable rule id — survives edits, used by the UI for diffing. */
16890
+ id: string(),
16891
+ /** Optional human-readable label rendered in the rule editor. */
16892
+ name: string().optional(),
16893
+ /** Zones this rule targets. The rule's `mode` applies to ALL
16894
+ * listed zones (OR-set: a detection in any one of them counts).
16895
+ * At least one zone id required — a rule with no targets is a
16896
+ * configuration mistake and the form validator rejects it. */
16897
+ zoneIds: array(string()).min(1).readonly(),
16898
+ mode: ZoneRuleModeEnum,
16901
16899
  /**
16902
- * Inference-frame id shared by every object event emitted from the SAME frame
16903
- * — the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
16904
- * 2 people + 1 dog) under one full frame, and link a track's frames over time
16905
- * (group by `trackId`, pick a representative `frameId` as the parent frame).
16906
- * Optional for backward-compat with pre-existing rows / the slim projection
16907
- * includes it (it is light). Absent on rows written before this field.
16900
+ * Class names this rule applies to. Empty / undefined ⇒ rule
16901
+ * applies to every class. Class strings match the `macroClass`
16902
+ * field on detections (e.g. `person`, `car`, `dog`).
16908
16903
  */
16909
- frameId: string().optional(),
16910
- /** Omitted in slim projection. */
16911
- trackId: string().optional(),
16912
- className: string(),
16913
- ...TieredLabelFields,
16914
- /** Omitted in slim projection. */
16915
- confidence: number().optional(),
16916
- /** Heavy JSON — omitted in slim projection. */
16917
- bbox: BoundingBoxSchema.optional(),
16918
- /** Heavy JSON — omitted in slim projection. */
16919
- zones: array(string()).readonly().optional(),
16920
- /** Omitted in slim projection. */
16921
- state: TrackStateSchema.optional(),
16904
+ classFilter: array(string()).readonly().optional(),
16922
16905
  /**
16923
- * The zone crossing this event IS, when it is one. Absent on every other
16924
- * event kind (movement state, appearance, package) — see
16925
- * {@link ZoneCrossingSchema}. Omitted in slim projection.
16906
+ * Minimum bbox/mask overlap (0–1) with any of the rule's zones
16907
+ * required to consider an entity "in the zone". Defaults to the
16908
+ * consumer's stage default when omitted. Kept for back-compat with
16909
+ * existing per-rule overrides; new operators pick the value via
16910
+ * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
16911
+ * set, the lower-level engine reads it as a 0–1 fraction.
16926
16912
  */
16927
- zoneCrossing: ZoneCrossingSchema.optional(),
16928
- /** Detection-frame dimensions in pixels — let consumers normalize the
16929
- * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
16930
- frameWidth: number().optional(),
16931
- frameHeight: number().optional(),
16932
- /** MediaStore key for the crop attached to this event (if any). */
16933
- mediaKey: string().optional(),
16934
- /** Design B: MediaStore key of the track's native-resolution key frame (the
16935
- * best-detection full frame). Resolve via the event-media data-plane
16936
- * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
16937
- * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
16938
- * sources — consumers fall back to `mediaKey` (the tight crop). */
16939
- keyFrameMediaKey: string().optional(),
16940
- /** Populated by B5 (recording playback URL for this event). */
16941
- mediaUrl: string().optional(),
16942
- /** The parent track's key-event importance [0,1], propagated to every object
16943
- * event of the track (so an event row can be sorted by importance without a
16944
- * track join). Absent on legacy rows / before the track was scored. */
16945
- importance: number().optional()
16913
+ overlapThreshold: number().min(0).max(1).optional(),
16914
+ /**
16915
+ * Operator-friendly version of `overlapThreshold` — the percentage
16916
+ * of the detection's bbox that must lie inside the zone for the
16917
+ * rule to match. Documented default is 85%; the engine substitutes
16918
+ * that when the field is omitted (kept optional so existing rules
16919
+ * stored without it stay valid).
16920
+ *
16921
+ * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
16922
+ * rule, the engine prefers `bboxInclusionPct` because it's the
16923
+ * field exposed in the UI. Internally both feed the same gate.
16924
+ */
16925
+ bboxInclusionPct: number().min(0).max(100).optional(),
16926
+ /**
16927
+ * When `true` and a detection has a segmentation mask, use the
16928
+ * mask for overlap instead of the bbox. Detection-stage only;
16929
+ * motion rules ignore this field.
16930
+ */
16931
+ preferMask: boolean().optional(),
16932
+ /**
16933
+ * Soft-toggle: `false` disables the rule without deleting it.
16934
+ * Defaults to `true` so operators creating a rule via the UI
16935
+ * see it active immediately.
16936
+ */
16937
+ enabled: boolean().default(true)
16946
16938
  });
16947
- var AudioEventSchema = object({
16948
- ...BaseEventFields,
16949
- kind: literal("audio"),
16950
- rms: number(),
16951
- dbfs: number(),
16952
- classification: object({
16953
- className: string(),
16954
- originalClass: string().optional(),
16955
- score: number()
16956
- }).optional(),
16957
- /** Populated by B5 (recording playback URL for this event). */
16958
- mediaUrl: string().optional()
16939
+ array(ZoneRuleSchema).readonly();
16940
+ /**
16941
+ * Zone — pure geometry + identity. NO filtering behaviour.
16942
+ *
16943
+ * Zones describe **where** in the frame the operator wants to flag
16944
+ * something; consumer-owned {@link ZoneRule} arrays describe **how**
16945
+ * each pipeline stage uses them. Splitting the two means a single
16946
+ * polygon "Driveway" can simultaneously back a motion-exclude rule,
16947
+ * a detection-include rule on `['car']`, and an occupancy aggregate
16948
+ * — without three duplicated polygons.
16949
+ *
16950
+ * Owned by the orchestrator addon (provider) and mirrored into the
16951
+ * `zones` device-state slice on every mutation. Consumers
16952
+ * (motion-wasm, pipeline-executor, analytics, admin UI) read either
16953
+ * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
16954
+ * mirror with `onChanged`).
16955
+ *
16956
+ * Coordinates are normalised fractions of the frame (0–1) so zones
16957
+ * survive resolution changes and stream profile switches.
16958
+ *
16959
+ * `kind` discriminates between full polygons (closed regions used
16960
+ * for intrusion / occupancy filters) and tripwires (open 2-point
16961
+ * line segments used for cross events). Onboard / firmware-reported
16962
+ * zones (Reolink, ONVIF) are out of scope for now — see the deferred
16963
+ * task list.
16964
+ */
16965
+ var ZoneKindEnum = _enum(["polygon", "tripwire"]);
16966
+ /** Polygon vertex in fraction-of-frame coordinates (0–1). */
16967
+ var PolygonPointSchema = object({
16968
+ x: number(),
16969
+ y: number()
16959
16970
  });
16960
- var MediaFileKindEnum = _enum([
16961
- "crop",
16962
- "thumbnail",
16963
- "snapshot",
16964
- "firstFrame",
16965
- "lastFrame",
16966
- "fullFrame",
16967
- "fullFrameBoxed",
16968
- "faceCrop",
16969
- "plateCrop",
16970
- "keyFrame",
16971
- "keyFrameSmall",
16972
- "thumbnailSmall"
16973
- ]);
16974
- var MediaFileSchema = object({
16975
- key: string(),
16976
- kind: MediaFileKindEnum,
16977
- base64: string(),
16978
- sizeBytes: number(),
16979
- timestamp: number()
16971
+ /** A camera detection zone — pure geometry/identity. */
16972
+ var ZoneSchema = object({
16973
+ id: string(),
16974
+ name: string(),
16975
+ kind: ZoneKindEnum.default("polygon"),
16976
+ /** Polygon vertices, fraction of frame (0–1). */
16977
+ polygon: array(PolygonPointSchema).readonly(),
16978
+ /** Visual color for UI rendering. */
16979
+ color: string().default("#3b82f6")
16980
16980
  });
16981
16981
  /**
16982
- * One media row WITHOUT its bytes.
16982
+ * Zones capability — per-camera CRUD over polygon detection zones.
16983
16983
  *
16984
- * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
16985
- * 140 s track), and a client that renders tiles from the media data plane needs
16986
- * to know only WHAT EXISTS — the bytes then arrive per tile, lazily, over HTTP
16987
- * with an immutable cache, instead of all at once inside a tRPC response that
16988
- * blocks the whole view.
16984
+ * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
16985
+ * to per-device settings and mirrors into the `zones` device-state
16986
+ * slice on every mutation, so downstream consumers can subscribe via
16987
+ * `dev.state.zones.onChanged`.
16989
16988
  *
16990
- * `sizeBytes` is carried because it is what lets a client decide between the
16991
- * stored blob and a `?variant=thumb` rendering without fetching either.
16989
+ * The cap surface only handles geometry + identity; filtering
16990
+ * behaviour (per-class, include/exclude, threshold) lives in the
16991
+ * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
16992
+ * `capabilities/schemas/zone-rule.js`.
16992
16993
  */
16993
- var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
16994
+ var zonesCapability = {
16995
+ name: "zones",
16996
+ scope: "device",
16997
+ mode: "singleton",
16998
+ deviceTypes: [DeviceType.Camera],
16999
+ methods: {
17000
+ listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
17001
+ addZone: method(object({
17002
+ deviceId: number(),
17003
+ zone: ZoneSchema
17004
+ }), _void(), {
17005
+ kind: "mutation",
17006
+ auth: "admin"
17007
+ }),
17008
+ removeZone: method(object({
17009
+ deviceId: number(),
17010
+ zoneId: string()
17011
+ }), _void(), {
17012
+ kind: "mutation",
17013
+ auth: "admin"
17014
+ }),
17015
+ updateZone: method(object({
17016
+ deviceId: number(),
17017
+ zone: ZoneSchema
17018
+ }), _void(), {
17019
+ kind: "mutation",
17020
+ auth: "admin"
17021
+ })
17022
+ },
17023
+ /**
17024
+ * Runtime-state slice — the live zone catalogue mirrored by the
17025
+ * orchestrator on every CRUD mutation. Consumers read via
17026
+ * `device.state.zones.value` / `.watch(...)` without round-tripping
17027
+ * the cap, and the codegen DeviceProxy auto-wires the reactive
17028
+ * handle. Slice shape is `{ zones: Zone[] }` so future extensions
17029
+ * (e.g. zone groupings) can sit alongside the polygon list.
17030
+ */
17031
+ runtimeState: object({ zones: array(ZoneSchema).readonly() }),
17032
+ /**
17033
+ * 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.
17034
+ *
17035
+ * See `RuntimeStateDurability`. Enforced by
17036
+ * `scripts/check-runtime-state-durability.ts`.
17037
+ */
17038
+ durability: "restored"
17039
+ };
16994
17040
  /**
16995
- * The MACRO tier of an annotation — a CLOSED set.
17041
+ * pipeline-analytics — device-scoped wrapper cap. Refines raw
17042
+ * per-frame detections emitted by the pipeline runner into tracked
17043
+ * objects, per-kind event collections (motion / object / audio), and
17044
+ * persisted media. Owns the post-detection domain end-to-end:
16996
17045
  *
16997
- * This is what the exported detector predicts, so a typo here is a new class
16998
- * with one example in it. `label` and `subLabel` are open strings by contrast:
16999
- * the whole point of the page is teaching the model things it does not know
17000
- * yet, and constraining that vocabulary would make it useless.
17046
+ * runner emits PipelineInferenceResult
17047
+ * ↓ (event bus)
17048
+ * pipeline-analytics subscriber
17049
+ * ↓ SORT tracker + zone engine + state analyzer + event emitter
17050
+ * → three DB collections (one per kind), one FS media tree, one
17051
+ * unified event emitter (FrameTracked + TrackStarted/Ended +
17052
+ * DetectionEvent on bus)
17001
17053
  *
17002
- * A macro class is NEVER a label. The provider refuses a write whose `label` or
17003
- * `subLabel` is one of these values, in any casing, because once `person`
17004
- * exists in both tiers "every person box" stops being answerable without
17005
- * knowing every string anyone ever typed — and the damage is retroactive.
17054
+ * Pure subscriber model. No `processFrame` cap method — the runner
17055
+ * already publishes the raw frame on the bus. The cap surface is
17056
+ * only QUERIES + per-device settings, bound on/off via
17057
+ * `device-manager.setWrapperActive`. `defaultActive: true` because
17058
+ * every camera with a detection pipeline wants its raw detections
17059
+ * refined; operators opt out per-device via BindingsTab when needed.
17060
+ *
17061
+ * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
17062
+ * (per-device surface) and `track-trail` caps — see P11 cleanup.
17006
17063
  */
17007
- var RetrainMacroClassSchema = _enum([
17064
+ var TrackStateSchema = _enum([
17065
+ "new",
17066
+ "entered",
17067
+ "left",
17068
+ "moving",
17069
+ "idle"
17070
+ ]);
17071
+ var EventKindSchema = _enum([
17072
+ "motion",
17073
+ "object",
17074
+ "audio"
17075
+ ]);
17076
+ /**
17077
+ * Spatial filter for `listTracks` — the rect + polygon variants of the shared
17078
+ * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
17079
+ * of the camera frame (top-left origin), matching the drawing-plane editor.
17080
+ */
17081
+ var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
17082
+ /** Closed icon vocabulary so clients render a known glyph per kind. */
17083
+ var EventKindIconSchema = _enum([
17084
+ "motion",
17085
+ "audio",
17008
17086
  "person",
17009
17087
  "vehicle",
17010
17088
  "animal",
17089
+ "door",
17090
+ "pir",
17091
+ "smoke",
17092
+ "water",
17093
+ "button",
17011
17094
  "package",
17012
- "face",
17013
- "plate"
17095
+ "generic"
17014
17096
  ]);
17015
- /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
17016
- var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
17017
- /** Did a human draw this box, or did the assist propose it? */
17018
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
17019
- /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
17020
- var RetrainBboxSchema = object({
17021
- x: number(),
17022
- y: number(),
17023
- w: number(),
17024
- h: number()
17097
+ var EventKindCategorySchema = _enum([
17098
+ "motion",
17099
+ "audio",
17100
+ "detection",
17101
+ "sensor",
17102
+ "control",
17103
+ "custom",
17104
+ "package"
17105
+ ]);
17106
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
17107
+ var EventKindLevelSchema = _enum(["macro", "sub"]);
17108
+ var EventKindDescriptorSchema = object({
17109
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
17110
+ kind: string(),
17111
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
17112
+ labelKey: string(),
17113
+ /** English fallback label (kept for clients that don't translate). */
17114
+ label: string(),
17115
+ /** Hex color for timeline/legend rendering. */
17116
+ color: string(),
17117
+ /** Dictionary id → lucide component on the UI side. */
17118
+ iconId: string(),
17119
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
17120
+ icon: EventKindIconSchema,
17121
+ category: EventKindCategorySchema,
17122
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
17123
+ parentKind: string().nullable(),
17124
+ /** Derived from `parentKind`, explicit for the client tree. */
17125
+ level: EventKindLevelSchema,
17126
+ /** Which cap + device contributes this kind. For built-ins the camera
17127
+ * itself; for sensor kinds the LINKED source device. */
17128
+ source: object({
17129
+ capName: string(),
17130
+ deviceId: number()
17131
+ })
17025
17132
  });
17026
- /**
17027
- * One annotated subject.
17028
- *
17029
- * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
17030
- * (letterboxed root / zone-cropped package / subject-cropped classifier) are
17031
- * derived from it at export and never stored — storing them is how one feature
17032
- * space ends up holding two crops of the same subject (D52).
17033
- */
17034
- var RetrainAnnotationSchema = object({
17035
- id: string(),
17036
- trackId: string(),
17133
+ /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
17134
+ var EventKindsForDeviceSchema = object({
17037
17135
  deviceId: number(),
17038
- /** The COPY in retrain storage — never the source track's media key. */
17039
- mediaKey: string(),
17040
- bbox: RetrainBboxSchema,
17041
- macroClass: RetrainMacroClassSchema,
17042
- label: string().optional(),
17043
- subLabel: string().optional(),
17044
- kind: RetrainAnnotationKindSchema,
17045
- source: RetrainAnnotationSourceSchema,
17046
- /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
17047
- assistModelId: string().optional(),
17048
- assistScore: number().optional(),
17049
- exportedInBatch: string().optional(),
17050
- createdAt: number()
17051
- });
17052
- /** The write form — the server owns `id`, `createdAt` and the frame binding. */
17053
- var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
17054
- id: true,
17055
- trackId: true,
17056
- deviceId: true,
17057
- mediaKey: true,
17058
- createdAt: true,
17059
- exportedInBatch: true
17136
+ kinds: array(EventKindDescriptorSchema).readonly()
17060
17137
  });
17061
- /** A track sitting in `staging`, with everything the worklist needs to rank it. */
17062
- var RetrainTrackSchema = object({
17063
- trackId: string(),
17138
+ var SensorEventSchema = object({
17139
+ id: string(),
17140
+ /** The CAMERA the event is attributed to (a sensor linked to N cameras
17141
+ * yields N rows, one per camera). */
17064
17142
  deviceId: number(),
17065
- className: string(),
17066
- label: string().optional(),
17067
- firstSeen: number(),
17068
- lastSeen: number(),
17069
- /** How many frames the dataset already holds from this track. */
17070
- frameCount: number().int(),
17071
- /** How many subjects have been annotated on those frames. `0` with
17072
- * `frameCount: 0` is exactly "staging, still to work". */
17073
- annotationCount: number().int()
17143
+ /** The linked sensor device whose state changed. */
17144
+ sourceDeviceId: number(),
17145
+ /** Event kind id — matches an `EventKindDescriptor.kind`. */
17146
+ kind: string(),
17147
+ /** Snapshot of the sensor cap's runtime-state slice at the change. */
17148
+ value: record(string(), unknown()).nullable(),
17149
+ timestamp: number()
17074
17150
  });
17075
- /** A frame the picker may offer — an index row, no blob was read to produce it. */
17076
- var RetrainFrameCandidateSchema = object({
17077
- mediaKey: string(),
17078
- kind: MediaFileKindEnum,
17151
+ var TrackPositionSchema = object({
17152
+ x: number(),
17153
+ y: number(),
17079
17154
  timestamp: number(),
17080
- sizeBytes: number().int(),
17081
- /** A copy of this original already exists — selecting it is free and cannot
17082
- * fail, whatever became of the original. */
17083
- copied: boolean()
17084
- });
17085
- /** A frame the dataset OWNS: bytes copied at selection time. */
17086
- var RetrainFrameSchema = object({
17087
- frameId: string(),
17088
- deviceId: number(),
17089
- trackId: string(),
17090
- /** Provenance only. It may already point at nothing — that is expected. */
17091
- sourceMediaKey: string(),
17092
- sourceKind: MediaFileKindEnum,
17093
- sizeBytes: number().int(),
17094
- width: number().int(),
17095
- height: number().int(),
17096
- copiedAt: number()
17097
- });
17098
- /** Why a copy-on-select could not be honoured — named, never a silent skip. */
17099
- var RetrainCopyRefusalSchema = _enum([
17100
- "source-missing",
17101
- "unreadable-image",
17102
- "write-failed"
17103
- ]);
17104
- var RetrainFrameSelectionSchema = object({
17105
- copied: array(RetrainFrameSchema).readonly(),
17106
- refused: array(object({
17107
- sourceMediaKey: string(),
17108
- reason: RetrainCopyRefusalSchema
17109
- })).readonly()
17155
+ bbox: BoundingBoxSchema
17110
17156
  });
17111
- var RetrainFrameListSchema = object({
17112
- candidates: array(RetrainFrameCandidateSchema).readonly(),
17113
- copies: array(RetrainFrameSchema).readonly(),
17114
- /** What the page pre-selects — the native key frame when one survives. */
17115
- autoPickMediaKey: string().optional()
17157
+ var TrackSnapshotSchema = object({
17158
+ timestamp: number(),
17159
+ position: TrackPositionSchema,
17160
+ /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
17161
+ mediaKey: string()
17116
17162
  });
17117
- /** What the operator asked the assist to look for. */
17118
- var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
17119
- kind: literal("package"),
17120
- zone: RetrainBboxSchema.optional()
17121
- }), object({
17122
- kind: literal("objects"),
17123
- modelId: string(),
17124
- minScore: number().optional()
17125
- })]);
17126
17163
  /**
17127
- * The assist's answer — a discriminated union, because "the model saw nothing"
17128
- * and "this node cannot run that model" lead to different next moves and a
17129
- * nullable result cannot tell them apart.
17164
+ * Normalized 0..1 trajectory envelope (min/max over every position bbox,
17165
+ * divided by the track's detection-frame dims), computed at persist time.
17166
+ * Absent when the frame dims were unknown when the track was persisted
17167
+ * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
17130
17168
  */
17131
- var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
17132
- kind: literal("proposed"),
17133
- modelId: string(),
17134
- stepId: string(),
17135
- minScore: number(),
17136
- /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
17137
- proposals: array(RetrainAnnotationDraftSchema).readonly(),
17138
- /** Returned by the runner but removed by the threshold. */
17139
- belowThreshold: number().int()
17140
- }), object({
17141
- kind: literal("refused"),
17142
- /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
17143
- reason: string(),
17144
- detail: string().optional()
17145
- })]);
17146
- /** The outcome of a lifecycle move owned by the retrain page. */
17147
- var RetrainTransitionResultSchema = object({
17148
- trackId: string(),
17149
- /** Where the track ended up, whatever happened. */
17150
- retrainStatus: RetrainStatusSchema,
17151
- /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
17152
- changed: boolean(),
17153
- reason: _enum([
17154
- "unknown-track",
17155
- "no-frames-copied",
17156
- "not-staging",
17157
- "not-trained",
17158
- "unchanged"
17159
- ]).optional()
17169
+ var TrackEnvelopeSchema = object({
17170
+ minX: number(),
17171
+ minY: number(),
17172
+ maxX: number(),
17173
+ maxY: number()
17160
17174
  });
17161
- var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
17162
- var MAX_EVENT_QUERY_LIMIT = 5e3;
17163
- var DeviceEventQueryInput = object({
17164
- deviceId: number(),
17165
- since: number().optional(),
17166
- until: number().optional(),
17167
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
17168
- /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
17169
- * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
17170
- * exact behaviour. Callers may omit this field — the store defaults to
17171
- * `full` when not provided. */
17172
- projection: _enum(["full", "slim"]).optional()
17173
- });
17174
- var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
17175
- var RecentTracksQueryInput = object({
17176
- /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
17177
- deviceIds: array(number()),
17178
- /** Window lower bound on `lastSeen` (inclusive). */
17179
- since: number().optional(),
17180
- /** Window upper bound on `lastSeen` (inclusive). */
17181
- until: number().optional(),
17182
- /** Page size. Default 200, max 1000. */
17183
- limit: number().int().min(1).max(1e3).default(200),
17184
- /** Opaque continuation cursor from a previous page's `nextCursor`.
17185
- * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
17186
- cursor: string().optional(),
17187
- /** See {@link TrackProjectionSchema}. Default `full`. */
17188
- projection: TrackProjectionSchema.optional(),
17189
- /** Include stationary-promoted rows (parked objects). Default false: the
17190
- * feed lists passages; parking records live on the stationary registry. */
17191
- includeStationary: boolean().optional()
17192
- });
17193
- var RecentTracksPageSchema = object({
17194
- /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
17195
- tracks: array(TrackSchema).readonly(),
17196
- /** Cursor for the next page, or null when this page is the last. */
17197
- nextCursor: string().nullable()
17198
- });
17199
- var LIST_GROUPS_DEFAULT_LIMIT = 40;
17200
- var LIST_GROUPS_MAX_LIMIT = 100;
17201
- var AnalyticsGroupRecordSchema = object({
17202
- id: string(),
17203
- deviceId: number().int(),
17204
- openedAt: number().int(),
17205
- closedAt: number().int(),
17206
- timestamp: number().int(),
17207
- memberCount: number().int(),
17208
- memberTrackIds: array(string()).readonly(),
17209
- className: string(),
17210
- classes: array(string()).readonly(),
17211
- /** Relative event-media path, or null when the group has no picture yet. */
17212
- mediaUrl: string().nullable(),
17213
- singleton: boolean()
17214
- });
17215
- var AnalyticsGroupMemberSchema = object({
17216
- trackId: string(),
17217
- deviceId: number().int(),
17218
- className: string(),
17219
- firstSeen: number().int(),
17220
- lastSeen: number().int(),
17221
- mediaUrl: string().nullable()
17222
- });
17223
- var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
17224
- var ListGroupsQueryInput = object({
17225
- /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
17226
- deviceIds: array(number()),
17227
- /** Window lower bound on `closedAt` (inclusive). */
17228
- since: number().optional(),
17229
- /** Window upper bound on `openedAt` (inclusive). */
17230
- until: number().optional(),
17231
- limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
17232
- /** Opaque continuation cursor from a previous page's `nextCursor`. */
17233
- cursor: string().optional()
17234
- });
17235
- var ListGroupsPageSchema = object({
17236
- groups: array(AnalyticsGroupRecordSchema).readonly(),
17237
- nextCursor: string().nullable()
17238
- });
17239
- var KeyEventQueryInput = object({
17240
- deviceId: number(),
17241
- /** Window lower bound (track firstSeen ≥ since). */
17242
- since: number(),
17243
- /** Window upper bound (track firstSeen ≤ until). */
17244
- until: number(),
17245
- limit: number().int().min(1).max(200).default(50),
17246
- /** Drop tracks scoring below this importance. */
17247
- minImportance: number().min(0).max(1).optional(),
17248
- /** Restrict to a single class (e.g. 'person'). */
17249
- classFilter: string().optional()
17250
- });
17251
- var KeyEventSchema = object({
17252
- /** The representative event id (the track's best ObjectEvent, else its trackId). */
17253
- id: string(),
17254
- trackId: string(),
17255
- /** Track start time (firstSeen). */
17256
- timestamp: number(),
17257
- className: string(),
17258
- ...TieredLabelFields,
17259
- importance: number(),
17260
- /** Highest-confidence ObjectEvent id for the track (empty when none). */
17261
- bestEventId: string(),
17262
- /** Track lifetime in ms (lastSeen - firstSeen). */
17263
- windowMs: number().optional(),
17264
- ...TrackFlagFields,
17265
- ...TrackRetrainFields
17266
- });
17267
- object({
17268
- trackId: string(),
17269
- className: string(),
17270
- confidence: number(),
17271
- bbox: BoundingBoxSchema,
17272
- zones: array(string()).readonly(),
17273
- state: TrackStateSchema
17274
- });
17275
- var OverlayDetectionSchema = looseObject({
17276
- id: string(),
17277
- kind: _enum(["first-level", "detail"]),
17278
- macroClass: string(),
17279
- score: number(),
17280
- bbox: object({
17281
- x: number(),
17282
- y: number(),
17283
- width: number(),
17284
- height: number()
17285
- }),
17286
- labels: array(looseObject({
17287
- label: string(),
17288
- score: number()
17289
- })).readonly(),
17290
- parentId: string().optional()
17291
- });
17292
- var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
17293
- var SearchObjectEventsInput = object({
17294
- text: string(),
17295
- deviceId: number().optional(),
17296
- since: number().optional(),
17297
- until: number().optional(),
17298
- classFilter: string().optional(),
17299
- limit: number().default(50),
17300
- minScore: number().min(0).max(1).default(.2)
17301
- });
17302
- var TrackCascadeCountsSchema = object({
17303
- /** Persisted track roots deleted (authoritative). */
17304
- tracks: number().int(),
17305
- /** Object events removed with their tracks (best-effort; see note above). */
17306
- events: number().int(),
17307
- /** Track/face/plate-owned media removed (best-effort). Never identity media. */
17308
- media: number().int(),
17309
- /** Unassigned (non-enrolled) face reads removed (best-effort). */
17310
- faces: number().int(),
17311
- /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
17312
- plates: number().int(),
17313
- /** Per-track CLIP search vectors removed (best-effort). */
17314
- embeddings: number().int(),
17315
- /** Group membership + group rows removed with their last member (best-effort). */
17316
- groups: number().int()
17317
- });
17318
- /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
17319
- var DiskReconcileCountsSchema = object({
17320
- mediaDropped: number().int(),
17321
- tracks: number().int(),
17322
- events: number().int()
17323
- });
17324
- /** Event-store footprint for one camera. */
17325
- var EventStoreDeviceFootprintSchema = object({
17326
- deviceId: number(),
17327
- /** Persisted event rows (motion + object + audio) for the camera. */
17328
- rows: number().int(),
17329
- /** Event-owned media bytes on disk for the camera. */
17330
- bytes: number().int()
17331
- });
17332
- /** Aggregate event-store footprint: global totals + per-camera breakdown. */
17333
- var EventStoreFootprintSchema = object({
17334
- totalRows: number().int(),
17335
- totalBytes: number().int(),
17336
- devices: array(EventStoreDeviceFootprintSchema).readonly()
17337
- });
17338
- /** Per-kind counts returned by the event-prune / device-delete mutations. */
17339
- var EventPruneCountsSchema = object({
17340
- motion: number().int(),
17341
- object: number().int(),
17342
- audio: number().int()
17175
+ /**
17176
+ * Row projection for track list queries. `full` (default) returns the
17177
+ * complete Track including the frame-rate `positions[]` history and the
17178
+ * `snapshots[]` references — megabytes across a page of tracks. `slim`
17179
+ * keeps every scalar the list surfaces actually render (ids, class(es),
17180
+ * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
17181
+ * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
17182
+ * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
17183
+ * `getTrack`. Mirrors the event-store `projection` convention
17184
+ * (`getObjectEvents` et al.).
17185
+ */
17186
+ var TrackProjectionSchema = _enum(["full", "slim"]);
17187
+ /**
17188
+ * One audio-classification label heard on the track's camera while the
17189
+ * track was alive, aggregated per label. An "episode" is one persisted
17190
+ * audio event (the confident-classification path: score ≥ the device's
17191
+ * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
17192
+ * one 32 ms inference chunk, so counts stay human-scaled.
17193
+ */
17194
+ var TrackAudioLabelSchema = object({
17195
+ label: string(),
17196
+ /** Highest classification score observed across the label's episodes. */
17197
+ peakScore: number(),
17198
+ /** Number of coalesced audio-event episodes carrying this label. */
17199
+ count: number(),
17200
+ firstAt: number(),
17201
+ lastAt: number()
17343
17202
  });
17344
17203
  /**
17345
- * Re-embed stored tracks from their key frames.
17204
+ * How a track was produced. `pipeline` (default / absent) = the spatial
17205
+ * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
17206
+ * no positions, a single snapshot, and no bbox trajectory at all:
17346
17207
  *
17347
- * The reason this is an operator-callable method and not a migration script:
17348
- * every knob that decides what a vector MEANS — encoder model, crop margin,
17349
- * squaring — is only changeable if the existing vectors can be regenerated.
17350
- * Mixing feature spaces in one index makes cosine scores incomparable, and the
17351
- * symptom is a quality regression with no visible cause.
17208
+ * - `sensor` — a linked sensor/control device state change.
17209
+ * - `audio` — an audio event on the camera itself that was anomalous for
17210
+ * THAT camera, loud, and heard while nothing visual was happening (D62).
17211
+ *
17212
+ * The spatial subsystems (tracker association, occupancy count, re-id /
17213
+ * embedding, resurrection) MUST skip every synthetic source. Test for that
17214
+ * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
17215
+ * check silently readmits every source added after it was written.
17352
17216
  */
17353
- var RebuildObjectEmbeddingsInput = object({
17354
- /** Restrict to one camera. Omit for the whole fleet. */
17355
- deviceId: number().optional(),
17356
- since: number().optional(),
17357
- until: number().optional(),
17358
- /** Stop after this many tracks; the result reports whether more remain. */
17359
- maxTracks: number().int().positive().optional(),
17360
- /**
17361
- * Run every embedding on THIS node instead of round-robining the fleet.
17362
- *
17363
- * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
17364
- * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
17365
- * calling it that would pin the rebuild REQUEST itself to that node — the
17366
- * rebuild orchestration lives on the hub, and only the per-track step runs
17367
- * remotely. This field is data; the per-track pin is applied inside.
17368
- *
17369
- * Absent ⇒ round-robin over every online node whose runner can serve the
17370
- * pinned model.
17371
- */
17372
- executeOnNodeId: string().optional(),
17373
- /**
17374
- * Milliseconds to wait between tracks; omit for the built-in default, `0` to
17375
- * run flat out.
17376
- *
17377
- * A rebuild is bulk maintenance on hub-main's single thread. Measured
17378
- * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
17379
- * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
17380
- * force is logged at start and finish so a deliberately slow pass reads
17381
- * differently from a stalled one.
17382
- */
17383
- pacingMs: number().int().nonnegative().optional()
17384
- });
17217
+ var TrackSourceSchema = _enum([
17218
+ "pipeline",
17219
+ "sensor",
17220
+ "audio"
17221
+ ]);
17385
17222
  /**
17386
- * Result of emptying the CLIP index.
17223
+ * Where a track sits in the RETRAIN lifecycle (D81).
17387
17224
  *
17388
- * The clean slate before a policy change: a new crop margin or encoder model
17389
- * leaves two feature spaces in one index whose cosine scores are not
17390
- * comparable, so wiping and rebuilding is the only way to be sure every vector
17391
- * means the same thing.
17225
+ * - `none` — never marked, or un-marked. Evictable.
17226
+ * - `staging` — the operator wants this track as training material and has not
17227
+ * finished with it. **This is the only state retention holds**: the track and
17228
+ * everything it owns (object events, crops, keyframes, CLIP vector) survive
17229
+ * the device's age window.
17230
+ * - `trained` — the retrain page has taken what it needed. The frames it chose
17231
+ * were COPIED into the retrain dataset at selection time, so the dataset no
17232
+ * longer depends on the track's media and the track becomes EVICTABLE again.
17233
+ * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
17234
+ * a deliberate action of the retrain page, not a side effect of a checkbox.
17235
+ *
17236
+ * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
17237
+ * the store's filter language has only positive equality and `whereIn` — no
17238
+ * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
17239
+ * would make the entire pre-column history immortal in one deploy.
17392
17240
  */
17393
- var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
17241
+ var RetrainStatusSchema = _enum([
17242
+ "none",
17243
+ "staging",
17244
+ "trained"
17245
+ ]);
17394
17246
  /**
17395
- * Acknowledgement that a rebuild STARTED.
17247
+ * Per-track OPERATOR flags — set by hand from the admin UI or the viewer, never
17248
+ * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
17249
+ * so the two surfaces cannot drift.
17396
17250
  *
17397
- * The pass costs ~1s per track — 45 minutes for a 2,600-track fleet — so it
17398
- * runs detached and this returns immediately. Waiting for it made the client
17399
- * time out while the work carried on server-side, which is the worst of both:
17400
- * no result and no way to know it was still going. Poll
17401
- * `getObjectEmbeddingRebuildStatus` for progress.
17402
- */
17403
- var RebuildObjectEmbeddingsResultSchema = object({
17404
- started: boolean(),
17405
- /** True when a pass was already running; the new request is ignored. */
17406
- alreadyRunning: boolean()
17407
- });
17408
- var RebuildStatusSchema = object({
17409
- running: boolean(),
17410
- scanned: number(),
17411
- rebuilt: number(),
17412
- /** Tracks whose key frame is gone — nothing to re-embed from. */
17413
- missingKeyFrame: number(),
17414
- /** Tracks with no usable detection box. */
17415
- missingBbox: number(),
17416
- /**
17417
- * Tracks an executing node REFUSED rather than broke on — an unreadable key
17418
- * frame, a step that threw. Separate from `failed` because the remedy is
17419
- * different, and because a whole camera silently contributing zero vectors
17420
- * is the shape of failure a rebuild must never hide.
17421
- */
17422
- notRunnable: number(),
17251
+ * **Absent ≠ false.** A track that has never been touched omits the field; an
17252
+ * explicitly un-flagged track carries `false`. Legacy rows written before the
17253
+ * columns existed read as absent, and a consumer that needs a boolean should say
17254
+ * `flag === true`, not `flag !== false`.
17255
+ *
17256
+ * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
17257
+ * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
17258
+ * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
17259
+ * `trained` track reports `false` while refusing both writes. The boolean is
17260
+ * kept because three surfaces drive a toggle off it; anything that needs to tell
17261
+ * "never marked" from "already trained" must read `retrainStatus`.
17262
+ *
17263
+ * `debug` does NOT pin; it is attention, not durability.
17264
+ *
17265
+ * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
17266
+ * A favourited track is skipped by retention the same way `staging` is, but
17267
+ * it does not enter `none|staging|trained` and has no staging budget.
17268
+ */
17269
+ var TrackFlagFields = {
17270
+ /** Operator marked this track as training material — i.e. `retrainStatus` is
17271
+ * `'staging'`. */
17272
+ markForTrain: boolean().optional(),
17273
+ /** Operator marked this track for diagnostic attention. */
17274
+ debug: boolean().optional(),
17275
+ /** Operator favourited this track. Pins it against pruning. */
17276
+ favourited: boolean().optional()
17277
+ };
17278
+ /**
17279
+ * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
17280
+ * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
17281
+ * write patch, and the status is not something the toggle sets — it is what the
17282
+ * toggle's boolean is derived from. Absent on an in-RAM track never touched;
17283
+ * always present on a persisted row (the column default materialises `'none'`).
17284
+ */
17285
+ var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
17286
+ /**
17287
+ * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
17288
+ * one flag can never clear the other — the toggles are independent and are
17289
+ * driven from three surfaces that do not know about each other.
17290
+ */
17291
+ var TrackFlagsPatchSchema = object(TrackFlagFields);
17292
+ /**
17293
+ * The resolved flag state after a write. Both fields are REQUIRED here (absent
17294
+ * collapses to `false`) so a caller can drive a toggle's checked state off the
17295
+ * mutation result without a re-fetch.
17296
+ */
17297
+ var TrackFlagsSchema = object({
17298
+ trackId: string(),
17299
+ markForTrain: boolean(),
17300
+ debug: boolean(),
17301
+ favourited: boolean(),
17302
+ /** The lifecycle state the boolean was derived from. Required here (unlike on
17303
+ * a track row) because this shape is only ever produced by the write body,
17304
+ * which always knows it — and a surface that has just written needs to render
17305
+ * `trained` without a re-fetch. */
17306
+ retrainStatus: RetrainStatusSchema
17307
+ });
17308
+ union([literal(1), literal(2)]);
17309
+ /**
17310
+ * WHO decided a label, and when. Carried per tier so a value can be traced to
17311
+ * the step and model that produced it — which is what makes the write rule
17312
+ * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
17313
+ * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
17314
+ *
17315
+ * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
17316
+ * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
17317
+ * `migration:4g` for a value the 4g migration moved from the single-slot era —
17318
+ * that value has no provenance, and the write rule lets ANY properly-attributed
17319
+ * write of the same tier replace it regardless of score.
17320
+ */
17321
+ var LabelAttributionSchema = object({
17322
+ stepId: string(),
17323
+ modelId: string().optional(),
17324
+ decidedAt: number(),
17423
17325
  /**
17424
- * The pass stopped because NO node could serve the pinned model.
17326
+ * The GALLERY id behind a recognised tier-2 label — a face-gallery
17327
+ * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
17425
17328
  *
17426
- * Distinct from `notRunnable` on purpose: that one says "this track was
17427
- * refused", this one says "the cluster cannot do this work at all" — every
17428
- * candidate node either lacks the `clip-embedding` step, lacks a build of the
17429
- * pinned model for its engine format, or dropped out. The remedy is a model /
17430
- * engine change, not a per-camera one. Non-zero here always comes with
17431
- * `complete: false`.
17329
+ * The text alone is a DISPLAY NAME, and a display name is renameable: a
17330
+ * notification rule authored on "Gianluca" stopped matching the moment the
17331
+ * operator fixed the spelling in the gallery, and nothing said so. The id is
17332
+ * the thing that does not move, so it is what a rule matches on
17333
+ * (`NcConditions.identities`) and the text is what a human is shown.
17334
+ *
17335
+ * Absent when the label names no gallery row — a plate the OCR read but no
17336
+ * vehicle claims, a sub-class, a species, any tier-1 value.
17432
17337
  */
17433
- noCapableNode: number(),
17434
- failed: number(),
17435
- /** Set once a pass ends: true only when EVERYTHING was covered. */
17436
- complete: boolean().nullable(),
17437
- startedAtMs: number().nullable(),
17438
- finishedAtMs: number().nullable(),
17439
- /** Present when the pass ended by throwing. */
17440
- error: string().nullable()
17338
+ identityId: string().optional()
17441
17339
  });
17442
- DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
17443
- deviceId: number(),
17444
- trackId: string()
17445
- }), TrackSchema.nullable()), method(object({
17446
- deviceId: number(),
17447
- since: number().optional(),
17448
- until: number().optional(),
17449
- limit: number().optional(),
17450
- /** Spatial filter — only tracks whose trajectory intersects the zone
17451
- * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
17452
- * envelope columns, then precisely tested per position. Tracks with
17453
- * an unknown envelope (no frame dims at persist time) always match. */
17454
- zone: TrackZoneFilterSchema.optional(),
17455
- /** See {@link TrackProjectionSchema}. Default `full` (backward
17456
- * compatible — omitting the field keeps today's exact behaviour). */
17457
- projection: TrackProjectionSchema.optional(),
17458
- /** Include stationary-promoted rows (parked objects handed to the
17459
- * stationary registry). Default false: the timeline lists passages,
17460
- * not parking records (operator decision, 2026-08-15). */
17461
- includeStationary: boolean().optional()
17462
- }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
17463
- deviceId: number(),
17464
- groupId: string().min(1)
17465
- }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
17466
- kind: "mutation",
17467
- auth: "admin"
17468
- }), 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({
17469
- deviceId: number(),
17470
- since: number().optional(),
17471
- until: number().optional(),
17472
- kinds: array(string()).optional(),
17473
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
17474
- }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
17475
- deviceId: number(),
17476
- since: number(),
17477
- until: number(),
17478
- bucketMs: number().int().positive()
17479
- }), array(object({
17480
- bucketStart: number(),
17481
- motion: number().int(),
17482
- object: number().int(),
17483
- audio: number().int()
17484
- })).readonly()), method(object({
17485
- deviceId: number(),
17486
- cutoffMs: number()
17487
- }), object({
17488
- motion: number().int(),
17489
- object: number().int(),
17490
- audio: number().int()
17491
- }), {
17492
- kind: "mutation",
17493
- auth: "admin"
17494
- }), method(object({
17495
- deviceId: number(),
17496
- cutoffMs: number()
17497
- }), TrackCascadeCountsSchema, {
17498
- kind: "mutation",
17499
- auth: "admin"
17500
- }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
17501
- kind: "mutation",
17502
- auth: "admin"
17503
- }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
17504
- kind: "mutation",
17505
- auth: "admin"
17506
- }), method(object({
17507
- deviceId: number(),
17508
- trackIds: array(string()).min(1)
17509
- }), object({
17510
- deleted: number().int(),
17511
- failed: array(string()).readonly()
17512
- }), {
17513
- kind: "mutation",
17514
- auth: "admin"
17515
- }), method(object({
17516
- /** Log/audit scope only — the trackId is globally unique on its own. */
17340
+ /**
17341
+ * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
17342
+ * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
17343
+ * track and its events always answer the same question the same way.
17344
+ *
17345
+ * Two scalar columns, not an array: every consumer wants "the coarse one" or
17346
+ * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
17347
+ * is tier 2, and each carries its own score + attribution.
17348
+ *
17349
+ * **Reading it.** What a human should be shown is `subLabel ?? label` — the
17350
+ * finest thing known. Before 4g the single `label` column held the finest
17351
+ * value, so a consumer that has not been updated reads the tier-1 slot and
17352
+ * shows nothing on a species-only row; that is why the migration puts every
17353
+ * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
17354
+ * and why the read surfaces were changed in the same train.
17355
+ *
17356
+ * **Writing it.** The slots are independent, which is the whole point: a
17357
+ * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
17358
+ * migratorius`), so fineness cannot regress by construction. Within a tier the
17359
+ * higher score wins. One rule, one implementation — see
17360
+ * `pipeline/label-tier.ts` in addon-post-analysis.
17361
+ */
17362
+ var TieredLabelFields = {
17363
+ /** Tier 1 — the sub-class. See {@link LabelTierSchema}. */
17364
+ label: string().optional(),
17365
+ /** Confidence of the tier-1 value, as reported by the deciding step. */
17366
+ labelScore: number().optional(),
17367
+ /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
17368
+ labelMeta: LabelAttributionSchema.optional(),
17369
+ /** Tier 2 — the instance. See {@link LabelTierSchema}. */
17370
+ subLabel: string().optional(),
17371
+ /** Confidence of the tier-2 value, as reported by the deciding step. */
17372
+ subLabelScore: number().optional(),
17373
+ /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
17374
+ subLabelMeta: LabelAttributionSchema.optional()
17375
+ };
17376
+ /** Per-camera slice of a training-export estimate. */
17377
+ var TrainingExportDeviceTotalsSchema = object({
17517
17378
  deviceId: number(),
17379
+ tracks: number().int(),
17380
+ files: number().int(),
17381
+ bytes: number().int()
17382
+ });
17383
+ /**
17384
+ * What a training export WOULD contain. Computed from media index rows only —
17385
+ * no blob is read to produce this.
17386
+ */
17387
+ var TrainingExportSummarySchema = object({
17388
+ generatedAt: number(),
17389
+ trackCount: number().int(),
17390
+ fileCount: number().int(),
17391
+ byteCount: number().int(),
17392
+ /** More marked tracks exist than a single pass carries. */
17393
+ truncated: boolean(),
17394
+ devices: array(TrainingExportDeviceTotalsSchema).readonly()
17395
+ });
17396
+ var TrackSchema = object({
17518
17397
  trackId: string(),
17519
- flags: TrackFlagsPatchSchema
17520
- }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
17521
- kind: "query",
17522
- auth: "admin"
17523
- }), method(object({
17524
- olderThanMs: number(),
17525
- reason: OpsLogReasonSchema.optional()
17526
- }), EventPruneCountsSchema, {
17527
- kind: "mutation",
17528
- auth: "admin"
17529
- }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
17530
- kind: "mutation",
17531
- auth: "admin"
17532
- }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
17533
- kind: "mutation",
17534
- auth: "admin"
17535
- }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
17536
- kind: "mutation",
17537
- auth: "admin"
17538
- }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
17539
- kind: "mutation",
17540
- auth: "admin"
17541
- }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
17542
- kind: "mutation",
17543
- auth: "admin"
17544
- }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
17545
- kind: "mutation",
17546
- auth: "admin"
17547
- }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
17548
- kind: "query",
17549
- auth: "admin"
17550
- }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
17551
- kind: "query",
17552
- auth: "admin"
17553
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
17554
- kind: "query",
17555
- auth: "admin"
17556
- }), method(object({
17557
- /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
17558
- * `deviceId`, deliberately: `deviceId` would make this device-bound and
17559
- * route it at one camera's owner, and "every camera" would stop being
17560
- * expressible at all. */
17561
- deviceIds: array(number()).optional(),
17562
- limit: number().int().min(1).max(500).optional()
17563
- }), array(RetrainTrackSchema).readonly(), {
17564
- kind: "query",
17565
- auth: "admin"
17566
- }), method(object({ trackId: string() }), RetrainFrameListSchema, {
17567
- kind: "query",
17568
- auth: "admin"
17569
- }), method(object({
17570
17398
  deviceId: number(),
17571
- trackId: string(),
17572
- mediaKeys: array(string()).min(1)
17573
- }), RetrainFrameSelectionSchema, {
17574
- kind: "mutation",
17575
- auth: "admin"
17576
- }), method(object({
17399
+ className: string(),
17400
+ ...TieredLabelFields,
17401
+ producingDeviceName: string().optional(),
17402
+ /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
17403
+ source: TrackSourceSchema.optional(),
17404
+ firstSeen: number(),
17405
+ lastSeen: number(),
17406
+ /** Frame-rate position history (subject to maxPositionHistory cap). */
17407
+ positions: array(TrackPositionSchema).readonly(),
17408
+ /** Periodic snapshots at snapshotIntervalMs cadence (subject to
17409
+ * saveThumbnails policy). */
17410
+ snapshots: array(TrackSnapshotSchema).readonly(),
17411
+ /** Deduplicated zones the track has entered at least once. Zone IDS. */
17412
+ zonesVisited: array(string()).readonly(),
17413
+ /**
17414
+ * Human NAMES for {@link zonesVisited}, resolved at READ time against the
17415
+ * `zones` capability.
17416
+ *
17417
+ * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
17418
+ * and no card can render — so every free-text search surface was structurally
17419
+ * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
17420
+ * just returned nothing. Resolving here rather than in each client keeps ONE
17421
+ * derivation and costs the clients no extra call (the `zones` cap is
17422
+ * per-device, so a client-side resolve would be a per-camera fan-out on a
17423
+ * surface built to avoid exactly that).
17424
+ *
17425
+ * Resolved, never invented: a zone deleted since the track was written has no
17426
+ * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
17427
+ * two are not positionally aligned. Absent when the track visited no zone, or
17428
+ * when the zone catalogue could not be read.
17429
+ */
17430
+ zoneNames: array(string()).readonly().optional(),
17431
+ /** Deduplicated set of detector classes observed for this track over its
17432
+ * life (a track may be reclassified, e.g. person→vehicle). Absent on
17433
+ * legacy rows written before class accumulation shipped. */
17434
+ classes: array(string()).readonly().optional(),
17435
+ /** Cumulative normalized distance travelled (0..1 units = full frame width). */
17436
+ totalDistance: number(),
17437
+ state: TrackStateSchema,
17438
+ active: boolean(),
17439
+ /** Deterministic key-event importance score in [0,1] (server-computed at
17440
+ * track expiry, recomputed on late label). Absent on legacy rows written
17441
+ * before scoring shipped — consumers degrade to absence / compute-on-read. */
17442
+ importance: number().optional(),
17443
+ /** Id of the track's highest-confidence ObjectEvent (its representative
17444
+ * "best" frame). Absent when the track produced no object events. */
17445
+ bestEventId: string().optional(),
17446
+ /** Tag of the importance sub-signal that dominated the score
17447
+ * (identity|dwell|proximity|class|confidence|travel|zone). */
17448
+ importanceReason: string().optional(),
17449
+ /** Audio-classification labels heard on the camera during the track's
17450
+ * life (score ≥ device `classificationMinScore`), aggregated per label.
17451
+ * Absent on legacy rows / tracks with no confident audio. */
17452
+ audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
17453
+ /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
17454
+ * Populated from the persisted envelope columns on historical reads;
17455
+ * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
17456
+ envelope: TrackEnvelopeSchema.optional(),
17457
+ /**
17458
+ * A face DETECTOR found a face on this track — nothing more. It says the
17459
+ * detail plane produced a `face` detail; it does NOT say the face was
17460
+ * embedded, matched, above `minFacePx`, or that the recognizer was even
17461
+ * enabled. Set once and never cleared.
17462
+ *
17463
+ * **This exists so "face present but not recognised" is expressible.** A
17464
+ * recognised identity lands in `subLabel` (attributed to the face chain via
17465
+ * `subLabelMeta.stepId`), so before this field a track with an unmatched face
17466
+ * and a track with no face at all were byte-identical on the wire and no
17467
+ * surface could tell them apart. The read is `hasFace === true && subLabel
17468
+ * === undefined`.
17469
+ *
17470
+ * **Absent ≠ false.** Every row written before the column existed omits it,
17471
+ * and so does every server that predates the field — a consumer must test
17472
+ * `=== true` and render nothing otherwise, never infer "no face".
17473
+ */
17474
+ hasFace: boolean().optional(),
17475
+ /**
17476
+ * This track has a face row IN THE GALLERY: a crop **and** an embedding — a
17477
+ * face an operator could ASSIGN to an identity.
17478
+ *
17479
+ * The STRICT twin of {@link hasFace}, and the pair only earns its keep
17480
+ * because the two disagree. `hasFace` is stamped at the TOP of the face
17481
+ * branch, before every gate, and means no more than "a face detector produced
17482
+ * a face detail". This one is stamped at the single moment the gallery row
17483
+ * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
17484
+ * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
17485
+ * candidate gate, the imageless-track drop (no crop was ever captured) and
17486
+ * the crop-store drop. Everything between the detector and that insert can
17487
+ * legitimately refuse the face, so a flag written any earlier promises the
17488
+ * operator something to assign and delivers nothing.
17489
+ *
17490
+ * **Independent of recognition.** A face collected but never auto-matched is
17491
+ * still assignable — it is in fact the face an operator most wants to reach —
17492
+ * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
17493
+ * `subLabel`; this says only that the raw material exists.
17494
+ *
17495
+ * **Set once, never cleared.** A track that produced a gallery row produced
17496
+ * one; deleting the row later is the gallery's business, not this flag's.
17497
+ *
17498
+ * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
17499
+ * before the column omits it, and so does every server that predates the
17500
+ * field. A consumer must test `=== true` and render nothing otherwise —
17501
+ * never infer "no assignable face".
17502
+ */
17503
+ hasEmbeddedFace: boolean().optional(),
17504
+ /**
17505
+ * This subject CONTAINS a folded rider — a person the rider-pairing step
17506
+ * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
17507
+ * so the passage is tracked once and as a VEHICLE.
17508
+ *
17509
+ * It exists because the fold's record was dishonest. D34 and the code both
17510
+ * said "the person is not lost — it is reported so both entities stay on the
17511
+ * record"; in fact the pair went into a per-processor RAM field behind an
17512
+ * accessor nobody called, and every durable surface said `vehicle`, full
17513
+ * stop. This is the composition note that makes the row true.
17514
+ *
17515
+ * A COMPOSITION, never a class and never a label. "This vehicle contains a
17516
+ * person" is not an answer to "what is this" — both label tiers would refuse
17517
+ * a macro token anyway (D89), and correctly. Nothing here changes what the
17518
+ * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
17519
+ * and a `person` rule still does not fire for someone cycling past.
17520
+ *
17521
+ * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
17522
+ * the column, and every hub that predates the field, omits it. Test
17523
+ * `=== true` and render nothing otherwise — never infer "no rider".
17524
+ */
17525
+ hasRider: boolean().optional(),
17526
+ ...TrackFlagFields,
17527
+ ...TrackRetrainFields
17528
+ });
17529
+ var BaseEventFields = {
17530
+ id: string(),
17577
17531
  deviceId: number(),
17578
- trackId: string(),
17579
- frameId: string()
17580
- }), object({
17581
- removed: boolean(),
17582
- removedAnnotations: number().int()
17583
- }), {
17584
- kind: "mutation",
17585
- auth: "admin"
17586
- }), method(object({ frameId: string() }), object({
17532
+ timestamp: number()
17533
+ };
17534
+ var MotionEventSchema = object({
17535
+ ...BaseEventFields,
17536
+ kind: literal("motion"),
17537
+ regionCount: number(),
17538
+ /** Heavy JSON array — omitted in slim projection. */
17539
+ regions: array(object({
17540
+ bbox: BoundingBoxSchema,
17541
+ pixelCount: number(),
17542
+ intensity: number()
17543
+ })).readonly().optional(),
17544
+ /** Omitted in slim projection. */
17545
+ frameWidth: number().optional(),
17546
+ /** Omitted in slim projection. */
17547
+ frameHeight: number().optional(),
17548
+ /** Populated by B5 (recording playback URL for this event). */
17549
+ mediaUrl: string().optional()
17550
+ });
17551
+ /**
17552
+ * Which detection SOURCE produced an object event. `pipeline` = the ML
17553
+ * detection pipeline (decoded-frame inference); `onboard` = the camera's
17554
+ * native on-device AI. Both flow through the SAME analysis layers (zoning,
17555
+ * tracking, per-kind persistence) but stay distinguishable so consumers
17556
+ * (advanced-notifier, occupancy, …) can select which source(s) to act on.
17557
+ * Absent on legacy rows ⇒ treat as `pipeline`.
17558
+ */
17559
+ var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
17560
+ /**
17561
+ * The confirmed zone crossing that produced an object event. Present ONLY on
17562
+ * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
17563
+ * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
17564
+ * appearance event carry none, so a rule asking for a direction fails closed
17565
+ * on them.
17566
+ *
17567
+ * Exactly ONE crossing per event: the emitter turns each confirmed crossing
17568
+ * into its own event, so a frame in which a track enters A while leaving B
17569
+ * produces two events with two directions — never one ambiguous row.
17570
+ *
17571
+ * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
17572
+ * membership the box has NOW, and by definition it no longer contains the zone
17573
+ * that was just left. Without the id here, a zone-scoped rule could never match
17574
+ * the exit it asked for.
17575
+ */
17576
+ var ZoneCrossingSchema = object({
17577
+ direction: _enum(["enter", "exit"]),
17578
+ /** Admin zone id crossed. */
17579
+ zoneId: string(),
17580
+ /** Zone display name at crossing time (falls back to the id). */
17581
+ zoneName: string().optional()
17582
+ });
17583
+ var ObjectEventSchema = object({
17584
+ ...BaseEventFields,
17585
+ kind: literal("object"),
17586
+ /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
17587
+ source: DetectionSourceSchema.optional(),
17588
+ /**
17589
+ * Inference-frame id shared by every object event emitted from the SAME frame
17590
+ * — the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
17591
+ * 2 people + 1 dog) under one full frame, and link a track's frames over time
17592
+ * (group by `trackId`, pick a representative `frameId` as the parent frame).
17593
+ * Optional for backward-compat with pre-existing rows / the slim projection
17594
+ * includes it (it is light). Absent on rows written before this field.
17595
+ */
17596
+ frameId: string().optional(),
17597
+ /** Omitted in slim projection. */
17598
+ trackId: string().optional(),
17599
+ className: string(),
17600
+ ...TieredLabelFields,
17601
+ /** Omitted in slim projection. */
17602
+ confidence: number().optional(),
17603
+ /** Heavy JSON — omitted in slim projection. */
17604
+ bbox: BoundingBoxSchema.optional(),
17605
+ /** Heavy JSON — omitted in slim projection. */
17606
+ zones: array(string()).readonly().optional(),
17607
+ /** Omitted in slim projection. */
17608
+ state: TrackStateSchema.optional(),
17609
+ /**
17610
+ * The zone crossing this event IS, when it is one. Absent on every other
17611
+ * event kind (movement state, appearance, package) — see
17612
+ * {@link ZoneCrossingSchema}. Omitted in slim projection.
17613
+ */
17614
+ zoneCrossing: ZoneCrossingSchema.optional(),
17615
+ /** Detection-frame dimensions in pixels — let consumers normalize the
17616
+ * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
17617
+ frameWidth: number().optional(),
17618
+ frameHeight: number().optional(),
17619
+ /** MediaStore key for the crop attached to this event (if any). */
17620
+ mediaKey: string().optional(),
17621
+ /** Design B: MediaStore key of the track's native-resolution key frame (the
17622
+ * best-detection full frame). Resolve via the event-media data-plane
17623
+ * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
17624
+ * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
17625
+ * sources — consumers fall back to `mediaKey` (the tight crop). */
17626
+ keyFrameMediaKey: string().optional(),
17627
+ /** Populated by B5 (recording playback URL for this event). */
17628
+ mediaUrl: string().optional(),
17629
+ /** The parent track's key-event importance [0,1], propagated to every object
17630
+ * event of the track (so an event row can be sorted by importance without a
17631
+ * track join). Absent on legacy rows / before the track was scored. */
17632
+ importance: number().optional()
17633
+ });
17634
+ var AudioEventSchema = object({
17635
+ ...BaseEventFields,
17636
+ kind: literal("audio"),
17637
+ rms: number(),
17638
+ dbfs: number(),
17639
+ classification: object({
17640
+ className: string(),
17641
+ originalClass: string().optional(),
17642
+ score: number()
17643
+ }).optional(),
17644
+ /** Populated by B5 (recording playback URL for this event). */
17645
+ mediaUrl: string().optional()
17646
+ });
17647
+ var MediaFileKindEnum = _enum([
17648
+ "crop",
17649
+ "thumbnail",
17650
+ "snapshot",
17651
+ "firstFrame",
17652
+ "lastFrame",
17653
+ "fullFrame",
17654
+ "fullFrameBoxed",
17655
+ "faceCrop",
17656
+ "plateCrop",
17657
+ "keyFrame",
17658
+ "keyFrameSmall",
17659
+ "thumbnailSmall"
17660
+ ]);
17661
+ var MediaFileSchema = object({
17662
+ key: string(),
17663
+ kind: MediaFileKindEnum,
17587
17664
  base64: string(),
17588
- width: number().int(),
17589
- height: number().int()
17590
- }), {
17591
- kind: "query",
17592
- auth: "admin"
17593
- }), method(object({
17594
- deviceId: number(),
17595
- trackId: string(),
17596
- frameId: string(),
17597
- subject: RetrainAssistSubjectSchema,
17598
- /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
17599
- nodeId: string().optional()
17600
- }), RetrainAssistResultSchema, {
17601
- kind: "mutation",
17602
- auth: "admin"
17603
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
17604
- kind: "query",
17605
- auth: "admin"
17606
- }), method(object({
17607
- deviceId: number(),
17665
+ sizeBytes: number(),
17666
+ timestamp: number()
17667
+ });
17668
+ /**
17669
+ * One media row WITHOUT its bytes.
17670
+ *
17671
+ * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
17672
+ * 140 s track), and a client that renders tiles from the media data plane needs
17673
+ * to know only WHAT EXISTS — the bytes then arrive per tile, lazily, over HTTP
17674
+ * with an immutable cache, instead of all at once inside a tRPC response that
17675
+ * blocks the whole view.
17676
+ *
17677
+ * `sizeBytes` is carried because it is what lets a client decide between the
17678
+ * stored blob and a `?variant=thumb` rendering without fetching either.
17679
+ */
17680
+ var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
17681
+ /**
17682
+ * The MACRO tier of an annotation — a CLOSED set.
17683
+ *
17684
+ * This is what the exported detector predicts, so a typo here is a new class
17685
+ * with one example in it. `label` and `subLabel` are open strings by contrast:
17686
+ * the whole point of the page is teaching the model things it does not know
17687
+ * yet, and constraining that vocabulary would make it useless.
17688
+ *
17689
+ * A macro class is NEVER a label. The provider refuses a write whose `label` or
17690
+ * `subLabel` is one of these values, in any casing, because once `person`
17691
+ * exists in both tiers "every person box" stops being answerable without
17692
+ * knowing every string anyone ever typed — and the damage is retroactive.
17693
+ */
17694
+ var RetrainMacroClassSchema = _enum([
17695
+ "person",
17696
+ "vehicle",
17697
+ "animal",
17698
+ "package",
17699
+ "face",
17700
+ "plate"
17701
+ ]);
17702
+ /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
17703
+ var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
17704
+ /** Did a human draw this box, or did the assist propose it? */
17705
+ var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
17706
+ /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
17707
+ var RetrainBboxSchema = object({
17708
+ x: number(),
17709
+ y: number(),
17710
+ w: number(),
17711
+ h: number()
17712
+ });
17713
+ /**
17714
+ * One annotated subject.
17715
+ *
17716
+ * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
17717
+ * (letterboxed root / zone-cropped package / subject-cropped classifier) are
17718
+ * derived from it at export and never stored — storing them is how one feature
17719
+ * space ends up holding two crops of the same subject (D52).
17720
+ */
17721
+ var RetrainAnnotationSchema = object({
17722
+ id: string(),
17608
17723
  trackId: string(),
17609
- frameId: string(),
17610
- annotations: array(RetrainAnnotationDraftSchema)
17611
- }), array(RetrainAnnotationSchema).readonly(), {
17612
- kind: "mutation",
17613
- auth: "admin"
17614
- }), method(object({
17615
- deviceId: number(),
17616
- trackId: string()
17617
- }), RetrainTransitionResultSchema, {
17618
- kind: "mutation",
17619
- auth: "admin"
17620
- }), method(object({
17621
17724
  deviceId: number(),
17622
- trackId: string()
17623
- }), RetrainTransitionResultSchema, {
17624
- kind: "mutation",
17625
- auth: "admin"
17626
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
17627
- kind: "query",
17628
- auth: "admin"
17629
- }), method(object({
17630
- eventId: string(),
17631
- kind: MediaFileKindEnum.optional(),
17632
- deviceId: number()
17633
- }), array(MediaFileSchema).readonly()), method(object({
17634
- trackId: string(),
17635
- kinds: array(MediaFileKindEnum).optional(),
17636
- deviceId: number()
17637
- }), array(MediaFileSchema).readonly()), method(object({
17725
+ /** The COPY in retrain storage — never the source track's media key. */
17726
+ mediaKey: string(),
17727
+ bbox: RetrainBboxSchema,
17728
+ macroClass: RetrainMacroClassSchema,
17729
+ label: string().optional(),
17730
+ subLabel: string().optional(),
17731
+ kind: RetrainAnnotationKindSchema,
17732
+ source: RetrainAnnotationSourceSchema,
17733
+ /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
17734
+ assistModelId: string().optional(),
17735
+ assistScore: number().optional(),
17736
+ exportedInBatch: string().optional(),
17737
+ createdAt: number()
17738
+ });
17739
+ /** The write form — the server owns `id`, `createdAt` and the frame binding. */
17740
+ var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
17741
+ id: true,
17742
+ trackId: true,
17743
+ deviceId: true,
17744
+ mediaKey: true,
17745
+ createdAt: true,
17746
+ exportedInBatch: true
17747
+ });
17748
+ /** A track sitting in `staging`, with everything the worklist needs to rank it. */
17749
+ var RetrainTrackSchema = object({
17638
17750
  trackId: string(),
17639
- deviceId: number()
17640
- }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
17641
- kind: "mutation",
17642
- auth: "admin"
17643
- }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
17644
- kind: "mutation",
17645
- auth: "admin"
17646
- }), method(object({}), RebuildStatusSchema), object({
17647
17751
  deviceId: number(),
17752
+ className: string(),
17753
+ label: string().optional(),
17754
+ firstSeen: number(),
17755
+ lastSeen: number(),
17756
+ /** How many frames the dataset already holds from this track. */
17757
+ frameCount: number().int(),
17758
+ /** How many subjects have been annotated on those frames. `0` with
17759
+ * `frameCount: 0` is exactly "staging, still to work". */
17760
+ annotationCount: number().int()
17761
+ });
17762
+ /** A frame the picker may offer — an index row, no blob was read to produce it. */
17763
+ var RetrainFrameCandidateSchema = object({
17764
+ mediaKey: string(),
17765
+ kind: MediaFileKindEnum,
17648
17766
  timestamp: number(),
17649
- frameWidth: number(),
17650
- frameHeight: number(),
17651
- detections: array(OverlayDetectionSchema).readonly()
17652
- }), object({
17767
+ sizeBytes: number().int(),
17768
+ /** A copy of this original already exists — selecting it is free and cannot
17769
+ * fail, whatever became of the original. */
17770
+ copied: boolean()
17771
+ });
17772
+ /** A frame the dataset OWNS: bytes copied at selection time. */
17773
+ var RetrainFrameSchema = object({
17774
+ frameId: string(),
17653
17775
  deviceId: number(),
17654
17776
  trackId: string(),
17655
- className: string()
17777
+ /** Provenance only. It may already point at nothing — that is expected. */
17778
+ sourceMediaKey: string(),
17779
+ sourceKind: MediaFileKindEnum,
17780
+ sizeBytes: number().int(),
17781
+ width: number().int(),
17782
+ height: number().int(),
17783
+ copiedAt: number()
17784
+ });
17785
+ /** Why a copy-on-select could not be honoured — named, never a silent skip. */
17786
+ var RetrainCopyRefusalSchema = _enum([
17787
+ "source-missing",
17788
+ "unreadable-image",
17789
+ "write-failed"
17790
+ ]);
17791
+ var RetrainFrameSelectionSchema = object({
17792
+ copied: array(RetrainFrameSchema).readonly(),
17793
+ refused: array(object({
17794
+ sourceMediaKey: string(),
17795
+ reason: RetrainCopyRefusalSchema
17796
+ })).readonly()
17797
+ });
17798
+ var RetrainFrameListSchema = object({
17799
+ candidates: array(RetrainFrameCandidateSchema).readonly(),
17800
+ copies: array(RetrainFrameSchema).readonly(),
17801
+ /** What the page pre-selects — the native key frame when one survives. */
17802
+ autoPickMediaKey: string().optional()
17803
+ });
17804
+ /** What the operator asked the assist to look for. */
17805
+ var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
17806
+ kind: literal("package"),
17807
+ zone: RetrainBboxSchema.optional()
17656
17808
  }), object({
17657
- deviceId: number(),
17658
- trackId: string(),
17659
- className: string(),
17660
- durationMs: number()
17809
+ kind: literal("objects"),
17810
+ modelId: string(),
17811
+ minScore: number().optional()
17812
+ })]);
17813
+ /**
17814
+ * The assist's answer — a discriminated union, because "the model saw nothing"
17815
+ * and "this node cannot run that model" lead to different next moves and a
17816
+ * nullable result cannot tell them apart.
17817
+ */
17818
+ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
17819
+ kind: literal("proposed"),
17820
+ modelId: string(),
17821
+ stepId: string(),
17822
+ minScore: number(),
17823
+ /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
17824
+ proposals: array(RetrainAnnotationDraftSchema).readonly(),
17825
+ /** Returned by the runner but removed by the threshold. */
17826
+ belowThreshold: number().int()
17661
17827
  }), object({
17828
+ kind: literal("refused"),
17829
+ /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
17830
+ reason: string(),
17831
+ detail: string().optional()
17832
+ })]);
17833
+ /** The outcome of a lifecycle move owned by the retrain page. */
17834
+ var RetrainTransitionResultSchema = object({
17835
+ trackId: string(),
17836
+ /** Where the track ended up, whatever happened. */
17837
+ retrainStatus: RetrainStatusSchema,
17838
+ /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
17839
+ changed: boolean(),
17840
+ reason: _enum([
17841
+ "unknown-track",
17842
+ "no-frames-copied",
17843
+ "not-staging",
17844
+ "not-trained",
17845
+ "unchanged"
17846
+ ]).optional()
17847
+ });
17848
+ var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
17849
+ var MAX_EVENT_QUERY_LIMIT = 5e3;
17850
+ var DeviceEventQueryInput = object({
17662
17851
  deviceId: number(),
17663
- kind: EventKindSchema,
17664
- eventId: string(),
17665
- timestamp: number()
17852
+ since: number().optional(),
17853
+ until: number().optional(),
17854
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
17855
+ /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
17856
+ * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
17857
+ * exact behaviour. Callers may omit this field — the store defaults to
17858
+ * `full` when not provided. */
17859
+ projection: _enum(["full", "slim"]).optional()
17666
17860
  });
17667
- /**
17668
- * Reference to the frame's retained NATIVE surface + the parent crop's placement
17669
- * within the frame, so the executor can re-cut a leaf child ROI at native
17670
- * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
17671
- */
17672
- var NativeCropRefSchema = object({
17673
- /** Handle keying the retained native surface (node-pinned to its owner). */
17674
- handle: FrameHandleSchema,
17675
- /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
17676
- cropFrameSpace: object({
17677
- x: number(),
17678
- y: number(),
17679
- w: number(),
17680
- h: number()
17681
- })
17861
+ var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
17862
+ var RecentTracksQueryInput = object({
17863
+ /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
17864
+ deviceIds: array(number()),
17865
+ /** Window lower bound on `lastSeen` (inclusive). */
17866
+ since: number().optional(),
17867
+ /** Window upper bound on `lastSeen` (inclusive). */
17868
+ until: number().optional(),
17869
+ /** Page size. Default 200, max 1000. */
17870
+ limit: number().int().min(1).max(1e3).default(200),
17871
+ /** Opaque continuation cursor from a previous page's `nextCursor`.
17872
+ * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
17873
+ cursor: string().optional(),
17874
+ /** See {@link TrackProjectionSchema}. Default `full`. */
17875
+ projection: TrackProjectionSchema.optional(),
17876
+ /** Include stationary-promoted rows (parked objects). Default false: the
17877
+ * feed lists passages; parking records live on the stationary registry. */
17878
+ includeStationary: boolean().optional()
17682
17879
  });
17683
- object({
17684
- crop: object({
17685
- left: number(),
17686
- top: number(),
17687
- width: number().positive(),
17688
- height: number().positive()
17689
- }).optional(),
17690
- content: object({
17691
- width: number().int().positive(),
17692
- height: number().int().positive()
17693
- }),
17694
- fit: _enum(["stretch", "contain"]),
17695
- format: _enum([
17696
- "rgb",
17697
- "gray",
17698
- "jpeg"
17699
- ])
17880
+ var RecentTracksPageSchema = object({
17881
+ /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
17882
+ tracks: array(TrackSchema).readonly(),
17883
+ /** Cursor for the next page, or null when this page is the last. */
17884
+ nextCursor: string().nullable()
17700
17885
  });
17701
- var FrameRefSchema = object({
17702
- registryId: string().min(1),
17703
- id: string().min(1),
17704
- width: number().int().positive(),
17705
- height: number().int().positive(),
17706
- format: _enum(["rgb", "gray"]),
17707
- timestamp: number(),
17708
- capturedAt: number().optional()
17886
+ var LIST_GROUPS_DEFAULT_LIMIT = 40;
17887
+ var LIST_GROUPS_MAX_LIMIT = 100;
17888
+ var AnalyticsGroupRecordSchema = object({
17889
+ id: string(),
17890
+ deviceId: number().int(),
17891
+ openedAt: number().int(),
17892
+ closedAt: number().int(),
17893
+ timestamp: number().int(),
17894
+ memberCount: number().int(),
17895
+ memberTrackIds: array(string()).readonly(),
17896
+ className: string(),
17897
+ classes: array(string()).readonly(),
17898
+ /** Relative event-media path, or null when the group has no picture yet. */
17899
+ mediaUrl: string().nullable(),
17900
+ singleton: boolean()
17709
17901
  });
17710
- var ModelFormatSchema$1 = _enum([
17711
- "onnx",
17712
- "coreml",
17713
- "openvino",
17714
- "tflite",
17715
- "pt",
17716
- "gguf"
17717
- ]);
17718
- var PipelineSlotSchema = _enum([
17719
- "detector",
17720
- "cropper",
17721
- "classifier",
17722
- "refiner",
17723
- "audio-classifier"
17724
- ]);
17725
- var PipelineEngineChoiceSchema = object({
17726
- runtime: _enum(["node", "python"]),
17727
- backend: string(),
17728
- format: ModelFormatSchema$1,
17729
- device: string().optional()
17902
+ var AnalyticsGroupMemberSchema = object({
17903
+ trackId: string(),
17904
+ deviceId: number().int(),
17905
+ className: string(),
17906
+ firstSeen: number().int(),
17907
+ lastSeen: number().int(),
17908
+ mediaUrl: string().nullable()
17730
17909
  });
17731
- var AvailableEngineSchema = object({
17732
- engine: PipelineEngineChoiceSchema,
17733
- devices: array(object({
17734
- id: string(),
17735
- label: string(),
17736
- description: string().optional()
17737
- })).readonly(),
17738
- defaultDevice: string()
17910
+ var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
17911
+ var ListGroupsQueryInput = object({
17912
+ /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
17913
+ deviceIds: array(number()),
17914
+ /** Window lower bound on `closedAt` (inclusive). */
17915
+ since: number().optional(),
17916
+ /** Window upper bound on `openedAt` (inclusive). */
17917
+ until: number().optional(),
17918
+ limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
17919
+ /** Opaque continuation cursor from a previous page's `nextCursor`. */
17920
+ cursor: string().optional()
17739
17921
  });
17740
- var PipelineDefaultStepSchema = lazy(() => object({
17741
- addonId: string(),
17742
- addonName: string(),
17743
- slot: PipelineSlotSchema,
17744
- inputClasses: array(string()).readonly(),
17745
- outputClasses: array(string()).readonly(),
17746
- enabled: boolean(),
17747
- modelId: string(),
17748
- children: array(PipelineDefaultStepSchema).readonly(),
17749
- group: string().optional(),
17750
- settings: record(string(), unknown()).optional()
17751
- }));
17752
- var PipelineTemplateStepSchema = lazy(() => object({
17753
- addonId: string(),
17754
- enabled: boolean(),
17755
- modelId: string(),
17756
- children: array(PipelineTemplateStepSchema).readonly(),
17757
- settings: record(string(), unknown()).optional()
17758
- }));
17759
- var PipelineTemplateSchema$1 = object({
17760
- id: string(),
17761
- name: string(),
17762
- createdAt: string(),
17763
- updatedAt: string(),
17764
- engine: PipelineEngineChoiceSchema,
17765
- steps: array(PipelineTemplateStepSchema).readonly()
17922
+ var ListGroupsPageSchema = object({
17923
+ groups: array(AnalyticsGroupRecordSchema).readonly(),
17924
+ nextCursor: string().nullable()
17925
+ });
17926
+ var KeyEventQueryInput = object({
17927
+ deviceId: number(),
17928
+ /** Window lower bound (track firstSeen ≥ since). */
17929
+ since: number(),
17930
+ /** Window upper bound (track firstSeen ≤ until). */
17931
+ until: number(),
17932
+ limit: number().int().min(1).max(200).default(50),
17933
+ /** Drop tracks scoring below this importance. */
17934
+ minImportance: number().min(0).max(1).optional(),
17935
+ /** Restrict to a single class (e.g. 'person'). */
17936
+ classFilter: string().optional()
17766
17937
  });
17767
- var PipelineModelOptionSchema = object({
17938
+ var KeyEventSchema = object({
17939
+ /** The representative event id (the track's best ObjectEvent, else its trackId). */
17768
17940
  id: string(),
17769
- name: string(),
17770
- formats: record(string(), object({
17771
- downloaded: boolean(),
17772
- sizeMB: number()
17773
- })),
17774
- group: ModelVariantGroupSchema.optional(),
17775
- legacy: boolean().optional(),
17776
- provider: ModelProviderIdSchema.optional()
17941
+ trackId: string(),
17942
+ /** Track start time (firstSeen). */
17943
+ timestamp: number(),
17944
+ className: string(),
17945
+ ...TieredLabelFields,
17946
+ importance: number(),
17947
+ /** Highest-confidence ObjectEvent id for the track (empty when none). */
17948
+ bestEventId: string(),
17949
+ /** Track lifetime in ms (lastSeen - firstSeen). */
17950
+ windowMs: number().optional(),
17951
+ ...TrackFlagFields,
17952
+ ...TrackRetrainFields
17777
17953
  });
17778
- var ConfigFieldBridge = custom();
17779
- var PipelineAddonSchemaSchema = object({
17780
- id: string(),
17781
- name: string(),
17782
- slot: PipelineSlotSchema,
17783
- inputClasses: array(string()).readonly(),
17784
- outputClasses: array(string()).readonly(),
17785
- childSlots: array(PipelineSlotSchema).readonly(),
17786
- models: array(PipelineModelOptionSchema).readonly(),
17787
- defaultModelId: string(),
17788
- defaultModelIdByFormat: record(string(), string()).optional(),
17789
- enabledByDefault: boolean().optional(),
17790
- backfillIntoExistingOverrides: boolean().optional(),
17791
- defaultConfidence: number(),
17792
- group: string().optional(),
17793
- configSchema: array(ConfigFieldBridge).readonly().optional()
17954
+ object({
17955
+ trackId: string(),
17956
+ className: string(),
17957
+ confidence: number(),
17958
+ bbox: BoundingBoxSchema,
17959
+ zones: array(string()).readonly(),
17960
+ state: TrackStateSchema
17794
17961
  });
17795
- var PipelineSlotSchemaSchema = object({
17796
- id: PipelineSlotSchema,
17797
- label: string(),
17798
- priority: number(),
17799
- parentSlot: PipelineSlotSchema.nullable(),
17800
- addons: array(PipelineAddonSchemaSchema).readonly()
17962
+ var OverlayDetectionSchema = looseObject({
17963
+ id: string(),
17964
+ kind: _enum(["first-level", "detail"]),
17965
+ macroClass: string(),
17966
+ score: number(),
17967
+ bbox: object({
17968
+ x: number(),
17969
+ y: number(),
17970
+ width: number(),
17971
+ height: number()
17972
+ }),
17973
+ labels: array(looseObject({
17974
+ label: string(),
17975
+ score: number()
17976
+ })).readonly(),
17977
+ parentId: string().optional()
17801
17978
  });
17802
- var PipelineSchemaSchema = object({
17803
- availableEngines: array(AvailableEngineSchema).readonly(),
17804
- selectedEngine: PipelineEngineChoiceSchema,
17805
- slots: array(PipelineSlotSchemaSchema).readonly()
17979
+ var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
17980
+ var SearchObjectEventsInput = object({
17981
+ text: string(),
17982
+ deviceId: number().optional(),
17983
+ since: number().optional(),
17984
+ until: number().optional(),
17985
+ classFilter: string().optional(),
17986
+ limit: number().default(50),
17987
+ minScore: number().min(0).max(1).default(.2)
17806
17988
  });
17807
- var EngineProvisioningSchema = object({
17808
- runtimeId: _enum([
17809
- "onnx",
17810
- "openvino",
17811
- "coreml",
17812
- "edgetpu"
17813
- ]).nullable(),
17814
- device: string().nullable(),
17815
- state: _enum([
17816
- "idle",
17817
- "installing",
17818
- "verifying",
17819
- "ready",
17820
- "failed"
17821
- ]),
17822
- progress: number().optional(),
17823
- error: string().optional(),
17824
- nextRetryAt: number().optional(),
17825
- /**
17826
- * Gate A (config-correctness gate at engine change): human-readable
17827
- * config issues surfaced EAGERLY when the node's engine changes — model
17828
- * substitutions ("chose X, running Y") and zero-build steps ("no model
17829
- * has a <format> build"). Additive/optional: informational only, never
17830
- * enforced here — `assertEngineReady` (readiness) still gates inference.
17831
- * Absent/empty when the node-default tree resolves cleanly.
17832
- */
17833
- configIssues: array(string()).optional()
17989
+ var TrackCascadeCountsSchema = object({
17990
+ /** Persisted track roots deleted (authoritative). */
17991
+ tracks: number().int(),
17992
+ /** Object events removed with their tracks (best-effort; see note above). */
17993
+ events: number().int(),
17994
+ /** Track/face/plate-owned media removed (best-effort). Never identity media. */
17995
+ media: number().int(),
17996
+ /** Unassigned (non-enrolled) face reads removed (best-effort). */
17997
+ faces: number().int(),
17998
+ /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
17999
+ plates: number().int(),
18000
+ /** Per-track CLIP search vectors removed (best-effort). */
18001
+ embeddings: number().int(),
18002
+ /** Group membership + group rows removed with their last member (best-effort). */
18003
+ groups: number().int()
17834
18004
  });
17835
- var PipelineStepInputSchema = lazy(() => object({
17836
- addonId: string(),
17837
- modelId: string().optional(),
17838
- enabled: boolean().default(true),
17839
- children: array(PipelineStepInputSchema).optional(),
17840
- settings: record(string(), unknown()).optional(),
17841
- jumpDeviceKey: string().optional()
17842
- }));
17843
- var ModelSubstitutionSchema = object({
17844
- addonId: string(),
17845
- chosen: string(),
17846
- running: string(),
17847
- format: string()
18005
+ /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
18006
+ var DiskReconcileCountsSchema = object({
18007
+ mediaDropped: number().int(),
18008
+ tracks: number().int(),
18009
+ events: number().int()
17848
18010
  });
17849
- var PipelineValidationIssueSchema = object({
17850
- addonId: string(),
17851
- kind: _enum(["unknown-addon", "no-format-build"]),
17852
- detail: string()
18011
+ /** Event-store footprint for one camera. */
18012
+ var EventStoreDeviceFootprintSchema = object({
18013
+ deviceId: number(),
18014
+ /** Persisted event rows (motion + object + audio) for the camera. */
18015
+ rows: number().int(),
18016
+ /** Event-owned media bytes on disk for the camera. */
18017
+ bytes: number().int()
17853
18018
  });
17854
- var PipelineValidationResultSchema = object({
17855
- ok: boolean(),
17856
- issues: array(PipelineValidationIssueSchema).readonly(),
17857
- substitutions: array(ModelSubstitutionSchema).readonly(),
17858
- /** The node's `currentEngine.format` this validation ran against. */
17859
- format: string()
18019
+ /** Aggregate event-store footprint: global totals + per-camera breakdown. */
18020
+ var EventStoreFootprintSchema = object({
18021
+ totalRows: number().int(),
18022
+ totalBytes: number().int(),
18023
+ devices: array(EventStoreDeviceFootprintSchema).readonly()
17860
18024
  });
17861
- var ReferenceImageEntrySchema = object({
17862
- filename: string(),
17863
- stepIds: array(string()).readonly().optional()
18025
+ /** Per-kind counts returned by the event-prune / device-delete mutations. */
18026
+ var EventPruneCountsSchema = object({
18027
+ motion: number().int(),
18028
+ object: number().int(),
18029
+ audio: number().int()
17864
18030
  });
17865
- var ReferenceImageBodySchema = object({
17866
- base64: string(),
17867
- filename: string()
18031
+ /**
18032
+ * Re-embed stored tracks from their key frames.
18033
+ *
18034
+ * The reason this is an operator-callable method and not a migration script:
18035
+ * every knob that decides what a vector MEANS — encoder model, crop margin,
18036
+ * squaring — is only changeable if the existing vectors can be regenerated.
18037
+ * Mixing feature spaces in one index makes cosine scores incomparable, and the
18038
+ * symptom is a quality regression with no visible cause.
18039
+ */
18040
+ var RebuildObjectEmbeddingsInput = object({
18041
+ /** Restrict to one camera. Omit for the whole fleet. */
18042
+ deviceId: number().optional(),
18043
+ since: number().optional(),
18044
+ until: number().optional(),
18045
+ /** Stop after this many tracks; the result reports whether more remain. */
18046
+ maxTracks: number().int().positive().optional(),
18047
+ /**
18048
+ * Run every embedding on THIS node instead of round-robining the fleet.
18049
+ *
18050
+ * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
18051
+ * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
18052
+ * calling it that would pin the rebuild REQUEST itself to that node — the
18053
+ * rebuild orchestration lives on the hub, and only the per-track step runs
18054
+ * remotely. This field is data; the per-track pin is applied inside.
18055
+ *
18056
+ * Absent ⇒ round-robin over every online node whose runner can serve the
18057
+ * pinned model.
18058
+ */
18059
+ executeOnNodeId: string().optional(),
18060
+ /**
18061
+ * Milliseconds to wait between tracks; omit for the built-in default, `0` to
18062
+ * run flat out.
18063
+ *
18064
+ * A rebuild is bulk maintenance on hub-main's single thread. Measured
18065
+ * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
18066
+ * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
18067
+ * force is logged at start and finish so a deliberately slow pass reads
18068
+ * differently from a stalled one.
18069
+ */
18070
+ pacingMs: number().int().nonnegative().optional()
17868
18071
  });
17869
- var ReferenceAudioEntrySchema = object({
17870
- filename: string(),
17871
- sizeKb: number()
18072
+ /**
18073
+ * Result of emptying the CLIP index.
18074
+ *
18075
+ * The clean slate before a policy change: a new crop margin or encoder model
18076
+ * leaves two feature spaces in one index whose cosine scores are not
18077
+ * comparable, so wiping and rebuilding is the only way to be sure every vector
18078
+ * means the same thing.
18079
+ */
18080
+ var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
18081
+ /**
18082
+ * Acknowledgement that a rebuild STARTED.
18083
+ *
18084
+ * The pass costs ~1s per track — 45 minutes for a 2,600-track fleet — so it
18085
+ * runs detached and this returns immediately. Waiting for it made the client
18086
+ * time out while the work carried on server-side, which is the worst of both:
18087
+ * no result and no way to know it was still going. Poll
18088
+ * `getObjectEmbeddingRebuildStatus` for progress.
18089
+ */
18090
+ var RebuildObjectEmbeddingsResultSchema = object({
18091
+ started: boolean(),
18092
+ /** True when a pass was already running; the new request is ignored. */
18093
+ alreadyRunning: boolean()
17872
18094
  });
17873
- var ReferenceAudioBodySchema = object({ base64: string() });
17874
- var AudioBackendSchema = object({
17875
- id: string(),
17876
- name: string(),
17877
- description: string(),
17878
- available: boolean(),
18095
+ var RebuildStatusSchema = object({
18096
+ running: boolean(),
18097
+ scanned: number(),
18098
+ rebuilt: number(),
18099
+ /** Tracks whose key frame is gone — nothing to re-embed from. */
18100
+ missingKeyFrame: number(),
18101
+ /** Tracks with no usable detection box. */
18102
+ missingBbox: number(),
18103
+ /**
18104
+ * Tracks an executing node REFUSED rather than broke on — an unreadable key
18105
+ * frame, a step that threw. Separate from `failed` because the remedy is
18106
+ * different, and because a whole camera silently contributing zero vectors
18107
+ * is the shape of failure a rebuild must never hide.
18108
+ */
18109
+ notRunnable: number(),
17879
18110
  /**
17880
- * Raw classifier labels this backend can emit (e.g. YAMNet's
17881
- * 521-class set or Apple SoundAnalysis's 303-class set). Used by
17882
- * the benchmark UI to populate the `enabledMicroClasses` filter
17883
- * specific to the selected backend without a separate fetch.
18111
+ * The pass stopped because NO node could serve the pinned model.
18112
+ *
18113
+ * Distinct from `notRunnable` on purpose: that one says "this track was
18114
+ * refused", this one says "the cluster cannot do this work at all" — every
18115
+ * candidate node either lacks the `clip-embedding` step, lacks a build of the
18116
+ * pinned model for its engine format, or dropped out. The remedy is a model /
18117
+ * engine change, not a per-camera one. Non-zero here always comes with
18118
+ * `complete: false`.
17884
18119
  */
17885
- rawLabels: array(string()).readonly().optional()
17886
- });
17887
- var AudioCapabilitiesSchema = object({
17888
- activeBackend: string(),
17889
- availableBackends: array(AudioBackendSchema).readonly(),
17890
- sampleRate: number(),
17891
- chunkDurationMs: number()
17892
- });
17893
- var DownloadModelResultSchema = object({
17894
- filePath: string(),
17895
- sizeMB: number(),
17896
- durationMs: number()
18120
+ noCapableNode: number(),
18121
+ failed: number(),
18122
+ /** Set once a pass ends: true only when EVERYTHING was covered. */
18123
+ complete: boolean().nullable(),
18124
+ startedAtMs: number().nullable(),
18125
+ finishedAtMs: number().nullable(),
18126
+ /** Present when the pass ended by throwing. */
18127
+ error: string().nullable()
17897
18128
  });
17898
- /**
17899
- * Wrapper carrying a single test run's result. Replaces the legacy
17900
- * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
17901
- * canonical `AudioResult` from the Phase 6 output rework: one
17902
- * `AudioDetection` per class above `minScore`, top-N candidates in
17903
- * `debug.alternateLabels['audio-classifier']`, per-source timings in
17904
- * `debug.stepTimings`. The outer `success`/`error` fields stay so the
17905
- * benchmark UI can still report a clean failure when the classifier
17906
- * cap isn't available.
17907
- */
17908
- var AudioTestResultSchema = object({
17909
- success: boolean(),
17910
- error: string().optional(),
17911
- frame: custom().optional()
18129
+ var ReplayFrameInputSchema = object({
18130
+ timestamp: number(),
18131
+ frame: PipelineRunResultBridge
17912
18132
  });
17913
- var PipelineConfigBridge = custom();
17914
- var ConfigUISchemaBridge = custom();
17915
- var ConfigUISchemaNullableBridge = custom();
17916
- var InferenceCapabilitiesBridge = custom();
17917
- var ModelAvailabilityListBridge = custom();
17918
- var PipelineRunResultBridge = custom();
17919
- method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
17920
- modelId: string(),
17921
- settings: record(string(), unknown()).readonly()
17922
- }))), method(object({ steps: record(string(), object({
17923
- modelId: string(),
17924
- settings: record(string(), unknown()).readonly()
17925
- })) }), object({ success: literal(true) }), {
18133
+ var RunReplayFrameProcessorResultSchema = object({ tracks: array(object({
18134
+ className: string(),
18135
+ firstSeenMs: number(),
18136
+ lastSeenMs: number(),
18137
+ /** Bbox of the track's FIRST matched detection, pixel-space in the clip's
18138
+ * frame — a representative box for the diff's `(className, window, IoU)`
18139
+ * pairing (`replay-diff.ts`). A replay does not need the full per-frame
18140
+ * trajectory production's `Track.positions` keeps. */
18141
+ bbox: BoundingBoxSchema,
18142
+ /** How many of the input frames this track matched a real detection on
18143
+ * (never a coasted/extrapolated frame) — the replay's own signal for "how
18144
+ * solid is this track", cheaper than re-deriving it from a trajectory. */
18145
+ framesMatched: number().int()
18146
+ })).readonly() });
18147
+ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
18148
+ deviceId: number(),
18149
+ trackId: string()
18150
+ }), TrackSchema.nullable()), method(object({
18151
+ deviceId: number(),
18152
+ since: number().optional(),
18153
+ until: number().optional(),
18154
+ limit: number().optional(),
18155
+ /** Spatial filter — only tracks whose trajectory intersects the zone
18156
+ * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
18157
+ * envelope columns, then precisely tested per position. Tracks with
18158
+ * an unknown envelope (no frame dims at persist time) always match. */
18159
+ zone: TrackZoneFilterSchema.optional(),
18160
+ /** See {@link TrackProjectionSchema}. Default `full` (backward
18161
+ * compatible — omitting the field keeps today's exact behaviour). */
18162
+ projection: TrackProjectionSchema.optional(),
18163
+ /** Include stationary-promoted rows (parked objects handed to the
18164
+ * stationary registry). Default false: the timeline lists passages,
18165
+ * not parking records (operator decision, 2026-08-15). */
18166
+ includeStationary: boolean().optional()
18167
+ }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
18168
+ deviceId: number(),
18169
+ groupId: string().min(1)
18170
+ }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
18171
+ kind: "mutation",
18172
+ auth: "admin"
18173
+ }), 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({
18174
+ deviceId: number(),
18175
+ since: number().optional(),
18176
+ until: number().optional(),
18177
+ kinds: array(string()).optional(),
18178
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
18179
+ }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
18180
+ deviceId: number(),
18181
+ since: number(),
18182
+ until: number(),
18183
+ bucketMs: number().int().positive()
18184
+ }), array(object({
18185
+ bucketStart: number(),
18186
+ motion: number().int(),
18187
+ object: number().int(),
18188
+ audio: number().int()
18189
+ })).readonly()), method(object({
18190
+ deviceId: number(),
18191
+ cutoffMs: number()
18192
+ }), object({
18193
+ motion: number().int(),
18194
+ object: number().int(),
18195
+ audio: number().int()
18196
+ }), {
18197
+ kind: "mutation",
18198
+ auth: "admin"
18199
+ }), method(object({
18200
+ deviceId: number(),
18201
+ cutoffMs: number()
18202
+ }), TrackCascadeCountsSchema, {
18203
+ kind: "mutation",
18204
+ auth: "admin"
18205
+ }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
18206
+ kind: "mutation",
18207
+ auth: "admin"
18208
+ }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
18209
+ kind: "mutation",
18210
+ auth: "admin"
18211
+ }), method(object({
18212
+ deviceId: number(),
18213
+ trackIds: array(string()).min(1)
18214
+ }), object({
18215
+ deleted: number().int(),
18216
+ failed: array(string()).readonly()
18217
+ }), {
18218
+ kind: "mutation",
18219
+ auth: "admin"
18220
+ }), method(object({
18221
+ /** Log/audit scope only — the trackId is globally unique on its own. */
18222
+ deviceId: number(),
18223
+ trackId: string(),
18224
+ flags: TrackFlagsPatchSchema
18225
+ }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
18226
+ kind: "query",
18227
+ auth: "admin"
18228
+ }), method(object({
18229
+ olderThanMs: number(),
18230
+ reason: OpsLogReasonSchema.optional()
18231
+ }), EventPruneCountsSchema, {
18232
+ kind: "mutation",
18233
+ auth: "admin"
18234
+ }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
18235
+ kind: "mutation",
18236
+ auth: "admin"
18237
+ }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
18238
+ kind: "mutation",
18239
+ auth: "admin"
18240
+ }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
18241
+ kind: "mutation",
18242
+ auth: "admin"
18243
+ }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
18244
+ kind: "mutation",
18245
+ auth: "admin"
18246
+ }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
18247
+ kind: "mutation",
18248
+ auth: "admin"
18249
+ }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18250
+ kind: "mutation",
18251
+ auth: "admin"
18252
+ }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
18253
+ kind: "mutation",
18254
+ auth: "admin"
18255
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
18256
+ kind: "query",
18257
+ auth: "admin"
18258
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18259
+ kind: "mutation",
18260
+ auth: "admin"
18261
+ }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
18262
+ kind: "query",
18263
+ auth: "admin"
18264
+ }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
18265
+ kind: "query",
18266
+ auth: "admin"
18267
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18268
+ kind: "query",
18269
+ auth: "admin"
18270
+ }), method(object({
18271
+ /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
18272
+ * `deviceId`, deliberately: `deviceId` would make this device-bound and
18273
+ * route it at one camera's owner, and "every camera" would stop being
18274
+ * expressible at all. */
18275
+ deviceIds: array(number()).optional(),
18276
+ limit: number().int().min(1).max(500).optional()
18277
+ }), array(RetrainTrackSchema).readonly(), {
18278
+ kind: "query",
18279
+ auth: "admin"
18280
+ }), method(object({ trackId: string() }), RetrainFrameListSchema, {
18281
+ kind: "query",
18282
+ auth: "admin"
18283
+ }), method(object({
18284
+ deviceId: number(),
18285
+ trackId: string(),
18286
+ mediaKeys: array(string()).min(1)
18287
+ }), RetrainFrameSelectionSchema, {
18288
+ kind: "mutation",
18289
+ auth: "admin"
18290
+ }), method(object({
18291
+ deviceId: number(),
18292
+ trackId: string(),
18293
+ frameId: string()
18294
+ }), object({
18295
+ removed: boolean(),
18296
+ removedAnnotations: number().int()
18297
+ }), {
18298
+ kind: "mutation",
18299
+ auth: "admin"
18300
+ }), method(object({ frameId: string() }), object({
18301
+ base64: string(),
18302
+ width: number().int(),
18303
+ height: number().int()
18304
+ }), {
18305
+ kind: "query",
18306
+ auth: "admin"
18307
+ }), method(object({
18308
+ deviceId: number(),
18309
+ trackId: string(),
18310
+ frameId: string(),
18311
+ subject: RetrainAssistSubjectSchema,
18312
+ /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
18313
+ nodeId: string().optional()
18314
+ }), RetrainAssistResultSchema, {
18315
+ kind: "mutation",
18316
+ auth: "admin"
18317
+ }), method(object({
18318
+ deviceId: number(),
18319
+ source: DetectionSourceSchema,
18320
+ zones: array(ZoneSchema).readonly().optional(),
18321
+ detectionRules: array(ZoneRuleSchema).readonly().optional(),
18322
+ zoneMembershipMinOverlap: number().min(0).max(1).optional(),
18323
+ frames: array(ReplayFrameInputSchema).min(1)
18324
+ }), RunReplayFrameProcessorResultSchema, {
18325
+ kind: "mutation",
18326
+ auth: "admin"
18327
+ }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
18328
+ kind: "query",
18329
+ auth: "admin"
18330
+ }), method(object({
18331
+ deviceId: number(),
18332
+ trackId: string(),
18333
+ frameId: string(),
18334
+ annotations: array(RetrainAnnotationDraftSchema)
18335
+ }), array(RetrainAnnotationSchema).readonly(), {
18336
+ kind: "mutation",
18337
+ auth: "admin"
18338
+ }), method(object({
18339
+ deviceId: number(),
18340
+ trackId: string()
18341
+ }), RetrainTransitionResultSchema, {
17926
18342
  kind: "mutation",
17927
18343
  auth: "admin"
17928
- }), method(object({ nodeId: string() }), object({
17929
- success: literal(true),
17930
- clearedDevices: number()
17931
- }), {
18344
+ }), method(object({
18345
+ deviceId: number(),
18346
+ trackId: string()
18347
+ }), RetrainTransitionResultSchema, {
17932
18348
  kind: "mutation",
17933
18349
  auth: "admin"
17934
- }), 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({
17935
- name: string(),
17936
- steps: array(PipelineTemplateStepSchema).readonly(),
17937
- engine: PipelineEngineChoiceSchema
17938
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
17939
- id: string(),
17940
- name: string().optional(),
17941
- steps: array(PipelineTemplateStepSchema).readonly().optional()
17942
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
17943
- addonId: string(),
17944
- modelId: string(),
17945
- format: ModelFormatSchema$1
17946
- }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
17947
- addonId: string(),
17948
- modelId: string(),
17949
- format: ModelFormatSchema$1
17950
- }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
17951
- engine: PipelineEngineChoiceSchema.optional(),
17952
- steps: array(PipelineStepInputSchema).min(1),
17953
- frame: FrameInputSchema.optional(),
17954
- /**
17955
- * Process-local lazy frame. Valid only when caller and provider resolve
17956
- * in the same execution-group process; split/cross-node callers use
17957
- * `frame`/`image` inline compatibility instead.
17958
- */
17959
- frameRef: FrameRefSchema.optional(),
17960
- /**
17961
- * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
17962
- * the decoded pixels live in. One more member of the one-of
17963
- * frame/frameHandle/image/imageBase64/referenceImage group.
17964
- */
17965
- frameHandle: FrameHandleSchema.optional(),
17966
- imageBase64: string().optional(),
17967
- /**
17968
- * Binary JPEG bytes — preferred over `imageBase64` on internal
17969
- * hops (hub → forked worker via Moleculer MsgPack) because it
17970
- * skips the 33% base64 overhead + the per-call base64 decode on
17971
- * the detection-pipeline worker. Callers can pass either; exactly
17972
- * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
17973
- */
17974
- image: _instanceof(Uint8Array).optional(),
17975
- referenceImage: string().optional(),
17976
- deviceId: number().optional(),
17977
- sessionId: string().optional(),
17978
- /**
17979
- * Execution plane. 'full' (default) runs the whole tree — benchmark,
17980
- * reference-image, and detail-subtree calls. 'frame' is the live
17981
- * per-frame dispatch: ONLY root-plane steps run; crop children
17982
- * (inputClasses ≠ null) are skipped and served per-track via
17983
- * pipelineRunner.runDetailSubtree (two-plane design).
17984
- */
17985
- plane: _enum(["full", "frame"]).optional(),
17986
- /**
17987
- * Inference-device selector (Phase 2 multi-device). Format
17988
- * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
17989
- * Omitted ⇒ the runner's default device (current single-engine
17990
- * behaviour). Selects WHICH device pool of the node runs the call.
17991
- */
17992
- deviceKey: string().optional(),
17993
- /**
17994
- * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
17995
- * when the parent crop was resolved from the frame's retained NATIVE
17996
- * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
17997
- * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
17998
- * resolution from that surface — the SAME quality path faces already
17999
- * had — instead of the downscaled parent tile. `handle` keys the native
18000
- * surface (node-pinned to its owner); `cropFrameSpace` is the parent
18001
- * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
18002
- * the executor's crop-normalized child ROI back into frame-normalized
18003
- * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
18004
- * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
18005
- * (today's behaviour on the fallback path).
18006
- */
18007
- nativeCropRef: NativeCropRefSchema.optional()
18008
- }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
18009
- engine: PipelineEngineChoiceSchema.optional(),
18010
- steps: array(PipelineStepInputSchema).min(1),
18011
- frames: array(FrameInputSchema).min(1).max(255),
18012
- deviceId: number().optional(),
18013
- sessionId: string().optional(),
18014
- /**
18015
- * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
18016
- * the batch to the Python pool's bench preprocess cache
18017
- * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
18018
- * preprocessed ONCE and every later inference is a pure-inference cache
18019
- * hit — the sustained-throughput run measures inference, not
18020
- * decode+preprocess+infer. Omitted/0 for live frames (all different →
18021
- * full preprocess every call, correct). Fresh per sustained run;
18022
- * released via `uncacheFrame`.
18023
- */
18024
- frameId: number().int().nonnegative().optional(),
18025
- /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
18026
- deviceKey: string().optional()
18027
- }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
18028
- data: _instanceof(Uint8Array),
18029
- width: number().int().positive(),
18030
- height: number().int().positive(),
18031
- format: _enum([
18032
- "rgb",
18033
- "bgr",
18034
- "gray"
18035
- ])
18036
- }), object({
18037
- frameId: number(),
18038
- width: number(),
18039
- height: number()
18040
- }), { kind: "mutation" }), method(object({
18041
- stepId: string(),
18042
- frameId: number().int()
18043
- }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
18044
- batchMode: string(),
18045
- windowMs: number(),
18046
- maxBatchSize: number(),
18047
- concurrency: number()
18048
- })), method(_void(), array(object({
18049
- engineKey: string(),
18050
- engine: PipelineEngineChoiceSchema,
18051
- modelsLoaded: array(string()).readonly(),
18052
- inUseByCameras: array(number()).readonly(),
18053
- /**
18054
- * Origin of this resident factory.
18055
- * - `runtime` — main camera-serving engine (no idle TTL).
18056
- * - `warm-override` — benchmark/test override held in the warm
18057
- * cache; auto-disposed after the idle TTL.
18058
- * - `device-pool` — a concurrent per-device pool (Phase 2
18059
- * multi-device, keyed by `deviceKey`) resolved
18060
- * via `resolveDeviceFactory`. Runs alongside the
18061
- * `runtime` engine on a DIFFERENT accelerator
18062
- * (NPU / iGPU / Coral) — this is how the
18063
- * Engines tab shows all pools running at once.
18064
- */
18065
- kind: _enum([
18066
- "runtime",
18067
- "warm-override",
18068
- "device-pool"
18069
- ]),
18070
- /** Native pid of the underlying Python pool (null when no pool). */
18071
- poolPid: number().nullable(),
18072
- /** ms since this factory was last used (null when not warm-tracked). */
18073
- idleMs: number().nullable(),
18074
- /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
18075
- idleTtlMs: number().nullable()
18076
- })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
18077
- kind: "mutation",
18350
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18351
+ kind: "query",
18078
18352
  auth: "admin"
18079
18353
  }), method(object({
18080
- engine: PipelineEngineChoiceSchema,
18081
- force: boolean().optional()
18082
- }), object({
18083
- success: boolean(),
18084
- reason: string().optional()
18085
- }), {
18354
+ eventId: string(),
18355
+ kind: MediaFileKindEnum.optional(),
18356
+ deviceId: number()
18357
+ }), array(MediaFileSchema).readonly()), method(object({
18358
+ trackId: string(),
18359
+ kinds: array(MediaFileKindEnum).optional(),
18360
+ deviceId: number()
18361
+ }), array(MediaFileSchema).readonly()), method(object({
18362
+ trackId: string(),
18363
+ deviceId: number()
18364
+ }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
18086
18365
  kind: "mutation",
18087
18366
  auth: "admin"
18088
- }), 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({
18089
- addonId: string(),
18090
- modelId: string(),
18091
- filename: string().optional(),
18092
- settings: record(string(), unknown()).optional()
18093
- }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
18367
+ }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
18368
+ kind: "mutation",
18369
+ auth: "admin"
18370
+ }), method(object({}), RebuildStatusSchema), object({
18371
+ deviceId: number(),
18372
+ timestamp: number(),
18373
+ frameWidth: number(),
18374
+ frameHeight: number(),
18375
+ detections: array(OverlayDetectionSchema).readonly()
18376
+ }), object({
18377
+ deviceId: number(),
18378
+ trackId: string(),
18379
+ className: string()
18380
+ }), object({
18381
+ deviceId: number(),
18382
+ trackId: string(),
18383
+ className: string(),
18384
+ durationMs: number()
18385
+ }), object({
18386
+ deviceId: number(),
18387
+ kind: EventKindSchema,
18388
+ eventId: string(),
18389
+ timestamp: number()
18390
+ });
18094
18391
  object({
18095
18392
  activeCameras: number(),
18096
18393
  throttledCameras: number(),
@@ -18102,119 +18399,19 @@ var CameraMetricsSchema = object({
18102
18399
  "disabled",
18103
18400
  "always-on",
18104
18401
  "on-motion"
18105
- ]),
18106
- configuredFps: number(),
18107
- actualFps: number(),
18108
- queueDepth: number(),
18109
- avgInferenceTimeMs: number(),
18110
- droppedFrames: number(),
18111
- phase: _enum([
18112
- "idle",
18113
- "watching",
18114
- "active"
18115
- ])
18116
- });
18117
- var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
18118
- /**
18119
- * Zone — pure geometry + identity. NO filtering behaviour.
18120
- *
18121
- * Zones describe **where** in the frame the operator wants to flag
18122
- * something; consumer-owned {@link ZoneRule} arrays describe **how**
18123
- * each pipeline stage uses them. Splitting the two means a single
18124
- * polygon "Driveway" can simultaneously back a motion-exclude rule,
18125
- * a detection-include rule on `['car']`, and an occupancy aggregate
18126
- * — without three duplicated polygons.
18127
- *
18128
- * Owned by the orchestrator addon (provider) and mirrored into the
18129
- * `zones` device-state slice on every mutation. Consumers
18130
- * (motion-wasm, pipeline-executor, analytics, admin UI) read either
18131
- * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
18132
- * mirror with `onChanged`).
18133
- *
18134
- * Coordinates are normalised fractions of the frame (0–1) so zones
18135
- * survive resolution changes and stream profile switches.
18136
- *
18137
- * `kind` discriminates between full polygons (closed regions used
18138
- * for intrusion / occupancy filters) and tripwires (open 2-point
18139
- * line segments used for cross events). Onboard / firmware-reported
18140
- * zones (Reolink, ONVIF) are out of scope for now — see the deferred
18141
- * task list.
18142
- */
18143
- var ZoneKindEnum = _enum(["polygon", "tripwire"]);
18144
- /** Polygon vertex in fraction-of-frame coordinates (0–1). */
18145
- var PolygonPointSchema = object({
18146
- x: number(),
18147
- y: number()
18148
- });
18149
- /** A camera detection zone — pure geometry/identity. */
18150
- var ZoneSchema = object({
18151
- id: string(),
18152
- name: string(),
18153
- kind: ZoneKindEnum.default("polygon"),
18154
- /** Polygon vertices, fraction of frame (0–1). */
18155
- polygon: array(PolygonPointSchema).readonly(),
18156
- /** Visual color for UI rendering. */
18157
- color: string().default("#3b82f6")
18402
+ ]),
18403
+ configuredFps: number(),
18404
+ actualFps: number(),
18405
+ queueDepth: number(),
18406
+ avgInferenceTimeMs: number(),
18407
+ droppedFrames: number(),
18408
+ phase: _enum([
18409
+ "idle",
18410
+ "watching",
18411
+ "active"
18412
+ ])
18158
18413
  });
18159
- /**
18160
- * Zones capability — per-camera CRUD over polygon detection zones.
18161
- *
18162
- * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
18163
- * to per-device settings and mirrors into the `zones` device-state
18164
- * slice on every mutation, so downstream consumers can subscribe via
18165
- * `dev.state.zones.onChanged`.
18166
- *
18167
- * The cap surface only handles geometry + identity; filtering
18168
- * behaviour (per-class, include/exclude, threshold) lives in the
18169
- * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
18170
- * `capabilities/schemas/zone-rule.js`.
18171
- */
18172
- var zonesCapability = {
18173
- name: "zones",
18174
- scope: "device",
18175
- mode: "singleton",
18176
- deviceTypes: [DeviceType.Camera],
18177
- methods: {
18178
- listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
18179
- addZone: method(object({
18180
- deviceId: number(),
18181
- zone: ZoneSchema
18182
- }), _void(), {
18183
- kind: "mutation",
18184
- auth: "admin"
18185
- }),
18186
- removeZone: method(object({
18187
- deviceId: number(),
18188
- zoneId: string()
18189
- }), _void(), {
18190
- kind: "mutation",
18191
- auth: "admin"
18192
- }),
18193
- updateZone: method(object({
18194
- deviceId: number(),
18195
- zone: ZoneSchema
18196
- }), _void(), {
18197
- kind: "mutation",
18198
- auth: "admin"
18199
- })
18200
- },
18201
- /**
18202
- * Runtime-state slice — the live zone catalogue mirrored by the
18203
- * orchestrator on every CRUD mutation. Consumers read via
18204
- * `device.state.zones.value` / `.watch(...)` without round-tripping
18205
- * the cap, and the codegen DeviceProxy auto-wires the reactive
18206
- * handle. Slice shape is `{ zones: Zone[] }` so future extensions
18207
- * (e.g. zone groupings) can sit alongside the polygon list.
18208
- */
18209
- runtimeState: object({ zones: array(ZoneSchema).readonly() }),
18210
- /**
18211
- * 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.
18212
- *
18213
- * See `RuntimeStateDurability`. Enforced by
18214
- * `scripts/check-runtime-state-durability.ts`.
18215
- */
18216
- durability: "restored"
18217
- };
18414
+ var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
18218
18415
  /**
18219
18416
  * A bounding box in NORMALIZED [0,1] frame coordinates for `getNativeCrop`. The
18220
18417
  * decode worker resolves it against the RETAINED native frame's real pixel dims,
@@ -20007,7 +20204,7 @@ method(object({
20007
20204
  * linking rather than produce an eternal token.
20008
20205
  */
20009
20206
  ttlSec: union([number().int().positive(), literal("never")]).optional()
20010
- }), object({ token: string() })), method(object({ token: string() }), SsoBridgeClaimsSchema.nullable());
20207
+ }), object({ token: string() }), { auth: "admin" }), method(object({ token: string() }), SsoBridgeClaimsSchema.nullable(), { auth: "admin" });
20011
20208
  var ProviderListEntrySchema = discriminatedUnion("shouldSaveDiskSpace", [object({
20012
20209
  providerId: string().min(1),
20013
20210
  displayName: string().min(1),
@@ -20102,10 +20299,13 @@ var EvictResultSchema = object({
20102
20299
  /** True when the provider has nothing left it is willing to drop on this location. */
20103
20300
  exhausted: boolean()
20104
20301
  });
20105
- method(object({ locationId: string() }), EvictableUsageSchema), method(object({
20302
+ method(object({ locationId: string() }), EvictableUsageSchema, { auth: "admin" }), method(object({
20106
20303
  locationId: string(),
20107
20304
  targetBytes: number().int().positive()
20108
- }), EvictResultSchema, { kind: "mutation" });
20305
+ }), EvictResultSchema, {
20306
+ kind: "mutation",
20307
+ auth: "admin"
20308
+ });
20109
20309
  method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin" }), method(StorageMigrationInputSchema, object({ jobId: string() }), {
20110
20310
  kind: "mutation",
20111
20311
  auth: "admin"
@@ -20165,26 +20365,50 @@ var ReadChunkInputSchema = object({
20165
20365
  length: number()
20166
20366
  });
20167
20367
  var EndDownloadInputSchema = object({ downloadId: string() });
20168
- method(_void(), ProviderInfoSchema), method(object({ config: record(string(), unknown()) }), TestLocationResultSchema, { auth: "admin" }), method(object({
20368
+ method(_void(), ProviderInfoSchema, { auth: "admin" }), method(object({ config: record(string(), unknown()) }), TestLocationResultSchema, { auth: "admin" }), method(object({
20169
20369
  location: StorageLocationSchema,
20170
20370
  relativePath: string()
20171
- }), string()), method(object({
20371
+ }), string(), { auth: "admin" }), method(object({
20172
20372
  location: StorageLocationSchema,
20173
20373
  relativePath: string(),
20174
20374
  data: _instanceof(Uint8Array)
20175
- }), _void(), { kind: "mutation" }), method(object({
20375
+ }), _void(), {
20376
+ kind: "mutation",
20377
+ auth: "admin"
20378
+ }), method(object({
20176
20379
  location: StorageLocationSchema,
20177
20380
  relativePath: string()
20178
- }), _instanceof(Uint8Array)), method(object({
20381
+ }), _instanceof(Uint8Array), { auth: "admin" }), method(object({
20179
20382
  location: StorageLocationSchema,
20180
20383
  relativePath: string()
20181
- }), boolean()), method(object({
20384
+ }), boolean(), { auth: "admin" }), method(object({
20182
20385
  location: StorageLocationSchema,
20183
20386
  prefix: string().optional()
20184
- }), array(string()).readonly()), method(object({
20387
+ }), array(string()).readonly(), { auth: "admin" }), method(object({
20185
20388
  location: StorageLocationSchema,
20186
20389
  relativePath: string()
20187
- }), _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" });
20390
+ }), _void(), {
20391
+ kind: "mutation",
20392
+ auth: "admin"
20393
+ }), method(object({ location: StorageLocationSchema }), number().nullable(), { auth: "admin" }), method(BeginUploadInputSchema, BeginUploadResultSchema, {
20394
+ kind: "mutation",
20395
+ auth: "admin"
20396
+ }), method(WriteChunkInputSchema, _void(), {
20397
+ kind: "mutation",
20398
+ auth: "admin"
20399
+ }), method(FinalizeUploadInputSchema, _void(), {
20400
+ kind: "mutation",
20401
+ auth: "admin"
20402
+ }), method(AbortUploadInputSchema, _void(), {
20403
+ kind: "mutation",
20404
+ auth: "admin"
20405
+ }), method(BeginDownloadInputSchema, BeginDownloadResultSchema, {
20406
+ kind: "mutation",
20407
+ auth: "admin"
20408
+ }), method(ReadChunkInputSchema, _instanceof(Uint8Array), { auth: "admin" }), method(EndDownloadInputSchema, _void(), {
20409
+ kind: "mutation",
20410
+ auth: "admin"
20411
+ });
20188
20412
  /** Profile-exported FormBuilder schema. Shape is ConfigUISchema at the UI. */
20189
20413
  var ProfileSettingsSchemaBridge = unknown().nullable();
20190
20414
  var ProfileSettingsBagSchema = record(string(), unknown());
@@ -20442,7 +20666,8 @@ method(object({
20442
20666
  access: "create"
20443
20667
  }), method(object({ userId: string().optional() }), object({ optionsJSON: record(string(), unknown()) }), {
20444
20668
  kind: "mutation",
20445
- access: "view"
20669
+ access: "view",
20670
+ auth: "admin"
20446
20671
  }), method(object({
20447
20672
  /** Required — the user the assertion belongs to (verified). */
20448
20673
  userId: string(),
@@ -20450,10 +20675,12 @@ method(object({
20450
20675
  response: record(string(), unknown())
20451
20676
  }), object({ verified: boolean() }), {
20452
20677
  kind: "mutation",
20453
- access: "view"
20678
+ access: "view",
20679
+ auth: "admin"
20454
20680
  }), method(object({}), object({ optionsJSON: record(string(), unknown()) }), {
20455
20681
  kind: "mutation",
20456
- access: "view"
20682
+ access: "view",
20683
+ auth: "admin"
20457
20684
  }), method(object({
20458
20685
  /** AuthenticationResponseJSON from the browser. */
20459
20686
  response: record(string(), unknown()) }), object({
@@ -20461,7 +20688,8 @@ response: record(string(), unknown()) }), object({
20461
20688
  userId: string().nullable()
20462
20689
  }), {
20463
20690
  kind: "mutation",
20464
- access: "view"
20691
+ access: "view",
20692
+ auth: "admin"
20465
20693
  }), method(object({ userId: string() }), array(PasskeySummarySchema), { auth: "admin" }), method(object({
20466
20694
  userId: string(),
20467
20695
  credentialId: string()
@@ -20633,7 +20861,19 @@ var VectorStatsResultSchema = object({
20633
20861
  /** False when the backend ranks approximately. */
20634
20862
  exact: boolean()
20635
20863
  });
20636
- 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);
20864
+ method(VectorDeclareIndexInputSchema, _void(), {
20865
+ kind: "mutation",
20866
+ auth: "admin"
20867
+ }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
20868
+ kind: "mutation",
20869
+ auth: "admin"
20870
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
20871
+ kind: "mutation",
20872
+ auth: "admin"
20873
+ }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
20874
+ kind: "mutation",
20875
+ auth: "admin"
20876
+ }), method(VectorStatsInputSchema, VectorStatsResultSchema, { auth: "admin" });
20637
20877
  var ClipSchema = object({
20638
20878
  /** Opaque, provider-namespaced id. The default provider encodes the time
20639
20879
  * window so `getClipPlayback` is self-contained (no event re-query). */
@@ -23094,7 +23334,27 @@ var MediaFileLiteSchema$1 = object({
23094
23334
  sizeBytes: number(),
23095
23335
  timestamp: number()
23096
23336
  });
23097
- method(_void(), array(IdentitySchema).readonly()), method(object({ name: string().min(1) }), IdentitySchema, {
23337
+ method(object({
23338
+ /**
23339
+ * Inline {@link IdentitySchema.coverBase64} on every row.
23340
+ *
23341
+ * Default `false`, the same inversion `listRecentFaces` and
23342
+ * `listPlates` took on 2026-08-25 (see `include-crops-default.ts` for
23343
+ * why the burden belongs on the caller that WANTS the bytes). Measured
23344
+ * on the live hub the same day: four identities cost 40,979 B with the
23345
+ * covers inline, ~10 KB of base64 per row, on a query this UI mounts
23346
+ * four times and the viewer holds at `staleTime: 30_000`.
23347
+ *
23348
+ * Nothing loses its avatar: `coverMediaKey` is already on every row and
23349
+ * the `event-media` plane serves that key `immutable` with an ETag.
23350
+ *
23351
+ * **This is an INPUT field, so it does not reach the addon until the
23352
+ * next train** — the hub router validates cap inputs against its own
23353
+ * compiled Zod and strips a key it does not know. Until then the
23354
+ * provider sees `undefined`, which resolves to `false`: the cheap shape
23355
+ * is what ships, and the opt-in becomes reachable when the train lands.
23356
+ */
23357
+ includeCrops: boolean().optional() }).optional(), array(IdentitySchema).readonly()), method(object({ name: string().min(1) }), IdentitySchema, {
23098
23358
  kind: "mutation",
23099
23359
  auth: "admin"
23100
23360
  }), method(object({
@@ -25984,8 +26244,10 @@ var PlateInfoSchema = object({
25984
26244
  keyFrameMediaKey: string().optional(),
25985
26245
  base64: string().optional(),
25986
26246
  /**
25987
- * Same crop as a data-plane URL. `getPlateByTrack` returns this and
25988
- * never inlines JPEG; `listPlates` still inlines for the admin-ui.
26247
+ * Same crop as a data-plane URL, always present when the plate has a stored
26248
+ * crop. `getPlateByTrack` returns this and never inlines JPEG; `listPlates`
26249
+ * and `searchPlates` inline the crop only when their `includeCrops` input is
26250
+ * left at its `true` default.
25989
26251
  */
25990
26252
  cropUrl: string().optional()
25991
26253
  });
@@ -26005,14 +26267,34 @@ var PlateClusterSchema = object({
26005
26267
  });
26006
26268
  method(object({
26007
26269
  deviceId: number().int().optional(),
26008
- limit: number().int().positive().optional()
26270
+ limit: number().int().positive().optional(),
26271
+ /**
26272
+ * Inline the base64 crop on every row. Default `true` — the existing
26273
+ * behaviour, kept so no caller breaks.
26274
+ *
26275
+ * Set `false` once the caller renders {@link PlateInfo.cropUrl}.
26276
+ * Measured on the live hub at the 500 rows the Plates view asks for:
26277
+ * 879,403 B and 27.7 s with the crops inline, against a few KiB of
26278
+ * metadata without them — and the browser then caches the images.
26279
+ *
26280
+ * This is the plate twin of `faceGallery.listRecentFaces`'s option;
26281
+ * plates were the one gallery list left without it.
26282
+ *
26283
+ * **This is an INPUT field, so it does not reach the addon until the
26284
+ * next train.** The hub router validates cap inputs against its own
26285
+ * compiled Zod and strips a key it does not know. Until the train
26286
+ * ships, sending `false` is harmless and keeps the crops inline.
26287
+ */
26288
+ includeCrops: boolean().optional()
26009
26289
  }).optional(), array(PlateInfoSchema).readonly()), method(object({
26010
26290
  deviceId: number().int(),
26011
26291
  trackId: string()
26012
26292
  }), PlateInfoSchema.nullable()), method(object({ plateId: string() }), array(MediaFileLiteSchema).readonly()), method(object({
26013
26293
  text: string().min(1),
26014
26294
  maxDistance: number().int().min(0).optional(),
26015
- limit: number().int().positive().optional()
26295
+ limit: number().int().positive().optional(),
26296
+ /** See `listPlates.includeCrops`. Default `true`. */
26297
+ includeCrops: boolean().optional()
26016
26298
  }), array(PlateInfoSchema).readonly()), method(object({
26017
26299
  maxDistance: number().int().min(0).optional(),
26018
26300
  minClusterSize: number().int().min(2).optional(),
@@ -26026,7 +26308,13 @@ method(object({
26026
26308
  }), method(object({ plateId: string() }), _void(), {
26027
26309
  kind: "mutation",
26028
26310
  auth: "admin"
26029
- }), method(_void(), array(VehicleSchema).readonly()), method(object({ name: string().min(1) }), VehicleSchema, {
26311
+ }), method(object({
26312
+ /** Inline {@link VehicleSchema.coverBase64} on every row. Default
26313
+ * `false` — the vehicle twin of `faceGallery.listIdentities`'s
26314
+ * option; `coverMediaKey` + the `event-media` plane carry the picture.
26315
+ * INPUT field: stripped by the hub router until the train ships, which
26316
+ * resolves to `false` and is exactly the intended default. */
26317
+ includeCrops: boolean().optional() }).optional(), array(VehicleSchema).readonly()), method(object({ name: string().min(1) }), VehicleSchema, {
26030
26318
  kind: "mutation",
26031
26319
  auth: "admin"
26032
26320
  }), method(object({
@@ -27547,92 +27835,6 @@ var sceneMonitorCapability = {
27547
27835
  durability: "session"
27548
27836
  };
27549
27837
  /**
27550
- * Per-stage gating mode applied to the zones a rule references.
27551
- *
27552
- * - `include`: the rule contributes to a **whitelist** for its stage.
27553
- * When at least one `include` rule fires for a stage, only entities
27554
- * inside one of those zones pass that stage.
27555
- * - `exclude`: the rule contributes to a **blacklist** for its stage.
27556
- * Entities inside one of those zones are dropped at that stage.
27557
- *
27558
- * `monitor`-style observation (count without filtering) is not a rule
27559
- * mode — zones without any matching rule are observed naturally by
27560
- * `zone-analytics` (live snapshot + history), so an "I just want to
27561
- * count, not filter" use case needs no rule at all.
27562
- */
27563
- var ZoneRuleModeEnum = _enum(["include", "exclude"]);
27564
- /**
27565
- * Per-consumer rule that references existing zones (geometry) and
27566
- * defines how a specific pipeline stage should treat them. Each
27567
- * consumer addon owns its own `ZoneRule[]` array in its per-device
27568
- * settings:
27569
- *
27570
- * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
27571
- * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
27572
- * - future: notification rules, audio gating, etc.
27573
- *
27574
- * One rule applies to N zones (`zoneIds[]`) so the operator can
27575
- * express "ignore motion in ALL of {garden, street}" with a single
27576
- * rule. `classFilter` narrows the rule to specific object classes —
27577
- * "drop person detections in the street, but keep cars" is one
27578
- * `exclude` rule with `classFilter: ['person']`.
27579
- *
27580
- * `enabled` is a soft toggle — the operator can keep the rule
27581
- * configured but inert without deleting it.
27582
- */
27583
- var ZoneRuleSchema = object({
27584
- /** Stable rule id — survives edits, used by the UI for diffing. */
27585
- id: string(),
27586
- /** Optional human-readable label rendered in the rule editor. */
27587
- name: string().optional(),
27588
- /** Zones this rule targets. The rule's `mode` applies to ALL
27589
- * listed zones (OR-set: a detection in any one of them counts).
27590
- * At least one zone id required — a rule with no targets is a
27591
- * configuration mistake and the form validator rejects it. */
27592
- zoneIds: array(string()).min(1).readonly(),
27593
- mode: ZoneRuleModeEnum,
27594
- /**
27595
- * Class names this rule applies to. Empty / undefined ⇒ rule
27596
- * applies to every class. Class strings match the `macroClass`
27597
- * field on detections (e.g. `person`, `car`, `dog`).
27598
- */
27599
- classFilter: array(string()).readonly().optional(),
27600
- /**
27601
- * Minimum bbox/mask overlap (0–1) with any of the rule's zones
27602
- * required to consider an entity "in the zone". Defaults to the
27603
- * consumer's stage default when omitted. Kept for back-compat with
27604
- * existing per-rule overrides; new operators pick the value via
27605
- * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
27606
- * set, the lower-level engine reads it as a 0–1 fraction.
27607
- */
27608
- overlapThreshold: number().min(0).max(1).optional(),
27609
- /**
27610
- * Operator-friendly version of `overlapThreshold` — the percentage
27611
- * of the detection's bbox that must lie inside the zone for the
27612
- * rule to match. Documented default is 85%; the engine substitutes
27613
- * that when the field is omitted (kept optional so existing rules
27614
- * stored without it stay valid).
27615
- *
27616
- * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
27617
- * rule, the engine prefers `bboxInclusionPct` because it's the
27618
- * field exposed in the UI. Internally both feed the same gate.
27619
- */
27620
- bboxInclusionPct: number().min(0).max(100).optional(),
27621
- /**
27622
- * When `true` and a detection has a segmentation mask, use the
27623
- * mask for overlap instead of the bbox. Detection-stage only;
27624
- * motion rules ignore this field.
27625
- */
27626
- preferMask: boolean().optional(),
27627
- /**
27628
- * Soft-toggle: `false` disables the rule without deleting it.
27629
- * Defaults to `true` so operators creating a rule via the UI
27630
- * see it active immediately.
27631
- */
27632
- enabled: boolean().default(true)
27633
- });
27634
- array(ZoneRuleSchema).readonly();
27635
- /**
27636
27838
  * Script-runner cap. Models HA `script.*` entities on
27637
27839
  * `DeviceType.Script`. A Script is a pre-recorded action sequence
27638
27840
  * that can be invoked imperatively — optionally with a variables
@@ -33287,6 +33489,12 @@ Object.freeze({
33287
33489
  addonId: null,
33288
33490
  access: "create"
33289
33491
  },
33492
+ "pipelineAnalytics.cancelRelocateMedia": {
33493
+ capName: "pipeline-analytics",
33494
+ capScope: "device",
33495
+ addonId: null,
33496
+ access: "create"
33497
+ },
33290
33498
  "pipelineAnalytics.cancelStorageMigrationMove": {
33291
33499
  capName: "pipeline-analytics",
33292
33500
  capScope: "device",
@@ -33461,6 +33669,12 @@ Object.freeze({
33461
33669
  addonId: null,
33462
33670
  access: "view"
33463
33671
  },
33672
+ "pipelineAnalytics.listRelocateMediaJobs": {
33673
+ capName: "pipeline-analytics",
33674
+ capScope: "device",
33675
+ addonId: null,
33676
+ access: "view"
33677
+ },
33464
33678
  "pipelineAnalytics.listRetrainAnnotations": {
33465
33679
  capName: "pipeline-analytics",
33466
33680
  capScope: "device",
@@ -33539,6 +33753,12 @@ Object.freeze({
33539
33753
  addonId: null,
33540
33754
  access: "create"
33541
33755
  },
33756
+ "pipelineAnalytics.relocateMedia": {
33757
+ capName: "pipeline-analytics",
33758
+ capScope: "device",
33759
+ addonId: null,
33760
+ access: "create"
33761
+ },
33542
33762
  "pipelineAnalytics.restageRetrainTrack": {
33543
33763
  capName: "pipeline-analytics",
33544
33764
  capScope: "device",
@@ -33551,6 +33771,12 @@ Object.freeze({
33551
33771
  addonId: null,
33552
33772
  access: "create"
33553
33773
  },
33774
+ "pipelineAnalytics.runReplayFrameProcessor": {
33775
+ capName: "pipeline-analytics",
33776
+ capScope: "device",
33777
+ addonId: null,
33778
+ access: "create"
33779
+ },
33554
33780
  "pipelineAnalytics.saveRetrainAnnotations": {
33555
33781
  capName: "pipeline-analytics",
33556
33782
  capScope: "device",
@@ -33683,6 +33909,12 @@ Object.freeze({
33683
33909
  addonId: null,
33684
33910
  access: "view"
33685
33911
  },
33912
+ "pipelineExecutor.getInferenceDeviceHealth": {
33913
+ capName: "pipeline-executor",
33914
+ capScope: "system",
33915
+ addonId: null,
33916
+ access: "view"
33917
+ },
33686
33918
  "pipelineExecutor.getOrchestratorConfigSchema": {
33687
33919
  capName: "pipeline-executor",
33688
33920
  capScope: "system",
@@ -33755,6 +33987,12 @@ Object.freeze({
33755
33987
  addonId: null,
33756
33988
  access: "view"
33757
33989
  },
33990
+ "pipelineExecutor.rearmInferenceDevice": {
33991
+ capName: "pipeline-executor",
33992
+ capScope: "system",
33993
+ addonId: null,
33994
+ access: "create"
33995
+ },
33758
33996
  "pipelineExecutor.runAudioTest": {
33759
33997
  capName: "pipeline-executor",
33760
33998
  capScope: "system",
@@ -37003,6 +37241,11 @@ Object.freeze({
37003
37241
  form: "single",
37004
37242
  optional: false
37005
37243
  }],
37244
+ "pipelineAnalytics.runReplayFrameProcessor": [{
37245
+ name: "deviceId",
37246
+ form: "single",
37247
+ optional: false
37248
+ }],
37006
37249
  "pipelineAnalytics.saveRetrainAnnotations": [{
37007
37250
  name: "deviceId",
37008
37251
  form: "single",