@camstack/addon-provider-rtsp 1.2.28 → 1.2.30

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