@camstack/addon-provider-homematic 1.2.29 → 1.2.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/addon.js +2135 -1892
  2. package/dist/addon.mjs +2135 -1892
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -6639,7 +6639,7 @@ function method(input, output, options) {
6639
6639
  input,
6640
6640
  output,
6641
6641
  kind: options?.kind ?? "query",
6642
- auth: options?.auth ?? "protected",
6642
+ ...options?.auth !== void 0 ? { auth: options.auth } : {},
6643
6643
  ...options?.access !== void 0 ? { access: options.access } : {},
6644
6644
  ...options?.caller !== void 0 ? { caller: options.caller } : {},
6645
6645
  timeoutMs: options?.timeoutMs
@@ -6663,7 +6663,7 @@ function event(data) {
6663
6663
  }
6664
6664
  var StaticDirOutputSchema$1 = object({ staticDir: string() });
6665
6665
  var VersionOutputSchema$1 = object({ version: string() });
6666
- method(_void(), StaticDirOutputSchema$1), method(_void(), VersionOutputSchema$1);
6666
+ method(_void(), StaticDirOutputSchema$1, { auth: "admin" }), method(_void(), VersionOutputSchema$1, { auth: "admin" });
6667
6667
  var DeviceType = /* @__PURE__ */ function(DeviceType) {
6668
6668
  DeviceType["Camera"] = "camera";
6669
6669
  DeviceType["Hub"] = "hub";
@@ -6984,7 +6984,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
6984
6984
  }({});
6985
6985
  var StaticDirOutputSchema = object({ staticDir: string() });
6986
6986
  var VersionOutputSchema = object({ version: string() });
6987
- method(_void(), StaticDirOutputSchema), method(_void(), VersionOutputSchema);
6987
+ method(_void(), StaticDirOutputSchema, { auth: "admin" }), method(_void(), VersionOutputSchema, { auth: "admin" });
6988
6988
  /**
6989
6989
  * device-ops — device-scoped cap that unifies the per-IDevice operations
6990
6990
  * previously routed through the `.device-ops` Moleculer bridge service.
@@ -7610,24 +7610,6 @@ var RecordingRetentionSchema = object({
7610
7610
  maxSizeGb: number().min(0).optional()
7611
7611
  });
7612
7612
  /**
7613
- * Scrub-thumbnail fidelity preset — the single per-camera selector bundling the
7614
- * sprite tile RESOLUTION + JPEG QUALITY the recorder packs timeline-scrub
7615
- * previews at. Five graduated steps; absent on a config = `standard` (the
7616
- * shipped default, matching `sheet-geometry`/`sheet-composer`).
7617
- *
7618
- * Existing sheets are IMMUTABLE — a changed preset applies to NEW windows only.
7619
- * Each window's index sidecar carries its own tile dims, so a camera whose
7620
- * preset changed over time renders every historical window at the dims it was
7621
- * written with.
7622
- */
7623
- var ScrubThumbnailPresetSchema = _enum([
7624
- "minimal",
7625
- "low",
7626
- "standard",
7627
- "high",
7628
- "max"
7629
- ]);
7630
- /**
7631
7613
  * The full per-camera recording intent — the wire shape of a RecordingTarget.
7632
7614
  *
7633
7615
  * `bands` is the ONLY authored recording intent: what to record, when, and on
@@ -7635,7 +7617,11 @@ var ScrubThumbnailPresetSchema = _enum([
7635
7617
  * other field is a storage knob (profiles, segment length, retention, scrub).
7636
7618
  *
7637
7619
  * STRICT on purpose: the legacy authoring surface (`schedule`/`schedules`/
7638
- * `triggers`/`preBufferSec`/`postBufferSec`/`rules`) was retired 2026-07-30.
7620
+ * `triggers`/`preBufferSec`/`postBufferSec`/`rules`) was retired 2026-07-30,
7621
+ * and `scrubThumbnails` — a five-step fidelity knob for a sprite tier that was
7622
+ * deleted on 2026-07-24 and had ZERO consumers in the recorder — on 2026-08-25
7623
+ * (D62: a switch that writes a store nobody reads is worse than no switch).
7624
+ * Stored rows keep loading: the READ schema is `.strip()` (config-store.ts).
7639
7625
  * A stale caller must fail loudly — silently stripping its legacy intent would
7640
7626
  * persist a band-less config, i.e. silently stop recording the camera.
7641
7627
  */
@@ -7658,14 +7644,7 @@ var RecordingConfigSchema = object({
7658
7644
  * "off" is the absence of a covering band, never a band value.
7659
7645
  */
7660
7646
  bands: array(RecordingBandSchema).default([]),
7661
- retention: RecordingRetentionSchema.optional(),
7662
- /**
7663
- * Per-camera scrub-thumbnail fidelity preset (resolution + JPEG quality for
7664
- * timeline-scrub sprite previews). Absent = `standard`. Applies to NEW
7665
- * windows only — existing sheets are immutable, and each window's index
7666
- * carries its own tile dims so mixed-preset history renders correctly.
7667
- */
7668
- scrubThumbnails: ScrubThumbnailPresetSchema.optional()
7647
+ retention: RecordingRetentionSchema.optional()
7669
7648
  }).strict();
7670
7649
  /**
7671
7650
  * Entity-relocation job state (storage entity-routing spec, Phase 4).
@@ -7741,10 +7720,11 @@ var RelocateFootageInputSchema = object({
7741
7720
  * `RecordingConfig.enabled` or camera wrapper bindings. */
7742
7721
  var StorageMigrationLeaseInputSchema = object({ leaseId: string().min(1) });
7743
7722
  var StorageMigrationFootageMoveInputSchema = RelocateFootageInputSchema.extend({ leaseId: string().min(1) });
7744
- var StorageMigrationMediaMoveInputSchema = object({
7723
+ var RelocateMediaInputSchema = object({
7745
7724
  toLocationId: string(),
7746
7725
  throttleMbps: number().min(1).max(1e3).optional()
7747
- }).extend({ leaseId: string().min(1) });
7726
+ });
7727
+ var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
7748
7728
  /** The independently selectable logical storage classes. `recordings`
7749
7729
  * encompasses the high and mid segment profiles; `recordingsLow` is low
7750
7730
  * segments; `eventMedia` is post-analysis blobs. */
@@ -8039,7 +8019,26 @@ var LabelDefinitionSchema = object({
8039
8019
  description: string().optional(),
8040
8020
  icon: string().optional()
8041
8021
  });
8042
- var ClassMapDefinitionSchema = object({
8022
+ /**
8023
+ * Wire schema for a per-model CATALOG classMap override
8024
+ * (`ModelCatalogEntry.classMap` / `ModelConvertMetadata.classMap`) —
8025
+ * restricted to {@link CLASS_MAP_MACRO_TARGETS}, the only macros the
8026
+ * detection pipeline executor actually routes.
8027
+ *
8028
+ * This is deliberately a DIFFERENT, narrower shape than the general-purpose
8029
+ * `ClassMapDefinition` interface above (e.g. `IDetectionAddon.getClassMap()`
8030
+ * and the audio `YAMNET_TO_MACRO` catalog both use macro targets outside this
8031
+ * enum) — the two used to share the name `ClassMapDefinition`/
8032
+ * `ClassMapDefinitionSchema`, which made the schema-type-twin guard
8033
+ * (`scripts/check-schema-type-twins.ts`) flag them as a duplicated shape. They
8034
+ * are not: it is two different concepts colliding on a name. Keep this type
8035
+ * under its own name rather than reusing `ClassMapDefinition` — reusing it
8036
+ * would either narrow every `ClassMapDefinition` consumer to the four
8037
+ * detection macros (breaking `YAMNET_TO_MACRO`) or drop the validation this
8038
+ * schema exists for (see the "rejects a classMap whose target is not a
8039
+ * detection macro" test in `model-catalog-schema.test.ts`).
8040
+ */
8041
+ var DetectionCatalogClassMapSchema = object({
8043
8042
  mapping: record(string(), _enum([
8044
8043
  "person",
8045
8044
  "vehicle",
@@ -8244,7 +8243,7 @@ var ModelCatalogEntrySchema = object({
8244
8243
  * applies (Frigate / COCO public catalog). Set on a custom model whose raw
8245
8244
  * labels already ARE the CamStack macros (Scrypted identity map).
8246
8245
  */
8247
- classMap: ClassMapDefinitionSchema.optional()
8246
+ classMap: DetectionCatalogClassMapSchema.optional()
8248
8247
  });
8249
8248
  var ConvertTargetSchema = discriminatedUnion("format", [object({
8250
8249
  format: literal("openvino"),
@@ -8274,7 +8273,7 @@ var ModelConvertMetadataSchema = object({
8274
8273
  "segmentation"
8275
8274
  ]),
8276
8275
  faceAlignment: boolean().optional(),
8277
- classMap: ClassMapDefinitionSchema.optional()
8276
+ classMap: DetectionCatalogClassMapSchema.optional()
8278
8277
  });
8279
8278
  var ConvertResultSchema = object({
8280
8279
  entry: ModelCatalogEntrySchema,
@@ -9137,7 +9136,7 @@ var AddonPageDeclarationSchema = object({
9137
9136
  /** Display label for a CUSTOM `section` id (ignored for well-known ids). */
9138
9137
  sectionLabel: string().optional()
9139
9138
  });
9140
- method(_void(), array(AddonPageDeclarationSchema).readonly());
9139
+ method(_void(), array(AddonPageDeclarationSchema).readonly(), { auth: "admin" });
9141
9140
  var AddonHttpRouteSchema = object({
9142
9141
  method: _enum([
9143
9142
  "GET",
@@ -9372,7 +9371,7 @@ var WidgetMetadataSchema = object({
9372
9371
  defaultColumns: number().int().min(1).max(12).default(6),
9373
9372
  defaultRows: number().int().min(1).max(12).default(1)
9374
9373
  });
9375
- method(_void(), array(WidgetMetadataSchema).readonly());
9374
+ method(_void(), array(WidgetMetadataSchema).readonly(), { auth: "admin" });
9376
9375
  /**
9377
9376
  * `addon-widgets` — system-scoped singleton aggregator cap. Public-facing
9378
9377
  * surface that admin-ui consumes through `useAddonWidgetsListWidgets()`.
@@ -11045,7 +11044,7 @@ var CustomModelDescriptorSchema = object({
11045
11044
  stepId: string(),
11046
11045
  entry: ModelCatalogEntrySchema
11047
11046
  });
11048
- method(_void(), array(CustomModelDescriptorSchema).readonly());
11047
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
11049
11048
  /**
11050
11049
  * Query filter for settings-store collections.
11051
11050
  */
@@ -11132,7 +11131,8 @@ method(object({
11132
11131
  }), _void(), { kind: "mutation" }), method(object({
11133
11132
  namespace: string().optional(),
11134
11133
  collection: string(),
11135
- filter: QueryFilterSchema.optional()
11134
+ filter: QueryFilterSchema.optional(),
11135
+ columns: array(string()).readonly().optional()
11136
11136
  }), array(SettingsRecordSchema).readonly()), method(object({
11137
11137
  namespace: string().optional(),
11138
11138
  collection: string(),
@@ -11195,46 +11195,87 @@ var EngineInfoSchema = object({
11195
11195
  kind: _enum(["relational", "vector"]),
11196
11196
  displayName: string()
11197
11197
  });
11198
- method(_void(), EngineInfoSchema), method(object({
11198
+ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
11199
11199
  namespace: string().optional(),
11200
11200
  collection: string(),
11201
11201
  key: string()
11202
- }), unknown()), method(object({
11202
+ }), unknown(), { auth: "admin" }), method(object({
11203
11203
  namespace: string().optional(),
11204
11204
  collection: string(),
11205
11205
  key: string(),
11206
11206
  value: unknown()
11207
- }), _void(), { kind: "mutation" }), method(object({
11207
+ }), _void(), {
11208
+ kind: "mutation",
11209
+ auth: "admin"
11210
+ }), method(object({
11208
11211
  namespace: string().optional(),
11209
11212
  collection: string(),
11210
- filter: QueryFilterSchema.optional()
11211
- }), array(SettingsRecordSchema).readonly()), method(object({
11213
+ filter: QueryFilterSchema.optional(),
11214
+ /**
11215
+ * SQL-level column projection — MUST mirror `settings-store.query`.
11216
+ *
11217
+ * ⚠ An earlier version of this comment blamed Zod stripping, and that
11218
+ * was wrong — corrected 2026-08-26 after the hop map
11219
+ * (`docs/design/2026-08-26-mappa-hop-argomenti.md`) traced the path.
11220
+ * There is **no Zod parse at all** between the door and the engine: the
11221
+ * dispatcher forwards the payload verbatim and UDS carries it whole. A
11222
+ * field declared here reaches `SqliteSettingsBackend` either way.
11223
+ *
11224
+ * What actually lost `columns` was the THIRD declaration of this shape:
11225
+ * `SettingsQueryInput` in `interfaces/storage.ts`, a hand-written TS
11226
+ * interface the engine destructures from. The field existed on both
11227
+ * schemas and the engine still never read it, because nothing checks a
11228
+ * registered provider against `InferProvider<cap>` —
11229
+ * `ProviderRegistration.provider` is typed `object`.
11230
+ *
11231
+ * It is declared here anyway, and must stay in step with
11232
+ * `settings-store.query`: a caller reading only the cap definitions has
11233
+ * to be able to see that this call carries a projection.
11234
+ * `data-door-schema-parity.spec.ts` keeps the two aligned.
11235
+ */
11236
+ columns: array(string()).readonly().optional()
11237
+ }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
11212
11238
  namespace: string().optional(),
11213
11239
  collection: string(),
11214
11240
  record: SettingsRecordSchema
11215
- }), _void(), { kind: "mutation" }), method(object({
11241
+ }), _void(), {
11242
+ kind: "mutation",
11243
+ auth: "admin"
11244
+ }), method(object({
11216
11245
  namespace: string().optional(),
11217
11246
  collection: string(),
11218
11247
  id: string(),
11219
11248
  data: record(string(), unknown())
11220
- }), _void(), { kind: "mutation" }), method(object({
11249
+ }), _void(), {
11250
+ kind: "mutation",
11251
+ auth: "admin"
11252
+ }), method(object({
11221
11253
  namespace: string().optional(),
11222
11254
  collection: string(),
11223
11255
  key: string()
11224
- }), _void(), { kind: "mutation" }), method(object({
11256
+ }), _void(), {
11257
+ kind: "mutation",
11258
+ auth: "admin"
11259
+ }), method(object({
11225
11260
  namespace: string().optional(),
11226
11261
  collection: string(),
11227
11262
  filter: MutationFilterSchema
11228
- }), object({ deleted: number().int() }), { kind: "mutation" }), method(object({
11263
+ }), object({ deleted: number().int() }), {
11264
+ kind: "mutation",
11265
+ auth: "admin"
11266
+ }), method(object({
11229
11267
  namespace: string().optional(),
11230
11268
  collection: string(),
11231
11269
  filter: MutationFilterSchema,
11232
11270
  data: record(string(), unknown())
11233
- }), object({ updated: number().int() }), { kind: "mutation" }), method(object({
11271
+ }), object({ updated: number().int() }), {
11272
+ kind: "mutation",
11273
+ auth: "admin"
11274
+ }), method(object({
11234
11275
  namespace: string().optional(),
11235
11276
  collection: string(),
11236
11277
  filter: QueryFilterSchema.optional()
11237
- }), number()), method(object({
11278
+ }), number(), { auth: "admin" }), method(object({
11238
11279
  namespace: string().optional(),
11239
11280
  collection: string(),
11240
11281
  field: string(),
@@ -11244,15 +11285,18 @@ method(_void(), EngineInfoSchema), method(object({
11244
11285
  }), array(object({
11245
11286
  bucket: number().int(),
11246
11287
  count: number().int()
11247
- })).readonly()), method(object({
11288
+ })).readonly(), { auth: "admin" }), method(object({
11248
11289
  namespace: string().optional(),
11249
11290
  collection: string()
11250
- }), boolean()), method(object({
11291
+ }), boolean(), { auth: "admin" }), method(object({
11251
11292
  namespace: string().optional(),
11252
11293
  collection: string(),
11253
11294
  columns: array(CollectionColumnSchema).readonly(),
11254
11295
  indexes: array(CollectionIndexSchema).readonly().optional()
11255
- }), _void(), { kind: "mutation" });
11296
+ }), _void(), {
11297
+ kind: "mutation",
11298
+ auth: "admin"
11299
+ });
11256
11300
  /**
11257
11301
  * shm ring usage stats for a `frameSink: 'shm'` decoder session —
11258
11302
  * exposed via `decoder.getShmStats` so downstream consumers can
@@ -12559,7 +12603,7 @@ method(object({
12559
12603
  crop: _instanceof(Uint8Array),
12560
12604
  width: number(),
12561
12605
  height: number()
12562
- }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
12606
+ }), EmbeddingResultSchema, { auth: "admin" }), method(object({ text: string() }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" });
12563
12607
  /**
12564
12608
  * filesystem-browse — per-node capability for browsing the node's local
12565
12609
  * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
@@ -12852,19 +12896,22 @@ method(LlmGenerateBaseInputSchema.extend({
12852
12896
  runtime: ManagedRuntimeConfigSchema,
12853
12897
  /** The managed profile's timeout, threaded by the hub provider. */
12854
12898
  timeoutMs: number().int().positive().optional()
12855
- }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
12899
+ }), LlmGenerateResultSchema, {
12900
+ kind: "mutation",
12901
+ auth: "admin"
12902
+ }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
12856
12903
  kind: "mutation",
12857
12904
  auth: "admin"
12858
12905
  }), method(object({}), _void(), {
12859
12906
  kind: "mutation",
12860
12907
  auth: "admin"
12861
- }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
12908
+ }), method(object({}), LlmRuntimeStatusSchema, { auth: "admin" }), method(object({ model: ManagedModelRefSchema }), _void(), {
12862
12909
  kind: "mutation",
12863
12910
  auth: "admin"
12864
12911
  }), method(object({ file: string() }), _void(), {
12865
12912
  kind: "mutation",
12866
12913
  auth: "admin"
12867
- }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
12914
+ }), method(object({}), array(LlmNodeModelSchema), { auth: "admin" }), method(object({}), LlmRuntimeDiskUsageSchema, { auth: "admin" });
12868
12915
  /**
12869
12916
  * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
12870
12917
  * methods concat-fan across providers; single-row methods route to ONE
@@ -16375,1748 +16422,1998 @@ var OauthIntegrationDescriptorSchema = object({
16375
16422
  */
16376
16423
  refreshTokenTtlSec: union([number().int().positive(), literal("never")]).optional()
16377
16424
  });
16378
- method(_void(), OauthIntegrationDescriptorSchema);
16425
+ method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
16379
16426
  /**
16380
- * pipeline-analytics — device-scoped wrapper cap. Refines raw
16381
- * per-frame detections emitted by the pipeline runner into tracked
16382
- * objects, per-kind event collections (motion / object / audio), and
16383
- * persisted media. Owns the post-detection domain end-to-end:
16384
- *
16385
- * runner emits PipelineInferenceResult
16386
- * ↓ (event bus)
16387
- * pipeline-analytics subscriber
16388
- * ↓ SORT tracker + zone engine + state analyzer + event emitter
16389
- * → three DB collections (one per kind), one FS media tree, one
16390
- * unified event emitter (FrameTracked + TrackStarted/Ended +
16391
- * DetectionEvent on bus)
16392
- *
16393
- * Pure subscriber model. No `processFrame` cap method — the runner
16394
- * already publishes the raw frame on the bus. The cap surface is
16395
- * only QUERIES + per-device settings, bound on/off via
16396
- * `device-manager.setWrapperActive`. `defaultActive: true` because
16397
- * every camera with a detection pipeline wants its raw detections
16398
- * refined; operators opt out per-device via BindingsTab when needed.
16399
- *
16400
- * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
16401
- * (per-device surface) and `track-trail` caps — see P11 cleanup.
16427
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
16428
+ * within the frame, so the executor can re-cut a leaf child ROI at native
16429
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
16402
16430
  */
16403
- var TrackStateSchema = _enum([
16404
- "new",
16405
- "entered",
16406
- "left",
16407
- "moving",
16408
- "idle"
16409
- ]);
16410
- var EventKindSchema = _enum([
16411
- "motion",
16412
- "object",
16413
- "audio"
16414
- ]);
16431
+ var NativeCropRefSchema = object({
16432
+ /** Handle keying the retained native surface (node-pinned to its owner). */
16433
+ handle: FrameHandleSchema,
16434
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
16435
+ cropFrameSpace: object({
16436
+ x: number(),
16437
+ y: number(),
16438
+ w: number(),
16439
+ h: number()
16440
+ })
16441
+ });
16442
+ object({
16443
+ crop: object({
16444
+ left: number(),
16445
+ top: number(),
16446
+ width: number().positive(),
16447
+ height: number().positive()
16448
+ }).optional(),
16449
+ content: object({
16450
+ width: number().int().positive(),
16451
+ height: number().int().positive()
16452
+ }),
16453
+ fit: _enum(["stretch", "contain"]),
16454
+ format: _enum([
16455
+ "rgb",
16456
+ "gray",
16457
+ "jpeg"
16458
+ ])
16459
+ });
16415
16460
  /**
16416
- * Spatial filter for `listTracks` — the rect + polygon variants of the shared
16417
- * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
16418
- * of the camera frame (top-left origin), matching the drawing-plane editor.
16461
+ * Process-local frame identity. It is serializable so it can ride an in-process
16462
+ * capability call, but `registryId` deliberately prevents resolution in any
16463
+ * other process or execution group.
16419
16464
  */
16420
- var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
16421
- /** Closed icon vocabulary so clients render a known glyph per kind. */
16422
- var EventKindIconSchema = _enum([
16423
- "motion",
16424
- "audio",
16425
- "person",
16426
- "vehicle",
16427
- "animal",
16428
- "door",
16429
- "pir",
16430
- "smoke",
16431
- "water",
16432
- "button",
16433
- "package",
16434
- "generic"
16465
+ var FrameRefSchema = object({
16466
+ registryId: string().min(1),
16467
+ id: string().min(1),
16468
+ width: number().int().positive(),
16469
+ height: number().int().positive(),
16470
+ format: _enum(["rgb", "gray"]),
16471
+ timestamp: number(),
16472
+ capturedAt: number().optional()
16473
+ });
16474
+ var ModelFormatSchema$1 = _enum([
16475
+ "onnx",
16476
+ "coreml",
16477
+ "openvino",
16478
+ "tflite",
16479
+ "pt",
16480
+ "gguf"
16435
16481
  ]);
16436
- var EventKindCategorySchema = _enum([
16437
- "motion",
16438
- "audio",
16439
- "detection",
16440
- "sensor",
16441
- "control",
16442
- "custom",
16443
- "package"
16482
+ var PipelineSlotSchema = _enum([
16483
+ "detector",
16484
+ "cropper",
16485
+ "classifier",
16486
+ "refiner",
16487
+ "audio-classifier"
16444
16488
  ]);
16445
- /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
16446
- var EventKindLevelSchema = _enum(["macro", "sub"]);
16447
- var EventKindDescriptorSchema = object({
16448
- /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
16449
- kind: string(),
16450
- /** i18n key resolved on the UI side; `label` is the English fallback. */
16451
- labelKey: string(),
16452
- /** English fallback label (kept for clients that don't translate). */
16453
- label: string(),
16454
- /** Hex color for timeline/legend rendering. */
16455
- color: string(),
16456
- /** Dictionary id → lucide component on the UI side. */
16457
- iconId: string(),
16458
- /** Legacy closed-vocab glyph — fallback for `iconId`. */
16459
- icon: EventKindIconSchema,
16460
- category: EventKindCategorySchema,
16461
- /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
16462
- parentKind: string().nullable(),
16463
- /** Derived from `parentKind`, explicit for the client tree. */
16464
- level: EventKindLevelSchema,
16465
- /** Which cap + device contributes this kind. For built-ins the camera
16466
- * itself; for sensor kinds the LINKED source device. */
16467
- source: object({
16468
- capName: string(),
16469
- deviceId: number()
16470
- })
16489
+ var PipelineEngineChoiceSchema = object({
16490
+ runtime: _enum(["node", "python"]),
16491
+ backend: string(),
16492
+ format: ModelFormatSchema$1,
16493
+ device: string().optional()
16471
16494
  });
16472
- /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
16473
- var EventKindsForDeviceSchema = object({
16474
- deviceId: number(),
16475
- kinds: array(EventKindDescriptorSchema).readonly()
16495
+ var AvailableEngineSchema = object({
16496
+ engine: PipelineEngineChoiceSchema,
16497
+ devices: array(object({
16498
+ id: string(),
16499
+ label: string(),
16500
+ description: string().optional()
16501
+ })).readonly(),
16502
+ defaultDevice: string()
16476
16503
  });
16477
- var SensorEventSchema = object({
16504
+ var PipelineDefaultStepSchema = lazy(() => object({
16505
+ addonId: string(),
16506
+ addonName: string(),
16507
+ slot: PipelineSlotSchema,
16508
+ inputClasses: array(string()).readonly(),
16509
+ outputClasses: array(string()).readonly(),
16510
+ enabled: boolean(),
16511
+ modelId: string(),
16512
+ children: array(PipelineDefaultStepSchema).readonly(),
16513
+ group: string().optional(),
16514
+ settings: record(string(), unknown()).optional()
16515
+ }));
16516
+ var PipelineTemplateStepSchema = lazy(() => object({
16517
+ addonId: string(),
16518
+ enabled: boolean(),
16519
+ modelId: string(),
16520
+ children: array(PipelineTemplateStepSchema).readonly(),
16521
+ settings: record(string(), unknown()).optional()
16522
+ }));
16523
+ var PipelineTemplateSchema$1 = object({
16478
16524
  id: string(),
16479
- /** The CAMERA the event is attributed to (a sensor linked to N cameras
16480
- * yields N rows, one per camera). */
16481
- deviceId: number(),
16482
- /** The linked sensor device whose state changed. */
16483
- sourceDeviceId: number(),
16484
- /** Event kind id — matches an `EventKindDescriptor.kind`. */
16485
- kind: string(),
16486
- /** Snapshot of the sensor cap's runtime-state slice at the change. */
16487
- value: record(string(), unknown()).nullable(),
16488
- timestamp: number()
16489
- });
16490
- var TrackPositionSchema = object({
16491
- x: number(),
16492
- y: number(),
16493
- timestamp: number(),
16494
- bbox: BoundingBoxSchema
16525
+ name: string(),
16526
+ createdAt: string(),
16527
+ updatedAt: string(),
16528
+ engine: PipelineEngineChoiceSchema,
16529
+ steps: array(PipelineTemplateStepSchema).readonly()
16495
16530
  });
16496
- var TrackSnapshotSchema = object({
16497
- timestamp: number(),
16498
- position: TrackPositionSchema,
16499
- /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
16500
- mediaKey: string()
16531
+ var PipelineModelOptionSchema = object({
16532
+ id: string(),
16533
+ name: string(),
16534
+ formats: record(string(), object({
16535
+ downloaded: boolean(),
16536
+ sizeMB: number()
16537
+ })),
16538
+ group: ModelVariantGroupSchema.optional(),
16539
+ legacy: boolean().optional(),
16540
+ provider: ModelProviderIdSchema.optional()
16501
16541
  });
16502
- /**
16503
- * Normalized 0..1 trajectory envelope (min/max over every position bbox,
16504
- * divided by the track's detection-frame dims), computed at persist time.
16505
- * Absent when the frame dims were unknown when the track was persisted
16506
- * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
16507
- */
16508
- var TrackEnvelopeSchema = object({
16509
- minX: number(),
16510
- minY: number(),
16511
- maxX: number(),
16512
- maxY: number()
16542
+ var ConfigFieldBridge = custom();
16543
+ var PipelineAddonSchemaSchema = object({
16544
+ id: string(),
16545
+ name: string(),
16546
+ slot: PipelineSlotSchema,
16547
+ inputClasses: array(string()).readonly(),
16548
+ outputClasses: array(string()).readonly(),
16549
+ childSlots: array(PipelineSlotSchema).readonly(),
16550
+ models: array(PipelineModelOptionSchema).readonly(),
16551
+ defaultModelId: string(),
16552
+ defaultModelIdByFormat: record(string(), string()).optional(),
16553
+ enabledByDefault: boolean().optional(),
16554
+ backfillIntoExistingOverrides: boolean().optional(),
16555
+ defaultConfidence: number(),
16556
+ group: string().optional(),
16557
+ configSchema: array(ConfigFieldBridge).readonly().optional()
16513
16558
  });
16514
- /**
16515
- * Row projection for track list queries. `full` (default) returns the
16516
- * complete Track including the frame-rate `positions[]` history and the
16517
- * `snapshots[]` references — megabytes across a page of tracks. `slim`
16518
- * keeps every scalar the list surfaces actually render (ids, class(es),
16519
- * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
16520
- * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
16521
- * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
16522
- * `getTrack`. Mirrors the event-store `projection` convention
16523
- * (`getObjectEvents` et al.).
16524
- */
16525
- var TrackProjectionSchema = _enum(["full", "slim"]);
16526
- /**
16527
- * One audio-classification label heard on the track's camera while the
16528
- * track was alive, aggregated per label. An "episode" is one persisted
16529
- * audio event (the confident-classification path: score ≥ the device's
16530
- * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
16531
- * one 32 ms inference chunk, so counts stay human-scaled.
16532
- */
16533
- var TrackAudioLabelSchema = object({
16559
+ var PipelineSlotSchemaSchema = object({
16560
+ id: PipelineSlotSchema,
16534
16561
  label: string(),
16535
- /** Highest classification score observed across the label's episodes. */
16536
- peakScore: number(),
16537
- /** Number of coalesced audio-event episodes carrying this label. */
16538
- count: number(),
16539
- firstAt: number(),
16540
- lastAt: number()
16562
+ priority: number(),
16563
+ parentSlot: PipelineSlotSchema.nullable(),
16564
+ addons: array(PipelineAddonSchemaSchema).readonly()
16541
16565
  });
16542
- /**
16543
- * How a track was produced. `pipeline` (default / absent) = the spatial
16544
- * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
16545
- * no positions, a single snapshot, and no bbox trajectory at all:
16546
- *
16547
- * - `sensor` — a linked sensor/control device state change.
16548
- * - `audio` — an audio event on the camera itself that was anomalous for
16549
- * THAT camera, loud, and heard while nothing visual was happening (D62).
16550
- *
16551
- * The spatial subsystems (tracker association, occupancy count, re-id /
16552
- * embedding, resurrection) MUST skip every synthetic source. Test for that
16553
- * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
16554
- * check silently readmits every source added after it was written.
16555
- */
16556
- var TrackSourceSchema = _enum([
16557
- "pipeline",
16558
- "sensor",
16559
- "audio"
16560
- ]);
16561
- /**
16562
- * Where a track sits in the RETRAIN lifecycle (D81).
16563
- *
16564
- * - `none` — never marked, or un-marked. Evictable.
16565
- * - `staging` — the operator wants this track as training material and has not
16566
- * finished with it. **This is the only state retention holds**: the track and
16567
- * everything it owns (object events, crops, keyframes, CLIP vector) survive
16568
- * the device's age window.
16569
- * - `trained` — the retrain page has taken what it needed. The frames it chose
16570
- * were COPIED into the retrain dataset at selection time, so the dataset no
16571
- * longer depends on the track's media and the track becomes EVICTABLE again.
16572
- * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
16573
- * a deliberate action of the retrain page, not a side effect of a checkbox.
16574
- *
16575
- * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
16576
- * the store's filter language has only positive equality and `whereIn` — no
16577
- * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
16578
- * would make the entire pre-column history immortal in one deploy.
16579
- */
16580
- var RetrainStatusSchema = _enum([
16581
- "none",
16582
- "staging",
16583
- "trained"
16584
- ]);
16585
- /**
16586
- * Per-track OPERATOR flags — set by hand from the admin UI or the viewer, never
16587
- * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
16588
- * so the two surfaces cannot drift.
16589
- *
16590
- * **Absent ≠ false.** A track that has never been touched omits the field; an
16591
- * explicitly un-flagged track carries `false`. Legacy rows written before the
16592
- * columns existed read as absent, and a consumer that needs a boolean should say
16593
- * `flag === true`, not `flag !== false`.
16594
- *
16595
- * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
16596
- * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
16597
- * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
16598
- * `trained` track reports `false` while refusing both writes. The boolean is
16599
- * kept because three surfaces drive a toggle off it; anything that needs to tell
16600
- * "never marked" from "already trained" must read `retrainStatus`.
16601
- *
16602
- * `debug` does NOT pin; it is attention, not durability.
16603
- *
16604
- * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
16605
- * A favourited track is skipped by retention the same way `staging` is, but
16606
- * it does not enter `none|staging|trained` and has no staging budget.
16607
- */
16608
- var TrackFlagFields = {
16609
- /** Operator marked this track as training material — i.e. `retrainStatus` is
16610
- * `'staging'`. */
16611
- markForTrain: boolean().optional(),
16612
- /** Operator marked this track for diagnostic attention. */
16613
- debug: boolean().optional(),
16614
- /** Operator favourited this track. Pins it against pruning. */
16615
- favourited: boolean().optional()
16616
- };
16617
- /**
16618
- * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
16619
- * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
16620
- * write patch, and the status is not something the toggle sets — it is what the
16621
- * toggle's boolean is derived from. Absent on an in-RAM track never touched;
16622
- * always present on a persisted row (the column default materialises `'none'`).
16623
- */
16624
- var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
16625
- /**
16626
- * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
16627
- * one flag can never clear the other — the toggles are independent and are
16628
- * driven from three surfaces that do not know about each other.
16629
- */
16630
- var TrackFlagsPatchSchema = object(TrackFlagFields);
16631
- /**
16632
- * The resolved flag state after a write. Both fields are REQUIRED here (absent
16633
- * collapses to `false`) so a caller can drive a toggle's checked state off the
16634
- * mutation result without a re-fetch.
16635
- */
16636
- var TrackFlagsSchema = object({
16637
- trackId: string(),
16638
- markForTrain: boolean(),
16639
- debug: boolean(),
16640
- favourited: boolean(),
16641
- /** The lifecycle state the boolean was derived from. Required here (unlike on
16642
- * a track row) because this shape is only ever produced by the write body,
16643
- * which always knows it — and a surface that has just written needs to render
16644
- * `trained` without a re-fetch. */
16645
- retrainStatus: RetrainStatusSchema
16566
+ var PipelineSchemaSchema = object({
16567
+ availableEngines: array(AvailableEngineSchema).readonly(),
16568
+ selectedEngine: PipelineEngineChoiceSchema,
16569
+ slots: array(PipelineSlotSchemaSchema).readonly()
16646
16570
  });
16647
- union([literal(1), literal(2)]);
16648
- /**
16649
- * WHO decided a label, and when. Carried per tier so a value can be traced to
16650
- * the step and model that produced it — which is what makes the write rule
16651
- * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
16652
- * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
16653
- *
16654
- * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
16655
- * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
16656
- * `migration:4g` for a value the 4g migration moved from the single-slot era —
16657
- * that value has no provenance, and the write rule lets ANY properly-attributed
16658
- * write of the same tier replace it regardless of score.
16659
- */
16660
- var LabelAttributionSchema = object({
16661
- stepId: string(),
16662
- modelId: string().optional(),
16663
- decidedAt: number(),
16571
+ var EngineProvisioningSchema = object({
16572
+ runtimeId: _enum([
16573
+ "onnx",
16574
+ "openvino",
16575
+ "coreml",
16576
+ "edgetpu"
16577
+ ]).nullable(),
16578
+ device: string().nullable(),
16579
+ state: _enum([
16580
+ "idle",
16581
+ "installing",
16582
+ "verifying",
16583
+ "ready",
16584
+ "failed"
16585
+ ]),
16586
+ progress: number().optional(),
16587
+ error: string().optional(),
16588
+ nextRetryAt: number().optional(),
16664
16589
  /**
16665
- * The GALLERY id behind a recognised tier-2 label — a face-gallery
16666
- * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
16667
- *
16668
- * The text alone is a DISPLAY NAME, and a display name is renameable: a
16669
- * notification rule authored on "Gianluca" stopped matching the moment the
16670
- * operator fixed the spelling in the gallery, and nothing said so. The id is
16671
- * the thing that does not move, so it is what a rule matches on
16672
- * (`NcConditions.identities`) and the text is what a human is shown.
16673
- *
16674
- * Absent when the label names no gallery row — a plate the OCR read but no
16675
- * vehicle claims, a sub-class, a species, any tier-1 value.
16590
+ * Gate A (config-correctness gate at engine change): human-readable
16591
+ * config issues surfaced EAGERLY when the node's engine changes — model
16592
+ * substitutions ("chose X, running Y") and zero-build steps ("no model
16593
+ * has a <format> build"). Additive/optional: informational only, never
16594
+ * enforced here — `assertEngineReady` (readiness) still gates inference.
16595
+ * Absent/empty when the node-default tree resolves cleanly.
16676
16596
  */
16677
- identityId: string().optional()
16597
+ configIssues: array(string()).optional()
16678
16598
  });
16679
- /**
16680
- * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
16681
- * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
16682
- * track and its events always answer the same question the same way.
16683
- *
16684
- * Two scalar columns, not an array: every consumer wants "the coarse one" or
16685
- * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
16686
- * is tier 2, and each carries its own score + attribution.
16687
- *
16688
- * **Reading it.** What a human should be shown is `subLabel ?? label` — the
16689
- * finest thing known. Before 4g the single `label` column held the finest
16690
- * value, so a consumer that has not been updated reads the tier-1 slot and
16691
- * shows nothing on a species-only row; that is why the migration puts every
16692
- * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
16693
- * and why the read surfaces were changed in the same train.
16694
- *
16695
- * **Writing it.** The slots are independent, which is the whole point: a
16696
- * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
16697
- * migratorius`), so fineness cannot regress by construction. Within a tier the
16698
- * higher score wins. One rule, one implementation — see
16699
- * `pipeline/label-tier.ts` in addon-post-analysis.
16700
- */
16701
- var TieredLabelFields = {
16702
- /** Tier 1 — the sub-class. See {@link LabelTierSchema}. */
16703
- label: string().optional(),
16704
- /** Confidence of the tier-1 value, as reported by the deciding step. */
16705
- labelScore: number().optional(),
16706
- /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
16707
- labelMeta: LabelAttributionSchema.optional(),
16708
- /** Tier 2 — the instance. See {@link LabelTierSchema}. */
16709
- subLabel: string().optional(),
16710
- /** Confidence of the tier-2 value, as reported by the deciding step. */
16711
- subLabelScore: number().optional(),
16712
- /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
16713
- subLabelMeta: LabelAttributionSchema.optional()
16714
- };
16715
- /** Per-camera slice of a training-export estimate. */
16716
- var TrainingExportDeviceTotalsSchema = object({
16717
- deviceId: number(),
16718
- tracks: number().int(),
16719
- files: number().int(),
16720
- bytes: number().int()
16599
+ var PipelineStepInputSchema = lazy(() => object({
16600
+ addonId: string(),
16601
+ modelId: string().optional(),
16602
+ enabled: boolean().default(true),
16603
+ children: array(PipelineStepInputSchema).optional(),
16604
+ settings: record(string(), unknown()).optional(),
16605
+ jumpDeviceKey: string().optional()
16606
+ }));
16607
+ var ModelSubstitutionSchema = object({
16608
+ addonId: string(),
16609
+ chosen: string(),
16610
+ running: string(),
16611
+ format: string()
16612
+ });
16613
+ var PipelineValidationIssueSchema = object({
16614
+ addonId: string(),
16615
+ kind: _enum(["unknown-addon", "no-format-build"]),
16616
+ detail: string()
16617
+ });
16618
+ var PipelineValidationResultSchema = object({
16619
+ ok: boolean(),
16620
+ issues: array(PipelineValidationIssueSchema).readonly(),
16621
+ substitutions: array(ModelSubstitutionSchema).readonly(),
16622
+ /** The node's `currentEngine.format` this validation ran against. */
16623
+ format: string()
16624
+ });
16625
+ var ReferenceImageEntrySchema = object({
16626
+ filename: string(),
16627
+ stepIds: array(string()).readonly().optional()
16628
+ });
16629
+ var ReferenceImageBodySchema = object({
16630
+ base64: string(),
16631
+ filename: string()
16632
+ });
16633
+ var ReferenceAudioEntrySchema = object({
16634
+ filename: string(),
16635
+ sizeKb: number()
16636
+ });
16637
+ var ReferenceAudioBodySchema = object({ base64: string() });
16638
+ var AudioBackendSchema = object({
16639
+ id: string(),
16640
+ name: string(),
16641
+ description: string(),
16642
+ available: boolean(),
16643
+ /**
16644
+ * Raw classifier labels this backend can emit (e.g. YAMNet's
16645
+ * 521-class set or Apple SoundAnalysis's 303-class set). Used by
16646
+ * the benchmark UI to populate the `enabledMicroClasses` filter
16647
+ * specific to the selected backend without a separate fetch.
16648
+ */
16649
+ rawLabels: array(string()).readonly().optional()
16650
+ });
16651
+ var AudioCapabilitiesSchema = object({
16652
+ activeBackend: string(),
16653
+ availableBackends: array(AudioBackendSchema).readonly(),
16654
+ sampleRate: number(),
16655
+ chunkDurationMs: number()
16656
+ });
16657
+ var DownloadModelResultSchema = object({
16658
+ filePath: string(),
16659
+ sizeMB: number(),
16660
+ durationMs: number()
16721
16661
  });
16722
16662
  /**
16723
- * What a training export WOULD contain. Computed from media index rows only —
16724
- * no blob is read to produce this.
16663
+ * Wrapper carrying a single test run's result. Replaces the legacy
16664
+ * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
16665
+ * canonical `AudioResult` from the Phase 6 output rework: one
16666
+ * `AudioDetection` per class above `minScore`, top-N candidates in
16667
+ * `debug.alternateLabels['audio-classifier']`, per-source timings in
16668
+ * `debug.stepTimings`. The outer `success`/`error` fields stay so the
16669
+ * benchmark UI can still report a clean failure when the classifier
16670
+ * cap isn't available.
16725
16671
  */
16726
- var TrainingExportSummarySchema = object({
16727
- generatedAt: number(),
16728
- trackCount: number().int(),
16729
- fileCount: number().int(),
16730
- byteCount: number().int(),
16731
- /** More marked tracks exist than a single pass carries. */
16732
- truncated: boolean(),
16733
- devices: array(TrainingExportDeviceTotalsSchema).readonly()
16672
+ var AudioTestResultSchema = object({
16673
+ success: boolean(),
16674
+ error: string().optional(),
16675
+ frame: custom().optional()
16734
16676
  });
16735
- var TrackSchema = object({
16736
- trackId: string(),
16737
- deviceId: number(),
16738
- className: string(),
16739
- ...TieredLabelFields,
16740
- producingDeviceName: string().optional(),
16741
- /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
16742
- source: TrackSourceSchema.optional(),
16743
- firstSeen: number(),
16744
- lastSeen: number(),
16745
- /** Frame-rate position history (subject to maxPositionHistory cap). */
16746
- positions: array(TrackPositionSchema).readonly(),
16747
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
16748
- * saveThumbnails policy). */
16749
- snapshots: array(TrackSnapshotSchema).readonly(),
16750
- /** Deduplicated zones the track has entered at least once. Zone IDS. */
16751
- zonesVisited: array(string()).readonly(),
16677
+ var PipelineConfigBridge = custom();
16678
+ var ConfigUISchemaBridge = custom();
16679
+ var ConfigUISchemaNullableBridge = custom();
16680
+ var InferenceCapabilitiesBridge = custom();
16681
+ var ModelAvailabilityListBridge = custom();
16682
+ var PipelineRunResultBridge = custom();
16683
+ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
16684
+ modelId: string(),
16685
+ settings: record(string(), unknown()).readonly()
16686
+ }))), method(object({ steps: record(string(), object({
16687
+ modelId: string(),
16688
+ settings: record(string(), unknown()).readonly()
16689
+ })) }), object({ success: literal(true) }), {
16690
+ kind: "mutation",
16691
+ auth: "admin"
16692
+ }), method(object({ nodeId: string() }), object({
16693
+ success: literal(true),
16694
+ clearedDevices: number()
16695
+ }), {
16696
+ kind: "mutation",
16697
+ auth: "admin"
16698
+ }), method(object({ nodeId: string() }), object({ unhealthy: array(object({
16699
+ /** `<backend>:<device>`, e.g. `openvino:gpu`. */
16700
+ deviceKey: string(),
16752
16701
  /**
16753
- * Human NAMES for {@link zonesVisited}, resolved at READ time against the
16754
- * `zones` capability.
16755
- *
16756
- * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
16757
- * and no card can render — so every free-text search surface was structurally
16758
- * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
16759
- * just returned nothing. Resolving here rather than in each client keeps ONE
16760
- * derivation and costs the clients no extra call (the `zones` cap is
16761
- * per-device, so a client-side resolve would be a per-camera fan-out on a
16762
- * surface built to avoid exactly that).
16763
- *
16764
- * Resolved, never invented: a zone deleted since the track was written has no
16765
- * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
16766
- * two are not positionally aligned. Absent when the track visited no zone, or
16767
- * when the zone catalogue could not be read.
16702
+ * `failed` — the per-device restart budget is exhausted; no pool
16703
+ * will be spawned until an operator re-arms it or the runner
16704
+ * respawns. `backoff` — under budget, waiting out the backoff (or
16705
+ * a cached pool observed dead and not yet condemned).
16768
16706
  */
16769
- zoneNames: array(string()).readonly().optional(),
16770
- /** Deduplicated set of detector classes observed for this track over its
16771
- * life (a track may be reclassified, e.g. person→vehicle). Absent on
16772
- * legacy rows written before class accumulation shipped. */
16773
- classes: array(string()).readonly().optional(),
16774
- /** Cumulative normalized distance travelled (0..1 units = full frame width). */
16775
- totalDistance: number(),
16776
- state: TrackStateSchema,
16777
- active: boolean(),
16778
- /** Deterministic key-event importance score in [0,1] (server-computed at
16779
- * track expiry, recomputed on late label). Absent on legacy rows written
16780
- * before scoring shipped — consumers degrade to absence / compute-on-read. */
16781
- importance: number().optional(),
16782
- /** Id of the track's highest-confidence ObjectEvent (its representative
16783
- * "best" frame). Absent when the track produced no object events. */
16784
- bestEventId: string().optional(),
16785
- /** Tag of the importance sub-signal that dominated the score
16786
- * (identity|dwell|proximity|class|confidence|travel|zone). */
16787
- importanceReason: string().optional(),
16788
- /** Audio-classification labels heard on the camera during the track's
16789
- * life (score ≥ device `classificationMinScore`), aggregated per label.
16790
- * Absent on legacy rows / tracks with no confident audio. */
16791
- audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
16792
- /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
16793
- * Populated from the persisted envelope columns on historical reads;
16794
- * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
16795
- envelope: TrackEnvelopeSchema.optional(),
16707
+ state: _enum(["failed", "backoff"]),
16708
+ /** Epoch ms of the death that produced this state. */
16709
+ since: number(),
16710
+ /** Pool deaths inside the current window. */
16711
+ deaths: number(),
16712
+ /** The last death's message. */
16713
+ lastError: string()
16714
+ })).readonly() })), method(object({
16715
+ nodeId: string(),
16716
+ deviceKey: string()
16717
+ }), object({ rearmed: boolean() }), {
16718
+ kind: "mutation",
16719
+ auth: "admin"
16720
+ }), 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({
16721
+ name: string(),
16722
+ steps: array(PipelineTemplateStepSchema).readonly(),
16723
+ engine: PipelineEngineChoiceSchema
16724
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
16725
+ id: string(),
16726
+ name: string().optional(),
16727
+ steps: array(PipelineTemplateStepSchema).readonly().optional()
16728
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
16729
+ addonId: string(),
16730
+ modelId: string(),
16731
+ format: ModelFormatSchema$1
16732
+ }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
16733
+ addonId: string(),
16734
+ modelId: string(),
16735
+ format: ModelFormatSchema$1
16736
+ }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
16737
+ engine: PipelineEngineChoiceSchema.optional(),
16738
+ steps: array(PipelineStepInputSchema).min(1),
16739
+ frame: FrameInputSchema.optional(),
16796
16740
  /**
16797
- * A face DETECTOR found a face on this track — nothing more. It says the
16798
- * detail plane produced a `face` detail; it does NOT say the face was
16799
- * embedded, matched, above `minFacePx`, or that the recognizer was even
16800
- * enabled. Set once and never cleared.
16801
- *
16802
- * **This exists so "face present but not recognised" is expressible.** A
16803
- * recognised identity lands in `subLabel` (attributed to the face chain via
16804
- * `subLabelMeta.stepId`), so before this field a track with an unmatched face
16805
- * and a track with no face at all were byte-identical on the wire and no
16806
- * surface could tell them apart. The read is `hasFace === true && subLabel
16807
- * === undefined`.
16808
- *
16809
- * **Absent ≠ false.** Every row written before the column existed omits it,
16810
- * and so does every server that predates the field — a consumer must test
16811
- * `=== true` and render nothing otherwise, never infer "no face".
16741
+ * Process-local lazy frame. Valid only when caller and provider resolve
16742
+ * in the same execution-group process; split/cross-node callers use
16743
+ * `frame`/`image` inline compatibility instead.
16812
16744
  */
16813
- hasFace: boolean().optional(),
16745
+ frameRef: FrameRefSchema.optional(),
16814
16746
  /**
16815
- * This track has a face row IN THE GALLERY: a crop **and** an embedding — a
16816
- * face an operator could ASSIGN to an identity.
16817
- *
16818
- * The STRICT twin of {@link hasFace}, and the pair only earns its keep
16819
- * because the two disagree. `hasFace` is stamped at the TOP of the face
16820
- * branch, before every gate, and means no more than "a face detector produced
16821
- * a face detail". This one is stamped at the single moment the gallery row
16822
- * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
16823
- * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
16824
- * candidate gate, the imageless-track drop (no crop was ever captured) and
16825
- * the crop-store drop. Everything between the detector and that insert can
16826
- * legitimately refuse the face, so a flag written any earlier promises the
16827
- * operator something to assign and delivers nothing.
16828
- *
16829
- * **Independent of recognition.** A face collected but never auto-matched is
16830
- * still assignable — it is in fact the face an operator most wants to reach —
16831
- * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
16832
- * `subLabel`; this says only that the raw material exists.
16833
- *
16834
- * **Set once, never cleared.** A track that produced a gallery row produced
16835
- * one; deleting the row later is the gallery's business, not this flag's.
16836
- *
16837
- * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
16838
- * before the column omits it, and so does every server that predates the
16839
- * field. A consumer must test `=== true` and render nothing otherwise —
16840
- * never infer "no assignable face".
16747
+ * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
16748
+ * the decoded pixels live in. One more member of the one-of
16749
+ * frame/frameHandle/image/imageBase64/referenceImage group.
16841
16750
  */
16842
- hasEmbeddedFace: boolean().optional(),
16751
+ frameHandle: FrameHandleSchema.optional(),
16752
+ imageBase64: string().optional(),
16843
16753
  /**
16844
- * This subject CONTAINS a folded rider — a person the rider-pairing step
16845
- * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
16846
- * so the passage is tracked once and as a VEHICLE.
16847
- *
16848
- * It exists because the fold's record was dishonest. D34 and the code both
16849
- * said "the person is not lost — it is reported so both entities stay on the
16850
- * record"; in fact the pair went into a per-processor RAM field behind an
16851
- * accessor nobody called, and every durable surface said `vehicle`, full
16852
- * stop. This is the composition note that makes the row true.
16853
- *
16854
- * A COMPOSITION, never a class and never a label. "This vehicle contains a
16855
- * person" is not an answer to "what is this" — both label tiers would refuse
16856
- * a macro token anyway (D89), and correctly. Nothing here changes what the
16857
- * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
16858
- * and a `person` rule still does not fire for someone cycling past.
16859
- *
16860
- * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
16861
- * the column, and every hub that predates the field, omits it. Test
16862
- * `=== true` and render nothing otherwise — never infer "no rider".
16754
+ * Binary JPEG bytes — preferred over `imageBase64` on internal
16755
+ * hops (hub → forked worker via Moleculer MsgPack) because it
16756
+ * skips the 33% base64 overhead + the per-call base64 decode on
16757
+ * the detection-pipeline worker. Callers can pass either; exactly
16758
+ * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
16863
16759
  */
16864
- hasRider: boolean().optional(),
16865
- ...TrackFlagFields,
16866
- ...TrackRetrainFields
16867
- });
16868
- var BaseEventFields = {
16869
- id: string(),
16870
- deviceId: number(),
16871
- timestamp: number()
16872
- };
16873
- var MotionEventSchema = object({
16874
- ...BaseEventFields,
16875
- kind: literal("motion"),
16876
- regionCount: number(),
16877
- /** Heavy JSON array — omitted in slim projection. */
16878
- regions: array(object({
16879
- bbox: BoundingBoxSchema,
16880
- pixelCount: number(),
16881
- intensity: number()
16882
- })).readonly().optional(),
16883
- /** Omitted in slim projection. */
16884
- frameWidth: number().optional(),
16885
- /** Omitted in slim projection. */
16886
- frameHeight: number().optional(),
16887
- /** Populated by B5 (recording playback URL for this event). */
16888
- mediaUrl: string().optional()
16889
- });
16760
+ image: _instanceof(Uint8Array).optional(),
16761
+ referenceImage: string().optional(),
16762
+ deviceId: number().optional(),
16763
+ sessionId: string().optional(),
16764
+ /**
16765
+ * Execution plane. 'full' (default) runs the whole tree — benchmark,
16766
+ * reference-image, and detail-subtree calls. 'frame' is the live
16767
+ * per-frame dispatch: ONLY root-plane steps run; crop children
16768
+ * (inputClasses ≠ null) are skipped and served per-track via
16769
+ * pipelineRunner.runDetailSubtree (two-plane design).
16770
+ */
16771
+ plane: _enum(["full", "frame"]).optional(),
16772
+ /**
16773
+ * Inference-device selector (Phase 2 multi-device). Format
16774
+ * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
16775
+ * Omitted ⇒ the runner's default device (current single-engine
16776
+ * behaviour). Selects WHICH device pool of the node runs the call.
16777
+ */
16778
+ deviceKey: string().optional(),
16779
+ /**
16780
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
16781
+ * when the parent crop was resolved from the frame's retained NATIVE
16782
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
16783
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
16784
+ * resolution from that surface — the SAME quality path faces already
16785
+ * had — instead of the downscaled parent tile. `handle` keys the native
16786
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
16787
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
16788
+ * the executor's crop-normalized child ROI back into frame-normalized
16789
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
16790
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
16791
+ * (today's behaviour on the fallback path).
16792
+ */
16793
+ nativeCropRef: NativeCropRefSchema.optional()
16794
+ }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
16795
+ engine: PipelineEngineChoiceSchema.optional(),
16796
+ steps: array(PipelineStepInputSchema).min(1),
16797
+ frames: array(FrameInputSchema).min(1).max(255),
16798
+ deviceId: number().optional(),
16799
+ sessionId: string().optional(),
16800
+ /**
16801
+ * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
16802
+ * the batch to the Python pool's bench preprocess cache
16803
+ * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
16804
+ * preprocessed ONCE and every later inference is a pure-inference cache
16805
+ * hit — the sustained-throughput run measures inference, not
16806
+ * decode+preprocess+infer. Omitted/0 for live frames (all different →
16807
+ * full preprocess every call, correct). Fresh per sustained run;
16808
+ * released via `uncacheFrame`.
16809
+ */
16810
+ frameId: number().int().nonnegative().optional(),
16811
+ /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
16812
+ deviceKey: string().optional()
16813
+ }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
16814
+ data: _instanceof(Uint8Array),
16815
+ width: number().int().positive(),
16816
+ height: number().int().positive(),
16817
+ format: _enum([
16818
+ "rgb",
16819
+ "bgr",
16820
+ "gray"
16821
+ ])
16822
+ }), object({
16823
+ frameId: number(),
16824
+ width: number(),
16825
+ height: number()
16826
+ }), { kind: "mutation" }), method(object({
16827
+ stepId: string(),
16828
+ frameId: number().int()
16829
+ }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
16830
+ batchMode: string(),
16831
+ windowMs: number(),
16832
+ maxBatchSize: number(),
16833
+ concurrency: number()
16834
+ })), method(_void(), array(object({
16835
+ engineKey: string(),
16836
+ engine: PipelineEngineChoiceSchema,
16837
+ modelsLoaded: array(string()).readonly(),
16838
+ inUseByCameras: array(number()).readonly(),
16839
+ /**
16840
+ * Origin of this resident factory.
16841
+ * - `runtime` — main camera-serving engine (no idle TTL).
16842
+ * - `warm-override` — benchmark/test override held in the warm
16843
+ * cache; auto-disposed after the idle TTL.
16844
+ * - `device-pool` — a concurrent per-device pool (Phase 2
16845
+ * multi-device, keyed by `deviceKey`) resolved
16846
+ * via `resolveDeviceFactory`. Runs alongside the
16847
+ * `runtime` engine on a DIFFERENT accelerator
16848
+ * (NPU / iGPU / Coral) — this is how the
16849
+ * Engines tab shows all pools running at once.
16850
+ */
16851
+ kind: _enum([
16852
+ "runtime",
16853
+ "warm-override",
16854
+ "device-pool"
16855
+ ]),
16856
+ /** Native pid of the underlying Python pool (null when no pool). */
16857
+ poolPid: number().nullable(),
16858
+ /** ms since this factory was last used (null when not warm-tracked). */
16859
+ idleMs: number().nullable(),
16860
+ /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
16861
+ idleTtlMs: number().nullable()
16862
+ })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
16863
+ kind: "mutation",
16864
+ auth: "admin"
16865
+ }), method(object({
16866
+ engine: PipelineEngineChoiceSchema,
16867
+ force: boolean().optional()
16868
+ }), object({
16869
+ success: boolean(),
16870
+ reason: string().optional()
16871
+ }), {
16872
+ kind: "mutation",
16873
+ auth: "admin"
16874
+ }), 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({
16875
+ addonId: string(),
16876
+ modelId: string(),
16877
+ filename: string().optional(),
16878
+ settings: record(string(), unknown()).optional()
16879
+ }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
16890
16880
  /**
16891
- * Which detection SOURCE produced an object event. `pipeline` = the ML
16892
- * detection pipeline (decoded-frame inference); `onboard` = the camera's
16893
- * native on-device AI. Both flow through the SAME analysis layers (zoning,
16894
- * tracking, per-kind persistence) but stay distinguishable so consumers
16895
- * (advanced-notifier, occupancy, …) can select which source(s) to act on.
16896
- * Absent on legacy rows ⇒ treat as `pipeline`.
16881
+ * Per-stage gating mode applied to the zones a rule references.
16882
+ *
16883
+ * - `include`: the rule contributes to a **whitelist** for its stage.
16884
+ * When at least one `include` rule fires for a stage, only entities
16885
+ * inside one of those zones pass that stage.
16886
+ * - `exclude`: the rule contributes to a **blacklist** for its stage.
16887
+ * Entities inside one of those zones are dropped at that stage.
16888
+ *
16889
+ * `monitor`-style observation (count without filtering) is not a rule
16890
+ * mode — zones without any matching rule are observed naturally by
16891
+ * `zone-analytics` (live snapshot + history), so an "I just want to
16892
+ * count, not filter" use case needs no rule at all.
16897
16893
  */
16898
- var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
16894
+ var ZoneRuleModeEnum = _enum(["include", "exclude"]);
16899
16895
  /**
16900
- * The confirmed zone crossing that produced an object event. Present ONLY on
16901
- * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
16902
- * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
16903
- * appearance event carry none, so a rule asking for a direction fails closed
16904
- * on them.
16896
+ * Per-consumer rule that references existing zones (geometry) and
16897
+ * defines how a specific pipeline stage should treat them. Each
16898
+ * consumer addon owns its own `ZoneRule[]` array in its per-device
16899
+ * settings:
16905
16900
  *
16906
- * Exactly ONE crossing per event: the emitter turns each confirmed crossing
16907
- * into its own event, so a frame in which a track enters A while leaving B
16908
- * produces two events with two directions — never one ambiguous row.
16901
+ * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
16902
+ * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
16903
+ * - future: notification rules, audio gating, etc.
16909
16904
  *
16910
- * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
16911
- * membership the box has NOW, and by definition it no longer contains the zone
16912
- * that was just left. Without the id here, a zone-scoped rule could never match
16913
- * the exit it asked for.
16905
+ * One rule applies to N zones (`zoneIds[]`) so the operator can
16906
+ * express "ignore motion in ALL of {garden, street}" with a single
16907
+ * rule. `classFilter` narrows the rule to specific object classes —
16908
+ * "drop person detections in the street, but keep cars" is one
16909
+ * `exclude` rule with `classFilter: ['person']`.
16910
+ *
16911
+ * `enabled` is a soft toggle — the operator can keep the rule
16912
+ * configured but inert without deleting it.
16914
16913
  */
16915
- var ZoneCrossingSchema = object({
16916
- direction: _enum(["enter", "exit"]),
16917
- /** Admin zone id crossed. */
16918
- zoneId: string(),
16919
- /** Zone display name at crossing time (falls back to the id). */
16920
- zoneName: string().optional()
16921
- });
16922
- var ObjectEventSchema = object({
16923
- ...BaseEventFields,
16924
- kind: literal("object"),
16925
- /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
16926
- source: DetectionSourceSchema.optional(),
16914
+ var ZoneRuleSchema = object({
16915
+ /** Stable rule id — survives edits, used by the UI for diffing. */
16916
+ id: string(),
16917
+ /** Optional human-readable label rendered in the rule editor. */
16918
+ name: string().optional(),
16919
+ /** Zones this rule targets. The rule's `mode` applies to ALL
16920
+ * listed zones (OR-set: a detection in any one of them counts).
16921
+ * At least one zone id required — a rule with no targets is a
16922
+ * configuration mistake and the form validator rejects it. */
16923
+ zoneIds: array(string()).min(1).readonly(),
16924
+ mode: ZoneRuleModeEnum,
16927
16925
  /**
16928
- * Inference-frame id shared by every object event emitted from the SAME frame
16929
- * — the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
16930
- * 2 people + 1 dog) under one full frame, and link a track's frames over time
16931
- * (group by `trackId`, pick a representative `frameId` as the parent frame).
16932
- * Optional for backward-compat with pre-existing rows / the slim projection
16933
- * includes it (it is light). Absent on rows written before this field.
16926
+ * Class names this rule applies to. Empty / undefined ⇒ rule
16927
+ * applies to every class. Class strings match the `macroClass`
16928
+ * field on detections (e.g. `person`, `car`, `dog`).
16934
16929
  */
16935
- frameId: string().optional(),
16936
- /** Omitted in slim projection. */
16937
- trackId: string().optional(),
16938
- className: string(),
16939
- ...TieredLabelFields,
16940
- /** Omitted in slim projection. */
16941
- confidence: number().optional(),
16942
- /** Heavy JSON — omitted in slim projection. */
16943
- bbox: BoundingBoxSchema.optional(),
16944
- /** Heavy JSON — omitted in slim projection. */
16945
- zones: array(string()).readonly().optional(),
16946
- /** Omitted in slim projection. */
16947
- state: TrackStateSchema.optional(),
16930
+ classFilter: array(string()).readonly().optional(),
16948
16931
  /**
16949
- * The zone crossing this event IS, when it is one. Absent on every other
16950
- * event kind (movement state, appearance, package) — see
16951
- * {@link ZoneCrossingSchema}. Omitted in slim projection.
16932
+ * Minimum bbox/mask overlap (0–1) with any of the rule's zones
16933
+ * required to consider an entity "in the zone". Defaults to the
16934
+ * consumer's stage default when omitted. Kept for back-compat with
16935
+ * existing per-rule overrides; new operators pick the value via
16936
+ * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
16937
+ * set, the lower-level engine reads it as a 0–1 fraction.
16952
16938
  */
16953
- zoneCrossing: ZoneCrossingSchema.optional(),
16954
- /** Detection-frame dimensions in pixels — let consumers normalize the
16955
- * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
16956
- frameWidth: number().optional(),
16957
- frameHeight: number().optional(),
16958
- /** MediaStore key for the crop attached to this event (if any). */
16959
- mediaKey: string().optional(),
16960
- /** Design B: MediaStore key of the track's native-resolution key frame (the
16961
- * best-detection full frame). Resolve via the event-media data-plane
16962
- * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
16963
- * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
16964
- * sources — consumers fall back to `mediaKey` (the tight crop). */
16965
- keyFrameMediaKey: string().optional(),
16966
- /** Populated by B5 (recording playback URL for this event). */
16967
- mediaUrl: string().optional(),
16968
- /** The parent track's key-event importance [0,1], propagated to every object
16969
- * event of the track (so an event row can be sorted by importance without a
16970
- * track join). Absent on legacy rows / before the track was scored. */
16971
- importance: number().optional()
16939
+ overlapThreshold: number().min(0).max(1).optional(),
16940
+ /**
16941
+ * Operator-friendly version of `overlapThreshold` — the percentage
16942
+ * of the detection's bbox that must lie inside the zone for the
16943
+ * rule to match. Documented default is 85%; the engine substitutes
16944
+ * that when the field is omitted (kept optional so existing rules
16945
+ * stored without it stay valid).
16946
+ *
16947
+ * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
16948
+ * rule, the engine prefers `bboxInclusionPct` because it's the
16949
+ * field exposed in the UI. Internally both feed the same gate.
16950
+ */
16951
+ bboxInclusionPct: number().min(0).max(100).optional(),
16952
+ /**
16953
+ * When `true` and a detection has a segmentation mask, use the
16954
+ * mask for overlap instead of the bbox. Detection-stage only;
16955
+ * motion rules ignore this field.
16956
+ */
16957
+ preferMask: boolean().optional(),
16958
+ /**
16959
+ * Soft-toggle: `false` disables the rule without deleting it.
16960
+ * Defaults to `true` so operators creating a rule via the UI
16961
+ * see it active immediately.
16962
+ */
16963
+ enabled: boolean().default(true)
16972
16964
  });
16973
- var AudioEventSchema = object({
16974
- ...BaseEventFields,
16975
- kind: literal("audio"),
16976
- rms: number(),
16977
- dbfs: number(),
16978
- classification: object({
16979
- className: string(),
16980
- originalClass: string().optional(),
16981
- score: number()
16982
- }).optional(),
16983
- /** Populated by B5 (recording playback URL for this event). */
16984
- mediaUrl: string().optional()
16965
+ array(ZoneRuleSchema).readonly();
16966
+ /**
16967
+ * Zone — pure geometry + identity. NO filtering behaviour.
16968
+ *
16969
+ * Zones describe **where** in the frame the operator wants to flag
16970
+ * something; consumer-owned {@link ZoneRule} arrays describe **how**
16971
+ * each pipeline stage uses them. Splitting the two means a single
16972
+ * polygon "Driveway" can simultaneously back a motion-exclude rule,
16973
+ * a detection-include rule on `['car']`, and an occupancy aggregate
16974
+ * — without three duplicated polygons.
16975
+ *
16976
+ * Owned by the orchestrator addon (provider) and mirrored into the
16977
+ * `zones` device-state slice on every mutation. Consumers
16978
+ * (motion-wasm, pipeline-executor, analytics, admin UI) read either
16979
+ * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
16980
+ * mirror with `onChanged`).
16981
+ *
16982
+ * Coordinates are normalised fractions of the frame (0–1) so zones
16983
+ * survive resolution changes and stream profile switches.
16984
+ *
16985
+ * `kind` discriminates between full polygons (closed regions used
16986
+ * for intrusion / occupancy filters) and tripwires (open 2-point
16987
+ * line segments used for cross events). Onboard / firmware-reported
16988
+ * zones (Reolink, ONVIF) are out of scope for now — see the deferred
16989
+ * task list.
16990
+ */
16991
+ var ZoneKindEnum = _enum(["polygon", "tripwire"]);
16992
+ /** Polygon vertex in fraction-of-frame coordinates (0–1). */
16993
+ var PolygonPointSchema = object({
16994
+ x: number(),
16995
+ y: number()
16985
16996
  });
16986
- var MediaFileKindEnum = _enum([
16987
- "crop",
16988
- "thumbnail",
16989
- "snapshot",
16990
- "firstFrame",
16991
- "lastFrame",
16992
- "fullFrame",
16993
- "fullFrameBoxed",
16994
- "faceCrop",
16995
- "plateCrop",
16996
- "keyFrame",
16997
- "keyFrameSmall",
16998
- "thumbnailSmall"
16999
- ]);
17000
- var MediaFileSchema = object({
17001
- key: string(),
17002
- kind: MediaFileKindEnum,
17003
- base64: string(),
17004
- sizeBytes: number(),
17005
- timestamp: number()
16997
+ /** A camera detection zone — pure geometry/identity. */
16998
+ var ZoneSchema = object({
16999
+ id: string(),
17000
+ name: string(),
17001
+ kind: ZoneKindEnum.default("polygon"),
17002
+ /** Polygon vertices, fraction of frame (0–1). */
17003
+ polygon: array(PolygonPointSchema).readonly(),
17004
+ /** Visual color for UI rendering. */
17005
+ color: string().default("#3b82f6")
17006
17006
  });
17007
17007
  /**
17008
- * One media row WITHOUT its bytes.
17008
+ * Zones capability — per-camera CRUD over polygon detection zones.
17009
17009
  *
17010
- * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
17011
- * 140 s track), and a client that renders tiles from the media data plane needs
17012
- * to know only WHAT EXISTS — the bytes then arrive per tile, lazily, over HTTP
17013
- * with an immutable cache, instead of all at once inside a tRPC response that
17014
- * blocks the whole view.
17010
+ * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
17011
+ * to per-device settings and mirrors into the `zones` device-state
17012
+ * slice on every mutation, so downstream consumers can subscribe via
17013
+ * `dev.state.zones.onChanged`.
17015
17014
  *
17016
- * `sizeBytes` is carried because it is what lets a client decide between the
17017
- * stored blob and a `?variant=thumb` rendering without fetching either.
17015
+ * The cap surface only handles geometry + identity; filtering
17016
+ * behaviour (per-class, include/exclude, threshold) lives in the
17017
+ * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
17018
+ * `capabilities/schemas/zone-rule.js`.
17018
17019
  */
17019
- var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
17020
+ var zonesCapability = {
17021
+ name: "zones",
17022
+ scope: "device",
17023
+ mode: "singleton",
17024
+ deviceTypes: [DeviceType.Camera],
17025
+ methods: {
17026
+ listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
17027
+ addZone: method(object({
17028
+ deviceId: number(),
17029
+ zone: ZoneSchema
17030
+ }), _void(), {
17031
+ kind: "mutation",
17032
+ auth: "admin"
17033
+ }),
17034
+ removeZone: method(object({
17035
+ deviceId: number(),
17036
+ zoneId: string()
17037
+ }), _void(), {
17038
+ kind: "mutation",
17039
+ auth: "admin"
17040
+ }),
17041
+ updateZone: method(object({
17042
+ deviceId: number(),
17043
+ zone: ZoneSchema
17044
+ }), _void(), {
17045
+ kind: "mutation",
17046
+ auth: "admin"
17047
+ })
17048
+ },
17049
+ /**
17050
+ * Runtime-state slice — the live zone catalogue mirrored by the
17051
+ * orchestrator on every CRUD mutation. Consumers read via
17052
+ * `device.state.zones.value` / `.watch(...)` without round-tripping
17053
+ * the cap, and the codegen DeviceProxy auto-wires the reactive
17054
+ * handle. Slice shape is `{ zones: Zone[] }` so future extensions
17055
+ * (e.g. zone groupings) can sit alongside the polygon list.
17056
+ */
17057
+ runtimeState: object({ zones: array(ZoneSchema).readonly() }),
17058
+ /**
17059
+ * 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.
17060
+ *
17061
+ * See `RuntimeStateDurability`. Enforced by
17062
+ * `scripts/check-runtime-state-durability.ts`.
17063
+ */
17064
+ durability: "restored"
17065
+ };
17020
17066
  /**
17021
- * The MACRO tier of an annotation — a CLOSED set.
17067
+ * pipeline-analytics — device-scoped wrapper cap. Refines raw
17068
+ * per-frame detections emitted by the pipeline runner into tracked
17069
+ * objects, per-kind event collections (motion / object / audio), and
17070
+ * persisted media. Owns the post-detection domain end-to-end:
17022
17071
  *
17023
- * This is what the exported detector predicts, so a typo here is a new class
17024
- * with one example in it. `label` and `subLabel` are open strings by contrast:
17025
- * the whole point of the page is teaching the model things it does not know
17026
- * yet, and constraining that vocabulary would make it useless.
17072
+ * runner emits PipelineInferenceResult
17073
+ * ↓ (event bus)
17074
+ * pipeline-analytics subscriber
17075
+ * ↓ SORT tracker + zone engine + state analyzer + event emitter
17076
+ * → three DB collections (one per kind), one FS media tree, one
17077
+ * unified event emitter (FrameTracked + TrackStarted/Ended +
17078
+ * DetectionEvent on bus)
17027
17079
  *
17028
- * A macro class is NEVER a label. The provider refuses a write whose `label` or
17029
- * `subLabel` is one of these values, in any casing, because once `person`
17030
- * exists in both tiers "every person box" stops being answerable without
17031
- * knowing every string anyone ever typed — and the damage is retroactive.
17080
+ * Pure subscriber model. No `processFrame` cap method — the runner
17081
+ * already publishes the raw frame on the bus. The cap surface is
17082
+ * only QUERIES + per-device settings, bound on/off via
17083
+ * `device-manager.setWrapperActive`. `defaultActive: true` because
17084
+ * every camera with a detection pipeline wants its raw detections
17085
+ * refined; operators opt out per-device via BindingsTab when needed.
17086
+ *
17087
+ * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
17088
+ * (per-device surface) and `track-trail` caps — see P11 cleanup.
17032
17089
  */
17033
- var RetrainMacroClassSchema = _enum([
17090
+ var TrackStateSchema = _enum([
17091
+ "new",
17092
+ "entered",
17093
+ "left",
17094
+ "moving",
17095
+ "idle"
17096
+ ]);
17097
+ var EventKindSchema = _enum([
17098
+ "motion",
17099
+ "object",
17100
+ "audio"
17101
+ ]);
17102
+ /**
17103
+ * Spatial filter for `listTracks` — the rect + polygon variants of the shared
17104
+ * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
17105
+ * of the camera frame (top-left origin), matching the drawing-plane editor.
17106
+ */
17107
+ var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
17108
+ /** Closed icon vocabulary so clients render a known glyph per kind. */
17109
+ var EventKindIconSchema = _enum([
17110
+ "motion",
17111
+ "audio",
17034
17112
  "person",
17035
17113
  "vehicle",
17036
17114
  "animal",
17115
+ "door",
17116
+ "pir",
17117
+ "smoke",
17118
+ "water",
17119
+ "button",
17037
17120
  "package",
17038
- "face",
17039
- "plate"
17121
+ "generic"
17040
17122
  ]);
17041
- /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
17042
- var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
17043
- /** Did a human draw this box, or did the assist propose it? */
17044
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
17045
- /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
17046
- var RetrainBboxSchema = object({
17047
- x: number(),
17048
- y: number(),
17049
- w: number(),
17050
- h: number()
17123
+ var EventKindCategorySchema = _enum([
17124
+ "motion",
17125
+ "audio",
17126
+ "detection",
17127
+ "sensor",
17128
+ "control",
17129
+ "custom",
17130
+ "package"
17131
+ ]);
17132
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
17133
+ var EventKindLevelSchema = _enum(["macro", "sub"]);
17134
+ var EventKindDescriptorSchema = object({
17135
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
17136
+ kind: string(),
17137
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
17138
+ labelKey: string(),
17139
+ /** English fallback label (kept for clients that don't translate). */
17140
+ label: string(),
17141
+ /** Hex color for timeline/legend rendering. */
17142
+ color: string(),
17143
+ /** Dictionary id → lucide component on the UI side. */
17144
+ iconId: string(),
17145
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
17146
+ icon: EventKindIconSchema,
17147
+ category: EventKindCategorySchema,
17148
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
17149
+ parentKind: string().nullable(),
17150
+ /** Derived from `parentKind`, explicit for the client tree. */
17151
+ level: EventKindLevelSchema,
17152
+ /** Which cap + device contributes this kind. For built-ins the camera
17153
+ * itself; for sensor kinds the LINKED source device. */
17154
+ source: object({
17155
+ capName: string(),
17156
+ deviceId: number()
17157
+ })
17051
17158
  });
17052
- /**
17053
- * One annotated subject.
17054
- *
17055
- * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
17056
- * (letterboxed root / zone-cropped package / subject-cropped classifier) are
17057
- * derived from it at export and never stored — storing them is how one feature
17058
- * space ends up holding two crops of the same subject (D52).
17059
- */
17060
- var RetrainAnnotationSchema = object({
17061
- id: string(),
17062
- trackId: string(),
17159
+ /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
17160
+ var EventKindsForDeviceSchema = object({
17063
17161
  deviceId: number(),
17064
- /** The COPY in retrain storage — never the source track's media key. */
17065
- mediaKey: string(),
17066
- bbox: RetrainBboxSchema,
17067
- macroClass: RetrainMacroClassSchema,
17068
- label: string().optional(),
17069
- subLabel: string().optional(),
17070
- kind: RetrainAnnotationKindSchema,
17071
- source: RetrainAnnotationSourceSchema,
17072
- /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
17073
- assistModelId: string().optional(),
17074
- assistScore: number().optional(),
17075
- exportedInBatch: string().optional(),
17076
- createdAt: number()
17077
- });
17078
- /** The write form — the server owns `id`, `createdAt` and the frame binding. */
17079
- var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
17080
- id: true,
17081
- trackId: true,
17082
- deviceId: true,
17083
- mediaKey: true,
17084
- createdAt: true,
17085
- exportedInBatch: true
17162
+ kinds: array(EventKindDescriptorSchema).readonly()
17086
17163
  });
17087
- /** A track sitting in `staging`, with everything the worklist needs to rank it. */
17088
- var RetrainTrackSchema = object({
17089
- trackId: string(),
17164
+ var SensorEventSchema = object({
17165
+ id: string(),
17166
+ /** The CAMERA the event is attributed to (a sensor linked to N cameras
17167
+ * yields N rows, one per camera). */
17090
17168
  deviceId: number(),
17091
- className: string(),
17092
- label: string().optional(),
17093
- firstSeen: number(),
17094
- lastSeen: number(),
17095
- /** How many frames the dataset already holds from this track. */
17096
- frameCount: number().int(),
17097
- /** How many subjects have been annotated on those frames. `0` with
17098
- * `frameCount: 0` is exactly "staging, still to work". */
17099
- annotationCount: number().int()
17169
+ /** The linked sensor device whose state changed. */
17170
+ sourceDeviceId: number(),
17171
+ /** Event kind id — matches an `EventKindDescriptor.kind`. */
17172
+ kind: string(),
17173
+ /** Snapshot of the sensor cap's runtime-state slice at the change. */
17174
+ value: record(string(), unknown()).nullable(),
17175
+ timestamp: number()
17100
17176
  });
17101
- /** A frame the picker may offer — an index row, no blob was read to produce it. */
17102
- var RetrainFrameCandidateSchema = object({
17103
- mediaKey: string(),
17104
- kind: MediaFileKindEnum,
17177
+ var TrackPositionSchema = object({
17178
+ x: number(),
17179
+ y: number(),
17105
17180
  timestamp: number(),
17106
- sizeBytes: number().int(),
17107
- /** A copy of this original already exists — selecting it is free and cannot
17108
- * fail, whatever became of the original. */
17109
- copied: boolean()
17110
- });
17111
- /** A frame the dataset OWNS: bytes copied at selection time. */
17112
- var RetrainFrameSchema = object({
17113
- frameId: string(),
17114
- deviceId: number(),
17115
- trackId: string(),
17116
- /** Provenance only. It may already point at nothing — that is expected. */
17117
- sourceMediaKey: string(),
17118
- sourceKind: MediaFileKindEnum,
17119
- sizeBytes: number().int(),
17120
- width: number().int(),
17121
- height: number().int(),
17122
- copiedAt: number()
17123
- });
17124
- /** Why a copy-on-select could not be honoured — named, never a silent skip. */
17125
- var RetrainCopyRefusalSchema = _enum([
17126
- "source-missing",
17127
- "unreadable-image",
17128
- "write-failed"
17129
- ]);
17130
- var RetrainFrameSelectionSchema = object({
17131
- copied: array(RetrainFrameSchema).readonly(),
17132
- refused: array(object({
17133
- sourceMediaKey: string(),
17134
- reason: RetrainCopyRefusalSchema
17135
- })).readonly()
17181
+ bbox: BoundingBoxSchema
17136
17182
  });
17137
- var RetrainFrameListSchema = object({
17138
- candidates: array(RetrainFrameCandidateSchema).readonly(),
17139
- copies: array(RetrainFrameSchema).readonly(),
17140
- /** What the page pre-selects — the native key frame when one survives. */
17141
- autoPickMediaKey: string().optional()
17183
+ var TrackSnapshotSchema = object({
17184
+ timestamp: number(),
17185
+ position: TrackPositionSchema,
17186
+ /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
17187
+ mediaKey: string()
17142
17188
  });
17143
- /** What the operator asked the assist to look for. */
17144
- var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
17145
- kind: literal("package"),
17146
- zone: RetrainBboxSchema.optional()
17147
- }), object({
17148
- kind: literal("objects"),
17149
- modelId: string(),
17150
- minScore: number().optional()
17151
- })]);
17152
17189
  /**
17153
- * The assist's answer — a discriminated union, because "the model saw nothing"
17154
- * and "this node cannot run that model" lead to different next moves and a
17155
- * nullable result cannot tell them apart.
17190
+ * Normalized 0..1 trajectory envelope (min/max over every position bbox,
17191
+ * divided by the track's detection-frame dims), computed at persist time.
17192
+ * Absent when the frame dims were unknown when the track was persisted
17193
+ * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
17156
17194
  */
17157
- var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
17158
- kind: literal("proposed"),
17159
- modelId: string(),
17160
- stepId: string(),
17161
- minScore: number(),
17162
- /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
17163
- proposals: array(RetrainAnnotationDraftSchema).readonly(),
17164
- /** Returned by the runner but removed by the threshold. */
17165
- belowThreshold: number().int()
17166
- }), object({
17167
- kind: literal("refused"),
17168
- /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
17169
- reason: string(),
17170
- detail: string().optional()
17171
- })]);
17172
- /** The outcome of a lifecycle move owned by the retrain page. */
17173
- var RetrainTransitionResultSchema = object({
17174
- trackId: string(),
17175
- /** Where the track ended up, whatever happened. */
17176
- retrainStatus: RetrainStatusSchema,
17177
- /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
17178
- changed: boolean(),
17179
- reason: _enum([
17180
- "unknown-track",
17181
- "no-frames-copied",
17182
- "not-staging",
17183
- "not-trained",
17184
- "unchanged"
17185
- ]).optional()
17195
+ var TrackEnvelopeSchema = object({
17196
+ minX: number(),
17197
+ minY: number(),
17198
+ maxX: number(),
17199
+ maxY: number()
17186
17200
  });
17187
- var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
17188
- var MAX_EVENT_QUERY_LIMIT = 5e3;
17189
- var DeviceEventQueryInput = object({
17190
- deviceId: number(),
17191
- since: number().optional(),
17192
- until: number().optional(),
17193
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
17194
- /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
17195
- * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
17196
- * exact behaviour. Callers may omit this field — the store defaults to
17197
- * `full` when not provided. */
17198
- projection: _enum(["full", "slim"]).optional()
17199
- });
17200
- var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
17201
- var RecentTracksQueryInput = object({
17202
- /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
17203
- deviceIds: array(number()),
17204
- /** Window lower bound on `lastSeen` (inclusive). */
17205
- since: number().optional(),
17206
- /** Window upper bound on `lastSeen` (inclusive). */
17207
- until: number().optional(),
17208
- /** Page size. Default 200, max 1000. */
17209
- limit: number().int().min(1).max(1e3).default(200),
17210
- /** Opaque continuation cursor from a previous page's `nextCursor`.
17211
- * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
17212
- cursor: string().optional(),
17213
- /** See {@link TrackProjectionSchema}. Default `full`. */
17214
- projection: TrackProjectionSchema.optional(),
17215
- /** Include stationary-promoted rows (parked objects). Default false: the
17216
- * feed lists passages; parking records live on the stationary registry. */
17217
- includeStationary: boolean().optional()
17218
- });
17219
- var RecentTracksPageSchema = object({
17220
- /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
17221
- tracks: array(TrackSchema).readonly(),
17222
- /** Cursor for the next page, or null when this page is the last. */
17223
- nextCursor: string().nullable()
17224
- });
17225
- var LIST_GROUPS_DEFAULT_LIMIT = 40;
17226
- var LIST_GROUPS_MAX_LIMIT = 100;
17227
- var AnalyticsGroupRecordSchema = object({
17228
- id: string(),
17229
- deviceId: number().int(),
17230
- openedAt: number().int(),
17231
- closedAt: number().int(),
17232
- timestamp: number().int(),
17233
- memberCount: number().int(),
17234
- memberTrackIds: array(string()).readonly(),
17235
- className: string(),
17236
- classes: array(string()).readonly(),
17237
- /** Relative event-media path, or null when the group has no picture yet. */
17238
- mediaUrl: string().nullable(),
17239
- singleton: boolean()
17240
- });
17241
- var AnalyticsGroupMemberSchema = object({
17242
- trackId: string(),
17243
- deviceId: number().int(),
17244
- className: string(),
17245
- firstSeen: number().int(),
17246
- lastSeen: number().int(),
17247
- mediaUrl: string().nullable()
17248
- });
17249
- var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
17250
- var ListGroupsQueryInput = object({
17251
- /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
17252
- deviceIds: array(number()),
17253
- /** Window lower bound on `closedAt` (inclusive). */
17254
- since: number().optional(),
17255
- /** Window upper bound on `openedAt` (inclusive). */
17256
- until: number().optional(),
17257
- limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
17258
- /** Opaque continuation cursor from a previous page's `nextCursor`. */
17259
- cursor: string().optional()
17260
- });
17261
- var ListGroupsPageSchema = object({
17262
- groups: array(AnalyticsGroupRecordSchema).readonly(),
17263
- nextCursor: string().nullable()
17264
- });
17265
- var KeyEventQueryInput = object({
17266
- deviceId: number(),
17267
- /** Window lower bound (track firstSeen ≥ since). */
17268
- since: number(),
17269
- /** Window upper bound (track firstSeen ≤ until). */
17270
- until: number(),
17271
- limit: number().int().min(1).max(200).default(50),
17272
- /** Drop tracks scoring below this importance. */
17273
- minImportance: number().min(0).max(1).optional(),
17274
- /** Restrict to a single class (e.g. 'person'). */
17275
- classFilter: string().optional()
17276
- });
17277
- var KeyEventSchema = object({
17278
- /** The representative event id (the track's best ObjectEvent, else its trackId). */
17279
- id: string(),
17280
- trackId: string(),
17281
- /** Track start time (firstSeen). */
17282
- timestamp: number(),
17283
- className: string(),
17284
- ...TieredLabelFields,
17285
- importance: number(),
17286
- /** Highest-confidence ObjectEvent id for the track (empty when none). */
17287
- bestEventId: string(),
17288
- /** Track lifetime in ms (lastSeen - firstSeen). */
17289
- windowMs: number().optional(),
17290
- ...TrackFlagFields,
17291
- ...TrackRetrainFields
17292
- });
17293
- object({
17294
- trackId: string(),
17295
- className: string(),
17296
- confidence: number(),
17297
- bbox: BoundingBoxSchema,
17298
- zones: array(string()).readonly(),
17299
- state: TrackStateSchema
17300
- });
17301
- var OverlayDetectionSchema = looseObject({
17302
- id: string(),
17303
- kind: _enum(["first-level", "detail"]),
17304
- macroClass: string(),
17305
- score: number(),
17306
- bbox: object({
17307
- x: number(),
17308
- y: number(),
17309
- width: number(),
17310
- height: number()
17311
- }),
17312
- labels: array(looseObject({
17313
- label: string(),
17314
- score: number()
17315
- })).readonly(),
17316
- parentId: string().optional()
17317
- });
17318
- var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
17319
- var SearchObjectEventsInput = object({
17320
- text: string(),
17321
- deviceId: number().optional(),
17322
- since: number().optional(),
17323
- until: number().optional(),
17324
- classFilter: string().optional(),
17325
- limit: number().default(50),
17326
- minScore: number().min(0).max(1).default(.2)
17327
- });
17328
- var TrackCascadeCountsSchema = object({
17329
- /** Persisted track roots deleted (authoritative). */
17330
- tracks: number().int(),
17331
- /** Object events removed with their tracks (best-effort; see note above). */
17332
- events: number().int(),
17333
- /** Track/face/plate-owned media removed (best-effort). Never identity media. */
17334
- media: number().int(),
17335
- /** Unassigned (non-enrolled) face reads removed (best-effort). */
17336
- faces: number().int(),
17337
- /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
17338
- plates: number().int(),
17339
- /** Per-track CLIP search vectors removed (best-effort). */
17340
- embeddings: number().int(),
17341
- /** Group membership + group rows removed with their last member (best-effort). */
17342
- groups: number().int()
17343
- });
17344
- /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
17345
- var DiskReconcileCountsSchema = object({
17346
- mediaDropped: number().int(),
17347
- tracks: number().int(),
17348
- events: number().int()
17349
- });
17350
- /** Event-store footprint for one camera. */
17351
- var EventStoreDeviceFootprintSchema = object({
17352
- deviceId: number(),
17353
- /** Persisted event rows (motion + object + audio) for the camera. */
17354
- rows: number().int(),
17355
- /** Event-owned media bytes on disk for the camera. */
17356
- bytes: number().int()
17357
- });
17358
- /** Aggregate event-store footprint: global totals + per-camera breakdown. */
17359
- var EventStoreFootprintSchema = object({
17360
- totalRows: number().int(),
17361
- totalBytes: number().int(),
17362
- devices: array(EventStoreDeviceFootprintSchema).readonly()
17363
- });
17364
- /** Per-kind counts returned by the event-prune / device-delete mutations. */
17365
- var EventPruneCountsSchema = object({
17366
- motion: number().int(),
17367
- object: number().int(),
17368
- audio: number().int()
17201
+ /**
17202
+ * Row projection for track list queries. `full` (default) returns the
17203
+ * complete Track including the frame-rate `positions[]` history and the
17204
+ * `snapshots[]` references — megabytes across a page of tracks. `slim`
17205
+ * keeps every scalar the list surfaces actually render (ids, class(es),
17206
+ * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
17207
+ * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
17208
+ * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
17209
+ * `getTrack`. Mirrors the event-store `projection` convention
17210
+ * (`getObjectEvents` et al.).
17211
+ */
17212
+ var TrackProjectionSchema = _enum(["full", "slim"]);
17213
+ /**
17214
+ * One audio-classification label heard on the track's camera while the
17215
+ * track was alive, aggregated per label. An "episode" is one persisted
17216
+ * audio event (the confident-classification path: score ≥ the device's
17217
+ * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
17218
+ * one 32 ms inference chunk, so counts stay human-scaled.
17219
+ */
17220
+ var TrackAudioLabelSchema = object({
17221
+ label: string(),
17222
+ /** Highest classification score observed across the label's episodes. */
17223
+ peakScore: number(),
17224
+ /** Number of coalesced audio-event episodes carrying this label. */
17225
+ count: number(),
17226
+ firstAt: number(),
17227
+ lastAt: number()
17369
17228
  });
17370
17229
  /**
17371
- * Re-embed stored tracks from their key frames.
17230
+ * How a track was produced. `pipeline` (default / absent) = the spatial
17231
+ * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
17232
+ * no positions, a single snapshot, and no bbox trajectory at all:
17372
17233
  *
17373
- * The reason this is an operator-callable method and not a migration script:
17374
- * every knob that decides what a vector MEANS — encoder model, crop margin,
17375
- * squaring — is only changeable if the existing vectors can be regenerated.
17376
- * Mixing feature spaces in one index makes cosine scores incomparable, and the
17377
- * symptom is a quality regression with no visible cause.
17234
+ * - `sensor` — a linked sensor/control device state change.
17235
+ * - `audio` — an audio event on the camera itself that was anomalous for
17236
+ * THAT camera, loud, and heard while nothing visual was happening (D62).
17237
+ *
17238
+ * The spatial subsystems (tracker association, occupancy count, re-id /
17239
+ * embedding, resurrection) MUST skip every synthetic source. Test for that
17240
+ * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
17241
+ * check silently readmits every source added after it was written.
17378
17242
  */
17379
- var RebuildObjectEmbeddingsInput = object({
17380
- /** Restrict to one camera. Omit for the whole fleet. */
17381
- deviceId: number().optional(),
17382
- since: number().optional(),
17383
- until: number().optional(),
17384
- /** Stop after this many tracks; the result reports whether more remain. */
17385
- maxTracks: number().int().positive().optional(),
17386
- /**
17387
- * Run every embedding on THIS node instead of round-robining the fleet.
17388
- *
17389
- * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
17390
- * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
17391
- * calling it that would pin the rebuild REQUEST itself to that node — the
17392
- * rebuild orchestration lives on the hub, and only the per-track step runs
17393
- * remotely. This field is data; the per-track pin is applied inside.
17394
- *
17395
- * Absent ⇒ round-robin over every online node whose runner can serve the
17396
- * pinned model.
17397
- */
17398
- executeOnNodeId: string().optional(),
17399
- /**
17400
- * Milliseconds to wait between tracks; omit for the built-in default, `0` to
17401
- * run flat out.
17402
- *
17403
- * A rebuild is bulk maintenance on hub-main's single thread. Measured
17404
- * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
17405
- * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
17406
- * force is logged at start and finish so a deliberately slow pass reads
17407
- * differently from a stalled one.
17408
- */
17409
- pacingMs: number().int().nonnegative().optional()
17410
- });
17243
+ var TrackSourceSchema = _enum([
17244
+ "pipeline",
17245
+ "sensor",
17246
+ "audio"
17247
+ ]);
17411
17248
  /**
17412
- * Result of emptying the CLIP index.
17249
+ * Where a track sits in the RETRAIN lifecycle (D81).
17413
17250
  *
17414
- * The clean slate before a policy change: a new crop margin or encoder model
17415
- * leaves two feature spaces in one index whose cosine scores are not
17416
- * comparable, so wiping and rebuilding is the only way to be sure every vector
17417
- * means the same thing.
17251
+ * - `none` — never marked, or un-marked. Evictable.
17252
+ * - `staging` — the operator wants this track as training material and has not
17253
+ * finished with it. **This is the only state retention holds**: the track and
17254
+ * everything it owns (object events, crops, keyframes, CLIP vector) survive
17255
+ * the device's age window.
17256
+ * - `trained` — the retrain page has taken what it needed. The frames it chose
17257
+ * were COPIED into the retrain dataset at selection time, so the dataset no
17258
+ * longer depends on the track's media and the track becomes EVICTABLE again.
17259
+ * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
17260
+ * a deliberate action of the retrain page, not a side effect of a checkbox.
17261
+ *
17262
+ * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
17263
+ * the store's filter language has only positive equality and `whereIn` — no
17264
+ * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
17265
+ * would make the entire pre-column history immortal in one deploy.
17418
17266
  */
17419
- var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
17267
+ var RetrainStatusSchema = _enum([
17268
+ "none",
17269
+ "staging",
17270
+ "trained"
17271
+ ]);
17420
17272
  /**
17421
- * Acknowledgement that a rebuild STARTED.
17273
+ * Per-track OPERATOR flags — set by hand from the admin UI or the viewer, never
17274
+ * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
17275
+ * so the two surfaces cannot drift.
17422
17276
  *
17423
- * The pass costs ~1s per track — 45 minutes for a 2,600-track fleet — so it
17424
- * runs detached and this returns immediately. Waiting for it made the client
17425
- * time out while the work carried on server-side, which is the worst of both:
17426
- * no result and no way to know it was still going. Poll
17427
- * `getObjectEmbeddingRebuildStatus` for progress.
17428
- */
17429
- var RebuildObjectEmbeddingsResultSchema = object({
17430
- started: boolean(),
17431
- /** True when a pass was already running; the new request is ignored. */
17432
- alreadyRunning: boolean()
17433
- });
17434
- var RebuildStatusSchema = object({
17435
- running: boolean(),
17436
- scanned: number(),
17437
- rebuilt: number(),
17438
- /** Tracks whose key frame is gone — nothing to re-embed from. */
17439
- missingKeyFrame: number(),
17440
- /** Tracks with no usable detection box. */
17441
- missingBbox: number(),
17442
- /**
17443
- * Tracks an executing node REFUSED rather than broke on — an unreadable key
17444
- * frame, a step that threw. Separate from `failed` because the remedy is
17445
- * different, and because a whole camera silently contributing zero vectors
17446
- * is the shape of failure a rebuild must never hide.
17447
- */
17448
- notRunnable: number(),
17277
+ * **Absent ≠ false.** A track that has never been touched omits the field; an
17278
+ * explicitly un-flagged track carries `false`. Legacy rows written before the
17279
+ * columns existed read as absent, and a consumer that needs a boolean should say
17280
+ * `flag === true`, not `flag !== false`.
17281
+ *
17282
+ * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
17283
+ * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
17284
+ * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
17285
+ * `trained` track reports `false` while refusing both writes. The boolean is
17286
+ * kept because three surfaces drive a toggle off it; anything that needs to tell
17287
+ * "never marked" from "already trained" must read `retrainStatus`.
17288
+ *
17289
+ * `debug` does NOT pin; it is attention, not durability.
17290
+ *
17291
+ * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
17292
+ * A favourited track is skipped by retention the same way `staging` is, but
17293
+ * it does not enter `none|staging|trained` and has no staging budget.
17294
+ */
17295
+ var TrackFlagFields = {
17296
+ /** Operator marked this track as training material — i.e. `retrainStatus` is
17297
+ * `'staging'`. */
17298
+ markForTrain: boolean().optional(),
17299
+ /** Operator marked this track for diagnostic attention. */
17300
+ debug: boolean().optional(),
17301
+ /** Operator favourited this track. Pins it against pruning. */
17302
+ favourited: boolean().optional()
17303
+ };
17304
+ /**
17305
+ * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
17306
+ * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
17307
+ * write patch, and the status is not something the toggle sets — it is what the
17308
+ * toggle's boolean is derived from. Absent on an in-RAM track never touched;
17309
+ * always present on a persisted row (the column default materialises `'none'`).
17310
+ */
17311
+ var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
17312
+ /**
17313
+ * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
17314
+ * one flag can never clear the other — the toggles are independent and are
17315
+ * driven from three surfaces that do not know about each other.
17316
+ */
17317
+ var TrackFlagsPatchSchema = object(TrackFlagFields);
17318
+ /**
17319
+ * The resolved flag state after a write. Both fields are REQUIRED here (absent
17320
+ * collapses to `false`) so a caller can drive a toggle's checked state off the
17321
+ * mutation result without a re-fetch.
17322
+ */
17323
+ var TrackFlagsSchema = object({
17324
+ trackId: string(),
17325
+ markForTrain: boolean(),
17326
+ debug: boolean(),
17327
+ favourited: boolean(),
17328
+ /** The lifecycle state the boolean was derived from. Required here (unlike on
17329
+ * a track row) because this shape is only ever produced by the write body,
17330
+ * which always knows it — and a surface that has just written needs to render
17331
+ * `trained` without a re-fetch. */
17332
+ retrainStatus: RetrainStatusSchema
17333
+ });
17334
+ union([literal(1), literal(2)]);
17335
+ /**
17336
+ * WHO decided a label, and when. Carried per tier so a value can be traced to
17337
+ * the step and model that produced it — which is what makes the write rule
17338
+ * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
17339
+ * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
17340
+ *
17341
+ * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
17342
+ * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
17343
+ * `migration:4g` for a value the 4g migration moved from the single-slot era —
17344
+ * that value has no provenance, and the write rule lets ANY properly-attributed
17345
+ * write of the same tier replace it regardless of score.
17346
+ */
17347
+ var LabelAttributionSchema = object({
17348
+ stepId: string(),
17349
+ modelId: string().optional(),
17350
+ decidedAt: number(),
17449
17351
  /**
17450
- * The pass stopped because NO node could serve the pinned model.
17352
+ * The GALLERY id behind a recognised tier-2 label — a face-gallery
17353
+ * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
17451
17354
  *
17452
- * Distinct from `notRunnable` on purpose: that one says "this track was
17453
- * refused", this one says "the cluster cannot do this work at all" — every
17454
- * candidate node either lacks the `clip-embedding` step, lacks a build of the
17455
- * pinned model for its engine format, or dropped out. The remedy is a model /
17456
- * engine change, not a per-camera one. Non-zero here always comes with
17457
- * `complete: false`.
17355
+ * The text alone is a DISPLAY NAME, and a display name is renameable: a
17356
+ * notification rule authored on "Gianluca" stopped matching the moment the
17357
+ * operator fixed the spelling in the gallery, and nothing said so. The id is
17358
+ * the thing that does not move, so it is what a rule matches on
17359
+ * (`NcConditions.identities`) and the text is what a human is shown.
17360
+ *
17361
+ * Absent when the label names no gallery row — a plate the OCR read but no
17362
+ * vehicle claims, a sub-class, a species, any tier-1 value.
17458
17363
  */
17459
- noCapableNode: number(),
17460
- failed: number(),
17461
- /** Set once a pass ends: true only when EVERYTHING was covered. */
17462
- complete: boolean().nullable(),
17463
- startedAtMs: number().nullable(),
17464
- finishedAtMs: number().nullable(),
17465
- /** Present when the pass ended by throwing. */
17466
- error: string().nullable()
17364
+ identityId: string().optional()
17467
17365
  });
17468
- DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
17469
- deviceId: number(),
17470
- trackId: string()
17471
- }), TrackSchema.nullable()), method(object({
17472
- deviceId: number(),
17473
- since: number().optional(),
17474
- until: number().optional(),
17475
- limit: number().optional(),
17476
- /** Spatial filter — only tracks whose trajectory intersects the zone
17477
- * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
17478
- * envelope columns, then precisely tested per position. Tracks with
17479
- * an unknown envelope (no frame dims at persist time) always match. */
17480
- zone: TrackZoneFilterSchema.optional(),
17481
- /** See {@link TrackProjectionSchema}. Default `full` (backward
17482
- * compatible — omitting the field keeps today's exact behaviour). */
17483
- projection: TrackProjectionSchema.optional(),
17484
- /** Include stationary-promoted rows (parked objects handed to the
17485
- * stationary registry). Default false: the timeline lists passages,
17486
- * not parking records (operator decision, 2026-08-15). */
17487
- includeStationary: boolean().optional()
17488
- }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
17489
- deviceId: number(),
17490
- groupId: string().min(1)
17491
- }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
17492
- kind: "mutation",
17493
- auth: "admin"
17494
- }), 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({
17495
- deviceId: number(),
17496
- since: number().optional(),
17497
- until: number().optional(),
17498
- kinds: array(string()).optional(),
17499
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
17500
- }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
17501
- deviceId: number(),
17502
- since: number(),
17503
- until: number(),
17504
- bucketMs: number().int().positive()
17505
- }), array(object({
17506
- bucketStart: number(),
17507
- motion: number().int(),
17508
- object: number().int(),
17509
- audio: number().int()
17510
- })).readonly()), method(object({
17511
- deviceId: number(),
17512
- cutoffMs: number()
17513
- }), object({
17514
- motion: number().int(),
17515
- object: number().int(),
17516
- audio: number().int()
17517
- }), {
17518
- kind: "mutation",
17519
- auth: "admin"
17520
- }), method(object({
17521
- deviceId: number(),
17522
- cutoffMs: number()
17523
- }), TrackCascadeCountsSchema, {
17524
- kind: "mutation",
17525
- auth: "admin"
17526
- }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
17527
- kind: "mutation",
17528
- auth: "admin"
17529
- }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
17530
- kind: "mutation",
17531
- auth: "admin"
17532
- }), method(object({
17533
- deviceId: number(),
17534
- trackIds: array(string()).min(1)
17535
- }), object({
17536
- deleted: number().int(),
17537
- failed: array(string()).readonly()
17538
- }), {
17539
- kind: "mutation",
17540
- auth: "admin"
17541
- }), method(object({
17542
- /** Log/audit scope only — the trackId is globally unique on its own. */
17366
+ /**
17367
+ * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
17368
+ * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
17369
+ * track and its events always answer the same question the same way.
17370
+ *
17371
+ * Two scalar columns, not an array: every consumer wants "the coarse one" or
17372
+ * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
17373
+ * is tier 2, and each carries its own score + attribution.
17374
+ *
17375
+ * **Reading it.** What a human should be shown is `subLabel ?? label` — the
17376
+ * finest thing known. Before 4g the single `label` column held the finest
17377
+ * value, so a consumer that has not been updated reads the tier-1 slot and
17378
+ * shows nothing on a species-only row; that is why the migration puts every
17379
+ * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
17380
+ * and why the read surfaces were changed in the same train.
17381
+ *
17382
+ * **Writing it.** The slots are independent, which is the whole point: a
17383
+ * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
17384
+ * migratorius`), so fineness cannot regress by construction. Within a tier the
17385
+ * higher score wins. One rule, one implementation — see
17386
+ * `pipeline/label-tier.ts` in addon-post-analysis.
17387
+ */
17388
+ var TieredLabelFields = {
17389
+ /** Tier 1 — the sub-class. See {@link LabelTierSchema}. */
17390
+ label: string().optional(),
17391
+ /** Confidence of the tier-1 value, as reported by the deciding step. */
17392
+ labelScore: number().optional(),
17393
+ /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
17394
+ labelMeta: LabelAttributionSchema.optional(),
17395
+ /** Tier 2 — the instance. See {@link LabelTierSchema}. */
17396
+ subLabel: string().optional(),
17397
+ /** Confidence of the tier-2 value, as reported by the deciding step. */
17398
+ subLabelScore: number().optional(),
17399
+ /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
17400
+ subLabelMeta: LabelAttributionSchema.optional()
17401
+ };
17402
+ /** Per-camera slice of a training-export estimate. */
17403
+ var TrainingExportDeviceTotalsSchema = object({
17543
17404
  deviceId: number(),
17405
+ tracks: number().int(),
17406
+ files: number().int(),
17407
+ bytes: number().int()
17408
+ });
17409
+ /**
17410
+ * What a training export WOULD contain. Computed from media index rows only —
17411
+ * no blob is read to produce this.
17412
+ */
17413
+ var TrainingExportSummarySchema = object({
17414
+ generatedAt: number(),
17415
+ trackCount: number().int(),
17416
+ fileCount: number().int(),
17417
+ byteCount: number().int(),
17418
+ /** More marked tracks exist than a single pass carries. */
17419
+ truncated: boolean(),
17420
+ devices: array(TrainingExportDeviceTotalsSchema).readonly()
17421
+ });
17422
+ var TrackSchema = object({
17544
17423
  trackId: string(),
17545
- flags: TrackFlagsPatchSchema
17546
- }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
17547
- kind: "query",
17548
- auth: "admin"
17549
- }), method(object({
17550
- olderThanMs: number(),
17551
- reason: OpsLogReasonSchema.optional()
17552
- }), EventPruneCountsSchema, {
17553
- kind: "mutation",
17554
- auth: "admin"
17555
- }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
17556
- kind: "mutation",
17557
- auth: "admin"
17558
- }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
17559
- kind: "mutation",
17560
- auth: "admin"
17561
- }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
17562
- kind: "mutation",
17563
- auth: "admin"
17564
- }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
17565
- kind: "mutation",
17566
- auth: "admin"
17567
- }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
17568
- kind: "mutation",
17569
- auth: "admin"
17570
- }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
17571
- kind: "mutation",
17572
- auth: "admin"
17573
- }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
17574
- kind: "query",
17575
- auth: "admin"
17576
- }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
17577
- kind: "query",
17578
- auth: "admin"
17579
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
17580
- kind: "query",
17581
- auth: "admin"
17582
- }), method(object({
17583
- /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
17584
- * `deviceId`, deliberately: `deviceId` would make this device-bound and
17585
- * route it at one camera's owner, and "every camera" would stop being
17586
- * expressible at all. */
17587
- deviceIds: array(number()).optional(),
17588
- limit: number().int().min(1).max(500).optional()
17589
- }), array(RetrainTrackSchema).readonly(), {
17590
- kind: "query",
17591
- auth: "admin"
17592
- }), method(object({ trackId: string() }), RetrainFrameListSchema, {
17593
- kind: "query",
17594
- auth: "admin"
17595
- }), method(object({
17596
17424
  deviceId: number(),
17597
- trackId: string(),
17598
- mediaKeys: array(string()).min(1)
17599
- }), RetrainFrameSelectionSchema, {
17600
- kind: "mutation",
17601
- auth: "admin"
17602
- }), method(object({
17425
+ className: string(),
17426
+ ...TieredLabelFields,
17427
+ producingDeviceName: string().optional(),
17428
+ /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
17429
+ source: TrackSourceSchema.optional(),
17430
+ firstSeen: number(),
17431
+ lastSeen: number(),
17432
+ /** Frame-rate position history (subject to maxPositionHistory cap). */
17433
+ positions: array(TrackPositionSchema).readonly(),
17434
+ /** Periodic snapshots at snapshotIntervalMs cadence (subject to
17435
+ * saveThumbnails policy). */
17436
+ snapshots: array(TrackSnapshotSchema).readonly(),
17437
+ /** Deduplicated zones the track has entered at least once. Zone IDS. */
17438
+ zonesVisited: array(string()).readonly(),
17439
+ /**
17440
+ * Human NAMES for {@link zonesVisited}, resolved at READ time against the
17441
+ * `zones` capability.
17442
+ *
17443
+ * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
17444
+ * and no card can render — so every free-text search surface was structurally
17445
+ * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
17446
+ * just returned nothing. Resolving here rather than in each client keeps ONE
17447
+ * derivation and costs the clients no extra call (the `zones` cap is
17448
+ * per-device, so a client-side resolve would be a per-camera fan-out on a
17449
+ * surface built to avoid exactly that).
17450
+ *
17451
+ * Resolved, never invented: a zone deleted since the track was written has no
17452
+ * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
17453
+ * two are not positionally aligned. Absent when the track visited no zone, or
17454
+ * when the zone catalogue could not be read.
17455
+ */
17456
+ zoneNames: array(string()).readonly().optional(),
17457
+ /** Deduplicated set of detector classes observed for this track over its
17458
+ * life (a track may be reclassified, e.g. person→vehicle). Absent on
17459
+ * legacy rows written before class accumulation shipped. */
17460
+ classes: array(string()).readonly().optional(),
17461
+ /** Cumulative normalized distance travelled (0..1 units = full frame width). */
17462
+ totalDistance: number(),
17463
+ state: TrackStateSchema,
17464
+ active: boolean(),
17465
+ /** Deterministic key-event importance score in [0,1] (server-computed at
17466
+ * track expiry, recomputed on late label). Absent on legacy rows written
17467
+ * before scoring shipped — consumers degrade to absence / compute-on-read. */
17468
+ importance: number().optional(),
17469
+ /** Id of the track's highest-confidence ObjectEvent (its representative
17470
+ * "best" frame). Absent when the track produced no object events. */
17471
+ bestEventId: string().optional(),
17472
+ /** Tag of the importance sub-signal that dominated the score
17473
+ * (identity|dwell|proximity|class|confidence|travel|zone). */
17474
+ importanceReason: string().optional(),
17475
+ /** Audio-classification labels heard on the camera during the track's
17476
+ * life (score ≥ device `classificationMinScore`), aggregated per label.
17477
+ * Absent on legacy rows / tracks with no confident audio. */
17478
+ audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
17479
+ /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
17480
+ * Populated from the persisted envelope columns on historical reads;
17481
+ * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
17482
+ envelope: TrackEnvelopeSchema.optional(),
17483
+ /**
17484
+ * A face DETECTOR found a face on this track — nothing more. It says the
17485
+ * detail plane produced a `face` detail; it does NOT say the face was
17486
+ * embedded, matched, above `minFacePx`, or that the recognizer was even
17487
+ * enabled. Set once and never cleared.
17488
+ *
17489
+ * **This exists so "face present but not recognised" is expressible.** A
17490
+ * recognised identity lands in `subLabel` (attributed to the face chain via
17491
+ * `subLabelMeta.stepId`), so before this field a track with an unmatched face
17492
+ * and a track with no face at all were byte-identical on the wire and no
17493
+ * surface could tell them apart. The read is `hasFace === true && subLabel
17494
+ * === undefined`.
17495
+ *
17496
+ * **Absent ≠ false.** Every row written before the column existed omits it,
17497
+ * and so does every server that predates the field — a consumer must test
17498
+ * `=== true` and render nothing otherwise, never infer "no face".
17499
+ */
17500
+ hasFace: boolean().optional(),
17501
+ /**
17502
+ * This track has a face row IN THE GALLERY: a crop **and** an embedding — a
17503
+ * face an operator could ASSIGN to an identity.
17504
+ *
17505
+ * The STRICT twin of {@link hasFace}, and the pair only earns its keep
17506
+ * because the two disagree. `hasFace` is stamped at the TOP of the face
17507
+ * branch, before every gate, and means no more than "a face detector produced
17508
+ * a face detail". This one is stamped at the single moment the gallery row
17509
+ * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
17510
+ * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
17511
+ * candidate gate, the imageless-track drop (no crop was ever captured) and
17512
+ * the crop-store drop. Everything between the detector and that insert can
17513
+ * legitimately refuse the face, so a flag written any earlier promises the
17514
+ * operator something to assign and delivers nothing.
17515
+ *
17516
+ * **Independent of recognition.** A face collected but never auto-matched is
17517
+ * still assignable — it is in fact the face an operator most wants to reach —
17518
+ * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
17519
+ * `subLabel`; this says only that the raw material exists.
17520
+ *
17521
+ * **Set once, never cleared.** A track that produced a gallery row produced
17522
+ * one; deleting the row later is the gallery's business, not this flag's.
17523
+ *
17524
+ * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
17525
+ * before the column omits it, and so does every server that predates the
17526
+ * field. A consumer must test `=== true` and render nothing otherwise —
17527
+ * never infer "no assignable face".
17528
+ */
17529
+ hasEmbeddedFace: boolean().optional(),
17530
+ /**
17531
+ * This subject CONTAINS a folded rider — a person the rider-pairing step
17532
+ * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
17533
+ * so the passage is tracked once and as a VEHICLE.
17534
+ *
17535
+ * It exists because the fold's record was dishonest. D34 and the code both
17536
+ * said "the person is not lost — it is reported so both entities stay on the
17537
+ * record"; in fact the pair went into a per-processor RAM field behind an
17538
+ * accessor nobody called, and every durable surface said `vehicle`, full
17539
+ * stop. This is the composition note that makes the row true.
17540
+ *
17541
+ * A COMPOSITION, never a class and never a label. "This vehicle contains a
17542
+ * person" is not an answer to "what is this" — both label tiers would refuse
17543
+ * a macro token anyway (D89), and correctly. Nothing here changes what the
17544
+ * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
17545
+ * and a `person` rule still does not fire for someone cycling past.
17546
+ *
17547
+ * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
17548
+ * the column, and every hub that predates the field, omits it. Test
17549
+ * `=== true` and render nothing otherwise — never infer "no rider".
17550
+ */
17551
+ hasRider: boolean().optional(),
17552
+ ...TrackFlagFields,
17553
+ ...TrackRetrainFields
17554
+ });
17555
+ var BaseEventFields = {
17556
+ id: string(),
17603
17557
  deviceId: number(),
17604
- trackId: string(),
17605
- frameId: string()
17606
- }), object({
17607
- removed: boolean(),
17608
- removedAnnotations: number().int()
17609
- }), {
17610
- kind: "mutation",
17611
- auth: "admin"
17612
- }), method(object({ frameId: string() }), object({
17558
+ timestamp: number()
17559
+ };
17560
+ var MotionEventSchema = object({
17561
+ ...BaseEventFields,
17562
+ kind: literal("motion"),
17563
+ regionCount: number(),
17564
+ /** Heavy JSON array — omitted in slim projection. */
17565
+ regions: array(object({
17566
+ bbox: BoundingBoxSchema,
17567
+ pixelCount: number(),
17568
+ intensity: number()
17569
+ })).readonly().optional(),
17570
+ /** Omitted in slim projection. */
17571
+ frameWidth: number().optional(),
17572
+ /** Omitted in slim projection. */
17573
+ frameHeight: number().optional(),
17574
+ /** Populated by B5 (recording playback URL for this event). */
17575
+ mediaUrl: string().optional()
17576
+ });
17577
+ /**
17578
+ * Which detection SOURCE produced an object event. `pipeline` = the ML
17579
+ * detection pipeline (decoded-frame inference); `onboard` = the camera's
17580
+ * native on-device AI. Both flow through the SAME analysis layers (zoning,
17581
+ * tracking, per-kind persistence) but stay distinguishable so consumers
17582
+ * (advanced-notifier, occupancy, …) can select which source(s) to act on.
17583
+ * Absent on legacy rows ⇒ treat as `pipeline`.
17584
+ */
17585
+ var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
17586
+ /**
17587
+ * The confirmed zone crossing that produced an object event. Present ONLY on
17588
+ * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
17589
+ * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
17590
+ * appearance event carry none, so a rule asking for a direction fails closed
17591
+ * on them.
17592
+ *
17593
+ * Exactly ONE crossing per event: the emitter turns each confirmed crossing
17594
+ * into its own event, so a frame in which a track enters A while leaving B
17595
+ * produces two events with two directions — never one ambiguous row.
17596
+ *
17597
+ * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
17598
+ * membership the box has NOW, and by definition it no longer contains the zone
17599
+ * that was just left. Without the id here, a zone-scoped rule could never match
17600
+ * the exit it asked for.
17601
+ */
17602
+ var ZoneCrossingSchema = object({
17603
+ direction: _enum(["enter", "exit"]),
17604
+ /** Admin zone id crossed. */
17605
+ zoneId: string(),
17606
+ /** Zone display name at crossing time (falls back to the id). */
17607
+ zoneName: string().optional()
17608
+ });
17609
+ var ObjectEventSchema = object({
17610
+ ...BaseEventFields,
17611
+ kind: literal("object"),
17612
+ /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
17613
+ source: DetectionSourceSchema.optional(),
17614
+ /**
17615
+ * Inference-frame id shared by every object event emitted from the SAME frame
17616
+ * — the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
17617
+ * 2 people + 1 dog) under one full frame, and link a track's frames over time
17618
+ * (group by `trackId`, pick a representative `frameId` as the parent frame).
17619
+ * Optional for backward-compat with pre-existing rows / the slim projection
17620
+ * includes it (it is light). Absent on rows written before this field.
17621
+ */
17622
+ frameId: string().optional(),
17623
+ /** Omitted in slim projection. */
17624
+ trackId: string().optional(),
17625
+ className: string(),
17626
+ ...TieredLabelFields,
17627
+ /** Omitted in slim projection. */
17628
+ confidence: number().optional(),
17629
+ /** Heavy JSON — omitted in slim projection. */
17630
+ bbox: BoundingBoxSchema.optional(),
17631
+ /** Heavy JSON — omitted in slim projection. */
17632
+ zones: array(string()).readonly().optional(),
17633
+ /** Omitted in slim projection. */
17634
+ state: TrackStateSchema.optional(),
17635
+ /**
17636
+ * The zone crossing this event IS, when it is one. Absent on every other
17637
+ * event kind (movement state, appearance, package) — see
17638
+ * {@link ZoneCrossingSchema}. Omitted in slim projection.
17639
+ */
17640
+ zoneCrossing: ZoneCrossingSchema.optional(),
17641
+ /** Detection-frame dimensions in pixels — let consumers normalize the
17642
+ * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
17643
+ frameWidth: number().optional(),
17644
+ frameHeight: number().optional(),
17645
+ /** MediaStore key for the crop attached to this event (if any). */
17646
+ mediaKey: string().optional(),
17647
+ /** Design B: MediaStore key of the track's native-resolution key frame (the
17648
+ * best-detection full frame). Resolve via the event-media data-plane
17649
+ * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
17650
+ * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
17651
+ * sources — consumers fall back to `mediaKey` (the tight crop). */
17652
+ keyFrameMediaKey: string().optional(),
17653
+ /** Populated by B5 (recording playback URL for this event). */
17654
+ mediaUrl: string().optional(),
17655
+ /** The parent track's key-event importance [0,1], propagated to every object
17656
+ * event of the track (so an event row can be sorted by importance without a
17657
+ * track join). Absent on legacy rows / before the track was scored. */
17658
+ importance: number().optional()
17659
+ });
17660
+ var AudioEventSchema = object({
17661
+ ...BaseEventFields,
17662
+ kind: literal("audio"),
17663
+ rms: number(),
17664
+ dbfs: number(),
17665
+ classification: object({
17666
+ className: string(),
17667
+ originalClass: string().optional(),
17668
+ score: number()
17669
+ }).optional(),
17670
+ /** Populated by B5 (recording playback URL for this event). */
17671
+ mediaUrl: string().optional()
17672
+ });
17673
+ var MediaFileKindEnum = _enum([
17674
+ "crop",
17675
+ "thumbnail",
17676
+ "snapshot",
17677
+ "firstFrame",
17678
+ "lastFrame",
17679
+ "fullFrame",
17680
+ "fullFrameBoxed",
17681
+ "faceCrop",
17682
+ "plateCrop",
17683
+ "keyFrame",
17684
+ "keyFrameSmall",
17685
+ "thumbnailSmall"
17686
+ ]);
17687
+ var MediaFileSchema = object({
17688
+ key: string(),
17689
+ kind: MediaFileKindEnum,
17613
17690
  base64: string(),
17614
- width: number().int(),
17615
- height: number().int()
17616
- }), {
17617
- kind: "query",
17618
- auth: "admin"
17619
- }), method(object({
17620
- deviceId: number(),
17621
- trackId: string(),
17622
- frameId: string(),
17623
- subject: RetrainAssistSubjectSchema,
17624
- /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
17625
- nodeId: string().optional()
17626
- }), RetrainAssistResultSchema, {
17627
- kind: "mutation",
17628
- auth: "admin"
17629
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
17630
- kind: "query",
17631
- auth: "admin"
17632
- }), method(object({
17633
- deviceId: number(),
17691
+ sizeBytes: number(),
17692
+ timestamp: number()
17693
+ });
17694
+ /**
17695
+ * One media row WITHOUT its bytes.
17696
+ *
17697
+ * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
17698
+ * 140 s track), and a client that renders tiles from the media data plane needs
17699
+ * to know only WHAT EXISTS — the bytes then arrive per tile, lazily, over HTTP
17700
+ * with an immutable cache, instead of all at once inside a tRPC response that
17701
+ * blocks the whole view.
17702
+ *
17703
+ * `sizeBytes` is carried because it is what lets a client decide between the
17704
+ * stored blob and a `?variant=thumb` rendering without fetching either.
17705
+ */
17706
+ var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
17707
+ /**
17708
+ * The MACRO tier of an annotation — a CLOSED set.
17709
+ *
17710
+ * This is what the exported detector predicts, so a typo here is a new class
17711
+ * with one example in it. `label` and `subLabel` are open strings by contrast:
17712
+ * the whole point of the page is teaching the model things it does not know
17713
+ * yet, and constraining that vocabulary would make it useless.
17714
+ *
17715
+ * A macro class is NEVER a label. The provider refuses a write whose `label` or
17716
+ * `subLabel` is one of these values, in any casing, because once `person`
17717
+ * exists in both tiers "every person box" stops being answerable without
17718
+ * knowing every string anyone ever typed — and the damage is retroactive.
17719
+ */
17720
+ var RetrainMacroClassSchema = _enum([
17721
+ "person",
17722
+ "vehicle",
17723
+ "animal",
17724
+ "package",
17725
+ "face",
17726
+ "plate"
17727
+ ]);
17728
+ /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
17729
+ var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
17730
+ /** Did a human draw this box, or did the assist propose it? */
17731
+ var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
17732
+ /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
17733
+ var RetrainBboxSchema = object({
17734
+ x: number(),
17735
+ y: number(),
17736
+ w: number(),
17737
+ h: number()
17738
+ });
17739
+ /**
17740
+ * One annotated subject.
17741
+ *
17742
+ * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
17743
+ * (letterboxed root / zone-cropped package / subject-cropped classifier) are
17744
+ * derived from it at export and never stored — storing them is how one feature
17745
+ * space ends up holding two crops of the same subject (D52).
17746
+ */
17747
+ var RetrainAnnotationSchema = object({
17748
+ id: string(),
17634
17749
  trackId: string(),
17635
- frameId: string(),
17636
- annotations: array(RetrainAnnotationDraftSchema)
17637
- }), array(RetrainAnnotationSchema).readonly(), {
17638
- kind: "mutation",
17639
- auth: "admin"
17640
- }), method(object({
17641
- deviceId: number(),
17642
- trackId: string()
17643
- }), RetrainTransitionResultSchema, {
17644
- kind: "mutation",
17645
- auth: "admin"
17646
- }), method(object({
17647
17750
  deviceId: number(),
17648
- trackId: string()
17649
- }), RetrainTransitionResultSchema, {
17650
- kind: "mutation",
17651
- auth: "admin"
17652
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
17653
- kind: "query",
17654
- auth: "admin"
17655
- }), method(object({
17656
- eventId: string(),
17657
- kind: MediaFileKindEnum.optional(),
17658
- deviceId: number()
17659
- }), array(MediaFileSchema).readonly()), method(object({
17660
- trackId: string(),
17661
- kinds: array(MediaFileKindEnum).optional(),
17662
- deviceId: number()
17663
- }), array(MediaFileSchema).readonly()), method(object({
17751
+ /** The COPY in retrain storage — never the source track's media key. */
17752
+ mediaKey: string(),
17753
+ bbox: RetrainBboxSchema,
17754
+ macroClass: RetrainMacroClassSchema,
17755
+ label: string().optional(),
17756
+ subLabel: string().optional(),
17757
+ kind: RetrainAnnotationKindSchema,
17758
+ source: RetrainAnnotationSourceSchema,
17759
+ /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
17760
+ assistModelId: string().optional(),
17761
+ assistScore: number().optional(),
17762
+ exportedInBatch: string().optional(),
17763
+ createdAt: number()
17764
+ });
17765
+ /** The write form — the server owns `id`, `createdAt` and the frame binding. */
17766
+ var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
17767
+ id: true,
17768
+ trackId: true,
17769
+ deviceId: true,
17770
+ mediaKey: true,
17771
+ createdAt: true,
17772
+ exportedInBatch: true
17773
+ });
17774
+ /** A track sitting in `staging`, with everything the worklist needs to rank it. */
17775
+ var RetrainTrackSchema = object({
17664
17776
  trackId: string(),
17665
- deviceId: number()
17666
- }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
17667
- kind: "mutation",
17668
- auth: "admin"
17669
- }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
17670
- kind: "mutation",
17671
- auth: "admin"
17672
- }), method(object({}), RebuildStatusSchema), object({
17673
17777
  deviceId: number(),
17778
+ className: string(),
17779
+ label: string().optional(),
17780
+ firstSeen: number(),
17781
+ lastSeen: number(),
17782
+ /** How many frames the dataset already holds from this track. */
17783
+ frameCount: number().int(),
17784
+ /** How many subjects have been annotated on those frames. `0` with
17785
+ * `frameCount: 0` is exactly "staging, still to work". */
17786
+ annotationCount: number().int()
17787
+ });
17788
+ /** A frame the picker may offer — an index row, no blob was read to produce it. */
17789
+ var RetrainFrameCandidateSchema = object({
17790
+ mediaKey: string(),
17791
+ kind: MediaFileKindEnum,
17674
17792
  timestamp: number(),
17675
- frameWidth: number(),
17676
- frameHeight: number(),
17677
- detections: array(OverlayDetectionSchema).readonly()
17678
- }), object({
17793
+ sizeBytes: number().int(),
17794
+ /** A copy of this original already exists — selecting it is free and cannot
17795
+ * fail, whatever became of the original. */
17796
+ copied: boolean()
17797
+ });
17798
+ /** A frame the dataset OWNS: bytes copied at selection time. */
17799
+ var RetrainFrameSchema = object({
17800
+ frameId: string(),
17679
17801
  deviceId: number(),
17680
17802
  trackId: string(),
17681
- className: string()
17803
+ /** Provenance only. It may already point at nothing — that is expected. */
17804
+ sourceMediaKey: string(),
17805
+ sourceKind: MediaFileKindEnum,
17806
+ sizeBytes: number().int(),
17807
+ width: number().int(),
17808
+ height: number().int(),
17809
+ copiedAt: number()
17810
+ });
17811
+ /** Why a copy-on-select could not be honoured — named, never a silent skip. */
17812
+ var RetrainCopyRefusalSchema = _enum([
17813
+ "source-missing",
17814
+ "unreadable-image",
17815
+ "write-failed"
17816
+ ]);
17817
+ var RetrainFrameSelectionSchema = object({
17818
+ copied: array(RetrainFrameSchema).readonly(),
17819
+ refused: array(object({
17820
+ sourceMediaKey: string(),
17821
+ reason: RetrainCopyRefusalSchema
17822
+ })).readonly()
17823
+ });
17824
+ var RetrainFrameListSchema = object({
17825
+ candidates: array(RetrainFrameCandidateSchema).readonly(),
17826
+ copies: array(RetrainFrameSchema).readonly(),
17827
+ /** What the page pre-selects — the native key frame when one survives. */
17828
+ autoPickMediaKey: string().optional()
17829
+ });
17830
+ /** What the operator asked the assist to look for. */
17831
+ var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
17832
+ kind: literal("package"),
17833
+ zone: RetrainBboxSchema.optional()
17682
17834
  }), object({
17683
- deviceId: number(),
17684
- trackId: string(),
17685
- className: string(),
17686
- durationMs: number()
17835
+ kind: literal("objects"),
17836
+ modelId: string(),
17837
+ minScore: number().optional()
17838
+ })]);
17839
+ /**
17840
+ * The assist's answer — a discriminated union, because "the model saw nothing"
17841
+ * and "this node cannot run that model" lead to different next moves and a
17842
+ * nullable result cannot tell them apart.
17843
+ */
17844
+ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
17845
+ kind: literal("proposed"),
17846
+ modelId: string(),
17847
+ stepId: string(),
17848
+ minScore: number(),
17849
+ /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
17850
+ proposals: array(RetrainAnnotationDraftSchema).readonly(),
17851
+ /** Returned by the runner but removed by the threshold. */
17852
+ belowThreshold: number().int()
17687
17853
  }), object({
17854
+ kind: literal("refused"),
17855
+ /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
17856
+ reason: string(),
17857
+ detail: string().optional()
17858
+ })]);
17859
+ /** The outcome of a lifecycle move owned by the retrain page. */
17860
+ var RetrainTransitionResultSchema = object({
17861
+ trackId: string(),
17862
+ /** Where the track ended up, whatever happened. */
17863
+ retrainStatus: RetrainStatusSchema,
17864
+ /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
17865
+ changed: boolean(),
17866
+ reason: _enum([
17867
+ "unknown-track",
17868
+ "no-frames-copied",
17869
+ "not-staging",
17870
+ "not-trained",
17871
+ "unchanged"
17872
+ ]).optional()
17873
+ });
17874
+ var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
17875
+ var MAX_EVENT_QUERY_LIMIT = 5e3;
17876
+ var DeviceEventQueryInput = object({
17688
17877
  deviceId: number(),
17689
- kind: EventKindSchema,
17690
- eventId: string(),
17691
- timestamp: number()
17878
+ since: number().optional(),
17879
+ until: number().optional(),
17880
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
17881
+ /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
17882
+ * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
17883
+ * exact behaviour. Callers may omit this field — the store defaults to
17884
+ * `full` when not provided. */
17885
+ projection: _enum(["full", "slim"]).optional()
17692
17886
  });
17693
- /**
17694
- * Reference to the frame's retained NATIVE surface + the parent crop's placement
17695
- * within the frame, so the executor can re-cut a leaf child ROI at native
17696
- * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
17697
- */
17698
- var NativeCropRefSchema = object({
17699
- /** Handle keying the retained native surface (node-pinned to its owner). */
17700
- handle: FrameHandleSchema,
17701
- /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
17702
- cropFrameSpace: object({
17703
- x: number(),
17704
- y: number(),
17705
- w: number(),
17706
- h: number()
17707
- })
17887
+ var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
17888
+ var RecentTracksQueryInput = object({
17889
+ /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
17890
+ deviceIds: array(number()),
17891
+ /** Window lower bound on `lastSeen` (inclusive). */
17892
+ since: number().optional(),
17893
+ /** Window upper bound on `lastSeen` (inclusive). */
17894
+ until: number().optional(),
17895
+ /** Page size. Default 200, max 1000. */
17896
+ limit: number().int().min(1).max(1e3).default(200),
17897
+ /** Opaque continuation cursor from a previous page's `nextCursor`.
17898
+ * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
17899
+ cursor: string().optional(),
17900
+ /** See {@link TrackProjectionSchema}. Default `full`. */
17901
+ projection: TrackProjectionSchema.optional(),
17902
+ /** Include stationary-promoted rows (parked objects). Default false: the
17903
+ * feed lists passages; parking records live on the stationary registry. */
17904
+ includeStationary: boolean().optional()
17708
17905
  });
17709
- object({
17710
- crop: object({
17711
- left: number(),
17712
- top: number(),
17713
- width: number().positive(),
17714
- height: number().positive()
17715
- }).optional(),
17716
- content: object({
17717
- width: number().int().positive(),
17718
- height: number().int().positive()
17719
- }),
17720
- fit: _enum(["stretch", "contain"]),
17721
- format: _enum([
17722
- "rgb",
17723
- "gray",
17724
- "jpeg"
17725
- ])
17906
+ var RecentTracksPageSchema = object({
17907
+ /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
17908
+ tracks: array(TrackSchema).readonly(),
17909
+ /** Cursor for the next page, or null when this page is the last. */
17910
+ nextCursor: string().nullable()
17726
17911
  });
17727
- var FrameRefSchema = object({
17728
- registryId: string().min(1),
17729
- id: string().min(1),
17730
- width: number().int().positive(),
17731
- height: number().int().positive(),
17732
- format: _enum(["rgb", "gray"]),
17733
- timestamp: number(),
17734
- capturedAt: number().optional()
17912
+ var LIST_GROUPS_DEFAULT_LIMIT = 40;
17913
+ var LIST_GROUPS_MAX_LIMIT = 100;
17914
+ var AnalyticsGroupRecordSchema = object({
17915
+ id: string(),
17916
+ deviceId: number().int(),
17917
+ openedAt: number().int(),
17918
+ closedAt: number().int(),
17919
+ timestamp: number().int(),
17920
+ memberCount: number().int(),
17921
+ memberTrackIds: array(string()).readonly(),
17922
+ className: string(),
17923
+ classes: array(string()).readonly(),
17924
+ /** Relative event-media path, or null when the group has no picture yet. */
17925
+ mediaUrl: string().nullable(),
17926
+ singleton: boolean()
17735
17927
  });
17736
- var ModelFormatSchema$1 = _enum([
17737
- "onnx",
17738
- "coreml",
17739
- "openvino",
17740
- "tflite",
17741
- "pt",
17742
- "gguf"
17743
- ]);
17744
- var PipelineSlotSchema = _enum([
17745
- "detector",
17746
- "cropper",
17747
- "classifier",
17748
- "refiner",
17749
- "audio-classifier"
17750
- ]);
17751
- var PipelineEngineChoiceSchema = object({
17752
- runtime: _enum(["node", "python"]),
17753
- backend: string(),
17754
- format: ModelFormatSchema$1,
17755
- device: string().optional()
17928
+ var AnalyticsGroupMemberSchema = object({
17929
+ trackId: string(),
17930
+ deviceId: number().int(),
17931
+ className: string(),
17932
+ firstSeen: number().int(),
17933
+ lastSeen: number().int(),
17934
+ mediaUrl: string().nullable()
17756
17935
  });
17757
- var AvailableEngineSchema = object({
17758
- engine: PipelineEngineChoiceSchema,
17759
- devices: array(object({
17760
- id: string(),
17761
- label: string(),
17762
- description: string().optional()
17763
- })).readonly(),
17764
- defaultDevice: string()
17936
+ var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
17937
+ var ListGroupsQueryInput = object({
17938
+ /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
17939
+ deviceIds: array(number()),
17940
+ /** Window lower bound on `closedAt` (inclusive). */
17941
+ since: number().optional(),
17942
+ /** Window upper bound on `openedAt` (inclusive). */
17943
+ until: number().optional(),
17944
+ limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
17945
+ /** Opaque continuation cursor from a previous page's `nextCursor`. */
17946
+ cursor: string().optional()
17765
17947
  });
17766
- var PipelineDefaultStepSchema = lazy(() => object({
17767
- addonId: string(),
17768
- addonName: string(),
17769
- slot: PipelineSlotSchema,
17770
- inputClasses: array(string()).readonly(),
17771
- outputClasses: array(string()).readonly(),
17772
- enabled: boolean(),
17773
- modelId: string(),
17774
- children: array(PipelineDefaultStepSchema).readonly(),
17775
- group: string().optional(),
17776
- settings: record(string(), unknown()).optional()
17777
- }));
17778
- var PipelineTemplateStepSchema = lazy(() => object({
17779
- addonId: string(),
17780
- enabled: boolean(),
17781
- modelId: string(),
17782
- children: array(PipelineTemplateStepSchema).readonly(),
17783
- settings: record(string(), unknown()).optional()
17784
- }));
17785
- var PipelineTemplateSchema$1 = object({
17786
- id: string(),
17787
- name: string(),
17788
- createdAt: string(),
17789
- updatedAt: string(),
17790
- engine: PipelineEngineChoiceSchema,
17791
- steps: array(PipelineTemplateStepSchema).readonly()
17948
+ var ListGroupsPageSchema = object({
17949
+ groups: array(AnalyticsGroupRecordSchema).readonly(),
17950
+ nextCursor: string().nullable()
17951
+ });
17952
+ var KeyEventQueryInput = object({
17953
+ deviceId: number(),
17954
+ /** Window lower bound (track firstSeen ≥ since). */
17955
+ since: number(),
17956
+ /** Window upper bound (track firstSeen ≤ until). */
17957
+ until: number(),
17958
+ limit: number().int().min(1).max(200).default(50),
17959
+ /** Drop tracks scoring below this importance. */
17960
+ minImportance: number().min(0).max(1).optional(),
17961
+ /** Restrict to a single class (e.g. 'person'). */
17962
+ classFilter: string().optional()
17792
17963
  });
17793
- var PipelineModelOptionSchema = object({
17964
+ var KeyEventSchema = object({
17965
+ /** The representative event id (the track's best ObjectEvent, else its trackId). */
17794
17966
  id: string(),
17795
- name: string(),
17796
- formats: record(string(), object({
17797
- downloaded: boolean(),
17798
- sizeMB: number()
17799
- })),
17800
- group: ModelVariantGroupSchema.optional(),
17801
- legacy: boolean().optional(),
17802
- provider: ModelProviderIdSchema.optional()
17967
+ trackId: string(),
17968
+ /** Track start time (firstSeen). */
17969
+ timestamp: number(),
17970
+ className: string(),
17971
+ ...TieredLabelFields,
17972
+ importance: number(),
17973
+ /** Highest-confidence ObjectEvent id for the track (empty when none). */
17974
+ bestEventId: string(),
17975
+ /** Track lifetime in ms (lastSeen - firstSeen). */
17976
+ windowMs: number().optional(),
17977
+ ...TrackFlagFields,
17978
+ ...TrackRetrainFields
17803
17979
  });
17804
- var ConfigFieldBridge = custom();
17805
- var PipelineAddonSchemaSchema = object({
17806
- id: string(),
17807
- name: string(),
17808
- slot: PipelineSlotSchema,
17809
- inputClasses: array(string()).readonly(),
17810
- outputClasses: array(string()).readonly(),
17811
- childSlots: array(PipelineSlotSchema).readonly(),
17812
- models: array(PipelineModelOptionSchema).readonly(),
17813
- defaultModelId: string(),
17814
- defaultModelIdByFormat: record(string(), string()).optional(),
17815
- enabledByDefault: boolean().optional(),
17816
- backfillIntoExistingOverrides: boolean().optional(),
17817
- defaultConfidence: number(),
17818
- group: string().optional(),
17819
- configSchema: array(ConfigFieldBridge).readonly().optional()
17980
+ object({
17981
+ trackId: string(),
17982
+ className: string(),
17983
+ confidence: number(),
17984
+ bbox: BoundingBoxSchema,
17985
+ zones: array(string()).readonly(),
17986
+ state: TrackStateSchema
17820
17987
  });
17821
- var PipelineSlotSchemaSchema = object({
17822
- id: PipelineSlotSchema,
17823
- label: string(),
17824
- priority: number(),
17825
- parentSlot: PipelineSlotSchema.nullable(),
17826
- addons: array(PipelineAddonSchemaSchema).readonly()
17988
+ var OverlayDetectionSchema = looseObject({
17989
+ id: string(),
17990
+ kind: _enum(["first-level", "detail"]),
17991
+ macroClass: string(),
17992
+ score: number(),
17993
+ bbox: object({
17994
+ x: number(),
17995
+ y: number(),
17996
+ width: number(),
17997
+ height: number()
17998
+ }),
17999
+ labels: array(looseObject({
18000
+ label: string(),
18001
+ score: number()
18002
+ })).readonly(),
18003
+ parentId: string().optional()
17827
18004
  });
17828
- var PipelineSchemaSchema = object({
17829
- availableEngines: array(AvailableEngineSchema).readonly(),
17830
- selectedEngine: PipelineEngineChoiceSchema,
17831
- slots: array(PipelineSlotSchemaSchema).readonly()
18005
+ var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
18006
+ var SearchObjectEventsInput = object({
18007
+ text: string(),
18008
+ deviceId: number().optional(),
18009
+ since: number().optional(),
18010
+ until: number().optional(),
18011
+ classFilter: string().optional(),
18012
+ limit: number().default(50),
18013
+ minScore: number().min(0).max(1).default(.2)
17832
18014
  });
17833
- var EngineProvisioningSchema = object({
17834
- runtimeId: _enum([
17835
- "onnx",
17836
- "openvino",
17837
- "coreml",
17838
- "edgetpu"
17839
- ]).nullable(),
17840
- device: string().nullable(),
17841
- state: _enum([
17842
- "idle",
17843
- "installing",
17844
- "verifying",
17845
- "ready",
17846
- "failed"
17847
- ]),
17848
- progress: number().optional(),
17849
- error: string().optional(),
17850
- nextRetryAt: number().optional(),
17851
- /**
17852
- * Gate A (config-correctness gate at engine change): human-readable
17853
- * config issues surfaced EAGERLY when the node's engine changes — model
17854
- * substitutions ("chose X, running Y") and zero-build steps ("no model
17855
- * has a <format> build"). Additive/optional: informational only, never
17856
- * enforced here — `assertEngineReady` (readiness) still gates inference.
17857
- * Absent/empty when the node-default tree resolves cleanly.
17858
- */
17859
- configIssues: array(string()).optional()
18015
+ var TrackCascadeCountsSchema = object({
18016
+ /** Persisted track roots deleted (authoritative). */
18017
+ tracks: number().int(),
18018
+ /** Object events removed with their tracks (best-effort; see note above). */
18019
+ events: number().int(),
18020
+ /** Track/face/plate-owned media removed (best-effort). Never identity media. */
18021
+ media: number().int(),
18022
+ /** Unassigned (non-enrolled) face reads removed (best-effort). */
18023
+ faces: number().int(),
18024
+ /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
18025
+ plates: number().int(),
18026
+ /** Per-track CLIP search vectors removed (best-effort). */
18027
+ embeddings: number().int(),
18028
+ /** Group membership + group rows removed with their last member (best-effort). */
18029
+ groups: number().int()
17860
18030
  });
17861
- var PipelineStepInputSchema = lazy(() => object({
17862
- addonId: string(),
17863
- modelId: string().optional(),
17864
- enabled: boolean().default(true),
17865
- children: array(PipelineStepInputSchema).optional(),
17866
- settings: record(string(), unknown()).optional(),
17867
- jumpDeviceKey: string().optional()
17868
- }));
17869
- var ModelSubstitutionSchema = object({
17870
- addonId: string(),
17871
- chosen: string(),
17872
- running: string(),
17873
- format: string()
18031
+ /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
18032
+ var DiskReconcileCountsSchema = object({
18033
+ mediaDropped: number().int(),
18034
+ tracks: number().int(),
18035
+ events: number().int()
17874
18036
  });
17875
- var PipelineValidationIssueSchema = object({
17876
- addonId: string(),
17877
- kind: _enum(["unknown-addon", "no-format-build"]),
17878
- detail: string()
18037
+ /** Event-store footprint for one camera. */
18038
+ var EventStoreDeviceFootprintSchema = object({
18039
+ deviceId: number(),
18040
+ /** Persisted event rows (motion + object + audio) for the camera. */
18041
+ rows: number().int(),
18042
+ /** Event-owned media bytes on disk for the camera. */
18043
+ bytes: number().int()
17879
18044
  });
17880
- var PipelineValidationResultSchema = object({
17881
- ok: boolean(),
17882
- issues: array(PipelineValidationIssueSchema).readonly(),
17883
- substitutions: array(ModelSubstitutionSchema).readonly(),
17884
- /** The node's `currentEngine.format` this validation ran against. */
17885
- format: string()
18045
+ /** Aggregate event-store footprint: global totals + per-camera breakdown. */
18046
+ var EventStoreFootprintSchema = object({
18047
+ totalRows: number().int(),
18048
+ totalBytes: number().int(),
18049
+ devices: array(EventStoreDeviceFootprintSchema).readonly()
17886
18050
  });
17887
- var ReferenceImageEntrySchema = object({
17888
- filename: string(),
17889
- stepIds: array(string()).readonly().optional()
18051
+ /** Per-kind counts returned by the event-prune / device-delete mutations. */
18052
+ var EventPruneCountsSchema = object({
18053
+ motion: number().int(),
18054
+ object: number().int(),
18055
+ audio: number().int()
17890
18056
  });
17891
- var ReferenceImageBodySchema = object({
17892
- base64: string(),
17893
- filename: string()
18057
+ /**
18058
+ * Re-embed stored tracks from their key frames.
18059
+ *
18060
+ * The reason this is an operator-callable method and not a migration script:
18061
+ * every knob that decides what a vector MEANS — encoder model, crop margin,
18062
+ * squaring — is only changeable if the existing vectors can be regenerated.
18063
+ * Mixing feature spaces in one index makes cosine scores incomparable, and the
18064
+ * symptom is a quality regression with no visible cause.
18065
+ */
18066
+ var RebuildObjectEmbeddingsInput = object({
18067
+ /** Restrict to one camera. Omit for the whole fleet. */
18068
+ deviceId: number().optional(),
18069
+ since: number().optional(),
18070
+ until: number().optional(),
18071
+ /** Stop after this many tracks; the result reports whether more remain. */
18072
+ maxTracks: number().int().positive().optional(),
18073
+ /**
18074
+ * Run every embedding on THIS node instead of round-robining the fleet.
18075
+ *
18076
+ * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
18077
+ * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
18078
+ * calling it that would pin the rebuild REQUEST itself to that node — the
18079
+ * rebuild orchestration lives on the hub, and only the per-track step runs
18080
+ * remotely. This field is data; the per-track pin is applied inside.
18081
+ *
18082
+ * Absent ⇒ round-robin over every online node whose runner can serve the
18083
+ * pinned model.
18084
+ */
18085
+ executeOnNodeId: string().optional(),
18086
+ /**
18087
+ * Milliseconds to wait between tracks; omit for the built-in default, `0` to
18088
+ * run flat out.
18089
+ *
18090
+ * A rebuild is bulk maintenance on hub-main's single thread. Measured
18091
+ * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
18092
+ * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
18093
+ * force is logged at start and finish so a deliberately slow pass reads
18094
+ * differently from a stalled one.
18095
+ */
18096
+ pacingMs: number().int().nonnegative().optional()
17894
18097
  });
17895
- var ReferenceAudioEntrySchema = object({
17896
- filename: string(),
17897
- sizeKb: number()
18098
+ /**
18099
+ * Result of emptying the CLIP index.
18100
+ *
18101
+ * The clean slate before a policy change: a new crop margin or encoder model
18102
+ * leaves two feature spaces in one index whose cosine scores are not
18103
+ * comparable, so wiping and rebuilding is the only way to be sure every vector
18104
+ * means the same thing.
18105
+ */
18106
+ var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
18107
+ /**
18108
+ * Acknowledgement that a rebuild STARTED.
18109
+ *
18110
+ * The pass costs ~1s per track — 45 minutes for a 2,600-track fleet — so it
18111
+ * runs detached and this returns immediately. Waiting for it made the client
18112
+ * time out while the work carried on server-side, which is the worst of both:
18113
+ * no result and no way to know it was still going. Poll
18114
+ * `getObjectEmbeddingRebuildStatus` for progress.
18115
+ */
18116
+ var RebuildObjectEmbeddingsResultSchema = object({
18117
+ started: boolean(),
18118
+ /** True when a pass was already running; the new request is ignored. */
18119
+ alreadyRunning: boolean()
17898
18120
  });
17899
- var ReferenceAudioBodySchema = object({ base64: string() });
17900
- var AudioBackendSchema = object({
17901
- id: string(),
17902
- name: string(),
17903
- description: string(),
17904
- available: boolean(),
18121
+ var RebuildStatusSchema = object({
18122
+ running: boolean(),
18123
+ scanned: number(),
18124
+ rebuilt: number(),
18125
+ /** Tracks whose key frame is gone — nothing to re-embed from. */
18126
+ missingKeyFrame: number(),
18127
+ /** Tracks with no usable detection box. */
18128
+ missingBbox: number(),
18129
+ /**
18130
+ * Tracks an executing node REFUSED rather than broke on — an unreadable key
18131
+ * frame, a step that threw. Separate from `failed` because the remedy is
18132
+ * different, and because a whole camera silently contributing zero vectors
18133
+ * is the shape of failure a rebuild must never hide.
18134
+ */
18135
+ notRunnable: number(),
17905
18136
  /**
17906
- * Raw classifier labels this backend can emit (e.g. YAMNet's
17907
- * 521-class set or Apple SoundAnalysis's 303-class set). Used by
17908
- * the benchmark UI to populate the `enabledMicroClasses` filter
17909
- * specific to the selected backend without a separate fetch.
18137
+ * The pass stopped because NO node could serve the pinned model.
18138
+ *
18139
+ * Distinct from `notRunnable` on purpose: that one says "this track was
18140
+ * refused", this one says "the cluster cannot do this work at all" — every
18141
+ * candidate node either lacks the `clip-embedding` step, lacks a build of the
18142
+ * pinned model for its engine format, or dropped out. The remedy is a model /
18143
+ * engine change, not a per-camera one. Non-zero here always comes with
18144
+ * `complete: false`.
17910
18145
  */
17911
- rawLabels: array(string()).readonly().optional()
17912
- });
17913
- var AudioCapabilitiesSchema = object({
17914
- activeBackend: string(),
17915
- availableBackends: array(AudioBackendSchema).readonly(),
17916
- sampleRate: number(),
17917
- chunkDurationMs: number()
17918
- });
17919
- var DownloadModelResultSchema = object({
17920
- filePath: string(),
17921
- sizeMB: number(),
17922
- durationMs: number()
18146
+ noCapableNode: number(),
18147
+ failed: number(),
18148
+ /** Set once a pass ends: true only when EVERYTHING was covered. */
18149
+ complete: boolean().nullable(),
18150
+ startedAtMs: number().nullable(),
18151
+ finishedAtMs: number().nullable(),
18152
+ /** Present when the pass ended by throwing. */
18153
+ error: string().nullable()
17923
18154
  });
17924
- /**
17925
- * Wrapper carrying a single test run's result. Replaces the legacy
17926
- * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
17927
- * canonical `AudioResult` from the Phase 6 output rework: one
17928
- * `AudioDetection` per class above `minScore`, top-N candidates in
17929
- * `debug.alternateLabels['audio-classifier']`, per-source timings in
17930
- * `debug.stepTimings`. The outer `success`/`error` fields stay so the
17931
- * benchmark UI can still report a clean failure when the classifier
17932
- * cap isn't available.
17933
- */
17934
- var AudioTestResultSchema = object({
17935
- success: boolean(),
17936
- error: string().optional(),
17937
- frame: custom().optional()
18155
+ var ReplayFrameInputSchema = object({
18156
+ timestamp: number(),
18157
+ frame: PipelineRunResultBridge
17938
18158
  });
17939
- var PipelineConfigBridge = custom();
17940
- var ConfigUISchemaBridge = custom();
17941
- var ConfigUISchemaNullableBridge = custom();
17942
- var InferenceCapabilitiesBridge = custom();
17943
- var ModelAvailabilityListBridge = custom();
17944
- var PipelineRunResultBridge = custom();
17945
- method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
17946
- modelId: string(),
17947
- settings: record(string(), unknown()).readonly()
17948
- }))), method(object({ steps: record(string(), object({
17949
- modelId: string(),
17950
- settings: record(string(), unknown()).readonly()
17951
- })) }), object({ success: literal(true) }), {
18159
+ var RunReplayFrameProcessorResultSchema = object({ tracks: array(object({
18160
+ className: string(),
18161
+ firstSeenMs: number(),
18162
+ lastSeenMs: number(),
18163
+ /** Bbox of the track's FIRST matched detection, pixel-space in the clip's
18164
+ * frame — a representative box for the diff's `(className, window, IoU)`
18165
+ * pairing (`replay-diff.ts`). A replay does not need the full per-frame
18166
+ * trajectory production's `Track.positions` keeps. */
18167
+ bbox: BoundingBoxSchema,
18168
+ /** How many of the input frames this track matched a real detection on
18169
+ * (never a coasted/extrapolated frame) — the replay's own signal for "how
18170
+ * solid is this track", cheaper than re-deriving it from a trajectory. */
18171
+ framesMatched: number().int()
18172
+ })).readonly() });
18173
+ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
18174
+ deviceId: number(),
18175
+ trackId: string()
18176
+ }), TrackSchema.nullable()), method(object({
18177
+ deviceId: number(),
18178
+ since: number().optional(),
18179
+ until: number().optional(),
18180
+ limit: number().optional(),
18181
+ /** Spatial filter — only tracks whose trajectory intersects the zone
18182
+ * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
18183
+ * envelope columns, then precisely tested per position. Tracks with
18184
+ * an unknown envelope (no frame dims at persist time) always match. */
18185
+ zone: TrackZoneFilterSchema.optional(),
18186
+ /** See {@link TrackProjectionSchema}. Default `full` (backward
18187
+ * compatible — omitting the field keeps today's exact behaviour). */
18188
+ projection: TrackProjectionSchema.optional(),
18189
+ /** Include stationary-promoted rows (parked objects handed to the
18190
+ * stationary registry). Default false: the timeline lists passages,
18191
+ * not parking records (operator decision, 2026-08-15). */
18192
+ includeStationary: boolean().optional()
18193
+ }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
18194
+ deviceId: number(),
18195
+ groupId: string().min(1)
18196
+ }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
18197
+ kind: "mutation",
18198
+ auth: "admin"
18199
+ }), 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({
18200
+ deviceId: number(),
18201
+ since: number().optional(),
18202
+ until: number().optional(),
18203
+ kinds: array(string()).optional(),
18204
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
18205
+ }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
18206
+ deviceId: number(),
18207
+ since: number(),
18208
+ until: number(),
18209
+ bucketMs: number().int().positive()
18210
+ }), array(object({
18211
+ bucketStart: number(),
18212
+ motion: number().int(),
18213
+ object: number().int(),
18214
+ audio: number().int()
18215
+ })).readonly()), method(object({
18216
+ deviceId: number(),
18217
+ cutoffMs: number()
18218
+ }), object({
18219
+ motion: number().int(),
18220
+ object: number().int(),
18221
+ audio: number().int()
18222
+ }), {
18223
+ kind: "mutation",
18224
+ auth: "admin"
18225
+ }), method(object({
18226
+ deviceId: number(),
18227
+ cutoffMs: number()
18228
+ }), TrackCascadeCountsSchema, {
18229
+ kind: "mutation",
18230
+ auth: "admin"
18231
+ }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
18232
+ kind: "mutation",
18233
+ auth: "admin"
18234
+ }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
18235
+ kind: "mutation",
18236
+ auth: "admin"
18237
+ }), method(object({
18238
+ deviceId: number(),
18239
+ trackIds: array(string()).min(1)
18240
+ }), object({
18241
+ deleted: number().int(),
18242
+ failed: array(string()).readonly()
18243
+ }), {
18244
+ kind: "mutation",
18245
+ auth: "admin"
18246
+ }), method(object({
18247
+ /** Log/audit scope only — the trackId is globally unique on its own. */
18248
+ deviceId: number(),
18249
+ trackId: string(),
18250
+ flags: TrackFlagsPatchSchema
18251
+ }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
18252
+ kind: "query",
18253
+ auth: "admin"
18254
+ }), method(object({
18255
+ olderThanMs: number(),
18256
+ reason: OpsLogReasonSchema.optional()
18257
+ }), EventPruneCountsSchema, {
18258
+ kind: "mutation",
18259
+ auth: "admin"
18260
+ }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
18261
+ kind: "mutation",
18262
+ auth: "admin"
18263
+ }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
18264
+ kind: "mutation",
18265
+ auth: "admin"
18266
+ }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
18267
+ kind: "mutation",
18268
+ auth: "admin"
18269
+ }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
18270
+ kind: "mutation",
18271
+ auth: "admin"
18272
+ }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
18273
+ kind: "mutation",
18274
+ auth: "admin"
18275
+ }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18276
+ kind: "mutation",
18277
+ auth: "admin"
18278
+ }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
18279
+ kind: "mutation",
18280
+ auth: "admin"
18281
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
18282
+ kind: "query",
18283
+ auth: "admin"
18284
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18285
+ kind: "mutation",
18286
+ auth: "admin"
18287
+ }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
18288
+ kind: "query",
18289
+ auth: "admin"
18290
+ }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
18291
+ kind: "query",
18292
+ auth: "admin"
18293
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18294
+ kind: "query",
18295
+ auth: "admin"
18296
+ }), method(object({
18297
+ /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
18298
+ * `deviceId`, deliberately: `deviceId` would make this device-bound and
18299
+ * route it at one camera's owner, and "every camera" would stop being
18300
+ * expressible at all. */
18301
+ deviceIds: array(number()).optional(),
18302
+ limit: number().int().min(1).max(500).optional()
18303
+ }), array(RetrainTrackSchema).readonly(), {
18304
+ kind: "query",
18305
+ auth: "admin"
18306
+ }), method(object({ trackId: string() }), RetrainFrameListSchema, {
18307
+ kind: "query",
18308
+ auth: "admin"
18309
+ }), method(object({
18310
+ deviceId: number(),
18311
+ trackId: string(),
18312
+ mediaKeys: array(string()).min(1)
18313
+ }), RetrainFrameSelectionSchema, {
18314
+ kind: "mutation",
18315
+ auth: "admin"
18316
+ }), method(object({
18317
+ deviceId: number(),
18318
+ trackId: string(),
18319
+ frameId: string()
18320
+ }), object({
18321
+ removed: boolean(),
18322
+ removedAnnotations: number().int()
18323
+ }), {
18324
+ kind: "mutation",
18325
+ auth: "admin"
18326
+ }), method(object({ frameId: string() }), object({
18327
+ base64: string(),
18328
+ width: number().int(),
18329
+ height: number().int()
18330
+ }), {
18331
+ kind: "query",
18332
+ auth: "admin"
18333
+ }), method(object({
18334
+ deviceId: number(),
18335
+ trackId: string(),
18336
+ frameId: string(),
18337
+ subject: RetrainAssistSubjectSchema,
18338
+ /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
18339
+ nodeId: string().optional()
18340
+ }), RetrainAssistResultSchema, {
18341
+ kind: "mutation",
18342
+ auth: "admin"
18343
+ }), method(object({
18344
+ deviceId: number(),
18345
+ source: DetectionSourceSchema,
18346
+ zones: array(ZoneSchema).readonly().optional(),
18347
+ detectionRules: array(ZoneRuleSchema).readonly().optional(),
18348
+ zoneMembershipMinOverlap: number().min(0).max(1).optional(),
18349
+ frames: array(ReplayFrameInputSchema).min(1)
18350
+ }), RunReplayFrameProcessorResultSchema, {
18351
+ kind: "mutation",
18352
+ auth: "admin"
18353
+ }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
18354
+ kind: "query",
18355
+ auth: "admin"
18356
+ }), method(object({
18357
+ deviceId: number(),
18358
+ trackId: string(),
18359
+ frameId: string(),
18360
+ annotations: array(RetrainAnnotationDraftSchema)
18361
+ }), array(RetrainAnnotationSchema).readonly(), {
18362
+ kind: "mutation",
18363
+ auth: "admin"
18364
+ }), method(object({
18365
+ deviceId: number(),
18366
+ trackId: string()
18367
+ }), RetrainTransitionResultSchema, {
17952
18368
  kind: "mutation",
17953
18369
  auth: "admin"
17954
- }), method(object({ nodeId: string() }), object({
17955
- success: literal(true),
17956
- clearedDevices: number()
17957
- }), {
18370
+ }), method(object({
18371
+ deviceId: number(),
18372
+ trackId: string()
18373
+ }), RetrainTransitionResultSchema, {
17958
18374
  kind: "mutation",
17959
18375
  auth: "admin"
17960
- }), 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({
17961
- name: string(),
17962
- steps: array(PipelineTemplateStepSchema).readonly(),
17963
- engine: PipelineEngineChoiceSchema
17964
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
17965
- id: string(),
17966
- name: string().optional(),
17967
- steps: array(PipelineTemplateStepSchema).readonly().optional()
17968
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
17969
- addonId: string(),
17970
- modelId: string(),
17971
- format: ModelFormatSchema$1
17972
- }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
17973
- addonId: string(),
17974
- modelId: string(),
17975
- format: ModelFormatSchema$1
17976
- }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
17977
- engine: PipelineEngineChoiceSchema.optional(),
17978
- steps: array(PipelineStepInputSchema).min(1),
17979
- frame: FrameInputSchema.optional(),
17980
- /**
17981
- * Process-local lazy frame. Valid only when caller and provider resolve
17982
- * in the same execution-group process; split/cross-node callers use
17983
- * `frame`/`image` inline compatibility instead.
17984
- */
17985
- frameRef: FrameRefSchema.optional(),
17986
- /**
17987
- * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
17988
- * the decoded pixels live in. One more member of the one-of
17989
- * frame/frameHandle/image/imageBase64/referenceImage group.
17990
- */
17991
- frameHandle: FrameHandleSchema.optional(),
17992
- imageBase64: string().optional(),
17993
- /**
17994
- * Binary JPEG bytes — preferred over `imageBase64` on internal
17995
- * hops (hub → forked worker via Moleculer MsgPack) because it
17996
- * skips the 33% base64 overhead + the per-call base64 decode on
17997
- * the detection-pipeline worker. Callers can pass either; exactly
17998
- * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
17999
- */
18000
- image: _instanceof(Uint8Array).optional(),
18001
- referenceImage: string().optional(),
18002
- deviceId: number().optional(),
18003
- sessionId: string().optional(),
18004
- /**
18005
- * Execution plane. 'full' (default) runs the whole tree — benchmark,
18006
- * reference-image, and detail-subtree calls. 'frame' is the live
18007
- * per-frame dispatch: ONLY root-plane steps run; crop children
18008
- * (inputClasses ≠ null) are skipped and served per-track via
18009
- * pipelineRunner.runDetailSubtree (two-plane design).
18010
- */
18011
- plane: _enum(["full", "frame"]).optional(),
18012
- /**
18013
- * Inference-device selector (Phase 2 multi-device). Format
18014
- * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
18015
- * Omitted ⇒ the runner's default device (current single-engine
18016
- * behaviour). Selects WHICH device pool of the node runs the call.
18017
- */
18018
- deviceKey: string().optional(),
18019
- /**
18020
- * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
18021
- * when the parent crop was resolved from the frame's retained NATIVE
18022
- * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
18023
- * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
18024
- * resolution from that surface — the SAME quality path faces already
18025
- * had — instead of the downscaled parent tile. `handle` keys the native
18026
- * surface (node-pinned to its owner); `cropFrameSpace` is the parent
18027
- * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
18028
- * the executor's crop-normalized child ROI back into frame-normalized
18029
- * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
18030
- * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
18031
- * (today's behaviour on the fallback path).
18032
- */
18033
- nativeCropRef: NativeCropRefSchema.optional()
18034
- }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
18035
- engine: PipelineEngineChoiceSchema.optional(),
18036
- steps: array(PipelineStepInputSchema).min(1),
18037
- frames: array(FrameInputSchema).min(1).max(255),
18038
- deviceId: number().optional(),
18039
- sessionId: string().optional(),
18040
- /**
18041
- * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
18042
- * the batch to the Python pool's bench preprocess cache
18043
- * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
18044
- * preprocessed ONCE and every later inference is a pure-inference cache
18045
- * hit — the sustained-throughput run measures inference, not
18046
- * decode+preprocess+infer. Omitted/0 for live frames (all different →
18047
- * full preprocess every call, correct). Fresh per sustained run;
18048
- * released via `uncacheFrame`.
18049
- */
18050
- frameId: number().int().nonnegative().optional(),
18051
- /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
18052
- deviceKey: string().optional()
18053
- }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
18054
- data: _instanceof(Uint8Array),
18055
- width: number().int().positive(),
18056
- height: number().int().positive(),
18057
- format: _enum([
18058
- "rgb",
18059
- "bgr",
18060
- "gray"
18061
- ])
18062
- }), object({
18063
- frameId: number(),
18064
- width: number(),
18065
- height: number()
18066
- }), { kind: "mutation" }), method(object({
18067
- stepId: string(),
18068
- frameId: number().int()
18069
- }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
18070
- batchMode: string(),
18071
- windowMs: number(),
18072
- maxBatchSize: number(),
18073
- concurrency: number()
18074
- })), method(_void(), array(object({
18075
- engineKey: string(),
18076
- engine: PipelineEngineChoiceSchema,
18077
- modelsLoaded: array(string()).readonly(),
18078
- inUseByCameras: array(number()).readonly(),
18079
- /**
18080
- * Origin of this resident factory.
18081
- * - `runtime` — main camera-serving engine (no idle TTL).
18082
- * - `warm-override` — benchmark/test override held in the warm
18083
- * cache; auto-disposed after the idle TTL.
18084
- * - `device-pool` — a concurrent per-device pool (Phase 2
18085
- * multi-device, keyed by `deviceKey`) resolved
18086
- * via `resolveDeviceFactory`. Runs alongside the
18087
- * `runtime` engine on a DIFFERENT accelerator
18088
- * (NPU / iGPU / Coral) — this is how the
18089
- * Engines tab shows all pools running at once.
18090
- */
18091
- kind: _enum([
18092
- "runtime",
18093
- "warm-override",
18094
- "device-pool"
18095
- ]),
18096
- /** Native pid of the underlying Python pool (null when no pool). */
18097
- poolPid: number().nullable(),
18098
- /** ms since this factory was last used (null when not warm-tracked). */
18099
- idleMs: number().nullable(),
18100
- /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
18101
- idleTtlMs: number().nullable()
18102
- })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
18103
- kind: "mutation",
18376
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18377
+ kind: "query",
18104
18378
  auth: "admin"
18105
18379
  }), method(object({
18106
- engine: PipelineEngineChoiceSchema,
18107
- force: boolean().optional()
18108
- }), object({
18109
- success: boolean(),
18110
- reason: string().optional()
18111
- }), {
18380
+ eventId: string(),
18381
+ kind: MediaFileKindEnum.optional(),
18382
+ deviceId: number()
18383
+ }), array(MediaFileSchema).readonly()), method(object({
18384
+ trackId: string(),
18385
+ kinds: array(MediaFileKindEnum).optional(),
18386
+ deviceId: number()
18387
+ }), array(MediaFileSchema).readonly()), method(object({
18388
+ trackId: string(),
18389
+ deviceId: number()
18390
+ }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
18112
18391
  kind: "mutation",
18113
18392
  auth: "admin"
18114
- }), 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({
18115
- addonId: string(),
18116
- modelId: string(),
18117
- filename: string().optional(),
18118
- settings: record(string(), unknown()).optional()
18119
- }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
18393
+ }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
18394
+ kind: "mutation",
18395
+ auth: "admin"
18396
+ }), method(object({}), RebuildStatusSchema), object({
18397
+ deviceId: number(),
18398
+ timestamp: number(),
18399
+ frameWidth: number(),
18400
+ frameHeight: number(),
18401
+ detections: array(OverlayDetectionSchema).readonly()
18402
+ }), object({
18403
+ deviceId: number(),
18404
+ trackId: string(),
18405
+ className: string()
18406
+ }), object({
18407
+ deviceId: number(),
18408
+ trackId: string(),
18409
+ className: string(),
18410
+ durationMs: number()
18411
+ }), object({
18412
+ deviceId: number(),
18413
+ kind: EventKindSchema,
18414
+ eventId: string(),
18415
+ timestamp: number()
18416
+ });
18120
18417
  object({
18121
18418
  activeCameras: number(),
18122
18419
  throttledCameras: number(),
@@ -18128,119 +18425,19 @@ var CameraMetricsSchema = object({
18128
18425
  "disabled",
18129
18426
  "always-on",
18130
18427
  "on-motion"
18131
- ]),
18132
- configuredFps: number(),
18133
- actualFps: number(),
18134
- queueDepth: number(),
18135
- avgInferenceTimeMs: number(),
18136
- droppedFrames: number(),
18137
- phase: _enum([
18138
- "idle",
18139
- "watching",
18140
- "active"
18141
- ])
18142
- });
18143
- var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
18144
- /**
18145
- * Zone — pure geometry + identity. NO filtering behaviour.
18146
- *
18147
- * Zones describe **where** in the frame the operator wants to flag
18148
- * something; consumer-owned {@link ZoneRule} arrays describe **how**
18149
- * each pipeline stage uses them. Splitting the two means a single
18150
- * polygon "Driveway" can simultaneously back a motion-exclude rule,
18151
- * a detection-include rule on `['car']`, and an occupancy aggregate
18152
- * — without three duplicated polygons.
18153
- *
18154
- * Owned by the orchestrator addon (provider) and mirrored into the
18155
- * `zones` device-state slice on every mutation. Consumers
18156
- * (motion-wasm, pipeline-executor, analytics, admin UI) read either
18157
- * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
18158
- * mirror with `onChanged`).
18159
- *
18160
- * Coordinates are normalised fractions of the frame (0–1) so zones
18161
- * survive resolution changes and stream profile switches.
18162
- *
18163
- * `kind` discriminates between full polygons (closed regions used
18164
- * for intrusion / occupancy filters) and tripwires (open 2-point
18165
- * line segments used for cross events). Onboard / firmware-reported
18166
- * zones (Reolink, ONVIF) are out of scope for now — see the deferred
18167
- * task list.
18168
- */
18169
- var ZoneKindEnum = _enum(["polygon", "tripwire"]);
18170
- /** Polygon vertex in fraction-of-frame coordinates (0–1). */
18171
- var PolygonPointSchema = object({
18172
- x: number(),
18173
- y: number()
18174
- });
18175
- /** A camera detection zone — pure geometry/identity. */
18176
- var ZoneSchema = object({
18177
- id: string(),
18178
- name: string(),
18179
- kind: ZoneKindEnum.default("polygon"),
18180
- /** Polygon vertices, fraction of frame (0–1). */
18181
- polygon: array(PolygonPointSchema).readonly(),
18182
- /** Visual color for UI rendering. */
18183
- color: string().default("#3b82f6")
18428
+ ]),
18429
+ configuredFps: number(),
18430
+ actualFps: number(),
18431
+ queueDepth: number(),
18432
+ avgInferenceTimeMs: number(),
18433
+ droppedFrames: number(),
18434
+ phase: _enum([
18435
+ "idle",
18436
+ "watching",
18437
+ "active"
18438
+ ])
18184
18439
  });
18185
- /**
18186
- * Zones capability — per-camera CRUD over polygon detection zones.
18187
- *
18188
- * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
18189
- * to per-device settings and mirrors into the `zones` device-state
18190
- * slice on every mutation, so downstream consumers can subscribe via
18191
- * `dev.state.zones.onChanged`.
18192
- *
18193
- * The cap surface only handles geometry + identity; filtering
18194
- * behaviour (per-class, include/exclude, threshold) lives in the
18195
- * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
18196
- * `capabilities/schemas/zone-rule.js`.
18197
- */
18198
- var zonesCapability = {
18199
- name: "zones",
18200
- scope: "device",
18201
- mode: "singleton",
18202
- deviceTypes: [DeviceType.Camera],
18203
- methods: {
18204
- listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
18205
- addZone: method(object({
18206
- deviceId: number(),
18207
- zone: ZoneSchema
18208
- }), _void(), {
18209
- kind: "mutation",
18210
- auth: "admin"
18211
- }),
18212
- removeZone: method(object({
18213
- deviceId: number(),
18214
- zoneId: string()
18215
- }), _void(), {
18216
- kind: "mutation",
18217
- auth: "admin"
18218
- }),
18219
- updateZone: method(object({
18220
- deviceId: number(),
18221
- zone: ZoneSchema
18222
- }), _void(), {
18223
- kind: "mutation",
18224
- auth: "admin"
18225
- })
18226
- },
18227
- /**
18228
- * Runtime-state slice — the live zone catalogue mirrored by the
18229
- * orchestrator on every CRUD mutation. Consumers read via
18230
- * `device.state.zones.value` / `.watch(...)` without round-tripping
18231
- * the cap, and the codegen DeviceProxy auto-wires the reactive
18232
- * handle. Slice shape is `{ zones: Zone[] }` so future extensions
18233
- * (e.g. zone groupings) can sit alongside the polygon list.
18234
- */
18235
- runtimeState: object({ zones: array(ZoneSchema).readonly() }),
18236
- /**
18237
- * 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.
18238
- *
18239
- * See `RuntimeStateDurability`. Enforced by
18240
- * `scripts/check-runtime-state-durability.ts`.
18241
- */
18242
- durability: "restored"
18243
- };
18440
+ var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
18244
18441
  /**
18245
18442
  * A bounding box in NORMALIZED [0,1] frame coordinates for `getNativeCrop`. The
18246
18443
  * decode worker resolves it against the RETAINED native frame's real pixel dims,
@@ -19929,7 +20126,7 @@ method(object({
19929
20126
  * linking rather than produce an eternal token.
19930
20127
  */
19931
20128
  ttlSec: union([number().int().positive(), literal("never")]).optional()
19932
- }), object({ token: string() })), method(object({ token: string() }), SsoBridgeClaimsSchema.nullable());
20129
+ }), object({ token: string() }), { auth: "admin" }), method(object({ token: string() }), SsoBridgeClaimsSchema.nullable(), { auth: "admin" });
19933
20130
  var ProviderListEntrySchema = discriminatedUnion("shouldSaveDiskSpace", [object({
19934
20131
  providerId: string().min(1),
19935
20132
  displayName: string().min(1),
@@ -20024,10 +20221,13 @@ var EvictResultSchema = object({
20024
20221
  /** True when the provider has nothing left it is willing to drop on this location. */
20025
20222
  exhausted: boolean()
20026
20223
  });
20027
- method(object({ locationId: string() }), EvictableUsageSchema), method(object({
20224
+ method(object({ locationId: string() }), EvictableUsageSchema, { auth: "admin" }), method(object({
20028
20225
  locationId: string(),
20029
20226
  targetBytes: number().int().positive()
20030
- }), EvictResultSchema, { kind: "mutation" });
20227
+ }), EvictResultSchema, {
20228
+ kind: "mutation",
20229
+ auth: "admin"
20230
+ });
20031
20231
  method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin" }), method(StorageMigrationInputSchema, object({ jobId: string() }), {
20032
20232
  kind: "mutation",
20033
20233
  auth: "admin"
@@ -20087,26 +20287,50 @@ var ReadChunkInputSchema = object({
20087
20287
  length: number()
20088
20288
  });
20089
20289
  var EndDownloadInputSchema = object({ downloadId: string() });
20090
- method(_void(), ProviderInfoSchema), method(object({ config: record(string(), unknown()) }), TestLocationResultSchema, { auth: "admin" }), method(object({
20290
+ method(_void(), ProviderInfoSchema, { auth: "admin" }), method(object({ config: record(string(), unknown()) }), TestLocationResultSchema, { auth: "admin" }), method(object({
20091
20291
  location: StorageLocationSchema,
20092
20292
  relativePath: string()
20093
- }), string()), method(object({
20293
+ }), string(), { auth: "admin" }), method(object({
20094
20294
  location: StorageLocationSchema,
20095
20295
  relativePath: string(),
20096
20296
  data: _instanceof(Uint8Array)
20097
- }), _void(), { kind: "mutation" }), method(object({
20297
+ }), _void(), {
20298
+ kind: "mutation",
20299
+ auth: "admin"
20300
+ }), method(object({
20098
20301
  location: StorageLocationSchema,
20099
20302
  relativePath: string()
20100
- }), _instanceof(Uint8Array)), method(object({
20303
+ }), _instanceof(Uint8Array), { auth: "admin" }), method(object({
20101
20304
  location: StorageLocationSchema,
20102
20305
  relativePath: string()
20103
- }), boolean()), method(object({
20306
+ }), boolean(), { auth: "admin" }), method(object({
20104
20307
  location: StorageLocationSchema,
20105
20308
  prefix: string().optional()
20106
- }), array(string()).readonly()), method(object({
20309
+ }), array(string()).readonly(), { auth: "admin" }), method(object({
20107
20310
  location: StorageLocationSchema,
20108
20311
  relativePath: string()
20109
- }), _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" });
20312
+ }), _void(), {
20313
+ kind: "mutation",
20314
+ auth: "admin"
20315
+ }), method(object({ location: StorageLocationSchema }), number().nullable(), { auth: "admin" }), method(BeginUploadInputSchema, BeginUploadResultSchema, {
20316
+ kind: "mutation",
20317
+ auth: "admin"
20318
+ }), method(WriteChunkInputSchema, _void(), {
20319
+ kind: "mutation",
20320
+ auth: "admin"
20321
+ }), method(FinalizeUploadInputSchema, _void(), {
20322
+ kind: "mutation",
20323
+ auth: "admin"
20324
+ }), method(AbortUploadInputSchema, _void(), {
20325
+ kind: "mutation",
20326
+ auth: "admin"
20327
+ }), method(BeginDownloadInputSchema, BeginDownloadResultSchema, {
20328
+ kind: "mutation",
20329
+ auth: "admin"
20330
+ }), method(ReadChunkInputSchema, _instanceof(Uint8Array), { auth: "admin" }), method(EndDownloadInputSchema, _void(), {
20331
+ kind: "mutation",
20332
+ auth: "admin"
20333
+ });
20110
20334
  /** Profile-exported FormBuilder schema. Shape is ConfigUISchema at the UI. */
20111
20335
  var ProfileSettingsSchemaBridge = unknown().nullable();
20112
20336
  var ProfileSettingsBagSchema = record(string(), unknown());
@@ -20364,7 +20588,8 @@ method(object({
20364
20588
  access: "create"
20365
20589
  }), method(object({ userId: string().optional() }), object({ optionsJSON: record(string(), unknown()) }), {
20366
20590
  kind: "mutation",
20367
- access: "view"
20591
+ access: "view",
20592
+ auth: "admin"
20368
20593
  }), method(object({
20369
20594
  /** Required — the user the assertion belongs to (verified). */
20370
20595
  userId: string(),
@@ -20372,10 +20597,12 @@ method(object({
20372
20597
  response: record(string(), unknown())
20373
20598
  }), object({ verified: boolean() }), {
20374
20599
  kind: "mutation",
20375
- access: "view"
20600
+ access: "view",
20601
+ auth: "admin"
20376
20602
  }), method(object({}), object({ optionsJSON: record(string(), unknown()) }), {
20377
20603
  kind: "mutation",
20378
- access: "view"
20604
+ access: "view",
20605
+ auth: "admin"
20379
20606
  }), method(object({
20380
20607
  /** AuthenticationResponseJSON from the browser. */
20381
20608
  response: record(string(), unknown()) }), object({
@@ -20383,7 +20610,8 @@ response: record(string(), unknown()) }), object({
20383
20610
  userId: string().nullable()
20384
20611
  }), {
20385
20612
  kind: "mutation",
20386
- access: "view"
20613
+ access: "view",
20614
+ auth: "admin"
20387
20615
  }), method(object({ userId: string() }), array(PasskeySummarySchema), { auth: "admin" }), method(object({
20388
20616
  userId: string(),
20389
20617
  credentialId: string()
@@ -20555,7 +20783,19 @@ var VectorStatsResultSchema = object({
20555
20783
  /** False when the backend ranks approximately. */
20556
20784
  exact: boolean()
20557
20785
  });
20558
- 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);
20786
+ method(VectorDeclareIndexInputSchema, _void(), {
20787
+ kind: "mutation",
20788
+ auth: "admin"
20789
+ }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
20790
+ kind: "mutation",
20791
+ auth: "admin"
20792
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
20793
+ kind: "mutation",
20794
+ auth: "admin"
20795
+ }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
20796
+ kind: "mutation",
20797
+ auth: "admin"
20798
+ }), method(VectorStatsInputSchema, VectorStatsResultSchema, { auth: "admin" });
20559
20799
  var ClipSchema = object({
20560
20800
  /** Opaque, provider-namespaced id. The default provider encodes the time
20561
20801
  * window so `getClipPlayback` is self-contained (no event re-query). */
@@ -23008,7 +23248,27 @@ var MediaFileLiteSchema$1 = object({
23008
23248
  sizeBytes: number(),
23009
23249
  timestamp: number()
23010
23250
  });
23011
- method(_void(), array(IdentitySchema).readonly()), method(object({ name: string().min(1) }), IdentitySchema, {
23251
+ method(object({
23252
+ /**
23253
+ * Inline {@link IdentitySchema.coverBase64} on every row.
23254
+ *
23255
+ * Default `false`, the same inversion `listRecentFaces` and
23256
+ * `listPlates` took on 2026-08-25 (see `include-crops-default.ts` for
23257
+ * why the burden belongs on the caller that WANTS the bytes). Measured
23258
+ * on the live hub the same day: four identities cost 40,979 B with the
23259
+ * covers inline, ~10 KB of base64 per row, on a query this UI mounts
23260
+ * four times and the viewer holds at `staleTime: 30_000`.
23261
+ *
23262
+ * Nothing loses its avatar: `coverMediaKey` is already on every row and
23263
+ * the `event-media` plane serves that key `immutable` with an ETag.
23264
+ *
23265
+ * **This is an INPUT field, so it does not reach the addon until the
23266
+ * next train** — the hub router validates cap inputs against its own
23267
+ * compiled Zod and strips a key it does not know. Until then the
23268
+ * provider sees `undefined`, which resolves to `false`: the cheap shape
23269
+ * is what ships, and the opt-in becomes reachable when the train lands.
23270
+ */
23271
+ includeCrops: boolean().optional() }).optional(), array(IdentitySchema).readonly()), method(object({ name: string().min(1) }), IdentitySchema, {
23012
23272
  kind: "mutation",
23013
23273
  auth: "admin"
23014
23274
  }), method(object({
@@ -25898,8 +26158,10 @@ var PlateInfoSchema = object({
25898
26158
  keyFrameMediaKey: string().optional(),
25899
26159
  base64: string().optional(),
25900
26160
  /**
25901
- * Same crop as a data-plane URL. `getPlateByTrack` returns this and
25902
- * never inlines JPEG; `listPlates` still inlines for the admin-ui.
26161
+ * Same crop as a data-plane URL, always present when the plate has a stored
26162
+ * crop. `getPlateByTrack` returns this and never inlines JPEG; `listPlates`
26163
+ * and `searchPlates` inline the crop only when their `includeCrops` input is
26164
+ * left at its `true` default.
25903
26165
  */
25904
26166
  cropUrl: string().optional()
25905
26167
  });
@@ -25919,14 +26181,34 @@ var PlateClusterSchema = object({
25919
26181
  });
25920
26182
  method(object({
25921
26183
  deviceId: number().int().optional(),
25922
- limit: number().int().positive().optional()
26184
+ limit: number().int().positive().optional(),
26185
+ /**
26186
+ * Inline the base64 crop on every row. Default `true` — the existing
26187
+ * behaviour, kept so no caller breaks.
26188
+ *
26189
+ * Set `false` once the caller renders {@link PlateInfo.cropUrl}.
26190
+ * Measured on the live hub at the 500 rows the Plates view asks for:
26191
+ * 879,403 B and 27.7 s with the crops inline, against a few KiB of
26192
+ * metadata without them — and the browser then caches the images.
26193
+ *
26194
+ * This is the plate twin of `faceGallery.listRecentFaces`'s option;
26195
+ * plates were the one gallery list left without it.
26196
+ *
26197
+ * **This is an INPUT field, so it does not reach the addon until the
26198
+ * next train.** The hub router validates cap inputs against its own
26199
+ * compiled Zod and strips a key it does not know. Until the train
26200
+ * ships, sending `false` is harmless and keeps the crops inline.
26201
+ */
26202
+ includeCrops: boolean().optional()
25923
26203
  }).optional(), array(PlateInfoSchema).readonly()), method(object({
25924
26204
  deviceId: number().int(),
25925
26205
  trackId: string()
25926
26206
  }), PlateInfoSchema.nullable()), method(object({ plateId: string() }), array(MediaFileLiteSchema).readonly()), method(object({
25927
26207
  text: string().min(1),
25928
26208
  maxDistance: number().int().min(0).optional(),
25929
- limit: number().int().positive().optional()
26209
+ limit: number().int().positive().optional(),
26210
+ /** See `listPlates.includeCrops`. Default `true`. */
26211
+ includeCrops: boolean().optional()
25930
26212
  }), array(PlateInfoSchema).readonly()), method(object({
25931
26213
  maxDistance: number().int().min(0).optional(),
25932
26214
  minClusterSize: number().int().min(2).optional(),
@@ -25940,7 +26222,13 @@ method(object({
25940
26222
  }), method(object({ plateId: string() }), _void(), {
25941
26223
  kind: "mutation",
25942
26224
  auth: "admin"
25943
- }), method(_void(), array(VehicleSchema).readonly()), method(object({ name: string().min(1) }), VehicleSchema, {
26225
+ }), method(object({
26226
+ /** Inline {@link VehicleSchema.coverBase64} on every row. Default
26227
+ * `false` — the vehicle twin of `faceGallery.listIdentities`'s
26228
+ * option; `coverMediaKey` + the `event-media` plane carry the picture.
26229
+ * INPUT field: stripped by the hub router until the train ships, which
26230
+ * resolves to `false` and is exactly the intended default. */
26231
+ includeCrops: boolean().optional() }).optional(), array(VehicleSchema).readonly()), method(object({ name: string().min(1) }), VehicleSchema, {
25944
26232
  kind: "mutation",
25945
26233
  auth: "admin"
25946
26234
  }), method(object({
@@ -27461,92 +27749,6 @@ var sceneMonitorCapability = {
27461
27749
  durability: "session"
27462
27750
  };
27463
27751
  /**
27464
- * Per-stage gating mode applied to the zones a rule references.
27465
- *
27466
- * - `include`: the rule contributes to a **whitelist** for its stage.
27467
- * When at least one `include` rule fires for a stage, only entities
27468
- * inside one of those zones pass that stage.
27469
- * - `exclude`: the rule contributes to a **blacklist** for its stage.
27470
- * Entities inside one of those zones are dropped at that stage.
27471
- *
27472
- * `monitor`-style observation (count without filtering) is not a rule
27473
- * mode — zones without any matching rule are observed naturally by
27474
- * `zone-analytics` (live snapshot + history), so an "I just want to
27475
- * count, not filter" use case needs no rule at all.
27476
- */
27477
- var ZoneRuleModeEnum = _enum(["include", "exclude"]);
27478
- /**
27479
- * Per-consumer rule that references existing zones (geometry) and
27480
- * defines how a specific pipeline stage should treat them. Each
27481
- * consumer addon owns its own `ZoneRule[]` array in its per-device
27482
- * settings:
27483
- *
27484
- * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
27485
- * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
27486
- * - future: notification rules, audio gating, etc.
27487
- *
27488
- * One rule applies to N zones (`zoneIds[]`) so the operator can
27489
- * express "ignore motion in ALL of {garden, street}" with a single
27490
- * rule. `classFilter` narrows the rule to specific object classes —
27491
- * "drop person detections in the street, but keep cars" is one
27492
- * `exclude` rule with `classFilter: ['person']`.
27493
- *
27494
- * `enabled` is a soft toggle — the operator can keep the rule
27495
- * configured but inert without deleting it.
27496
- */
27497
- var ZoneRuleSchema = object({
27498
- /** Stable rule id — survives edits, used by the UI for diffing. */
27499
- id: string(),
27500
- /** Optional human-readable label rendered in the rule editor. */
27501
- name: string().optional(),
27502
- /** Zones this rule targets. The rule's `mode` applies to ALL
27503
- * listed zones (OR-set: a detection in any one of them counts).
27504
- * At least one zone id required — a rule with no targets is a
27505
- * configuration mistake and the form validator rejects it. */
27506
- zoneIds: array(string()).min(1).readonly(),
27507
- mode: ZoneRuleModeEnum,
27508
- /**
27509
- * Class names this rule applies to. Empty / undefined ⇒ rule
27510
- * applies to every class. Class strings match the `macroClass`
27511
- * field on detections (e.g. `person`, `car`, `dog`).
27512
- */
27513
- classFilter: array(string()).readonly().optional(),
27514
- /**
27515
- * Minimum bbox/mask overlap (0–1) with any of the rule's zones
27516
- * required to consider an entity "in the zone". Defaults to the
27517
- * consumer's stage default when omitted. Kept for back-compat with
27518
- * existing per-rule overrides; new operators pick the value via
27519
- * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
27520
- * set, the lower-level engine reads it as a 0–1 fraction.
27521
- */
27522
- overlapThreshold: number().min(0).max(1).optional(),
27523
- /**
27524
- * Operator-friendly version of `overlapThreshold` — the percentage
27525
- * of the detection's bbox that must lie inside the zone for the
27526
- * rule to match. Documented default is 85%; the engine substitutes
27527
- * that when the field is omitted (kept optional so existing rules
27528
- * stored without it stay valid).
27529
- *
27530
- * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
27531
- * rule, the engine prefers `bboxInclusionPct` because it's the
27532
- * field exposed in the UI. Internally both feed the same gate.
27533
- */
27534
- bboxInclusionPct: number().min(0).max(100).optional(),
27535
- /**
27536
- * When `true` and a detection has a segmentation mask, use the
27537
- * mask for overlap instead of the bbox. Detection-stage only;
27538
- * motion rules ignore this field.
27539
- */
27540
- preferMask: boolean().optional(),
27541
- /**
27542
- * Soft-toggle: `false` disables the rule without deleting it.
27543
- * Defaults to `true` so operators creating a rule via the UI
27544
- * see it active immediately.
27545
- */
27546
- enabled: boolean().default(true)
27547
- });
27548
- array(ZoneRuleSchema).readonly();
27549
- /**
27550
27752
  * Script-runner cap. Models HA `script.*` entities on
27551
27753
  * `DeviceType.Script`. A Script is a pre-recorded action sequence
27552
27754
  * that can be invoked imperatively — optionally with a variables
@@ -33201,6 +33403,12 @@ Object.freeze({
33201
33403
  addonId: null,
33202
33404
  access: "create"
33203
33405
  },
33406
+ "pipelineAnalytics.cancelRelocateMedia": {
33407
+ capName: "pipeline-analytics",
33408
+ capScope: "device",
33409
+ addonId: null,
33410
+ access: "create"
33411
+ },
33204
33412
  "pipelineAnalytics.cancelStorageMigrationMove": {
33205
33413
  capName: "pipeline-analytics",
33206
33414
  capScope: "device",
@@ -33375,6 +33583,12 @@ Object.freeze({
33375
33583
  addonId: null,
33376
33584
  access: "view"
33377
33585
  },
33586
+ "pipelineAnalytics.listRelocateMediaJobs": {
33587
+ capName: "pipeline-analytics",
33588
+ capScope: "device",
33589
+ addonId: null,
33590
+ access: "view"
33591
+ },
33378
33592
  "pipelineAnalytics.listRetrainAnnotations": {
33379
33593
  capName: "pipeline-analytics",
33380
33594
  capScope: "device",
@@ -33453,6 +33667,12 @@ Object.freeze({
33453
33667
  addonId: null,
33454
33668
  access: "create"
33455
33669
  },
33670
+ "pipelineAnalytics.relocateMedia": {
33671
+ capName: "pipeline-analytics",
33672
+ capScope: "device",
33673
+ addonId: null,
33674
+ access: "create"
33675
+ },
33456
33676
  "pipelineAnalytics.restageRetrainTrack": {
33457
33677
  capName: "pipeline-analytics",
33458
33678
  capScope: "device",
@@ -33465,6 +33685,12 @@ Object.freeze({
33465
33685
  addonId: null,
33466
33686
  access: "create"
33467
33687
  },
33688
+ "pipelineAnalytics.runReplayFrameProcessor": {
33689
+ capName: "pipeline-analytics",
33690
+ capScope: "device",
33691
+ addonId: null,
33692
+ access: "create"
33693
+ },
33468
33694
  "pipelineAnalytics.saveRetrainAnnotations": {
33469
33695
  capName: "pipeline-analytics",
33470
33696
  capScope: "device",
@@ -33597,6 +33823,12 @@ Object.freeze({
33597
33823
  addonId: null,
33598
33824
  access: "view"
33599
33825
  },
33826
+ "pipelineExecutor.getInferenceDeviceHealth": {
33827
+ capName: "pipeline-executor",
33828
+ capScope: "system",
33829
+ addonId: null,
33830
+ access: "view"
33831
+ },
33600
33832
  "pipelineExecutor.getOrchestratorConfigSchema": {
33601
33833
  capName: "pipeline-executor",
33602
33834
  capScope: "system",
@@ -33669,6 +33901,12 @@ Object.freeze({
33669
33901
  addonId: null,
33670
33902
  access: "view"
33671
33903
  },
33904
+ "pipelineExecutor.rearmInferenceDevice": {
33905
+ capName: "pipeline-executor",
33906
+ capScope: "system",
33907
+ addonId: null,
33908
+ access: "create"
33909
+ },
33672
33910
  "pipelineExecutor.runAudioTest": {
33673
33911
  capName: "pipeline-executor",
33674
33912
  capScope: "system",
@@ -36917,6 +37155,11 @@ Object.freeze({
36917
37155
  form: "single",
36918
37156
  optional: false
36919
37157
  }],
37158
+ "pipelineAnalytics.runReplayFrameProcessor": [{
37159
+ name: "deviceId",
37160
+ form: "single",
37161
+ optional: false
37162
+ }],
36920
37163
  "pipelineAnalytics.saveRetrainAnnotations": [{
36921
37164
  name: "deviceId",
36922
37165
  form: "single",