@camstack/addon-model-studio 1.1.42 → 1.1.44

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 (22) hide show
  1. package/dist/{MotionZonesSettings-CjuAU9G1.mjs → MotionZonesSettings-BQmeOC6s.mjs} +2 -2
  2. package/dist/{PrivacyMaskSettings-DGgoakvb.mjs → PrivacyMaskSettings-MznS24IR.mjs} +4 -4
  3. package/dist/{SceneMonitorEditor-BbhGQMS0.mjs → SceneMonitorEditor-slpx5RVW.mjs} +3 -3
  4. package/dist/_stub.js +3721 -3354
  5. package/dist/{_virtual_mf-localSharedImportMap___mfe_internal__addon_model_studio_page-C6iWEfrD.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_model_studio_page-DLIAvBWe.mjs} +4 -4
  6. package/dist/_virtual_mf___mfe_internal__addon_model_studio_page__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-Dz7eB41h.mjs +26 -0
  7. package/dist/{hostInit-DiT_J3FN.mjs → hostInit-B-Aii0wU.mjs} +3 -3
  8. package/dist/model-studio.addon.js +2151 -1874
  9. package/dist/model-studio.addon.mjs +2151 -1874
  10. package/dist/{player-overlays-DxUZLAfW.mjs → player-overlays-ZV106hch.mjs} +1 -1
  11. package/dist/remoteEntry.js +1 -1
  12. package/dist/{responsive-CTOSHDQc.mjs → responsive-BWcJ76VI.mjs} +1 -1
  13. package/dist/{square-xdu1CBwb.mjs → square-DK5dno3H.mjs} +1 -1
  14. package/dist/{trash-2-Dhb8HSyo.mjs → trash-2-B9ZCrm5O.mjs} +1 -1
  15. package/dist/{use-device-snapshot-B5bRXvO7.mjs → use-device-snapshot-_PNv-X_c.mjs} +1 -1
  16. package/dist/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_model_studio_page__remoteEntry_js-CJdZ-nWm.mjs → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_model_studio_page__remoteEntry_js-0gBx_lhr.mjs} +1 -1
  17. package/package.json +1 -1
  18. package/python/__pycache__/convert.cpython-314.pyc +0 -0
  19. package/python/__pycache__/convert_lib.cpython-312.pyc +0 -0
  20. package/python/__pycache__/convert_lib.cpython-314.pyc +0 -0
  21. package/python/__tests__/__pycache__/test_convert_lib.cpython-314.pyc +0 -0
  22. package/dist/_virtual_mf___mfe_internal__addon_model_studio_page__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-4Obpn8FN.mjs +0 -26
@@ -7308,7 +7308,7 @@ function method(input, output, options) {
7308
7308
  input,
7309
7309
  output,
7310
7310
  kind: options?.kind ?? "query",
7311
- auth: options?.auth ?? "protected",
7311
+ ...options?.auth !== void 0 ? { auth: options.auth } : {},
7312
7312
  ...options?.access !== void 0 ? { access: options.access } : {},
7313
7313
  ...options?.caller !== void 0 ? { caller: options.caller } : {},
7314
7314
  timeoutMs: options?.timeoutMs
@@ -7328,7 +7328,7 @@ function systemMethod(input, output, options) {
7328
7328
  }
7329
7329
  var StaticDirOutputSchema$1 = object({ staticDir: string() });
7330
7330
  var VersionOutputSchema$1 = object({ version: string() });
7331
- method(_void(), StaticDirOutputSchema$1), method(_void(), VersionOutputSchema$1);
7331
+ method(_void(), StaticDirOutputSchema$1, { auth: "admin" }), method(_void(), VersionOutputSchema$1, { auth: "admin" });
7332
7332
  var DeviceType = /* @__PURE__ */ function(DeviceType) {
7333
7333
  DeviceType["Camera"] = "camera";
7334
7334
  DeviceType["Hub"] = "hub";
@@ -7649,7 +7649,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
7649
7649
  }({});
7650
7650
  var StaticDirOutputSchema = object({ staticDir: string() });
7651
7651
  var VersionOutputSchema = object({ version: string() });
7652
- method(_void(), StaticDirOutputSchema), method(_void(), VersionOutputSchema);
7652
+ method(_void(), StaticDirOutputSchema, { auth: "admin" }), method(_void(), VersionOutputSchema, { auth: "admin" });
7653
7653
  /**
7654
7654
  * device-ops — device-scoped cap that unifies the per-IDevice operations
7655
7655
  * previously routed through the `.device-ops` Moleculer bridge service.
@@ -8263,24 +8263,6 @@ var RecordingRetentionSchema = object({
8263
8263
  maxSizeGb: number().min(0).optional()
8264
8264
  });
8265
8265
  /**
8266
- * Scrub-thumbnail fidelity preset — the single per-camera selector bundling the
8267
- * sprite tile RESOLUTION + JPEG QUALITY the recorder packs timeline-scrub
8268
- * previews at. Five graduated steps; absent on a config = `standard` (the
8269
- * shipped default, matching `sheet-geometry`/`sheet-composer`).
8270
- *
8271
- * Existing sheets are IMMUTABLE — a changed preset applies to NEW windows only.
8272
- * Each window's index sidecar carries its own tile dims, so a camera whose
8273
- * preset changed over time renders every historical window at the dims it was
8274
- * written with.
8275
- */
8276
- var ScrubThumbnailPresetSchema = _enum([
8277
- "minimal",
8278
- "low",
8279
- "standard",
8280
- "high",
8281
- "max"
8282
- ]);
8283
- /**
8284
8266
  * The full per-camera recording intent — the wire shape of a RecordingTarget.
8285
8267
  *
8286
8268
  * `bands` is the ONLY authored recording intent: what to record, when, and on
@@ -8288,7 +8270,11 @@ var ScrubThumbnailPresetSchema = _enum([
8288
8270
  * other field is a storage knob (profiles, segment length, retention, scrub).
8289
8271
  *
8290
8272
  * STRICT on purpose: the legacy authoring surface (`schedule`/`schedules`/
8291
- * `triggers`/`preBufferSec`/`postBufferSec`/`rules`) was retired 2026-07-30.
8273
+ * `triggers`/`preBufferSec`/`postBufferSec`/`rules`) was retired 2026-07-30,
8274
+ * and `scrubThumbnails` — a five-step fidelity knob for a sprite tier that was
8275
+ * deleted on 2026-07-24 and had ZERO consumers in the recorder — on 2026-08-25
8276
+ * (D62: a switch that writes a store nobody reads is worse than no switch).
8277
+ * Stored rows keep loading: the READ schema is `.strip()` (config-store.ts).
8292
8278
  * A stale caller must fail loudly — silently stripping its legacy intent would
8293
8279
  * persist a band-less config, i.e. silently stop recording the camera.
8294
8280
  */
@@ -8311,14 +8297,7 @@ var RecordingConfigSchema = object({
8311
8297
  * "off" is the absence of a covering band, never a band value.
8312
8298
  */
8313
8299
  bands: array(RecordingBandSchema).default([]),
8314
- retention: RecordingRetentionSchema.optional(),
8315
- /**
8316
- * Per-camera scrub-thumbnail fidelity preset (resolution + JPEG quality for
8317
- * timeline-scrub sprite previews). Absent = `standard`. Applies to NEW
8318
- * windows only — existing sheets are immutable, and each window's index
8319
- * carries its own tile dims so mixed-preset history renders correctly.
8320
- */
8321
- scrubThumbnails: ScrubThumbnailPresetSchema.optional()
8300
+ retention: RecordingRetentionSchema.optional()
8322
8301
  }).strict();
8323
8302
  /**
8324
8303
  * Entity-relocation job state (storage entity-routing spec, Phase 4).
@@ -8394,10 +8373,11 @@ var RelocateFootageInputSchema = object({
8394
8373
  * `RecordingConfig.enabled` or camera wrapper bindings. */
8395
8374
  var StorageMigrationLeaseInputSchema = object({ leaseId: string().min(1) });
8396
8375
  var StorageMigrationFootageMoveInputSchema = RelocateFootageInputSchema.extend({ leaseId: string().min(1) });
8397
- var StorageMigrationMediaMoveInputSchema = object({
8376
+ var RelocateMediaInputSchema = object({
8398
8377
  toLocationId: string(),
8399
8378
  throttleMbps: number().min(1).max(1e3).optional()
8400
- }).extend({ leaseId: string().min(1) });
8379
+ });
8380
+ var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
8401
8381
  /** The independently selectable logical storage classes. `recordings`
8402
8382
  * encompasses the high and mid segment profiles; `recordingsLow` is low
8403
8383
  * segments; `eventMedia` is post-analysis blobs. */
@@ -8692,7 +8672,26 @@ var LabelDefinitionSchema = object({
8692
8672
  description: string().optional(),
8693
8673
  icon: string().optional()
8694
8674
  });
8695
- var ClassMapDefinitionSchema = object({
8675
+ /**
8676
+ * Wire schema for a per-model CATALOG classMap override
8677
+ * (`ModelCatalogEntry.classMap` / `ModelConvertMetadata.classMap`) —
8678
+ * restricted to {@link CLASS_MAP_MACRO_TARGETS}, the only macros the
8679
+ * detection pipeline executor actually routes.
8680
+ *
8681
+ * This is deliberately a DIFFERENT, narrower shape than the general-purpose
8682
+ * `ClassMapDefinition` interface above (e.g. `IDetectionAddon.getClassMap()`
8683
+ * and the audio `YAMNET_TO_MACRO` catalog both use macro targets outside this
8684
+ * enum) — the two used to share the name `ClassMapDefinition`/
8685
+ * `ClassMapDefinitionSchema`, which made the schema-type-twin guard
8686
+ * (`scripts/check-schema-type-twins.ts`) flag them as a duplicated shape. They
8687
+ * are not: it is two different concepts colliding on a name. Keep this type
8688
+ * under its own name rather than reusing `ClassMapDefinition` — reusing it
8689
+ * would either narrow every `ClassMapDefinition` consumer to the four
8690
+ * detection macros (breaking `YAMNET_TO_MACRO`) or drop the validation this
8691
+ * schema exists for (see the "rejects a classMap whose target is not a
8692
+ * detection macro" test in `model-catalog-schema.test.ts`).
8693
+ */
8694
+ var DetectionCatalogClassMapSchema = object({
8696
8695
  mapping: record(string(), _enum([
8697
8696
  "person",
8698
8697
  "vehicle",
@@ -8897,7 +8896,7 @@ var ModelCatalogEntrySchema = object({
8897
8896
  * applies (Frigate / COCO public catalog). Set on a custom model whose raw
8898
8897
  * labels already ARE the CamStack macros (Scrypted identity map).
8899
8898
  */
8900
- classMap: ClassMapDefinitionSchema.optional()
8899
+ classMap: DetectionCatalogClassMapSchema.optional()
8901
8900
  });
8902
8901
  var ConvertTargetSchema = discriminatedUnion("format", [object({
8903
8902
  format: literal("openvino"),
@@ -8927,7 +8926,7 @@ var ModelConvertMetadataSchema = object({
8927
8926
  "segmentation"
8928
8927
  ]),
8929
8928
  faceAlignment: boolean().optional(),
8930
- classMap: ClassMapDefinitionSchema.optional()
8929
+ classMap: DetectionCatalogClassMapSchema.optional()
8931
8930
  });
8932
8931
  var ConvertArtifactSchema = object({
8933
8932
  format: _enum(MODEL_FORMATS),
@@ -9796,7 +9795,18 @@ var addonPagesSourceCapability = {
9796
9795
  scope: "system",
9797
9796
  mode: "collection",
9798
9797
  internal: true,
9799
- methods: { listPages: method(_void(), array(AddonPageDeclarationSchema).readonly()) }
9798
+ methods: {
9799
+ /**
9800
+ * `internal: true` did not gate the mount (see the 2026-08-26 note on
9801
+ * `data-store-provider`) — this was reachable on the AppRouter by ANY
9802
+ * authenticated session at the default `auth: 'protected'`. The only
9803
+ * consumer, the `addon-pages-aggregator` builtin, reads it via
9804
+ * `ctx.capabilities.getCollection('addon-pages-source')` — LOCAL-PROCESS
9805
+ * only, never tRPC (per `ctx.capabilities` seeing only the local
9806
+ * process). The public, enriched listing admin-ui actually consumes is
9807
+ * the separate `addon-pages` cap, unaffected by this change.
9808
+ */
9809
+ listPages: method(_void(), array(AddonPageDeclarationSchema).readonly(), { auth: "admin" }) }
9800
9810
  };
9801
9811
  var AddonHttpRouteSchema = object({
9802
9812
  method: _enum([
@@ -10032,7 +10042,7 @@ var WidgetMetadataSchema = object({
10032
10042
  defaultColumns: number().int().min(1).max(12).default(6),
10033
10043
  defaultRows: number().int().min(1).max(12).default(1)
10034
10044
  });
10035
- method(_void(), array(WidgetMetadataSchema).readonly());
10045
+ method(_void(), array(WidgetMetadataSchema).readonly(), { auth: "admin" });
10036
10046
  /**
10037
10047
  * `addon-widgets` — system-scoped singleton aggregator cap. Public-facing
10038
10048
  * surface that admin-ui consumes through `useAddonWidgetsListWidgets()`.
@@ -11581,7 +11591,17 @@ var customModelRegistryCapability = {
11581
11591
  scope: "system",
11582
11592
  mode: "collection",
11583
11593
  internal: true,
11584
- methods: { listModels: method(_void(), array(CustomModelDescriptorSchema).readonly()) }
11594
+ methods: {
11595
+ /**
11596
+ * `internal: true` did not gate the mount (see the 2026-08-26 note on
11597
+ * `data-store-provider`) — this was reachable on the AppRouter by ANY
11598
+ * authenticated session at the default `auth: 'protected'`. The only
11599
+ * consumer, the detection-pipeline's model resolution
11600
+ * (`addon-pipeline/src/detection-pipeline/provider.ts`), calls
11601
+ * `ctx.api.customModelRegistry.listModels.query()` — UDS/Moleculer,
11602
+ * never tRPC — so `auth: 'admin'` costs it nothing.
11603
+ */
11604
+ listModels: method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" }) }
11585
11605
  };
11586
11606
  /**
11587
11607
  * Query filter for settings-store collections.
@@ -11669,7 +11689,8 @@ method(object({
11669
11689
  }), _void(), { kind: "mutation" }), method(object({
11670
11690
  namespace: string().optional(),
11671
11691
  collection: string(),
11672
- filter: QueryFilterSchema.optional()
11692
+ filter: QueryFilterSchema.optional(),
11693
+ columns: array(string()).readonly().optional()
11673
11694
  }), array(SettingsRecordSchema).readonly()), method(object({
11674
11695
  namespace: string().optional(),
11675
11696
  collection: string(),
@@ -11732,46 +11753,87 @@ var EngineInfoSchema = object({
11732
11753
  kind: _enum(["relational", "vector"]),
11733
11754
  displayName: string()
11734
11755
  });
11735
- method(_void(), EngineInfoSchema), method(object({
11756
+ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
11736
11757
  namespace: string().optional(),
11737
11758
  collection: string(),
11738
11759
  key: string()
11739
- }), unknown()), method(object({
11760
+ }), unknown(), { auth: "admin" }), method(object({
11740
11761
  namespace: string().optional(),
11741
11762
  collection: string(),
11742
11763
  key: string(),
11743
11764
  value: unknown()
11744
- }), _void(), { kind: "mutation" }), method(object({
11765
+ }), _void(), {
11766
+ kind: "mutation",
11767
+ auth: "admin"
11768
+ }), method(object({
11745
11769
  namespace: string().optional(),
11746
11770
  collection: string(),
11747
- filter: QueryFilterSchema.optional()
11748
- }), array(SettingsRecordSchema).readonly()), method(object({
11771
+ filter: QueryFilterSchema.optional(),
11772
+ /**
11773
+ * SQL-level column projection — MUST mirror `settings-store.query`.
11774
+ *
11775
+ * ⚠ An earlier version of this comment blamed Zod stripping, and that
11776
+ * was wrong — corrected 2026-08-26 after the hop map
11777
+ * (`docs/design/2026-08-26-mappa-hop-argomenti.md`) traced the path.
11778
+ * There is **no Zod parse at all** between the door and the engine: the
11779
+ * dispatcher forwards the payload verbatim and UDS carries it whole. A
11780
+ * field declared here reaches `SqliteSettingsBackend` either way.
11781
+ *
11782
+ * What actually lost `columns` was the THIRD declaration of this shape:
11783
+ * `SettingsQueryInput` in `interfaces/storage.ts`, a hand-written TS
11784
+ * interface the engine destructures from. The field existed on both
11785
+ * schemas and the engine still never read it, because nothing checks a
11786
+ * registered provider against `InferProvider<cap>` —
11787
+ * `ProviderRegistration.provider` is typed `object`.
11788
+ *
11789
+ * It is declared here anyway, and must stay in step with
11790
+ * `settings-store.query`: a caller reading only the cap definitions has
11791
+ * to be able to see that this call carries a projection.
11792
+ * `data-door-schema-parity.spec.ts` keeps the two aligned.
11793
+ */
11794
+ columns: array(string()).readonly().optional()
11795
+ }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
11749
11796
  namespace: string().optional(),
11750
11797
  collection: string(),
11751
11798
  record: SettingsRecordSchema
11752
- }), _void(), { kind: "mutation" }), method(object({
11799
+ }), _void(), {
11800
+ kind: "mutation",
11801
+ auth: "admin"
11802
+ }), method(object({
11753
11803
  namespace: string().optional(),
11754
11804
  collection: string(),
11755
11805
  id: string(),
11756
11806
  data: record(string(), unknown())
11757
- }), _void(), { kind: "mutation" }), method(object({
11807
+ }), _void(), {
11808
+ kind: "mutation",
11809
+ auth: "admin"
11810
+ }), method(object({
11758
11811
  namespace: string().optional(),
11759
11812
  collection: string(),
11760
11813
  key: string()
11761
- }), _void(), { kind: "mutation" }), method(object({
11814
+ }), _void(), {
11815
+ kind: "mutation",
11816
+ auth: "admin"
11817
+ }), method(object({
11762
11818
  namespace: string().optional(),
11763
11819
  collection: string(),
11764
11820
  filter: MutationFilterSchema
11765
- }), object({ deleted: number().int() }), { kind: "mutation" }), method(object({
11821
+ }), object({ deleted: number().int() }), {
11822
+ kind: "mutation",
11823
+ auth: "admin"
11824
+ }), method(object({
11766
11825
  namespace: string().optional(),
11767
11826
  collection: string(),
11768
11827
  filter: MutationFilterSchema,
11769
11828
  data: record(string(), unknown())
11770
- }), object({ updated: number().int() }), { kind: "mutation" }), method(object({
11829
+ }), object({ updated: number().int() }), {
11830
+ kind: "mutation",
11831
+ auth: "admin"
11832
+ }), method(object({
11771
11833
  namespace: string().optional(),
11772
11834
  collection: string(),
11773
11835
  filter: QueryFilterSchema.optional()
11774
- }), number()), method(object({
11836
+ }), number(), { auth: "admin" }), method(object({
11775
11837
  namespace: string().optional(),
11776
11838
  collection: string(),
11777
11839
  field: string(),
@@ -11781,15 +11843,18 @@ method(_void(), EngineInfoSchema), method(object({
11781
11843
  }), array(object({
11782
11844
  bucket: number().int(),
11783
11845
  count: number().int()
11784
- })).readonly()), method(object({
11846
+ })).readonly(), { auth: "admin" }), method(object({
11785
11847
  namespace: string().optional(),
11786
11848
  collection: string()
11787
- }), boolean()), method(object({
11849
+ }), boolean(), { auth: "admin" }), method(object({
11788
11850
  namespace: string().optional(),
11789
11851
  collection: string(),
11790
11852
  columns: array(CollectionColumnSchema).readonly(),
11791
11853
  indexes: array(CollectionIndexSchema).readonly().optional()
11792
- }), _void(), { kind: "mutation" });
11854
+ }), _void(), {
11855
+ kind: "mutation",
11856
+ auth: "admin"
11857
+ });
11793
11858
  /**
11794
11859
  * shm ring usage stats for a `frameSink: 'shm'` decoder session —
11795
11860
  * exposed via `decoder.getShmStats` so downstream consumers can
@@ -12917,7 +12982,7 @@ method(object({
12917
12982
  crop: _instanceof(Uint8Array),
12918
12983
  width: number(),
12919
12984
  height: number()
12920
- }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
12985
+ }), EmbeddingResultSchema, { auth: "admin" }), method(object({ text: string() }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" });
12921
12986
  /**
12922
12987
  * filesystem-browse — per-node capability for browsing the node's local
12923
12988
  * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
@@ -13210,19 +13275,22 @@ method(LlmGenerateBaseInputSchema.extend({
13210
13275
  runtime: ManagedRuntimeConfigSchema,
13211
13276
  /** The managed profile's timeout, threaded by the hub provider. */
13212
13277
  timeoutMs: number().int().positive().optional()
13213
- }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
13278
+ }), LlmGenerateResultSchema, {
13279
+ kind: "mutation",
13280
+ auth: "admin"
13281
+ }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
13214
13282
  kind: "mutation",
13215
13283
  auth: "admin"
13216
13284
  }), method(object({}), _void(), {
13217
13285
  kind: "mutation",
13218
13286
  auth: "admin"
13219
- }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
13287
+ }), method(object({}), LlmRuntimeStatusSchema, { auth: "admin" }), method(object({ model: ManagedModelRefSchema }), _void(), {
13220
13288
  kind: "mutation",
13221
13289
  auth: "admin"
13222
13290
  }), method(object({ file: string() }), _void(), {
13223
13291
  kind: "mutation",
13224
13292
  auth: "admin"
13225
- }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
13293
+ }), method(object({}), array(LlmNodeModelSchema), { auth: "admin" }), method(object({}), LlmRuntimeDiskUsageSchema, { auth: "admin" });
13226
13294
  /**
13227
13295
  * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
13228
13296
  * methods concat-fan across providers; single-row methods route to ONE
@@ -16701,1832 +16769,1982 @@ var OauthIntegrationDescriptorSchema = object({
16701
16769
  */
16702
16770
  refreshTokenTtlSec: union([number().int().positive(), literal("never")]).optional()
16703
16771
  });
16704
- method(_void(), OauthIntegrationDescriptorSchema);
16772
+ method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
16705
16773
  /**
16706
- * pipeline-analytics device-scoped wrapper cap. Refines raw
16707
- * per-frame detections emitted by the pipeline runner into tracked
16708
- * objects, per-kind event collections (motion / object / audio), and
16709
- * persisted media. Owns the post-detection domain end-to-end:
16710
- *
16711
- * runner emits PipelineInferenceResult
16712
- * ↓ (event bus)
16713
- * pipeline-analytics subscriber
16714
- * ↓ SORT tracker + zone engine + state analyzer + event emitter
16715
- * → three DB collections (one per kind), one FS media tree, one
16716
- * unified event emitter (FrameTracked + TrackStarted/Ended +
16717
- * DetectionEvent on bus)
16718
- *
16719
- * Pure subscriber model. No `processFrame` cap method — the runner
16720
- * already publishes the raw frame on the bus. The cap surface is
16721
- * only QUERIES + per-device settings, bound on/off via
16722
- * `device-manager.setWrapperActive`. `defaultActive: true` because
16723
- * every camera with a detection pipeline wants its raw detections
16724
- * refined; operators opt out per-device via BindingsTab when needed.
16725
- *
16726
- * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
16727
- * (per-device surface) and `track-trail` caps — see P11 cleanup.
16774
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
16775
+ * within the frame, so the executor can re-cut a leaf child ROI at native
16776
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
16728
16777
  */
16729
- var TrackStateSchema = _enum([
16730
- "new",
16731
- "entered",
16732
- "left",
16733
- "moving",
16734
- "idle"
16735
- ]);
16736
- var EventKindSchema = _enum([
16737
- "motion",
16738
- "object",
16739
- "audio"
16740
- ]);
16778
+ var NativeCropRefSchema = object({
16779
+ /** Handle keying the retained native surface (node-pinned to its owner). */
16780
+ handle: FrameHandleSchema,
16781
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
16782
+ cropFrameSpace: object({
16783
+ x: number(),
16784
+ y: number(),
16785
+ w: number(),
16786
+ h: number()
16787
+ })
16788
+ });
16789
+ object({
16790
+ crop: object({
16791
+ left: number(),
16792
+ top: number(),
16793
+ width: number().positive(),
16794
+ height: number().positive()
16795
+ }).optional(),
16796
+ content: object({
16797
+ width: number().int().positive(),
16798
+ height: number().int().positive()
16799
+ }),
16800
+ fit: _enum(["stretch", "contain"]),
16801
+ format: _enum([
16802
+ "rgb",
16803
+ "gray",
16804
+ "jpeg"
16805
+ ])
16806
+ });
16741
16807
  /**
16742
- * Spatial filter for `listTracks` the rect + polygon variants of the shared
16743
- * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
16744
- * of the camera frame (top-left origin), matching the drawing-plane editor.
16808
+ * Process-local frame identity. It is serializable so it can ride an in-process
16809
+ * capability call, but `registryId` deliberately prevents resolution in any
16810
+ * other process or execution group.
16745
16811
  */
16746
- var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
16747
- /** Closed icon vocabulary so clients render a known glyph per kind. */
16748
- var EventKindIconSchema = _enum([
16749
- "motion",
16750
- "audio",
16751
- "person",
16752
- "vehicle",
16753
- "animal",
16754
- "door",
16755
- "pir",
16756
- "smoke",
16757
- "water",
16758
- "button",
16759
- "package",
16760
- "generic"
16812
+ var FrameRefSchema = object({
16813
+ registryId: string().min(1),
16814
+ id: string().min(1),
16815
+ width: number().int().positive(),
16816
+ height: number().int().positive(),
16817
+ format: _enum(["rgb", "gray"]),
16818
+ timestamp: number(),
16819
+ capturedAt: number().optional()
16820
+ });
16821
+ var ModelFormatSchema$1 = _enum([
16822
+ "onnx",
16823
+ "coreml",
16824
+ "openvino",
16825
+ "tflite",
16826
+ "pt",
16827
+ "gguf"
16761
16828
  ]);
16762
- var EventKindCategorySchema = _enum([
16763
- "motion",
16764
- "audio",
16765
- "detection",
16766
- "sensor",
16767
- "control",
16768
- "custom",
16769
- "package"
16829
+ var PipelineSlotSchema = _enum([
16830
+ "detector",
16831
+ "cropper",
16832
+ "classifier",
16833
+ "refiner",
16834
+ "audio-classifier"
16770
16835
  ]);
16771
- /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
16772
- var EventKindLevelSchema = _enum(["macro", "sub"]);
16773
- var EventKindDescriptorSchema = object({
16774
- /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
16775
- kind: string(),
16776
- /** i18n key resolved on the UI side; `label` is the English fallback. */
16777
- labelKey: string(),
16778
- /** English fallback label (kept for clients that don't translate). */
16779
- label: string(),
16780
- /** Hex color for timeline/legend rendering. */
16781
- color: string(),
16782
- /** Dictionary id → lucide component on the UI side. */
16783
- iconId: string(),
16784
- /** Legacy closed-vocab glyph — fallback for `iconId`. */
16785
- icon: EventKindIconSchema,
16786
- category: EventKindCategorySchema,
16787
- /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
16788
- parentKind: string().nullable(),
16789
- /** Derived from `parentKind`, explicit for the client tree. */
16790
- level: EventKindLevelSchema,
16791
- /** Which cap + device contributes this kind. For built-ins the camera
16792
- * itself; for sensor kinds the LINKED source device. */
16793
- source: object({
16794
- capName: string(),
16795
- deviceId: number()
16796
- })
16836
+ var PipelineEngineChoiceSchema = object({
16837
+ runtime: _enum(["node", "python"]),
16838
+ backend: string(),
16839
+ format: ModelFormatSchema$1,
16840
+ device: string().optional()
16797
16841
  });
16798
- /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
16799
- var EventKindsForDeviceSchema = object({
16800
- deviceId: number(),
16801
- kinds: array(EventKindDescriptorSchema).readonly()
16842
+ var AvailableEngineSchema = object({
16843
+ engine: PipelineEngineChoiceSchema,
16844
+ devices: array(object({
16845
+ id: string(),
16846
+ label: string(),
16847
+ description: string().optional()
16848
+ })).readonly(),
16849
+ defaultDevice: string()
16802
16850
  });
16803
- var SensorEventSchema = object({
16851
+ var PipelineDefaultStepSchema = lazy(() => object({
16852
+ addonId: string(),
16853
+ addonName: string(),
16854
+ slot: PipelineSlotSchema,
16855
+ inputClasses: array(string()).readonly(),
16856
+ outputClasses: array(string()).readonly(),
16857
+ enabled: boolean(),
16858
+ modelId: string(),
16859
+ children: array(PipelineDefaultStepSchema).readonly(),
16860
+ group: string().optional(),
16861
+ settings: record(string(), unknown()).optional()
16862
+ }));
16863
+ var PipelineTemplateStepSchema = lazy(() => object({
16864
+ addonId: string(),
16865
+ enabled: boolean(),
16866
+ modelId: string(),
16867
+ children: array(PipelineTemplateStepSchema).readonly(),
16868
+ settings: record(string(), unknown()).optional()
16869
+ }));
16870
+ var PipelineTemplateSchema$1 = object({
16804
16871
  id: string(),
16805
- /** The CAMERA the event is attributed to (a sensor linked to N cameras
16806
- * yields N rows, one per camera). */
16807
- deviceId: number(),
16808
- /** The linked sensor device whose state changed. */
16809
- sourceDeviceId: number(),
16810
- /** Event kind id — matches an `EventKindDescriptor.kind`. */
16811
- kind: string(),
16812
- /** Snapshot of the sensor cap's runtime-state slice at the change. */
16813
- value: record(string(), unknown()).nullable(),
16814
- timestamp: number()
16872
+ name: string(),
16873
+ createdAt: string(),
16874
+ updatedAt: string(),
16875
+ engine: PipelineEngineChoiceSchema,
16876
+ steps: array(PipelineTemplateStepSchema).readonly()
16815
16877
  });
16816
- var TrackPositionSchema = object({
16817
- x: number(),
16818
- y: number(),
16819
- timestamp: number(),
16820
- bbox: BoundingBoxSchema
16821
- });
16822
- var TrackSnapshotSchema = object({
16823
- timestamp: number(),
16824
- position: TrackPositionSchema,
16825
- /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
16826
- mediaKey: string()
16878
+ var PipelineModelOptionSchema = object({
16879
+ id: string(),
16880
+ name: string(),
16881
+ formats: record(string(), object({
16882
+ downloaded: boolean(),
16883
+ sizeMB: number()
16884
+ })),
16885
+ group: ModelVariantGroupSchema.optional(),
16886
+ legacy: boolean().optional(),
16887
+ provider: ModelProviderIdSchema.optional()
16827
16888
  });
16828
- /**
16829
- * Normalized 0..1 trajectory envelope (min/max over every position bbox,
16830
- * divided by the track's detection-frame dims), computed at persist time.
16831
- * Absent when the frame dims were unknown when the track was persisted
16832
- * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
16833
- */
16834
- var TrackEnvelopeSchema = object({
16835
- minX: number(),
16836
- minY: number(),
16837
- maxX: number(),
16838
- maxY: number()
16889
+ var ConfigFieldBridge = custom();
16890
+ var PipelineAddonSchemaSchema = object({
16891
+ id: string(),
16892
+ name: string(),
16893
+ slot: PipelineSlotSchema,
16894
+ inputClasses: array(string()).readonly(),
16895
+ outputClasses: array(string()).readonly(),
16896
+ childSlots: array(PipelineSlotSchema).readonly(),
16897
+ models: array(PipelineModelOptionSchema).readonly(),
16898
+ defaultModelId: string(),
16899
+ defaultModelIdByFormat: record(string(), string()).optional(),
16900
+ enabledByDefault: boolean().optional(),
16901
+ backfillIntoExistingOverrides: boolean().optional(),
16902
+ defaultConfidence: number(),
16903
+ group: string().optional(),
16904
+ configSchema: array(ConfigFieldBridge).readonly().optional()
16839
16905
  });
16840
- /**
16841
- * Row projection for track list queries. `full` (default) returns the
16842
- * complete Track including the frame-rate `positions[]` history and the
16843
- * `snapshots[]` references — megabytes across a page of tracks. `slim`
16844
- * keeps every scalar the list surfaces actually render (ids, class(es),
16845
- * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
16846
- * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
16847
- * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
16848
- * `getTrack`. Mirrors the event-store `projection` convention
16849
- * (`getObjectEvents` et al.).
16850
- */
16851
- var TrackProjectionSchema = _enum(["full", "slim"]);
16852
- /**
16853
- * One audio-classification label heard on the track's camera while the
16854
- * track was alive, aggregated per label. An "episode" is one persisted
16855
- * audio event (the confident-classification path: score ≥ the device's
16856
- * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
16857
- * one 32 ms inference chunk, so counts stay human-scaled.
16858
- */
16859
- var TrackAudioLabelSchema = object({
16906
+ var PipelineSlotSchemaSchema = object({
16907
+ id: PipelineSlotSchema,
16860
16908
  label: string(),
16861
- /** Highest classification score observed across the label's episodes. */
16862
- peakScore: number(),
16863
- /** Number of coalesced audio-event episodes carrying this label. */
16864
- count: number(),
16865
- firstAt: number(),
16866
- lastAt: number()
16909
+ priority: number(),
16910
+ parentSlot: PipelineSlotSchema.nullable(),
16911
+ addons: array(PipelineAddonSchemaSchema).readonly()
16867
16912
  });
16868
- /**
16869
- * How a track was produced. `pipeline` (default / absent) = the spatial
16870
- * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
16871
- * no positions, a single snapshot, and no bbox trajectory at all:
16872
- *
16873
- * - `sensor` — a linked sensor/control device state change.
16874
- * - `audio` — an audio event on the camera itself that was anomalous for
16875
- * THAT camera, loud, and heard while nothing visual was happening (D62).
16876
- *
16877
- * The spatial subsystems (tracker association, occupancy count, re-id /
16878
- * embedding, resurrection) MUST skip every synthetic source. Test for that
16879
- * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
16880
- * check silently readmits every source added after it was written.
16881
- */
16882
- var TrackSourceSchema = _enum([
16883
- "pipeline",
16884
- "sensor",
16885
- "audio"
16886
- ]);
16887
- /**
16888
- * Where a track sits in the RETRAIN lifecycle (D81).
16889
- *
16890
- * - `none` — never marked, or un-marked. Evictable.
16891
- * - `staging` — the operator wants this track as training material and has not
16892
- * finished with it. **This is the only state retention holds**: the track and
16893
- * everything it owns (object events, crops, keyframes, CLIP vector) survive
16894
- * the device's age window.
16895
- * - `trained` — the retrain page has taken what it needed. The frames it chose
16896
- * were COPIED into the retrain dataset at selection time, so the dataset no
16897
- * longer depends on the track's media and the track becomes EVICTABLE again.
16898
- * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
16899
- * a deliberate action of the retrain page, not a side effect of a checkbox.
16900
- *
16901
- * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
16902
- * the store's filter language has only positive equality and `whereIn` — no
16903
- * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
16904
- * would make the entire pre-column history immortal in one deploy.
16905
- */
16906
- var RetrainStatusSchema = _enum([
16907
- "none",
16908
- "staging",
16909
- "trained"
16910
- ]);
16911
- /**
16912
- * Per-track OPERATOR flags — set by hand from the admin UI or the viewer, never
16913
- * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
16914
- * so the two surfaces cannot drift.
16915
- *
16916
- * **Absent ≠ false.** A track that has never been touched omits the field; an
16917
- * explicitly un-flagged track carries `false`. Legacy rows written before the
16918
- * columns existed read as absent, and a consumer that needs a boolean should say
16919
- * `flag === true`, not `flag !== false`.
16920
- *
16921
- * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
16922
- * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
16923
- * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
16924
- * `trained` track reports `false` while refusing both writes. The boolean is
16925
- * kept because three surfaces drive a toggle off it; anything that needs to tell
16926
- * "never marked" from "already trained" must read `retrainStatus`.
16927
- *
16928
- * `debug` does NOT pin; it is attention, not durability.
16929
- *
16930
- * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
16931
- * A favourited track is skipped by retention the same way `staging` is, but
16932
- * it does not enter `none|staging|trained` and has no staging budget.
16933
- */
16934
- var TrackFlagFields = {
16935
- /** Operator marked this track as training material — i.e. `retrainStatus` is
16936
- * `'staging'`. */
16937
- markForTrain: boolean().optional(),
16938
- /** Operator marked this track for diagnostic attention. */
16939
- debug: boolean().optional(),
16940
- /** Operator favourited this track. Pins it against pruning. */
16941
- favourited: boolean().optional()
16942
- };
16943
- /**
16944
- * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
16945
- * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
16946
- * write patch, and the status is not something the toggle sets — it is what the
16947
- * toggle's boolean is derived from. Absent on an in-RAM track never touched;
16948
- * always present on a persisted row (the column default materialises `'none'`).
16949
- */
16950
- var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
16951
- /**
16952
- * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
16953
- * one flag can never clear the other — the toggles are independent and are
16954
- * driven from three surfaces that do not know about each other.
16955
- */
16956
- var TrackFlagsPatchSchema = object(TrackFlagFields);
16957
- /**
16958
- * The resolved flag state after a write. Both fields are REQUIRED here (absent
16959
- * collapses to `false`) so a caller can drive a toggle's checked state off the
16960
- * mutation result without a re-fetch.
16961
- */
16962
- var TrackFlagsSchema = object({
16963
- trackId: string(),
16964
- markForTrain: boolean(),
16965
- debug: boolean(),
16966
- favourited: boolean(),
16967
- /** The lifecycle state the boolean was derived from. Required here (unlike on
16968
- * a track row) because this shape is only ever produced by the write body,
16969
- * which always knows it — and a surface that has just written needs to render
16970
- * `trained` without a re-fetch. */
16971
- retrainStatus: RetrainStatusSchema
16913
+ var PipelineSchemaSchema = object({
16914
+ availableEngines: array(AvailableEngineSchema).readonly(),
16915
+ selectedEngine: PipelineEngineChoiceSchema,
16916
+ slots: array(PipelineSlotSchemaSchema).readonly()
16972
16917
  });
16973
- union([literal(1), literal(2)]);
16974
- /**
16975
- * WHO decided a label, and when. Carried per tier so a value can be traced to
16976
- * the step and model that produced it — which is what makes the write rule
16977
- * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
16978
- * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
16979
- *
16980
- * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
16981
- * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
16982
- * `migration:4g` for a value the 4g migration moved from the single-slot era —
16983
- * that value has no provenance, and the write rule lets ANY properly-attributed
16984
- * write of the same tier replace it regardless of score.
16985
- */
16986
- var LabelAttributionSchema = object({
16987
- stepId: string(),
16988
- modelId: string().optional(),
16989
- decidedAt: number(),
16918
+ var EngineProvisioningSchema = object({
16919
+ runtimeId: _enum([
16920
+ "onnx",
16921
+ "openvino",
16922
+ "coreml",
16923
+ "edgetpu"
16924
+ ]).nullable(),
16925
+ device: string().nullable(),
16926
+ state: _enum([
16927
+ "idle",
16928
+ "installing",
16929
+ "verifying",
16930
+ "ready",
16931
+ "failed"
16932
+ ]),
16933
+ progress: number().optional(),
16934
+ error: string().optional(),
16935
+ nextRetryAt: number().optional(),
16990
16936
  /**
16991
- * The GALLERY id behind a recognised tier-2 label — a face-gallery
16992
- * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
16993
- *
16994
- * The text alone is a DISPLAY NAME, and a display name is renameable: a
16995
- * notification rule authored on "Gianluca" stopped matching the moment the
16996
- * operator fixed the spelling in the gallery, and nothing said so. The id is
16997
- * the thing that does not move, so it is what a rule matches on
16998
- * (`NcConditions.identities`) and the text is what a human is shown.
16999
- *
17000
- * Absent when the label names no gallery row — a plate the OCR read but no
17001
- * vehicle claims, a sub-class, a species, any tier-1 value.
16937
+ * Gate A (config-correctness gate at engine change): human-readable
16938
+ * config issues surfaced EAGERLY when the node's engine changes — model
16939
+ * substitutions ("chose X, running Y") and zero-build steps ("no model
16940
+ * has a <format> build"). Additive/optional: informational only, never
16941
+ * enforced here `assertEngineReady` (readiness) still gates inference.
16942
+ * Absent/empty when the node-default tree resolves cleanly.
17002
16943
  */
17003
- identityId: string().optional()
16944
+ configIssues: array(string()).optional()
17004
16945
  });
17005
- /**
17006
- * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
17007
- * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
17008
- * track and its events always answer the same question the same way.
17009
- *
17010
- * Two scalar columns, not an array: every consumer wants "the coarse one" or
17011
- * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
17012
- * is tier 2, and each carries its own score + attribution.
17013
- *
17014
- * **Reading it.** What a human should be shown is `subLabel ?? label` — the
17015
- * finest thing known. Before 4g the single `label` column held the finest
17016
- * value, so a consumer that has not been updated reads the tier-1 slot and
17017
- * shows nothing on a species-only row; that is why the migration puts every
17018
- * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
17019
- * and why the read surfaces were changed in the same train.
17020
- *
17021
- * **Writing it.** The slots are independent, which is the whole point: a
17022
- * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
17023
- * migratorius`), so fineness cannot regress by construction. Within a tier the
17024
- * higher score wins. One rule, one implementation — see
17025
- * `pipeline/label-tier.ts` in addon-post-analysis.
17026
- */
17027
- var TieredLabelFields = {
17028
- /** Tier 1 the sub-class. See {@link LabelTierSchema}. */
17029
- label: string().optional(),
17030
- /** Confidence of the tier-1 value, as reported by the deciding step. */
17031
- labelScore: number().optional(),
17032
- /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
17033
- labelMeta: LabelAttributionSchema.optional(),
17034
- /** Tier 2 — the instance. See {@link LabelTierSchema}. */
17035
- subLabel: string().optional(),
17036
- /** Confidence of the tier-2 value, as reported by the deciding step. */
17037
- subLabelScore: number().optional(),
17038
- /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
17039
- subLabelMeta: LabelAttributionSchema.optional()
17040
- };
17041
- /** Per-camera slice of a training-export estimate. */
17042
- var TrainingExportDeviceTotalsSchema = object({
17043
- deviceId: number(),
17044
- tracks: number().int(),
17045
- files: number().int(),
17046
- bytes: number().int()
16946
+ var PipelineStepInputSchema = lazy(() => object({
16947
+ addonId: string(),
16948
+ modelId: string().optional(),
16949
+ enabled: boolean().default(true),
16950
+ children: array(PipelineStepInputSchema).optional(),
16951
+ settings: record(string(), unknown()).optional(),
16952
+ jumpDeviceKey: string().optional()
16953
+ }));
16954
+ var ModelSubstitutionSchema = object({
16955
+ addonId: string(),
16956
+ chosen: string(),
16957
+ running: string(),
16958
+ format: string()
16959
+ });
16960
+ var PipelineValidationIssueSchema = object({
16961
+ addonId: string(),
16962
+ kind: _enum(["unknown-addon", "no-format-build"]),
16963
+ detail: string()
16964
+ });
16965
+ var PipelineValidationResultSchema = object({
16966
+ ok: boolean(),
16967
+ issues: array(PipelineValidationIssueSchema).readonly(),
16968
+ substitutions: array(ModelSubstitutionSchema).readonly(),
16969
+ /** The node's `currentEngine.format` this validation ran against. */
16970
+ format: string()
16971
+ });
16972
+ var ReferenceImageEntrySchema = object({
16973
+ filename: string(),
16974
+ stepIds: array(string()).readonly().optional()
16975
+ });
16976
+ var ReferenceImageBodySchema = object({
16977
+ base64: string(),
16978
+ filename: string()
16979
+ });
16980
+ var ReferenceAudioEntrySchema = object({
16981
+ filename: string(),
16982
+ sizeKb: number()
16983
+ });
16984
+ var ReferenceAudioBodySchema = object({ base64: string() });
16985
+ var AudioBackendSchema = object({
16986
+ id: string(),
16987
+ name: string(),
16988
+ description: string(),
16989
+ available: boolean(),
16990
+ /**
16991
+ * Raw classifier labels this backend can emit (e.g. YAMNet's
16992
+ * 521-class set or Apple SoundAnalysis's 303-class set). Used by
16993
+ * the benchmark UI to populate the `enabledMicroClasses` filter
16994
+ * specific to the selected backend without a separate fetch.
16995
+ */
16996
+ rawLabels: array(string()).readonly().optional()
16997
+ });
16998
+ var AudioCapabilitiesSchema = object({
16999
+ activeBackend: string(),
17000
+ availableBackends: array(AudioBackendSchema).readonly(),
17001
+ sampleRate: number(),
17002
+ chunkDurationMs: number()
17003
+ });
17004
+ var DownloadModelResultSchema = object({
17005
+ filePath: string(),
17006
+ sizeMB: number(),
17007
+ durationMs: number()
17047
17008
  });
17048
17009
  /**
17049
- * What a training export WOULD contain. Computed from media index rows only —
17050
- * no blob is read to produce this.
17010
+ * Wrapper carrying a single test run's result. Replaces the legacy
17011
+ * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
17012
+ * canonical `AudioResult` from the Phase 6 output rework: one
17013
+ * `AudioDetection` per class above `minScore`, top-N candidates in
17014
+ * `debug.alternateLabels['audio-classifier']`, per-source timings in
17015
+ * `debug.stepTimings`. The outer `success`/`error` fields stay so the
17016
+ * benchmark UI can still report a clean failure when the classifier
17017
+ * cap isn't available.
17051
17018
  */
17052
- var TrainingExportSummarySchema = object({
17053
- generatedAt: number(),
17054
- trackCount: number().int(),
17055
- fileCount: number().int(),
17056
- byteCount: number().int(),
17057
- /** More marked tracks exist than a single pass carries. */
17058
- truncated: boolean(),
17059
- devices: array(TrainingExportDeviceTotalsSchema).readonly()
17019
+ var AudioTestResultSchema = object({
17020
+ success: boolean(),
17021
+ error: string().optional(),
17022
+ frame: custom().optional()
17060
17023
  });
17061
- var TrackSchema = object({
17062
- trackId: string(),
17063
- deviceId: number(),
17064
- className: string(),
17065
- ...TieredLabelFields,
17066
- producingDeviceName: string().optional(),
17067
- /** Track provenance. Absent `pipeline` (legacy rows). */
17068
- source: TrackSourceSchema.optional(),
17069
- firstSeen: number(),
17070
- lastSeen: number(),
17071
- /** Frame-rate position history (subject to maxPositionHistory cap). */
17072
- positions: array(TrackPositionSchema).readonly(),
17073
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
17074
- * saveThumbnails policy). */
17075
- snapshots: array(TrackSnapshotSchema).readonly(),
17076
- /** Deduplicated zones the track has entered at least once. Zone IDS. */
17077
- zonesVisited: array(string()).readonly(),
17024
+ var PipelineConfigBridge = custom();
17025
+ var ConfigUISchemaBridge = custom();
17026
+ var ConfigUISchemaNullableBridge = custom();
17027
+ var InferenceCapabilitiesBridge = custom();
17028
+ var ModelAvailabilityListBridge = custom();
17029
+ var PipelineRunResultBridge = custom();
17030
+ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
17031
+ modelId: string(),
17032
+ settings: record(string(), unknown()).readonly()
17033
+ }))), method(object({ steps: record(string(), object({
17034
+ modelId: string(),
17035
+ settings: record(string(), unknown()).readonly()
17036
+ })) }), object({ success: literal(true) }), {
17037
+ kind: "mutation",
17038
+ auth: "admin"
17039
+ }), method(object({ nodeId: string() }), object({
17040
+ success: literal(true),
17041
+ clearedDevices: number()
17042
+ }), {
17043
+ kind: "mutation",
17044
+ auth: "admin"
17045
+ }), method(object({ nodeId: string() }), object({ unhealthy: array(object({
17046
+ /** `<backend>:<device>`, e.g. `openvino:gpu`. */
17047
+ deviceKey: string(),
17078
17048
  /**
17079
- * Human NAMES for {@link zonesVisited}, resolved at READ time against the
17080
- * `zones` capability.
17081
- *
17082
- * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
17083
- * and no card can render — so every free-text search surface was structurally
17084
- * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
17085
- * just returned nothing. Resolving here rather than in each client keeps ONE
17086
- * derivation and costs the clients no extra call (the `zones` cap is
17087
- * per-device, so a client-side resolve would be a per-camera fan-out on a
17088
- * surface built to avoid exactly that).
17089
- *
17090
- * Resolved, never invented: a zone deleted since the track was written has no
17091
- * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
17092
- * two are not positionally aligned. Absent when the track visited no zone, or
17093
- * when the zone catalogue could not be read.
17049
+ * `failed` the per-device restart budget is exhausted; no pool
17050
+ * will be spawned until an operator re-arms it or the runner
17051
+ * respawns. `backoff` — under budget, waiting out the backoff (or
17052
+ * a cached pool observed dead and not yet condemned).
17094
17053
  */
17095
- zoneNames: array(string()).readonly().optional(),
17096
- /** Deduplicated set of detector classes observed for this track over its
17097
- * life (a track may be reclassified, e.g. person→vehicle). Absent on
17098
- * legacy rows written before class accumulation shipped. */
17099
- classes: array(string()).readonly().optional(),
17100
- /** Cumulative normalized distance travelled (0..1 units = full frame width). */
17101
- totalDistance: number(),
17102
- state: TrackStateSchema,
17103
- active: boolean(),
17104
- /** Deterministic key-event importance score in [0,1] (server-computed at
17105
- * track expiry, recomputed on late label). Absent on legacy rows written
17106
- * before scoring shipped — consumers degrade to absence / compute-on-read. */
17107
- importance: number().optional(),
17108
- /** Id of the track's highest-confidence ObjectEvent (its representative
17109
- * "best" frame). Absent when the track produced no object events. */
17110
- bestEventId: string().optional(),
17111
- /** Tag of the importance sub-signal that dominated the score
17112
- * (identity|dwell|proximity|class|confidence|travel|zone). */
17113
- importanceReason: string().optional(),
17114
- /** Audio-classification labels heard on the camera during the track's
17115
- * life (score ≥ device `classificationMinScore`), aggregated per label.
17116
- * Absent on legacy rows / tracks with no confident audio. */
17117
- audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
17118
- /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
17119
- * Populated from the persisted envelope columns on historical reads;
17120
- * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
17121
- envelope: TrackEnvelopeSchema.optional(),
17054
+ state: _enum(["failed", "backoff"]),
17055
+ /** Epoch ms of the death that produced this state. */
17056
+ since: number(),
17057
+ /** Pool deaths inside the current window. */
17058
+ deaths: number(),
17059
+ /** The last death's message. */
17060
+ lastError: string()
17061
+ })).readonly() })), method(object({
17062
+ nodeId: string(),
17063
+ deviceKey: string()
17064
+ }), object({ rearmed: boolean() }), {
17065
+ kind: "mutation",
17066
+ auth: "admin"
17067
+ }), 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({
17068
+ name: string(),
17069
+ steps: array(PipelineTemplateStepSchema).readonly(),
17070
+ engine: PipelineEngineChoiceSchema
17071
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
17072
+ id: string(),
17073
+ name: string().optional(),
17074
+ steps: array(PipelineTemplateStepSchema).readonly().optional()
17075
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
17076
+ addonId: string(),
17077
+ modelId: string(),
17078
+ format: ModelFormatSchema$1
17079
+ }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
17080
+ addonId: string(),
17081
+ modelId: string(),
17082
+ format: ModelFormatSchema$1
17083
+ }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
17084
+ engine: PipelineEngineChoiceSchema.optional(),
17085
+ steps: array(PipelineStepInputSchema).min(1),
17086
+ frame: FrameInputSchema.optional(),
17122
17087
  /**
17123
- * A face DETECTOR found a face on this track — nothing more. It says the
17124
- * detail plane produced a `face` detail; it does NOT say the face was
17125
- * embedded, matched, above `minFacePx`, or that the recognizer was even
17126
- * enabled. Set once and never cleared.
17127
- *
17128
- * **This exists so "face present but not recognised" is expressible.** A
17129
- * recognised identity lands in `subLabel` (attributed to the face chain via
17130
- * `subLabelMeta.stepId`), so before this field a track with an unmatched face
17131
- * and a track with no face at all were byte-identical on the wire and no
17132
- * surface could tell them apart. The read is `hasFace === true && subLabel
17133
- * === undefined`.
17134
- *
17135
- * **Absent ≠ false.** Every row written before the column existed omits it,
17136
- * and so does every server that predates the field — a consumer must test
17137
- * `=== true` and render nothing otherwise, never infer "no face".
17088
+ * Process-local lazy frame. Valid only when caller and provider resolve
17089
+ * in the same execution-group process; split/cross-node callers use
17090
+ * `frame`/`image` inline compatibility instead.
17138
17091
  */
17139
- hasFace: boolean().optional(),
17092
+ frameRef: FrameRefSchema.optional(),
17140
17093
  /**
17141
- * This track has a face row IN THE GALLERY: a crop **and** an embedding a
17142
- * face an operator could ASSIGN to an identity.
17143
- *
17144
- * The STRICT twin of {@link hasFace}, and the pair only earns its keep
17145
- * because the two disagree. `hasFace` is stamped at the TOP of the face
17146
- * branch, before every gate, and means no more than "a face detector produced
17147
- * a face detail". This one is stamped at the single moment the gallery row
17148
- * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
17149
- * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
17150
- * candidate gate, the imageless-track drop (no crop was ever captured) and
17151
- * the crop-store drop. Everything between the detector and that insert can
17152
- * legitimately refuse the face, so a flag written any earlier promises the
17153
- * operator something to assign and delivers nothing.
17154
- *
17155
- * **Independent of recognition.** A face collected but never auto-matched is
17156
- * still assignable — it is in fact the face an operator most wants to reach —
17157
- * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
17158
- * `subLabel`; this says only that the raw material exists.
17159
- *
17160
- * **Set once, never cleared.** A track that produced a gallery row produced
17161
- * one; deleting the row later is the gallery's business, not this flag's.
17162
- *
17163
- * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
17164
- * before the column omits it, and so does every server that predates the
17165
- * field. A consumer must test `=== true` and render nothing otherwise —
17166
- * never infer "no assignable face".
17094
+ * CB5 shm passthrough a `FrameHandle` naming the same ring slot
17095
+ * the decoded pixels live in. One more member of the one-of
17096
+ * frame/frameHandle/image/imageBase64/referenceImage group.
17167
17097
  */
17168
- hasEmbeddedFace: boolean().optional(),
17098
+ frameHandle: FrameHandleSchema.optional(),
17099
+ imageBase64: string().optional(),
17169
17100
  /**
17170
- * This subject CONTAINS a folded rider a person the rider-pairing step
17171
- * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
17172
- * so the passage is tracked once and as a VEHICLE.
17173
- *
17174
- * It exists because the fold's record was dishonest. D34 and the code both
17175
- * said "the person is not lost — it is reported so both entities stay on the
17176
- * record"; in fact the pair went into a per-processor RAM field behind an
17177
- * accessor nobody called, and every durable surface said `vehicle`, full
17178
- * stop. This is the composition note that makes the row true.
17179
- *
17180
- * A COMPOSITION, never a class and never a label. "This vehicle contains a
17181
- * person" is not an answer to "what is this" — both label tiers would refuse
17182
- * a macro token anyway (D89), and correctly. Nothing here changes what the
17183
- * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
17184
- * and a `person` rule still does not fire for someone cycling past.
17185
- *
17186
- * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
17187
- * the column, and every hub that predates the field, omits it. Test
17188
- * `=== true` and render nothing otherwise — never infer "no rider".
17101
+ * Binary JPEG bytespreferred over `imageBase64` on internal
17102
+ * hops (hub forked worker via Moleculer MsgPack) because it
17103
+ * skips the 33% base64 overhead + the per-call base64 decode on
17104
+ * the detection-pipeline worker. Callers can pass either; exactly
17105
+ * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
17189
17106
  */
17190
- hasRider: boolean().optional(),
17191
- ...TrackFlagFields,
17192
- ...TrackRetrainFields
17193
- });
17194
- var BaseEventFields = {
17195
- id: string(),
17196
- deviceId: number(),
17197
- timestamp: number()
17198
- };
17199
- var MotionEventSchema = object({
17200
- ...BaseEventFields,
17201
- kind: literal("motion"),
17202
- regionCount: number(),
17203
- /** Heavy JSON array omitted in slim projection. */
17204
- regions: array(object({
17205
- bbox: BoundingBoxSchema,
17206
- pixelCount: number(),
17207
- intensity: number()
17208
- })).readonly().optional(),
17209
- /** Omitted in slim projection. */
17210
- frameWidth: number().optional(),
17211
- /** Omitted in slim projection. */
17212
- frameHeight: number().optional(),
17213
- /** Populated by B5 (recording playback URL for this event). */
17214
- mediaUrl: string().optional()
17215
- });
17107
+ image: _instanceof(Uint8Array).optional(),
17108
+ referenceImage: string().optional(),
17109
+ deviceId: number().optional(),
17110
+ sessionId: string().optional(),
17111
+ /**
17112
+ * Execution plane. 'full' (default) runs the whole tree — benchmark,
17113
+ * reference-image, and detail-subtree calls. 'frame' is the live
17114
+ * per-frame dispatch: ONLY root-plane steps run; crop children
17115
+ * (inputClasses ≠ null) are skipped and served per-track via
17116
+ * pipelineRunner.runDetailSubtree (two-plane design).
17117
+ */
17118
+ plane: _enum(["full", "frame"]).optional(),
17119
+ /**
17120
+ * Inference-device selector (Phase 2 multi-device). Format
17121
+ * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
17122
+ * Omitted ⇒ the runner's default device (current single-engine
17123
+ * behaviour). Selects WHICH device pool of the node runs the call.
17124
+ */
17125
+ deviceKey: string().optional(),
17126
+ /**
17127
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
17128
+ * when the parent crop was resolved from the frame's retained NATIVE
17129
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
17130
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
17131
+ * resolution from that surface — the SAME quality path faces already
17132
+ * had — instead of the downscaled parent tile. `handle` keys the native
17133
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
17134
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
17135
+ * the executor's crop-normalized child ROI back into frame-normalized
17136
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
17137
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
17138
+ * (today's behaviour on the fallback path).
17139
+ */
17140
+ nativeCropRef: NativeCropRefSchema.optional()
17141
+ }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
17142
+ engine: PipelineEngineChoiceSchema.optional(),
17143
+ steps: array(PipelineStepInputSchema).min(1),
17144
+ frames: array(FrameInputSchema).min(1).max(255),
17145
+ deviceId: number().optional(),
17146
+ sessionId: string().optional(),
17147
+ /**
17148
+ * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
17149
+ * the batch to the Python pool's bench preprocess cache
17150
+ * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
17151
+ * preprocessed ONCE and every later inference is a pure-inference cache
17152
+ * hit — the sustained-throughput run measures inference, not
17153
+ * decode+preprocess+infer. Omitted/0 for live frames (all different →
17154
+ * full preprocess every call, correct). Fresh per sustained run;
17155
+ * released via `uncacheFrame`.
17156
+ */
17157
+ frameId: number().int().nonnegative().optional(),
17158
+ /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
17159
+ deviceKey: string().optional()
17160
+ }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
17161
+ data: _instanceof(Uint8Array),
17162
+ width: number().int().positive(),
17163
+ height: number().int().positive(),
17164
+ format: _enum([
17165
+ "rgb",
17166
+ "bgr",
17167
+ "gray"
17168
+ ])
17169
+ }), object({
17170
+ frameId: number(),
17171
+ width: number(),
17172
+ height: number()
17173
+ }), { kind: "mutation" }), method(object({
17174
+ stepId: string(),
17175
+ frameId: number().int()
17176
+ }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
17177
+ batchMode: string(),
17178
+ windowMs: number(),
17179
+ maxBatchSize: number(),
17180
+ concurrency: number()
17181
+ })), method(_void(), array(object({
17182
+ engineKey: string(),
17183
+ engine: PipelineEngineChoiceSchema,
17184
+ modelsLoaded: array(string()).readonly(),
17185
+ inUseByCameras: array(number()).readonly(),
17186
+ /**
17187
+ * Origin of this resident factory.
17188
+ * - `runtime` — main camera-serving engine (no idle TTL).
17189
+ * - `warm-override` — benchmark/test override held in the warm
17190
+ * cache; auto-disposed after the idle TTL.
17191
+ * - `device-pool` — a concurrent per-device pool (Phase 2
17192
+ * multi-device, keyed by `deviceKey`) resolved
17193
+ * via `resolveDeviceFactory`. Runs alongside the
17194
+ * `runtime` engine on a DIFFERENT accelerator
17195
+ * (NPU / iGPU / Coral) — this is how the
17196
+ * Engines tab shows all pools running at once.
17197
+ */
17198
+ kind: _enum([
17199
+ "runtime",
17200
+ "warm-override",
17201
+ "device-pool"
17202
+ ]),
17203
+ /** Native pid of the underlying Python pool (null when no pool). */
17204
+ poolPid: number().nullable(),
17205
+ /** ms since this factory was last used (null when not warm-tracked). */
17206
+ idleMs: number().nullable(),
17207
+ /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
17208
+ idleTtlMs: number().nullable()
17209
+ })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
17210
+ kind: "mutation",
17211
+ auth: "admin"
17212
+ }), method(object({
17213
+ engine: PipelineEngineChoiceSchema,
17214
+ force: boolean().optional()
17215
+ }), object({
17216
+ success: boolean(),
17217
+ reason: string().optional()
17218
+ }), {
17219
+ kind: "mutation",
17220
+ auth: "admin"
17221
+ }), 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({
17222
+ addonId: string(),
17223
+ modelId: string(),
17224
+ filename: string().optional(),
17225
+ settings: record(string(), unknown()).optional()
17226
+ }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
17216
17227
  /**
17217
- * Which detection SOURCE produced an object event. `pipeline` = the ML
17218
- * detection pipeline (decoded-frame inference); `onboard` = the camera's
17219
- * native on-device AI. Both flow through the SAME analysis layers (zoning,
17220
- * tracking, per-kind persistence) but stay distinguishable so consumers
17221
- * (advanced-notifier, occupancy, …) can select which source(s) to act on.
17222
- * Absent on legacy rows treat as `pipeline`.
17228
+ * Per-stage gating mode applied to the zones a rule references.
17229
+ *
17230
+ * - `include`: the rule contributes to a **whitelist** for its stage.
17231
+ * When at least one `include` rule fires for a stage, only entities
17232
+ * inside one of those zones pass that stage.
17233
+ * - `exclude`: the rule contributes to a **blacklist** for its stage.
17234
+ * Entities inside one of those zones are dropped at that stage.
17235
+ *
17236
+ * `monitor`-style observation (count without filtering) is not a rule
17237
+ * mode — zones without any matching rule are observed naturally by
17238
+ * `zone-analytics` (live snapshot + history), so an "I just want to
17239
+ * count, not filter" use case needs no rule at all.
17223
17240
  */
17224
- var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
17241
+ var ZoneRuleModeEnum = _enum(["include", "exclude"]);
17225
17242
  /**
17226
- * The confirmed zone crossing that produced an object event. Present ONLY on
17227
- * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
17228
- * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
17229
- * appearance event carry none, so a rule asking for a direction fails closed
17230
- * on them.
17243
+ * Per-consumer rule that references existing zones (geometry) and
17244
+ * defines how a specific pipeline stage should treat them. Each
17245
+ * consumer addon owns its own `ZoneRule[]` array in its per-device
17246
+ * settings:
17231
17247
  *
17232
- * Exactly ONE crossing per event: the emitter turns each confirmed crossing
17233
- * into its own event, so a frame in which a track enters A while leaving B
17234
- * produces two events with two directions — never one ambiguous row.
17248
+ * - `addon-motion-wasm` `motionZoneRules: ZoneRule[]` (motion stage)
17249
+ * - `addon-detection-pipeline` `detectionZoneRules: ZoneRule[]` (detection stage)
17250
+ * - future: notification rules, audio gating, etc.
17235
17251
  *
17236
- * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
17237
- * membership the box has NOW, and by definition it no longer contains the zone
17238
- * that was just left. Without the id here, a zone-scoped rule could never match
17239
- * the exit it asked for.
17252
+ * One rule applies to N zones (`zoneIds[]`) so the operator can
17253
+ * express "ignore motion in ALL of {garden, street}" with a single
17254
+ * rule. `classFilter` narrows the rule to specific object classes
17255
+ * "drop person detections in the street, but keep cars" is one
17256
+ * `exclude` rule with `classFilter: ['person']`.
17257
+ *
17258
+ * `enabled` is a soft toggle — the operator can keep the rule
17259
+ * configured but inert without deleting it.
17240
17260
  */
17241
- var ZoneCrossingSchema = object({
17242
- direction: _enum(["enter", "exit"]),
17243
- /** Admin zone id crossed. */
17244
- zoneId: string(),
17245
- /** Zone display name at crossing time (falls back to the id). */
17246
- zoneName: string().optional()
17247
- });
17248
- var ObjectEventSchema = object({
17249
- ...BaseEventFields,
17250
- kind: literal("object"),
17251
- /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
17252
- source: DetectionSourceSchema.optional(),
17261
+ var ZoneRuleSchema = object({
17262
+ /** Stable rule id — survives edits, used by the UI for diffing. */
17263
+ id: string(),
17264
+ /** Optional human-readable label rendered in the rule editor. */
17265
+ name: string().optional(),
17266
+ /** Zones this rule targets. The rule's `mode` applies to ALL
17267
+ * listed zones (OR-set: a detection in any one of them counts).
17268
+ * At least one zone id required — a rule with no targets is a
17269
+ * configuration mistake and the form validator rejects it. */
17270
+ zoneIds: array(string()).min(1).readonly(),
17271
+ mode: ZoneRuleModeEnum,
17253
17272
  /**
17254
- * Inference-frame id shared by every object event emitted from the SAME frame
17255
- * the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
17256
- * 2 people + 1 dog) under one full frame, and link a track's frames over time
17257
- * (group by `trackId`, pick a representative `frameId` as the parent frame).
17258
- * Optional for backward-compat with pre-existing rows / the slim projection
17259
- * includes it (it is light). Absent on rows written before this field.
17273
+ * Class names this rule applies to. Empty / undefined rule
17274
+ * applies to every class. Class strings match the `macroClass`
17275
+ * field on detections (e.g. `person`, `car`, `dog`).
17260
17276
  */
17261
- frameId: string().optional(),
17262
- /** Omitted in slim projection. */
17263
- trackId: string().optional(),
17264
- className: string(),
17265
- ...TieredLabelFields,
17266
- /** Omitted in slim projection. */
17267
- confidence: number().optional(),
17268
- /** Heavy JSON — omitted in slim projection. */
17269
- bbox: BoundingBoxSchema.optional(),
17270
- /** Heavy JSON — omitted in slim projection. */
17271
- zones: array(string()).readonly().optional(),
17272
- /** Omitted in slim projection. */
17273
- state: TrackStateSchema.optional(),
17277
+ classFilter: array(string()).readonly().optional(),
17274
17278
  /**
17275
- * The zone crossing this event IS, when it is one. Absent on every other
17276
- * event kind (movement state, appearance, package) see
17277
- * {@link ZoneCrossingSchema}. Omitted in slim projection.
17279
+ * Minimum bbox/mask overlap (0–1) with any of the rule's zones
17280
+ * required to consider an entity "in the zone". Defaults to the
17281
+ * consumer's stage default when omitted. Kept for back-compat with
17282
+ * existing per-rule overrides; new operators pick the value via
17283
+ * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
17284
+ * set, the lower-level engine reads it as a 0–1 fraction.
17278
17285
  */
17279
- zoneCrossing: ZoneCrossingSchema.optional(),
17280
- /** Detection-frame dimensions in pixels — let consumers normalize the
17281
- * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
17282
- frameWidth: number().optional(),
17283
- frameHeight: number().optional(),
17284
- /** MediaStore key for the crop attached to this event (if any). */
17285
- mediaKey: string().optional(),
17286
- /** Design B: MediaStore key of the track's native-resolution key frame (the
17287
- * best-detection full frame). Resolve via the event-media data-plane
17288
- * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
17289
- * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
17290
- * sources — consumers fall back to `mediaKey` (the tight crop). */
17291
- keyFrameMediaKey: string().optional(),
17292
- /** Populated by B5 (recording playback URL for this event). */
17293
- mediaUrl: string().optional(),
17294
- /** The parent track's key-event importance [0,1], propagated to every object
17295
- * event of the track (so an event row can be sorted by importance without a
17296
- * track join). Absent on legacy rows / before the track was scored. */
17297
- importance: number().optional()
17298
- });
17299
- var AudioEventSchema = object({
17300
- ...BaseEventFields,
17301
- kind: literal("audio"),
17302
- rms: number(),
17303
- dbfs: number(),
17304
- classification: object({
17305
- className: string(),
17306
- originalClass: string().optional(),
17307
- score: number()
17308
- }).optional(),
17309
- /** Populated by B5 (recording playback URL for this event). */
17310
- mediaUrl: string().optional()
17311
- });
17312
- var MediaFileKindEnum = _enum([
17313
- "crop",
17314
- "thumbnail",
17315
- "snapshot",
17316
- "firstFrame",
17317
- "lastFrame",
17318
- "fullFrame",
17319
- "fullFrameBoxed",
17320
- "faceCrop",
17321
- "plateCrop",
17322
- "keyFrame",
17323
- "keyFrameSmall",
17324
- "thumbnailSmall"
17325
- ]);
17326
- var MediaFileSchema = object({
17327
- key: string(),
17328
- kind: MediaFileKindEnum,
17329
- base64: string(),
17330
- sizeBytes: number(),
17331
- timestamp: number()
17286
+ overlapThreshold: number().min(0).max(1).optional(),
17287
+ /**
17288
+ * Operator-friendly version of `overlapThreshold` the percentage
17289
+ * of the detection's bbox that must lie inside the zone for the
17290
+ * rule to match. Documented default is 85%; the engine substitutes
17291
+ * that when the field is omitted (kept optional so existing rules
17292
+ * stored without it stay valid).
17293
+ *
17294
+ * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
17295
+ * rule, the engine prefers `bboxInclusionPct` because it's the
17296
+ * field exposed in the UI. Internally both feed the same gate.
17297
+ */
17298
+ bboxInclusionPct: number().min(0).max(100).optional(),
17299
+ /**
17300
+ * When `true` and a detection has a segmentation mask, use the
17301
+ * mask for overlap instead of the bbox. Detection-stage only;
17302
+ * motion rules ignore this field.
17303
+ */
17304
+ preferMask: boolean().optional(),
17305
+ /**
17306
+ * Soft-toggle: `false` disables the rule without deleting it.
17307
+ * Defaults to `true` so operators creating a rule via the UI
17308
+ * see it active immediately.
17309
+ */
17310
+ enabled: boolean().default(true)
17332
17311
  });
17312
+ array(ZoneRuleSchema).readonly();
17333
17313
  /**
17334
- * One media row WITHOUT its bytes.
17314
+ * Zone pure geometry + identity. NO filtering behaviour.
17335
17315
  *
17336
- * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
17337
- * 140 s track), and a client that renders tiles from the media data plane needs
17338
- * to know only WHAT EXISTS the bytes then arrive per tile, lazily, over HTTP
17339
- * with an immutable cache, instead of all at once inside a tRPC response that
17340
- * blocks the whole view.
17316
+ * Zones describe **where** in the frame the operator wants to flag
17317
+ * something; consumer-owned {@link ZoneRule} arrays describe **how**
17318
+ * each pipeline stage uses them. Splitting the two means a single
17319
+ * polygon "Driveway" can simultaneously back a motion-exclude rule,
17320
+ * a detection-include rule on `['car']`, and an occupancy aggregate
17321
+ * — without three duplicated polygons.
17341
17322
  *
17342
- * `sizeBytes` is carried because it is what lets a client decide between the
17343
- * stored blob and a `?variant=thumb` rendering without fetching either.
17323
+ * Owned by the orchestrator addon (provider) and mirrored into the
17324
+ * `zones` device-state slice on every mutation. Consumers
17325
+ * (motion-wasm, pipeline-executor, analytics, admin UI) read either
17326
+ * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
17327
+ * mirror with `onChanged`).
17328
+ *
17329
+ * Coordinates are normalised fractions of the frame (0–1) so zones
17330
+ * survive resolution changes and stream profile switches.
17331
+ *
17332
+ * `kind` discriminates between full polygons (closed regions used
17333
+ * for intrusion / occupancy filters) and tripwires (open 2-point
17334
+ * line segments used for cross events). Onboard / firmware-reported
17335
+ * zones (Reolink, ONVIF) are out of scope for now — see the deferred
17336
+ * task list.
17344
17337
  */
17345
- var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
17338
+ var ZoneKindEnum = _enum(["polygon", "tripwire"]);
17339
+ /** Polygon vertex in fraction-of-frame coordinates (0–1). */
17340
+ var PolygonPointSchema = object({
17341
+ x: number(),
17342
+ y: number()
17343
+ });
17344
+ /** A camera detection zone — pure geometry/identity. */
17345
+ var ZoneSchema = object({
17346
+ id: string(),
17347
+ name: string(),
17348
+ kind: ZoneKindEnum.default("polygon"),
17349
+ /** Polygon vertices, fraction of frame (0–1). */
17350
+ polygon: array(PolygonPointSchema).readonly(),
17351
+ /** Visual color for UI rendering. */
17352
+ color: string().default("#3b82f6")
17353
+ });
17354
+ DeviceType.Camera, method(object({ deviceId: number() }), array(ZoneSchema).readonly()), method(object({
17355
+ deviceId: number(),
17356
+ zone: ZoneSchema
17357
+ }), _void(), {
17358
+ kind: "mutation",
17359
+ auth: "admin"
17360
+ }), method(object({
17361
+ deviceId: number(),
17362
+ zoneId: string()
17363
+ }), _void(), {
17364
+ kind: "mutation",
17365
+ auth: "admin"
17366
+ }), method(object({
17367
+ deviceId: number(),
17368
+ zone: ZoneSchema
17369
+ }), _void(), {
17370
+ kind: "mutation",
17371
+ auth: "admin"
17372
+ }), object({ zones: array(ZoneSchema).readonly() });
17346
17373
  /**
17347
- * The MACRO tier of an annotation — a CLOSED set.
17374
+ * pipeline-analytics device-scoped wrapper cap. Refines raw
17375
+ * per-frame detections emitted by the pipeline runner into tracked
17376
+ * objects, per-kind event collections (motion / object / audio), and
17377
+ * persisted media. Owns the post-detection domain end-to-end:
17348
17378
  *
17349
- * This is what the exported detector predicts, so a typo here is a new class
17350
- * with one example in it. `label` and `subLabel` are open strings by contrast:
17351
- * the whole point of the page is teaching the model things it does not know
17352
- * yet, and constraining that vocabulary would make it useless.
17379
+ * runner emits PipelineInferenceResult
17380
+ * (event bus)
17381
+ * pipeline-analytics subscriber
17382
+ * SORT tracker + zone engine + state analyzer + event emitter
17383
+ * → three DB collections (one per kind), one FS media tree, one
17384
+ * unified event emitter (FrameTracked + TrackStarted/Ended +
17385
+ * DetectionEvent on bus)
17353
17386
  *
17354
- * A macro class is NEVER a label. The provider refuses a write whose `label` or
17355
- * `subLabel` is one of these values, in any casing, because once `person`
17356
- * exists in both tiers "every person box" stops being answerable without
17357
- * knowing every string anyone ever typed — and the damage is retroactive.
17387
+ * Pure subscriber model. No `processFrame` cap method the runner
17388
+ * already publishes the raw frame on the bus. The cap surface is
17389
+ * only QUERIES + per-device settings, bound on/off via
17390
+ * `device-manager.setWrapperActive`. `defaultActive: true` because
17391
+ * every camera with a detection pipeline wants its raw detections
17392
+ * refined; operators opt out per-device via BindingsTab when needed.
17393
+ *
17394
+ * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
17395
+ * (per-device surface) and `track-trail` caps — see P11 cleanup.
17358
17396
  */
17359
- var RetrainMacroClassSchema = _enum([
17397
+ var TrackStateSchema = _enum([
17398
+ "new",
17399
+ "entered",
17400
+ "left",
17401
+ "moving",
17402
+ "idle"
17403
+ ]);
17404
+ var EventKindSchema = _enum([
17405
+ "motion",
17406
+ "object",
17407
+ "audio"
17408
+ ]);
17409
+ /**
17410
+ * Spatial filter for `listTracks` — the rect + polygon variants of the shared
17411
+ * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
17412
+ * of the camera frame (top-left origin), matching the drawing-plane editor.
17413
+ */
17414
+ var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
17415
+ /** Closed icon vocabulary so clients render a known glyph per kind. */
17416
+ var EventKindIconSchema = _enum([
17417
+ "motion",
17418
+ "audio",
17360
17419
  "person",
17361
17420
  "vehicle",
17362
17421
  "animal",
17422
+ "door",
17423
+ "pir",
17424
+ "smoke",
17425
+ "water",
17426
+ "button",
17363
17427
  "package",
17364
- "face",
17365
- "plate"
17428
+ "generic"
17366
17429
  ]);
17367
- /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
17368
- var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
17369
- /** Did a human draw this box, or did the assist propose it? */
17370
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
17371
- /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
17372
- var RetrainBboxSchema = object({
17373
- x: number(),
17374
- y: number(),
17375
- w: number(),
17376
- h: number()
17377
- });
17378
- /**
17379
- * One annotated subject.
17380
- *
17381
- * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
17382
- * (letterboxed root / zone-cropped package / subject-cropped classifier) are
17383
- * derived from it at export and never stored storing them is how one feature
17384
- * space ends up holding two crops of the same subject (D52).
17385
- */
17386
- var RetrainAnnotationSchema = object({
17387
- id: string(),
17388
- trackId: string(),
17389
- deviceId: number(),
17390
- /** The COPY in retrain storage — never the source track's media key. */
17391
- mediaKey: string(),
17392
- bbox: RetrainBboxSchema,
17393
- macroClass: RetrainMacroClassSchema,
17394
- label: string().optional(),
17395
- subLabel: string().optional(),
17396
- kind: RetrainAnnotationKindSchema,
17397
- source: RetrainAnnotationSourceSchema,
17398
- /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
17399
- assistModelId: string().optional(),
17400
- assistScore: number().optional(),
17401
- exportedInBatch: string().optional(),
17402
- createdAt: number()
17403
- });
17404
- /** The write form — the server owns `id`, `createdAt` and the frame binding. */
17405
- var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
17406
- id: true,
17407
- trackId: true,
17408
- deviceId: true,
17409
- mediaKey: true,
17410
- createdAt: true,
17411
- exportedInBatch: true
17430
+ var EventKindCategorySchema = _enum([
17431
+ "motion",
17432
+ "audio",
17433
+ "detection",
17434
+ "sensor",
17435
+ "control",
17436
+ "custom",
17437
+ "package"
17438
+ ]);
17439
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
17440
+ var EventKindLevelSchema = _enum(["macro", "sub"]);
17441
+ var EventKindDescriptorSchema = object({
17442
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
17443
+ kind: string(),
17444
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
17445
+ labelKey: string(),
17446
+ /** English fallback label (kept for clients that don't translate). */
17447
+ label: string(),
17448
+ /** Hex color for timeline/legend rendering. */
17449
+ color: string(),
17450
+ /** Dictionary id → lucide component on the UI side. */
17451
+ iconId: string(),
17452
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
17453
+ icon: EventKindIconSchema,
17454
+ category: EventKindCategorySchema,
17455
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
17456
+ parentKind: string().nullable(),
17457
+ /** Derived from `parentKind`, explicit for the client tree. */
17458
+ level: EventKindLevelSchema,
17459
+ /** Which cap + device contributes this kind. For built-ins the camera
17460
+ * itself; for sensor kinds the LINKED source device. */
17461
+ source: object({
17462
+ capName: string(),
17463
+ deviceId: number()
17464
+ })
17412
17465
  });
17413
- /** A track sitting in `staging`, with everything the worklist needs to rank it. */
17414
- var RetrainTrackSchema = object({
17415
- trackId: string(),
17466
+ /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
17467
+ var EventKindsForDeviceSchema = object({
17416
17468
  deviceId: number(),
17417
- className: string(),
17418
- label: string().optional(),
17419
- firstSeen: number(),
17420
- lastSeen: number(),
17421
- /** How many frames the dataset already holds from this track. */
17422
- frameCount: number().int(),
17423
- /** How many subjects have been annotated on those frames. `0` with
17424
- * `frameCount: 0` is exactly "staging, still to work". */
17425
- annotationCount: number().int()
17426
- });
17427
- /** A frame the picker may offer — an index row, no blob was read to produce it. */
17428
- var RetrainFrameCandidateSchema = object({
17429
- mediaKey: string(),
17430
- kind: MediaFileKindEnum,
17431
- timestamp: number(),
17432
- sizeBytes: number().int(),
17433
- /** A copy of this original already exists — selecting it is free and cannot
17434
- * fail, whatever became of the original. */
17435
- copied: boolean()
17469
+ kinds: array(EventKindDescriptorSchema).readonly()
17436
17470
  });
17437
- /** A frame the dataset OWNS: bytes copied at selection time. */
17438
- var RetrainFrameSchema = object({
17439
- frameId: string(),
17471
+ var SensorEventSchema = object({
17472
+ id: string(),
17473
+ /** The CAMERA the event is attributed to (a sensor linked to N cameras
17474
+ * yields N rows, one per camera). */
17440
17475
  deviceId: number(),
17441
- trackId: string(),
17442
- /** Provenance only. It may already point at nothing — that is expected. */
17443
- sourceMediaKey: string(),
17444
- sourceKind: MediaFileKindEnum,
17445
- sizeBytes: number().int(),
17446
- width: number().int(),
17447
- height: number().int(),
17448
- copiedAt: number()
17476
+ /** The linked sensor device whose state changed. */
17477
+ sourceDeviceId: number(),
17478
+ /** Event kind id — matches an `EventKindDescriptor.kind`. */
17479
+ kind: string(),
17480
+ /** Snapshot of the sensor cap's runtime-state slice at the change. */
17481
+ value: record(string(), unknown()).nullable(),
17482
+ timestamp: number()
17449
17483
  });
17450
- /** Why a copy-on-select could not be honoured — named, never a silent skip. */
17451
- var RetrainCopyRefusalSchema = _enum([
17452
- "source-missing",
17453
- "unreadable-image",
17454
- "write-failed"
17455
- ]);
17456
- var RetrainFrameSelectionSchema = object({
17457
- copied: array(RetrainFrameSchema).readonly(),
17458
- refused: array(object({
17459
- sourceMediaKey: string(),
17460
- reason: RetrainCopyRefusalSchema
17461
- })).readonly()
17484
+ var TrackPositionSchema = object({
17485
+ x: number(),
17486
+ y: number(),
17487
+ timestamp: number(),
17488
+ bbox: BoundingBoxSchema
17462
17489
  });
17463
- var RetrainFrameListSchema = object({
17464
- candidates: array(RetrainFrameCandidateSchema).readonly(),
17465
- copies: array(RetrainFrameSchema).readonly(),
17466
- /** What the page pre-selects the native key frame when one survives. */
17467
- autoPickMediaKey: string().optional()
17490
+ var TrackSnapshotSchema = object({
17491
+ timestamp: number(),
17492
+ position: TrackPositionSchema,
17493
+ /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
17494
+ mediaKey: string()
17468
17495
  });
17469
- /** What the operator asked the assist to look for. */
17470
- var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
17471
- kind: literal("package"),
17472
- zone: RetrainBboxSchema.optional()
17473
- }), object({
17474
- kind: literal("objects"),
17475
- modelId: string(),
17476
- minScore: number().optional()
17477
- })]);
17478
17496
  /**
17479
- * The assist's answer a discriminated union, because "the model saw nothing"
17480
- * and "this node cannot run that model" lead to different next moves and a
17481
- * nullable result cannot tell them apart.
17497
+ * Normalized 0..1 trajectory envelope (min/max over every position bbox,
17498
+ * divided by the track's detection-frame dims), computed at persist time.
17499
+ * Absent when the frame dims were unknown when the track was persisted
17500
+ * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
17482
17501
  */
17483
- var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
17484
- kind: literal("proposed"),
17485
- modelId: string(),
17486
- stepId: string(),
17487
- minScore: number(),
17488
- /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
17489
- proposals: array(RetrainAnnotationDraftSchema).readonly(),
17490
- /** Returned by the runner but removed by the threshold. */
17491
- belowThreshold: number().int()
17492
- }), object({
17493
- kind: literal("refused"),
17494
- /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
17495
- reason: string(),
17496
- detail: string().optional()
17497
- })]);
17498
- /** The outcome of a lifecycle move owned by the retrain page. */
17499
- var RetrainTransitionResultSchema = object({
17500
- trackId: string(),
17501
- /** Where the track ended up, whatever happened. */
17502
- retrainStatus: RetrainStatusSchema,
17503
- /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
17504
- changed: boolean(),
17505
- reason: _enum([
17506
- "unknown-track",
17507
- "no-frames-copied",
17508
- "not-staging",
17509
- "not-trained",
17510
- "unchanged"
17511
- ]).optional()
17512
- });
17513
- var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
17514
- var MAX_EVENT_QUERY_LIMIT = 5e3;
17515
- var DeviceEventQueryInput = object({
17516
- deviceId: number(),
17517
- since: number().optional(),
17518
- until: number().optional(),
17519
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
17520
- /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
17521
- * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
17522
- * exact behaviour. Callers may omit this field — the store defaults to
17523
- * `full` when not provided. */
17524
- projection: _enum(["full", "slim"]).optional()
17525
- });
17526
- var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
17527
- var RecentTracksQueryInput = object({
17528
- /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
17529
- deviceIds: array(number()),
17530
- /** Window lower bound on `lastSeen` (inclusive). */
17531
- since: number().optional(),
17532
- /** Window upper bound on `lastSeen` (inclusive). */
17533
- until: number().optional(),
17534
- /** Page size. Default 200, max 1000. */
17535
- limit: number().int().min(1).max(1e3).default(200),
17536
- /** Opaque continuation cursor from a previous page's `nextCursor`.
17537
- * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
17538
- cursor: string().optional(),
17539
- /** See {@link TrackProjectionSchema}. Default `full`. */
17540
- projection: TrackProjectionSchema.optional(),
17541
- /** Include stationary-promoted rows (parked objects). Default false: the
17542
- * feed lists passages; parking records live on the stationary registry. */
17543
- includeStationary: boolean().optional()
17502
+ var TrackEnvelopeSchema = object({
17503
+ minX: number(),
17504
+ minY: number(),
17505
+ maxX: number(),
17506
+ maxY: number()
17544
17507
  });
17545
- var RecentTracksPageSchema = object({
17546
- /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
17547
- tracks: array(TrackSchema).readonly(),
17548
- /** Cursor for the next page, or null when this page is the last. */
17549
- nextCursor: string().nullable()
17550
- });
17551
- var LIST_GROUPS_DEFAULT_LIMIT = 40;
17552
- var LIST_GROUPS_MAX_LIMIT = 100;
17553
- var AnalyticsGroupRecordSchema = object({
17554
- id: string(),
17555
- deviceId: number().int(),
17556
- openedAt: number().int(),
17557
- closedAt: number().int(),
17558
- timestamp: number().int(),
17559
- memberCount: number().int(),
17560
- memberTrackIds: array(string()).readonly(),
17561
- className: string(),
17562
- classes: array(string()).readonly(),
17563
- /** Relative event-media path, or null when the group has no picture yet. */
17564
- mediaUrl: string().nullable(),
17565
- singleton: boolean()
17566
- });
17567
- var AnalyticsGroupMemberSchema = object({
17568
- trackId: string(),
17569
- deviceId: number().int(),
17570
- className: string(),
17571
- firstSeen: number().int(),
17572
- lastSeen: number().int(),
17573
- mediaUrl: string().nullable()
17574
- });
17575
- var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
17576
- var ListGroupsQueryInput = object({
17577
- /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
17578
- deviceIds: array(number()),
17579
- /** Window lower bound on `closedAt` (inclusive). */
17580
- since: number().optional(),
17581
- /** Window upper bound on `openedAt` (inclusive). */
17582
- until: number().optional(),
17583
- limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
17584
- /** Opaque continuation cursor from a previous page's `nextCursor`. */
17585
- cursor: string().optional()
17586
- });
17587
- var ListGroupsPageSchema = object({
17588
- groups: array(AnalyticsGroupRecordSchema).readonly(),
17589
- nextCursor: string().nullable()
17590
- });
17591
- var KeyEventQueryInput = object({
17592
- deviceId: number(),
17593
- /** Window lower bound (track firstSeen ≥ since). */
17594
- since: number(),
17595
- /** Window upper bound (track firstSeen ≤ until). */
17596
- until: number(),
17597
- limit: number().int().min(1).max(200).default(50),
17598
- /** Drop tracks scoring below this importance. */
17599
- minImportance: number().min(0).max(1).optional(),
17600
- /** Restrict to a single class (e.g. 'person'). */
17601
- classFilter: string().optional()
17602
- });
17603
- var KeyEventSchema = object({
17604
- /** The representative event id (the track's best ObjectEvent, else its trackId). */
17605
- id: string(),
17606
- trackId: string(),
17607
- /** Track start time (firstSeen). */
17608
- timestamp: number(),
17609
- className: string(),
17610
- ...TieredLabelFields,
17611
- importance: number(),
17612
- /** Highest-confidence ObjectEvent id for the track (empty when none). */
17613
- bestEventId: string(),
17614
- /** Track lifetime in ms (lastSeen - firstSeen). */
17615
- windowMs: number().optional(),
17616
- ...TrackFlagFields,
17617
- ...TrackRetrainFields
17618
- });
17619
- object({
17620
- trackId: string(),
17621
- className: string(),
17622
- confidence: number(),
17623
- bbox: BoundingBoxSchema,
17624
- zones: array(string()).readonly(),
17625
- state: TrackStateSchema
17626
- });
17627
- var OverlayDetectionSchema = looseObject({
17628
- id: string(),
17629
- kind: _enum(["first-level", "detail"]),
17630
- macroClass: string(),
17631
- score: number(),
17632
- bbox: object({
17633
- x: number(),
17634
- y: number(),
17635
- width: number(),
17636
- height: number()
17637
- }),
17638
- labels: array(looseObject({
17639
- label: string(),
17640
- score: number()
17641
- })).readonly(),
17642
- parentId: string().optional()
17643
- });
17644
- var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
17645
- var SearchObjectEventsInput = object({
17646
- text: string(),
17647
- deviceId: number().optional(),
17648
- since: number().optional(),
17649
- until: number().optional(),
17650
- classFilter: string().optional(),
17651
- limit: number().default(50),
17652
- minScore: number().min(0).max(1).default(.2)
17653
- });
17654
- var TrackCascadeCountsSchema = object({
17655
- /** Persisted track roots deleted (authoritative). */
17656
- tracks: number().int(),
17657
- /** Object events removed with their tracks (best-effort; see note above). */
17658
- events: number().int(),
17659
- /** Track/face/plate-owned media removed (best-effort). Never identity media. */
17660
- media: number().int(),
17661
- /** Unassigned (non-enrolled) face reads removed (best-effort). */
17662
- faces: number().int(),
17663
- /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
17664
- plates: number().int(),
17665
- /** Per-track CLIP search vectors removed (best-effort). */
17666
- embeddings: number().int(),
17667
- /** Group membership + group rows removed with their last member (best-effort). */
17668
- groups: number().int()
17669
- });
17670
- /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
17671
- var DiskReconcileCountsSchema = object({
17672
- mediaDropped: number().int(),
17673
- tracks: number().int(),
17674
- events: number().int()
17675
- });
17676
- /** Event-store footprint for one camera. */
17677
- var EventStoreDeviceFootprintSchema = object({
17678
- deviceId: number(),
17679
- /** Persisted event rows (motion + object + audio) for the camera. */
17680
- rows: number().int(),
17681
- /** Event-owned media bytes on disk for the camera. */
17682
- bytes: number().int()
17683
- });
17684
- /** Aggregate event-store footprint: global totals + per-camera breakdown. */
17685
- var EventStoreFootprintSchema = object({
17686
- totalRows: number().int(),
17687
- totalBytes: number().int(),
17688
- devices: array(EventStoreDeviceFootprintSchema).readonly()
17689
- });
17690
- /** Per-kind counts returned by the event-prune / device-delete mutations. */
17691
- var EventPruneCountsSchema = object({
17692
- motion: number().int(),
17693
- object: number().int(),
17694
- audio: number().int()
17508
+ /**
17509
+ * Row projection for track list queries. `full` (default) returns the
17510
+ * complete Track including the frame-rate `positions[]` history and the
17511
+ * `snapshots[]` references megabytes across a page of tracks. `slim`
17512
+ * keeps every scalar the list surfaces actually render (ids, class(es),
17513
+ * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
17514
+ * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
17515
+ * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
17516
+ * `getTrack`. Mirrors the event-store `projection` convention
17517
+ * (`getObjectEvents` et al.).
17518
+ */
17519
+ var TrackProjectionSchema = _enum(["full", "slim"]);
17520
+ /**
17521
+ * One audio-classification label heard on the track's camera while the
17522
+ * track was alive, aggregated per label. An "episode" is one persisted
17523
+ * audio event (the confident-classification path: score ≥ the device's
17524
+ * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
17525
+ * one 32 ms inference chunk, so counts stay human-scaled.
17526
+ */
17527
+ var TrackAudioLabelSchema = object({
17528
+ label: string(),
17529
+ /** Highest classification score observed across the label's episodes. */
17530
+ peakScore: number(),
17531
+ /** Number of coalesced audio-event episodes carrying this label. */
17532
+ count: number(),
17533
+ firstAt: number(),
17534
+ lastAt: number()
17695
17535
  });
17696
17536
  /**
17697
- * Re-embed stored tracks from their key frames.
17537
+ * How a track was produced. `pipeline` (default / absent) = the spatial
17538
+ * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
17539
+ * no positions, a single snapshot, and no bbox trajectory at all:
17698
17540
  *
17699
- * The reason this is an operator-callable method and not a migration script:
17700
- * every knob that decides what a vector MEANS encoder model, crop margin,
17701
- * squaring is only changeable if the existing vectors can be regenerated.
17702
- * Mixing feature spaces in one index makes cosine scores incomparable, and the
17703
- * symptom is a quality regression with no visible cause.
17541
+ * - `sensor` a linked sensor/control device state change.
17542
+ * - `audio` an audio event on the camera itself that was anomalous for
17543
+ * THAT camera, loud, and heard while nothing visual was happening (D62).
17544
+ *
17545
+ * The spatial subsystems (tracker association, occupancy count, re-id /
17546
+ * embedding, resurrection) MUST skip every synthetic source. Test for that
17547
+ * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
17548
+ * check silently readmits every source added after it was written.
17704
17549
  */
17705
- var RebuildObjectEmbeddingsInput = object({
17706
- /** Restrict to one camera. Omit for the whole fleet. */
17707
- deviceId: number().optional(),
17708
- since: number().optional(),
17709
- until: number().optional(),
17710
- /** Stop after this many tracks; the result reports whether more remain. */
17711
- maxTracks: number().int().positive().optional(),
17712
- /**
17713
- * Run every embedding on THIS node instead of round-robining the fleet.
17714
- *
17715
- * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
17716
- * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
17717
- * calling it that would pin the rebuild REQUEST itself to that node — the
17718
- * rebuild orchestration lives on the hub, and only the per-track step runs
17719
- * remotely. This field is data; the per-track pin is applied inside.
17720
- *
17721
- * Absent ⇒ round-robin over every online node whose runner can serve the
17722
- * pinned model.
17723
- */
17724
- executeOnNodeId: string().optional(),
17725
- /**
17726
- * Milliseconds to wait between tracks; omit for the built-in default, `0` to
17727
- * run flat out.
17728
- *
17729
- * A rebuild is bulk maintenance on hub-main's single thread. Measured
17730
- * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
17731
- * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
17732
- * force is logged at start and finish so a deliberately slow pass reads
17733
- * differently from a stalled one.
17734
- */
17735
- pacingMs: number().int().nonnegative().optional()
17736
- });
17550
+ var TrackSourceSchema = _enum([
17551
+ "pipeline",
17552
+ "sensor",
17553
+ "audio"
17554
+ ]);
17737
17555
  /**
17738
- * Result of emptying the CLIP index.
17556
+ * Where a track sits in the RETRAIN lifecycle (D81).
17739
17557
  *
17740
- * The clean slate before a policy change: a new crop margin or encoder model
17741
- * leaves two feature spaces in one index whose cosine scores are not
17742
- * comparable, so wiping and rebuilding is the only way to be sure every vector
17743
- * means the same thing.
17558
+ * - `none` never marked, or un-marked. Evictable.
17559
+ * - `staging` the operator wants this track as training material and has not
17560
+ * finished with it. **This is the only state retention holds**: the track and
17561
+ * everything it owns (object events, crops, keyframes, CLIP vector) survive
17562
+ * the device's age window.
17563
+ * - `trained` — the retrain page has taken what it needed. The frames it chose
17564
+ * were COPIED into the retrain dataset at selection time, so the dataset no
17565
+ * longer depends on the track's media and the track becomes EVICTABLE again.
17566
+ * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
17567
+ * a deliberate action of the retrain page, not a side effect of a checkbox.
17568
+ *
17569
+ * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
17570
+ * the store's filter language has only positive equality and `whereIn` — no
17571
+ * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
17572
+ * would make the entire pre-column history immortal in one deploy.
17744
17573
  */
17745
- var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
17574
+ var RetrainStatusSchema = _enum([
17575
+ "none",
17576
+ "staging",
17577
+ "trained"
17578
+ ]);
17746
17579
  /**
17747
- * Acknowledgement that a rebuild STARTED.
17580
+ * Per-track OPERATOR flags set by hand from the admin UI or the viewer, never
17581
+ * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
17582
+ * so the two surfaces cannot drift.
17748
17583
  *
17749
- * The pass costs ~1s per track 45 minutes for a 2,600-track fleet so it
17750
- * runs detached and this returns immediately. Waiting for it made the client
17751
- * time out while the work carried on server-side, which is the worst of both:
17752
- * no result and no way to know it was still going. Poll
17753
- * `getObjectEmbeddingRebuildStatus` for progress.
17584
+ * **Absent false.** A track that has never been touched omits the field; an
17585
+ * explicitly un-flagged track carries `false`. Legacy rows written before the
17586
+ * columns existed read as absent, and a consumer that needs a boolean should say
17587
+ * `flag === true`, not `flag !== false`.
17588
+ *
17589
+ * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
17590
+ * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
17591
+ * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
17592
+ * `trained` track reports `false` while refusing both writes. The boolean is
17593
+ * kept because three surfaces drive a toggle off it; anything that needs to tell
17594
+ * "never marked" from "already trained" must read `retrainStatus`.
17595
+ *
17596
+ * `debug` does NOT pin; it is attention, not durability.
17597
+ *
17598
+ * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
17599
+ * A favourited track is skipped by retention the same way `staging` is, but
17600
+ * it does not enter `none|staging|trained` and has no staging budget.
17754
17601
  */
17755
- var RebuildObjectEmbeddingsResultSchema = object({
17756
- started: boolean(),
17757
- /** True when a pass was already running; the new request is ignored. */
17758
- alreadyRunning: boolean()
17759
- });
17760
- var RebuildStatusSchema = object({
17761
- running: boolean(),
17762
- scanned: number(),
17763
- rebuilt: number(),
17764
- /** Tracks whose key frame is gone — nothing to re-embed from. */
17765
- missingKeyFrame: number(),
17766
- /** Tracks with no usable detection box. */
17767
- missingBbox: number(),
17768
- /**
17769
- * Tracks an executing node REFUSED rather than broke on an unreadable key
17770
- * frame, a step that threw. Separate from `failed` because the remedy is
17771
- * different, and because a whole camera silently contributing zero vectors
17772
- * is the shape of failure a rebuild must never hide.
17773
- */
17774
- notRunnable: number(),
17602
+ var TrackFlagFields = {
17603
+ /** Operator marked this track as training material — i.e. `retrainStatus` is
17604
+ * `'staging'`. */
17605
+ markForTrain: boolean().optional(),
17606
+ /** Operator marked this track for diagnostic attention. */
17607
+ debug: boolean().optional(),
17608
+ /** Operator favourited this track. Pins it against pruning. */
17609
+ favourited: boolean().optional()
17610
+ };
17611
+ /**
17612
+ * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
17613
+ * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
17614
+ * write patch, and the status is not something the toggle sets — it is what the
17615
+ * toggle's boolean is derived from. Absent on an in-RAM track never touched;
17616
+ * always present on a persisted row (the column default materialises `'none'`).
17617
+ */
17618
+ var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
17619
+ /**
17620
+ * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
17621
+ * one flag can never clear the other — the toggles are independent and are
17622
+ * driven from three surfaces that do not know about each other.
17623
+ */
17624
+ var TrackFlagsPatchSchema = object(TrackFlagFields);
17625
+ /**
17626
+ * The resolved flag state after a write. Both fields are REQUIRED here (absent
17627
+ * collapses to `false`) so a caller can drive a toggle's checked state off the
17628
+ * mutation result without a re-fetch.
17629
+ */
17630
+ var TrackFlagsSchema = object({
17631
+ trackId: string(),
17632
+ markForTrain: boolean(),
17633
+ debug: boolean(),
17634
+ favourited: boolean(),
17635
+ /** The lifecycle state the boolean was derived from. Required here (unlike on
17636
+ * a track row) because this shape is only ever produced by the write body,
17637
+ * which always knows it — and a surface that has just written needs to render
17638
+ * `trained` without a re-fetch. */
17639
+ retrainStatus: RetrainStatusSchema
17640
+ });
17641
+ union([literal(1), literal(2)]);
17642
+ /**
17643
+ * WHO decided a label, and when. Carried per tier so a value can be traced to
17644
+ * the step and model that produced it — which is what makes the write rule
17645
+ * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
17646
+ * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
17647
+ *
17648
+ * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
17649
+ * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
17650
+ * `migration:4g` for a value the 4g migration moved from the single-slot era —
17651
+ * that value has no provenance, and the write rule lets ANY properly-attributed
17652
+ * write of the same tier replace it regardless of score.
17653
+ */
17654
+ var LabelAttributionSchema = object({
17655
+ stepId: string(),
17656
+ modelId: string().optional(),
17657
+ decidedAt: number(),
17775
17658
  /**
17776
- * The pass stopped because NO node could serve the pinned model.
17659
+ * The GALLERY id behind a recognised tier-2 label a face-gallery
17660
+ * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
17777
17661
  *
17778
- * Distinct from `notRunnable` on purpose: that one says "this track was
17779
- * refused", this one says "the cluster cannot do this work at all" — every
17780
- * candidate node either lacks the `clip-embedding` step, lacks a build of the
17781
- * pinned model for its engine format, or dropped out. The remedy is a model /
17782
- * engine change, not a per-camera one. Non-zero here always comes with
17783
- * `complete: false`.
17662
+ * The text alone is a DISPLAY NAME, and a display name is renameable: a
17663
+ * notification rule authored on "Gianluca" stopped matching the moment the
17664
+ * operator fixed the spelling in the gallery, and nothing said so. The id is
17665
+ * the thing that does not move, so it is what a rule matches on
17666
+ * (`NcConditions.identities`) and the text is what a human is shown.
17667
+ *
17668
+ * Absent when the label names no gallery row — a plate the OCR read but no
17669
+ * vehicle claims, a sub-class, a species, any tier-1 value.
17784
17670
  */
17785
- noCapableNode: number(),
17786
- failed: number(),
17787
- /** Set once a pass ends: true only when EVERYTHING was covered. */
17788
- complete: boolean().nullable(),
17789
- startedAtMs: number().nullable(),
17790
- finishedAtMs: number().nullable(),
17791
- /** Present when the pass ended by throwing. */
17792
- error: string().nullable()
17671
+ identityId: string().optional()
17793
17672
  });
17794
- DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
17795
- deviceId: number(),
17796
- trackId: string()
17797
- }), TrackSchema.nullable()), method(object({
17798
- deviceId: number(),
17799
- since: number().optional(),
17800
- until: number().optional(),
17801
- limit: number().optional(),
17802
- /** Spatial filter — only tracks whose trajectory intersects the zone
17803
- * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
17804
- * envelope columns, then precisely tested per position. Tracks with
17805
- * an unknown envelope (no frame dims at persist time) always match. */
17806
- zone: TrackZoneFilterSchema.optional(),
17807
- /** See {@link TrackProjectionSchema}. Default `full` (backward
17808
- * compatible omitting the field keeps today's exact behaviour). */
17809
- projection: TrackProjectionSchema.optional(),
17810
- /** Include stationary-promoted rows (parked objects handed to the
17811
- * stationary registry). Default false: the timeline lists passages,
17812
- * not parking records (operator decision, 2026-08-15). */
17813
- includeStationary: boolean().optional()
17814
- }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
17815
- deviceId: number(),
17816
- groupId: string().min(1)
17817
- }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
17818
- kind: "mutation",
17819
- auth: "admin"
17820
- }), 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({
17821
- deviceId: number(),
17822
- since: number().optional(),
17823
- until: number().optional(),
17824
- kinds: array(string()).optional(),
17825
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
17826
- }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
17827
- deviceId: number(),
17828
- since: number(),
17829
- until: number(),
17830
- bucketMs: number().int().positive()
17831
- }), array(object({
17832
- bucketStart: number(),
17833
- motion: number().int(),
17834
- object: number().int(),
17835
- audio: number().int()
17836
- })).readonly()), method(object({
17837
- deviceId: number(),
17838
- cutoffMs: number()
17839
- }), object({
17840
- motion: number().int(),
17841
- object: number().int(),
17842
- audio: number().int()
17843
- }), {
17844
- kind: "mutation",
17845
- auth: "admin"
17846
- }), method(object({
17847
- deviceId: number(),
17848
- cutoffMs: number()
17849
- }), TrackCascadeCountsSchema, {
17850
- kind: "mutation",
17851
- auth: "admin"
17852
- }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
17853
- kind: "mutation",
17854
- auth: "admin"
17855
- }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
17856
- kind: "mutation",
17857
- auth: "admin"
17858
- }), method(object({
17859
- deviceId: number(),
17860
- trackIds: array(string()).min(1)
17861
- }), object({
17862
- deleted: number().int(),
17863
- failed: array(string()).readonly()
17864
- }), {
17865
- kind: "mutation",
17866
- auth: "admin"
17867
- }), method(object({
17868
- /** Log/audit scope only — the trackId is globally unique on its own. */
17673
+ /**
17674
+ * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
17675
+ * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
17676
+ * track and its events always answer the same question the same way.
17677
+ *
17678
+ * Two scalar columns, not an array: every consumer wants "the coarse one" or
17679
+ * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
17680
+ * is tier 2, and each carries its own score + attribution.
17681
+ *
17682
+ * **Reading it.** What a human should be shown is `subLabel ?? label` — the
17683
+ * finest thing known. Before 4g the single `label` column held the finest
17684
+ * value, so a consumer that has not been updated reads the tier-1 slot and
17685
+ * shows nothing on a species-only row; that is why the migration puts every
17686
+ * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
17687
+ * and why the read surfaces were changed in the same train.
17688
+ *
17689
+ * **Writing it.** The slots are independent, which is the whole point: a
17690
+ * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
17691
+ * migratorius`), so fineness cannot regress by construction. Within a tier the
17692
+ * higher score wins. One rule, one implementation — see
17693
+ * `pipeline/label-tier.ts` in addon-post-analysis.
17694
+ */
17695
+ var TieredLabelFields = {
17696
+ /** Tier 1 the sub-class. See {@link LabelTierSchema}. */
17697
+ label: string().optional(),
17698
+ /** Confidence of the tier-1 value, as reported by the deciding step. */
17699
+ labelScore: number().optional(),
17700
+ /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
17701
+ labelMeta: LabelAttributionSchema.optional(),
17702
+ /** Tier 2 — the instance. See {@link LabelTierSchema}. */
17703
+ subLabel: string().optional(),
17704
+ /** Confidence of the tier-2 value, as reported by the deciding step. */
17705
+ subLabelScore: number().optional(),
17706
+ /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
17707
+ subLabelMeta: LabelAttributionSchema.optional()
17708
+ };
17709
+ /** Per-camera slice of a training-export estimate. */
17710
+ var TrainingExportDeviceTotalsSchema = object({
17869
17711
  deviceId: number(),
17712
+ tracks: number().int(),
17713
+ files: number().int(),
17714
+ bytes: number().int()
17715
+ });
17716
+ /**
17717
+ * What a training export WOULD contain. Computed from media index rows only —
17718
+ * no blob is read to produce this.
17719
+ */
17720
+ var TrainingExportSummarySchema = object({
17721
+ generatedAt: number(),
17722
+ trackCount: number().int(),
17723
+ fileCount: number().int(),
17724
+ byteCount: number().int(),
17725
+ /** More marked tracks exist than a single pass carries. */
17726
+ truncated: boolean(),
17727
+ devices: array(TrainingExportDeviceTotalsSchema).readonly()
17728
+ });
17729
+ var TrackSchema = object({
17870
17730
  trackId: string(),
17871
- flags: TrackFlagsPatchSchema
17872
- }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
17873
- kind: "query",
17874
- auth: "admin"
17875
- }), method(object({
17876
- olderThanMs: number(),
17877
- reason: OpsLogReasonSchema.optional()
17878
- }), EventPruneCountsSchema, {
17879
- kind: "mutation",
17880
- auth: "admin"
17881
- }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
17882
- kind: "mutation",
17883
- auth: "admin"
17884
- }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
17885
- kind: "mutation",
17886
- auth: "admin"
17887
- }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
17888
- kind: "mutation",
17889
- auth: "admin"
17890
- }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
17891
- kind: "mutation",
17892
- auth: "admin"
17893
- }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
17894
- kind: "mutation",
17895
- auth: "admin"
17896
- }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
17897
- kind: "mutation",
17898
- auth: "admin"
17899
- }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
17900
- kind: "query",
17901
- auth: "admin"
17902
- }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
17903
- kind: "query",
17904
- auth: "admin"
17905
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
17906
- kind: "query",
17907
- auth: "admin"
17908
- }), method(object({
17909
- /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
17910
- * `deviceId`, deliberately: `deviceId` would make this device-bound and
17911
- * route it at one camera's owner, and "every camera" would stop being
17912
- * expressible at all. */
17913
- deviceIds: array(number()).optional(),
17914
- limit: number().int().min(1).max(500).optional()
17915
- }), array(RetrainTrackSchema).readonly(), {
17916
- kind: "query",
17917
- auth: "admin"
17918
- }), method(object({ trackId: string() }), RetrainFrameListSchema, {
17919
- kind: "query",
17920
- auth: "admin"
17921
- }), method(object({
17922
17731
  deviceId: number(),
17923
- trackId: string(),
17924
- mediaKeys: array(string()).min(1)
17925
- }), RetrainFrameSelectionSchema, {
17926
- kind: "mutation",
17927
- auth: "admin"
17928
- }), method(object({
17732
+ className: string(),
17733
+ ...TieredLabelFields,
17734
+ producingDeviceName: string().optional(),
17735
+ /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
17736
+ source: TrackSourceSchema.optional(),
17737
+ firstSeen: number(),
17738
+ lastSeen: number(),
17739
+ /** Frame-rate position history (subject to maxPositionHistory cap). */
17740
+ positions: array(TrackPositionSchema).readonly(),
17741
+ /** Periodic snapshots at snapshotIntervalMs cadence (subject to
17742
+ * saveThumbnails policy). */
17743
+ snapshots: array(TrackSnapshotSchema).readonly(),
17744
+ /** Deduplicated zones the track has entered at least once. Zone IDS. */
17745
+ zonesVisited: array(string()).readonly(),
17746
+ /**
17747
+ * Human NAMES for {@link zonesVisited}, resolved at READ time against the
17748
+ * `zones` capability.
17749
+ *
17750
+ * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
17751
+ * and no card can render — so every free-text search surface was structurally
17752
+ * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
17753
+ * just returned nothing. Resolving here rather than in each client keeps ONE
17754
+ * derivation and costs the clients no extra call (the `zones` cap is
17755
+ * per-device, so a client-side resolve would be a per-camera fan-out on a
17756
+ * surface built to avoid exactly that).
17757
+ *
17758
+ * Resolved, never invented: a zone deleted since the track was written has no
17759
+ * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
17760
+ * two are not positionally aligned. Absent when the track visited no zone, or
17761
+ * when the zone catalogue could not be read.
17762
+ */
17763
+ zoneNames: array(string()).readonly().optional(),
17764
+ /** Deduplicated set of detector classes observed for this track over its
17765
+ * life (a track may be reclassified, e.g. person→vehicle). Absent on
17766
+ * legacy rows written before class accumulation shipped. */
17767
+ classes: array(string()).readonly().optional(),
17768
+ /** Cumulative normalized distance travelled (0..1 units = full frame width). */
17769
+ totalDistance: number(),
17770
+ state: TrackStateSchema,
17771
+ active: boolean(),
17772
+ /** Deterministic key-event importance score in [0,1] (server-computed at
17773
+ * track expiry, recomputed on late label). Absent on legacy rows written
17774
+ * before scoring shipped — consumers degrade to absence / compute-on-read. */
17775
+ importance: number().optional(),
17776
+ /** Id of the track's highest-confidence ObjectEvent (its representative
17777
+ * "best" frame). Absent when the track produced no object events. */
17778
+ bestEventId: string().optional(),
17779
+ /** Tag of the importance sub-signal that dominated the score
17780
+ * (identity|dwell|proximity|class|confidence|travel|zone). */
17781
+ importanceReason: string().optional(),
17782
+ /** Audio-classification labels heard on the camera during the track's
17783
+ * life (score ≥ device `classificationMinScore`), aggregated per label.
17784
+ * Absent on legacy rows / tracks with no confident audio. */
17785
+ audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
17786
+ /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
17787
+ * Populated from the persisted envelope columns on historical reads;
17788
+ * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
17789
+ envelope: TrackEnvelopeSchema.optional(),
17790
+ /**
17791
+ * A face DETECTOR found a face on this track — nothing more. It says the
17792
+ * detail plane produced a `face` detail; it does NOT say the face was
17793
+ * embedded, matched, above `minFacePx`, or that the recognizer was even
17794
+ * enabled. Set once and never cleared.
17795
+ *
17796
+ * **This exists so "face present but not recognised" is expressible.** A
17797
+ * recognised identity lands in `subLabel` (attributed to the face chain via
17798
+ * `subLabelMeta.stepId`), so before this field a track with an unmatched face
17799
+ * and a track with no face at all were byte-identical on the wire and no
17800
+ * surface could tell them apart. The read is `hasFace === true && subLabel
17801
+ * === undefined`.
17802
+ *
17803
+ * **Absent ≠ false.** Every row written before the column existed omits it,
17804
+ * and so does every server that predates the field — a consumer must test
17805
+ * `=== true` and render nothing otherwise, never infer "no face".
17806
+ */
17807
+ hasFace: boolean().optional(),
17808
+ /**
17809
+ * This track has a face row IN THE GALLERY: a crop **and** an embedding — a
17810
+ * face an operator could ASSIGN to an identity.
17811
+ *
17812
+ * The STRICT twin of {@link hasFace}, and the pair only earns its keep
17813
+ * because the two disagree. `hasFace` is stamped at the TOP of the face
17814
+ * branch, before every gate, and means no more than "a face detector produced
17815
+ * a face detail". This one is stamped at the single moment the gallery row
17816
+ * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
17817
+ * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
17818
+ * candidate gate, the imageless-track drop (no crop was ever captured) and
17819
+ * the crop-store drop. Everything between the detector and that insert can
17820
+ * legitimately refuse the face, so a flag written any earlier promises the
17821
+ * operator something to assign and delivers nothing.
17822
+ *
17823
+ * **Independent of recognition.** A face collected but never auto-matched is
17824
+ * still assignable — it is in fact the face an operator most wants to reach —
17825
+ * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
17826
+ * `subLabel`; this says only that the raw material exists.
17827
+ *
17828
+ * **Set once, never cleared.** A track that produced a gallery row produced
17829
+ * one; deleting the row later is the gallery's business, not this flag's.
17830
+ *
17831
+ * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
17832
+ * before the column omits it, and so does every server that predates the
17833
+ * field. A consumer must test `=== true` and render nothing otherwise —
17834
+ * never infer "no assignable face".
17835
+ */
17836
+ hasEmbeddedFace: boolean().optional(),
17837
+ /**
17838
+ * This subject CONTAINS a folded rider — a person the rider-pairing step
17839
+ * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
17840
+ * so the passage is tracked once and as a VEHICLE.
17841
+ *
17842
+ * It exists because the fold's record was dishonest. D34 and the code both
17843
+ * said "the person is not lost — it is reported so both entities stay on the
17844
+ * record"; in fact the pair went into a per-processor RAM field behind an
17845
+ * accessor nobody called, and every durable surface said `vehicle`, full
17846
+ * stop. This is the composition note that makes the row true.
17847
+ *
17848
+ * A COMPOSITION, never a class and never a label. "This vehicle contains a
17849
+ * person" is not an answer to "what is this" — both label tiers would refuse
17850
+ * a macro token anyway (D89), and correctly. Nothing here changes what the
17851
+ * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
17852
+ * and a `person` rule still does not fire for someone cycling past.
17853
+ *
17854
+ * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
17855
+ * the column, and every hub that predates the field, omits it. Test
17856
+ * `=== true` and render nothing otherwise — never infer "no rider".
17857
+ */
17858
+ hasRider: boolean().optional(),
17859
+ ...TrackFlagFields,
17860
+ ...TrackRetrainFields
17861
+ });
17862
+ var BaseEventFields = {
17863
+ id: string(),
17929
17864
  deviceId: number(),
17930
- trackId: string(),
17931
- frameId: string()
17932
- }), object({
17933
- removed: boolean(),
17934
- removedAnnotations: number().int()
17935
- }), {
17936
- kind: "mutation",
17937
- auth: "admin"
17938
- }), method(object({ frameId: string() }), object({
17865
+ timestamp: number()
17866
+ };
17867
+ var MotionEventSchema = object({
17868
+ ...BaseEventFields,
17869
+ kind: literal("motion"),
17870
+ regionCount: number(),
17871
+ /** Heavy JSON array — omitted in slim projection. */
17872
+ regions: array(object({
17873
+ bbox: BoundingBoxSchema,
17874
+ pixelCount: number(),
17875
+ intensity: number()
17876
+ })).readonly().optional(),
17877
+ /** Omitted in slim projection. */
17878
+ frameWidth: number().optional(),
17879
+ /** Omitted in slim projection. */
17880
+ frameHeight: number().optional(),
17881
+ /** Populated by B5 (recording playback URL for this event). */
17882
+ mediaUrl: string().optional()
17883
+ });
17884
+ /**
17885
+ * Which detection SOURCE produced an object event. `pipeline` = the ML
17886
+ * detection pipeline (decoded-frame inference); `onboard` = the camera's
17887
+ * native on-device AI. Both flow through the SAME analysis layers (zoning,
17888
+ * tracking, per-kind persistence) but stay distinguishable so consumers
17889
+ * (advanced-notifier, occupancy, …) can select which source(s) to act on.
17890
+ * Absent on legacy rows ⇒ treat as `pipeline`.
17891
+ */
17892
+ var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
17893
+ /**
17894
+ * The confirmed zone crossing that produced an object event. Present ONLY on
17895
+ * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
17896
+ * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
17897
+ * appearance event carry none, so a rule asking for a direction fails closed
17898
+ * on them.
17899
+ *
17900
+ * Exactly ONE crossing per event: the emitter turns each confirmed crossing
17901
+ * into its own event, so a frame in which a track enters A while leaving B
17902
+ * produces two events with two directions — never one ambiguous row.
17903
+ *
17904
+ * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
17905
+ * membership the box has NOW, and by definition it no longer contains the zone
17906
+ * that was just left. Without the id here, a zone-scoped rule could never match
17907
+ * the exit it asked for.
17908
+ */
17909
+ var ZoneCrossingSchema = object({
17910
+ direction: _enum(["enter", "exit"]),
17911
+ /** Admin zone id crossed. */
17912
+ zoneId: string(),
17913
+ /** Zone display name at crossing time (falls back to the id). */
17914
+ zoneName: string().optional()
17915
+ });
17916
+ var ObjectEventSchema = object({
17917
+ ...BaseEventFields,
17918
+ kind: literal("object"),
17919
+ /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
17920
+ source: DetectionSourceSchema.optional(),
17921
+ /**
17922
+ * Inference-frame id shared by every object event emitted from the SAME frame
17923
+ * — the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
17924
+ * 2 people + 1 dog) under one full frame, and link a track's frames over time
17925
+ * (group by `trackId`, pick a representative `frameId` as the parent frame).
17926
+ * Optional for backward-compat with pre-existing rows / the slim projection
17927
+ * includes it (it is light). Absent on rows written before this field.
17928
+ */
17929
+ frameId: string().optional(),
17930
+ /** Omitted in slim projection. */
17931
+ trackId: string().optional(),
17932
+ className: string(),
17933
+ ...TieredLabelFields,
17934
+ /** Omitted in slim projection. */
17935
+ confidence: number().optional(),
17936
+ /** Heavy JSON — omitted in slim projection. */
17937
+ bbox: BoundingBoxSchema.optional(),
17938
+ /** Heavy JSON — omitted in slim projection. */
17939
+ zones: array(string()).readonly().optional(),
17940
+ /** Omitted in slim projection. */
17941
+ state: TrackStateSchema.optional(),
17942
+ /**
17943
+ * The zone crossing this event IS, when it is one. Absent on every other
17944
+ * event kind (movement state, appearance, package) — see
17945
+ * {@link ZoneCrossingSchema}. Omitted in slim projection.
17946
+ */
17947
+ zoneCrossing: ZoneCrossingSchema.optional(),
17948
+ /** Detection-frame dimensions in pixels — let consumers normalize the
17949
+ * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
17950
+ frameWidth: number().optional(),
17951
+ frameHeight: number().optional(),
17952
+ /** MediaStore key for the crop attached to this event (if any). */
17953
+ mediaKey: string().optional(),
17954
+ /** Design B: MediaStore key of the track's native-resolution key frame (the
17955
+ * best-detection full frame). Resolve via the event-media data-plane
17956
+ * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
17957
+ * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
17958
+ * sources — consumers fall back to `mediaKey` (the tight crop). */
17959
+ keyFrameMediaKey: string().optional(),
17960
+ /** Populated by B5 (recording playback URL for this event). */
17961
+ mediaUrl: string().optional(),
17962
+ /** The parent track's key-event importance [0,1], propagated to every object
17963
+ * event of the track (so an event row can be sorted by importance without a
17964
+ * track join). Absent on legacy rows / before the track was scored. */
17965
+ importance: number().optional()
17966
+ });
17967
+ var AudioEventSchema = object({
17968
+ ...BaseEventFields,
17969
+ kind: literal("audio"),
17970
+ rms: number(),
17971
+ dbfs: number(),
17972
+ classification: object({
17973
+ className: string(),
17974
+ originalClass: string().optional(),
17975
+ score: number()
17976
+ }).optional(),
17977
+ /** Populated by B5 (recording playback URL for this event). */
17978
+ mediaUrl: string().optional()
17979
+ });
17980
+ var MediaFileKindEnum = _enum([
17981
+ "crop",
17982
+ "thumbnail",
17983
+ "snapshot",
17984
+ "firstFrame",
17985
+ "lastFrame",
17986
+ "fullFrame",
17987
+ "fullFrameBoxed",
17988
+ "faceCrop",
17989
+ "plateCrop",
17990
+ "keyFrame",
17991
+ "keyFrameSmall",
17992
+ "thumbnailSmall"
17993
+ ]);
17994
+ var MediaFileSchema = object({
17995
+ key: string(),
17996
+ kind: MediaFileKindEnum,
17939
17997
  base64: string(),
17940
- width: number().int(),
17941
- height: number().int()
17942
- }), {
17943
- kind: "query",
17944
- auth: "admin"
17945
- }), method(object({
17946
- deviceId: number(),
17947
- trackId: string(),
17948
- frameId: string(),
17949
- subject: RetrainAssistSubjectSchema,
17950
- /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
17951
- nodeId: string().optional()
17952
- }), RetrainAssistResultSchema, {
17953
- kind: "mutation",
17954
- auth: "admin"
17955
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
17956
- kind: "query",
17957
- auth: "admin"
17958
- }), method(object({
17959
- deviceId: number(),
17998
+ sizeBytes: number(),
17999
+ timestamp: number()
18000
+ });
18001
+ /**
18002
+ * One media row WITHOUT its bytes.
18003
+ *
18004
+ * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
18005
+ * 140 s track), and a client that renders tiles from the media data plane needs
18006
+ * to know only WHAT EXISTS — the bytes then arrive per tile, lazily, over HTTP
18007
+ * with an immutable cache, instead of all at once inside a tRPC response that
18008
+ * blocks the whole view.
18009
+ *
18010
+ * `sizeBytes` is carried because it is what lets a client decide between the
18011
+ * stored blob and a `?variant=thumb` rendering without fetching either.
18012
+ */
18013
+ var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
18014
+ /**
18015
+ * The MACRO tier of an annotation — a CLOSED set.
18016
+ *
18017
+ * This is what the exported detector predicts, so a typo here is a new class
18018
+ * with one example in it. `label` and `subLabel` are open strings by contrast:
18019
+ * the whole point of the page is teaching the model things it does not know
18020
+ * yet, and constraining that vocabulary would make it useless.
18021
+ *
18022
+ * A macro class is NEVER a label. The provider refuses a write whose `label` or
18023
+ * `subLabel` is one of these values, in any casing, because once `person`
18024
+ * exists in both tiers "every person box" stops being answerable without
18025
+ * knowing every string anyone ever typed — and the damage is retroactive.
18026
+ */
18027
+ var RetrainMacroClassSchema = _enum([
18028
+ "person",
18029
+ "vehicle",
18030
+ "animal",
18031
+ "package",
18032
+ "face",
18033
+ "plate"
18034
+ ]);
18035
+ /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
18036
+ var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
18037
+ /** Did a human draw this box, or did the assist propose it? */
18038
+ var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
18039
+ /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
18040
+ var RetrainBboxSchema = object({
18041
+ x: number(),
18042
+ y: number(),
18043
+ w: number(),
18044
+ h: number()
18045
+ });
18046
+ /**
18047
+ * One annotated subject.
18048
+ *
18049
+ * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
18050
+ * (letterboxed root / zone-cropped package / subject-cropped classifier) are
18051
+ * derived from it at export and never stored — storing them is how one feature
18052
+ * space ends up holding two crops of the same subject (D52).
18053
+ */
18054
+ var RetrainAnnotationSchema = object({
18055
+ id: string(),
17960
18056
  trackId: string(),
17961
- frameId: string(),
17962
- annotations: array(RetrainAnnotationDraftSchema)
17963
- }), array(RetrainAnnotationSchema).readonly(), {
17964
- kind: "mutation",
17965
- auth: "admin"
17966
- }), method(object({
17967
18057
  deviceId: number(),
17968
- trackId: string()
17969
- }), RetrainTransitionResultSchema, {
17970
- kind: "mutation",
17971
- auth: "admin"
17972
- }), method(object({
17973
- deviceId: number(),
17974
- trackId: string()
17975
- }), RetrainTransitionResultSchema, {
17976
- kind: "mutation",
17977
- auth: "admin"
17978
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
17979
- kind: "query",
17980
- auth: "admin"
17981
- }), method(object({
17982
- eventId: string(),
17983
- kind: MediaFileKindEnum.optional(),
17984
- deviceId: number()
17985
- }), array(MediaFileSchema).readonly()), method(object({
17986
- trackId: string(),
17987
- kinds: array(MediaFileKindEnum).optional(),
17988
- deviceId: number()
17989
- }), array(MediaFileSchema).readonly()), method(object({
17990
- trackId: string(),
17991
- deviceId: number()
17992
- }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
17993
- kind: "mutation",
17994
- auth: "admin"
17995
- }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
17996
- kind: "mutation",
17997
- auth: "admin"
17998
- }), method(object({}), RebuildStatusSchema), object({
18058
+ /** The COPY in retrain storage — never the source track's media key. */
18059
+ mediaKey: string(),
18060
+ bbox: RetrainBboxSchema,
18061
+ macroClass: RetrainMacroClassSchema,
18062
+ label: string().optional(),
18063
+ subLabel: string().optional(),
18064
+ kind: RetrainAnnotationKindSchema,
18065
+ source: RetrainAnnotationSourceSchema,
18066
+ /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
18067
+ assistModelId: string().optional(),
18068
+ assistScore: number().optional(),
18069
+ exportedInBatch: string().optional(),
18070
+ createdAt: number()
18071
+ });
18072
+ /** The write form — the server owns `id`, `createdAt` and the frame binding. */
18073
+ var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
18074
+ id: true,
18075
+ trackId: true,
18076
+ deviceId: true,
18077
+ mediaKey: true,
18078
+ createdAt: true,
18079
+ exportedInBatch: true
18080
+ });
18081
+ /** A track sitting in `staging`, with everything the worklist needs to rank it. */
18082
+ var RetrainTrackSchema = object({
18083
+ trackId: string(),
17999
18084
  deviceId: number(),
18085
+ className: string(),
18086
+ label: string().optional(),
18087
+ firstSeen: number(),
18088
+ lastSeen: number(),
18089
+ /** How many frames the dataset already holds from this track. */
18090
+ frameCount: number().int(),
18091
+ /** How many subjects have been annotated on those frames. `0` with
18092
+ * `frameCount: 0` is exactly "staging, still to work". */
18093
+ annotationCount: number().int()
18094
+ });
18095
+ /** A frame the picker may offer — an index row, no blob was read to produce it. */
18096
+ var RetrainFrameCandidateSchema = object({
18097
+ mediaKey: string(),
18098
+ kind: MediaFileKindEnum,
18000
18099
  timestamp: number(),
18001
- frameWidth: number(),
18002
- frameHeight: number(),
18003
- detections: array(OverlayDetectionSchema).readonly()
18004
- }), object({
18100
+ sizeBytes: number().int(),
18101
+ /** A copy of this original already exists — selecting it is free and cannot
18102
+ * fail, whatever became of the original. */
18103
+ copied: boolean()
18104
+ });
18105
+ /** A frame the dataset OWNS: bytes copied at selection time. */
18106
+ var RetrainFrameSchema = object({
18107
+ frameId: string(),
18005
18108
  deviceId: number(),
18006
18109
  trackId: string(),
18007
- className: string()
18110
+ /** Provenance only. It may already point at nothing — that is expected. */
18111
+ sourceMediaKey: string(),
18112
+ sourceKind: MediaFileKindEnum,
18113
+ sizeBytes: number().int(),
18114
+ width: number().int(),
18115
+ height: number().int(),
18116
+ copiedAt: number()
18117
+ });
18118
+ /** Why a copy-on-select could not be honoured — named, never a silent skip. */
18119
+ var RetrainCopyRefusalSchema = _enum([
18120
+ "source-missing",
18121
+ "unreadable-image",
18122
+ "write-failed"
18123
+ ]);
18124
+ var RetrainFrameSelectionSchema = object({
18125
+ copied: array(RetrainFrameSchema).readonly(),
18126
+ refused: array(object({
18127
+ sourceMediaKey: string(),
18128
+ reason: RetrainCopyRefusalSchema
18129
+ })).readonly()
18130
+ });
18131
+ var RetrainFrameListSchema = object({
18132
+ candidates: array(RetrainFrameCandidateSchema).readonly(),
18133
+ copies: array(RetrainFrameSchema).readonly(),
18134
+ /** What the page pre-selects — the native key frame when one survives. */
18135
+ autoPickMediaKey: string().optional()
18136
+ });
18137
+ /** What the operator asked the assist to look for. */
18138
+ var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
18139
+ kind: literal("package"),
18140
+ zone: RetrainBboxSchema.optional()
18008
18141
  }), object({
18009
- deviceId: number(),
18010
- trackId: string(),
18011
- className: string(),
18012
- durationMs: number()
18142
+ kind: literal("objects"),
18143
+ modelId: string(),
18144
+ minScore: number().optional()
18145
+ })]);
18146
+ /**
18147
+ * The assist's answer — a discriminated union, because "the model saw nothing"
18148
+ * and "this node cannot run that model" lead to different next moves and a
18149
+ * nullable result cannot tell them apart.
18150
+ */
18151
+ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
18152
+ kind: literal("proposed"),
18153
+ modelId: string(),
18154
+ stepId: string(),
18155
+ minScore: number(),
18156
+ /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
18157
+ proposals: array(RetrainAnnotationDraftSchema).readonly(),
18158
+ /** Returned by the runner but removed by the threshold. */
18159
+ belowThreshold: number().int()
18013
18160
  }), object({
18161
+ kind: literal("refused"),
18162
+ /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
18163
+ reason: string(),
18164
+ detail: string().optional()
18165
+ })]);
18166
+ /** The outcome of a lifecycle move owned by the retrain page. */
18167
+ var RetrainTransitionResultSchema = object({
18168
+ trackId: string(),
18169
+ /** Where the track ended up, whatever happened. */
18170
+ retrainStatus: RetrainStatusSchema,
18171
+ /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
18172
+ changed: boolean(),
18173
+ reason: _enum([
18174
+ "unknown-track",
18175
+ "no-frames-copied",
18176
+ "not-staging",
18177
+ "not-trained",
18178
+ "unchanged"
18179
+ ]).optional()
18180
+ });
18181
+ var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
18182
+ var MAX_EVENT_QUERY_LIMIT = 5e3;
18183
+ var DeviceEventQueryInput = object({
18014
18184
  deviceId: number(),
18015
- kind: EventKindSchema,
18016
- eventId: string(),
18017
- timestamp: number()
18185
+ since: number().optional(),
18186
+ until: number().optional(),
18187
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
18188
+ /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
18189
+ * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
18190
+ * exact behaviour. Callers may omit this field — the store defaults to
18191
+ * `full` when not provided. */
18192
+ projection: _enum(["full", "slim"]).optional()
18018
18193
  });
18019
- /**
18020
- * Reference to the frame's retained NATIVE surface + the parent crop's placement
18021
- * within the frame, so the executor can re-cut a leaf child ROI at native
18022
- * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
18023
- */
18024
- var NativeCropRefSchema = object({
18025
- /** Handle keying the retained native surface (node-pinned to its owner). */
18026
- handle: FrameHandleSchema,
18027
- /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
18028
- cropFrameSpace: object({
18029
- x: number(),
18030
- y: number(),
18031
- w: number(),
18032
- h: number()
18033
- })
18194
+ var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
18195
+ var RecentTracksQueryInput = object({
18196
+ /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
18197
+ deviceIds: array(number()),
18198
+ /** Window lower bound on `lastSeen` (inclusive). */
18199
+ since: number().optional(),
18200
+ /** Window upper bound on `lastSeen` (inclusive). */
18201
+ until: number().optional(),
18202
+ /** Page size. Default 200, max 1000. */
18203
+ limit: number().int().min(1).max(1e3).default(200),
18204
+ /** Opaque continuation cursor from a previous page's `nextCursor`.
18205
+ * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
18206
+ cursor: string().optional(),
18207
+ /** See {@link TrackProjectionSchema}. Default `full`. */
18208
+ projection: TrackProjectionSchema.optional(),
18209
+ /** Include stationary-promoted rows (parked objects). Default false: the
18210
+ * feed lists passages; parking records live on the stationary registry. */
18211
+ includeStationary: boolean().optional()
18034
18212
  });
18035
- object({
18036
- crop: object({
18037
- left: number(),
18038
- top: number(),
18039
- width: number().positive(),
18040
- height: number().positive()
18041
- }).optional(),
18042
- content: object({
18043
- width: number().int().positive(),
18044
- height: number().int().positive()
18045
- }),
18046
- fit: _enum(["stretch", "contain"]),
18047
- format: _enum([
18048
- "rgb",
18049
- "gray",
18050
- "jpeg"
18051
- ])
18213
+ var RecentTracksPageSchema = object({
18214
+ /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
18215
+ tracks: array(TrackSchema).readonly(),
18216
+ /** Cursor for the next page, or null when this page is the last. */
18217
+ nextCursor: string().nullable()
18052
18218
  });
18053
- var FrameRefSchema = object({
18054
- registryId: string().min(1),
18055
- id: string().min(1),
18056
- width: number().int().positive(),
18057
- height: number().int().positive(),
18058
- format: _enum(["rgb", "gray"]),
18059
- timestamp: number(),
18060
- capturedAt: number().optional()
18219
+ var LIST_GROUPS_DEFAULT_LIMIT = 40;
18220
+ var LIST_GROUPS_MAX_LIMIT = 100;
18221
+ var AnalyticsGroupRecordSchema = object({
18222
+ id: string(),
18223
+ deviceId: number().int(),
18224
+ openedAt: number().int(),
18225
+ closedAt: number().int(),
18226
+ timestamp: number().int(),
18227
+ memberCount: number().int(),
18228
+ memberTrackIds: array(string()).readonly(),
18229
+ className: string(),
18230
+ classes: array(string()).readonly(),
18231
+ /** Relative event-media path, or null when the group has no picture yet. */
18232
+ mediaUrl: string().nullable(),
18233
+ singleton: boolean()
18061
18234
  });
18062
- var ModelFormatSchema$1 = _enum([
18063
- "onnx",
18064
- "coreml",
18065
- "openvino",
18066
- "tflite",
18067
- "pt",
18068
- "gguf"
18069
- ]);
18070
- var PipelineSlotSchema = _enum([
18071
- "detector",
18072
- "cropper",
18073
- "classifier",
18074
- "refiner",
18075
- "audio-classifier"
18076
- ]);
18077
- var PipelineEngineChoiceSchema = object({
18078
- runtime: _enum(["node", "python"]),
18079
- backend: string(),
18080
- format: ModelFormatSchema$1,
18081
- device: string().optional()
18235
+ var AnalyticsGroupMemberSchema = object({
18236
+ trackId: string(),
18237
+ deviceId: number().int(),
18238
+ className: string(),
18239
+ firstSeen: number().int(),
18240
+ lastSeen: number().int(),
18241
+ mediaUrl: string().nullable()
18082
18242
  });
18083
- var AvailableEngineSchema = object({
18084
- engine: PipelineEngineChoiceSchema,
18085
- devices: array(object({
18086
- id: string(),
18087
- label: string(),
18088
- description: string().optional()
18089
- })).readonly(),
18090
- defaultDevice: string()
18243
+ var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
18244
+ var ListGroupsQueryInput = object({
18245
+ /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
18246
+ deviceIds: array(number()),
18247
+ /** Window lower bound on `closedAt` (inclusive). */
18248
+ since: number().optional(),
18249
+ /** Window upper bound on `openedAt` (inclusive). */
18250
+ until: number().optional(),
18251
+ limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
18252
+ /** Opaque continuation cursor from a previous page's `nextCursor`. */
18253
+ cursor: string().optional()
18254
+ });
18255
+ var ListGroupsPageSchema = object({
18256
+ groups: array(AnalyticsGroupRecordSchema).readonly(),
18257
+ nextCursor: string().nullable()
18258
+ });
18259
+ var KeyEventQueryInput = object({
18260
+ deviceId: number(),
18261
+ /** Window lower bound (track firstSeen ≥ since). */
18262
+ since: number(),
18263
+ /** Window upper bound (track firstSeen ≤ until). */
18264
+ until: number(),
18265
+ limit: number().int().min(1).max(200).default(50),
18266
+ /** Drop tracks scoring below this importance. */
18267
+ minImportance: number().min(0).max(1).optional(),
18268
+ /** Restrict to a single class (e.g. 'person'). */
18269
+ classFilter: string().optional()
18091
18270
  });
18092
- var PipelineDefaultStepSchema = lazy(() => object({
18093
- addonId: string(),
18094
- addonName: string(),
18095
- slot: PipelineSlotSchema,
18096
- inputClasses: array(string()).readonly(),
18097
- outputClasses: array(string()).readonly(),
18098
- enabled: boolean(),
18099
- modelId: string(),
18100
- children: array(PipelineDefaultStepSchema).readonly(),
18101
- group: string().optional(),
18102
- settings: record(string(), unknown()).optional()
18103
- }));
18104
- var PipelineTemplateStepSchema = lazy(() => object({
18105
- addonId: string(),
18106
- enabled: boolean(),
18107
- modelId: string(),
18108
- children: array(PipelineTemplateStepSchema).readonly(),
18109
- settings: record(string(), unknown()).optional()
18110
- }));
18111
- var PipelineTemplateSchema$1 = object({
18271
+ var KeyEventSchema = object({
18272
+ /** The representative event id (the track's best ObjectEvent, else its trackId). */
18112
18273
  id: string(),
18113
- name: string(),
18114
- createdAt: string(),
18115
- updatedAt: string(),
18116
- engine: PipelineEngineChoiceSchema,
18117
- steps: array(PipelineTemplateStepSchema).readonly()
18274
+ trackId: string(),
18275
+ /** Track start time (firstSeen). */
18276
+ timestamp: number(),
18277
+ className: string(),
18278
+ ...TieredLabelFields,
18279
+ importance: number(),
18280
+ /** Highest-confidence ObjectEvent id for the track (empty when none). */
18281
+ bestEventId: string(),
18282
+ /** Track lifetime in ms (lastSeen - firstSeen). */
18283
+ windowMs: number().optional(),
18284
+ ...TrackFlagFields,
18285
+ ...TrackRetrainFields
18118
18286
  });
18119
- var PipelineModelOptionSchema = object({
18120
- id: string(),
18121
- name: string(),
18122
- formats: record(string(), object({
18123
- downloaded: boolean(),
18124
- sizeMB: number()
18125
- })),
18126
- group: ModelVariantGroupSchema.optional(),
18127
- legacy: boolean().optional(),
18128
- provider: ModelProviderIdSchema.optional()
18287
+ object({
18288
+ trackId: string(),
18289
+ className: string(),
18290
+ confidence: number(),
18291
+ bbox: BoundingBoxSchema,
18292
+ zones: array(string()).readonly(),
18293
+ state: TrackStateSchema
18129
18294
  });
18130
- var ConfigFieldBridge = custom();
18131
- var PipelineAddonSchemaSchema = object({
18295
+ var OverlayDetectionSchema = looseObject({
18132
18296
  id: string(),
18133
- name: string(),
18134
- slot: PipelineSlotSchema,
18135
- inputClasses: array(string()).readonly(),
18136
- outputClasses: array(string()).readonly(),
18137
- childSlots: array(PipelineSlotSchema).readonly(),
18138
- models: array(PipelineModelOptionSchema).readonly(),
18139
- defaultModelId: string(),
18140
- defaultModelIdByFormat: record(string(), string()).optional(),
18141
- enabledByDefault: boolean().optional(),
18142
- backfillIntoExistingOverrides: boolean().optional(),
18143
- defaultConfidence: number(),
18144
- group: string().optional(),
18145
- configSchema: array(ConfigFieldBridge).readonly().optional()
18146
- });
18147
- var PipelineSlotSchemaSchema = object({
18148
- id: PipelineSlotSchema,
18149
- label: string(),
18150
- priority: number(),
18151
- parentSlot: PipelineSlotSchema.nullable(),
18152
- addons: array(PipelineAddonSchemaSchema).readonly()
18297
+ kind: _enum(["first-level", "detail"]),
18298
+ macroClass: string(),
18299
+ score: number(),
18300
+ bbox: object({
18301
+ x: number(),
18302
+ y: number(),
18303
+ width: number(),
18304
+ height: number()
18305
+ }),
18306
+ labels: array(looseObject({
18307
+ label: string(),
18308
+ score: number()
18309
+ })).readonly(),
18310
+ parentId: string().optional()
18153
18311
  });
18154
- var PipelineSchemaSchema = object({
18155
- availableEngines: array(AvailableEngineSchema).readonly(),
18156
- selectedEngine: PipelineEngineChoiceSchema,
18157
- slots: array(PipelineSlotSchemaSchema).readonly()
18312
+ var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
18313
+ var SearchObjectEventsInput = object({
18314
+ text: string(),
18315
+ deviceId: number().optional(),
18316
+ since: number().optional(),
18317
+ until: number().optional(),
18318
+ classFilter: string().optional(),
18319
+ limit: number().default(50),
18320
+ minScore: number().min(0).max(1).default(.2)
18158
18321
  });
18159
- var EngineProvisioningSchema = object({
18160
- runtimeId: _enum([
18161
- "onnx",
18162
- "openvino",
18163
- "coreml",
18164
- "edgetpu"
18165
- ]).nullable(),
18166
- device: string().nullable(),
18167
- state: _enum([
18168
- "idle",
18169
- "installing",
18170
- "verifying",
18171
- "ready",
18172
- "failed"
18173
- ]),
18174
- progress: number().optional(),
18175
- error: string().optional(),
18176
- nextRetryAt: number().optional(),
18177
- /**
18178
- * Gate A (config-correctness gate at engine change): human-readable
18179
- * config issues surfaced EAGERLY when the node's engine changes — model
18180
- * substitutions ("chose X, running Y") and zero-build steps ("no model
18181
- * has a <format> build"). Additive/optional: informational only, never
18182
- * enforced here — `assertEngineReady` (readiness) still gates inference.
18183
- * Absent/empty when the node-default tree resolves cleanly.
18184
- */
18185
- configIssues: array(string()).optional()
18322
+ var TrackCascadeCountsSchema = object({
18323
+ /** Persisted track roots deleted (authoritative). */
18324
+ tracks: number().int(),
18325
+ /** Object events removed with their tracks (best-effort; see note above). */
18326
+ events: number().int(),
18327
+ /** Track/face/plate-owned media removed (best-effort). Never identity media. */
18328
+ media: number().int(),
18329
+ /** Unassigned (non-enrolled) face reads removed (best-effort). */
18330
+ faces: number().int(),
18331
+ /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
18332
+ plates: number().int(),
18333
+ /** Per-track CLIP search vectors removed (best-effort). */
18334
+ embeddings: number().int(),
18335
+ /** Group membership + group rows removed with their last member (best-effort). */
18336
+ groups: number().int()
18186
18337
  });
18187
- var PipelineStepInputSchema = lazy(() => object({
18188
- addonId: string(),
18189
- modelId: string().optional(),
18190
- enabled: boolean().default(true),
18191
- children: array(PipelineStepInputSchema).optional(),
18192
- settings: record(string(), unknown()).optional(),
18193
- jumpDeviceKey: string().optional()
18194
- }));
18195
- var ModelSubstitutionSchema = object({
18196
- addonId: string(),
18197
- chosen: string(),
18198
- running: string(),
18199
- format: string()
18338
+ /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
18339
+ var DiskReconcileCountsSchema = object({
18340
+ mediaDropped: number().int(),
18341
+ tracks: number().int(),
18342
+ events: number().int()
18200
18343
  });
18201
- var PipelineValidationIssueSchema = object({
18202
- addonId: string(),
18203
- kind: _enum(["unknown-addon", "no-format-build"]),
18204
- detail: string()
18344
+ /** Event-store footprint for one camera. */
18345
+ var EventStoreDeviceFootprintSchema = object({
18346
+ deviceId: number(),
18347
+ /** Persisted event rows (motion + object + audio) for the camera. */
18348
+ rows: number().int(),
18349
+ /** Event-owned media bytes on disk for the camera. */
18350
+ bytes: number().int()
18205
18351
  });
18206
- var PipelineValidationResultSchema = object({
18207
- ok: boolean(),
18208
- issues: array(PipelineValidationIssueSchema).readonly(),
18209
- substitutions: array(ModelSubstitutionSchema).readonly(),
18210
- /** The node's `currentEngine.format` this validation ran against. */
18211
- format: string()
18352
+ /** Aggregate event-store footprint: global totals + per-camera breakdown. */
18353
+ var EventStoreFootprintSchema = object({
18354
+ totalRows: number().int(),
18355
+ totalBytes: number().int(),
18356
+ devices: array(EventStoreDeviceFootprintSchema).readonly()
18212
18357
  });
18213
- var ReferenceImageEntrySchema = object({
18214
- filename: string(),
18215
- stepIds: array(string()).readonly().optional()
18358
+ /** Per-kind counts returned by the event-prune / device-delete mutations. */
18359
+ var EventPruneCountsSchema = object({
18360
+ motion: number().int(),
18361
+ object: number().int(),
18362
+ audio: number().int()
18216
18363
  });
18217
- var ReferenceImageBodySchema = object({
18218
- base64: string(),
18219
- filename: string()
18364
+ /**
18365
+ * Re-embed stored tracks from their key frames.
18366
+ *
18367
+ * The reason this is an operator-callable method and not a migration script:
18368
+ * every knob that decides what a vector MEANS — encoder model, crop margin,
18369
+ * squaring — is only changeable if the existing vectors can be regenerated.
18370
+ * Mixing feature spaces in one index makes cosine scores incomparable, and the
18371
+ * symptom is a quality regression with no visible cause.
18372
+ */
18373
+ var RebuildObjectEmbeddingsInput = object({
18374
+ /** Restrict to one camera. Omit for the whole fleet. */
18375
+ deviceId: number().optional(),
18376
+ since: number().optional(),
18377
+ until: number().optional(),
18378
+ /** Stop after this many tracks; the result reports whether more remain. */
18379
+ maxTracks: number().int().positive().optional(),
18380
+ /**
18381
+ * Run every embedding on THIS node instead of round-robining the fleet.
18382
+ *
18383
+ * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
18384
+ * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
18385
+ * calling it that would pin the rebuild REQUEST itself to that node — the
18386
+ * rebuild orchestration lives on the hub, and only the per-track step runs
18387
+ * remotely. This field is data; the per-track pin is applied inside.
18388
+ *
18389
+ * Absent ⇒ round-robin over every online node whose runner can serve the
18390
+ * pinned model.
18391
+ */
18392
+ executeOnNodeId: string().optional(),
18393
+ /**
18394
+ * Milliseconds to wait between tracks; omit for the built-in default, `0` to
18395
+ * run flat out.
18396
+ *
18397
+ * A rebuild is bulk maintenance on hub-main's single thread. Measured
18398
+ * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
18399
+ * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
18400
+ * force is logged at start and finish so a deliberately slow pass reads
18401
+ * differently from a stalled one.
18402
+ */
18403
+ pacingMs: number().int().nonnegative().optional()
18220
18404
  });
18221
- var ReferenceAudioEntrySchema = object({
18222
- filename: string(),
18223
- sizeKb: number()
18405
+ /**
18406
+ * Result of emptying the CLIP index.
18407
+ *
18408
+ * The clean slate before a policy change: a new crop margin or encoder model
18409
+ * leaves two feature spaces in one index whose cosine scores are not
18410
+ * comparable, so wiping and rebuilding is the only way to be sure every vector
18411
+ * means the same thing.
18412
+ */
18413
+ var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
18414
+ /**
18415
+ * Acknowledgement that a rebuild STARTED.
18416
+ *
18417
+ * The pass costs ~1s per track — 45 minutes for a 2,600-track fleet — so it
18418
+ * runs detached and this returns immediately. Waiting for it made the client
18419
+ * time out while the work carried on server-side, which is the worst of both:
18420
+ * no result and no way to know it was still going. Poll
18421
+ * `getObjectEmbeddingRebuildStatus` for progress.
18422
+ */
18423
+ var RebuildObjectEmbeddingsResultSchema = object({
18424
+ started: boolean(),
18425
+ /** True when a pass was already running; the new request is ignored. */
18426
+ alreadyRunning: boolean()
18224
18427
  });
18225
- var ReferenceAudioBodySchema = object({ base64: string() });
18226
- var AudioBackendSchema = object({
18227
- id: string(),
18228
- name: string(),
18229
- description: string(),
18230
- available: boolean(),
18428
+ var RebuildStatusSchema = object({
18429
+ running: boolean(),
18430
+ scanned: number(),
18431
+ rebuilt: number(),
18432
+ /** Tracks whose key frame is gone — nothing to re-embed from. */
18433
+ missingKeyFrame: number(),
18434
+ /** Tracks with no usable detection box. */
18435
+ missingBbox: number(),
18231
18436
  /**
18232
- * Raw classifier labels this backend can emit (e.g. YAMNet's
18233
- * 521-class set or Apple SoundAnalysis's 303-class set). Used by
18234
- * the benchmark UI to populate the `enabledMicroClasses` filter
18235
- * specific to the selected backend without a separate fetch.
18437
+ * Tracks an executing node REFUSED rather than broke on — an unreadable key
18438
+ * frame, a step that threw. Separate from `failed` because the remedy is
18439
+ * different, and because a whole camera silently contributing zero vectors
18440
+ * is the shape of failure a rebuild must never hide.
18236
18441
  */
18237
- rawLabels: array(string()).readonly().optional()
18238
- });
18239
- var AudioCapabilitiesSchema = object({
18240
- activeBackend: string(),
18241
- availableBackends: array(AudioBackendSchema).readonly(),
18242
- sampleRate: number(),
18243
- chunkDurationMs: number()
18244
- });
18245
- var DownloadModelResultSchema = object({
18246
- filePath: string(),
18247
- sizeMB: number(),
18248
- durationMs: number()
18442
+ notRunnable: number(),
18443
+ /**
18444
+ * The pass stopped because NO node could serve the pinned model.
18445
+ *
18446
+ * Distinct from `notRunnable` on purpose: that one says "this track was
18447
+ * refused", this one says "the cluster cannot do this work at all" — every
18448
+ * candidate node either lacks the `clip-embedding` step, lacks a build of the
18449
+ * pinned model for its engine format, or dropped out. The remedy is a model /
18450
+ * engine change, not a per-camera one. Non-zero here always comes with
18451
+ * `complete: false`.
18452
+ */
18453
+ noCapableNode: number(),
18454
+ failed: number(),
18455
+ /** Set once a pass ends: true only when EVERYTHING was covered. */
18456
+ complete: boolean().nullable(),
18457
+ startedAtMs: number().nullable(),
18458
+ finishedAtMs: number().nullable(),
18459
+ /** Present when the pass ended by throwing. */
18460
+ error: string().nullable()
18249
18461
  });
18250
- /**
18251
- * Wrapper carrying a single test run's result. Replaces the legacy
18252
- * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
18253
- * canonical `AudioResult` from the Phase 6 output rework: one
18254
- * `AudioDetection` per class above `minScore`, top-N candidates in
18255
- * `debug.alternateLabels['audio-classifier']`, per-source timings in
18256
- * `debug.stepTimings`. The outer `success`/`error` fields stay so the
18257
- * benchmark UI can still report a clean failure when the classifier
18258
- * cap isn't available.
18259
- */
18260
- var AudioTestResultSchema = object({
18261
- success: boolean(),
18262
- error: string().optional(),
18263
- frame: custom().optional()
18462
+ var ReplayFrameInputSchema = object({
18463
+ timestamp: number(),
18464
+ frame: PipelineRunResultBridge
18264
18465
  });
18265
- var PipelineConfigBridge = custom();
18266
- var ConfigUISchemaBridge = custom();
18267
- var ConfigUISchemaNullableBridge = custom();
18268
- var InferenceCapabilitiesBridge = custom();
18269
- var ModelAvailabilityListBridge = custom();
18270
- var PipelineRunResultBridge = custom();
18271
- method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
18272
- modelId: string(),
18273
- settings: record(string(), unknown()).readonly()
18274
- }))), method(object({ steps: record(string(), object({
18275
- modelId: string(),
18276
- settings: record(string(), unknown()).readonly()
18277
- })) }), object({ success: literal(true) }), {
18466
+ var RunReplayFrameProcessorResultSchema = object({ tracks: array(object({
18467
+ className: string(),
18468
+ firstSeenMs: number(),
18469
+ lastSeenMs: number(),
18470
+ /** Bbox of the track's FIRST matched detection, pixel-space in the clip's
18471
+ * frame a representative box for the diff's `(className, window, IoU)`
18472
+ * pairing (`replay-diff.ts`). A replay does not need the full per-frame
18473
+ * trajectory production's `Track.positions` keeps. */
18474
+ bbox: BoundingBoxSchema,
18475
+ /** How many of the input frames this track matched a real detection on
18476
+ * (never a coasted/extrapolated frame) — the replay's own signal for "how
18477
+ * solid is this track", cheaper than re-deriving it from a trajectory. */
18478
+ framesMatched: number().int()
18479
+ })).readonly() });
18480
+ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
18481
+ deviceId: number(),
18482
+ trackId: string()
18483
+ }), TrackSchema.nullable()), method(object({
18484
+ deviceId: number(),
18485
+ since: number().optional(),
18486
+ until: number().optional(),
18487
+ limit: number().optional(),
18488
+ /** Spatial filter — only tracks whose trajectory intersects the zone
18489
+ * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
18490
+ * envelope columns, then precisely tested per position. Tracks with
18491
+ * an unknown envelope (no frame dims at persist time) always match. */
18492
+ zone: TrackZoneFilterSchema.optional(),
18493
+ /** See {@link TrackProjectionSchema}. Default `full` (backward
18494
+ * compatible — omitting the field keeps today's exact behaviour). */
18495
+ projection: TrackProjectionSchema.optional(),
18496
+ /** Include stationary-promoted rows (parked objects handed to the
18497
+ * stationary registry). Default false: the timeline lists passages,
18498
+ * not parking records (operator decision, 2026-08-15). */
18499
+ includeStationary: boolean().optional()
18500
+ }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
18501
+ deviceId: number(),
18502
+ groupId: string().min(1)
18503
+ }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
18278
18504
  kind: "mutation",
18279
18505
  auth: "admin"
18280
- }), method(object({ nodeId: string() }), object({
18281
- success: literal(true),
18282
- clearedDevices: number()
18506
+ }), 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({
18507
+ deviceId: number(),
18508
+ since: number().optional(),
18509
+ until: number().optional(),
18510
+ kinds: array(string()).optional(),
18511
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
18512
+ }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
18513
+ deviceId: number(),
18514
+ since: number(),
18515
+ until: number(),
18516
+ bucketMs: number().int().positive()
18517
+ }), array(object({
18518
+ bucketStart: number(),
18519
+ motion: number().int(),
18520
+ object: number().int(),
18521
+ audio: number().int()
18522
+ })).readonly()), method(object({
18523
+ deviceId: number(),
18524
+ cutoffMs: number()
18525
+ }), object({
18526
+ motion: number().int(),
18527
+ object: number().int(),
18528
+ audio: number().int()
18283
18529
  }), {
18284
18530
  kind: "mutation",
18285
18531
  auth: "admin"
18286
- }), 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({
18287
- name: string(),
18288
- steps: array(PipelineTemplateStepSchema).readonly(),
18289
- engine: PipelineEngineChoiceSchema
18290
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
18291
- id: string(),
18292
- name: string().optional(),
18293
- steps: array(PipelineTemplateStepSchema).readonly().optional()
18294
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
18295
- addonId: string(),
18296
- modelId: string(),
18297
- format: ModelFormatSchema$1
18298
- }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
18299
- addonId: string(),
18300
- modelId: string(),
18301
- format: ModelFormatSchema$1
18302
- }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
18303
- engine: PipelineEngineChoiceSchema.optional(),
18304
- steps: array(PipelineStepInputSchema).min(1),
18305
- frame: FrameInputSchema.optional(),
18306
- /**
18307
- * Process-local lazy frame. Valid only when caller and provider resolve
18308
- * in the same execution-group process; split/cross-node callers use
18309
- * `frame`/`image` inline compatibility instead.
18310
- */
18311
- frameRef: FrameRefSchema.optional(),
18312
- /**
18313
- * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
18314
- * the decoded pixels live in. One more member of the one-of
18315
- * frame/frameHandle/image/imageBase64/referenceImage group.
18316
- */
18317
- frameHandle: FrameHandleSchema.optional(),
18318
- imageBase64: string().optional(),
18319
- /**
18320
- * Binary JPEG bytes — preferred over `imageBase64` on internal
18321
- * hops (hub → forked worker via Moleculer MsgPack) because it
18322
- * skips the 33% base64 overhead + the per-call base64 decode on
18323
- * the detection-pipeline worker. Callers can pass either; exactly
18324
- * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
18325
- */
18326
- image: _instanceof(Uint8Array).optional(),
18327
- referenceImage: string().optional(),
18328
- deviceId: number().optional(),
18329
- sessionId: string().optional(),
18330
- /**
18331
- * Execution plane. 'full' (default) runs the whole tree — benchmark,
18332
- * reference-image, and detail-subtree calls. 'frame' is the live
18333
- * per-frame dispatch: ONLY root-plane steps run; crop children
18334
- * (inputClasses ≠ null) are skipped and served per-track via
18335
- * pipelineRunner.runDetailSubtree (two-plane design).
18336
- */
18337
- plane: _enum(["full", "frame"]).optional(),
18338
- /**
18339
- * Inference-device selector (Phase 2 multi-device). Format
18340
- * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
18341
- * Omitted ⇒ the runner's default device (current single-engine
18342
- * behaviour). Selects WHICH device pool of the node runs the call.
18343
- */
18344
- deviceKey: string().optional(),
18345
- /**
18346
- * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
18347
- * when the parent crop was resolved from the frame's retained NATIVE
18348
- * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
18349
- * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
18350
- * resolution from that surface — the SAME quality path faces already
18351
- * had — instead of the downscaled parent tile. `handle` keys the native
18352
- * surface (node-pinned to its owner); `cropFrameSpace` is the parent
18353
- * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
18354
- * the executor's crop-normalized child ROI back into frame-normalized
18355
- * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
18356
- * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
18357
- * (today's behaviour on the fallback path).
18358
- */
18359
- nativeCropRef: NativeCropRefSchema.optional()
18360
- }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
18361
- engine: PipelineEngineChoiceSchema.optional(),
18362
- steps: array(PipelineStepInputSchema).min(1),
18363
- frames: array(FrameInputSchema).min(1).max(255),
18364
- deviceId: number().optional(),
18365
- sessionId: string().optional(),
18366
- /**
18367
- * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
18368
- * the batch to the Python pool's bench preprocess cache
18369
- * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
18370
- * preprocessed ONCE and every later inference is a pure-inference cache
18371
- * hit — the sustained-throughput run measures inference, not
18372
- * decode+preprocess+infer. Omitted/0 for live frames (all different →
18373
- * full preprocess every call, correct). Fresh per sustained run;
18374
- * released via `uncacheFrame`.
18375
- */
18376
- frameId: number().int().nonnegative().optional(),
18377
- /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
18378
- deviceKey: string().optional()
18379
- }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
18380
- data: _instanceof(Uint8Array),
18381
- width: number().int().positive(),
18382
- height: number().int().positive(),
18383
- format: _enum([
18384
- "rgb",
18385
- "bgr",
18386
- "gray"
18387
- ])
18532
+ }), method(object({
18533
+ deviceId: number(),
18534
+ cutoffMs: number()
18535
+ }), TrackCascadeCountsSchema, {
18536
+ kind: "mutation",
18537
+ auth: "admin"
18538
+ }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
18539
+ kind: "mutation",
18540
+ auth: "admin"
18541
+ }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
18542
+ kind: "mutation",
18543
+ auth: "admin"
18544
+ }), method(object({
18545
+ deviceId: number(),
18546
+ trackIds: array(string()).min(1)
18388
18547
  }), object({
18389
- frameId: number(),
18390
- width: number(),
18391
- height: number()
18392
- }), { kind: "mutation" }), method(object({
18393
- stepId: string(),
18394
- frameId: number().int()
18395
- }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
18396
- batchMode: string(),
18397
- windowMs: number(),
18398
- maxBatchSize: number(),
18399
- concurrency: number()
18400
- })), method(_void(), array(object({
18401
- engineKey: string(),
18402
- engine: PipelineEngineChoiceSchema,
18403
- modelsLoaded: array(string()).readonly(),
18404
- inUseByCameras: array(number()).readonly(),
18405
- /**
18406
- * Origin of this resident factory.
18407
- * - `runtime` — main camera-serving engine (no idle TTL).
18408
- * - `warm-override` — benchmark/test override held in the warm
18409
- * cache; auto-disposed after the idle TTL.
18410
- * - `device-pool` — a concurrent per-device pool (Phase 2
18411
- * multi-device, keyed by `deviceKey`) resolved
18412
- * via `resolveDeviceFactory`. Runs alongside the
18413
- * `runtime` engine on a DIFFERENT accelerator
18414
- * (NPU / iGPU / Coral) — this is how the
18415
- * Engines tab shows all pools running at once.
18416
- */
18417
- kind: _enum([
18418
- "runtime",
18419
- "warm-override",
18420
- "device-pool"
18421
- ]),
18422
- /** Native pid of the underlying Python pool (null when no pool). */
18423
- poolPid: number().nullable(),
18424
- /** ms since this factory was last used (null when not warm-tracked). */
18425
- idleMs: number().nullable(),
18426
- /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
18427
- idleTtlMs: number().nullable()
18428
- })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
18548
+ deleted: number().int(),
18549
+ failed: array(string()).readonly()
18550
+ }), {
18429
18551
  kind: "mutation",
18430
18552
  auth: "admin"
18431
18553
  }), method(object({
18432
- engine: PipelineEngineChoiceSchema,
18433
- force: boolean().optional()
18554
+ /** Log/audit scope only — the trackId is globally unique on its own. */
18555
+ deviceId: number(),
18556
+ trackId: string(),
18557
+ flags: TrackFlagsPatchSchema
18558
+ }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
18559
+ kind: "query",
18560
+ auth: "admin"
18561
+ }), method(object({
18562
+ olderThanMs: number(),
18563
+ reason: OpsLogReasonSchema.optional()
18564
+ }), EventPruneCountsSchema, {
18565
+ kind: "mutation",
18566
+ auth: "admin"
18567
+ }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
18568
+ kind: "mutation",
18569
+ auth: "admin"
18570
+ }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
18571
+ kind: "mutation",
18572
+ auth: "admin"
18573
+ }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
18574
+ kind: "mutation",
18575
+ auth: "admin"
18576
+ }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
18577
+ kind: "mutation",
18578
+ auth: "admin"
18579
+ }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
18580
+ kind: "mutation",
18581
+ auth: "admin"
18582
+ }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18583
+ kind: "mutation",
18584
+ auth: "admin"
18585
+ }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
18586
+ kind: "mutation",
18587
+ auth: "admin"
18588
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
18589
+ kind: "query",
18590
+ auth: "admin"
18591
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18592
+ kind: "mutation",
18593
+ auth: "admin"
18594
+ }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
18595
+ kind: "query",
18596
+ auth: "admin"
18597
+ }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
18598
+ kind: "query",
18599
+ auth: "admin"
18600
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18601
+ kind: "query",
18602
+ auth: "admin"
18603
+ }), method(object({
18604
+ /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
18605
+ * `deviceId`, deliberately: `deviceId` would make this device-bound and
18606
+ * route it at one camera's owner, and "every camera" would stop being
18607
+ * expressible at all. */
18608
+ deviceIds: array(number()).optional(),
18609
+ limit: number().int().min(1).max(500).optional()
18610
+ }), array(RetrainTrackSchema).readonly(), {
18611
+ kind: "query",
18612
+ auth: "admin"
18613
+ }), method(object({ trackId: string() }), RetrainFrameListSchema, {
18614
+ kind: "query",
18615
+ auth: "admin"
18616
+ }), method(object({
18617
+ deviceId: number(),
18618
+ trackId: string(),
18619
+ mediaKeys: array(string()).min(1)
18620
+ }), RetrainFrameSelectionSchema, {
18621
+ kind: "mutation",
18622
+ auth: "admin"
18623
+ }), method(object({
18624
+ deviceId: number(),
18625
+ trackId: string(),
18626
+ frameId: string()
18434
18627
  }), object({
18435
- success: boolean(),
18436
- reason: string().optional()
18628
+ removed: boolean(),
18629
+ removedAnnotations: number().int()
18437
18630
  }), {
18438
18631
  kind: "mutation",
18439
18632
  auth: "admin"
18440
- }), 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({
18441
- addonId: string(),
18442
- modelId: string(),
18443
- filename: string().optional(),
18444
- settings: record(string(), unknown()).optional()
18445
- }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
18446
- object({
18447
- activeCameras: number(),
18448
- throttledCameras: number(),
18449
- avgInferenceTimeMs: number(),
18450
- queueDepth: number()
18451
- });
18452
- var CameraMetricsSchema = object({
18453
- detectionMode: _enum([
18454
- "disabled",
18455
- "always-on",
18456
- "on-motion"
18457
- ]),
18458
- configuredFps: number(),
18459
- actualFps: number(),
18460
- queueDepth: number(),
18461
- avgInferenceTimeMs: number(),
18462
- droppedFrames: number(),
18463
- phase: _enum([
18464
- "idle",
18465
- "watching",
18466
- "active"
18467
- ])
18468
- });
18469
- var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
18470
- /**
18471
- * Zone — pure geometry + identity. NO filtering behaviour.
18472
- *
18473
- * Zones describe **where** in the frame the operator wants to flag
18474
- * something; consumer-owned {@link ZoneRule} arrays describe **how**
18475
- * each pipeline stage uses them. Splitting the two means a single
18476
- * polygon "Driveway" can simultaneously back a motion-exclude rule,
18477
- * a detection-include rule on `['car']`, and an occupancy aggregate
18478
- * — without three duplicated polygons.
18479
- *
18480
- * Owned by the orchestrator addon (provider) and mirrored into the
18481
- * `zones` device-state slice on every mutation. Consumers
18482
- * (motion-wasm, pipeline-executor, analytics, admin UI) read either
18483
- * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
18484
- * mirror with `onChanged`).
18485
- *
18486
- * Coordinates are normalised fractions of the frame (0–1) so zones
18487
- * survive resolution changes and stream profile switches.
18488
- *
18489
- * `kind` discriminates between full polygons (closed regions used
18490
- * for intrusion / occupancy filters) and tripwires (open 2-point
18491
- * line segments used for cross events). Onboard / firmware-reported
18492
- * zones (Reolink, ONVIF) are out of scope for now — see the deferred
18493
- * task list.
18494
- */
18495
- var ZoneKindEnum = _enum(["polygon", "tripwire"]);
18496
- /** Polygon vertex in fraction-of-frame coordinates (0–1). */
18497
- var PolygonPointSchema = object({
18498
- x: number(),
18499
- y: number()
18500
- });
18501
- /** A camera detection zone — pure geometry/identity. */
18502
- var ZoneSchema = object({
18503
- id: string(),
18504
- name: string(),
18505
- kind: ZoneKindEnum.default("polygon"),
18506
- /** Polygon vertices, fraction of frame (0–1). */
18507
- polygon: array(PolygonPointSchema).readonly(),
18508
- /** Visual color for UI rendering. */
18509
- color: string().default("#3b82f6")
18510
- });
18511
- DeviceType.Camera, method(object({ deviceId: number() }), array(ZoneSchema).readonly()), method(object({
18633
+ }), method(object({ frameId: string() }), object({
18634
+ base64: string(),
18635
+ width: number().int(),
18636
+ height: number().int()
18637
+ }), {
18638
+ kind: "query",
18639
+ auth: "admin"
18640
+ }), method(object({
18512
18641
  deviceId: number(),
18513
- zone: ZoneSchema
18514
- }), _void(), {
18642
+ trackId: string(),
18643
+ frameId: string(),
18644
+ subject: RetrainAssistSubjectSchema,
18645
+ /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
18646
+ nodeId: string().optional()
18647
+ }), RetrainAssistResultSchema, {
18515
18648
  kind: "mutation",
18516
18649
  auth: "admin"
18517
18650
  }), method(object({
18518
18651
  deviceId: number(),
18519
- zoneId: string()
18520
- }), _void(), {
18652
+ source: DetectionSourceSchema,
18653
+ zones: array(ZoneSchema).readonly().optional(),
18654
+ detectionRules: array(ZoneRuleSchema).readonly().optional(),
18655
+ zoneMembershipMinOverlap: number().min(0).max(1).optional(),
18656
+ frames: array(ReplayFrameInputSchema).min(1)
18657
+ }), RunReplayFrameProcessorResultSchema, {
18658
+ kind: "mutation",
18659
+ auth: "admin"
18660
+ }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
18661
+ kind: "query",
18662
+ auth: "admin"
18663
+ }), method(object({
18664
+ deviceId: number(),
18665
+ trackId: string(),
18666
+ frameId: string(),
18667
+ annotations: array(RetrainAnnotationDraftSchema)
18668
+ }), array(RetrainAnnotationSchema).readonly(), {
18669
+ kind: "mutation",
18670
+ auth: "admin"
18671
+ }), method(object({
18672
+ deviceId: number(),
18673
+ trackId: string()
18674
+ }), RetrainTransitionResultSchema, {
18675
+ kind: "mutation",
18676
+ auth: "admin"
18677
+ }), method(object({
18678
+ deviceId: number(),
18679
+ trackId: string()
18680
+ }), RetrainTransitionResultSchema, {
18681
+ kind: "mutation",
18682
+ auth: "admin"
18683
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18684
+ kind: "query",
18685
+ auth: "admin"
18686
+ }), method(object({
18687
+ eventId: string(),
18688
+ kind: MediaFileKindEnum.optional(),
18689
+ deviceId: number()
18690
+ }), array(MediaFileSchema).readonly()), method(object({
18691
+ trackId: string(),
18692
+ kinds: array(MediaFileKindEnum).optional(),
18693
+ deviceId: number()
18694
+ }), array(MediaFileSchema).readonly()), method(object({
18695
+ trackId: string(),
18696
+ deviceId: number()
18697
+ }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
18521
18698
  kind: "mutation",
18522
18699
  auth: "admin"
18523
- }), method(object({
18524
- deviceId: number(),
18525
- zone: ZoneSchema
18526
- }), _void(), {
18700
+ }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
18527
18701
  kind: "mutation",
18528
18702
  auth: "admin"
18529
- }), object({ zones: array(ZoneSchema).readonly() });
18703
+ }), method(object({}), RebuildStatusSchema), object({
18704
+ deviceId: number(),
18705
+ timestamp: number(),
18706
+ frameWidth: number(),
18707
+ frameHeight: number(),
18708
+ detections: array(OverlayDetectionSchema).readonly()
18709
+ }), object({
18710
+ deviceId: number(),
18711
+ trackId: string(),
18712
+ className: string()
18713
+ }), object({
18714
+ deviceId: number(),
18715
+ trackId: string(),
18716
+ className: string(),
18717
+ durationMs: number()
18718
+ }), object({
18719
+ deviceId: number(),
18720
+ kind: EventKindSchema,
18721
+ eventId: string(),
18722
+ timestamp: number()
18723
+ });
18724
+ object({
18725
+ activeCameras: number(),
18726
+ throttledCameras: number(),
18727
+ avgInferenceTimeMs: number(),
18728
+ queueDepth: number()
18729
+ });
18730
+ var CameraMetricsSchema = object({
18731
+ detectionMode: _enum([
18732
+ "disabled",
18733
+ "always-on",
18734
+ "on-motion"
18735
+ ]),
18736
+ configuredFps: number(),
18737
+ actualFps: number(),
18738
+ queueDepth: number(),
18739
+ avgInferenceTimeMs: number(),
18740
+ droppedFrames: number(),
18741
+ phase: _enum([
18742
+ "idle",
18743
+ "watching",
18744
+ "active"
18745
+ ])
18746
+ });
18747
+ var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
18530
18748
  /**
18531
18749
  * A bounding box in NORMALIZED [0,1] frame coordinates for `getNativeCrop`. The
18532
18750
  * decode worker resolves it against the RETAINED native frame's real pixel dims,
@@ -20215,7 +20433,7 @@ method(object({
20215
20433
  * linking rather than produce an eternal token.
20216
20434
  */
20217
20435
  ttlSec: union([number().int().positive(), literal("never")]).optional()
20218
- }), object({ token: string() })), method(object({ token: string() }), SsoBridgeClaimsSchema.nullable());
20436
+ }), object({ token: string() }), { auth: "admin" }), method(object({ token: string() }), SsoBridgeClaimsSchema.nullable(), { auth: "admin" });
20219
20437
  var ProviderListEntrySchema = discriminatedUnion("shouldSaveDiskSpace", [object({
20220
20438
  providerId: string().min(1),
20221
20439
  displayName: string().min(1),
@@ -20310,10 +20528,13 @@ var EvictResultSchema = object({
20310
20528
  /** True when the provider has nothing left it is willing to drop on this location. */
20311
20529
  exhausted: boolean()
20312
20530
  });
20313
- method(object({ locationId: string() }), EvictableUsageSchema), method(object({
20531
+ method(object({ locationId: string() }), EvictableUsageSchema, { auth: "admin" }), method(object({
20314
20532
  locationId: string(),
20315
20533
  targetBytes: number().int().positive()
20316
- }), EvictResultSchema, { kind: "mutation" });
20534
+ }), EvictResultSchema, {
20535
+ kind: "mutation",
20536
+ auth: "admin"
20537
+ });
20317
20538
  method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin" }), method(StorageMigrationInputSchema, object({ jobId: string() }), {
20318
20539
  kind: "mutation",
20319
20540
  auth: "admin"
@@ -20373,26 +20594,50 @@ var ReadChunkInputSchema = object({
20373
20594
  length: number()
20374
20595
  });
20375
20596
  var EndDownloadInputSchema = object({ downloadId: string() });
20376
- method(_void(), ProviderInfoSchema), method(object({ config: record(string(), unknown()) }), TestLocationResultSchema, { auth: "admin" }), method(object({
20597
+ method(_void(), ProviderInfoSchema, { auth: "admin" }), method(object({ config: record(string(), unknown()) }), TestLocationResultSchema, { auth: "admin" }), method(object({
20377
20598
  location: StorageLocationSchema,
20378
20599
  relativePath: string()
20379
- }), string()), method(object({
20600
+ }), string(), { auth: "admin" }), method(object({
20380
20601
  location: StorageLocationSchema,
20381
20602
  relativePath: string(),
20382
20603
  data: _instanceof(Uint8Array)
20383
- }), _void(), { kind: "mutation" }), method(object({
20604
+ }), _void(), {
20605
+ kind: "mutation",
20606
+ auth: "admin"
20607
+ }), method(object({
20384
20608
  location: StorageLocationSchema,
20385
20609
  relativePath: string()
20386
- }), _instanceof(Uint8Array)), method(object({
20610
+ }), _instanceof(Uint8Array), { auth: "admin" }), method(object({
20387
20611
  location: StorageLocationSchema,
20388
20612
  relativePath: string()
20389
- }), boolean()), method(object({
20613
+ }), boolean(), { auth: "admin" }), method(object({
20390
20614
  location: StorageLocationSchema,
20391
20615
  prefix: string().optional()
20392
- }), array(string()).readonly()), method(object({
20616
+ }), array(string()).readonly(), { auth: "admin" }), method(object({
20393
20617
  location: StorageLocationSchema,
20394
20618
  relativePath: string()
20395
- }), _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" });
20619
+ }), _void(), {
20620
+ kind: "mutation",
20621
+ auth: "admin"
20622
+ }), method(object({ location: StorageLocationSchema }), number().nullable(), { auth: "admin" }), method(BeginUploadInputSchema, BeginUploadResultSchema, {
20623
+ kind: "mutation",
20624
+ auth: "admin"
20625
+ }), method(WriteChunkInputSchema, _void(), {
20626
+ kind: "mutation",
20627
+ auth: "admin"
20628
+ }), method(FinalizeUploadInputSchema, _void(), {
20629
+ kind: "mutation",
20630
+ auth: "admin"
20631
+ }), method(AbortUploadInputSchema, _void(), {
20632
+ kind: "mutation",
20633
+ auth: "admin"
20634
+ }), method(BeginDownloadInputSchema, BeginDownloadResultSchema, {
20635
+ kind: "mutation",
20636
+ auth: "admin"
20637
+ }), method(ReadChunkInputSchema, _instanceof(Uint8Array), { auth: "admin" }), method(EndDownloadInputSchema, _void(), {
20638
+ kind: "mutation",
20639
+ auth: "admin"
20640
+ });
20396
20641
  /** Profile-exported FormBuilder schema. Shape is ConfigUISchema at the UI. */
20397
20642
  var ProfileSettingsSchemaBridge = unknown().nullable();
20398
20643
  var ProfileSettingsBagSchema = record(string(), unknown());
@@ -20650,7 +20895,8 @@ method(object({
20650
20895
  access: "create"
20651
20896
  }), method(object({ userId: string().optional() }), object({ optionsJSON: record(string(), unknown()) }), {
20652
20897
  kind: "mutation",
20653
- access: "view"
20898
+ access: "view",
20899
+ auth: "admin"
20654
20900
  }), method(object({
20655
20901
  /** Required — the user the assertion belongs to (verified). */
20656
20902
  userId: string(),
@@ -20658,10 +20904,12 @@ method(object({
20658
20904
  response: record(string(), unknown())
20659
20905
  }), object({ verified: boolean() }), {
20660
20906
  kind: "mutation",
20661
- access: "view"
20907
+ access: "view",
20908
+ auth: "admin"
20662
20909
  }), method(object({}), object({ optionsJSON: record(string(), unknown()) }), {
20663
20910
  kind: "mutation",
20664
- access: "view"
20911
+ access: "view",
20912
+ auth: "admin"
20665
20913
  }), method(object({
20666
20914
  /** AuthenticationResponseJSON from the browser. */
20667
20915
  response: record(string(), unknown()) }), object({
@@ -20669,7 +20917,8 @@ response: record(string(), unknown()) }), object({
20669
20917
  userId: string().nullable()
20670
20918
  }), {
20671
20919
  kind: "mutation",
20672
- access: "view"
20920
+ access: "view",
20921
+ auth: "admin"
20673
20922
  }), method(object({ userId: string() }), array(PasskeySummarySchema), { auth: "admin" }), method(object({
20674
20923
  userId: string(),
20675
20924
  credentialId: string()
@@ -20841,7 +21090,19 @@ var VectorStatsResultSchema = object({
20841
21090
  /** False when the backend ranks approximately. */
20842
21091
  exact: boolean()
20843
21092
  });
20844
- 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);
21093
+ method(VectorDeclareIndexInputSchema, _void(), {
21094
+ kind: "mutation",
21095
+ auth: "admin"
21096
+ }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
21097
+ kind: "mutation",
21098
+ auth: "admin"
21099
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
21100
+ kind: "mutation",
21101
+ auth: "admin"
21102
+ }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
21103
+ kind: "mutation",
21104
+ auth: "admin"
21105
+ }), method(VectorStatsInputSchema, VectorStatsResultSchema, { auth: "admin" });
20845
21106
  var ClipSchema = object({
20846
21107
  /** Opaque, provider-namespaced id. The default provider encodes the time
20847
21108
  * window so `getClipPlayback` is self-contained (no event re-query). */
@@ -22564,7 +22825,27 @@ var MediaFileLiteSchema$1 = object({
22564
22825
  sizeBytes: number(),
22565
22826
  timestamp: number()
22566
22827
  });
22567
- method(_void(), array(IdentitySchema).readonly()), method(object({ name: string().min(1) }), IdentitySchema, {
22828
+ method(object({
22829
+ /**
22830
+ * Inline {@link IdentitySchema.coverBase64} on every row.
22831
+ *
22832
+ * Default `false`, the same inversion `listRecentFaces` and
22833
+ * `listPlates` took on 2026-08-25 (see `include-crops-default.ts` for
22834
+ * why the burden belongs on the caller that WANTS the bytes). Measured
22835
+ * on the live hub the same day: four identities cost 40,979 B with the
22836
+ * covers inline, ~10 KB of base64 per row, on a query this UI mounts
22837
+ * four times and the viewer holds at `staleTime: 30_000`.
22838
+ *
22839
+ * Nothing loses its avatar: `coverMediaKey` is already on every row and
22840
+ * the `event-media` plane serves that key `immutable` with an ETag.
22841
+ *
22842
+ * **This is an INPUT field, so it does not reach the addon until the
22843
+ * next train** — the hub router validates cap inputs against its own
22844
+ * compiled Zod and strips a key it does not know. Until then the
22845
+ * provider sees `undefined`, which resolves to `false`: the cheap shape
22846
+ * is what ships, and the opt-in becomes reachable when the train lands.
22847
+ */
22848
+ includeCrops: boolean().optional() }).optional(), array(IdentitySchema).readonly()), method(object({ name: string().min(1) }), IdentitySchema, {
22568
22849
  kind: "mutation",
22569
22850
  auth: "admin"
22570
22851
  }), method(object({
@@ -24711,8 +24992,10 @@ var PlateInfoSchema = object({
24711
24992
  keyFrameMediaKey: string().optional(),
24712
24993
  base64: string().optional(),
24713
24994
  /**
24714
- * Same crop as a data-plane URL. `getPlateByTrack` returns this and
24715
- * never inlines JPEG; `listPlates` still inlines for the admin-ui.
24995
+ * Same crop as a data-plane URL, always present when the plate has a stored
24996
+ * crop. `getPlateByTrack` returns this and never inlines JPEG; `listPlates`
24997
+ * and `searchPlates` inline the crop only when their `includeCrops` input is
24998
+ * left at its `true` default.
24716
24999
  */
24717
25000
  cropUrl: string().optional()
24718
25001
  });
@@ -24732,14 +25015,34 @@ var PlateClusterSchema = object({
24732
25015
  });
24733
25016
  method(object({
24734
25017
  deviceId: number().int().optional(),
24735
- limit: number().int().positive().optional()
25018
+ limit: number().int().positive().optional(),
25019
+ /**
25020
+ * Inline the base64 crop on every row. Default `true` — the existing
25021
+ * behaviour, kept so no caller breaks.
25022
+ *
25023
+ * Set `false` once the caller renders {@link PlateInfo.cropUrl}.
25024
+ * Measured on the live hub at the 500 rows the Plates view asks for:
25025
+ * 879,403 B and 27.7 s with the crops inline, against a few KiB of
25026
+ * metadata without them — and the browser then caches the images.
25027
+ *
25028
+ * This is the plate twin of `faceGallery.listRecentFaces`'s option;
25029
+ * plates were the one gallery list left without it.
25030
+ *
25031
+ * **This is an INPUT field, so it does not reach the addon until the
25032
+ * next train.** The hub router validates cap inputs against its own
25033
+ * compiled Zod and strips a key it does not know. Until the train
25034
+ * ships, sending `false` is harmless and keeps the crops inline.
25035
+ */
25036
+ includeCrops: boolean().optional()
24736
25037
  }).optional(), array(PlateInfoSchema).readonly()), method(object({
24737
25038
  deviceId: number().int(),
24738
25039
  trackId: string()
24739
25040
  }), PlateInfoSchema.nullable()), method(object({ plateId: string() }), array(MediaFileLiteSchema).readonly()), method(object({
24740
25041
  text: string().min(1),
24741
25042
  maxDistance: number().int().min(0).optional(),
24742
- limit: number().int().positive().optional()
25043
+ limit: number().int().positive().optional(),
25044
+ /** See `listPlates.includeCrops`. Default `true`. */
25045
+ includeCrops: boolean().optional()
24743
25046
  }), array(PlateInfoSchema).readonly()), method(object({
24744
25047
  maxDistance: number().int().min(0).optional(),
24745
25048
  minClusterSize: number().int().min(2).optional(),
@@ -24753,7 +25056,13 @@ method(object({
24753
25056
  }), method(object({ plateId: string() }), _void(), {
24754
25057
  kind: "mutation",
24755
25058
  auth: "admin"
24756
- }), method(_void(), array(VehicleSchema).readonly()), method(object({ name: string().min(1) }), VehicleSchema, {
25059
+ }), method(object({
25060
+ /** Inline {@link VehicleSchema.coverBase64} on every row. Default
25061
+ * `false` — the vehicle twin of `faceGallery.listIdentities`'s
25062
+ * option; `coverMediaKey` + the `event-media` plane carry the picture.
25063
+ * INPUT field: stripped by the hub router until the train ships, which
25064
+ * resolves to `false` and is exactly the intended default. */
25065
+ includeCrops: boolean().optional() }).optional(), array(VehicleSchema).readonly()), method(object({ name: string().min(1) }), VehicleSchema, {
24757
25066
  kind: "mutation",
24758
25067
  auth: "admin"
24759
25068
  }), method(object({
@@ -26018,92 +26327,6 @@ DeviceType.Camera, method(object({ deviceId: number() }), SceneMonitorStatusSche
26018
26327
  kind: "mutation",
26019
26328
  auth: "admin"
26020
26329
  });
26021
- /**
26022
- * Per-stage gating mode applied to the zones a rule references.
26023
- *
26024
- * - `include`: the rule contributes to a **whitelist** for its stage.
26025
- * When at least one `include` rule fires for a stage, only entities
26026
- * inside one of those zones pass that stage.
26027
- * - `exclude`: the rule contributes to a **blacklist** for its stage.
26028
- * Entities inside one of those zones are dropped at that stage.
26029
- *
26030
- * `monitor`-style observation (count without filtering) is not a rule
26031
- * mode — zones without any matching rule are observed naturally by
26032
- * `zone-analytics` (live snapshot + history), so an "I just want to
26033
- * count, not filter" use case needs no rule at all.
26034
- */
26035
- var ZoneRuleModeEnum = _enum(["include", "exclude"]);
26036
- /**
26037
- * Per-consumer rule that references existing zones (geometry) and
26038
- * defines how a specific pipeline stage should treat them. Each
26039
- * consumer addon owns its own `ZoneRule[]` array in its per-device
26040
- * settings:
26041
- *
26042
- * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
26043
- * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
26044
- * - future: notification rules, audio gating, etc.
26045
- *
26046
- * One rule applies to N zones (`zoneIds[]`) so the operator can
26047
- * express "ignore motion in ALL of {garden, street}" with a single
26048
- * rule. `classFilter` narrows the rule to specific object classes —
26049
- * "drop person detections in the street, but keep cars" is one
26050
- * `exclude` rule with `classFilter: ['person']`.
26051
- *
26052
- * `enabled` is a soft toggle — the operator can keep the rule
26053
- * configured but inert without deleting it.
26054
- */
26055
- var ZoneRuleSchema = object({
26056
- /** Stable rule id — survives edits, used by the UI for diffing. */
26057
- id: string(),
26058
- /** Optional human-readable label rendered in the rule editor. */
26059
- name: string().optional(),
26060
- /** Zones this rule targets. The rule's `mode` applies to ALL
26061
- * listed zones (OR-set: a detection in any one of them counts).
26062
- * At least one zone id required — a rule with no targets is a
26063
- * configuration mistake and the form validator rejects it. */
26064
- zoneIds: array(string()).min(1).readonly(),
26065
- mode: ZoneRuleModeEnum,
26066
- /**
26067
- * Class names this rule applies to. Empty / undefined ⇒ rule
26068
- * applies to every class. Class strings match the `macroClass`
26069
- * field on detections (e.g. `person`, `car`, `dog`).
26070
- */
26071
- classFilter: array(string()).readonly().optional(),
26072
- /**
26073
- * Minimum bbox/mask overlap (0–1) with any of the rule's zones
26074
- * required to consider an entity "in the zone". Defaults to the
26075
- * consumer's stage default when omitted. Kept for back-compat with
26076
- * existing per-rule overrides; new operators pick the value via
26077
- * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
26078
- * set, the lower-level engine reads it as a 0–1 fraction.
26079
- */
26080
- overlapThreshold: number().min(0).max(1).optional(),
26081
- /**
26082
- * Operator-friendly version of `overlapThreshold` — the percentage
26083
- * of the detection's bbox that must lie inside the zone for the
26084
- * rule to match. Documented default is 85%; the engine substitutes
26085
- * that when the field is omitted (kept optional so existing rules
26086
- * stored without it stay valid).
26087
- *
26088
- * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
26089
- * rule, the engine prefers `bboxInclusionPct` because it's the
26090
- * field exposed in the UI. Internally both feed the same gate.
26091
- */
26092
- bboxInclusionPct: number().min(0).max(100).optional(),
26093
- /**
26094
- * When `true` and a detection has a segmentation mask, use the
26095
- * mask for overlap instead of the bbox. Detection-stage only;
26096
- * motion rules ignore this field.
26097
- */
26098
- preferMask: boolean().optional(),
26099
- /**
26100
- * Soft-toggle: `false` disables the rule without deleting it.
26101
- * Defaults to `true` so operators creating a rule via the UI
26102
- * see it active immediately.
26103
- */
26104
- enabled: boolean().default(true)
26105
- });
26106
- array(ZoneRuleSchema).readonly();
26107
26330
  object({
26108
26331
  /** Whether the script is currently executing. */
26109
26332
  isRunning: boolean(),
@@ -30130,6 +30353,12 @@ Object.freeze({
30130
30353
  addonId: null,
30131
30354
  access: "create"
30132
30355
  },
30356
+ "pipelineAnalytics.cancelRelocateMedia": {
30357
+ capName: "pipeline-analytics",
30358
+ capScope: "device",
30359
+ addonId: null,
30360
+ access: "create"
30361
+ },
30133
30362
  "pipelineAnalytics.cancelStorageMigrationMove": {
30134
30363
  capName: "pipeline-analytics",
30135
30364
  capScope: "device",
@@ -30304,6 +30533,12 @@ Object.freeze({
30304
30533
  addonId: null,
30305
30534
  access: "view"
30306
30535
  },
30536
+ "pipelineAnalytics.listRelocateMediaJobs": {
30537
+ capName: "pipeline-analytics",
30538
+ capScope: "device",
30539
+ addonId: null,
30540
+ access: "view"
30541
+ },
30307
30542
  "pipelineAnalytics.listRetrainAnnotations": {
30308
30543
  capName: "pipeline-analytics",
30309
30544
  capScope: "device",
@@ -30382,6 +30617,12 @@ Object.freeze({
30382
30617
  addonId: null,
30383
30618
  access: "create"
30384
30619
  },
30620
+ "pipelineAnalytics.relocateMedia": {
30621
+ capName: "pipeline-analytics",
30622
+ capScope: "device",
30623
+ addonId: null,
30624
+ access: "create"
30625
+ },
30385
30626
  "pipelineAnalytics.restageRetrainTrack": {
30386
30627
  capName: "pipeline-analytics",
30387
30628
  capScope: "device",
@@ -30394,6 +30635,12 @@ Object.freeze({
30394
30635
  addonId: null,
30395
30636
  access: "create"
30396
30637
  },
30638
+ "pipelineAnalytics.runReplayFrameProcessor": {
30639
+ capName: "pipeline-analytics",
30640
+ capScope: "device",
30641
+ addonId: null,
30642
+ access: "create"
30643
+ },
30397
30644
  "pipelineAnalytics.saveRetrainAnnotations": {
30398
30645
  capName: "pipeline-analytics",
30399
30646
  capScope: "device",
@@ -30526,6 +30773,12 @@ Object.freeze({
30526
30773
  addonId: null,
30527
30774
  access: "view"
30528
30775
  },
30776
+ "pipelineExecutor.getInferenceDeviceHealth": {
30777
+ capName: "pipeline-executor",
30778
+ capScope: "system",
30779
+ addonId: null,
30780
+ access: "view"
30781
+ },
30529
30782
  "pipelineExecutor.getOrchestratorConfigSchema": {
30530
30783
  capName: "pipeline-executor",
30531
30784
  capScope: "system",
@@ -30598,6 +30851,12 @@ Object.freeze({
30598
30851
  addonId: null,
30599
30852
  access: "view"
30600
30853
  },
30854
+ "pipelineExecutor.rearmInferenceDevice": {
30855
+ capName: "pipeline-executor",
30856
+ capScope: "system",
30857
+ addonId: null,
30858
+ access: "create"
30859
+ },
30601
30860
  "pipelineExecutor.runAudioTest": {
30602
30861
  capName: "pipeline-executor",
30603
30862
  capScope: "system",
@@ -33846,6 +34105,11 @@ Object.freeze({
33846
34105
  form: "single",
33847
34106
  optional: false
33848
34107
  }],
34108
+ "pipelineAnalytics.runReplayFrameProcessor": [{
34109
+ name: "deviceId",
34110
+ form: "single",
34111
+ optional: false
34112
+ }],
33849
34113
  "pipelineAnalytics.saveRetrainAnnotations": [{
33850
34114
  name: "deviceId",
33851
34115
  form: "single",
@@ -35682,6 +35946,38 @@ var ScryptedCatalogDriftSchema = object({
35682
35946
  ]),
35683
35947
  details: string().optional()
35684
35948
  });
35949
+ /**
35950
+ * Curated PUBLIC Frigate catalog entry (D214 addendum). Named + exported so
35951
+ * the UI's `listFrigateCatalog` result parses against the SAME schema this
35952
+ * action's output is declared with (see `modelStudioActions.listFrigateCatalog`
35953
+ * below) — one shape, not a hand-duplicated interface on the UI side.
35954
+ */
35955
+ var FrigateCatalogEntrySchema = object({
35956
+ id: string(),
35957
+ label: string(),
35958
+ format: _enum(MODEL_FORMATS),
35959
+ sizeMB: number(),
35960
+ inputSize: number(),
35961
+ notes: string()
35962
+ });
35963
+ /**
35964
+ * Frigate+ `/v1/model/list` entry (see `frigate-plus.ts`). `isBaseModel` is
35965
+ * the Base/Custom discriminator Frigate's own UI groups on. Named + exported
35966
+ * for the same reason as {@link FrigateCatalogEntrySchema}.
35967
+ */
35968
+ var FrigatePlusModelSchema = object({
35969
+ id: string(),
35970
+ name: string(),
35971
+ type: string(),
35972
+ isBaseModel: boolean(),
35973
+ baseModel: string(),
35974
+ supportedDetectors: array(string()).readonly(),
35975
+ trainDate: string(),
35976
+ hailoDevice: string().optional(),
35977
+ verifiedImages: number(),
35978
+ width: number().optional(),
35979
+ height: number().optional()
35980
+ });
35685
35981
  var modelStudioActions = defineCustomActions({
35686
35982
  registerCustomModel: customAction(CustomModelDescriptorSchema, object({ ok: literal(true) }), { kind: "mutation" }),
35687
35983
  removeCustomModel: customAction(object({ modelId: string() }), object({ removed: boolean() }), { kind: "mutation" }),
@@ -35730,14 +36026,7 @@ var modelStudioActions = defineCustomActions({
35730
36026
  * the hub's modelsDir and registers the descriptor with the public URL
35731
36027
  * (other nodes download on demand — no Distribute needed).
35732
36028
  */
35733
- listFrigateCatalog: customAction(_void(), array(object({
35734
- id: string(),
35735
- label: string(),
35736
- format: _enum(MODEL_FORMATS),
35737
- sizeMB: number(),
35738
- inputSize: number(),
35739
- notes: string()
35740
- })).readonly()),
36029
+ listFrigateCatalog: customAction(_void(), array(FrigateCatalogEntrySchema).readonly()),
35741
36030
  importFrigateCatalogModel: customAction(object({
35742
36031
  catalogId: string(),
35743
36032
  modelId: string().optional(),
@@ -35777,19 +36066,7 @@ var modelStudioActions = defineCustomActions({
35777
36066
  ok: boolean(),
35778
36067
  error: string().optional()
35779
36068
  }), { kind: "mutation" }),
35780
- frigatePlusListModels: customAction(_void(), array(object({
35781
- id: string(),
35782
- name: string(),
35783
- type: string(),
35784
- isBaseModel: boolean(),
35785
- baseModel: string(),
35786
- supportedDetectors: array(string()).readonly(),
35787
- trainDate: string(),
35788
- hailoDevice: string().optional(),
35789
- verifiedImages: number(),
35790
- width: number().optional(),
35791
- height: number().optional()
35792
- })).readonly()),
36069
+ frigatePlusListModels: customAction(_void(), array(FrigatePlusModelSchema).readonly()),
35793
36070
  importFrigatePlusModel: customAction(object({
35794
36071
  plusModelId: string(),
35795
36072
  modelId: string(),