@camstack/addon-provider-dreo 0.2.28 → 0.2.30

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