@camstack/addon-import-alexa 0.2.27 → 0.2.29

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 +2136 -1893
  2. package/dist/addon.mjs +2136 -1893
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -6669,7 +6669,7 @@ function method(input, output, options) {
6669
6669
  input,
6670
6670
  output,
6671
6671
  kind: options?.kind ?? "query",
6672
- auth: options?.auth ?? "protected",
6672
+ ...options?.auth !== void 0 ? { auth: options.auth } : {},
6673
6673
  ...options?.access !== void 0 ? { access: options.access } : {},
6674
6674
  ...options?.caller !== void 0 ? { caller: options.caller } : {},
6675
6675
  timeoutMs: options?.timeoutMs
@@ -6693,7 +6693,7 @@ function event(data) {
6693
6693
  }
6694
6694
  var StaticDirOutputSchema$1 = object({ staticDir: string() });
6695
6695
  var VersionOutputSchema$1 = object({ version: string() });
6696
- method(_void(), StaticDirOutputSchema$1), method(_void(), VersionOutputSchema$1);
6696
+ method(_void(), StaticDirOutputSchema$1, { auth: "admin" }), method(_void(), VersionOutputSchema$1, { auth: "admin" });
6697
6697
  var DeviceType = /* @__PURE__ */ function(DeviceType) {
6698
6698
  DeviceType["Camera"] = "camera";
6699
6699
  DeviceType["Hub"] = "hub";
@@ -7014,7 +7014,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
7014
7014
  }({});
7015
7015
  var StaticDirOutputSchema = object({ staticDir: string() });
7016
7016
  var VersionOutputSchema = object({ version: string() });
7017
- method(_void(), StaticDirOutputSchema), method(_void(), VersionOutputSchema);
7017
+ method(_void(), StaticDirOutputSchema, { auth: "admin" }), method(_void(), VersionOutputSchema, { auth: "admin" });
7018
7018
  /**
7019
7019
  * device-ops — device-scoped cap that unifies the per-IDevice operations
7020
7020
  * previously routed through the `.device-ops` Moleculer bridge service.
@@ -7759,24 +7759,6 @@ var RecordingRetentionSchema = object({
7759
7759
  maxSizeGb: number().min(0).optional()
7760
7760
  });
7761
7761
  /**
7762
- * Scrub-thumbnail fidelity preset — the single per-camera selector bundling the
7763
- * sprite tile RESOLUTION + JPEG QUALITY the recorder packs timeline-scrub
7764
- * previews at. Five graduated steps; absent on a config = `standard` (the
7765
- * shipped default, matching `sheet-geometry`/`sheet-composer`).
7766
- *
7767
- * Existing sheets are IMMUTABLE — a changed preset applies to NEW windows only.
7768
- * Each window's index sidecar carries its own tile dims, so a camera whose
7769
- * preset changed over time renders every historical window at the dims it was
7770
- * written with.
7771
- */
7772
- var ScrubThumbnailPresetSchema = _enum([
7773
- "minimal",
7774
- "low",
7775
- "standard",
7776
- "high",
7777
- "max"
7778
- ]);
7779
- /**
7780
7762
  * The full per-camera recording intent — the wire shape of a RecordingTarget.
7781
7763
  *
7782
7764
  * `bands` is the ONLY authored recording intent: what to record, when, and on
@@ -7784,7 +7766,11 @@ var ScrubThumbnailPresetSchema = _enum([
7784
7766
  * other field is a storage knob (profiles, segment length, retention, scrub).
7785
7767
  *
7786
7768
  * STRICT on purpose: the legacy authoring surface (`schedule`/`schedules`/
7787
- * `triggers`/`preBufferSec`/`postBufferSec`/`rules`) was retired 2026-07-30.
7769
+ * `triggers`/`preBufferSec`/`postBufferSec`/`rules`) was retired 2026-07-30,
7770
+ * and `scrubThumbnails` — a five-step fidelity knob for a sprite tier that was
7771
+ * deleted on 2026-07-24 and had ZERO consumers in the recorder — on 2026-08-25
7772
+ * (D62: a switch that writes a store nobody reads is worse than no switch).
7773
+ * Stored rows keep loading: the READ schema is `.strip()` (config-store.ts).
7788
7774
  * A stale caller must fail loudly — silently stripping its legacy intent would
7789
7775
  * persist a band-less config, i.e. silently stop recording the camera.
7790
7776
  */
@@ -7807,14 +7793,7 @@ var RecordingConfigSchema = object({
7807
7793
  * "off" is the absence of a covering band, never a band value.
7808
7794
  */
7809
7795
  bands: array(RecordingBandSchema).default([]),
7810
- retention: RecordingRetentionSchema.optional(),
7811
- /**
7812
- * Per-camera scrub-thumbnail fidelity preset (resolution + JPEG quality for
7813
- * timeline-scrub sprite previews). Absent = `standard`. Applies to NEW
7814
- * windows only — existing sheets are immutable, and each window's index
7815
- * carries its own tile dims so mixed-preset history renders correctly.
7816
- */
7817
- scrubThumbnails: ScrubThumbnailPresetSchema.optional()
7796
+ retention: RecordingRetentionSchema.optional()
7818
7797
  }).strict();
7819
7798
  /**
7820
7799
  * Entity-relocation job state (storage entity-routing spec, Phase 4).
@@ -7890,10 +7869,11 @@ var RelocateFootageInputSchema = object({
7890
7869
  * `RecordingConfig.enabled` or camera wrapper bindings. */
7891
7870
  var StorageMigrationLeaseInputSchema = object({ leaseId: string().min(1) });
7892
7871
  var StorageMigrationFootageMoveInputSchema = RelocateFootageInputSchema.extend({ leaseId: string().min(1) });
7893
- var StorageMigrationMediaMoveInputSchema = object({
7872
+ var RelocateMediaInputSchema = object({
7894
7873
  toLocationId: string(),
7895
7874
  throttleMbps: number().min(1).max(1e3).optional()
7896
- }).extend({ leaseId: string().min(1) });
7875
+ });
7876
+ var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
7897
7877
  /** The independently selectable logical storage classes. `recordings`
7898
7878
  * encompasses the high and mid segment profiles; `recordingsLow` is low
7899
7879
  * segments; `eventMedia` is post-analysis blobs. */
@@ -8188,7 +8168,26 @@ var LabelDefinitionSchema = object({
8188
8168
  description: string().optional(),
8189
8169
  icon: string().optional()
8190
8170
  });
8191
- var ClassMapDefinitionSchema = object({
8171
+ /**
8172
+ * Wire schema for a per-model CATALOG classMap override
8173
+ * (`ModelCatalogEntry.classMap` / `ModelConvertMetadata.classMap`) —
8174
+ * restricted to {@link CLASS_MAP_MACRO_TARGETS}, the only macros the
8175
+ * detection pipeline executor actually routes.
8176
+ *
8177
+ * This is deliberately a DIFFERENT, narrower shape than the general-purpose
8178
+ * `ClassMapDefinition` interface above (e.g. `IDetectionAddon.getClassMap()`
8179
+ * and the audio `YAMNET_TO_MACRO` catalog both use macro targets outside this
8180
+ * enum) — the two used to share the name `ClassMapDefinition`/
8181
+ * `ClassMapDefinitionSchema`, which made the schema-type-twin guard
8182
+ * (`scripts/check-schema-type-twins.ts`) flag them as a duplicated shape. They
8183
+ * are not: it is two different concepts colliding on a name. Keep this type
8184
+ * under its own name rather than reusing `ClassMapDefinition` — reusing it
8185
+ * would either narrow every `ClassMapDefinition` consumer to the four
8186
+ * detection macros (breaking `YAMNET_TO_MACRO`) or drop the validation this
8187
+ * schema exists for (see the "rejects a classMap whose target is not a
8188
+ * detection macro" test in `model-catalog-schema.test.ts`).
8189
+ */
8190
+ var DetectionCatalogClassMapSchema = object({
8192
8191
  mapping: record(string(), _enum([
8193
8192
  "person",
8194
8193
  "vehicle",
@@ -8393,7 +8392,7 @@ var ModelCatalogEntrySchema = object({
8393
8392
  * applies (Frigate / COCO public catalog). Set on a custom model whose raw
8394
8393
  * labels already ARE the CamStack macros (Scrypted identity map).
8395
8394
  */
8396
- classMap: ClassMapDefinitionSchema.optional()
8395
+ classMap: DetectionCatalogClassMapSchema.optional()
8397
8396
  });
8398
8397
  var ConvertTargetSchema = discriminatedUnion("format", [object({
8399
8398
  format: literal("openvino"),
@@ -8423,7 +8422,7 @@ var ModelConvertMetadataSchema = object({
8423
8422
  "segmentation"
8424
8423
  ]),
8425
8424
  faceAlignment: boolean().optional(),
8426
- classMap: ClassMapDefinitionSchema.optional()
8425
+ classMap: DetectionCatalogClassMapSchema.optional()
8427
8426
  });
8428
8427
  var ConvertResultSchema = object({
8429
8428
  entry: ModelCatalogEntrySchema,
@@ -9286,7 +9285,7 @@ var AddonPageDeclarationSchema = object({
9286
9285
  /** Display label for a CUSTOM `section` id (ignored for well-known ids). */
9287
9286
  sectionLabel: string().optional()
9288
9287
  });
9289
- method(_void(), array(AddonPageDeclarationSchema).readonly());
9288
+ method(_void(), array(AddonPageDeclarationSchema).readonly(), { auth: "admin" });
9290
9289
  var AddonHttpRouteSchema = object({
9291
9290
  method: _enum([
9292
9291
  "GET",
@@ -9540,7 +9539,7 @@ var WidgetMetadataSchema = object({
9540
9539
  defaultColumns: number().int().min(1).max(12).default(6),
9541
9540
  defaultRows: number().int().min(1).max(12).default(1)
9542
9541
  });
9543
- method(_void(), array(WidgetMetadataSchema).readonly());
9542
+ method(_void(), array(WidgetMetadataSchema).readonly(), { auth: "admin" });
9544
9543
  /**
9545
9544
  * `addon-widgets` — system-scoped singleton aggregator cap. Public-facing
9546
9545
  * surface that admin-ui consumes through `useAddonWidgetsListWidgets()`.
@@ -11213,7 +11212,7 @@ var CustomModelDescriptorSchema = object({
11213
11212
  stepId: string(),
11214
11213
  entry: ModelCatalogEntrySchema
11215
11214
  });
11216
- method(_void(), array(CustomModelDescriptorSchema).readonly());
11215
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
11217
11216
  /**
11218
11217
  * Query filter for settings-store collections.
11219
11218
  */
@@ -11300,7 +11299,8 @@ method(object({
11300
11299
  }), _void(), { kind: "mutation" }), method(object({
11301
11300
  namespace: string().optional(),
11302
11301
  collection: string(),
11303
- filter: QueryFilterSchema.optional()
11302
+ filter: QueryFilterSchema.optional(),
11303
+ columns: array(string()).readonly().optional()
11304
11304
  }), array(SettingsRecordSchema).readonly()), method(object({
11305
11305
  namespace: string().optional(),
11306
11306
  collection: string(),
@@ -11363,46 +11363,87 @@ var EngineInfoSchema = object({
11363
11363
  kind: _enum(["relational", "vector"]),
11364
11364
  displayName: string()
11365
11365
  });
11366
- method(_void(), EngineInfoSchema), method(object({
11366
+ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
11367
11367
  namespace: string().optional(),
11368
11368
  collection: string(),
11369
11369
  key: string()
11370
- }), unknown()), method(object({
11370
+ }), unknown(), { auth: "admin" }), method(object({
11371
11371
  namespace: string().optional(),
11372
11372
  collection: string(),
11373
11373
  key: string(),
11374
11374
  value: unknown()
11375
- }), _void(), { kind: "mutation" }), method(object({
11375
+ }), _void(), {
11376
+ kind: "mutation",
11377
+ auth: "admin"
11378
+ }), method(object({
11376
11379
  namespace: string().optional(),
11377
11380
  collection: string(),
11378
- filter: QueryFilterSchema.optional()
11379
- }), array(SettingsRecordSchema).readonly()), method(object({
11381
+ filter: QueryFilterSchema.optional(),
11382
+ /**
11383
+ * SQL-level column projection — MUST mirror `settings-store.query`.
11384
+ *
11385
+ * ⚠ An earlier version of this comment blamed Zod stripping, and that
11386
+ * was wrong — corrected 2026-08-26 after the hop map
11387
+ * (`docs/design/2026-08-26-mappa-hop-argomenti.md`) traced the path.
11388
+ * There is **no Zod parse at all** between the door and the engine: the
11389
+ * dispatcher forwards the payload verbatim and UDS carries it whole. A
11390
+ * field declared here reaches `SqliteSettingsBackend` either way.
11391
+ *
11392
+ * What actually lost `columns` was the THIRD declaration of this shape:
11393
+ * `SettingsQueryInput` in `interfaces/storage.ts`, a hand-written TS
11394
+ * interface the engine destructures from. The field existed on both
11395
+ * schemas and the engine still never read it, because nothing checks a
11396
+ * registered provider against `InferProvider<cap>` —
11397
+ * `ProviderRegistration.provider` is typed `object`.
11398
+ *
11399
+ * It is declared here anyway, and must stay in step with
11400
+ * `settings-store.query`: a caller reading only the cap definitions has
11401
+ * to be able to see that this call carries a projection.
11402
+ * `data-door-schema-parity.spec.ts` keeps the two aligned.
11403
+ */
11404
+ columns: array(string()).readonly().optional()
11405
+ }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
11380
11406
  namespace: string().optional(),
11381
11407
  collection: string(),
11382
11408
  record: SettingsRecordSchema
11383
- }), _void(), { kind: "mutation" }), method(object({
11409
+ }), _void(), {
11410
+ kind: "mutation",
11411
+ auth: "admin"
11412
+ }), method(object({
11384
11413
  namespace: string().optional(),
11385
11414
  collection: string(),
11386
11415
  id: string(),
11387
11416
  data: record(string(), unknown())
11388
- }), _void(), { kind: "mutation" }), method(object({
11417
+ }), _void(), {
11418
+ kind: "mutation",
11419
+ auth: "admin"
11420
+ }), method(object({
11389
11421
  namespace: string().optional(),
11390
11422
  collection: string(),
11391
11423
  key: string()
11392
- }), _void(), { kind: "mutation" }), method(object({
11424
+ }), _void(), {
11425
+ kind: "mutation",
11426
+ auth: "admin"
11427
+ }), method(object({
11393
11428
  namespace: string().optional(),
11394
11429
  collection: string(),
11395
11430
  filter: MutationFilterSchema
11396
- }), object({ deleted: number().int() }), { kind: "mutation" }), method(object({
11431
+ }), object({ deleted: number().int() }), {
11432
+ kind: "mutation",
11433
+ auth: "admin"
11434
+ }), method(object({
11397
11435
  namespace: string().optional(),
11398
11436
  collection: string(),
11399
11437
  filter: MutationFilterSchema,
11400
11438
  data: record(string(), unknown())
11401
- }), object({ updated: number().int() }), { kind: "mutation" }), method(object({
11439
+ }), object({ updated: number().int() }), {
11440
+ kind: "mutation",
11441
+ auth: "admin"
11442
+ }), method(object({
11402
11443
  namespace: string().optional(),
11403
11444
  collection: string(),
11404
11445
  filter: QueryFilterSchema.optional()
11405
- }), number()), method(object({
11446
+ }), number(), { auth: "admin" }), method(object({
11406
11447
  namespace: string().optional(),
11407
11448
  collection: string(),
11408
11449
  field: string(),
@@ -11412,15 +11453,18 @@ method(_void(), EngineInfoSchema), method(object({
11412
11453
  }), array(object({
11413
11454
  bucket: number().int(),
11414
11455
  count: number().int()
11415
- })).readonly()), method(object({
11456
+ })).readonly(), { auth: "admin" }), method(object({
11416
11457
  namespace: string().optional(),
11417
11458
  collection: string()
11418
- }), boolean()), method(object({
11459
+ }), boolean(), { auth: "admin" }), method(object({
11419
11460
  namespace: string().optional(),
11420
11461
  collection: string(),
11421
11462
  columns: array(CollectionColumnSchema).readonly(),
11422
11463
  indexes: array(CollectionIndexSchema).readonly().optional()
11423
- }), _void(), { kind: "mutation" });
11464
+ }), _void(), {
11465
+ kind: "mutation",
11466
+ auth: "admin"
11467
+ });
11424
11468
  /**
11425
11469
  * shm ring usage stats for a `frameSink: 'shm'` decoder session —
11426
11470
  * exposed via `decoder.getShmStats` so downstream consumers can
@@ -12727,7 +12771,7 @@ method(object({
12727
12771
  crop: _instanceof(Uint8Array),
12728
12772
  width: number(),
12729
12773
  height: number()
12730
- }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
12774
+ }), EmbeddingResultSchema, { auth: "admin" }), method(object({ text: string() }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" });
12731
12775
  /**
12732
12776
  * filesystem-browse — per-node capability for browsing the node's local
12733
12777
  * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
@@ -13020,19 +13064,22 @@ method(LlmGenerateBaseInputSchema.extend({
13020
13064
  runtime: ManagedRuntimeConfigSchema,
13021
13065
  /** The managed profile's timeout, threaded by the hub provider. */
13022
13066
  timeoutMs: number().int().positive().optional()
13023
- }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
13067
+ }), LlmGenerateResultSchema, {
13068
+ kind: "mutation",
13069
+ auth: "admin"
13070
+ }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
13024
13071
  kind: "mutation",
13025
13072
  auth: "admin"
13026
13073
  }), method(object({}), _void(), {
13027
13074
  kind: "mutation",
13028
13075
  auth: "admin"
13029
- }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
13076
+ }), method(object({}), LlmRuntimeStatusSchema, { auth: "admin" }), method(object({ model: ManagedModelRefSchema }), _void(), {
13030
13077
  kind: "mutation",
13031
13078
  auth: "admin"
13032
13079
  }), method(object({ file: string() }), _void(), {
13033
13080
  kind: "mutation",
13034
13081
  auth: "admin"
13035
- }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
13082
+ }), method(object({}), array(LlmNodeModelSchema), { auth: "admin" }), method(object({}), LlmRuntimeDiskUsageSchema, { auth: "admin" });
13036
13083
  /**
13037
13084
  * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
13038
13085
  * methods concat-fan across providers; single-row methods route to ONE
@@ -16543,1748 +16590,1998 @@ var OauthIntegrationDescriptorSchema = object({
16543
16590
  */
16544
16591
  refreshTokenTtlSec: union([number().int().positive(), literal("never")]).optional()
16545
16592
  });
16546
- method(_void(), OauthIntegrationDescriptorSchema);
16593
+ method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
16547
16594
  /**
16548
- * pipeline-analytics — device-scoped wrapper cap. Refines raw
16549
- * per-frame detections emitted by the pipeline runner into tracked
16550
- * objects, per-kind event collections (motion / object / audio), and
16551
- * persisted media. Owns the post-detection domain end-to-end:
16552
- *
16553
- * runner emits PipelineInferenceResult
16554
- * ↓ (event bus)
16555
- * pipeline-analytics subscriber
16556
- * ↓ SORT tracker + zone engine + state analyzer + event emitter
16557
- * → three DB collections (one per kind), one FS media tree, one
16558
- * unified event emitter (FrameTracked + TrackStarted/Ended +
16559
- * DetectionEvent on bus)
16560
- *
16561
- * Pure subscriber model. No `processFrame` cap method — the runner
16562
- * already publishes the raw frame on the bus. The cap surface is
16563
- * only QUERIES + per-device settings, bound on/off via
16564
- * `device-manager.setWrapperActive`. `defaultActive: true` because
16565
- * every camera with a detection pipeline wants its raw detections
16566
- * refined; operators opt out per-device via BindingsTab when needed.
16567
- *
16568
- * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
16569
- * (per-device surface) and `track-trail` caps — see P11 cleanup.
16595
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
16596
+ * within the frame, so the executor can re-cut a leaf child ROI at native
16597
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
16570
16598
  */
16571
- var TrackStateSchema = _enum([
16572
- "new",
16573
- "entered",
16574
- "left",
16575
- "moving",
16576
- "idle"
16577
- ]);
16578
- var EventKindSchema = _enum([
16579
- "motion",
16580
- "object",
16581
- "audio"
16582
- ]);
16599
+ var NativeCropRefSchema = object({
16600
+ /** Handle keying the retained native surface (node-pinned to its owner). */
16601
+ handle: FrameHandleSchema,
16602
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
16603
+ cropFrameSpace: object({
16604
+ x: number(),
16605
+ y: number(),
16606
+ w: number(),
16607
+ h: number()
16608
+ })
16609
+ });
16610
+ object({
16611
+ crop: object({
16612
+ left: number(),
16613
+ top: number(),
16614
+ width: number().positive(),
16615
+ height: number().positive()
16616
+ }).optional(),
16617
+ content: object({
16618
+ width: number().int().positive(),
16619
+ height: number().int().positive()
16620
+ }),
16621
+ fit: _enum(["stretch", "contain"]),
16622
+ format: _enum([
16623
+ "rgb",
16624
+ "gray",
16625
+ "jpeg"
16626
+ ])
16627
+ });
16583
16628
  /**
16584
- * Spatial filter for `listTracks` — the rect + polygon variants of the shared
16585
- * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
16586
- * of the camera frame (top-left origin), matching the drawing-plane editor.
16629
+ * Process-local frame identity. It is serializable so it can ride an in-process
16630
+ * capability call, but `registryId` deliberately prevents resolution in any
16631
+ * other process or execution group.
16587
16632
  */
16588
- var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
16589
- /** Closed icon vocabulary so clients render a known glyph per kind. */
16590
- var EventKindIconSchema = _enum([
16591
- "motion",
16592
- "audio",
16593
- "person",
16594
- "vehicle",
16595
- "animal",
16596
- "door",
16597
- "pir",
16598
- "smoke",
16599
- "water",
16600
- "button",
16601
- "package",
16602
- "generic"
16633
+ var FrameRefSchema = object({
16634
+ registryId: string().min(1),
16635
+ id: string().min(1),
16636
+ width: number().int().positive(),
16637
+ height: number().int().positive(),
16638
+ format: _enum(["rgb", "gray"]),
16639
+ timestamp: number(),
16640
+ capturedAt: number().optional()
16641
+ });
16642
+ var ModelFormatSchema$1 = _enum([
16643
+ "onnx",
16644
+ "coreml",
16645
+ "openvino",
16646
+ "tflite",
16647
+ "pt",
16648
+ "gguf"
16603
16649
  ]);
16604
- var EventKindCategorySchema = _enum([
16605
- "motion",
16606
- "audio",
16607
- "detection",
16608
- "sensor",
16609
- "control",
16610
- "custom",
16611
- "package"
16650
+ var PipelineSlotSchema = _enum([
16651
+ "detector",
16652
+ "cropper",
16653
+ "classifier",
16654
+ "refiner",
16655
+ "audio-classifier"
16612
16656
  ]);
16613
- /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
16614
- var EventKindLevelSchema = _enum(["macro", "sub"]);
16615
- var EventKindDescriptorSchema = object({
16616
- /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
16617
- kind: string(),
16618
- /** i18n key resolved on the UI side; `label` is the English fallback. */
16619
- labelKey: string(),
16620
- /** English fallback label (kept for clients that don't translate). */
16621
- label: string(),
16622
- /** Hex color for timeline/legend rendering. */
16623
- color: string(),
16624
- /** Dictionary id → lucide component on the UI side. */
16625
- iconId: string(),
16626
- /** Legacy closed-vocab glyph — fallback for `iconId`. */
16627
- icon: EventKindIconSchema,
16628
- category: EventKindCategorySchema,
16629
- /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
16630
- parentKind: string().nullable(),
16631
- /** Derived from `parentKind`, explicit for the client tree. */
16632
- level: EventKindLevelSchema,
16633
- /** Which cap + device contributes this kind. For built-ins the camera
16634
- * itself; for sensor kinds the LINKED source device. */
16635
- source: object({
16636
- capName: string(),
16637
- deviceId: number()
16638
- })
16657
+ var PipelineEngineChoiceSchema = object({
16658
+ runtime: _enum(["node", "python"]),
16659
+ backend: string(),
16660
+ format: ModelFormatSchema$1,
16661
+ device: string().optional()
16639
16662
  });
16640
- /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
16641
- var EventKindsForDeviceSchema = object({
16642
- deviceId: number(),
16643
- kinds: array(EventKindDescriptorSchema).readonly()
16663
+ var AvailableEngineSchema = object({
16664
+ engine: PipelineEngineChoiceSchema,
16665
+ devices: array(object({
16666
+ id: string(),
16667
+ label: string(),
16668
+ description: string().optional()
16669
+ })).readonly(),
16670
+ defaultDevice: string()
16644
16671
  });
16645
- var SensorEventSchema = object({
16672
+ var PipelineDefaultStepSchema = lazy(() => object({
16673
+ addonId: string(),
16674
+ addonName: string(),
16675
+ slot: PipelineSlotSchema,
16676
+ inputClasses: array(string()).readonly(),
16677
+ outputClasses: array(string()).readonly(),
16678
+ enabled: boolean(),
16679
+ modelId: string(),
16680
+ children: array(PipelineDefaultStepSchema).readonly(),
16681
+ group: string().optional(),
16682
+ settings: record(string(), unknown()).optional()
16683
+ }));
16684
+ var PipelineTemplateStepSchema = lazy(() => object({
16685
+ addonId: string(),
16686
+ enabled: boolean(),
16687
+ modelId: string(),
16688
+ children: array(PipelineTemplateStepSchema).readonly(),
16689
+ settings: record(string(), unknown()).optional()
16690
+ }));
16691
+ var PipelineTemplateSchema$1 = object({
16646
16692
  id: string(),
16647
- /** The CAMERA the event is attributed to (a sensor linked to N cameras
16648
- * yields N rows, one per camera). */
16649
- deviceId: number(),
16650
- /** The linked sensor device whose state changed. */
16651
- sourceDeviceId: number(),
16652
- /** Event kind id — matches an `EventKindDescriptor.kind`. */
16653
- kind: string(),
16654
- /** Snapshot of the sensor cap's runtime-state slice at the change. */
16655
- value: record(string(), unknown()).nullable(),
16656
- timestamp: number()
16657
- });
16658
- var TrackPositionSchema = object({
16659
- x: number(),
16660
- y: number(),
16661
- timestamp: number(),
16662
- bbox: BoundingBoxSchema
16693
+ name: string(),
16694
+ createdAt: string(),
16695
+ updatedAt: string(),
16696
+ engine: PipelineEngineChoiceSchema,
16697
+ steps: array(PipelineTemplateStepSchema).readonly()
16663
16698
  });
16664
- var TrackSnapshotSchema = object({
16665
- timestamp: number(),
16666
- position: TrackPositionSchema,
16667
- /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
16668
- mediaKey: string()
16699
+ var PipelineModelOptionSchema = object({
16700
+ id: string(),
16701
+ name: string(),
16702
+ formats: record(string(), object({
16703
+ downloaded: boolean(),
16704
+ sizeMB: number()
16705
+ })),
16706
+ group: ModelVariantGroupSchema.optional(),
16707
+ legacy: boolean().optional(),
16708
+ provider: ModelProviderIdSchema.optional()
16669
16709
  });
16670
- /**
16671
- * Normalized 0..1 trajectory envelope (min/max over every position bbox,
16672
- * divided by the track's detection-frame dims), computed at persist time.
16673
- * Absent when the frame dims were unknown when the track was persisted
16674
- * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
16675
- */
16676
- var TrackEnvelopeSchema = object({
16677
- minX: number(),
16678
- minY: number(),
16679
- maxX: number(),
16680
- maxY: number()
16710
+ var ConfigFieldBridge = custom();
16711
+ var PipelineAddonSchemaSchema = object({
16712
+ id: string(),
16713
+ name: string(),
16714
+ slot: PipelineSlotSchema,
16715
+ inputClasses: array(string()).readonly(),
16716
+ outputClasses: array(string()).readonly(),
16717
+ childSlots: array(PipelineSlotSchema).readonly(),
16718
+ models: array(PipelineModelOptionSchema).readonly(),
16719
+ defaultModelId: string(),
16720
+ defaultModelIdByFormat: record(string(), string()).optional(),
16721
+ enabledByDefault: boolean().optional(),
16722
+ backfillIntoExistingOverrides: boolean().optional(),
16723
+ defaultConfidence: number(),
16724
+ group: string().optional(),
16725
+ configSchema: array(ConfigFieldBridge).readonly().optional()
16681
16726
  });
16682
- /**
16683
- * Row projection for track list queries. `full` (default) returns the
16684
- * complete Track including the frame-rate `positions[]` history and the
16685
- * `snapshots[]` references — megabytes across a page of tracks. `slim`
16686
- * keeps every scalar the list surfaces actually render (ids, class(es),
16687
- * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
16688
- * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
16689
- * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
16690
- * `getTrack`. Mirrors the event-store `projection` convention
16691
- * (`getObjectEvents` et al.).
16692
- */
16693
- var TrackProjectionSchema = _enum(["full", "slim"]);
16694
- /**
16695
- * One audio-classification label heard on the track's camera while the
16696
- * track was alive, aggregated per label. An "episode" is one persisted
16697
- * audio event (the confident-classification path: score ≥ the device's
16698
- * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
16699
- * one 32 ms inference chunk, so counts stay human-scaled.
16700
- */
16701
- var TrackAudioLabelSchema = object({
16727
+ var PipelineSlotSchemaSchema = object({
16728
+ id: PipelineSlotSchema,
16702
16729
  label: string(),
16703
- /** Highest classification score observed across the label's episodes. */
16704
- peakScore: number(),
16705
- /** Number of coalesced audio-event episodes carrying this label. */
16706
- count: number(),
16707
- firstAt: number(),
16708
- lastAt: number()
16730
+ priority: number(),
16731
+ parentSlot: PipelineSlotSchema.nullable(),
16732
+ addons: array(PipelineAddonSchemaSchema).readonly()
16709
16733
  });
16710
- /**
16711
- * How a track was produced. `pipeline` (default / absent) = the spatial
16712
- * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
16713
- * no positions, a single snapshot, and no bbox trajectory at all:
16714
- *
16715
- * - `sensor` — a linked sensor/control device state change.
16716
- * - `audio` — an audio event on the camera itself that was anomalous for
16717
- * THAT camera, loud, and heard while nothing visual was happening (D62).
16718
- *
16719
- * The spatial subsystems (tracker association, occupancy count, re-id /
16720
- * embedding, resurrection) MUST skip every synthetic source. Test for that
16721
- * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
16722
- * check silently readmits every source added after it was written.
16723
- */
16724
- var TrackSourceSchema = _enum([
16725
- "pipeline",
16726
- "sensor",
16727
- "audio"
16728
- ]);
16729
- /**
16730
- * Where a track sits in the RETRAIN lifecycle (D81).
16731
- *
16732
- * - `none` — never marked, or un-marked. Evictable.
16733
- * - `staging` — the operator wants this track as training material and has not
16734
- * finished with it. **This is the only state retention holds**: the track and
16735
- * everything it owns (object events, crops, keyframes, CLIP vector) survive
16736
- * the device's age window.
16737
- * - `trained` — the retrain page has taken what it needed. The frames it chose
16738
- * were COPIED into the retrain dataset at selection time, so the dataset no
16739
- * longer depends on the track's media and the track becomes EVICTABLE again.
16740
- * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
16741
- * a deliberate action of the retrain page, not a side effect of a checkbox.
16742
- *
16743
- * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
16744
- * the store's filter language has only positive equality and `whereIn` — no
16745
- * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
16746
- * would make the entire pre-column history immortal in one deploy.
16747
- */
16748
- var RetrainStatusSchema = _enum([
16749
- "none",
16750
- "staging",
16751
- "trained"
16752
- ]);
16753
- /**
16754
- * Per-track OPERATOR flags — set by hand from the admin UI or the viewer, never
16755
- * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
16756
- * so the two surfaces cannot drift.
16757
- *
16758
- * **Absent ≠ false.** A track that has never been touched omits the field; an
16759
- * explicitly un-flagged track carries `false`. Legacy rows written before the
16760
- * columns existed read as absent, and a consumer that needs a boolean should say
16761
- * `flag === true`, not `flag !== false`.
16762
- *
16763
- * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
16764
- * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
16765
- * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
16766
- * `trained` track reports `false` while refusing both writes. The boolean is
16767
- * kept because three surfaces drive a toggle off it; anything that needs to tell
16768
- * "never marked" from "already trained" must read `retrainStatus`.
16769
- *
16770
- * `debug` does NOT pin; it is attention, not durability.
16771
- *
16772
- * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
16773
- * A favourited track is skipped by retention the same way `staging` is, but
16774
- * it does not enter `none|staging|trained` and has no staging budget.
16775
- */
16776
- var TrackFlagFields = {
16777
- /** Operator marked this track as training material — i.e. `retrainStatus` is
16778
- * `'staging'`. */
16779
- markForTrain: boolean().optional(),
16780
- /** Operator marked this track for diagnostic attention. */
16781
- debug: boolean().optional(),
16782
- /** Operator favourited this track. Pins it against pruning. */
16783
- favourited: boolean().optional()
16784
- };
16785
- /**
16786
- * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
16787
- * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
16788
- * write patch, and the status is not something the toggle sets — it is what the
16789
- * toggle's boolean is derived from. Absent on an in-RAM track never touched;
16790
- * always present on a persisted row (the column default materialises `'none'`).
16791
- */
16792
- var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
16793
- /**
16794
- * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
16795
- * one flag can never clear the other — the toggles are independent and are
16796
- * driven from three surfaces that do not know about each other.
16797
- */
16798
- var TrackFlagsPatchSchema = object(TrackFlagFields);
16799
- /**
16800
- * The resolved flag state after a write. Both fields are REQUIRED here (absent
16801
- * collapses to `false`) so a caller can drive a toggle's checked state off the
16802
- * mutation result without a re-fetch.
16803
- */
16804
- var TrackFlagsSchema = object({
16805
- trackId: string(),
16806
- markForTrain: boolean(),
16807
- debug: boolean(),
16808
- favourited: boolean(),
16809
- /** The lifecycle state the boolean was derived from. Required here (unlike on
16810
- * a track row) because this shape is only ever produced by the write body,
16811
- * which always knows it — and a surface that has just written needs to render
16812
- * `trained` without a re-fetch. */
16813
- retrainStatus: RetrainStatusSchema
16734
+ var PipelineSchemaSchema = object({
16735
+ availableEngines: array(AvailableEngineSchema).readonly(),
16736
+ selectedEngine: PipelineEngineChoiceSchema,
16737
+ slots: array(PipelineSlotSchemaSchema).readonly()
16814
16738
  });
16815
- union([literal(1), literal(2)]);
16816
- /**
16817
- * WHO decided a label, and when. Carried per tier so a value can be traced to
16818
- * the step and model that produced it — which is what makes the write rule
16819
- * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
16820
- * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
16821
- *
16822
- * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
16823
- * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
16824
- * `migration:4g` for a value the 4g migration moved from the single-slot era —
16825
- * that value has no provenance, and the write rule lets ANY properly-attributed
16826
- * write of the same tier replace it regardless of score.
16827
- */
16828
- var LabelAttributionSchema = object({
16829
- stepId: string(),
16830
- modelId: string().optional(),
16831
- decidedAt: number(),
16739
+ var EngineProvisioningSchema = object({
16740
+ runtimeId: _enum([
16741
+ "onnx",
16742
+ "openvino",
16743
+ "coreml",
16744
+ "edgetpu"
16745
+ ]).nullable(),
16746
+ device: string().nullable(),
16747
+ state: _enum([
16748
+ "idle",
16749
+ "installing",
16750
+ "verifying",
16751
+ "ready",
16752
+ "failed"
16753
+ ]),
16754
+ progress: number().optional(),
16755
+ error: string().optional(),
16756
+ nextRetryAt: number().optional(),
16832
16757
  /**
16833
- * The GALLERY id behind a recognised tier-2 label — a face-gallery
16834
- * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
16835
- *
16836
- * The text alone is a DISPLAY NAME, and a display name is renameable: a
16837
- * notification rule authored on "Gianluca" stopped matching the moment the
16838
- * operator fixed the spelling in the gallery, and nothing said so. The id is
16839
- * the thing that does not move, so it is what a rule matches on
16840
- * (`NcConditions.identities`) and the text is what a human is shown.
16841
- *
16842
- * Absent when the label names no gallery row — a plate the OCR read but no
16843
- * vehicle claims, a sub-class, a species, any tier-1 value.
16758
+ * Gate A (config-correctness gate at engine change): human-readable
16759
+ * config issues surfaced EAGERLY when the node's engine changes — model
16760
+ * substitutions ("chose X, running Y") and zero-build steps ("no model
16761
+ * has a <format> build"). Additive/optional: informational only, never
16762
+ * enforced here — `assertEngineReady` (readiness) still gates inference.
16763
+ * Absent/empty when the node-default tree resolves cleanly.
16844
16764
  */
16845
- identityId: string().optional()
16765
+ configIssues: array(string()).optional()
16846
16766
  });
16847
- /**
16848
- * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
16849
- * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
16850
- * track and its events always answer the same question the same way.
16851
- *
16852
- * Two scalar columns, not an array: every consumer wants "the coarse one" or
16853
- * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
16854
- * is tier 2, and each carries its own score + attribution.
16855
- *
16856
- * **Reading it.** What a human should be shown is `subLabel ?? label` — the
16857
- * finest thing known. Before 4g the single `label` column held the finest
16858
- * value, so a consumer that has not been updated reads the tier-1 slot and
16859
- * shows nothing on a species-only row; that is why the migration puts every
16860
- * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
16861
- * and why the read surfaces were changed in the same train.
16862
- *
16863
- * **Writing it.** The slots are independent, which is the whole point: a
16864
- * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
16865
- * migratorius`), so fineness cannot regress by construction. Within a tier the
16866
- * higher score wins. One rule, one implementation — see
16867
- * `pipeline/label-tier.ts` in addon-post-analysis.
16868
- */
16869
- var TieredLabelFields = {
16870
- /** Tier 1 — the sub-class. See {@link LabelTierSchema}. */
16871
- label: string().optional(),
16872
- /** Confidence of the tier-1 value, as reported by the deciding step. */
16873
- labelScore: number().optional(),
16874
- /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
16875
- labelMeta: LabelAttributionSchema.optional(),
16876
- /** Tier 2 — the instance. See {@link LabelTierSchema}. */
16877
- subLabel: string().optional(),
16878
- /** Confidence of the tier-2 value, as reported by the deciding step. */
16879
- subLabelScore: number().optional(),
16880
- /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
16881
- subLabelMeta: LabelAttributionSchema.optional()
16882
- };
16883
- /** Per-camera slice of a training-export estimate. */
16884
- var TrainingExportDeviceTotalsSchema = object({
16885
- deviceId: number(),
16886
- tracks: number().int(),
16887
- files: number().int(),
16888
- bytes: number().int()
16767
+ var PipelineStepInputSchema = lazy(() => object({
16768
+ addonId: string(),
16769
+ modelId: string().optional(),
16770
+ enabled: boolean().default(true),
16771
+ children: array(PipelineStepInputSchema).optional(),
16772
+ settings: record(string(), unknown()).optional(),
16773
+ jumpDeviceKey: string().optional()
16774
+ }));
16775
+ var ModelSubstitutionSchema = object({
16776
+ addonId: string(),
16777
+ chosen: string(),
16778
+ running: string(),
16779
+ format: string()
16780
+ });
16781
+ var PipelineValidationIssueSchema = object({
16782
+ addonId: string(),
16783
+ kind: _enum(["unknown-addon", "no-format-build"]),
16784
+ detail: string()
16785
+ });
16786
+ var PipelineValidationResultSchema = object({
16787
+ ok: boolean(),
16788
+ issues: array(PipelineValidationIssueSchema).readonly(),
16789
+ substitutions: array(ModelSubstitutionSchema).readonly(),
16790
+ /** The node's `currentEngine.format` this validation ran against. */
16791
+ format: string()
16792
+ });
16793
+ var ReferenceImageEntrySchema = object({
16794
+ filename: string(),
16795
+ stepIds: array(string()).readonly().optional()
16796
+ });
16797
+ var ReferenceImageBodySchema = object({
16798
+ base64: string(),
16799
+ filename: string()
16800
+ });
16801
+ var ReferenceAudioEntrySchema = object({
16802
+ filename: string(),
16803
+ sizeKb: number()
16804
+ });
16805
+ var ReferenceAudioBodySchema = object({ base64: string() });
16806
+ var AudioBackendSchema = object({
16807
+ id: string(),
16808
+ name: string(),
16809
+ description: string(),
16810
+ available: boolean(),
16811
+ /**
16812
+ * Raw classifier labels this backend can emit (e.g. YAMNet's
16813
+ * 521-class set or Apple SoundAnalysis's 303-class set). Used by
16814
+ * the benchmark UI to populate the `enabledMicroClasses` filter
16815
+ * specific to the selected backend without a separate fetch.
16816
+ */
16817
+ rawLabels: array(string()).readonly().optional()
16818
+ });
16819
+ var AudioCapabilitiesSchema = object({
16820
+ activeBackend: string(),
16821
+ availableBackends: array(AudioBackendSchema).readonly(),
16822
+ sampleRate: number(),
16823
+ chunkDurationMs: number()
16824
+ });
16825
+ var DownloadModelResultSchema = object({
16826
+ filePath: string(),
16827
+ sizeMB: number(),
16828
+ durationMs: number()
16889
16829
  });
16890
16830
  /**
16891
- * What a training export WOULD contain. Computed from media index rows only —
16892
- * no blob is read to produce this.
16831
+ * Wrapper carrying a single test run's result. Replaces the legacy
16832
+ * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
16833
+ * canonical `AudioResult` from the Phase 6 output rework: one
16834
+ * `AudioDetection` per class above `minScore`, top-N candidates in
16835
+ * `debug.alternateLabels['audio-classifier']`, per-source timings in
16836
+ * `debug.stepTimings`. The outer `success`/`error` fields stay so the
16837
+ * benchmark UI can still report a clean failure when the classifier
16838
+ * cap isn't available.
16893
16839
  */
16894
- var TrainingExportSummarySchema = object({
16895
- generatedAt: number(),
16896
- trackCount: number().int(),
16897
- fileCount: number().int(),
16898
- byteCount: number().int(),
16899
- /** More marked tracks exist than a single pass carries. */
16900
- truncated: boolean(),
16901
- devices: array(TrainingExportDeviceTotalsSchema).readonly()
16840
+ var AudioTestResultSchema = object({
16841
+ success: boolean(),
16842
+ error: string().optional(),
16843
+ frame: custom().optional()
16902
16844
  });
16903
- var TrackSchema = object({
16904
- trackId: string(),
16905
- deviceId: number(),
16906
- className: string(),
16907
- ...TieredLabelFields,
16908
- producingDeviceName: string().optional(),
16909
- /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
16910
- source: TrackSourceSchema.optional(),
16911
- firstSeen: number(),
16912
- lastSeen: number(),
16913
- /** Frame-rate position history (subject to maxPositionHistory cap). */
16914
- positions: array(TrackPositionSchema).readonly(),
16915
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
16916
- * saveThumbnails policy). */
16917
- snapshots: array(TrackSnapshotSchema).readonly(),
16918
- /** Deduplicated zones the track has entered at least once. Zone IDS. */
16919
- zonesVisited: array(string()).readonly(),
16845
+ var PipelineConfigBridge = custom();
16846
+ var ConfigUISchemaBridge = custom();
16847
+ var ConfigUISchemaNullableBridge = custom();
16848
+ var InferenceCapabilitiesBridge = custom();
16849
+ var ModelAvailabilityListBridge = custom();
16850
+ var PipelineRunResultBridge = custom();
16851
+ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
16852
+ modelId: string(),
16853
+ settings: record(string(), unknown()).readonly()
16854
+ }))), method(object({ steps: record(string(), object({
16855
+ modelId: string(),
16856
+ settings: record(string(), unknown()).readonly()
16857
+ })) }), object({ success: literal(true) }), {
16858
+ kind: "mutation",
16859
+ auth: "admin"
16860
+ }), method(object({ nodeId: string() }), object({
16861
+ success: literal(true),
16862
+ clearedDevices: number()
16863
+ }), {
16864
+ kind: "mutation",
16865
+ auth: "admin"
16866
+ }), method(object({ nodeId: string() }), object({ unhealthy: array(object({
16867
+ /** `<backend>:<device>`, e.g. `openvino:gpu`. */
16868
+ deviceKey: string(),
16920
16869
  /**
16921
- * Human NAMES for {@link zonesVisited}, resolved at READ time against the
16922
- * `zones` capability.
16923
- *
16924
- * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
16925
- * and no card can render — so every free-text search surface was structurally
16926
- * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
16927
- * just returned nothing. Resolving here rather than in each client keeps ONE
16928
- * derivation and costs the clients no extra call (the `zones` cap is
16929
- * per-device, so a client-side resolve would be a per-camera fan-out on a
16930
- * surface built to avoid exactly that).
16931
- *
16932
- * Resolved, never invented: a zone deleted since the track was written has no
16933
- * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
16934
- * two are not positionally aligned. Absent when the track visited no zone, or
16935
- * when the zone catalogue could not be read.
16870
+ * `failed` — the per-device restart budget is exhausted; no pool
16871
+ * will be spawned until an operator re-arms it or the runner
16872
+ * respawns. `backoff` — under budget, waiting out the backoff (or
16873
+ * a cached pool observed dead and not yet condemned).
16936
16874
  */
16937
- zoneNames: array(string()).readonly().optional(),
16938
- /** Deduplicated set of detector classes observed for this track over its
16939
- * life (a track may be reclassified, e.g. person→vehicle). Absent on
16940
- * legacy rows written before class accumulation shipped. */
16941
- classes: array(string()).readonly().optional(),
16942
- /** Cumulative normalized distance travelled (0..1 units = full frame width). */
16943
- totalDistance: number(),
16944
- state: TrackStateSchema,
16945
- active: boolean(),
16946
- /** Deterministic key-event importance score in [0,1] (server-computed at
16947
- * track expiry, recomputed on late label). Absent on legacy rows written
16948
- * before scoring shipped — consumers degrade to absence / compute-on-read. */
16949
- importance: number().optional(),
16950
- /** Id of the track's highest-confidence ObjectEvent (its representative
16951
- * "best" frame). Absent when the track produced no object events. */
16952
- bestEventId: string().optional(),
16953
- /** Tag of the importance sub-signal that dominated the score
16954
- * (identity|dwell|proximity|class|confidence|travel|zone). */
16955
- importanceReason: string().optional(),
16956
- /** Audio-classification labels heard on the camera during the track's
16957
- * life (score ≥ device `classificationMinScore`), aggregated per label.
16958
- * Absent on legacy rows / tracks with no confident audio. */
16959
- audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
16960
- /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
16961
- * Populated from the persisted envelope columns on historical reads;
16962
- * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
16963
- envelope: TrackEnvelopeSchema.optional(),
16875
+ state: _enum(["failed", "backoff"]),
16876
+ /** Epoch ms of the death that produced this state. */
16877
+ since: number(),
16878
+ /** Pool deaths inside the current window. */
16879
+ deaths: number(),
16880
+ /** The last death's message. */
16881
+ lastError: string()
16882
+ })).readonly() })), method(object({
16883
+ nodeId: string(),
16884
+ deviceKey: string()
16885
+ }), object({ rearmed: boolean() }), {
16886
+ kind: "mutation",
16887
+ auth: "admin"
16888
+ }), 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({
16889
+ name: string(),
16890
+ steps: array(PipelineTemplateStepSchema).readonly(),
16891
+ engine: PipelineEngineChoiceSchema
16892
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
16893
+ id: string(),
16894
+ name: string().optional(),
16895
+ steps: array(PipelineTemplateStepSchema).readonly().optional()
16896
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
16897
+ addonId: string(),
16898
+ modelId: string(),
16899
+ format: ModelFormatSchema$1
16900
+ }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
16901
+ addonId: string(),
16902
+ modelId: string(),
16903
+ format: ModelFormatSchema$1
16904
+ }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
16905
+ engine: PipelineEngineChoiceSchema.optional(),
16906
+ steps: array(PipelineStepInputSchema).min(1),
16907
+ frame: FrameInputSchema.optional(),
16964
16908
  /**
16965
- * A face DETECTOR found a face on this track — nothing more. It says the
16966
- * detail plane produced a `face` detail; it does NOT say the face was
16967
- * embedded, matched, above `minFacePx`, or that the recognizer was even
16968
- * enabled. Set once and never cleared.
16969
- *
16970
- * **This exists so "face present but not recognised" is expressible.** A
16971
- * recognised identity lands in `subLabel` (attributed to the face chain via
16972
- * `subLabelMeta.stepId`), so before this field a track with an unmatched face
16973
- * and a track with no face at all were byte-identical on the wire and no
16974
- * surface could tell them apart. The read is `hasFace === true && subLabel
16975
- * === undefined`.
16976
- *
16977
- * **Absent ≠ false.** Every row written before the column existed omits it,
16978
- * and so does every server that predates the field — a consumer must test
16979
- * `=== true` and render nothing otherwise, never infer "no face".
16909
+ * Process-local lazy frame. Valid only when caller and provider resolve
16910
+ * in the same execution-group process; split/cross-node callers use
16911
+ * `frame`/`image` inline compatibility instead.
16980
16912
  */
16981
- hasFace: boolean().optional(),
16913
+ frameRef: FrameRefSchema.optional(),
16982
16914
  /**
16983
- * This track has a face row IN THE GALLERY: a crop **and** an embedding — a
16984
- * face an operator could ASSIGN to an identity.
16985
- *
16986
- * The STRICT twin of {@link hasFace}, and the pair only earns its keep
16987
- * because the two disagree. `hasFace` is stamped at the TOP of the face
16988
- * branch, before every gate, and means no more than "a face detector produced
16989
- * a face detail". This one is stamped at the single moment the gallery row
16990
- * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
16991
- * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
16992
- * candidate gate, the imageless-track drop (no crop was ever captured) and
16993
- * the crop-store drop. Everything between the detector and that insert can
16994
- * legitimately refuse the face, so a flag written any earlier promises the
16995
- * operator something to assign and delivers nothing.
16996
- *
16997
- * **Independent of recognition.** A face collected but never auto-matched is
16998
- * still assignable — it is in fact the face an operator most wants to reach —
16999
- * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
17000
- * `subLabel`; this says only that the raw material exists.
17001
- *
17002
- * **Set once, never cleared.** A track that produced a gallery row produced
17003
- * one; deleting the row later is the gallery's business, not this flag's.
17004
- *
17005
- * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
17006
- * before the column omits it, and so does every server that predates the
17007
- * field. A consumer must test `=== true` and render nothing otherwise —
17008
- * never infer "no assignable face".
17009
- */
17010
- hasEmbeddedFace: boolean().optional(),
16915
+ * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
16916
+ * the decoded pixels live in. One more member of the one-of
16917
+ * frame/frameHandle/image/imageBase64/referenceImage group.
16918
+ */
16919
+ frameHandle: FrameHandleSchema.optional(),
16920
+ imageBase64: string().optional(),
17011
16921
  /**
17012
- * This subject CONTAINS a folded rider — a person the rider-pairing step
17013
- * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
17014
- * so the passage is tracked once and as a VEHICLE.
17015
- *
17016
- * It exists because the fold's record was dishonest. D34 and the code both
17017
- * said "the person is not lost — it is reported so both entities stay on the
17018
- * record"; in fact the pair went into a per-processor RAM field behind an
17019
- * accessor nobody called, and every durable surface said `vehicle`, full
17020
- * stop. This is the composition note that makes the row true.
17021
- *
17022
- * A COMPOSITION, never a class and never a label. "This vehicle contains a
17023
- * person" is not an answer to "what is this" — both label tiers would refuse
17024
- * a macro token anyway (D89), and correctly. Nothing here changes what the
17025
- * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
17026
- * and a `person` rule still does not fire for someone cycling past.
17027
- *
17028
- * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
17029
- * the column, and every hub that predates the field, omits it. Test
17030
- * `=== true` and render nothing otherwise — never infer "no rider".
16922
+ * Binary JPEG bytes — preferred over `imageBase64` on internal
16923
+ * hops (hub → forked worker via Moleculer MsgPack) because it
16924
+ * skips the 33% base64 overhead + the per-call base64 decode on
16925
+ * the detection-pipeline worker. Callers can pass either; exactly
16926
+ * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
17031
16927
  */
17032
- hasRider: boolean().optional(),
17033
- ...TrackFlagFields,
17034
- ...TrackRetrainFields
17035
- });
17036
- var BaseEventFields = {
17037
- id: string(),
17038
- deviceId: number(),
17039
- timestamp: number()
17040
- };
17041
- var MotionEventSchema = object({
17042
- ...BaseEventFields,
17043
- kind: literal("motion"),
17044
- regionCount: number(),
17045
- /** Heavy JSON array — omitted in slim projection. */
17046
- regions: array(object({
17047
- bbox: BoundingBoxSchema,
17048
- pixelCount: number(),
17049
- intensity: number()
17050
- })).readonly().optional(),
17051
- /** Omitted in slim projection. */
17052
- frameWidth: number().optional(),
17053
- /** Omitted in slim projection. */
17054
- frameHeight: number().optional(),
17055
- /** Populated by B5 (recording playback URL for this event). */
17056
- mediaUrl: string().optional()
17057
- });
16928
+ image: _instanceof(Uint8Array).optional(),
16929
+ referenceImage: string().optional(),
16930
+ deviceId: number().optional(),
16931
+ sessionId: string().optional(),
16932
+ /**
16933
+ * Execution plane. 'full' (default) runs the whole tree — benchmark,
16934
+ * reference-image, and detail-subtree calls. 'frame' is the live
16935
+ * per-frame dispatch: ONLY root-plane steps run; crop children
16936
+ * (inputClasses ≠ null) are skipped and served per-track via
16937
+ * pipelineRunner.runDetailSubtree (two-plane design).
16938
+ */
16939
+ plane: _enum(["full", "frame"]).optional(),
16940
+ /**
16941
+ * Inference-device selector (Phase 2 multi-device). Format
16942
+ * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
16943
+ * Omitted ⇒ the runner's default device (current single-engine
16944
+ * behaviour). Selects WHICH device pool of the node runs the call.
16945
+ */
16946
+ deviceKey: string().optional(),
16947
+ /**
16948
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
16949
+ * when the parent crop was resolved from the frame's retained NATIVE
16950
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
16951
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
16952
+ * resolution from that surface — the SAME quality path faces already
16953
+ * had — instead of the downscaled parent tile. `handle` keys the native
16954
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
16955
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
16956
+ * the executor's crop-normalized child ROI back into frame-normalized
16957
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
16958
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
16959
+ * (today's behaviour on the fallback path).
16960
+ */
16961
+ nativeCropRef: NativeCropRefSchema.optional()
16962
+ }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
16963
+ engine: PipelineEngineChoiceSchema.optional(),
16964
+ steps: array(PipelineStepInputSchema).min(1),
16965
+ frames: array(FrameInputSchema).min(1).max(255),
16966
+ deviceId: number().optional(),
16967
+ sessionId: string().optional(),
16968
+ /**
16969
+ * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
16970
+ * the batch to the Python pool's bench preprocess cache
16971
+ * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
16972
+ * preprocessed ONCE and every later inference is a pure-inference cache
16973
+ * hit — the sustained-throughput run measures inference, not
16974
+ * decode+preprocess+infer. Omitted/0 for live frames (all different →
16975
+ * full preprocess every call, correct). Fresh per sustained run;
16976
+ * released via `uncacheFrame`.
16977
+ */
16978
+ frameId: number().int().nonnegative().optional(),
16979
+ /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
16980
+ deviceKey: string().optional()
16981
+ }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
16982
+ data: _instanceof(Uint8Array),
16983
+ width: number().int().positive(),
16984
+ height: number().int().positive(),
16985
+ format: _enum([
16986
+ "rgb",
16987
+ "bgr",
16988
+ "gray"
16989
+ ])
16990
+ }), object({
16991
+ frameId: number(),
16992
+ width: number(),
16993
+ height: number()
16994
+ }), { kind: "mutation" }), method(object({
16995
+ stepId: string(),
16996
+ frameId: number().int()
16997
+ }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
16998
+ batchMode: string(),
16999
+ windowMs: number(),
17000
+ maxBatchSize: number(),
17001
+ concurrency: number()
17002
+ })), method(_void(), array(object({
17003
+ engineKey: string(),
17004
+ engine: PipelineEngineChoiceSchema,
17005
+ modelsLoaded: array(string()).readonly(),
17006
+ inUseByCameras: array(number()).readonly(),
17007
+ /**
17008
+ * Origin of this resident factory.
17009
+ * - `runtime` — main camera-serving engine (no idle TTL).
17010
+ * - `warm-override` — benchmark/test override held in the warm
17011
+ * cache; auto-disposed after the idle TTL.
17012
+ * - `device-pool` — a concurrent per-device pool (Phase 2
17013
+ * multi-device, keyed by `deviceKey`) resolved
17014
+ * via `resolveDeviceFactory`. Runs alongside the
17015
+ * `runtime` engine on a DIFFERENT accelerator
17016
+ * (NPU / iGPU / Coral) — this is how the
17017
+ * Engines tab shows all pools running at once.
17018
+ */
17019
+ kind: _enum([
17020
+ "runtime",
17021
+ "warm-override",
17022
+ "device-pool"
17023
+ ]),
17024
+ /** Native pid of the underlying Python pool (null when no pool). */
17025
+ poolPid: number().nullable(),
17026
+ /** ms since this factory was last used (null when not warm-tracked). */
17027
+ idleMs: number().nullable(),
17028
+ /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
17029
+ idleTtlMs: number().nullable()
17030
+ })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
17031
+ kind: "mutation",
17032
+ auth: "admin"
17033
+ }), method(object({
17034
+ engine: PipelineEngineChoiceSchema,
17035
+ force: boolean().optional()
17036
+ }), object({
17037
+ success: boolean(),
17038
+ reason: string().optional()
17039
+ }), {
17040
+ kind: "mutation",
17041
+ auth: "admin"
17042
+ }), 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({
17043
+ addonId: string(),
17044
+ modelId: string(),
17045
+ filename: string().optional(),
17046
+ settings: record(string(), unknown()).optional()
17047
+ }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
17058
17048
  /**
17059
- * Which detection SOURCE produced an object event. `pipeline` = the ML
17060
- * detection pipeline (decoded-frame inference); `onboard` = the camera's
17061
- * native on-device AI. Both flow through the SAME analysis layers (zoning,
17062
- * tracking, per-kind persistence) but stay distinguishable so consumers
17063
- * (advanced-notifier, occupancy, …) can select which source(s) to act on.
17064
- * Absent on legacy rows ⇒ treat as `pipeline`.
17049
+ * Per-stage gating mode applied to the zones a rule references.
17050
+ *
17051
+ * - `include`: the rule contributes to a **whitelist** for its stage.
17052
+ * When at least one `include` rule fires for a stage, only entities
17053
+ * inside one of those zones pass that stage.
17054
+ * - `exclude`: the rule contributes to a **blacklist** for its stage.
17055
+ * Entities inside one of those zones are dropped at that stage.
17056
+ *
17057
+ * `monitor`-style observation (count without filtering) is not a rule
17058
+ * mode — zones without any matching rule are observed naturally by
17059
+ * `zone-analytics` (live snapshot + history), so an "I just want to
17060
+ * count, not filter" use case needs no rule at all.
17065
17061
  */
17066
- var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
17062
+ var ZoneRuleModeEnum = _enum(["include", "exclude"]);
17067
17063
  /**
17068
- * The confirmed zone crossing that produced an object event. Present ONLY on
17069
- * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
17070
- * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
17071
- * appearance event carry none, so a rule asking for a direction fails closed
17072
- * on them.
17064
+ * Per-consumer rule that references existing zones (geometry) and
17065
+ * defines how a specific pipeline stage should treat them. Each
17066
+ * consumer addon owns its own `ZoneRule[]` array in its per-device
17067
+ * settings:
17073
17068
  *
17074
- * Exactly ONE crossing per event: the emitter turns each confirmed crossing
17075
- * into its own event, so a frame in which a track enters A while leaving B
17076
- * produces two events with two directions — never one ambiguous row.
17069
+ * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
17070
+ * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
17071
+ * - future: notification rules, audio gating, etc.
17077
17072
  *
17078
- * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
17079
- * membership the box has NOW, and by definition it no longer contains the zone
17080
- * that was just left. Without the id here, a zone-scoped rule could never match
17081
- * the exit it asked for.
17073
+ * One rule applies to N zones (`zoneIds[]`) so the operator can
17074
+ * express "ignore motion in ALL of {garden, street}" with a single
17075
+ * rule. `classFilter` narrows the rule to specific object classes —
17076
+ * "drop person detections in the street, but keep cars" is one
17077
+ * `exclude` rule with `classFilter: ['person']`.
17078
+ *
17079
+ * `enabled` is a soft toggle — the operator can keep the rule
17080
+ * configured but inert without deleting it.
17082
17081
  */
17083
- var ZoneCrossingSchema = object({
17084
- direction: _enum(["enter", "exit"]),
17085
- /** Admin zone id crossed. */
17086
- zoneId: string(),
17087
- /** Zone display name at crossing time (falls back to the id). */
17088
- zoneName: string().optional()
17089
- });
17090
- var ObjectEventSchema = object({
17091
- ...BaseEventFields,
17092
- kind: literal("object"),
17093
- /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
17094
- source: DetectionSourceSchema.optional(),
17082
+ var ZoneRuleSchema = object({
17083
+ /** Stable rule id — survives edits, used by the UI for diffing. */
17084
+ id: string(),
17085
+ /** Optional human-readable label rendered in the rule editor. */
17086
+ name: string().optional(),
17087
+ /** Zones this rule targets. The rule's `mode` applies to ALL
17088
+ * listed zones (OR-set: a detection in any one of them counts).
17089
+ * At least one zone id required — a rule with no targets is a
17090
+ * configuration mistake and the form validator rejects it. */
17091
+ zoneIds: array(string()).min(1).readonly(),
17092
+ mode: ZoneRuleModeEnum,
17095
17093
  /**
17096
- * Inference-frame id shared by every object event emitted from the SAME frame
17097
- * — the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
17098
- * 2 people + 1 dog) under one full frame, and link a track's frames over time
17099
- * (group by `trackId`, pick a representative `frameId` as the parent frame).
17100
- * Optional for backward-compat with pre-existing rows / the slim projection
17101
- * includes it (it is light). Absent on rows written before this field.
17094
+ * Class names this rule applies to. Empty / undefined ⇒ rule
17095
+ * applies to every class. Class strings match the `macroClass`
17096
+ * field on detections (e.g. `person`, `car`, `dog`).
17102
17097
  */
17103
- frameId: string().optional(),
17104
- /** Omitted in slim projection. */
17105
- trackId: string().optional(),
17106
- className: string(),
17107
- ...TieredLabelFields,
17108
- /** Omitted in slim projection. */
17109
- confidence: number().optional(),
17110
- /** Heavy JSON — omitted in slim projection. */
17111
- bbox: BoundingBoxSchema.optional(),
17112
- /** Heavy JSON — omitted in slim projection. */
17113
- zones: array(string()).readonly().optional(),
17114
- /** Omitted in slim projection. */
17115
- state: TrackStateSchema.optional(),
17098
+ classFilter: array(string()).readonly().optional(),
17116
17099
  /**
17117
- * The zone crossing this event IS, when it is one. Absent on every other
17118
- * event kind (movement state, appearance, package) — see
17119
- * {@link ZoneCrossingSchema}. Omitted in slim projection.
17100
+ * Minimum bbox/mask overlap (0–1) with any of the rule's zones
17101
+ * required to consider an entity "in the zone". Defaults to the
17102
+ * consumer's stage default when omitted. Kept for back-compat with
17103
+ * existing per-rule overrides; new operators pick the value via
17104
+ * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
17105
+ * set, the lower-level engine reads it as a 0–1 fraction.
17120
17106
  */
17121
- zoneCrossing: ZoneCrossingSchema.optional(),
17122
- /** Detection-frame dimensions in pixels — let consumers normalize the
17123
- * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
17124
- frameWidth: number().optional(),
17125
- frameHeight: number().optional(),
17126
- /** MediaStore key for the crop attached to this event (if any). */
17127
- mediaKey: string().optional(),
17128
- /** Design B: MediaStore key of the track's native-resolution key frame (the
17129
- * best-detection full frame). Resolve via the event-media data-plane
17130
- * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
17131
- * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
17132
- * sources — consumers fall back to `mediaKey` (the tight crop). */
17133
- keyFrameMediaKey: string().optional(),
17134
- /** Populated by B5 (recording playback URL for this event). */
17135
- mediaUrl: string().optional(),
17136
- /** The parent track's key-event importance [0,1], propagated to every object
17137
- * event of the track (so an event row can be sorted by importance without a
17138
- * track join). Absent on legacy rows / before the track was scored. */
17139
- importance: number().optional()
17107
+ overlapThreshold: number().min(0).max(1).optional(),
17108
+ /**
17109
+ * Operator-friendly version of `overlapThreshold` — the percentage
17110
+ * of the detection's bbox that must lie inside the zone for the
17111
+ * rule to match. Documented default is 85%; the engine substitutes
17112
+ * that when the field is omitted (kept optional so existing rules
17113
+ * stored without it stay valid).
17114
+ *
17115
+ * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
17116
+ * rule, the engine prefers `bboxInclusionPct` because it's the
17117
+ * field exposed in the UI. Internally both feed the same gate.
17118
+ */
17119
+ bboxInclusionPct: number().min(0).max(100).optional(),
17120
+ /**
17121
+ * When `true` and a detection has a segmentation mask, use the
17122
+ * mask for overlap instead of the bbox. Detection-stage only;
17123
+ * motion rules ignore this field.
17124
+ */
17125
+ preferMask: boolean().optional(),
17126
+ /**
17127
+ * Soft-toggle: `false` disables the rule without deleting it.
17128
+ * Defaults to `true` so operators creating a rule via the UI
17129
+ * see it active immediately.
17130
+ */
17131
+ enabled: boolean().default(true)
17140
17132
  });
17141
- var AudioEventSchema = object({
17142
- ...BaseEventFields,
17143
- kind: literal("audio"),
17144
- rms: number(),
17145
- dbfs: number(),
17146
- classification: object({
17147
- className: string(),
17148
- originalClass: string().optional(),
17149
- score: number()
17150
- }).optional(),
17151
- /** Populated by B5 (recording playback URL for this event). */
17152
- mediaUrl: string().optional()
17133
+ array(ZoneRuleSchema).readonly();
17134
+ /**
17135
+ * Zone — pure geometry + identity. NO filtering behaviour.
17136
+ *
17137
+ * Zones describe **where** in the frame the operator wants to flag
17138
+ * something; consumer-owned {@link ZoneRule} arrays describe **how**
17139
+ * each pipeline stage uses them. Splitting the two means a single
17140
+ * polygon "Driveway" can simultaneously back a motion-exclude rule,
17141
+ * a detection-include rule on `['car']`, and an occupancy aggregate
17142
+ * — without three duplicated polygons.
17143
+ *
17144
+ * Owned by the orchestrator addon (provider) and mirrored into the
17145
+ * `zones` device-state slice on every mutation. Consumers
17146
+ * (motion-wasm, pipeline-executor, analytics, admin UI) read either
17147
+ * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
17148
+ * mirror with `onChanged`).
17149
+ *
17150
+ * Coordinates are normalised fractions of the frame (0–1) so zones
17151
+ * survive resolution changes and stream profile switches.
17152
+ *
17153
+ * `kind` discriminates between full polygons (closed regions used
17154
+ * for intrusion / occupancy filters) and tripwires (open 2-point
17155
+ * line segments used for cross events). Onboard / firmware-reported
17156
+ * zones (Reolink, ONVIF) are out of scope for now — see the deferred
17157
+ * task list.
17158
+ */
17159
+ var ZoneKindEnum = _enum(["polygon", "tripwire"]);
17160
+ /** Polygon vertex in fraction-of-frame coordinates (0–1). */
17161
+ var PolygonPointSchema = object({
17162
+ x: number(),
17163
+ y: number()
17153
17164
  });
17154
- var MediaFileKindEnum = _enum([
17155
- "crop",
17156
- "thumbnail",
17157
- "snapshot",
17158
- "firstFrame",
17159
- "lastFrame",
17160
- "fullFrame",
17161
- "fullFrameBoxed",
17162
- "faceCrop",
17163
- "plateCrop",
17164
- "keyFrame",
17165
- "keyFrameSmall",
17166
- "thumbnailSmall"
17167
- ]);
17168
- var MediaFileSchema = object({
17169
- key: string(),
17170
- kind: MediaFileKindEnum,
17171
- base64: string(),
17172
- sizeBytes: number(),
17173
- timestamp: number()
17165
+ /** A camera detection zone — pure geometry/identity. */
17166
+ var ZoneSchema = object({
17167
+ id: string(),
17168
+ name: string(),
17169
+ kind: ZoneKindEnum.default("polygon"),
17170
+ /** Polygon vertices, fraction of frame (0–1). */
17171
+ polygon: array(PolygonPointSchema).readonly(),
17172
+ /** Visual color for UI rendering. */
17173
+ color: string().default("#3b82f6")
17174
17174
  });
17175
17175
  /**
17176
- * One media row WITHOUT its bytes.
17176
+ * Zones capability — per-camera CRUD over polygon detection zones.
17177
17177
  *
17178
- * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
17179
- * 140 s track), and a client that renders tiles from the media data plane needs
17180
- * to know only WHAT EXISTS — the bytes then arrive per tile, lazily, over HTTP
17181
- * with an immutable cache, instead of all at once inside a tRPC response that
17182
- * blocks the whole view.
17178
+ * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
17179
+ * to per-device settings and mirrors into the `zones` device-state
17180
+ * slice on every mutation, so downstream consumers can subscribe via
17181
+ * `dev.state.zones.onChanged`.
17183
17182
  *
17184
- * `sizeBytes` is carried because it is what lets a client decide between the
17185
- * stored blob and a `?variant=thumb` rendering without fetching either.
17183
+ * The cap surface only handles geometry + identity; filtering
17184
+ * behaviour (per-class, include/exclude, threshold) lives in the
17185
+ * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
17186
+ * `capabilities/schemas/zone-rule.js`.
17186
17187
  */
17187
- var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
17188
+ var zonesCapability = {
17189
+ name: "zones",
17190
+ scope: "device",
17191
+ mode: "singleton",
17192
+ deviceTypes: [DeviceType.Camera],
17193
+ methods: {
17194
+ listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
17195
+ addZone: method(object({
17196
+ deviceId: number(),
17197
+ zone: ZoneSchema
17198
+ }), _void(), {
17199
+ kind: "mutation",
17200
+ auth: "admin"
17201
+ }),
17202
+ removeZone: method(object({
17203
+ deviceId: number(),
17204
+ zoneId: string()
17205
+ }), _void(), {
17206
+ kind: "mutation",
17207
+ auth: "admin"
17208
+ }),
17209
+ updateZone: method(object({
17210
+ deviceId: number(),
17211
+ zone: ZoneSchema
17212
+ }), _void(), {
17213
+ kind: "mutation",
17214
+ auth: "admin"
17215
+ })
17216
+ },
17217
+ /**
17218
+ * Runtime-state slice — the live zone catalogue mirrored by the
17219
+ * orchestrator on every CRUD mutation. Consumers read via
17220
+ * `device.state.zones.value` / `.watch(...)` without round-tripping
17221
+ * the cap, and the codegen DeviceProxy auto-wires the reactive
17222
+ * handle. Slice shape is `{ zones: Zone[] }` so future extensions
17223
+ * (e.g. zone groupings) can sit alongside the polygon list.
17224
+ */
17225
+ runtimeState: object({ zones: array(ZoneSchema).readonly() }),
17226
+ /**
17227
+ * 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.
17228
+ *
17229
+ * See `RuntimeStateDurability`. Enforced by
17230
+ * `scripts/check-runtime-state-durability.ts`.
17231
+ */
17232
+ durability: "restored"
17233
+ };
17188
17234
  /**
17189
- * The MACRO tier of an annotation — a CLOSED set.
17235
+ * pipeline-analytics — device-scoped wrapper cap. Refines raw
17236
+ * per-frame detections emitted by the pipeline runner into tracked
17237
+ * objects, per-kind event collections (motion / object / audio), and
17238
+ * persisted media. Owns the post-detection domain end-to-end:
17190
17239
  *
17191
- * This is what the exported detector predicts, so a typo here is a new class
17192
- * with one example in it. `label` and `subLabel` are open strings by contrast:
17193
- * the whole point of the page is teaching the model things it does not know
17194
- * yet, and constraining that vocabulary would make it useless.
17240
+ * runner emits PipelineInferenceResult
17241
+ * ↓ (event bus)
17242
+ * pipeline-analytics subscriber
17243
+ * ↓ SORT tracker + zone engine + state analyzer + event emitter
17244
+ * → three DB collections (one per kind), one FS media tree, one
17245
+ * unified event emitter (FrameTracked + TrackStarted/Ended +
17246
+ * DetectionEvent on bus)
17195
17247
  *
17196
- * A macro class is NEVER a label. The provider refuses a write whose `label` or
17197
- * `subLabel` is one of these values, in any casing, because once `person`
17198
- * exists in both tiers "every person box" stops being answerable without
17199
- * knowing every string anyone ever typed — and the damage is retroactive.
17248
+ * Pure subscriber model. No `processFrame` cap method — the runner
17249
+ * already publishes the raw frame on the bus. The cap surface is
17250
+ * only QUERIES + per-device settings, bound on/off via
17251
+ * `device-manager.setWrapperActive`. `defaultActive: true` because
17252
+ * every camera with a detection pipeline wants its raw detections
17253
+ * refined; operators opt out per-device via BindingsTab when needed.
17254
+ *
17255
+ * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
17256
+ * (per-device surface) and `track-trail` caps — see P11 cleanup.
17200
17257
  */
17201
- var RetrainMacroClassSchema = _enum([
17258
+ var TrackStateSchema = _enum([
17259
+ "new",
17260
+ "entered",
17261
+ "left",
17262
+ "moving",
17263
+ "idle"
17264
+ ]);
17265
+ var EventKindSchema = _enum([
17266
+ "motion",
17267
+ "object",
17268
+ "audio"
17269
+ ]);
17270
+ /**
17271
+ * Spatial filter for `listTracks` — the rect + polygon variants of the shared
17272
+ * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
17273
+ * of the camera frame (top-left origin), matching the drawing-plane editor.
17274
+ */
17275
+ var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
17276
+ /** Closed icon vocabulary so clients render a known glyph per kind. */
17277
+ var EventKindIconSchema = _enum([
17278
+ "motion",
17279
+ "audio",
17202
17280
  "person",
17203
17281
  "vehicle",
17204
17282
  "animal",
17205
- "package",
17206
- "face",
17207
- "plate"
17283
+ "door",
17284
+ "pir",
17285
+ "smoke",
17286
+ "water",
17287
+ "button",
17288
+ "package",
17289
+ "generic"
17208
17290
  ]);
17209
- /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
17210
- var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
17211
- /** Did a human draw this box, or did the assist propose it? */
17212
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
17213
- /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
17214
- var RetrainBboxSchema = object({
17215
- x: number(),
17216
- y: number(),
17217
- w: number(),
17218
- h: number()
17291
+ var EventKindCategorySchema = _enum([
17292
+ "motion",
17293
+ "audio",
17294
+ "detection",
17295
+ "sensor",
17296
+ "control",
17297
+ "custom",
17298
+ "package"
17299
+ ]);
17300
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
17301
+ var EventKindLevelSchema = _enum(["macro", "sub"]);
17302
+ var EventKindDescriptorSchema = object({
17303
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
17304
+ kind: string(),
17305
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
17306
+ labelKey: string(),
17307
+ /** English fallback label (kept for clients that don't translate). */
17308
+ label: string(),
17309
+ /** Hex color for timeline/legend rendering. */
17310
+ color: string(),
17311
+ /** Dictionary id → lucide component on the UI side. */
17312
+ iconId: string(),
17313
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
17314
+ icon: EventKindIconSchema,
17315
+ category: EventKindCategorySchema,
17316
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
17317
+ parentKind: string().nullable(),
17318
+ /** Derived from `parentKind`, explicit for the client tree. */
17319
+ level: EventKindLevelSchema,
17320
+ /** Which cap + device contributes this kind. For built-ins the camera
17321
+ * itself; for sensor kinds the LINKED source device. */
17322
+ source: object({
17323
+ capName: string(),
17324
+ deviceId: number()
17325
+ })
17219
17326
  });
17220
- /**
17221
- * One annotated subject.
17222
- *
17223
- * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
17224
- * (letterboxed root / zone-cropped package / subject-cropped classifier) are
17225
- * derived from it at export and never stored — storing them is how one feature
17226
- * space ends up holding two crops of the same subject (D52).
17227
- */
17228
- var RetrainAnnotationSchema = object({
17229
- id: string(),
17230
- trackId: string(),
17327
+ /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
17328
+ var EventKindsForDeviceSchema = object({
17231
17329
  deviceId: number(),
17232
- /** The COPY in retrain storage — never the source track's media key. */
17233
- mediaKey: string(),
17234
- bbox: RetrainBboxSchema,
17235
- macroClass: RetrainMacroClassSchema,
17236
- label: string().optional(),
17237
- subLabel: string().optional(),
17238
- kind: RetrainAnnotationKindSchema,
17239
- source: RetrainAnnotationSourceSchema,
17240
- /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
17241
- assistModelId: string().optional(),
17242
- assistScore: number().optional(),
17243
- exportedInBatch: string().optional(),
17244
- createdAt: number()
17245
- });
17246
- /** The write form — the server owns `id`, `createdAt` and the frame binding. */
17247
- var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
17248
- id: true,
17249
- trackId: true,
17250
- deviceId: true,
17251
- mediaKey: true,
17252
- createdAt: true,
17253
- exportedInBatch: true
17330
+ kinds: array(EventKindDescriptorSchema).readonly()
17254
17331
  });
17255
- /** A track sitting in `staging`, with everything the worklist needs to rank it. */
17256
- var RetrainTrackSchema = object({
17257
- trackId: string(),
17332
+ var SensorEventSchema = object({
17333
+ id: string(),
17334
+ /** The CAMERA the event is attributed to (a sensor linked to N cameras
17335
+ * yields N rows, one per camera). */
17258
17336
  deviceId: number(),
17259
- className: string(),
17260
- label: string().optional(),
17261
- firstSeen: number(),
17262
- lastSeen: number(),
17263
- /** How many frames the dataset already holds from this track. */
17264
- frameCount: number().int(),
17265
- /** How many subjects have been annotated on those frames. `0` with
17266
- * `frameCount: 0` is exactly "staging, still to work". */
17267
- annotationCount: number().int()
17337
+ /** The linked sensor device whose state changed. */
17338
+ sourceDeviceId: number(),
17339
+ /** Event kind id — matches an `EventKindDescriptor.kind`. */
17340
+ kind: string(),
17341
+ /** Snapshot of the sensor cap's runtime-state slice at the change. */
17342
+ value: record(string(), unknown()).nullable(),
17343
+ timestamp: number()
17268
17344
  });
17269
- /** A frame the picker may offer — an index row, no blob was read to produce it. */
17270
- var RetrainFrameCandidateSchema = object({
17271
- mediaKey: string(),
17272
- kind: MediaFileKindEnum,
17345
+ var TrackPositionSchema = object({
17346
+ x: number(),
17347
+ y: number(),
17273
17348
  timestamp: number(),
17274
- sizeBytes: number().int(),
17275
- /** A copy of this original already exists — selecting it is free and cannot
17276
- * fail, whatever became of the original. */
17277
- copied: boolean()
17278
- });
17279
- /** A frame the dataset OWNS: bytes copied at selection time. */
17280
- var RetrainFrameSchema = object({
17281
- frameId: string(),
17282
- deviceId: number(),
17283
- trackId: string(),
17284
- /** Provenance only. It may already point at nothing — that is expected. */
17285
- sourceMediaKey: string(),
17286
- sourceKind: MediaFileKindEnum,
17287
- sizeBytes: number().int(),
17288
- width: number().int(),
17289
- height: number().int(),
17290
- copiedAt: number()
17291
- });
17292
- /** Why a copy-on-select could not be honoured — named, never a silent skip. */
17293
- var RetrainCopyRefusalSchema = _enum([
17294
- "source-missing",
17295
- "unreadable-image",
17296
- "write-failed"
17297
- ]);
17298
- var RetrainFrameSelectionSchema = object({
17299
- copied: array(RetrainFrameSchema).readonly(),
17300
- refused: array(object({
17301
- sourceMediaKey: string(),
17302
- reason: RetrainCopyRefusalSchema
17303
- })).readonly()
17349
+ bbox: BoundingBoxSchema
17304
17350
  });
17305
- var RetrainFrameListSchema = object({
17306
- candidates: array(RetrainFrameCandidateSchema).readonly(),
17307
- copies: array(RetrainFrameSchema).readonly(),
17308
- /** What the page pre-selects — the native key frame when one survives. */
17309
- autoPickMediaKey: string().optional()
17351
+ var TrackSnapshotSchema = object({
17352
+ timestamp: number(),
17353
+ position: TrackPositionSchema,
17354
+ /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
17355
+ mediaKey: string()
17310
17356
  });
17311
- /** What the operator asked the assist to look for. */
17312
- var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
17313
- kind: literal("package"),
17314
- zone: RetrainBboxSchema.optional()
17315
- }), object({
17316
- kind: literal("objects"),
17317
- modelId: string(),
17318
- minScore: number().optional()
17319
- })]);
17320
17357
  /**
17321
- * The assist's answer — a discriminated union, because "the model saw nothing"
17322
- * and "this node cannot run that model" lead to different next moves and a
17323
- * nullable result cannot tell them apart.
17358
+ * Normalized 0..1 trajectory envelope (min/max over every position bbox,
17359
+ * divided by the track's detection-frame dims), computed at persist time.
17360
+ * Absent when the frame dims were unknown when the track was persisted
17361
+ * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
17324
17362
  */
17325
- var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
17326
- kind: literal("proposed"),
17327
- modelId: string(),
17328
- stepId: string(),
17329
- minScore: number(),
17330
- /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
17331
- proposals: array(RetrainAnnotationDraftSchema).readonly(),
17332
- /** Returned by the runner but removed by the threshold. */
17333
- belowThreshold: number().int()
17334
- }), object({
17335
- kind: literal("refused"),
17336
- /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
17337
- reason: string(),
17338
- detail: string().optional()
17339
- })]);
17340
- /** The outcome of a lifecycle move owned by the retrain page. */
17341
- var RetrainTransitionResultSchema = object({
17342
- trackId: string(),
17343
- /** Where the track ended up, whatever happened. */
17344
- retrainStatus: RetrainStatusSchema,
17345
- /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
17346
- changed: boolean(),
17347
- reason: _enum([
17348
- "unknown-track",
17349
- "no-frames-copied",
17350
- "not-staging",
17351
- "not-trained",
17352
- "unchanged"
17353
- ]).optional()
17363
+ var TrackEnvelopeSchema = object({
17364
+ minX: number(),
17365
+ minY: number(),
17366
+ maxX: number(),
17367
+ maxY: number()
17354
17368
  });
17355
- var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
17356
- var MAX_EVENT_QUERY_LIMIT = 5e3;
17357
- var DeviceEventQueryInput = object({
17358
- deviceId: number(),
17359
- since: number().optional(),
17360
- until: number().optional(),
17361
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
17362
- /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
17363
- * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
17364
- * exact behaviour. Callers may omit this field — the store defaults to
17365
- * `full` when not provided. */
17366
- projection: _enum(["full", "slim"]).optional()
17367
- });
17368
- var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
17369
- var RecentTracksQueryInput = object({
17370
- /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
17371
- deviceIds: array(number()),
17372
- /** Window lower bound on `lastSeen` (inclusive). */
17373
- since: number().optional(),
17374
- /** Window upper bound on `lastSeen` (inclusive). */
17375
- until: number().optional(),
17376
- /** Page size. Default 200, max 1000. */
17377
- limit: number().int().min(1).max(1e3).default(200),
17378
- /** Opaque continuation cursor from a previous page's `nextCursor`.
17379
- * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
17380
- cursor: string().optional(),
17381
- /** See {@link TrackProjectionSchema}. Default `full`. */
17382
- projection: TrackProjectionSchema.optional(),
17383
- /** Include stationary-promoted rows (parked objects). Default false: the
17384
- * feed lists passages; parking records live on the stationary registry. */
17385
- includeStationary: boolean().optional()
17386
- });
17387
- var RecentTracksPageSchema = object({
17388
- /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
17389
- tracks: array(TrackSchema).readonly(),
17390
- /** Cursor for the next page, or null when this page is the last. */
17391
- nextCursor: string().nullable()
17392
- });
17393
- var LIST_GROUPS_DEFAULT_LIMIT = 40;
17394
- var LIST_GROUPS_MAX_LIMIT = 100;
17395
- var AnalyticsGroupRecordSchema = object({
17396
- id: string(),
17397
- deviceId: number().int(),
17398
- openedAt: number().int(),
17399
- closedAt: number().int(),
17400
- timestamp: number().int(),
17401
- memberCount: number().int(),
17402
- memberTrackIds: array(string()).readonly(),
17403
- className: string(),
17404
- classes: array(string()).readonly(),
17405
- /** Relative event-media path, or null when the group has no picture yet. */
17406
- mediaUrl: string().nullable(),
17407
- singleton: boolean()
17408
- });
17409
- var AnalyticsGroupMemberSchema = object({
17410
- trackId: string(),
17411
- deviceId: number().int(),
17412
- className: string(),
17413
- firstSeen: number().int(),
17414
- lastSeen: number().int(),
17415
- mediaUrl: string().nullable()
17416
- });
17417
- var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
17418
- var ListGroupsQueryInput = object({
17419
- /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
17420
- deviceIds: array(number()),
17421
- /** Window lower bound on `closedAt` (inclusive). */
17422
- since: number().optional(),
17423
- /** Window upper bound on `openedAt` (inclusive). */
17424
- until: number().optional(),
17425
- limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
17426
- /** Opaque continuation cursor from a previous page's `nextCursor`. */
17427
- cursor: string().optional()
17428
- });
17429
- var ListGroupsPageSchema = object({
17430
- groups: array(AnalyticsGroupRecordSchema).readonly(),
17431
- nextCursor: string().nullable()
17432
- });
17433
- var KeyEventQueryInput = object({
17434
- deviceId: number(),
17435
- /** Window lower bound (track firstSeen ≥ since). */
17436
- since: number(),
17437
- /** Window upper bound (track firstSeen ≤ until). */
17438
- until: number(),
17439
- limit: number().int().min(1).max(200).default(50),
17440
- /** Drop tracks scoring below this importance. */
17441
- minImportance: number().min(0).max(1).optional(),
17442
- /** Restrict to a single class (e.g. 'person'). */
17443
- classFilter: string().optional()
17444
- });
17445
- var KeyEventSchema = object({
17446
- /** The representative event id (the track's best ObjectEvent, else its trackId). */
17447
- id: string(),
17448
- trackId: string(),
17449
- /** Track start time (firstSeen). */
17450
- timestamp: number(),
17451
- className: string(),
17452
- ...TieredLabelFields,
17453
- importance: number(),
17454
- /** Highest-confidence ObjectEvent id for the track (empty when none). */
17455
- bestEventId: string(),
17456
- /** Track lifetime in ms (lastSeen - firstSeen). */
17457
- windowMs: number().optional(),
17458
- ...TrackFlagFields,
17459
- ...TrackRetrainFields
17460
- });
17461
- object({
17462
- trackId: string(),
17463
- className: string(),
17464
- confidence: number(),
17465
- bbox: BoundingBoxSchema,
17466
- zones: array(string()).readonly(),
17467
- state: TrackStateSchema
17468
- });
17469
- var OverlayDetectionSchema = looseObject({
17470
- id: string(),
17471
- kind: _enum(["first-level", "detail"]),
17472
- macroClass: string(),
17473
- score: number(),
17474
- bbox: object({
17475
- x: number(),
17476
- y: number(),
17477
- width: number(),
17478
- height: number()
17479
- }),
17480
- labels: array(looseObject({
17481
- label: string(),
17482
- score: number()
17483
- })).readonly(),
17484
- parentId: string().optional()
17485
- });
17486
- var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
17487
- var SearchObjectEventsInput = object({
17488
- text: string(),
17489
- deviceId: number().optional(),
17490
- since: number().optional(),
17491
- until: number().optional(),
17492
- classFilter: string().optional(),
17493
- limit: number().default(50),
17494
- minScore: number().min(0).max(1).default(.2)
17495
- });
17496
- var TrackCascadeCountsSchema = object({
17497
- /** Persisted track roots deleted (authoritative). */
17498
- tracks: number().int(),
17499
- /** Object events removed with their tracks (best-effort; see note above). */
17500
- events: number().int(),
17501
- /** Track/face/plate-owned media removed (best-effort). Never identity media. */
17502
- media: number().int(),
17503
- /** Unassigned (non-enrolled) face reads removed (best-effort). */
17504
- faces: number().int(),
17505
- /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
17506
- plates: number().int(),
17507
- /** Per-track CLIP search vectors removed (best-effort). */
17508
- embeddings: number().int(),
17509
- /** Group membership + group rows removed with their last member (best-effort). */
17510
- groups: number().int()
17511
- });
17512
- /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
17513
- var DiskReconcileCountsSchema = object({
17514
- mediaDropped: number().int(),
17515
- tracks: number().int(),
17516
- events: number().int()
17517
- });
17518
- /** Event-store footprint for one camera. */
17519
- var EventStoreDeviceFootprintSchema = object({
17520
- deviceId: number(),
17521
- /** Persisted event rows (motion + object + audio) for the camera. */
17522
- rows: number().int(),
17523
- /** Event-owned media bytes on disk for the camera. */
17524
- bytes: number().int()
17525
- });
17526
- /** Aggregate event-store footprint: global totals + per-camera breakdown. */
17527
- var EventStoreFootprintSchema = object({
17528
- totalRows: number().int(),
17529
- totalBytes: number().int(),
17530
- devices: array(EventStoreDeviceFootprintSchema).readonly()
17531
- });
17532
- /** Per-kind counts returned by the event-prune / device-delete mutations. */
17533
- var EventPruneCountsSchema = object({
17534
- motion: number().int(),
17535
- object: number().int(),
17536
- audio: number().int()
17369
+ /**
17370
+ * Row projection for track list queries. `full` (default) returns the
17371
+ * complete Track including the frame-rate `positions[]` history and the
17372
+ * `snapshots[]` references — megabytes across a page of tracks. `slim`
17373
+ * keeps every scalar the list surfaces actually render (ids, class(es),
17374
+ * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
17375
+ * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
17376
+ * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
17377
+ * `getTrack`. Mirrors the event-store `projection` convention
17378
+ * (`getObjectEvents` et al.).
17379
+ */
17380
+ var TrackProjectionSchema = _enum(["full", "slim"]);
17381
+ /**
17382
+ * One audio-classification label heard on the track's camera while the
17383
+ * track was alive, aggregated per label. An "episode" is one persisted
17384
+ * audio event (the confident-classification path: score ≥ the device's
17385
+ * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
17386
+ * one 32 ms inference chunk, so counts stay human-scaled.
17387
+ */
17388
+ var TrackAudioLabelSchema = object({
17389
+ label: string(),
17390
+ /** Highest classification score observed across the label's episodes. */
17391
+ peakScore: number(),
17392
+ /** Number of coalesced audio-event episodes carrying this label. */
17393
+ count: number(),
17394
+ firstAt: number(),
17395
+ lastAt: number()
17537
17396
  });
17538
17397
  /**
17539
- * Re-embed stored tracks from their key frames.
17398
+ * How a track was produced. `pipeline` (default / absent) = the spatial
17399
+ * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
17400
+ * no positions, a single snapshot, and no bbox trajectory at all:
17540
17401
  *
17541
- * The reason this is an operator-callable method and not a migration script:
17542
- * every knob that decides what a vector MEANS — encoder model, crop margin,
17543
- * squaring — is only changeable if the existing vectors can be regenerated.
17544
- * Mixing feature spaces in one index makes cosine scores incomparable, and the
17545
- * symptom is a quality regression with no visible cause.
17402
+ * - `sensor` — a linked sensor/control device state change.
17403
+ * - `audio` — an audio event on the camera itself that was anomalous for
17404
+ * THAT camera, loud, and heard while nothing visual was happening (D62).
17405
+ *
17406
+ * The spatial subsystems (tracker association, occupancy count, re-id /
17407
+ * embedding, resurrection) MUST skip every synthetic source. Test for that
17408
+ * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
17409
+ * check silently readmits every source added after it was written.
17546
17410
  */
17547
- var RebuildObjectEmbeddingsInput = object({
17548
- /** Restrict to one camera. Omit for the whole fleet. */
17549
- deviceId: number().optional(),
17550
- since: number().optional(),
17551
- until: number().optional(),
17552
- /** Stop after this many tracks; the result reports whether more remain. */
17553
- maxTracks: number().int().positive().optional(),
17554
- /**
17555
- * Run every embedding on THIS node instead of round-robining the fleet.
17556
- *
17557
- * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
17558
- * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
17559
- * calling it that would pin the rebuild REQUEST itself to that node — the
17560
- * rebuild orchestration lives on the hub, and only the per-track step runs
17561
- * remotely. This field is data; the per-track pin is applied inside.
17562
- *
17563
- * Absent ⇒ round-robin over every online node whose runner can serve the
17564
- * pinned model.
17565
- */
17566
- executeOnNodeId: string().optional(),
17567
- /**
17568
- * Milliseconds to wait between tracks; omit for the built-in default, `0` to
17569
- * run flat out.
17570
- *
17571
- * A rebuild is bulk maintenance on hub-main's single thread. Measured
17572
- * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
17573
- * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
17574
- * force is logged at start and finish so a deliberately slow pass reads
17575
- * differently from a stalled one.
17576
- */
17577
- pacingMs: number().int().nonnegative().optional()
17578
- });
17411
+ var TrackSourceSchema = _enum([
17412
+ "pipeline",
17413
+ "sensor",
17414
+ "audio"
17415
+ ]);
17579
17416
  /**
17580
- * Result of emptying the CLIP index.
17417
+ * Where a track sits in the RETRAIN lifecycle (D81).
17581
17418
  *
17582
- * The clean slate before a policy change: a new crop margin or encoder model
17583
- * leaves two feature spaces in one index whose cosine scores are not
17584
- * comparable, so wiping and rebuilding is the only way to be sure every vector
17585
- * means the same thing.
17419
+ * - `none` — never marked, or un-marked. Evictable.
17420
+ * - `staging` — the operator wants this track as training material and has not
17421
+ * finished with it. **This is the only state retention holds**: the track and
17422
+ * everything it owns (object events, crops, keyframes, CLIP vector) survive
17423
+ * the device's age window.
17424
+ * - `trained` — the retrain page has taken what it needed. The frames it chose
17425
+ * were COPIED into the retrain dataset at selection time, so the dataset no
17426
+ * longer depends on the track's media and the track becomes EVICTABLE again.
17427
+ * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
17428
+ * a deliberate action of the retrain page, not a side effect of a checkbox.
17429
+ *
17430
+ * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
17431
+ * the store's filter language has only positive equality and `whereIn` — no
17432
+ * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
17433
+ * would make the entire pre-column history immortal in one deploy.
17586
17434
  */
17587
- var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
17435
+ var RetrainStatusSchema = _enum([
17436
+ "none",
17437
+ "staging",
17438
+ "trained"
17439
+ ]);
17588
17440
  /**
17589
- * Acknowledgement that a rebuild STARTED.
17441
+ * Per-track OPERATOR flags — set by hand from the admin UI or the viewer, never
17442
+ * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
17443
+ * so the two surfaces cannot drift.
17590
17444
  *
17591
- * The pass costs ~1s per track — 45 minutes for a 2,600-track fleet — so it
17592
- * runs detached and this returns immediately. Waiting for it made the client
17593
- * time out while the work carried on server-side, which is the worst of both:
17594
- * no result and no way to know it was still going. Poll
17595
- * `getObjectEmbeddingRebuildStatus` for progress.
17596
- */
17597
- var RebuildObjectEmbeddingsResultSchema = object({
17598
- started: boolean(),
17599
- /** True when a pass was already running; the new request is ignored. */
17600
- alreadyRunning: boolean()
17445
+ * **Absent ≠ false.** A track that has never been touched omits the field; an
17446
+ * explicitly un-flagged track carries `false`. Legacy rows written before the
17447
+ * columns existed read as absent, and a consumer that needs a boolean should say
17448
+ * `flag === true`, not `flag !== false`.
17449
+ *
17450
+ * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
17451
+ * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
17452
+ * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
17453
+ * `trained` track reports `false` while refusing both writes. The boolean is
17454
+ * kept because three surfaces drive a toggle off it; anything that needs to tell
17455
+ * "never marked" from "already trained" must read `retrainStatus`.
17456
+ *
17457
+ * `debug` does NOT pin; it is attention, not durability.
17458
+ *
17459
+ * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
17460
+ * A favourited track is skipped by retention the same way `staging` is, but
17461
+ * it does not enter `none|staging|trained` and has no staging budget.
17462
+ */
17463
+ var TrackFlagFields = {
17464
+ /** Operator marked this track as training material — i.e. `retrainStatus` is
17465
+ * `'staging'`. */
17466
+ markForTrain: boolean().optional(),
17467
+ /** Operator marked this track for diagnostic attention. */
17468
+ debug: boolean().optional(),
17469
+ /** Operator favourited this track. Pins it against pruning. */
17470
+ favourited: boolean().optional()
17471
+ };
17472
+ /**
17473
+ * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
17474
+ * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
17475
+ * write patch, and the status is not something the toggle sets — it is what the
17476
+ * toggle's boolean is derived from. Absent on an in-RAM track never touched;
17477
+ * always present on a persisted row (the column default materialises `'none'`).
17478
+ */
17479
+ var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
17480
+ /**
17481
+ * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
17482
+ * one flag can never clear the other — the toggles are independent and are
17483
+ * driven from three surfaces that do not know about each other.
17484
+ */
17485
+ var TrackFlagsPatchSchema = object(TrackFlagFields);
17486
+ /**
17487
+ * The resolved flag state after a write. Both fields are REQUIRED here (absent
17488
+ * collapses to `false`) so a caller can drive a toggle's checked state off the
17489
+ * mutation result without a re-fetch.
17490
+ */
17491
+ var TrackFlagsSchema = object({
17492
+ trackId: string(),
17493
+ markForTrain: boolean(),
17494
+ debug: boolean(),
17495
+ favourited: boolean(),
17496
+ /** The lifecycle state the boolean was derived from. Required here (unlike on
17497
+ * a track row) because this shape is only ever produced by the write body,
17498
+ * which always knows it — and a surface that has just written needs to render
17499
+ * `trained` without a re-fetch. */
17500
+ retrainStatus: RetrainStatusSchema
17601
17501
  });
17602
- var RebuildStatusSchema = object({
17603
- running: boolean(),
17604
- scanned: number(),
17605
- rebuilt: number(),
17606
- /** Tracks whose key frame is gone — nothing to re-embed from. */
17607
- missingKeyFrame: number(),
17608
- /** Tracks with no usable detection box. */
17609
- missingBbox: number(),
17610
- /**
17611
- * Tracks an executing node REFUSED rather than broke on — an unreadable key
17612
- * frame, a step that threw. Separate from `failed` because the remedy is
17613
- * different, and because a whole camera silently contributing zero vectors
17614
- * is the shape of failure a rebuild must never hide.
17615
- */
17616
- notRunnable: number(),
17502
+ union([literal(1), literal(2)]);
17503
+ /**
17504
+ * WHO decided a label, and when. Carried per tier so a value can be traced to
17505
+ * the step and model that produced it — which is what makes the write rule
17506
+ * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
17507
+ * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
17508
+ *
17509
+ * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
17510
+ * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
17511
+ * `migration:4g` for a value the 4g migration moved from the single-slot era —
17512
+ * that value has no provenance, and the write rule lets ANY properly-attributed
17513
+ * write of the same tier replace it regardless of score.
17514
+ */
17515
+ var LabelAttributionSchema = object({
17516
+ stepId: string(),
17517
+ modelId: string().optional(),
17518
+ decidedAt: number(),
17617
17519
  /**
17618
- * The pass stopped because NO node could serve the pinned model.
17520
+ * The GALLERY id behind a recognised tier-2 label — a face-gallery
17521
+ * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
17619
17522
  *
17620
- * Distinct from `notRunnable` on purpose: that one says "this track was
17621
- * refused", this one says "the cluster cannot do this work at all" — every
17622
- * candidate node either lacks the `clip-embedding` step, lacks a build of the
17623
- * pinned model for its engine format, or dropped out. The remedy is a model /
17624
- * engine change, not a per-camera one. Non-zero here always comes with
17625
- * `complete: false`.
17523
+ * The text alone is a DISPLAY NAME, and a display name is renameable: a
17524
+ * notification rule authored on "Gianluca" stopped matching the moment the
17525
+ * operator fixed the spelling in the gallery, and nothing said so. The id is
17526
+ * the thing that does not move, so it is what a rule matches on
17527
+ * (`NcConditions.identities`) and the text is what a human is shown.
17528
+ *
17529
+ * Absent when the label names no gallery row — a plate the OCR read but no
17530
+ * vehicle claims, a sub-class, a species, any tier-1 value.
17626
17531
  */
17627
- noCapableNode: number(),
17628
- failed: number(),
17629
- /** Set once a pass ends: true only when EVERYTHING was covered. */
17630
- complete: boolean().nullable(),
17631
- startedAtMs: number().nullable(),
17632
- finishedAtMs: number().nullable(),
17633
- /** Present when the pass ended by throwing. */
17634
- error: string().nullable()
17532
+ identityId: string().optional()
17635
17533
  });
17636
- DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
17637
- deviceId: number(),
17638
- trackId: string()
17639
- }), TrackSchema.nullable()), method(object({
17640
- deviceId: number(),
17641
- since: number().optional(),
17642
- until: number().optional(),
17643
- limit: number().optional(),
17644
- /** Spatial filter — only tracks whose trajectory intersects the zone
17645
- * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
17646
- * envelope columns, then precisely tested per position. Tracks with
17647
- * an unknown envelope (no frame dims at persist time) always match. */
17648
- zone: TrackZoneFilterSchema.optional(),
17649
- /** See {@link TrackProjectionSchema}. Default `full` (backward
17650
- * compatible — omitting the field keeps today's exact behaviour). */
17651
- projection: TrackProjectionSchema.optional(),
17652
- /** Include stationary-promoted rows (parked objects handed to the
17653
- * stationary registry). Default false: the timeline lists passages,
17654
- * not parking records (operator decision, 2026-08-15). */
17655
- includeStationary: boolean().optional()
17656
- }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
17657
- deviceId: number(),
17658
- groupId: string().min(1)
17659
- }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
17660
- kind: "mutation",
17661
- auth: "admin"
17662
- }), 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({
17663
- deviceId: number(),
17664
- since: number().optional(),
17665
- until: number().optional(),
17666
- kinds: array(string()).optional(),
17667
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
17668
- }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
17669
- deviceId: number(),
17670
- since: number(),
17671
- until: number(),
17672
- bucketMs: number().int().positive()
17673
- }), array(object({
17674
- bucketStart: number(),
17675
- motion: number().int(),
17676
- object: number().int(),
17677
- audio: number().int()
17678
- })).readonly()), method(object({
17679
- deviceId: number(),
17680
- cutoffMs: number()
17681
- }), object({
17682
- motion: number().int(),
17683
- object: number().int(),
17684
- audio: number().int()
17685
- }), {
17686
- kind: "mutation",
17687
- auth: "admin"
17688
- }), method(object({
17689
- deviceId: number(),
17690
- cutoffMs: number()
17691
- }), TrackCascadeCountsSchema, {
17692
- kind: "mutation",
17693
- auth: "admin"
17694
- }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
17695
- kind: "mutation",
17696
- auth: "admin"
17697
- }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
17698
- kind: "mutation",
17699
- auth: "admin"
17700
- }), method(object({
17701
- deviceId: number(),
17702
- trackIds: array(string()).min(1)
17703
- }), object({
17704
- deleted: number().int(),
17705
- failed: array(string()).readonly()
17706
- }), {
17707
- kind: "mutation",
17708
- auth: "admin"
17709
- }), method(object({
17710
- /** Log/audit scope only — the trackId is globally unique on its own. */
17534
+ /**
17535
+ * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
17536
+ * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
17537
+ * track and its events always answer the same question the same way.
17538
+ *
17539
+ * Two scalar columns, not an array: every consumer wants "the coarse one" or
17540
+ * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
17541
+ * is tier 2, and each carries its own score + attribution.
17542
+ *
17543
+ * **Reading it.** What a human should be shown is `subLabel ?? label` — the
17544
+ * finest thing known. Before 4g the single `label` column held the finest
17545
+ * value, so a consumer that has not been updated reads the tier-1 slot and
17546
+ * shows nothing on a species-only row; that is why the migration puts every
17547
+ * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
17548
+ * and why the read surfaces were changed in the same train.
17549
+ *
17550
+ * **Writing it.** The slots are independent, which is the whole point: a
17551
+ * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
17552
+ * migratorius`), so fineness cannot regress by construction. Within a tier the
17553
+ * higher score wins. One rule, one implementation — see
17554
+ * `pipeline/label-tier.ts` in addon-post-analysis.
17555
+ */
17556
+ var TieredLabelFields = {
17557
+ /** Tier 1 — the sub-class. See {@link LabelTierSchema}. */
17558
+ label: string().optional(),
17559
+ /** Confidence of the tier-1 value, as reported by the deciding step. */
17560
+ labelScore: number().optional(),
17561
+ /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
17562
+ labelMeta: LabelAttributionSchema.optional(),
17563
+ /** Tier 2 — the instance. See {@link LabelTierSchema}. */
17564
+ subLabel: string().optional(),
17565
+ /** Confidence of the tier-2 value, as reported by the deciding step. */
17566
+ subLabelScore: number().optional(),
17567
+ /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
17568
+ subLabelMeta: LabelAttributionSchema.optional()
17569
+ };
17570
+ /** Per-camera slice of a training-export estimate. */
17571
+ var TrainingExportDeviceTotalsSchema = object({
17711
17572
  deviceId: number(),
17573
+ tracks: number().int(),
17574
+ files: number().int(),
17575
+ bytes: number().int()
17576
+ });
17577
+ /**
17578
+ * What a training export WOULD contain. Computed from media index rows only —
17579
+ * no blob is read to produce this.
17580
+ */
17581
+ var TrainingExportSummarySchema = object({
17582
+ generatedAt: number(),
17583
+ trackCount: number().int(),
17584
+ fileCount: number().int(),
17585
+ byteCount: number().int(),
17586
+ /** More marked tracks exist than a single pass carries. */
17587
+ truncated: boolean(),
17588
+ devices: array(TrainingExportDeviceTotalsSchema).readonly()
17589
+ });
17590
+ var TrackSchema = object({
17712
17591
  trackId: string(),
17713
- flags: TrackFlagsPatchSchema
17714
- }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
17715
- kind: "query",
17716
- auth: "admin"
17717
- }), method(object({
17718
- olderThanMs: number(),
17719
- reason: OpsLogReasonSchema.optional()
17720
- }), EventPruneCountsSchema, {
17721
- kind: "mutation",
17722
- auth: "admin"
17723
- }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
17724
- kind: "mutation",
17725
- auth: "admin"
17726
- }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
17727
- kind: "mutation",
17728
- auth: "admin"
17729
- }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
17730
- kind: "mutation",
17731
- auth: "admin"
17732
- }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
17733
- kind: "mutation",
17734
- auth: "admin"
17735
- }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
17736
- kind: "mutation",
17737
- auth: "admin"
17738
- }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
17739
- kind: "mutation",
17740
- auth: "admin"
17741
- }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
17742
- kind: "query",
17743
- auth: "admin"
17744
- }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
17745
- kind: "query",
17746
- auth: "admin"
17747
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
17748
- kind: "query",
17749
- auth: "admin"
17750
- }), method(object({
17751
- /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
17752
- * `deviceId`, deliberately: `deviceId` would make this device-bound and
17753
- * route it at one camera's owner, and "every camera" would stop being
17754
- * expressible at all. */
17755
- deviceIds: array(number()).optional(),
17756
- limit: number().int().min(1).max(500).optional()
17757
- }), array(RetrainTrackSchema).readonly(), {
17758
- kind: "query",
17759
- auth: "admin"
17760
- }), method(object({ trackId: string() }), RetrainFrameListSchema, {
17761
- kind: "query",
17762
- auth: "admin"
17763
- }), method(object({
17764
17592
  deviceId: number(),
17765
- trackId: string(),
17766
- mediaKeys: array(string()).min(1)
17767
- }), RetrainFrameSelectionSchema, {
17768
- kind: "mutation",
17769
- auth: "admin"
17770
- }), method(object({
17593
+ className: string(),
17594
+ ...TieredLabelFields,
17595
+ producingDeviceName: string().optional(),
17596
+ /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
17597
+ source: TrackSourceSchema.optional(),
17598
+ firstSeen: number(),
17599
+ lastSeen: number(),
17600
+ /** Frame-rate position history (subject to maxPositionHistory cap). */
17601
+ positions: array(TrackPositionSchema).readonly(),
17602
+ /** Periodic snapshots at snapshotIntervalMs cadence (subject to
17603
+ * saveThumbnails policy). */
17604
+ snapshots: array(TrackSnapshotSchema).readonly(),
17605
+ /** Deduplicated zones the track has entered at least once. Zone IDS. */
17606
+ zonesVisited: array(string()).readonly(),
17607
+ /**
17608
+ * Human NAMES for {@link zonesVisited}, resolved at READ time against the
17609
+ * `zones` capability.
17610
+ *
17611
+ * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
17612
+ * and no card can render — so every free-text search surface was structurally
17613
+ * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
17614
+ * just returned nothing. Resolving here rather than in each client keeps ONE
17615
+ * derivation and costs the clients no extra call (the `zones` cap is
17616
+ * per-device, so a client-side resolve would be a per-camera fan-out on a
17617
+ * surface built to avoid exactly that).
17618
+ *
17619
+ * Resolved, never invented: a zone deleted since the track was written has no
17620
+ * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
17621
+ * two are not positionally aligned. Absent when the track visited no zone, or
17622
+ * when the zone catalogue could not be read.
17623
+ */
17624
+ zoneNames: array(string()).readonly().optional(),
17625
+ /** Deduplicated set of detector classes observed for this track over its
17626
+ * life (a track may be reclassified, e.g. person→vehicle). Absent on
17627
+ * legacy rows written before class accumulation shipped. */
17628
+ classes: array(string()).readonly().optional(),
17629
+ /** Cumulative normalized distance travelled (0..1 units = full frame width). */
17630
+ totalDistance: number(),
17631
+ state: TrackStateSchema,
17632
+ active: boolean(),
17633
+ /** Deterministic key-event importance score in [0,1] (server-computed at
17634
+ * track expiry, recomputed on late label). Absent on legacy rows written
17635
+ * before scoring shipped — consumers degrade to absence / compute-on-read. */
17636
+ importance: number().optional(),
17637
+ /** Id of the track's highest-confidence ObjectEvent (its representative
17638
+ * "best" frame). Absent when the track produced no object events. */
17639
+ bestEventId: string().optional(),
17640
+ /** Tag of the importance sub-signal that dominated the score
17641
+ * (identity|dwell|proximity|class|confidence|travel|zone). */
17642
+ importanceReason: string().optional(),
17643
+ /** Audio-classification labels heard on the camera during the track's
17644
+ * life (score ≥ device `classificationMinScore`), aggregated per label.
17645
+ * Absent on legacy rows / tracks with no confident audio. */
17646
+ audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
17647
+ /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
17648
+ * Populated from the persisted envelope columns on historical reads;
17649
+ * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
17650
+ envelope: TrackEnvelopeSchema.optional(),
17651
+ /**
17652
+ * A face DETECTOR found a face on this track — nothing more. It says the
17653
+ * detail plane produced a `face` detail; it does NOT say the face was
17654
+ * embedded, matched, above `minFacePx`, or that the recognizer was even
17655
+ * enabled. Set once and never cleared.
17656
+ *
17657
+ * **This exists so "face present but not recognised" is expressible.** A
17658
+ * recognised identity lands in `subLabel` (attributed to the face chain via
17659
+ * `subLabelMeta.stepId`), so before this field a track with an unmatched face
17660
+ * and a track with no face at all were byte-identical on the wire and no
17661
+ * surface could tell them apart. The read is `hasFace === true && subLabel
17662
+ * === undefined`.
17663
+ *
17664
+ * **Absent ≠ false.** Every row written before the column existed omits it,
17665
+ * and so does every server that predates the field — a consumer must test
17666
+ * `=== true` and render nothing otherwise, never infer "no face".
17667
+ */
17668
+ hasFace: boolean().optional(),
17669
+ /**
17670
+ * This track has a face row IN THE GALLERY: a crop **and** an embedding — a
17671
+ * face an operator could ASSIGN to an identity.
17672
+ *
17673
+ * The STRICT twin of {@link hasFace}, and the pair only earns its keep
17674
+ * because the two disagree. `hasFace` is stamped at the TOP of the face
17675
+ * branch, before every gate, and means no more than "a face detector produced
17676
+ * a face detail". This one is stamped at the single moment the gallery row
17677
+ * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
17678
+ * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
17679
+ * candidate gate, the imageless-track drop (no crop was ever captured) and
17680
+ * the crop-store drop. Everything between the detector and that insert can
17681
+ * legitimately refuse the face, so a flag written any earlier promises the
17682
+ * operator something to assign and delivers nothing.
17683
+ *
17684
+ * **Independent of recognition.** A face collected but never auto-matched is
17685
+ * still assignable — it is in fact the face an operator most wants to reach —
17686
+ * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
17687
+ * `subLabel`; this says only that the raw material exists.
17688
+ *
17689
+ * **Set once, never cleared.** A track that produced a gallery row produced
17690
+ * one; deleting the row later is the gallery's business, not this flag's.
17691
+ *
17692
+ * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
17693
+ * before the column omits it, and so does every server that predates the
17694
+ * field. A consumer must test `=== true` and render nothing otherwise —
17695
+ * never infer "no assignable face".
17696
+ */
17697
+ hasEmbeddedFace: boolean().optional(),
17698
+ /**
17699
+ * This subject CONTAINS a folded rider — a person the rider-pairing step
17700
+ * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
17701
+ * so the passage is tracked once and as a VEHICLE.
17702
+ *
17703
+ * It exists because the fold's record was dishonest. D34 and the code both
17704
+ * said "the person is not lost — it is reported so both entities stay on the
17705
+ * record"; in fact the pair went into a per-processor RAM field behind an
17706
+ * accessor nobody called, and every durable surface said `vehicle`, full
17707
+ * stop. This is the composition note that makes the row true.
17708
+ *
17709
+ * A COMPOSITION, never a class and never a label. "This vehicle contains a
17710
+ * person" is not an answer to "what is this" — both label tiers would refuse
17711
+ * a macro token anyway (D89), and correctly. Nothing here changes what the
17712
+ * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
17713
+ * and a `person` rule still does not fire for someone cycling past.
17714
+ *
17715
+ * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
17716
+ * the column, and every hub that predates the field, omits it. Test
17717
+ * `=== true` and render nothing otherwise — never infer "no rider".
17718
+ */
17719
+ hasRider: boolean().optional(),
17720
+ ...TrackFlagFields,
17721
+ ...TrackRetrainFields
17722
+ });
17723
+ var BaseEventFields = {
17724
+ id: string(),
17771
17725
  deviceId: number(),
17772
- trackId: string(),
17773
- frameId: string()
17774
- }), object({
17775
- removed: boolean(),
17776
- removedAnnotations: number().int()
17777
- }), {
17778
- kind: "mutation",
17779
- auth: "admin"
17780
- }), method(object({ frameId: string() }), object({
17726
+ timestamp: number()
17727
+ };
17728
+ var MotionEventSchema = object({
17729
+ ...BaseEventFields,
17730
+ kind: literal("motion"),
17731
+ regionCount: number(),
17732
+ /** Heavy JSON array — omitted in slim projection. */
17733
+ regions: array(object({
17734
+ bbox: BoundingBoxSchema,
17735
+ pixelCount: number(),
17736
+ intensity: number()
17737
+ })).readonly().optional(),
17738
+ /** Omitted in slim projection. */
17739
+ frameWidth: number().optional(),
17740
+ /** Omitted in slim projection. */
17741
+ frameHeight: number().optional(),
17742
+ /** Populated by B5 (recording playback URL for this event). */
17743
+ mediaUrl: string().optional()
17744
+ });
17745
+ /**
17746
+ * Which detection SOURCE produced an object event. `pipeline` = the ML
17747
+ * detection pipeline (decoded-frame inference); `onboard` = the camera's
17748
+ * native on-device AI. Both flow through the SAME analysis layers (zoning,
17749
+ * tracking, per-kind persistence) but stay distinguishable so consumers
17750
+ * (advanced-notifier, occupancy, …) can select which source(s) to act on.
17751
+ * Absent on legacy rows ⇒ treat as `pipeline`.
17752
+ */
17753
+ var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
17754
+ /**
17755
+ * The confirmed zone crossing that produced an object event. Present ONLY on
17756
+ * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
17757
+ * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
17758
+ * appearance event carry none, so a rule asking for a direction fails closed
17759
+ * on them.
17760
+ *
17761
+ * Exactly ONE crossing per event: the emitter turns each confirmed crossing
17762
+ * into its own event, so a frame in which a track enters A while leaving B
17763
+ * produces two events with two directions — never one ambiguous row.
17764
+ *
17765
+ * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
17766
+ * membership the box has NOW, and by definition it no longer contains the zone
17767
+ * that was just left. Without the id here, a zone-scoped rule could never match
17768
+ * the exit it asked for.
17769
+ */
17770
+ var ZoneCrossingSchema = object({
17771
+ direction: _enum(["enter", "exit"]),
17772
+ /** Admin zone id crossed. */
17773
+ zoneId: string(),
17774
+ /** Zone display name at crossing time (falls back to the id). */
17775
+ zoneName: string().optional()
17776
+ });
17777
+ var ObjectEventSchema = object({
17778
+ ...BaseEventFields,
17779
+ kind: literal("object"),
17780
+ /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
17781
+ source: DetectionSourceSchema.optional(),
17782
+ /**
17783
+ * Inference-frame id shared by every object event emitted from the SAME frame
17784
+ * — the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
17785
+ * 2 people + 1 dog) under one full frame, and link a track's frames over time
17786
+ * (group by `trackId`, pick a representative `frameId` as the parent frame).
17787
+ * Optional for backward-compat with pre-existing rows / the slim projection
17788
+ * includes it (it is light). Absent on rows written before this field.
17789
+ */
17790
+ frameId: string().optional(),
17791
+ /** Omitted in slim projection. */
17792
+ trackId: string().optional(),
17793
+ className: string(),
17794
+ ...TieredLabelFields,
17795
+ /** Omitted in slim projection. */
17796
+ confidence: number().optional(),
17797
+ /** Heavy JSON — omitted in slim projection. */
17798
+ bbox: BoundingBoxSchema.optional(),
17799
+ /** Heavy JSON — omitted in slim projection. */
17800
+ zones: array(string()).readonly().optional(),
17801
+ /** Omitted in slim projection. */
17802
+ state: TrackStateSchema.optional(),
17803
+ /**
17804
+ * The zone crossing this event IS, when it is one. Absent on every other
17805
+ * event kind (movement state, appearance, package) — see
17806
+ * {@link ZoneCrossingSchema}. Omitted in slim projection.
17807
+ */
17808
+ zoneCrossing: ZoneCrossingSchema.optional(),
17809
+ /** Detection-frame dimensions in pixels — let consumers normalize the
17810
+ * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
17811
+ frameWidth: number().optional(),
17812
+ frameHeight: number().optional(),
17813
+ /** MediaStore key for the crop attached to this event (if any). */
17814
+ mediaKey: string().optional(),
17815
+ /** Design B: MediaStore key of the track's native-resolution key frame (the
17816
+ * best-detection full frame). Resolve via the event-media data-plane
17817
+ * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
17818
+ * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
17819
+ * sources — consumers fall back to `mediaKey` (the tight crop). */
17820
+ keyFrameMediaKey: string().optional(),
17821
+ /** Populated by B5 (recording playback URL for this event). */
17822
+ mediaUrl: string().optional(),
17823
+ /** The parent track's key-event importance [0,1], propagated to every object
17824
+ * event of the track (so an event row can be sorted by importance without a
17825
+ * track join). Absent on legacy rows / before the track was scored. */
17826
+ importance: number().optional()
17827
+ });
17828
+ var AudioEventSchema = object({
17829
+ ...BaseEventFields,
17830
+ kind: literal("audio"),
17831
+ rms: number(),
17832
+ dbfs: number(),
17833
+ classification: object({
17834
+ className: string(),
17835
+ originalClass: string().optional(),
17836
+ score: number()
17837
+ }).optional(),
17838
+ /** Populated by B5 (recording playback URL for this event). */
17839
+ mediaUrl: string().optional()
17840
+ });
17841
+ var MediaFileKindEnum = _enum([
17842
+ "crop",
17843
+ "thumbnail",
17844
+ "snapshot",
17845
+ "firstFrame",
17846
+ "lastFrame",
17847
+ "fullFrame",
17848
+ "fullFrameBoxed",
17849
+ "faceCrop",
17850
+ "plateCrop",
17851
+ "keyFrame",
17852
+ "keyFrameSmall",
17853
+ "thumbnailSmall"
17854
+ ]);
17855
+ var MediaFileSchema = object({
17856
+ key: string(),
17857
+ kind: MediaFileKindEnum,
17781
17858
  base64: string(),
17782
- width: number().int(),
17783
- height: number().int()
17784
- }), {
17785
- kind: "query",
17786
- auth: "admin"
17787
- }), method(object({
17788
- deviceId: number(),
17789
- trackId: string(),
17790
- frameId: string(),
17791
- subject: RetrainAssistSubjectSchema,
17792
- /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
17793
- nodeId: string().optional()
17794
- }), RetrainAssistResultSchema, {
17795
- kind: "mutation",
17796
- auth: "admin"
17797
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
17798
- kind: "query",
17799
- auth: "admin"
17800
- }), method(object({
17801
- deviceId: number(),
17859
+ sizeBytes: number(),
17860
+ timestamp: number()
17861
+ });
17862
+ /**
17863
+ * One media row WITHOUT its bytes.
17864
+ *
17865
+ * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
17866
+ * 140 s track), and a client that renders tiles from the media data plane needs
17867
+ * to know only WHAT EXISTS — the bytes then arrive per tile, lazily, over HTTP
17868
+ * with an immutable cache, instead of all at once inside a tRPC response that
17869
+ * blocks the whole view.
17870
+ *
17871
+ * `sizeBytes` is carried because it is what lets a client decide between the
17872
+ * stored blob and a `?variant=thumb` rendering without fetching either.
17873
+ */
17874
+ var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
17875
+ /**
17876
+ * The MACRO tier of an annotation — a CLOSED set.
17877
+ *
17878
+ * This is what the exported detector predicts, so a typo here is a new class
17879
+ * with one example in it. `label` and `subLabel` are open strings by contrast:
17880
+ * the whole point of the page is teaching the model things it does not know
17881
+ * yet, and constraining that vocabulary would make it useless.
17882
+ *
17883
+ * A macro class is NEVER a label. The provider refuses a write whose `label` or
17884
+ * `subLabel` is one of these values, in any casing, because once `person`
17885
+ * exists in both tiers "every person box" stops being answerable without
17886
+ * knowing every string anyone ever typed — and the damage is retroactive.
17887
+ */
17888
+ var RetrainMacroClassSchema = _enum([
17889
+ "person",
17890
+ "vehicle",
17891
+ "animal",
17892
+ "package",
17893
+ "face",
17894
+ "plate"
17895
+ ]);
17896
+ /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
17897
+ var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
17898
+ /** Did a human draw this box, or did the assist propose it? */
17899
+ var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
17900
+ /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
17901
+ var RetrainBboxSchema = object({
17902
+ x: number(),
17903
+ y: number(),
17904
+ w: number(),
17905
+ h: number()
17906
+ });
17907
+ /**
17908
+ * One annotated subject.
17909
+ *
17910
+ * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
17911
+ * (letterboxed root / zone-cropped package / subject-cropped classifier) are
17912
+ * derived from it at export and never stored — storing them is how one feature
17913
+ * space ends up holding two crops of the same subject (D52).
17914
+ */
17915
+ var RetrainAnnotationSchema = object({
17916
+ id: string(),
17802
17917
  trackId: string(),
17803
- frameId: string(),
17804
- annotations: array(RetrainAnnotationDraftSchema)
17805
- }), array(RetrainAnnotationSchema).readonly(), {
17806
- kind: "mutation",
17807
- auth: "admin"
17808
- }), method(object({
17809
- deviceId: number(),
17810
- trackId: string()
17811
- }), RetrainTransitionResultSchema, {
17812
- kind: "mutation",
17813
- auth: "admin"
17814
- }), method(object({
17815
17918
  deviceId: number(),
17816
- trackId: string()
17817
- }), RetrainTransitionResultSchema, {
17818
- kind: "mutation",
17819
- auth: "admin"
17820
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
17821
- kind: "query",
17822
- auth: "admin"
17823
- }), method(object({
17824
- eventId: string(),
17825
- kind: MediaFileKindEnum.optional(),
17826
- deviceId: number()
17827
- }), array(MediaFileSchema).readonly()), method(object({
17828
- trackId: string(),
17829
- kinds: array(MediaFileKindEnum).optional(),
17830
- deviceId: number()
17831
- }), array(MediaFileSchema).readonly()), method(object({
17919
+ /** The COPY in retrain storage — never the source track's media key. */
17920
+ mediaKey: string(),
17921
+ bbox: RetrainBboxSchema,
17922
+ macroClass: RetrainMacroClassSchema,
17923
+ label: string().optional(),
17924
+ subLabel: string().optional(),
17925
+ kind: RetrainAnnotationKindSchema,
17926
+ source: RetrainAnnotationSourceSchema,
17927
+ /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
17928
+ assistModelId: string().optional(),
17929
+ assistScore: number().optional(),
17930
+ exportedInBatch: string().optional(),
17931
+ createdAt: number()
17932
+ });
17933
+ /** The write form — the server owns `id`, `createdAt` and the frame binding. */
17934
+ var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
17935
+ id: true,
17936
+ trackId: true,
17937
+ deviceId: true,
17938
+ mediaKey: true,
17939
+ createdAt: true,
17940
+ exportedInBatch: true
17941
+ });
17942
+ /** A track sitting in `staging`, with everything the worklist needs to rank it. */
17943
+ var RetrainTrackSchema = object({
17832
17944
  trackId: string(),
17833
- deviceId: number()
17834
- }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
17835
- kind: "mutation",
17836
- auth: "admin"
17837
- }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
17838
- kind: "mutation",
17839
- auth: "admin"
17840
- }), method(object({}), RebuildStatusSchema), object({
17841
17945
  deviceId: number(),
17946
+ className: string(),
17947
+ label: string().optional(),
17948
+ firstSeen: number(),
17949
+ lastSeen: number(),
17950
+ /** How many frames the dataset already holds from this track. */
17951
+ frameCount: number().int(),
17952
+ /** How many subjects have been annotated on those frames. `0` with
17953
+ * `frameCount: 0` is exactly "staging, still to work". */
17954
+ annotationCount: number().int()
17955
+ });
17956
+ /** A frame the picker may offer — an index row, no blob was read to produce it. */
17957
+ var RetrainFrameCandidateSchema = object({
17958
+ mediaKey: string(),
17959
+ kind: MediaFileKindEnum,
17842
17960
  timestamp: number(),
17843
- frameWidth: number(),
17844
- frameHeight: number(),
17845
- detections: array(OverlayDetectionSchema).readonly()
17846
- }), object({
17961
+ sizeBytes: number().int(),
17962
+ /** A copy of this original already exists — selecting it is free and cannot
17963
+ * fail, whatever became of the original. */
17964
+ copied: boolean()
17965
+ });
17966
+ /** A frame the dataset OWNS: bytes copied at selection time. */
17967
+ var RetrainFrameSchema = object({
17968
+ frameId: string(),
17847
17969
  deviceId: number(),
17848
17970
  trackId: string(),
17849
- className: string()
17971
+ /** Provenance only. It may already point at nothing — that is expected. */
17972
+ sourceMediaKey: string(),
17973
+ sourceKind: MediaFileKindEnum,
17974
+ sizeBytes: number().int(),
17975
+ width: number().int(),
17976
+ height: number().int(),
17977
+ copiedAt: number()
17978
+ });
17979
+ /** Why a copy-on-select could not be honoured — named, never a silent skip. */
17980
+ var RetrainCopyRefusalSchema = _enum([
17981
+ "source-missing",
17982
+ "unreadable-image",
17983
+ "write-failed"
17984
+ ]);
17985
+ var RetrainFrameSelectionSchema = object({
17986
+ copied: array(RetrainFrameSchema).readonly(),
17987
+ refused: array(object({
17988
+ sourceMediaKey: string(),
17989
+ reason: RetrainCopyRefusalSchema
17990
+ })).readonly()
17991
+ });
17992
+ var RetrainFrameListSchema = object({
17993
+ candidates: array(RetrainFrameCandidateSchema).readonly(),
17994
+ copies: array(RetrainFrameSchema).readonly(),
17995
+ /** What the page pre-selects — the native key frame when one survives. */
17996
+ autoPickMediaKey: string().optional()
17997
+ });
17998
+ /** What the operator asked the assist to look for. */
17999
+ var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
18000
+ kind: literal("package"),
18001
+ zone: RetrainBboxSchema.optional()
17850
18002
  }), object({
17851
- deviceId: number(),
17852
- trackId: string(),
17853
- className: string(),
17854
- durationMs: number()
18003
+ kind: literal("objects"),
18004
+ modelId: string(),
18005
+ minScore: number().optional()
18006
+ })]);
18007
+ /**
18008
+ * The assist's answer — a discriminated union, because "the model saw nothing"
18009
+ * and "this node cannot run that model" lead to different next moves and a
18010
+ * nullable result cannot tell them apart.
18011
+ */
18012
+ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
18013
+ kind: literal("proposed"),
18014
+ modelId: string(),
18015
+ stepId: string(),
18016
+ minScore: number(),
18017
+ /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
18018
+ proposals: array(RetrainAnnotationDraftSchema).readonly(),
18019
+ /** Returned by the runner but removed by the threshold. */
18020
+ belowThreshold: number().int()
17855
18021
  }), object({
18022
+ kind: literal("refused"),
18023
+ /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
18024
+ reason: string(),
18025
+ detail: string().optional()
18026
+ })]);
18027
+ /** The outcome of a lifecycle move owned by the retrain page. */
18028
+ var RetrainTransitionResultSchema = object({
18029
+ trackId: string(),
18030
+ /** Where the track ended up, whatever happened. */
18031
+ retrainStatus: RetrainStatusSchema,
18032
+ /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
18033
+ changed: boolean(),
18034
+ reason: _enum([
18035
+ "unknown-track",
18036
+ "no-frames-copied",
18037
+ "not-staging",
18038
+ "not-trained",
18039
+ "unchanged"
18040
+ ]).optional()
18041
+ });
18042
+ var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
18043
+ var MAX_EVENT_QUERY_LIMIT = 5e3;
18044
+ var DeviceEventQueryInput = object({
17856
18045
  deviceId: number(),
17857
- kind: EventKindSchema,
17858
- eventId: string(),
17859
- timestamp: number()
18046
+ since: number().optional(),
18047
+ until: number().optional(),
18048
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
18049
+ /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
18050
+ * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
18051
+ * exact behaviour. Callers may omit this field — the store defaults to
18052
+ * `full` when not provided. */
18053
+ projection: _enum(["full", "slim"]).optional()
17860
18054
  });
17861
- /**
17862
- * Reference to the frame's retained NATIVE surface + the parent crop's placement
17863
- * within the frame, so the executor can re-cut a leaf child ROI at native
17864
- * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
17865
- */
17866
- var NativeCropRefSchema = object({
17867
- /** Handle keying the retained native surface (node-pinned to its owner). */
17868
- handle: FrameHandleSchema,
17869
- /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
17870
- cropFrameSpace: object({
17871
- x: number(),
17872
- y: number(),
17873
- w: number(),
17874
- h: number()
17875
- })
18055
+ var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
18056
+ var RecentTracksQueryInput = object({
18057
+ /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
18058
+ deviceIds: array(number()),
18059
+ /** Window lower bound on `lastSeen` (inclusive). */
18060
+ since: number().optional(),
18061
+ /** Window upper bound on `lastSeen` (inclusive). */
18062
+ until: number().optional(),
18063
+ /** Page size. Default 200, max 1000. */
18064
+ limit: number().int().min(1).max(1e3).default(200),
18065
+ /** Opaque continuation cursor from a previous page's `nextCursor`.
18066
+ * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
18067
+ cursor: string().optional(),
18068
+ /** See {@link TrackProjectionSchema}. Default `full`. */
18069
+ projection: TrackProjectionSchema.optional(),
18070
+ /** Include stationary-promoted rows (parked objects). Default false: the
18071
+ * feed lists passages; parking records live on the stationary registry. */
18072
+ includeStationary: boolean().optional()
17876
18073
  });
17877
- object({
17878
- crop: object({
17879
- left: number(),
17880
- top: number(),
17881
- width: number().positive(),
17882
- height: number().positive()
17883
- }).optional(),
17884
- content: object({
17885
- width: number().int().positive(),
17886
- height: number().int().positive()
17887
- }),
17888
- fit: _enum(["stretch", "contain"]),
17889
- format: _enum([
17890
- "rgb",
17891
- "gray",
17892
- "jpeg"
17893
- ])
18074
+ var RecentTracksPageSchema = object({
18075
+ /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
18076
+ tracks: array(TrackSchema).readonly(),
18077
+ /** Cursor for the next page, or null when this page is the last. */
18078
+ nextCursor: string().nullable()
17894
18079
  });
17895
- var FrameRefSchema = object({
17896
- registryId: string().min(1),
17897
- id: string().min(1),
17898
- width: number().int().positive(),
17899
- height: number().int().positive(),
17900
- format: _enum(["rgb", "gray"]),
17901
- timestamp: number(),
17902
- capturedAt: number().optional()
18080
+ var LIST_GROUPS_DEFAULT_LIMIT = 40;
18081
+ var LIST_GROUPS_MAX_LIMIT = 100;
18082
+ var AnalyticsGroupRecordSchema = object({
18083
+ id: string(),
18084
+ deviceId: number().int(),
18085
+ openedAt: number().int(),
18086
+ closedAt: number().int(),
18087
+ timestamp: number().int(),
18088
+ memberCount: number().int(),
18089
+ memberTrackIds: array(string()).readonly(),
18090
+ className: string(),
18091
+ classes: array(string()).readonly(),
18092
+ /** Relative event-media path, or null when the group has no picture yet. */
18093
+ mediaUrl: string().nullable(),
18094
+ singleton: boolean()
17903
18095
  });
17904
- var ModelFormatSchema$1 = _enum([
17905
- "onnx",
17906
- "coreml",
17907
- "openvino",
17908
- "tflite",
17909
- "pt",
17910
- "gguf"
17911
- ]);
17912
- var PipelineSlotSchema = _enum([
17913
- "detector",
17914
- "cropper",
17915
- "classifier",
17916
- "refiner",
17917
- "audio-classifier"
17918
- ]);
17919
- var PipelineEngineChoiceSchema = object({
17920
- runtime: _enum(["node", "python"]),
17921
- backend: string(),
17922
- format: ModelFormatSchema$1,
17923
- device: string().optional()
18096
+ var AnalyticsGroupMemberSchema = object({
18097
+ trackId: string(),
18098
+ deviceId: number().int(),
18099
+ className: string(),
18100
+ firstSeen: number().int(),
18101
+ lastSeen: number().int(),
18102
+ mediaUrl: string().nullable()
17924
18103
  });
17925
- var AvailableEngineSchema = object({
17926
- engine: PipelineEngineChoiceSchema,
17927
- devices: array(object({
17928
- id: string(),
17929
- label: string(),
17930
- description: string().optional()
17931
- })).readonly(),
17932
- defaultDevice: string()
18104
+ var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
18105
+ var ListGroupsQueryInput = object({
18106
+ /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
18107
+ deviceIds: array(number()),
18108
+ /** Window lower bound on `closedAt` (inclusive). */
18109
+ since: number().optional(),
18110
+ /** Window upper bound on `openedAt` (inclusive). */
18111
+ until: number().optional(),
18112
+ limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
18113
+ /** Opaque continuation cursor from a previous page's `nextCursor`. */
18114
+ cursor: string().optional()
17933
18115
  });
17934
- var PipelineDefaultStepSchema = lazy(() => object({
17935
- addonId: string(),
17936
- addonName: string(),
17937
- slot: PipelineSlotSchema,
17938
- inputClasses: array(string()).readonly(),
17939
- outputClasses: array(string()).readonly(),
17940
- enabled: boolean(),
17941
- modelId: string(),
17942
- children: array(PipelineDefaultStepSchema).readonly(),
17943
- group: string().optional(),
17944
- settings: record(string(), unknown()).optional()
17945
- }));
17946
- var PipelineTemplateStepSchema = lazy(() => object({
17947
- addonId: string(),
17948
- enabled: boolean(),
17949
- modelId: string(),
17950
- children: array(PipelineTemplateStepSchema).readonly(),
17951
- settings: record(string(), unknown()).optional()
17952
- }));
17953
- var PipelineTemplateSchema$1 = object({
17954
- id: string(),
17955
- name: string(),
17956
- createdAt: string(),
17957
- updatedAt: string(),
17958
- engine: PipelineEngineChoiceSchema,
17959
- steps: array(PipelineTemplateStepSchema).readonly()
18116
+ var ListGroupsPageSchema = object({
18117
+ groups: array(AnalyticsGroupRecordSchema).readonly(),
18118
+ nextCursor: string().nullable()
18119
+ });
18120
+ var KeyEventQueryInput = object({
18121
+ deviceId: number(),
18122
+ /** Window lower bound (track firstSeen ≥ since). */
18123
+ since: number(),
18124
+ /** Window upper bound (track firstSeen ≤ until). */
18125
+ until: number(),
18126
+ limit: number().int().min(1).max(200).default(50),
18127
+ /** Drop tracks scoring below this importance. */
18128
+ minImportance: number().min(0).max(1).optional(),
18129
+ /** Restrict to a single class (e.g. 'person'). */
18130
+ classFilter: string().optional()
17960
18131
  });
17961
- var PipelineModelOptionSchema = object({
18132
+ var KeyEventSchema = object({
18133
+ /** The representative event id (the track's best ObjectEvent, else its trackId). */
17962
18134
  id: string(),
17963
- name: string(),
17964
- formats: record(string(), object({
17965
- downloaded: boolean(),
17966
- sizeMB: number()
17967
- })),
17968
- group: ModelVariantGroupSchema.optional(),
17969
- legacy: boolean().optional(),
17970
- provider: ModelProviderIdSchema.optional()
18135
+ trackId: string(),
18136
+ /** Track start time (firstSeen). */
18137
+ timestamp: number(),
18138
+ className: string(),
18139
+ ...TieredLabelFields,
18140
+ importance: number(),
18141
+ /** Highest-confidence ObjectEvent id for the track (empty when none). */
18142
+ bestEventId: string(),
18143
+ /** Track lifetime in ms (lastSeen - firstSeen). */
18144
+ windowMs: number().optional(),
18145
+ ...TrackFlagFields,
18146
+ ...TrackRetrainFields
17971
18147
  });
17972
- var ConfigFieldBridge = custom();
17973
- var PipelineAddonSchemaSchema = object({
17974
- id: string(),
17975
- name: string(),
17976
- slot: PipelineSlotSchema,
17977
- inputClasses: array(string()).readonly(),
17978
- outputClasses: array(string()).readonly(),
17979
- childSlots: array(PipelineSlotSchema).readonly(),
17980
- models: array(PipelineModelOptionSchema).readonly(),
17981
- defaultModelId: string(),
17982
- defaultModelIdByFormat: record(string(), string()).optional(),
17983
- enabledByDefault: boolean().optional(),
17984
- backfillIntoExistingOverrides: boolean().optional(),
17985
- defaultConfidence: number(),
17986
- group: string().optional(),
17987
- configSchema: array(ConfigFieldBridge).readonly().optional()
18148
+ object({
18149
+ trackId: string(),
18150
+ className: string(),
18151
+ confidence: number(),
18152
+ bbox: BoundingBoxSchema,
18153
+ zones: array(string()).readonly(),
18154
+ state: TrackStateSchema
17988
18155
  });
17989
- var PipelineSlotSchemaSchema = object({
17990
- id: PipelineSlotSchema,
17991
- label: string(),
17992
- priority: number(),
17993
- parentSlot: PipelineSlotSchema.nullable(),
17994
- addons: array(PipelineAddonSchemaSchema).readonly()
18156
+ var OverlayDetectionSchema = looseObject({
18157
+ id: string(),
18158
+ kind: _enum(["first-level", "detail"]),
18159
+ macroClass: string(),
18160
+ score: number(),
18161
+ bbox: object({
18162
+ x: number(),
18163
+ y: number(),
18164
+ width: number(),
18165
+ height: number()
18166
+ }),
18167
+ labels: array(looseObject({
18168
+ label: string(),
18169
+ score: number()
18170
+ })).readonly(),
18171
+ parentId: string().optional()
17995
18172
  });
17996
- var PipelineSchemaSchema = object({
17997
- availableEngines: array(AvailableEngineSchema).readonly(),
17998
- selectedEngine: PipelineEngineChoiceSchema,
17999
- slots: array(PipelineSlotSchemaSchema).readonly()
18173
+ var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
18174
+ var SearchObjectEventsInput = object({
18175
+ text: string(),
18176
+ deviceId: number().optional(),
18177
+ since: number().optional(),
18178
+ until: number().optional(),
18179
+ classFilter: string().optional(),
18180
+ limit: number().default(50),
18181
+ minScore: number().min(0).max(1).default(.2)
18000
18182
  });
18001
- var EngineProvisioningSchema = object({
18002
- runtimeId: _enum([
18003
- "onnx",
18004
- "openvino",
18005
- "coreml",
18006
- "edgetpu"
18007
- ]).nullable(),
18008
- device: string().nullable(),
18009
- state: _enum([
18010
- "idle",
18011
- "installing",
18012
- "verifying",
18013
- "ready",
18014
- "failed"
18015
- ]),
18016
- progress: number().optional(),
18017
- error: string().optional(),
18018
- nextRetryAt: number().optional(),
18019
- /**
18020
- * Gate A (config-correctness gate at engine change): human-readable
18021
- * config issues surfaced EAGERLY when the node's engine changes — model
18022
- * substitutions ("chose X, running Y") and zero-build steps ("no model
18023
- * has a <format> build"). Additive/optional: informational only, never
18024
- * enforced here — `assertEngineReady` (readiness) still gates inference.
18025
- * Absent/empty when the node-default tree resolves cleanly.
18026
- */
18027
- configIssues: array(string()).optional()
18183
+ var TrackCascadeCountsSchema = object({
18184
+ /** Persisted track roots deleted (authoritative). */
18185
+ tracks: number().int(),
18186
+ /** Object events removed with their tracks (best-effort; see note above). */
18187
+ events: number().int(),
18188
+ /** Track/face/plate-owned media removed (best-effort). Never identity media. */
18189
+ media: number().int(),
18190
+ /** Unassigned (non-enrolled) face reads removed (best-effort). */
18191
+ faces: number().int(),
18192
+ /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
18193
+ plates: number().int(),
18194
+ /** Per-track CLIP search vectors removed (best-effort). */
18195
+ embeddings: number().int(),
18196
+ /** Group membership + group rows removed with their last member (best-effort). */
18197
+ groups: number().int()
18028
18198
  });
18029
- var PipelineStepInputSchema = lazy(() => object({
18030
- addonId: string(),
18031
- modelId: string().optional(),
18032
- enabled: boolean().default(true),
18033
- children: array(PipelineStepInputSchema).optional(),
18034
- settings: record(string(), unknown()).optional(),
18035
- jumpDeviceKey: string().optional()
18036
- }));
18037
- var ModelSubstitutionSchema = object({
18038
- addonId: string(),
18039
- chosen: string(),
18040
- running: string(),
18041
- format: string()
18199
+ /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
18200
+ var DiskReconcileCountsSchema = object({
18201
+ mediaDropped: number().int(),
18202
+ tracks: number().int(),
18203
+ events: number().int()
18042
18204
  });
18043
- var PipelineValidationIssueSchema = object({
18044
- addonId: string(),
18045
- kind: _enum(["unknown-addon", "no-format-build"]),
18046
- detail: string()
18205
+ /** Event-store footprint for one camera. */
18206
+ var EventStoreDeviceFootprintSchema = object({
18207
+ deviceId: number(),
18208
+ /** Persisted event rows (motion + object + audio) for the camera. */
18209
+ rows: number().int(),
18210
+ /** Event-owned media bytes on disk for the camera. */
18211
+ bytes: number().int()
18047
18212
  });
18048
- var PipelineValidationResultSchema = object({
18049
- ok: boolean(),
18050
- issues: array(PipelineValidationIssueSchema).readonly(),
18051
- substitutions: array(ModelSubstitutionSchema).readonly(),
18052
- /** The node's `currentEngine.format` this validation ran against. */
18053
- format: string()
18213
+ /** Aggregate event-store footprint: global totals + per-camera breakdown. */
18214
+ var EventStoreFootprintSchema = object({
18215
+ totalRows: number().int(),
18216
+ totalBytes: number().int(),
18217
+ devices: array(EventStoreDeviceFootprintSchema).readonly()
18054
18218
  });
18055
- var ReferenceImageEntrySchema = object({
18056
- filename: string(),
18057
- stepIds: array(string()).readonly().optional()
18219
+ /** Per-kind counts returned by the event-prune / device-delete mutations. */
18220
+ var EventPruneCountsSchema = object({
18221
+ motion: number().int(),
18222
+ object: number().int(),
18223
+ audio: number().int()
18058
18224
  });
18059
- var ReferenceImageBodySchema = object({
18060
- base64: string(),
18061
- filename: string()
18225
+ /**
18226
+ * Re-embed stored tracks from their key frames.
18227
+ *
18228
+ * The reason this is an operator-callable method and not a migration script:
18229
+ * every knob that decides what a vector MEANS — encoder model, crop margin,
18230
+ * squaring — is only changeable if the existing vectors can be regenerated.
18231
+ * Mixing feature spaces in one index makes cosine scores incomparable, and the
18232
+ * symptom is a quality regression with no visible cause.
18233
+ */
18234
+ var RebuildObjectEmbeddingsInput = object({
18235
+ /** Restrict to one camera. Omit for the whole fleet. */
18236
+ deviceId: number().optional(),
18237
+ since: number().optional(),
18238
+ until: number().optional(),
18239
+ /** Stop after this many tracks; the result reports whether more remain. */
18240
+ maxTracks: number().int().positive().optional(),
18241
+ /**
18242
+ * Run every embedding on THIS node instead of round-robining the fleet.
18243
+ *
18244
+ * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
18245
+ * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
18246
+ * calling it that would pin the rebuild REQUEST itself to that node — the
18247
+ * rebuild orchestration lives on the hub, and only the per-track step runs
18248
+ * remotely. This field is data; the per-track pin is applied inside.
18249
+ *
18250
+ * Absent ⇒ round-robin over every online node whose runner can serve the
18251
+ * pinned model.
18252
+ */
18253
+ executeOnNodeId: string().optional(),
18254
+ /**
18255
+ * Milliseconds to wait between tracks; omit for the built-in default, `0` to
18256
+ * run flat out.
18257
+ *
18258
+ * A rebuild is bulk maintenance on hub-main's single thread. Measured
18259
+ * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
18260
+ * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
18261
+ * force is logged at start and finish so a deliberately slow pass reads
18262
+ * differently from a stalled one.
18263
+ */
18264
+ pacingMs: number().int().nonnegative().optional()
18062
18265
  });
18063
- var ReferenceAudioEntrySchema = object({
18064
- filename: string(),
18065
- sizeKb: number()
18266
+ /**
18267
+ * Result of emptying the CLIP index.
18268
+ *
18269
+ * The clean slate before a policy change: a new crop margin or encoder model
18270
+ * leaves two feature spaces in one index whose cosine scores are not
18271
+ * comparable, so wiping and rebuilding is the only way to be sure every vector
18272
+ * means the same thing.
18273
+ */
18274
+ var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
18275
+ /**
18276
+ * Acknowledgement that a rebuild STARTED.
18277
+ *
18278
+ * The pass costs ~1s per track — 45 minutes for a 2,600-track fleet — so it
18279
+ * runs detached and this returns immediately. Waiting for it made the client
18280
+ * time out while the work carried on server-side, which is the worst of both:
18281
+ * no result and no way to know it was still going. Poll
18282
+ * `getObjectEmbeddingRebuildStatus` for progress.
18283
+ */
18284
+ var RebuildObjectEmbeddingsResultSchema = object({
18285
+ started: boolean(),
18286
+ /** True when a pass was already running; the new request is ignored. */
18287
+ alreadyRunning: boolean()
18066
18288
  });
18067
- var ReferenceAudioBodySchema = object({ base64: string() });
18068
- var AudioBackendSchema = object({
18069
- id: string(),
18070
- name: string(),
18071
- description: string(),
18072
- available: boolean(),
18289
+ var RebuildStatusSchema = object({
18290
+ running: boolean(),
18291
+ scanned: number(),
18292
+ rebuilt: number(),
18293
+ /** Tracks whose key frame is gone — nothing to re-embed from. */
18294
+ missingKeyFrame: number(),
18295
+ /** Tracks with no usable detection box. */
18296
+ missingBbox: number(),
18297
+ /**
18298
+ * Tracks an executing node REFUSED rather than broke on — an unreadable key
18299
+ * frame, a step that threw. Separate from `failed` because the remedy is
18300
+ * different, and because a whole camera silently contributing zero vectors
18301
+ * is the shape of failure a rebuild must never hide.
18302
+ */
18303
+ notRunnable: number(),
18073
18304
  /**
18074
- * Raw classifier labels this backend can emit (e.g. YAMNet's
18075
- * 521-class set or Apple SoundAnalysis's 303-class set). Used by
18076
- * the benchmark UI to populate the `enabledMicroClasses` filter
18077
- * specific to the selected backend without a separate fetch.
18305
+ * The pass stopped because NO node could serve the pinned model.
18306
+ *
18307
+ * Distinct from `notRunnable` on purpose: that one says "this track was
18308
+ * refused", this one says "the cluster cannot do this work at all" — every
18309
+ * candidate node either lacks the `clip-embedding` step, lacks a build of the
18310
+ * pinned model for its engine format, or dropped out. The remedy is a model /
18311
+ * engine change, not a per-camera one. Non-zero here always comes with
18312
+ * `complete: false`.
18078
18313
  */
18079
- rawLabels: array(string()).readonly().optional()
18080
- });
18081
- var AudioCapabilitiesSchema = object({
18082
- activeBackend: string(),
18083
- availableBackends: array(AudioBackendSchema).readonly(),
18084
- sampleRate: number(),
18085
- chunkDurationMs: number()
18086
- });
18087
- var DownloadModelResultSchema = object({
18088
- filePath: string(),
18089
- sizeMB: number(),
18090
- durationMs: number()
18314
+ noCapableNode: number(),
18315
+ failed: number(),
18316
+ /** Set once a pass ends: true only when EVERYTHING was covered. */
18317
+ complete: boolean().nullable(),
18318
+ startedAtMs: number().nullable(),
18319
+ finishedAtMs: number().nullable(),
18320
+ /** Present when the pass ended by throwing. */
18321
+ error: string().nullable()
18091
18322
  });
18092
- /**
18093
- * Wrapper carrying a single test run's result. Replaces the legacy
18094
- * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
18095
- * canonical `AudioResult` from the Phase 6 output rework: one
18096
- * `AudioDetection` per class above `minScore`, top-N candidates in
18097
- * `debug.alternateLabels['audio-classifier']`, per-source timings in
18098
- * `debug.stepTimings`. The outer `success`/`error` fields stay so the
18099
- * benchmark UI can still report a clean failure when the classifier
18100
- * cap isn't available.
18101
- */
18102
- var AudioTestResultSchema = object({
18103
- success: boolean(),
18104
- error: string().optional(),
18105
- frame: custom().optional()
18323
+ var ReplayFrameInputSchema = object({
18324
+ timestamp: number(),
18325
+ frame: PipelineRunResultBridge
18106
18326
  });
18107
- var PipelineConfigBridge = custom();
18108
- var ConfigUISchemaBridge = custom();
18109
- var ConfigUISchemaNullableBridge = custom();
18110
- var InferenceCapabilitiesBridge = custom();
18111
- var ModelAvailabilityListBridge = custom();
18112
- var PipelineRunResultBridge = custom();
18113
- method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
18114
- modelId: string(),
18115
- settings: record(string(), unknown()).readonly()
18116
- }))), method(object({ steps: record(string(), object({
18117
- modelId: string(),
18118
- settings: record(string(), unknown()).readonly()
18119
- })) }), object({ success: literal(true) }), {
18327
+ var RunReplayFrameProcessorResultSchema = object({ tracks: array(object({
18328
+ className: string(),
18329
+ firstSeenMs: number(),
18330
+ lastSeenMs: number(),
18331
+ /** Bbox of the track's FIRST matched detection, pixel-space in the clip's
18332
+ * frame — a representative box for the diff's `(className, window, IoU)`
18333
+ * pairing (`replay-diff.ts`). A replay does not need the full per-frame
18334
+ * trajectory production's `Track.positions` keeps. */
18335
+ bbox: BoundingBoxSchema,
18336
+ /** How many of the input frames this track matched a real detection on
18337
+ * (never a coasted/extrapolated frame) — the replay's own signal for "how
18338
+ * solid is this track", cheaper than re-deriving it from a trajectory. */
18339
+ framesMatched: number().int()
18340
+ })).readonly() });
18341
+ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
18342
+ deviceId: number(),
18343
+ trackId: string()
18344
+ }), TrackSchema.nullable()), method(object({
18345
+ deviceId: number(),
18346
+ since: number().optional(),
18347
+ until: number().optional(),
18348
+ limit: number().optional(),
18349
+ /** Spatial filter — only tracks whose trajectory intersects the zone
18350
+ * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
18351
+ * envelope columns, then precisely tested per position. Tracks with
18352
+ * an unknown envelope (no frame dims at persist time) always match. */
18353
+ zone: TrackZoneFilterSchema.optional(),
18354
+ /** See {@link TrackProjectionSchema}. Default `full` (backward
18355
+ * compatible — omitting the field keeps today's exact behaviour). */
18356
+ projection: TrackProjectionSchema.optional(),
18357
+ /** Include stationary-promoted rows (parked objects handed to the
18358
+ * stationary registry). Default false: the timeline lists passages,
18359
+ * not parking records (operator decision, 2026-08-15). */
18360
+ includeStationary: boolean().optional()
18361
+ }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
18362
+ deviceId: number(),
18363
+ groupId: string().min(1)
18364
+ }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
18365
+ kind: "mutation",
18366
+ auth: "admin"
18367
+ }), 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({
18368
+ deviceId: number(),
18369
+ since: number().optional(),
18370
+ until: number().optional(),
18371
+ kinds: array(string()).optional(),
18372
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
18373
+ }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
18374
+ deviceId: number(),
18375
+ since: number(),
18376
+ until: number(),
18377
+ bucketMs: number().int().positive()
18378
+ }), array(object({
18379
+ bucketStart: number(),
18380
+ motion: number().int(),
18381
+ object: number().int(),
18382
+ audio: number().int()
18383
+ })).readonly()), method(object({
18384
+ deviceId: number(),
18385
+ cutoffMs: number()
18386
+ }), object({
18387
+ motion: number().int(),
18388
+ object: number().int(),
18389
+ audio: number().int()
18390
+ }), {
18391
+ kind: "mutation",
18392
+ auth: "admin"
18393
+ }), method(object({
18394
+ deviceId: number(),
18395
+ cutoffMs: number()
18396
+ }), TrackCascadeCountsSchema, {
18397
+ kind: "mutation",
18398
+ auth: "admin"
18399
+ }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
18400
+ kind: "mutation",
18401
+ auth: "admin"
18402
+ }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
18403
+ kind: "mutation",
18404
+ auth: "admin"
18405
+ }), method(object({
18406
+ deviceId: number(),
18407
+ trackIds: array(string()).min(1)
18408
+ }), object({
18409
+ deleted: number().int(),
18410
+ failed: array(string()).readonly()
18411
+ }), {
18412
+ kind: "mutation",
18413
+ auth: "admin"
18414
+ }), method(object({
18415
+ /** Log/audit scope only — the trackId is globally unique on its own. */
18416
+ deviceId: number(),
18417
+ trackId: string(),
18418
+ flags: TrackFlagsPatchSchema
18419
+ }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
18420
+ kind: "query",
18421
+ auth: "admin"
18422
+ }), method(object({
18423
+ olderThanMs: number(),
18424
+ reason: OpsLogReasonSchema.optional()
18425
+ }), EventPruneCountsSchema, {
18426
+ kind: "mutation",
18427
+ auth: "admin"
18428
+ }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
18429
+ kind: "mutation",
18430
+ auth: "admin"
18431
+ }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
18432
+ kind: "mutation",
18433
+ auth: "admin"
18434
+ }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
18435
+ kind: "mutation",
18436
+ auth: "admin"
18437
+ }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
18438
+ kind: "mutation",
18439
+ auth: "admin"
18440
+ }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
18441
+ kind: "mutation",
18442
+ auth: "admin"
18443
+ }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18444
+ kind: "mutation",
18445
+ auth: "admin"
18446
+ }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
18447
+ kind: "mutation",
18448
+ auth: "admin"
18449
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
18450
+ kind: "query",
18451
+ auth: "admin"
18452
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18453
+ kind: "mutation",
18454
+ auth: "admin"
18455
+ }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
18456
+ kind: "query",
18457
+ auth: "admin"
18458
+ }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
18459
+ kind: "query",
18460
+ auth: "admin"
18461
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18462
+ kind: "query",
18463
+ auth: "admin"
18464
+ }), method(object({
18465
+ /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
18466
+ * `deviceId`, deliberately: `deviceId` would make this device-bound and
18467
+ * route it at one camera's owner, and "every camera" would stop being
18468
+ * expressible at all. */
18469
+ deviceIds: array(number()).optional(),
18470
+ limit: number().int().min(1).max(500).optional()
18471
+ }), array(RetrainTrackSchema).readonly(), {
18472
+ kind: "query",
18473
+ auth: "admin"
18474
+ }), method(object({ trackId: string() }), RetrainFrameListSchema, {
18475
+ kind: "query",
18476
+ auth: "admin"
18477
+ }), method(object({
18478
+ deviceId: number(),
18479
+ trackId: string(),
18480
+ mediaKeys: array(string()).min(1)
18481
+ }), RetrainFrameSelectionSchema, {
18482
+ kind: "mutation",
18483
+ auth: "admin"
18484
+ }), method(object({
18485
+ deviceId: number(),
18486
+ trackId: string(),
18487
+ frameId: string()
18488
+ }), object({
18489
+ removed: boolean(),
18490
+ removedAnnotations: number().int()
18491
+ }), {
18492
+ kind: "mutation",
18493
+ auth: "admin"
18494
+ }), method(object({ frameId: string() }), object({
18495
+ base64: string(),
18496
+ width: number().int(),
18497
+ height: number().int()
18498
+ }), {
18499
+ kind: "query",
18500
+ auth: "admin"
18501
+ }), method(object({
18502
+ deviceId: number(),
18503
+ trackId: string(),
18504
+ frameId: string(),
18505
+ subject: RetrainAssistSubjectSchema,
18506
+ /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
18507
+ nodeId: string().optional()
18508
+ }), RetrainAssistResultSchema, {
18509
+ kind: "mutation",
18510
+ auth: "admin"
18511
+ }), method(object({
18512
+ deviceId: number(),
18513
+ source: DetectionSourceSchema,
18514
+ zones: array(ZoneSchema).readonly().optional(),
18515
+ detectionRules: array(ZoneRuleSchema).readonly().optional(),
18516
+ zoneMembershipMinOverlap: number().min(0).max(1).optional(),
18517
+ frames: array(ReplayFrameInputSchema).min(1)
18518
+ }), RunReplayFrameProcessorResultSchema, {
18519
+ kind: "mutation",
18520
+ auth: "admin"
18521
+ }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
18522
+ kind: "query",
18523
+ auth: "admin"
18524
+ }), method(object({
18525
+ deviceId: number(),
18526
+ trackId: string(),
18527
+ frameId: string(),
18528
+ annotations: array(RetrainAnnotationDraftSchema)
18529
+ }), array(RetrainAnnotationSchema).readonly(), {
18530
+ kind: "mutation",
18531
+ auth: "admin"
18532
+ }), method(object({
18533
+ deviceId: number(),
18534
+ trackId: string()
18535
+ }), RetrainTransitionResultSchema, {
18120
18536
  kind: "mutation",
18121
18537
  auth: "admin"
18122
- }), method(object({ nodeId: string() }), object({
18123
- success: literal(true),
18124
- clearedDevices: number()
18125
- }), {
18538
+ }), method(object({
18539
+ deviceId: number(),
18540
+ trackId: string()
18541
+ }), RetrainTransitionResultSchema, {
18126
18542
  kind: "mutation",
18127
18543
  auth: "admin"
18128
- }), 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({
18129
- name: string(),
18130
- steps: array(PipelineTemplateStepSchema).readonly(),
18131
- engine: PipelineEngineChoiceSchema
18132
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
18133
- id: string(),
18134
- name: string().optional(),
18135
- steps: array(PipelineTemplateStepSchema).readonly().optional()
18136
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
18137
- addonId: string(),
18138
- modelId: string(),
18139
- format: ModelFormatSchema$1
18140
- }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
18141
- addonId: string(),
18142
- modelId: string(),
18143
- format: ModelFormatSchema$1
18144
- }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
18145
- engine: PipelineEngineChoiceSchema.optional(),
18146
- steps: array(PipelineStepInputSchema).min(1),
18147
- frame: FrameInputSchema.optional(),
18148
- /**
18149
- * Process-local lazy frame. Valid only when caller and provider resolve
18150
- * in the same execution-group process; split/cross-node callers use
18151
- * `frame`/`image` inline compatibility instead.
18152
- */
18153
- frameRef: FrameRefSchema.optional(),
18154
- /**
18155
- * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
18156
- * the decoded pixels live in. One more member of the one-of
18157
- * frame/frameHandle/image/imageBase64/referenceImage group.
18158
- */
18159
- frameHandle: FrameHandleSchema.optional(),
18160
- imageBase64: string().optional(),
18161
- /**
18162
- * Binary JPEG bytes — preferred over `imageBase64` on internal
18163
- * hops (hub → forked worker via Moleculer MsgPack) because it
18164
- * skips the 33% base64 overhead + the per-call base64 decode on
18165
- * the detection-pipeline worker. Callers can pass either; exactly
18166
- * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
18167
- */
18168
- image: _instanceof(Uint8Array).optional(),
18169
- referenceImage: string().optional(),
18170
- deviceId: number().optional(),
18171
- sessionId: string().optional(),
18172
- /**
18173
- * Execution plane. 'full' (default) runs the whole tree — benchmark,
18174
- * reference-image, and detail-subtree calls. 'frame' is the live
18175
- * per-frame dispatch: ONLY root-plane steps run; crop children
18176
- * (inputClasses ≠ null) are skipped and served per-track via
18177
- * pipelineRunner.runDetailSubtree (two-plane design).
18178
- */
18179
- plane: _enum(["full", "frame"]).optional(),
18180
- /**
18181
- * Inference-device selector (Phase 2 multi-device). Format
18182
- * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
18183
- * Omitted ⇒ the runner's default device (current single-engine
18184
- * behaviour). Selects WHICH device pool of the node runs the call.
18185
- */
18186
- deviceKey: string().optional(),
18187
- /**
18188
- * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
18189
- * when the parent crop was resolved from the frame's retained NATIVE
18190
- * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
18191
- * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
18192
- * resolution from that surface — the SAME quality path faces already
18193
- * had — instead of the downscaled parent tile. `handle` keys the native
18194
- * surface (node-pinned to its owner); `cropFrameSpace` is the parent
18195
- * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
18196
- * the executor's crop-normalized child ROI back into frame-normalized
18197
- * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
18198
- * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
18199
- * (today's behaviour on the fallback path).
18200
- */
18201
- nativeCropRef: NativeCropRefSchema.optional()
18202
- }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
18203
- engine: PipelineEngineChoiceSchema.optional(),
18204
- steps: array(PipelineStepInputSchema).min(1),
18205
- frames: array(FrameInputSchema).min(1).max(255),
18206
- deviceId: number().optional(),
18207
- sessionId: string().optional(),
18208
- /**
18209
- * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
18210
- * the batch to the Python pool's bench preprocess cache
18211
- * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
18212
- * preprocessed ONCE and every later inference is a pure-inference cache
18213
- * hit — the sustained-throughput run measures inference, not
18214
- * decode+preprocess+infer. Omitted/0 for live frames (all different →
18215
- * full preprocess every call, correct). Fresh per sustained run;
18216
- * released via `uncacheFrame`.
18217
- */
18218
- frameId: number().int().nonnegative().optional(),
18219
- /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
18220
- deviceKey: string().optional()
18221
- }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
18222
- data: _instanceof(Uint8Array),
18223
- width: number().int().positive(),
18224
- height: number().int().positive(),
18225
- format: _enum([
18226
- "rgb",
18227
- "bgr",
18228
- "gray"
18229
- ])
18230
- }), object({
18231
- frameId: number(),
18232
- width: number(),
18233
- height: number()
18234
- }), { kind: "mutation" }), method(object({
18235
- stepId: string(),
18236
- frameId: number().int()
18237
- }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
18238
- batchMode: string(),
18239
- windowMs: number(),
18240
- maxBatchSize: number(),
18241
- concurrency: number()
18242
- })), method(_void(), array(object({
18243
- engineKey: string(),
18244
- engine: PipelineEngineChoiceSchema,
18245
- modelsLoaded: array(string()).readonly(),
18246
- inUseByCameras: array(number()).readonly(),
18247
- /**
18248
- * Origin of this resident factory.
18249
- * - `runtime` — main camera-serving engine (no idle TTL).
18250
- * - `warm-override` — benchmark/test override held in the warm
18251
- * cache; auto-disposed after the idle TTL.
18252
- * - `device-pool` — a concurrent per-device pool (Phase 2
18253
- * multi-device, keyed by `deviceKey`) resolved
18254
- * via `resolveDeviceFactory`. Runs alongside the
18255
- * `runtime` engine on a DIFFERENT accelerator
18256
- * (NPU / iGPU / Coral) — this is how the
18257
- * Engines tab shows all pools running at once.
18258
- */
18259
- kind: _enum([
18260
- "runtime",
18261
- "warm-override",
18262
- "device-pool"
18263
- ]),
18264
- /** Native pid of the underlying Python pool (null when no pool). */
18265
- poolPid: number().nullable(),
18266
- /** ms since this factory was last used (null when not warm-tracked). */
18267
- idleMs: number().nullable(),
18268
- /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
18269
- idleTtlMs: number().nullable()
18270
- })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
18271
- kind: "mutation",
18544
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18545
+ kind: "query",
18272
18546
  auth: "admin"
18273
18547
  }), method(object({
18274
- engine: PipelineEngineChoiceSchema,
18275
- force: boolean().optional()
18276
- }), object({
18277
- success: boolean(),
18278
- reason: string().optional()
18279
- }), {
18548
+ eventId: string(),
18549
+ kind: MediaFileKindEnum.optional(),
18550
+ deviceId: number()
18551
+ }), array(MediaFileSchema).readonly()), method(object({
18552
+ trackId: string(),
18553
+ kinds: array(MediaFileKindEnum).optional(),
18554
+ deviceId: number()
18555
+ }), array(MediaFileSchema).readonly()), method(object({
18556
+ trackId: string(),
18557
+ deviceId: number()
18558
+ }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
18280
18559
  kind: "mutation",
18281
18560
  auth: "admin"
18282
- }), 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({
18283
- addonId: string(),
18284
- modelId: string(),
18285
- filename: string().optional(),
18286
- settings: record(string(), unknown()).optional()
18287
- }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
18561
+ }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
18562
+ kind: "mutation",
18563
+ auth: "admin"
18564
+ }), method(object({}), RebuildStatusSchema), object({
18565
+ deviceId: number(),
18566
+ timestamp: number(),
18567
+ frameWidth: number(),
18568
+ frameHeight: number(),
18569
+ detections: array(OverlayDetectionSchema).readonly()
18570
+ }), object({
18571
+ deviceId: number(),
18572
+ trackId: string(),
18573
+ className: string()
18574
+ }), object({
18575
+ deviceId: number(),
18576
+ trackId: string(),
18577
+ className: string(),
18578
+ durationMs: number()
18579
+ }), object({
18580
+ deviceId: number(),
18581
+ kind: EventKindSchema,
18582
+ eventId: string(),
18583
+ timestamp: number()
18584
+ });
18288
18585
  object({
18289
18586
  activeCameras: number(),
18290
18587
  throttledCameras: number(),
@@ -18296,119 +18593,19 @@ var CameraMetricsSchema = object({
18296
18593
  "disabled",
18297
18594
  "always-on",
18298
18595
  "on-motion"
18299
- ]),
18300
- configuredFps: number(),
18301
- actualFps: number(),
18302
- queueDepth: number(),
18303
- avgInferenceTimeMs: number(),
18304
- droppedFrames: number(),
18305
- phase: _enum([
18306
- "idle",
18307
- "watching",
18308
- "active"
18309
- ])
18310
- });
18311
- var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
18312
- /**
18313
- * Zone — pure geometry + identity. NO filtering behaviour.
18314
- *
18315
- * Zones describe **where** in the frame the operator wants to flag
18316
- * something; consumer-owned {@link ZoneRule} arrays describe **how**
18317
- * each pipeline stage uses them. Splitting the two means a single
18318
- * polygon "Driveway" can simultaneously back a motion-exclude rule,
18319
- * a detection-include rule on `['car']`, and an occupancy aggregate
18320
- * — without three duplicated polygons.
18321
- *
18322
- * Owned by the orchestrator addon (provider) and mirrored into the
18323
- * `zones` device-state slice on every mutation. Consumers
18324
- * (motion-wasm, pipeline-executor, analytics, admin UI) read either
18325
- * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
18326
- * mirror with `onChanged`).
18327
- *
18328
- * Coordinates are normalised fractions of the frame (0–1) so zones
18329
- * survive resolution changes and stream profile switches.
18330
- *
18331
- * `kind` discriminates between full polygons (closed regions used
18332
- * for intrusion / occupancy filters) and tripwires (open 2-point
18333
- * line segments used for cross events). Onboard / firmware-reported
18334
- * zones (Reolink, ONVIF) are out of scope for now — see the deferred
18335
- * task list.
18336
- */
18337
- var ZoneKindEnum = _enum(["polygon", "tripwire"]);
18338
- /** Polygon vertex in fraction-of-frame coordinates (0–1). */
18339
- var PolygonPointSchema = object({
18340
- x: number(),
18341
- y: number()
18342
- });
18343
- /** A camera detection zone — pure geometry/identity. */
18344
- var ZoneSchema = object({
18345
- id: string(),
18346
- name: string(),
18347
- kind: ZoneKindEnum.default("polygon"),
18348
- /** Polygon vertices, fraction of frame (0–1). */
18349
- polygon: array(PolygonPointSchema).readonly(),
18350
- /** Visual color for UI rendering. */
18351
- color: string().default("#3b82f6")
18596
+ ]),
18597
+ configuredFps: number(),
18598
+ actualFps: number(),
18599
+ queueDepth: number(),
18600
+ avgInferenceTimeMs: number(),
18601
+ droppedFrames: number(),
18602
+ phase: _enum([
18603
+ "idle",
18604
+ "watching",
18605
+ "active"
18606
+ ])
18352
18607
  });
18353
- /**
18354
- * Zones capability — per-camera CRUD over polygon detection zones.
18355
- *
18356
- * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
18357
- * to per-device settings and mirrors into the `zones` device-state
18358
- * slice on every mutation, so downstream consumers can subscribe via
18359
- * `dev.state.zones.onChanged`.
18360
- *
18361
- * The cap surface only handles geometry + identity; filtering
18362
- * behaviour (per-class, include/exclude, threshold) lives in the
18363
- * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
18364
- * `capabilities/schemas/zone-rule.js`.
18365
- */
18366
- var zonesCapability = {
18367
- name: "zones",
18368
- scope: "device",
18369
- mode: "singleton",
18370
- deviceTypes: [DeviceType.Camera],
18371
- methods: {
18372
- listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
18373
- addZone: method(object({
18374
- deviceId: number(),
18375
- zone: ZoneSchema
18376
- }), _void(), {
18377
- kind: "mutation",
18378
- auth: "admin"
18379
- }),
18380
- removeZone: method(object({
18381
- deviceId: number(),
18382
- zoneId: string()
18383
- }), _void(), {
18384
- kind: "mutation",
18385
- auth: "admin"
18386
- }),
18387
- updateZone: method(object({
18388
- deviceId: number(),
18389
- zone: ZoneSchema
18390
- }), _void(), {
18391
- kind: "mutation",
18392
- auth: "admin"
18393
- })
18394
- },
18395
- /**
18396
- * Runtime-state slice — the live zone catalogue mirrored by the
18397
- * orchestrator on every CRUD mutation. Consumers read via
18398
- * `device.state.zones.value` / `.watch(...)` without round-tripping
18399
- * the cap, and the codegen DeviceProxy auto-wires the reactive
18400
- * handle. Slice shape is `{ zones: Zone[] }` so future extensions
18401
- * (e.g. zone groupings) can sit alongside the polygon list.
18402
- */
18403
- runtimeState: object({ zones: array(ZoneSchema).readonly() }),
18404
- /**
18405
- * 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.
18406
- *
18407
- * See `RuntimeStateDurability`. Enforced by
18408
- * `scripts/check-runtime-state-durability.ts`.
18409
- */
18410
- durability: "restored"
18411
- };
18608
+ var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
18412
18609
  /**
18413
18610
  * A bounding box in NORMALIZED [0,1] frame coordinates for `getNativeCrop`. The
18414
18611
  * decode worker resolves it against the RETAINED native frame's real pixel dims,
@@ -20097,7 +20294,7 @@ method(object({
20097
20294
  * linking rather than produce an eternal token.
20098
20295
  */
20099
20296
  ttlSec: union([number().int().positive(), literal("never")]).optional()
20100
- }), object({ token: string() })), method(object({ token: string() }), SsoBridgeClaimsSchema.nullable());
20297
+ }), object({ token: string() }), { auth: "admin" }), method(object({ token: string() }), SsoBridgeClaimsSchema.nullable(), { auth: "admin" });
20101
20298
  var ProviderListEntrySchema = discriminatedUnion("shouldSaveDiskSpace", [object({
20102
20299
  providerId: string().min(1),
20103
20300
  displayName: string().min(1),
@@ -20192,10 +20389,13 @@ var EvictResultSchema = object({
20192
20389
  /** True when the provider has nothing left it is willing to drop on this location. */
20193
20390
  exhausted: boolean()
20194
20391
  });
20195
- method(object({ locationId: string() }), EvictableUsageSchema), method(object({
20392
+ method(object({ locationId: string() }), EvictableUsageSchema, { auth: "admin" }), method(object({
20196
20393
  locationId: string(),
20197
20394
  targetBytes: number().int().positive()
20198
- }), EvictResultSchema, { kind: "mutation" });
20395
+ }), EvictResultSchema, {
20396
+ kind: "mutation",
20397
+ auth: "admin"
20398
+ });
20199
20399
  method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin" }), method(StorageMigrationInputSchema, object({ jobId: string() }), {
20200
20400
  kind: "mutation",
20201
20401
  auth: "admin"
@@ -20255,26 +20455,50 @@ var ReadChunkInputSchema = object({
20255
20455
  length: number()
20256
20456
  });
20257
20457
  var EndDownloadInputSchema = object({ downloadId: string() });
20258
- method(_void(), ProviderInfoSchema), method(object({ config: record(string(), unknown()) }), TestLocationResultSchema, { auth: "admin" }), method(object({
20458
+ method(_void(), ProviderInfoSchema, { auth: "admin" }), method(object({ config: record(string(), unknown()) }), TestLocationResultSchema, { auth: "admin" }), method(object({
20259
20459
  location: StorageLocationSchema,
20260
20460
  relativePath: string()
20261
- }), string()), method(object({
20461
+ }), string(), { auth: "admin" }), method(object({
20262
20462
  location: StorageLocationSchema,
20263
20463
  relativePath: string(),
20264
20464
  data: _instanceof(Uint8Array)
20265
- }), _void(), { kind: "mutation" }), method(object({
20465
+ }), _void(), {
20466
+ kind: "mutation",
20467
+ auth: "admin"
20468
+ }), method(object({
20266
20469
  location: StorageLocationSchema,
20267
20470
  relativePath: string()
20268
- }), _instanceof(Uint8Array)), method(object({
20471
+ }), _instanceof(Uint8Array), { auth: "admin" }), method(object({
20269
20472
  location: StorageLocationSchema,
20270
20473
  relativePath: string()
20271
- }), boolean()), method(object({
20474
+ }), boolean(), { auth: "admin" }), method(object({
20272
20475
  location: StorageLocationSchema,
20273
20476
  prefix: string().optional()
20274
- }), array(string()).readonly()), method(object({
20477
+ }), array(string()).readonly(), { auth: "admin" }), method(object({
20275
20478
  location: StorageLocationSchema,
20276
20479
  relativePath: string()
20277
- }), _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" });
20480
+ }), _void(), {
20481
+ kind: "mutation",
20482
+ auth: "admin"
20483
+ }), method(object({ location: StorageLocationSchema }), number().nullable(), { auth: "admin" }), method(BeginUploadInputSchema, BeginUploadResultSchema, {
20484
+ kind: "mutation",
20485
+ auth: "admin"
20486
+ }), method(WriteChunkInputSchema, _void(), {
20487
+ kind: "mutation",
20488
+ auth: "admin"
20489
+ }), method(FinalizeUploadInputSchema, _void(), {
20490
+ kind: "mutation",
20491
+ auth: "admin"
20492
+ }), method(AbortUploadInputSchema, _void(), {
20493
+ kind: "mutation",
20494
+ auth: "admin"
20495
+ }), method(BeginDownloadInputSchema, BeginDownloadResultSchema, {
20496
+ kind: "mutation",
20497
+ auth: "admin"
20498
+ }), method(ReadChunkInputSchema, _instanceof(Uint8Array), { auth: "admin" }), method(EndDownloadInputSchema, _void(), {
20499
+ kind: "mutation",
20500
+ auth: "admin"
20501
+ });
20278
20502
  /** Profile-exported FormBuilder schema. Shape is ConfigUISchema at the UI. */
20279
20503
  var ProfileSettingsSchemaBridge = unknown().nullable();
20280
20504
  var ProfileSettingsBagSchema = record(string(), unknown());
@@ -20532,7 +20756,8 @@ method(object({
20532
20756
  access: "create"
20533
20757
  }), method(object({ userId: string().optional() }), object({ optionsJSON: record(string(), unknown()) }), {
20534
20758
  kind: "mutation",
20535
- access: "view"
20759
+ access: "view",
20760
+ auth: "admin"
20536
20761
  }), method(object({
20537
20762
  /** Required — the user the assertion belongs to (verified). */
20538
20763
  userId: string(),
@@ -20540,10 +20765,12 @@ method(object({
20540
20765
  response: record(string(), unknown())
20541
20766
  }), object({ verified: boolean() }), {
20542
20767
  kind: "mutation",
20543
- access: "view"
20768
+ access: "view",
20769
+ auth: "admin"
20544
20770
  }), method(object({}), object({ optionsJSON: record(string(), unknown()) }), {
20545
20771
  kind: "mutation",
20546
- access: "view"
20772
+ access: "view",
20773
+ auth: "admin"
20547
20774
  }), method(object({
20548
20775
  /** AuthenticationResponseJSON from the browser. */
20549
20776
  response: record(string(), unknown()) }), object({
@@ -20551,7 +20778,8 @@ response: record(string(), unknown()) }), object({
20551
20778
  userId: string().nullable()
20552
20779
  }), {
20553
20780
  kind: "mutation",
20554
- access: "view"
20781
+ access: "view",
20782
+ auth: "admin"
20555
20783
  }), method(object({ userId: string() }), array(PasskeySummarySchema), { auth: "admin" }), method(object({
20556
20784
  userId: string(),
20557
20785
  credentialId: string()
@@ -20723,7 +20951,19 @@ var VectorStatsResultSchema = object({
20723
20951
  /** False when the backend ranks approximately. */
20724
20952
  exact: boolean()
20725
20953
  });
20726
- 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);
20954
+ method(VectorDeclareIndexInputSchema, _void(), {
20955
+ kind: "mutation",
20956
+ auth: "admin"
20957
+ }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
20958
+ kind: "mutation",
20959
+ auth: "admin"
20960
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
20961
+ kind: "mutation",
20962
+ auth: "admin"
20963
+ }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
20964
+ kind: "mutation",
20965
+ auth: "admin"
20966
+ }), method(VectorStatsInputSchema, VectorStatsResultSchema, { auth: "admin" });
20727
20967
  var ClipSchema = object({
20728
20968
  /** Opaque, provider-namespaced id. The default provider encodes the time
20729
20969
  * window so `getClipPlayback` is self-contained (no event re-query). */
@@ -23193,7 +23433,27 @@ var MediaFileLiteSchema$1 = object({
23193
23433
  sizeBytes: number(),
23194
23434
  timestamp: number()
23195
23435
  });
23196
- method(_void(), array(IdentitySchema).readonly()), method(object({ name: string().min(1) }), IdentitySchema, {
23436
+ method(object({
23437
+ /**
23438
+ * Inline {@link IdentitySchema.coverBase64} on every row.
23439
+ *
23440
+ * Default `false`, the same inversion `listRecentFaces` and
23441
+ * `listPlates` took on 2026-08-25 (see `include-crops-default.ts` for
23442
+ * why the burden belongs on the caller that WANTS the bytes). Measured
23443
+ * on the live hub the same day: four identities cost 40,979 B with the
23444
+ * covers inline, ~10 KB of base64 per row, on a query this UI mounts
23445
+ * four times and the viewer holds at `staleTime: 30_000`.
23446
+ *
23447
+ * Nothing loses its avatar: `coverMediaKey` is already on every row and
23448
+ * the `event-media` plane serves that key `immutable` with an ETag.
23449
+ *
23450
+ * **This is an INPUT field, so it does not reach the addon until the
23451
+ * next train** — the hub router validates cap inputs against its own
23452
+ * compiled Zod and strips a key it does not know. Until then the
23453
+ * provider sees `undefined`, which resolves to `false`: the cheap shape
23454
+ * is what ships, and the opt-in becomes reachable when the train lands.
23455
+ */
23456
+ includeCrops: boolean().optional() }).optional(), array(IdentitySchema).readonly()), method(object({ name: string().min(1) }), IdentitySchema, {
23197
23457
  kind: "mutation",
23198
23458
  auth: "admin"
23199
23459
  }), method(object({
@@ -26083,8 +26343,10 @@ var PlateInfoSchema = object({
26083
26343
  keyFrameMediaKey: string().optional(),
26084
26344
  base64: string().optional(),
26085
26345
  /**
26086
- * Same crop as a data-plane URL. `getPlateByTrack` returns this and
26087
- * never inlines JPEG; `listPlates` still inlines for the admin-ui.
26346
+ * Same crop as a data-plane URL, always present when the plate has a stored
26347
+ * crop. `getPlateByTrack` returns this and never inlines JPEG; `listPlates`
26348
+ * and `searchPlates` inline the crop only when their `includeCrops` input is
26349
+ * left at its `true` default.
26088
26350
  */
26089
26351
  cropUrl: string().optional()
26090
26352
  });
@@ -26104,14 +26366,34 @@ var PlateClusterSchema = object({
26104
26366
  });
26105
26367
  method(object({
26106
26368
  deviceId: number().int().optional(),
26107
- limit: number().int().positive().optional()
26369
+ limit: number().int().positive().optional(),
26370
+ /**
26371
+ * Inline the base64 crop on every row. Default `true` — the existing
26372
+ * behaviour, kept so no caller breaks.
26373
+ *
26374
+ * Set `false` once the caller renders {@link PlateInfo.cropUrl}.
26375
+ * Measured on the live hub at the 500 rows the Plates view asks for:
26376
+ * 879,403 B and 27.7 s with the crops inline, against a few KiB of
26377
+ * metadata without them — and the browser then caches the images.
26378
+ *
26379
+ * This is the plate twin of `faceGallery.listRecentFaces`'s option;
26380
+ * plates were the one gallery list left without it.
26381
+ *
26382
+ * **This is an INPUT field, so it does not reach the addon until the
26383
+ * next train.** The hub router validates cap inputs against its own
26384
+ * compiled Zod and strips a key it does not know. Until the train
26385
+ * ships, sending `false` is harmless and keeps the crops inline.
26386
+ */
26387
+ includeCrops: boolean().optional()
26108
26388
  }).optional(), array(PlateInfoSchema).readonly()), method(object({
26109
26389
  deviceId: number().int(),
26110
26390
  trackId: string()
26111
26391
  }), PlateInfoSchema.nullable()), method(object({ plateId: string() }), array(MediaFileLiteSchema).readonly()), method(object({
26112
26392
  text: string().min(1),
26113
26393
  maxDistance: number().int().min(0).optional(),
26114
- limit: number().int().positive().optional()
26394
+ limit: number().int().positive().optional(),
26395
+ /** See `listPlates.includeCrops`. Default `true`. */
26396
+ includeCrops: boolean().optional()
26115
26397
  }), array(PlateInfoSchema).readonly()), method(object({
26116
26398
  maxDistance: number().int().min(0).optional(),
26117
26399
  minClusterSize: number().int().min(2).optional(),
@@ -26125,7 +26407,13 @@ method(object({
26125
26407
  }), method(object({ plateId: string() }), _void(), {
26126
26408
  kind: "mutation",
26127
26409
  auth: "admin"
26128
- }), method(_void(), array(VehicleSchema).readonly()), method(object({ name: string().min(1) }), VehicleSchema, {
26410
+ }), method(object({
26411
+ /** Inline {@link VehicleSchema.coverBase64} on every row. Default
26412
+ * `false` — the vehicle twin of `faceGallery.listIdentities`'s
26413
+ * option; `coverMediaKey` + the `event-media` plane carry the picture.
26414
+ * INPUT field: stripped by the hub router until the train ships, which
26415
+ * resolves to `false` and is exactly the intended default. */
26416
+ includeCrops: boolean().optional() }).optional(), array(VehicleSchema).readonly()), method(object({ name: string().min(1) }), VehicleSchema, {
26129
26417
  kind: "mutation",
26130
26418
  auth: "admin"
26131
26419
  }), method(object({
@@ -27646,92 +27934,6 @@ var sceneMonitorCapability = {
27646
27934
  durability: "session"
27647
27935
  };
27648
27936
  /**
27649
- * Per-stage gating mode applied to the zones a rule references.
27650
- *
27651
- * - `include`: the rule contributes to a **whitelist** for its stage.
27652
- * When at least one `include` rule fires for a stage, only entities
27653
- * inside one of those zones pass that stage.
27654
- * - `exclude`: the rule contributes to a **blacklist** for its stage.
27655
- * Entities inside one of those zones are dropped at that stage.
27656
- *
27657
- * `monitor`-style observation (count without filtering) is not a rule
27658
- * mode — zones without any matching rule are observed naturally by
27659
- * `zone-analytics` (live snapshot + history), so an "I just want to
27660
- * count, not filter" use case needs no rule at all.
27661
- */
27662
- var ZoneRuleModeEnum = _enum(["include", "exclude"]);
27663
- /**
27664
- * Per-consumer rule that references existing zones (geometry) and
27665
- * defines how a specific pipeline stage should treat them. Each
27666
- * consumer addon owns its own `ZoneRule[]` array in its per-device
27667
- * settings:
27668
- *
27669
- * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
27670
- * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
27671
- * - future: notification rules, audio gating, etc.
27672
- *
27673
- * One rule applies to N zones (`zoneIds[]`) so the operator can
27674
- * express "ignore motion in ALL of {garden, street}" with a single
27675
- * rule. `classFilter` narrows the rule to specific object classes —
27676
- * "drop person detections in the street, but keep cars" is one
27677
- * `exclude` rule with `classFilter: ['person']`.
27678
- *
27679
- * `enabled` is a soft toggle — the operator can keep the rule
27680
- * configured but inert without deleting it.
27681
- */
27682
- var ZoneRuleSchema = object({
27683
- /** Stable rule id — survives edits, used by the UI for diffing. */
27684
- id: string(),
27685
- /** Optional human-readable label rendered in the rule editor. */
27686
- name: string().optional(),
27687
- /** Zones this rule targets. The rule's `mode` applies to ALL
27688
- * listed zones (OR-set: a detection in any one of them counts).
27689
- * At least one zone id required — a rule with no targets is a
27690
- * configuration mistake and the form validator rejects it. */
27691
- zoneIds: array(string()).min(1).readonly(),
27692
- mode: ZoneRuleModeEnum,
27693
- /**
27694
- * Class names this rule applies to. Empty / undefined ⇒ rule
27695
- * applies to every class. Class strings match the `macroClass`
27696
- * field on detections (e.g. `person`, `car`, `dog`).
27697
- */
27698
- classFilter: array(string()).readonly().optional(),
27699
- /**
27700
- * Minimum bbox/mask overlap (0–1) with any of the rule's zones
27701
- * required to consider an entity "in the zone". Defaults to the
27702
- * consumer's stage default when omitted. Kept for back-compat with
27703
- * existing per-rule overrides; new operators pick the value via
27704
- * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
27705
- * set, the lower-level engine reads it as a 0–1 fraction.
27706
- */
27707
- overlapThreshold: number().min(0).max(1).optional(),
27708
- /**
27709
- * Operator-friendly version of `overlapThreshold` — the percentage
27710
- * of the detection's bbox that must lie inside the zone for the
27711
- * rule to match. Documented default is 85%; the engine substitutes
27712
- * that when the field is omitted (kept optional so existing rules
27713
- * stored without it stay valid).
27714
- *
27715
- * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
27716
- * rule, the engine prefers `bboxInclusionPct` because it's the
27717
- * field exposed in the UI. Internally both feed the same gate.
27718
- */
27719
- bboxInclusionPct: number().min(0).max(100).optional(),
27720
- /**
27721
- * When `true` and a detection has a segmentation mask, use the
27722
- * mask for overlap instead of the bbox. Detection-stage only;
27723
- * motion rules ignore this field.
27724
- */
27725
- preferMask: boolean().optional(),
27726
- /**
27727
- * Soft-toggle: `false` disables the rule without deleting it.
27728
- * Defaults to `true` so operators creating a rule via the UI
27729
- * see it active immediately.
27730
- */
27731
- enabled: boolean().default(true)
27732
- });
27733
- array(ZoneRuleSchema).readonly();
27734
- /**
27735
27937
  * Script-runner cap. Models HA `script.*` entities on
27736
27938
  * `DeviceType.Script`. A Script is a pre-recorded action sequence
27737
27939
  * that can be invoked imperatively — optionally with a variables
@@ -33386,6 +33588,12 @@ Object.freeze({
33386
33588
  addonId: null,
33387
33589
  access: "create"
33388
33590
  },
33591
+ "pipelineAnalytics.cancelRelocateMedia": {
33592
+ capName: "pipeline-analytics",
33593
+ capScope: "device",
33594
+ addonId: null,
33595
+ access: "create"
33596
+ },
33389
33597
  "pipelineAnalytics.cancelStorageMigrationMove": {
33390
33598
  capName: "pipeline-analytics",
33391
33599
  capScope: "device",
@@ -33560,6 +33768,12 @@ Object.freeze({
33560
33768
  addonId: null,
33561
33769
  access: "view"
33562
33770
  },
33771
+ "pipelineAnalytics.listRelocateMediaJobs": {
33772
+ capName: "pipeline-analytics",
33773
+ capScope: "device",
33774
+ addonId: null,
33775
+ access: "view"
33776
+ },
33563
33777
  "pipelineAnalytics.listRetrainAnnotations": {
33564
33778
  capName: "pipeline-analytics",
33565
33779
  capScope: "device",
@@ -33638,6 +33852,12 @@ Object.freeze({
33638
33852
  addonId: null,
33639
33853
  access: "create"
33640
33854
  },
33855
+ "pipelineAnalytics.relocateMedia": {
33856
+ capName: "pipeline-analytics",
33857
+ capScope: "device",
33858
+ addonId: null,
33859
+ access: "create"
33860
+ },
33641
33861
  "pipelineAnalytics.restageRetrainTrack": {
33642
33862
  capName: "pipeline-analytics",
33643
33863
  capScope: "device",
@@ -33650,6 +33870,12 @@ Object.freeze({
33650
33870
  addonId: null,
33651
33871
  access: "create"
33652
33872
  },
33873
+ "pipelineAnalytics.runReplayFrameProcessor": {
33874
+ capName: "pipeline-analytics",
33875
+ capScope: "device",
33876
+ addonId: null,
33877
+ access: "create"
33878
+ },
33653
33879
  "pipelineAnalytics.saveRetrainAnnotations": {
33654
33880
  capName: "pipeline-analytics",
33655
33881
  capScope: "device",
@@ -33782,6 +34008,12 @@ Object.freeze({
33782
34008
  addonId: null,
33783
34009
  access: "view"
33784
34010
  },
34011
+ "pipelineExecutor.getInferenceDeviceHealth": {
34012
+ capName: "pipeline-executor",
34013
+ capScope: "system",
34014
+ addonId: null,
34015
+ access: "view"
34016
+ },
33785
34017
  "pipelineExecutor.getOrchestratorConfigSchema": {
33786
34018
  capName: "pipeline-executor",
33787
34019
  capScope: "system",
@@ -33854,6 +34086,12 @@ Object.freeze({
33854
34086
  addonId: null,
33855
34087
  access: "view"
33856
34088
  },
34089
+ "pipelineExecutor.rearmInferenceDevice": {
34090
+ capName: "pipeline-executor",
34091
+ capScope: "system",
34092
+ addonId: null,
34093
+ access: "create"
34094
+ },
33857
34095
  "pipelineExecutor.runAudioTest": {
33858
34096
  capName: "pipeline-executor",
33859
34097
  capScope: "system",
@@ -37102,6 +37340,11 @@ Object.freeze({
37102
37340
  form: "single",
37103
37341
  optional: false
37104
37342
  }],
37343
+ "pipelineAnalytics.runReplayFrameProcessor": [{
37344
+ name: "deviceId",
37345
+ form: "single",
37346
+ optional: false
37347
+ }],
37105
37348
  "pipelineAnalytics.saveRetrainAnnotations": [{
37106
37349
  name: "deviceId",
37107
37350
  form: "single",