@camstack/addon-provider-dreame 0.2.28 → 0.2.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/addon.js +2140 -1897
  2. package/dist/addon.mjs +2140 -1897
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -57135,7 +57135,7 @@ function method(input, output, options) {
57135
57135
  input,
57136
57136
  output,
57137
57137
  kind: options?.kind ?? "query",
57138
- auth: options?.auth ?? "protected",
57138
+ ...options?.auth !== void 0 ? { auth: options.auth } : {},
57139
57139
  ...options?.access !== void 0 ? { access: options.access } : {},
57140
57140
  ...options?.caller !== void 0 ? { caller: options.caller } : {},
57141
57141
  timeoutMs: options?.timeoutMs
@@ -57159,7 +57159,7 @@ function event(data) {
57159
57159
  }
57160
57160
  var StaticDirOutputSchema$1 = object({ staticDir: string() });
57161
57161
  var VersionOutputSchema$1 = object({ version: string() });
57162
- method(_void(), StaticDirOutputSchema$1), method(_void(), VersionOutputSchema$1);
57162
+ method(_void(), StaticDirOutputSchema$1, { auth: "admin" }), method(_void(), VersionOutputSchema$1, { auth: "admin" });
57163
57163
  var DeviceType = /* @__PURE__ */ function(DeviceType) {
57164
57164
  DeviceType["Camera"] = "camera";
57165
57165
  DeviceType["Hub"] = "hub";
@@ -57480,7 +57480,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
57480
57480
  }({});
57481
57481
  var StaticDirOutputSchema = object({ staticDir: string() });
57482
57482
  var VersionOutputSchema = object({ version: string() });
57483
- method(_void(), StaticDirOutputSchema), method(_void(), VersionOutputSchema);
57483
+ method(_void(), StaticDirOutputSchema, { auth: "admin" }), method(_void(), VersionOutputSchema, { auth: "admin" });
57484
57484
  /**
57485
57485
  * device-ops — device-scoped cap that unifies the per-IDevice operations
57486
57486
  * previously routed through the `.device-ops` Moleculer bridge service.
@@ -58106,24 +58106,6 @@ var RecordingRetentionSchema = object({
58106
58106
  maxSizeGb: number().min(0).optional()
58107
58107
  });
58108
58108
  /**
58109
- * Scrub-thumbnail fidelity preset — the single per-camera selector bundling the
58110
- * sprite tile RESOLUTION + JPEG QUALITY the recorder packs timeline-scrub
58111
- * previews at. Five graduated steps; absent on a config = `standard` (the
58112
- * shipped default, matching `sheet-geometry`/`sheet-composer`).
58113
- *
58114
- * Existing sheets are IMMUTABLE — a changed preset applies to NEW windows only.
58115
- * Each window's index sidecar carries its own tile dims, so a camera whose
58116
- * preset changed over time renders every historical window at the dims it was
58117
- * written with.
58118
- */
58119
- var ScrubThumbnailPresetSchema = _enum([
58120
- "minimal",
58121
- "low",
58122
- "standard",
58123
- "high",
58124
- "max"
58125
- ]);
58126
- /**
58127
58109
  * The full per-camera recording intent — the wire shape of a RecordingTarget.
58128
58110
  *
58129
58111
  * `bands` is the ONLY authored recording intent: what to record, when, and on
@@ -58131,7 +58113,11 @@ var ScrubThumbnailPresetSchema = _enum([
58131
58113
  * other field is a storage knob (profiles, segment length, retention, scrub).
58132
58114
  *
58133
58115
  * STRICT on purpose: the legacy authoring surface (`schedule`/`schedules`/
58134
- * `triggers`/`preBufferSec`/`postBufferSec`/`rules`) was retired 2026-07-30.
58116
+ * `triggers`/`preBufferSec`/`postBufferSec`/`rules`) was retired 2026-07-30,
58117
+ * and `scrubThumbnails` — a five-step fidelity knob for a sprite tier that was
58118
+ * deleted on 2026-07-24 and had ZERO consumers in the recorder — on 2026-08-25
58119
+ * (D62: a switch that writes a store nobody reads is worse than no switch).
58120
+ * Stored rows keep loading: the READ schema is `.strip()` (config-store.ts).
58135
58121
  * A stale caller must fail loudly — silently stripping its legacy intent would
58136
58122
  * persist a band-less config, i.e. silently stop recording the camera.
58137
58123
  */
@@ -58154,14 +58140,7 @@ var RecordingConfigSchema = object({
58154
58140
  * "off" is the absence of a covering band, never a band value.
58155
58141
  */
58156
58142
  bands: array(RecordingBandSchema).default([]),
58157
- retention: RecordingRetentionSchema.optional(),
58158
- /**
58159
- * Per-camera scrub-thumbnail fidelity preset (resolution + JPEG quality for
58160
- * timeline-scrub sprite previews). Absent = `standard`. Applies to NEW
58161
- * windows only — existing sheets are immutable, and each window's index
58162
- * carries its own tile dims so mixed-preset history renders correctly.
58163
- */
58164
- scrubThumbnails: ScrubThumbnailPresetSchema.optional()
58143
+ retention: RecordingRetentionSchema.optional()
58165
58144
  }).strict();
58166
58145
  /**
58167
58146
  * Entity-relocation job state (storage entity-routing spec, Phase 4).
@@ -58237,10 +58216,11 @@ var RelocateFootageInputSchema = object({
58237
58216
  * `RecordingConfig.enabled` or camera wrapper bindings. */
58238
58217
  var StorageMigrationLeaseInputSchema = object({ leaseId: string().min(1) });
58239
58218
  var StorageMigrationFootageMoveInputSchema = RelocateFootageInputSchema.extend({ leaseId: string().min(1) });
58240
- var StorageMigrationMediaMoveInputSchema = object({
58219
+ var RelocateMediaInputSchema = object({
58241
58220
  toLocationId: string(),
58242
58221
  throttleMbps: number().min(1).max(1e3).optional()
58243
- }).extend({ leaseId: string().min(1) });
58222
+ });
58223
+ var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
58244
58224
  /** The independently selectable logical storage classes. `recordings`
58245
58225
  * encompasses the high and mid segment profiles; `recordingsLow` is low
58246
58226
  * segments; `eventMedia` is post-analysis blobs. */
@@ -58535,7 +58515,26 @@ var LabelDefinitionSchema = object({
58535
58515
  description: string().optional(),
58536
58516
  icon: string().optional()
58537
58517
  });
58538
- var ClassMapDefinitionSchema = object({
58518
+ /**
58519
+ * Wire schema for a per-model CATALOG classMap override
58520
+ * (`ModelCatalogEntry.classMap` / `ModelConvertMetadata.classMap`) —
58521
+ * restricted to {@link CLASS_MAP_MACRO_TARGETS}, the only macros the
58522
+ * detection pipeline executor actually routes.
58523
+ *
58524
+ * This is deliberately a DIFFERENT, narrower shape than the general-purpose
58525
+ * `ClassMapDefinition` interface above (e.g. `IDetectionAddon.getClassMap()`
58526
+ * and the audio `YAMNET_TO_MACRO` catalog both use macro targets outside this
58527
+ * enum) — the two used to share the name `ClassMapDefinition`/
58528
+ * `ClassMapDefinitionSchema`, which made the schema-type-twin guard
58529
+ * (`scripts/check-schema-type-twins.ts`) flag them as a duplicated shape. They
58530
+ * are not: it is two different concepts colliding on a name. Keep this type
58531
+ * under its own name rather than reusing `ClassMapDefinition` — reusing it
58532
+ * would either narrow every `ClassMapDefinition` consumer to the four
58533
+ * detection macros (breaking `YAMNET_TO_MACRO`) or drop the validation this
58534
+ * schema exists for (see the "rejects a classMap whose target is not a
58535
+ * detection macro" test in `model-catalog-schema.test.ts`).
58536
+ */
58537
+ var DetectionCatalogClassMapSchema = object({
58539
58538
  mapping: record(string(), _enum([
58540
58539
  "person",
58541
58540
  "vehicle",
@@ -58740,7 +58739,7 @@ var ModelCatalogEntrySchema = object({
58740
58739
  * applies (Frigate / COCO public catalog). Set on a custom model whose raw
58741
58740
  * labels already ARE the CamStack macros (Scrypted identity map).
58742
58741
  */
58743
- classMap: ClassMapDefinitionSchema.optional()
58742
+ classMap: DetectionCatalogClassMapSchema.optional()
58744
58743
  });
58745
58744
  var ConvertTargetSchema = discriminatedUnion("format", [object({
58746
58745
  format: literal("openvino"),
@@ -58770,7 +58769,7 @@ var ModelConvertMetadataSchema = object({
58770
58769
  "segmentation"
58771
58770
  ]),
58772
58771
  faceAlignment: boolean().optional(),
58773
- classMap: ClassMapDefinitionSchema.optional()
58772
+ classMap: DetectionCatalogClassMapSchema.optional()
58774
58773
  });
58775
58774
  var ConvertResultSchema = object({
58776
58775
  entry: ModelCatalogEntrySchema,
@@ -59633,7 +59632,7 @@ var AddonPageDeclarationSchema = object({
59633
59632
  /** Display label for a CUSTOM `section` id (ignored for well-known ids). */
59634
59633
  sectionLabel: string().optional()
59635
59634
  });
59636
- method(_void(), array(AddonPageDeclarationSchema).readonly());
59635
+ method(_void(), array(AddonPageDeclarationSchema).readonly(), { auth: "admin" });
59637
59636
  var AddonHttpRouteSchema = object({
59638
59637
  method: _enum([
59639
59638
  "GET",
@@ -59868,7 +59867,7 @@ var WidgetMetadataSchema = object({
59868
59867
  defaultColumns: number().int().min(1).max(12).default(6),
59869
59868
  defaultRows: number().int().min(1).max(12).default(1)
59870
59869
  });
59871
- method(_void(), array(WidgetMetadataSchema).readonly());
59870
+ method(_void(), array(WidgetMetadataSchema).readonly(), { auth: "admin" });
59872
59871
  /**
59873
59872
  * `addon-widgets` — system-scoped singleton aggregator cap. Public-facing
59874
59873
  * surface that admin-ui consumes through `useAddonWidgetsListWidgets()`.
@@ -61492,7 +61491,7 @@ var CustomModelDescriptorSchema = object({
61492
61491
  stepId: string(),
61493
61492
  entry: ModelCatalogEntrySchema
61494
61493
  });
61495
- method(_void(), array(CustomModelDescriptorSchema).readonly());
61494
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
61496
61495
  /**
61497
61496
  * Query filter for settings-store collections.
61498
61497
  */
@@ -61579,7 +61578,8 @@ method(object({
61579
61578
  }), _void(), { kind: "mutation" }), method(object({
61580
61579
  namespace: string().optional(),
61581
61580
  collection: string(),
61582
- filter: QueryFilterSchema.optional()
61581
+ filter: QueryFilterSchema.optional(),
61582
+ columns: array(string()).readonly().optional()
61583
61583
  }), array(SettingsRecordSchema).readonly()), method(object({
61584
61584
  namespace: string().optional(),
61585
61585
  collection: string(),
@@ -61642,46 +61642,87 @@ var EngineInfoSchema = object({
61642
61642
  kind: _enum(["relational", "vector"]),
61643
61643
  displayName: string()
61644
61644
  });
61645
- method(_void(), EngineInfoSchema), method(object({
61645
+ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
61646
61646
  namespace: string().optional(),
61647
61647
  collection: string(),
61648
61648
  key: string()
61649
- }), unknown()), method(object({
61649
+ }), unknown(), { auth: "admin" }), method(object({
61650
61650
  namespace: string().optional(),
61651
61651
  collection: string(),
61652
61652
  key: string(),
61653
61653
  value: unknown()
61654
- }), _void(), { kind: "mutation" }), method(object({
61654
+ }), _void(), {
61655
+ kind: "mutation",
61656
+ auth: "admin"
61657
+ }), method(object({
61655
61658
  namespace: string().optional(),
61656
61659
  collection: string(),
61657
- filter: QueryFilterSchema.optional()
61658
- }), array(SettingsRecordSchema).readonly()), method(object({
61660
+ filter: QueryFilterSchema.optional(),
61661
+ /**
61662
+ * SQL-level column projection — MUST mirror `settings-store.query`.
61663
+ *
61664
+ * ⚠ An earlier version of this comment blamed Zod stripping, and that
61665
+ * was wrong — corrected 2026-08-26 after the hop map
61666
+ * (`docs/design/2026-08-26-mappa-hop-argomenti.md`) traced the path.
61667
+ * There is **no Zod parse at all** between the door and the engine: the
61668
+ * dispatcher forwards the payload verbatim and UDS carries it whole. A
61669
+ * field declared here reaches `SqliteSettingsBackend` either way.
61670
+ *
61671
+ * What actually lost `columns` was the THIRD declaration of this shape:
61672
+ * `SettingsQueryInput` in `interfaces/storage.ts`, a hand-written TS
61673
+ * interface the engine destructures from. The field existed on both
61674
+ * schemas and the engine still never read it, because nothing checks a
61675
+ * registered provider against `InferProvider<cap>` —
61676
+ * `ProviderRegistration.provider` is typed `object`.
61677
+ *
61678
+ * It is declared here anyway, and must stay in step with
61679
+ * `settings-store.query`: a caller reading only the cap definitions has
61680
+ * to be able to see that this call carries a projection.
61681
+ * `data-door-schema-parity.spec.ts` keeps the two aligned.
61682
+ */
61683
+ columns: array(string()).readonly().optional()
61684
+ }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
61659
61685
  namespace: string().optional(),
61660
61686
  collection: string(),
61661
61687
  record: SettingsRecordSchema
61662
- }), _void(), { kind: "mutation" }), method(object({
61688
+ }), _void(), {
61689
+ kind: "mutation",
61690
+ auth: "admin"
61691
+ }), method(object({
61663
61692
  namespace: string().optional(),
61664
61693
  collection: string(),
61665
61694
  id: string(),
61666
61695
  data: record(string(), unknown())
61667
- }), _void(), { kind: "mutation" }), method(object({
61696
+ }), _void(), {
61697
+ kind: "mutation",
61698
+ auth: "admin"
61699
+ }), method(object({
61668
61700
  namespace: string().optional(),
61669
61701
  collection: string(),
61670
61702
  key: string()
61671
- }), _void(), { kind: "mutation" }), method(object({
61703
+ }), _void(), {
61704
+ kind: "mutation",
61705
+ auth: "admin"
61706
+ }), method(object({
61672
61707
  namespace: string().optional(),
61673
61708
  collection: string(),
61674
61709
  filter: MutationFilterSchema
61675
- }), object({ deleted: number().int() }), { kind: "mutation" }), method(object({
61710
+ }), object({ deleted: number().int() }), {
61711
+ kind: "mutation",
61712
+ auth: "admin"
61713
+ }), method(object({
61676
61714
  namespace: string().optional(),
61677
61715
  collection: string(),
61678
61716
  filter: MutationFilterSchema,
61679
61717
  data: record(string(), unknown())
61680
- }), object({ updated: number().int() }), { kind: "mutation" }), method(object({
61718
+ }), object({ updated: number().int() }), {
61719
+ kind: "mutation",
61720
+ auth: "admin"
61721
+ }), method(object({
61681
61722
  namespace: string().optional(),
61682
61723
  collection: string(),
61683
61724
  filter: QueryFilterSchema.optional()
61684
- }), number()), method(object({
61725
+ }), number(), { auth: "admin" }), method(object({
61685
61726
  namespace: string().optional(),
61686
61727
  collection: string(),
61687
61728
  field: string(),
@@ -61691,15 +61732,18 @@ method(_void(), EngineInfoSchema), method(object({
61691
61732
  }), array(object({
61692
61733
  bucket: number().int(),
61693
61734
  count: number().int()
61694
- })).readonly()), method(object({
61735
+ })).readonly(), { auth: "admin" }), method(object({
61695
61736
  namespace: string().optional(),
61696
61737
  collection: string()
61697
- }), boolean()), method(object({
61738
+ }), boolean(), { auth: "admin" }), method(object({
61698
61739
  namespace: string().optional(),
61699
61740
  collection: string(),
61700
61741
  columns: array(CollectionColumnSchema).readonly(),
61701
61742
  indexes: array(CollectionIndexSchema).readonly().optional()
61702
- }), _void(), { kind: "mutation" });
61743
+ }), _void(), {
61744
+ kind: "mutation",
61745
+ auth: "admin"
61746
+ });
61703
61747
  /**
61704
61748
  * shm ring usage stats for a `frameSink: 'shm'` decoder session —
61705
61749
  * exposed via `decoder.getShmStats` so downstream consumers can
@@ -63006,7 +63050,7 @@ method(object({
63006
63050
  crop: _instanceof(Uint8Array),
63007
63051
  width: number(),
63008
63052
  height: number()
63009
- }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
63053
+ }), EmbeddingResultSchema, { auth: "admin" }), method(object({ text: string() }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" });
63010
63054
  /**
63011
63055
  * filesystem-browse — per-node capability for browsing the node's local
63012
63056
  * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
@@ -63299,19 +63343,22 @@ method(LlmGenerateBaseInputSchema.extend({
63299
63343
  runtime: ManagedRuntimeConfigSchema,
63300
63344
  /** The managed profile's timeout, threaded by the hub provider. */
63301
63345
  timeoutMs: number().int().positive().optional()
63302
- }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
63346
+ }), LlmGenerateResultSchema, {
63347
+ kind: "mutation",
63348
+ auth: "admin"
63349
+ }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
63303
63350
  kind: "mutation",
63304
63351
  auth: "admin"
63305
63352
  }), method(object({}), _void(), {
63306
63353
  kind: "mutation",
63307
63354
  auth: "admin"
63308
- }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
63355
+ }), method(object({}), LlmRuntimeStatusSchema, { auth: "admin" }), method(object({ model: ManagedModelRefSchema }), _void(), {
63309
63356
  kind: "mutation",
63310
63357
  auth: "admin"
63311
63358
  }), method(object({ file: string() }), _void(), {
63312
63359
  kind: "mutation",
63313
63360
  auth: "admin"
63314
- }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
63361
+ }), method(object({}), array(LlmNodeModelSchema), { auth: "admin" }), method(object({}), LlmRuntimeDiskUsageSchema, { auth: "admin" });
63315
63362
  /**
63316
63363
  * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
63317
63364
  * methods concat-fan across providers; single-row methods route to ONE
@@ -66822,1748 +66869,1998 @@ var OauthIntegrationDescriptorSchema = object({
66822
66869
  */
66823
66870
  refreshTokenTtlSec: union([number().int().positive(), literal("never")]).optional()
66824
66871
  });
66825
- method(_void(), OauthIntegrationDescriptorSchema);
66872
+ method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
66826
66873
  /**
66827
- * pipeline-analytics — device-scoped wrapper cap. Refines raw
66828
- * per-frame detections emitted by the pipeline runner into tracked
66829
- * objects, per-kind event collections (motion / object / audio), and
66830
- * persisted media. Owns the post-detection domain end-to-end:
66831
- *
66832
- * runner emits PipelineInferenceResult
66833
- * ↓ (event bus)
66834
- * pipeline-analytics subscriber
66835
- * ↓ SORT tracker + zone engine + state analyzer + event emitter
66836
- * → three DB collections (one per kind), one FS media tree, one
66837
- * unified event emitter (FrameTracked + TrackStarted/Ended +
66838
- * DetectionEvent on bus)
66839
- *
66840
- * Pure subscriber model. No `processFrame` cap method — the runner
66841
- * already publishes the raw frame on the bus. The cap surface is
66842
- * only QUERIES + per-device settings, bound on/off via
66843
- * `device-manager.setWrapperActive`. `defaultActive: true` because
66844
- * every camera with a detection pipeline wants its raw detections
66845
- * refined; operators opt out per-device via BindingsTab when needed.
66846
- *
66847
- * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
66848
- * (per-device surface) and `track-trail` caps — see P11 cleanup.
66874
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
66875
+ * within the frame, so the executor can re-cut a leaf child ROI at native
66876
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
66849
66877
  */
66850
- var TrackStateSchema = _enum([
66851
- "new",
66852
- "entered",
66853
- "left",
66854
- "moving",
66855
- "idle"
66856
- ]);
66857
- var EventKindSchema = _enum([
66858
- "motion",
66859
- "object",
66860
- "audio"
66861
- ]);
66878
+ var NativeCropRefSchema = object({
66879
+ /** Handle keying the retained native surface (node-pinned to its owner). */
66880
+ handle: FrameHandleSchema,
66881
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
66882
+ cropFrameSpace: object({
66883
+ x: number(),
66884
+ y: number(),
66885
+ w: number(),
66886
+ h: number()
66887
+ })
66888
+ });
66889
+ object({
66890
+ crop: object({
66891
+ left: number(),
66892
+ top: number(),
66893
+ width: number().positive(),
66894
+ height: number().positive()
66895
+ }).optional(),
66896
+ content: object({
66897
+ width: number().int().positive(),
66898
+ height: number().int().positive()
66899
+ }),
66900
+ fit: _enum(["stretch", "contain"]),
66901
+ format: _enum([
66902
+ "rgb",
66903
+ "gray",
66904
+ "jpeg"
66905
+ ])
66906
+ });
66862
66907
  /**
66863
- * Spatial filter for `listTracks` — the rect + polygon variants of the shared
66864
- * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
66865
- * of the camera frame (top-left origin), matching the drawing-plane editor.
66908
+ * Process-local frame identity. It is serializable so it can ride an in-process
66909
+ * capability call, but `registryId` deliberately prevents resolution in any
66910
+ * other process or execution group.
66866
66911
  */
66867
- var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
66868
- /** Closed icon vocabulary so clients render a known glyph per kind. */
66869
- var EventKindIconSchema = _enum([
66870
- "motion",
66871
- "audio",
66872
- "person",
66873
- "vehicle",
66874
- "animal",
66875
- "door",
66876
- "pir",
66877
- "smoke",
66878
- "water",
66879
- "button",
66880
- "package",
66881
- "generic"
66912
+ var FrameRefSchema = object({
66913
+ registryId: string().min(1),
66914
+ id: string().min(1),
66915
+ width: number().int().positive(),
66916
+ height: number().int().positive(),
66917
+ format: _enum(["rgb", "gray"]),
66918
+ timestamp: number(),
66919
+ capturedAt: number().optional()
66920
+ });
66921
+ var ModelFormatSchema$1 = _enum([
66922
+ "onnx",
66923
+ "coreml",
66924
+ "openvino",
66925
+ "tflite",
66926
+ "pt",
66927
+ "gguf"
66882
66928
  ]);
66883
- var EventKindCategorySchema = _enum([
66884
- "motion",
66885
- "audio",
66886
- "detection",
66887
- "sensor",
66888
- "control",
66889
- "custom",
66890
- "package"
66929
+ var PipelineSlotSchema = _enum([
66930
+ "detector",
66931
+ "cropper",
66932
+ "classifier",
66933
+ "refiner",
66934
+ "audio-classifier"
66891
66935
  ]);
66892
- /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
66893
- var EventKindLevelSchema = _enum(["macro", "sub"]);
66894
- var EventKindDescriptorSchema = object({
66895
- /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
66896
- kind: string(),
66897
- /** i18n key resolved on the UI side; `label` is the English fallback. */
66898
- labelKey: string(),
66899
- /** English fallback label (kept for clients that don't translate). */
66900
- label: string(),
66901
- /** Hex color for timeline/legend rendering. */
66902
- color: string(),
66903
- /** Dictionary id → lucide component on the UI side. */
66904
- iconId: string(),
66905
- /** Legacy closed-vocab glyph — fallback for `iconId`. */
66906
- icon: EventKindIconSchema,
66907
- category: EventKindCategorySchema,
66908
- /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
66909
- parentKind: string().nullable(),
66910
- /** Derived from `parentKind`, explicit for the client tree. */
66911
- level: EventKindLevelSchema,
66912
- /** Which cap + device contributes this kind. For built-ins the camera
66913
- * itself; for sensor kinds the LINKED source device. */
66914
- source: object({
66915
- capName: string(),
66916
- deviceId: number()
66917
- })
66936
+ var PipelineEngineChoiceSchema = object({
66937
+ runtime: _enum(["node", "python"]),
66938
+ backend: string(),
66939
+ format: ModelFormatSchema$1,
66940
+ device: string().optional()
66918
66941
  });
66919
- /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
66920
- var EventKindsForDeviceSchema = object({
66921
- deviceId: number(),
66922
- kinds: array(EventKindDescriptorSchema).readonly()
66942
+ var AvailableEngineSchema = object({
66943
+ engine: PipelineEngineChoiceSchema,
66944
+ devices: array(object({
66945
+ id: string(),
66946
+ label: string(),
66947
+ description: string().optional()
66948
+ })).readonly(),
66949
+ defaultDevice: string()
66923
66950
  });
66924
- var SensorEventSchema = object({
66951
+ var PipelineDefaultStepSchema = lazy(() => object({
66952
+ addonId: string(),
66953
+ addonName: string(),
66954
+ slot: PipelineSlotSchema,
66955
+ inputClasses: array(string()).readonly(),
66956
+ outputClasses: array(string()).readonly(),
66957
+ enabled: boolean(),
66958
+ modelId: string(),
66959
+ children: array(PipelineDefaultStepSchema).readonly(),
66960
+ group: string().optional(),
66961
+ settings: record(string(), unknown()).optional()
66962
+ }));
66963
+ var PipelineTemplateStepSchema = lazy(() => object({
66964
+ addonId: string(),
66965
+ enabled: boolean(),
66966
+ modelId: string(),
66967
+ children: array(PipelineTemplateStepSchema).readonly(),
66968
+ settings: record(string(), unknown()).optional()
66969
+ }));
66970
+ var PipelineTemplateSchema$1 = object({
66925
66971
  id: string(),
66926
- /** The CAMERA the event is attributed to (a sensor linked to N cameras
66927
- * yields N rows, one per camera). */
66928
- deviceId: number(),
66929
- /** The linked sensor device whose state changed. */
66930
- sourceDeviceId: number(),
66931
- /** Event kind id — matches an `EventKindDescriptor.kind`. */
66932
- kind: string(),
66933
- /** Snapshot of the sensor cap's runtime-state slice at the change. */
66934
- value: record(string(), unknown()).nullable(),
66935
- timestamp: number()
66972
+ name: string(),
66973
+ createdAt: string(),
66974
+ updatedAt: string(),
66975
+ engine: PipelineEngineChoiceSchema,
66976
+ steps: array(PipelineTemplateStepSchema).readonly()
66936
66977
  });
66937
- var TrackPositionSchema = object({
66938
- x: number(),
66939
- y: number(),
66940
- timestamp: number(),
66941
- bbox: BoundingBoxSchema
66942
- });
66943
- var TrackSnapshotSchema = object({
66944
- timestamp: number(),
66945
- position: TrackPositionSchema,
66946
- /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
66947
- mediaKey: string()
66978
+ var PipelineModelOptionSchema = object({
66979
+ id: string(),
66980
+ name: string(),
66981
+ formats: record(string(), object({
66982
+ downloaded: boolean(),
66983
+ sizeMB: number()
66984
+ })),
66985
+ group: ModelVariantGroupSchema.optional(),
66986
+ legacy: boolean().optional(),
66987
+ provider: ModelProviderIdSchema.optional()
66948
66988
  });
66949
- /**
66950
- * Normalized 0..1 trajectory envelope (min/max over every position bbox,
66951
- * divided by the track's detection-frame dims), computed at persist time.
66952
- * Absent when the frame dims were unknown when the track was persisted
66953
- * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
66954
- */
66955
- var TrackEnvelopeSchema = object({
66956
- minX: number(),
66957
- minY: number(),
66958
- maxX: number(),
66959
- maxY: number()
66989
+ var ConfigFieldBridge = custom();
66990
+ var PipelineAddonSchemaSchema = object({
66991
+ id: string(),
66992
+ name: string(),
66993
+ slot: PipelineSlotSchema,
66994
+ inputClasses: array(string()).readonly(),
66995
+ outputClasses: array(string()).readonly(),
66996
+ childSlots: array(PipelineSlotSchema).readonly(),
66997
+ models: array(PipelineModelOptionSchema).readonly(),
66998
+ defaultModelId: string(),
66999
+ defaultModelIdByFormat: record(string(), string()).optional(),
67000
+ enabledByDefault: boolean().optional(),
67001
+ backfillIntoExistingOverrides: boolean().optional(),
67002
+ defaultConfidence: number(),
67003
+ group: string().optional(),
67004
+ configSchema: array(ConfigFieldBridge).readonly().optional()
66960
67005
  });
66961
- /**
66962
- * Row projection for track list queries. `full` (default) returns the
66963
- * complete Track including the frame-rate `positions[]` history and the
66964
- * `snapshots[]` references — megabytes across a page of tracks. `slim`
66965
- * keeps every scalar the list surfaces actually render (ids, class(es),
66966
- * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
66967
- * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
66968
- * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
66969
- * `getTrack`. Mirrors the event-store `projection` convention
66970
- * (`getObjectEvents` et al.).
66971
- */
66972
- var TrackProjectionSchema = _enum(["full", "slim"]);
66973
- /**
66974
- * One audio-classification label heard on the track's camera while the
66975
- * track was alive, aggregated per label. An "episode" is one persisted
66976
- * audio event (the confident-classification path: score ≥ the device's
66977
- * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
66978
- * one 32 ms inference chunk, so counts stay human-scaled.
66979
- */
66980
- var TrackAudioLabelSchema = object({
67006
+ var PipelineSlotSchemaSchema = object({
67007
+ id: PipelineSlotSchema,
66981
67008
  label: string(),
66982
- /** Highest classification score observed across the label's episodes. */
66983
- peakScore: number(),
66984
- /** Number of coalesced audio-event episodes carrying this label. */
66985
- count: number(),
66986
- firstAt: number(),
66987
- lastAt: number()
67009
+ priority: number(),
67010
+ parentSlot: PipelineSlotSchema.nullable(),
67011
+ addons: array(PipelineAddonSchemaSchema).readonly()
66988
67012
  });
66989
- /**
66990
- * How a track was produced. `pipeline` (default / absent) = the spatial
66991
- * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
66992
- * no positions, a single snapshot, and no bbox trajectory at all:
66993
- *
66994
- * - `sensor` — a linked sensor/control device state change.
66995
- * - `audio` — an audio event on the camera itself that was anomalous for
66996
- * THAT camera, loud, and heard while nothing visual was happening (D62).
66997
- *
66998
- * The spatial subsystems (tracker association, occupancy count, re-id /
66999
- * embedding, resurrection) MUST skip every synthetic source. Test for that
67000
- * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
67001
- * check silently readmits every source added after it was written.
67002
- */
67003
- var TrackSourceSchema = _enum([
67004
- "pipeline",
67005
- "sensor",
67006
- "audio"
67007
- ]);
67008
- /**
67009
- * Where a track sits in the RETRAIN lifecycle (D81).
67010
- *
67011
- * - `none` — never marked, or un-marked. Evictable.
67012
- * - `staging` — the operator wants this track as training material and has not
67013
- * finished with it. **This is the only state retention holds**: the track and
67014
- * everything it owns (object events, crops, keyframes, CLIP vector) survive
67015
- * the device's age window.
67016
- * - `trained` — the retrain page has taken what it needed. The frames it chose
67017
- * were COPIED into the retrain dataset at selection time, so the dataset no
67018
- * longer depends on the track's media and the track becomes EVICTABLE again.
67019
- * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
67020
- * a deliberate action of the retrain page, not a side effect of a checkbox.
67021
- *
67022
- * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
67023
- * the store's filter language has only positive equality and `whereIn` — no
67024
- * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
67025
- * would make the entire pre-column history immortal in one deploy.
67026
- */
67027
- var RetrainStatusSchema = _enum([
67028
- "none",
67029
- "staging",
67030
- "trained"
67031
- ]);
67032
- /**
67033
- * Per-track OPERATOR flags — set by hand from the admin UI or the viewer, never
67034
- * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
67035
- * so the two surfaces cannot drift.
67036
- *
67037
- * **Absent ≠ false.** A track that has never been touched omits the field; an
67038
- * explicitly un-flagged track carries `false`. Legacy rows written before the
67039
- * columns existed read as absent, and a consumer that needs a boolean should say
67040
- * `flag === true`, not `flag !== false`.
67041
- *
67042
- * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
67043
- * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
67044
- * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
67045
- * `trained` track reports `false` while refusing both writes. The boolean is
67046
- * kept because three surfaces drive a toggle off it; anything that needs to tell
67047
- * "never marked" from "already trained" must read `retrainStatus`.
67048
- *
67049
- * `debug` does NOT pin; it is attention, not durability.
67050
- *
67051
- * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
67052
- * A favourited track is skipped by retention the same way `staging` is, but
67053
- * it does not enter `none|staging|trained` and has no staging budget.
67054
- */
67055
- var TrackFlagFields = {
67056
- /** Operator marked this track as training material — i.e. `retrainStatus` is
67057
- * `'staging'`. */
67058
- markForTrain: boolean().optional(),
67059
- /** Operator marked this track for diagnostic attention. */
67060
- debug: boolean().optional(),
67061
- /** Operator favourited this track. Pins it against pruning. */
67062
- favourited: boolean().optional()
67063
- };
67064
- /**
67065
- * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
67066
- * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
67067
- * write patch, and the status is not something the toggle sets — it is what the
67068
- * toggle's boolean is derived from. Absent on an in-RAM track never touched;
67069
- * always present on a persisted row (the column default materialises `'none'`).
67070
- */
67071
- var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
67072
- /**
67073
- * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
67074
- * one flag can never clear the other — the toggles are independent and are
67075
- * driven from three surfaces that do not know about each other.
67076
- */
67077
- var TrackFlagsPatchSchema = object(TrackFlagFields);
67078
- /**
67079
- * The resolved flag state after a write. Both fields are REQUIRED here (absent
67080
- * collapses to `false`) so a caller can drive a toggle's checked state off the
67081
- * mutation result without a re-fetch.
67082
- */
67083
- var TrackFlagsSchema = object({
67084
- trackId: string(),
67085
- markForTrain: boolean(),
67086
- debug: boolean(),
67087
- favourited: boolean(),
67088
- /** The lifecycle state the boolean was derived from. Required here (unlike on
67089
- * a track row) because this shape is only ever produced by the write body,
67090
- * which always knows it — and a surface that has just written needs to render
67091
- * `trained` without a re-fetch. */
67092
- retrainStatus: RetrainStatusSchema
67013
+ var PipelineSchemaSchema = object({
67014
+ availableEngines: array(AvailableEngineSchema).readonly(),
67015
+ selectedEngine: PipelineEngineChoiceSchema,
67016
+ slots: array(PipelineSlotSchemaSchema).readonly()
67093
67017
  });
67094
- union([literal(1), literal(2)]);
67095
- /**
67096
- * WHO decided a label, and when. Carried per tier so a value can be traced to
67097
- * the step and model that produced it — which is what makes the write rule
67098
- * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
67099
- * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
67100
- *
67101
- * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
67102
- * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
67103
- * `migration:4g` for a value the 4g migration moved from the single-slot era —
67104
- * that value has no provenance, and the write rule lets ANY properly-attributed
67105
- * write of the same tier replace it regardless of score.
67106
- */
67107
- var LabelAttributionSchema = object({
67108
- stepId: string(),
67109
- modelId: string().optional(),
67110
- decidedAt: number(),
67018
+ var EngineProvisioningSchema = object({
67019
+ runtimeId: _enum([
67020
+ "onnx",
67021
+ "openvino",
67022
+ "coreml",
67023
+ "edgetpu"
67024
+ ]).nullable(),
67025
+ device: string().nullable(),
67026
+ state: _enum([
67027
+ "idle",
67028
+ "installing",
67029
+ "verifying",
67030
+ "ready",
67031
+ "failed"
67032
+ ]),
67033
+ progress: number().optional(),
67034
+ error: string().optional(),
67035
+ nextRetryAt: number().optional(),
67111
67036
  /**
67112
- * The GALLERY id behind a recognised tier-2 label — a face-gallery
67113
- * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
67114
- *
67115
- * The text alone is a DISPLAY NAME, and a display name is renameable: a
67116
- * notification rule authored on "Gianluca" stopped matching the moment the
67117
- * operator fixed the spelling in the gallery, and nothing said so. The id is
67118
- * the thing that does not move, so it is what a rule matches on
67119
- * (`NcConditions.identities`) and the text is what a human is shown.
67120
- *
67121
- * Absent when the label names no gallery row — a plate the OCR read but no
67122
- * vehicle claims, a sub-class, a species, any tier-1 value.
67037
+ * Gate A (config-correctness gate at engine change): human-readable
67038
+ * config issues surfaced EAGERLY when the node's engine changes — model
67039
+ * substitutions ("chose X, running Y") and zero-build steps ("no model
67040
+ * has a <format> build"). Additive/optional: informational only, never
67041
+ * enforced here — `assertEngineReady` (readiness) still gates inference.
67042
+ * Absent/empty when the node-default tree resolves cleanly.
67123
67043
  */
67124
- identityId: string().optional()
67044
+ configIssues: array(string()).optional()
67125
67045
  });
67126
- /**
67127
- * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
67128
- * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
67129
- * track and its events always answer the same question the same way.
67130
- *
67131
- * Two scalar columns, not an array: every consumer wants "the coarse one" or
67132
- * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
67133
- * is tier 2, and each carries its own score + attribution.
67134
- *
67135
- * **Reading it.** What a human should be shown is `subLabel ?? label` — the
67136
- * finest thing known. Before 4g the single `label` column held the finest
67137
- * value, so a consumer that has not been updated reads the tier-1 slot and
67138
- * shows nothing on a species-only row; that is why the migration puts every
67139
- * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
67140
- * and why the read surfaces were changed in the same train.
67141
- *
67142
- * **Writing it.** The slots are independent, which is the whole point: a
67143
- * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
67144
- * migratorius`), so fineness cannot regress by construction. Within a tier the
67145
- * higher score wins. One rule, one implementation — see
67146
- * `pipeline/label-tier.ts` in addon-post-analysis.
67147
- */
67148
- var TieredLabelFields = {
67149
- /** Tier 1 — the sub-class. See {@link LabelTierSchema}. */
67150
- label: string().optional(),
67151
- /** Confidence of the tier-1 value, as reported by the deciding step. */
67152
- labelScore: number().optional(),
67153
- /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
67154
- labelMeta: LabelAttributionSchema.optional(),
67155
- /** Tier 2 — the instance. See {@link LabelTierSchema}. */
67156
- subLabel: string().optional(),
67157
- /** Confidence of the tier-2 value, as reported by the deciding step. */
67158
- subLabelScore: number().optional(),
67159
- /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
67160
- subLabelMeta: LabelAttributionSchema.optional()
67161
- };
67162
- /** Per-camera slice of a training-export estimate. */
67163
- var TrainingExportDeviceTotalsSchema = object({
67164
- deviceId: number(),
67165
- tracks: number().int(),
67166
- files: number().int(),
67167
- bytes: number().int()
67046
+ var PipelineStepInputSchema = lazy(() => object({
67047
+ addonId: string(),
67048
+ modelId: string().optional(),
67049
+ enabled: boolean().default(true),
67050
+ children: array(PipelineStepInputSchema).optional(),
67051
+ settings: record(string(), unknown()).optional(),
67052
+ jumpDeviceKey: string().optional()
67053
+ }));
67054
+ var ModelSubstitutionSchema = object({
67055
+ addonId: string(),
67056
+ chosen: string(),
67057
+ running: string(),
67058
+ format: string()
67059
+ });
67060
+ var PipelineValidationIssueSchema = object({
67061
+ addonId: string(),
67062
+ kind: _enum(["unknown-addon", "no-format-build"]),
67063
+ detail: string()
67064
+ });
67065
+ var PipelineValidationResultSchema = object({
67066
+ ok: boolean(),
67067
+ issues: array(PipelineValidationIssueSchema).readonly(),
67068
+ substitutions: array(ModelSubstitutionSchema).readonly(),
67069
+ /** The node's `currentEngine.format` this validation ran against. */
67070
+ format: string()
67071
+ });
67072
+ var ReferenceImageEntrySchema = object({
67073
+ filename: string(),
67074
+ stepIds: array(string()).readonly().optional()
67075
+ });
67076
+ var ReferenceImageBodySchema = object({
67077
+ base64: string(),
67078
+ filename: string()
67079
+ });
67080
+ var ReferenceAudioEntrySchema = object({
67081
+ filename: string(),
67082
+ sizeKb: number()
67083
+ });
67084
+ var ReferenceAudioBodySchema = object({ base64: string() });
67085
+ var AudioBackendSchema = object({
67086
+ id: string(),
67087
+ name: string(),
67088
+ description: string(),
67089
+ available: boolean(),
67090
+ /**
67091
+ * Raw classifier labels this backend can emit (e.g. YAMNet's
67092
+ * 521-class set or Apple SoundAnalysis's 303-class set). Used by
67093
+ * the benchmark UI to populate the `enabledMicroClasses` filter
67094
+ * specific to the selected backend without a separate fetch.
67095
+ */
67096
+ rawLabels: array(string()).readonly().optional()
67097
+ });
67098
+ var AudioCapabilitiesSchema = object({
67099
+ activeBackend: string(),
67100
+ availableBackends: array(AudioBackendSchema).readonly(),
67101
+ sampleRate: number(),
67102
+ chunkDurationMs: number()
67103
+ });
67104
+ var DownloadModelResultSchema = object({
67105
+ filePath: string(),
67106
+ sizeMB: number(),
67107
+ durationMs: number()
67168
67108
  });
67169
67109
  /**
67170
- * What a training export WOULD contain. Computed from media index rows only —
67171
- * no blob is read to produce this.
67110
+ * Wrapper carrying a single test run's result. Replaces the legacy
67111
+ * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
67112
+ * canonical `AudioResult` from the Phase 6 output rework: one
67113
+ * `AudioDetection` per class above `minScore`, top-N candidates in
67114
+ * `debug.alternateLabels['audio-classifier']`, per-source timings in
67115
+ * `debug.stepTimings`. The outer `success`/`error` fields stay so the
67116
+ * benchmark UI can still report a clean failure when the classifier
67117
+ * cap isn't available.
67172
67118
  */
67173
- var TrainingExportSummarySchema = object({
67174
- generatedAt: number(),
67175
- trackCount: number().int(),
67176
- fileCount: number().int(),
67177
- byteCount: number().int(),
67178
- /** More marked tracks exist than a single pass carries. */
67179
- truncated: boolean(),
67180
- devices: array(TrainingExportDeviceTotalsSchema).readonly()
67119
+ var AudioTestResultSchema = object({
67120
+ success: boolean(),
67121
+ error: string().optional(),
67122
+ frame: custom().optional()
67181
67123
  });
67182
- var TrackSchema = object({
67183
- trackId: string(),
67184
- deviceId: number(),
67185
- className: string(),
67186
- ...TieredLabelFields,
67187
- producingDeviceName: string().optional(),
67188
- /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
67189
- source: TrackSourceSchema.optional(),
67190
- firstSeen: number(),
67191
- lastSeen: number(),
67192
- /** Frame-rate position history (subject to maxPositionHistory cap). */
67193
- positions: array(TrackPositionSchema).readonly(),
67194
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
67195
- * saveThumbnails policy). */
67196
- snapshots: array(TrackSnapshotSchema).readonly(),
67197
- /** Deduplicated zones the track has entered at least once. Zone IDS. */
67198
- zonesVisited: array(string()).readonly(),
67124
+ var PipelineConfigBridge = custom();
67125
+ var ConfigUISchemaBridge = custom();
67126
+ var ConfigUISchemaNullableBridge = custom();
67127
+ var InferenceCapabilitiesBridge = custom();
67128
+ var ModelAvailabilityListBridge = custom();
67129
+ var PipelineRunResultBridge = custom();
67130
+ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
67131
+ modelId: string(),
67132
+ settings: record(string(), unknown()).readonly()
67133
+ }))), method(object({ steps: record(string(), object({
67134
+ modelId: string(),
67135
+ settings: record(string(), unknown()).readonly()
67136
+ })) }), object({ success: literal(true) }), {
67137
+ kind: "mutation",
67138
+ auth: "admin"
67139
+ }), method(object({ nodeId: string() }), object({
67140
+ success: literal(true),
67141
+ clearedDevices: number()
67142
+ }), {
67143
+ kind: "mutation",
67144
+ auth: "admin"
67145
+ }), method(object({ nodeId: string() }), object({ unhealthy: array(object({
67146
+ /** `<backend>:<device>`, e.g. `openvino:gpu`. */
67147
+ deviceKey: string(),
67199
67148
  /**
67200
- * Human NAMES for {@link zonesVisited}, resolved at READ time against the
67201
- * `zones` capability.
67202
- *
67203
- * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
67204
- * and no card can render — so every free-text search surface was structurally
67205
- * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
67206
- * just returned nothing. Resolving here rather than in each client keeps ONE
67207
- * derivation and costs the clients no extra call (the `zones` cap is
67208
- * per-device, so a client-side resolve would be a per-camera fan-out on a
67209
- * surface built to avoid exactly that).
67210
- *
67211
- * Resolved, never invented: a zone deleted since the track was written has no
67212
- * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
67213
- * two are not positionally aligned. Absent when the track visited no zone, or
67214
- * when the zone catalogue could not be read.
67149
+ * `failed` — the per-device restart budget is exhausted; no pool
67150
+ * will be spawned until an operator re-arms it or the runner
67151
+ * respawns. `backoff` — under budget, waiting out the backoff (or
67152
+ * a cached pool observed dead and not yet condemned).
67215
67153
  */
67216
- zoneNames: array(string()).readonly().optional(),
67217
- /** Deduplicated set of detector classes observed for this track over its
67218
- * life (a track may be reclassified, e.g. person→vehicle). Absent on
67219
- * legacy rows written before class accumulation shipped. */
67220
- classes: array(string()).readonly().optional(),
67221
- /** Cumulative normalized distance travelled (0..1 units = full frame width). */
67222
- totalDistance: number(),
67223
- state: TrackStateSchema,
67224
- active: boolean(),
67225
- /** Deterministic key-event importance score in [0,1] (server-computed at
67226
- * track expiry, recomputed on late label). Absent on legacy rows written
67227
- * before scoring shipped — consumers degrade to absence / compute-on-read. */
67228
- importance: number().optional(),
67229
- /** Id of the track's highest-confidence ObjectEvent (its representative
67230
- * "best" frame). Absent when the track produced no object events. */
67231
- bestEventId: string().optional(),
67232
- /** Tag of the importance sub-signal that dominated the score
67233
- * (identity|dwell|proximity|class|confidence|travel|zone). */
67234
- importanceReason: string().optional(),
67235
- /** Audio-classification labels heard on the camera during the track's
67236
- * life (score ≥ device `classificationMinScore`), aggregated per label.
67237
- * Absent on legacy rows / tracks with no confident audio. */
67238
- audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
67239
- /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
67240
- * Populated from the persisted envelope columns on historical reads;
67241
- * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
67242
- envelope: TrackEnvelopeSchema.optional(),
67154
+ state: _enum(["failed", "backoff"]),
67155
+ /** Epoch ms of the death that produced this state. */
67156
+ since: number(),
67157
+ /** Pool deaths inside the current window. */
67158
+ deaths: number(),
67159
+ /** The last death's message. */
67160
+ lastError: string()
67161
+ })).readonly() })), method(object({
67162
+ nodeId: string(),
67163
+ deviceKey: string()
67164
+ }), object({ rearmed: boolean() }), {
67165
+ kind: "mutation",
67166
+ auth: "admin"
67167
+ }), 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({
67168
+ name: string(),
67169
+ steps: array(PipelineTemplateStepSchema).readonly(),
67170
+ engine: PipelineEngineChoiceSchema
67171
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
67172
+ id: string(),
67173
+ name: string().optional(),
67174
+ steps: array(PipelineTemplateStepSchema).readonly().optional()
67175
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
67176
+ addonId: string(),
67177
+ modelId: string(),
67178
+ format: ModelFormatSchema$1
67179
+ }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
67180
+ addonId: string(),
67181
+ modelId: string(),
67182
+ format: ModelFormatSchema$1
67183
+ }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
67184
+ engine: PipelineEngineChoiceSchema.optional(),
67185
+ steps: array(PipelineStepInputSchema).min(1),
67186
+ frame: FrameInputSchema.optional(),
67243
67187
  /**
67244
- * A face DETECTOR found a face on this track — nothing more. It says the
67245
- * detail plane produced a `face` detail; it does NOT say the face was
67246
- * embedded, matched, above `minFacePx`, or that the recognizer was even
67247
- * enabled. Set once and never cleared.
67248
- *
67249
- * **This exists so "face present but not recognised" is expressible.** A
67250
- * recognised identity lands in `subLabel` (attributed to the face chain via
67251
- * `subLabelMeta.stepId`), so before this field a track with an unmatched face
67252
- * and a track with no face at all were byte-identical on the wire and no
67253
- * surface could tell them apart. The read is `hasFace === true && subLabel
67254
- * === undefined`.
67255
- *
67256
- * **Absent ≠ false.** Every row written before the column existed omits it,
67257
- * and so does every server that predates the field — a consumer must test
67258
- * `=== true` and render nothing otherwise, never infer "no face".
67188
+ * Process-local lazy frame. Valid only when caller and provider resolve
67189
+ * in the same execution-group process; split/cross-node callers use
67190
+ * `frame`/`image` inline compatibility instead.
67259
67191
  */
67260
- hasFace: boolean().optional(),
67192
+ frameRef: FrameRefSchema.optional(),
67261
67193
  /**
67262
- * This track has a face row IN THE GALLERY: a crop **and** an embedding — a
67263
- * face an operator could ASSIGN to an identity.
67264
- *
67265
- * The STRICT twin of {@link hasFace}, and the pair only earns its keep
67266
- * because the two disagree. `hasFace` is stamped at the TOP of the face
67267
- * branch, before every gate, and means no more than "a face detector produced
67268
- * a face detail". This one is stamped at the single moment the gallery row
67269
- * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
67270
- * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
67271
- * candidate gate, the imageless-track drop (no crop was ever captured) and
67272
- * the crop-store drop. Everything between the detector and that insert can
67273
- * legitimately refuse the face, so a flag written any earlier promises the
67274
- * operator something to assign and delivers nothing.
67275
- *
67276
- * **Independent of recognition.** A face collected but never auto-matched is
67277
- * still assignable — it is in fact the face an operator most wants to reach —
67278
- * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
67279
- * `subLabel`; this says only that the raw material exists.
67280
- *
67281
- * **Set once, never cleared.** A track that produced a gallery row produced
67282
- * one; deleting the row later is the gallery's business, not this flag's.
67283
- *
67284
- * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
67285
- * before the column omits it, and so does every server that predates the
67286
- * field. A consumer must test `=== true` and render nothing otherwise —
67287
- * never infer "no assignable face".
67194
+ * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
67195
+ * the decoded pixels live in. One more member of the one-of
67196
+ * frame/frameHandle/image/imageBase64/referenceImage group.
67288
67197
  */
67289
- hasEmbeddedFace: boolean().optional(),
67198
+ frameHandle: FrameHandleSchema.optional(),
67199
+ imageBase64: string().optional(),
67290
67200
  /**
67291
- * This subject CONTAINS a folded rider — a person the rider-pairing step
67292
- * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
67293
- * so the passage is tracked once and as a VEHICLE.
67294
- *
67295
- * It exists because the fold's record was dishonest. D34 and the code both
67296
- * said "the person is not lost — it is reported so both entities stay on the
67297
- * record"; in fact the pair went into a per-processor RAM field behind an
67298
- * accessor nobody called, and every durable surface said `vehicle`, full
67299
- * stop. This is the composition note that makes the row true.
67300
- *
67301
- * A COMPOSITION, never a class and never a label. "This vehicle contains a
67302
- * person" is not an answer to "what is this" — both label tiers would refuse
67303
- * a macro token anyway (D89), and correctly. Nothing here changes what the
67304
- * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
67305
- * and a `person` rule still does not fire for someone cycling past.
67306
- *
67307
- * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
67308
- * the column, and every hub that predates the field, omits it. Test
67309
- * `=== true` and render nothing otherwise — never infer "no rider".
67201
+ * Binary JPEG bytes — preferred over `imageBase64` on internal
67202
+ * hops (hub → forked worker via Moleculer MsgPack) because it
67203
+ * skips the 33% base64 overhead + the per-call base64 decode on
67204
+ * the detection-pipeline worker. Callers can pass either; exactly
67205
+ * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
67310
67206
  */
67311
- hasRider: boolean().optional(),
67312
- ...TrackFlagFields,
67313
- ...TrackRetrainFields
67314
- });
67315
- var BaseEventFields = {
67316
- id: string(),
67317
- deviceId: number(),
67318
- timestamp: number()
67319
- };
67320
- var MotionEventSchema = object({
67321
- ...BaseEventFields,
67322
- kind: literal("motion"),
67323
- regionCount: number(),
67324
- /** Heavy JSON array — omitted in slim projection. */
67325
- regions: array(object({
67326
- bbox: BoundingBoxSchema,
67327
- pixelCount: number(),
67328
- intensity: number()
67329
- })).readonly().optional(),
67330
- /** Omitted in slim projection. */
67331
- frameWidth: number().optional(),
67332
- /** Omitted in slim projection. */
67333
- frameHeight: number().optional(),
67334
- /** Populated by B5 (recording playback URL for this event). */
67335
- mediaUrl: string().optional()
67336
- });
67207
+ image: _instanceof(Uint8Array).optional(),
67208
+ referenceImage: string().optional(),
67209
+ deviceId: number().optional(),
67210
+ sessionId: string().optional(),
67211
+ /**
67212
+ * Execution plane. 'full' (default) runs the whole tree — benchmark,
67213
+ * reference-image, and detail-subtree calls. 'frame' is the live
67214
+ * per-frame dispatch: ONLY root-plane steps run; crop children
67215
+ * (inputClasses ≠ null) are skipped and served per-track via
67216
+ * pipelineRunner.runDetailSubtree (two-plane design).
67217
+ */
67218
+ plane: _enum(["full", "frame"]).optional(),
67219
+ /**
67220
+ * Inference-device selector (Phase 2 multi-device). Format
67221
+ * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
67222
+ * Omitted ⇒ the runner's default device (current single-engine
67223
+ * behaviour). Selects WHICH device pool of the node runs the call.
67224
+ */
67225
+ deviceKey: string().optional(),
67226
+ /**
67227
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
67228
+ * when the parent crop was resolved from the frame's retained NATIVE
67229
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
67230
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
67231
+ * resolution from that surface — the SAME quality path faces already
67232
+ * had — instead of the downscaled parent tile. `handle` keys the native
67233
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
67234
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
67235
+ * the executor's crop-normalized child ROI back into frame-normalized
67236
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
67237
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
67238
+ * (today's behaviour on the fallback path).
67239
+ */
67240
+ nativeCropRef: NativeCropRefSchema.optional()
67241
+ }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
67242
+ engine: PipelineEngineChoiceSchema.optional(),
67243
+ steps: array(PipelineStepInputSchema).min(1),
67244
+ frames: array(FrameInputSchema).min(1).max(255),
67245
+ deviceId: number().optional(),
67246
+ sessionId: string().optional(),
67247
+ /**
67248
+ * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
67249
+ * the batch to the Python pool's bench preprocess cache
67250
+ * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
67251
+ * preprocessed ONCE and every later inference is a pure-inference cache
67252
+ * hit — the sustained-throughput run measures inference, not
67253
+ * decode+preprocess+infer. Omitted/0 for live frames (all different →
67254
+ * full preprocess every call, correct). Fresh per sustained run;
67255
+ * released via `uncacheFrame`.
67256
+ */
67257
+ frameId: number().int().nonnegative().optional(),
67258
+ /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
67259
+ deviceKey: string().optional()
67260
+ }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
67261
+ data: _instanceof(Uint8Array),
67262
+ width: number().int().positive(),
67263
+ height: number().int().positive(),
67264
+ format: _enum([
67265
+ "rgb",
67266
+ "bgr",
67267
+ "gray"
67268
+ ])
67269
+ }), object({
67270
+ frameId: number(),
67271
+ width: number(),
67272
+ height: number()
67273
+ }), { kind: "mutation" }), method(object({
67274
+ stepId: string(),
67275
+ frameId: number().int()
67276
+ }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
67277
+ batchMode: string(),
67278
+ windowMs: number(),
67279
+ maxBatchSize: number(),
67280
+ concurrency: number()
67281
+ })), method(_void(), array(object({
67282
+ engineKey: string(),
67283
+ engine: PipelineEngineChoiceSchema,
67284
+ modelsLoaded: array(string()).readonly(),
67285
+ inUseByCameras: array(number()).readonly(),
67286
+ /**
67287
+ * Origin of this resident factory.
67288
+ * - `runtime` — main camera-serving engine (no idle TTL).
67289
+ * - `warm-override` — benchmark/test override held in the warm
67290
+ * cache; auto-disposed after the idle TTL.
67291
+ * - `device-pool` — a concurrent per-device pool (Phase 2
67292
+ * multi-device, keyed by `deviceKey`) resolved
67293
+ * via `resolveDeviceFactory`. Runs alongside the
67294
+ * `runtime` engine on a DIFFERENT accelerator
67295
+ * (NPU / iGPU / Coral) — this is how the
67296
+ * Engines tab shows all pools running at once.
67297
+ */
67298
+ kind: _enum([
67299
+ "runtime",
67300
+ "warm-override",
67301
+ "device-pool"
67302
+ ]),
67303
+ /** Native pid of the underlying Python pool (null when no pool). */
67304
+ poolPid: number().nullable(),
67305
+ /** ms since this factory was last used (null when not warm-tracked). */
67306
+ idleMs: number().nullable(),
67307
+ /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
67308
+ idleTtlMs: number().nullable()
67309
+ })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
67310
+ kind: "mutation",
67311
+ auth: "admin"
67312
+ }), method(object({
67313
+ engine: PipelineEngineChoiceSchema,
67314
+ force: boolean().optional()
67315
+ }), object({
67316
+ success: boolean(),
67317
+ reason: string().optional()
67318
+ }), {
67319
+ kind: "mutation",
67320
+ auth: "admin"
67321
+ }), 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({
67322
+ addonId: string(),
67323
+ modelId: string(),
67324
+ filename: string().optional(),
67325
+ settings: record(string(), unknown()).optional()
67326
+ }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
67337
67327
  /**
67338
- * Which detection SOURCE produced an object event. `pipeline` = the ML
67339
- * detection pipeline (decoded-frame inference); `onboard` = the camera's
67340
- * native on-device AI. Both flow through the SAME analysis layers (zoning,
67341
- * tracking, per-kind persistence) but stay distinguishable so consumers
67342
- * (advanced-notifier, occupancy, …) can select which source(s) to act on.
67343
- * Absent on legacy rows ⇒ treat as `pipeline`.
67328
+ * Per-stage gating mode applied to the zones a rule references.
67329
+ *
67330
+ * - `include`: the rule contributes to a **whitelist** for its stage.
67331
+ * When at least one `include` rule fires for a stage, only entities
67332
+ * inside one of those zones pass that stage.
67333
+ * - `exclude`: the rule contributes to a **blacklist** for its stage.
67334
+ * Entities inside one of those zones are dropped at that stage.
67335
+ *
67336
+ * `monitor`-style observation (count without filtering) is not a rule
67337
+ * mode — zones without any matching rule are observed naturally by
67338
+ * `zone-analytics` (live snapshot + history), so an "I just want to
67339
+ * count, not filter" use case needs no rule at all.
67344
67340
  */
67345
- var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
67341
+ var ZoneRuleModeEnum = _enum(["include", "exclude"]);
67346
67342
  /**
67347
- * The confirmed zone crossing that produced an object event. Present ONLY on
67348
- * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
67349
- * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
67350
- * appearance event carry none, so a rule asking for a direction fails closed
67351
- * on them.
67343
+ * Per-consumer rule that references existing zones (geometry) and
67344
+ * defines how a specific pipeline stage should treat them. Each
67345
+ * consumer addon owns its own `ZoneRule[]` array in its per-device
67346
+ * settings:
67352
67347
  *
67353
- * Exactly ONE crossing per event: the emitter turns each confirmed crossing
67354
- * into its own event, so a frame in which a track enters A while leaving B
67355
- * produces two events with two directions — never one ambiguous row.
67348
+ * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
67349
+ * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
67350
+ * - future: notification rules, audio gating, etc.
67356
67351
  *
67357
- * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
67358
- * membership the box has NOW, and by definition it no longer contains the zone
67359
- * that was just left. Without the id here, a zone-scoped rule could never match
67360
- * the exit it asked for.
67352
+ * One rule applies to N zones (`zoneIds[]`) so the operator can
67353
+ * express "ignore motion in ALL of {garden, street}" with a single
67354
+ * rule. `classFilter` narrows the rule to specific object classes —
67355
+ * "drop person detections in the street, but keep cars" is one
67356
+ * `exclude` rule with `classFilter: ['person']`.
67357
+ *
67358
+ * `enabled` is a soft toggle — the operator can keep the rule
67359
+ * configured but inert without deleting it.
67361
67360
  */
67362
- var ZoneCrossingSchema = object({
67363
- direction: _enum(["enter", "exit"]),
67364
- /** Admin zone id crossed. */
67365
- zoneId: string(),
67366
- /** Zone display name at crossing time (falls back to the id). */
67367
- zoneName: string().optional()
67368
- });
67369
- var ObjectEventSchema = object({
67370
- ...BaseEventFields,
67371
- kind: literal("object"),
67372
- /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
67373
- source: DetectionSourceSchema.optional(),
67361
+ var ZoneRuleSchema = object({
67362
+ /** Stable rule id — survives edits, used by the UI for diffing. */
67363
+ id: string(),
67364
+ /** Optional human-readable label rendered in the rule editor. */
67365
+ name: string().optional(),
67366
+ /** Zones this rule targets. The rule's `mode` applies to ALL
67367
+ * listed zones (OR-set: a detection in any one of them counts).
67368
+ * At least one zone id required — a rule with no targets is a
67369
+ * configuration mistake and the form validator rejects it. */
67370
+ zoneIds: array(string()).min(1).readonly(),
67371
+ mode: ZoneRuleModeEnum,
67374
67372
  /**
67375
- * Inference-frame id shared by every object event emitted from the SAME frame
67376
- * — the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
67377
- * 2 people + 1 dog) under one full frame, and link a track's frames over time
67378
- * (group by `trackId`, pick a representative `frameId` as the parent frame).
67379
- * Optional for backward-compat with pre-existing rows / the slim projection
67380
- * includes it (it is light). Absent on rows written before this field.
67381
- */
67382
- frameId: string().optional(),
67383
- /** Omitted in slim projection. */
67384
- trackId: string().optional(),
67385
- className: string(),
67386
- ...TieredLabelFields,
67387
- /** Omitted in slim projection. */
67388
- confidence: number().optional(),
67389
- /** Heavy JSON — omitted in slim projection. */
67390
- bbox: BoundingBoxSchema.optional(),
67391
- /** Heavy JSON — omitted in slim projection. */
67392
- zones: array(string()).readonly().optional(),
67393
- /** Omitted in slim projection. */
67394
- state: TrackStateSchema.optional(),
67373
+ * Class names this rule applies to. Empty / undefined ⇒ rule
67374
+ * applies to every class. Class strings match the `macroClass`
67375
+ * field on detections (e.g. `person`, `car`, `dog`).
67376
+ */
67377
+ classFilter: array(string()).readonly().optional(),
67395
67378
  /**
67396
- * The zone crossing this event IS, when it is one. Absent on every other
67397
- * event kind (movement state, appearance, package) — see
67398
- * {@link ZoneCrossingSchema}. Omitted in slim projection.
67379
+ * Minimum bbox/mask overlap (0–1) with any of the rule's zones
67380
+ * required to consider an entity "in the zone". Defaults to the
67381
+ * consumer's stage default when omitted. Kept for back-compat with
67382
+ * existing per-rule overrides; new operators pick the value via
67383
+ * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
67384
+ * set, the lower-level engine reads it as a 0–1 fraction.
67399
67385
  */
67400
- zoneCrossing: ZoneCrossingSchema.optional(),
67401
- /** Detection-frame dimensions in pixels — let consumers normalize the
67402
- * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
67403
- frameWidth: number().optional(),
67404
- frameHeight: number().optional(),
67405
- /** MediaStore key for the crop attached to this event (if any). */
67406
- mediaKey: string().optional(),
67407
- /** Design B: MediaStore key of the track's native-resolution key frame (the
67408
- * best-detection full frame). Resolve via the event-media data-plane
67409
- * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
67410
- * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
67411
- * sources — consumers fall back to `mediaKey` (the tight crop). */
67412
- keyFrameMediaKey: string().optional(),
67413
- /** Populated by B5 (recording playback URL for this event). */
67414
- mediaUrl: string().optional(),
67415
- /** The parent track's key-event importance [0,1], propagated to every object
67416
- * event of the track (so an event row can be sorted by importance without a
67417
- * track join). Absent on legacy rows / before the track was scored. */
67418
- importance: number().optional()
67419
- });
67420
- var AudioEventSchema = object({
67421
- ...BaseEventFields,
67422
- kind: literal("audio"),
67423
- rms: number(),
67424
- dbfs: number(),
67425
- classification: object({
67426
- className: string(),
67427
- originalClass: string().optional(),
67428
- score: number()
67429
- }).optional(),
67430
- /** Populated by B5 (recording playback URL for this event). */
67431
- mediaUrl: string().optional()
67432
- });
67433
- var MediaFileKindEnum = _enum([
67434
- "crop",
67435
- "thumbnail",
67436
- "snapshot",
67437
- "firstFrame",
67438
- "lastFrame",
67439
- "fullFrame",
67440
- "fullFrameBoxed",
67441
- "faceCrop",
67442
- "plateCrop",
67443
- "keyFrame",
67444
- "keyFrameSmall",
67445
- "thumbnailSmall"
67446
- ]);
67447
- var MediaFileSchema = object({
67448
- key: string(),
67449
- kind: MediaFileKindEnum,
67450
- base64: string(),
67451
- sizeBytes: number(),
67452
- timestamp: number()
67386
+ overlapThreshold: number().min(0).max(1).optional(),
67387
+ /**
67388
+ * Operator-friendly version of `overlapThreshold` — the percentage
67389
+ * of the detection's bbox that must lie inside the zone for the
67390
+ * rule to match. Documented default is 85%; the engine substitutes
67391
+ * that when the field is omitted (kept optional so existing rules
67392
+ * stored without it stay valid).
67393
+ *
67394
+ * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
67395
+ * rule, the engine prefers `bboxInclusionPct` because it's the
67396
+ * field exposed in the UI. Internally both feed the same gate.
67397
+ */
67398
+ bboxInclusionPct: number().min(0).max(100).optional(),
67399
+ /**
67400
+ * When `true` and a detection has a segmentation mask, use the
67401
+ * mask for overlap instead of the bbox. Detection-stage only;
67402
+ * motion rules ignore this field.
67403
+ */
67404
+ preferMask: boolean().optional(),
67405
+ /**
67406
+ * Soft-toggle: `false` disables the rule without deleting it.
67407
+ * Defaults to `true` so operators creating a rule via the UI
67408
+ * see it active immediately.
67409
+ */
67410
+ enabled: boolean().default(true)
67453
67411
  });
67412
+ array(ZoneRuleSchema).readonly();
67454
67413
  /**
67455
- * One media row WITHOUT its bytes.
67414
+ * Zone — pure geometry + identity. NO filtering behaviour.
67456
67415
  *
67457
- * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
67458
- * 140 s track), and a client that renders tiles from the media data plane needs
67459
- * to know only WHAT EXISTS — the bytes then arrive per tile, lazily, over HTTP
67460
- * with an immutable cache, instead of all at once inside a tRPC response that
67461
- * blocks the whole view.
67416
+ * Zones describe **where** in the frame the operator wants to flag
67417
+ * something; consumer-owned {@link ZoneRule} arrays describe **how**
67418
+ * each pipeline stage uses them. Splitting the two means a single
67419
+ * polygon "Driveway" can simultaneously back a motion-exclude rule,
67420
+ * a detection-include rule on `['car']`, and an occupancy aggregate
67421
+ * — without three duplicated polygons.
67462
67422
  *
67463
- * `sizeBytes` is carried because it is what lets a client decide between the
67464
- * stored blob and a `?variant=thumb` rendering without fetching either.
67465
- */
67466
- var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
67467
- /**
67468
- * The MACRO tier of an annotation — a CLOSED set.
67423
+ * Owned by the orchestrator addon (provider) and mirrored into the
67424
+ * `zones` device-state slice on every mutation. Consumers
67425
+ * (motion-wasm, pipeline-executor, analytics, admin UI) read either
67426
+ * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
67427
+ * mirror with `onChanged`).
67469
67428
  *
67470
- * This is what the exported detector predicts, so a typo here is a new class
67471
- * with one example in it. `label` and `subLabel` are open strings by contrast:
67472
- * the whole point of the page is teaching the model things it does not know
67473
- * yet, and constraining that vocabulary would make it useless.
67429
+ * Coordinates are normalised fractions of the frame (0–1) so zones
67430
+ * survive resolution changes and stream profile switches.
67474
67431
  *
67475
- * A macro class is NEVER a label. The provider refuses a write whose `label` or
67476
- * `subLabel` is one of these values, in any casing, because once `person`
67477
- * exists in both tiers "every person box" stops being answerable without
67478
- * knowing every string anyone ever typed — and the damage is retroactive.
67432
+ * `kind` discriminates between full polygons (closed regions used
67433
+ * for intrusion / occupancy filters) and tripwires (open 2-point
67434
+ * line segments used for cross events). Onboard / firmware-reported
67435
+ * zones (Reolink, ONVIF) are out of scope for now — see the deferred
67436
+ * task list.
67479
67437
  */
67480
- var RetrainMacroClassSchema = _enum([
67481
- "person",
67482
- "vehicle",
67483
- "animal",
67484
- "package",
67485
- "face",
67486
- "plate"
67487
- ]);
67488
- /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
67489
- var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
67490
- /** Did a human draw this box, or did the assist propose it? */
67491
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
67492
- /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
67493
- var RetrainBboxSchema = object({
67438
+ var ZoneKindEnum = _enum(["polygon", "tripwire"]);
67439
+ /** Polygon vertex in fraction-of-frame coordinates (0–1). */
67440
+ var PolygonPointSchema = object({
67494
67441
  x: number(),
67495
- y: number(),
67496
- w: number(),
67497
- h: number()
67442
+ y: number()
67443
+ });
67444
+ /** A camera detection zone — pure geometry/identity. */
67445
+ var ZoneSchema = object({
67446
+ id: string(),
67447
+ name: string(),
67448
+ kind: ZoneKindEnum.default("polygon"),
67449
+ /** Polygon vertices, fraction of frame (0–1). */
67450
+ polygon: array(PolygonPointSchema).readonly(),
67451
+ /** Visual color for UI rendering. */
67452
+ color: string().default("#3b82f6")
67498
67453
  });
67499
67454
  /**
67500
- * One annotated subject.
67455
+ * Zones capability — per-camera CRUD over polygon detection zones.
67501
67456
  *
67502
- * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
67503
- * (letterboxed root / zone-cropped package / subject-cropped classifier) are
67504
- * derived from it at export and never stored — storing them is how one feature
67505
- * space ends up holding two crops of the same subject (D52).
67457
+ * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
67458
+ * to per-device settings and mirrors into the `zones` device-state
67459
+ * slice on every mutation, so downstream consumers can subscribe via
67460
+ * `dev.state.zones.onChanged`.
67461
+ *
67462
+ * The cap surface only handles geometry + identity; filtering
67463
+ * behaviour (per-class, include/exclude, threshold) lives in the
67464
+ * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
67465
+ * `capabilities/schemas/zone-rule.js`.
67506
67466
  */
67507
- var RetrainAnnotationSchema = object({
67508
- id: string(),
67509
- trackId: string(),
67510
- deviceId: number(),
67511
- /** The COPY in retrain storage — never the source track's media key. */
67512
- mediaKey: string(),
67513
- bbox: RetrainBboxSchema,
67514
- macroClass: RetrainMacroClassSchema,
67515
- label: string().optional(),
67516
- subLabel: string().optional(),
67517
- kind: RetrainAnnotationKindSchema,
67518
- source: RetrainAnnotationSourceSchema,
67519
- /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
67520
- assistModelId: string().optional(),
67521
- assistScore: number().optional(),
67522
- exportedInBatch: string().optional(),
67523
- createdAt: number()
67524
- });
67525
- /** The write form — the server owns `id`, `createdAt` and the frame binding. */
67526
- var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
67527
- id: true,
67528
- trackId: true,
67529
- deviceId: true,
67530
- mediaKey: true,
67531
- createdAt: true,
67532
- exportedInBatch: true
67533
- });
67534
- /** A track sitting in `staging`, with everything the worklist needs to rank it. */
67535
- var RetrainTrackSchema = object({
67536
- trackId: string(),
67537
- deviceId: number(),
67538
- className: string(),
67539
- label: string().optional(),
67540
- firstSeen: number(),
67541
- lastSeen: number(),
67542
- /** How many frames the dataset already holds from this track. */
67543
- frameCount: number().int(),
67544
- /** How many subjects have been annotated on those frames. `0` with
67545
- * `frameCount: 0` is exactly "staging, still to work". */
67546
- annotationCount: number().int()
67547
- });
67548
- /** A frame the picker may offer — an index row, no blob was read to produce it. */
67549
- var RetrainFrameCandidateSchema = object({
67550
- mediaKey: string(),
67551
- kind: MediaFileKindEnum,
67552
- timestamp: number(),
67553
- sizeBytes: number().int(),
67554
- /** A copy of this original already exists — selecting it is free and cannot
67555
- * fail, whatever became of the original. */
67556
- copied: boolean()
67557
- });
67558
- /** A frame the dataset OWNS: bytes copied at selection time. */
67559
- var RetrainFrameSchema = object({
67560
- frameId: string(),
67561
- deviceId: number(),
67562
- trackId: string(),
67563
- /** Provenance only. It may already point at nothing — that is expected. */
67564
- sourceMediaKey: string(),
67565
- sourceKind: MediaFileKindEnum,
67566
- sizeBytes: number().int(),
67567
- width: number().int(),
67568
- height: number().int(),
67569
- copiedAt: number()
67570
- });
67571
- /** Why a copy-on-select could not be honoured — named, never a silent skip. */
67572
- var RetrainCopyRefusalSchema = _enum([
67573
- "source-missing",
67574
- "unreadable-image",
67575
- "write-failed"
67467
+ var zonesCapability = {
67468
+ name: "zones",
67469
+ scope: "device",
67470
+ mode: "singleton",
67471
+ deviceTypes: [DeviceType.Camera],
67472
+ methods: {
67473
+ listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
67474
+ addZone: method(object({
67475
+ deviceId: number(),
67476
+ zone: ZoneSchema
67477
+ }), _void(), {
67478
+ kind: "mutation",
67479
+ auth: "admin"
67480
+ }),
67481
+ removeZone: method(object({
67482
+ deviceId: number(),
67483
+ zoneId: string()
67484
+ }), _void(), {
67485
+ kind: "mutation",
67486
+ auth: "admin"
67487
+ }),
67488
+ updateZone: method(object({
67489
+ deviceId: number(),
67490
+ zone: ZoneSchema
67491
+ }), _void(), {
67492
+ kind: "mutation",
67493
+ auth: "admin"
67494
+ })
67495
+ },
67496
+ /**
67497
+ * Runtime-state slice — the live zone catalogue mirrored by the
67498
+ * orchestrator on every CRUD mutation. Consumers read via
67499
+ * `device.state.zones.value` / `.watch(...)` without round-tripping
67500
+ * the cap, and the codegen DeviceProxy auto-wires the reactive
67501
+ * handle. Slice shape is `{ zones: Zone[] }` so future extensions
67502
+ * (e.g. zone groupings) can sit alongside the polygon list.
67503
+ */
67504
+ runtimeState: object({ zones: array(ZoneSchema).readonly() }),
67505
+ /**
67506
+ * Runtime-state durability: **restored** — written only on operator mutation, so a camera that never had one has nothing to re-derive from. This is the slice `zone-mirror-hydration.ts` exists to paper over.
67507
+ *
67508
+ * See `RuntimeStateDurability`. Enforced by
67509
+ * `scripts/check-runtime-state-durability.ts`.
67510
+ */
67511
+ durability: "restored"
67512
+ };
67513
+ /**
67514
+ * pipeline-analytics — device-scoped wrapper cap. Refines raw
67515
+ * per-frame detections emitted by the pipeline runner into tracked
67516
+ * objects, per-kind event collections (motion / object / audio), and
67517
+ * persisted media. Owns the post-detection domain end-to-end:
67518
+ *
67519
+ * runner emits PipelineInferenceResult
67520
+ * ↓ (event bus)
67521
+ * pipeline-analytics subscriber
67522
+ * ↓ SORT tracker + zone engine + state analyzer + event emitter
67523
+ * → three DB collections (one per kind), one FS media tree, one
67524
+ * unified event emitter (FrameTracked + TrackStarted/Ended +
67525
+ * DetectionEvent on bus)
67526
+ *
67527
+ * Pure subscriber model. No `processFrame` cap method — the runner
67528
+ * already publishes the raw frame on the bus. The cap surface is
67529
+ * only QUERIES + per-device settings, bound on/off via
67530
+ * `device-manager.setWrapperActive`. `defaultActive: true` because
67531
+ * every camera with a detection pipeline wants its raw detections
67532
+ * refined; operators opt out per-device via BindingsTab when needed.
67533
+ *
67534
+ * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
67535
+ * (per-device surface) and `track-trail` caps — see P11 cleanup.
67536
+ */
67537
+ var TrackStateSchema = _enum([
67538
+ "new",
67539
+ "entered",
67540
+ "left",
67541
+ "moving",
67542
+ "idle"
67543
+ ]);
67544
+ var EventKindSchema = _enum([
67545
+ "motion",
67546
+ "object",
67547
+ "audio"
67576
67548
  ]);
67577
- var RetrainFrameSelectionSchema = object({
67578
- copied: array(RetrainFrameSchema).readonly(),
67579
- refused: array(object({
67580
- sourceMediaKey: string(),
67581
- reason: RetrainCopyRefusalSchema
67582
- })).readonly()
67583
- });
67584
- var RetrainFrameListSchema = object({
67585
- candidates: array(RetrainFrameCandidateSchema).readonly(),
67586
- copies: array(RetrainFrameSchema).readonly(),
67587
- /** What the page pre-selects — the native key frame when one survives. */
67588
- autoPickMediaKey: string().optional()
67589
- });
67590
- /** What the operator asked the assist to look for. */
67591
- var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
67592
- kind: literal("package"),
67593
- zone: RetrainBboxSchema.optional()
67594
- }), object({
67595
- kind: literal("objects"),
67596
- modelId: string(),
67597
- minScore: number().optional()
67598
- })]);
67599
67549
  /**
67600
- * The assist's answer — a discriminated union, because "the model saw nothing"
67601
- * and "this node cannot run that model" lead to different next moves and a
67602
- * nullable result cannot tell them apart.
67550
+ * Spatial filter for `listTracks` — the rect + polygon variants of the shared
67551
+ * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
67552
+ * of the camera frame (top-left origin), matching the drawing-plane editor.
67603
67553
  */
67604
- var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
67605
- kind: literal("proposed"),
67606
- modelId: string(),
67607
- stepId: string(),
67608
- minScore: number(),
67609
- /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
67610
- proposals: array(RetrainAnnotationDraftSchema).readonly(),
67611
- /** Returned by the runner but removed by the threshold. */
67612
- belowThreshold: number().int()
67613
- }), object({
67614
- kind: literal("refused"),
67615
- /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
67616
- reason: string(),
67617
- detail: string().optional()
67618
- })]);
67619
- /** The outcome of a lifecycle move owned by the retrain page. */
67620
- var RetrainTransitionResultSchema = object({
67621
- trackId: string(),
67622
- /** Where the track ended up, whatever happened. */
67623
- retrainStatus: RetrainStatusSchema,
67624
- /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
67625
- changed: boolean(),
67626
- reason: _enum([
67627
- "unknown-track",
67628
- "no-frames-copied",
67629
- "not-staging",
67630
- "not-trained",
67631
- "unchanged"
67632
- ]).optional()
67554
+ var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
67555
+ /** Closed icon vocabulary so clients render a known glyph per kind. */
67556
+ var EventKindIconSchema = _enum([
67557
+ "motion",
67558
+ "audio",
67559
+ "person",
67560
+ "vehicle",
67561
+ "animal",
67562
+ "door",
67563
+ "pir",
67564
+ "smoke",
67565
+ "water",
67566
+ "button",
67567
+ "package",
67568
+ "generic"
67569
+ ]);
67570
+ var EventKindCategorySchema = _enum([
67571
+ "motion",
67572
+ "audio",
67573
+ "detection",
67574
+ "sensor",
67575
+ "control",
67576
+ "custom",
67577
+ "package"
67578
+ ]);
67579
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
67580
+ var EventKindLevelSchema = _enum(["macro", "sub"]);
67581
+ var EventKindDescriptorSchema = object({
67582
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
67583
+ kind: string(),
67584
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
67585
+ labelKey: string(),
67586
+ /** English fallback label (kept for clients that don't translate). */
67587
+ label: string(),
67588
+ /** Hex color for timeline/legend rendering. */
67589
+ color: string(),
67590
+ /** Dictionary id → lucide component on the UI side. */
67591
+ iconId: string(),
67592
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
67593
+ icon: EventKindIconSchema,
67594
+ category: EventKindCategorySchema,
67595
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
67596
+ parentKind: string().nullable(),
67597
+ /** Derived from `parentKind`, explicit for the client tree. */
67598
+ level: EventKindLevelSchema,
67599
+ /** Which cap + device contributes this kind. For built-ins the camera
67600
+ * itself; for sensor kinds the LINKED source device. */
67601
+ source: object({
67602
+ capName: string(),
67603
+ deviceId: number()
67604
+ })
67633
67605
  });
67634
- var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
67635
- var MAX_EVENT_QUERY_LIMIT = 5e3;
67636
- var DeviceEventQueryInput = object({
67606
+ /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
67607
+ var EventKindsForDeviceSchema = object({
67637
67608
  deviceId: number(),
67638
- since: number().optional(),
67639
- until: number().optional(),
67640
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
67641
- /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
67642
- * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
67643
- * exact behaviour. Callers may omit this field — the store defaults to
67644
- * `full` when not provided. */
67645
- projection: _enum(["full", "slim"]).optional()
67609
+ kinds: array(EventKindDescriptorSchema).readonly()
67646
67610
  });
67647
- var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
67648
- var RecentTracksQueryInput = object({
67649
- /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
67650
- deviceIds: array(number()),
67651
- /** Window lower bound on `lastSeen` (inclusive). */
67652
- since: number().optional(),
67653
- /** Window upper bound on `lastSeen` (inclusive). */
67654
- until: number().optional(),
67655
- /** Page size. Default 200, max 1000. */
67656
- limit: number().int().min(1).max(1e3).default(200),
67657
- /** Opaque continuation cursor from a previous page's `nextCursor`.
67658
- * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
67659
- cursor: string().optional(),
67660
- /** See {@link TrackProjectionSchema}. Default `full`. */
67661
- projection: TrackProjectionSchema.optional(),
67662
- /** Include stationary-promoted rows (parked objects). Default false: the
67663
- * feed lists passages; parking records live on the stationary registry. */
67664
- includeStationary: boolean().optional()
67611
+ var SensorEventSchema = object({
67612
+ id: string(),
67613
+ /** The CAMERA the event is attributed to (a sensor linked to N cameras
67614
+ * yields N rows, one per camera). */
67615
+ deviceId: number(),
67616
+ /** The linked sensor device whose state changed. */
67617
+ sourceDeviceId: number(),
67618
+ /** Event kind id — matches an `EventKindDescriptor.kind`. */
67619
+ kind: string(),
67620
+ /** Snapshot of the sensor cap's runtime-state slice at the change. */
67621
+ value: record(string(), unknown()).nullable(),
67622
+ timestamp: number()
67665
67623
  });
67666
- var RecentTracksPageSchema = object({
67667
- /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
67668
- tracks: array(TrackSchema).readonly(),
67669
- /** Cursor for the next page, or null when this page is the last. */
67670
- nextCursor: string().nullable()
67624
+ var TrackPositionSchema = object({
67625
+ x: number(),
67626
+ y: number(),
67627
+ timestamp: number(),
67628
+ bbox: BoundingBoxSchema
67671
67629
  });
67672
- var LIST_GROUPS_DEFAULT_LIMIT = 40;
67673
- var LIST_GROUPS_MAX_LIMIT = 100;
67674
- var AnalyticsGroupRecordSchema = object({
67675
- id: string(),
67676
- deviceId: number().int(),
67677
- openedAt: number().int(),
67678
- closedAt: number().int(),
67679
- timestamp: number().int(),
67680
- memberCount: number().int(),
67681
- memberTrackIds: array(string()).readonly(),
67682
- className: string(),
67683
- classes: array(string()).readonly(),
67684
- /** Relative event-media path, or null when the group has no picture yet. */
67685
- mediaUrl: string().nullable(),
67686
- singleton: boolean()
67687
- });
67688
- var AnalyticsGroupMemberSchema = object({
67689
- trackId: string(),
67690
- deviceId: number().int(),
67691
- className: string(),
67692
- firstSeen: number().int(),
67693
- lastSeen: number().int(),
67694
- mediaUrl: string().nullable()
67695
- });
67696
- var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
67697
- var ListGroupsQueryInput = object({
67698
- /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
67699
- deviceIds: array(number()),
67700
- /** Window lower bound on `closedAt` (inclusive). */
67701
- since: number().optional(),
67702
- /** Window upper bound on `openedAt` (inclusive). */
67703
- until: number().optional(),
67704
- limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
67705
- /** Opaque continuation cursor from a previous page's `nextCursor`. */
67706
- cursor: string().optional()
67707
- });
67708
- var ListGroupsPageSchema = object({
67709
- groups: array(AnalyticsGroupRecordSchema).readonly(),
67710
- nextCursor: string().nullable()
67711
- });
67712
- var KeyEventQueryInput = object({
67713
- deviceId: number(),
67714
- /** Window lower bound (track firstSeen ≥ since). */
67715
- since: number(),
67716
- /** Window upper bound (track firstSeen ≤ until). */
67717
- until: number(),
67718
- limit: number().int().min(1).max(200).default(50),
67719
- /** Drop tracks scoring below this importance. */
67720
- minImportance: number().min(0).max(1).optional(),
67721
- /** Restrict to a single class (e.g. 'person'). */
67722
- classFilter: string().optional()
67723
- });
67724
- var KeyEventSchema = object({
67725
- /** The representative event id (the track's best ObjectEvent, else its trackId). */
67726
- id: string(),
67727
- trackId: string(),
67728
- /** Track start time (firstSeen). */
67630
+ var TrackSnapshotSchema = object({
67729
67631
  timestamp: number(),
67730
- className: string(),
67731
- ...TieredLabelFields,
67732
- importance: number(),
67733
- /** Highest-confidence ObjectEvent id for the track (empty when none). */
67734
- bestEventId: string(),
67735
- /** Track lifetime in ms (lastSeen - firstSeen). */
67736
- windowMs: number().optional(),
67737
- ...TrackFlagFields,
67738
- ...TrackRetrainFields
67739
- });
67740
- object({
67741
- trackId: string(),
67742
- className: string(),
67743
- confidence: number(),
67744
- bbox: BoundingBoxSchema,
67745
- zones: array(string()).readonly(),
67746
- state: TrackStateSchema
67747
- });
67748
- var OverlayDetectionSchema = looseObject({
67749
- id: string(),
67750
- kind: _enum(["first-level", "detail"]),
67751
- macroClass: string(),
67752
- score: number(),
67753
- bbox: object({
67754
- x: number(),
67755
- y: number(),
67756
- width: number(),
67757
- height: number()
67758
- }),
67759
- labels: array(looseObject({
67760
- label: string(),
67761
- score: number()
67762
- })).readonly(),
67763
- parentId: string().optional()
67764
- });
67765
- var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
67766
- var SearchObjectEventsInput = object({
67767
- text: string(),
67768
- deviceId: number().optional(),
67769
- since: number().optional(),
67770
- until: number().optional(),
67771
- classFilter: string().optional(),
67772
- limit: number().default(50),
67773
- minScore: number().min(0).max(1).default(.2)
67774
- });
67775
- var TrackCascadeCountsSchema = object({
67776
- /** Persisted track roots deleted (authoritative). */
67777
- tracks: number().int(),
67778
- /** Object events removed with their tracks (best-effort; see note above). */
67779
- events: number().int(),
67780
- /** Track/face/plate-owned media removed (best-effort). Never identity media. */
67781
- media: number().int(),
67782
- /** Unassigned (non-enrolled) face reads removed (best-effort). */
67783
- faces: number().int(),
67784
- /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
67785
- plates: number().int(),
67786
- /** Per-track CLIP search vectors removed (best-effort). */
67787
- embeddings: number().int(),
67788
- /** Group membership + group rows removed with their last member (best-effort). */
67789
- groups: number().int()
67790
- });
67791
- /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
67792
- var DiskReconcileCountsSchema = object({
67793
- mediaDropped: number().int(),
67794
- tracks: number().int(),
67795
- events: number().int()
67796
- });
67797
- /** Event-store footprint for one camera. */
67798
- var EventStoreDeviceFootprintSchema = object({
67799
- deviceId: number(),
67800
- /** Persisted event rows (motion + object + audio) for the camera. */
67801
- rows: number().int(),
67802
- /** Event-owned media bytes on disk for the camera. */
67803
- bytes: number().int()
67804
- });
67805
- /** Aggregate event-store footprint: global totals + per-camera breakdown. */
67806
- var EventStoreFootprintSchema = object({
67807
- totalRows: number().int(),
67808
- totalBytes: number().int(),
67809
- devices: array(EventStoreDeviceFootprintSchema).readonly()
67632
+ position: TrackPositionSchema,
67633
+ /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
67634
+ mediaKey: string()
67810
67635
  });
67811
- /** Per-kind counts returned by the event-prune / device-delete mutations. */
67812
- var EventPruneCountsSchema = object({
67813
- motion: number().int(),
67814
- object: number().int(),
67815
- audio: number().int()
67636
+ /**
67637
+ * Normalized 0..1 trajectory envelope (min/max over every position bbox,
67638
+ * divided by the track's detection-frame dims), computed at persist time.
67639
+ * Absent when the frame dims were unknown when the track was persisted
67640
+ * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
67641
+ */
67642
+ var TrackEnvelopeSchema = object({
67643
+ minX: number(),
67644
+ minY: number(),
67645
+ maxX: number(),
67646
+ maxY: number()
67816
67647
  });
67817
67648
  /**
67818
- * Re-embed stored tracks from their key frames.
67819
- *
67820
- * The reason this is an operator-callable method and not a migration script:
67821
- * every knob that decides what a vector MEANS — encoder model, crop margin,
67822
- * squaring — is only changeable if the existing vectors can be regenerated.
67823
- * Mixing feature spaces in one index makes cosine scores incomparable, and the
67824
- * symptom is a quality regression with no visible cause.
67649
+ * Row projection for track list queries. `full` (default) returns the
67650
+ * complete Track including the frame-rate `positions[]` history and the
67651
+ * `snapshots[]` references — megabytes across a page of tracks. `slim`
67652
+ * keeps every scalar the list surfaces actually render (ids, class(es),
67653
+ * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
67654
+ * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
67655
+ * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
67656
+ * `getTrack`. Mirrors the event-store `projection` convention
67657
+ * (`getObjectEvents` et al.).
67825
67658
  */
67826
- var RebuildObjectEmbeddingsInput = object({
67827
- /** Restrict to one camera. Omit for the whole fleet. */
67828
- deviceId: number().optional(),
67829
- since: number().optional(),
67830
- until: number().optional(),
67831
- /** Stop after this many tracks; the result reports whether more remain. */
67832
- maxTracks: number().int().positive().optional(),
67833
- /**
67834
- * Run every embedding on THIS node instead of round-robining the fleet.
67835
- *
67836
- * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
67837
- * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
67838
- * calling it that would pin the rebuild REQUEST itself to that node — the
67839
- * rebuild orchestration lives on the hub, and only the per-track step runs
67840
- * remotely. This field is data; the per-track pin is applied inside.
67841
- *
67842
- * Absent ⇒ round-robin over every online node whose runner can serve the
67843
- * pinned model.
67844
- */
67845
- executeOnNodeId: string().optional(),
67846
- /**
67847
- * Milliseconds to wait between tracks; omit for the built-in default, `0` to
67848
- * run flat out.
67849
- *
67850
- * A rebuild is bulk maintenance on hub-main's single thread. Measured
67851
- * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
67852
- * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
67853
- * force is logged at start and finish so a deliberately slow pass reads
67854
- * differently from a stalled one.
67855
- */
67856
- pacingMs: number().int().nonnegative().optional()
67659
+ var TrackProjectionSchema = _enum(["full", "slim"]);
67660
+ /**
67661
+ * One audio-classification label heard on the track's camera while the
67662
+ * track was alive, aggregated per label. An "episode" is one persisted
67663
+ * audio event (the confident-classification path: score ≥ the device's
67664
+ * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
67665
+ * one 32 ms inference chunk, so counts stay human-scaled.
67666
+ */
67667
+ var TrackAudioLabelSchema = object({
67668
+ label: string(),
67669
+ /** Highest classification score observed across the label's episodes. */
67670
+ peakScore: number(),
67671
+ /** Number of coalesced audio-event episodes carrying this label. */
67672
+ count: number(),
67673
+ firstAt: number(),
67674
+ lastAt: number()
67857
67675
  });
67858
67676
  /**
67859
- * Result of emptying the CLIP index.
67677
+ * How a track was produced. `pipeline` (default / absent) = the spatial
67678
+ * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
67679
+ * no positions, a single snapshot, and no bbox trajectory at all:
67860
67680
  *
67861
- * The clean slate before a policy change: a new crop margin or encoder model
67862
- * leaves two feature spaces in one index whose cosine scores are not
67863
- * comparable, so wiping and rebuilding is the only way to be sure every vector
67864
- * means the same thing.
67681
+ * - `sensor` — a linked sensor/control device state change.
67682
+ * - `audio` — an audio event on the camera itself that was anomalous for
67683
+ * THAT camera, loud, and heard while nothing visual was happening (D62).
67684
+ *
67685
+ * The spatial subsystems (tracker association, occupancy count, re-id /
67686
+ * embedding, resurrection) MUST skip every synthetic source. Test for that
67687
+ * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
67688
+ * check silently readmits every source added after it was written.
67865
67689
  */
67866
- var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
67690
+ var TrackSourceSchema = _enum([
67691
+ "pipeline",
67692
+ "sensor",
67693
+ "audio"
67694
+ ]);
67867
67695
  /**
67868
- * Acknowledgement that a rebuild STARTED.
67696
+ * Where a track sits in the RETRAIN lifecycle (D81).
67869
67697
  *
67870
- * The pass costs ~1s per track — 45 minutes for a 2,600-track fleet — so it
67871
- * runs detached and this returns immediately. Waiting for it made the client
67872
- * time out while the work carried on server-side, which is the worst of both:
67873
- * no result and no way to know it was still going. Poll
67874
- * `getObjectEmbeddingRebuildStatus` for progress.
67698
+ * - `none` — never marked, or un-marked. Evictable.
67699
+ * - `staging` — the operator wants this track as training material and has not
67700
+ * finished with it. **This is the only state retention holds**: the track and
67701
+ * everything it owns (object events, crops, keyframes, CLIP vector) survive
67702
+ * the device's age window.
67703
+ * - `trained` — the retrain page has taken what it needed. The frames it chose
67704
+ * were COPIED into the retrain dataset at selection time, so the dataset no
67705
+ * longer depends on the track's media and the track becomes EVICTABLE again.
67706
+ * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
67707
+ * a deliberate action of the retrain page, not a side effect of a checkbox.
67708
+ *
67709
+ * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
67710
+ * the store's filter language has only positive equality and `whereIn` — no
67711
+ * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
67712
+ * would make the entire pre-column history immortal in one deploy.
67875
67713
  */
67876
- var RebuildObjectEmbeddingsResultSchema = object({
67877
- started: boolean(),
67878
- /** True when a pass was already running; the new request is ignored. */
67879
- alreadyRunning: boolean()
67714
+ var RetrainStatusSchema = _enum([
67715
+ "none",
67716
+ "staging",
67717
+ "trained"
67718
+ ]);
67719
+ /**
67720
+ * Per-track OPERATOR flags — set by hand from the admin UI or the viewer, never
67721
+ * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
67722
+ * so the two surfaces cannot drift.
67723
+ *
67724
+ * **Absent ≠ false.** A track that has never been touched omits the field; an
67725
+ * explicitly un-flagged track carries `false`. Legacy rows written before the
67726
+ * columns existed read as absent, and a consumer that needs a boolean should say
67727
+ * `flag === true`, not `flag !== false`.
67728
+ *
67729
+ * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
67730
+ * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
67731
+ * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
67732
+ * `trained` track reports `false` while refusing both writes. The boolean is
67733
+ * kept because three surfaces drive a toggle off it; anything that needs to tell
67734
+ * "never marked" from "already trained" must read `retrainStatus`.
67735
+ *
67736
+ * `debug` does NOT pin; it is attention, not durability.
67737
+ *
67738
+ * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
67739
+ * A favourited track is skipped by retention the same way `staging` is, but
67740
+ * it does not enter `none|staging|trained` and has no staging budget.
67741
+ */
67742
+ var TrackFlagFields = {
67743
+ /** Operator marked this track as training material — i.e. `retrainStatus` is
67744
+ * `'staging'`. */
67745
+ markForTrain: boolean().optional(),
67746
+ /** Operator marked this track for diagnostic attention. */
67747
+ debug: boolean().optional(),
67748
+ /** Operator favourited this track. Pins it against pruning. */
67749
+ favourited: boolean().optional()
67750
+ };
67751
+ /**
67752
+ * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
67753
+ * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
67754
+ * write patch, and the status is not something the toggle sets — it is what the
67755
+ * toggle's boolean is derived from. Absent on an in-RAM track never touched;
67756
+ * always present on a persisted row (the column default materialises `'none'`).
67757
+ */
67758
+ var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
67759
+ /**
67760
+ * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
67761
+ * one flag can never clear the other — the toggles are independent and are
67762
+ * driven from three surfaces that do not know about each other.
67763
+ */
67764
+ var TrackFlagsPatchSchema = object(TrackFlagFields);
67765
+ /**
67766
+ * The resolved flag state after a write. Both fields are REQUIRED here (absent
67767
+ * collapses to `false`) so a caller can drive a toggle's checked state off the
67768
+ * mutation result without a re-fetch.
67769
+ */
67770
+ var TrackFlagsSchema = object({
67771
+ trackId: string(),
67772
+ markForTrain: boolean(),
67773
+ debug: boolean(),
67774
+ favourited: boolean(),
67775
+ /** The lifecycle state the boolean was derived from. Required here (unlike on
67776
+ * a track row) because this shape is only ever produced by the write body,
67777
+ * which always knows it — and a surface that has just written needs to render
67778
+ * `trained` without a re-fetch. */
67779
+ retrainStatus: RetrainStatusSchema
67880
67780
  });
67881
- var RebuildStatusSchema = object({
67882
- running: boolean(),
67883
- scanned: number(),
67884
- rebuilt: number(),
67885
- /** Tracks whose key frame is gone — nothing to re-embed from. */
67886
- missingKeyFrame: number(),
67887
- /** Tracks with no usable detection box. */
67888
- missingBbox: number(),
67889
- /**
67890
- * Tracks an executing node REFUSED rather than broke on — an unreadable key
67891
- * frame, a step that threw. Separate from `failed` because the remedy is
67892
- * different, and because a whole camera silently contributing zero vectors
67893
- * is the shape of failure a rebuild must never hide.
67894
- */
67895
- notRunnable: number(),
67781
+ union([literal(1), literal(2)]);
67782
+ /**
67783
+ * WHO decided a label, and when. Carried per tier so a value can be traced to
67784
+ * the step and model that produced it — which is what makes the write rule
67785
+ * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
67786
+ * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
67787
+ *
67788
+ * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
67789
+ * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
67790
+ * `migration:4g` for a value the 4g migration moved from the single-slot era —
67791
+ * that value has no provenance, and the write rule lets ANY properly-attributed
67792
+ * write of the same tier replace it regardless of score.
67793
+ */
67794
+ var LabelAttributionSchema = object({
67795
+ stepId: string(),
67796
+ modelId: string().optional(),
67797
+ decidedAt: number(),
67896
67798
  /**
67897
- * The pass stopped because NO node could serve the pinned model.
67799
+ * The GALLERY id behind a recognised tier-2 label — a face-gallery
67800
+ * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
67898
67801
  *
67899
- * Distinct from `notRunnable` on purpose: that one says "this track was
67900
- * refused", this one says "the cluster cannot do this work at all" — every
67901
- * candidate node either lacks the `clip-embedding` step, lacks a build of the
67902
- * pinned model for its engine format, or dropped out. The remedy is a model /
67903
- * engine change, not a per-camera one. Non-zero here always comes with
67904
- * `complete: false`.
67802
+ * The text alone is a DISPLAY NAME, and a display name is renameable: a
67803
+ * notification rule authored on "Gianluca" stopped matching the moment the
67804
+ * operator fixed the spelling in the gallery, and nothing said so. The id is
67805
+ * the thing that does not move, so it is what a rule matches on
67806
+ * (`NcConditions.identities`) and the text is what a human is shown.
67807
+ *
67808
+ * Absent when the label names no gallery row — a plate the OCR read but no
67809
+ * vehicle claims, a sub-class, a species, any tier-1 value.
67905
67810
  */
67906
- noCapableNode: number(),
67907
- failed: number(),
67908
- /** Set once a pass ends: true only when EVERYTHING was covered. */
67909
- complete: boolean().nullable(),
67910
- startedAtMs: number().nullable(),
67911
- finishedAtMs: number().nullable(),
67912
- /** Present when the pass ended by throwing. */
67913
- error: string().nullable()
67811
+ identityId: string().optional()
67914
67812
  });
67915
- DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
67916
- deviceId: number(),
67917
- trackId: string()
67918
- }), TrackSchema.nullable()), method(object({
67919
- deviceId: number(),
67920
- since: number().optional(),
67921
- until: number().optional(),
67922
- limit: number().optional(),
67923
- /** Spatial filter — only tracks whose trajectory intersects the zone
67924
- * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
67925
- * envelope columns, then precisely tested per position. Tracks with
67926
- * an unknown envelope (no frame dims at persist time) always match. */
67927
- zone: TrackZoneFilterSchema.optional(),
67928
- /** See {@link TrackProjectionSchema}. Default `full` (backward
67929
- * compatible — omitting the field keeps today's exact behaviour). */
67930
- projection: TrackProjectionSchema.optional(),
67931
- /** Include stationary-promoted rows (parked objects handed to the
67932
- * stationary registry). Default false: the timeline lists passages,
67933
- * not parking records (operator decision, 2026-08-15). */
67934
- includeStationary: boolean().optional()
67935
- }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
67936
- deviceId: number(),
67937
- groupId: string().min(1)
67938
- }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
67939
- kind: "mutation",
67940
- auth: "admin"
67941
- }), 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({
67942
- deviceId: number(),
67943
- since: number().optional(),
67944
- until: number().optional(),
67945
- kinds: array(string()).optional(),
67946
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
67947
- }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
67948
- deviceId: number(),
67949
- since: number(),
67950
- until: number(),
67951
- bucketMs: number().int().positive()
67952
- }), array(object({
67953
- bucketStart: number(),
67954
- motion: number().int(),
67955
- object: number().int(),
67956
- audio: number().int()
67957
- })).readonly()), method(object({
67958
- deviceId: number(),
67959
- cutoffMs: number()
67960
- }), object({
67961
- motion: number().int(),
67962
- object: number().int(),
67963
- audio: number().int()
67964
- }), {
67965
- kind: "mutation",
67966
- auth: "admin"
67967
- }), method(object({
67813
+ /**
67814
+ * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
67815
+ * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
67816
+ * track and its events always answer the same question the same way.
67817
+ *
67818
+ * Two scalar columns, not an array: every consumer wants "the coarse one" or
67819
+ * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
67820
+ * is tier 2, and each carries its own score + attribution.
67821
+ *
67822
+ * **Reading it.** What a human should be shown is `subLabel ?? label` — the
67823
+ * finest thing known. Before 4g the single `label` column held the finest
67824
+ * value, so a consumer that has not been updated reads the tier-1 slot and
67825
+ * shows nothing on a species-only row; that is why the migration puts every
67826
+ * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
67827
+ * and why the read surfaces were changed in the same train.
67828
+ *
67829
+ * **Writing it.** The slots are independent, which is the whole point: a
67830
+ * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
67831
+ * migratorius`), so fineness cannot regress by construction. Within a tier the
67832
+ * higher score wins. One rule, one implementation — see
67833
+ * `pipeline/label-tier.ts` in addon-post-analysis.
67834
+ */
67835
+ var TieredLabelFields = {
67836
+ /** Tier 1 — the sub-class. See {@link LabelTierSchema}. */
67837
+ label: string().optional(),
67838
+ /** Confidence of the tier-1 value, as reported by the deciding step. */
67839
+ labelScore: number().optional(),
67840
+ /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
67841
+ labelMeta: LabelAttributionSchema.optional(),
67842
+ /** Tier 2 — the instance. See {@link LabelTierSchema}. */
67843
+ subLabel: string().optional(),
67844
+ /** Confidence of the tier-2 value, as reported by the deciding step. */
67845
+ subLabelScore: number().optional(),
67846
+ /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
67847
+ subLabelMeta: LabelAttributionSchema.optional()
67848
+ };
67849
+ /** Per-camera slice of a training-export estimate. */
67850
+ var TrainingExportDeviceTotalsSchema = object({
67968
67851
  deviceId: number(),
67969
- cutoffMs: number()
67970
- }), TrackCascadeCountsSchema, {
67971
- kind: "mutation",
67972
- auth: "admin"
67973
- }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
67974
- kind: "mutation",
67975
- auth: "admin"
67976
- }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
67977
- kind: "mutation",
67978
- auth: "admin"
67979
- }), method(object({
67852
+ tracks: number().int(),
67853
+ files: number().int(),
67854
+ bytes: number().int()
67855
+ });
67856
+ /**
67857
+ * What a training export WOULD contain. Computed from media index rows only —
67858
+ * no blob is read to produce this.
67859
+ */
67860
+ var TrainingExportSummarySchema = object({
67861
+ generatedAt: number(),
67862
+ trackCount: number().int(),
67863
+ fileCount: number().int(),
67864
+ byteCount: number().int(),
67865
+ /** More marked tracks exist than a single pass carries. */
67866
+ truncated: boolean(),
67867
+ devices: array(TrainingExportDeviceTotalsSchema).readonly()
67868
+ });
67869
+ var TrackSchema = object({
67870
+ trackId: string(),
67980
67871
  deviceId: number(),
67981
- trackIds: array(string()).min(1)
67982
- }), object({
67983
- deleted: number().int(),
67984
- failed: array(string()).readonly()
67985
- }), {
67986
- kind: "mutation",
67987
- auth: "admin"
67988
- }), method(object({
67989
- /** Log/audit scope only — the trackId is globally unique on its own. */
67990
- deviceId: number(),
67991
- trackId: string(),
67992
- flags: TrackFlagsPatchSchema
67993
- }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
67994
- kind: "query",
67995
- auth: "admin"
67996
- }), method(object({
67997
- olderThanMs: number(),
67998
- reason: OpsLogReasonSchema.optional()
67999
- }), EventPruneCountsSchema, {
68000
- kind: "mutation",
68001
- auth: "admin"
68002
- }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
68003
- kind: "mutation",
68004
- auth: "admin"
68005
- }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
68006
- kind: "mutation",
68007
- auth: "admin"
68008
- }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
68009
- kind: "mutation",
68010
- auth: "admin"
68011
- }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
68012
- kind: "mutation",
68013
- auth: "admin"
68014
- }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
68015
- kind: "mutation",
68016
- auth: "admin"
68017
- }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
68018
- kind: "mutation",
68019
- auth: "admin"
68020
- }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
68021
- kind: "query",
68022
- auth: "admin"
68023
- }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
68024
- kind: "query",
68025
- auth: "admin"
68026
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
68027
- kind: "query",
68028
- auth: "admin"
68029
- }), method(object({
68030
- /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
68031
- * `deviceId`, deliberately: `deviceId` would make this device-bound and
68032
- * route it at one camera's owner, and "every camera" would stop being
68033
- * expressible at all. */
68034
- deviceIds: array(number()).optional(),
68035
- limit: number().int().min(1).max(500).optional()
68036
- }), array(RetrainTrackSchema).readonly(), {
68037
- kind: "query",
68038
- auth: "admin"
68039
- }), method(object({ trackId: string() }), RetrainFrameListSchema, {
68040
- kind: "query",
68041
- auth: "admin"
68042
- }), method(object({
68043
- deviceId: number(),
68044
- trackId: string(),
68045
- mediaKeys: array(string()).min(1)
68046
- }), RetrainFrameSelectionSchema, {
68047
- kind: "mutation",
68048
- auth: "admin"
68049
- }), method(object({
67872
+ className: string(),
67873
+ ...TieredLabelFields,
67874
+ producingDeviceName: string().optional(),
67875
+ /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
67876
+ source: TrackSourceSchema.optional(),
67877
+ firstSeen: number(),
67878
+ lastSeen: number(),
67879
+ /** Frame-rate position history (subject to maxPositionHistory cap). */
67880
+ positions: array(TrackPositionSchema).readonly(),
67881
+ /** Periodic snapshots at snapshotIntervalMs cadence (subject to
67882
+ * saveThumbnails policy). */
67883
+ snapshots: array(TrackSnapshotSchema).readonly(),
67884
+ /** Deduplicated zones the track has entered at least once. Zone IDS. */
67885
+ zonesVisited: array(string()).readonly(),
67886
+ /**
67887
+ * Human NAMES for {@link zonesVisited}, resolved at READ time against the
67888
+ * `zones` capability.
67889
+ *
67890
+ * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
67891
+ * and no card can render — so every free-text search surface was structurally
67892
+ * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
67893
+ * just returned nothing. Resolving here rather than in each client keeps ONE
67894
+ * derivation and costs the clients no extra call (the `zones` cap is
67895
+ * per-device, so a client-side resolve would be a per-camera fan-out on a
67896
+ * surface built to avoid exactly that).
67897
+ *
67898
+ * Resolved, never invented: a zone deleted since the track was written has no
67899
+ * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
67900
+ * two are not positionally aligned. Absent when the track visited no zone, or
67901
+ * when the zone catalogue could not be read.
67902
+ */
67903
+ zoneNames: array(string()).readonly().optional(),
67904
+ /** Deduplicated set of detector classes observed for this track over its
67905
+ * life (a track may be reclassified, e.g. person→vehicle). Absent on
67906
+ * legacy rows written before class accumulation shipped. */
67907
+ classes: array(string()).readonly().optional(),
67908
+ /** Cumulative normalized distance travelled (0..1 units = full frame width). */
67909
+ totalDistance: number(),
67910
+ state: TrackStateSchema,
67911
+ active: boolean(),
67912
+ /** Deterministic key-event importance score in [0,1] (server-computed at
67913
+ * track expiry, recomputed on late label). Absent on legacy rows written
67914
+ * before scoring shipped — consumers degrade to absence / compute-on-read. */
67915
+ importance: number().optional(),
67916
+ /** Id of the track's highest-confidence ObjectEvent (its representative
67917
+ * "best" frame). Absent when the track produced no object events. */
67918
+ bestEventId: string().optional(),
67919
+ /** Tag of the importance sub-signal that dominated the score
67920
+ * (identity|dwell|proximity|class|confidence|travel|zone). */
67921
+ importanceReason: string().optional(),
67922
+ /** Audio-classification labels heard on the camera during the track's
67923
+ * life (score ≥ device `classificationMinScore`), aggregated per label.
67924
+ * Absent on legacy rows / tracks with no confident audio. */
67925
+ audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
67926
+ /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
67927
+ * Populated from the persisted envelope columns on historical reads;
67928
+ * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
67929
+ envelope: TrackEnvelopeSchema.optional(),
67930
+ /**
67931
+ * A face DETECTOR found a face on this track — nothing more. It says the
67932
+ * detail plane produced a `face` detail; it does NOT say the face was
67933
+ * embedded, matched, above `minFacePx`, or that the recognizer was even
67934
+ * enabled. Set once and never cleared.
67935
+ *
67936
+ * **This exists so "face present but not recognised" is expressible.** A
67937
+ * recognised identity lands in `subLabel` (attributed to the face chain via
67938
+ * `subLabelMeta.stepId`), so before this field a track with an unmatched face
67939
+ * and a track with no face at all were byte-identical on the wire and no
67940
+ * surface could tell them apart. The read is `hasFace === true && subLabel
67941
+ * === undefined`.
67942
+ *
67943
+ * **Absent ≠ false.** Every row written before the column existed omits it,
67944
+ * and so does every server that predates the field — a consumer must test
67945
+ * `=== true` and render nothing otherwise, never infer "no face".
67946
+ */
67947
+ hasFace: boolean().optional(),
67948
+ /**
67949
+ * This track has a face row IN THE GALLERY: a crop **and** an embedding — a
67950
+ * face an operator could ASSIGN to an identity.
67951
+ *
67952
+ * The STRICT twin of {@link hasFace}, and the pair only earns its keep
67953
+ * because the two disagree. `hasFace` is stamped at the TOP of the face
67954
+ * branch, before every gate, and means no more than "a face detector produced
67955
+ * a face detail". This one is stamped at the single moment the gallery row
67956
+ * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
67957
+ * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
67958
+ * candidate gate, the imageless-track drop (no crop was ever captured) and
67959
+ * the crop-store drop. Everything between the detector and that insert can
67960
+ * legitimately refuse the face, so a flag written any earlier promises the
67961
+ * operator something to assign and delivers nothing.
67962
+ *
67963
+ * **Independent of recognition.** A face collected but never auto-matched is
67964
+ * still assignable — it is in fact the face an operator most wants to reach —
67965
+ * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
67966
+ * `subLabel`; this says only that the raw material exists.
67967
+ *
67968
+ * **Set once, never cleared.** A track that produced a gallery row produced
67969
+ * one; deleting the row later is the gallery's business, not this flag's.
67970
+ *
67971
+ * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
67972
+ * before the column omits it, and so does every server that predates the
67973
+ * field. A consumer must test `=== true` and render nothing otherwise —
67974
+ * never infer "no assignable face".
67975
+ */
67976
+ hasEmbeddedFace: boolean().optional(),
67977
+ /**
67978
+ * This subject CONTAINS a folded rider — a person the rider-pairing step
67979
+ * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
67980
+ * so the passage is tracked once and as a VEHICLE.
67981
+ *
67982
+ * It exists because the fold's record was dishonest. D34 and the code both
67983
+ * said "the person is not lost — it is reported so both entities stay on the
67984
+ * record"; in fact the pair went into a per-processor RAM field behind an
67985
+ * accessor nobody called, and every durable surface said `vehicle`, full
67986
+ * stop. This is the composition note that makes the row true.
67987
+ *
67988
+ * A COMPOSITION, never a class and never a label. "This vehicle contains a
67989
+ * person" is not an answer to "what is this" — both label tiers would refuse
67990
+ * a macro token anyway (D89), and correctly. Nothing here changes what the
67991
+ * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
67992
+ * and a `person` rule still does not fire for someone cycling past.
67993
+ *
67994
+ * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
67995
+ * the column, and every hub that predates the field, omits it. Test
67996
+ * `=== true` and render nothing otherwise — never infer "no rider".
67997
+ */
67998
+ hasRider: boolean().optional(),
67999
+ ...TrackFlagFields,
68000
+ ...TrackRetrainFields
68001
+ });
68002
+ var BaseEventFields = {
68003
+ id: string(),
68050
68004
  deviceId: number(),
68051
- trackId: string(),
68052
- frameId: string()
68053
- }), object({
68054
- removed: boolean(),
68055
- removedAnnotations: number().int()
68056
- }), {
68057
- kind: "mutation",
68058
- auth: "admin"
68059
- }), method(object({ frameId: string() }), object({
68005
+ timestamp: number()
68006
+ };
68007
+ var MotionEventSchema = object({
68008
+ ...BaseEventFields,
68009
+ kind: literal("motion"),
68010
+ regionCount: number(),
68011
+ /** Heavy JSON array — omitted in slim projection. */
68012
+ regions: array(object({
68013
+ bbox: BoundingBoxSchema,
68014
+ pixelCount: number(),
68015
+ intensity: number()
68016
+ })).readonly().optional(),
68017
+ /** Omitted in slim projection. */
68018
+ frameWidth: number().optional(),
68019
+ /** Omitted in slim projection. */
68020
+ frameHeight: number().optional(),
68021
+ /** Populated by B5 (recording playback URL for this event). */
68022
+ mediaUrl: string().optional()
68023
+ });
68024
+ /**
68025
+ * Which detection SOURCE produced an object event. `pipeline` = the ML
68026
+ * detection pipeline (decoded-frame inference); `onboard` = the camera's
68027
+ * native on-device AI. Both flow through the SAME analysis layers (zoning,
68028
+ * tracking, per-kind persistence) but stay distinguishable so consumers
68029
+ * (advanced-notifier, occupancy, …) can select which source(s) to act on.
68030
+ * Absent on legacy rows ⇒ treat as `pipeline`.
68031
+ */
68032
+ var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
68033
+ /**
68034
+ * The confirmed zone crossing that produced an object event. Present ONLY on
68035
+ * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
68036
+ * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
68037
+ * appearance event carry none, so a rule asking for a direction fails closed
68038
+ * on them.
68039
+ *
68040
+ * Exactly ONE crossing per event: the emitter turns each confirmed crossing
68041
+ * into its own event, so a frame in which a track enters A while leaving B
68042
+ * produces two events with two directions — never one ambiguous row.
68043
+ *
68044
+ * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
68045
+ * membership the box has NOW, and by definition it no longer contains the zone
68046
+ * that was just left. Without the id here, a zone-scoped rule could never match
68047
+ * the exit it asked for.
68048
+ */
68049
+ var ZoneCrossingSchema = object({
68050
+ direction: _enum(["enter", "exit"]),
68051
+ /** Admin zone id crossed. */
68052
+ zoneId: string(),
68053
+ /** Zone display name at crossing time (falls back to the id). */
68054
+ zoneName: string().optional()
68055
+ });
68056
+ var ObjectEventSchema = object({
68057
+ ...BaseEventFields,
68058
+ kind: literal("object"),
68059
+ /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
68060
+ source: DetectionSourceSchema.optional(),
68061
+ /**
68062
+ * Inference-frame id shared by every object event emitted from the SAME frame
68063
+ * — the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
68064
+ * 2 people + 1 dog) under one full frame, and link a track's frames over time
68065
+ * (group by `trackId`, pick a representative `frameId` as the parent frame).
68066
+ * Optional for backward-compat with pre-existing rows / the slim projection
68067
+ * includes it (it is light). Absent on rows written before this field.
68068
+ */
68069
+ frameId: string().optional(),
68070
+ /** Omitted in slim projection. */
68071
+ trackId: string().optional(),
68072
+ className: string(),
68073
+ ...TieredLabelFields,
68074
+ /** Omitted in slim projection. */
68075
+ confidence: number().optional(),
68076
+ /** Heavy JSON — omitted in slim projection. */
68077
+ bbox: BoundingBoxSchema.optional(),
68078
+ /** Heavy JSON — omitted in slim projection. */
68079
+ zones: array(string()).readonly().optional(),
68080
+ /** Omitted in slim projection. */
68081
+ state: TrackStateSchema.optional(),
68082
+ /**
68083
+ * The zone crossing this event IS, when it is one. Absent on every other
68084
+ * event kind (movement state, appearance, package) — see
68085
+ * {@link ZoneCrossingSchema}. Omitted in slim projection.
68086
+ */
68087
+ zoneCrossing: ZoneCrossingSchema.optional(),
68088
+ /** Detection-frame dimensions in pixels — let consumers normalize the
68089
+ * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
68090
+ frameWidth: number().optional(),
68091
+ frameHeight: number().optional(),
68092
+ /** MediaStore key for the crop attached to this event (if any). */
68093
+ mediaKey: string().optional(),
68094
+ /** Design B: MediaStore key of the track's native-resolution key frame (the
68095
+ * best-detection full frame). Resolve via the event-media data-plane
68096
+ * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
68097
+ * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
68098
+ * sources — consumers fall back to `mediaKey` (the tight crop). */
68099
+ keyFrameMediaKey: string().optional(),
68100
+ /** Populated by B5 (recording playback URL for this event). */
68101
+ mediaUrl: string().optional(),
68102
+ /** The parent track's key-event importance [0,1], propagated to every object
68103
+ * event of the track (so an event row can be sorted by importance without a
68104
+ * track join). Absent on legacy rows / before the track was scored. */
68105
+ importance: number().optional()
68106
+ });
68107
+ var AudioEventSchema = object({
68108
+ ...BaseEventFields,
68109
+ kind: literal("audio"),
68110
+ rms: number(),
68111
+ dbfs: number(),
68112
+ classification: object({
68113
+ className: string(),
68114
+ originalClass: string().optional(),
68115
+ score: number()
68116
+ }).optional(),
68117
+ /** Populated by B5 (recording playback URL for this event). */
68118
+ mediaUrl: string().optional()
68119
+ });
68120
+ var MediaFileKindEnum = _enum([
68121
+ "crop",
68122
+ "thumbnail",
68123
+ "snapshot",
68124
+ "firstFrame",
68125
+ "lastFrame",
68126
+ "fullFrame",
68127
+ "fullFrameBoxed",
68128
+ "faceCrop",
68129
+ "plateCrop",
68130
+ "keyFrame",
68131
+ "keyFrameSmall",
68132
+ "thumbnailSmall"
68133
+ ]);
68134
+ var MediaFileSchema = object({
68135
+ key: string(),
68136
+ kind: MediaFileKindEnum,
68060
68137
  base64: string(),
68061
- width: number().int(),
68062
- height: number().int()
68063
- }), {
68064
- kind: "query",
68065
- auth: "admin"
68066
- }), method(object({
68067
- deviceId: number(),
68068
- trackId: string(),
68069
- frameId: string(),
68070
- subject: RetrainAssistSubjectSchema,
68071
- /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
68072
- nodeId: string().optional()
68073
- }), RetrainAssistResultSchema, {
68074
- kind: "mutation",
68075
- auth: "admin"
68076
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
68077
- kind: "query",
68078
- auth: "admin"
68079
- }), method(object({
68080
- deviceId: number(),
68138
+ sizeBytes: number(),
68139
+ timestamp: number()
68140
+ });
68141
+ /**
68142
+ * One media row WITHOUT its bytes.
68143
+ *
68144
+ * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
68145
+ * 140 s track), and a client that renders tiles from the media data plane needs
68146
+ * to know only WHAT EXISTS — the bytes then arrive per tile, lazily, over HTTP
68147
+ * with an immutable cache, instead of all at once inside a tRPC response that
68148
+ * blocks the whole view.
68149
+ *
68150
+ * `sizeBytes` is carried because it is what lets a client decide between the
68151
+ * stored blob and a `?variant=thumb` rendering without fetching either.
68152
+ */
68153
+ var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
68154
+ /**
68155
+ * The MACRO tier of an annotation — a CLOSED set.
68156
+ *
68157
+ * This is what the exported detector predicts, so a typo here is a new class
68158
+ * with one example in it. `label` and `subLabel` are open strings by contrast:
68159
+ * the whole point of the page is teaching the model things it does not know
68160
+ * yet, and constraining that vocabulary would make it useless.
68161
+ *
68162
+ * A macro class is NEVER a label. The provider refuses a write whose `label` or
68163
+ * `subLabel` is one of these values, in any casing, because once `person`
68164
+ * exists in both tiers "every person box" stops being answerable without
68165
+ * knowing every string anyone ever typed — and the damage is retroactive.
68166
+ */
68167
+ var RetrainMacroClassSchema = _enum([
68168
+ "person",
68169
+ "vehicle",
68170
+ "animal",
68171
+ "package",
68172
+ "face",
68173
+ "plate"
68174
+ ]);
68175
+ /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
68176
+ var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
68177
+ /** Did a human draw this box, or did the assist propose it? */
68178
+ var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
68179
+ /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
68180
+ var RetrainBboxSchema = object({
68181
+ x: number(),
68182
+ y: number(),
68183
+ w: number(),
68184
+ h: number()
68185
+ });
68186
+ /**
68187
+ * One annotated subject.
68188
+ *
68189
+ * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
68190
+ * (letterboxed root / zone-cropped package / subject-cropped classifier) are
68191
+ * derived from it at export and never stored — storing them is how one feature
68192
+ * space ends up holding two crops of the same subject (D52).
68193
+ */
68194
+ var RetrainAnnotationSchema = object({
68195
+ id: string(),
68081
68196
  trackId: string(),
68082
- frameId: string(),
68083
- annotations: array(RetrainAnnotationDraftSchema)
68084
- }), array(RetrainAnnotationSchema).readonly(), {
68085
- kind: "mutation",
68086
- auth: "admin"
68087
- }), method(object({
68088
68197
  deviceId: number(),
68089
- trackId: string()
68090
- }), RetrainTransitionResultSchema, {
68091
- kind: "mutation",
68092
- auth: "admin"
68093
- }), method(object({
68094
- deviceId: number(),
68095
- trackId: string()
68096
- }), RetrainTransitionResultSchema, {
68097
- kind: "mutation",
68098
- auth: "admin"
68099
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
68100
- kind: "query",
68101
- auth: "admin"
68102
- }), method(object({
68103
- eventId: string(),
68104
- kind: MediaFileKindEnum.optional(),
68105
- deviceId: number()
68106
- }), array(MediaFileSchema).readonly()), method(object({
68107
- trackId: string(),
68108
- kinds: array(MediaFileKindEnum).optional(),
68109
- deviceId: number()
68110
- }), array(MediaFileSchema).readonly()), method(object({
68198
+ /** The COPY in retrain storage — never the source track's media key. */
68199
+ mediaKey: string(),
68200
+ bbox: RetrainBboxSchema,
68201
+ macroClass: RetrainMacroClassSchema,
68202
+ label: string().optional(),
68203
+ subLabel: string().optional(),
68204
+ kind: RetrainAnnotationKindSchema,
68205
+ source: RetrainAnnotationSourceSchema,
68206
+ /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
68207
+ assistModelId: string().optional(),
68208
+ assistScore: number().optional(),
68209
+ exportedInBatch: string().optional(),
68210
+ createdAt: number()
68211
+ });
68212
+ /** The write form — the server owns `id`, `createdAt` and the frame binding. */
68213
+ var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
68214
+ id: true,
68215
+ trackId: true,
68216
+ deviceId: true,
68217
+ mediaKey: true,
68218
+ createdAt: true,
68219
+ exportedInBatch: true
68220
+ });
68221
+ /** A track sitting in `staging`, with everything the worklist needs to rank it. */
68222
+ var RetrainTrackSchema = object({
68111
68223
  trackId: string(),
68112
- deviceId: number()
68113
- }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
68114
- kind: "mutation",
68115
- auth: "admin"
68116
- }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
68117
- kind: "mutation",
68118
- auth: "admin"
68119
- }), method(object({}), RebuildStatusSchema), object({
68120
68224
  deviceId: number(),
68225
+ className: string(),
68226
+ label: string().optional(),
68227
+ firstSeen: number(),
68228
+ lastSeen: number(),
68229
+ /** How many frames the dataset already holds from this track. */
68230
+ frameCount: number().int(),
68231
+ /** How many subjects have been annotated on those frames. `0` with
68232
+ * `frameCount: 0` is exactly "staging, still to work". */
68233
+ annotationCount: number().int()
68234
+ });
68235
+ /** A frame the picker may offer — an index row, no blob was read to produce it. */
68236
+ var RetrainFrameCandidateSchema = object({
68237
+ mediaKey: string(),
68238
+ kind: MediaFileKindEnum,
68121
68239
  timestamp: number(),
68122
- frameWidth: number(),
68123
- frameHeight: number(),
68124
- detections: array(OverlayDetectionSchema).readonly()
68125
- }), object({
68240
+ sizeBytes: number().int(),
68241
+ /** A copy of this original already exists — selecting it is free and cannot
68242
+ * fail, whatever became of the original. */
68243
+ copied: boolean()
68244
+ });
68245
+ /** A frame the dataset OWNS: bytes copied at selection time. */
68246
+ var RetrainFrameSchema = object({
68247
+ frameId: string(),
68126
68248
  deviceId: number(),
68127
68249
  trackId: string(),
68128
- className: string()
68250
+ /** Provenance only. It may already point at nothing — that is expected. */
68251
+ sourceMediaKey: string(),
68252
+ sourceKind: MediaFileKindEnum,
68253
+ sizeBytes: number().int(),
68254
+ width: number().int(),
68255
+ height: number().int(),
68256
+ copiedAt: number()
68257
+ });
68258
+ /** Why a copy-on-select could not be honoured — named, never a silent skip. */
68259
+ var RetrainCopyRefusalSchema = _enum([
68260
+ "source-missing",
68261
+ "unreadable-image",
68262
+ "write-failed"
68263
+ ]);
68264
+ var RetrainFrameSelectionSchema = object({
68265
+ copied: array(RetrainFrameSchema).readonly(),
68266
+ refused: array(object({
68267
+ sourceMediaKey: string(),
68268
+ reason: RetrainCopyRefusalSchema
68269
+ })).readonly()
68270
+ });
68271
+ var RetrainFrameListSchema = object({
68272
+ candidates: array(RetrainFrameCandidateSchema).readonly(),
68273
+ copies: array(RetrainFrameSchema).readonly(),
68274
+ /** What the page pre-selects — the native key frame when one survives. */
68275
+ autoPickMediaKey: string().optional()
68276
+ });
68277
+ /** What the operator asked the assist to look for. */
68278
+ var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
68279
+ kind: literal("package"),
68280
+ zone: RetrainBboxSchema.optional()
68129
68281
  }), object({
68130
- deviceId: number(),
68131
- trackId: string(),
68132
- className: string(),
68133
- durationMs: number()
68282
+ kind: literal("objects"),
68283
+ modelId: string(),
68284
+ minScore: number().optional()
68285
+ })]);
68286
+ /**
68287
+ * The assist's answer — a discriminated union, because "the model saw nothing"
68288
+ * and "this node cannot run that model" lead to different next moves and a
68289
+ * nullable result cannot tell them apart.
68290
+ */
68291
+ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
68292
+ kind: literal("proposed"),
68293
+ modelId: string(),
68294
+ stepId: string(),
68295
+ minScore: number(),
68296
+ /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
68297
+ proposals: array(RetrainAnnotationDraftSchema).readonly(),
68298
+ /** Returned by the runner but removed by the threshold. */
68299
+ belowThreshold: number().int()
68134
68300
  }), object({
68301
+ kind: literal("refused"),
68302
+ /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
68303
+ reason: string(),
68304
+ detail: string().optional()
68305
+ })]);
68306
+ /** The outcome of a lifecycle move owned by the retrain page. */
68307
+ var RetrainTransitionResultSchema = object({
68308
+ trackId: string(),
68309
+ /** Where the track ended up, whatever happened. */
68310
+ retrainStatus: RetrainStatusSchema,
68311
+ /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
68312
+ changed: boolean(),
68313
+ reason: _enum([
68314
+ "unknown-track",
68315
+ "no-frames-copied",
68316
+ "not-staging",
68317
+ "not-trained",
68318
+ "unchanged"
68319
+ ]).optional()
68320
+ });
68321
+ var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
68322
+ var MAX_EVENT_QUERY_LIMIT = 5e3;
68323
+ var DeviceEventQueryInput = object({
68135
68324
  deviceId: number(),
68136
- kind: EventKindSchema,
68137
- eventId: string(),
68138
- timestamp: number()
68325
+ since: number().optional(),
68326
+ until: number().optional(),
68327
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
68328
+ /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
68329
+ * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
68330
+ * exact behaviour. Callers may omit this field — the store defaults to
68331
+ * `full` when not provided. */
68332
+ projection: _enum(["full", "slim"]).optional()
68139
68333
  });
68140
- /**
68141
- * Reference to the frame's retained NATIVE surface + the parent crop's placement
68142
- * within the frame, so the executor can re-cut a leaf child ROI at native
68143
- * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
68144
- */
68145
- var NativeCropRefSchema = object({
68146
- /** Handle keying the retained native surface (node-pinned to its owner). */
68147
- handle: FrameHandleSchema,
68148
- /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
68149
- cropFrameSpace: object({
68150
- x: number(),
68151
- y: number(),
68152
- w: number(),
68153
- h: number()
68154
- })
68334
+ var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
68335
+ var RecentTracksQueryInput = object({
68336
+ /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
68337
+ deviceIds: array(number()),
68338
+ /** Window lower bound on `lastSeen` (inclusive). */
68339
+ since: number().optional(),
68340
+ /** Window upper bound on `lastSeen` (inclusive). */
68341
+ until: number().optional(),
68342
+ /** Page size. Default 200, max 1000. */
68343
+ limit: number().int().min(1).max(1e3).default(200),
68344
+ /** Opaque continuation cursor from a previous page's `nextCursor`.
68345
+ * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
68346
+ cursor: string().optional(),
68347
+ /** See {@link TrackProjectionSchema}. Default `full`. */
68348
+ projection: TrackProjectionSchema.optional(),
68349
+ /** Include stationary-promoted rows (parked objects). Default false: the
68350
+ * feed lists passages; parking records live on the stationary registry. */
68351
+ includeStationary: boolean().optional()
68155
68352
  });
68156
- object({
68157
- crop: object({
68158
- left: number(),
68159
- top: number(),
68160
- width: number().positive(),
68161
- height: number().positive()
68162
- }).optional(),
68163
- content: object({
68164
- width: number().int().positive(),
68165
- height: number().int().positive()
68166
- }),
68167
- fit: _enum(["stretch", "contain"]),
68168
- format: _enum([
68169
- "rgb",
68170
- "gray",
68171
- "jpeg"
68172
- ])
68353
+ var RecentTracksPageSchema = object({
68354
+ /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
68355
+ tracks: array(TrackSchema).readonly(),
68356
+ /** Cursor for the next page, or null when this page is the last. */
68357
+ nextCursor: string().nullable()
68173
68358
  });
68174
- var FrameRefSchema = object({
68175
- registryId: string().min(1),
68176
- id: string().min(1),
68177
- width: number().int().positive(),
68178
- height: number().int().positive(),
68179
- format: _enum(["rgb", "gray"]),
68180
- timestamp: number(),
68181
- capturedAt: number().optional()
68359
+ var LIST_GROUPS_DEFAULT_LIMIT = 40;
68360
+ var LIST_GROUPS_MAX_LIMIT = 100;
68361
+ var AnalyticsGroupRecordSchema = object({
68362
+ id: string(),
68363
+ deviceId: number().int(),
68364
+ openedAt: number().int(),
68365
+ closedAt: number().int(),
68366
+ timestamp: number().int(),
68367
+ memberCount: number().int(),
68368
+ memberTrackIds: array(string()).readonly(),
68369
+ className: string(),
68370
+ classes: array(string()).readonly(),
68371
+ /** Relative event-media path, or null when the group has no picture yet. */
68372
+ mediaUrl: string().nullable(),
68373
+ singleton: boolean()
68182
68374
  });
68183
- var ModelFormatSchema$1 = _enum([
68184
- "onnx",
68185
- "coreml",
68186
- "openvino",
68187
- "tflite",
68188
- "pt",
68189
- "gguf"
68190
- ]);
68191
- var PipelineSlotSchema = _enum([
68192
- "detector",
68193
- "cropper",
68194
- "classifier",
68195
- "refiner",
68196
- "audio-classifier"
68197
- ]);
68198
- var PipelineEngineChoiceSchema = object({
68199
- runtime: _enum(["node", "python"]),
68200
- backend: string(),
68201
- format: ModelFormatSchema$1,
68202
- device: string().optional()
68375
+ var AnalyticsGroupMemberSchema = object({
68376
+ trackId: string(),
68377
+ deviceId: number().int(),
68378
+ className: string(),
68379
+ firstSeen: number().int(),
68380
+ lastSeen: number().int(),
68381
+ mediaUrl: string().nullable()
68203
68382
  });
68204
- var AvailableEngineSchema = object({
68205
- engine: PipelineEngineChoiceSchema,
68206
- devices: array(object({
68207
- id: string(),
68208
- label: string(),
68209
- description: string().optional()
68210
- })).readonly(),
68211
- defaultDevice: string()
68383
+ var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
68384
+ var ListGroupsQueryInput = object({
68385
+ /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
68386
+ deviceIds: array(number()),
68387
+ /** Window lower bound on `closedAt` (inclusive). */
68388
+ since: number().optional(),
68389
+ /** Window upper bound on `openedAt` (inclusive). */
68390
+ until: number().optional(),
68391
+ limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
68392
+ /** Opaque continuation cursor from a previous page's `nextCursor`. */
68393
+ cursor: string().optional()
68212
68394
  });
68213
- var PipelineDefaultStepSchema = lazy(() => object({
68214
- addonId: string(),
68215
- addonName: string(),
68216
- slot: PipelineSlotSchema,
68217
- inputClasses: array(string()).readonly(),
68218
- outputClasses: array(string()).readonly(),
68219
- enabled: boolean(),
68220
- modelId: string(),
68221
- children: array(PipelineDefaultStepSchema).readonly(),
68222
- group: string().optional(),
68223
- settings: record(string(), unknown()).optional()
68224
- }));
68225
- var PipelineTemplateStepSchema = lazy(() => object({
68226
- addonId: string(),
68227
- enabled: boolean(),
68228
- modelId: string(),
68229
- children: array(PipelineTemplateStepSchema).readonly(),
68230
- settings: record(string(), unknown()).optional()
68231
- }));
68232
- var PipelineTemplateSchema$1 = object({
68233
- id: string(),
68234
- name: string(),
68235
- createdAt: string(),
68236
- updatedAt: string(),
68237
- engine: PipelineEngineChoiceSchema,
68238
- steps: array(PipelineTemplateStepSchema).readonly()
68395
+ var ListGroupsPageSchema = object({
68396
+ groups: array(AnalyticsGroupRecordSchema).readonly(),
68397
+ nextCursor: string().nullable()
68398
+ });
68399
+ var KeyEventQueryInput = object({
68400
+ deviceId: number(),
68401
+ /** Window lower bound (track firstSeen ≥ since). */
68402
+ since: number(),
68403
+ /** Window upper bound (track firstSeen ≤ until). */
68404
+ until: number(),
68405
+ limit: number().int().min(1).max(200).default(50),
68406
+ /** Drop tracks scoring below this importance. */
68407
+ minImportance: number().min(0).max(1).optional(),
68408
+ /** Restrict to a single class (e.g. 'person'). */
68409
+ classFilter: string().optional()
68239
68410
  });
68240
- var PipelineModelOptionSchema = object({
68411
+ var KeyEventSchema = object({
68412
+ /** The representative event id (the track's best ObjectEvent, else its trackId). */
68241
68413
  id: string(),
68242
- name: string(),
68243
- formats: record(string(), object({
68244
- downloaded: boolean(),
68245
- sizeMB: number()
68246
- })),
68247
- group: ModelVariantGroupSchema.optional(),
68248
- legacy: boolean().optional(),
68249
- provider: ModelProviderIdSchema.optional()
68414
+ trackId: string(),
68415
+ /** Track start time (firstSeen). */
68416
+ timestamp: number(),
68417
+ className: string(),
68418
+ ...TieredLabelFields,
68419
+ importance: number(),
68420
+ /** Highest-confidence ObjectEvent id for the track (empty when none). */
68421
+ bestEventId: string(),
68422
+ /** Track lifetime in ms (lastSeen - firstSeen). */
68423
+ windowMs: number().optional(),
68424
+ ...TrackFlagFields,
68425
+ ...TrackRetrainFields
68250
68426
  });
68251
- var ConfigFieldBridge = custom();
68252
- var PipelineAddonSchemaSchema = object({
68253
- id: string(),
68254
- name: string(),
68255
- slot: PipelineSlotSchema,
68256
- inputClasses: array(string()).readonly(),
68257
- outputClasses: array(string()).readonly(),
68258
- childSlots: array(PipelineSlotSchema).readonly(),
68259
- models: array(PipelineModelOptionSchema).readonly(),
68260
- defaultModelId: string(),
68261
- defaultModelIdByFormat: record(string(), string()).optional(),
68262
- enabledByDefault: boolean().optional(),
68263
- backfillIntoExistingOverrides: boolean().optional(),
68264
- defaultConfidence: number(),
68265
- group: string().optional(),
68266
- configSchema: array(ConfigFieldBridge).readonly().optional()
68427
+ object({
68428
+ trackId: string(),
68429
+ className: string(),
68430
+ confidence: number(),
68431
+ bbox: BoundingBoxSchema,
68432
+ zones: array(string()).readonly(),
68433
+ state: TrackStateSchema
68267
68434
  });
68268
- var PipelineSlotSchemaSchema = object({
68269
- id: PipelineSlotSchema,
68270
- label: string(),
68271
- priority: number(),
68272
- parentSlot: PipelineSlotSchema.nullable(),
68273
- addons: array(PipelineAddonSchemaSchema).readonly()
68435
+ var OverlayDetectionSchema = looseObject({
68436
+ id: string(),
68437
+ kind: _enum(["first-level", "detail"]),
68438
+ macroClass: string(),
68439
+ score: number(),
68440
+ bbox: object({
68441
+ x: number(),
68442
+ y: number(),
68443
+ width: number(),
68444
+ height: number()
68445
+ }),
68446
+ labels: array(looseObject({
68447
+ label: string(),
68448
+ score: number()
68449
+ })).readonly(),
68450
+ parentId: string().optional()
68274
68451
  });
68275
- var PipelineSchemaSchema = object({
68276
- availableEngines: array(AvailableEngineSchema).readonly(),
68277
- selectedEngine: PipelineEngineChoiceSchema,
68278
- slots: array(PipelineSlotSchemaSchema).readonly()
68452
+ var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
68453
+ var SearchObjectEventsInput = object({
68454
+ text: string(),
68455
+ deviceId: number().optional(),
68456
+ since: number().optional(),
68457
+ until: number().optional(),
68458
+ classFilter: string().optional(),
68459
+ limit: number().default(50),
68460
+ minScore: number().min(0).max(1).default(.2)
68279
68461
  });
68280
- var EngineProvisioningSchema = object({
68281
- runtimeId: _enum([
68282
- "onnx",
68283
- "openvino",
68284
- "coreml",
68285
- "edgetpu"
68286
- ]).nullable(),
68287
- device: string().nullable(),
68288
- state: _enum([
68289
- "idle",
68290
- "installing",
68291
- "verifying",
68292
- "ready",
68293
- "failed"
68294
- ]),
68295
- progress: number().optional(),
68296
- error: string().optional(),
68297
- nextRetryAt: number().optional(),
68298
- /**
68299
- * Gate A (config-correctness gate at engine change): human-readable
68300
- * config issues surfaced EAGERLY when the node's engine changes — model
68301
- * substitutions ("chose X, running Y") and zero-build steps ("no model
68302
- * has a <format> build"). Additive/optional: informational only, never
68303
- * enforced here — `assertEngineReady` (readiness) still gates inference.
68304
- * Absent/empty when the node-default tree resolves cleanly.
68305
- */
68306
- configIssues: array(string()).optional()
68462
+ var TrackCascadeCountsSchema = object({
68463
+ /** Persisted track roots deleted (authoritative). */
68464
+ tracks: number().int(),
68465
+ /** Object events removed with their tracks (best-effort; see note above). */
68466
+ events: number().int(),
68467
+ /** Track/face/plate-owned media removed (best-effort). Never identity media. */
68468
+ media: number().int(),
68469
+ /** Unassigned (non-enrolled) face reads removed (best-effort). */
68470
+ faces: number().int(),
68471
+ /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
68472
+ plates: number().int(),
68473
+ /** Per-track CLIP search vectors removed (best-effort). */
68474
+ embeddings: number().int(),
68475
+ /** Group membership + group rows removed with their last member (best-effort). */
68476
+ groups: number().int()
68307
68477
  });
68308
- var PipelineStepInputSchema = lazy(() => object({
68309
- addonId: string(),
68310
- modelId: string().optional(),
68311
- enabled: boolean().default(true),
68312
- children: array(PipelineStepInputSchema).optional(),
68313
- settings: record(string(), unknown()).optional(),
68314
- jumpDeviceKey: string().optional()
68315
- }));
68316
- var ModelSubstitutionSchema = object({
68317
- addonId: string(),
68318
- chosen: string(),
68319
- running: string(),
68320
- format: string()
68478
+ /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
68479
+ var DiskReconcileCountsSchema = object({
68480
+ mediaDropped: number().int(),
68481
+ tracks: number().int(),
68482
+ events: number().int()
68321
68483
  });
68322
- var PipelineValidationIssueSchema = object({
68323
- addonId: string(),
68324
- kind: _enum(["unknown-addon", "no-format-build"]),
68325
- detail: string()
68484
+ /** Event-store footprint for one camera. */
68485
+ var EventStoreDeviceFootprintSchema = object({
68486
+ deviceId: number(),
68487
+ /** Persisted event rows (motion + object + audio) for the camera. */
68488
+ rows: number().int(),
68489
+ /** Event-owned media bytes on disk for the camera. */
68490
+ bytes: number().int()
68326
68491
  });
68327
- var PipelineValidationResultSchema = object({
68328
- ok: boolean(),
68329
- issues: array(PipelineValidationIssueSchema).readonly(),
68330
- substitutions: array(ModelSubstitutionSchema).readonly(),
68331
- /** The node's `currentEngine.format` this validation ran against. */
68332
- format: string()
68492
+ /** Aggregate event-store footprint: global totals + per-camera breakdown. */
68493
+ var EventStoreFootprintSchema = object({
68494
+ totalRows: number().int(),
68495
+ totalBytes: number().int(),
68496
+ devices: array(EventStoreDeviceFootprintSchema).readonly()
68333
68497
  });
68334
- var ReferenceImageEntrySchema = object({
68335
- filename: string(),
68336
- stepIds: array(string()).readonly().optional()
68498
+ /** Per-kind counts returned by the event-prune / device-delete mutations. */
68499
+ var EventPruneCountsSchema = object({
68500
+ motion: number().int(),
68501
+ object: number().int(),
68502
+ audio: number().int()
68337
68503
  });
68338
- var ReferenceImageBodySchema = object({
68339
- base64: string(),
68340
- filename: string()
68504
+ /**
68505
+ * Re-embed stored tracks from their key frames.
68506
+ *
68507
+ * The reason this is an operator-callable method and not a migration script:
68508
+ * every knob that decides what a vector MEANS — encoder model, crop margin,
68509
+ * squaring — is only changeable if the existing vectors can be regenerated.
68510
+ * Mixing feature spaces in one index makes cosine scores incomparable, and the
68511
+ * symptom is a quality regression with no visible cause.
68512
+ */
68513
+ var RebuildObjectEmbeddingsInput = object({
68514
+ /** Restrict to one camera. Omit for the whole fleet. */
68515
+ deviceId: number().optional(),
68516
+ since: number().optional(),
68517
+ until: number().optional(),
68518
+ /** Stop after this many tracks; the result reports whether more remain. */
68519
+ maxTracks: number().int().positive().optional(),
68520
+ /**
68521
+ * Run every embedding on THIS node instead of round-robining the fleet.
68522
+ *
68523
+ * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
68524
+ * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
68525
+ * calling it that would pin the rebuild REQUEST itself to that node — the
68526
+ * rebuild orchestration lives on the hub, and only the per-track step runs
68527
+ * remotely. This field is data; the per-track pin is applied inside.
68528
+ *
68529
+ * Absent ⇒ round-robin over every online node whose runner can serve the
68530
+ * pinned model.
68531
+ */
68532
+ executeOnNodeId: string().optional(),
68533
+ /**
68534
+ * Milliseconds to wait between tracks; omit for the built-in default, `0` to
68535
+ * run flat out.
68536
+ *
68537
+ * A rebuild is bulk maintenance on hub-main's single thread. Measured
68538
+ * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
68539
+ * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
68540
+ * force is logged at start and finish so a deliberately slow pass reads
68541
+ * differently from a stalled one.
68542
+ */
68543
+ pacingMs: number().int().nonnegative().optional()
68341
68544
  });
68342
- var ReferenceAudioEntrySchema = object({
68343
- filename: string(),
68344
- sizeKb: number()
68545
+ /**
68546
+ * Result of emptying the CLIP index.
68547
+ *
68548
+ * The clean slate before a policy change: a new crop margin or encoder model
68549
+ * leaves two feature spaces in one index whose cosine scores are not
68550
+ * comparable, so wiping and rebuilding is the only way to be sure every vector
68551
+ * means the same thing.
68552
+ */
68553
+ var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
68554
+ /**
68555
+ * Acknowledgement that a rebuild STARTED.
68556
+ *
68557
+ * The pass costs ~1s per track — 45 minutes for a 2,600-track fleet — so it
68558
+ * runs detached and this returns immediately. Waiting for it made the client
68559
+ * time out while the work carried on server-side, which is the worst of both:
68560
+ * no result and no way to know it was still going. Poll
68561
+ * `getObjectEmbeddingRebuildStatus` for progress.
68562
+ */
68563
+ var RebuildObjectEmbeddingsResultSchema = object({
68564
+ started: boolean(),
68565
+ /** True when a pass was already running; the new request is ignored. */
68566
+ alreadyRunning: boolean()
68345
68567
  });
68346
- var ReferenceAudioBodySchema = object({ base64: string() });
68347
- var AudioBackendSchema = object({
68348
- id: string(),
68349
- name: string(),
68350
- description: string(),
68351
- available: boolean(),
68568
+ var RebuildStatusSchema = object({
68569
+ running: boolean(),
68570
+ scanned: number(),
68571
+ rebuilt: number(),
68572
+ /** Tracks whose key frame is gone — nothing to re-embed from. */
68573
+ missingKeyFrame: number(),
68574
+ /** Tracks with no usable detection box. */
68575
+ missingBbox: number(),
68576
+ /**
68577
+ * Tracks an executing node REFUSED rather than broke on — an unreadable key
68578
+ * frame, a step that threw. Separate from `failed` because the remedy is
68579
+ * different, and because a whole camera silently contributing zero vectors
68580
+ * is the shape of failure a rebuild must never hide.
68581
+ */
68582
+ notRunnable: number(),
68352
68583
  /**
68353
- * Raw classifier labels this backend can emit (e.g. YAMNet's
68354
- * 521-class set or Apple SoundAnalysis's 303-class set). Used by
68355
- * the benchmark UI to populate the `enabledMicroClasses` filter
68356
- * specific to the selected backend without a separate fetch.
68584
+ * The pass stopped because NO node could serve the pinned model.
68585
+ *
68586
+ * Distinct from `notRunnable` on purpose: that one says "this track was
68587
+ * refused", this one says "the cluster cannot do this work at all" — every
68588
+ * candidate node either lacks the `clip-embedding` step, lacks a build of the
68589
+ * pinned model for its engine format, or dropped out. The remedy is a model /
68590
+ * engine change, not a per-camera one. Non-zero here always comes with
68591
+ * `complete: false`.
68357
68592
  */
68358
- rawLabels: array(string()).readonly().optional()
68359
- });
68360
- var AudioCapabilitiesSchema = object({
68361
- activeBackend: string(),
68362
- availableBackends: array(AudioBackendSchema).readonly(),
68363
- sampleRate: number(),
68364
- chunkDurationMs: number()
68365
- });
68366
- var DownloadModelResultSchema = object({
68367
- filePath: string(),
68368
- sizeMB: number(),
68369
- durationMs: number()
68593
+ noCapableNode: number(),
68594
+ failed: number(),
68595
+ /** Set once a pass ends: true only when EVERYTHING was covered. */
68596
+ complete: boolean().nullable(),
68597
+ startedAtMs: number().nullable(),
68598
+ finishedAtMs: number().nullable(),
68599
+ /** Present when the pass ended by throwing. */
68600
+ error: string().nullable()
68370
68601
  });
68371
- /**
68372
- * Wrapper carrying a single test run's result. Replaces the legacy
68373
- * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
68374
- * canonical `AudioResult` from the Phase 6 output rework: one
68375
- * `AudioDetection` per class above `minScore`, top-N candidates in
68376
- * `debug.alternateLabels['audio-classifier']`, per-source timings in
68377
- * `debug.stepTimings`. The outer `success`/`error` fields stay so the
68378
- * benchmark UI can still report a clean failure when the classifier
68379
- * cap isn't available.
68380
- */
68381
- var AudioTestResultSchema = object({
68382
- success: boolean(),
68383
- error: string().optional(),
68384
- frame: custom().optional()
68602
+ var ReplayFrameInputSchema = object({
68603
+ timestamp: number(),
68604
+ frame: PipelineRunResultBridge
68385
68605
  });
68386
- var PipelineConfigBridge = custom();
68387
- var ConfigUISchemaBridge = custom();
68388
- var ConfigUISchemaNullableBridge = custom();
68389
- var InferenceCapabilitiesBridge = custom();
68390
- var ModelAvailabilityListBridge = custom();
68391
- var PipelineRunResultBridge = custom();
68392
- method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
68393
- modelId: string(),
68394
- settings: record(string(), unknown()).readonly()
68395
- }))), method(object({ steps: record(string(), object({
68396
- modelId: string(),
68397
- settings: record(string(), unknown()).readonly()
68398
- })) }), object({ success: literal(true) }), {
68606
+ var RunReplayFrameProcessorResultSchema = object({ tracks: array(object({
68607
+ className: string(),
68608
+ firstSeenMs: number(),
68609
+ lastSeenMs: number(),
68610
+ /** Bbox of the track's FIRST matched detection, pixel-space in the clip's
68611
+ * frame — a representative box for the diff's `(className, window, IoU)`
68612
+ * pairing (`replay-diff.ts`). A replay does not need the full per-frame
68613
+ * trajectory production's `Track.positions` keeps. */
68614
+ bbox: BoundingBoxSchema,
68615
+ /** How many of the input frames this track matched a real detection on
68616
+ * (never a coasted/extrapolated frame) — the replay's own signal for "how
68617
+ * solid is this track", cheaper than re-deriving it from a trajectory. */
68618
+ framesMatched: number().int()
68619
+ })).readonly() });
68620
+ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
68621
+ deviceId: number(),
68622
+ trackId: string()
68623
+ }), TrackSchema.nullable()), method(object({
68624
+ deviceId: number(),
68625
+ since: number().optional(),
68626
+ until: number().optional(),
68627
+ limit: number().optional(),
68628
+ /** Spatial filter — only tracks whose trajectory intersects the zone
68629
+ * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
68630
+ * envelope columns, then precisely tested per position. Tracks with
68631
+ * an unknown envelope (no frame dims at persist time) always match. */
68632
+ zone: TrackZoneFilterSchema.optional(),
68633
+ /** See {@link TrackProjectionSchema}. Default `full` (backward
68634
+ * compatible — omitting the field keeps today's exact behaviour). */
68635
+ projection: TrackProjectionSchema.optional(),
68636
+ /** Include stationary-promoted rows (parked objects handed to the
68637
+ * stationary registry). Default false: the timeline lists passages,
68638
+ * not parking records (operator decision, 2026-08-15). */
68639
+ includeStationary: boolean().optional()
68640
+ }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
68641
+ deviceId: number(),
68642
+ groupId: string().min(1)
68643
+ }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
68644
+ kind: "mutation",
68645
+ auth: "admin"
68646
+ }), 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({
68647
+ deviceId: number(),
68648
+ since: number().optional(),
68649
+ until: number().optional(),
68650
+ kinds: array(string()).optional(),
68651
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
68652
+ }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
68653
+ deviceId: number(),
68654
+ since: number(),
68655
+ until: number(),
68656
+ bucketMs: number().int().positive()
68657
+ }), array(object({
68658
+ bucketStart: number(),
68659
+ motion: number().int(),
68660
+ object: number().int(),
68661
+ audio: number().int()
68662
+ })).readonly()), method(object({
68663
+ deviceId: number(),
68664
+ cutoffMs: number()
68665
+ }), object({
68666
+ motion: number().int(),
68667
+ object: number().int(),
68668
+ audio: number().int()
68669
+ }), {
68670
+ kind: "mutation",
68671
+ auth: "admin"
68672
+ }), method(object({
68673
+ deviceId: number(),
68674
+ cutoffMs: number()
68675
+ }), TrackCascadeCountsSchema, {
68676
+ kind: "mutation",
68677
+ auth: "admin"
68678
+ }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
68679
+ kind: "mutation",
68680
+ auth: "admin"
68681
+ }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
68682
+ kind: "mutation",
68683
+ auth: "admin"
68684
+ }), method(object({
68685
+ deviceId: number(),
68686
+ trackIds: array(string()).min(1)
68687
+ }), object({
68688
+ deleted: number().int(),
68689
+ failed: array(string()).readonly()
68690
+ }), {
68691
+ kind: "mutation",
68692
+ auth: "admin"
68693
+ }), method(object({
68694
+ /** Log/audit scope only — the trackId is globally unique on its own. */
68695
+ deviceId: number(),
68696
+ trackId: string(),
68697
+ flags: TrackFlagsPatchSchema
68698
+ }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
68699
+ kind: "query",
68700
+ auth: "admin"
68701
+ }), method(object({
68702
+ olderThanMs: number(),
68703
+ reason: OpsLogReasonSchema.optional()
68704
+ }), EventPruneCountsSchema, {
68705
+ kind: "mutation",
68706
+ auth: "admin"
68707
+ }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
68708
+ kind: "mutation",
68709
+ auth: "admin"
68710
+ }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
68711
+ kind: "mutation",
68712
+ auth: "admin"
68713
+ }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
68714
+ kind: "mutation",
68715
+ auth: "admin"
68716
+ }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
68717
+ kind: "mutation",
68718
+ auth: "admin"
68719
+ }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
68720
+ kind: "mutation",
68721
+ auth: "admin"
68722
+ }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
68723
+ kind: "mutation",
68724
+ auth: "admin"
68725
+ }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
68726
+ kind: "mutation",
68727
+ auth: "admin"
68728
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
68729
+ kind: "query",
68730
+ auth: "admin"
68731
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
68732
+ kind: "mutation",
68733
+ auth: "admin"
68734
+ }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
68735
+ kind: "query",
68736
+ auth: "admin"
68737
+ }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
68738
+ kind: "query",
68739
+ auth: "admin"
68740
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
68741
+ kind: "query",
68742
+ auth: "admin"
68743
+ }), method(object({
68744
+ /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
68745
+ * `deviceId`, deliberately: `deviceId` would make this device-bound and
68746
+ * route it at one camera's owner, and "every camera" would stop being
68747
+ * expressible at all. */
68748
+ deviceIds: array(number()).optional(),
68749
+ limit: number().int().min(1).max(500).optional()
68750
+ }), array(RetrainTrackSchema).readonly(), {
68751
+ kind: "query",
68752
+ auth: "admin"
68753
+ }), method(object({ trackId: string() }), RetrainFrameListSchema, {
68754
+ kind: "query",
68755
+ auth: "admin"
68756
+ }), method(object({
68757
+ deviceId: number(),
68758
+ trackId: string(),
68759
+ mediaKeys: array(string()).min(1)
68760
+ }), RetrainFrameSelectionSchema, {
68761
+ kind: "mutation",
68762
+ auth: "admin"
68763
+ }), method(object({
68764
+ deviceId: number(),
68765
+ trackId: string(),
68766
+ frameId: string()
68767
+ }), object({
68768
+ removed: boolean(),
68769
+ removedAnnotations: number().int()
68770
+ }), {
68771
+ kind: "mutation",
68772
+ auth: "admin"
68773
+ }), method(object({ frameId: string() }), object({
68774
+ base64: string(),
68775
+ width: number().int(),
68776
+ height: number().int()
68777
+ }), {
68778
+ kind: "query",
68779
+ auth: "admin"
68780
+ }), method(object({
68781
+ deviceId: number(),
68782
+ trackId: string(),
68783
+ frameId: string(),
68784
+ subject: RetrainAssistSubjectSchema,
68785
+ /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
68786
+ nodeId: string().optional()
68787
+ }), RetrainAssistResultSchema, {
68788
+ kind: "mutation",
68789
+ auth: "admin"
68790
+ }), method(object({
68791
+ deviceId: number(),
68792
+ source: DetectionSourceSchema,
68793
+ zones: array(ZoneSchema).readonly().optional(),
68794
+ detectionRules: array(ZoneRuleSchema).readonly().optional(),
68795
+ zoneMembershipMinOverlap: number().min(0).max(1).optional(),
68796
+ frames: array(ReplayFrameInputSchema).min(1)
68797
+ }), RunReplayFrameProcessorResultSchema, {
68798
+ kind: "mutation",
68799
+ auth: "admin"
68800
+ }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
68801
+ kind: "query",
68802
+ auth: "admin"
68803
+ }), method(object({
68804
+ deviceId: number(),
68805
+ trackId: string(),
68806
+ frameId: string(),
68807
+ annotations: array(RetrainAnnotationDraftSchema)
68808
+ }), array(RetrainAnnotationSchema).readonly(), {
68809
+ kind: "mutation",
68810
+ auth: "admin"
68811
+ }), method(object({
68812
+ deviceId: number(),
68813
+ trackId: string()
68814
+ }), RetrainTransitionResultSchema, {
68399
68815
  kind: "mutation",
68400
68816
  auth: "admin"
68401
- }), method(object({ nodeId: string() }), object({
68402
- success: literal(true),
68403
- clearedDevices: number()
68404
- }), {
68817
+ }), method(object({
68818
+ deviceId: number(),
68819
+ trackId: string()
68820
+ }), RetrainTransitionResultSchema, {
68405
68821
  kind: "mutation",
68406
68822
  auth: "admin"
68407
- }), 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({
68408
- name: string(),
68409
- steps: array(PipelineTemplateStepSchema).readonly(),
68410
- engine: PipelineEngineChoiceSchema
68411
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
68412
- id: string(),
68413
- name: string().optional(),
68414
- steps: array(PipelineTemplateStepSchema).readonly().optional()
68415
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
68416
- addonId: string(),
68417
- modelId: string(),
68418
- format: ModelFormatSchema$1
68419
- }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
68420
- addonId: string(),
68421
- modelId: string(),
68422
- format: ModelFormatSchema$1
68423
- }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
68424
- engine: PipelineEngineChoiceSchema.optional(),
68425
- steps: array(PipelineStepInputSchema).min(1),
68426
- frame: FrameInputSchema.optional(),
68427
- /**
68428
- * Process-local lazy frame. Valid only when caller and provider resolve
68429
- * in the same execution-group process; split/cross-node callers use
68430
- * `frame`/`image` inline compatibility instead.
68431
- */
68432
- frameRef: FrameRefSchema.optional(),
68433
- /**
68434
- * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
68435
- * the decoded pixels live in. One more member of the one-of
68436
- * frame/frameHandle/image/imageBase64/referenceImage group.
68437
- */
68438
- frameHandle: FrameHandleSchema.optional(),
68439
- imageBase64: string().optional(),
68440
- /**
68441
- * Binary JPEG bytes — preferred over `imageBase64` on internal
68442
- * hops (hub → forked worker via Moleculer MsgPack) because it
68443
- * skips the 33% base64 overhead + the per-call base64 decode on
68444
- * the detection-pipeline worker. Callers can pass either; exactly
68445
- * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
68446
- */
68447
- image: _instanceof(Uint8Array).optional(),
68448
- referenceImage: string().optional(),
68449
- deviceId: number().optional(),
68450
- sessionId: string().optional(),
68451
- /**
68452
- * Execution plane. 'full' (default) runs the whole tree — benchmark,
68453
- * reference-image, and detail-subtree calls. 'frame' is the live
68454
- * per-frame dispatch: ONLY root-plane steps run; crop children
68455
- * (inputClasses ≠ null) are skipped and served per-track via
68456
- * pipelineRunner.runDetailSubtree (two-plane design).
68457
- */
68458
- plane: _enum(["full", "frame"]).optional(),
68459
- /**
68460
- * Inference-device selector (Phase 2 multi-device). Format
68461
- * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
68462
- * Omitted ⇒ the runner's default device (current single-engine
68463
- * behaviour). Selects WHICH device pool of the node runs the call.
68464
- */
68465
- deviceKey: string().optional(),
68466
- /**
68467
- * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
68468
- * when the parent crop was resolved from the frame's retained NATIVE
68469
- * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
68470
- * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
68471
- * resolution from that surface — the SAME quality path faces already
68472
- * had — instead of the downscaled parent tile. `handle` keys the native
68473
- * surface (node-pinned to its owner); `cropFrameSpace` is the parent
68474
- * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
68475
- * the executor's crop-normalized child ROI back into frame-normalized
68476
- * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
68477
- * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
68478
- * (today's behaviour on the fallback path).
68479
- */
68480
- nativeCropRef: NativeCropRefSchema.optional()
68481
- }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
68482
- engine: PipelineEngineChoiceSchema.optional(),
68483
- steps: array(PipelineStepInputSchema).min(1),
68484
- frames: array(FrameInputSchema).min(1).max(255),
68485
- deviceId: number().optional(),
68486
- sessionId: string().optional(),
68487
- /**
68488
- * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
68489
- * the batch to the Python pool's bench preprocess cache
68490
- * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
68491
- * preprocessed ONCE and every later inference is a pure-inference cache
68492
- * hit — the sustained-throughput run measures inference, not
68493
- * decode+preprocess+infer. Omitted/0 for live frames (all different →
68494
- * full preprocess every call, correct). Fresh per sustained run;
68495
- * released via `uncacheFrame`.
68496
- */
68497
- frameId: number().int().nonnegative().optional(),
68498
- /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
68499
- deviceKey: string().optional()
68500
- }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
68501
- data: _instanceof(Uint8Array),
68502
- width: number().int().positive(),
68503
- height: number().int().positive(),
68504
- format: _enum([
68505
- "rgb",
68506
- "bgr",
68507
- "gray"
68508
- ])
68509
- }), object({
68510
- frameId: number(),
68511
- width: number(),
68512
- height: number()
68513
- }), { kind: "mutation" }), method(object({
68514
- stepId: string(),
68515
- frameId: number().int()
68516
- }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
68517
- batchMode: string(),
68518
- windowMs: number(),
68519
- maxBatchSize: number(),
68520
- concurrency: number()
68521
- })), method(_void(), array(object({
68522
- engineKey: string(),
68523
- engine: PipelineEngineChoiceSchema,
68524
- modelsLoaded: array(string()).readonly(),
68525
- inUseByCameras: array(number()).readonly(),
68526
- /**
68527
- * Origin of this resident factory.
68528
- * - `runtime` — main camera-serving engine (no idle TTL).
68529
- * - `warm-override` — benchmark/test override held in the warm
68530
- * cache; auto-disposed after the idle TTL.
68531
- * - `device-pool` — a concurrent per-device pool (Phase 2
68532
- * multi-device, keyed by `deviceKey`) resolved
68533
- * via `resolveDeviceFactory`. Runs alongside the
68534
- * `runtime` engine on a DIFFERENT accelerator
68535
- * (NPU / iGPU / Coral) — this is how the
68536
- * Engines tab shows all pools running at once.
68537
- */
68538
- kind: _enum([
68539
- "runtime",
68540
- "warm-override",
68541
- "device-pool"
68542
- ]),
68543
- /** Native pid of the underlying Python pool (null when no pool). */
68544
- poolPid: number().nullable(),
68545
- /** ms since this factory was last used (null when not warm-tracked). */
68546
- idleMs: number().nullable(),
68547
- /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
68548
- idleTtlMs: number().nullable()
68549
- })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
68550
- kind: "mutation",
68823
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
68824
+ kind: "query",
68551
68825
  auth: "admin"
68552
68826
  }), method(object({
68553
- engine: PipelineEngineChoiceSchema,
68554
- force: boolean().optional()
68555
- }), object({
68556
- success: boolean(),
68557
- reason: string().optional()
68558
- }), {
68827
+ eventId: string(),
68828
+ kind: MediaFileKindEnum.optional(),
68829
+ deviceId: number()
68830
+ }), array(MediaFileSchema).readonly()), method(object({
68831
+ trackId: string(),
68832
+ kinds: array(MediaFileKindEnum).optional(),
68833
+ deviceId: number()
68834
+ }), array(MediaFileSchema).readonly()), method(object({
68835
+ trackId: string(),
68836
+ deviceId: number()
68837
+ }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
68559
68838
  kind: "mutation",
68560
68839
  auth: "admin"
68561
- }), 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({
68562
- addonId: string(),
68563
- modelId: string(),
68564
- filename: string().optional(),
68565
- settings: record(string(), unknown()).optional()
68566
- }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
68840
+ }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
68841
+ kind: "mutation",
68842
+ auth: "admin"
68843
+ }), method(object({}), RebuildStatusSchema), object({
68844
+ deviceId: number(),
68845
+ timestamp: number(),
68846
+ frameWidth: number(),
68847
+ frameHeight: number(),
68848
+ detections: array(OverlayDetectionSchema).readonly()
68849
+ }), object({
68850
+ deviceId: number(),
68851
+ trackId: string(),
68852
+ className: string()
68853
+ }), object({
68854
+ deviceId: number(),
68855
+ trackId: string(),
68856
+ className: string(),
68857
+ durationMs: number()
68858
+ }), object({
68859
+ deviceId: number(),
68860
+ kind: EventKindSchema,
68861
+ eventId: string(),
68862
+ timestamp: number()
68863
+ });
68567
68864
  object({
68568
68865
  activeCameras: number(),
68569
68866
  throttledCameras: number(),
@@ -68575,119 +68872,19 @@ var CameraMetricsSchema = object({
68575
68872
  "disabled",
68576
68873
  "always-on",
68577
68874
  "on-motion"
68578
- ]),
68579
- configuredFps: number(),
68580
- actualFps: number(),
68581
- queueDepth: number(),
68582
- avgInferenceTimeMs: number(),
68583
- droppedFrames: number(),
68584
- phase: _enum([
68585
- "idle",
68586
- "watching",
68587
- "active"
68588
- ])
68589
- });
68590
- var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
68591
- /**
68592
- * Zone — pure geometry + identity. NO filtering behaviour.
68593
- *
68594
- * Zones describe **where** in the frame the operator wants to flag
68595
- * something; consumer-owned {@link ZoneRule} arrays describe **how**
68596
- * each pipeline stage uses them. Splitting the two means a single
68597
- * polygon "Driveway" can simultaneously back a motion-exclude rule,
68598
- * a detection-include rule on `['car']`, and an occupancy aggregate
68599
- * — without three duplicated polygons.
68600
- *
68601
- * Owned by the orchestrator addon (provider) and mirrored into the
68602
- * `zones` device-state slice on every mutation. Consumers
68603
- * (motion-wasm, pipeline-executor, analytics, admin UI) read either
68604
- * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
68605
- * mirror with `onChanged`).
68606
- *
68607
- * Coordinates are normalised fractions of the frame (0–1) so zones
68608
- * survive resolution changes and stream profile switches.
68609
- *
68610
- * `kind` discriminates between full polygons (closed regions used
68611
- * for intrusion / occupancy filters) and tripwires (open 2-point
68612
- * line segments used for cross events). Onboard / firmware-reported
68613
- * zones (Reolink, ONVIF) are out of scope for now — see the deferred
68614
- * task list.
68615
- */
68616
- var ZoneKindEnum = _enum(["polygon", "tripwire"]);
68617
- /** Polygon vertex in fraction-of-frame coordinates (0–1). */
68618
- var PolygonPointSchema = object({
68619
- x: number(),
68620
- y: number()
68621
- });
68622
- /** A camera detection zone — pure geometry/identity. */
68623
- var ZoneSchema = object({
68624
- id: string(),
68625
- name: string(),
68626
- kind: ZoneKindEnum.default("polygon"),
68627
- /** Polygon vertices, fraction of frame (0–1). */
68628
- polygon: array(PolygonPointSchema).readonly(),
68629
- /** Visual color for UI rendering. */
68630
- color: string().default("#3b82f6")
68875
+ ]),
68876
+ configuredFps: number(),
68877
+ actualFps: number(),
68878
+ queueDepth: number(),
68879
+ avgInferenceTimeMs: number(),
68880
+ droppedFrames: number(),
68881
+ phase: _enum([
68882
+ "idle",
68883
+ "watching",
68884
+ "active"
68885
+ ])
68631
68886
  });
68632
- /**
68633
- * Zones capability — per-camera CRUD over polygon detection zones.
68634
- *
68635
- * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
68636
- * to per-device settings and mirrors into the `zones` device-state
68637
- * slice on every mutation, so downstream consumers can subscribe via
68638
- * `dev.state.zones.onChanged`.
68639
- *
68640
- * The cap surface only handles geometry + identity; filtering
68641
- * behaviour (per-class, include/exclude, threshold) lives in the
68642
- * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
68643
- * `capabilities/schemas/zone-rule.js`.
68644
- */
68645
- var zonesCapability = {
68646
- name: "zones",
68647
- scope: "device",
68648
- mode: "singleton",
68649
- deviceTypes: [DeviceType.Camera],
68650
- methods: {
68651
- listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
68652
- addZone: method(object({
68653
- deviceId: number(),
68654
- zone: ZoneSchema
68655
- }), _void(), {
68656
- kind: "mutation",
68657
- auth: "admin"
68658
- }),
68659
- removeZone: method(object({
68660
- deviceId: number(),
68661
- zoneId: string()
68662
- }), _void(), {
68663
- kind: "mutation",
68664
- auth: "admin"
68665
- }),
68666
- updateZone: method(object({
68667
- deviceId: number(),
68668
- zone: ZoneSchema
68669
- }), _void(), {
68670
- kind: "mutation",
68671
- auth: "admin"
68672
- })
68673
- },
68674
- /**
68675
- * Runtime-state slice — the live zone catalogue mirrored by the
68676
- * orchestrator on every CRUD mutation. Consumers read via
68677
- * `device.state.zones.value` / `.watch(...)` without round-tripping
68678
- * the cap, and the codegen DeviceProxy auto-wires the reactive
68679
- * handle. Slice shape is `{ zones: Zone[] }` so future extensions
68680
- * (e.g. zone groupings) can sit alongside the polygon list.
68681
- */
68682
- runtimeState: object({ zones: array(ZoneSchema).readonly() }),
68683
- /**
68684
- * Runtime-state durability: **restored** — written only on operator mutation, so a camera that never had one has nothing to re-derive from. This is the slice `zone-mirror-hydration.ts` exists to paper over.
68685
- *
68686
- * See `RuntimeStateDurability`. Enforced by
68687
- * `scripts/check-runtime-state-durability.ts`.
68688
- */
68689
- durability: "restored"
68690
- };
68887
+ var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
68691
68888
  /**
68692
68889
  * A bounding box in NORMALIZED [0,1] frame coordinates for `getNativeCrop`. The
68693
68890
  * decode worker resolves it against the RETAINED native frame's real pixel dims,
@@ -70376,7 +70573,7 @@ method(object({
70376
70573
  * linking rather than produce an eternal token.
70377
70574
  */
70378
70575
  ttlSec: union([number().int().positive(), literal("never")]).optional()
70379
- }), object({ token: string() })), method(object({ token: string() }), SsoBridgeClaimsSchema.nullable());
70576
+ }), object({ token: string() }), { auth: "admin" }), method(object({ token: string() }), SsoBridgeClaimsSchema.nullable(), { auth: "admin" });
70380
70577
  var ProviderListEntrySchema = discriminatedUnion("shouldSaveDiskSpace", [object({
70381
70578
  providerId: string().min(1),
70382
70579
  displayName: string().min(1),
@@ -70471,10 +70668,13 @@ var EvictResultSchema = object({
70471
70668
  /** True when the provider has nothing left it is willing to drop on this location. */
70472
70669
  exhausted: boolean()
70473
70670
  });
70474
- method(object({ locationId: string() }), EvictableUsageSchema), method(object({
70671
+ method(object({ locationId: string() }), EvictableUsageSchema, { auth: "admin" }), method(object({
70475
70672
  locationId: string(),
70476
70673
  targetBytes: number().int().positive()
70477
- }), EvictResultSchema, { kind: "mutation" });
70674
+ }), EvictResultSchema, {
70675
+ kind: "mutation",
70676
+ auth: "admin"
70677
+ });
70478
70678
  method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin" }), method(StorageMigrationInputSchema, object({ jobId: string() }), {
70479
70679
  kind: "mutation",
70480
70680
  auth: "admin"
@@ -70534,26 +70734,50 @@ var ReadChunkInputSchema = object({
70534
70734
  length: number()
70535
70735
  });
70536
70736
  var EndDownloadInputSchema = object({ downloadId: string() });
70537
- method(_void(), ProviderInfoSchema), method(object({ config: record(string(), unknown()) }), TestLocationResultSchema, { auth: "admin" }), method(object({
70737
+ method(_void(), ProviderInfoSchema, { auth: "admin" }), method(object({ config: record(string(), unknown()) }), TestLocationResultSchema, { auth: "admin" }), method(object({
70538
70738
  location: StorageLocationSchema,
70539
70739
  relativePath: string()
70540
- }), string()), method(object({
70740
+ }), string(), { auth: "admin" }), method(object({
70541
70741
  location: StorageLocationSchema,
70542
70742
  relativePath: string(),
70543
70743
  data: _instanceof(Uint8Array)
70544
- }), _void(), { kind: "mutation" }), method(object({
70744
+ }), _void(), {
70745
+ kind: "mutation",
70746
+ auth: "admin"
70747
+ }), method(object({
70545
70748
  location: StorageLocationSchema,
70546
70749
  relativePath: string()
70547
- }), _instanceof(Uint8Array)), method(object({
70750
+ }), _instanceof(Uint8Array), { auth: "admin" }), method(object({
70548
70751
  location: StorageLocationSchema,
70549
70752
  relativePath: string()
70550
- }), boolean()), method(object({
70753
+ }), boolean(), { auth: "admin" }), method(object({
70551
70754
  location: StorageLocationSchema,
70552
70755
  prefix: string().optional()
70553
- }), array(string()).readonly()), method(object({
70756
+ }), array(string()).readonly(), { auth: "admin" }), method(object({
70554
70757
  location: StorageLocationSchema,
70555
70758
  relativePath: string()
70556
- }), _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" });
70759
+ }), _void(), {
70760
+ kind: "mutation",
70761
+ auth: "admin"
70762
+ }), method(object({ location: StorageLocationSchema }), number().nullable(), { auth: "admin" }), method(BeginUploadInputSchema, BeginUploadResultSchema, {
70763
+ kind: "mutation",
70764
+ auth: "admin"
70765
+ }), method(WriteChunkInputSchema, _void(), {
70766
+ kind: "mutation",
70767
+ auth: "admin"
70768
+ }), method(FinalizeUploadInputSchema, _void(), {
70769
+ kind: "mutation",
70770
+ auth: "admin"
70771
+ }), method(AbortUploadInputSchema, _void(), {
70772
+ kind: "mutation",
70773
+ auth: "admin"
70774
+ }), method(BeginDownloadInputSchema, BeginDownloadResultSchema, {
70775
+ kind: "mutation",
70776
+ auth: "admin"
70777
+ }), method(ReadChunkInputSchema, _instanceof(Uint8Array), { auth: "admin" }), method(EndDownloadInputSchema, _void(), {
70778
+ kind: "mutation",
70779
+ auth: "admin"
70780
+ });
70557
70781
  /** Profile-exported FormBuilder schema. Shape is ConfigUISchema at the UI. */
70558
70782
  var ProfileSettingsSchemaBridge = unknown().nullable();
70559
70783
  var ProfileSettingsBagSchema = record(string(), unknown());
@@ -70811,7 +71035,8 @@ method(object({
70811
71035
  access: "create"
70812
71036
  }), method(object({ userId: string().optional() }), object({ optionsJSON: record(string(), unknown()) }), {
70813
71037
  kind: "mutation",
70814
- access: "view"
71038
+ access: "view",
71039
+ auth: "admin"
70815
71040
  }), method(object({
70816
71041
  /** Required — the user the assertion belongs to (verified). */
70817
71042
  userId: string(),
@@ -70819,10 +71044,12 @@ method(object({
70819
71044
  response: record(string(), unknown())
70820
71045
  }), object({ verified: boolean() }), {
70821
71046
  kind: "mutation",
70822
- access: "view"
71047
+ access: "view",
71048
+ auth: "admin"
70823
71049
  }), method(object({}), object({ optionsJSON: record(string(), unknown()) }), {
70824
71050
  kind: "mutation",
70825
- access: "view"
71051
+ access: "view",
71052
+ auth: "admin"
70826
71053
  }), method(object({
70827
71054
  /** AuthenticationResponseJSON from the browser. */
70828
71055
  response: record(string(), unknown()) }), object({
@@ -70830,7 +71057,8 @@ response: record(string(), unknown()) }), object({
70830
71057
  userId: string().nullable()
70831
71058
  }), {
70832
71059
  kind: "mutation",
70833
- access: "view"
71060
+ access: "view",
71061
+ auth: "admin"
70834
71062
  }), method(object({ userId: string() }), array(PasskeySummarySchema), { auth: "admin" }), method(object({
70835
71063
  userId: string(),
70836
71064
  credentialId: string()
@@ -71002,7 +71230,19 @@ var VectorStatsResultSchema = object({
71002
71230
  /** False when the backend ranks approximately. */
71003
71231
  exact: boolean()
71004
71232
  });
71005
- 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);
71233
+ method(VectorDeclareIndexInputSchema, _void(), {
71234
+ kind: "mutation",
71235
+ auth: "admin"
71236
+ }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
71237
+ kind: "mutation",
71238
+ auth: "admin"
71239
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
71240
+ kind: "mutation",
71241
+ auth: "admin"
71242
+ }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
71243
+ kind: "mutation",
71244
+ auth: "admin"
71245
+ }), method(VectorStatsInputSchema, VectorStatsResultSchema, { auth: "admin" });
71006
71246
  var ClipSchema = object({
71007
71247
  /** Opaque, provider-namespaced id. The default provider encodes the time
71008
71248
  * window so `getClipPlayback` is self-contained (no event re-query). */
@@ -73480,7 +73720,27 @@ var MediaFileLiteSchema$1 = object({
73480
73720
  sizeBytes: number(),
73481
73721
  timestamp: number()
73482
73722
  });
73483
- method(_void(), array(IdentitySchema).readonly()), method(object({ name: string().min(1) }), IdentitySchema, {
73723
+ method(object({
73724
+ /**
73725
+ * Inline {@link IdentitySchema.coverBase64} on every row.
73726
+ *
73727
+ * Default `false`, the same inversion `listRecentFaces` and
73728
+ * `listPlates` took on 2026-08-25 (see `include-crops-default.ts` for
73729
+ * why the burden belongs on the caller that WANTS the bytes). Measured
73730
+ * on the live hub the same day: four identities cost 40,979 B with the
73731
+ * covers inline, ~10 KB of base64 per row, on a query this UI mounts
73732
+ * four times and the viewer holds at `staleTime: 30_000`.
73733
+ *
73734
+ * Nothing loses its avatar: `coverMediaKey` is already on every row and
73735
+ * the `event-media` plane serves that key `immutable` with an ETag.
73736
+ *
73737
+ * **This is an INPUT field, so it does not reach the addon until the
73738
+ * next train** — the hub router validates cap inputs against its own
73739
+ * compiled Zod and strips a key it does not know. Until then the
73740
+ * provider sees `undefined`, which resolves to `false`: the cheap shape
73741
+ * is what ships, and the opt-in becomes reachable when the train lands.
73742
+ */
73743
+ includeCrops: boolean().optional() }).optional(), array(IdentitySchema).readonly()), method(object({ name: string().min(1) }), IdentitySchema, {
73484
73744
  kind: "mutation",
73485
73745
  auth: "admin"
73486
73746
  }), method(object({
@@ -76370,8 +76630,10 @@ var PlateInfoSchema = object({
76370
76630
  keyFrameMediaKey: string().optional(),
76371
76631
  base64: string().optional(),
76372
76632
  /**
76373
- * Same crop as a data-plane URL. `getPlateByTrack` returns this and
76374
- * never inlines JPEG; `listPlates` still inlines for the admin-ui.
76633
+ * Same crop as a data-plane URL, always present when the plate has a stored
76634
+ * crop. `getPlateByTrack` returns this and never inlines JPEG; `listPlates`
76635
+ * and `searchPlates` inline the crop only when their `includeCrops` input is
76636
+ * left at its `true` default.
76375
76637
  */
76376
76638
  cropUrl: string().optional()
76377
76639
  });
@@ -76391,14 +76653,34 @@ var PlateClusterSchema = object({
76391
76653
  });
76392
76654
  method(object({
76393
76655
  deviceId: number().int().optional(),
76394
- limit: number().int().positive().optional()
76656
+ limit: number().int().positive().optional(),
76657
+ /**
76658
+ * Inline the base64 crop on every row. Default `true` — the existing
76659
+ * behaviour, kept so no caller breaks.
76660
+ *
76661
+ * Set `false` once the caller renders {@link PlateInfo.cropUrl}.
76662
+ * Measured on the live hub at the 500 rows the Plates view asks for:
76663
+ * 879,403 B and 27.7 s with the crops inline, against a few KiB of
76664
+ * metadata without them — and the browser then caches the images.
76665
+ *
76666
+ * This is the plate twin of `faceGallery.listRecentFaces`'s option;
76667
+ * plates were the one gallery list left without it.
76668
+ *
76669
+ * **This is an INPUT field, so it does not reach the addon until the
76670
+ * next train.** The hub router validates cap inputs against its own
76671
+ * compiled Zod and strips a key it does not know. Until the train
76672
+ * ships, sending `false` is harmless and keeps the crops inline.
76673
+ */
76674
+ includeCrops: boolean().optional()
76395
76675
  }).optional(), array(PlateInfoSchema).readonly()), method(object({
76396
76676
  deviceId: number().int(),
76397
76677
  trackId: string()
76398
76678
  }), PlateInfoSchema.nullable()), method(object({ plateId: string() }), array(MediaFileLiteSchema).readonly()), method(object({
76399
76679
  text: string().min(1),
76400
76680
  maxDistance: number().int().min(0).optional(),
76401
- limit: number().int().positive().optional()
76681
+ limit: number().int().positive().optional(),
76682
+ /** See `listPlates.includeCrops`. Default `true`. */
76683
+ includeCrops: boolean().optional()
76402
76684
  }), array(PlateInfoSchema).readonly()), method(object({
76403
76685
  maxDistance: number().int().min(0).optional(),
76404
76686
  minClusterSize: number().int().min(2).optional(),
@@ -76412,7 +76694,13 @@ method(object({
76412
76694
  }), method(object({ plateId: string() }), _void(), {
76413
76695
  kind: "mutation",
76414
76696
  auth: "admin"
76415
- }), method(_void(), array(VehicleSchema).readonly()), method(object({ name: string().min(1) }), VehicleSchema, {
76697
+ }), method(object({
76698
+ /** Inline {@link VehicleSchema.coverBase64} on every row. Default
76699
+ * `false` — the vehicle twin of `faceGallery.listIdentities`'s
76700
+ * option; `coverMediaKey` + the `event-media` plane carry the picture.
76701
+ * INPUT field: stripped by the hub router until the train ships, which
76702
+ * resolves to `false` and is exactly the intended default. */
76703
+ includeCrops: boolean().optional() }).optional(), array(VehicleSchema).readonly()), method(object({ name: string().min(1) }), VehicleSchema, {
76416
76704
  kind: "mutation",
76417
76705
  auth: "admin"
76418
76706
  }), method(object({
@@ -77933,92 +78221,6 @@ var sceneMonitorCapability = {
77933
78221
  durability: "session"
77934
78222
  };
77935
78223
  /**
77936
- * Per-stage gating mode applied to the zones a rule references.
77937
- *
77938
- * - `include`: the rule contributes to a **whitelist** for its stage.
77939
- * When at least one `include` rule fires for a stage, only entities
77940
- * inside one of those zones pass that stage.
77941
- * - `exclude`: the rule contributes to a **blacklist** for its stage.
77942
- * Entities inside one of those zones are dropped at that stage.
77943
- *
77944
- * `monitor`-style observation (count without filtering) is not a rule
77945
- * mode — zones without any matching rule are observed naturally by
77946
- * `zone-analytics` (live snapshot + history), so an "I just want to
77947
- * count, not filter" use case needs no rule at all.
77948
- */
77949
- var ZoneRuleModeEnum = _enum(["include", "exclude"]);
77950
- /**
77951
- * Per-consumer rule that references existing zones (geometry) and
77952
- * defines how a specific pipeline stage should treat them. Each
77953
- * consumer addon owns its own `ZoneRule[]` array in its per-device
77954
- * settings:
77955
- *
77956
- * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
77957
- * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
77958
- * - future: notification rules, audio gating, etc.
77959
- *
77960
- * One rule applies to N zones (`zoneIds[]`) so the operator can
77961
- * express "ignore motion in ALL of {garden, street}" with a single
77962
- * rule. `classFilter` narrows the rule to specific object classes —
77963
- * "drop person detections in the street, but keep cars" is one
77964
- * `exclude` rule with `classFilter: ['person']`.
77965
- *
77966
- * `enabled` is a soft toggle — the operator can keep the rule
77967
- * configured but inert without deleting it.
77968
- */
77969
- var ZoneRuleSchema = object({
77970
- /** Stable rule id — survives edits, used by the UI for diffing. */
77971
- id: string(),
77972
- /** Optional human-readable label rendered in the rule editor. */
77973
- name: string().optional(),
77974
- /** Zones this rule targets. The rule's `mode` applies to ALL
77975
- * listed zones (OR-set: a detection in any one of them counts).
77976
- * At least one zone id required — a rule with no targets is a
77977
- * configuration mistake and the form validator rejects it. */
77978
- zoneIds: array(string()).min(1).readonly(),
77979
- mode: ZoneRuleModeEnum,
77980
- /**
77981
- * Class names this rule applies to. Empty / undefined ⇒ rule
77982
- * applies to every class. Class strings match the `macroClass`
77983
- * field on detections (e.g. `person`, `car`, `dog`).
77984
- */
77985
- classFilter: array(string()).readonly().optional(),
77986
- /**
77987
- * Minimum bbox/mask overlap (0–1) with any of the rule's zones
77988
- * required to consider an entity "in the zone". Defaults to the
77989
- * consumer's stage default when omitted. Kept for back-compat with
77990
- * existing per-rule overrides; new operators pick the value via
77991
- * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
77992
- * set, the lower-level engine reads it as a 0–1 fraction.
77993
- */
77994
- overlapThreshold: number().min(0).max(1).optional(),
77995
- /**
77996
- * Operator-friendly version of `overlapThreshold` — the percentage
77997
- * of the detection's bbox that must lie inside the zone for the
77998
- * rule to match. Documented default is 85%; the engine substitutes
77999
- * that when the field is omitted (kept optional so existing rules
78000
- * stored without it stay valid).
78001
- *
78002
- * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
78003
- * rule, the engine prefers `bboxInclusionPct` because it's the
78004
- * field exposed in the UI. Internally both feed the same gate.
78005
- */
78006
- bboxInclusionPct: number().min(0).max(100).optional(),
78007
- /**
78008
- * When `true` and a detection has a segmentation mask, use the
78009
- * mask for overlap instead of the bbox. Detection-stage only;
78010
- * motion rules ignore this field.
78011
- */
78012
- preferMask: boolean().optional(),
78013
- /**
78014
- * Soft-toggle: `false` disables the rule without deleting it.
78015
- * Defaults to `true` so operators creating a rule via the UI
78016
- * see it active immediately.
78017
- */
78018
- enabled: boolean().default(true)
78019
- });
78020
- array(ZoneRuleSchema).readonly();
78021
- /**
78022
78224
  * Script-runner cap. Models HA `script.*` entities on
78023
78225
  * `DeviceType.Script`. A Script is a pre-recorded action sequence
78024
78226
  * that can be invoked imperatively — optionally with a variables
@@ -83673,6 +83875,12 @@ Object.freeze({
83673
83875
  addonId: null,
83674
83876
  access: "create"
83675
83877
  },
83878
+ "pipelineAnalytics.cancelRelocateMedia": {
83879
+ capName: "pipeline-analytics",
83880
+ capScope: "device",
83881
+ addonId: null,
83882
+ access: "create"
83883
+ },
83676
83884
  "pipelineAnalytics.cancelStorageMigrationMove": {
83677
83885
  capName: "pipeline-analytics",
83678
83886
  capScope: "device",
@@ -83847,6 +84055,12 @@ Object.freeze({
83847
84055
  addonId: null,
83848
84056
  access: "view"
83849
84057
  },
84058
+ "pipelineAnalytics.listRelocateMediaJobs": {
84059
+ capName: "pipeline-analytics",
84060
+ capScope: "device",
84061
+ addonId: null,
84062
+ access: "view"
84063
+ },
83850
84064
  "pipelineAnalytics.listRetrainAnnotations": {
83851
84065
  capName: "pipeline-analytics",
83852
84066
  capScope: "device",
@@ -83925,6 +84139,12 @@ Object.freeze({
83925
84139
  addonId: null,
83926
84140
  access: "create"
83927
84141
  },
84142
+ "pipelineAnalytics.relocateMedia": {
84143
+ capName: "pipeline-analytics",
84144
+ capScope: "device",
84145
+ addonId: null,
84146
+ access: "create"
84147
+ },
83928
84148
  "pipelineAnalytics.restageRetrainTrack": {
83929
84149
  capName: "pipeline-analytics",
83930
84150
  capScope: "device",
@@ -83937,6 +84157,12 @@ Object.freeze({
83937
84157
  addonId: null,
83938
84158
  access: "create"
83939
84159
  },
84160
+ "pipelineAnalytics.runReplayFrameProcessor": {
84161
+ capName: "pipeline-analytics",
84162
+ capScope: "device",
84163
+ addonId: null,
84164
+ access: "create"
84165
+ },
83940
84166
  "pipelineAnalytics.saveRetrainAnnotations": {
83941
84167
  capName: "pipeline-analytics",
83942
84168
  capScope: "device",
@@ -84069,6 +84295,12 @@ Object.freeze({
84069
84295
  addonId: null,
84070
84296
  access: "view"
84071
84297
  },
84298
+ "pipelineExecutor.getInferenceDeviceHealth": {
84299
+ capName: "pipeline-executor",
84300
+ capScope: "system",
84301
+ addonId: null,
84302
+ access: "view"
84303
+ },
84072
84304
  "pipelineExecutor.getOrchestratorConfigSchema": {
84073
84305
  capName: "pipeline-executor",
84074
84306
  capScope: "system",
@@ -84141,6 +84373,12 @@ Object.freeze({
84141
84373
  addonId: null,
84142
84374
  access: "view"
84143
84375
  },
84376
+ "pipelineExecutor.rearmInferenceDevice": {
84377
+ capName: "pipeline-executor",
84378
+ capScope: "system",
84379
+ addonId: null,
84380
+ access: "create"
84381
+ },
84144
84382
  "pipelineExecutor.runAudioTest": {
84145
84383
  capName: "pipeline-executor",
84146
84384
  capScope: "system",
@@ -87389,6 +87627,11 @@ Object.freeze({
87389
87627
  form: "single",
87390
87628
  optional: false
87391
87629
  }],
87630
+ "pipelineAnalytics.runReplayFrameProcessor": [{
87631
+ name: "deviceId",
87632
+ form: "single",
87633
+ optional: false
87634
+ }],
87392
87635
  "pipelineAnalytics.saveRetrainAnnotations": [{
87393
87636
  name: "deviceId",
87394
87637
  form: "single",