@camstack/addon-export-hap 1.2.39 → 1.2.41

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.
@@ -6774,7 +6774,7 @@ function method(input, output, options) {
6774
6774
  input,
6775
6775
  output,
6776
6776
  kind: options?.kind ?? "query",
6777
- auth: options?.auth ?? "protected",
6777
+ ...options?.auth !== void 0 ? { auth: options.auth } : {},
6778
6778
  ...options?.access !== void 0 ? { access: options.access } : {},
6779
6779
  ...options?.caller !== void 0 ? { caller: options.caller } : {},
6780
6780
  timeoutMs: options?.timeoutMs
@@ -6794,7 +6794,7 @@ function systemMethod(input, output, options) {
6794
6794
  }
6795
6795
  var StaticDirOutputSchema$1 = object({ staticDir: string() });
6796
6796
  var VersionOutputSchema$1 = object({ version: string() });
6797
- method(_void(), StaticDirOutputSchema$1), method(_void(), VersionOutputSchema$1);
6797
+ method(_void(), StaticDirOutputSchema$1, { auth: "admin" }), method(_void(), VersionOutputSchema$1, { auth: "admin" });
6798
6798
  var DeviceType = /* @__PURE__ */ function(DeviceType) {
6799
6799
  DeviceType["Camera"] = "camera";
6800
6800
  DeviceType["Hub"] = "hub";
@@ -7115,7 +7115,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
7115
7115
  }({});
7116
7116
  var StaticDirOutputSchema = object({ staticDir: string() });
7117
7117
  var VersionOutputSchema = object({ version: string() });
7118
- method(_void(), StaticDirOutputSchema), method(_void(), VersionOutputSchema);
7118
+ method(_void(), StaticDirOutputSchema, { auth: "admin" }), method(_void(), VersionOutputSchema, { auth: "admin" });
7119
7119
  /**
7120
7120
  * device-ops — device-scoped cap that unifies the per-IDevice operations
7121
7121
  * previously routed through the `.device-ops` Moleculer bridge service.
@@ -8267,24 +8267,6 @@ var RecordingRetentionSchema = object({
8267
8267
  maxSizeGb: number().min(0).optional()
8268
8268
  });
8269
8269
  /**
8270
- * Scrub-thumbnail fidelity preset — the single per-camera selector bundling the
8271
- * sprite tile RESOLUTION + JPEG QUALITY the recorder packs timeline-scrub
8272
- * previews at. Five graduated steps; absent on a config = `standard` (the
8273
- * shipped default, matching `sheet-geometry`/`sheet-composer`).
8274
- *
8275
- * Existing sheets are IMMUTABLE — a changed preset applies to NEW windows only.
8276
- * Each window's index sidecar carries its own tile dims, so a camera whose
8277
- * preset changed over time renders every historical window at the dims it was
8278
- * written with.
8279
- */
8280
- var ScrubThumbnailPresetSchema = _enum([
8281
- "minimal",
8282
- "low",
8283
- "standard",
8284
- "high",
8285
- "max"
8286
- ]);
8287
- /**
8288
8270
  * The full per-camera recording intent — the wire shape of a RecordingTarget.
8289
8271
  *
8290
8272
  * `bands` is the ONLY authored recording intent: what to record, when, and on
@@ -8292,7 +8274,11 @@ var ScrubThumbnailPresetSchema = _enum([
8292
8274
  * other field is a storage knob (profiles, segment length, retention, scrub).
8293
8275
  *
8294
8276
  * STRICT on purpose: the legacy authoring surface (`schedule`/`schedules`/
8295
- * `triggers`/`preBufferSec`/`postBufferSec`/`rules`) was retired 2026-07-30.
8277
+ * `triggers`/`preBufferSec`/`postBufferSec`/`rules`) was retired 2026-07-30,
8278
+ * and `scrubThumbnails` — a five-step fidelity knob for a sprite tier that was
8279
+ * deleted on 2026-07-24 and had ZERO consumers in the recorder — on 2026-08-25
8280
+ * (D62: a switch that writes a store nobody reads is worse than no switch).
8281
+ * Stored rows keep loading: the READ schema is `.strip()` (config-store.ts).
8296
8282
  * A stale caller must fail loudly — silently stripping its legacy intent would
8297
8283
  * persist a band-less config, i.e. silently stop recording the camera.
8298
8284
  */
@@ -8315,14 +8301,7 @@ var RecordingConfigSchema = object({
8315
8301
  * "off" is the absence of a covering band, never a band value.
8316
8302
  */
8317
8303
  bands: array(RecordingBandSchema).default([]),
8318
- retention: RecordingRetentionSchema.optional(),
8319
- /**
8320
- * Per-camera scrub-thumbnail fidelity preset (resolution + JPEG quality for
8321
- * timeline-scrub sprite previews). Absent = `standard`. Applies to NEW
8322
- * windows only — existing sheets are immutable, and each window's index
8323
- * carries its own tile dims so mixed-preset history renders correctly.
8324
- */
8325
- scrubThumbnails: ScrubThumbnailPresetSchema.optional()
8304
+ retention: RecordingRetentionSchema.optional()
8326
8305
  }).strict();
8327
8306
  /**
8328
8307
  * Entity-relocation job state (storage entity-routing spec, Phase 4).
@@ -8398,10 +8377,11 @@ var RelocateFootageInputSchema = object({
8398
8377
  * `RecordingConfig.enabled` or camera wrapper bindings. */
8399
8378
  var StorageMigrationLeaseInputSchema = object({ leaseId: string().min(1) });
8400
8379
  var StorageMigrationFootageMoveInputSchema = RelocateFootageInputSchema.extend({ leaseId: string().min(1) });
8401
- var StorageMigrationMediaMoveInputSchema = object({
8380
+ var RelocateMediaInputSchema = object({
8402
8381
  toLocationId: string(),
8403
8382
  throttleMbps: number().min(1).max(1e3).optional()
8404
- }).extend({ leaseId: string().min(1) });
8383
+ });
8384
+ var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
8405
8385
  /** The independently selectable logical storage classes. `recordings`
8406
8386
  * encompasses the high and mid segment profiles; `recordingsLow` is low
8407
8387
  * segments; `eventMedia` is post-analysis blobs. */
@@ -8750,7 +8730,26 @@ var LabelDefinitionSchema = object({
8750
8730
  description: string().optional(),
8751
8731
  icon: string().optional()
8752
8732
  });
8753
- var ClassMapDefinitionSchema = object({
8733
+ /**
8734
+ * Wire schema for a per-model CATALOG classMap override
8735
+ * (`ModelCatalogEntry.classMap` / `ModelConvertMetadata.classMap`) —
8736
+ * restricted to {@link CLASS_MAP_MACRO_TARGETS}, the only macros the
8737
+ * detection pipeline executor actually routes.
8738
+ *
8739
+ * This is deliberately a DIFFERENT, narrower shape than the general-purpose
8740
+ * `ClassMapDefinition` interface above (e.g. `IDetectionAddon.getClassMap()`
8741
+ * and the audio `YAMNET_TO_MACRO` catalog both use macro targets outside this
8742
+ * enum) — the two used to share the name `ClassMapDefinition`/
8743
+ * `ClassMapDefinitionSchema`, which made the schema-type-twin guard
8744
+ * (`scripts/check-schema-type-twins.ts`) flag them as a duplicated shape. They
8745
+ * are not: it is two different concepts colliding on a name. Keep this type
8746
+ * under its own name rather than reusing `ClassMapDefinition` — reusing it
8747
+ * would either narrow every `ClassMapDefinition` consumer to the four
8748
+ * detection macros (breaking `YAMNET_TO_MACRO`) or drop the validation this
8749
+ * schema exists for (see the "rejects a classMap whose target is not a
8750
+ * detection macro" test in `model-catalog-schema.test.ts`).
8751
+ */
8752
+ var DetectionCatalogClassMapSchema = object({
8754
8753
  mapping: record(string(), _enum([
8755
8754
  "person",
8756
8755
  "vehicle",
@@ -8955,7 +8954,7 @@ var ModelCatalogEntrySchema = object({
8955
8954
  * applies (Frigate / COCO public catalog). Set on a custom model whose raw
8956
8955
  * labels already ARE the CamStack macros (Scrypted identity map).
8957
8956
  */
8958
- classMap: ClassMapDefinitionSchema.optional()
8957
+ classMap: DetectionCatalogClassMapSchema.optional()
8959
8958
  });
8960
8959
  var ConvertTargetSchema = discriminatedUnion("format", [object({
8961
8960
  format: literal("openvino"),
@@ -8985,7 +8984,7 @@ var ModelConvertMetadataSchema = object({
8985
8984
  "segmentation"
8986
8985
  ]),
8987
8986
  faceAlignment: boolean().optional(),
8988
- classMap: ClassMapDefinitionSchema.optional()
8987
+ classMap: DetectionCatalogClassMapSchema.optional()
8989
8988
  });
8990
8989
  var ConvertResultSchema = object({
8991
8990
  entry: ModelCatalogEntrySchema,
@@ -9848,7 +9847,7 @@ var AddonPageDeclarationSchema = object({
9848
9847
  /** Display label for a CUSTOM `section` id (ignored for well-known ids). */
9849
9848
  sectionLabel: string().optional()
9850
9849
  });
9851
- method(_void(), array(AddonPageDeclarationSchema).readonly());
9850
+ method(_void(), array(AddonPageDeclarationSchema).readonly(), { auth: "admin" });
9852
9851
  var AddonHttpRouteSchema = object({
9853
9852
  method: _enum([
9854
9853
  "GET",
@@ -10083,7 +10082,7 @@ var WidgetMetadataSchema = object({
10083
10082
  defaultColumns: number().int().min(1).max(12).default(6),
10084
10083
  defaultRows: number().int().min(1).max(12).default(1)
10085
10084
  });
10086
- method(_void(), array(WidgetMetadataSchema).readonly());
10085
+ method(_void(), array(WidgetMetadataSchema).readonly(), { auth: "admin" });
10087
10086
  /**
10088
10087
  * `addon-widgets` — system-scoped singleton aggregator cap. Public-facing
10089
10088
  * surface that admin-ui consumes through `useAddonWidgetsListWidgets()`.
@@ -11605,7 +11604,7 @@ var CustomModelDescriptorSchema = object({
11605
11604
  stepId: string(),
11606
11605
  entry: ModelCatalogEntrySchema
11607
11606
  });
11608
- method(_void(), array(CustomModelDescriptorSchema).readonly());
11607
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
11609
11608
  /**
11610
11609
  * Query filter for settings-store collections.
11611
11610
  */
@@ -11692,7 +11691,8 @@ method(object({
11692
11691
  }), _void(), { kind: "mutation" }), method(object({
11693
11692
  namespace: string().optional(),
11694
11693
  collection: string(),
11695
- filter: QueryFilterSchema.optional()
11694
+ filter: QueryFilterSchema.optional(),
11695
+ columns: array(string()).readonly().optional()
11696
11696
  }), array(SettingsRecordSchema).readonly()), method(object({
11697
11697
  namespace: string().optional(),
11698
11698
  collection: string(),
@@ -11755,46 +11755,87 @@ var EngineInfoSchema = object({
11755
11755
  kind: _enum(["relational", "vector"]),
11756
11756
  displayName: string()
11757
11757
  });
11758
- method(_void(), EngineInfoSchema), method(object({
11758
+ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
11759
11759
  namespace: string().optional(),
11760
11760
  collection: string(),
11761
11761
  key: string()
11762
- }), unknown()), method(object({
11762
+ }), unknown(), { auth: "admin" }), method(object({
11763
11763
  namespace: string().optional(),
11764
11764
  collection: string(),
11765
11765
  key: string(),
11766
11766
  value: unknown()
11767
- }), _void(), { kind: "mutation" }), method(object({
11767
+ }), _void(), {
11768
+ kind: "mutation",
11769
+ auth: "admin"
11770
+ }), method(object({
11768
11771
  namespace: string().optional(),
11769
11772
  collection: string(),
11770
- filter: QueryFilterSchema.optional()
11771
- }), array(SettingsRecordSchema).readonly()), method(object({
11773
+ filter: QueryFilterSchema.optional(),
11774
+ /**
11775
+ * SQL-level column projection — MUST mirror `settings-store.query`.
11776
+ *
11777
+ * ⚠ An earlier version of this comment blamed Zod stripping, and that
11778
+ * was wrong — corrected 2026-08-26 after the hop map
11779
+ * (`docs/design/2026-08-26-mappa-hop-argomenti.md`) traced the path.
11780
+ * There is **no Zod parse at all** between the door and the engine: the
11781
+ * dispatcher forwards the payload verbatim and UDS carries it whole. A
11782
+ * field declared here reaches `SqliteSettingsBackend` either way.
11783
+ *
11784
+ * What actually lost `columns` was the THIRD declaration of this shape:
11785
+ * `SettingsQueryInput` in `interfaces/storage.ts`, a hand-written TS
11786
+ * interface the engine destructures from. The field existed on both
11787
+ * schemas and the engine still never read it, because nothing checks a
11788
+ * registered provider against `InferProvider<cap>` —
11789
+ * `ProviderRegistration.provider` is typed `object`.
11790
+ *
11791
+ * It is declared here anyway, and must stay in step with
11792
+ * `settings-store.query`: a caller reading only the cap definitions has
11793
+ * to be able to see that this call carries a projection.
11794
+ * `data-door-schema-parity.spec.ts` keeps the two aligned.
11795
+ */
11796
+ columns: array(string()).readonly().optional()
11797
+ }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
11772
11798
  namespace: string().optional(),
11773
11799
  collection: string(),
11774
11800
  record: SettingsRecordSchema
11775
- }), _void(), { kind: "mutation" }), method(object({
11801
+ }), _void(), {
11802
+ kind: "mutation",
11803
+ auth: "admin"
11804
+ }), method(object({
11776
11805
  namespace: string().optional(),
11777
11806
  collection: string(),
11778
11807
  id: string(),
11779
11808
  data: record(string(), unknown())
11780
- }), _void(), { kind: "mutation" }), method(object({
11809
+ }), _void(), {
11810
+ kind: "mutation",
11811
+ auth: "admin"
11812
+ }), method(object({
11781
11813
  namespace: string().optional(),
11782
11814
  collection: string(),
11783
11815
  key: string()
11784
- }), _void(), { kind: "mutation" }), method(object({
11816
+ }), _void(), {
11817
+ kind: "mutation",
11818
+ auth: "admin"
11819
+ }), method(object({
11785
11820
  namespace: string().optional(),
11786
11821
  collection: string(),
11787
11822
  filter: MutationFilterSchema
11788
- }), object({ deleted: number().int() }), { kind: "mutation" }), method(object({
11823
+ }), object({ deleted: number().int() }), {
11824
+ kind: "mutation",
11825
+ auth: "admin"
11826
+ }), method(object({
11789
11827
  namespace: string().optional(),
11790
11828
  collection: string(),
11791
11829
  filter: MutationFilterSchema,
11792
11830
  data: record(string(), unknown())
11793
- }), object({ updated: number().int() }), { kind: "mutation" }), method(object({
11831
+ }), object({ updated: number().int() }), {
11832
+ kind: "mutation",
11833
+ auth: "admin"
11834
+ }), method(object({
11794
11835
  namespace: string().optional(),
11795
11836
  collection: string(),
11796
11837
  filter: QueryFilterSchema.optional()
11797
- }), number()), method(object({
11838
+ }), number(), { auth: "admin" }), method(object({
11798
11839
  namespace: string().optional(),
11799
11840
  collection: string(),
11800
11841
  field: string(),
@@ -11804,15 +11845,18 @@ method(_void(), EngineInfoSchema), method(object({
11804
11845
  }), array(object({
11805
11846
  bucket: number().int(),
11806
11847
  count: number().int()
11807
- })).readonly()), method(object({
11848
+ })).readonly(), { auth: "admin" }), method(object({
11808
11849
  namespace: string().optional(),
11809
11850
  collection: string()
11810
- }), boolean()), method(object({
11851
+ }), boolean(), { auth: "admin" }), method(object({
11811
11852
  namespace: string().optional(),
11812
11853
  collection: string(),
11813
11854
  columns: array(CollectionColumnSchema).readonly(),
11814
11855
  indexes: array(CollectionIndexSchema).readonly().optional()
11815
- }), _void(), { kind: "mutation" });
11856
+ }), _void(), {
11857
+ kind: "mutation",
11858
+ auth: "admin"
11859
+ });
11816
11860
  /**
11817
11861
  * Stable UI option list for the `hwaccel` setting. Decoder addons
11818
11862
  * reuse this for `globalSettingsSchema()` so the dropdown is
@@ -13021,7 +13065,7 @@ method(object({
13021
13065
  crop: _instanceof(Uint8Array),
13022
13066
  width: number(),
13023
13067
  height: number()
13024
- }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
13068
+ }), EmbeddingResultSchema, { auth: "admin" }), method(object({ text: string() }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" });
13025
13069
  /**
13026
13070
  * filesystem-browse — per-node capability for browsing the node's local
13027
13071
  * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
@@ -13314,19 +13358,22 @@ method(LlmGenerateBaseInputSchema.extend({
13314
13358
  runtime: ManagedRuntimeConfigSchema,
13315
13359
  /** The managed profile's timeout, threaded by the hub provider. */
13316
13360
  timeoutMs: number().int().positive().optional()
13317
- }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
13361
+ }), LlmGenerateResultSchema, {
13362
+ kind: "mutation",
13363
+ auth: "admin"
13364
+ }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
13318
13365
  kind: "mutation",
13319
13366
  auth: "admin"
13320
13367
  }), method(object({}), _void(), {
13321
13368
  kind: "mutation",
13322
13369
  auth: "admin"
13323
- }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
13370
+ }), method(object({}), LlmRuntimeStatusSchema, { auth: "admin" }), method(object({ model: ManagedModelRefSchema }), _void(), {
13324
13371
  kind: "mutation",
13325
13372
  auth: "admin"
13326
13373
  }), method(object({ file: string() }), _void(), {
13327
13374
  kind: "mutation",
13328
13375
  auth: "admin"
13329
- }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
13376
+ }), method(object({}), array(LlmNodeModelSchema), { auth: "admin" }), method(object({}), LlmRuntimeDiskUsageSchema, { auth: "admin" });
13330
13377
  /**
13331
13378
  * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
13332
13379
  * methods concat-fan across providers; single-row methods route to ONE
@@ -16799,1748 +16846,1958 @@ var OauthIntegrationDescriptorSchema = object({
16799
16846
  */
16800
16847
  refreshTokenTtlSec: union([number().int().positive(), literal("never")]).optional()
16801
16848
  });
16802
- method(_void(), OauthIntegrationDescriptorSchema);
16849
+ method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
16803
16850
  /**
16804
- * pipeline-analytics device-scoped wrapper cap. Refines raw
16805
- * per-frame detections emitted by the pipeline runner into tracked
16806
- * objects, per-kind event collections (motion / object / audio), and
16807
- * persisted media. Owns the post-detection domain end-to-end:
16808
- *
16809
- * runner emits PipelineInferenceResult
16810
- * ↓ (event bus)
16811
- * pipeline-analytics subscriber
16812
- * ↓ SORT tracker + zone engine + state analyzer + event emitter
16813
- * → three DB collections (one per kind), one FS media tree, one
16814
- * unified event emitter (FrameTracked + TrackStarted/Ended +
16815
- * DetectionEvent on bus)
16816
- *
16817
- * Pure subscriber model. No `processFrame` cap method — the runner
16818
- * already publishes the raw frame on the bus. The cap surface is
16819
- * only QUERIES + per-device settings, bound on/off via
16820
- * `device-manager.setWrapperActive`. `defaultActive: true` because
16821
- * every camera with a detection pipeline wants its raw detections
16822
- * refined; operators opt out per-device via BindingsTab when needed.
16823
- *
16824
- * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
16825
- * (per-device surface) and `track-trail` caps — see P11 cleanup.
16851
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
16852
+ * within the frame, so the executor can re-cut a leaf child ROI at native
16853
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
16826
16854
  */
16827
- var TrackStateSchema = _enum([
16828
- "new",
16829
- "entered",
16830
- "left",
16831
- "moving",
16832
- "idle"
16833
- ]);
16834
- var EventKindSchema = _enum([
16835
- "motion",
16836
- "object",
16837
- "audio"
16838
- ]);
16855
+ var NativeCropRefSchema = object({
16856
+ /** Handle keying the retained native surface (node-pinned to its owner). */
16857
+ handle: FrameHandleSchema,
16858
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
16859
+ cropFrameSpace: object({
16860
+ x: number(),
16861
+ y: number(),
16862
+ w: number(),
16863
+ h: number()
16864
+ })
16865
+ });
16866
+ object({
16867
+ crop: object({
16868
+ left: number(),
16869
+ top: number(),
16870
+ width: number().positive(),
16871
+ height: number().positive()
16872
+ }).optional(),
16873
+ content: object({
16874
+ width: number().int().positive(),
16875
+ height: number().int().positive()
16876
+ }),
16877
+ fit: _enum(["stretch", "contain"]),
16878
+ format: _enum([
16879
+ "rgb",
16880
+ "gray",
16881
+ "jpeg"
16882
+ ])
16883
+ });
16839
16884
  /**
16840
- * Spatial filter for `listTracks` the rect + polygon variants of the shared
16841
- * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
16842
- * of the camera frame (top-left origin), matching the drawing-plane editor.
16885
+ * Process-local frame identity. It is serializable so it can ride an in-process
16886
+ * capability call, but `registryId` deliberately prevents resolution in any
16887
+ * other process or execution group.
16843
16888
  */
16844
- var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
16845
- /** Closed icon vocabulary so clients render a known glyph per kind. */
16846
- var EventKindIconSchema = _enum([
16847
- "motion",
16848
- "audio",
16849
- "person",
16850
- "vehicle",
16851
- "animal",
16852
- "door",
16853
- "pir",
16854
- "smoke",
16855
- "water",
16856
- "button",
16857
- "package",
16858
- "generic"
16889
+ var FrameRefSchema = object({
16890
+ registryId: string().min(1),
16891
+ id: string().min(1),
16892
+ width: number().int().positive(),
16893
+ height: number().int().positive(),
16894
+ format: _enum(["rgb", "gray"]),
16895
+ timestamp: number(),
16896
+ capturedAt: number().optional()
16897
+ });
16898
+ var ModelFormatSchema$1 = _enum([
16899
+ "onnx",
16900
+ "coreml",
16901
+ "openvino",
16902
+ "tflite",
16903
+ "pt",
16904
+ "gguf"
16859
16905
  ]);
16860
- var EventKindCategorySchema = _enum([
16861
- "motion",
16862
- "audio",
16863
- "detection",
16864
- "sensor",
16865
- "control",
16866
- "custom",
16867
- "package"
16906
+ var PipelineSlotSchema = _enum([
16907
+ "detector",
16908
+ "cropper",
16909
+ "classifier",
16910
+ "refiner",
16911
+ "audio-classifier"
16868
16912
  ]);
16869
- /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
16870
- var EventKindLevelSchema = _enum(["macro", "sub"]);
16871
- var EventKindDescriptorSchema = object({
16872
- /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
16873
- kind: string(),
16874
- /** i18n key resolved on the UI side; `label` is the English fallback. */
16875
- labelKey: string(),
16876
- /** English fallback label (kept for clients that don't translate). */
16877
- label: string(),
16878
- /** Hex color for timeline/legend rendering. */
16879
- color: string(),
16880
- /** Dictionary id → lucide component on the UI side. */
16881
- iconId: string(),
16882
- /** Legacy closed-vocab glyph — fallback for `iconId`. */
16883
- icon: EventKindIconSchema,
16884
- category: EventKindCategorySchema,
16885
- /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
16886
- parentKind: string().nullable(),
16887
- /** Derived from `parentKind`, explicit for the client tree. */
16888
- level: EventKindLevelSchema,
16889
- /** Which cap + device contributes this kind. For built-ins the camera
16890
- * itself; for sensor kinds the LINKED source device. */
16891
- source: object({
16892
- capName: string(),
16893
- deviceId: number()
16894
- })
16913
+ var PipelineEngineChoiceSchema = object({
16914
+ runtime: _enum(["node", "python"]),
16915
+ backend: string(),
16916
+ format: ModelFormatSchema$1,
16917
+ device: string().optional()
16895
16918
  });
16896
- /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
16897
- var EventKindsForDeviceSchema = object({
16898
- deviceId: number(),
16899
- kinds: array(EventKindDescriptorSchema).readonly()
16919
+ var AvailableEngineSchema = object({
16920
+ engine: PipelineEngineChoiceSchema,
16921
+ devices: array(object({
16922
+ id: string(),
16923
+ label: string(),
16924
+ description: string().optional()
16925
+ })).readonly(),
16926
+ defaultDevice: string()
16900
16927
  });
16901
- var SensorEventSchema = object({
16928
+ var PipelineDefaultStepSchema = lazy(() => object({
16929
+ addonId: string(),
16930
+ addonName: string(),
16931
+ slot: PipelineSlotSchema,
16932
+ inputClasses: array(string()).readonly(),
16933
+ outputClasses: array(string()).readonly(),
16934
+ enabled: boolean(),
16935
+ modelId: string(),
16936
+ children: array(PipelineDefaultStepSchema).readonly(),
16937
+ group: string().optional(),
16938
+ settings: record(string(), unknown()).optional()
16939
+ }));
16940
+ var PipelineTemplateStepSchema = lazy(() => object({
16941
+ addonId: string(),
16942
+ enabled: boolean(),
16943
+ modelId: string(),
16944
+ children: array(PipelineTemplateStepSchema).readonly(),
16945
+ settings: record(string(), unknown()).optional()
16946
+ }));
16947
+ var PipelineTemplateSchema$1 = object({
16902
16948
  id: string(),
16903
- /** The CAMERA the event is attributed to (a sensor linked to N cameras
16904
- * yields N rows, one per camera). */
16905
- deviceId: number(),
16906
- /** The linked sensor device whose state changed. */
16907
- sourceDeviceId: number(),
16908
- /** Event kind id — matches an `EventKindDescriptor.kind`. */
16909
- kind: string(),
16910
- /** Snapshot of the sensor cap's runtime-state slice at the change. */
16911
- value: record(string(), unknown()).nullable(),
16912
- timestamp: number()
16913
- });
16914
- var TrackPositionSchema = object({
16915
- x: number(),
16916
- y: number(),
16917
- timestamp: number(),
16918
- bbox: BoundingBoxSchema
16949
+ name: string(),
16950
+ createdAt: string(),
16951
+ updatedAt: string(),
16952
+ engine: PipelineEngineChoiceSchema,
16953
+ steps: array(PipelineTemplateStepSchema).readonly()
16919
16954
  });
16920
- var TrackSnapshotSchema = object({
16921
- timestamp: number(),
16922
- position: TrackPositionSchema,
16923
- /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
16924
- mediaKey: string()
16955
+ var PipelineModelOptionSchema = object({
16956
+ id: string(),
16957
+ name: string(),
16958
+ formats: record(string(), object({
16959
+ downloaded: boolean(),
16960
+ sizeMB: number()
16961
+ })),
16962
+ group: ModelVariantGroupSchema.optional(),
16963
+ legacy: boolean().optional(),
16964
+ provider: ModelProviderIdSchema.optional()
16925
16965
  });
16926
- /**
16927
- * Normalized 0..1 trajectory envelope (min/max over every position bbox,
16928
- * divided by the track's detection-frame dims), computed at persist time.
16929
- * Absent when the frame dims were unknown when the track was persisted
16930
- * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
16931
- */
16932
- var TrackEnvelopeSchema = object({
16933
- minX: number(),
16934
- minY: number(),
16935
- maxX: number(),
16936
- maxY: number()
16966
+ var ConfigFieldBridge = custom();
16967
+ var PipelineAddonSchemaSchema = object({
16968
+ id: string(),
16969
+ name: string(),
16970
+ slot: PipelineSlotSchema,
16971
+ inputClasses: array(string()).readonly(),
16972
+ outputClasses: array(string()).readonly(),
16973
+ childSlots: array(PipelineSlotSchema).readonly(),
16974
+ models: array(PipelineModelOptionSchema).readonly(),
16975
+ defaultModelId: string(),
16976
+ defaultModelIdByFormat: record(string(), string()).optional(),
16977
+ enabledByDefault: boolean().optional(),
16978
+ backfillIntoExistingOverrides: boolean().optional(),
16979
+ defaultConfidence: number(),
16980
+ group: string().optional(),
16981
+ configSchema: array(ConfigFieldBridge).readonly().optional()
16937
16982
  });
16938
- /**
16939
- * Row projection for track list queries. `full` (default) returns the
16940
- * complete Track including the frame-rate `positions[]` history and the
16941
- * `snapshots[]` references — megabytes across a page of tracks. `slim`
16942
- * keeps every scalar the list surfaces actually render (ids, class(es),
16943
- * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
16944
- * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
16945
- * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
16946
- * `getTrack`. Mirrors the event-store `projection` convention
16947
- * (`getObjectEvents` et al.).
16948
- */
16949
- var TrackProjectionSchema = _enum(["full", "slim"]);
16950
- /**
16951
- * One audio-classification label heard on the track's camera while the
16952
- * track was alive, aggregated per label. An "episode" is one persisted
16953
- * audio event (the confident-classification path: score ≥ the device's
16954
- * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
16955
- * one 32 ms inference chunk, so counts stay human-scaled.
16956
- */
16957
- var TrackAudioLabelSchema = object({
16983
+ var PipelineSlotSchemaSchema = object({
16984
+ id: PipelineSlotSchema,
16958
16985
  label: string(),
16959
- /** Highest classification score observed across the label's episodes. */
16960
- peakScore: number(),
16961
- /** Number of coalesced audio-event episodes carrying this label. */
16962
- count: number(),
16963
- firstAt: number(),
16964
- lastAt: number()
16986
+ priority: number(),
16987
+ parentSlot: PipelineSlotSchema.nullable(),
16988
+ addons: array(PipelineAddonSchemaSchema).readonly()
16965
16989
  });
16966
- /**
16967
- * How a track was produced. `pipeline` (default / absent) = the spatial
16968
- * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
16969
- * no positions, a single snapshot, and no bbox trajectory at all:
16970
- *
16971
- * - `sensor` — a linked sensor/control device state change.
16972
- * - `audio` — an audio event on the camera itself that was anomalous for
16973
- * THAT camera, loud, and heard while nothing visual was happening (D62).
16974
- *
16975
- * The spatial subsystems (tracker association, occupancy count, re-id /
16976
- * embedding, resurrection) MUST skip every synthetic source. Test for that
16977
- * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
16978
- * check silently readmits every source added after it was written.
16979
- */
16980
- var TrackSourceSchema = _enum([
16981
- "pipeline",
16982
- "sensor",
16983
- "audio"
16984
- ]);
16985
- /**
16986
- * Where a track sits in the RETRAIN lifecycle (D81).
16987
- *
16988
- * - `none` — never marked, or un-marked. Evictable.
16989
- * - `staging` — the operator wants this track as training material and has not
16990
- * finished with it. **This is the only state retention holds**: the track and
16991
- * everything it owns (object events, crops, keyframes, CLIP vector) survive
16992
- * the device's age window.
16993
- * - `trained` — the retrain page has taken what it needed. The frames it chose
16994
- * were COPIED into the retrain dataset at selection time, so the dataset no
16995
- * longer depends on the track's media and the track becomes EVICTABLE again.
16996
- * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
16997
- * a deliberate action of the retrain page, not a side effect of a checkbox.
16998
- *
16999
- * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
17000
- * the store's filter language has only positive equality and `whereIn` — no
17001
- * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
17002
- * would make the entire pre-column history immortal in one deploy.
17003
- */
17004
- var RetrainStatusSchema = _enum([
17005
- "none",
17006
- "staging",
17007
- "trained"
17008
- ]);
17009
- /**
17010
- * Per-track OPERATOR flags — set by hand from the admin UI or the viewer, never
17011
- * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
17012
- * so the two surfaces cannot drift.
17013
- *
17014
- * **Absent ≠ false.** A track that has never been touched omits the field; an
17015
- * explicitly un-flagged track carries `false`. Legacy rows written before the
17016
- * columns existed read as absent, and a consumer that needs a boolean should say
17017
- * `flag === true`, not `flag !== false`.
17018
- *
17019
- * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
17020
- * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
17021
- * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
17022
- * `trained` track reports `false` while refusing both writes. The boolean is
17023
- * kept because three surfaces drive a toggle off it; anything that needs to tell
17024
- * "never marked" from "already trained" must read `retrainStatus`.
17025
- *
17026
- * `debug` does NOT pin; it is attention, not durability.
17027
- *
17028
- * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
17029
- * A favourited track is skipped by retention the same way `staging` is, but
17030
- * it does not enter `none|staging|trained` and has no staging budget.
17031
- */
17032
- var TrackFlagFields = {
17033
- /** Operator marked this track as training material — i.e. `retrainStatus` is
17034
- * `'staging'`. */
17035
- markForTrain: boolean().optional(),
17036
- /** Operator marked this track for diagnostic attention. */
17037
- debug: boolean().optional(),
17038
- /** Operator favourited this track. Pins it against pruning. */
17039
- favourited: boolean().optional()
17040
- };
17041
- /**
17042
- * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
17043
- * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
17044
- * write patch, and the status is not something the toggle sets — it is what the
17045
- * toggle's boolean is derived from. Absent on an in-RAM track never touched;
17046
- * always present on a persisted row (the column default materialises `'none'`).
17047
- */
17048
- var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
17049
- /**
17050
- * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
17051
- * one flag can never clear the other — the toggles are independent and are
17052
- * driven from three surfaces that do not know about each other.
17053
- */
17054
- var TrackFlagsPatchSchema = object(TrackFlagFields);
17055
- /**
17056
- * The resolved flag state after a write. Both fields are REQUIRED here (absent
17057
- * collapses to `false`) so a caller can drive a toggle's checked state off the
17058
- * mutation result without a re-fetch.
17059
- */
17060
- var TrackFlagsSchema = object({
17061
- trackId: string(),
17062
- markForTrain: boolean(),
17063
- debug: boolean(),
17064
- favourited: boolean(),
17065
- /** The lifecycle state the boolean was derived from. Required here (unlike on
17066
- * a track row) because this shape is only ever produced by the write body,
17067
- * which always knows it — and a surface that has just written needs to render
17068
- * `trained` without a re-fetch. */
17069
- retrainStatus: RetrainStatusSchema
16990
+ var PipelineSchemaSchema = object({
16991
+ availableEngines: array(AvailableEngineSchema).readonly(),
16992
+ selectedEngine: PipelineEngineChoiceSchema,
16993
+ slots: array(PipelineSlotSchemaSchema).readonly()
17070
16994
  });
17071
- union([literal(1), literal(2)]);
17072
- /**
17073
- * WHO decided a label, and when. Carried per tier so a value can be traced to
17074
- * the step and model that produced it — which is what makes the write rule
17075
- * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
17076
- * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
17077
- *
17078
- * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
17079
- * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
17080
- * `migration:4g` for a value the 4g migration moved from the single-slot era —
17081
- * that value has no provenance, and the write rule lets ANY properly-attributed
17082
- * write of the same tier replace it regardless of score.
17083
- */
17084
- var LabelAttributionSchema = object({
17085
- stepId: string(),
17086
- modelId: string().optional(),
17087
- decidedAt: number(),
16995
+ var EngineProvisioningSchema = object({
16996
+ runtimeId: _enum([
16997
+ "onnx",
16998
+ "openvino",
16999
+ "coreml",
17000
+ "edgetpu"
17001
+ ]).nullable(),
17002
+ device: string().nullable(),
17003
+ state: _enum([
17004
+ "idle",
17005
+ "installing",
17006
+ "verifying",
17007
+ "ready",
17008
+ "failed"
17009
+ ]),
17010
+ progress: number().optional(),
17011
+ error: string().optional(),
17012
+ nextRetryAt: number().optional(),
17088
17013
  /**
17089
- * The GALLERY id behind a recognised tier-2 label — a face-gallery
17090
- * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
17091
- *
17092
- * The text alone is a DISPLAY NAME, and a display name is renameable: a
17093
- * notification rule authored on "Gianluca" stopped matching the moment the
17094
- * operator fixed the spelling in the gallery, and nothing said so. The id is
17095
- * the thing that does not move, so it is what a rule matches on
17096
- * (`NcConditions.identities`) and the text is what a human is shown.
17097
- *
17098
- * Absent when the label names no gallery row — a plate the OCR read but no
17099
- * vehicle claims, a sub-class, a species, any tier-1 value.
17014
+ * Gate A (config-correctness gate at engine change): human-readable
17015
+ * config issues surfaced EAGERLY when the node's engine changes — model
17016
+ * substitutions ("chose X, running Y") and zero-build steps ("no model
17017
+ * has a <format> build"). Additive/optional: informational only, never
17018
+ * enforced here `assertEngineReady` (readiness) still gates inference.
17019
+ * Absent/empty when the node-default tree resolves cleanly.
17100
17020
  */
17101
- identityId: string().optional()
17021
+ configIssues: array(string()).optional()
17102
17022
  });
17103
- /**
17104
- * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
17105
- * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
17106
- * track and its events always answer the same question the same way.
17107
- *
17108
- * Two scalar columns, not an array: every consumer wants "the coarse one" or
17109
- * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
17110
- * is tier 2, and each carries its own score + attribution.
17111
- *
17112
- * **Reading it.** What a human should be shown is `subLabel ?? label` — the
17113
- * finest thing known. Before 4g the single `label` column held the finest
17114
- * value, so a consumer that has not been updated reads the tier-1 slot and
17115
- * shows nothing on a species-only row; that is why the migration puts every
17116
- * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
17117
- * and why the read surfaces were changed in the same train.
17118
- *
17119
- * **Writing it.** The slots are independent, which is the whole point: a
17120
- * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
17121
- * migratorius`), so fineness cannot regress by construction. Within a tier the
17122
- * higher score wins. One rule, one implementation — see
17123
- * `pipeline/label-tier.ts` in addon-post-analysis.
17124
- */
17125
- var TieredLabelFields = {
17126
- /** Tier 1 the sub-class. See {@link LabelTierSchema}. */
17127
- label: string().optional(),
17128
- /** Confidence of the tier-1 value, as reported by the deciding step. */
17129
- labelScore: number().optional(),
17130
- /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
17131
- labelMeta: LabelAttributionSchema.optional(),
17132
- /** Tier 2 — the instance. See {@link LabelTierSchema}. */
17133
- subLabel: string().optional(),
17134
- /** Confidence of the tier-2 value, as reported by the deciding step. */
17135
- subLabelScore: number().optional(),
17136
- /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
17137
- subLabelMeta: LabelAttributionSchema.optional()
17138
- };
17139
- /** Per-camera slice of a training-export estimate. */
17140
- var TrainingExportDeviceTotalsSchema = object({
17141
- deviceId: number(),
17142
- tracks: number().int(),
17143
- files: number().int(),
17144
- bytes: number().int()
17023
+ var PipelineStepInputSchema = lazy(() => object({
17024
+ addonId: string(),
17025
+ modelId: string().optional(),
17026
+ enabled: boolean().default(true),
17027
+ children: array(PipelineStepInputSchema).optional(),
17028
+ settings: record(string(), unknown()).optional(),
17029
+ jumpDeviceKey: string().optional()
17030
+ }));
17031
+ var ModelSubstitutionSchema = object({
17032
+ addonId: string(),
17033
+ chosen: string(),
17034
+ running: string(),
17035
+ format: string()
17036
+ });
17037
+ var PipelineValidationIssueSchema = object({
17038
+ addonId: string(),
17039
+ kind: _enum(["unknown-addon", "no-format-build"]),
17040
+ detail: string()
17041
+ });
17042
+ var PipelineValidationResultSchema = object({
17043
+ ok: boolean(),
17044
+ issues: array(PipelineValidationIssueSchema).readonly(),
17045
+ substitutions: array(ModelSubstitutionSchema).readonly(),
17046
+ /** The node's `currentEngine.format` this validation ran against. */
17047
+ format: string()
17048
+ });
17049
+ var ReferenceImageEntrySchema = object({
17050
+ filename: string(),
17051
+ stepIds: array(string()).readonly().optional()
17052
+ });
17053
+ var ReferenceImageBodySchema = object({
17054
+ base64: string(),
17055
+ filename: string()
17056
+ });
17057
+ var ReferenceAudioEntrySchema = object({
17058
+ filename: string(),
17059
+ sizeKb: number()
17060
+ });
17061
+ var ReferenceAudioBodySchema = object({ base64: string() });
17062
+ var AudioBackendSchema = object({
17063
+ id: string(),
17064
+ name: string(),
17065
+ description: string(),
17066
+ available: boolean(),
17067
+ /**
17068
+ * Raw classifier labels this backend can emit (e.g. YAMNet's
17069
+ * 521-class set or Apple SoundAnalysis's 303-class set). Used by
17070
+ * the benchmark UI to populate the `enabledMicroClasses` filter
17071
+ * specific to the selected backend without a separate fetch.
17072
+ */
17073
+ rawLabels: array(string()).readonly().optional()
17074
+ });
17075
+ var AudioCapabilitiesSchema = object({
17076
+ activeBackend: string(),
17077
+ availableBackends: array(AudioBackendSchema).readonly(),
17078
+ sampleRate: number(),
17079
+ chunkDurationMs: number()
17080
+ });
17081
+ var DownloadModelResultSchema = object({
17082
+ filePath: string(),
17083
+ sizeMB: number(),
17084
+ durationMs: number()
17145
17085
  });
17146
17086
  /**
17147
- * What a training export WOULD contain. Computed from media index rows only —
17148
- * no blob is read to produce this.
17087
+ * Wrapper carrying a single test run's result. Replaces the legacy
17088
+ * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
17089
+ * canonical `AudioResult` from the Phase 6 output rework: one
17090
+ * `AudioDetection` per class above `minScore`, top-N candidates in
17091
+ * `debug.alternateLabels['audio-classifier']`, per-source timings in
17092
+ * `debug.stepTimings`. The outer `success`/`error` fields stay so the
17093
+ * benchmark UI can still report a clean failure when the classifier
17094
+ * cap isn't available.
17149
17095
  */
17150
- var TrainingExportSummarySchema = object({
17151
- generatedAt: number(),
17152
- trackCount: number().int(),
17153
- fileCount: number().int(),
17154
- byteCount: number().int(),
17155
- /** More marked tracks exist than a single pass carries. */
17156
- truncated: boolean(),
17157
- devices: array(TrainingExportDeviceTotalsSchema).readonly()
17096
+ var AudioTestResultSchema = object({
17097
+ success: boolean(),
17098
+ error: string().optional(),
17099
+ frame: custom().optional()
17158
17100
  });
17159
- var TrackSchema = object({
17160
- trackId: string(),
17161
- deviceId: number(),
17162
- className: string(),
17163
- ...TieredLabelFields,
17164
- producingDeviceName: string().optional(),
17165
- /** Track provenance. Absent `pipeline` (legacy rows). */
17166
- source: TrackSourceSchema.optional(),
17167
- firstSeen: number(),
17168
- lastSeen: number(),
17169
- /** Frame-rate position history (subject to maxPositionHistory cap). */
17170
- positions: array(TrackPositionSchema).readonly(),
17171
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
17172
- * saveThumbnails policy). */
17173
- snapshots: array(TrackSnapshotSchema).readonly(),
17174
- /** Deduplicated zones the track has entered at least once. Zone IDS. */
17175
- zonesVisited: array(string()).readonly(),
17101
+ var PipelineConfigBridge = custom();
17102
+ var ConfigUISchemaBridge = custom();
17103
+ var ConfigUISchemaNullableBridge = custom();
17104
+ var InferenceCapabilitiesBridge = custom();
17105
+ var ModelAvailabilityListBridge = custom();
17106
+ var PipelineRunResultBridge = custom();
17107
+ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
17108
+ modelId: string(),
17109
+ settings: record(string(), unknown()).readonly()
17110
+ }))), method(object({ steps: record(string(), object({
17111
+ modelId: string(),
17112
+ settings: record(string(), unknown()).readonly()
17113
+ })) }), object({ success: literal(true) }), {
17114
+ kind: "mutation",
17115
+ auth: "admin"
17116
+ }), method(object({ nodeId: string() }), object({
17117
+ success: literal(true),
17118
+ clearedDevices: number()
17119
+ }), {
17120
+ kind: "mutation",
17121
+ auth: "admin"
17122
+ }), method(object({ nodeId: string() }), object({ unhealthy: array(object({
17123
+ /** `<backend>:<device>`, e.g. `openvino:gpu`. */
17124
+ deviceKey: string(),
17176
17125
  /**
17177
- * Human NAMES for {@link zonesVisited}, resolved at READ time against the
17178
- * `zones` capability.
17179
- *
17180
- * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
17181
- * and no card can render — so every free-text search surface was structurally
17182
- * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
17183
- * just returned nothing. Resolving here rather than in each client keeps ONE
17184
- * derivation and costs the clients no extra call (the `zones` cap is
17185
- * per-device, so a client-side resolve would be a per-camera fan-out on a
17186
- * surface built to avoid exactly that).
17187
- *
17188
- * Resolved, never invented: a zone deleted since the track was written has no
17189
- * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
17190
- * two are not positionally aligned. Absent when the track visited no zone, or
17191
- * when the zone catalogue could not be read.
17126
+ * `failed` the per-device restart budget is exhausted; no pool
17127
+ * will be spawned until an operator re-arms it or the runner
17128
+ * respawns. `backoff` — under budget, waiting out the backoff (or
17129
+ * a cached pool observed dead and not yet condemned).
17192
17130
  */
17193
- zoneNames: array(string()).readonly().optional(),
17194
- /** Deduplicated set of detector classes observed for this track over its
17195
- * life (a track may be reclassified, e.g. person→vehicle). Absent on
17196
- * legacy rows written before class accumulation shipped. */
17197
- classes: array(string()).readonly().optional(),
17198
- /** Cumulative normalized distance travelled (0..1 units = full frame width). */
17199
- totalDistance: number(),
17200
- state: TrackStateSchema,
17201
- active: boolean(),
17202
- /** Deterministic key-event importance score in [0,1] (server-computed at
17203
- * track expiry, recomputed on late label). Absent on legacy rows written
17204
- * before scoring shipped — consumers degrade to absence / compute-on-read. */
17205
- importance: number().optional(),
17206
- /** Id of the track's highest-confidence ObjectEvent (its representative
17207
- * "best" frame). Absent when the track produced no object events. */
17208
- bestEventId: string().optional(),
17209
- /** Tag of the importance sub-signal that dominated the score
17210
- * (identity|dwell|proximity|class|confidence|travel|zone). */
17211
- importanceReason: string().optional(),
17212
- /** Audio-classification labels heard on the camera during the track's
17213
- * life (score ≥ device `classificationMinScore`), aggregated per label.
17214
- * Absent on legacy rows / tracks with no confident audio. */
17215
- audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
17216
- /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
17217
- * Populated from the persisted envelope columns on historical reads;
17218
- * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
17219
- envelope: TrackEnvelopeSchema.optional(),
17131
+ state: _enum(["failed", "backoff"]),
17132
+ /** Epoch ms of the death that produced this state. */
17133
+ since: number(),
17134
+ /** Pool deaths inside the current window. */
17135
+ deaths: number(),
17136
+ /** The last death's message. */
17137
+ lastError: string()
17138
+ })).readonly() })), method(object({
17139
+ nodeId: string(),
17140
+ deviceKey: string()
17141
+ }), object({ rearmed: boolean() }), {
17142
+ kind: "mutation",
17143
+ auth: "admin"
17144
+ }), 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({
17145
+ name: string(),
17146
+ steps: array(PipelineTemplateStepSchema).readonly(),
17147
+ engine: PipelineEngineChoiceSchema
17148
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
17149
+ id: string(),
17150
+ name: string().optional(),
17151
+ steps: array(PipelineTemplateStepSchema).readonly().optional()
17152
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
17153
+ addonId: string(),
17154
+ modelId: string(),
17155
+ format: ModelFormatSchema$1
17156
+ }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
17157
+ addonId: string(),
17158
+ modelId: string(),
17159
+ format: ModelFormatSchema$1
17160
+ }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
17161
+ engine: PipelineEngineChoiceSchema.optional(),
17162
+ steps: array(PipelineStepInputSchema).min(1),
17163
+ frame: FrameInputSchema.optional(),
17220
17164
  /**
17221
- * A face DETECTOR found a face on this track — nothing more. It says the
17222
- * detail plane produced a `face` detail; it does NOT say the face was
17223
- * embedded, matched, above `minFacePx`, or that the recognizer was even
17224
- * enabled. Set once and never cleared.
17225
- *
17226
- * **This exists so "face present but not recognised" is expressible.** A
17227
- * recognised identity lands in `subLabel` (attributed to the face chain via
17228
- * `subLabelMeta.stepId`), so before this field a track with an unmatched face
17229
- * and a track with no face at all were byte-identical on the wire and no
17230
- * surface could tell them apart. The read is `hasFace === true && subLabel
17231
- * === undefined`.
17232
- *
17233
- * **Absent ≠ false.** Every row written before the column existed omits it,
17234
- * and so does every server that predates the field — a consumer must test
17235
- * `=== true` and render nothing otherwise, never infer "no face".
17165
+ * Process-local lazy frame. Valid only when caller and provider resolve
17166
+ * in the same execution-group process; split/cross-node callers use
17167
+ * `frame`/`image` inline compatibility instead.
17236
17168
  */
17237
- hasFace: boolean().optional(),
17169
+ frameRef: FrameRefSchema.optional(),
17238
17170
  /**
17239
- * This track has a face row IN THE GALLERY: a crop **and** an embedding a
17240
- * face an operator could ASSIGN to an identity.
17241
- *
17242
- * The STRICT twin of {@link hasFace}, and the pair only earns its keep
17243
- * because the two disagree. `hasFace` is stamped at the TOP of the face
17244
- * branch, before every gate, and means no more than "a face detector produced
17245
- * a face detail". This one is stamped at the single moment the gallery row
17246
- * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
17247
- * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
17248
- * candidate gate, the imageless-track drop (no crop was ever captured) and
17249
- * the crop-store drop. Everything between the detector and that insert can
17250
- * legitimately refuse the face, so a flag written any earlier promises the
17251
- * operator something to assign and delivers nothing.
17252
- *
17253
- * **Independent of recognition.** A face collected but never auto-matched is
17254
- * still assignable — it is in fact the face an operator most wants to reach —
17255
- * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
17256
- * `subLabel`; this says only that the raw material exists.
17257
- *
17258
- * **Set once, never cleared.** A track that produced a gallery row produced
17259
- * one; deleting the row later is the gallery's business, not this flag's.
17260
- *
17261
- * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
17262
- * before the column omits it, and so does every server that predates the
17263
- * field. A consumer must test `=== true` and render nothing otherwise —
17264
- * never infer "no assignable face".
17171
+ * CB5 shm passthrough a `FrameHandle` naming the same ring slot
17172
+ * the decoded pixels live in. One more member of the one-of
17173
+ * frame/frameHandle/image/imageBase64/referenceImage group.
17265
17174
  */
17266
- hasEmbeddedFace: boolean().optional(),
17175
+ frameHandle: FrameHandleSchema.optional(),
17176
+ imageBase64: string().optional(),
17267
17177
  /**
17268
- * This subject CONTAINS a folded rider a person the rider-pairing step
17269
- * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
17270
- * so the passage is tracked once and as a VEHICLE.
17271
- *
17272
- * It exists because the fold's record was dishonest. D34 and the code both
17273
- * said "the person is not lost — it is reported so both entities stay on the
17274
- * record"; in fact the pair went into a per-processor RAM field behind an
17275
- * accessor nobody called, and every durable surface said `vehicle`, full
17276
- * stop. This is the composition note that makes the row true.
17277
- *
17278
- * A COMPOSITION, never a class and never a label. "This vehicle contains a
17279
- * person" is not an answer to "what is this" — both label tiers would refuse
17280
- * a macro token anyway (D89), and correctly. Nothing here changes what the
17281
- * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
17282
- * and a `person` rule still does not fire for someone cycling past.
17283
- *
17284
- * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
17285
- * the column, and every hub that predates the field, omits it. Test
17286
- * `=== true` and render nothing otherwise — never infer "no rider".
17178
+ * Binary JPEG bytespreferred over `imageBase64` on internal
17179
+ * hops (hub forked worker via Moleculer MsgPack) because it
17180
+ * skips the 33% base64 overhead + the per-call base64 decode on
17181
+ * the detection-pipeline worker. Callers can pass either; exactly
17182
+ * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
17287
17183
  */
17288
- hasRider: boolean().optional(),
17289
- ...TrackFlagFields,
17290
- ...TrackRetrainFields
17291
- });
17292
- var BaseEventFields = {
17293
- id: string(),
17294
- deviceId: number(),
17295
- timestamp: number()
17296
- };
17297
- var MotionEventSchema = object({
17298
- ...BaseEventFields,
17299
- kind: literal("motion"),
17300
- regionCount: number(),
17301
- /** Heavy JSON array omitted in slim projection. */
17302
- regions: array(object({
17303
- bbox: BoundingBoxSchema,
17304
- pixelCount: number(),
17305
- intensity: number()
17306
- })).readonly().optional(),
17307
- /** Omitted in slim projection. */
17308
- frameWidth: number().optional(),
17309
- /** Omitted in slim projection. */
17310
- frameHeight: number().optional(),
17311
- /** Populated by B5 (recording playback URL for this event). */
17312
- mediaUrl: string().optional()
17313
- });
17184
+ image: _instanceof(Uint8Array).optional(),
17185
+ referenceImage: string().optional(),
17186
+ deviceId: number().optional(),
17187
+ sessionId: string().optional(),
17188
+ /**
17189
+ * Execution plane. 'full' (default) runs the whole tree — benchmark,
17190
+ * reference-image, and detail-subtree calls. 'frame' is the live
17191
+ * per-frame dispatch: ONLY root-plane steps run; crop children
17192
+ * (inputClasses ≠ null) are skipped and served per-track via
17193
+ * pipelineRunner.runDetailSubtree (two-plane design).
17194
+ */
17195
+ plane: _enum(["full", "frame"]).optional(),
17196
+ /**
17197
+ * Inference-device selector (Phase 2 multi-device). Format
17198
+ * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
17199
+ * Omitted ⇒ the runner's default device (current single-engine
17200
+ * behaviour). Selects WHICH device pool of the node runs the call.
17201
+ */
17202
+ deviceKey: string().optional(),
17203
+ /**
17204
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
17205
+ * when the parent crop was resolved from the frame's retained NATIVE
17206
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
17207
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
17208
+ * resolution from that surface — the SAME quality path faces already
17209
+ * had — instead of the downscaled parent tile. `handle` keys the native
17210
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
17211
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
17212
+ * the executor's crop-normalized child ROI back into frame-normalized
17213
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
17214
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
17215
+ * (today's behaviour on the fallback path).
17216
+ */
17217
+ nativeCropRef: NativeCropRefSchema.optional()
17218
+ }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
17219
+ engine: PipelineEngineChoiceSchema.optional(),
17220
+ steps: array(PipelineStepInputSchema).min(1),
17221
+ frames: array(FrameInputSchema).min(1).max(255),
17222
+ deviceId: number().optional(),
17223
+ sessionId: string().optional(),
17224
+ /**
17225
+ * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
17226
+ * the batch to the Python pool's bench preprocess cache
17227
+ * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
17228
+ * preprocessed ONCE and every later inference is a pure-inference cache
17229
+ * hit — the sustained-throughput run measures inference, not
17230
+ * decode+preprocess+infer. Omitted/0 for live frames (all different →
17231
+ * full preprocess every call, correct). Fresh per sustained run;
17232
+ * released via `uncacheFrame`.
17233
+ */
17234
+ frameId: number().int().nonnegative().optional(),
17235
+ /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
17236
+ deviceKey: string().optional()
17237
+ }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
17238
+ data: _instanceof(Uint8Array),
17239
+ width: number().int().positive(),
17240
+ height: number().int().positive(),
17241
+ format: _enum([
17242
+ "rgb",
17243
+ "bgr",
17244
+ "gray"
17245
+ ])
17246
+ }), object({
17247
+ frameId: number(),
17248
+ width: number(),
17249
+ height: number()
17250
+ }), { kind: "mutation" }), method(object({
17251
+ stepId: string(),
17252
+ frameId: number().int()
17253
+ }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
17254
+ batchMode: string(),
17255
+ windowMs: number(),
17256
+ maxBatchSize: number(),
17257
+ concurrency: number()
17258
+ })), method(_void(), array(object({
17259
+ engineKey: string(),
17260
+ engine: PipelineEngineChoiceSchema,
17261
+ modelsLoaded: array(string()).readonly(),
17262
+ inUseByCameras: array(number()).readonly(),
17263
+ /**
17264
+ * Origin of this resident factory.
17265
+ * - `runtime` — main camera-serving engine (no idle TTL).
17266
+ * - `warm-override` — benchmark/test override held in the warm
17267
+ * cache; auto-disposed after the idle TTL.
17268
+ * - `device-pool` — a concurrent per-device pool (Phase 2
17269
+ * multi-device, keyed by `deviceKey`) resolved
17270
+ * via `resolveDeviceFactory`. Runs alongside the
17271
+ * `runtime` engine on a DIFFERENT accelerator
17272
+ * (NPU / iGPU / Coral) — this is how the
17273
+ * Engines tab shows all pools running at once.
17274
+ */
17275
+ kind: _enum([
17276
+ "runtime",
17277
+ "warm-override",
17278
+ "device-pool"
17279
+ ]),
17280
+ /** Native pid of the underlying Python pool (null when no pool). */
17281
+ poolPid: number().nullable(),
17282
+ /** ms since this factory was last used (null when not warm-tracked). */
17283
+ idleMs: number().nullable(),
17284
+ /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
17285
+ idleTtlMs: number().nullable()
17286
+ })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
17287
+ kind: "mutation",
17288
+ auth: "admin"
17289
+ }), method(object({
17290
+ engine: PipelineEngineChoiceSchema,
17291
+ force: boolean().optional()
17292
+ }), object({
17293
+ success: boolean(),
17294
+ reason: string().optional()
17295
+ }), {
17296
+ kind: "mutation",
17297
+ auth: "admin"
17298
+ }), 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({
17299
+ addonId: string(),
17300
+ modelId: string(),
17301
+ filename: string().optional(),
17302
+ settings: record(string(), unknown()).optional()
17303
+ }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
17314
17304
  /**
17315
- * Which detection SOURCE produced an object event. `pipeline` = the ML
17316
- * detection pipeline (decoded-frame inference); `onboard` = the camera's
17317
- * native on-device AI. Both flow through the SAME analysis layers (zoning,
17318
- * tracking, per-kind persistence) but stay distinguishable so consumers
17319
- * (advanced-notifier, occupancy, …) can select which source(s) to act on.
17320
- * Absent on legacy rows treat as `pipeline`.
17305
+ * Per-stage gating mode applied to the zones a rule references.
17306
+ *
17307
+ * - `include`: the rule contributes to a **whitelist** for its stage.
17308
+ * When at least one `include` rule fires for a stage, only entities
17309
+ * inside one of those zones pass that stage.
17310
+ * - `exclude`: the rule contributes to a **blacklist** for its stage.
17311
+ * Entities inside one of those zones are dropped at that stage.
17312
+ *
17313
+ * `monitor`-style observation (count without filtering) is not a rule
17314
+ * mode — zones without any matching rule are observed naturally by
17315
+ * `zone-analytics` (live snapshot + history), so an "I just want to
17316
+ * count, not filter" use case needs no rule at all.
17321
17317
  */
17322
- var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
17318
+ var ZoneRuleModeEnum = _enum(["include", "exclude"]);
17323
17319
  /**
17324
- * The confirmed zone crossing that produced an object event. Present ONLY on
17325
- * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
17326
- * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
17327
- * appearance event carry none, so a rule asking for a direction fails closed
17328
- * on them.
17320
+ * Per-consumer rule that references existing zones (geometry) and
17321
+ * defines how a specific pipeline stage should treat them. Each
17322
+ * consumer addon owns its own `ZoneRule[]` array in its per-device
17323
+ * settings:
17329
17324
  *
17330
- * Exactly ONE crossing per event: the emitter turns each confirmed crossing
17331
- * into its own event, so a frame in which a track enters A while leaving B
17332
- * produces two events with two directions — never one ambiguous row.
17325
+ * - `addon-motion-wasm` `motionZoneRules: ZoneRule[]` (motion stage)
17326
+ * - `addon-detection-pipeline` `detectionZoneRules: ZoneRule[]` (detection stage)
17327
+ * - future: notification rules, audio gating, etc.
17333
17328
  *
17334
- * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
17335
- * membership the box has NOW, and by definition it no longer contains the zone
17336
- * that was just left. Without the id here, a zone-scoped rule could never match
17337
- * the exit it asked for.
17329
+ * One rule applies to N zones (`zoneIds[]`) so the operator can
17330
+ * express "ignore motion in ALL of {garden, street}" with a single
17331
+ * rule. `classFilter` narrows the rule to specific object classes
17332
+ * "drop person detections in the street, but keep cars" is one
17333
+ * `exclude` rule with `classFilter: ['person']`.
17334
+ *
17335
+ * `enabled` is a soft toggle — the operator can keep the rule
17336
+ * configured but inert without deleting it.
17338
17337
  */
17339
- var ZoneCrossingSchema = object({
17340
- direction: _enum(["enter", "exit"]),
17341
- /** Admin zone id crossed. */
17342
- zoneId: string(),
17343
- /** Zone display name at crossing time (falls back to the id). */
17344
- zoneName: string().optional()
17345
- });
17346
- var ObjectEventSchema = object({
17347
- ...BaseEventFields,
17348
- kind: literal("object"),
17349
- /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
17350
- source: DetectionSourceSchema.optional(),
17338
+ var ZoneRuleSchema = object({
17339
+ /** Stable rule id — survives edits, used by the UI for diffing. */
17340
+ id: string(),
17341
+ /** Optional human-readable label rendered in the rule editor. */
17342
+ name: string().optional(),
17343
+ /** Zones this rule targets. The rule's `mode` applies to ALL
17344
+ * listed zones (OR-set: a detection in any one of them counts).
17345
+ * At least one zone id required — a rule with no targets is a
17346
+ * configuration mistake and the form validator rejects it. */
17347
+ zoneIds: array(string()).min(1).readonly(),
17348
+ mode: ZoneRuleModeEnum,
17351
17349
  /**
17352
- * Inference-frame id shared by every object event emitted from the SAME frame
17353
- * the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
17354
- * 2 people + 1 dog) under one full frame, and link a track's frames over time
17355
- * (group by `trackId`, pick a representative `frameId` as the parent frame).
17356
- * Optional for backward-compat with pre-existing rows / the slim projection
17357
- * includes it (it is light). Absent on rows written before this field.
17350
+ * Class names this rule applies to. Empty / undefined rule
17351
+ * applies to every class. Class strings match the `macroClass`
17352
+ * field on detections (e.g. `person`, `car`, `dog`).
17358
17353
  */
17359
- frameId: string().optional(),
17360
- /** Omitted in slim projection. */
17361
- trackId: string().optional(),
17362
- className: string(),
17363
- ...TieredLabelFields,
17364
- /** Omitted in slim projection. */
17365
- confidence: number().optional(),
17366
- /** Heavy JSON — omitted in slim projection. */
17367
- bbox: BoundingBoxSchema.optional(),
17368
- /** Heavy JSON — omitted in slim projection. */
17369
- zones: array(string()).readonly().optional(),
17370
- /** Omitted in slim projection. */
17371
- state: TrackStateSchema.optional(),
17354
+ classFilter: array(string()).readonly().optional(),
17372
17355
  /**
17373
- * The zone crossing this event IS, when it is one. Absent on every other
17374
- * event kind (movement state, appearance, package) see
17375
- * {@link ZoneCrossingSchema}. Omitted in slim projection.
17356
+ * Minimum bbox/mask overlap (0–1) with any of the rule's zones
17357
+ * required to consider an entity "in the zone". Defaults to the
17358
+ * consumer's stage default when omitted. Kept for back-compat with
17359
+ * existing per-rule overrides; new operators pick the value via
17360
+ * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
17361
+ * set, the lower-level engine reads it as a 0–1 fraction.
17376
17362
  */
17377
- zoneCrossing: ZoneCrossingSchema.optional(),
17378
- /** Detection-frame dimensions in pixels — let consumers normalize the
17379
- * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
17380
- frameWidth: number().optional(),
17381
- frameHeight: number().optional(),
17382
- /** MediaStore key for the crop attached to this event (if any). */
17383
- mediaKey: string().optional(),
17384
- /** Design B: MediaStore key of the track's native-resolution key frame (the
17385
- * best-detection full frame). Resolve via the event-media data-plane
17386
- * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
17387
- * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
17388
- * sources — consumers fall back to `mediaKey` (the tight crop). */
17389
- keyFrameMediaKey: string().optional(),
17390
- /** Populated by B5 (recording playback URL for this event). */
17391
- mediaUrl: string().optional(),
17392
- /** The parent track's key-event importance [0,1], propagated to every object
17393
- * event of the track (so an event row can be sorted by importance without a
17394
- * track join). Absent on legacy rows / before the track was scored. */
17395
- importance: number().optional()
17396
- });
17397
- var AudioEventSchema = object({
17398
- ...BaseEventFields,
17399
- kind: literal("audio"),
17400
- rms: number(),
17401
- dbfs: number(),
17402
- classification: object({
17403
- className: string(),
17404
- originalClass: string().optional(),
17405
- score: number()
17406
- }).optional(),
17407
- /** Populated by B5 (recording playback URL for this event). */
17408
- mediaUrl: string().optional()
17409
- });
17410
- var MediaFileKindEnum = _enum([
17411
- "crop",
17412
- "thumbnail",
17413
- "snapshot",
17414
- "firstFrame",
17415
- "lastFrame",
17416
- "fullFrame",
17417
- "fullFrameBoxed",
17418
- "faceCrop",
17419
- "plateCrop",
17420
- "keyFrame",
17421
- "keyFrameSmall",
17422
- "thumbnailSmall"
17423
- ]);
17424
- var MediaFileSchema = object({
17425
- key: string(),
17426
- kind: MediaFileKindEnum,
17427
- base64: string(),
17428
- sizeBytes: number(),
17429
- timestamp: number()
17363
+ overlapThreshold: number().min(0).max(1).optional(),
17364
+ /**
17365
+ * Operator-friendly version of `overlapThreshold` the percentage
17366
+ * of the detection's bbox that must lie inside the zone for the
17367
+ * rule to match. Documented default is 85%; the engine substitutes
17368
+ * that when the field is omitted (kept optional so existing rules
17369
+ * stored without it stay valid).
17370
+ *
17371
+ * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
17372
+ * rule, the engine prefers `bboxInclusionPct` because it's the
17373
+ * field exposed in the UI. Internally both feed the same gate.
17374
+ */
17375
+ bboxInclusionPct: number().min(0).max(100).optional(),
17376
+ /**
17377
+ * When `true` and a detection has a segmentation mask, use the
17378
+ * mask for overlap instead of the bbox. Detection-stage only;
17379
+ * motion rules ignore this field.
17380
+ */
17381
+ preferMask: boolean().optional(),
17382
+ /**
17383
+ * Soft-toggle: `false` disables the rule without deleting it.
17384
+ * Defaults to `true` so operators creating a rule via the UI
17385
+ * see it active immediately.
17386
+ */
17387
+ enabled: boolean().default(true)
17430
17388
  });
17389
+ array(ZoneRuleSchema).readonly();
17431
17390
  /**
17432
- * One media row WITHOUT its bytes.
17391
+ * Zone pure geometry + identity. NO filtering behaviour.
17433
17392
  *
17434
- * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
17435
- * 140 s track), and a client that renders tiles from the media data plane needs
17436
- * to know only WHAT EXISTS the bytes then arrive per tile, lazily, over HTTP
17437
- * with an immutable cache, instead of all at once inside a tRPC response that
17438
- * blocks the whole view.
17393
+ * Zones describe **where** in the frame the operator wants to flag
17394
+ * something; consumer-owned {@link ZoneRule} arrays describe **how**
17395
+ * each pipeline stage uses them. Splitting the two means a single
17396
+ * polygon "Driveway" can simultaneously back a motion-exclude rule,
17397
+ * a detection-include rule on `['car']`, and an occupancy aggregate
17398
+ * — without three duplicated polygons.
17439
17399
  *
17440
- * `sizeBytes` is carried because it is what lets a client decide between the
17441
- * stored blob and a `?variant=thumb` rendering without fetching either.
17400
+ * Owned by the orchestrator addon (provider) and mirrored into the
17401
+ * `zones` device-state slice on every mutation. Consumers
17402
+ * (motion-wasm, pipeline-executor, analytics, admin UI) read either
17403
+ * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
17404
+ * mirror with `onChanged`).
17405
+ *
17406
+ * Coordinates are normalised fractions of the frame (0–1) so zones
17407
+ * survive resolution changes and stream profile switches.
17408
+ *
17409
+ * `kind` discriminates between full polygons (closed regions used
17410
+ * for intrusion / occupancy filters) and tripwires (open 2-point
17411
+ * line segments used for cross events). Onboard / firmware-reported
17412
+ * zones (Reolink, ONVIF) are out of scope for now — see the deferred
17413
+ * task list.
17442
17414
  */
17443
- var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
17415
+ var ZoneKindEnum = _enum(["polygon", "tripwire"]);
17416
+ /** Polygon vertex in fraction-of-frame coordinates (0–1). */
17417
+ var PolygonPointSchema = object({
17418
+ x: number(),
17419
+ y: number()
17420
+ });
17421
+ /** A camera detection zone — pure geometry/identity. */
17422
+ var ZoneSchema = object({
17423
+ id: string(),
17424
+ name: string(),
17425
+ kind: ZoneKindEnum.default("polygon"),
17426
+ /** Polygon vertices, fraction of frame (0–1). */
17427
+ polygon: array(PolygonPointSchema).readonly(),
17428
+ /** Visual color for UI rendering. */
17429
+ color: string().default("#3b82f6")
17430
+ });
17431
+ DeviceType.Camera, method(object({ deviceId: number() }), array(ZoneSchema).readonly()), method(object({
17432
+ deviceId: number(),
17433
+ zone: ZoneSchema
17434
+ }), _void(), {
17435
+ kind: "mutation",
17436
+ auth: "admin"
17437
+ }), method(object({
17438
+ deviceId: number(),
17439
+ zoneId: string()
17440
+ }), _void(), {
17441
+ kind: "mutation",
17442
+ auth: "admin"
17443
+ }), method(object({
17444
+ deviceId: number(),
17445
+ zone: ZoneSchema
17446
+ }), _void(), {
17447
+ kind: "mutation",
17448
+ auth: "admin"
17449
+ }), object({ zones: array(ZoneSchema).readonly() });
17444
17450
  /**
17445
- * The MACRO tier of an annotation — a CLOSED set.
17451
+ * pipeline-analytics device-scoped wrapper cap. Refines raw
17452
+ * per-frame detections emitted by the pipeline runner into tracked
17453
+ * objects, per-kind event collections (motion / object / audio), and
17454
+ * persisted media. Owns the post-detection domain end-to-end:
17446
17455
  *
17447
- * This is what the exported detector predicts, so a typo here is a new class
17448
- * with one example in it. `label` and `subLabel` are open strings by contrast:
17449
- * the whole point of the page is teaching the model things it does not know
17450
- * yet, and constraining that vocabulary would make it useless.
17456
+ * runner emits PipelineInferenceResult
17457
+ * (event bus)
17458
+ * pipeline-analytics subscriber
17459
+ * SORT tracker + zone engine + state analyzer + event emitter
17460
+ * → three DB collections (one per kind), one FS media tree, one
17461
+ * unified event emitter (FrameTracked + TrackStarted/Ended +
17462
+ * DetectionEvent on bus)
17451
17463
  *
17452
- * A macro class is NEVER a label. The provider refuses a write whose `label` or
17453
- * `subLabel` is one of these values, in any casing, because once `person`
17454
- * exists in both tiers "every person box" stops being answerable without
17455
- * knowing every string anyone ever typed — and the damage is retroactive.
17464
+ * Pure subscriber model. No `processFrame` cap method the runner
17465
+ * already publishes the raw frame on the bus. The cap surface is
17466
+ * only QUERIES + per-device settings, bound on/off via
17467
+ * `device-manager.setWrapperActive`. `defaultActive: true` because
17468
+ * every camera with a detection pipeline wants its raw detections
17469
+ * refined; operators opt out per-device via BindingsTab when needed.
17470
+ *
17471
+ * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
17472
+ * (per-device surface) and `track-trail` caps — see P11 cleanup.
17456
17473
  */
17457
- var RetrainMacroClassSchema = _enum([
17474
+ var TrackStateSchema = _enum([
17475
+ "new",
17476
+ "entered",
17477
+ "left",
17478
+ "moving",
17479
+ "idle"
17480
+ ]);
17481
+ var EventKindSchema = _enum([
17482
+ "motion",
17483
+ "object",
17484
+ "audio"
17485
+ ]);
17486
+ /**
17487
+ * Spatial filter for `listTracks` — the rect + polygon variants of the shared
17488
+ * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
17489
+ * of the camera frame (top-left origin), matching the drawing-plane editor.
17490
+ */
17491
+ var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
17492
+ /** Closed icon vocabulary so clients render a known glyph per kind. */
17493
+ var EventKindIconSchema = _enum([
17494
+ "motion",
17495
+ "audio",
17458
17496
  "person",
17459
17497
  "vehicle",
17460
17498
  "animal",
17499
+ "door",
17500
+ "pir",
17501
+ "smoke",
17502
+ "water",
17503
+ "button",
17461
17504
  "package",
17462
- "face",
17463
- "plate"
17505
+ "generic"
17464
17506
  ]);
17465
- /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
17466
- var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
17467
- /** Did a human draw this box, or did the assist propose it? */
17468
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
17469
- /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
17470
- var RetrainBboxSchema = object({
17471
- x: number(),
17472
- y: number(),
17473
- w: number(),
17474
- h: number()
17475
- });
17476
- /**
17477
- * One annotated subject.
17478
- *
17479
- * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
17480
- * (letterboxed root / zone-cropped package / subject-cropped classifier) are
17481
- * derived from it at export and never stored storing them is how one feature
17482
- * space ends up holding two crops of the same subject (D52).
17483
- */
17484
- var RetrainAnnotationSchema = object({
17485
- id: string(),
17486
- trackId: string(),
17487
- deviceId: number(),
17488
- /** The COPY in retrain storage — never the source track's media key. */
17489
- mediaKey: string(),
17490
- bbox: RetrainBboxSchema,
17491
- macroClass: RetrainMacroClassSchema,
17492
- label: string().optional(),
17493
- subLabel: string().optional(),
17494
- kind: RetrainAnnotationKindSchema,
17495
- source: RetrainAnnotationSourceSchema,
17496
- /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
17497
- assistModelId: string().optional(),
17498
- assistScore: number().optional(),
17499
- exportedInBatch: string().optional(),
17500
- createdAt: number()
17501
- });
17502
- /** The write form — the server owns `id`, `createdAt` and the frame binding. */
17503
- var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
17504
- id: true,
17505
- trackId: true,
17506
- deviceId: true,
17507
- mediaKey: true,
17508
- createdAt: true,
17509
- exportedInBatch: true
17507
+ var EventKindCategorySchema = _enum([
17508
+ "motion",
17509
+ "audio",
17510
+ "detection",
17511
+ "sensor",
17512
+ "control",
17513
+ "custom",
17514
+ "package"
17515
+ ]);
17516
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
17517
+ var EventKindLevelSchema = _enum(["macro", "sub"]);
17518
+ var EventKindDescriptorSchema = object({
17519
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
17520
+ kind: string(),
17521
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
17522
+ labelKey: string(),
17523
+ /** English fallback label (kept for clients that don't translate). */
17524
+ label: string(),
17525
+ /** Hex color for timeline/legend rendering. */
17526
+ color: string(),
17527
+ /** Dictionary id → lucide component on the UI side. */
17528
+ iconId: string(),
17529
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
17530
+ icon: EventKindIconSchema,
17531
+ category: EventKindCategorySchema,
17532
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
17533
+ parentKind: string().nullable(),
17534
+ /** Derived from `parentKind`, explicit for the client tree. */
17535
+ level: EventKindLevelSchema,
17536
+ /** Which cap + device contributes this kind. For built-ins the camera
17537
+ * itself; for sensor kinds the LINKED source device. */
17538
+ source: object({
17539
+ capName: string(),
17540
+ deviceId: number()
17541
+ })
17510
17542
  });
17511
- /** A track sitting in `staging`, with everything the worklist needs to rank it. */
17512
- var RetrainTrackSchema = object({
17513
- trackId: string(),
17543
+ /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
17544
+ var EventKindsForDeviceSchema = object({
17514
17545
  deviceId: number(),
17515
- className: string(),
17516
- label: string().optional(),
17517
- firstSeen: number(),
17518
- lastSeen: number(),
17519
- /** How many frames the dataset already holds from this track. */
17520
- frameCount: number().int(),
17521
- /** How many subjects have been annotated on those frames. `0` with
17522
- * `frameCount: 0` is exactly "staging, still to work". */
17523
- annotationCount: number().int()
17524
- });
17525
- /** A frame the picker may offer — an index row, no blob was read to produce it. */
17526
- var RetrainFrameCandidateSchema = object({
17527
- mediaKey: string(),
17528
- kind: MediaFileKindEnum,
17529
- timestamp: number(),
17530
- sizeBytes: number().int(),
17531
- /** A copy of this original already exists — selecting it is free and cannot
17532
- * fail, whatever became of the original. */
17533
- copied: boolean()
17546
+ kinds: array(EventKindDescriptorSchema).readonly()
17534
17547
  });
17535
- /** A frame the dataset OWNS: bytes copied at selection time. */
17536
- var RetrainFrameSchema = object({
17537
- frameId: string(),
17548
+ var SensorEventSchema = object({
17549
+ id: string(),
17550
+ /** The CAMERA the event is attributed to (a sensor linked to N cameras
17551
+ * yields N rows, one per camera). */
17538
17552
  deviceId: number(),
17539
- trackId: string(),
17540
- /** Provenance only. It may already point at nothing — that is expected. */
17541
- sourceMediaKey: string(),
17542
- sourceKind: MediaFileKindEnum,
17543
- sizeBytes: number().int(),
17544
- width: number().int(),
17545
- height: number().int(),
17546
- copiedAt: number()
17553
+ /** The linked sensor device whose state changed. */
17554
+ sourceDeviceId: number(),
17555
+ /** Event kind id — matches an `EventKindDescriptor.kind`. */
17556
+ kind: string(),
17557
+ /** Snapshot of the sensor cap's runtime-state slice at the change. */
17558
+ value: record(string(), unknown()).nullable(),
17559
+ timestamp: number()
17547
17560
  });
17548
- /** Why a copy-on-select could not be honoured — named, never a silent skip. */
17549
- var RetrainCopyRefusalSchema = _enum([
17550
- "source-missing",
17551
- "unreadable-image",
17552
- "write-failed"
17553
- ]);
17554
- var RetrainFrameSelectionSchema = object({
17555
- copied: array(RetrainFrameSchema).readonly(),
17556
- refused: array(object({
17557
- sourceMediaKey: string(),
17558
- reason: RetrainCopyRefusalSchema
17559
- })).readonly()
17561
+ var TrackPositionSchema = object({
17562
+ x: number(),
17563
+ y: number(),
17564
+ timestamp: number(),
17565
+ bbox: BoundingBoxSchema
17560
17566
  });
17561
- var RetrainFrameListSchema = object({
17562
- candidates: array(RetrainFrameCandidateSchema).readonly(),
17563
- copies: array(RetrainFrameSchema).readonly(),
17564
- /** What the page pre-selects the native key frame when one survives. */
17565
- autoPickMediaKey: string().optional()
17567
+ var TrackSnapshotSchema = object({
17568
+ timestamp: number(),
17569
+ position: TrackPositionSchema,
17570
+ /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
17571
+ mediaKey: string()
17566
17572
  });
17567
- /** What the operator asked the assist to look for. */
17568
- var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
17569
- kind: literal("package"),
17570
- zone: RetrainBboxSchema.optional()
17571
- }), object({
17572
- kind: literal("objects"),
17573
- modelId: string(),
17574
- minScore: number().optional()
17575
- })]);
17576
17573
  /**
17577
- * The assist's answer a discriminated union, because "the model saw nothing"
17578
- * and "this node cannot run that model" lead to different next moves and a
17579
- * nullable result cannot tell them apart.
17574
+ * Normalized 0..1 trajectory envelope (min/max over every position bbox,
17575
+ * divided by the track's detection-frame dims), computed at persist time.
17576
+ * Absent when the frame dims were unknown when the track was persisted
17577
+ * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
17580
17578
  */
17581
- var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
17582
- kind: literal("proposed"),
17583
- modelId: string(),
17584
- stepId: string(),
17585
- minScore: number(),
17586
- /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
17587
- proposals: array(RetrainAnnotationDraftSchema).readonly(),
17588
- /** Returned by the runner but removed by the threshold. */
17589
- belowThreshold: number().int()
17590
- }), object({
17591
- kind: literal("refused"),
17592
- /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
17593
- reason: string(),
17594
- detail: string().optional()
17595
- })]);
17596
- /** The outcome of a lifecycle move owned by the retrain page. */
17597
- var RetrainTransitionResultSchema = object({
17598
- trackId: string(),
17599
- /** Where the track ended up, whatever happened. */
17600
- retrainStatus: RetrainStatusSchema,
17601
- /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
17602
- changed: boolean(),
17603
- reason: _enum([
17604
- "unknown-track",
17605
- "no-frames-copied",
17606
- "not-staging",
17607
- "not-trained",
17608
- "unchanged"
17609
- ]).optional()
17610
- });
17611
- var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
17612
- var MAX_EVENT_QUERY_LIMIT = 5e3;
17613
- var DeviceEventQueryInput = object({
17614
- deviceId: number(),
17615
- since: number().optional(),
17616
- until: number().optional(),
17617
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
17618
- /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
17619
- * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
17620
- * exact behaviour. Callers may omit this field — the store defaults to
17621
- * `full` when not provided. */
17622
- projection: _enum(["full", "slim"]).optional()
17623
- });
17624
- var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
17625
- var RecentTracksQueryInput = object({
17626
- /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
17627
- deviceIds: array(number()),
17628
- /** Window lower bound on `lastSeen` (inclusive). */
17629
- since: number().optional(),
17630
- /** Window upper bound on `lastSeen` (inclusive). */
17631
- until: number().optional(),
17632
- /** Page size. Default 200, max 1000. */
17633
- limit: number().int().min(1).max(1e3).default(200),
17634
- /** Opaque continuation cursor from a previous page's `nextCursor`.
17635
- * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
17636
- cursor: string().optional(),
17637
- /** See {@link TrackProjectionSchema}. Default `full`. */
17638
- projection: TrackProjectionSchema.optional(),
17639
- /** Include stationary-promoted rows (parked objects). Default false: the
17640
- * feed lists passages; parking records live on the stationary registry. */
17641
- includeStationary: boolean().optional()
17642
- });
17643
- var RecentTracksPageSchema = object({
17644
- /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
17645
- tracks: array(TrackSchema).readonly(),
17646
- /** Cursor for the next page, or null when this page is the last. */
17647
- nextCursor: string().nullable()
17579
+ var TrackEnvelopeSchema = object({
17580
+ minX: number(),
17581
+ minY: number(),
17582
+ maxX: number(),
17583
+ maxY: number()
17648
17584
  });
17649
- var LIST_GROUPS_DEFAULT_LIMIT = 40;
17650
- var LIST_GROUPS_MAX_LIMIT = 100;
17651
- var AnalyticsGroupRecordSchema = object({
17652
- id: string(),
17653
- deviceId: number().int(),
17654
- openedAt: number().int(),
17655
- closedAt: number().int(),
17656
- timestamp: number().int(),
17657
- memberCount: number().int(),
17658
- memberTrackIds: array(string()).readonly(),
17659
- className: string(),
17660
- classes: array(string()).readonly(),
17661
- /** Relative event-media path, or null when the group has no picture yet. */
17662
- mediaUrl: string().nullable(),
17663
- singleton: boolean()
17664
- });
17665
- var AnalyticsGroupMemberSchema = object({
17666
- trackId: string(),
17667
- deviceId: number().int(),
17668
- className: string(),
17669
- firstSeen: number().int(),
17670
- lastSeen: number().int(),
17671
- mediaUrl: string().nullable()
17672
- });
17673
- var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
17674
- var ListGroupsQueryInput = object({
17675
- /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
17676
- deviceIds: array(number()),
17677
- /** Window lower bound on `closedAt` (inclusive). */
17678
- since: number().optional(),
17679
- /** Window upper bound on `openedAt` (inclusive). */
17680
- until: number().optional(),
17681
- limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
17682
- /** Opaque continuation cursor from a previous page's `nextCursor`. */
17683
- cursor: string().optional()
17684
- });
17685
- var ListGroupsPageSchema = object({
17686
- groups: array(AnalyticsGroupRecordSchema).readonly(),
17687
- nextCursor: string().nullable()
17688
- });
17689
- var KeyEventQueryInput = object({
17690
- deviceId: number(),
17691
- /** Window lower bound (track firstSeen ≥ since). */
17692
- since: number(),
17693
- /** Window upper bound (track firstSeen ≤ until). */
17694
- until: number(),
17695
- limit: number().int().min(1).max(200).default(50),
17696
- /** Drop tracks scoring below this importance. */
17697
- minImportance: number().min(0).max(1).optional(),
17698
- /** Restrict to a single class (e.g. 'person'). */
17699
- classFilter: string().optional()
17700
- });
17701
- var KeyEventSchema = object({
17702
- /** The representative event id (the track's best ObjectEvent, else its trackId). */
17703
- id: string(),
17704
- trackId: string(),
17705
- /** Track start time (firstSeen). */
17706
- timestamp: number(),
17707
- className: string(),
17708
- ...TieredLabelFields,
17709
- importance: number(),
17710
- /** Highest-confidence ObjectEvent id for the track (empty when none). */
17711
- bestEventId: string(),
17712
- /** Track lifetime in ms (lastSeen - firstSeen). */
17713
- windowMs: number().optional(),
17714
- ...TrackFlagFields,
17715
- ...TrackRetrainFields
17716
- });
17717
- object({
17718
- trackId: string(),
17719
- className: string(),
17720
- confidence: number(),
17721
- bbox: BoundingBoxSchema,
17722
- zones: array(string()).readonly(),
17723
- state: TrackStateSchema
17724
- });
17725
- var OverlayDetectionSchema = looseObject({
17726
- id: string(),
17727
- kind: _enum(["first-level", "detail"]),
17728
- macroClass: string(),
17729
- score: number(),
17730
- bbox: object({
17731
- x: number(),
17732
- y: number(),
17733
- width: number(),
17734
- height: number()
17735
- }),
17736
- labels: array(looseObject({
17737
- label: string(),
17738
- score: number()
17739
- })).readonly(),
17740
- parentId: string().optional()
17741
- });
17742
- var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
17743
- var SearchObjectEventsInput = object({
17744
- text: string(),
17745
- deviceId: number().optional(),
17746
- since: number().optional(),
17747
- until: number().optional(),
17748
- classFilter: string().optional(),
17749
- limit: number().default(50),
17750
- minScore: number().min(0).max(1).default(.2)
17751
- });
17752
- var TrackCascadeCountsSchema = object({
17753
- /** Persisted track roots deleted (authoritative). */
17754
- tracks: number().int(),
17755
- /** Object events removed with their tracks (best-effort; see note above). */
17756
- events: number().int(),
17757
- /** Track/face/plate-owned media removed (best-effort). Never identity media. */
17758
- media: number().int(),
17759
- /** Unassigned (non-enrolled) face reads removed (best-effort). */
17760
- faces: number().int(),
17761
- /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
17762
- plates: number().int(),
17763
- /** Per-track CLIP search vectors removed (best-effort). */
17764
- embeddings: number().int(),
17765
- /** Group membership + group rows removed with their last member (best-effort). */
17766
- groups: number().int()
17767
- });
17768
- /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
17769
- var DiskReconcileCountsSchema = object({
17770
- mediaDropped: number().int(),
17771
- tracks: number().int(),
17772
- events: number().int()
17773
- });
17774
- /** Event-store footprint for one camera. */
17775
- var EventStoreDeviceFootprintSchema = object({
17776
- deviceId: number(),
17777
- /** Persisted event rows (motion + object + audio) for the camera. */
17778
- rows: number().int(),
17779
- /** Event-owned media bytes on disk for the camera. */
17780
- bytes: number().int()
17781
- });
17782
- /** Aggregate event-store footprint: global totals + per-camera breakdown. */
17783
- var EventStoreFootprintSchema = object({
17784
- totalRows: number().int(),
17785
- totalBytes: number().int(),
17786
- devices: array(EventStoreDeviceFootprintSchema).readonly()
17787
- });
17788
- /** Per-kind counts returned by the event-prune / device-delete mutations. */
17789
- var EventPruneCountsSchema = object({
17790
- motion: number().int(),
17791
- object: number().int(),
17792
- audio: number().int()
17585
+ /**
17586
+ * Row projection for track list queries. `full` (default) returns the
17587
+ * complete Track including the frame-rate `positions[]` history and the
17588
+ * `snapshots[]` references — megabytes across a page of tracks. `slim`
17589
+ * keeps every scalar the list surfaces actually render (ids, class(es),
17590
+ * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
17591
+ * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
17592
+ * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
17593
+ * `getTrack`. Mirrors the event-store `projection` convention
17594
+ * (`getObjectEvents` et al.).
17595
+ */
17596
+ var TrackProjectionSchema = _enum(["full", "slim"]);
17597
+ /**
17598
+ * One audio-classification label heard on the track's camera while the
17599
+ * track was alive, aggregated per label. An "episode" is one persisted
17600
+ * audio event (the confident-classification path: score ≥ the device's
17601
+ * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
17602
+ * one 32 ms inference chunk, so counts stay human-scaled.
17603
+ */
17604
+ var TrackAudioLabelSchema = object({
17605
+ label: string(),
17606
+ /** Highest classification score observed across the label's episodes. */
17607
+ peakScore: number(),
17608
+ /** Number of coalesced audio-event episodes carrying this label. */
17609
+ count: number(),
17610
+ firstAt: number(),
17611
+ lastAt: number()
17793
17612
  });
17794
17613
  /**
17795
- * Re-embed stored tracks from their key frames.
17614
+ * How a track was produced. `pipeline` (default / absent) = the spatial
17615
+ * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
17616
+ * no positions, a single snapshot, and no bbox trajectory at all:
17796
17617
  *
17797
- * The reason this is an operator-callable method and not a migration script:
17798
- * every knob that decides what a vector MEANS encoder model, crop margin,
17799
- * squaring is only changeable if the existing vectors can be regenerated.
17800
- * Mixing feature spaces in one index makes cosine scores incomparable, and the
17801
- * symptom is a quality regression with no visible cause.
17618
+ * - `sensor` a linked sensor/control device state change.
17619
+ * - `audio` an audio event on the camera itself that was anomalous for
17620
+ * THAT camera, loud, and heard while nothing visual was happening (D62).
17621
+ *
17622
+ * The spatial subsystems (tracker association, occupancy count, re-id /
17623
+ * embedding, resurrection) MUST skip every synthetic source. Test for that
17624
+ * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
17625
+ * check silently readmits every source added after it was written.
17802
17626
  */
17803
- var RebuildObjectEmbeddingsInput = object({
17804
- /** Restrict to one camera. Omit for the whole fleet. */
17805
- deviceId: number().optional(),
17806
- since: number().optional(),
17807
- until: number().optional(),
17808
- /** Stop after this many tracks; the result reports whether more remain. */
17809
- maxTracks: number().int().positive().optional(),
17810
- /**
17811
- * Run every embedding on THIS node instead of round-robining the fleet.
17812
- *
17813
- * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
17814
- * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
17815
- * calling it that would pin the rebuild REQUEST itself to that node — the
17816
- * rebuild orchestration lives on the hub, and only the per-track step runs
17817
- * remotely. This field is data; the per-track pin is applied inside.
17818
- *
17819
- * Absent ⇒ round-robin over every online node whose runner can serve the
17820
- * pinned model.
17821
- */
17822
- executeOnNodeId: string().optional(),
17823
- /**
17824
- * Milliseconds to wait between tracks; omit for the built-in default, `0` to
17825
- * run flat out.
17826
- *
17827
- * A rebuild is bulk maintenance on hub-main's single thread. Measured
17828
- * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
17829
- * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
17830
- * force is logged at start and finish so a deliberately slow pass reads
17831
- * differently from a stalled one.
17832
- */
17833
- pacingMs: number().int().nonnegative().optional()
17834
- });
17627
+ var TrackSourceSchema = _enum([
17628
+ "pipeline",
17629
+ "sensor",
17630
+ "audio"
17631
+ ]);
17835
17632
  /**
17836
- * Result of emptying the CLIP index.
17633
+ * Where a track sits in the RETRAIN lifecycle (D81).
17837
17634
  *
17838
- * The clean slate before a policy change: a new crop margin or encoder model
17839
- * leaves two feature spaces in one index whose cosine scores are not
17840
- * comparable, so wiping and rebuilding is the only way to be sure every vector
17841
- * means the same thing.
17635
+ * - `none` never marked, or un-marked. Evictable.
17636
+ * - `staging` the operator wants this track as training material and has not
17637
+ * finished with it. **This is the only state retention holds**: the track and
17638
+ * everything it owns (object events, crops, keyframes, CLIP vector) survive
17639
+ * the device's age window.
17640
+ * - `trained` — the retrain page has taken what it needed. The frames it chose
17641
+ * were COPIED into the retrain dataset at selection time, so the dataset no
17642
+ * longer depends on the track's media and the track becomes EVICTABLE again.
17643
+ * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
17644
+ * a deliberate action of the retrain page, not a side effect of a checkbox.
17645
+ *
17646
+ * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
17647
+ * the store's filter language has only positive equality and `whereIn` — no
17648
+ * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
17649
+ * would make the entire pre-column history immortal in one deploy.
17842
17650
  */
17843
- var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
17651
+ var RetrainStatusSchema = _enum([
17652
+ "none",
17653
+ "staging",
17654
+ "trained"
17655
+ ]);
17844
17656
  /**
17845
- * Acknowledgement that a rebuild STARTED.
17657
+ * Per-track OPERATOR flags set by hand from the admin UI or the viewer, never
17658
+ * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
17659
+ * so the two surfaces cannot drift.
17846
17660
  *
17847
- * The pass costs ~1s per track 45 minutes for a 2,600-track fleet so it
17848
- * runs detached and this returns immediately. Waiting for it made the client
17849
- * time out while the work carried on server-side, which is the worst of both:
17850
- * no result and no way to know it was still going. Poll
17851
- * `getObjectEmbeddingRebuildStatus` for progress.
17661
+ * **Absent false.** A track that has never been touched omits the field; an
17662
+ * explicitly un-flagged track carries `false`. Legacy rows written before the
17663
+ * columns existed read as absent, and a consumer that needs a boolean should say
17664
+ * `flag === true`, not `flag !== false`.
17665
+ *
17666
+ * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
17667
+ * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
17668
+ * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
17669
+ * `trained` track reports `false` while refusing both writes. The boolean is
17670
+ * kept because three surfaces drive a toggle off it; anything that needs to tell
17671
+ * "never marked" from "already trained" must read `retrainStatus`.
17672
+ *
17673
+ * `debug` does NOT pin; it is attention, not durability.
17674
+ *
17675
+ * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
17676
+ * A favourited track is skipped by retention the same way `staging` is, but
17677
+ * it does not enter `none|staging|trained` and has no staging budget.
17852
17678
  */
17853
- var RebuildObjectEmbeddingsResultSchema = object({
17854
- started: boolean(),
17855
- /** True when a pass was already running; the new request is ignored. */
17856
- alreadyRunning: boolean()
17857
- });
17858
- var RebuildStatusSchema = object({
17859
- running: boolean(),
17860
- scanned: number(),
17861
- rebuilt: number(),
17862
- /** Tracks whose key frame is gone — nothing to re-embed from. */
17863
- missingKeyFrame: number(),
17864
- /** Tracks with no usable detection box. */
17865
- missingBbox: number(),
17866
- /**
17867
- * Tracks an executing node REFUSED rather than broke on an unreadable key
17868
- * frame, a step that threw. Separate from `failed` because the remedy is
17869
- * different, and because a whole camera silently contributing zero vectors
17870
- * is the shape of failure a rebuild must never hide.
17871
- */
17872
- notRunnable: number(),
17873
- /**
17874
- * The pass stopped because NO node could serve the pinned model.
17679
+ var TrackFlagFields = {
17680
+ /** Operator marked this track as training material — i.e. `retrainStatus` is
17681
+ * `'staging'`. */
17682
+ markForTrain: boolean().optional(),
17683
+ /** Operator marked this track for diagnostic attention. */
17684
+ debug: boolean().optional(),
17685
+ /** Operator favourited this track. Pins it against pruning. */
17686
+ favourited: boolean().optional()
17687
+ };
17688
+ /**
17689
+ * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
17690
+ * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
17691
+ * write patch, and the status is not something the toggle sets — it is what the
17692
+ * toggle's boolean is derived from. Absent on an in-RAM track never touched;
17693
+ * always present on a persisted row (the column default materialises `'none'`).
17694
+ */
17695
+ var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
17696
+ /**
17697
+ * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
17698
+ * one flag can never clear the other — the toggles are independent and are
17699
+ * driven from three surfaces that do not know about each other.
17700
+ */
17701
+ var TrackFlagsPatchSchema = object(TrackFlagFields);
17702
+ /**
17703
+ * The resolved flag state after a write. Both fields are REQUIRED here (absent
17704
+ * collapses to `false`) so a caller can drive a toggle's checked state off the
17705
+ * mutation result without a re-fetch.
17706
+ */
17707
+ var TrackFlagsSchema = object({
17708
+ trackId: string(),
17709
+ markForTrain: boolean(),
17710
+ debug: boolean(),
17711
+ favourited: boolean(),
17712
+ /** The lifecycle state the boolean was derived from. Required here (unlike on
17713
+ * a track row) because this shape is only ever produced by the write body,
17714
+ * which always knows it — and a surface that has just written needs to render
17715
+ * `trained` without a re-fetch. */
17716
+ retrainStatus: RetrainStatusSchema
17717
+ });
17718
+ union([literal(1), literal(2)]);
17719
+ /**
17720
+ * WHO decided a label, and when. Carried per tier so a value can be traced to
17721
+ * the step and model that produced it — which is what makes the write rule
17722
+ * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
17723
+ * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
17724
+ *
17725
+ * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
17726
+ * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
17727
+ * `migration:4g` for a value the 4g migration moved from the single-slot era —
17728
+ * that value has no provenance, and the write rule lets ANY properly-attributed
17729
+ * write of the same tier replace it regardless of score.
17730
+ */
17731
+ var LabelAttributionSchema = object({
17732
+ stepId: string(),
17733
+ modelId: string().optional(),
17734
+ decidedAt: number(),
17735
+ /**
17736
+ * The GALLERY id behind a recognised tier-2 label — a face-gallery
17737
+ * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
17875
17738
  *
17876
- * Distinct from `notRunnable` on purpose: that one says "this track was
17877
- * refused", this one says "the cluster cannot do this work at all" — every
17878
- * candidate node either lacks the `clip-embedding` step, lacks a build of the
17879
- * pinned model for its engine format, or dropped out. The remedy is a model /
17880
- * engine change, not a per-camera one. Non-zero here always comes with
17881
- * `complete: false`.
17739
+ * The text alone is a DISPLAY NAME, and a display name is renameable: a
17740
+ * notification rule authored on "Gianluca" stopped matching the moment the
17741
+ * operator fixed the spelling in the gallery, and nothing said so. The id is
17742
+ * the thing that does not move, so it is what a rule matches on
17743
+ * (`NcConditions.identities`) and the text is what a human is shown.
17744
+ *
17745
+ * Absent when the label names no gallery row — a plate the OCR read but no
17746
+ * vehicle claims, a sub-class, a species, any tier-1 value.
17882
17747
  */
17883
- noCapableNode: number(),
17884
- failed: number(),
17885
- /** Set once a pass ends: true only when EVERYTHING was covered. */
17886
- complete: boolean().nullable(),
17887
- startedAtMs: number().nullable(),
17888
- finishedAtMs: number().nullable(),
17889
- /** Present when the pass ended by throwing. */
17890
- error: string().nullable()
17748
+ identityId: string().optional()
17891
17749
  });
17892
- DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
17893
- deviceId: number(),
17894
- trackId: string()
17895
- }), TrackSchema.nullable()), method(object({
17896
- deviceId: number(),
17897
- since: number().optional(),
17898
- until: number().optional(),
17899
- limit: number().optional(),
17900
- /** Spatial filter — only tracks whose trajectory intersects the zone
17901
- * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
17902
- * envelope columns, then precisely tested per position. Tracks with
17903
- * an unknown envelope (no frame dims at persist time) always match. */
17904
- zone: TrackZoneFilterSchema.optional(),
17905
- /** See {@link TrackProjectionSchema}. Default `full` (backward
17906
- * compatible omitting the field keeps today's exact behaviour). */
17907
- projection: TrackProjectionSchema.optional(),
17908
- /** Include stationary-promoted rows (parked objects handed to the
17909
- * stationary registry). Default false: the timeline lists passages,
17910
- * not parking records (operator decision, 2026-08-15). */
17911
- includeStationary: boolean().optional()
17912
- }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
17913
- deviceId: number(),
17914
- groupId: string().min(1)
17915
- }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
17916
- kind: "mutation",
17917
- auth: "admin"
17918
- }), 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({
17919
- deviceId: number(),
17920
- since: number().optional(),
17921
- until: number().optional(),
17922
- kinds: array(string()).optional(),
17923
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
17924
- }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
17925
- deviceId: number(),
17926
- since: number(),
17927
- until: number(),
17928
- bucketMs: number().int().positive()
17929
- }), array(object({
17930
- bucketStart: number(),
17931
- motion: number().int(),
17932
- object: number().int(),
17933
- audio: number().int()
17934
- })).readonly()), method(object({
17935
- deviceId: number(),
17936
- cutoffMs: number()
17937
- }), object({
17938
- motion: number().int(),
17939
- object: number().int(),
17940
- audio: number().int()
17941
- }), {
17942
- kind: "mutation",
17943
- auth: "admin"
17944
- }), method(object({
17945
- deviceId: number(),
17946
- cutoffMs: number()
17947
- }), TrackCascadeCountsSchema, {
17948
- kind: "mutation",
17949
- auth: "admin"
17950
- }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
17951
- kind: "mutation",
17952
- auth: "admin"
17953
- }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
17954
- kind: "mutation",
17955
- auth: "admin"
17956
- }), method(object({
17957
- deviceId: number(),
17958
- trackIds: array(string()).min(1)
17959
- }), object({
17960
- deleted: number().int(),
17961
- failed: array(string()).readonly()
17962
- }), {
17963
- kind: "mutation",
17964
- auth: "admin"
17965
- }), method(object({
17966
- /** Log/audit scope only — the trackId is globally unique on its own. */
17750
+ /**
17751
+ * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
17752
+ * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
17753
+ * track and its events always answer the same question the same way.
17754
+ *
17755
+ * Two scalar columns, not an array: every consumer wants "the coarse one" or
17756
+ * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
17757
+ * is tier 2, and each carries its own score + attribution.
17758
+ *
17759
+ * **Reading it.** What a human should be shown is `subLabel ?? label` — the
17760
+ * finest thing known. Before 4g the single `label` column held the finest
17761
+ * value, so a consumer that has not been updated reads the tier-1 slot and
17762
+ * shows nothing on a species-only row; that is why the migration puts every
17763
+ * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
17764
+ * and why the read surfaces were changed in the same train.
17765
+ *
17766
+ * **Writing it.** The slots are independent, which is the whole point: a
17767
+ * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
17768
+ * migratorius`), so fineness cannot regress by construction. Within a tier the
17769
+ * higher score wins. One rule, one implementation — see
17770
+ * `pipeline/label-tier.ts` in addon-post-analysis.
17771
+ */
17772
+ var TieredLabelFields = {
17773
+ /** Tier 1 the sub-class. See {@link LabelTierSchema}. */
17774
+ label: string().optional(),
17775
+ /** Confidence of the tier-1 value, as reported by the deciding step. */
17776
+ labelScore: number().optional(),
17777
+ /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
17778
+ labelMeta: LabelAttributionSchema.optional(),
17779
+ /** Tier 2 — the instance. See {@link LabelTierSchema}. */
17780
+ subLabel: string().optional(),
17781
+ /** Confidence of the tier-2 value, as reported by the deciding step. */
17782
+ subLabelScore: number().optional(),
17783
+ /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
17784
+ subLabelMeta: LabelAttributionSchema.optional()
17785
+ };
17786
+ /** Per-camera slice of a training-export estimate. */
17787
+ var TrainingExportDeviceTotalsSchema = object({
17967
17788
  deviceId: number(),
17789
+ tracks: number().int(),
17790
+ files: number().int(),
17791
+ bytes: number().int()
17792
+ });
17793
+ /**
17794
+ * What a training export WOULD contain. Computed from media index rows only —
17795
+ * no blob is read to produce this.
17796
+ */
17797
+ var TrainingExportSummarySchema = object({
17798
+ generatedAt: number(),
17799
+ trackCount: number().int(),
17800
+ fileCount: number().int(),
17801
+ byteCount: number().int(),
17802
+ /** More marked tracks exist than a single pass carries. */
17803
+ truncated: boolean(),
17804
+ devices: array(TrainingExportDeviceTotalsSchema).readonly()
17805
+ });
17806
+ var TrackSchema = object({
17968
17807
  trackId: string(),
17969
- flags: TrackFlagsPatchSchema
17970
- }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
17971
- kind: "query",
17972
- auth: "admin"
17973
- }), method(object({
17974
- olderThanMs: number(),
17975
- reason: OpsLogReasonSchema.optional()
17976
- }), EventPruneCountsSchema, {
17977
- kind: "mutation",
17978
- auth: "admin"
17979
- }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
17980
- kind: "mutation",
17981
- auth: "admin"
17982
- }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
17983
- kind: "mutation",
17984
- auth: "admin"
17985
- }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
17986
- kind: "mutation",
17987
- auth: "admin"
17988
- }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
17989
- kind: "mutation",
17990
- auth: "admin"
17991
- }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
17992
- kind: "mutation",
17993
- auth: "admin"
17994
- }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
17995
- kind: "mutation",
17996
- auth: "admin"
17997
- }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
17998
- kind: "query",
17999
- auth: "admin"
18000
- }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
18001
- kind: "query",
18002
- auth: "admin"
18003
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18004
- kind: "query",
18005
- auth: "admin"
18006
- }), method(object({
18007
- /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
18008
- * `deviceId`, deliberately: `deviceId` would make this device-bound and
18009
- * route it at one camera's owner, and "every camera" would stop being
18010
- * expressible at all. */
18011
- deviceIds: array(number()).optional(),
18012
- limit: number().int().min(1).max(500).optional()
18013
- }), array(RetrainTrackSchema).readonly(), {
18014
- kind: "query",
18015
- auth: "admin"
18016
- }), method(object({ trackId: string() }), RetrainFrameListSchema, {
18017
- kind: "query",
18018
- auth: "admin"
18019
- }), method(object({
18020
17808
  deviceId: number(),
18021
- trackId: string(),
18022
- mediaKeys: array(string()).min(1)
18023
- }), RetrainFrameSelectionSchema, {
18024
- kind: "mutation",
18025
- auth: "admin"
18026
- }), method(object({
17809
+ className: string(),
17810
+ ...TieredLabelFields,
17811
+ producingDeviceName: string().optional(),
17812
+ /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
17813
+ source: TrackSourceSchema.optional(),
17814
+ firstSeen: number(),
17815
+ lastSeen: number(),
17816
+ /** Frame-rate position history (subject to maxPositionHistory cap). */
17817
+ positions: array(TrackPositionSchema).readonly(),
17818
+ /** Periodic snapshots at snapshotIntervalMs cadence (subject to
17819
+ * saveThumbnails policy). */
17820
+ snapshots: array(TrackSnapshotSchema).readonly(),
17821
+ /** Deduplicated zones the track has entered at least once. Zone IDS. */
17822
+ zonesVisited: array(string()).readonly(),
17823
+ /**
17824
+ * Human NAMES for {@link zonesVisited}, resolved at READ time against the
17825
+ * `zones` capability.
17826
+ *
17827
+ * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
17828
+ * and no card can render — so every free-text search surface was structurally
17829
+ * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
17830
+ * just returned nothing. Resolving here rather than in each client keeps ONE
17831
+ * derivation and costs the clients no extra call (the `zones` cap is
17832
+ * per-device, so a client-side resolve would be a per-camera fan-out on a
17833
+ * surface built to avoid exactly that).
17834
+ *
17835
+ * Resolved, never invented: a zone deleted since the track was written has no
17836
+ * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
17837
+ * two are not positionally aligned. Absent when the track visited no zone, or
17838
+ * when the zone catalogue could not be read.
17839
+ */
17840
+ zoneNames: array(string()).readonly().optional(),
17841
+ /** Deduplicated set of detector classes observed for this track over its
17842
+ * life (a track may be reclassified, e.g. person→vehicle). Absent on
17843
+ * legacy rows written before class accumulation shipped. */
17844
+ classes: array(string()).readonly().optional(),
17845
+ /** Cumulative normalized distance travelled (0..1 units = full frame width). */
17846
+ totalDistance: number(),
17847
+ state: TrackStateSchema,
17848
+ active: boolean(),
17849
+ /** Deterministic key-event importance score in [0,1] (server-computed at
17850
+ * track expiry, recomputed on late label). Absent on legacy rows written
17851
+ * before scoring shipped — consumers degrade to absence / compute-on-read. */
17852
+ importance: number().optional(),
17853
+ /** Id of the track's highest-confidence ObjectEvent (its representative
17854
+ * "best" frame). Absent when the track produced no object events. */
17855
+ bestEventId: string().optional(),
17856
+ /** Tag of the importance sub-signal that dominated the score
17857
+ * (identity|dwell|proximity|class|confidence|travel|zone). */
17858
+ importanceReason: string().optional(),
17859
+ /** Audio-classification labels heard on the camera during the track's
17860
+ * life (score ≥ device `classificationMinScore`), aggregated per label.
17861
+ * Absent on legacy rows / tracks with no confident audio. */
17862
+ audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
17863
+ /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
17864
+ * Populated from the persisted envelope columns on historical reads;
17865
+ * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
17866
+ envelope: TrackEnvelopeSchema.optional(),
17867
+ /**
17868
+ * A face DETECTOR found a face on this track — nothing more. It says the
17869
+ * detail plane produced a `face` detail; it does NOT say the face was
17870
+ * embedded, matched, above `minFacePx`, or that the recognizer was even
17871
+ * enabled. Set once and never cleared.
17872
+ *
17873
+ * **This exists so "face present but not recognised" is expressible.** A
17874
+ * recognised identity lands in `subLabel` (attributed to the face chain via
17875
+ * `subLabelMeta.stepId`), so before this field a track with an unmatched face
17876
+ * and a track with no face at all were byte-identical on the wire and no
17877
+ * surface could tell them apart. The read is `hasFace === true && subLabel
17878
+ * === undefined`.
17879
+ *
17880
+ * **Absent ≠ false.** Every row written before the column existed omits it,
17881
+ * and so does every server that predates the field — a consumer must test
17882
+ * `=== true` and render nothing otherwise, never infer "no face".
17883
+ */
17884
+ hasFace: boolean().optional(),
17885
+ /**
17886
+ * This track has a face row IN THE GALLERY: a crop **and** an embedding — a
17887
+ * face an operator could ASSIGN to an identity.
17888
+ *
17889
+ * The STRICT twin of {@link hasFace}, and the pair only earns its keep
17890
+ * because the two disagree. `hasFace` is stamped at the TOP of the face
17891
+ * branch, before every gate, and means no more than "a face detector produced
17892
+ * a face detail". This one is stamped at the single moment the gallery row
17893
+ * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
17894
+ * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
17895
+ * candidate gate, the imageless-track drop (no crop was ever captured) and
17896
+ * the crop-store drop. Everything between the detector and that insert can
17897
+ * legitimately refuse the face, so a flag written any earlier promises the
17898
+ * operator something to assign and delivers nothing.
17899
+ *
17900
+ * **Independent of recognition.** A face collected but never auto-matched is
17901
+ * still assignable — it is in fact the face an operator most wants to reach —
17902
+ * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
17903
+ * `subLabel`; this says only that the raw material exists.
17904
+ *
17905
+ * **Set once, never cleared.** A track that produced a gallery row produced
17906
+ * one; deleting the row later is the gallery's business, not this flag's.
17907
+ *
17908
+ * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
17909
+ * before the column omits it, and so does every server that predates the
17910
+ * field. A consumer must test `=== true` and render nothing otherwise —
17911
+ * never infer "no assignable face".
17912
+ */
17913
+ hasEmbeddedFace: boolean().optional(),
17914
+ /**
17915
+ * This subject CONTAINS a folded rider — a person the rider-pairing step
17916
+ * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
17917
+ * so the passage is tracked once and as a VEHICLE.
17918
+ *
17919
+ * It exists because the fold's record was dishonest. D34 and the code both
17920
+ * said "the person is not lost — it is reported so both entities stay on the
17921
+ * record"; in fact the pair went into a per-processor RAM field behind an
17922
+ * accessor nobody called, and every durable surface said `vehicle`, full
17923
+ * stop. This is the composition note that makes the row true.
17924
+ *
17925
+ * A COMPOSITION, never a class and never a label. "This vehicle contains a
17926
+ * person" is not an answer to "what is this" — both label tiers would refuse
17927
+ * a macro token anyway (D89), and correctly. Nothing here changes what the
17928
+ * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
17929
+ * and a `person` rule still does not fire for someone cycling past.
17930
+ *
17931
+ * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
17932
+ * the column, and every hub that predates the field, omits it. Test
17933
+ * `=== true` and render nothing otherwise — never infer "no rider".
17934
+ */
17935
+ hasRider: boolean().optional(),
17936
+ ...TrackFlagFields,
17937
+ ...TrackRetrainFields
17938
+ });
17939
+ var BaseEventFields = {
17940
+ id: string(),
18027
17941
  deviceId: number(),
18028
- trackId: string(),
18029
- frameId: string()
18030
- }), object({
18031
- removed: boolean(),
18032
- removedAnnotations: number().int()
18033
- }), {
18034
- kind: "mutation",
18035
- auth: "admin"
18036
- }), method(object({ frameId: string() }), object({
17942
+ timestamp: number()
17943
+ };
17944
+ var MotionEventSchema = object({
17945
+ ...BaseEventFields,
17946
+ kind: literal("motion"),
17947
+ regionCount: number(),
17948
+ /** Heavy JSON array — omitted in slim projection. */
17949
+ regions: array(object({
17950
+ bbox: BoundingBoxSchema,
17951
+ pixelCount: number(),
17952
+ intensity: number()
17953
+ })).readonly().optional(),
17954
+ /** Omitted in slim projection. */
17955
+ frameWidth: number().optional(),
17956
+ /** Omitted in slim projection. */
17957
+ frameHeight: number().optional(),
17958
+ /** Populated by B5 (recording playback URL for this event). */
17959
+ mediaUrl: string().optional()
17960
+ });
17961
+ /**
17962
+ * Which detection SOURCE produced an object event. `pipeline` = the ML
17963
+ * detection pipeline (decoded-frame inference); `onboard` = the camera's
17964
+ * native on-device AI. Both flow through the SAME analysis layers (zoning,
17965
+ * tracking, per-kind persistence) but stay distinguishable so consumers
17966
+ * (advanced-notifier, occupancy, …) can select which source(s) to act on.
17967
+ * Absent on legacy rows ⇒ treat as `pipeline`.
17968
+ */
17969
+ var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
17970
+ /**
17971
+ * The confirmed zone crossing that produced an object event. Present ONLY on
17972
+ * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
17973
+ * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
17974
+ * appearance event carry none, so a rule asking for a direction fails closed
17975
+ * on them.
17976
+ *
17977
+ * Exactly ONE crossing per event: the emitter turns each confirmed crossing
17978
+ * into its own event, so a frame in which a track enters A while leaving B
17979
+ * produces two events with two directions — never one ambiguous row.
17980
+ *
17981
+ * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
17982
+ * membership the box has NOW, and by definition it no longer contains the zone
17983
+ * that was just left. Without the id here, a zone-scoped rule could never match
17984
+ * the exit it asked for.
17985
+ */
17986
+ var ZoneCrossingSchema = object({
17987
+ direction: _enum(["enter", "exit"]),
17988
+ /** Admin zone id crossed. */
17989
+ zoneId: string(),
17990
+ /** Zone display name at crossing time (falls back to the id). */
17991
+ zoneName: string().optional()
17992
+ });
17993
+ var ObjectEventSchema = object({
17994
+ ...BaseEventFields,
17995
+ kind: literal("object"),
17996
+ /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
17997
+ source: DetectionSourceSchema.optional(),
17998
+ /**
17999
+ * Inference-frame id shared by every object event emitted from the SAME frame
18000
+ * — the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
18001
+ * 2 people + 1 dog) under one full frame, and link a track's frames over time
18002
+ * (group by `trackId`, pick a representative `frameId` as the parent frame).
18003
+ * Optional for backward-compat with pre-existing rows / the slim projection
18004
+ * includes it (it is light). Absent on rows written before this field.
18005
+ */
18006
+ frameId: string().optional(),
18007
+ /** Omitted in slim projection. */
18008
+ trackId: string().optional(),
18009
+ className: string(),
18010
+ ...TieredLabelFields,
18011
+ /** Omitted in slim projection. */
18012
+ confidence: number().optional(),
18013
+ /** Heavy JSON — omitted in slim projection. */
18014
+ bbox: BoundingBoxSchema.optional(),
18015
+ /** Heavy JSON — omitted in slim projection. */
18016
+ zones: array(string()).readonly().optional(),
18017
+ /** Omitted in slim projection. */
18018
+ state: TrackStateSchema.optional(),
18019
+ /**
18020
+ * The zone crossing this event IS, when it is one. Absent on every other
18021
+ * event kind (movement state, appearance, package) — see
18022
+ * {@link ZoneCrossingSchema}. Omitted in slim projection.
18023
+ */
18024
+ zoneCrossing: ZoneCrossingSchema.optional(),
18025
+ /** Detection-frame dimensions in pixels — let consumers normalize the
18026
+ * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
18027
+ frameWidth: number().optional(),
18028
+ frameHeight: number().optional(),
18029
+ /** MediaStore key for the crop attached to this event (if any). */
18030
+ mediaKey: string().optional(),
18031
+ /** Design B: MediaStore key of the track's native-resolution key frame (the
18032
+ * best-detection full frame). Resolve via the event-media data-plane
18033
+ * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
18034
+ * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
18035
+ * sources — consumers fall back to `mediaKey` (the tight crop). */
18036
+ keyFrameMediaKey: string().optional(),
18037
+ /** Populated by B5 (recording playback URL for this event). */
18038
+ mediaUrl: string().optional(),
18039
+ /** The parent track's key-event importance [0,1], propagated to every object
18040
+ * event of the track (so an event row can be sorted by importance without a
18041
+ * track join). Absent on legacy rows / before the track was scored. */
18042
+ importance: number().optional()
18043
+ });
18044
+ var AudioEventSchema = object({
18045
+ ...BaseEventFields,
18046
+ kind: literal("audio"),
18047
+ rms: number(),
18048
+ dbfs: number(),
18049
+ classification: object({
18050
+ className: string(),
18051
+ originalClass: string().optional(),
18052
+ score: number()
18053
+ }).optional(),
18054
+ /** Populated by B5 (recording playback URL for this event). */
18055
+ mediaUrl: string().optional()
18056
+ });
18057
+ var MediaFileKindEnum = _enum([
18058
+ "crop",
18059
+ "thumbnail",
18060
+ "snapshot",
18061
+ "firstFrame",
18062
+ "lastFrame",
18063
+ "fullFrame",
18064
+ "fullFrameBoxed",
18065
+ "faceCrop",
18066
+ "plateCrop",
18067
+ "keyFrame",
18068
+ "keyFrameSmall",
18069
+ "thumbnailSmall"
18070
+ ]);
18071
+ var MediaFileSchema = object({
18072
+ key: string(),
18073
+ kind: MediaFileKindEnum,
18037
18074
  base64: string(),
18038
- width: number().int(),
18039
- height: number().int()
18040
- }), {
18041
- kind: "query",
18042
- auth: "admin"
18043
- }), method(object({
18044
- deviceId: number(),
18045
- trackId: string(),
18046
- frameId: string(),
18047
- subject: RetrainAssistSubjectSchema,
18048
- /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
18049
- nodeId: string().optional()
18050
- }), RetrainAssistResultSchema, {
18051
- kind: "mutation",
18052
- auth: "admin"
18053
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
18054
- kind: "query",
18055
- auth: "admin"
18056
- }), method(object({
18057
- deviceId: number(),
18058
- trackId: string(),
18059
- frameId: string(),
18060
- annotations: array(RetrainAnnotationDraftSchema)
18061
- }), array(RetrainAnnotationSchema).readonly(), {
18062
- kind: "mutation",
18063
- auth: "admin"
18064
- }), method(object({
18065
- deviceId: number(),
18066
- trackId: string()
18067
- }), RetrainTransitionResultSchema, {
18068
- kind: "mutation",
18069
- auth: "admin"
18070
- }), method(object({
18071
- deviceId: number(),
18072
- trackId: string()
18073
- }), RetrainTransitionResultSchema, {
18074
- kind: "mutation",
18075
- auth: "admin"
18076
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18077
- kind: "query",
18078
- auth: "admin"
18079
- }), method(object({
18080
- eventId: string(),
18081
- kind: MediaFileKindEnum.optional(),
18082
- deviceId: number()
18083
- }), array(MediaFileSchema).readonly()), method(object({
18084
- trackId: string(),
18085
- kinds: array(MediaFileKindEnum).optional(),
18086
- deviceId: number()
18087
- }), array(MediaFileSchema).readonly()), method(object({
18075
+ sizeBytes: number(),
18076
+ timestamp: number()
18077
+ });
18078
+ /**
18079
+ * One media row WITHOUT its bytes.
18080
+ *
18081
+ * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
18082
+ * 140 s track), and a client that renders tiles from the media data plane needs
18083
+ * to know only WHAT EXISTS — the bytes then arrive per tile, lazily, over HTTP
18084
+ * with an immutable cache, instead of all at once inside a tRPC response that
18085
+ * blocks the whole view.
18086
+ *
18087
+ * `sizeBytes` is carried because it is what lets a client decide between the
18088
+ * stored blob and a `?variant=thumb` rendering without fetching either.
18089
+ */
18090
+ var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
18091
+ /**
18092
+ * The MACRO tier of an annotation — a CLOSED set.
18093
+ *
18094
+ * This is what the exported detector predicts, so a typo here is a new class
18095
+ * with one example in it. `label` and `subLabel` are open strings by contrast:
18096
+ * the whole point of the page is teaching the model things it does not know
18097
+ * yet, and constraining that vocabulary would make it useless.
18098
+ *
18099
+ * A macro class is NEVER a label. The provider refuses a write whose `label` or
18100
+ * `subLabel` is one of these values, in any casing, because once `person`
18101
+ * exists in both tiers "every person box" stops being answerable without
18102
+ * knowing every string anyone ever typed — and the damage is retroactive.
18103
+ */
18104
+ var RetrainMacroClassSchema = _enum([
18105
+ "person",
18106
+ "vehicle",
18107
+ "animal",
18108
+ "package",
18109
+ "face",
18110
+ "plate"
18111
+ ]);
18112
+ /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
18113
+ var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
18114
+ /** Did a human draw this box, or did the assist propose it? */
18115
+ var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
18116
+ /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
18117
+ var RetrainBboxSchema = object({
18118
+ x: number(),
18119
+ y: number(),
18120
+ w: number(),
18121
+ h: number()
18122
+ });
18123
+ /**
18124
+ * One annotated subject.
18125
+ *
18126
+ * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
18127
+ * (letterboxed root / zone-cropped package / subject-cropped classifier) are
18128
+ * derived from it at export and never stored — storing them is how one feature
18129
+ * space ends up holding two crops of the same subject (D52).
18130
+ */
18131
+ var RetrainAnnotationSchema = object({
18132
+ id: string(),
18088
18133
  trackId: string(),
18089
- deviceId: number()
18090
- }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
18091
- kind: "mutation",
18092
- auth: "admin"
18093
- }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
18094
- kind: "mutation",
18095
- auth: "admin"
18096
- }), method(object({}), RebuildStatusSchema), object({
18097
- deviceId: number(),
18098
- timestamp: number(),
18099
- frameWidth: number(),
18100
- frameHeight: number(),
18101
- detections: array(OverlayDetectionSchema).readonly()
18102
- }), object({
18103
18134
  deviceId: number(),
18135
+ /** The COPY in retrain storage — never the source track's media key. */
18136
+ mediaKey: string(),
18137
+ bbox: RetrainBboxSchema,
18138
+ macroClass: RetrainMacroClassSchema,
18139
+ label: string().optional(),
18140
+ subLabel: string().optional(),
18141
+ kind: RetrainAnnotationKindSchema,
18142
+ source: RetrainAnnotationSourceSchema,
18143
+ /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
18144
+ assistModelId: string().optional(),
18145
+ assistScore: number().optional(),
18146
+ exportedInBatch: string().optional(),
18147
+ createdAt: number()
18148
+ });
18149
+ /** The write form — the server owns `id`, `createdAt` and the frame binding. */
18150
+ var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
18151
+ id: true,
18152
+ trackId: true,
18153
+ deviceId: true,
18154
+ mediaKey: true,
18155
+ createdAt: true,
18156
+ exportedInBatch: true
18157
+ });
18158
+ /** A track sitting in `staging`, with everything the worklist needs to rank it. */
18159
+ var RetrainTrackSchema = object({
18104
18160
  trackId: string(),
18105
- className: string()
18106
- }), object({
18107
18161
  deviceId: number(),
18108
- trackId: string(),
18109
18162
  className: string(),
18110
- durationMs: number()
18111
- }), object({
18163
+ label: string().optional(),
18164
+ firstSeen: number(),
18165
+ lastSeen: number(),
18166
+ /** How many frames the dataset already holds from this track. */
18167
+ frameCount: number().int(),
18168
+ /** How many subjects have been annotated on those frames. `0` with
18169
+ * `frameCount: 0` is exactly "staging, still to work". */
18170
+ annotationCount: number().int()
18171
+ });
18172
+ /** A frame the picker may offer — an index row, no blob was read to produce it. */
18173
+ var RetrainFrameCandidateSchema = object({
18174
+ mediaKey: string(),
18175
+ kind: MediaFileKindEnum,
18176
+ timestamp: number(),
18177
+ sizeBytes: number().int(),
18178
+ /** A copy of this original already exists — selecting it is free and cannot
18179
+ * fail, whatever became of the original. */
18180
+ copied: boolean()
18181
+ });
18182
+ /** A frame the dataset OWNS: bytes copied at selection time. */
18183
+ var RetrainFrameSchema = object({
18184
+ frameId: string(),
18112
18185
  deviceId: number(),
18113
- kind: EventKindSchema,
18114
- eventId: string(),
18115
- timestamp: number()
18186
+ trackId: string(),
18187
+ /** Provenance only. It may already point at nothing — that is expected. */
18188
+ sourceMediaKey: string(),
18189
+ sourceKind: MediaFileKindEnum,
18190
+ sizeBytes: number().int(),
18191
+ width: number().int(),
18192
+ height: number().int(),
18193
+ copiedAt: number()
18194
+ });
18195
+ /** Why a copy-on-select could not be honoured — named, never a silent skip. */
18196
+ var RetrainCopyRefusalSchema = _enum([
18197
+ "source-missing",
18198
+ "unreadable-image",
18199
+ "write-failed"
18200
+ ]);
18201
+ var RetrainFrameSelectionSchema = object({
18202
+ copied: array(RetrainFrameSchema).readonly(),
18203
+ refused: array(object({
18204
+ sourceMediaKey: string(),
18205
+ reason: RetrainCopyRefusalSchema
18206
+ })).readonly()
18207
+ });
18208
+ var RetrainFrameListSchema = object({
18209
+ candidates: array(RetrainFrameCandidateSchema).readonly(),
18210
+ copies: array(RetrainFrameSchema).readonly(),
18211
+ /** What the page pre-selects — the native key frame when one survives. */
18212
+ autoPickMediaKey: string().optional()
18116
18213
  });
18214
+ /** What the operator asked the assist to look for. */
18215
+ var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
18216
+ kind: literal("package"),
18217
+ zone: RetrainBboxSchema.optional()
18218
+ }), object({
18219
+ kind: literal("objects"),
18220
+ modelId: string(),
18221
+ minScore: number().optional()
18222
+ })]);
18117
18223
  /**
18118
- * Reference to the frame's retained NATIVE surface + the parent crop's placement
18119
- * within the frame, so the executor can re-cut a leaf child ROI at native
18120
- * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
18224
+ * The assist's answer a discriminated union, because "the model saw nothing"
18225
+ * and "this node cannot run that model" lead to different next moves and a
18226
+ * nullable result cannot tell them apart.
18121
18227
  */
18122
- var NativeCropRefSchema = object({
18123
- /** Handle keying the retained native surface (node-pinned to its owner). */
18124
- handle: FrameHandleSchema,
18125
- /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
18126
- cropFrameSpace: object({
18127
- x: number(),
18128
- y: number(),
18129
- w: number(),
18130
- h: number()
18131
- })
18132
- });
18133
- object({
18134
- crop: object({
18135
- left: number(),
18136
- top: number(),
18137
- width: number().positive(),
18138
- height: number().positive()
18139
- }).optional(),
18140
- content: object({
18141
- width: number().int().positive(),
18142
- height: number().int().positive()
18143
- }),
18144
- fit: _enum(["stretch", "contain"]),
18145
- format: _enum([
18146
- "rgb",
18147
- "gray",
18148
- "jpeg"
18149
- ])
18228
+ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
18229
+ kind: literal("proposed"),
18230
+ modelId: string(),
18231
+ stepId: string(),
18232
+ minScore: number(),
18233
+ /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
18234
+ proposals: array(RetrainAnnotationDraftSchema).readonly(),
18235
+ /** Returned by the runner but removed by the threshold. */
18236
+ belowThreshold: number().int()
18237
+ }), object({
18238
+ kind: literal("refused"),
18239
+ /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
18240
+ reason: string(),
18241
+ detail: string().optional()
18242
+ })]);
18243
+ /** The outcome of a lifecycle move owned by the retrain page. */
18244
+ var RetrainTransitionResultSchema = object({
18245
+ trackId: string(),
18246
+ /** Where the track ended up, whatever happened. */
18247
+ retrainStatus: RetrainStatusSchema,
18248
+ /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
18249
+ changed: boolean(),
18250
+ reason: _enum([
18251
+ "unknown-track",
18252
+ "no-frames-copied",
18253
+ "not-staging",
18254
+ "not-trained",
18255
+ "unchanged"
18256
+ ]).optional()
18150
18257
  });
18151
- var FrameRefSchema = object({
18152
- registryId: string().min(1),
18153
- id: string().min(1),
18154
- width: number().int().positive(),
18155
- height: number().int().positive(),
18156
- format: _enum(["rgb", "gray"]),
18157
- timestamp: number(),
18158
- capturedAt: number().optional()
18258
+ var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
18259
+ var MAX_EVENT_QUERY_LIMIT = 5e3;
18260
+ var DeviceEventQueryInput = object({
18261
+ deviceId: number(),
18262
+ since: number().optional(),
18263
+ until: number().optional(),
18264
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
18265
+ /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
18266
+ * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
18267
+ * exact behaviour. Callers may omit this field — the store defaults to
18268
+ * `full` when not provided. */
18269
+ projection: _enum(["full", "slim"]).optional()
18159
18270
  });
18160
- var ModelFormatSchema$1 = _enum([
18161
- "onnx",
18162
- "coreml",
18163
- "openvino",
18164
- "tflite",
18165
- "pt",
18166
- "gguf"
18167
- ]);
18168
- var PipelineSlotSchema = _enum([
18169
- "detector",
18170
- "cropper",
18171
- "classifier",
18172
- "refiner",
18173
- "audio-classifier"
18174
- ]);
18175
- var PipelineEngineChoiceSchema = object({
18176
- runtime: _enum(["node", "python"]),
18177
- backend: string(),
18178
- format: ModelFormatSchema$1,
18179
- device: string().optional()
18271
+ var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
18272
+ var RecentTracksQueryInput = object({
18273
+ /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
18274
+ deviceIds: array(number()),
18275
+ /** Window lower bound on `lastSeen` (inclusive). */
18276
+ since: number().optional(),
18277
+ /** Window upper bound on `lastSeen` (inclusive). */
18278
+ until: number().optional(),
18279
+ /** Page size. Default 200, max 1000. */
18280
+ limit: number().int().min(1).max(1e3).default(200),
18281
+ /** Opaque continuation cursor from a previous page's `nextCursor`.
18282
+ * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
18283
+ cursor: string().optional(),
18284
+ /** See {@link TrackProjectionSchema}. Default `full`. */
18285
+ projection: TrackProjectionSchema.optional(),
18286
+ /** Include stationary-promoted rows (parked objects). Default false: the
18287
+ * feed lists passages; parking records live on the stationary registry. */
18288
+ includeStationary: boolean().optional()
18180
18289
  });
18181
- var AvailableEngineSchema = object({
18182
- engine: PipelineEngineChoiceSchema,
18183
- devices: array(object({
18184
- id: string(),
18185
- label: string(),
18186
- description: string().optional()
18187
- })).readonly(),
18188
- defaultDevice: string()
18290
+ var RecentTracksPageSchema = object({
18291
+ /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
18292
+ tracks: array(TrackSchema).readonly(),
18293
+ /** Cursor for the next page, or null when this page is the last. */
18294
+ nextCursor: string().nullable()
18189
18295
  });
18190
- var PipelineDefaultStepSchema = lazy(() => object({
18191
- addonId: string(),
18192
- addonName: string(),
18193
- slot: PipelineSlotSchema,
18194
- inputClasses: array(string()).readonly(),
18195
- outputClasses: array(string()).readonly(),
18196
- enabled: boolean(),
18197
- modelId: string(),
18198
- children: array(PipelineDefaultStepSchema).readonly(),
18199
- group: string().optional(),
18200
- settings: record(string(), unknown()).optional()
18201
- }));
18202
- var PipelineTemplateStepSchema = lazy(() => object({
18203
- addonId: string(),
18204
- enabled: boolean(),
18205
- modelId: string(),
18206
- children: array(PipelineTemplateStepSchema).readonly(),
18207
- settings: record(string(), unknown()).optional()
18208
- }));
18209
- var PipelineTemplateSchema$1 = object({
18296
+ var LIST_GROUPS_DEFAULT_LIMIT = 40;
18297
+ var LIST_GROUPS_MAX_LIMIT = 100;
18298
+ var AnalyticsGroupRecordSchema = object({
18210
18299
  id: string(),
18211
- name: string(),
18212
- createdAt: string(),
18213
- updatedAt: string(),
18214
- engine: PipelineEngineChoiceSchema,
18215
- steps: array(PipelineTemplateStepSchema).readonly()
18300
+ deviceId: number().int(),
18301
+ openedAt: number().int(),
18302
+ closedAt: number().int(),
18303
+ timestamp: number().int(),
18304
+ memberCount: number().int(),
18305
+ memberTrackIds: array(string()).readonly(),
18306
+ className: string(),
18307
+ classes: array(string()).readonly(),
18308
+ /** Relative event-media path, or null when the group has no picture yet. */
18309
+ mediaUrl: string().nullable(),
18310
+ singleton: boolean()
18216
18311
  });
18217
- var PipelineModelOptionSchema = object({
18218
- id: string(),
18219
- name: string(),
18220
- formats: record(string(), object({
18221
- downloaded: boolean(),
18222
- sizeMB: number()
18223
- })),
18224
- group: ModelVariantGroupSchema.optional(),
18225
- legacy: boolean().optional(),
18226
- provider: ModelProviderIdSchema.optional()
18312
+ var AnalyticsGroupMemberSchema = object({
18313
+ trackId: string(),
18314
+ deviceId: number().int(),
18315
+ className: string(),
18316
+ firstSeen: number().int(),
18317
+ lastSeen: number().int(),
18318
+ mediaUrl: string().nullable()
18227
18319
  });
18228
- var ConfigFieldBridge = custom();
18229
- var PipelineAddonSchemaSchema = object({
18230
- id: string(),
18231
- name: string(),
18232
- slot: PipelineSlotSchema,
18233
- inputClasses: array(string()).readonly(),
18234
- outputClasses: array(string()).readonly(),
18235
- childSlots: array(PipelineSlotSchema).readonly(),
18236
- models: array(PipelineModelOptionSchema).readonly(),
18237
- defaultModelId: string(),
18238
- defaultModelIdByFormat: record(string(), string()).optional(),
18239
- enabledByDefault: boolean().optional(),
18240
- backfillIntoExistingOverrides: boolean().optional(),
18241
- defaultConfidence: number(),
18242
- group: string().optional(),
18243
- configSchema: array(ConfigFieldBridge).readonly().optional()
18320
+ var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
18321
+ var ListGroupsQueryInput = object({
18322
+ /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
18323
+ deviceIds: array(number()),
18324
+ /** Window lower bound on `closedAt` (inclusive). */
18325
+ since: number().optional(),
18326
+ /** Window upper bound on `openedAt` (inclusive). */
18327
+ until: number().optional(),
18328
+ limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
18329
+ /** Opaque continuation cursor from a previous page's `nextCursor`. */
18330
+ cursor: string().optional()
18244
18331
  });
18245
- var PipelineSlotSchemaSchema = object({
18246
- id: PipelineSlotSchema,
18247
- label: string(),
18248
- priority: number(),
18249
- parentSlot: PipelineSlotSchema.nullable(),
18250
- addons: array(PipelineAddonSchemaSchema).readonly()
18332
+ var ListGroupsPageSchema = object({
18333
+ groups: array(AnalyticsGroupRecordSchema).readonly(),
18334
+ nextCursor: string().nullable()
18251
18335
  });
18252
- var PipelineSchemaSchema = object({
18253
- availableEngines: array(AvailableEngineSchema).readonly(),
18254
- selectedEngine: PipelineEngineChoiceSchema,
18255
- slots: array(PipelineSlotSchemaSchema).readonly()
18336
+ var KeyEventQueryInput = object({
18337
+ deviceId: number(),
18338
+ /** Window lower bound (track firstSeen ≥ since). */
18339
+ since: number(),
18340
+ /** Window upper bound (track firstSeen ≤ until). */
18341
+ until: number(),
18342
+ limit: number().int().min(1).max(200).default(50),
18343
+ /** Drop tracks scoring below this importance. */
18344
+ minImportance: number().min(0).max(1).optional(),
18345
+ /** Restrict to a single class (e.g. 'person'). */
18346
+ classFilter: string().optional()
18256
18347
  });
18257
- var EngineProvisioningSchema = object({
18258
- runtimeId: _enum([
18259
- "onnx",
18260
- "openvino",
18261
- "coreml",
18262
- "edgetpu"
18263
- ]).nullable(),
18264
- device: string().nullable(),
18265
- state: _enum([
18266
- "idle",
18267
- "installing",
18268
- "verifying",
18269
- "ready",
18270
- "failed"
18271
- ]),
18272
- progress: number().optional(),
18273
- error: string().optional(),
18274
- nextRetryAt: number().optional(),
18275
- /**
18276
- * Gate A (config-correctness gate at engine change): human-readable
18277
- * config issues surfaced EAGERLY when the node's engine changes — model
18278
- * substitutions ("chose X, running Y") and zero-build steps ("no model
18279
- * has a <format> build"). Additive/optional: informational only, never
18280
- * enforced here — `assertEngineReady` (readiness) still gates inference.
18281
- * Absent/empty when the node-default tree resolves cleanly.
18282
- */
18283
- configIssues: array(string()).optional()
18348
+ var KeyEventSchema = object({
18349
+ /** The representative event id (the track's best ObjectEvent, else its trackId). */
18350
+ id: string(),
18351
+ trackId: string(),
18352
+ /** Track start time (firstSeen). */
18353
+ timestamp: number(),
18354
+ className: string(),
18355
+ ...TieredLabelFields,
18356
+ importance: number(),
18357
+ /** Highest-confidence ObjectEvent id for the track (empty when none). */
18358
+ bestEventId: string(),
18359
+ /** Track lifetime in ms (lastSeen - firstSeen). */
18360
+ windowMs: number().optional(),
18361
+ ...TrackFlagFields,
18362
+ ...TrackRetrainFields
18284
18363
  });
18285
- var PipelineStepInputSchema = lazy(() => object({
18286
- addonId: string(),
18287
- modelId: string().optional(),
18288
- enabled: boolean().default(true),
18289
- children: array(PipelineStepInputSchema).optional(),
18290
- settings: record(string(), unknown()).optional(),
18291
- jumpDeviceKey: string().optional()
18292
- }));
18293
- var ModelSubstitutionSchema = object({
18294
- addonId: string(),
18295
- chosen: string(),
18296
- running: string(),
18297
- format: string()
18364
+ object({
18365
+ trackId: string(),
18366
+ className: string(),
18367
+ confidence: number(),
18368
+ bbox: BoundingBoxSchema,
18369
+ zones: array(string()).readonly(),
18370
+ state: TrackStateSchema
18298
18371
  });
18299
- var PipelineValidationIssueSchema = object({
18300
- addonId: string(),
18301
- kind: _enum(["unknown-addon", "no-format-build"]),
18302
- detail: string()
18372
+ var OverlayDetectionSchema = looseObject({
18373
+ id: string(),
18374
+ kind: _enum(["first-level", "detail"]),
18375
+ macroClass: string(),
18376
+ score: number(),
18377
+ bbox: object({
18378
+ x: number(),
18379
+ y: number(),
18380
+ width: number(),
18381
+ height: number()
18382
+ }),
18383
+ labels: array(looseObject({
18384
+ label: string(),
18385
+ score: number()
18386
+ })).readonly(),
18387
+ parentId: string().optional()
18303
18388
  });
18304
- var PipelineValidationResultSchema = object({
18305
- ok: boolean(),
18306
- issues: array(PipelineValidationIssueSchema).readonly(),
18307
- substitutions: array(ModelSubstitutionSchema).readonly(),
18308
- /** The node's `currentEngine.format` this validation ran against. */
18309
- format: string()
18389
+ var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
18390
+ var SearchObjectEventsInput = object({
18391
+ text: string(),
18392
+ deviceId: number().optional(),
18393
+ since: number().optional(),
18394
+ until: number().optional(),
18395
+ classFilter: string().optional(),
18396
+ limit: number().default(50),
18397
+ minScore: number().min(0).max(1).default(.2)
18310
18398
  });
18311
- var ReferenceImageEntrySchema = object({
18312
- filename: string(),
18313
- stepIds: array(string()).readonly().optional()
18399
+ var TrackCascadeCountsSchema = object({
18400
+ /** Persisted track roots deleted (authoritative). */
18401
+ tracks: number().int(),
18402
+ /** Object events removed with their tracks (best-effort; see note above). */
18403
+ events: number().int(),
18404
+ /** Track/face/plate-owned media removed (best-effort). Never identity media. */
18405
+ media: number().int(),
18406
+ /** Unassigned (non-enrolled) face reads removed (best-effort). */
18407
+ faces: number().int(),
18408
+ /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
18409
+ plates: number().int(),
18410
+ /** Per-track CLIP search vectors removed (best-effort). */
18411
+ embeddings: number().int(),
18412
+ /** Group membership + group rows removed with their last member (best-effort). */
18413
+ groups: number().int()
18314
18414
  });
18315
- var ReferenceImageBodySchema = object({
18316
- base64: string(),
18317
- filename: string()
18415
+ /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
18416
+ var DiskReconcileCountsSchema = object({
18417
+ mediaDropped: number().int(),
18418
+ tracks: number().int(),
18419
+ events: number().int()
18318
18420
  });
18319
- var ReferenceAudioEntrySchema = object({
18320
- filename: string(),
18321
- sizeKb: number()
18421
+ /** Event-store footprint for one camera. */
18422
+ var EventStoreDeviceFootprintSchema = object({
18423
+ deviceId: number(),
18424
+ /** Persisted event rows (motion + object + audio) for the camera. */
18425
+ rows: number().int(),
18426
+ /** Event-owned media bytes on disk for the camera. */
18427
+ bytes: number().int()
18322
18428
  });
18323
- var ReferenceAudioBodySchema = object({ base64: string() });
18324
- var AudioBackendSchema = object({
18325
- id: string(),
18326
- name: string(),
18327
- description: string(),
18328
- available: boolean(),
18329
- /**
18330
- * Raw classifier labels this backend can emit (e.g. YAMNet's
18331
- * 521-class set or Apple SoundAnalysis's 303-class set). Used by
18332
- * the benchmark UI to populate the `enabledMicroClasses` filter
18333
- * specific to the selected backend without a separate fetch.
18334
- */
18335
- rawLabels: array(string()).readonly().optional()
18429
+ /** Aggregate event-store footprint: global totals + per-camera breakdown. */
18430
+ var EventStoreFootprintSchema = object({
18431
+ totalRows: number().int(),
18432
+ totalBytes: number().int(),
18433
+ devices: array(EventStoreDeviceFootprintSchema).readonly()
18336
18434
  });
18337
- var AudioCapabilitiesSchema = object({
18338
- activeBackend: string(),
18339
- availableBackends: array(AudioBackendSchema).readonly(),
18340
- sampleRate: number(),
18341
- chunkDurationMs: number()
18435
+ /** Per-kind counts returned by the event-prune / device-delete mutations. */
18436
+ var EventPruneCountsSchema = object({
18437
+ motion: number().int(),
18438
+ object: number().int(),
18439
+ audio: number().int()
18342
18440
  });
18343
- var DownloadModelResultSchema = object({
18344
- filePath: string(),
18345
- sizeMB: number(),
18346
- durationMs: number()
18441
+ /**
18442
+ * Re-embed stored tracks from their key frames.
18443
+ *
18444
+ * The reason this is an operator-callable method and not a migration script:
18445
+ * every knob that decides what a vector MEANS — encoder model, crop margin,
18446
+ * squaring — is only changeable if the existing vectors can be regenerated.
18447
+ * Mixing feature spaces in one index makes cosine scores incomparable, and the
18448
+ * symptom is a quality regression with no visible cause.
18449
+ */
18450
+ var RebuildObjectEmbeddingsInput = object({
18451
+ /** Restrict to one camera. Omit for the whole fleet. */
18452
+ deviceId: number().optional(),
18453
+ since: number().optional(),
18454
+ until: number().optional(),
18455
+ /** Stop after this many tracks; the result reports whether more remain. */
18456
+ maxTracks: number().int().positive().optional(),
18457
+ /**
18458
+ * Run every embedding on THIS node instead of round-robining the fleet.
18459
+ *
18460
+ * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
18461
+ * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
18462
+ * calling it that would pin the rebuild REQUEST itself to that node — the
18463
+ * rebuild orchestration lives on the hub, and only the per-track step runs
18464
+ * remotely. This field is data; the per-track pin is applied inside.
18465
+ *
18466
+ * Absent ⇒ round-robin over every online node whose runner can serve the
18467
+ * pinned model.
18468
+ */
18469
+ executeOnNodeId: string().optional(),
18470
+ /**
18471
+ * Milliseconds to wait between tracks; omit for the built-in default, `0` to
18472
+ * run flat out.
18473
+ *
18474
+ * A rebuild is bulk maintenance on hub-main's single thread. Measured
18475
+ * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
18476
+ * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
18477
+ * force is logged at start and finish so a deliberately slow pass reads
18478
+ * differently from a stalled one.
18479
+ */
18480
+ pacingMs: number().int().nonnegative().optional()
18347
18481
  });
18348
18482
  /**
18349
- * Wrapper carrying a single test run's result. Replaces the legacy
18350
- * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
18351
- * canonical `AudioResult` from the Phase 6 output rework: one
18352
- * `AudioDetection` per class above `minScore`, top-N candidates in
18353
- * `debug.alternateLabels['audio-classifier']`, per-source timings in
18354
- * `debug.stepTimings`. The outer `success`/`error` fields stay so the
18355
- * benchmark UI can still report a clean failure when the classifier
18356
- * cap isn't available.
18483
+ * Result of emptying the CLIP index.
18484
+ *
18485
+ * The clean slate before a policy change: a new crop margin or encoder model
18486
+ * leaves two feature spaces in one index whose cosine scores are not
18487
+ * comparable, so wiping and rebuilding is the only way to be sure every vector
18488
+ * means the same thing.
18357
18489
  */
18358
- var AudioTestResultSchema = object({
18359
- success: boolean(),
18360
- error: string().optional(),
18361
- frame: custom().optional()
18490
+ var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
18491
+ /**
18492
+ * Acknowledgement that a rebuild STARTED.
18493
+ *
18494
+ * The pass costs ~1s per track — 45 minutes for a 2,600-track fleet — so it
18495
+ * runs detached and this returns immediately. Waiting for it made the client
18496
+ * time out while the work carried on server-side, which is the worst of both:
18497
+ * no result and no way to know it was still going. Poll
18498
+ * `getObjectEmbeddingRebuildStatus` for progress.
18499
+ */
18500
+ var RebuildObjectEmbeddingsResultSchema = object({
18501
+ started: boolean(),
18502
+ /** True when a pass was already running; the new request is ignored. */
18503
+ alreadyRunning: boolean()
18362
18504
  });
18363
- var PipelineConfigBridge = custom();
18364
- var ConfigUISchemaBridge = custom();
18365
- var ConfigUISchemaNullableBridge = custom();
18366
- var InferenceCapabilitiesBridge = custom();
18367
- var ModelAvailabilityListBridge = custom();
18368
- var PipelineRunResultBridge = custom();
18369
- method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
18370
- modelId: string(),
18371
- settings: record(string(), unknown()).readonly()
18372
- }))), method(object({ steps: record(string(), object({
18373
- modelId: string(),
18374
- settings: record(string(), unknown()).readonly()
18375
- })) }), object({ success: literal(true) }), {
18505
+ var RebuildStatusSchema = object({
18506
+ running: boolean(),
18507
+ scanned: number(),
18508
+ rebuilt: number(),
18509
+ /** Tracks whose key frame is gone — nothing to re-embed from. */
18510
+ missingKeyFrame: number(),
18511
+ /** Tracks with no usable detection box. */
18512
+ missingBbox: number(),
18513
+ /**
18514
+ * Tracks an executing node REFUSED rather than broke on — an unreadable key
18515
+ * frame, a step that threw. Separate from `failed` because the remedy is
18516
+ * different, and because a whole camera silently contributing zero vectors
18517
+ * is the shape of failure a rebuild must never hide.
18518
+ */
18519
+ notRunnable: number(),
18520
+ /**
18521
+ * The pass stopped because NO node could serve the pinned model.
18522
+ *
18523
+ * Distinct from `notRunnable` on purpose: that one says "this track was
18524
+ * refused", this one says "the cluster cannot do this work at all" — every
18525
+ * candidate node either lacks the `clip-embedding` step, lacks a build of the
18526
+ * pinned model for its engine format, or dropped out. The remedy is a model /
18527
+ * engine change, not a per-camera one. Non-zero here always comes with
18528
+ * `complete: false`.
18529
+ */
18530
+ noCapableNode: number(),
18531
+ failed: number(),
18532
+ /** Set once a pass ends: true only when EVERYTHING was covered. */
18533
+ complete: boolean().nullable(),
18534
+ startedAtMs: number().nullable(),
18535
+ finishedAtMs: number().nullable(),
18536
+ /** Present when the pass ended by throwing. */
18537
+ error: string().nullable()
18538
+ });
18539
+ var ReplayFrameInputSchema = object({
18540
+ timestamp: number(),
18541
+ frame: PipelineRunResultBridge
18542
+ });
18543
+ var RunReplayFrameProcessorResultSchema = object({ tracks: array(object({
18544
+ className: string(),
18545
+ firstSeenMs: number(),
18546
+ lastSeenMs: number(),
18547
+ /** Bbox of the track's FIRST matched detection, pixel-space in the clip's
18548
+ * frame — a representative box for the diff's `(className, window, IoU)`
18549
+ * pairing (`replay-diff.ts`). A replay does not need the full per-frame
18550
+ * trajectory production's `Track.positions` keeps. */
18551
+ bbox: BoundingBoxSchema,
18552
+ /** How many of the input frames this track matched a real detection on
18553
+ * (never a coasted/extrapolated frame) — the replay's own signal for "how
18554
+ * solid is this track", cheaper than re-deriving it from a trajectory. */
18555
+ framesMatched: number().int()
18556
+ })).readonly() });
18557
+ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
18558
+ deviceId: number(),
18559
+ trackId: string()
18560
+ }), TrackSchema.nullable()), method(object({
18561
+ deviceId: number(),
18562
+ since: number().optional(),
18563
+ until: number().optional(),
18564
+ limit: number().optional(),
18565
+ /** Spatial filter — only tracks whose trajectory intersects the zone
18566
+ * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
18567
+ * envelope columns, then precisely tested per position. Tracks with
18568
+ * an unknown envelope (no frame dims at persist time) always match. */
18569
+ zone: TrackZoneFilterSchema.optional(),
18570
+ /** See {@link TrackProjectionSchema}. Default `full` (backward
18571
+ * compatible — omitting the field keeps today's exact behaviour). */
18572
+ projection: TrackProjectionSchema.optional(),
18573
+ /** Include stationary-promoted rows (parked objects handed to the
18574
+ * stationary registry). Default false: the timeline lists passages,
18575
+ * not parking records (operator decision, 2026-08-15). */
18576
+ includeStationary: boolean().optional()
18577
+ }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
18578
+ deviceId: number(),
18579
+ groupId: string().min(1)
18580
+ }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
18581
+ kind: "mutation",
18582
+ auth: "admin"
18583
+ }), 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({
18584
+ deviceId: number(),
18585
+ since: number().optional(),
18586
+ until: number().optional(),
18587
+ kinds: array(string()).optional(),
18588
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
18589
+ }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
18590
+ deviceId: number(),
18591
+ since: number(),
18592
+ until: number(),
18593
+ bucketMs: number().int().positive()
18594
+ }), array(object({
18595
+ bucketStart: number(),
18596
+ motion: number().int(),
18597
+ object: number().int(),
18598
+ audio: number().int()
18599
+ })).readonly()), method(object({
18600
+ deviceId: number(),
18601
+ cutoffMs: number()
18602
+ }), object({
18603
+ motion: number().int(),
18604
+ object: number().int(),
18605
+ audio: number().int()
18606
+ }), {
18607
+ kind: "mutation",
18608
+ auth: "admin"
18609
+ }), method(object({
18610
+ deviceId: number(),
18611
+ cutoffMs: number()
18612
+ }), TrackCascadeCountsSchema, {
18613
+ kind: "mutation",
18614
+ auth: "admin"
18615
+ }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
18616
+ kind: "mutation",
18617
+ auth: "admin"
18618
+ }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
18619
+ kind: "mutation",
18620
+ auth: "admin"
18621
+ }), method(object({
18622
+ deviceId: number(),
18623
+ trackIds: array(string()).min(1)
18624
+ }), object({
18625
+ deleted: number().int(),
18626
+ failed: array(string()).readonly()
18627
+ }), {
18628
+ kind: "mutation",
18629
+ auth: "admin"
18630
+ }), method(object({
18631
+ /** Log/audit scope only — the trackId is globally unique on its own. */
18632
+ deviceId: number(),
18633
+ trackId: string(),
18634
+ flags: TrackFlagsPatchSchema
18635
+ }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
18636
+ kind: "query",
18637
+ auth: "admin"
18638
+ }), method(object({
18639
+ olderThanMs: number(),
18640
+ reason: OpsLogReasonSchema.optional()
18641
+ }), EventPruneCountsSchema, {
18642
+ kind: "mutation",
18643
+ auth: "admin"
18644
+ }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
18645
+ kind: "mutation",
18646
+ auth: "admin"
18647
+ }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
18648
+ kind: "mutation",
18649
+ auth: "admin"
18650
+ }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
18651
+ kind: "mutation",
18652
+ auth: "admin"
18653
+ }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
18654
+ kind: "mutation",
18655
+ auth: "admin"
18656
+ }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
18657
+ kind: "mutation",
18658
+ auth: "admin"
18659
+ }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18660
+ kind: "mutation",
18661
+ auth: "admin"
18662
+ }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
18663
+ kind: "mutation",
18664
+ auth: "admin"
18665
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
18666
+ kind: "query",
18667
+ auth: "admin"
18668
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18669
+ kind: "mutation",
18670
+ auth: "admin"
18671
+ }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
18672
+ kind: "query",
18673
+ auth: "admin"
18674
+ }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
18675
+ kind: "query",
18676
+ auth: "admin"
18677
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18678
+ kind: "query",
18679
+ auth: "admin"
18680
+ }), method(object({
18681
+ /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
18682
+ * `deviceId`, deliberately: `deviceId` would make this device-bound and
18683
+ * route it at one camera's owner, and "every camera" would stop being
18684
+ * expressible at all. */
18685
+ deviceIds: array(number()).optional(),
18686
+ limit: number().int().min(1).max(500).optional()
18687
+ }), array(RetrainTrackSchema).readonly(), {
18688
+ kind: "query",
18689
+ auth: "admin"
18690
+ }), method(object({ trackId: string() }), RetrainFrameListSchema, {
18691
+ kind: "query",
18692
+ auth: "admin"
18693
+ }), method(object({
18694
+ deviceId: number(),
18695
+ trackId: string(),
18696
+ mediaKeys: array(string()).min(1)
18697
+ }), RetrainFrameSelectionSchema, {
18376
18698
  kind: "mutation",
18377
18699
  auth: "admin"
18378
- }), method(object({ nodeId: string() }), object({
18379
- success: literal(true),
18380
- clearedDevices: number()
18700
+ }), method(object({
18701
+ deviceId: number(),
18702
+ trackId: string(),
18703
+ frameId: string()
18704
+ }), object({
18705
+ removed: boolean(),
18706
+ removedAnnotations: number().int()
18381
18707
  }), {
18382
18708
  kind: "mutation",
18383
18709
  auth: "admin"
18384
- }), 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({
18385
- name: string(),
18386
- steps: array(PipelineTemplateStepSchema).readonly(),
18387
- engine: PipelineEngineChoiceSchema
18388
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
18389
- id: string(),
18390
- name: string().optional(),
18391
- steps: array(PipelineTemplateStepSchema).readonly().optional()
18392
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
18393
- addonId: string(),
18394
- modelId: string(),
18395
- format: ModelFormatSchema$1
18396
- }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
18397
- addonId: string(),
18398
- modelId: string(),
18399
- format: ModelFormatSchema$1
18400
- }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
18401
- engine: PipelineEngineChoiceSchema.optional(),
18402
- steps: array(PipelineStepInputSchema).min(1),
18403
- frame: FrameInputSchema.optional(),
18404
- /**
18405
- * Process-local lazy frame. Valid only when caller and provider resolve
18406
- * in the same execution-group process; split/cross-node callers use
18407
- * `frame`/`image` inline compatibility instead.
18408
- */
18409
- frameRef: FrameRefSchema.optional(),
18410
- /**
18411
- * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
18412
- * the decoded pixels live in. One more member of the one-of
18413
- * frame/frameHandle/image/imageBase64/referenceImage group.
18414
- */
18415
- frameHandle: FrameHandleSchema.optional(),
18416
- imageBase64: string().optional(),
18417
- /**
18418
- * Binary JPEG bytes — preferred over `imageBase64` on internal
18419
- * hops (hub → forked worker via Moleculer MsgPack) because it
18420
- * skips the 33% base64 overhead + the per-call base64 decode on
18421
- * the detection-pipeline worker. Callers can pass either; exactly
18422
- * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
18423
- */
18424
- image: _instanceof(Uint8Array).optional(),
18425
- referenceImage: string().optional(),
18426
- deviceId: number().optional(),
18427
- sessionId: string().optional(),
18428
- /**
18429
- * Execution plane. 'full' (default) runs the whole tree — benchmark,
18430
- * reference-image, and detail-subtree calls. 'frame' is the live
18431
- * per-frame dispatch: ONLY root-plane steps run; crop children
18432
- * (inputClasses ≠ null) are skipped and served per-track via
18433
- * pipelineRunner.runDetailSubtree (two-plane design).
18434
- */
18435
- plane: _enum(["full", "frame"]).optional(),
18436
- /**
18437
- * Inference-device selector (Phase 2 multi-device). Format
18438
- * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
18439
- * Omitted ⇒ the runner's default device (current single-engine
18440
- * behaviour). Selects WHICH device pool of the node runs the call.
18441
- */
18442
- deviceKey: string().optional(),
18443
- /**
18444
- * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
18445
- * when the parent crop was resolved from the frame's retained NATIVE
18446
- * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
18447
- * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
18448
- * resolution from that surface — the SAME quality path faces already
18449
- * had — instead of the downscaled parent tile. `handle` keys the native
18450
- * surface (node-pinned to its owner); `cropFrameSpace` is the parent
18451
- * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
18452
- * the executor's crop-normalized child ROI back into frame-normalized
18453
- * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
18454
- * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
18455
- * (today's behaviour on the fallback path).
18456
- */
18457
- nativeCropRef: NativeCropRefSchema.optional()
18458
- }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
18459
- engine: PipelineEngineChoiceSchema.optional(),
18460
- steps: array(PipelineStepInputSchema).min(1),
18461
- frames: array(FrameInputSchema).min(1).max(255),
18462
- deviceId: number().optional(),
18463
- sessionId: string().optional(),
18464
- /**
18465
- * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
18466
- * the batch to the Python pool's bench preprocess cache
18467
- * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
18468
- * preprocessed ONCE and every later inference is a pure-inference cache
18469
- * hit — the sustained-throughput run measures inference, not
18470
- * decode+preprocess+infer. Omitted/0 for live frames (all different →
18471
- * full preprocess every call, correct). Fresh per sustained run;
18472
- * released via `uncacheFrame`.
18473
- */
18474
- frameId: number().int().nonnegative().optional(),
18475
- /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
18476
- deviceKey: string().optional()
18477
- }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
18478
- data: _instanceof(Uint8Array),
18479
- width: number().int().positive(),
18480
- height: number().int().positive(),
18481
- format: _enum([
18482
- "rgb",
18483
- "bgr",
18484
- "gray"
18485
- ])
18486
- }), object({
18487
- frameId: number(),
18488
- width: number(),
18489
- height: number()
18490
- }), { kind: "mutation" }), method(object({
18491
- stepId: string(),
18492
- frameId: number().int()
18493
- }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
18494
- batchMode: string(),
18495
- windowMs: number(),
18496
- maxBatchSize: number(),
18497
- concurrency: number()
18498
- })), method(_void(), array(object({
18499
- engineKey: string(),
18500
- engine: PipelineEngineChoiceSchema,
18501
- modelsLoaded: array(string()).readonly(),
18502
- inUseByCameras: array(number()).readonly(),
18503
- /**
18504
- * Origin of this resident factory.
18505
- * - `runtime` — main camera-serving engine (no idle TTL).
18506
- * - `warm-override` — benchmark/test override held in the warm
18507
- * cache; auto-disposed after the idle TTL.
18508
- * - `device-pool` — a concurrent per-device pool (Phase 2
18509
- * multi-device, keyed by `deviceKey`) resolved
18510
- * via `resolveDeviceFactory`. Runs alongside the
18511
- * `runtime` engine on a DIFFERENT accelerator
18512
- * (NPU / iGPU / Coral) — this is how the
18513
- * Engines tab shows all pools running at once.
18514
- */
18515
- kind: _enum([
18516
- "runtime",
18517
- "warm-override",
18518
- "device-pool"
18519
- ]),
18520
- /** Native pid of the underlying Python pool (null when no pool). */
18521
- poolPid: number().nullable(),
18522
- /** ms since this factory was last used (null when not warm-tracked). */
18523
- idleMs: number().nullable(),
18524
- /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
18525
- idleTtlMs: number().nullable()
18526
- })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
18710
+ }), method(object({ frameId: string() }), object({
18711
+ base64: string(),
18712
+ width: number().int(),
18713
+ height: number().int()
18714
+ }), {
18715
+ kind: "query",
18716
+ auth: "admin"
18717
+ }), method(object({
18718
+ deviceId: number(),
18719
+ trackId: string(),
18720
+ frameId: string(),
18721
+ subject: RetrainAssistSubjectSchema,
18722
+ /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
18723
+ nodeId: string().optional()
18724
+ }), RetrainAssistResultSchema, {
18527
18725
  kind: "mutation",
18528
18726
  auth: "admin"
18529
18727
  }), method(object({
18530
- engine: PipelineEngineChoiceSchema,
18531
- force: boolean().optional()
18532
- }), object({
18533
- success: boolean(),
18534
- reason: string().optional()
18535
- }), {
18728
+ deviceId: number(),
18729
+ source: DetectionSourceSchema,
18730
+ zones: array(ZoneSchema).readonly().optional(),
18731
+ detectionRules: array(ZoneRuleSchema).readonly().optional(),
18732
+ zoneMembershipMinOverlap: number().min(0).max(1).optional(),
18733
+ frames: array(ReplayFrameInputSchema).min(1)
18734
+ }), RunReplayFrameProcessorResultSchema, {
18536
18735
  kind: "mutation",
18537
18736
  auth: "admin"
18538
- }), 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({
18539
- addonId: string(),
18540
- modelId: string(),
18541
- filename: string().optional(),
18542
- settings: record(string(), unknown()).optional()
18543
- }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
18737
+ }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
18738
+ kind: "query",
18739
+ auth: "admin"
18740
+ }), method(object({
18741
+ deviceId: number(),
18742
+ trackId: string(),
18743
+ frameId: string(),
18744
+ annotations: array(RetrainAnnotationDraftSchema)
18745
+ }), array(RetrainAnnotationSchema).readonly(), {
18746
+ kind: "mutation",
18747
+ auth: "admin"
18748
+ }), method(object({
18749
+ deviceId: number(),
18750
+ trackId: string()
18751
+ }), RetrainTransitionResultSchema, {
18752
+ kind: "mutation",
18753
+ auth: "admin"
18754
+ }), method(object({
18755
+ deviceId: number(),
18756
+ trackId: string()
18757
+ }), RetrainTransitionResultSchema, {
18758
+ kind: "mutation",
18759
+ auth: "admin"
18760
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18761
+ kind: "query",
18762
+ auth: "admin"
18763
+ }), method(object({
18764
+ eventId: string(),
18765
+ kind: MediaFileKindEnum.optional(),
18766
+ deviceId: number()
18767
+ }), array(MediaFileSchema).readonly()), method(object({
18768
+ trackId: string(),
18769
+ kinds: array(MediaFileKindEnum).optional(),
18770
+ deviceId: number()
18771
+ }), array(MediaFileSchema).readonly()), method(object({
18772
+ trackId: string(),
18773
+ deviceId: number()
18774
+ }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
18775
+ kind: "mutation",
18776
+ auth: "admin"
18777
+ }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
18778
+ kind: "mutation",
18779
+ auth: "admin"
18780
+ }), method(object({}), RebuildStatusSchema), object({
18781
+ deviceId: number(),
18782
+ timestamp: number(),
18783
+ frameWidth: number(),
18784
+ frameHeight: number(),
18785
+ detections: array(OverlayDetectionSchema).readonly()
18786
+ }), object({
18787
+ deviceId: number(),
18788
+ trackId: string(),
18789
+ className: string()
18790
+ }), object({
18791
+ deviceId: number(),
18792
+ trackId: string(),
18793
+ className: string(),
18794
+ durationMs: number()
18795
+ }), object({
18796
+ deviceId: number(),
18797
+ kind: EventKindSchema,
18798
+ eventId: string(),
18799
+ timestamp: number()
18800
+ });
18544
18801
  object({
18545
18802
  activeCameras: number(),
18546
18803
  throttledCameras: number(),
@@ -18566,66 +18823,6 @@ var CameraMetricsSchema = object({
18566
18823
  });
18567
18824
  var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
18568
18825
  /**
18569
- * Zone — pure geometry + identity. NO filtering behaviour.
18570
- *
18571
- * Zones describe **where** in the frame the operator wants to flag
18572
- * something; consumer-owned {@link ZoneRule} arrays describe **how**
18573
- * each pipeline stage uses them. Splitting the two means a single
18574
- * polygon "Driveway" can simultaneously back a motion-exclude rule,
18575
- * a detection-include rule on `['car']`, and an occupancy aggregate
18576
- * — without three duplicated polygons.
18577
- *
18578
- * Owned by the orchestrator addon (provider) and mirrored into the
18579
- * `zones` device-state slice on every mutation. Consumers
18580
- * (motion-wasm, pipeline-executor, analytics, admin UI) read either
18581
- * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
18582
- * mirror with `onChanged`).
18583
- *
18584
- * Coordinates are normalised fractions of the frame (0–1) so zones
18585
- * survive resolution changes and stream profile switches.
18586
- *
18587
- * `kind` discriminates between full polygons (closed regions used
18588
- * for intrusion / occupancy filters) and tripwires (open 2-point
18589
- * line segments used for cross events). Onboard / firmware-reported
18590
- * zones (Reolink, ONVIF) are out of scope for now — see the deferred
18591
- * task list.
18592
- */
18593
- var ZoneKindEnum = _enum(["polygon", "tripwire"]);
18594
- /** Polygon vertex in fraction-of-frame coordinates (0–1). */
18595
- var PolygonPointSchema = object({
18596
- x: number(),
18597
- y: number()
18598
- });
18599
- /** A camera detection zone — pure geometry/identity. */
18600
- var ZoneSchema = object({
18601
- id: string(),
18602
- name: string(),
18603
- kind: ZoneKindEnum.default("polygon"),
18604
- /** Polygon vertices, fraction of frame (0–1). */
18605
- polygon: array(PolygonPointSchema).readonly(),
18606
- /** Visual color for UI rendering. */
18607
- color: string().default("#3b82f6")
18608
- });
18609
- DeviceType.Camera, method(object({ deviceId: number() }), array(ZoneSchema).readonly()), method(object({
18610
- deviceId: number(),
18611
- zone: ZoneSchema
18612
- }), _void(), {
18613
- kind: "mutation",
18614
- auth: "admin"
18615
- }), method(object({
18616
- deviceId: number(),
18617
- zoneId: string()
18618
- }), _void(), {
18619
- kind: "mutation",
18620
- auth: "admin"
18621
- }), method(object({
18622
- deviceId: number(),
18623
- zone: ZoneSchema
18624
- }), _void(), {
18625
- kind: "mutation",
18626
- auth: "admin"
18627
- }), object({ zones: array(ZoneSchema).readonly() });
18628
- /**
18629
18826
  * A bounding box in NORMALIZED [0,1] frame coordinates for `getNativeCrop`. The
18630
18827
  * decode worker resolves it against the RETAINED native frame's real pixel dims,
18631
18828
  * so the caller supplies only the detection-res bbox divided by the detection
@@ -20313,7 +20510,7 @@ method(object({
20313
20510
  * linking rather than produce an eternal token.
20314
20511
  */
20315
20512
  ttlSec: union([number().int().positive(), literal("never")]).optional()
20316
- }), object({ token: string() })), method(object({ token: string() }), SsoBridgeClaimsSchema.nullable());
20513
+ }), object({ token: string() }), { auth: "admin" }), method(object({ token: string() }), SsoBridgeClaimsSchema.nullable(), { auth: "admin" });
20317
20514
  var ProviderListEntrySchema = discriminatedUnion("shouldSaveDiskSpace", [object({
20318
20515
  providerId: string().min(1),
20319
20516
  displayName: string().min(1),
@@ -20408,10 +20605,13 @@ var EvictResultSchema = object({
20408
20605
  /** True when the provider has nothing left it is willing to drop on this location. */
20409
20606
  exhausted: boolean()
20410
20607
  });
20411
- method(object({ locationId: string() }), EvictableUsageSchema), method(object({
20608
+ method(object({ locationId: string() }), EvictableUsageSchema, { auth: "admin" }), method(object({
20412
20609
  locationId: string(),
20413
20610
  targetBytes: number().int().positive()
20414
- }), EvictResultSchema, { kind: "mutation" });
20611
+ }), EvictResultSchema, {
20612
+ kind: "mutation",
20613
+ auth: "admin"
20614
+ });
20415
20615
  method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin" }), method(StorageMigrationInputSchema, object({ jobId: string() }), {
20416
20616
  kind: "mutation",
20417
20617
  auth: "admin"
@@ -20471,26 +20671,50 @@ var ReadChunkInputSchema = object({
20471
20671
  length: number()
20472
20672
  });
20473
20673
  var EndDownloadInputSchema = object({ downloadId: string() });
20474
- method(_void(), ProviderInfoSchema), method(object({ config: record(string(), unknown()) }), TestLocationResultSchema, { auth: "admin" }), method(object({
20674
+ method(_void(), ProviderInfoSchema, { auth: "admin" }), method(object({ config: record(string(), unknown()) }), TestLocationResultSchema, { auth: "admin" }), method(object({
20475
20675
  location: StorageLocationSchema,
20476
20676
  relativePath: string()
20477
- }), string()), method(object({
20677
+ }), string(), { auth: "admin" }), method(object({
20478
20678
  location: StorageLocationSchema,
20479
20679
  relativePath: string(),
20480
20680
  data: _instanceof(Uint8Array)
20481
- }), _void(), { kind: "mutation" }), method(object({
20681
+ }), _void(), {
20682
+ kind: "mutation",
20683
+ auth: "admin"
20684
+ }), method(object({
20482
20685
  location: StorageLocationSchema,
20483
20686
  relativePath: string()
20484
- }), _instanceof(Uint8Array)), method(object({
20687
+ }), _instanceof(Uint8Array), { auth: "admin" }), method(object({
20485
20688
  location: StorageLocationSchema,
20486
20689
  relativePath: string()
20487
- }), boolean()), method(object({
20690
+ }), boolean(), { auth: "admin" }), method(object({
20488
20691
  location: StorageLocationSchema,
20489
20692
  prefix: string().optional()
20490
- }), array(string()).readonly()), method(object({
20693
+ }), array(string()).readonly(), { auth: "admin" }), method(object({
20491
20694
  location: StorageLocationSchema,
20492
20695
  relativePath: string()
20493
- }), _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" });
20696
+ }), _void(), {
20697
+ kind: "mutation",
20698
+ auth: "admin"
20699
+ }), method(object({ location: StorageLocationSchema }), number().nullable(), { auth: "admin" }), method(BeginUploadInputSchema, BeginUploadResultSchema, {
20700
+ kind: "mutation",
20701
+ auth: "admin"
20702
+ }), method(WriteChunkInputSchema, _void(), {
20703
+ kind: "mutation",
20704
+ auth: "admin"
20705
+ }), method(FinalizeUploadInputSchema, _void(), {
20706
+ kind: "mutation",
20707
+ auth: "admin"
20708
+ }), method(AbortUploadInputSchema, _void(), {
20709
+ kind: "mutation",
20710
+ auth: "admin"
20711
+ }), method(BeginDownloadInputSchema, BeginDownloadResultSchema, {
20712
+ kind: "mutation",
20713
+ auth: "admin"
20714
+ }), method(ReadChunkInputSchema, _instanceof(Uint8Array), { auth: "admin" }), method(EndDownloadInputSchema, _void(), {
20715
+ kind: "mutation",
20716
+ auth: "admin"
20717
+ });
20494
20718
  /** Profile-exported FormBuilder schema. Shape is ConfigUISchema at the UI. */
20495
20719
  var ProfileSettingsSchemaBridge = unknown().nullable();
20496
20720
  var ProfileSettingsBagSchema = record(string(), unknown());
@@ -20748,7 +20972,8 @@ method(object({
20748
20972
  access: "create"
20749
20973
  }), method(object({ userId: string().optional() }), object({ optionsJSON: record(string(), unknown()) }), {
20750
20974
  kind: "mutation",
20751
- access: "view"
20975
+ access: "view",
20976
+ auth: "admin"
20752
20977
  }), method(object({
20753
20978
  /** Required — the user the assertion belongs to (verified). */
20754
20979
  userId: string(),
@@ -20756,10 +20981,12 @@ method(object({
20756
20981
  response: record(string(), unknown())
20757
20982
  }), object({ verified: boolean() }), {
20758
20983
  kind: "mutation",
20759
- access: "view"
20984
+ access: "view",
20985
+ auth: "admin"
20760
20986
  }), method(object({}), object({ optionsJSON: record(string(), unknown()) }), {
20761
20987
  kind: "mutation",
20762
- access: "view"
20988
+ access: "view",
20989
+ auth: "admin"
20763
20990
  }), method(object({
20764
20991
  /** AuthenticationResponseJSON from the browser. */
20765
20992
  response: record(string(), unknown()) }), object({
@@ -20767,7 +20994,8 @@ response: record(string(), unknown()) }), object({
20767
20994
  userId: string().nullable()
20768
20995
  }), {
20769
20996
  kind: "mutation",
20770
- access: "view"
20997
+ access: "view",
20998
+ auth: "admin"
20771
20999
  }), method(object({ userId: string() }), array(PasskeySummarySchema), { auth: "admin" }), method(object({
20772
21000
  userId: string(),
20773
21001
  credentialId: string()
@@ -20939,7 +21167,19 @@ var VectorStatsResultSchema = object({
20939
21167
  /** False when the backend ranks approximately. */
20940
21168
  exact: boolean()
20941
21169
  });
20942
- 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);
21170
+ method(VectorDeclareIndexInputSchema, _void(), {
21171
+ kind: "mutation",
21172
+ auth: "admin"
21173
+ }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
21174
+ kind: "mutation",
21175
+ auth: "admin"
21176
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
21177
+ kind: "mutation",
21178
+ auth: "admin"
21179
+ }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
21180
+ kind: "mutation",
21181
+ auth: "admin"
21182
+ }), method(VectorStatsInputSchema, VectorStatsResultSchema, { auth: "admin" });
20943
21183
  var ClipSchema = object({
20944
21184
  /** Opaque, provider-namespaced id. The default provider encodes the time
20945
21185
  * window so `getClipPlayback` is self-contained (no event re-query). */
@@ -22682,7 +22922,27 @@ var MediaFileLiteSchema$1 = object({
22682
22922
  sizeBytes: number(),
22683
22923
  timestamp: number()
22684
22924
  });
22685
- method(_void(), array(IdentitySchema).readonly()), method(object({ name: string().min(1) }), IdentitySchema, {
22925
+ method(object({
22926
+ /**
22927
+ * Inline {@link IdentitySchema.coverBase64} on every row.
22928
+ *
22929
+ * Default `false`, the same inversion `listRecentFaces` and
22930
+ * `listPlates` took on 2026-08-25 (see `include-crops-default.ts` for
22931
+ * why the burden belongs on the caller that WANTS the bytes). Measured
22932
+ * on the live hub the same day: four identities cost 40,979 B with the
22933
+ * covers inline, ~10 KB of base64 per row, on a query this UI mounts
22934
+ * four times and the viewer holds at `staleTime: 30_000`.
22935
+ *
22936
+ * Nothing loses its avatar: `coverMediaKey` is already on every row and
22937
+ * the `event-media` plane serves that key `immutable` with an ETag.
22938
+ *
22939
+ * **This is an INPUT field, so it does not reach the addon until the
22940
+ * next train** — the hub router validates cap inputs against its own
22941
+ * compiled Zod and strips a key it does not know. Until then the
22942
+ * provider sees `undefined`, which resolves to `false`: the cheap shape
22943
+ * is what ships, and the opt-in becomes reachable when the train lands.
22944
+ */
22945
+ includeCrops: boolean().optional() }).optional(), array(IdentitySchema).readonly()), method(object({ name: string().min(1) }), IdentitySchema, {
22686
22946
  kind: "mutation",
22687
22947
  auth: "admin"
22688
22948
  }), method(object({
@@ -24857,8 +25117,10 @@ var PlateInfoSchema = object({
24857
25117
  keyFrameMediaKey: string().optional(),
24858
25118
  base64: string().optional(),
24859
25119
  /**
24860
- * Same crop as a data-plane URL. `getPlateByTrack` returns this and
24861
- * never inlines JPEG; `listPlates` still inlines for the admin-ui.
25120
+ * Same crop as a data-plane URL, always present when the plate has a stored
25121
+ * crop. `getPlateByTrack` returns this and never inlines JPEG; `listPlates`
25122
+ * and `searchPlates` inline the crop only when their `includeCrops` input is
25123
+ * left at its `true` default.
24862
25124
  */
24863
25125
  cropUrl: string().optional()
24864
25126
  });
@@ -24878,14 +25140,34 @@ var PlateClusterSchema = object({
24878
25140
  });
24879
25141
  method(object({
24880
25142
  deviceId: number().int().optional(),
24881
- limit: number().int().positive().optional()
25143
+ limit: number().int().positive().optional(),
25144
+ /**
25145
+ * Inline the base64 crop on every row. Default `true` — the existing
25146
+ * behaviour, kept so no caller breaks.
25147
+ *
25148
+ * Set `false` once the caller renders {@link PlateInfo.cropUrl}.
25149
+ * Measured on the live hub at the 500 rows the Plates view asks for:
25150
+ * 879,403 B and 27.7 s with the crops inline, against a few KiB of
25151
+ * metadata without them — and the browser then caches the images.
25152
+ *
25153
+ * This is the plate twin of `faceGallery.listRecentFaces`'s option;
25154
+ * plates were the one gallery list left without it.
25155
+ *
25156
+ * **This is an INPUT field, so it does not reach the addon until the
25157
+ * next train.** The hub router validates cap inputs against its own
25158
+ * compiled Zod and strips a key it does not know. Until the train
25159
+ * ships, sending `false` is harmless and keeps the crops inline.
25160
+ */
25161
+ includeCrops: boolean().optional()
24882
25162
  }).optional(), array(PlateInfoSchema).readonly()), method(object({
24883
25163
  deviceId: number().int(),
24884
25164
  trackId: string()
24885
25165
  }), PlateInfoSchema.nullable()), method(object({ plateId: string() }), array(MediaFileLiteSchema).readonly()), method(object({
24886
25166
  text: string().min(1),
24887
25167
  maxDistance: number().int().min(0).optional(),
24888
- limit: number().int().positive().optional()
25168
+ limit: number().int().positive().optional(),
25169
+ /** See `listPlates.includeCrops`. Default `true`. */
25170
+ includeCrops: boolean().optional()
24889
25171
  }), array(PlateInfoSchema).readonly()), method(object({
24890
25172
  maxDistance: number().int().min(0).optional(),
24891
25173
  minClusterSize: number().int().min(2).optional(),
@@ -24899,7 +25181,13 @@ method(object({
24899
25181
  }), method(object({ plateId: string() }), _void(), {
24900
25182
  kind: "mutation",
24901
25183
  auth: "admin"
24902
- }), method(_void(), array(VehicleSchema).readonly()), method(object({ name: string().min(1) }), VehicleSchema, {
25184
+ }), method(object({
25185
+ /** Inline {@link VehicleSchema.coverBase64} on every row. Default
25186
+ * `false` — the vehicle twin of `faceGallery.listIdentities`'s
25187
+ * option; `coverMediaKey` + the `event-media` plane carry the picture.
25188
+ * INPUT field: stripped by the hub router until the train ships, which
25189
+ * resolves to `false` and is exactly the intended default. */
25190
+ includeCrops: boolean().optional() }).optional(), array(VehicleSchema).readonly()), method(object({ name: string().min(1) }), VehicleSchema, {
24903
25191
  kind: "mutation",
24904
25192
  auth: "admin"
24905
25193
  }), method(object({
@@ -26164,92 +26452,6 @@ DeviceType.Camera, method(object({ deviceId: number() }), SceneMonitorStatusSche
26164
26452
  kind: "mutation",
26165
26453
  auth: "admin"
26166
26454
  });
26167
- /**
26168
- * Per-stage gating mode applied to the zones a rule references.
26169
- *
26170
- * - `include`: the rule contributes to a **whitelist** for its stage.
26171
- * When at least one `include` rule fires for a stage, only entities
26172
- * inside one of those zones pass that stage.
26173
- * - `exclude`: the rule contributes to a **blacklist** for its stage.
26174
- * Entities inside one of those zones are dropped at that stage.
26175
- *
26176
- * `monitor`-style observation (count without filtering) is not a rule
26177
- * mode — zones without any matching rule are observed naturally by
26178
- * `zone-analytics` (live snapshot + history), so an "I just want to
26179
- * count, not filter" use case needs no rule at all.
26180
- */
26181
- var ZoneRuleModeEnum = _enum(["include", "exclude"]);
26182
- /**
26183
- * Per-consumer rule that references existing zones (geometry) and
26184
- * defines how a specific pipeline stage should treat them. Each
26185
- * consumer addon owns its own `ZoneRule[]` array in its per-device
26186
- * settings:
26187
- *
26188
- * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
26189
- * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
26190
- * - future: notification rules, audio gating, etc.
26191
- *
26192
- * One rule applies to N zones (`zoneIds[]`) so the operator can
26193
- * express "ignore motion in ALL of {garden, street}" with a single
26194
- * rule. `classFilter` narrows the rule to specific object classes —
26195
- * "drop person detections in the street, but keep cars" is one
26196
- * `exclude` rule with `classFilter: ['person']`.
26197
- *
26198
- * `enabled` is a soft toggle — the operator can keep the rule
26199
- * configured but inert without deleting it.
26200
- */
26201
- var ZoneRuleSchema = object({
26202
- /** Stable rule id — survives edits, used by the UI for diffing. */
26203
- id: string(),
26204
- /** Optional human-readable label rendered in the rule editor. */
26205
- name: string().optional(),
26206
- /** Zones this rule targets. The rule's `mode` applies to ALL
26207
- * listed zones (OR-set: a detection in any one of them counts).
26208
- * At least one zone id required — a rule with no targets is a
26209
- * configuration mistake and the form validator rejects it. */
26210
- zoneIds: array(string()).min(1).readonly(),
26211
- mode: ZoneRuleModeEnum,
26212
- /**
26213
- * Class names this rule applies to. Empty / undefined ⇒ rule
26214
- * applies to every class. Class strings match the `macroClass`
26215
- * field on detections (e.g. `person`, `car`, `dog`).
26216
- */
26217
- classFilter: array(string()).readonly().optional(),
26218
- /**
26219
- * Minimum bbox/mask overlap (0–1) with any of the rule's zones
26220
- * required to consider an entity "in the zone". Defaults to the
26221
- * consumer's stage default when omitted. Kept for back-compat with
26222
- * existing per-rule overrides; new operators pick the value via
26223
- * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
26224
- * set, the lower-level engine reads it as a 0–1 fraction.
26225
- */
26226
- overlapThreshold: number().min(0).max(1).optional(),
26227
- /**
26228
- * Operator-friendly version of `overlapThreshold` — the percentage
26229
- * of the detection's bbox that must lie inside the zone for the
26230
- * rule to match. Documented default is 85%; the engine substitutes
26231
- * that when the field is omitted (kept optional so existing rules
26232
- * stored without it stay valid).
26233
- *
26234
- * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
26235
- * rule, the engine prefers `bboxInclusionPct` because it's the
26236
- * field exposed in the UI. Internally both feed the same gate.
26237
- */
26238
- bboxInclusionPct: number().min(0).max(100).optional(),
26239
- /**
26240
- * When `true` and a detection has a segmentation mask, use the
26241
- * mask for overlap instead of the bbox. Detection-stage only;
26242
- * motion rules ignore this field.
26243
- */
26244
- preferMask: boolean().optional(),
26245
- /**
26246
- * Soft-toggle: `false` disables the rule without deleting it.
26247
- * Defaults to `true` so operators creating a rule via the UI
26248
- * see it active immediately.
26249
- */
26250
- enabled: boolean().default(true)
26251
- });
26252
- array(ZoneRuleSchema).readonly();
26253
26455
  object({
26254
26456
  /** Whether the script is currently executing. */
26255
26457
  isRunning: boolean(),
@@ -30301,6 +30503,12 @@ Object.freeze({
30301
30503
  addonId: null,
30302
30504
  access: "create"
30303
30505
  },
30506
+ "pipelineAnalytics.cancelRelocateMedia": {
30507
+ capName: "pipeline-analytics",
30508
+ capScope: "device",
30509
+ addonId: null,
30510
+ access: "create"
30511
+ },
30304
30512
  "pipelineAnalytics.cancelStorageMigrationMove": {
30305
30513
  capName: "pipeline-analytics",
30306
30514
  capScope: "device",
@@ -30475,6 +30683,12 @@ Object.freeze({
30475
30683
  addonId: null,
30476
30684
  access: "view"
30477
30685
  },
30686
+ "pipelineAnalytics.listRelocateMediaJobs": {
30687
+ capName: "pipeline-analytics",
30688
+ capScope: "device",
30689
+ addonId: null,
30690
+ access: "view"
30691
+ },
30478
30692
  "pipelineAnalytics.listRetrainAnnotations": {
30479
30693
  capName: "pipeline-analytics",
30480
30694
  capScope: "device",
@@ -30553,6 +30767,12 @@ Object.freeze({
30553
30767
  addonId: null,
30554
30768
  access: "create"
30555
30769
  },
30770
+ "pipelineAnalytics.relocateMedia": {
30771
+ capName: "pipeline-analytics",
30772
+ capScope: "device",
30773
+ addonId: null,
30774
+ access: "create"
30775
+ },
30556
30776
  "pipelineAnalytics.restageRetrainTrack": {
30557
30777
  capName: "pipeline-analytics",
30558
30778
  capScope: "device",
@@ -30565,6 +30785,12 @@ Object.freeze({
30565
30785
  addonId: null,
30566
30786
  access: "create"
30567
30787
  },
30788
+ "pipelineAnalytics.runReplayFrameProcessor": {
30789
+ capName: "pipeline-analytics",
30790
+ capScope: "device",
30791
+ addonId: null,
30792
+ access: "create"
30793
+ },
30568
30794
  "pipelineAnalytics.saveRetrainAnnotations": {
30569
30795
  capName: "pipeline-analytics",
30570
30796
  capScope: "device",
@@ -30697,6 +30923,12 @@ Object.freeze({
30697
30923
  addonId: null,
30698
30924
  access: "view"
30699
30925
  },
30926
+ "pipelineExecutor.getInferenceDeviceHealth": {
30927
+ capName: "pipeline-executor",
30928
+ capScope: "system",
30929
+ addonId: null,
30930
+ access: "view"
30931
+ },
30700
30932
  "pipelineExecutor.getOrchestratorConfigSchema": {
30701
30933
  capName: "pipeline-executor",
30702
30934
  capScope: "system",
@@ -30769,6 +31001,12 @@ Object.freeze({
30769
31001
  addonId: null,
30770
31002
  access: "view"
30771
31003
  },
31004
+ "pipelineExecutor.rearmInferenceDevice": {
31005
+ capName: "pipeline-executor",
31006
+ capScope: "system",
31007
+ addonId: null,
31008
+ access: "create"
31009
+ },
30772
31010
  "pipelineExecutor.runAudioTest": {
30773
31011
  capName: "pipeline-executor",
30774
31012
  capScope: "system",
@@ -34017,6 +34255,11 @@ Object.freeze({
34017
34255
  form: "single",
34018
34256
  optional: false
34019
34257
  }],
34258
+ "pipelineAnalytics.runReplayFrameProcessor": [{
34259
+ name: "deviceId",
34260
+ form: "single",
34261
+ optional: false
34262
+ }],
34020
34263
  "pipelineAnalytics.saveRetrainAnnotations": [{
34021
34264
  name: "deviceId",
34022
34265
  form: "single",