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