@camstack/addon-provider-wyze 0.2.32 → 0.2.34

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