@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
@@ -7285,7 +7285,7 @@ function method(input, output, options) {
7285
7285
  input,
7286
7286
  output,
7287
7287
  kind: options?.kind ?? "query",
7288
- auth: options?.auth ?? "protected",
7288
+ ...options?.auth !== void 0 ? { auth: options.auth } : {},
7289
7289
  ...options?.access !== void 0 ? { access: options.access } : {},
7290
7290
  ...options?.caller !== void 0 ? { caller: options.caller } : {},
7291
7291
  timeoutMs: options?.timeoutMs
@@ -7305,7 +7305,7 @@ function systemMethod(input, output, options) {
7305
7305
  }
7306
7306
  var StaticDirOutputSchema$1 = object({ staticDir: string() });
7307
7307
  var VersionOutputSchema$1 = object({ version: string() });
7308
- method(_void(), StaticDirOutputSchema$1), method(_void(), VersionOutputSchema$1);
7308
+ method(_void(), StaticDirOutputSchema$1, { auth: "admin" }), method(_void(), VersionOutputSchema$1, { auth: "admin" });
7309
7309
  var DeviceType = /* @__PURE__ */ function(DeviceType) {
7310
7310
  DeviceType["Camera"] = "camera";
7311
7311
  DeviceType["Hub"] = "hub";
@@ -7626,7 +7626,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
7626
7626
  }({});
7627
7627
  var StaticDirOutputSchema = object({ staticDir: string() });
7628
7628
  var VersionOutputSchema = object({ version: string() });
7629
- method(_void(), StaticDirOutputSchema), method(_void(), VersionOutputSchema);
7629
+ method(_void(), StaticDirOutputSchema, { auth: "admin" }), method(_void(), VersionOutputSchema, { auth: "admin" });
7630
7630
  /**
7631
7631
  * device-ops — device-scoped cap that unifies the per-IDevice operations
7632
7632
  * previously routed through the `.device-ops` Moleculer bridge service.
@@ -8240,24 +8240,6 @@ var RecordingRetentionSchema = object({
8240
8240
  maxSizeGb: number().min(0).optional()
8241
8241
  });
8242
8242
  /**
8243
- * Scrub-thumbnail fidelity preset — the single per-camera selector bundling the
8244
- * sprite tile RESOLUTION + JPEG QUALITY the recorder packs timeline-scrub
8245
- * previews at. Five graduated steps; absent on a config = `standard` (the
8246
- * shipped default, matching `sheet-geometry`/`sheet-composer`).
8247
- *
8248
- * Existing sheets are IMMUTABLE — a changed preset applies to NEW windows only.
8249
- * Each window's index sidecar carries its own tile dims, so a camera whose
8250
- * preset changed over time renders every historical window at the dims it was
8251
- * written with.
8252
- */
8253
- var ScrubThumbnailPresetSchema = _enum([
8254
- "minimal",
8255
- "low",
8256
- "standard",
8257
- "high",
8258
- "max"
8259
- ]);
8260
- /**
8261
8243
  * The full per-camera recording intent — the wire shape of a RecordingTarget.
8262
8244
  *
8263
8245
  * `bands` is the ONLY authored recording intent: what to record, when, and on
@@ -8265,7 +8247,11 @@ var ScrubThumbnailPresetSchema = _enum([
8265
8247
  * other field is a storage knob (profiles, segment length, retention, scrub).
8266
8248
  *
8267
8249
  * STRICT on purpose: the legacy authoring surface (`schedule`/`schedules`/
8268
- * `triggers`/`preBufferSec`/`postBufferSec`/`rules`) was retired 2026-07-30.
8250
+ * `triggers`/`preBufferSec`/`postBufferSec`/`rules`) was retired 2026-07-30,
8251
+ * and `scrubThumbnails` — a five-step fidelity knob for a sprite tier that was
8252
+ * deleted on 2026-07-24 and had ZERO consumers in the recorder — on 2026-08-25
8253
+ * (D62: a switch that writes a store nobody reads is worse than no switch).
8254
+ * Stored rows keep loading: the READ schema is `.strip()` (config-store.ts).
8269
8255
  * A stale caller must fail loudly — silently stripping its legacy intent would
8270
8256
  * persist a band-less config, i.e. silently stop recording the camera.
8271
8257
  */
@@ -8288,14 +8274,7 @@ var RecordingConfigSchema = object({
8288
8274
  * "off" is the absence of a covering band, never a band value.
8289
8275
  */
8290
8276
  bands: array(RecordingBandSchema).default([]),
8291
- retention: RecordingRetentionSchema.optional(),
8292
- /**
8293
- * Per-camera scrub-thumbnail fidelity preset (resolution + JPEG quality for
8294
- * timeline-scrub sprite previews). Absent = `standard`. Applies to NEW
8295
- * windows only — existing sheets are immutable, and each window's index
8296
- * carries its own tile dims so mixed-preset history renders correctly.
8297
- */
8298
- scrubThumbnails: ScrubThumbnailPresetSchema.optional()
8277
+ retention: RecordingRetentionSchema.optional()
8299
8278
  }).strict();
8300
8279
  /**
8301
8280
  * Entity-relocation job state (storage entity-routing spec, Phase 4).
@@ -8371,10 +8350,11 @@ var RelocateFootageInputSchema = object({
8371
8350
  * `RecordingConfig.enabled` or camera wrapper bindings. */
8372
8351
  var StorageMigrationLeaseInputSchema = object({ leaseId: string().min(1) });
8373
8352
  var StorageMigrationFootageMoveInputSchema = RelocateFootageInputSchema.extend({ leaseId: string().min(1) });
8374
- var StorageMigrationMediaMoveInputSchema = object({
8353
+ var RelocateMediaInputSchema = object({
8375
8354
  toLocationId: string(),
8376
8355
  throttleMbps: number().min(1).max(1e3).optional()
8377
- }).extend({ leaseId: string().min(1) });
8356
+ });
8357
+ var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
8378
8358
  /** The independently selectable logical storage classes. `recordings`
8379
8359
  * encompasses the high and mid segment profiles; `recordingsLow` is low
8380
8360
  * segments; `eventMedia` is post-analysis blobs. */
@@ -8669,7 +8649,26 @@ var LabelDefinitionSchema = object({
8669
8649
  description: string().optional(),
8670
8650
  icon: string().optional()
8671
8651
  });
8672
- var ClassMapDefinitionSchema = object({
8652
+ /**
8653
+ * Wire schema for a per-model CATALOG classMap override
8654
+ * (`ModelCatalogEntry.classMap` / `ModelConvertMetadata.classMap`) —
8655
+ * restricted to {@link CLASS_MAP_MACRO_TARGETS}, the only macros the
8656
+ * detection pipeline executor actually routes.
8657
+ *
8658
+ * This is deliberately a DIFFERENT, narrower shape than the general-purpose
8659
+ * `ClassMapDefinition` interface above (e.g. `IDetectionAddon.getClassMap()`
8660
+ * and the audio `YAMNET_TO_MACRO` catalog both use macro targets outside this
8661
+ * enum) — the two used to share the name `ClassMapDefinition`/
8662
+ * `ClassMapDefinitionSchema`, which made the schema-type-twin guard
8663
+ * (`scripts/check-schema-type-twins.ts`) flag them as a duplicated shape. They
8664
+ * are not: it is two different concepts colliding on a name. Keep this type
8665
+ * under its own name rather than reusing `ClassMapDefinition` — reusing it
8666
+ * would either narrow every `ClassMapDefinition` consumer to the four
8667
+ * detection macros (breaking `YAMNET_TO_MACRO`) or drop the validation this
8668
+ * schema exists for (see the "rejects a classMap whose target is not a
8669
+ * detection macro" test in `model-catalog-schema.test.ts`).
8670
+ */
8671
+ var DetectionCatalogClassMapSchema = object({
8673
8672
  mapping: record(string(), _enum([
8674
8673
  "person",
8675
8674
  "vehicle",
@@ -8874,7 +8873,7 @@ var ModelCatalogEntrySchema = object({
8874
8873
  * applies (Frigate / COCO public catalog). Set on a custom model whose raw
8875
8874
  * labels already ARE the CamStack macros (Scrypted identity map).
8876
8875
  */
8877
- classMap: ClassMapDefinitionSchema.optional()
8876
+ classMap: DetectionCatalogClassMapSchema.optional()
8878
8877
  });
8879
8878
  var ConvertTargetSchema = discriminatedUnion("format", [object({
8880
8879
  format: literal("openvino"),
@@ -8904,7 +8903,7 @@ var ModelConvertMetadataSchema = object({
8904
8903
  "segmentation"
8905
8904
  ]),
8906
8905
  faceAlignment: boolean().optional(),
8907
- classMap: ClassMapDefinitionSchema.optional()
8906
+ classMap: DetectionCatalogClassMapSchema.optional()
8908
8907
  });
8909
8908
  var ConvertArtifactSchema = object({
8910
8909
  format: _enum(MODEL_FORMATS),
@@ -9773,7 +9772,18 @@ var addonPagesSourceCapability = {
9773
9772
  scope: "system",
9774
9773
  mode: "collection",
9775
9774
  internal: true,
9776
- methods: { listPages: method(_void(), array(AddonPageDeclarationSchema).readonly()) }
9775
+ methods: {
9776
+ /**
9777
+ * `internal: true` did not gate the mount (see the 2026-08-26 note on
9778
+ * `data-store-provider`) — this was reachable on the AppRouter by ANY
9779
+ * authenticated session at the default `auth: 'protected'`. The only
9780
+ * consumer, the `addon-pages-aggregator` builtin, reads it via
9781
+ * `ctx.capabilities.getCollection('addon-pages-source')` — LOCAL-PROCESS
9782
+ * only, never tRPC (per `ctx.capabilities` seeing only the local
9783
+ * process). The public, enriched listing admin-ui actually consumes is
9784
+ * the separate `addon-pages` cap, unaffected by this change.
9785
+ */
9786
+ listPages: method(_void(), array(AddonPageDeclarationSchema).readonly(), { auth: "admin" }) }
9777
9787
  };
9778
9788
  var AddonHttpRouteSchema = object({
9779
9789
  method: _enum([
@@ -10009,7 +10019,7 @@ var WidgetMetadataSchema = object({
10009
10019
  defaultColumns: number().int().min(1).max(12).default(6),
10010
10020
  defaultRows: number().int().min(1).max(12).default(1)
10011
10021
  });
10012
- method(_void(), array(WidgetMetadataSchema).readonly());
10022
+ method(_void(), array(WidgetMetadataSchema).readonly(), { auth: "admin" });
10013
10023
  /**
10014
10024
  * `addon-widgets` — system-scoped singleton aggregator cap. Public-facing
10015
10025
  * surface that admin-ui consumes through `useAddonWidgetsListWidgets()`.
@@ -11558,7 +11568,17 @@ var customModelRegistryCapability = {
11558
11568
  scope: "system",
11559
11569
  mode: "collection",
11560
11570
  internal: true,
11561
- methods: { listModels: method(_void(), array(CustomModelDescriptorSchema).readonly()) }
11571
+ methods: {
11572
+ /**
11573
+ * `internal: true` did not gate the mount (see the 2026-08-26 note on
11574
+ * `data-store-provider`) — this was reachable on the AppRouter by ANY
11575
+ * authenticated session at the default `auth: 'protected'`. The only
11576
+ * consumer, the detection-pipeline's model resolution
11577
+ * (`addon-pipeline/src/detection-pipeline/provider.ts`), calls
11578
+ * `ctx.api.customModelRegistry.listModels.query()` — UDS/Moleculer,
11579
+ * never tRPC — so `auth: 'admin'` costs it nothing.
11580
+ */
11581
+ listModels: method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" }) }
11562
11582
  };
11563
11583
  /**
11564
11584
  * Query filter for settings-store collections.
@@ -11646,7 +11666,8 @@ method(object({
11646
11666
  }), _void(), { kind: "mutation" }), method(object({
11647
11667
  namespace: string().optional(),
11648
11668
  collection: string(),
11649
- filter: QueryFilterSchema.optional()
11669
+ filter: QueryFilterSchema.optional(),
11670
+ columns: array(string()).readonly().optional()
11650
11671
  }), array(SettingsRecordSchema).readonly()), method(object({
11651
11672
  namespace: string().optional(),
11652
11673
  collection: string(),
@@ -11709,46 +11730,87 @@ var EngineInfoSchema = object({
11709
11730
  kind: _enum(["relational", "vector"]),
11710
11731
  displayName: string()
11711
11732
  });
11712
- method(_void(), EngineInfoSchema), method(object({
11733
+ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
11713
11734
  namespace: string().optional(),
11714
11735
  collection: string(),
11715
11736
  key: string()
11716
- }), unknown()), method(object({
11737
+ }), unknown(), { auth: "admin" }), method(object({
11717
11738
  namespace: string().optional(),
11718
11739
  collection: string(),
11719
11740
  key: string(),
11720
11741
  value: unknown()
11721
- }), _void(), { kind: "mutation" }), method(object({
11742
+ }), _void(), {
11743
+ kind: "mutation",
11744
+ auth: "admin"
11745
+ }), method(object({
11722
11746
  namespace: string().optional(),
11723
11747
  collection: string(),
11724
- filter: QueryFilterSchema.optional()
11725
- }), array(SettingsRecordSchema).readonly()), method(object({
11748
+ filter: QueryFilterSchema.optional(),
11749
+ /**
11750
+ * SQL-level column projection — MUST mirror `settings-store.query`.
11751
+ *
11752
+ * ⚠ An earlier version of this comment blamed Zod stripping, and that
11753
+ * was wrong — corrected 2026-08-26 after the hop map
11754
+ * (`docs/design/2026-08-26-mappa-hop-argomenti.md`) traced the path.
11755
+ * There is **no Zod parse at all** between the door and the engine: the
11756
+ * dispatcher forwards the payload verbatim and UDS carries it whole. A
11757
+ * field declared here reaches `SqliteSettingsBackend` either way.
11758
+ *
11759
+ * What actually lost `columns` was the THIRD declaration of this shape:
11760
+ * `SettingsQueryInput` in `interfaces/storage.ts`, a hand-written TS
11761
+ * interface the engine destructures from. The field existed on both
11762
+ * schemas and the engine still never read it, because nothing checks a
11763
+ * registered provider against `InferProvider<cap>` —
11764
+ * `ProviderRegistration.provider` is typed `object`.
11765
+ *
11766
+ * It is declared here anyway, and must stay in step with
11767
+ * `settings-store.query`: a caller reading only the cap definitions has
11768
+ * to be able to see that this call carries a projection.
11769
+ * `data-door-schema-parity.spec.ts` keeps the two aligned.
11770
+ */
11771
+ columns: array(string()).readonly().optional()
11772
+ }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
11726
11773
  namespace: string().optional(),
11727
11774
  collection: string(),
11728
11775
  record: SettingsRecordSchema
11729
- }), _void(), { kind: "mutation" }), method(object({
11776
+ }), _void(), {
11777
+ kind: "mutation",
11778
+ auth: "admin"
11779
+ }), method(object({
11730
11780
  namespace: string().optional(),
11731
11781
  collection: string(),
11732
11782
  id: string(),
11733
11783
  data: record(string(), unknown())
11734
- }), _void(), { kind: "mutation" }), method(object({
11784
+ }), _void(), {
11785
+ kind: "mutation",
11786
+ auth: "admin"
11787
+ }), method(object({
11735
11788
  namespace: string().optional(),
11736
11789
  collection: string(),
11737
11790
  key: string()
11738
- }), _void(), { kind: "mutation" }), method(object({
11791
+ }), _void(), {
11792
+ kind: "mutation",
11793
+ auth: "admin"
11794
+ }), method(object({
11739
11795
  namespace: string().optional(),
11740
11796
  collection: string(),
11741
11797
  filter: MutationFilterSchema
11742
- }), object({ deleted: number().int() }), { kind: "mutation" }), method(object({
11798
+ }), object({ deleted: number().int() }), {
11799
+ kind: "mutation",
11800
+ auth: "admin"
11801
+ }), method(object({
11743
11802
  namespace: string().optional(),
11744
11803
  collection: string(),
11745
11804
  filter: MutationFilterSchema,
11746
11805
  data: record(string(), unknown())
11747
- }), object({ updated: number().int() }), { kind: "mutation" }), method(object({
11806
+ }), object({ updated: number().int() }), {
11807
+ kind: "mutation",
11808
+ auth: "admin"
11809
+ }), method(object({
11748
11810
  namespace: string().optional(),
11749
11811
  collection: string(),
11750
11812
  filter: QueryFilterSchema.optional()
11751
- }), number()), method(object({
11813
+ }), number(), { auth: "admin" }), method(object({
11752
11814
  namespace: string().optional(),
11753
11815
  collection: string(),
11754
11816
  field: string(),
@@ -11758,15 +11820,18 @@ method(_void(), EngineInfoSchema), method(object({
11758
11820
  }), array(object({
11759
11821
  bucket: number().int(),
11760
11822
  count: number().int()
11761
- })).readonly()), method(object({
11823
+ })).readonly(), { auth: "admin" }), method(object({
11762
11824
  namespace: string().optional(),
11763
11825
  collection: string()
11764
- }), boolean()), method(object({
11826
+ }), boolean(), { auth: "admin" }), method(object({
11765
11827
  namespace: string().optional(),
11766
11828
  collection: string(),
11767
11829
  columns: array(CollectionColumnSchema).readonly(),
11768
11830
  indexes: array(CollectionIndexSchema).readonly().optional()
11769
- }), _void(), { kind: "mutation" });
11831
+ }), _void(), {
11832
+ kind: "mutation",
11833
+ auth: "admin"
11834
+ });
11770
11835
  /**
11771
11836
  * shm ring usage stats for a `frameSink: 'shm'` decoder session —
11772
11837
  * exposed via `decoder.getShmStats` so downstream consumers can
@@ -12894,7 +12959,7 @@ method(object({
12894
12959
  crop: _instanceof(Uint8Array),
12895
12960
  width: number(),
12896
12961
  height: number()
12897
- }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
12962
+ }), EmbeddingResultSchema, { auth: "admin" }), method(object({ text: string() }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" });
12898
12963
  /**
12899
12964
  * filesystem-browse — per-node capability for browsing the node's local
12900
12965
  * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
@@ -13187,19 +13252,22 @@ method(LlmGenerateBaseInputSchema.extend({
13187
13252
  runtime: ManagedRuntimeConfigSchema,
13188
13253
  /** The managed profile's timeout, threaded by the hub provider. */
13189
13254
  timeoutMs: number().int().positive().optional()
13190
- }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
13255
+ }), LlmGenerateResultSchema, {
13256
+ kind: "mutation",
13257
+ auth: "admin"
13258
+ }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
13191
13259
  kind: "mutation",
13192
13260
  auth: "admin"
13193
13261
  }), method(object({}), _void(), {
13194
13262
  kind: "mutation",
13195
13263
  auth: "admin"
13196
- }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
13264
+ }), method(object({}), LlmRuntimeStatusSchema, { auth: "admin" }), method(object({ model: ManagedModelRefSchema }), _void(), {
13197
13265
  kind: "mutation",
13198
13266
  auth: "admin"
13199
13267
  }), method(object({ file: string() }), _void(), {
13200
13268
  kind: "mutation",
13201
13269
  auth: "admin"
13202
- }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
13270
+ }), method(object({}), array(LlmNodeModelSchema), { auth: "admin" }), method(object({}), LlmRuntimeDiskUsageSchema, { auth: "admin" });
13203
13271
  /**
13204
13272
  * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
13205
13273
  * methods concat-fan across providers; single-row methods route to ONE
@@ -16678,1832 +16746,1982 @@ var OauthIntegrationDescriptorSchema = object({
16678
16746
  */
16679
16747
  refreshTokenTtlSec: union([number().int().positive(), literal("never")]).optional()
16680
16748
  });
16681
- method(_void(), OauthIntegrationDescriptorSchema);
16749
+ method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
16682
16750
  /**
16683
- * pipeline-analytics device-scoped wrapper cap. Refines raw
16684
- * per-frame detections emitted by the pipeline runner into tracked
16685
- * objects, per-kind event collections (motion / object / audio), and
16686
- * persisted media. Owns the post-detection domain end-to-end:
16687
- *
16688
- * runner emits PipelineInferenceResult
16689
- * ↓ (event bus)
16690
- * pipeline-analytics subscriber
16691
- * ↓ SORT tracker + zone engine + state analyzer + event emitter
16692
- * → three DB collections (one per kind), one FS media tree, one
16693
- * unified event emitter (FrameTracked + TrackStarted/Ended +
16694
- * DetectionEvent on bus)
16695
- *
16696
- * Pure subscriber model. No `processFrame` cap method — the runner
16697
- * already publishes the raw frame on the bus. The cap surface is
16698
- * only QUERIES + per-device settings, bound on/off via
16699
- * `device-manager.setWrapperActive`. `defaultActive: true` because
16700
- * every camera with a detection pipeline wants its raw detections
16701
- * refined; operators opt out per-device via BindingsTab when needed.
16702
- *
16703
- * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
16704
- * (per-device surface) and `track-trail` caps — see P11 cleanup.
16751
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
16752
+ * within the frame, so the executor can re-cut a leaf child ROI at native
16753
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
16705
16754
  */
16706
- var TrackStateSchema = _enum([
16707
- "new",
16708
- "entered",
16709
- "left",
16710
- "moving",
16711
- "idle"
16712
- ]);
16713
- var EventKindSchema = _enum([
16714
- "motion",
16715
- "object",
16716
- "audio"
16717
- ]);
16755
+ var NativeCropRefSchema = object({
16756
+ /** Handle keying the retained native surface (node-pinned to its owner). */
16757
+ handle: FrameHandleSchema,
16758
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
16759
+ cropFrameSpace: object({
16760
+ x: number(),
16761
+ y: number(),
16762
+ w: number(),
16763
+ h: number()
16764
+ })
16765
+ });
16766
+ object({
16767
+ crop: object({
16768
+ left: number(),
16769
+ top: number(),
16770
+ width: number().positive(),
16771
+ height: number().positive()
16772
+ }).optional(),
16773
+ content: object({
16774
+ width: number().int().positive(),
16775
+ height: number().int().positive()
16776
+ }),
16777
+ fit: _enum(["stretch", "contain"]),
16778
+ format: _enum([
16779
+ "rgb",
16780
+ "gray",
16781
+ "jpeg"
16782
+ ])
16783
+ });
16718
16784
  /**
16719
- * Spatial filter for `listTracks` the rect + polygon variants of the shared
16720
- * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
16721
- * of the camera frame (top-left origin), matching the drawing-plane editor.
16785
+ * Process-local frame identity. It is serializable so it can ride an in-process
16786
+ * capability call, but `registryId` deliberately prevents resolution in any
16787
+ * other process or execution group.
16722
16788
  */
16723
- var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
16724
- /** Closed icon vocabulary so clients render a known glyph per kind. */
16725
- var EventKindIconSchema = _enum([
16726
- "motion",
16727
- "audio",
16728
- "person",
16729
- "vehicle",
16730
- "animal",
16731
- "door",
16732
- "pir",
16733
- "smoke",
16734
- "water",
16735
- "button",
16736
- "package",
16737
- "generic"
16789
+ var FrameRefSchema = object({
16790
+ registryId: string().min(1),
16791
+ id: string().min(1),
16792
+ width: number().int().positive(),
16793
+ height: number().int().positive(),
16794
+ format: _enum(["rgb", "gray"]),
16795
+ timestamp: number(),
16796
+ capturedAt: number().optional()
16797
+ });
16798
+ var ModelFormatSchema$1 = _enum([
16799
+ "onnx",
16800
+ "coreml",
16801
+ "openvino",
16802
+ "tflite",
16803
+ "pt",
16804
+ "gguf"
16738
16805
  ]);
16739
- var EventKindCategorySchema = _enum([
16740
- "motion",
16741
- "audio",
16742
- "detection",
16743
- "sensor",
16744
- "control",
16745
- "custom",
16746
- "package"
16806
+ var PipelineSlotSchema = _enum([
16807
+ "detector",
16808
+ "cropper",
16809
+ "classifier",
16810
+ "refiner",
16811
+ "audio-classifier"
16747
16812
  ]);
16748
- /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
16749
- var EventKindLevelSchema = _enum(["macro", "sub"]);
16750
- var EventKindDescriptorSchema = object({
16751
- /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
16752
- kind: string(),
16753
- /** i18n key resolved on the UI side; `label` is the English fallback. */
16754
- labelKey: string(),
16755
- /** English fallback label (kept for clients that don't translate). */
16756
- label: string(),
16757
- /** Hex color for timeline/legend rendering. */
16758
- color: string(),
16759
- /** Dictionary id → lucide component on the UI side. */
16760
- iconId: string(),
16761
- /** Legacy closed-vocab glyph — fallback for `iconId`. */
16762
- icon: EventKindIconSchema,
16763
- category: EventKindCategorySchema,
16764
- /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
16765
- parentKind: string().nullable(),
16766
- /** Derived from `parentKind`, explicit for the client tree. */
16767
- level: EventKindLevelSchema,
16768
- /** Which cap + device contributes this kind. For built-ins the camera
16769
- * itself; for sensor kinds the LINKED source device. */
16770
- source: object({
16771
- capName: string(),
16772
- deviceId: number()
16773
- })
16813
+ var PipelineEngineChoiceSchema = object({
16814
+ runtime: _enum(["node", "python"]),
16815
+ backend: string(),
16816
+ format: ModelFormatSchema$1,
16817
+ device: string().optional()
16774
16818
  });
16775
- /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
16776
- var EventKindsForDeviceSchema = object({
16777
- deviceId: number(),
16778
- kinds: array(EventKindDescriptorSchema).readonly()
16819
+ var AvailableEngineSchema = object({
16820
+ engine: PipelineEngineChoiceSchema,
16821
+ devices: array(object({
16822
+ id: string(),
16823
+ label: string(),
16824
+ description: string().optional()
16825
+ })).readonly(),
16826
+ defaultDevice: string()
16779
16827
  });
16780
- var SensorEventSchema = object({
16828
+ var PipelineDefaultStepSchema = lazy(() => object({
16829
+ addonId: string(),
16830
+ addonName: string(),
16831
+ slot: PipelineSlotSchema,
16832
+ inputClasses: array(string()).readonly(),
16833
+ outputClasses: array(string()).readonly(),
16834
+ enabled: boolean(),
16835
+ modelId: string(),
16836
+ children: array(PipelineDefaultStepSchema).readonly(),
16837
+ group: string().optional(),
16838
+ settings: record(string(), unknown()).optional()
16839
+ }));
16840
+ var PipelineTemplateStepSchema = lazy(() => object({
16841
+ addonId: string(),
16842
+ enabled: boolean(),
16843
+ modelId: string(),
16844
+ children: array(PipelineTemplateStepSchema).readonly(),
16845
+ settings: record(string(), unknown()).optional()
16846
+ }));
16847
+ var PipelineTemplateSchema$1 = object({
16781
16848
  id: string(),
16782
- /** The CAMERA the event is attributed to (a sensor linked to N cameras
16783
- * yields N rows, one per camera). */
16784
- deviceId: number(),
16785
- /** The linked sensor device whose state changed. */
16786
- sourceDeviceId: number(),
16787
- /** Event kind id — matches an `EventKindDescriptor.kind`. */
16788
- kind: string(),
16789
- /** Snapshot of the sensor cap's runtime-state slice at the change. */
16790
- value: record(string(), unknown()).nullable(),
16791
- timestamp: number()
16849
+ name: string(),
16850
+ createdAt: string(),
16851
+ updatedAt: string(),
16852
+ engine: PipelineEngineChoiceSchema,
16853
+ steps: array(PipelineTemplateStepSchema).readonly()
16792
16854
  });
16793
- var TrackPositionSchema = object({
16794
- x: number(),
16795
- y: number(),
16796
- timestamp: number(),
16797
- bbox: BoundingBoxSchema
16798
- });
16799
- var TrackSnapshotSchema = object({
16800
- timestamp: number(),
16801
- position: TrackPositionSchema,
16802
- /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
16803
- mediaKey: string()
16855
+ var PipelineModelOptionSchema = object({
16856
+ id: string(),
16857
+ name: string(),
16858
+ formats: record(string(), object({
16859
+ downloaded: boolean(),
16860
+ sizeMB: number()
16861
+ })),
16862
+ group: ModelVariantGroupSchema.optional(),
16863
+ legacy: boolean().optional(),
16864
+ provider: ModelProviderIdSchema.optional()
16804
16865
  });
16805
- /**
16806
- * Normalized 0..1 trajectory envelope (min/max over every position bbox,
16807
- * divided by the track's detection-frame dims), computed at persist time.
16808
- * Absent when the frame dims were unknown when the track was persisted
16809
- * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
16810
- */
16811
- var TrackEnvelopeSchema = object({
16812
- minX: number(),
16813
- minY: number(),
16814
- maxX: number(),
16815
- maxY: number()
16866
+ var ConfigFieldBridge = custom();
16867
+ var PipelineAddonSchemaSchema = object({
16868
+ id: string(),
16869
+ name: string(),
16870
+ slot: PipelineSlotSchema,
16871
+ inputClasses: array(string()).readonly(),
16872
+ outputClasses: array(string()).readonly(),
16873
+ childSlots: array(PipelineSlotSchema).readonly(),
16874
+ models: array(PipelineModelOptionSchema).readonly(),
16875
+ defaultModelId: string(),
16876
+ defaultModelIdByFormat: record(string(), string()).optional(),
16877
+ enabledByDefault: boolean().optional(),
16878
+ backfillIntoExistingOverrides: boolean().optional(),
16879
+ defaultConfidence: number(),
16880
+ group: string().optional(),
16881
+ configSchema: array(ConfigFieldBridge).readonly().optional()
16816
16882
  });
16817
- /**
16818
- * Row projection for track list queries. `full` (default) returns the
16819
- * complete Track including the frame-rate `positions[]` history and the
16820
- * `snapshots[]` references — megabytes across a page of tracks. `slim`
16821
- * keeps every scalar the list surfaces actually render (ids, class(es),
16822
- * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
16823
- * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
16824
- * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
16825
- * `getTrack`. Mirrors the event-store `projection` convention
16826
- * (`getObjectEvents` et al.).
16827
- */
16828
- var TrackProjectionSchema = _enum(["full", "slim"]);
16829
- /**
16830
- * One audio-classification label heard on the track's camera while the
16831
- * track was alive, aggregated per label. An "episode" is one persisted
16832
- * audio event (the confident-classification path: score ≥ the device's
16833
- * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
16834
- * one 32 ms inference chunk, so counts stay human-scaled.
16835
- */
16836
- var TrackAudioLabelSchema = object({
16883
+ var PipelineSlotSchemaSchema = object({
16884
+ id: PipelineSlotSchema,
16837
16885
  label: string(),
16838
- /** Highest classification score observed across the label's episodes. */
16839
- peakScore: number(),
16840
- /** Number of coalesced audio-event episodes carrying this label. */
16841
- count: number(),
16842
- firstAt: number(),
16843
- lastAt: number()
16886
+ priority: number(),
16887
+ parentSlot: PipelineSlotSchema.nullable(),
16888
+ addons: array(PipelineAddonSchemaSchema).readonly()
16844
16889
  });
16845
- /**
16846
- * How a track was produced. `pipeline` (default / absent) = the spatial
16847
- * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
16848
- * no positions, a single snapshot, and no bbox trajectory at all:
16849
- *
16850
- * - `sensor` — a linked sensor/control device state change.
16851
- * - `audio` — an audio event on the camera itself that was anomalous for
16852
- * THAT camera, loud, and heard while nothing visual was happening (D62).
16853
- *
16854
- * The spatial subsystems (tracker association, occupancy count, re-id /
16855
- * embedding, resurrection) MUST skip every synthetic source. Test for that
16856
- * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
16857
- * check silently readmits every source added after it was written.
16858
- */
16859
- var TrackSourceSchema = _enum([
16860
- "pipeline",
16861
- "sensor",
16862
- "audio"
16863
- ]);
16864
- /**
16865
- * Where a track sits in the RETRAIN lifecycle (D81).
16866
- *
16867
- * - `none` — never marked, or un-marked. Evictable.
16868
- * - `staging` — the operator wants this track as training material and has not
16869
- * finished with it. **This is the only state retention holds**: the track and
16870
- * everything it owns (object events, crops, keyframes, CLIP vector) survive
16871
- * the device's age window.
16872
- * - `trained` — the retrain page has taken what it needed. The frames it chose
16873
- * were COPIED into the retrain dataset at selection time, so the dataset no
16874
- * longer depends on the track's media and the track becomes EVICTABLE again.
16875
- * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
16876
- * a deliberate action of the retrain page, not a side effect of a checkbox.
16877
- *
16878
- * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
16879
- * the store's filter language has only positive equality and `whereIn` — no
16880
- * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
16881
- * would make the entire pre-column history immortal in one deploy.
16882
- */
16883
- var RetrainStatusSchema = _enum([
16884
- "none",
16885
- "staging",
16886
- "trained"
16887
- ]);
16888
- /**
16889
- * Per-track OPERATOR flags — set by hand from the admin UI or the viewer, never
16890
- * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
16891
- * so the two surfaces cannot drift.
16892
- *
16893
- * **Absent ≠ false.** A track that has never been touched omits the field; an
16894
- * explicitly un-flagged track carries `false`. Legacy rows written before the
16895
- * columns existed read as absent, and a consumer that needs a boolean should say
16896
- * `flag === true`, not `flag !== false`.
16897
- *
16898
- * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
16899
- * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
16900
- * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
16901
- * `trained` track reports `false` while refusing both writes. The boolean is
16902
- * kept because three surfaces drive a toggle off it; anything that needs to tell
16903
- * "never marked" from "already trained" must read `retrainStatus`.
16904
- *
16905
- * `debug` does NOT pin; it is attention, not durability.
16906
- *
16907
- * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
16908
- * A favourited track is skipped by retention the same way `staging` is, but
16909
- * it does not enter `none|staging|trained` and has no staging budget.
16910
- */
16911
- var TrackFlagFields = {
16912
- /** Operator marked this track as training material — i.e. `retrainStatus` is
16913
- * `'staging'`. */
16914
- markForTrain: boolean().optional(),
16915
- /** Operator marked this track for diagnostic attention. */
16916
- debug: boolean().optional(),
16917
- /** Operator favourited this track. Pins it against pruning. */
16918
- favourited: boolean().optional()
16919
- };
16920
- /**
16921
- * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
16922
- * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
16923
- * write patch, and the status is not something the toggle sets — it is what the
16924
- * toggle's boolean is derived from. Absent on an in-RAM track never touched;
16925
- * always present on a persisted row (the column default materialises `'none'`).
16926
- */
16927
- var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
16928
- /**
16929
- * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
16930
- * one flag can never clear the other — the toggles are independent and are
16931
- * driven from three surfaces that do not know about each other.
16932
- */
16933
- var TrackFlagsPatchSchema = object(TrackFlagFields);
16934
- /**
16935
- * The resolved flag state after a write. Both fields are REQUIRED here (absent
16936
- * collapses to `false`) so a caller can drive a toggle's checked state off the
16937
- * mutation result without a re-fetch.
16938
- */
16939
- var TrackFlagsSchema = object({
16940
- trackId: string(),
16941
- markForTrain: boolean(),
16942
- debug: boolean(),
16943
- favourited: boolean(),
16944
- /** The lifecycle state the boolean was derived from. Required here (unlike on
16945
- * a track row) because this shape is only ever produced by the write body,
16946
- * which always knows it — and a surface that has just written needs to render
16947
- * `trained` without a re-fetch. */
16948
- retrainStatus: RetrainStatusSchema
16890
+ var PipelineSchemaSchema = object({
16891
+ availableEngines: array(AvailableEngineSchema).readonly(),
16892
+ selectedEngine: PipelineEngineChoiceSchema,
16893
+ slots: array(PipelineSlotSchemaSchema).readonly()
16949
16894
  });
16950
- union([literal(1), literal(2)]);
16951
- /**
16952
- * WHO decided a label, and when. Carried per tier so a value can be traced to
16953
- * the step and model that produced it — which is what makes the write rule
16954
- * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
16955
- * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
16956
- *
16957
- * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
16958
- * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
16959
- * `migration:4g` for a value the 4g migration moved from the single-slot era —
16960
- * that value has no provenance, and the write rule lets ANY properly-attributed
16961
- * write of the same tier replace it regardless of score.
16962
- */
16963
- var LabelAttributionSchema = object({
16964
- stepId: string(),
16965
- modelId: string().optional(),
16966
- decidedAt: number(),
16895
+ var EngineProvisioningSchema = object({
16896
+ runtimeId: _enum([
16897
+ "onnx",
16898
+ "openvino",
16899
+ "coreml",
16900
+ "edgetpu"
16901
+ ]).nullable(),
16902
+ device: string().nullable(),
16903
+ state: _enum([
16904
+ "idle",
16905
+ "installing",
16906
+ "verifying",
16907
+ "ready",
16908
+ "failed"
16909
+ ]),
16910
+ progress: number().optional(),
16911
+ error: string().optional(),
16912
+ nextRetryAt: number().optional(),
16967
16913
  /**
16968
- * The GALLERY id behind a recognised tier-2 label — a face-gallery
16969
- * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
16970
- *
16971
- * The text alone is a DISPLAY NAME, and a display name is renameable: a
16972
- * notification rule authored on "Gianluca" stopped matching the moment the
16973
- * operator fixed the spelling in the gallery, and nothing said so. The id is
16974
- * the thing that does not move, so it is what a rule matches on
16975
- * (`NcConditions.identities`) and the text is what a human is shown.
16976
- *
16977
- * Absent when the label names no gallery row — a plate the OCR read but no
16978
- * vehicle claims, a sub-class, a species, any tier-1 value.
16914
+ * Gate A (config-correctness gate at engine change): human-readable
16915
+ * config issues surfaced EAGERLY when the node's engine changes — model
16916
+ * substitutions ("chose X, running Y") and zero-build steps ("no model
16917
+ * has a <format> build"). Additive/optional: informational only, never
16918
+ * enforced here `assertEngineReady` (readiness) still gates inference.
16919
+ * Absent/empty when the node-default tree resolves cleanly.
16979
16920
  */
16980
- identityId: string().optional()
16921
+ configIssues: array(string()).optional()
16981
16922
  });
16982
- /**
16983
- * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
16984
- * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
16985
- * track and its events always answer the same question the same way.
16986
- *
16987
- * Two scalar columns, not an array: every consumer wants "the coarse one" or
16988
- * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
16989
- * is tier 2, and each carries its own score + attribution.
16990
- *
16991
- * **Reading it.** What a human should be shown is `subLabel ?? label` — the
16992
- * finest thing known. Before 4g the single `label` column held the finest
16993
- * value, so a consumer that has not been updated reads the tier-1 slot and
16994
- * shows nothing on a species-only row; that is why the migration puts every
16995
- * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
16996
- * and why the read surfaces were changed in the same train.
16997
- *
16998
- * **Writing it.** The slots are independent, which is the whole point: a
16999
- * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
17000
- * migratorius`), so fineness cannot regress by construction. Within a tier the
17001
- * higher score wins. One rule, one implementation — see
17002
- * `pipeline/label-tier.ts` in addon-post-analysis.
17003
- */
17004
- var TieredLabelFields = {
17005
- /** Tier 1 the sub-class. See {@link LabelTierSchema}. */
17006
- label: string().optional(),
17007
- /** Confidence of the tier-1 value, as reported by the deciding step. */
17008
- labelScore: number().optional(),
17009
- /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
17010
- labelMeta: LabelAttributionSchema.optional(),
17011
- /** Tier 2 — the instance. See {@link LabelTierSchema}. */
17012
- subLabel: string().optional(),
17013
- /** Confidence of the tier-2 value, as reported by the deciding step. */
17014
- subLabelScore: number().optional(),
17015
- /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
17016
- subLabelMeta: LabelAttributionSchema.optional()
17017
- };
17018
- /** Per-camera slice of a training-export estimate. */
17019
- var TrainingExportDeviceTotalsSchema = object({
17020
- deviceId: number(),
17021
- tracks: number().int(),
17022
- files: number().int(),
17023
- bytes: number().int()
16923
+ var PipelineStepInputSchema = lazy(() => object({
16924
+ addonId: string(),
16925
+ modelId: string().optional(),
16926
+ enabled: boolean().default(true),
16927
+ children: array(PipelineStepInputSchema).optional(),
16928
+ settings: record(string(), unknown()).optional(),
16929
+ jumpDeviceKey: string().optional()
16930
+ }));
16931
+ var ModelSubstitutionSchema = object({
16932
+ addonId: string(),
16933
+ chosen: string(),
16934
+ running: string(),
16935
+ format: string()
16936
+ });
16937
+ var PipelineValidationIssueSchema = object({
16938
+ addonId: string(),
16939
+ kind: _enum(["unknown-addon", "no-format-build"]),
16940
+ detail: string()
16941
+ });
16942
+ var PipelineValidationResultSchema = object({
16943
+ ok: boolean(),
16944
+ issues: array(PipelineValidationIssueSchema).readonly(),
16945
+ substitutions: array(ModelSubstitutionSchema).readonly(),
16946
+ /** The node's `currentEngine.format` this validation ran against. */
16947
+ format: string()
16948
+ });
16949
+ var ReferenceImageEntrySchema = object({
16950
+ filename: string(),
16951
+ stepIds: array(string()).readonly().optional()
16952
+ });
16953
+ var ReferenceImageBodySchema = object({
16954
+ base64: string(),
16955
+ filename: string()
16956
+ });
16957
+ var ReferenceAudioEntrySchema = object({
16958
+ filename: string(),
16959
+ sizeKb: number()
16960
+ });
16961
+ var ReferenceAudioBodySchema = object({ base64: string() });
16962
+ var AudioBackendSchema = object({
16963
+ id: string(),
16964
+ name: string(),
16965
+ description: string(),
16966
+ available: boolean(),
16967
+ /**
16968
+ * Raw classifier labels this backend can emit (e.g. YAMNet's
16969
+ * 521-class set or Apple SoundAnalysis's 303-class set). Used by
16970
+ * the benchmark UI to populate the `enabledMicroClasses` filter
16971
+ * specific to the selected backend without a separate fetch.
16972
+ */
16973
+ rawLabels: array(string()).readonly().optional()
16974
+ });
16975
+ var AudioCapabilitiesSchema = object({
16976
+ activeBackend: string(),
16977
+ availableBackends: array(AudioBackendSchema).readonly(),
16978
+ sampleRate: number(),
16979
+ chunkDurationMs: number()
16980
+ });
16981
+ var DownloadModelResultSchema = object({
16982
+ filePath: string(),
16983
+ sizeMB: number(),
16984
+ durationMs: number()
17024
16985
  });
17025
16986
  /**
17026
- * What a training export WOULD contain. Computed from media index rows only —
17027
- * no blob is read to produce this.
16987
+ * Wrapper carrying a single test run's result. Replaces the legacy
16988
+ * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
16989
+ * canonical `AudioResult` from the Phase 6 output rework: one
16990
+ * `AudioDetection` per class above `minScore`, top-N candidates in
16991
+ * `debug.alternateLabels['audio-classifier']`, per-source timings in
16992
+ * `debug.stepTimings`. The outer `success`/`error` fields stay so the
16993
+ * benchmark UI can still report a clean failure when the classifier
16994
+ * cap isn't available.
17028
16995
  */
17029
- var TrainingExportSummarySchema = object({
17030
- generatedAt: number(),
17031
- trackCount: number().int(),
17032
- fileCount: number().int(),
17033
- byteCount: number().int(),
17034
- /** More marked tracks exist than a single pass carries. */
17035
- truncated: boolean(),
17036
- devices: array(TrainingExportDeviceTotalsSchema).readonly()
16996
+ var AudioTestResultSchema = object({
16997
+ success: boolean(),
16998
+ error: string().optional(),
16999
+ frame: custom().optional()
17037
17000
  });
17038
- var TrackSchema = object({
17039
- trackId: string(),
17040
- deviceId: number(),
17041
- className: string(),
17042
- ...TieredLabelFields,
17043
- producingDeviceName: string().optional(),
17044
- /** Track provenance. Absent `pipeline` (legacy rows). */
17045
- source: TrackSourceSchema.optional(),
17046
- firstSeen: number(),
17047
- lastSeen: number(),
17048
- /** Frame-rate position history (subject to maxPositionHistory cap). */
17049
- positions: array(TrackPositionSchema).readonly(),
17050
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
17051
- * saveThumbnails policy). */
17052
- snapshots: array(TrackSnapshotSchema).readonly(),
17053
- /** Deduplicated zones the track has entered at least once. Zone IDS. */
17054
- zonesVisited: array(string()).readonly(),
17001
+ var PipelineConfigBridge = custom();
17002
+ var ConfigUISchemaBridge = custom();
17003
+ var ConfigUISchemaNullableBridge = custom();
17004
+ var InferenceCapabilitiesBridge = custom();
17005
+ var ModelAvailabilityListBridge = custom();
17006
+ var PipelineRunResultBridge = custom();
17007
+ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
17008
+ modelId: string(),
17009
+ settings: record(string(), unknown()).readonly()
17010
+ }))), method(object({ steps: record(string(), object({
17011
+ modelId: string(),
17012
+ settings: record(string(), unknown()).readonly()
17013
+ })) }), object({ success: literal(true) }), {
17014
+ kind: "mutation",
17015
+ auth: "admin"
17016
+ }), method(object({ nodeId: string() }), object({
17017
+ success: literal(true),
17018
+ clearedDevices: number()
17019
+ }), {
17020
+ kind: "mutation",
17021
+ auth: "admin"
17022
+ }), method(object({ nodeId: string() }), object({ unhealthy: array(object({
17023
+ /** `<backend>:<device>`, e.g. `openvino:gpu`. */
17024
+ deviceKey: string(),
17055
17025
  /**
17056
- * Human NAMES for {@link zonesVisited}, resolved at READ time against the
17057
- * `zones` capability.
17058
- *
17059
- * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
17060
- * and no card can render — so every free-text search surface was structurally
17061
- * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
17062
- * just returned nothing. Resolving here rather than in each client keeps ONE
17063
- * derivation and costs the clients no extra call (the `zones` cap is
17064
- * per-device, so a client-side resolve would be a per-camera fan-out on a
17065
- * surface built to avoid exactly that).
17066
- *
17067
- * Resolved, never invented: a zone deleted since the track was written has no
17068
- * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
17069
- * two are not positionally aligned. Absent when the track visited no zone, or
17070
- * when the zone catalogue could not be read.
17026
+ * `failed` the per-device restart budget is exhausted; no pool
17027
+ * will be spawned until an operator re-arms it or the runner
17028
+ * respawns. `backoff` — under budget, waiting out the backoff (or
17029
+ * a cached pool observed dead and not yet condemned).
17071
17030
  */
17072
- zoneNames: array(string()).readonly().optional(),
17073
- /** Deduplicated set of detector classes observed for this track over its
17074
- * life (a track may be reclassified, e.g. person→vehicle). Absent on
17075
- * legacy rows written before class accumulation shipped. */
17076
- classes: array(string()).readonly().optional(),
17077
- /** Cumulative normalized distance travelled (0..1 units = full frame width). */
17078
- totalDistance: number(),
17079
- state: TrackStateSchema,
17080
- active: boolean(),
17081
- /** Deterministic key-event importance score in [0,1] (server-computed at
17082
- * track expiry, recomputed on late label). Absent on legacy rows written
17083
- * before scoring shipped — consumers degrade to absence / compute-on-read. */
17084
- importance: number().optional(),
17085
- /** Id of the track's highest-confidence ObjectEvent (its representative
17086
- * "best" frame). Absent when the track produced no object events. */
17087
- bestEventId: string().optional(),
17088
- /** Tag of the importance sub-signal that dominated the score
17089
- * (identity|dwell|proximity|class|confidence|travel|zone). */
17090
- importanceReason: string().optional(),
17091
- /** Audio-classification labels heard on the camera during the track's
17092
- * life (score ≥ device `classificationMinScore`), aggregated per label.
17093
- * Absent on legacy rows / tracks with no confident audio. */
17094
- audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
17095
- /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
17096
- * Populated from the persisted envelope columns on historical reads;
17097
- * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
17098
- envelope: TrackEnvelopeSchema.optional(),
17031
+ state: _enum(["failed", "backoff"]),
17032
+ /** Epoch ms of the death that produced this state. */
17033
+ since: number(),
17034
+ /** Pool deaths inside the current window. */
17035
+ deaths: number(),
17036
+ /** The last death's message. */
17037
+ lastError: string()
17038
+ })).readonly() })), method(object({
17039
+ nodeId: string(),
17040
+ deviceKey: string()
17041
+ }), object({ rearmed: boolean() }), {
17042
+ kind: "mutation",
17043
+ auth: "admin"
17044
+ }), 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({
17045
+ name: string(),
17046
+ steps: array(PipelineTemplateStepSchema).readonly(),
17047
+ engine: PipelineEngineChoiceSchema
17048
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
17049
+ id: string(),
17050
+ name: string().optional(),
17051
+ steps: array(PipelineTemplateStepSchema).readonly().optional()
17052
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
17053
+ addonId: string(),
17054
+ modelId: string(),
17055
+ format: ModelFormatSchema$1
17056
+ }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
17057
+ addonId: string(),
17058
+ modelId: string(),
17059
+ format: ModelFormatSchema$1
17060
+ }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
17061
+ engine: PipelineEngineChoiceSchema.optional(),
17062
+ steps: array(PipelineStepInputSchema).min(1),
17063
+ frame: FrameInputSchema.optional(),
17099
17064
  /**
17100
- * A face DETECTOR found a face on this track — nothing more. It says the
17101
- * detail plane produced a `face` detail; it does NOT say the face was
17102
- * embedded, matched, above `minFacePx`, or that the recognizer was even
17103
- * enabled. Set once and never cleared.
17104
- *
17105
- * **This exists so "face present but not recognised" is expressible.** A
17106
- * recognised identity lands in `subLabel` (attributed to the face chain via
17107
- * `subLabelMeta.stepId`), so before this field a track with an unmatched face
17108
- * and a track with no face at all were byte-identical on the wire and no
17109
- * surface could tell them apart. The read is `hasFace === true && subLabel
17110
- * === undefined`.
17111
- *
17112
- * **Absent ≠ false.** Every row written before the column existed omits it,
17113
- * and so does every server that predates the field — a consumer must test
17114
- * `=== true` and render nothing otherwise, never infer "no face".
17065
+ * Process-local lazy frame. Valid only when caller and provider resolve
17066
+ * in the same execution-group process; split/cross-node callers use
17067
+ * `frame`/`image` inline compatibility instead.
17115
17068
  */
17116
- hasFace: boolean().optional(),
17069
+ frameRef: FrameRefSchema.optional(),
17117
17070
  /**
17118
- * This track has a face row IN THE GALLERY: a crop **and** an embedding a
17119
- * face an operator could ASSIGN to an identity.
17120
- *
17121
- * The STRICT twin of {@link hasFace}, and the pair only earns its keep
17122
- * because the two disagree. `hasFace` is stamped at the TOP of the face
17123
- * branch, before every gate, and means no more than "a face detector produced
17124
- * a face detail". This one is stamped at the single moment the gallery row
17125
- * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
17126
- * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
17127
- * candidate gate, the imageless-track drop (no crop was ever captured) and
17128
- * the crop-store drop. Everything between the detector and that insert can
17129
- * legitimately refuse the face, so a flag written any earlier promises the
17130
- * operator something to assign and delivers nothing.
17131
- *
17132
- * **Independent of recognition.** A face collected but never auto-matched is
17133
- * still assignable — it is in fact the face an operator most wants to reach —
17134
- * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
17135
- * `subLabel`; this says only that the raw material exists.
17136
- *
17137
- * **Set once, never cleared.** A track that produced a gallery row produced
17138
- * one; deleting the row later is the gallery's business, not this flag's.
17139
- *
17140
- * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
17141
- * before the column omits it, and so does every server that predates the
17142
- * field. A consumer must test `=== true` and render nothing otherwise —
17143
- * never infer "no assignable face".
17071
+ * CB5 shm passthrough a `FrameHandle` naming the same ring slot
17072
+ * the decoded pixels live in. One more member of the one-of
17073
+ * frame/frameHandle/image/imageBase64/referenceImage group.
17144
17074
  */
17145
- hasEmbeddedFace: boolean().optional(),
17075
+ frameHandle: FrameHandleSchema.optional(),
17076
+ imageBase64: string().optional(),
17146
17077
  /**
17147
- * This subject CONTAINS a folded rider a person the rider-pairing step
17148
- * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
17149
- * so the passage is tracked once and as a VEHICLE.
17150
- *
17151
- * It exists because the fold's record was dishonest. D34 and the code both
17152
- * said "the person is not lost — it is reported so both entities stay on the
17153
- * record"; in fact the pair went into a per-processor RAM field behind an
17154
- * accessor nobody called, and every durable surface said `vehicle`, full
17155
- * stop. This is the composition note that makes the row true.
17156
- *
17157
- * A COMPOSITION, never a class and never a label. "This vehicle contains a
17158
- * person" is not an answer to "what is this" — both label tiers would refuse
17159
- * a macro token anyway (D89), and correctly. Nothing here changes what the
17160
- * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
17161
- * and a `person` rule still does not fire for someone cycling past.
17162
- *
17163
- * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
17164
- * the column, and every hub that predates the field, omits it. Test
17165
- * `=== true` and render nothing otherwise — never infer "no rider".
17078
+ * Binary JPEG bytespreferred over `imageBase64` on internal
17079
+ * hops (hub forked worker via Moleculer MsgPack) because it
17080
+ * skips the 33% base64 overhead + the per-call base64 decode on
17081
+ * the detection-pipeline worker. Callers can pass either; exactly
17082
+ * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
17166
17083
  */
17167
- hasRider: boolean().optional(),
17168
- ...TrackFlagFields,
17169
- ...TrackRetrainFields
17170
- });
17171
- var BaseEventFields = {
17172
- id: string(),
17173
- deviceId: number(),
17174
- timestamp: number()
17175
- };
17176
- var MotionEventSchema = object({
17177
- ...BaseEventFields,
17178
- kind: literal("motion"),
17179
- regionCount: number(),
17180
- /** Heavy JSON array omitted in slim projection. */
17181
- regions: array(object({
17182
- bbox: BoundingBoxSchema,
17183
- pixelCount: number(),
17184
- intensity: number()
17185
- })).readonly().optional(),
17186
- /** Omitted in slim projection. */
17187
- frameWidth: number().optional(),
17188
- /** Omitted in slim projection. */
17189
- frameHeight: number().optional(),
17190
- /** Populated by B5 (recording playback URL for this event). */
17191
- mediaUrl: string().optional()
17192
- });
17084
+ image: _instanceof(Uint8Array).optional(),
17085
+ referenceImage: string().optional(),
17086
+ deviceId: number().optional(),
17087
+ sessionId: string().optional(),
17088
+ /**
17089
+ * Execution plane. 'full' (default) runs the whole tree — benchmark,
17090
+ * reference-image, and detail-subtree calls. 'frame' is the live
17091
+ * per-frame dispatch: ONLY root-plane steps run; crop children
17092
+ * (inputClasses ≠ null) are skipped and served per-track via
17093
+ * pipelineRunner.runDetailSubtree (two-plane design).
17094
+ */
17095
+ plane: _enum(["full", "frame"]).optional(),
17096
+ /**
17097
+ * Inference-device selector (Phase 2 multi-device). Format
17098
+ * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
17099
+ * Omitted ⇒ the runner's default device (current single-engine
17100
+ * behaviour). Selects WHICH device pool of the node runs the call.
17101
+ */
17102
+ deviceKey: string().optional(),
17103
+ /**
17104
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
17105
+ * when the parent crop was resolved from the frame's retained NATIVE
17106
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
17107
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
17108
+ * resolution from that surface — the SAME quality path faces already
17109
+ * had — instead of the downscaled parent tile. `handle` keys the native
17110
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
17111
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
17112
+ * the executor's crop-normalized child ROI back into frame-normalized
17113
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
17114
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
17115
+ * (today's behaviour on the fallback path).
17116
+ */
17117
+ nativeCropRef: NativeCropRefSchema.optional()
17118
+ }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
17119
+ engine: PipelineEngineChoiceSchema.optional(),
17120
+ steps: array(PipelineStepInputSchema).min(1),
17121
+ frames: array(FrameInputSchema).min(1).max(255),
17122
+ deviceId: number().optional(),
17123
+ sessionId: string().optional(),
17124
+ /**
17125
+ * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
17126
+ * the batch to the Python pool's bench preprocess cache
17127
+ * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
17128
+ * preprocessed ONCE and every later inference is a pure-inference cache
17129
+ * hit — the sustained-throughput run measures inference, not
17130
+ * decode+preprocess+infer. Omitted/0 for live frames (all different →
17131
+ * full preprocess every call, correct). Fresh per sustained run;
17132
+ * released via `uncacheFrame`.
17133
+ */
17134
+ frameId: number().int().nonnegative().optional(),
17135
+ /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
17136
+ deviceKey: string().optional()
17137
+ }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
17138
+ data: _instanceof(Uint8Array),
17139
+ width: number().int().positive(),
17140
+ height: number().int().positive(),
17141
+ format: _enum([
17142
+ "rgb",
17143
+ "bgr",
17144
+ "gray"
17145
+ ])
17146
+ }), object({
17147
+ frameId: number(),
17148
+ width: number(),
17149
+ height: number()
17150
+ }), { kind: "mutation" }), method(object({
17151
+ stepId: string(),
17152
+ frameId: number().int()
17153
+ }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
17154
+ batchMode: string(),
17155
+ windowMs: number(),
17156
+ maxBatchSize: number(),
17157
+ concurrency: number()
17158
+ })), method(_void(), array(object({
17159
+ engineKey: string(),
17160
+ engine: PipelineEngineChoiceSchema,
17161
+ modelsLoaded: array(string()).readonly(),
17162
+ inUseByCameras: array(number()).readonly(),
17163
+ /**
17164
+ * Origin of this resident factory.
17165
+ * - `runtime` — main camera-serving engine (no idle TTL).
17166
+ * - `warm-override` — benchmark/test override held in the warm
17167
+ * cache; auto-disposed after the idle TTL.
17168
+ * - `device-pool` — a concurrent per-device pool (Phase 2
17169
+ * multi-device, keyed by `deviceKey`) resolved
17170
+ * via `resolveDeviceFactory`. Runs alongside the
17171
+ * `runtime` engine on a DIFFERENT accelerator
17172
+ * (NPU / iGPU / Coral) — this is how the
17173
+ * Engines tab shows all pools running at once.
17174
+ */
17175
+ kind: _enum([
17176
+ "runtime",
17177
+ "warm-override",
17178
+ "device-pool"
17179
+ ]),
17180
+ /** Native pid of the underlying Python pool (null when no pool). */
17181
+ poolPid: number().nullable(),
17182
+ /** ms since this factory was last used (null when not warm-tracked). */
17183
+ idleMs: number().nullable(),
17184
+ /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
17185
+ idleTtlMs: number().nullable()
17186
+ })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
17187
+ kind: "mutation",
17188
+ auth: "admin"
17189
+ }), method(object({
17190
+ engine: PipelineEngineChoiceSchema,
17191
+ force: boolean().optional()
17192
+ }), object({
17193
+ success: boolean(),
17194
+ reason: string().optional()
17195
+ }), {
17196
+ kind: "mutation",
17197
+ auth: "admin"
17198
+ }), 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({
17199
+ addonId: string(),
17200
+ modelId: string(),
17201
+ filename: string().optional(),
17202
+ settings: record(string(), unknown()).optional()
17203
+ }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
17193
17204
  /**
17194
- * Which detection SOURCE produced an object event. `pipeline` = the ML
17195
- * detection pipeline (decoded-frame inference); `onboard` = the camera's
17196
- * native on-device AI. Both flow through the SAME analysis layers (zoning,
17197
- * tracking, per-kind persistence) but stay distinguishable so consumers
17198
- * (advanced-notifier, occupancy, …) can select which source(s) to act on.
17199
- * Absent on legacy rows treat as `pipeline`.
17205
+ * Per-stage gating mode applied to the zones a rule references.
17206
+ *
17207
+ * - `include`: the rule contributes to a **whitelist** for its stage.
17208
+ * When at least one `include` rule fires for a stage, only entities
17209
+ * inside one of those zones pass that stage.
17210
+ * - `exclude`: the rule contributes to a **blacklist** for its stage.
17211
+ * Entities inside one of those zones are dropped at that stage.
17212
+ *
17213
+ * `monitor`-style observation (count without filtering) is not a rule
17214
+ * mode — zones without any matching rule are observed naturally by
17215
+ * `zone-analytics` (live snapshot + history), so an "I just want to
17216
+ * count, not filter" use case needs no rule at all.
17200
17217
  */
17201
- var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
17218
+ var ZoneRuleModeEnum = _enum(["include", "exclude"]);
17202
17219
  /**
17203
- * The confirmed zone crossing that produced an object event. Present ONLY on
17204
- * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
17205
- * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
17206
- * appearance event carry none, so a rule asking for a direction fails closed
17207
- * on them.
17220
+ * Per-consumer rule that references existing zones (geometry) and
17221
+ * defines how a specific pipeline stage should treat them. Each
17222
+ * consumer addon owns its own `ZoneRule[]` array in its per-device
17223
+ * settings:
17208
17224
  *
17209
- * Exactly ONE crossing per event: the emitter turns each confirmed crossing
17210
- * into its own event, so a frame in which a track enters A while leaving B
17211
- * produces two events with two directions — never one ambiguous row.
17225
+ * - `addon-motion-wasm` `motionZoneRules: ZoneRule[]` (motion stage)
17226
+ * - `addon-detection-pipeline` `detectionZoneRules: ZoneRule[]` (detection stage)
17227
+ * - future: notification rules, audio gating, etc.
17212
17228
  *
17213
- * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
17214
- * membership the box has NOW, and by definition it no longer contains the zone
17215
- * that was just left. Without the id here, a zone-scoped rule could never match
17216
- * the exit it asked for.
17229
+ * One rule applies to N zones (`zoneIds[]`) so the operator can
17230
+ * express "ignore motion in ALL of {garden, street}" with a single
17231
+ * rule. `classFilter` narrows the rule to specific object classes
17232
+ * "drop person detections in the street, but keep cars" is one
17233
+ * `exclude` rule with `classFilter: ['person']`.
17234
+ *
17235
+ * `enabled` is a soft toggle — the operator can keep the rule
17236
+ * configured but inert without deleting it.
17217
17237
  */
17218
- var ZoneCrossingSchema = object({
17219
- direction: _enum(["enter", "exit"]),
17220
- /** Admin zone id crossed. */
17221
- zoneId: string(),
17222
- /** Zone display name at crossing time (falls back to the id). */
17223
- zoneName: string().optional()
17224
- });
17225
- var ObjectEventSchema = object({
17226
- ...BaseEventFields,
17227
- kind: literal("object"),
17228
- /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
17229
- source: DetectionSourceSchema.optional(),
17238
+ var ZoneRuleSchema = object({
17239
+ /** Stable rule id — survives edits, used by the UI for diffing. */
17240
+ id: string(),
17241
+ /** Optional human-readable label rendered in the rule editor. */
17242
+ name: string().optional(),
17243
+ /** Zones this rule targets. The rule's `mode` applies to ALL
17244
+ * listed zones (OR-set: a detection in any one of them counts).
17245
+ * At least one zone id required — a rule with no targets is a
17246
+ * configuration mistake and the form validator rejects it. */
17247
+ zoneIds: array(string()).min(1).readonly(),
17248
+ mode: ZoneRuleModeEnum,
17230
17249
  /**
17231
- * Inference-frame id shared by every object event emitted from the SAME frame
17232
- * the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
17233
- * 2 people + 1 dog) under one full frame, and link a track's frames over time
17234
- * (group by `trackId`, pick a representative `frameId` as the parent frame).
17235
- * Optional for backward-compat with pre-existing rows / the slim projection
17236
- * includes it (it is light). Absent on rows written before this field.
17250
+ * Class names this rule applies to. Empty / undefined rule
17251
+ * applies to every class. Class strings match the `macroClass`
17252
+ * field on detections (e.g. `person`, `car`, `dog`).
17237
17253
  */
17238
- frameId: string().optional(),
17239
- /** Omitted in slim projection. */
17240
- trackId: string().optional(),
17241
- className: string(),
17242
- ...TieredLabelFields,
17243
- /** Omitted in slim projection. */
17244
- confidence: number().optional(),
17245
- /** Heavy JSON — omitted in slim projection. */
17246
- bbox: BoundingBoxSchema.optional(),
17247
- /** Heavy JSON — omitted in slim projection. */
17248
- zones: array(string()).readonly().optional(),
17249
- /** Omitted in slim projection. */
17250
- state: TrackStateSchema.optional(),
17254
+ classFilter: array(string()).readonly().optional(),
17251
17255
  /**
17252
- * The zone crossing this event IS, when it is one. Absent on every other
17253
- * event kind (movement state, appearance, package) see
17254
- * {@link ZoneCrossingSchema}. Omitted in slim projection.
17256
+ * Minimum bbox/mask overlap (0–1) with any of the rule's zones
17257
+ * required to consider an entity "in the zone". Defaults to the
17258
+ * consumer's stage default when omitted. Kept for back-compat with
17259
+ * existing per-rule overrides; new operators pick the value via
17260
+ * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
17261
+ * set, the lower-level engine reads it as a 0–1 fraction.
17255
17262
  */
17256
- zoneCrossing: ZoneCrossingSchema.optional(),
17257
- /** Detection-frame dimensions in pixels — let consumers normalize the
17258
- * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
17259
- frameWidth: number().optional(),
17260
- frameHeight: number().optional(),
17261
- /** MediaStore key for the crop attached to this event (if any). */
17262
- mediaKey: string().optional(),
17263
- /** Design B: MediaStore key of the track's native-resolution key frame (the
17264
- * best-detection full frame). Resolve via the event-media data-plane
17265
- * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
17266
- * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
17267
- * sources — consumers fall back to `mediaKey` (the tight crop). */
17268
- keyFrameMediaKey: string().optional(),
17269
- /** Populated by B5 (recording playback URL for this event). */
17270
- mediaUrl: string().optional(),
17271
- /** The parent track's key-event importance [0,1], propagated to every object
17272
- * event of the track (so an event row can be sorted by importance without a
17273
- * track join). Absent on legacy rows / before the track was scored. */
17274
- importance: number().optional()
17275
- });
17276
- var AudioEventSchema = object({
17277
- ...BaseEventFields,
17278
- kind: literal("audio"),
17279
- rms: number(),
17280
- dbfs: number(),
17281
- classification: object({
17282
- className: string(),
17283
- originalClass: string().optional(),
17284
- score: number()
17285
- }).optional(),
17286
- /** Populated by B5 (recording playback URL for this event). */
17287
- mediaUrl: string().optional()
17288
- });
17289
- var MediaFileKindEnum = _enum([
17290
- "crop",
17291
- "thumbnail",
17292
- "snapshot",
17293
- "firstFrame",
17294
- "lastFrame",
17295
- "fullFrame",
17296
- "fullFrameBoxed",
17297
- "faceCrop",
17298
- "plateCrop",
17299
- "keyFrame",
17300
- "keyFrameSmall",
17301
- "thumbnailSmall"
17302
- ]);
17303
- var MediaFileSchema = object({
17304
- key: string(),
17305
- kind: MediaFileKindEnum,
17306
- base64: string(),
17307
- sizeBytes: number(),
17308
- timestamp: number()
17263
+ overlapThreshold: number().min(0).max(1).optional(),
17264
+ /**
17265
+ * Operator-friendly version of `overlapThreshold` the percentage
17266
+ * of the detection's bbox that must lie inside the zone for the
17267
+ * rule to match. Documented default is 85%; the engine substitutes
17268
+ * that when the field is omitted (kept optional so existing rules
17269
+ * stored without it stay valid).
17270
+ *
17271
+ * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
17272
+ * rule, the engine prefers `bboxInclusionPct` because it's the
17273
+ * field exposed in the UI. Internally both feed the same gate.
17274
+ */
17275
+ bboxInclusionPct: number().min(0).max(100).optional(),
17276
+ /**
17277
+ * When `true` and a detection has a segmentation mask, use the
17278
+ * mask for overlap instead of the bbox. Detection-stage only;
17279
+ * motion rules ignore this field.
17280
+ */
17281
+ preferMask: boolean().optional(),
17282
+ /**
17283
+ * Soft-toggle: `false` disables the rule without deleting it.
17284
+ * Defaults to `true` so operators creating a rule via the UI
17285
+ * see it active immediately.
17286
+ */
17287
+ enabled: boolean().default(true)
17309
17288
  });
17289
+ array(ZoneRuleSchema).readonly();
17310
17290
  /**
17311
- * One media row WITHOUT its bytes.
17291
+ * Zone pure geometry + identity. NO filtering behaviour.
17312
17292
  *
17313
- * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
17314
- * 140 s track), and a client that renders tiles from the media data plane needs
17315
- * to know only WHAT EXISTS the bytes then arrive per tile, lazily, over HTTP
17316
- * with an immutable cache, instead of all at once inside a tRPC response that
17317
- * blocks the whole view.
17293
+ * Zones describe **where** in the frame the operator wants to flag
17294
+ * something; consumer-owned {@link ZoneRule} arrays describe **how**
17295
+ * each pipeline stage uses them. Splitting the two means a single
17296
+ * polygon "Driveway" can simultaneously back a motion-exclude rule,
17297
+ * a detection-include rule on `['car']`, and an occupancy aggregate
17298
+ * — without three duplicated polygons.
17318
17299
  *
17319
- * `sizeBytes` is carried because it is what lets a client decide between the
17320
- * stored blob and a `?variant=thumb` rendering without fetching either.
17300
+ * Owned by the orchestrator addon (provider) and mirrored into the
17301
+ * `zones` device-state slice on every mutation. Consumers
17302
+ * (motion-wasm, pipeline-executor, analytics, admin UI) read either
17303
+ * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
17304
+ * mirror with `onChanged`).
17305
+ *
17306
+ * Coordinates are normalised fractions of the frame (0–1) so zones
17307
+ * survive resolution changes and stream profile switches.
17308
+ *
17309
+ * `kind` discriminates between full polygons (closed regions used
17310
+ * for intrusion / occupancy filters) and tripwires (open 2-point
17311
+ * line segments used for cross events). Onboard / firmware-reported
17312
+ * zones (Reolink, ONVIF) are out of scope for now — see the deferred
17313
+ * task list.
17321
17314
  */
17322
- var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
17315
+ var ZoneKindEnum = _enum(["polygon", "tripwire"]);
17316
+ /** Polygon vertex in fraction-of-frame coordinates (0–1). */
17317
+ var PolygonPointSchema = object({
17318
+ x: number(),
17319
+ y: number()
17320
+ });
17321
+ /** A camera detection zone — pure geometry/identity. */
17322
+ var ZoneSchema = object({
17323
+ id: string(),
17324
+ name: string(),
17325
+ kind: ZoneKindEnum.default("polygon"),
17326
+ /** Polygon vertices, fraction of frame (0–1). */
17327
+ polygon: array(PolygonPointSchema).readonly(),
17328
+ /** Visual color for UI rendering. */
17329
+ color: string().default("#3b82f6")
17330
+ });
17331
+ DeviceType.Camera, method(object({ deviceId: number() }), array(ZoneSchema).readonly()), method(object({
17332
+ deviceId: number(),
17333
+ zone: ZoneSchema
17334
+ }), _void(), {
17335
+ kind: "mutation",
17336
+ auth: "admin"
17337
+ }), method(object({
17338
+ deviceId: number(),
17339
+ zoneId: string()
17340
+ }), _void(), {
17341
+ kind: "mutation",
17342
+ auth: "admin"
17343
+ }), method(object({
17344
+ deviceId: number(),
17345
+ zone: ZoneSchema
17346
+ }), _void(), {
17347
+ kind: "mutation",
17348
+ auth: "admin"
17349
+ }), object({ zones: array(ZoneSchema).readonly() });
17323
17350
  /**
17324
- * The MACRO tier of an annotation — a CLOSED set.
17351
+ * pipeline-analytics device-scoped wrapper cap. Refines raw
17352
+ * per-frame detections emitted by the pipeline runner into tracked
17353
+ * objects, per-kind event collections (motion / object / audio), and
17354
+ * persisted media. Owns the post-detection domain end-to-end:
17325
17355
  *
17326
- * This is what the exported detector predicts, so a typo here is a new class
17327
- * with one example in it. `label` and `subLabel` are open strings by contrast:
17328
- * the whole point of the page is teaching the model things it does not know
17329
- * yet, and constraining that vocabulary would make it useless.
17356
+ * runner emits PipelineInferenceResult
17357
+ * (event bus)
17358
+ * pipeline-analytics subscriber
17359
+ * SORT tracker + zone engine + state analyzer + event emitter
17360
+ * → three DB collections (one per kind), one FS media tree, one
17361
+ * unified event emitter (FrameTracked + TrackStarted/Ended +
17362
+ * DetectionEvent on bus)
17330
17363
  *
17331
- * A macro class is NEVER a label. The provider refuses a write whose `label` or
17332
- * `subLabel` is one of these values, in any casing, because once `person`
17333
- * exists in both tiers "every person box" stops being answerable without
17334
- * knowing every string anyone ever typed — and the damage is retroactive.
17364
+ * Pure subscriber model. No `processFrame` cap method the runner
17365
+ * already publishes the raw frame on the bus. The cap surface is
17366
+ * only QUERIES + per-device settings, bound on/off via
17367
+ * `device-manager.setWrapperActive`. `defaultActive: true` because
17368
+ * every camera with a detection pipeline wants its raw detections
17369
+ * refined; operators opt out per-device via BindingsTab when needed.
17370
+ *
17371
+ * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
17372
+ * (per-device surface) and `track-trail` caps — see P11 cleanup.
17335
17373
  */
17336
- var RetrainMacroClassSchema = _enum([
17374
+ var TrackStateSchema = _enum([
17375
+ "new",
17376
+ "entered",
17377
+ "left",
17378
+ "moving",
17379
+ "idle"
17380
+ ]);
17381
+ var EventKindSchema = _enum([
17382
+ "motion",
17383
+ "object",
17384
+ "audio"
17385
+ ]);
17386
+ /**
17387
+ * Spatial filter for `listTracks` — the rect + polygon variants of the shared
17388
+ * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
17389
+ * of the camera frame (top-left origin), matching the drawing-plane editor.
17390
+ */
17391
+ var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
17392
+ /** Closed icon vocabulary so clients render a known glyph per kind. */
17393
+ var EventKindIconSchema = _enum([
17394
+ "motion",
17395
+ "audio",
17337
17396
  "person",
17338
17397
  "vehicle",
17339
17398
  "animal",
17399
+ "door",
17400
+ "pir",
17401
+ "smoke",
17402
+ "water",
17403
+ "button",
17340
17404
  "package",
17341
- "face",
17342
- "plate"
17405
+ "generic"
17343
17406
  ]);
17344
- /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
17345
- var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
17346
- /** Did a human draw this box, or did the assist propose it? */
17347
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
17348
- /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
17349
- var RetrainBboxSchema = object({
17350
- x: number(),
17351
- y: number(),
17352
- w: number(),
17353
- h: number()
17354
- });
17355
- /**
17356
- * One annotated subject.
17357
- *
17358
- * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
17359
- * (letterboxed root / zone-cropped package / subject-cropped classifier) are
17360
- * derived from it at export and never stored storing them is how one feature
17361
- * space ends up holding two crops of the same subject (D52).
17362
- */
17363
- var RetrainAnnotationSchema = object({
17364
- id: string(),
17365
- trackId: string(),
17366
- deviceId: number(),
17367
- /** The COPY in retrain storage — never the source track's media key. */
17368
- mediaKey: string(),
17369
- bbox: RetrainBboxSchema,
17370
- macroClass: RetrainMacroClassSchema,
17371
- label: string().optional(),
17372
- subLabel: string().optional(),
17373
- kind: RetrainAnnotationKindSchema,
17374
- source: RetrainAnnotationSourceSchema,
17375
- /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
17376
- assistModelId: string().optional(),
17377
- assistScore: number().optional(),
17378
- exportedInBatch: string().optional(),
17379
- createdAt: number()
17380
- });
17381
- /** The write form — the server owns `id`, `createdAt` and the frame binding. */
17382
- var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
17383
- id: true,
17384
- trackId: true,
17385
- deviceId: true,
17386
- mediaKey: true,
17387
- createdAt: true,
17388
- exportedInBatch: true
17407
+ var EventKindCategorySchema = _enum([
17408
+ "motion",
17409
+ "audio",
17410
+ "detection",
17411
+ "sensor",
17412
+ "control",
17413
+ "custom",
17414
+ "package"
17415
+ ]);
17416
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
17417
+ var EventKindLevelSchema = _enum(["macro", "sub"]);
17418
+ var EventKindDescriptorSchema = object({
17419
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
17420
+ kind: string(),
17421
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
17422
+ labelKey: string(),
17423
+ /** English fallback label (kept for clients that don't translate). */
17424
+ label: string(),
17425
+ /** Hex color for timeline/legend rendering. */
17426
+ color: string(),
17427
+ /** Dictionary id → lucide component on the UI side. */
17428
+ iconId: string(),
17429
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
17430
+ icon: EventKindIconSchema,
17431
+ category: EventKindCategorySchema,
17432
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
17433
+ parentKind: string().nullable(),
17434
+ /** Derived from `parentKind`, explicit for the client tree. */
17435
+ level: EventKindLevelSchema,
17436
+ /** Which cap + device contributes this kind. For built-ins the camera
17437
+ * itself; for sensor kinds the LINKED source device. */
17438
+ source: object({
17439
+ capName: string(),
17440
+ deviceId: number()
17441
+ })
17389
17442
  });
17390
- /** A track sitting in `staging`, with everything the worklist needs to rank it. */
17391
- var RetrainTrackSchema = object({
17392
- trackId: string(),
17443
+ /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
17444
+ var EventKindsForDeviceSchema = object({
17393
17445
  deviceId: number(),
17394
- className: string(),
17395
- label: string().optional(),
17396
- firstSeen: number(),
17397
- lastSeen: number(),
17398
- /** How many frames the dataset already holds from this track. */
17399
- frameCount: number().int(),
17400
- /** How many subjects have been annotated on those frames. `0` with
17401
- * `frameCount: 0` is exactly "staging, still to work". */
17402
- annotationCount: number().int()
17403
- });
17404
- /** A frame the picker may offer — an index row, no blob was read to produce it. */
17405
- var RetrainFrameCandidateSchema = object({
17406
- mediaKey: string(),
17407
- kind: MediaFileKindEnum,
17408
- timestamp: number(),
17409
- sizeBytes: number().int(),
17410
- /** A copy of this original already exists — selecting it is free and cannot
17411
- * fail, whatever became of the original. */
17412
- copied: boolean()
17446
+ kinds: array(EventKindDescriptorSchema).readonly()
17413
17447
  });
17414
- /** A frame the dataset OWNS: bytes copied at selection time. */
17415
- var RetrainFrameSchema = object({
17416
- frameId: string(),
17448
+ var SensorEventSchema = object({
17449
+ id: string(),
17450
+ /** The CAMERA the event is attributed to (a sensor linked to N cameras
17451
+ * yields N rows, one per camera). */
17417
17452
  deviceId: number(),
17418
- trackId: string(),
17419
- /** Provenance only. It may already point at nothing — that is expected. */
17420
- sourceMediaKey: string(),
17421
- sourceKind: MediaFileKindEnum,
17422
- sizeBytes: number().int(),
17423
- width: number().int(),
17424
- height: number().int(),
17425
- copiedAt: number()
17453
+ /** The linked sensor device whose state changed. */
17454
+ sourceDeviceId: number(),
17455
+ /** Event kind id — matches an `EventKindDescriptor.kind`. */
17456
+ kind: string(),
17457
+ /** Snapshot of the sensor cap's runtime-state slice at the change. */
17458
+ value: record(string(), unknown()).nullable(),
17459
+ timestamp: number()
17426
17460
  });
17427
- /** Why a copy-on-select could not be honoured — named, never a silent skip. */
17428
- var RetrainCopyRefusalSchema = _enum([
17429
- "source-missing",
17430
- "unreadable-image",
17431
- "write-failed"
17432
- ]);
17433
- var RetrainFrameSelectionSchema = object({
17434
- copied: array(RetrainFrameSchema).readonly(),
17435
- refused: array(object({
17436
- sourceMediaKey: string(),
17437
- reason: RetrainCopyRefusalSchema
17438
- })).readonly()
17461
+ var TrackPositionSchema = object({
17462
+ x: number(),
17463
+ y: number(),
17464
+ timestamp: number(),
17465
+ bbox: BoundingBoxSchema
17439
17466
  });
17440
- var RetrainFrameListSchema = object({
17441
- candidates: array(RetrainFrameCandidateSchema).readonly(),
17442
- copies: array(RetrainFrameSchema).readonly(),
17443
- /** What the page pre-selects the native key frame when one survives. */
17444
- autoPickMediaKey: string().optional()
17467
+ var TrackSnapshotSchema = object({
17468
+ timestamp: number(),
17469
+ position: TrackPositionSchema,
17470
+ /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
17471
+ mediaKey: string()
17445
17472
  });
17446
- /** What the operator asked the assist to look for. */
17447
- var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
17448
- kind: literal("package"),
17449
- zone: RetrainBboxSchema.optional()
17450
- }), object({
17451
- kind: literal("objects"),
17452
- modelId: string(),
17453
- minScore: number().optional()
17454
- })]);
17455
17473
  /**
17456
- * The assist's answer a discriminated union, because "the model saw nothing"
17457
- * and "this node cannot run that model" lead to different next moves and a
17458
- * nullable result cannot tell them apart.
17474
+ * Normalized 0..1 trajectory envelope (min/max over every position bbox,
17475
+ * divided by the track's detection-frame dims), computed at persist time.
17476
+ * Absent when the frame dims were unknown when the track was persisted
17477
+ * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
17459
17478
  */
17460
- var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
17461
- kind: literal("proposed"),
17462
- modelId: string(),
17463
- stepId: string(),
17464
- minScore: number(),
17465
- /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
17466
- proposals: array(RetrainAnnotationDraftSchema).readonly(),
17467
- /** Returned by the runner but removed by the threshold. */
17468
- belowThreshold: number().int()
17469
- }), object({
17470
- kind: literal("refused"),
17471
- /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
17472
- reason: string(),
17473
- detail: string().optional()
17474
- })]);
17475
- /** The outcome of a lifecycle move owned by the retrain page. */
17476
- var RetrainTransitionResultSchema = object({
17477
- trackId: string(),
17478
- /** Where the track ended up, whatever happened. */
17479
- retrainStatus: RetrainStatusSchema,
17480
- /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
17481
- changed: boolean(),
17482
- reason: _enum([
17483
- "unknown-track",
17484
- "no-frames-copied",
17485
- "not-staging",
17486
- "not-trained",
17487
- "unchanged"
17488
- ]).optional()
17489
- });
17490
- var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
17491
- var MAX_EVENT_QUERY_LIMIT = 5e3;
17492
- var DeviceEventQueryInput = object({
17493
- deviceId: number(),
17494
- since: number().optional(),
17495
- until: number().optional(),
17496
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
17497
- /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
17498
- * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
17499
- * exact behaviour. Callers may omit this field — the store defaults to
17500
- * `full` when not provided. */
17501
- projection: _enum(["full", "slim"]).optional()
17502
- });
17503
- var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
17504
- var RecentTracksQueryInput = object({
17505
- /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
17506
- deviceIds: array(number()),
17507
- /** Window lower bound on `lastSeen` (inclusive). */
17508
- since: number().optional(),
17509
- /** Window upper bound on `lastSeen` (inclusive). */
17510
- until: number().optional(),
17511
- /** Page size. Default 200, max 1000. */
17512
- limit: number().int().min(1).max(1e3).default(200),
17513
- /** Opaque continuation cursor from a previous page's `nextCursor`.
17514
- * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
17515
- cursor: string().optional(),
17516
- /** See {@link TrackProjectionSchema}. Default `full`. */
17517
- projection: TrackProjectionSchema.optional(),
17518
- /** Include stationary-promoted rows (parked objects). Default false: the
17519
- * feed lists passages; parking records live on the stationary registry. */
17520
- includeStationary: boolean().optional()
17479
+ var TrackEnvelopeSchema = object({
17480
+ minX: number(),
17481
+ minY: number(),
17482
+ maxX: number(),
17483
+ maxY: number()
17521
17484
  });
17522
- var RecentTracksPageSchema = object({
17523
- /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
17524
- tracks: array(TrackSchema).readonly(),
17525
- /** Cursor for the next page, or null when this page is the last. */
17526
- nextCursor: string().nullable()
17527
- });
17528
- var LIST_GROUPS_DEFAULT_LIMIT = 40;
17529
- var LIST_GROUPS_MAX_LIMIT = 100;
17530
- var AnalyticsGroupRecordSchema = object({
17531
- id: string(),
17532
- deviceId: number().int(),
17533
- openedAt: number().int(),
17534
- closedAt: number().int(),
17535
- timestamp: number().int(),
17536
- memberCount: number().int(),
17537
- memberTrackIds: array(string()).readonly(),
17538
- className: string(),
17539
- classes: array(string()).readonly(),
17540
- /** Relative event-media path, or null when the group has no picture yet. */
17541
- mediaUrl: string().nullable(),
17542
- singleton: boolean()
17543
- });
17544
- var AnalyticsGroupMemberSchema = object({
17545
- trackId: string(),
17546
- deviceId: number().int(),
17547
- className: string(),
17548
- firstSeen: number().int(),
17549
- lastSeen: number().int(),
17550
- mediaUrl: string().nullable()
17551
- });
17552
- var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
17553
- var ListGroupsQueryInput = object({
17554
- /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
17555
- deviceIds: array(number()),
17556
- /** Window lower bound on `closedAt` (inclusive). */
17557
- since: number().optional(),
17558
- /** Window upper bound on `openedAt` (inclusive). */
17559
- until: number().optional(),
17560
- limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
17561
- /** Opaque continuation cursor from a previous page's `nextCursor`. */
17562
- cursor: string().optional()
17563
- });
17564
- var ListGroupsPageSchema = object({
17565
- groups: array(AnalyticsGroupRecordSchema).readonly(),
17566
- nextCursor: string().nullable()
17567
- });
17568
- var KeyEventQueryInput = object({
17569
- deviceId: number(),
17570
- /** Window lower bound (track firstSeen ≥ since). */
17571
- since: number(),
17572
- /** Window upper bound (track firstSeen ≤ until). */
17573
- until: number(),
17574
- limit: number().int().min(1).max(200).default(50),
17575
- /** Drop tracks scoring below this importance. */
17576
- minImportance: number().min(0).max(1).optional(),
17577
- /** Restrict to a single class (e.g. 'person'). */
17578
- classFilter: string().optional()
17579
- });
17580
- var KeyEventSchema = object({
17581
- /** The representative event id (the track's best ObjectEvent, else its trackId). */
17582
- id: string(),
17583
- trackId: string(),
17584
- /** Track start time (firstSeen). */
17585
- timestamp: number(),
17586
- className: string(),
17587
- ...TieredLabelFields,
17588
- importance: number(),
17589
- /** Highest-confidence ObjectEvent id for the track (empty when none). */
17590
- bestEventId: string(),
17591
- /** Track lifetime in ms (lastSeen - firstSeen). */
17592
- windowMs: number().optional(),
17593
- ...TrackFlagFields,
17594
- ...TrackRetrainFields
17595
- });
17596
- object({
17597
- trackId: string(),
17598
- className: string(),
17599
- confidence: number(),
17600
- bbox: BoundingBoxSchema,
17601
- zones: array(string()).readonly(),
17602
- state: TrackStateSchema
17603
- });
17604
- var OverlayDetectionSchema = looseObject({
17605
- id: string(),
17606
- kind: _enum(["first-level", "detail"]),
17607
- macroClass: string(),
17608
- score: number(),
17609
- bbox: object({
17610
- x: number(),
17611
- y: number(),
17612
- width: number(),
17613
- height: number()
17614
- }),
17615
- labels: array(looseObject({
17616
- label: string(),
17617
- score: number()
17618
- })).readonly(),
17619
- parentId: string().optional()
17620
- });
17621
- var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
17622
- var SearchObjectEventsInput = object({
17623
- text: string(),
17624
- deviceId: number().optional(),
17625
- since: number().optional(),
17626
- until: number().optional(),
17627
- classFilter: string().optional(),
17628
- limit: number().default(50),
17629
- minScore: number().min(0).max(1).default(.2)
17630
- });
17631
- var TrackCascadeCountsSchema = object({
17632
- /** Persisted track roots deleted (authoritative). */
17633
- tracks: number().int(),
17634
- /** Object events removed with their tracks (best-effort; see note above). */
17635
- events: number().int(),
17636
- /** Track/face/plate-owned media removed (best-effort). Never identity media. */
17637
- media: number().int(),
17638
- /** Unassigned (non-enrolled) face reads removed (best-effort). */
17639
- faces: number().int(),
17640
- /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
17641
- plates: number().int(),
17642
- /** Per-track CLIP search vectors removed (best-effort). */
17643
- embeddings: number().int(),
17644
- /** Group membership + group rows removed with their last member (best-effort). */
17645
- groups: number().int()
17646
- });
17647
- /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
17648
- var DiskReconcileCountsSchema = object({
17649
- mediaDropped: number().int(),
17650
- tracks: number().int(),
17651
- events: number().int()
17652
- });
17653
- /** Event-store footprint for one camera. */
17654
- var EventStoreDeviceFootprintSchema = object({
17655
- deviceId: number(),
17656
- /** Persisted event rows (motion + object + audio) for the camera. */
17657
- rows: number().int(),
17658
- /** Event-owned media bytes on disk for the camera. */
17659
- bytes: number().int()
17660
- });
17661
- /** Aggregate event-store footprint: global totals + per-camera breakdown. */
17662
- var EventStoreFootprintSchema = object({
17663
- totalRows: number().int(),
17664
- totalBytes: number().int(),
17665
- devices: array(EventStoreDeviceFootprintSchema).readonly()
17666
- });
17667
- /** Per-kind counts returned by the event-prune / device-delete mutations. */
17668
- var EventPruneCountsSchema = object({
17669
- motion: number().int(),
17670
- object: number().int(),
17671
- audio: number().int()
17485
+ /**
17486
+ * Row projection for track list queries. `full` (default) returns the
17487
+ * complete Track including the frame-rate `positions[]` history and the
17488
+ * `snapshots[]` references megabytes across a page of tracks. `slim`
17489
+ * keeps every scalar the list surfaces actually render (ids, class(es),
17490
+ * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
17491
+ * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
17492
+ * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
17493
+ * `getTrack`. Mirrors the event-store `projection` convention
17494
+ * (`getObjectEvents` et al.).
17495
+ */
17496
+ var TrackProjectionSchema = _enum(["full", "slim"]);
17497
+ /**
17498
+ * One audio-classification label heard on the track's camera while the
17499
+ * track was alive, aggregated per label. An "episode" is one persisted
17500
+ * audio event (the confident-classification path: score ≥ the device's
17501
+ * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
17502
+ * one 32 ms inference chunk, so counts stay human-scaled.
17503
+ */
17504
+ var TrackAudioLabelSchema = object({
17505
+ label: string(),
17506
+ /** Highest classification score observed across the label's episodes. */
17507
+ peakScore: number(),
17508
+ /** Number of coalesced audio-event episodes carrying this label. */
17509
+ count: number(),
17510
+ firstAt: number(),
17511
+ lastAt: number()
17672
17512
  });
17673
17513
  /**
17674
- * Re-embed stored tracks from their key frames.
17514
+ * How a track was produced. `pipeline` (default / absent) = the spatial
17515
+ * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
17516
+ * no positions, a single snapshot, and no bbox trajectory at all:
17675
17517
  *
17676
- * The reason this is an operator-callable method and not a migration script:
17677
- * every knob that decides what a vector MEANS encoder model, crop margin,
17678
- * squaring is only changeable if the existing vectors can be regenerated.
17679
- * Mixing feature spaces in one index makes cosine scores incomparable, and the
17680
- * symptom is a quality regression with no visible cause.
17518
+ * - `sensor` a linked sensor/control device state change.
17519
+ * - `audio` an audio event on the camera itself that was anomalous for
17520
+ * THAT camera, loud, and heard while nothing visual was happening (D62).
17521
+ *
17522
+ * The spatial subsystems (tracker association, occupancy count, re-id /
17523
+ * embedding, resurrection) MUST skip every synthetic source. Test for that
17524
+ * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
17525
+ * check silently readmits every source added after it was written.
17681
17526
  */
17682
- var RebuildObjectEmbeddingsInput = object({
17683
- /** Restrict to one camera. Omit for the whole fleet. */
17684
- deviceId: number().optional(),
17685
- since: number().optional(),
17686
- until: number().optional(),
17687
- /** Stop after this many tracks; the result reports whether more remain. */
17688
- maxTracks: number().int().positive().optional(),
17689
- /**
17690
- * Run every embedding on THIS node instead of round-robining the fleet.
17691
- *
17692
- * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
17693
- * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
17694
- * calling it that would pin the rebuild REQUEST itself to that node — the
17695
- * rebuild orchestration lives on the hub, and only the per-track step runs
17696
- * remotely. This field is data; the per-track pin is applied inside.
17697
- *
17698
- * Absent ⇒ round-robin over every online node whose runner can serve the
17699
- * pinned model.
17700
- */
17701
- executeOnNodeId: string().optional(),
17702
- /**
17703
- * Milliseconds to wait between tracks; omit for the built-in default, `0` to
17704
- * run flat out.
17705
- *
17706
- * A rebuild is bulk maintenance on hub-main's single thread. Measured
17707
- * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
17708
- * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
17709
- * force is logged at start and finish so a deliberately slow pass reads
17710
- * differently from a stalled one.
17711
- */
17712
- pacingMs: number().int().nonnegative().optional()
17713
- });
17527
+ var TrackSourceSchema = _enum([
17528
+ "pipeline",
17529
+ "sensor",
17530
+ "audio"
17531
+ ]);
17714
17532
  /**
17715
- * Result of emptying the CLIP index.
17533
+ * Where a track sits in the RETRAIN lifecycle (D81).
17716
17534
  *
17717
- * The clean slate before a policy change: a new crop margin or encoder model
17718
- * leaves two feature spaces in one index whose cosine scores are not
17719
- * comparable, so wiping and rebuilding is the only way to be sure every vector
17720
- * means the same thing.
17535
+ * - `none` never marked, or un-marked. Evictable.
17536
+ * - `staging` the operator wants this track as training material and has not
17537
+ * finished with it. **This is the only state retention holds**: the track and
17538
+ * everything it owns (object events, crops, keyframes, CLIP vector) survive
17539
+ * the device's age window.
17540
+ * - `trained` — the retrain page has taken what it needed. The frames it chose
17541
+ * were COPIED into the retrain dataset at selection time, so the dataset no
17542
+ * longer depends on the track's media and the track becomes EVICTABLE again.
17543
+ * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
17544
+ * a deliberate action of the retrain page, not a side effect of a checkbox.
17545
+ *
17546
+ * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
17547
+ * the store's filter language has only positive equality and `whereIn` — no
17548
+ * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
17549
+ * would make the entire pre-column history immortal in one deploy.
17721
17550
  */
17722
- var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
17551
+ var RetrainStatusSchema = _enum([
17552
+ "none",
17553
+ "staging",
17554
+ "trained"
17555
+ ]);
17723
17556
  /**
17724
- * Acknowledgement that a rebuild STARTED.
17557
+ * Per-track OPERATOR flags set by hand from the admin UI or the viewer, never
17558
+ * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
17559
+ * so the two surfaces cannot drift.
17725
17560
  *
17726
- * The pass costs ~1s per track 45 minutes for a 2,600-track fleet so it
17727
- * runs detached and this returns immediately. Waiting for it made the client
17728
- * time out while the work carried on server-side, which is the worst of both:
17729
- * no result and no way to know it was still going. Poll
17730
- * `getObjectEmbeddingRebuildStatus` for progress.
17561
+ * **Absent false.** A track that has never been touched omits the field; an
17562
+ * explicitly un-flagged track carries `false`. Legacy rows written before the
17563
+ * columns existed read as absent, and a consumer that needs a boolean should say
17564
+ * `flag === true`, not `flag !== false`.
17565
+ *
17566
+ * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
17567
+ * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
17568
+ * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
17569
+ * `trained` track reports `false` while refusing both writes. The boolean is
17570
+ * kept because three surfaces drive a toggle off it; anything that needs to tell
17571
+ * "never marked" from "already trained" must read `retrainStatus`.
17572
+ *
17573
+ * `debug` does NOT pin; it is attention, not durability.
17574
+ *
17575
+ * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
17576
+ * A favourited track is skipped by retention the same way `staging` is, but
17577
+ * it does not enter `none|staging|trained` and has no staging budget.
17731
17578
  */
17732
- var RebuildObjectEmbeddingsResultSchema = object({
17733
- started: boolean(),
17734
- /** True when a pass was already running; the new request is ignored. */
17735
- alreadyRunning: boolean()
17736
- });
17737
- var RebuildStatusSchema = object({
17738
- running: boolean(),
17739
- scanned: number(),
17740
- rebuilt: number(),
17741
- /** Tracks whose key frame is gone — nothing to re-embed from. */
17742
- missingKeyFrame: number(),
17743
- /** Tracks with no usable detection box. */
17744
- missingBbox: number(),
17745
- /**
17746
- * Tracks an executing node REFUSED rather than broke on an unreadable key
17747
- * frame, a step that threw. Separate from `failed` because the remedy is
17748
- * different, and because a whole camera silently contributing zero vectors
17749
- * is the shape of failure a rebuild must never hide.
17750
- */
17751
- notRunnable: number(),
17579
+ var TrackFlagFields = {
17580
+ /** Operator marked this track as training material — i.e. `retrainStatus` is
17581
+ * `'staging'`. */
17582
+ markForTrain: boolean().optional(),
17583
+ /** Operator marked this track for diagnostic attention. */
17584
+ debug: boolean().optional(),
17585
+ /** Operator favourited this track. Pins it against pruning. */
17586
+ favourited: boolean().optional()
17587
+ };
17588
+ /**
17589
+ * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
17590
+ * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
17591
+ * write patch, and the status is not something the toggle sets — it is what the
17592
+ * toggle's boolean is derived from. Absent on an in-RAM track never touched;
17593
+ * always present on a persisted row (the column default materialises `'none'`).
17594
+ */
17595
+ var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
17596
+ /**
17597
+ * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
17598
+ * one flag can never clear the other — the toggles are independent and are
17599
+ * driven from three surfaces that do not know about each other.
17600
+ */
17601
+ var TrackFlagsPatchSchema = object(TrackFlagFields);
17602
+ /**
17603
+ * The resolved flag state after a write. Both fields are REQUIRED here (absent
17604
+ * collapses to `false`) so a caller can drive a toggle's checked state off the
17605
+ * mutation result without a re-fetch.
17606
+ */
17607
+ var TrackFlagsSchema = object({
17608
+ trackId: string(),
17609
+ markForTrain: boolean(),
17610
+ debug: boolean(),
17611
+ favourited: boolean(),
17612
+ /** The lifecycle state the boolean was derived from. Required here (unlike on
17613
+ * a track row) because this shape is only ever produced by the write body,
17614
+ * which always knows it — and a surface that has just written needs to render
17615
+ * `trained` without a re-fetch. */
17616
+ retrainStatus: RetrainStatusSchema
17617
+ });
17618
+ union([literal(1), literal(2)]);
17619
+ /**
17620
+ * WHO decided a label, and when. Carried per tier so a value can be traced to
17621
+ * the step and model that produced it — which is what makes the write rule
17622
+ * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
17623
+ * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
17624
+ *
17625
+ * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
17626
+ * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
17627
+ * `migration:4g` for a value the 4g migration moved from the single-slot era —
17628
+ * that value has no provenance, and the write rule lets ANY properly-attributed
17629
+ * write of the same tier replace it regardless of score.
17630
+ */
17631
+ var LabelAttributionSchema = object({
17632
+ stepId: string(),
17633
+ modelId: string().optional(),
17634
+ decidedAt: number(),
17752
17635
  /**
17753
- * The pass stopped because NO node could serve the pinned model.
17636
+ * The GALLERY id behind a recognised tier-2 label a face-gallery
17637
+ * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
17754
17638
  *
17755
- * Distinct from `notRunnable` on purpose: that one says "this track was
17756
- * refused", this one says "the cluster cannot do this work at all" — every
17757
- * candidate node either lacks the `clip-embedding` step, lacks a build of the
17758
- * pinned model for its engine format, or dropped out. The remedy is a model /
17759
- * engine change, not a per-camera one. Non-zero here always comes with
17760
- * `complete: false`.
17639
+ * The text alone is a DISPLAY NAME, and a display name is renameable: a
17640
+ * notification rule authored on "Gianluca" stopped matching the moment the
17641
+ * operator fixed the spelling in the gallery, and nothing said so. The id is
17642
+ * the thing that does not move, so it is what a rule matches on
17643
+ * (`NcConditions.identities`) and the text is what a human is shown.
17644
+ *
17645
+ * Absent when the label names no gallery row — a plate the OCR read but no
17646
+ * vehicle claims, a sub-class, a species, any tier-1 value.
17761
17647
  */
17762
- noCapableNode: number(),
17763
- failed: number(),
17764
- /** Set once a pass ends: true only when EVERYTHING was covered. */
17765
- complete: boolean().nullable(),
17766
- startedAtMs: number().nullable(),
17767
- finishedAtMs: number().nullable(),
17768
- /** Present when the pass ended by throwing. */
17769
- error: string().nullable()
17648
+ identityId: string().optional()
17770
17649
  });
17771
- DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
17772
- deviceId: number(),
17773
- trackId: string()
17774
- }), TrackSchema.nullable()), method(object({
17775
- deviceId: number(),
17776
- since: number().optional(),
17777
- until: number().optional(),
17778
- limit: number().optional(),
17779
- /** Spatial filter — only tracks whose trajectory intersects the zone
17780
- * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
17781
- * envelope columns, then precisely tested per position. Tracks with
17782
- * an unknown envelope (no frame dims at persist time) always match. */
17783
- zone: TrackZoneFilterSchema.optional(),
17784
- /** See {@link TrackProjectionSchema}. Default `full` (backward
17785
- * compatible omitting the field keeps today's exact behaviour). */
17786
- projection: TrackProjectionSchema.optional(),
17787
- /** Include stationary-promoted rows (parked objects handed to the
17788
- * stationary registry). Default false: the timeline lists passages,
17789
- * not parking records (operator decision, 2026-08-15). */
17790
- includeStationary: boolean().optional()
17791
- }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
17792
- deviceId: number(),
17793
- groupId: string().min(1)
17794
- }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
17795
- kind: "mutation",
17796
- auth: "admin"
17797
- }), 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({
17798
- deviceId: number(),
17799
- since: number().optional(),
17800
- until: number().optional(),
17801
- kinds: array(string()).optional(),
17802
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
17803
- }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
17804
- deviceId: number(),
17805
- since: number(),
17806
- until: number(),
17807
- bucketMs: number().int().positive()
17808
- }), array(object({
17809
- bucketStart: number(),
17810
- motion: number().int(),
17811
- object: number().int(),
17812
- audio: number().int()
17813
- })).readonly()), method(object({
17814
- deviceId: number(),
17815
- cutoffMs: number()
17816
- }), object({
17817
- motion: number().int(),
17818
- object: number().int(),
17819
- audio: number().int()
17820
- }), {
17821
- kind: "mutation",
17822
- auth: "admin"
17823
- }), method(object({
17824
- deviceId: number(),
17825
- cutoffMs: number()
17826
- }), TrackCascadeCountsSchema, {
17827
- kind: "mutation",
17828
- auth: "admin"
17829
- }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
17830
- kind: "mutation",
17831
- auth: "admin"
17832
- }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
17833
- kind: "mutation",
17834
- auth: "admin"
17835
- }), method(object({
17836
- deviceId: number(),
17837
- trackIds: array(string()).min(1)
17838
- }), object({
17839
- deleted: number().int(),
17840
- failed: array(string()).readonly()
17841
- }), {
17842
- kind: "mutation",
17843
- auth: "admin"
17844
- }), method(object({
17845
- /** Log/audit scope only — the trackId is globally unique on its own. */
17650
+ /**
17651
+ * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
17652
+ * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
17653
+ * track and its events always answer the same question the same way.
17654
+ *
17655
+ * Two scalar columns, not an array: every consumer wants "the coarse one" or
17656
+ * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
17657
+ * is tier 2, and each carries its own score + attribution.
17658
+ *
17659
+ * **Reading it.** What a human should be shown is `subLabel ?? label` — the
17660
+ * finest thing known. Before 4g the single `label` column held the finest
17661
+ * value, so a consumer that has not been updated reads the tier-1 slot and
17662
+ * shows nothing on a species-only row; that is why the migration puts every
17663
+ * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
17664
+ * and why the read surfaces were changed in the same train.
17665
+ *
17666
+ * **Writing it.** The slots are independent, which is the whole point: a
17667
+ * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
17668
+ * migratorius`), so fineness cannot regress by construction. Within a tier the
17669
+ * higher score wins. One rule, one implementation — see
17670
+ * `pipeline/label-tier.ts` in addon-post-analysis.
17671
+ */
17672
+ var TieredLabelFields = {
17673
+ /** Tier 1 the sub-class. See {@link LabelTierSchema}. */
17674
+ label: string().optional(),
17675
+ /** Confidence of the tier-1 value, as reported by the deciding step. */
17676
+ labelScore: number().optional(),
17677
+ /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
17678
+ labelMeta: LabelAttributionSchema.optional(),
17679
+ /** Tier 2 — the instance. See {@link LabelTierSchema}. */
17680
+ subLabel: string().optional(),
17681
+ /** Confidence of the tier-2 value, as reported by the deciding step. */
17682
+ subLabelScore: number().optional(),
17683
+ /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
17684
+ subLabelMeta: LabelAttributionSchema.optional()
17685
+ };
17686
+ /** Per-camera slice of a training-export estimate. */
17687
+ var TrainingExportDeviceTotalsSchema = object({
17846
17688
  deviceId: number(),
17689
+ tracks: number().int(),
17690
+ files: number().int(),
17691
+ bytes: number().int()
17692
+ });
17693
+ /**
17694
+ * What a training export WOULD contain. Computed from media index rows only —
17695
+ * no blob is read to produce this.
17696
+ */
17697
+ var TrainingExportSummarySchema = object({
17698
+ generatedAt: number(),
17699
+ trackCount: number().int(),
17700
+ fileCount: number().int(),
17701
+ byteCount: number().int(),
17702
+ /** More marked tracks exist than a single pass carries. */
17703
+ truncated: boolean(),
17704
+ devices: array(TrainingExportDeviceTotalsSchema).readonly()
17705
+ });
17706
+ var TrackSchema = object({
17847
17707
  trackId: string(),
17848
- flags: TrackFlagsPatchSchema
17849
- }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
17850
- kind: "query",
17851
- auth: "admin"
17852
- }), method(object({
17853
- olderThanMs: number(),
17854
- reason: OpsLogReasonSchema.optional()
17855
- }), EventPruneCountsSchema, {
17856
- kind: "mutation",
17857
- auth: "admin"
17858
- }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
17859
- kind: "mutation",
17860
- auth: "admin"
17861
- }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
17862
- kind: "mutation",
17863
- auth: "admin"
17864
- }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
17865
- kind: "mutation",
17866
- auth: "admin"
17867
- }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
17868
- kind: "mutation",
17869
- auth: "admin"
17870
- }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
17871
- kind: "mutation",
17872
- auth: "admin"
17873
- }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
17874
- kind: "mutation",
17875
- auth: "admin"
17876
- }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
17877
- kind: "query",
17878
- auth: "admin"
17879
- }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
17880
- kind: "query",
17881
- auth: "admin"
17882
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
17883
- kind: "query",
17884
- auth: "admin"
17885
- }), method(object({
17886
- /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
17887
- * `deviceId`, deliberately: `deviceId` would make this device-bound and
17888
- * route it at one camera's owner, and "every camera" would stop being
17889
- * expressible at all. */
17890
- deviceIds: array(number()).optional(),
17891
- limit: number().int().min(1).max(500).optional()
17892
- }), array(RetrainTrackSchema).readonly(), {
17893
- kind: "query",
17894
- auth: "admin"
17895
- }), method(object({ trackId: string() }), RetrainFrameListSchema, {
17896
- kind: "query",
17897
- auth: "admin"
17898
- }), method(object({
17899
17708
  deviceId: number(),
17900
- trackId: string(),
17901
- mediaKeys: array(string()).min(1)
17902
- }), RetrainFrameSelectionSchema, {
17903
- kind: "mutation",
17904
- auth: "admin"
17905
- }), method(object({
17709
+ className: string(),
17710
+ ...TieredLabelFields,
17711
+ producingDeviceName: string().optional(),
17712
+ /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
17713
+ source: TrackSourceSchema.optional(),
17714
+ firstSeen: number(),
17715
+ lastSeen: number(),
17716
+ /** Frame-rate position history (subject to maxPositionHistory cap). */
17717
+ positions: array(TrackPositionSchema).readonly(),
17718
+ /** Periodic snapshots at snapshotIntervalMs cadence (subject to
17719
+ * saveThumbnails policy). */
17720
+ snapshots: array(TrackSnapshotSchema).readonly(),
17721
+ /** Deduplicated zones the track has entered at least once. Zone IDS. */
17722
+ zonesVisited: array(string()).readonly(),
17723
+ /**
17724
+ * Human NAMES for {@link zonesVisited}, resolved at READ time against the
17725
+ * `zones` capability.
17726
+ *
17727
+ * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
17728
+ * and no card can render — so every free-text search surface was structurally
17729
+ * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
17730
+ * just returned nothing. Resolving here rather than in each client keeps ONE
17731
+ * derivation and costs the clients no extra call (the `zones` cap is
17732
+ * per-device, so a client-side resolve would be a per-camera fan-out on a
17733
+ * surface built to avoid exactly that).
17734
+ *
17735
+ * Resolved, never invented: a zone deleted since the track was written has no
17736
+ * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
17737
+ * two are not positionally aligned. Absent when the track visited no zone, or
17738
+ * when the zone catalogue could not be read.
17739
+ */
17740
+ zoneNames: array(string()).readonly().optional(),
17741
+ /** Deduplicated set of detector classes observed for this track over its
17742
+ * life (a track may be reclassified, e.g. person→vehicle). Absent on
17743
+ * legacy rows written before class accumulation shipped. */
17744
+ classes: array(string()).readonly().optional(),
17745
+ /** Cumulative normalized distance travelled (0..1 units = full frame width). */
17746
+ totalDistance: number(),
17747
+ state: TrackStateSchema,
17748
+ active: boolean(),
17749
+ /** Deterministic key-event importance score in [0,1] (server-computed at
17750
+ * track expiry, recomputed on late label). Absent on legacy rows written
17751
+ * before scoring shipped — consumers degrade to absence / compute-on-read. */
17752
+ importance: number().optional(),
17753
+ /** Id of the track's highest-confidence ObjectEvent (its representative
17754
+ * "best" frame). Absent when the track produced no object events. */
17755
+ bestEventId: string().optional(),
17756
+ /** Tag of the importance sub-signal that dominated the score
17757
+ * (identity|dwell|proximity|class|confidence|travel|zone). */
17758
+ importanceReason: string().optional(),
17759
+ /** Audio-classification labels heard on the camera during the track's
17760
+ * life (score ≥ device `classificationMinScore`), aggregated per label.
17761
+ * Absent on legacy rows / tracks with no confident audio. */
17762
+ audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
17763
+ /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
17764
+ * Populated from the persisted envelope columns on historical reads;
17765
+ * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
17766
+ envelope: TrackEnvelopeSchema.optional(),
17767
+ /**
17768
+ * A face DETECTOR found a face on this track — nothing more. It says the
17769
+ * detail plane produced a `face` detail; it does NOT say the face was
17770
+ * embedded, matched, above `minFacePx`, or that the recognizer was even
17771
+ * enabled. Set once and never cleared.
17772
+ *
17773
+ * **This exists so "face present but not recognised" is expressible.** A
17774
+ * recognised identity lands in `subLabel` (attributed to the face chain via
17775
+ * `subLabelMeta.stepId`), so before this field a track with an unmatched face
17776
+ * and a track with no face at all were byte-identical on the wire and no
17777
+ * surface could tell them apart. The read is `hasFace === true && subLabel
17778
+ * === undefined`.
17779
+ *
17780
+ * **Absent ≠ false.** Every row written before the column existed omits it,
17781
+ * and so does every server that predates the field — a consumer must test
17782
+ * `=== true` and render nothing otherwise, never infer "no face".
17783
+ */
17784
+ hasFace: boolean().optional(),
17785
+ /**
17786
+ * This track has a face row IN THE GALLERY: a crop **and** an embedding — a
17787
+ * face an operator could ASSIGN to an identity.
17788
+ *
17789
+ * The STRICT twin of {@link hasFace}, and the pair only earns its keep
17790
+ * because the two disagree. `hasFace` is stamped at the TOP of the face
17791
+ * branch, before every gate, and means no more than "a face detector produced
17792
+ * a face detail". This one is stamped at the single moment the gallery row
17793
+ * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
17794
+ * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
17795
+ * candidate gate, the imageless-track drop (no crop was ever captured) and
17796
+ * the crop-store drop. Everything between the detector and that insert can
17797
+ * legitimately refuse the face, so a flag written any earlier promises the
17798
+ * operator something to assign and delivers nothing.
17799
+ *
17800
+ * **Independent of recognition.** A face collected but never auto-matched is
17801
+ * still assignable — it is in fact the face an operator most wants to reach —
17802
+ * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
17803
+ * `subLabel`; this says only that the raw material exists.
17804
+ *
17805
+ * **Set once, never cleared.** A track that produced a gallery row produced
17806
+ * one; deleting the row later is the gallery's business, not this flag's.
17807
+ *
17808
+ * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
17809
+ * before the column omits it, and so does every server that predates the
17810
+ * field. A consumer must test `=== true` and render nothing otherwise —
17811
+ * never infer "no assignable face".
17812
+ */
17813
+ hasEmbeddedFace: boolean().optional(),
17814
+ /**
17815
+ * This subject CONTAINS a folded rider — a person the rider-pairing step
17816
+ * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
17817
+ * so the passage is tracked once and as a VEHICLE.
17818
+ *
17819
+ * It exists because the fold's record was dishonest. D34 and the code both
17820
+ * said "the person is not lost — it is reported so both entities stay on the
17821
+ * record"; in fact the pair went into a per-processor RAM field behind an
17822
+ * accessor nobody called, and every durable surface said `vehicle`, full
17823
+ * stop. This is the composition note that makes the row true.
17824
+ *
17825
+ * A COMPOSITION, never a class and never a label. "This vehicle contains a
17826
+ * person" is not an answer to "what is this" — both label tiers would refuse
17827
+ * a macro token anyway (D89), and correctly. Nothing here changes what the
17828
+ * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
17829
+ * and a `person` rule still does not fire for someone cycling past.
17830
+ *
17831
+ * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
17832
+ * the column, and every hub that predates the field, omits it. Test
17833
+ * `=== true` and render nothing otherwise — never infer "no rider".
17834
+ */
17835
+ hasRider: boolean().optional(),
17836
+ ...TrackFlagFields,
17837
+ ...TrackRetrainFields
17838
+ });
17839
+ var BaseEventFields = {
17840
+ id: string(),
17906
17841
  deviceId: number(),
17907
- trackId: string(),
17908
- frameId: string()
17909
- }), object({
17910
- removed: boolean(),
17911
- removedAnnotations: number().int()
17912
- }), {
17913
- kind: "mutation",
17914
- auth: "admin"
17915
- }), method(object({ frameId: string() }), object({
17842
+ timestamp: number()
17843
+ };
17844
+ var MotionEventSchema = object({
17845
+ ...BaseEventFields,
17846
+ kind: literal("motion"),
17847
+ regionCount: number(),
17848
+ /** Heavy JSON array — omitted in slim projection. */
17849
+ regions: array(object({
17850
+ bbox: BoundingBoxSchema,
17851
+ pixelCount: number(),
17852
+ intensity: number()
17853
+ })).readonly().optional(),
17854
+ /** Omitted in slim projection. */
17855
+ frameWidth: number().optional(),
17856
+ /** Omitted in slim projection. */
17857
+ frameHeight: number().optional(),
17858
+ /** Populated by B5 (recording playback URL for this event). */
17859
+ mediaUrl: string().optional()
17860
+ });
17861
+ /**
17862
+ * Which detection SOURCE produced an object event. `pipeline` = the ML
17863
+ * detection pipeline (decoded-frame inference); `onboard` = the camera's
17864
+ * native on-device AI. Both flow through the SAME analysis layers (zoning,
17865
+ * tracking, per-kind persistence) but stay distinguishable so consumers
17866
+ * (advanced-notifier, occupancy, …) can select which source(s) to act on.
17867
+ * Absent on legacy rows ⇒ treat as `pipeline`.
17868
+ */
17869
+ var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
17870
+ /**
17871
+ * The confirmed zone crossing that produced an object event. Present ONLY on
17872
+ * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
17873
+ * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
17874
+ * appearance event carry none, so a rule asking for a direction fails closed
17875
+ * on them.
17876
+ *
17877
+ * Exactly ONE crossing per event: the emitter turns each confirmed crossing
17878
+ * into its own event, so a frame in which a track enters A while leaving B
17879
+ * produces two events with two directions — never one ambiguous row.
17880
+ *
17881
+ * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
17882
+ * membership the box has NOW, and by definition it no longer contains the zone
17883
+ * that was just left. Without the id here, a zone-scoped rule could never match
17884
+ * the exit it asked for.
17885
+ */
17886
+ var ZoneCrossingSchema = object({
17887
+ direction: _enum(["enter", "exit"]),
17888
+ /** Admin zone id crossed. */
17889
+ zoneId: string(),
17890
+ /** Zone display name at crossing time (falls back to the id). */
17891
+ zoneName: string().optional()
17892
+ });
17893
+ var ObjectEventSchema = object({
17894
+ ...BaseEventFields,
17895
+ kind: literal("object"),
17896
+ /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
17897
+ source: DetectionSourceSchema.optional(),
17898
+ /**
17899
+ * Inference-frame id shared by every object event emitted from the SAME frame
17900
+ * — the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
17901
+ * 2 people + 1 dog) under one full frame, and link a track's frames over time
17902
+ * (group by `trackId`, pick a representative `frameId` as the parent frame).
17903
+ * Optional for backward-compat with pre-existing rows / the slim projection
17904
+ * includes it (it is light). Absent on rows written before this field.
17905
+ */
17906
+ frameId: string().optional(),
17907
+ /** Omitted in slim projection. */
17908
+ trackId: string().optional(),
17909
+ className: string(),
17910
+ ...TieredLabelFields,
17911
+ /** Omitted in slim projection. */
17912
+ confidence: number().optional(),
17913
+ /** Heavy JSON — omitted in slim projection. */
17914
+ bbox: BoundingBoxSchema.optional(),
17915
+ /** Heavy JSON — omitted in slim projection. */
17916
+ zones: array(string()).readonly().optional(),
17917
+ /** Omitted in slim projection. */
17918
+ state: TrackStateSchema.optional(),
17919
+ /**
17920
+ * The zone crossing this event IS, when it is one. Absent on every other
17921
+ * event kind (movement state, appearance, package) — see
17922
+ * {@link ZoneCrossingSchema}. Omitted in slim projection.
17923
+ */
17924
+ zoneCrossing: ZoneCrossingSchema.optional(),
17925
+ /** Detection-frame dimensions in pixels — let consumers normalize the
17926
+ * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
17927
+ frameWidth: number().optional(),
17928
+ frameHeight: number().optional(),
17929
+ /** MediaStore key for the crop attached to this event (if any). */
17930
+ mediaKey: string().optional(),
17931
+ /** Design B: MediaStore key of the track's native-resolution key frame (the
17932
+ * best-detection full frame). Resolve via the event-media data-plane
17933
+ * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
17934
+ * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
17935
+ * sources — consumers fall back to `mediaKey` (the tight crop). */
17936
+ keyFrameMediaKey: string().optional(),
17937
+ /** Populated by B5 (recording playback URL for this event). */
17938
+ mediaUrl: string().optional(),
17939
+ /** The parent track's key-event importance [0,1], propagated to every object
17940
+ * event of the track (so an event row can be sorted by importance without a
17941
+ * track join). Absent on legacy rows / before the track was scored. */
17942
+ importance: number().optional()
17943
+ });
17944
+ var AudioEventSchema = object({
17945
+ ...BaseEventFields,
17946
+ kind: literal("audio"),
17947
+ rms: number(),
17948
+ dbfs: number(),
17949
+ classification: object({
17950
+ className: string(),
17951
+ originalClass: string().optional(),
17952
+ score: number()
17953
+ }).optional(),
17954
+ /** Populated by B5 (recording playback URL for this event). */
17955
+ mediaUrl: string().optional()
17956
+ });
17957
+ var MediaFileKindEnum = _enum([
17958
+ "crop",
17959
+ "thumbnail",
17960
+ "snapshot",
17961
+ "firstFrame",
17962
+ "lastFrame",
17963
+ "fullFrame",
17964
+ "fullFrameBoxed",
17965
+ "faceCrop",
17966
+ "plateCrop",
17967
+ "keyFrame",
17968
+ "keyFrameSmall",
17969
+ "thumbnailSmall"
17970
+ ]);
17971
+ var MediaFileSchema = object({
17972
+ key: string(),
17973
+ kind: MediaFileKindEnum,
17916
17974
  base64: string(),
17917
- width: number().int(),
17918
- height: number().int()
17919
- }), {
17920
- kind: "query",
17921
- auth: "admin"
17922
- }), method(object({
17923
- deviceId: number(),
17924
- trackId: string(),
17925
- frameId: string(),
17926
- subject: RetrainAssistSubjectSchema,
17927
- /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
17928
- nodeId: string().optional()
17929
- }), RetrainAssistResultSchema, {
17930
- kind: "mutation",
17931
- auth: "admin"
17932
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
17933
- kind: "query",
17934
- auth: "admin"
17935
- }), method(object({
17936
- deviceId: number(),
17975
+ sizeBytes: number(),
17976
+ timestamp: number()
17977
+ });
17978
+ /**
17979
+ * One media row WITHOUT its bytes.
17980
+ *
17981
+ * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
17982
+ * 140 s track), and a client that renders tiles from the media data plane needs
17983
+ * to know only WHAT EXISTS — the bytes then arrive per tile, lazily, over HTTP
17984
+ * with an immutable cache, instead of all at once inside a tRPC response that
17985
+ * blocks the whole view.
17986
+ *
17987
+ * `sizeBytes` is carried because it is what lets a client decide between the
17988
+ * stored blob and a `?variant=thumb` rendering without fetching either.
17989
+ */
17990
+ var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
17991
+ /**
17992
+ * The MACRO tier of an annotation — a CLOSED set.
17993
+ *
17994
+ * This is what the exported detector predicts, so a typo here is a new class
17995
+ * with one example in it. `label` and `subLabel` are open strings by contrast:
17996
+ * the whole point of the page is teaching the model things it does not know
17997
+ * yet, and constraining that vocabulary would make it useless.
17998
+ *
17999
+ * A macro class is NEVER a label. The provider refuses a write whose `label` or
18000
+ * `subLabel` is one of these values, in any casing, because once `person`
18001
+ * exists in both tiers "every person box" stops being answerable without
18002
+ * knowing every string anyone ever typed — and the damage is retroactive.
18003
+ */
18004
+ var RetrainMacroClassSchema = _enum([
18005
+ "person",
18006
+ "vehicle",
18007
+ "animal",
18008
+ "package",
18009
+ "face",
18010
+ "plate"
18011
+ ]);
18012
+ /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
18013
+ var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
18014
+ /** Did a human draw this box, or did the assist propose it? */
18015
+ var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
18016
+ /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
18017
+ var RetrainBboxSchema = object({
18018
+ x: number(),
18019
+ y: number(),
18020
+ w: number(),
18021
+ h: number()
18022
+ });
18023
+ /**
18024
+ * One annotated subject.
18025
+ *
18026
+ * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
18027
+ * (letterboxed root / zone-cropped package / subject-cropped classifier) are
18028
+ * derived from it at export and never stored — storing them is how one feature
18029
+ * space ends up holding two crops of the same subject (D52).
18030
+ */
18031
+ var RetrainAnnotationSchema = object({
18032
+ id: string(),
17937
18033
  trackId: string(),
17938
- frameId: string(),
17939
- annotations: array(RetrainAnnotationDraftSchema)
17940
- }), array(RetrainAnnotationSchema).readonly(), {
17941
- kind: "mutation",
17942
- auth: "admin"
17943
- }), method(object({
17944
18034
  deviceId: number(),
17945
- trackId: string()
17946
- }), RetrainTransitionResultSchema, {
17947
- kind: "mutation",
17948
- auth: "admin"
17949
- }), method(object({
17950
- deviceId: number(),
17951
- trackId: string()
17952
- }), RetrainTransitionResultSchema, {
17953
- kind: "mutation",
17954
- auth: "admin"
17955
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
17956
- kind: "query",
17957
- auth: "admin"
17958
- }), method(object({
17959
- eventId: string(),
17960
- kind: MediaFileKindEnum.optional(),
17961
- deviceId: number()
17962
- }), array(MediaFileSchema).readonly()), method(object({
17963
- trackId: string(),
17964
- kinds: array(MediaFileKindEnum).optional(),
17965
- deviceId: number()
17966
- }), array(MediaFileSchema).readonly()), method(object({
17967
- trackId: string(),
17968
- deviceId: number()
17969
- }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
17970
- kind: "mutation",
17971
- auth: "admin"
17972
- }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
17973
- kind: "mutation",
17974
- auth: "admin"
17975
- }), method(object({}), RebuildStatusSchema), object({
18035
+ /** The COPY in retrain storage — never the source track's media key. */
18036
+ mediaKey: string(),
18037
+ bbox: RetrainBboxSchema,
18038
+ macroClass: RetrainMacroClassSchema,
18039
+ label: string().optional(),
18040
+ subLabel: string().optional(),
18041
+ kind: RetrainAnnotationKindSchema,
18042
+ source: RetrainAnnotationSourceSchema,
18043
+ /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
18044
+ assistModelId: string().optional(),
18045
+ assistScore: number().optional(),
18046
+ exportedInBatch: string().optional(),
18047
+ createdAt: number()
18048
+ });
18049
+ /** The write form — the server owns `id`, `createdAt` and the frame binding. */
18050
+ var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
18051
+ id: true,
18052
+ trackId: true,
18053
+ deviceId: true,
18054
+ mediaKey: true,
18055
+ createdAt: true,
18056
+ exportedInBatch: true
18057
+ });
18058
+ /** A track sitting in `staging`, with everything the worklist needs to rank it. */
18059
+ var RetrainTrackSchema = object({
18060
+ trackId: string(),
17976
18061
  deviceId: number(),
18062
+ className: string(),
18063
+ label: string().optional(),
18064
+ firstSeen: number(),
18065
+ lastSeen: number(),
18066
+ /** How many frames the dataset already holds from this track. */
18067
+ frameCount: number().int(),
18068
+ /** How many subjects have been annotated on those frames. `0` with
18069
+ * `frameCount: 0` is exactly "staging, still to work". */
18070
+ annotationCount: number().int()
18071
+ });
18072
+ /** A frame the picker may offer — an index row, no blob was read to produce it. */
18073
+ var RetrainFrameCandidateSchema = object({
18074
+ mediaKey: string(),
18075
+ kind: MediaFileKindEnum,
17977
18076
  timestamp: number(),
17978
- frameWidth: number(),
17979
- frameHeight: number(),
17980
- detections: array(OverlayDetectionSchema).readonly()
17981
- }), object({
18077
+ sizeBytes: number().int(),
18078
+ /** A copy of this original already exists — selecting it is free and cannot
18079
+ * fail, whatever became of the original. */
18080
+ copied: boolean()
18081
+ });
18082
+ /** A frame the dataset OWNS: bytes copied at selection time. */
18083
+ var RetrainFrameSchema = object({
18084
+ frameId: string(),
17982
18085
  deviceId: number(),
17983
18086
  trackId: string(),
17984
- className: string()
18087
+ /** Provenance only. It may already point at nothing — that is expected. */
18088
+ sourceMediaKey: string(),
18089
+ sourceKind: MediaFileKindEnum,
18090
+ sizeBytes: number().int(),
18091
+ width: number().int(),
18092
+ height: number().int(),
18093
+ copiedAt: number()
18094
+ });
18095
+ /** Why a copy-on-select could not be honoured — named, never a silent skip. */
18096
+ var RetrainCopyRefusalSchema = _enum([
18097
+ "source-missing",
18098
+ "unreadable-image",
18099
+ "write-failed"
18100
+ ]);
18101
+ var RetrainFrameSelectionSchema = object({
18102
+ copied: array(RetrainFrameSchema).readonly(),
18103
+ refused: array(object({
18104
+ sourceMediaKey: string(),
18105
+ reason: RetrainCopyRefusalSchema
18106
+ })).readonly()
18107
+ });
18108
+ var RetrainFrameListSchema = object({
18109
+ candidates: array(RetrainFrameCandidateSchema).readonly(),
18110
+ copies: array(RetrainFrameSchema).readonly(),
18111
+ /** What the page pre-selects — the native key frame when one survives. */
18112
+ autoPickMediaKey: string().optional()
18113
+ });
18114
+ /** What the operator asked the assist to look for. */
18115
+ var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
18116
+ kind: literal("package"),
18117
+ zone: RetrainBboxSchema.optional()
17985
18118
  }), object({
17986
- deviceId: number(),
17987
- trackId: string(),
17988
- className: string(),
17989
- durationMs: number()
18119
+ kind: literal("objects"),
18120
+ modelId: string(),
18121
+ minScore: number().optional()
18122
+ })]);
18123
+ /**
18124
+ * The assist's answer — a discriminated union, because "the model saw nothing"
18125
+ * and "this node cannot run that model" lead to different next moves and a
18126
+ * nullable result cannot tell them apart.
18127
+ */
18128
+ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
18129
+ kind: literal("proposed"),
18130
+ modelId: string(),
18131
+ stepId: string(),
18132
+ minScore: number(),
18133
+ /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
18134
+ proposals: array(RetrainAnnotationDraftSchema).readonly(),
18135
+ /** Returned by the runner but removed by the threshold. */
18136
+ belowThreshold: number().int()
17990
18137
  }), object({
18138
+ kind: literal("refused"),
18139
+ /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
18140
+ reason: string(),
18141
+ detail: string().optional()
18142
+ })]);
18143
+ /** The outcome of a lifecycle move owned by the retrain page. */
18144
+ var RetrainTransitionResultSchema = object({
18145
+ trackId: string(),
18146
+ /** Where the track ended up, whatever happened. */
18147
+ retrainStatus: RetrainStatusSchema,
18148
+ /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
18149
+ changed: boolean(),
18150
+ reason: _enum([
18151
+ "unknown-track",
18152
+ "no-frames-copied",
18153
+ "not-staging",
18154
+ "not-trained",
18155
+ "unchanged"
18156
+ ]).optional()
18157
+ });
18158
+ var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
18159
+ var MAX_EVENT_QUERY_LIMIT = 5e3;
18160
+ var DeviceEventQueryInput = object({
17991
18161
  deviceId: number(),
17992
- kind: EventKindSchema,
17993
- eventId: string(),
17994
- timestamp: number()
18162
+ since: number().optional(),
18163
+ until: number().optional(),
18164
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
18165
+ /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
18166
+ * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
18167
+ * exact behaviour. Callers may omit this field — the store defaults to
18168
+ * `full` when not provided. */
18169
+ projection: _enum(["full", "slim"]).optional()
17995
18170
  });
17996
- /**
17997
- * Reference to the frame's retained NATIVE surface + the parent crop's placement
17998
- * within the frame, so the executor can re-cut a leaf child ROI at native
17999
- * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
18000
- */
18001
- var NativeCropRefSchema = object({
18002
- /** Handle keying the retained native surface (node-pinned to its owner). */
18003
- handle: FrameHandleSchema,
18004
- /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
18005
- cropFrameSpace: object({
18006
- x: number(),
18007
- y: number(),
18008
- w: number(),
18009
- h: number()
18010
- })
18171
+ var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
18172
+ var RecentTracksQueryInput = object({
18173
+ /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
18174
+ deviceIds: array(number()),
18175
+ /** Window lower bound on `lastSeen` (inclusive). */
18176
+ since: number().optional(),
18177
+ /** Window upper bound on `lastSeen` (inclusive). */
18178
+ until: number().optional(),
18179
+ /** Page size. Default 200, max 1000. */
18180
+ limit: number().int().min(1).max(1e3).default(200),
18181
+ /** Opaque continuation cursor from a previous page's `nextCursor`.
18182
+ * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
18183
+ cursor: string().optional(),
18184
+ /** See {@link TrackProjectionSchema}. Default `full`. */
18185
+ projection: TrackProjectionSchema.optional(),
18186
+ /** Include stationary-promoted rows (parked objects). Default false: the
18187
+ * feed lists passages; parking records live on the stationary registry. */
18188
+ includeStationary: boolean().optional()
18011
18189
  });
18012
- object({
18013
- crop: object({
18014
- left: number(),
18015
- top: number(),
18016
- width: number().positive(),
18017
- height: number().positive()
18018
- }).optional(),
18019
- content: object({
18020
- width: number().int().positive(),
18021
- height: number().int().positive()
18022
- }),
18023
- fit: _enum(["stretch", "contain"]),
18024
- format: _enum([
18025
- "rgb",
18026
- "gray",
18027
- "jpeg"
18028
- ])
18190
+ var RecentTracksPageSchema = object({
18191
+ /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
18192
+ tracks: array(TrackSchema).readonly(),
18193
+ /** Cursor for the next page, or null when this page is the last. */
18194
+ nextCursor: string().nullable()
18029
18195
  });
18030
- var FrameRefSchema = object({
18031
- registryId: string().min(1),
18032
- id: string().min(1),
18033
- width: number().int().positive(),
18034
- height: number().int().positive(),
18035
- format: _enum(["rgb", "gray"]),
18036
- timestamp: number(),
18037
- capturedAt: number().optional()
18196
+ var LIST_GROUPS_DEFAULT_LIMIT = 40;
18197
+ var LIST_GROUPS_MAX_LIMIT = 100;
18198
+ var AnalyticsGroupRecordSchema = object({
18199
+ id: string(),
18200
+ deviceId: number().int(),
18201
+ openedAt: number().int(),
18202
+ closedAt: number().int(),
18203
+ timestamp: number().int(),
18204
+ memberCount: number().int(),
18205
+ memberTrackIds: array(string()).readonly(),
18206
+ className: string(),
18207
+ classes: array(string()).readonly(),
18208
+ /** Relative event-media path, or null when the group has no picture yet. */
18209
+ mediaUrl: string().nullable(),
18210
+ singleton: boolean()
18038
18211
  });
18039
- var ModelFormatSchema$1 = _enum([
18040
- "onnx",
18041
- "coreml",
18042
- "openvino",
18043
- "tflite",
18044
- "pt",
18045
- "gguf"
18046
- ]);
18047
- var PipelineSlotSchema = _enum([
18048
- "detector",
18049
- "cropper",
18050
- "classifier",
18051
- "refiner",
18052
- "audio-classifier"
18053
- ]);
18054
- var PipelineEngineChoiceSchema = object({
18055
- runtime: _enum(["node", "python"]),
18056
- backend: string(),
18057
- format: ModelFormatSchema$1,
18058
- device: string().optional()
18212
+ var AnalyticsGroupMemberSchema = object({
18213
+ trackId: string(),
18214
+ deviceId: number().int(),
18215
+ className: string(),
18216
+ firstSeen: number().int(),
18217
+ lastSeen: number().int(),
18218
+ mediaUrl: string().nullable()
18059
18219
  });
18060
- var AvailableEngineSchema = object({
18061
- engine: PipelineEngineChoiceSchema,
18062
- devices: array(object({
18063
- id: string(),
18064
- label: string(),
18065
- description: string().optional()
18066
- })).readonly(),
18067
- defaultDevice: string()
18220
+ var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
18221
+ var ListGroupsQueryInput = object({
18222
+ /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
18223
+ deviceIds: array(number()),
18224
+ /** Window lower bound on `closedAt` (inclusive). */
18225
+ since: number().optional(),
18226
+ /** Window upper bound on `openedAt` (inclusive). */
18227
+ until: number().optional(),
18228
+ limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
18229
+ /** Opaque continuation cursor from a previous page's `nextCursor`. */
18230
+ cursor: string().optional()
18231
+ });
18232
+ var ListGroupsPageSchema = object({
18233
+ groups: array(AnalyticsGroupRecordSchema).readonly(),
18234
+ nextCursor: string().nullable()
18235
+ });
18236
+ var KeyEventQueryInput = object({
18237
+ deviceId: number(),
18238
+ /** Window lower bound (track firstSeen ≥ since). */
18239
+ since: number(),
18240
+ /** Window upper bound (track firstSeen ≤ until). */
18241
+ until: number(),
18242
+ limit: number().int().min(1).max(200).default(50),
18243
+ /** Drop tracks scoring below this importance. */
18244
+ minImportance: number().min(0).max(1).optional(),
18245
+ /** Restrict to a single class (e.g. 'person'). */
18246
+ classFilter: string().optional()
18068
18247
  });
18069
- var PipelineDefaultStepSchema = lazy(() => object({
18070
- addonId: string(),
18071
- addonName: string(),
18072
- slot: PipelineSlotSchema,
18073
- inputClasses: array(string()).readonly(),
18074
- outputClasses: array(string()).readonly(),
18075
- enabled: boolean(),
18076
- modelId: string(),
18077
- children: array(PipelineDefaultStepSchema).readonly(),
18078
- group: string().optional(),
18079
- settings: record(string(), unknown()).optional()
18080
- }));
18081
- var PipelineTemplateStepSchema = lazy(() => object({
18082
- addonId: string(),
18083
- enabled: boolean(),
18084
- modelId: string(),
18085
- children: array(PipelineTemplateStepSchema).readonly(),
18086
- settings: record(string(), unknown()).optional()
18087
- }));
18088
- var PipelineTemplateSchema$1 = object({
18248
+ var KeyEventSchema = object({
18249
+ /** The representative event id (the track's best ObjectEvent, else its trackId). */
18089
18250
  id: string(),
18090
- name: string(),
18091
- createdAt: string(),
18092
- updatedAt: string(),
18093
- engine: PipelineEngineChoiceSchema,
18094
- steps: array(PipelineTemplateStepSchema).readonly()
18251
+ trackId: string(),
18252
+ /** Track start time (firstSeen). */
18253
+ timestamp: number(),
18254
+ className: string(),
18255
+ ...TieredLabelFields,
18256
+ importance: number(),
18257
+ /** Highest-confidence ObjectEvent id for the track (empty when none). */
18258
+ bestEventId: string(),
18259
+ /** Track lifetime in ms (lastSeen - firstSeen). */
18260
+ windowMs: number().optional(),
18261
+ ...TrackFlagFields,
18262
+ ...TrackRetrainFields
18095
18263
  });
18096
- var PipelineModelOptionSchema = object({
18097
- id: string(),
18098
- name: string(),
18099
- formats: record(string(), object({
18100
- downloaded: boolean(),
18101
- sizeMB: number()
18102
- })),
18103
- group: ModelVariantGroupSchema.optional(),
18104
- legacy: boolean().optional(),
18105
- provider: ModelProviderIdSchema.optional()
18264
+ object({
18265
+ trackId: string(),
18266
+ className: string(),
18267
+ confidence: number(),
18268
+ bbox: BoundingBoxSchema,
18269
+ zones: array(string()).readonly(),
18270
+ state: TrackStateSchema
18106
18271
  });
18107
- var ConfigFieldBridge = custom();
18108
- var PipelineAddonSchemaSchema = object({
18272
+ var OverlayDetectionSchema = looseObject({
18109
18273
  id: string(),
18110
- name: string(),
18111
- slot: PipelineSlotSchema,
18112
- inputClasses: array(string()).readonly(),
18113
- outputClasses: array(string()).readonly(),
18114
- childSlots: array(PipelineSlotSchema).readonly(),
18115
- models: array(PipelineModelOptionSchema).readonly(),
18116
- defaultModelId: string(),
18117
- defaultModelIdByFormat: record(string(), string()).optional(),
18118
- enabledByDefault: boolean().optional(),
18119
- backfillIntoExistingOverrides: boolean().optional(),
18120
- defaultConfidence: number(),
18121
- group: string().optional(),
18122
- configSchema: array(ConfigFieldBridge).readonly().optional()
18123
- });
18124
- var PipelineSlotSchemaSchema = object({
18125
- id: PipelineSlotSchema,
18126
- label: string(),
18127
- priority: number(),
18128
- parentSlot: PipelineSlotSchema.nullable(),
18129
- addons: array(PipelineAddonSchemaSchema).readonly()
18274
+ kind: _enum(["first-level", "detail"]),
18275
+ macroClass: string(),
18276
+ score: number(),
18277
+ bbox: object({
18278
+ x: number(),
18279
+ y: number(),
18280
+ width: number(),
18281
+ height: number()
18282
+ }),
18283
+ labels: array(looseObject({
18284
+ label: string(),
18285
+ score: number()
18286
+ })).readonly(),
18287
+ parentId: string().optional()
18130
18288
  });
18131
- var PipelineSchemaSchema = object({
18132
- availableEngines: array(AvailableEngineSchema).readonly(),
18133
- selectedEngine: PipelineEngineChoiceSchema,
18134
- slots: array(PipelineSlotSchemaSchema).readonly()
18289
+ var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
18290
+ var SearchObjectEventsInput = object({
18291
+ text: string(),
18292
+ deviceId: number().optional(),
18293
+ since: number().optional(),
18294
+ until: number().optional(),
18295
+ classFilter: string().optional(),
18296
+ limit: number().default(50),
18297
+ minScore: number().min(0).max(1).default(.2)
18135
18298
  });
18136
- var EngineProvisioningSchema = object({
18137
- runtimeId: _enum([
18138
- "onnx",
18139
- "openvino",
18140
- "coreml",
18141
- "edgetpu"
18142
- ]).nullable(),
18143
- device: string().nullable(),
18144
- state: _enum([
18145
- "idle",
18146
- "installing",
18147
- "verifying",
18148
- "ready",
18149
- "failed"
18150
- ]),
18151
- progress: number().optional(),
18152
- error: string().optional(),
18153
- nextRetryAt: number().optional(),
18154
- /**
18155
- * Gate A (config-correctness gate at engine change): human-readable
18156
- * config issues surfaced EAGERLY when the node's engine changes — model
18157
- * substitutions ("chose X, running Y") and zero-build steps ("no model
18158
- * has a <format> build"). Additive/optional: informational only, never
18159
- * enforced here — `assertEngineReady` (readiness) still gates inference.
18160
- * Absent/empty when the node-default tree resolves cleanly.
18161
- */
18162
- configIssues: array(string()).optional()
18299
+ var TrackCascadeCountsSchema = object({
18300
+ /** Persisted track roots deleted (authoritative). */
18301
+ tracks: number().int(),
18302
+ /** Object events removed with their tracks (best-effort; see note above). */
18303
+ events: number().int(),
18304
+ /** Track/face/plate-owned media removed (best-effort). Never identity media. */
18305
+ media: number().int(),
18306
+ /** Unassigned (non-enrolled) face reads removed (best-effort). */
18307
+ faces: number().int(),
18308
+ /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
18309
+ plates: number().int(),
18310
+ /** Per-track CLIP search vectors removed (best-effort). */
18311
+ embeddings: number().int(),
18312
+ /** Group membership + group rows removed with their last member (best-effort). */
18313
+ groups: number().int()
18163
18314
  });
18164
- var PipelineStepInputSchema = lazy(() => object({
18165
- addonId: string(),
18166
- modelId: string().optional(),
18167
- enabled: boolean().default(true),
18168
- children: array(PipelineStepInputSchema).optional(),
18169
- settings: record(string(), unknown()).optional(),
18170
- jumpDeviceKey: string().optional()
18171
- }));
18172
- var ModelSubstitutionSchema = object({
18173
- addonId: string(),
18174
- chosen: string(),
18175
- running: string(),
18176
- format: string()
18315
+ /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
18316
+ var DiskReconcileCountsSchema = object({
18317
+ mediaDropped: number().int(),
18318
+ tracks: number().int(),
18319
+ events: number().int()
18177
18320
  });
18178
- var PipelineValidationIssueSchema = object({
18179
- addonId: string(),
18180
- kind: _enum(["unknown-addon", "no-format-build"]),
18181
- detail: string()
18321
+ /** Event-store footprint for one camera. */
18322
+ var EventStoreDeviceFootprintSchema = object({
18323
+ deviceId: number(),
18324
+ /** Persisted event rows (motion + object + audio) for the camera. */
18325
+ rows: number().int(),
18326
+ /** Event-owned media bytes on disk for the camera. */
18327
+ bytes: number().int()
18182
18328
  });
18183
- var PipelineValidationResultSchema = object({
18184
- ok: boolean(),
18185
- issues: array(PipelineValidationIssueSchema).readonly(),
18186
- substitutions: array(ModelSubstitutionSchema).readonly(),
18187
- /** The node's `currentEngine.format` this validation ran against. */
18188
- format: string()
18329
+ /** Aggregate event-store footprint: global totals + per-camera breakdown. */
18330
+ var EventStoreFootprintSchema = object({
18331
+ totalRows: number().int(),
18332
+ totalBytes: number().int(),
18333
+ devices: array(EventStoreDeviceFootprintSchema).readonly()
18189
18334
  });
18190
- var ReferenceImageEntrySchema = object({
18191
- filename: string(),
18192
- stepIds: array(string()).readonly().optional()
18335
+ /** Per-kind counts returned by the event-prune / device-delete mutations. */
18336
+ var EventPruneCountsSchema = object({
18337
+ motion: number().int(),
18338
+ object: number().int(),
18339
+ audio: number().int()
18193
18340
  });
18194
- var ReferenceImageBodySchema = object({
18195
- base64: string(),
18196
- filename: string()
18341
+ /**
18342
+ * Re-embed stored tracks from their key frames.
18343
+ *
18344
+ * The reason this is an operator-callable method and not a migration script:
18345
+ * every knob that decides what a vector MEANS — encoder model, crop margin,
18346
+ * squaring — is only changeable if the existing vectors can be regenerated.
18347
+ * Mixing feature spaces in one index makes cosine scores incomparable, and the
18348
+ * symptom is a quality regression with no visible cause.
18349
+ */
18350
+ var RebuildObjectEmbeddingsInput = object({
18351
+ /** Restrict to one camera. Omit for the whole fleet. */
18352
+ deviceId: number().optional(),
18353
+ since: number().optional(),
18354
+ until: number().optional(),
18355
+ /** Stop after this many tracks; the result reports whether more remain. */
18356
+ maxTracks: number().int().positive().optional(),
18357
+ /**
18358
+ * Run every embedding on THIS node instead of round-robining the fleet.
18359
+ *
18360
+ * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
18361
+ * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
18362
+ * calling it that would pin the rebuild REQUEST itself to that node — the
18363
+ * rebuild orchestration lives on the hub, and only the per-track step runs
18364
+ * remotely. This field is data; the per-track pin is applied inside.
18365
+ *
18366
+ * Absent ⇒ round-robin over every online node whose runner can serve the
18367
+ * pinned model.
18368
+ */
18369
+ executeOnNodeId: string().optional(),
18370
+ /**
18371
+ * Milliseconds to wait between tracks; omit for the built-in default, `0` to
18372
+ * run flat out.
18373
+ *
18374
+ * A rebuild is bulk maintenance on hub-main's single thread. Measured
18375
+ * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
18376
+ * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
18377
+ * force is logged at start and finish so a deliberately slow pass reads
18378
+ * differently from a stalled one.
18379
+ */
18380
+ pacingMs: number().int().nonnegative().optional()
18197
18381
  });
18198
- var ReferenceAudioEntrySchema = object({
18199
- filename: string(),
18200
- sizeKb: number()
18382
+ /**
18383
+ * Result of emptying the CLIP index.
18384
+ *
18385
+ * The clean slate before a policy change: a new crop margin or encoder model
18386
+ * leaves two feature spaces in one index whose cosine scores are not
18387
+ * comparable, so wiping and rebuilding is the only way to be sure every vector
18388
+ * means the same thing.
18389
+ */
18390
+ var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
18391
+ /**
18392
+ * Acknowledgement that a rebuild STARTED.
18393
+ *
18394
+ * The pass costs ~1s per track — 45 minutes for a 2,600-track fleet — so it
18395
+ * runs detached and this returns immediately. Waiting for it made the client
18396
+ * time out while the work carried on server-side, which is the worst of both:
18397
+ * no result and no way to know it was still going. Poll
18398
+ * `getObjectEmbeddingRebuildStatus` for progress.
18399
+ */
18400
+ var RebuildObjectEmbeddingsResultSchema = object({
18401
+ started: boolean(),
18402
+ /** True when a pass was already running; the new request is ignored. */
18403
+ alreadyRunning: boolean()
18201
18404
  });
18202
- var ReferenceAudioBodySchema = object({ base64: string() });
18203
- var AudioBackendSchema = object({
18204
- id: string(),
18205
- name: string(),
18206
- description: string(),
18207
- available: boolean(),
18405
+ var RebuildStatusSchema = object({
18406
+ running: boolean(),
18407
+ scanned: number(),
18408
+ rebuilt: number(),
18409
+ /** Tracks whose key frame is gone — nothing to re-embed from. */
18410
+ missingKeyFrame: number(),
18411
+ /** Tracks with no usable detection box. */
18412
+ missingBbox: number(),
18208
18413
  /**
18209
- * Raw classifier labels this backend can emit (e.g. YAMNet's
18210
- * 521-class set or Apple SoundAnalysis's 303-class set). Used by
18211
- * the benchmark UI to populate the `enabledMicroClasses` filter
18212
- * specific to the selected backend without a separate fetch.
18414
+ * Tracks an executing node REFUSED rather than broke on — an unreadable key
18415
+ * frame, a step that threw. Separate from `failed` because the remedy is
18416
+ * different, and because a whole camera silently contributing zero vectors
18417
+ * is the shape of failure a rebuild must never hide.
18213
18418
  */
18214
- rawLabels: array(string()).readonly().optional()
18215
- });
18216
- var AudioCapabilitiesSchema = object({
18217
- activeBackend: string(),
18218
- availableBackends: array(AudioBackendSchema).readonly(),
18219
- sampleRate: number(),
18220
- chunkDurationMs: number()
18221
- });
18222
- var DownloadModelResultSchema = object({
18223
- filePath: string(),
18224
- sizeMB: number(),
18225
- durationMs: number()
18419
+ notRunnable: number(),
18420
+ /**
18421
+ * The pass stopped because NO node could serve the pinned model.
18422
+ *
18423
+ * Distinct from `notRunnable` on purpose: that one says "this track was
18424
+ * refused", this one says "the cluster cannot do this work at all" — every
18425
+ * candidate node either lacks the `clip-embedding` step, lacks a build of the
18426
+ * pinned model for its engine format, or dropped out. The remedy is a model /
18427
+ * engine change, not a per-camera one. Non-zero here always comes with
18428
+ * `complete: false`.
18429
+ */
18430
+ noCapableNode: number(),
18431
+ failed: number(),
18432
+ /** Set once a pass ends: true only when EVERYTHING was covered. */
18433
+ complete: boolean().nullable(),
18434
+ startedAtMs: number().nullable(),
18435
+ finishedAtMs: number().nullable(),
18436
+ /** Present when the pass ended by throwing. */
18437
+ error: string().nullable()
18226
18438
  });
18227
- /**
18228
- * Wrapper carrying a single test run's result. Replaces the legacy
18229
- * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
18230
- * canonical `AudioResult` from the Phase 6 output rework: one
18231
- * `AudioDetection` per class above `minScore`, top-N candidates in
18232
- * `debug.alternateLabels['audio-classifier']`, per-source timings in
18233
- * `debug.stepTimings`. The outer `success`/`error` fields stay so the
18234
- * benchmark UI can still report a clean failure when the classifier
18235
- * cap isn't available.
18236
- */
18237
- var AudioTestResultSchema = object({
18238
- success: boolean(),
18239
- error: string().optional(),
18240
- frame: custom().optional()
18439
+ var ReplayFrameInputSchema = object({
18440
+ timestamp: number(),
18441
+ frame: PipelineRunResultBridge
18241
18442
  });
18242
- var PipelineConfigBridge = custom();
18243
- var ConfigUISchemaBridge = custom();
18244
- var ConfigUISchemaNullableBridge = custom();
18245
- var InferenceCapabilitiesBridge = custom();
18246
- var ModelAvailabilityListBridge = custom();
18247
- var PipelineRunResultBridge = custom();
18248
- method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
18249
- modelId: string(),
18250
- settings: record(string(), unknown()).readonly()
18251
- }))), method(object({ steps: record(string(), object({
18252
- modelId: string(),
18253
- settings: record(string(), unknown()).readonly()
18254
- })) }), object({ success: literal(true) }), {
18443
+ var RunReplayFrameProcessorResultSchema = object({ tracks: array(object({
18444
+ className: string(),
18445
+ firstSeenMs: number(),
18446
+ lastSeenMs: number(),
18447
+ /** Bbox of the track's FIRST matched detection, pixel-space in the clip's
18448
+ * frame a representative box for the diff's `(className, window, IoU)`
18449
+ * pairing (`replay-diff.ts`). A replay does not need the full per-frame
18450
+ * trajectory production's `Track.positions` keeps. */
18451
+ bbox: BoundingBoxSchema,
18452
+ /** How many of the input frames this track matched a real detection on
18453
+ * (never a coasted/extrapolated frame) — the replay's own signal for "how
18454
+ * solid is this track", cheaper than re-deriving it from a trajectory. */
18455
+ framesMatched: number().int()
18456
+ })).readonly() });
18457
+ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
18458
+ deviceId: number(),
18459
+ trackId: string()
18460
+ }), TrackSchema.nullable()), method(object({
18461
+ deviceId: number(),
18462
+ since: number().optional(),
18463
+ until: number().optional(),
18464
+ limit: number().optional(),
18465
+ /** Spatial filter — only tracks whose trajectory intersects the zone
18466
+ * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
18467
+ * envelope columns, then precisely tested per position. Tracks with
18468
+ * an unknown envelope (no frame dims at persist time) always match. */
18469
+ zone: TrackZoneFilterSchema.optional(),
18470
+ /** See {@link TrackProjectionSchema}. Default `full` (backward
18471
+ * compatible — omitting the field keeps today's exact behaviour). */
18472
+ projection: TrackProjectionSchema.optional(),
18473
+ /** Include stationary-promoted rows (parked objects handed to the
18474
+ * stationary registry). Default false: the timeline lists passages,
18475
+ * not parking records (operator decision, 2026-08-15). */
18476
+ includeStationary: boolean().optional()
18477
+ }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
18478
+ deviceId: number(),
18479
+ groupId: string().min(1)
18480
+ }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
18255
18481
  kind: "mutation",
18256
18482
  auth: "admin"
18257
- }), method(object({ nodeId: string() }), object({
18258
- success: literal(true),
18259
- clearedDevices: number()
18483
+ }), 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({
18484
+ deviceId: number(),
18485
+ since: number().optional(),
18486
+ until: number().optional(),
18487
+ kinds: array(string()).optional(),
18488
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
18489
+ }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
18490
+ deviceId: number(),
18491
+ since: number(),
18492
+ until: number(),
18493
+ bucketMs: number().int().positive()
18494
+ }), array(object({
18495
+ bucketStart: number(),
18496
+ motion: number().int(),
18497
+ object: number().int(),
18498
+ audio: number().int()
18499
+ })).readonly()), method(object({
18500
+ deviceId: number(),
18501
+ cutoffMs: number()
18502
+ }), object({
18503
+ motion: number().int(),
18504
+ object: number().int(),
18505
+ audio: number().int()
18260
18506
  }), {
18261
18507
  kind: "mutation",
18262
18508
  auth: "admin"
18263
- }), 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({
18264
- name: string(),
18265
- steps: array(PipelineTemplateStepSchema).readonly(),
18266
- engine: PipelineEngineChoiceSchema
18267
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
18268
- id: string(),
18269
- name: string().optional(),
18270
- steps: array(PipelineTemplateStepSchema).readonly().optional()
18271
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
18272
- addonId: string(),
18273
- modelId: string(),
18274
- format: ModelFormatSchema$1
18275
- }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
18276
- addonId: string(),
18277
- modelId: string(),
18278
- format: ModelFormatSchema$1
18279
- }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
18280
- engine: PipelineEngineChoiceSchema.optional(),
18281
- steps: array(PipelineStepInputSchema).min(1),
18282
- frame: FrameInputSchema.optional(),
18283
- /**
18284
- * Process-local lazy frame. Valid only when caller and provider resolve
18285
- * in the same execution-group process; split/cross-node callers use
18286
- * `frame`/`image` inline compatibility instead.
18287
- */
18288
- frameRef: FrameRefSchema.optional(),
18289
- /**
18290
- * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
18291
- * the decoded pixels live in. One more member of the one-of
18292
- * frame/frameHandle/image/imageBase64/referenceImage group.
18293
- */
18294
- frameHandle: FrameHandleSchema.optional(),
18295
- imageBase64: string().optional(),
18296
- /**
18297
- * Binary JPEG bytes — preferred over `imageBase64` on internal
18298
- * hops (hub → forked worker via Moleculer MsgPack) because it
18299
- * skips the 33% base64 overhead + the per-call base64 decode on
18300
- * the detection-pipeline worker. Callers can pass either; exactly
18301
- * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
18302
- */
18303
- image: _instanceof(Uint8Array).optional(),
18304
- referenceImage: string().optional(),
18305
- deviceId: number().optional(),
18306
- sessionId: string().optional(),
18307
- /**
18308
- * Execution plane. 'full' (default) runs the whole tree — benchmark,
18309
- * reference-image, and detail-subtree calls. 'frame' is the live
18310
- * per-frame dispatch: ONLY root-plane steps run; crop children
18311
- * (inputClasses ≠ null) are skipped and served per-track via
18312
- * pipelineRunner.runDetailSubtree (two-plane design).
18313
- */
18314
- plane: _enum(["full", "frame"]).optional(),
18315
- /**
18316
- * Inference-device selector (Phase 2 multi-device). Format
18317
- * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
18318
- * Omitted ⇒ the runner's default device (current single-engine
18319
- * behaviour). Selects WHICH device pool of the node runs the call.
18320
- */
18321
- deviceKey: string().optional(),
18322
- /**
18323
- * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
18324
- * when the parent crop was resolved from the frame's retained NATIVE
18325
- * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
18326
- * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
18327
- * resolution from that surface — the SAME quality path faces already
18328
- * had — instead of the downscaled parent tile. `handle` keys the native
18329
- * surface (node-pinned to its owner); `cropFrameSpace` is the parent
18330
- * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
18331
- * the executor's crop-normalized child ROI back into frame-normalized
18332
- * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
18333
- * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
18334
- * (today's behaviour on the fallback path).
18335
- */
18336
- nativeCropRef: NativeCropRefSchema.optional()
18337
- }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
18338
- engine: PipelineEngineChoiceSchema.optional(),
18339
- steps: array(PipelineStepInputSchema).min(1),
18340
- frames: array(FrameInputSchema).min(1).max(255),
18341
- deviceId: number().optional(),
18342
- sessionId: string().optional(),
18343
- /**
18344
- * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
18345
- * the batch to the Python pool's bench preprocess cache
18346
- * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
18347
- * preprocessed ONCE and every later inference is a pure-inference cache
18348
- * hit — the sustained-throughput run measures inference, not
18349
- * decode+preprocess+infer. Omitted/0 for live frames (all different →
18350
- * full preprocess every call, correct). Fresh per sustained run;
18351
- * released via `uncacheFrame`.
18352
- */
18353
- frameId: number().int().nonnegative().optional(),
18354
- /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
18355
- deviceKey: string().optional()
18356
- }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
18357
- data: _instanceof(Uint8Array),
18358
- width: number().int().positive(),
18359
- height: number().int().positive(),
18360
- format: _enum([
18361
- "rgb",
18362
- "bgr",
18363
- "gray"
18364
- ])
18509
+ }), method(object({
18510
+ deviceId: number(),
18511
+ cutoffMs: number()
18512
+ }), TrackCascadeCountsSchema, {
18513
+ kind: "mutation",
18514
+ auth: "admin"
18515
+ }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
18516
+ kind: "mutation",
18517
+ auth: "admin"
18518
+ }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
18519
+ kind: "mutation",
18520
+ auth: "admin"
18521
+ }), method(object({
18522
+ deviceId: number(),
18523
+ trackIds: array(string()).min(1)
18365
18524
  }), object({
18366
- frameId: number(),
18367
- width: number(),
18368
- height: number()
18369
- }), { kind: "mutation" }), method(object({
18370
- stepId: string(),
18371
- frameId: number().int()
18372
- }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
18373
- batchMode: string(),
18374
- windowMs: number(),
18375
- maxBatchSize: number(),
18376
- concurrency: number()
18377
- })), method(_void(), array(object({
18378
- engineKey: string(),
18379
- engine: PipelineEngineChoiceSchema,
18380
- modelsLoaded: array(string()).readonly(),
18381
- inUseByCameras: array(number()).readonly(),
18382
- /**
18383
- * Origin of this resident factory.
18384
- * - `runtime` — main camera-serving engine (no idle TTL).
18385
- * - `warm-override` — benchmark/test override held in the warm
18386
- * cache; auto-disposed after the idle TTL.
18387
- * - `device-pool` — a concurrent per-device pool (Phase 2
18388
- * multi-device, keyed by `deviceKey`) resolved
18389
- * via `resolveDeviceFactory`. Runs alongside the
18390
- * `runtime` engine on a DIFFERENT accelerator
18391
- * (NPU / iGPU / Coral) — this is how the
18392
- * Engines tab shows all pools running at once.
18393
- */
18394
- kind: _enum([
18395
- "runtime",
18396
- "warm-override",
18397
- "device-pool"
18398
- ]),
18399
- /** Native pid of the underlying Python pool (null when no pool). */
18400
- poolPid: number().nullable(),
18401
- /** ms since this factory was last used (null when not warm-tracked). */
18402
- idleMs: number().nullable(),
18403
- /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
18404
- idleTtlMs: number().nullable()
18405
- })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
18525
+ deleted: number().int(),
18526
+ failed: array(string()).readonly()
18527
+ }), {
18406
18528
  kind: "mutation",
18407
18529
  auth: "admin"
18408
18530
  }), method(object({
18409
- engine: PipelineEngineChoiceSchema,
18410
- force: boolean().optional()
18531
+ /** Log/audit scope only — the trackId is globally unique on its own. */
18532
+ deviceId: number(),
18533
+ trackId: string(),
18534
+ flags: TrackFlagsPatchSchema
18535
+ }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
18536
+ kind: "query",
18537
+ auth: "admin"
18538
+ }), method(object({
18539
+ olderThanMs: number(),
18540
+ reason: OpsLogReasonSchema.optional()
18541
+ }), EventPruneCountsSchema, {
18542
+ kind: "mutation",
18543
+ auth: "admin"
18544
+ }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
18545
+ kind: "mutation",
18546
+ auth: "admin"
18547
+ }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
18548
+ kind: "mutation",
18549
+ auth: "admin"
18550
+ }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
18551
+ kind: "mutation",
18552
+ auth: "admin"
18553
+ }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
18554
+ kind: "mutation",
18555
+ auth: "admin"
18556
+ }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
18557
+ kind: "mutation",
18558
+ auth: "admin"
18559
+ }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18560
+ kind: "mutation",
18561
+ auth: "admin"
18562
+ }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
18563
+ kind: "mutation",
18564
+ auth: "admin"
18565
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
18566
+ kind: "query",
18567
+ auth: "admin"
18568
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18569
+ kind: "mutation",
18570
+ auth: "admin"
18571
+ }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
18572
+ kind: "query",
18573
+ auth: "admin"
18574
+ }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
18575
+ kind: "query",
18576
+ auth: "admin"
18577
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18578
+ kind: "query",
18579
+ auth: "admin"
18580
+ }), method(object({
18581
+ /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
18582
+ * `deviceId`, deliberately: `deviceId` would make this device-bound and
18583
+ * route it at one camera's owner, and "every camera" would stop being
18584
+ * expressible at all. */
18585
+ deviceIds: array(number()).optional(),
18586
+ limit: number().int().min(1).max(500).optional()
18587
+ }), array(RetrainTrackSchema).readonly(), {
18588
+ kind: "query",
18589
+ auth: "admin"
18590
+ }), method(object({ trackId: string() }), RetrainFrameListSchema, {
18591
+ kind: "query",
18592
+ auth: "admin"
18593
+ }), method(object({
18594
+ deviceId: number(),
18595
+ trackId: string(),
18596
+ mediaKeys: array(string()).min(1)
18597
+ }), RetrainFrameSelectionSchema, {
18598
+ kind: "mutation",
18599
+ auth: "admin"
18600
+ }), method(object({
18601
+ deviceId: number(),
18602
+ trackId: string(),
18603
+ frameId: string()
18411
18604
  }), object({
18412
- success: boolean(),
18413
- reason: string().optional()
18605
+ removed: boolean(),
18606
+ removedAnnotations: number().int()
18414
18607
  }), {
18415
18608
  kind: "mutation",
18416
18609
  auth: "admin"
18417
- }), 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({
18418
- addonId: string(),
18419
- modelId: string(),
18420
- filename: string().optional(),
18421
- settings: record(string(), unknown()).optional()
18422
- }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
18423
- object({
18424
- activeCameras: number(),
18425
- throttledCameras: number(),
18426
- avgInferenceTimeMs: number(),
18427
- queueDepth: number()
18428
- });
18429
- var CameraMetricsSchema = object({
18430
- detectionMode: _enum([
18431
- "disabled",
18432
- "always-on",
18433
- "on-motion"
18434
- ]),
18435
- configuredFps: number(),
18436
- actualFps: number(),
18437
- queueDepth: number(),
18438
- avgInferenceTimeMs: number(),
18439
- droppedFrames: number(),
18440
- phase: _enum([
18441
- "idle",
18442
- "watching",
18443
- "active"
18444
- ])
18445
- });
18446
- var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
18447
- /**
18448
- * Zone — pure geometry + identity. NO filtering behaviour.
18449
- *
18450
- * Zones describe **where** in the frame the operator wants to flag
18451
- * something; consumer-owned {@link ZoneRule} arrays describe **how**
18452
- * each pipeline stage uses them. Splitting the two means a single
18453
- * polygon "Driveway" can simultaneously back a motion-exclude rule,
18454
- * a detection-include rule on `['car']`, and an occupancy aggregate
18455
- * — without three duplicated polygons.
18456
- *
18457
- * Owned by the orchestrator addon (provider) and mirrored into the
18458
- * `zones` device-state slice on every mutation. Consumers
18459
- * (motion-wasm, pipeline-executor, analytics, admin UI) read either
18460
- * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
18461
- * mirror with `onChanged`).
18462
- *
18463
- * Coordinates are normalised fractions of the frame (0–1) so zones
18464
- * survive resolution changes and stream profile switches.
18465
- *
18466
- * `kind` discriminates between full polygons (closed regions used
18467
- * for intrusion / occupancy filters) and tripwires (open 2-point
18468
- * line segments used for cross events). Onboard / firmware-reported
18469
- * zones (Reolink, ONVIF) are out of scope for now — see the deferred
18470
- * task list.
18471
- */
18472
- var ZoneKindEnum = _enum(["polygon", "tripwire"]);
18473
- /** Polygon vertex in fraction-of-frame coordinates (0–1). */
18474
- var PolygonPointSchema = object({
18475
- x: number(),
18476
- y: number()
18477
- });
18478
- /** A camera detection zone — pure geometry/identity. */
18479
- var ZoneSchema = object({
18480
- id: string(),
18481
- name: string(),
18482
- kind: ZoneKindEnum.default("polygon"),
18483
- /** Polygon vertices, fraction of frame (0–1). */
18484
- polygon: array(PolygonPointSchema).readonly(),
18485
- /** Visual color for UI rendering. */
18486
- color: string().default("#3b82f6")
18487
- });
18488
- DeviceType.Camera, method(object({ deviceId: number() }), array(ZoneSchema).readonly()), method(object({
18610
+ }), method(object({ frameId: string() }), object({
18611
+ base64: string(),
18612
+ width: number().int(),
18613
+ height: number().int()
18614
+ }), {
18615
+ kind: "query",
18616
+ auth: "admin"
18617
+ }), method(object({
18489
18618
  deviceId: number(),
18490
- zone: ZoneSchema
18491
- }), _void(), {
18619
+ trackId: string(),
18620
+ frameId: string(),
18621
+ subject: RetrainAssistSubjectSchema,
18622
+ /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
18623
+ nodeId: string().optional()
18624
+ }), RetrainAssistResultSchema, {
18492
18625
  kind: "mutation",
18493
18626
  auth: "admin"
18494
18627
  }), method(object({
18495
18628
  deviceId: number(),
18496
- zoneId: string()
18497
- }), _void(), {
18629
+ source: DetectionSourceSchema,
18630
+ zones: array(ZoneSchema).readonly().optional(),
18631
+ detectionRules: array(ZoneRuleSchema).readonly().optional(),
18632
+ zoneMembershipMinOverlap: number().min(0).max(1).optional(),
18633
+ frames: array(ReplayFrameInputSchema).min(1)
18634
+ }), RunReplayFrameProcessorResultSchema, {
18635
+ kind: "mutation",
18636
+ auth: "admin"
18637
+ }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
18638
+ kind: "query",
18639
+ auth: "admin"
18640
+ }), method(object({
18641
+ deviceId: number(),
18642
+ trackId: string(),
18643
+ frameId: string(),
18644
+ annotations: array(RetrainAnnotationDraftSchema)
18645
+ }), array(RetrainAnnotationSchema).readonly(), {
18646
+ kind: "mutation",
18647
+ auth: "admin"
18648
+ }), method(object({
18649
+ deviceId: number(),
18650
+ trackId: string()
18651
+ }), RetrainTransitionResultSchema, {
18652
+ kind: "mutation",
18653
+ auth: "admin"
18654
+ }), method(object({
18655
+ deviceId: number(),
18656
+ trackId: string()
18657
+ }), RetrainTransitionResultSchema, {
18658
+ kind: "mutation",
18659
+ auth: "admin"
18660
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18661
+ kind: "query",
18662
+ auth: "admin"
18663
+ }), method(object({
18664
+ eventId: string(),
18665
+ kind: MediaFileKindEnum.optional(),
18666
+ deviceId: number()
18667
+ }), array(MediaFileSchema).readonly()), method(object({
18668
+ trackId: string(),
18669
+ kinds: array(MediaFileKindEnum).optional(),
18670
+ deviceId: number()
18671
+ }), array(MediaFileSchema).readonly()), method(object({
18672
+ trackId: string(),
18673
+ deviceId: number()
18674
+ }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
18498
18675
  kind: "mutation",
18499
18676
  auth: "admin"
18500
- }), method(object({
18501
- deviceId: number(),
18502
- zone: ZoneSchema
18503
- }), _void(), {
18677
+ }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
18504
18678
  kind: "mutation",
18505
18679
  auth: "admin"
18506
- }), object({ zones: array(ZoneSchema).readonly() });
18680
+ }), method(object({}), RebuildStatusSchema), object({
18681
+ deviceId: number(),
18682
+ timestamp: number(),
18683
+ frameWidth: number(),
18684
+ frameHeight: number(),
18685
+ detections: array(OverlayDetectionSchema).readonly()
18686
+ }), object({
18687
+ deviceId: number(),
18688
+ trackId: string(),
18689
+ className: string()
18690
+ }), object({
18691
+ deviceId: number(),
18692
+ trackId: string(),
18693
+ className: string(),
18694
+ durationMs: number()
18695
+ }), object({
18696
+ deviceId: number(),
18697
+ kind: EventKindSchema,
18698
+ eventId: string(),
18699
+ timestamp: number()
18700
+ });
18701
+ object({
18702
+ activeCameras: number(),
18703
+ throttledCameras: number(),
18704
+ avgInferenceTimeMs: number(),
18705
+ queueDepth: number()
18706
+ });
18707
+ var CameraMetricsSchema = object({
18708
+ detectionMode: _enum([
18709
+ "disabled",
18710
+ "always-on",
18711
+ "on-motion"
18712
+ ]),
18713
+ configuredFps: number(),
18714
+ actualFps: number(),
18715
+ queueDepth: number(),
18716
+ avgInferenceTimeMs: number(),
18717
+ droppedFrames: number(),
18718
+ phase: _enum([
18719
+ "idle",
18720
+ "watching",
18721
+ "active"
18722
+ ])
18723
+ });
18724
+ var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
18507
18725
  /**
18508
18726
  * A bounding box in NORMALIZED [0,1] frame coordinates for `getNativeCrop`. The
18509
18727
  * decode worker resolves it against the RETAINED native frame's real pixel dims,
@@ -20192,7 +20410,7 @@ method(object({
20192
20410
  * linking rather than produce an eternal token.
20193
20411
  */
20194
20412
  ttlSec: union([number().int().positive(), literal("never")]).optional()
20195
- }), object({ token: string() })), method(object({ token: string() }), SsoBridgeClaimsSchema.nullable());
20413
+ }), object({ token: string() }), { auth: "admin" }), method(object({ token: string() }), SsoBridgeClaimsSchema.nullable(), { auth: "admin" });
20196
20414
  var ProviderListEntrySchema = discriminatedUnion("shouldSaveDiskSpace", [object({
20197
20415
  providerId: string().min(1),
20198
20416
  displayName: string().min(1),
@@ -20287,10 +20505,13 @@ var EvictResultSchema = object({
20287
20505
  /** True when the provider has nothing left it is willing to drop on this location. */
20288
20506
  exhausted: boolean()
20289
20507
  });
20290
- method(object({ locationId: string() }), EvictableUsageSchema), method(object({
20508
+ method(object({ locationId: string() }), EvictableUsageSchema, { auth: "admin" }), method(object({
20291
20509
  locationId: string(),
20292
20510
  targetBytes: number().int().positive()
20293
- }), EvictResultSchema, { kind: "mutation" });
20511
+ }), EvictResultSchema, {
20512
+ kind: "mutation",
20513
+ auth: "admin"
20514
+ });
20294
20515
  method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin" }), method(StorageMigrationInputSchema, object({ jobId: string() }), {
20295
20516
  kind: "mutation",
20296
20517
  auth: "admin"
@@ -20350,26 +20571,50 @@ var ReadChunkInputSchema = object({
20350
20571
  length: number()
20351
20572
  });
20352
20573
  var EndDownloadInputSchema = object({ downloadId: string() });
20353
- method(_void(), ProviderInfoSchema), method(object({ config: record(string(), unknown()) }), TestLocationResultSchema, { auth: "admin" }), method(object({
20574
+ method(_void(), ProviderInfoSchema, { auth: "admin" }), method(object({ config: record(string(), unknown()) }), TestLocationResultSchema, { auth: "admin" }), method(object({
20354
20575
  location: StorageLocationSchema,
20355
20576
  relativePath: string()
20356
- }), string()), method(object({
20577
+ }), string(), { auth: "admin" }), method(object({
20357
20578
  location: StorageLocationSchema,
20358
20579
  relativePath: string(),
20359
20580
  data: _instanceof(Uint8Array)
20360
- }), _void(), { kind: "mutation" }), method(object({
20581
+ }), _void(), {
20582
+ kind: "mutation",
20583
+ auth: "admin"
20584
+ }), method(object({
20361
20585
  location: StorageLocationSchema,
20362
20586
  relativePath: string()
20363
- }), _instanceof(Uint8Array)), method(object({
20587
+ }), _instanceof(Uint8Array), { auth: "admin" }), method(object({
20364
20588
  location: StorageLocationSchema,
20365
20589
  relativePath: string()
20366
- }), boolean()), method(object({
20590
+ }), boolean(), { auth: "admin" }), method(object({
20367
20591
  location: StorageLocationSchema,
20368
20592
  prefix: string().optional()
20369
- }), array(string()).readonly()), method(object({
20593
+ }), array(string()).readonly(), { auth: "admin" }), method(object({
20370
20594
  location: StorageLocationSchema,
20371
20595
  relativePath: string()
20372
- }), _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" });
20596
+ }), _void(), {
20597
+ kind: "mutation",
20598
+ auth: "admin"
20599
+ }), method(object({ location: StorageLocationSchema }), number().nullable(), { auth: "admin" }), method(BeginUploadInputSchema, BeginUploadResultSchema, {
20600
+ kind: "mutation",
20601
+ auth: "admin"
20602
+ }), method(WriteChunkInputSchema, _void(), {
20603
+ kind: "mutation",
20604
+ auth: "admin"
20605
+ }), method(FinalizeUploadInputSchema, _void(), {
20606
+ kind: "mutation",
20607
+ auth: "admin"
20608
+ }), method(AbortUploadInputSchema, _void(), {
20609
+ kind: "mutation",
20610
+ auth: "admin"
20611
+ }), method(BeginDownloadInputSchema, BeginDownloadResultSchema, {
20612
+ kind: "mutation",
20613
+ auth: "admin"
20614
+ }), method(ReadChunkInputSchema, _instanceof(Uint8Array), { auth: "admin" }), method(EndDownloadInputSchema, _void(), {
20615
+ kind: "mutation",
20616
+ auth: "admin"
20617
+ });
20373
20618
  /** Profile-exported FormBuilder schema. Shape is ConfigUISchema at the UI. */
20374
20619
  var ProfileSettingsSchemaBridge = unknown().nullable();
20375
20620
  var ProfileSettingsBagSchema = record(string(), unknown());
@@ -20627,7 +20872,8 @@ method(object({
20627
20872
  access: "create"
20628
20873
  }), method(object({ userId: string().optional() }), object({ optionsJSON: record(string(), unknown()) }), {
20629
20874
  kind: "mutation",
20630
- access: "view"
20875
+ access: "view",
20876
+ auth: "admin"
20631
20877
  }), method(object({
20632
20878
  /** Required — the user the assertion belongs to (verified). */
20633
20879
  userId: string(),
@@ -20635,10 +20881,12 @@ method(object({
20635
20881
  response: record(string(), unknown())
20636
20882
  }), object({ verified: boolean() }), {
20637
20883
  kind: "mutation",
20638
- access: "view"
20884
+ access: "view",
20885
+ auth: "admin"
20639
20886
  }), method(object({}), object({ optionsJSON: record(string(), unknown()) }), {
20640
20887
  kind: "mutation",
20641
- access: "view"
20888
+ access: "view",
20889
+ auth: "admin"
20642
20890
  }), method(object({
20643
20891
  /** AuthenticationResponseJSON from the browser. */
20644
20892
  response: record(string(), unknown()) }), object({
@@ -20646,7 +20894,8 @@ response: record(string(), unknown()) }), object({
20646
20894
  userId: string().nullable()
20647
20895
  }), {
20648
20896
  kind: "mutation",
20649
- access: "view"
20897
+ access: "view",
20898
+ auth: "admin"
20650
20899
  }), method(object({ userId: string() }), array(PasskeySummarySchema), { auth: "admin" }), method(object({
20651
20900
  userId: string(),
20652
20901
  credentialId: string()
@@ -20818,7 +21067,19 @@ var VectorStatsResultSchema = object({
20818
21067
  /** False when the backend ranks approximately. */
20819
21068
  exact: boolean()
20820
21069
  });
20821
- 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);
21070
+ method(VectorDeclareIndexInputSchema, _void(), {
21071
+ kind: "mutation",
21072
+ auth: "admin"
21073
+ }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
21074
+ kind: "mutation",
21075
+ auth: "admin"
21076
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
21077
+ kind: "mutation",
21078
+ auth: "admin"
21079
+ }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
21080
+ kind: "mutation",
21081
+ auth: "admin"
21082
+ }), method(VectorStatsInputSchema, VectorStatsResultSchema, { auth: "admin" });
20822
21083
  var ClipSchema = object({
20823
21084
  /** Opaque, provider-namespaced id. The default provider encodes the time
20824
21085
  * window so `getClipPlayback` is self-contained (no event re-query). */
@@ -22541,7 +22802,27 @@ var MediaFileLiteSchema$1 = object({
22541
22802
  sizeBytes: number(),
22542
22803
  timestamp: number()
22543
22804
  });
22544
- method(_void(), array(IdentitySchema).readonly()), method(object({ name: string().min(1) }), IdentitySchema, {
22805
+ method(object({
22806
+ /**
22807
+ * Inline {@link IdentitySchema.coverBase64} on every row.
22808
+ *
22809
+ * Default `false`, the same inversion `listRecentFaces` and
22810
+ * `listPlates` took on 2026-08-25 (see `include-crops-default.ts` for
22811
+ * why the burden belongs on the caller that WANTS the bytes). Measured
22812
+ * on the live hub the same day: four identities cost 40,979 B with the
22813
+ * covers inline, ~10 KB of base64 per row, on a query this UI mounts
22814
+ * four times and the viewer holds at `staleTime: 30_000`.
22815
+ *
22816
+ * Nothing loses its avatar: `coverMediaKey` is already on every row and
22817
+ * the `event-media` plane serves that key `immutable` with an ETag.
22818
+ *
22819
+ * **This is an INPUT field, so it does not reach the addon until the
22820
+ * next train** — the hub router validates cap inputs against its own
22821
+ * compiled Zod and strips a key it does not know. Until then the
22822
+ * provider sees `undefined`, which resolves to `false`: the cheap shape
22823
+ * is what ships, and the opt-in becomes reachable when the train lands.
22824
+ */
22825
+ includeCrops: boolean().optional() }).optional(), array(IdentitySchema).readonly()), method(object({ name: string().min(1) }), IdentitySchema, {
22545
22826
  kind: "mutation",
22546
22827
  auth: "admin"
22547
22828
  }), method(object({
@@ -24688,8 +24969,10 @@ var PlateInfoSchema = object({
24688
24969
  keyFrameMediaKey: string().optional(),
24689
24970
  base64: string().optional(),
24690
24971
  /**
24691
- * Same crop as a data-plane URL. `getPlateByTrack` returns this and
24692
- * never inlines JPEG; `listPlates` still inlines for the admin-ui.
24972
+ * Same crop as a data-plane URL, always present when the plate has a stored
24973
+ * crop. `getPlateByTrack` returns this and never inlines JPEG; `listPlates`
24974
+ * and `searchPlates` inline the crop only when their `includeCrops` input is
24975
+ * left at its `true` default.
24693
24976
  */
24694
24977
  cropUrl: string().optional()
24695
24978
  });
@@ -24709,14 +24992,34 @@ var PlateClusterSchema = object({
24709
24992
  });
24710
24993
  method(object({
24711
24994
  deviceId: number().int().optional(),
24712
- limit: number().int().positive().optional()
24995
+ limit: number().int().positive().optional(),
24996
+ /**
24997
+ * Inline the base64 crop on every row. Default `true` — the existing
24998
+ * behaviour, kept so no caller breaks.
24999
+ *
25000
+ * Set `false` once the caller renders {@link PlateInfo.cropUrl}.
25001
+ * Measured on the live hub at the 500 rows the Plates view asks for:
25002
+ * 879,403 B and 27.7 s with the crops inline, against a few KiB of
25003
+ * metadata without them — and the browser then caches the images.
25004
+ *
25005
+ * This is the plate twin of `faceGallery.listRecentFaces`'s option;
25006
+ * plates were the one gallery list left without it.
25007
+ *
25008
+ * **This is an INPUT field, so it does not reach the addon until the
25009
+ * next train.** The hub router validates cap inputs against its own
25010
+ * compiled Zod and strips a key it does not know. Until the train
25011
+ * ships, sending `false` is harmless and keeps the crops inline.
25012
+ */
25013
+ includeCrops: boolean().optional()
24713
25014
  }).optional(), array(PlateInfoSchema).readonly()), method(object({
24714
25015
  deviceId: number().int(),
24715
25016
  trackId: string()
24716
25017
  }), PlateInfoSchema.nullable()), method(object({ plateId: string() }), array(MediaFileLiteSchema).readonly()), method(object({
24717
25018
  text: string().min(1),
24718
25019
  maxDistance: number().int().min(0).optional(),
24719
- limit: number().int().positive().optional()
25020
+ limit: number().int().positive().optional(),
25021
+ /** See `listPlates.includeCrops`. Default `true`. */
25022
+ includeCrops: boolean().optional()
24720
25023
  }), array(PlateInfoSchema).readonly()), method(object({
24721
25024
  maxDistance: number().int().min(0).optional(),
24722
25025
  minClusterSize: number().int().min(2).optional(),
@@ -24730,7 +25033,13 @@ method(object({
24730
25033
  }), method(object({ plateId: string() }), _void(), {
24731
25034
  kind: "mutation",
24732
25035
  auth: "admin"
24733
- }), method(_void(), array(VehicleSchema).readonly()), method(object({ name: string().min(1) }), VehicleSchema, {
25036
+ }), method(object({
25037
+ /** Inline {@link VehicleSchema.coverBase64} on every row. Default
25038
+ * `false` — the vehicle twin of `faceGallery.listIdentities`'s
25039
+ * option; `coverMediaKey` + the `event-media` plane carry the picture.
25040
+ * INPUT field: stripped by the hub router until the train ships, which
25041
+ * resolves to `false` and is exactly the intended default. */
25042
+ includeCrops: boolean().optional() }).optional(), array(VehicleSchema).readonly()), method(object({ name: string().min(1) }), VehicleSchema, {
24734
25043
  kind: "mutation",
24735
25044
  auth: "admin"
24736
25045
  }), method(object({
@@ -25995,92 +26304,6 @@ DeviceType.Camera, method(object({ deviceId: number() }), SceneMonitorStatusSche
25995
26304
  kind: "mutation",
25996
26305
  auth: "admin"
25997
26306
  });
25998
- /**
25999
- * Per-stage gating mode applied to the zones a rule references.
26000
- *
26001
- * - `include`: the rule contributes to a **whitelist** for its stage.
26002
- * When at least one `include` rule fires for a stage, only entities
26003
- * inside one of those zones pass that stage.
26004
- * - `exclude`: the rule contributes to a **blacklist** for its stage.
26005
- * Entities inside one of those zones are dropped at that stage.
26006
- *
26007
- * `monitor`-style observation (count without filtering) is not a rule
26008
- * mode — zones without any matching rule are observed naturally by
26009
- * `zone-analytics` (live snapshot + history), so an "I just want to
26010
- * count, not filter" use case needs no rule at all.
26011
- */
26012
- var ZoneRuleModeEnum = _enum(["include", "exclude"]);
26013
- /**
26014
- * Per-consumer rule that references existing zones (geometry) and
26015
- * defines how a specific pipeline stage should treat them. Each
26016
- * consumer addon owns its own `ZoneRule[]` array in its per-device
26017
- * settings:
26018
- *
26019
- * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
26020
- * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
26021
- * - future: notification rules, audio gating, etc.
26022
- *
26023
- * One rule applies to N zones (`zoneIds[]`) so the operator can
26024
- * express "ignore motion in ALL of {garden, street}" with a single
26025
- * rule. `classFilter` narrows the rule to specific object classes —
26026
- * "drop person detections in the street, but keep cars" is one
26027
- * `exclude` rule with `classFilter: ['person']`.
26028
- *
26029
- * `enabled` is a soft toggle — the operator can keep the rule
26030
- * configured but inert without deleting it.
26031
- */
26032
- var ZoneRuleSchema = object({
26033
- /** Stable rule id — survives edits, used by the UI for diffing. */
26034
- id: string(),
26035
- /** Optional human-readable label rendered in the rule editor. */
26036
- name: string().optional(),
26037
- /** Zones this rule targets. The rule's `mode` applies to ALL
26038
- * listed zones (OR-set: a detection in any one of them counts).
26039
- * At least one zone id required — a rule with no targets is a
26040
- * configuration mistake and the form validator rejects it. */
26041
- zoneIds: array(string()).min(1).readonly(),
26042
- mode: ZoneRuleModeEnum,
26043
- /**
26044
- * Class names this rule applies to. Empty / undefined ⇒ rule
26045
- * applies to every class. Class strings match the `macroClass`
26046
- * field on detections (e.g. `person`, `car`, `dog`).
26047
- */
26048
- classFilter: array(string()).readonly().optional(),
26049
- /**
26050
- * Minimum bbox/mask overlap (0–1) with any of the rule's zones
26051
- * required to consider an entity "in the zone". Defaults to the
26052
- * consumer's stage default when omitted. Kept for back-compat with
26053
- * existing per-rule overrides; new operators pick the value via
26054
- * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
26055
- * set, the lower-level engine reads it as a 0–1 fraction.
26056
- */
26057
- overlapThreshold: number().min(0).max(1).optional(),
26058
- /**
26059
- * Operator-friendly version of `overlapThreshold` — the percentage
26060
- * of the detection's bbox that must lie inside the zone for the
26061
- * rule to match. Documented default is 85%; the engine substitutes
26062
- * that when the field is omitted (kept optional so existing rules
26063
- * stored without it stay valid).
26064
- *
26065
- * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
26066
- * rule, the engine prefers `bboxInclusionPct` because it's the
26067
- * field exposed in the UI. Internally both feed the same gate.
26068
- */
26069
- bboxInclusionPct: number().min(0).max(100).optional(),
26070
- /**
26071
- * When `true` and a detection has a segmentation mask, use the
26072
- * mask for overlap instead of the bbox. Detection-stage only;
26073
- * motion rules ignore this field.
26074
- */
26075
- preferMask: boolean().optional(),
26076
- /**
26077
- * Soft-toggle: `false` disables the rule without deleting it.
26078
- * Defaults to `true` so operators creating a rule via the UI
26079
- * see it active immediately.
26080
- */
26081
- enabled: boolean().default(true)
26082
- });
26083
- array(ZoneRuleSchema).readonly();
26084
26307
  object({
26085
26308
  /** Whether the script is currently executing. */
26086
26309
  isRunning: boolean(),
@@ -30107,6 +30330,12 @@ Object.freeze({
30107
30330
  addonId: null,
30108
30331
  access: "create"
30109
30332
  },
30333
+ "pipelineAnalytics.cancelRelocateMedia": {
30334
+ capName: "pipeline-analytics",
30335
+ capScope: "device",
30336
+ addonId: null,
30337
+ access: "create"
30338
+ },
30110
30339
  "pipelineAnalytics.cancelStorageMigrationMove": {
30111
30340
  capName: "pipeline-analytics",
30112
30341
  capScope: "device",
@@ -30281,6 +30510,12 @@ Object.freeze({
30281
30510
  addonId: null,
30282
30511
  access: "view"
30283
30512
  },
30513
+ "pipelineAnalytics.listRelocateMediaJobs": {
30514
+ capName: "pipeline-analytics",
30515
+ capScope: "device",
30516
+ addonId: null,
30517
+ access: "view"
30518
+ },
30284
30519
  "pipelineAnalytics.listRetrainAnnotations": {
30285
30520
  capName: "pipeline-analytics",
30286
30521
  capScope: "device",
@@ -30359,6 +30594,12 @@ Object.freeze({
30359
30594
  addonId: null,
30360
30595
  access: "create"
30361
30596
  },
30597
+ "pipelineAnalytics.relocateMedia": {
30598
+ capName: "pipeline-analytics",
30599
+ capScope: "device",
30600
+ addonId: null,
30601
+ access: "create"
30602
+ },
30362
30603
  "pipelineAnalytics.restageRetrainTrack": {
30363
30604
  capName: "pipeline-analytics",
30364
30605
  capScope: "device",
@@ -30371,6 +30612,12 @@ Object.freeze({
30371
30612
  addonId: null,
30372
30613
  access: "create"
30373
30614
  },
30615
+ "pipelineAnalytics.runReplayFrameProcessor": {
30616
+ capName: "pipeline-analytics",
30617
+ capScope: "device",
30618
+ addonId: null,
30619
+ access: "create"
30620
+ },
30374
30621
  "pipelineAnalytics.saveRetrainAnnotations": {
30375
30622
  capName: "pipeline-analytics",
30376
30623
  capScope: "device",
@@ -30503,6 +30750,12 @@ Object.freeze({
30503
30750
  addonId: null,
30504
30751
  access: "view"
30505
30752
  },
30753
+ "pipelineExecutor.getInferenceDeviceHealth": {
30754
+ capName: "pipeline-executor",
30755
+ capScope: "system",
30756
+ addonId: null,
30757
+ access: "view"
30758
+ },
30506
30759
  "pipelineExecutor.getOrchestratorConfigSchema": {
30507
30760
  capName: "pipeline-executor",
30508
30761
  capScope: "system",
@@ -30575,6 +30828,12 @@ Object.freeze({
30575
30828
  addonId: null,
30576
30829
  access: "view"
30577
30830
  },
30831
+ "pipelineExecutor.rearmInferenceDevice": {
30832
+ capName: "pipeline-executor",
30833
+ capScope: "system",
30834
+ addonId: null,
30835
+ access: "create"
30836
+ },
30578
30837
  "pipelineExecutor.runAudioTest": {
30579
30838
  capName: "pipeline-executor",
30580
30839
  capScope: "system",
@@ -33823,6 +34082,11 @@ Object.freeze({
33823
34082
  form: "single",
33824
34083
  optional: false
33825
34084
  }],
34085
+ "pipelineAnalytics.runReplayFrameProcessor": [{
34086
+ name: "deviceId",
34087
+ form: "single",
34088
+ optional: false
34089
+ }],
33826
34090
  "pipelineAnalytics.saveRetrainAnnotations": [{
33827
34091
  name: "deviceId",
33828
34092
  form: "single",
@@ -35659,6 +35923,38 @@ var ScryptedCatalogDriftSchema = object({
35659
35923
  ]),
35660
35924
  details: string().optional()
35661
35925
  });
35926
+ /**
35927
+ * Curated PUBLIC Frigate catalog entry (D214 addendum). Named + exported so
35928
+ * the UI's `listFrigateCatalog` result parses against the SAME schema this
35929
+ * action's output is declared with (see `modelStudioActions.listFrigateCatalog`
35930
+ * below) — one shape, not a hand-duplicated interface on the UI side.
35931
+ */
35932
+ var FrigateCatalogEntrySchema = object({
35933
+ id: string(),
35934
+ label: string(),
35935
+ format: _enum(MODEL_FORMATS),
35936
+ sizeMB: number(),
35937
+ inputSize: number(),
35938
+ notes: string()
35939
+ });
35940
+ /**
35941
+ * Frigate+ `/v1/model/list` entry (see `frigate-plus.ts`). `isBaseModel` is
35942
+ * the Base/Custom discriminator Frigate's own UI groups on. Named + exported
35943
+ * for the same reason as {@link FrigateCatalogEntrySchema}.
35944
+ */
35945
+ var FrigatePlusModelSchema = object({
35946
+ id: string(),
35947
+ name: string(),
35948
+ type: string(),
35949
+ isBaseModel: boolean(),
35950
+ baseModel: string(),
35951
+ supportedDetectors: array(string()).readonly(),
35952
+ trainDate: string(),
35953
+ hailoDevice: string().optional(),
35954
+ verifiedImages: number(),
35955
+ width: number().optional(),
35956
+ height: number().optional()
35957
+ });
35662
35958
  var modelStudioActions = defineCustomActions({
35663
35959
  registerCustomModel: customAction(CustomModelDescriptorSchema, object({ ok: literal(true) }), { kind: "mutation" }),
35664
35960
  removeCustomModel: customAction(object({ modelId: string() }), object({ removed: boolean() }), { kind: "mutation" }),
@@ -35707,14 +36003,7 @@ var modelStudioActions = defineCustomActions({
35707
36003
  * the hub's modelsDir and registers the descriptor with the public URL
35708
36004
  * (other nodes download on demand — no Distribute needed).
35709
36005
  */
35710
- listFrigateCatalog: customAction(_void(), array(object({
35711
- id: string(),
35712
- label: string(),
35713
- format: _enum(MODEL_FORMATS),
35714
- sizeMB: number(),
35715
- inputSize: number(),
35716
- notes: string()
35717
- })).readonly()),
36006
+ listFrigateCatalog: customAction(_void(), array(FrigateCatalogEntrySchema).readonly()),
35718
36007
  importFrigateCatalogModel: customAction(object({
35719
36008
  catalogId: string(),
35720
36009
  modelId: string().optional(),
@@ -35754,19 +36043,7 @@ var modelStudioActions = defineCustomActions({
35754
36043
  ok: boolean(),
35755
36044
  error: string().optional()
35756
36045
  }), { kind: "mutation" }),
35757
- frigatePlusListModels: customAction(_void(), array(object({
35758
- id: string(),
35759
- name: string(),
35760
- type: string(),
35761
- isBaseModel: boolean(),
35762
- baseModel: string(),
35763
- supportedDetectors: array(string()).readonly(),
35764
- trainDate: string(),
35765
- hailoDevice: string().optional(),
35766
- verifiedImages: number(),
35767
- width: number().optional(),
35768
- height: number().optional()
35769
- })).readonly()),
36046
+ frigatePlusListModels: customAction(_void(), array(FrigatePlusModelSchema).readonly()),
35770
36047
  importFrigatePlusModel: customAction(object({
35771
36048
  plusModelId: string(),
35772
36049
  modelId: string(),