@camstack/addon-provider-unifi 0.2.28 → 0.2.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/addon.js +2135 -1892
  2. package/dist/addon.mjs +2135 -1892
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -6630,7 +6630,7 @@ function method(input, output, options) {
6630
6630
  input,
6631
6631
  output,
6632
6632
  kind: options?.kind ?? "query",
6633
- auth: options?.auth ?? "protected",
6633
+ ...options?.auth !== void 0 ? { auth: options.auth } : {},
6634
6634
  ...options?.access !== void 0 ? { access: options.access } : {},
6635
6635
  ...options?.caller !== void 0 ? { caller: options.caller } : {},
6636
6636
  timeoutMs: options?.timeoutMs
@@ -6654,7 +6654,7 @@ function event(data) {
6654
6654
  }
6655
6655
  var StaticDirOutputSchema$1 = object({ staticDir: string() });
6656
6656
  var VersionOutputSchema$1 = object({ version: string() });
6657
- method(_void(), StaticDirOutputSchema$1), method(_void(), VersionOutputSchema$1);
6657
+ method(_void(), StaticDirOutputSchema$1, { auth: "admin" }), method(_void(), VersionOutputSchema$1, { auth: "admin" });
6658
6658
  var DeviceType = /* @__PURE__ */ function(DeviceType) {
6659
6659
  DeviceType["Camera"] = "camera";
6660
6660
  DeviceType["Hub"] = "hub";
@@ -6975,7 +6975,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
6975
6975
  }({});
6976
6976
  var StaticDirOutputSchema = object({ staticDir: string() });
6977
6977
  var VersionOutputSchema = object({ version: string() });
6978
- method(_void(), StaticDirOutputSchema), method(_void(), VersionOutputSchema);
6978
+ method(_void(), StaticDirOutputSchema, { auth: "admin" }), method(_void(), VersionOutputSchema, { auth: "admin" });
6979
6979
  /**
6980
6980
  * device-ops — device-scoped cap that unifies the per-IDevice operations
6981
6981
  * previously routed through the `.device-ops` Moleculer bridge service.
@@ -7601,24 +7601,6 @@ var RecordingRetentionSchema = object({
7601
7601
  maxSizeGb: number().min(0).optional()
7602
7602
  });
7603
7603
  /**
7604
- * Scrub-thumbnail fidelity preset — the single per-camera selector bundling the
7605
- * sprite tile RESOLUTION + JPEG QUALITY the recorder packs timeline-scrub
7606
- * previews at. Five graduated steps; absent on a config = `standard` (the
7607
- * shipped default, matching `sheet-geometry`/`sheet-composer`).
7608
- *
7609
- * Existing sheets are IMMUTABLE — a changed preset applies to NEW windows only.
7610
- * Each window's index sidecar carries its own tile dims, so a camera whose
7611
- * preset changed over time renders every historical window at the dims it was
7612
- * written with.
7613
- */
7614
- var ScrubThumbnailPresetSchema = _enum([
7615
- "minimal",
7616
- "low",
7617
- "standard",
7618
- "high",
7619
- "max"
7620
- ]);
7621
- /**
7622
7604
  * The full per-camera recording intent — the wire shape of a RecordingTarget.
7623
7605
  *
7624
7606
  * `bands` is the ONLY authored recording intent: what to record, when, and on
@@ -7626,7 +7608,11 @@ var ScrubThumbnailPresetSchema = _enum([
7626
7608
  * other field is a storage knob (profiles, segment length, retention, scrub).
7627
7609
  *
7628
7610
  * STRICT on purpose: the legacy authoring surface (`schedule`/`schedules`/
7629
- * `triggers`/`preBufferSec`/`postBufferSec`/`rules`) was retired 2026-07-30.
7611
+ * `triggers`/`preBufferSec`/`postBufferSec`/`rules`) was retired 2026-07-30,
7612
+ * and `scrubThumbnails` — a five-step fidelity knob for a sprite tier that was
7613
+ * deleted on 2026-07-24 and had ZERO consumers in the recorder — on 2026-08-25
7614
+ * (D62: a switch that writes a store nobody reads is worse than no switch).
7615
+ * Stored rows keep loading: the READ schema is `.strip()` (config-store.ts).
7630
7616
  * A stale caller must fail loudly — silently stripping its legacy intent would
7631
7617
  * persist a band-less config, i.e. silently stop recording the camera.
7632
7618
  */
@@ -7649,14 +7635,7 @@ var RecordingConfigSchema = object({
7649
7635
  * "off" is the absence of a covering band, never a band value.
7650
7636
  */
7651
7637
  bands: array(RecordingBandSchema).default([]),
7652
- retention: RecordingRetentionSchema.optional(),
7653
- /**
7654
- * Per-camera scrub-thumbnail fidelity preset (resolution + JPEG quality for
7655
- * timeline-scrub sprite previews). Absent = `standard`. Applies to NEW
7656
- * windows only — existing sheets are immutable, and each window's index
7657
- * carries its own tile dims so mixed-preset history renders correctly.
7658
- */
7659
- scrubThumbnails: ScrubThumbnailPresetSchema.optional()
7638
+ retention: RecordingRetentionSchema.optional()
7660
7639
  }).strict();
7661
7640
  /**
7662
7641
  * Entity-relocation job state (storage entity-routing spec, Phase 4).
@@ -7732,10 +7711,11 @@ var RelocateFootageInputSchema = object({
7732
7711
  * `RecordingConfig.enabled` or camera wrapper bindings. */
7733
7712
  var StorageMigrationLeaseInputSchema = object({ leaseId: string().min(1) });
7734
7713
  var StorageMigrationFootageMoveInputSchema = RelocateFootageInputSchema.extend({ leaseId: string().min(1) });
7735
- var StorageMigrationMediaMoveInputSchema = object({
7714
+ var RelocateMediaInputSchema = object({
7736
7715
  toLocationId: string(),
7737
7716
  throttleMbps: number().min(1).max(1e3).optional()
7738
- }).extend({ leaseId: string().min(1) });
7717
+ });
7718
+ var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
7739
7719
  /** The independently selectable logical storage classes. `recordings`
7740
7720
  * encompasses the high and mid segment profiles; `recordingsLow` is low
7741
7721
  * segments; `eventMedia` is post-analysis blobs. */
@@ -8030,7 +8010,26 @@ var LabelDefinitionSchema = object({
8030
8010
  description: string().optional(),
8031
8011
  icon: string().optional()
8032
8012
  });
8033
- var ClassMapDefinitionSchema = object({
8013
+ /**
8014
+ * Wire schema for a per-model CATALOG classMap override
8015
+ * (`ModelCatalogEntry.classMap` / `ModelConvertMetadata.classMap`) —
8016
+ * restricted to {@link CLASS_MAP_MACRO_TARGETS}, the only macros the
8017
+ * detection pipeline executor actually routes.
8018
+ *
8019
+ * This is deliberately a DIFFERENT, narrower shape than the general-purpose
8020
+ * `ClassMapDefinition` interface above (e.g. `IDetectionAddon.getClassMap()`
8021
+ * and the audio `YAMNET_TO_MACRO` catalog both use macro targets outside this
8022
+ * enum) — the two used to share the name `ClassMapDefinition`/
8023
+ * `ClassMapDefinitionSchema`, which made the schema-type-twin guard
8024
+ * (`scripts/check-schema-type-twins.ts`) flag them as a duplicated shape. They
8025
+ * are not: it is two different concepts colliding on a name. Keep this type
8026
+ * under its own name rather than reusing `ClassMapDefinition` — reusing it
8027
+ * would either narrow every `ClassMapDefinition` consumer to the four
8028
+ * detection macros (breaking `YAMNET_TO_MACRO`) or drop the validation this
8029
+ * schema exists for (see the "rejects a classMap whose target is not a
8030
+ * detection macro" test in `model-catalog-schema.test.ts`).
8031
+ */
8032
+ var DetectionCatalogClassMapSchema = object({
8034
8033
  mapping: record(string(), _enum([
8035
8034
  "person",
8036
8035
  "vehicle",
@@ -8235,7 +8234,7 @@ var ModelCatalogEntrySchema = object({
8235
8234
  * applies (Frigate / COCO public catalog). Set on a custom model whose raw
8236
8235
  * labels already ARE the CamStack macros (Scrypted identity map).
8237
8236
  */
8238
- classMap: ClassMapDefinitionSchema.optional()
8237
+ classMap: DetectionCatalogClassMapSchema.optional()
8239
8238
  });
8240
8239
  var ConvertTargetSchema = discriminatedUnion("format", [object({
8241
8240
  format: literal("openvino"),
@@ -8265,7 +8264,7 @@ var ModelConvertMetadataSchema = object({
8265
8264
  "segmentation"
8266
8265
  ]),
8267
8266
  faceAlignment: boolean().optional(),
8268
- classMap: ClassMapDefinitionSchema.optional()
8267
+ classMap: DetectionCatalogClassMapSchema.optional()
8269
8268
  });
8270
8269
  var ConvertResultSchema = object({
8271
8270
  entry: ModelCatalogEntrySchema,
@@ -9128,7 +9127,7 @@ var AddonPageDeclarationSchema = object({
9128
9127
  /** Display label for a CUSTOM `section` id (ignored for well-known ids). */
9129
9128
  sectionLabel: string().optional()
9130
9129
  });
9131
- method(_void(), array(AddonPageDeclarationSchema).readonly());
9130
+ method(_void(), array(AddonPageDeclarationSchema).readonly(), { auth: "admin" });
9132
9131
  var AddonHttpRouteSchema = object({
9133
9132
  method: _enum([
9134
9133
  "GET",
@@ -9363,7 +9362,7 @@ var WidgetMetadataSchema = object({
9363
9362
  defaultColumns: number().int().min(1).max(12).default(6),
9364
9363
  defaultRows: number().int().min(1).max(12).default(1)
9365
9364
  });
9366
- method(_void(), array(WidgetMetadataSchema).readonly());
9365
+ method(_void(), array(WidgetMetadataSchema).readonly(), { auth: "admin" });
9367
9366
  /**
9368
9367
  * `addon-widgets` — system-scoped singleton aggregator cap. Public-facing
9369
9368
  * surface that admin-ui consumes through `useAddonWidgetsListWidgets()`.
@@ -10987,7 +10986,7 @@ var CustomModelDescriptorSchema = object({
10987
10986
  stepId: string(),
10988
10987
  entry: ModelCatalogEntrySchema
10989
10988
  });
10990
- method(_void(), array(CustomModelDescriptorSchema).readonly());
10989
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
10991
10990
  /**
10992
10991
  * Query filter for settings-store collections.
10993
10992
  */
@@ -11074,7 +11073,8 @@ method(object({
11074
11073
  }), _void(), { kind: "mutation" }), method(object({
11075
11074
  namespace: string().optional(),
11076
11075
  collection: string(),
11077
- filter: QueryFilterSchema.optional()
11076
+ filter: QueryFilterSchema.optional(),
11077
+ columns: array(string()).readonly().optional()
11078
11078
  }), array(SettingsRecordSchema).readonly()), method(object({
11079
11079
  namespace: string().optional(),
11080
11080
  collection: string(),
@@ -11137,46 +11137,87 @@ var EngineInfoSchema = object({
11137
11137
  kind: _enum(["relational", "vector"]),
11138
11138
  displayName: string()
11139
11139
  });
11140
- method(_void(), EngineInfoSchema), method(object({
11140
+ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
11141
11141
  namespace: string().optional(),
11142
11142
  collection: string(),
11143
11143
  key: string()
11144
- }), unknown()), method(object({
11144
+ }), unknown(), { auth: "admin" }), method(object({
11145
11145
  namespace: string().optional(),
11146
11146
  collection: string(),
11147
11147
  key: string(),
11148
11148
  value: unknown()
11149
- }), _void(), { kind: "mutation" }), method(object({
11149
+ }), _void(), {
11150
+ kind: "mutation",
11151
+ auth: "admin"
11152
+ }), method(object({
11150
11153
  namespace: string().optional(),
11151
11154
  collection: string(),
11152
- filter: QueryFilterSchema.optional()
11153
- }), array(SettingsRecordSchema).readonly()), method(object({
11155
+ filter: QueryFilterSchema.optional(),
11156
+ /**
11157
+ * SQL-level column projection — MUST mirror `settings-store.query`.
11158
+ *
11159
+ * ⚠ An earlier version of this comment blamed Zod stripping, and that
11160
+ * was wrong — corrected 2026-08-26 after the hop map
11161
+ * (`docs/design/2026-08-26-mappa-hop-argomenti.md`) traced the path.
11162
+ * There is **no Zod parse at all** between the door and the engine: the
11163
+ * dispatcher forwards the payload verbatim and UDS carries it whole. A
11164
+ * field declared here reaches `SqliteSettingsBackend` either way.
11165
+ *
11166
+ * What actually lost `columns` was the THIRD declaration of this shape:
11167
+ * `SettingsQueryInput` in `interfaces/storage.ts`, a hand-written TS
11168
+ * interface the engine destructures from. The field existed on both
11169
+ * schemas and the engine still never read it, because nothing checks a
11170
+ * registered provider against `InferProvider<cap>` —
11171
+ * `ProviderRegistration.provider` is typed `object`.
11172
+ *
11173
+ * It is declared here anyway, and must stay in step with
11174
+ * `settings-store.query`: a caller reading only the cap definitions has
11175
+ * to be able to see that this call carries a projection.
11176
+ * `data-door-schema-parity.spec.ts` keeps the two aligned.
11177
+ */
11178
+ columns: array(string()).readonly().optional()
11179
+ }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
11154
11180
  namespace: string().optional(),
11155
11181
  collection: string(),
11156
11182
  record: SettingsRecordSchema
11157
- }), _void(), { kind: "mutation" }), method(object({
11183
+ }), _void(), {
11184
+ kind: "mutation",
11185
+ auth: "admin"
11186
+ }), method(object({
11158
11187
  namespace: string().optional(),
11159
11188
  collection: string(),
11160
11189
  id: string(),
11161
11190
  data: record(string(), unknown())
11162
- }), _void(), { kind: "mutation" }), method(object({
11191
+ }), _void(), {
11192
+ kind: "mutation",
11193
+ auth: "admin"
11194
+ }), method(object({
11163
11195
  namespace: string().optional(),
11164
11196
  collection: string(),
11165
11197
  key: string()
11166
- }), _void(), { kind: "mutation" }), method(object({
11198
+ }), _void(), {
11199
+ kind: "mutation",
11200
+ auth: "admin"
11201
+ }), method(object({
11167
11202
  namespace: string().optional(),
11168
11203
  collection: string(),
11169
11204
  filter: MutationFilterSchema
11170
- }), object({ deleted: number().int() }), { kind: "mutation" }), method(object({
11205
+ }), object({ deleted: number().int() }), {
11206
+ kind: "mutation",
11207
+ auth: "admin"
11208
+ }), method(object({
11171
11209
  namespace: string().optional(),
11172
11210
  collection: string(),
11173
11211
  filter: MutationFilterSchema,
11174
11212
  data: record(string(), unknown())
11175
- }), object({ updated: number().int() }), { kind: "mutation" }), method(object({
11213
+ }), object({ updated: number().int() }), {
11214
+ kind: "mutation",
11215
+ auth: "admin"
11216
+ }), method(object({
11176
11217
  namespace: string().optional(),
11177
11218
  collection: string(),
11178
11219
  filter: QueryFilterSchema.optional()
11179
- }), number()), method(object({
11220
+ }), number(), { auth: "admin" }), method(object({
11180
11221
  namespace: string().optional(),
11181
11222
  collection: string(),
11182
11223
  field: string(),
@@ -11186,15 +11227,18 @@ method(_void(), EngineInfoSchema), method(object({
11186
11227
  }), array(object({
11187
11228
  bucket: number().int(),
11188
11229
  count: number().int()
11189
- })).readonly()), method(object({
11230
+ })).readonly(), { auth: "admin" }), method(object({
11190
11231
  namespace: string().optional(),
11191
11232
  collection: string()
11192
- }), boolean()), method(object({
11233
+ }), boolean(), { auth: "admin" }), method(object({
11193
11234
  namespace: string().optional(),
11194
11235
  collection: string(),
11195
11236
  columns: array(CollectionColumnSchema).readonly(),
11196
11237
  indexes: array(CollectionIndexSchema).readonly().optional()
11197
- }), _void(), { kind: "mutation" });
11238
+ }), _void(), {
11239
+ kind: "mutation",
11240
+ auth: "admin"
11241
+ });
11198
11242
  /**
11199
11243
  * shm ring usage stats for a `frameSink: 'shm'` decoder session —
11200
11244
  * exposed via `decoder.getShmStats` so downstream consumers can
@@ -12484,7 +12528,7 @@ method(object({
12484
12528
  crop: _instanceof(Uint8Array),
12485
12529
  width: number(),
12486
12530
  height: number()
12487
- }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
12531
+ }), EmbeddingResultSchema, { auth: "admin" }), method(object({ text: string() }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" });
12488
12532
  /**
12489
12533
  * filesystem-browse — per-node capability for browsing the node's local
12490
12534
  * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
@@ -12777,19 +12821,22 @@ method(LlmGenerateBaseInputSchema.extend({
12777
12821
  runtime: ManagedRuntimeConfigSchema,
12778
12822
  /** The managed profile's timeout, threaded by the hub provider. */
12779
12823
  timeoutMs: number().int().positive().optional()
12780
- }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
12824
+ }), LlmGenerateResultSchema, {
12825
+ kind: "mutation",
12826
+ auth: "admin"
12827
+ }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
12781
12828
  kind: "mutation",
12782
12829
  auth: "admin"
12783
12830
  }), method(object({}), _void(), {
12784
12831
  kind: "mutation",
12785
12832
  auth: "admin"
12786
- }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
12833
+ }), method(object({}), LlmRuntimeStatusSchema, { auth: "admin" }), method(object({ model: ManagedModelRefSchema }), _void(), {
12787
12834
  kind: "mutation",
12788
12835
  auth: "admin"
12789
12836
  }), method(object({ file: string() }), _void(), {
12790
12837
  kind: "mutation",
12791
12838
  auth: "admin"
12792
- }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
12839
+ }), method(object({}), array(LlmNodeModelSchema), { auth: "admin" }), method(object({}), LlmRuntimeDiskUsageSchema, { auth: "admin" });
12793
12840
  /**
12794
12841
  * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
12795
12842
  * methods concat-fan across providers; single-row methods route to ONE
@@ -16300,1748 +16347,1998 @@ var OauthIntegrationDescriptorSchema = object({
16300
16347
  */
16301
16348
  refreshTokenTtlSec: union([number().int().positive(), literal("never")]).optional()
16302
16349
  });
16303
- method(_void(), OauthIntegrationDescriptorSchema);
16350
+ method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
16304
16351
  /**
16305
- * pipeline-analytics — device-scoped wrapper cap. Refines raw
16306
- * per-frame detections emitted by the pipeline runner into tracked
16307
- * objects, per-kind event collections (motion / object / audio), and
16308
- * persisted media. Owns the post-detection domain end-to-end:
16309
- *
16310
- * runner emits PipelineInferenceResult
16311
- * ↓ (event bus)
16312
- * pipeline-analytics subscriber
16313
- * ↓ SORT tracker + zone engine + state analyzer + event emitter
16314
- * → three DB collections (one per kind), one FS media tree, one
16315
- * unified event emitter (FrameTracked + TrackStarted/Ended +
16316
- * DetectionEvent on bus)
16317
- *
16318
- * Pure subscriber model. No `processFrame` cap method — the runner
16319
- * already publishes the raw frame on the bus. The cap surface is
16320
- * only QUERIES + per-device settings, bound on/off via
16321
- * `device-manager.setWrapperActive`. `defaultActive: true` because
16322
- * every camera with a detection pipeline wants its raw detections
16323
- * refined; operators opt out per-device via BindingsTab when needed.
16324
- *
16325
- * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
16326
- * (per-device surface) and `track-trail` caps — see P11 cleanup.
16352
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
16353
+ * within the frame, so the executor can re-cut a leaf child ROI at native
16354
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
16327
16355
  */
16328
- var TrackStateSchema = _enum([
16329
- "new",
16330
- "entered",
16331
- "left",
16332
- "moving",
16333
- "idle"
16334
- ]);
16335
- var EventKindSchema = _enum([
16336
- "motion",
16337
- "object",
16338
- "audio"
16339
- ]);
16356
+ var NativeCropRefSchema = object({
16357
+ /** Handle keying the retained native surface (node-pinned to its owner). */
16358
+ handle: FrameHandleSchema,
16359
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
16360
+ cropFrameSpace: object({
16361
+ x: number(),
16362
+ y: number(),
16363
+ w: number(),
16364
+ h: number()
16365
+ })
16366
+ });
16367
+ object({
16368
+ crop: object({
16369
+ left: number(),
16370
+ top: number(),
16371
+ width: number().positive(),
16372
+ height: number().positive()
16373
+ }).optional(),
16374
+ content: object({
16375
+ width: number().int().positive(),
16376
+ height: number().int().positive()
16377
+ }),
16378
+ fit: _enum(["stretch", "contain"]),
16379
+ format: _enum([
16380
+ "rgb",
16381
+ "gray",
16382
+ "jpeg"
16383
+ ])
16384
+ });
16340
16385
  /**
16341
- * Spatial filter for `listTracks` — the rect + polygon variants of the shared
16342
- * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
16343
- * of the camera frame (top-left origin), matching the drawing-plane editor.
16386
+ * Process-local frame identity. It is serializable so it can ride an in-process
16387
+ * capability call, but `registryId` deliberately prevents resolution in any
16388
+ * other process or execution group.
16344
16389
  */
16345
- var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
16346
- /** Closed icon vocabulary so clients render a known glyph per kind. */
16347
- var EventKindIconSchema = _enum([
16348
- "motion",
16349
- "audio",
16350
- "person",
16351
- "vehicle",
16352
- "animal",
16353
- "door",
16354
- "pir",
16355
- "smoke",
16356
- "water",
16357
- "button",
16358
- "package",
16359
- "generic"
16390
+ var FrameRefSchema = object({
16391
+ registryId: string().min(1),
16392
+ id: string().min(1),
16393
+ width: number().int().positive(),
16394
+ height: number().int().positive(),
16395
+ format: _enum(["rgb", "gray"]),
16396
+ timestamp: number(),
16397
+ capturedAt: number().optional()
16398
+ });
16399
+ var ModelFormatSchema$1 = _enum([
16400
+ "onnx",
16401
+ "coreml",
16402
+ "openvino",
16403
+ "tflite",
16404
+ "pt",
16405
+ "gguf"
16360
16406
  ]);
16361
- var EventKindCategorySchema = _enum([
16362
- "motion",
16363
- "audio",
16364
- "detection",
16365
- "sensor",
16366
- "control",
16367
- "custom",
16368
- "package"
16407
+ var PipelineSlotSchema = _enum([
16408
+ "detector",
16409
+ "cropper",
16410
+ "classifier",
16411
+ "refiner",
16412
+ "audio-classifier"
16369
16413
  ]);
16370
- /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
16371
- var EventKindLevelSchema = _enum(["macro", "sub"]);
16372
- var EventKindDescriptorSchema = object({
16373
- /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
16374
- kind: string(),
16375
- /** i18n key resolved on the UI side; `label` is the English fallback. */
16376
- labelKey: string(),
16377
- /** English fallback label (kept for clients that don't translate). */
16378
- label: string(),
16379
- /** Hex color for timeline/legend rendering. */
16380
- color: string(),
16381
- /** Dictionary id → lucide component on the UI side. */
16382
- iconId: string(),
16383
- /** Legacy closed-vocab glyph — fallback for `iconId`. */
16384
- icon: EventKindIconSchema,
16385
- category: EventKindCategorySchema,
16386
- /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
16387
- parentKind: string().nullable(),
16388
- /** Derived from `parentKind`, explicit for the client tree. */
16389
- level: EventKindLevelSchema,
16390
- /** Which cap + device contributes this kind. For built-ins the camera
16391
- * itself; for sensor kinds the LINKED source device. */
16392
- source: object({
16393
- capName: string(),
16394
- deviceId: number()
16395
- })
16414
+ var PipelineEngineChoiceSchema = object({
16415
+ runtime: _enum(["node", "python"]),
16416
+ backend: string(),
16417
+ format: ModelFormatSchema$1,
16418
+ device: string().optional()
16396
16419
  });
16397
- /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
16398
- var EventKindsForDeviceSchema = object({
16399
- deviceId: number(),
16400
- kinds: array(EventKindDescriptorSchema).readonly()
16420
+ var AvailableEngineSchema = object({
16421
+ engine: PipelineEngineChoiceSchema,
16422
+ devices: array(object({
16423
+ id: string(),
16424
+ label: string(),
16425
+ description: string().optional()
16426
+ })).readonly(),
16427
+ defaultDevice: string()
16401
16428
  });
16402
- var SensorEventSchema = object({
16429
+ var PipelineDefaultStepSchema = lazy(() => object({
16430
+ addonId: string(),
16431
+ addonName: string(),
16432
+ slot: PipelineSlotSchema,
16433
+ inputClasses: array(string()).readonly(),
16434
+ outputClasses: array(string()).readonly(),
16435
+ enabled: boolean(),
16436
+ modelId: string(),
16437
+ children: array(PipelineDefaultStepSchema).readonly(),
16438
+ group: string().optional(),
16439
+ settings: record(string(), unknown()).optional()
16440
+ }));
16441
+ var PipelineTemplateStepSchema = lazy(() => object({
16442
+ addonId: string(),
16443
+ enabled: boolean(),
16444
+ modelId: string(),
16445
+ children: array(PipelineTemplateStepSchema).readonly(),
16446
+ settings: record(string(), unknown()).optional()
16447
+ }));
16448
+ var PipelineTemplateSchema$1 = object({
16403
16449
  id: string(),
16404
- /** The CAMERA the event is attributed to (a sensor linked to N cameras
16405
- * yields N rows, one per camera). */
16406
- deviceId: number(),
16407
- /** The linked sensor device whose state changed. */
16408
- sourceDeviceId: number(),
16409
- /** Event kind id — matches an `EventKindDescriptor.kind`. */
16410
- kind: string(),
16411
- /** Snapshot of the sensor cap's runtime-state slice at the change. */
16412
- value: record(string(), unknown()).nullable(),
16413
- timestamp: number()
16414
- });
16415
- var TrackPositionSchema = object({
16416
- x: number(),
16417
- y: number(),
16418
- timestamp: number(),
16419
- bbox: BoundingBoxSchema
16450
+ name: string(),
16451
+ createdAt: string(),
16452
+ updatedAt: string(),
16453
+ engine: PipelineEngineChoiceSchema,
16454
+ steps: array(PipelineTemplateStepSchema).readonly()
16420
16455
  });
16421
- var TrackSnapshotSchema = object({
16422
- timestamp: number(),
16423
- position: TrackPositionSchema,
16424
- /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
16425
- mediaKey: string()
16456
+ var PipelineModelOptionSchema = object({
16457
+ id: string(),
16458
+ name: string(),
16459
+ formats: record(string(), object({
16460
+ downloaded: boolean(),
16461
+ sizeMB: number()
16462
+ })),
16463
+ group: ModelVariantGroupSchema.optional(),
16464
+ legacy: boolean().optional(),
16465
+ provider: ModelProviderIdSchema.optional()
16426
16466
  });
16427
- /**
16428
- * Normalized 0..1 trajectory envelope (min/max over every position bbox,
16429
- * divided by the track's detection-frame dims), computed at persist time.
16430
- * Absent when the frame dims were unknown when the track was persisted
16431
- * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
16432
- */
16433
- var TrackEnvelopeSchema = object({
16434
- minX: number(),
16435
- minY: number(),
16436
- maxX: number(),
16437
- maxY: number()
16467
+ var ConfigFieldBridge = custom();
16468
+ var PipelineAddonSchemaSchema = object({
16469
+ id: string(),
16470
+ name: string(),
16471
+ slot: PipelineSlotSchema,
16472
+ inputClasses: array(string()).readonly(),
16473
+ outputClasses: array(string()).readonly(),
16474
+ childSlots: array(PipelineSlotSchema).readonly(),
16475
+ models: array(PipelineModelOptionSchema).readonly(),
16476
+ defaultModelId: string(),
16477
+ defaultModelIdByFormat: record(string(), string()).optional(),
16478
+ enabledByDefault: boolean().optional(),
16479
+ backfillIntoExistingOverrides: boolean().optional(),
16480
+ defaultConfidence: number(),
16481
+ group: string().optional(),
16482
+ configSchema: array(ConfigFieldBridge).readonly().optional()
16438
16483
  });
16439
- /**
16440
- * Row projection for track list queries. `full` (default) returns the
16441
- * complete Track including the frame-rate `positions[]` history and the
16442
- * `snapshots[]` references — megabytes across a page of tracks. `slim`
16443
- * keeps every scalar the list surfaces actually render (ids, class(es),
16444
- * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
16445
- * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
16446
- * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
16447
- * `getTrack`. Mirrors the event-store `projection` convention
16448
- * (`getObjectEvents` et al.).
16449
- */
16450
- var TrackProjectionSchema = _enum(["full", "slim"]);
16451
- /**
16452
- * One audio-classification label heard on the track's camera while the
16453
- * track was alive, aggregated per label. An "episode" is one persisted
16454
- * audio event (the confident-classification path: score ≥ the device's
16455
- * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
16456
- * one 32 ms inference chunk, so counts stay human-scaled.
16457
- */
16458
- var TrackAudioLabelSchema = object({
16484
+ var PipelineSlotSchemaSchema = object({
16485
+ id: PipelineSlotSchema,
16459
16486
  label: string(),
16460
- /** Highest classification score observed across the label's episodes. */
16461
- peakScore: number(),
16462
- /** Number of coalesced audio-event episodes carrying this label. */
16463
- count: number(),
16464
- firstAt: number(),
16465
- lastAt: number()
16487
+ priority: number(),
16488
+ parentSlot: PipelineSlotSchema.nullable(),
16489
+ addons: array(PipelineAddonSchemaSchema).readonly()
16466
16490
  });
16467
- /**
16468
- * How a track was produced. `pipeline` (default / absent) = the spatial
16469
- * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
16470
- * no positions, a single snapshot, and no bbox trajectory at all:
16471
- *
16472
- * - `sensor` — a linked sensor/control device state change.
16473
- * - `audio` — an audio event on the camera itself that was anomalous for
16474
- * THAT camera, loud, and heard while nothing visual was happening (D62).
16475
- *
16476
- * The spatial subsystems (tracker association, occupancy count, re-id /
16477
- * embedding, resurrection) MUST skip every synthetic source. Test for that
16478
- * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
16479
- * check silently readmits every source added after it was written.
16480
- */
16481
- var TrackSourceSchema = _enum([
16482
- "pipeline",
16483
- "sensor",
16484
- "audio"
16485
- ]);
16486
- /**
16487
- * Where a track sits in the RETRAIN lifecycle (D81).
16488
- *
16489
- * - `none` — never marked, or un-marked. Evictable.
16490
- * - `staging` — the operator wants this track as training material and has not
16491
- * finished with it. **This is the only state retention holds**: the track and
16492
- * everything it owns (object events, crops, keyframes, CLIP vector) survive
16493
- * the device's age window.
16494
- * - `trained` — the retrain page has taken what it needed. The frames it chose
16495
- * were COPIED into the retrain dataset at selection time, so the dataset no
16496
- * longer depends on the track's media and the track becomes EVICTABLE again.
16497
- * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
16498
- * a deliberate action of the retrain page, not a side effect of a checkbox.
16499
- *
16500
- * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
16501
- * the store's filter language has only positive equality and `whereIn` — no
16502
- * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
16503
- * would make the entire pre-column history immortal in one deploy.
16504
- */
16505
- var RetrainStatusSchema = _enum([
16506
- "none",
16507
- "staging",
16508
- "trained"
16509
- ]);
16510
- /**
16511
- * Per-track OPERATOR flags — set by hand from the admin UI or the viewer, never
16512
- * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
16513
- * so the two surfaces cannot drift.
16514
- *
16515
- * **Absent ≠ false.** A track that has never been touched omits the field; an
16516
- * explicitly un-flagged track carries `false`. Legacy rows written before the
16517
- * columns existed read as absent, and a consumer that needs a boolean should say
16518
- * `flag === true`, not `flag !== false`.
16519
- *
16520
- * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
16521
- * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
16522
- * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
16523
- * `trained` track reports `false` while refusing both writes. The boolean is
16524
- * kept because three surfaces drive a toggle off it; anything that needs to tell
16525
- * "never marked" from "already trained" must read `retrainStatus`.
16526
- *
16527
- * `debug` does NOT pin; it is attention, not durability.
16528
- *
16529
- * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
16530
- * A favourited track is skipped by retention the same way `staging` is, but
16531
- * it does not enter `none|staging|trained` and has no staging budget.
16532
- */
16533
- var TrackFlagFields = {
16534
- /** Operator marked this track as training material — i.e. `retrainStatus` is
16535
- * `'staging'`. */
16536
- markForTrain: boolean().optional(),
16537
- /** Operator marked this track for diagnostic attention. */
16538
- debug: boolean().optional(),
16539
- /** Operator favourited this track. Pins it against pruning. */
16540
- favourited: boolean().optional()
16541
- };
16542
- /**
16543
- * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
16544
- * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
16545
- * write patch, and the status is not something the toggle sets — it is what the
16546
- * toggle's boolean is derived from. Absent on an in-RAM track never touched;
16547
- * always present on a persisted row (the column default materialises `'none'`).
16548
- */
16549
- var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
16550
- /**
16551
- * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
16552
- * one flag can never clear the other — the toggles are independent and are
16553
- * driven from three surfaces that do not know about each other.
16554
- */
16555
- var TrackFlagsPatchSchema = object(TrackFlagFields);
16556
- /**
16557
- * The resolved flag state after a write. Both fields are REQUIRED here (absent
16558
- * collapses to `false`) so a caller can drive a toggle's checked state off the
16559
- * mutation result without a re-fetch.
16560
- */
16561
- var TrackFlagsSchema = object({
16562
- trackId: string(),
16563
- markForTrain: boolean(),
16564
- debug: boolean(),
16565
- favourited: boolean(),
16566
- /** The lifecycle state the boolean was derived from. Required here (unlike on
16567
- * a track row) because this shape is only ever produced by the write body,
16568
- * which always knows it — and a surface that has just written needs to render
16569
- * `trained` without a re-fetch. */
16570
- retrainStatus: RetrainStatusSchema
16491
+ var PipelineSchemaSchema = object({
16492
+ availableEngines: array(AvailableEngineSchema).readonly(),
16493
+ selectedEngine: PipelineEngineChoiceSchema,
16494
+ slots: array(PipelineSlotSchemaSchema).readonly()
16571
16495
  });
16572
- union([literal(1), literal(2)]);
16573
- /**
16574
- * WHO decided a label, and when. Carried per tier so a value can be traced to
16575
- * the step and model that produced it — which is what makes the write rule
16576
- * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
16577
- * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
16578
- *
16579
- * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
16580
- * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
16581
- * `migration:4g` for a value the 4g migration moved from the single-slot era —
16582
- * that value has no provenance, and the write rule lets ANY properly-attributed
16583
- * write of the same tier replace it regardless of score.
16584
- */
16585
- var LabelAttributionSchema = object({
16586
- stepId: string(),
16587
- modelId: string().optional(),
16588
- decidedAt: number(),
16496
+ var EngineProvisioningSchema = object({
16497
+ runtimeId: _enum([
16498
+ "onnx",
16499
+ "openvino",
16500
+ "coreml",
16501
+ "edgetpu"
16502
+ ]).nullable(),
16503
+ device: string().nullable(),
16504
+ state: _enum([
16505
+ "idle",
16506
+ "installing",
16507
+ "verifying",
16508
+ "ready",
16509
+ "failed"
16510
+ ]),
16511
+ progress: number().optional(),
16512
+ error: string().optional(),
16513
+ nextRetryAt: number().optional(),
16589
16514
  /**
16590
- * The GALLERY id behind a recognised tier-2 label — a face-gallery
16591
- * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
16592
- *
16593
- * The text alone is a DISPLAY NAME, and a display name is renameable: a
16594
- * notification rule authored on "Gianluca" stopped matching the moment the
16595
- * operator fixed the spelling in the gallery, and nothing said so. The id is
16596
- * the thing that does not move, so it is what a rule matches on
16597
- * (`NcConditions.identities`) and the text is what a human is shown.
16598
- *
16599
- * Absent when the label names no gallery row — a plate the OCR read but no
16600
- * vehicle claims, a sub-class, a species, any tier-1 value.
16515
+ * Gate A (config-correctness gate at engine change): human-readable
16516
+ * config issues surfaced EAGERLY when the node's engine changes — model
16517
+ * substitutions ("chose X, running Y") and zero-build steps ("no model
16518
+ * has a <format> build"). Additive/optional: informational only, never
16519
+ * enforced here — `assertEngineReady` (readiness) still gates inference.
16520
+ * Absent/empty when the node-default tree resolves cleanly.
16601
16521
  */
16602
- identityId: string().optional()
16522
+ configIssues: array(string()).optional()
16603
16523
  });
16604
- /**
16605
- * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
16606
- * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
16607
- * track and its events always answer the same question the same way.
16608
- *
16609
- * Two scalar columns, not an array: every consumer wants "the coarse one" or
16610
- * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
16611
- * is tier 2, and each carries its own score + attribution.
16612
- *
16613
- * **Reading it.** What a human should be shown is `subLabel ?? label` — the
16614
- * finest thing known. Before 4g the single `label` column held the finest
16615
- * value, so a consumer that has not been updated reads the tier-1 slot and
16616
- * shows nothing on a species-only row; that is why the migration puts every
16617
- * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
16618
- * and why the read surfaces were changed in the same train.
16619
- *
16620
- * **Writing it.** The slots are independent, which is the whole point: a
16621
- * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
16622
- * migratorius`), so fineness cannot regress by construction. Within a tier the
16623
- * higher score wins. One rule, one implementation — see
16624
- * `pipeline/label-tier.ts` in addon-post-analysis.
16625
- */
16626
- var TieredLabelFields = {
16627
- /** Tier 1 — the sub-class. See {@link LabelTierSchema}. */
16628
- label: string().optional(),
16629
- /** Confidence of the tier-1 value, as reported by the deciding step. */
16630
- labelScore: number().optional(),
16631
- /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
16632
- labelMeta: LabelAttributionSchema.optional(),
16633
- /** Tier 2 — the instance. See {@link LabelTierSchema}. */
16634
- subLabel: string().optional(),
16635
- /** Confidence of the tier-2 value, as reported by the deciding step. */
16636
- subLabelScore: number().optional(),
16637
- /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
16638
- subLabelMeta: LabelAttributionSchema.optional()
16639
- };
16640
- /** Per-camera slice of a training-export estimate. */
16641
- var TrainingExportDeviceTotalsSchema = object({
16642
- deviceId: number(),
16643
- tracks: number().int(),
16644
- files: number().int(),
16645
- bytes: number().int()
16524
+ var PipelineStepInputSchema = lazy(() => object({
16525
+ addonId: string(),
16526
+ modelId: string().optional(),
16527
+ enabled: boolean().default(true),
16528
+ children: array(PipelineStepInputSchema).optional(),
16529
+ settings: record(string(), unknown()).optional(),
16530
+ jumpDeviceKey: string().optional()
16531
+ }));
16532
+ var ModelSubstitutionSchema = object({
16533
+ addonId: string(),
16534
+ chosen: string(),
16535
+ running: string(),
16536
+ format: string()
16537
+ });
16538
+ var PipelineValidationIssueSchema = object({
16539
+ addonId: string(),
16540
+ kind: _enum(["unknown-addon", "no-format-build"]),
16541
+ detail: string()
16542
+ });
16543
+ var PipelineValidationResultSchema = object({
16544
+ ok: boolean(),
16545
+ issues: array(PipelineValidationIssueSchema).readonly(),
16546
+ substitutions: array(ModelSubstitutionSchema).readonly(),
16547
+ /** The node's `currentEngine.format` this validation ran against. */
16548
+ format: string()
16549
+ });
16550
+ var ReferenceImageEntrySchema = object({
16551
+ filename: string(),
16552
+ stepIds: array(string()).readonly().optional()
16553
+ });
16554
+ var ReferenceImageBodySchema = object({
16555
+ base64: string(),
16556
+ filename: string()
16557
+ });
16558
+ var ReferenceAudioEntrySchema = object({
16559
+ filename: string(),
16560
+ sizeKb: number()
16561
+ });
16562
+ var ReferenceAudioBodySchema = object({ base64: string() });
16563
+ var AudioBackendSchema = object({
16564
+ id: string(),
16565
+ name: string(),
16566
+ description: string(),
16567
+ available: boolean(),
16568
+ /**
16569
+ * Raw classifier labels this backend can emit (e.g. YAMNet's
16570
+ * 521-class set or Apple SoundAnalysis's 303-class set). Used by
16571
+ * the benchmark UI to populate the `enabledMicroClasses` filter
16572
+ * specific to the selected backend without a separate fetch.
16573
+ */
16574
+ rawLabels: array(string()).readonly().optional()
16575
+ });
16576
+ var AudioCapabilitiesSchema = object({
16577
+ activeBackend: string(),
16578
+ availableBackends: array(AudioBackendSchema).readonly(),
16579
+ sampleRate: number(),
16580
+ chunkDurationMs: number()
16581
+ });
16582
+ var DownloadModelResultSchema = object({
16583
+ filePath: string(),
16584
+ sizeMB: number(),
16585
+ durationMs: number()
16646
16586
  });
16647
16587
  /**
16648
- * What a training export WOULD contain. Computed from media index rows only —
16649
- * no blob is read to produce this.
16588
+ * Wrapper carrying a single test run's result. Replaces the legacy
16589
+ * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
16590
+ * canonical `AudioResult` from the Phase 6 output rework: one
16591
+ * `AudioDetection` per class above `minScore`, top-N candidates in
16592
+ * `debug.alternateLabels['audio-classifier']`, per-source timings in
16593
+ * `debug.stepTimings`. The outer `success`/`error` fields stay so the
16594
+ * benchmark UI can still report a clean failure when the classifier
16595
+ * cap isn't available.
16650
16596
  */
16651
- var TrainingExportSummarySchema = object({
16652
- generatedAt: number(),
16653
- trackCount: number().int(),
16654
- fileCount: number().int(),
16655
- byteCount: number().int(),
16656
- /** More marked tracks exist than a single pass carries. */
16657
- truncated: boolean(),
16658
- devices: array(TrainingExportDeviceTotalsSchema).readonly()
16597
+ var AudioTestResultSchema = object({
16598
+ success: boolean(),
16599
+ error: string().optional(),
16600
+ frame: custom().optional()
16659
16601
  });
16660
- var TrackSchema = object({
16661
- trackId: string(),
16662
- deviceId: number(),
16663
- className: string(),
16664
- ...TieredLabelFields,
16665
- producingDeviceName: string().optional(),
16666
- /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
16667
- source: TrackSourceSchema.optional(),
16668
- firstSeen: number(),
16669
- lastSeen: number(),
16670
- /** Frame-rate position history (subject to maxPositionHistory cap). */
16671
- positions: array(TrackPositionSchema).readonly(),
16672
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
16673
- * saveThumbnails policy). */
16674
- snapshots: array(TrackSnapshotSchema).readonly(),
16675
- /** Deduplicated zones the track has entered at least once. Zone IDS. */
16676
- zonesVisited: array(string()).readonly(),
16602
+ var PipelineConfigBridge = custom();
16603
+ var ConfigUISchemaBridge = custom();
16604
+ var ConfigUISchemaNullableBridge = custom();
16605
+ var InferenceCapabilitiesBridge = custom();
16606
+ var ModelAvailabilityListBridge = custom();
16607
+ var PipelineRunResultBridge = custom();
16608
+ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
16609
+ modelId: string(),
16610
+ settings: record(string(), unknown()).readonly()
16611
+ }))), method(object({ steps: record(string(), object({
16612
+ modelId: string(),
16613
+ settings: record(string(), unknown()).readonly()
16614
+ })) }), object({ success: literal(true) }), {
16615
+ kind: "mutation",
16616
+ auth: "admin"
16617
+ }), method(object({ nodeId: string() }), object({
16618
+ success: literal(true),
16619
+ clearedDevices: number()
16620
+ }), {
16621
+ kind: "mutation",
16622
+ auth: "admin"
16623
+ }), method(object({ nodeId: string() }), object({ unhealthy: array(object({
16624
+ /** `<backend>:<device>`, e.g. `openvino:gpu`. */
16625
+ deviceKey: string(),
16677
16626
  /**
16678
- * Human NAMES for {@link zonesVisited}, resolved at READ time against the
16679
- * `zones` capability.
16680
- *
16681
- * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
16682
- * and no card can render — so every free-text search surface was structurally
16683
- * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
16684
- * just returned nothing. Resolving here rather than in each client keeps ONE
16685
- * derivation and costs the clients no extra call (the `zones` cap is
16686
- * per-device, so a client-side resolve would be a per-camera fan-out on a
16687
- * surface built to avoid exactly that).
16688
- *
16689
- * Resolved, never invented: a zone deleted since the track was written has no
16690
- * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
16691
- * two are not positionally aligned. Absent when the track visited no zone, or
16692
- * when the zone catalogue could not be read.
16627
+ * `failed` — the per-device restart budget is exhausted; no pool
16628
+ * will be spawned until an operator re-arms it or the runner
16629
+ * respawns. `backoff` — under budget, waiting out the backoff (or
16630
+ * a cached pool observed dead and not yet condemned).
16693
16631
  */
16694
- zoneNames: array(string()).readonly().optional(),
16695
- /** Deduplicated set of detector classes observed for this track over its
16696
- * life (a track may be reclassified, e.g. person→vehicle). Absent on
16697
- * legacy rows written before class accumulation shipped. */
16698
- classes: array(string()).readonly().optional(),
16699
- /** Cumulative normalized distance travelled (0..1 units = full frame width). */
16700
- totalDistance: number(),
16701
- state: TrackStateSchema,
16702
- active: boolean(),
16703
- /** Deterministic key-event importance score in [0,1] (server-computed at
16704
- * track expiry, recomputed on late label). Absent on legacy rows written
16705
- * before scoring shipped — consumers degrade to absence / compute-on-read. */
16706
- importance: number().optional(),
16707
- /** Id of the track's highest-confidence ObjectEvent (its representative
16708
- * "best" frame). Absent when the track produced no object events. */
16709
- bestEventId: string().optional(),
16710
- /** Tag of the importance sub-signal that dominated the score
16711
- * (identity|dwell|proximity|class|confidence|travel|zone). */
16712
- importanceReason: string().optional(),
16713
- /** Audio-classification labels heard on the camera during the track's
16714
- * life (score ≥ device `classificationMinScore`), aggregated per label.
16715
- * Absent on legacy rows / tracks with no confident audio. */
16716
- audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
16717
- /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
16718
- * Populated from the persisted envelope columns on historical reads;
16719
- * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
16720
- envelope: TrackEnvelopeSchema.optional(),
16632
+ state: _enum(["failed", "backoff"]),
16633
+ /** Epoch ms of the death that produced this state. */
16634
+ since: number(),
16635
+ /** Pool deaths inside the current window. */
16636
+ deaths: number(),
16637
+ /** The last death's message. */
16638
+ lastError: string()
16639
+ })).readonly() })), method(object({
16640
+ nodeId: string(),
16641
+ deviceKey: string()
16642
+ }), object({ rearmed: boolean() }), {
16643
+ kind: "mutation",
16644
+ auth: "admin"
16645
+ }), 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({
16646
+ name: string(),
16647
+ steps: array(PipelineTemplateStepSchema).readonly(),
16648
+ engine: PipelineEngineChoiceSchema
16649
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
16650
+ id: string(),
16651
+ name: string().optional(),
16652
+ steps: array(PipelineTemplateStepSchema).readonly().optional()
16653
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
16654
+ addonId: string(),
16655
+ modelId: string(),
16656
+ format: ModelFormatSchema$1
16657
+ }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
16658
+ addonId: string(),
16659
+ modelId: string(),
16660
+ format: ModelFormatSchema$1
16661
+ }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
16662
+ engine: PipelineEngineChoiceSchema.optional(),
16663
+ steps: array(PipelineStepInputSchema).min(1),
16664
+ frame: FrameInputSchema.optional(),
16721
16665
  /**
16722
- * A face DETECTOR found a face on this track — nothing more. It says the
16723
- * detail plane produced a `face` detail; it does NOT say the face was
16724
- * embedded, matched, above `minFacePx`, or that the recognizer was even
16725
- * enabled. Set once and never cleared.
16726
- *
16727
- * **This exists so "face present but not recognised" is expressible.** A
16728
- * recognised identity lands in `subLabel` (attributed to the face chain via
16729
- * `subLabelMeta.stepId`), so before this field a track with an unmatched face
16730
- * and a track with no face at all were byte-identical on the wire and no
16731
- * surface could tell them apart. The read is `hasFace === true && subLabel
16732
- * === undefined`.
16733
- *
16734
- * **Absent ≠ false.** Every row written before the column existed omits it,
16735
- * and so does every server that predates the field — a consumer must test
16736
- * `=== true` and render nothing otherwise, never infer "no face".
16666
+ * Process-local lazy frame. Valid only when caller and provider resolve
16667
+ * in the same execution-group process; split/cross-node callers use
16668
+ * `frame`/`image` inline compatibility instead.
16737
16669
  */
16738
- hasFace: boolean().optional(),
16670
+ frameRef: FrameRefSchema.optional(),
16739
16671
  /**
16740
- * This track has a face row IN THE GALLERY: a crop **and** an embedding — a
16741
- * face an operator could ASSIGN to an identity.
16742
- *
16743
- * The STRICT twin of {@link hasFace}, and the pair only earns its keep
16744
- * because the two disagree. `hasFace` is stamped at the TOP of the face
16745
- * branch, before every gate, and means no more than "a face detector produced
16746
- * a face detail". This one is stamped at the single moment the gallery row
16747
- * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
16748
- * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
16749
- * candidate gate, the imageless-track drop (no crop was ever captured) and
16750
- * the crop-store drop. Everything between the detector and that insert can
16751
- * legitimately refuse the face, so a flag written any earlier promises the
16752
- * operator something to assign and delivers nothing.
16753
- *
16754
- * **Independent of recognition.** A face collected but never auto-matched is
16755
- * still assignable — it is in fact the face an operator most wants to reach —
16756
- * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
16757
- * `subLabel`; this says only that the raw material exists.
16758
- *
16759
- * **Set once, never cleared.** A track that produced a gallery row produced
16760
- * one; deleting the row later is the gallery's business, not this flag's.
16761
- *
16762
- * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
16763
- * before the column omits it, and so does every server that predates the
16764
- * field. A consumer must test `=== true` and render nothing otherwise —
16765
- * never infer "no assignable face".
16672
+ * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
16673
+ * the decoded pixels live in. One more member of the one-of
16674
+ * frame/frameHandle/image/imageBase64/referenceImage group.
16766
16675
  */
16767
- hasEmbeddedFace: boolean().optional(),
16676
+ frameHandle: FrameHandleSchema.optional(),
16677
+ imageBase64: string().optional(),
16768
16678
  /**
16769
- * This subject CONTAINS a folded rider — a person the rider-pairing step
16770
- * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
16771
- * so the passage is tracked once and as a VEHICLE.
16772
- *
16773
- * It exists because the fold's record was dishonest. D34 and the code both
16774
- * said "the person is not lost — it is reported so both entities stay on the
16775
- * record"; in fact the pair went into a per-processor RAM field behind an
16776
- * accessor nobody called, and every durable surface said `vehicle`, full
16777
- * stop. This is the composition note that makes the row true.
16778
- *
16779
- * A COMPOSITION, never a class and never a label. "This vehicle contains a
16780
- * person" is not an answer to "what is this" — both label tiers would refuse
16781
- * a macro token anyway (D89), and correctly. Nothing here changes what the
16782
- * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
16783
- * and a `person` rule still does not fire for someone cycling past.
16784
- *
16785
- * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
16786
- * the column, and every hub that predates the field, omits it. Test
16787
- * `=== true` and render nothing otherwise — never infer "no rider".
16679
+ * Binary JPEG bytes — preferred over `imageBase64` on internal
16680
+ * hops (hub → forked worker via Moleculer MsgPack) because it
16681
+ * skips the 33% base64 overhead + the per-call base64 decode on
16682
+ * the detection-pipeline worker. Callers can pass either; exactly
16683
+ * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
16788
16684
  */
16789
- hasRider: boolean().optional(),
16790
- ...TrackFlagFields,
16791
- ...TrackRetrainFields
16792
- });
16793
- var BaseEventFields = {
16794
- id: string(),
16795
- deviceId: number(),
16796
- timestamp: number()
16797
- };
16798
- var MotionEventSchema = object({
16799
- ...BaseEventFields,
16800
- kind: literal("motion"),
16801
- regionCount: number(),
16802
- /** Heavy JSON array — omitted in slim projection. */
16803
- regions: array(object({
16804
- bbox: BoundingBoxSchema,
16805
- pixelCount: number(),
16806
- intensity: number()
16807
- })).readonly().optional(),
16808
- /** Omitted in slim projection. */
16809
- frameWidth: number().optional(),
16810
- /** Omitted in slim projection. */
16811
- frameHeight: number().optional(),
16812
- /** Populated by B5 (recording playback URL for this event). */
16813
- mediaUrl: string().optional()
16814
- });
16685
+ image: _instanceof(Uint8Array).optional(),
16686
+ referenceImage: string().optional(),
16687
+ deviceId: number().optional(),
16688
+ sessionId: string().optional(),
16689
+ /**
16690
+ * Execution plane. 'full' (default) runs the whole tree — benchmark,
16691
+ * reference-image, and detail-subtree calls. 'frame' is the live
16692
+ * per-frame dispatch: ONLY root-plane steps run; crop children
16693
+ * (inputClasses ≠ null) are skipped and served per-track via
16694
+ * pipelineRunner.runDetailSubtree (two-plane design).
16695
+ */
16696
+ plane: _enum(["full", "frame"]).optional(),
16697
+ /**
16698
+ * Inference-device selector (Phase 2 multi-device). Format
16699
+ * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
16700
+ * Omitted ⇒ the runner's default device (current single-engine
16701
+ * behaviour). Selects WHICH device pool of the node runs the call.
16702
+ */
16703
+ deviceKey: string().optional(),
16704
+ /**
16705
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
16706
+ * when the parent crop was resolved from the frame's retained NATIVE
16707
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
16708
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
16709
+ * resolution from that surface — the SAME quality path faces already
16710
+ * had — instead of the downscaled parent tile. `handle` keys the native
16711
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
16712
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
16713
+ * the executor's crop-normalized child ROI back into frame-normalized
16714
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
16715
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
16716
+ * (today's behaviour on the fallback path).
16717
+ */
16718
+ nativeCropRef: NativeCropRefSchema.optional()
16719
+ }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
16720
+ engine: PipelineEngineChoiceSchema.optional(),
16721
+ steps: array(PipelineStepInputSchema).min(1),
16722
+ frames: array(FrameInputSchema).min(1).max(255),
16723
+ deviceId: number().optional(),
16724
+ sessionId: string().optional(),
16725
+ /**
16726
+ * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
16727
+ * the batch to the Python pool's bench preprocess cache
16728
+ * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
16729
+ * preprocessed ONCE and every later inference is a pure-inference cache
16730
+ * hit — the sustained-throughput run measures inference, not
16731
+ * decode+preprocess+infer. Omitted/0 for live frames (all different →
16732
+ * full preprocess every call, correct). Fresh per sustained run;
16733
+ * released via `uncacheFrame`.
16734
+ */
16735
+ frameId: number().int().nonnegative().optional(),
16736
+ /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
16737
+ deviceKey: string().optional()
16738
+ }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
16739
+ data: _instanceof(Uint8Array),
16740
+ width: number().int().positive(),
16741
+ height: number().int().positive(),
16742
+ format: _enum([
16743
+ "rgb",
16744
+ "bgr",
16745
+ "gray"
16746
+ ])
16747
+ }), object({
16748
+ frameId: number(),
16749
+ width: number(),
16750
+ height: number()
16751
+ }), { kind: "mutation" }), method(object({
16752
+ stepId: string(),
16753
+ frameId: number().int()
16754
+ }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
16755
+ batchMode: string(),
16756
+ windowMs: number(),
16757
+ maxBatchSize: number(),
16758
+ concurrency: number()
16759
+ })), method(_void(), array(object({
16760
+ engineKey: string(),
16761
+ engine: PipelineEngineChoiceSchema,
16762
+ modelsLoaded: array(string()).readonly(),
16763
+ inUseByCameras: array(number()).readonly(),
16764
+ /**
16765
+ * Origin of this resident factory.
16766
+ * - `runtime` — main camera-serving engine (no idle TTL).
16767
+ * - `warm-override` — benchmark/test override held in the warm
16768
+ * cache; auto-disposed after the idle TTL.
16769
+ * - `device-pool` — a concurrent per-device pool (Phase 2
16770
+ * multi-device, keyed by `deviceKey`) resolved
16771
+ * via `resolveDeviceFactory`. Runs alongside the
16772
+ * `runtime` engine on a DIFFERENT accelerator
16773
+ * (NPU / iGPU / Coral) — this is how the
16774
+ * Engines tab shows all pools running at once.
16775
+ */
16776
+ kind: _enum([
16777
+ "runtime",
16778
+ "warm-override",
16779
+ "device-pool"
16780
+ ]),
16781
+ /** Native pid of the underlying Python pool (null when no pool). */
16782
+ poolPid: number().nullable(),
16783
+ /** ms since this factory was last used (null when not warm-tracked). */
16784
+ idleMs: number().nullable(),
16785
+ /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
16786
+ idleTtlMs: number().nullable()
16787
+ })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
16788
+ kind: "mutation",
16789
+ auth: "admin"
16790
+ }), method(object({
16791
+ engine: PipelineEngineChoiceSchema,
16792
+ force: boolean().optional()
16793
+ }), object({
16794
+ success: boolean(),
16795
+ reason: string().optional()
16796
+ }), {
16797
+ kind: "mutation",
16798
+ auth: "admin"
16799
+ }), 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({
16800
+ addonId: string(),
16801
+ modelId: string(),
16802
+ filename: string().optional(),
16803
+ settings: record(string(), unknown()).optional()
16804
+ }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
16815
16805
  /**
16816
- * Which detection SOURCE produced an object event. `pipeline` = the ML
16817
- * detection pipeline (decoded-frame inference); `onboard` = the camera's
16818
- * native on-device AI. Both flow through the SAME analysis layers (zoning,
16819
- * tracking, per-kind persistence) but stay distinguishable so consumers
16820
- * (advanced-notifier, occupancy, …) can select which source(s) to act on.
16821
- * Absent on legacy rows ⇒ treat as `pipeline`.
16806
+ * Per-stage gating mode applied to the zones a rule references.
16807
+ *
16808
+ * - `include`: the rule contributes to a **whitelist** for its stage.
16809
+ * When at least one `include` rule fires for a stage, only entities
16810
+ * inside one of those zones pass that stage.
16811
+ * - `exclude`: the rule contributes to a **blacklist** for its stage.
16812
+ * Entities inside one of those zones are dropped at that stage.
16813
+ *
16814
+ * `monitor`-style observation (count without filtering) is not a rule
16815
+ * mode — zones without any matching rule are observed naturally by
16816
+ * `zone-analytics` (live snapshot + history), so an "I just want to
16817
+ * count, not filter" use case needs no rule at all.
16822
16818
  */
16823
- var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
16819
+ var ZoneRuleModeEnum = _enum(["include", "exclude"]);
16824
16820
  /**
16825
- * The confirmed zone crossing that produced an object event. Present ONLY on
16826
- * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
16827
- * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
16828
- * appearance event carry none, so a rule asking for a direction fails closed
16829
- * on them.
16821
+ * Per-consumer rule that references existing zones (geometry) and
16822
+ * defines how a specific pipeline stage should treat them. Each
16823
+ * consumer addon owns its own `ZoneRule[]` array in its per-device
16824
+ * settings:
16830
16825
  *
16831
- * Exactly ONE crossing per event: the emitter turns each confirmed crossing
16832
- * into its own event, so a frame in which a track enters A while leaving B
16833
- * produces two events with two directions — never one ambiguous row.
16826
+ * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
16827
+ * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
16828
+ * - future: notification rules, audio gating, etc.
16834
16829
  *
16835
- * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
16836
- * membership the box has NOW, and by definition it no longer contains the zone
16837
- * that was just left. Without the id here, a zone-scoped rule could never match
16838
- * the exit it asked for.
16830
+ * One rule applies to N zones (`zoneIds[]`) so the operator can
16831
+ * express "ignore motion in ALL of {garden, street}" with a single
16832
+ * rule. `classFilter` narrows the rule to specific object classes —
16833
+ * "drop person detections in the street, but keep cars" is one
16834
+ * `exclude` rule with `classFilter: ['person']`.
16835
+ *
16836
+ * `enabled` is a soft toggle — the operator can keep the rule
16837
+ * configured but inert without deleting it.
16839
16838
  */
16840
- var ZoneCrossingSchema = object({
16841
- direction: _enum(["enter", "exit"]),
16842
- /** Admin zone id crossed. */
16843
- zoneId: string(),
16844
- /** Zone display name at crossing time (falls back to the id). */
16845
- zoneName: string().optional()
16846
- });
16847
- var ObjectEventSchema = object({
16848
- ...BaseEventFields,
16849
- kind: literal("object"),
16850
- /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
16851
- source: DetectionSourceSchema.optional(),
16839
+ var ZoneRuleSchema = object({
16840
+ /** Stable rule id — survives edits, used by the UI for diffing. */
16841
+ id: string(),
16842
+ /** Optional human-readable label rendered in the rule editor. */
16843
+ name: string().optional(),
16844
+ /** Zones this rule targets. The rule's `mode` applies to ALL
16845
+ * listed zones (OR-set: a detection in any one of them counts).
16846
+ * At least one zone id required — a rule with no targets is a
16847
+ * configuration mistake and the form validator rejects it. */
16848
+ zoneIds: array(string()).min(1).readonly(),
16849
+ mode: ZoneRuleModeEnum,
16852
16850
  /**
16853
- * Inference-frame id shared by every object event emitted from the SAME frame
16854
- * — the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
16855
- * 2 people + 1 dog) under one full frame, and link a track's frames over time
16856
- * (group by `trackId`, pick a representative `frameId` as the parent frame).
16857
- * Optional for backward-compat with pre-existing rows / the slim projection
16858
- * includes it (it is light). Absent on rows written before this field.
16851
+ * Class names this rule applies to. Empty / undefined ⇒ rule
16852
+ * applies to every class. Class strings match the `macroClass`
16853
+ * field on detections (e.g. `person`, `car`, `dog`).
16859
16854
  */
16860
- frameId: string().optional(),
16861
- /** Omitted in slim projection. */
16862
- trackId: string().optional(),
16863
- className: string(),
16864
- ...TieredLabelFields,
16865
- /** Omitted in slim projection. */
16866
- confidence: number().optional(),
16867
- /** Heavy JSON — omitted in slim projection. */
16868
- bbox: BoundingBoxSchema.optional(),
16869
- /** Heavy JSON — omitted in slim projection. */
16870
- zones: array(string()).readonly().optional(),
16871
- /** Omitted in slim projection. */
16872
- state: TrackStateSchema.optional(),
16855
+ classFilter: array(string()).readonly().optional(),
16873
16856
  /**
16874
- * The zone crossing this event IS, when it is one. Absent on every other
16875
- * event kind (movement state, appearance, package) — see
16876
- * {@link ZoneCrossingSchema}. Omitted in slim projection.
16857
+ * Minimum bbox/mask overlap (0–1) with any of the rule's zones
16858
+ * required to consider an entity "in the zone". Defaults to the
16859
+ * consumer's stage default when omitted. Kept for back-compat with
16860
+ * existing per-rule overrides; new operators pick the value via
16861
+ * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
16862
+ * set, the lower-level engine reads it as a 0–1 fraction.
16877
16863
  */
16878
- zoneCrossing: ZoneCrossingSchema.optional(),
16879
- /** Detection-frame dimensions in pixels — let consumers normalize the
16880
- * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
16881
- frameWidth: number().optional(),
16882
- frameHeight: number().optional(),
16883
- /** MediaStore key for the crop attached to this event (if any). */
16884
- mediaKey: string().optional(),
16885
- /** Design B: MediaStore key of the track's native-resolution key frame (the
16886
- * best-detection full frame). Resolve via the event-media data-plane
16887
- * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
16888
- * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
16889
- * sources — consumers fall back to `mediaKey` (the tight crop). */
16890
- keyFrameMediaKey: string().optional(),
16891
- /** Populated by B5 (recording playback URL for this event). */
16892
- mediaUrl: string().optional(),
16893
- /** The parent track's key-event importance [0,1], propagated to every object
16894
- * event of the track (so an event row can be sorted by importance without a
16895
- * track join). Absent on legacy rows / before the track was scored. */
16896
- importance: number().optional()
16864
+ overlapThreshold: number().min(0).max(1).optional(),
16865
+ /**
16866
+ * Operator-friendly version of `overlapThreshold` — the percentage
16867
+ * of the detection's bbox that must lie inside the zone for the
16868
+ * rule to match. Documented default is 85%; the engine substitutes
16869
+ * that when the field is omitted (kept optional so existing rules
16870
+ * stored without it stay valid).
16871
+ *
16872
+ * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
16873
+ * rule, the engine prefers `bboxInclusionPct` because it's the
16874
+ * field exposed in the UI. Internally both feed the same gate.
16875
+ */
16876
+ bboxInclusionPct: number().min(0).max(100).optional(),
16877
+ /**
16878
+ * When `true` and a detection has a segmentation mask, use the
16879
+ * mask for overlap instead of the bbox. Detection-stage only;
16880
+ * motion rules ignore this field.
16881
+ */
16882
+ preferMask: boolean().optional(),
16883
+ /**
16884
+ * Soft-toggle: `false` disables the rule without deleting it.
16885
+ * Defaults to `true` so operators creating a rule via the UI
16886
+ * see it active immediately.
16887
+ */
16888
+ enabled: boolean().default(true)
16897
16889
  });
16898
- var AudioEventSchema = object({
16899
- ...BaseEventFields,
16900
- kind: literal("audio"),
16901
- rms: number(),
16902
- dbfs: number(),
16903
- classification: object({
16904
- className: string(),
16905
- originalClass: string().optional(),
16906
- score: number()
16907
- }).optional(),
16908
- /** Populated by B5 (recording playback URL for this event). */
16909
- mediaUrl: string().optional()
16890
+ array(ZoneRuleSchema).readonly();
16891
+ /**
16892
+ * Zone — pure geometry + identity. NO filtering behaviour.
16893
+ *
16894
+ * Zones describe **where** in the frame the operator wants to flag
16895
+ * something; consumer-owned {@link ZoneRule} arrays describe **how**
16896
+ * each pipeline stage uses them. Splitting the two means a single
16897
+ * polygon "Driveway" can simultaneously back a motion-exclude rule,
16898
+ * a detection-include rule on `['car']`, and an occupancy aggregate
16899
+ * — without three duplicated polygons.
16900
+ *
16901
+ * Owned by the orchestrator addon (provider) and mirrored into the
16902
+ * `zones` device-state slice on every mutation. Consumers
16903
+ * (motion-wasm, pipeline-executor, analytics, admin UI) read either
16904
+ * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
16905
+ * mirror with `onChanged`).
16906
+ *
16907
+ * Coordinates are normalised fractions of the frame (0–1) so zones
16908
+ * survive resolution changes and stream profile switches.
16909
+ *
16910
+ * `kind` discriminates between full polygons (closed regions used
16911
+ * for intrusion / occupancy filters) and tripwires (open 2-point
16912
+ * line segments used for cross events). Onboard / firmware-reported
16913
+ * zones (Reolink, ONVIF) are out of scope for now — see the deferred
16914
+ * task list.
16915
+ */
16916
+ var ZoneKindEnum = _enum(["polygon", "tripwire"]);
16917
+ /** Polygon vertex in fraction-of-frame coordinates (0–1). */
16918
+ var PolygonPointSchema = object({
16919
+ x: number(),
16920
+ y: number()
16910
16921
  });
16911
- var MediaFileKindEnum = _enum([
16912
- "crop",
16913
- "thumbnail",
16914
- "snapshot",
16915
- "firstFrame",
16916
- "lastFrame",
16917
- "fullFrame",
16918
- "fullFrameBoxed",
16919
- "faceCrop",
16920
- "plateCrop",
16921
- "keyFrame",
16922
- "keyFrameSmall",
16923
- "thumbnailSmall"
16924
- ]);
16925
- var MediaFileSchema = object({
16926
- key: string(),
16927
- kind: MediaFileKindEnum,
16928
- base64: string(),
16929
- sizeBytes: number(),
16930
- timestamp: number()
16922
+ /** A camera detection zone — pure geometry/identity. */
16923
+ var ZoneSchema = object({
16924
+ id: string(),
16925
+ name: string(),
16926
+ kind: ZoneKindEnum.default("polygon"),
16927
+ /** Polygon vertices, fraction of frame (0–1). */
16928
+ polygon: array(PolygonPointSchema).readonly(),
16929
+ /** Visual color for UI rendering. */
16930
+ color: string().default("#3b82f6")
16931
16931
  });
16932
16932
  /**
16933
- * One media row WITHOUT its bytes.
16933
+ * Zones capability — per-camera CRUD over polygon detection zones.
16934
16934
  *
16935
- * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
16936
- * 140 s track), and a client that renders tiles from the media data plane needs
16937
- * to know only WHAT EXISTS — the bytes then arrive per tile, lazily, over HTTP
16938
- * with an immutable cache, instead of all at once inside a tRPC response that
16939
- * blocks the whole view.
16935
+ * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
16936
+ * to per-device settings and mirrors into the `zones` device-state
16937
+ * slice on every mutation, so downstream consumers can subscribe via
16938
+ * `dev.state.zones.onChanged`.
16940
16939
  *
16941
- * `sizeBytes` is carried because it is what lets a client decide between the
16942
- * stored blob and a `?variant=thumb` rendering without fetching either.
16940
+ * The cap surface only handles geometry + identity; filtering
16941
+ * behaviour (per-class, include/exclude, threshold) lives in the
16942
+ * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
16943
+ * `capabilities/schemas/zone-rule.js`.
16943
16944
  */
16944
- var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
16945
+ var zonesCapability = {
16946
+ name: "zones",
16947
+ scope: "device",
16948
+ mode: "singleton",
16949
+ deviceTypes: [DeviceType.Camera],
16950
+ methods: {
16951
+ listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
16952
+ addZone: method(object({
16953
+ deviceId: number(),
16954
+ zone: ZoneSchema
16955
+ }), _void(), {
16956
+ kind: "mutation",
16957
+ auth: "admin"
16958
+ }),
16959
+ removeZone: method(object({
16960
+ deviceId: number(),
16961
+ zoneId: string()
16962
+ }), _void(), {
16963
+ kind: "mutation",
16964
+ auth: "admin"
16965
+ }),
16966
+ updateZone: method(object({
16967
+ deviceId: number(),
16968
+ zone: ZoneSchema
16969
+ }), _void(), {
16970
+ kind: "mutation",
16971
+ auth: "admin"
16972
+ })
16973
+ },
16974
+ /**
16975
+ * Runtime-state slice — the live zone catalogue mirrored by the
16976
+ * orchestrator on every CRUD mutation. Consumers read via
16977
+ * `device.state.zones.value` / `.watch(...)` without round-tripping
16978
+ * the cap, and the codegen DeviceProxy auto-wires the reactive
16979
+ * handle. Slice shape is `{ zones: Zone[] }` so future extensions
16980
+ * (e.g. zone groupings) can sit alongside the polygon list.
16981
+ */
16982
+ runtimeState: object({ zones: array(ZoneSchema).readonly() }),
16983
+ /**
16984
+ * Runtime-state durability: **restored** — written only on operator mutation, so a camera that never had one has nothing to re-derive from. This is the slice `zone-mirror-hydration.ts` exists to paper over.
16985
+ *
16986
+ * See `RuntimeStateDurability`. Enforced by
16987
+ * `scripts/check-runtime-state-durability.ts`.
16988
+ */
16989
+ durability: "restored"
16990
+ };
16945
16991
  /**
16946
- * The MACRO tier of an annotation — a CLOSED set.
16992
+ * pipeline-analytics — device-scoped wrapper cap. Refines raw
16993
+ * per-frame detections emitted by the pipeline runner into tracked
16994
+ * objects, per-kind event collections (motion / object / audio), and
16995
+ * persisted media. Owns the post-detection domain end-to-end:
16947
16996
  *
16948
- * This is what the exported detector predicts, so a typo here is a new class
16949
- * with one example in it. `label` and `subLabel` are open strings by contrast:
16950
- * the whole point of the page is teaching the model things it does not know
16951
- * yet, and constraining that vocabulary would make it useless.
16997
+ * runner emits PipelineInferenceResult
16998
+ * ↓ (event bus)
16999
+ * pipeline-analytics subscriber
17000
+ * ↓ SORT tracker + zone engine + state analyzer + event emitter
17001
+ * → three DB collections (one per kind), one FS media tree, one
17002
+ * unified event emitter (FrameTracked + TrackStarted/Ended +
17003
+ * DetectionEvent on bus)
16952
17004
  *
16953
- * A macro class is NEVER a label. The provider refuses a write whose `label` or
16954
- * `subLabel` is one of these values, in any casing, because once `person`
16955
- * exists in both tiers "every person box" stops being answerable without
16956
- * knowing every string anyone ever typed — and the damage is retroactive.
17005
+ * Pure subscriber model. No `processFrame` cap method — the runner
17006
+ * already publishes the raw frame on the bus. The cap surface is
17007
+ * only QUERIES + per-device settings, bound on/off via
17008
+ * `device-manager.setWrapperActive`. `defaultActive: true` because
17009
+ * every camera with a detection pipeline wants its raw detections
17010
+ * refined; operators opt out per-device via BindingsTab when needed.
17011
+ *
17012
+ * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
17013
+ * (per-device surface) and `track-trail` caps — see P11 cleanup.
16957
17014
  */
16958
- var RetrainMacroClassSchema = _enum([
17015
+ var TrackStateSchema = _enum([
17016
+ "new",
17017
+ "entered",
17018
+ "left",
17019
+ "moving",
17020
+ "idle"
17021
+ ]);
17022
+ var EventKindSchema = _enum([
17023
+ "motion",
17024
+ "object",
17025
+ "audio"
17026
+ ]);
17027
+ /**
17028
+ * Spatial filter for `listTracks` — the rect + polygon variants of the shared
17029
+ * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
17030
+ * of the camera frame (top-left origin), matching the drawing-plane editor.
17031
+ */
17032
+ var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
17033
+ /** Closed icon vocabulary so clients render a known glyph per kind. */
17034
+ var EventKindIconSchema = _enum([
17035
+ "motion",
17036
+ "audio",
16959
17037
  "person",
16960
17038
  "vehicle",
16961
17039
  "animal",
17040
+ "door",
17041
+ "pir",
17042
+ "smoke",
17043
+ "water",
17044
+ "button",
16962
17045
  "package",
16963
- "face",
16964
- "plate"
17046
+ "generic"
16965
17047
  ]);
16966
- /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
16967
- var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
16968
- /** Did a human draw this box, or did the assist propose it? */
16969
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
16970
- /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
16971
- var RetrainBboxSchema = object({
16972
- x: number(),
16973
- y: number(),
16974
- w: number(),
16975
- h: number()
17048
+ var EventKindCategorySchema = _enum([
17049
+ "motion",
17050
+ "audio",
17051
+ "detection",
17052
+ "sensor",
17053
+ "control",
17054
+ "custom",
17055
+ "package"
17056
+ ]);
17057
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
17058
+ var EventKindLevelSchema = _enum(["macro", "sub"]);
17059
+ var EventKindDescriptorSchema = object({
17060
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
17061
+ kind: string(),
17062
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
17063
+ labelKey: string(),
17064
+ /** English fallback label (kept for clients that don't translate). */
17065
+ label: string(),
17066
+ /** Hex color for timeline/legend rendering. */
17067
+ color: string(),
17068
+ /** Dictionary id → lucide component on the UI side. */
17069
+ iconId: string(),
17070
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
17071
+ icon: EventKindIconSchema,
17072
+ category: EventKindCategorySchema,
17073
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
17074
+ parentKind: string().nullable(),
17075
+ /** Derived from `parentKind`, explicit for the client tree. */
17076
+ level: EventKindLevelSchema,
17077
+ /** Which cap + device contributes this kind. For built-ins the camera
17078
+ * itself; for sensor kinds the LINKED source device. */
17079
+ source: object({
17080
+ capName: string(),
17081
+ deviceId: number()
17082
+ })
16976
17083
  });
16977
- /**
16978
- * One annotated subject.
16979
- *
16980
- * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
16981
- * (letterboxed root / zone-cropped package / subject-cropped classifier) are
16982
- * derived from it at export and never stored — storing them is how one feature
16983
- * space ends up holding two crops of the same subject (D52).
16984
- */
16985
- var RetrainAnnotationSchema = object({
16986
- id: string(),
16987
- trackId: string(),
17084
+ /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
17085
+ var EventKindsForDeviceSchema = object({
16988
17086
  deviceId: number(),
16989
- /** The COPY in retrain storage — never the source track's media key. */
16990
- mediaKey: string(),
16991
- bbox: RetrainBboxSchema,
16992
- macroClass: RetrainMacroClassSchema,
16993
- label: string().optional(),
16994
- subLabel: string().optional(),
16995
- kind: RetrainAnnotationKindSchema,
16996
- source: RetrainAnnotationSourceSchema,
16997
- /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
16998
- assistModelId: string().optional(),
16999
- assistScore: number().optional(),
17000
- exportedInBatch: string().optional(),
17001
- createdAt: number()
17002
- });
17003
- /** The write form — the server owns `id`, `createdAt` and the frame binding. */
17004
- var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
17005
- id: true,
17006
- trackId: true,
17007
- deviceId: true,
17008
- mediaKey: true,
17009
- createdAt: true,
17010
- exportedInBatch: true
17087
+ kinds: array(EventKindDescriptorSchema).readonly()
17011
17088
  });
17012
- /** A track sitting in `staging`, with everything the worklist needs to rank it. */
17013
- var RetrainTrackSchema = object({
17014
- trackId: string(),
17089
+ var SensorEventSchema = object({
17090
+ id: string(),
17091
+ /** The CAMERA the event is attributed to (a sensor linked to N cameras
17092
+ * yields N rows, one per camera). */
17015
17093
  deviceId: number(),
17016
- className: string(),
17017
- label: string().optional(),
17018
- firstSeen: number(),
17019
- lastSeen: number(),
17020
- /** How many frames the dataset already holds from this track. */
17021
- frameCount: number().int(),
17022
- /** How many subjects have been annotated on those frames. `0` with
17023
- * `frameCount: 0` is exactly "staging, still to work". */
17024
- annotationCount: number().int()
17094
+ /** The linked sensor device whose state changed. */
17095
+ sourceDeviceId: number(),
17096
+ /** Event kind id — matches an `EventKindDescriptor.kind`. */
17097
+ kind: string(),
17098
+ /** Snapshot of the sensor cap's runtime-state slice at the change. */
17099
+ value: record(string(), unknown()).nullable(),
17100
+ timestamp: number()
17025
17101
  });
17026
- /** A frame the picker may offer — an index row, no blob was read to produce it. */
17027
- var RetrainFrameCandidateSchema = object({
17028
- mediaKey: string(),
17029
- kind: MediaFileKindEnum,
17102
+ var TrackPositionSchema = object({
17103
+ x: number(),
17104
+ y: number(),
17030
17105
  timestamp: number(),
17031
- sizeBytes: number().int(),
17032
- /** A copy of this original already exists — selecting it is free and cannot
17033
- * fail, whatever became of the original. */
17034
- copied: boolean()
17035
- });
17036
- /** A frame the dataset OWNS: bytes copied at selection time. */
17037
- var RetrainFrameSchema = object({
17038
- frameId: string(),
17039
- deviceId: number(),
17040
- trackId: string(),
17041
- /** Provenance only. It may already point at nothing — that is expected. */
17042
- sourceMediaKey: string(),
17043
- sourceKind: MediaFileKindEnum,
17044
- sizeBytes: number().int(),
17045
- width: number().int(),
17046
- height: number().int(),
17047
- copiedAt: number()
17048
- });
17049
- /** Why a copy-on-select could not be honoured — named, never a silent skip. */
17050
- var RetrainCopyRefusalSchema = _enum([
17051
- "source-missing",
17052
- "unreadable-image",
17053
- "write-failed"
17054
- ]);
17055
- var RetrainFrameSelectionSchema = object({
17056
- copied: array(RetrainFrameSchema).readonly(),
17057
- refused: array(object({
17058
- sourceMediaKey: string(),
17059
- reason: RetrainCopyRefusalSchema
17060
- })).readonly()
17106
+ bbox: BoundingBoxSchema
17061
17107
  });
17062
- var RetrainFrameListSchema = object({
17063
- candidates: array(RetrainFrameCandidateSchema).readonly(),
17064
- copies: array(RetrainFrameSchema).readonly(),
17065
- /** What the page pre-selects — the native key frame when one survives. */
17066
- autoPickMediaKey: string().optional()
17108
+ var TrackSnapshotSchema = object({
17109
+ timestamp: number(),
17110
+ position: TrackPositionSchema,
17111
+ /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
17112
+ mediaKey: string()
17067
17113
  });
17068
- /** What the operator asked the assist to look for. */
17069
- var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
17070
- kind: literal("package"),
17071
- zone: RetrainBboxSchema.optional()
17072
- }), object({
17073
- kind: literal("objects"),
17074
- modelId: string(),
17075
- minScore: number().optional()
17076
- })]);
17077
17114
  /**
17078
- * The assist's answer — a discriminated union, because "the model saw nothing"
17079
- * and "this node cannot run that model" lead to different next moves and a
17080
- * nullable result cannot tell them apart.
17115
+ * Normalized 0..1 trajectory envelope (min/max over every position bbox,
17116
+ * divided by the track's detection-frame dims), computed at persist time.
17117
+ * Absent when the frame dims were unknown when the track was persisted
17118
+ * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
17081
17119
  */
17082
- var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
17083
- kind: literal("proposed"),
17084
- modelId: string(),
17085
- stepId: string(),
17086
- minScore: number(),
17087
- /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
17088
- proposals: array(RetrainAnnotationDraftSchema).readonly(),
17089
- /** Returned by the runner but removed by the threshold. */
17090
- belowThreshold: number().int()
17091
- }), object({
17092
- kind: literal("refused"),
17093
- /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
17094
- reason: string(),
17095
- detail: string().optional()
17096
- })]);
17097
- /** The outcome of a lifecycle move owned by the retrain page. */
17098
- var RetrainTransitionResultSchema = object({
17099
- trackId: string(),
17100
- /** Where the track ended up, whatever happened. */
17101
- retrainStatus: RetrainStatusSchema,
17102
- /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
17103
- changed: boolean(),
17104
- reason: _enum([
17105
- "unknown-track",
17106
- "no-frames-copied",
17107
- "not-staging",
17108
- "not-trained",
17109
- "unchanged"
17110
- ]).optional()
17120
+ var TrackEnvelopeSchema = object({
17121
+ minX: number(),
17122
+ minY: number(),
17123
+ maxX: number(),
17124
+ maxY: number()
17111
17125
  });
17112
- var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
17113
- var MAX_EVENT_QUERY_LIMIT = 5e3;
17114
- var DeviceEventQueryInput = object({
17115
- deviceId: number(),
17116
- since: number().optional(),
17117
- until: number().optional(),
17118
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
17119
- /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
17120
- * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
17121
- * exact behaviour. Callers may omit this field — the store defaults to
17122
- * `full` when not provided. */
17123
- projection: _enum(["full", "slim"]).optional()
17124
- });
17125
- var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
17126
- var RecentTracksQueryInput = object({
17127
- /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
17128
- deviceIds: array(number()),
17129
- /** Window lower bound on `lastSeen` (inclusive). */
17130
- since: number().optional(),
17131
- /** Window upper bound on `lastSeen` (inclusive). */
17132
- until: number().optional(),
17133
- /** Page size. Default 200, max 1000. */
17134
- limit: number().int().min(1).max(1e3).default(200),
17135
- /** Opaque continuation cursor from a previous page's `nextCursor`.
17136
- * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
17137
- cursor: string().optional(),
17138
- /** See {@link TrackProjectionSchema}. Default `full`. */
17139
- projection: TrackProjectionSchema.optional(),
17140
- /** Include stationary-promoted rows (parked objects). Default false: the
17141
- * feed lists passages; parking records live on the stationary registry. */
17142
- includeStationary: boolean().optional()
17143
- });
17144
- var RecentTracksPageSchema = object({
17145
- /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
17146
- tracks: array(TrackSchema).readonly(),
17147
- /** Cursor for the next page, or null when this page is the last. */
17148
- nextCursor: string().nullable()
17149
- });
17150
- var LIST_GROUPS_DEFAULT_LIMIT = 40;
17151
- var LIST_GROUPS_MAX_LIMIT = 100;
17152
- var AnalyticsGroupRecordSchema = object({
17153
- id: string(),
17154
- deviceId: number().int(),
17155
- openedAt: number().int(),
17156
- closedAt: number().int(),
17157
- timestamp: number().int(),
17158
- memberCount: number().int(),
17159
- memberTrackIds: array(string()).readonly(),
17160
- className: string(),
17161
- classes: array(string()).readonly(),
17162
- /** Relative event-media path, or null when the group has no picture yet. */
17163
- mediaUrl: string().nullable(),
17164
- singleton: boolean()
17165
- });
17166
- var AnalyticsGroupMemberSchema = object({
17167
- trackId: string(),
17168
- deviceId: number().int(),
17169
- className: string(),
17170
- firstSeen: number().int(),
17171
- lastSeen: number().int(),
17172
- mediaUrl: string().nullable()
17173
- });
17174
- var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
17175
- var ListGroupsQueryInput = object({
17176
- /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
17177
- deviceIds: array(number()),
17178
- /** Window lower bound on `closedAt` (inclusive). */
17179
- since: number().optional(),
17180
- /** Window upper bound on `openedAt` (inclusive). */
17181
- until: number().optional(),
17182
- limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
17183
- /** Opaque continuation cursor from a previous page's `nextCursor`. */
17184
- cursor: string().optional()
17185
- });
17186
- var ListGroupsPageSchema = object({
17187
- groups: array(AnalyticsGroupRecordSchema).readonly(),
17188
- nextCursor: string().nullable()
17189
- });
17190
- var KeyEventQueryInput = object({
17191
- deviceId: number(),
17192
- /** Window lower bound (track firstSeen ≥ since). */
17193
- since: number(),
17194
- /** Window upper bound (track firstSeen ≤ until). */
17195
- until: number(),
17196
- limit: number().int().min(1).max(200).default(50),
17197
- /** Drop tracks scoring below this importance. */
17198
- minImportance: number().min(0).max(1).optional(),
17199
- /** Restrict to a single class (e.g. 'person'). */
17200
- classFilter: string().optional()
17201
- });
17202
- var KeyEventSchema = object({
17203
- /** The representative event id (the track's best ObjectEvent, else its trackId). */
17204
- id: string(),
17205
- trackId: string(),
17206
- /** Track start time (firstSeen). */
17207
- timestamp: number(),
17208
- className: string(),
17209
- ...TieredLabelFields,
17210
- importance: number(),
17211
- /** Highest-confidence ObjectEvent id for the track (empty when none). */
17212
- bestEventId: string(),
17213
- /** Track lifetime in ms (lastSeen - firstSeen). */
17214
- windowMs: number().optional(),
17215
- ...TrackFlagFields,
17216
- ...TrackRetrainFields
17217
- });
17218
- object({
17219
- trackId: string(),
17220
- className: string(),
17221
- confidence: number(),
17222
- bbox: BoundingBoxSchema,
17223
- zones: array(string()).readonly(),
17224
- state: TrackStateSchema
17225
- });
17226
- var OverlayDetectionSchema = looseObject({
17227
- id: string(),
17228
- kind: _enum(["first-level", "detail"]),
17229
- macroClass: string(),
17230
- score: number(),
17231
- bbox: object({
17232
- x: number(),
17233
- y: number(),
17234
- width: number(),
17235
- height: number()
17236
- }),
17237
- labels: array(looseObject({
17238
- label: string(),
17239
- score: number()
17240
- })).readonly(),
17241
- parentId: string().optional()
17242
- });
17243
- var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
17244
- var SearchObjectEventsInput = object({
17245
- text: string(),
17246
- deviceId: number().optional(),
17247
- since: number().optional(),
17248
- until: number().optional(),
17249
- classFilter: string().optional(),
17250
- limit: number().default(50),
17251
- minScore: number().min(0).max(1).default(.2)
17252
- });
17253
- var TrackCascadeCountsSchema = object({
17254
- /** Persisted track roots deleted (authoritative). */
17255
- tracks: number().int(),
17256
- /** Object events removed with their tracks (best-effort; see note above). */
17257
- events: number().int(),
17258
- /** Track/face/plate-owned media removed (best-effort). Never identity media. */
17259
- media: number().int(),
17260
- /** Unassigned (non-enrolled) face reads removed (best-effort). */
17261
- faces: number().int(),
17262
- /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
17263
- plates: number().int(),
17264
- /** Per-track CLIP search vectors removed (best-effort). */
17265
- embeddings: number().int(),
17266
- /** Group membership + group rows removed with their last member (best-effort). */
17267
- groups: number().int()
17268
- });
17269
- /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
17270
- var DiskReconcileCountsSchema = object({
17271
- mediaDropped: number().int(),
17272
- tracks: number().int(),
17273
- events: number().int()
17274
- });
17275
- /** Event-store footprint for one camera. */
17276
- var EventStoreDeviceFootprintSchema = object({
17277
- deviceId: number(),
17278
- /** Persisted event rows (motion + object + audio) for the camera. */
17279
- rows: number().int(),
17280
- /** Event-owned media bytes on disk for the camera. */
17281
- bytes: number().int()
17282
- });
17283
- /** Aggregate event-store footprint: global totals + per-camera breakdown. */
17284
- var EventStoreFootprintSchema = object({
17285
- totalRows: number().int(),
17286
- totalBytes: number().int(),
17287
- devices: array(EventStoreDeviceFootprintSchema).readonly()
17288
- });
17289
- /** Per-kind counts returned by the event-prune / device-delete mutations. */
17290
- var EventPruneCountsSchema = object({
17291
- motion: number().int(),
17292
- object: number().int(),
17293
- audio: number().int()
17126
+ /**
17127
+ * Row projection for track list queries. `full` (default) returns the
17128
+ * complete Track including the frame-rate `positions[]` history and the
17129
+ * `snapshots[]` references — megabytes across a page of tracks. `slim`
17130
+ * keeps every scalar the list surfaces actually render (ids, class(es),
17131
+ * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
17132
+ * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
17133
+ * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
17134
+ * `getTrack`. Mirrors the event-store `projection` convention
17135
+ * (`getObjectEvents` et al.).
17136
+ */
17137
+ var TrackProjectionSchema = _enum(["full", "slim"]);
17138
+ /**
17139
+ * One audio-classification label heard on the track's camera while the
17140
+ * track was alive, aggregated per label. An "episode" is one persisted
17141
+ * audio event (the confident-classification path: score ≥ the device's
17142
+ * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
17143
+ * one 32 ms inference chunk, so counts stay human-scaled.
17144
+ */
17145
+ var TrackAudioLabelSchema = object({
17146
+ label: string(),
17147
+ /** Highest classification score observed across the label's episodes. */
17148
+ peakScore: number(),
17149
+ /** Number of coalesced audio-event episodes carrying this label. */
17150
+ count: number(),
17151
+ firstAt: number(),
17152
+ lastAt: number()
17294
17153
  });
17295
17154
  /**
17296
- * Re-embed stored tracks from their key frames.
17155
+ * How a track was produced. `pipeline` (default / absent) = the spatial
17156
+ * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
17157
+ * no positions, a single snapshot, and no bbox trajectory at all:
17297
17158
  *
17298
- * The reason this is an operator-callable method and not a migration script:
17299
- * every knob that decides what a vector MEANS — encoder model, crop margin,
17300
- * squaring — is only changeable if the existing vectors can be regenerated.
17301
- * Mixing feature spaces in one index makes cosine scores incomparable, and the
17302
- * symptom is a quality regression with no visible cause.
17159
+ * - `sensor` — a linked sensor/control device state change.
17160
+ * - `audio` — an audio event on the camera itself that was anomalous for
17161
+ * THAT camera, loud, and heard while nothing visual was happening (D62).
17162
+ *
17163
+ * The spatial subsystems (tracker association, occupancy count, re-id /
17164
+ * embedding, resurrection) MUST skip every synthetic source. Test for that
17165
+ * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
17166
+ * check silently readmits every source added after it was written.
17303
17167
  */
17304
- var RebuildObjectEmbeddingsInput = object({
17305
- /** Restrict to one camera. Omit for the whole fleet. */
17306
- deviceId: number().optional(),
17307
- since: number().optional(),
17308
- until: number().optional(),
17309
- /** Stop after this many tracks; the result reports whether more remain. */
17310
- maxTracks: number().int().positive().optional(),
17311
- /**
17312
- * Run every embedding on THIS node instead of round-robining the fleet.
17313
- *
17314
- * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
17315
- * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
17316
- * calling it that would pin the rebuild REQUEST itself to that node — the
17317
- * rebuild orchestration lives on the hub, and only the per-track step runs
17318
- * remotely. This field is data; the per-track pin is applied inside.
17319
- *
17320
- * Absent ⇒ round-robin over every online node whose runner can serve the
17321
- * pinned model.
17322
- */
17323
- executeOnNodeId: string().optional(),
17324
- /**
17325
- * Milliseconds to wait between tracks; omit for the built-in default, `0` to
17326
- * run flat out.
17327
- *
17328
- * A rebuild is bulk maintenance on hub-main's single thread. Measured
17329
- * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
17330
- * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
17331
- * force is logged at start and finish so a deliberately slow pass reads
17332
- * differently from a stalled one.
17333
- */
17334
- pacingMs: number().int().nonnegative().optional()
17335
- });
17168
+ var TrackSourceSchema = _enum([
17169
+ "pipeline",
17170
+ "sensor",
17171
+ "audio"
17172
+ ]);
17336
17173
  /**
17337
- * Result of emptying the CLIP index.
17174
+ * Where a track sits in the RETRAIN lifecycle (D81).
17338
17175
  *
17339
- * The clean slate before a policy change: a new crop margin or encoder model
17340
- * leaves two feature spaces in one index whose cosine scores are not
17341
- * comparable, so wiping and rebuilding is the only way to be sure every vector
17342
- * means the same thing.
17176
+ * - `none` — never marked, or un-marked. Evictable.
17177
+ * - `staging` — the operator wants this track as training material and has not
17178
+ * finished with it. **This is the only state retention holds**: the track and
17179
+ * everything it owns (object events, crops, keyframes, CLIP vector) survive
17180
+ * the device's age window.
17181
+ * - `trained` — the retrain page has taken what it needed. The frames it chose
17182
+ * were COPIED into the retrain dataset at selection time, so the dataset no
17183
+ * longer depends on the track's media and the track becomes EVICTABLE again.
17184
+ * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
17185
+ * a deliberate action of the retrain page, not a side effect of a checkbox.
17186
+ *
17187
+ * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
17188
+ * the store's filter language has only positive equality and `whereIn` — no
17189
+ * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
17190
+ * would make the entire pre-column history immortal in one deploy.
17343
17191
  */
17344
- var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
17192
+ var RetrainStatusSchema = _enum([
17193
+ "none",
17194
+ "staging",
17195
+ "trained"
17196
+ ]);
17345
17197
  /**
17346
- * Acknowledgement that a rebuild STARTED.
17198
+ * Per-track OPERATOR flags — set by hand from the admin UI or the viewer, never
17199
+ * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
17200
+ * so the two surfaces cannot drift.
17347
17201
  *
17348
- * The pass costs ~1s per track — 45 minutes for a 2,600-track fleet — so it
17349
- * runs detached and this returns immediately. Waiting for it made the client
17350
- * time out while the work carried on server-side, which is the worst of both:
17351
- * no result and no way to know it was still going. Poll
17352
- * `getObjectEmbeddingRebuildStatus` for progress.
17353
- */
17354
- var RebuildObjectEmbeddingsResultSchema = object({
17355
- started: boolean(),
17356
- /** True when a pass was already running; the new request is ignored. */
17357
- alreadyRunning: boolean()
17358
- });
17359
- var RebuildStatusSchema = object({
17360
- running: boolean(),
17361
- scanned: number(),
17362
- rebuilt: number(),
17363
- /** Tracks whose key frame is gone — nothing to re-embed from. */
17364
- missingKeyFrame: number(),
17365
- /** Tracks with no usable detection box. */
17366
- missingBbox: number(),
17367
- /**
17368
- * Tracks an executing node REFUSED rather than broke on — an unreadable key
17369
- * frame, a step that threw. Separate from `failed` because the remedy is
17370
- * different, and because a whole camera silently contributing zero vectors
17371
- * is the shape of failure a rebuild must never hide.
17372
- */
17373
- notRunnable: number(),
17202
+ * **Absent ≠ false.** A track that has never been touched omits the field; an
17203
+ * explicitly un-flagged track carries `false`. Legacy rows written before the
17204
+ * columns existed read as absent, and a consumer that needs a boolean should say
17205
+ * `flag === true`, not `flag !== false`.
17206
+ *
17207
+ * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
17208
+ * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
17209
+ * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
17210
+ * `trained` track reports `false` while refusing both writes. The boolean is
17211
+ * kept because three surfaces drive a toggle off it; anything that needs to tell
17212
+ * "never marked" from "already trained" must read `retrainStatus`.
17213
+ *
17214
+ * `debug` does NOT pin; it is attention, not durability.
17215
+ *
17216
+ * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
17217
+ * A favourited track is skipped by retention the same way `staging` is, but
17218
+ * it does not enter `none|staging|trained` and has no staging budget.
17219
+ */
17220
+ var TrackFlagFields = {
17221
+ /** Operator marked this track as training material — i.e. `retrainStatus` is
17222
+ * `'staging'`. */
17223
+ markForTrain: boolean().optional(),
17224
+ /** Operator marked this track for diagnostic attention. */
17225
+ debug: boolean().optional(),
17226
+ /** Operator favourited this track. Pins it against pruning. */
17227
+ favourited: boolean().optional()
17228
+ };
17229
+ /**
17230
+ * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
17231
+ * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
17232
+ * write patch, and the status is not something the toggle sets — it is what the
17233
+ * toggle's boolean is derived from. Absent on an in-RAM track never touched;
17234
+ * always present on a persisted row (the column default materialises `'none'`).
17235
+ */
17236
+ var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
17237
+ /**
17238
+ * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
17239
+ * one flag can never clear the other — the toggles are independent and are
17240
+ * driven from three surfaces that do not know about each other.
17241
+ */
17242
+ var TrackFlagsPatchSchema = object(TrackFlagFields);
17243
+ /**
17244
+ * The resolved flag state after a write. Both fields are REQUIRED here (absent
17245
+ * collapses to `false`) so a caller can drive a toggle's checked state off the
17246
+ * mutation result without a re-fetch.
17247
+ */
17248
+ var TrackFlagsSchema = object({
17249
+ trackId: string(),
17250
+ markForTrain: boolean(),
17251
+ debug: boolean(),
17252
+ favourited: boolean(),
17253
+ /** The lifecycle state the boolean was derived from. Required here (unlike on
17254
+ * a track row) because this shape is only ever produced by the write body,
17255
+ * which always knows it — and a surface that has just written needs to render
17256
+ * `trained` without a re-fetch. */
17257
+ retrainStatus: RetrainStatusSchema
17258
+ });
17259
+ union([literal(1), literal(2)]);
17260
+ /**
17261
+ * WHO decided a label, and when. Carried per tier so a value can be traced to
17262
+ * the step and model that produced it — which is what makes the write rule
17263
+ * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
17264
+ * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
17265
+ *
17266
+ * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
17267
+ * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
17268
+ * `migration:4g` for a value the 4g migration moved from the single-slot era —
17269
+ * that value has no provenance, and the write rule lets ANY properly-attributed
17270
+ * write of the same tier replace it regardless of score.
17271
+ */
17272
+ var LabelAttributionSchema = object({
17273
+ stepId: string(),
17274
+ modelId: string().optional(),
17275
+ decidedAt: number(),
17374
17276
  /**
17375
- * The pass stopped because NO node could serve the pinned model.
17277
+ * The GALLERY id behind a recognised tier-2 label — a face-gallery
17278
+ * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
17376
17279
  *
17377
- * Distinct from `notRunnable` on purpose: that one says "this track was
17378
- * refused", this one says "the cluster cannot do this work at all" — every
17379
- * candidate node either lacks the `clip-embedding` step, lacks a build of the
17380
- * pinned model for its engine format, or dropped out. The remedy is a model /
17381
- * engine change, not a per-camera one. Non-zero here always comes with
17382
- * `complete: false`.
17280
+ * The text alone is a DISPLAY NAME, and a display name is renameable: a
17281
+ * notification rule authored on "Gianluca" stopped matching the moment the
17282
+ * operator fixed the spelling in the gallery, and nothing said so. The id is
17283
+ * the thing that does not move, so it is what a rule matches on
17284
+ * (`NcConditions.identities`) and the text is what a human is shown.
17285
+ *
17286
+ * Absent when the label names no gallery row — a plate the OCR read but no
17287
+ * vehicle claims, a sub-class, a species, any tier-1 value.
17383
17288
  */
17384
- noCapableNode: number(),
17385
- failed: number(),
17386
- /** Set once a pass ends: true only when EVERYTHING was covered. */
17387
- complete: boolean().nullable(),
17388
- startedAtMs: number().nullable(),
17389
- finishedAtMs: number().nullable(),
17390
- /** Present when the pass ended by throwing. */
17391
- error: string().nullable()
17289
+ identityId: string().optional()
17392
17290
  });
17393
- DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
17394
- deviceId: number(),
17395
- trackId: string()
17396
- }), TrackSchema.nullable()), method(object({
17397
- deviceId: number(),
17398
- since: number().optional(),
17399
- until: number().optional(),
17400
- limit: number().optional(),
17401
- /** Spatial filter — only tracks whose trajectory intersects the zone
17402
- * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
17403
- * envelope columns, then precisely tested per position. Tracks with
17404
- * an unknown envelope (no frame dims at persist time) always match. */
17405
- zone: TrackZoneFilterSchema.optional(),
17406
- /** See {@link TrackProjectionSchema}. Default `full` (backward
17407
- * compatible — omitting the field keeps today's exact behaviour). */
17408
- projection: TrackProjectionSchema.optional(),
17409
- /** Include stationary-promoted rows (parked objects handed to the
17410
- * stationary registry). Default false: the timeline lists passages,
17411
- * not parking records (operator decision, 2026-08-15). */
17412
- includeStationary: boolean().optional()
17413
- }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
17414
- deviceId: number(),
17415
- groupId: string().min(1)
17416
- }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
17417
- kind: "mutation",
17418
- auth: "admin"
17419
- }), 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({
17420
- deviceId: number(),
17421
- since: number().optional(),
17422
- until: number().optional(),
17423
- kinds: array(string()).optional(),
17424
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
17425
- }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
17426
- deviceId: number(),
17427
- since: number(),
17428
- until: number(),
17429
- bucketMs: number().int().positive()
17430
- }), array(object({
17431
- bucketStart: number(),
17432
- motion: number().int(),
17433
- object: number().int(),
17434
- audio: number().int()
17435
- })).readonly()), method(object({
17436
- deviceId: number(),
17437
- cutoffMs: number()
17438
- }), object({
17439
- motion: number().int(),
17440
- object: number().int(),
17441
- audio: number().int()
17442
- }), {
17443
- kind: "mutation",
17444
- auth: "admin"
17445
- }), method(object({
17446
- deviceId: number(),
17447
- cutoffMs: number()
17448
- }), TrackCascadeCountsSchema, {
17449
- kind: "mutation",
17450
- auth: "admin"
17451
- }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
17452
- kind: "mutation",
17453
- auth: "admin"
17454
- }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
17455
- kind: "mutation",
17456
- auth: "admin"
17457
- }), method(object({
17458
- deviceId: number(),
17459
- trackIds: array(string()).min(1)
17460
- }), object({
17461
- deleted: number().int(),
17462
- failed: array(string()).readonly()
17463
- }), {
17464
- kind: "mutation",
17465
- auth: "admin"
17466
- }), method(object({
17467
- /** Log/audit scope only — the trackId is globally unique on its own. */
17291
+ /**
17292
+ * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
17293
+ * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
17294
+ * track and its events always answer the same question the same way.
17295
+ *
17296
+ * Two scalar columns, not an array: every consumer wants "the coarse one" or
17297
+ * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
17298
+ * is tier 2, and each carries its own score + attribution.
17299
+ *
17300
+ * **Reading it.** What a human should be shown is `subLabel ?? label` — the
17301
+ * finest thing known. Before 4g the single `label` column held the finest
17302
+ * value, so a consumer that has not been updated reads the tier-1 slot and
17303
+ * shows nothing on a species-only row; that is why the migration puts every
17304
+ * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
17305
+ * and why the read surfaces were changed in the same train.
17306
+ *
17307
+ * **Writing it.** The slots are independent, which is the whole point: a
17308
+ * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
17309
+ * migratorius`), so fineness cannot regress by construction. Within a tier the
17310
+ * higher score wins. One rule, one implementation — see
17311
+ * `pipeline/label-tier.ts` in addon-post-analysis.
17312
+ */
17313
+ var TieredLabelFields = {
17314
+ /** Tier 1 — the sub-class. See {@link LabelTierSchema}. */
17315
+ label: string().optional(),
17316
+ /** Confidence of the tier-1 value, as reported by the deciding step. */
17317
+ labelScore: number().optional(),
17318
+ /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
17319
+ labelMeta: LabelAttributionSchema.optional(),
17320
+ /** Tier 2 — the instance. See {@link LabelTierSchema}. */
17321
+ subLabel: string().optional(),
17322
+ /** Confidence of the tier-2 value, as reported by the deciding step. */
17323
+ subLabelScore: number().optional(),
17324
+ /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
17325
+ subLabelMeta: LabelAttributionSchema.optional()
17326
+ };
17327
+ /** Per-camera slice of a training-export estimate. */
17328
+ var TrainingExportDeviceTotalsSchema = object({
17468
17329
  deviceId: number(),
17330
+ tracks: number().int(),
17331
+ files: number().int(),
17332
+ bytes: number().int()
17333
+ });
17334
+ /**
17335
+ * What a training export WOULD contain. Computed from media index rows only —
17336
+ * no blob is read to produce this.
17337
+ */
17338
+ var TrainingExportSummarySchema = object({
17339
+ generatedAt: number(),
17340
+ trackCount: number().int(),
17341
+ fileCount: number().int(),
17342
+ byteCount: number().int(),
17343
+ /** More marked tracks exist than a single pass carries. */
17344
+ truncated: boolean(),
17345
+ devices: array(TrainingExportDeviceTotalsSchema).readonly()
17346
+ });
17347
+ var TrackSchema = object({
17469
17348
  trackId: string(),
17470
- flags: TrackFlagsPatchSchema
17471
- }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
17472
- kind: "query",
17473
- auth: "admin"
17474
- }), method(object({
17475
- olderThanMs: number(),
17476
- reason: OpsLogReasonSchema.optional()
17477
- }), EventPruneCountsSchema, {
17478
- kind: "mutation",
17479
- auth: "admin"
17480
- }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
17481
- kind: "mutation",
17482
- auth: "admin"
17483
- }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
17484
- kind: "mutation",
17485
- auth: "admin"
17486
- }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
17487
- kind: "mutation",
17488
- auth: "admin"
17489
- }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
17490
- kind: "mutation",
17491
- auth: "admin"
17492
- }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
17493
- kind: "mutation",
17494
- auth: "admin"
17495
- }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
17496
- kind: "mutation",
17497
- auth: "admin"
17498
- }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
17499
- kind: "query",
17500
- auth: "admin"
17501
- }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
17502
- kind: "query",
17503
- auth: "admin"
17504
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
17505
- kind: "query",
17506
- auth: "admin"
17507
- }), method(object({
17508
- /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
17509
- * `deviceId`, deliberately: `deviceId` would make this device-bound and
17510
- * route it at one camera's owner, and "every camera" would stop being
17511
- * expressible at all. */
17512
- deviceIds: array(number()).optional(),
17513
- limit: number().int().min(1).max(500).optional()
17514
- }), array(RetrainTrackSchema).readonly(), {
17515
- kind: "query",
17516
- auth: "admin"
17517
- }), method(object({ trackId: string() }), RetrainFrameListSchema, {
17518
- kind: "query",
17519
- auth: "admin"
17520
- }), method(object({
17521
17349
  deviceId: number(),
17522
- trackId: string(),
17523
- mediaKeys: array(string()).min(1)
17524
- }), RetrainFrameSelectionSchema, {
17525
- kind: "mutation",
17526
- auth: "admin"
17527
- }), method(object({
17350
+ className: string(),
17351
+ ...TieredLabelFields,
17352
+ producingDeviceName: string().optional(),
17353
+ /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
17354
+ source: TrackSourceSchema.optional(),
17355
+ firstSeen: number(),
17356
+ lastSeen: number(),
17357
+ /** Frame-rate position history (subject to maxPositionHistory cap). */
17358
+ positions: array(TrackPositionSchema).readonly(),
17359
+ /** Periodic snapshots at snapshotIntervalMs cadence (subject to
17360
+ * saveThumbnails policy). */
17361
+ snapshots: array(TrackSnapshotSchema).readonly(),
17362
+ /** Deduplicated zones the track has entered at least once. Zone IDS. */
17363
+ zonesVisited: array(string()).readonly(),
17364
+ /**
17365
+ * Human NAMES for {@link zonesVisited}, resolved at READ time against the
17366
+ * `zones` capability.
17367
+ *
17368
+ * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
17369
+ * and no card can render — so every free-text search surface was structurally
17370
+ * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
17371
+ * just returned nothing. Resolving here rather than in each client keeps ONE
17372
+ * derivation and costs the clients no extra call (the `zones` cap is
17373
+ * per-device, so a client-side resolve would be a per-camera fan-out on a
17374
+ * surface built to avoid exactly that).
17375
+ *
17376
+ * Resolved, never invented: a zone deleted since the track was written has no
17377
+ * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
17378
+ * two are not positionally aligned. Absent when the track visited no zone, or
17379
+ * when the zone catalogue could not be read.
17380
+ */
17381
+ zoneNames: array(string()).readonly().optional(),
17382
+ /** Deduplicated set of detector classes observed for this track over its
17383
+ * life (a track may be reclassified, e.g. person→vehicle). Absent on
17384
+ * legacy rows written before class accumulation shipped. */
17385
+ classes: array(string()).readonly().optional(),
17386
+ /** Cumulative normalized distance travelled (0..1 units = full frame width). */
17387
+ totalDistance: number(),
17388
+ state: TrackStateSchema,
17389
+ active: boolean(),
17390
+ /** Deterministic key-event importance score in [0,1] (server-computed at
17391
+ * track expiry, recomputed on late label). Absent on legacy rows written
17392
+ * before scoring shipped — consumers degrade to absence / compute-on-read. */
17393
+ importance: number().optional(),
17394
+ /** Id of the track's highest-confidence ObjectEvent (its representative
17395
+ * "best" frame). Absent when the track produced no object events. */
17396
+ bestEventId: string().optional(),
17397
+ /** Tag of the importance sub-signal that dominated the score
17398
+ * (identity|dwell|proximity|class|confidence|travel|zone). */
17399
+ importanceReason: string().optional(),
17400
+ /** Audio-classification labels heard on the camera during the track's
17401
+ * life (score ≥ device `classificationMinScore`), aggregated per label.
17402
+ * Absent on legacy rows / tracks with no confident audio. */
17403
+ audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
17404
+ /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
17405
+ * Populated from the persisted envelope columns on historical reads;
17406
+ * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
17407
+ envelope: TrackEnvelopeSchema.optional(),
17408
+ /**
17409
+ * A face DETECTOR found a face on this track — nothing more. It says the
17410
+ * detail plane produced a `face` detail; it does NOT say the face was
17411
+ * embedded, matched, above `minFacePx`, or that the recognizer was even
17412
+ * enabled. Set once and never cleared.
17413
+ *
17414
+ * **This exists so "face present but not recognised" is expressible.** A
17415
+ * recognised identity lands in `subLabel` (attributed to the face chain via
17416
+ * `subLabelMeta.stepId`), so before this field a track with an unmatched face
17417
+ * and a track with no face at all were byte-identical on the wire and no
17418
+ * surface could tell them apart. The read is `hasFace === true && subLabel
17419
+ * === undefined`.
17420
+ *
17421
+ * **Absent ≠ false.** Every row written before the column existed omits it,
17422
+ * and so does every server that predates the field — a consumer must test
17423
+ * `=== true` and render nothing otherwise, never infer "no face".
17424
+ */
17425
+ hasFace: boolean().optional(),
17426
+ /**
17427
+ * This track has a face row IN THE GALLERY: a crop **and** an embedding — a
17428
+ * face an operator could ASSIGN to an identity.
17429
+ *
17430
+ * The STRICT twin of {@link hasFace}, and the pair only earns its keep
17431
+ * because the two disagree. `hasFace` is stamped at the TOP of the face
17432
+ * branch, before every gate, and means no more than "a face detector produced
17433
+ * a face detail". This one is stamped at the single moment the gallery row
17434
+ * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
17435
+ * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
17436
+ * candidate gate, the imageless-track drop (no crop was ever captured) and
17437
+ * the crop-store drop. Everything between the detector and that insert can
17438
+ * legitimately refuse the face, so a flag written any earlier promises the
17439
+ * operator something to assign and delivers nothing.
17440
+ *
17441
+ * **Independent of recognition.** A face collected but never auto-matched is
17442
+ * still assignable — it is in fact the face an operator most wants to reach —
17443
+ * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
17444
+ * `subLabel`; this says only that the raw material exists.
17445
+ *
17446
+ * **Set once, never cleared.** A track that produced a gallery row produced
17447
+ * one; deleting the row later is the gallery's business, not this flag's.
17448
+ *
17449
+ * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
17450
+ * before the column omits it, and so does every server that predates the
17451
+ * field. A consumer must test `=== true` and render nothing otherwise —
17452
+ * never infer "no assignable face".
17453
+ */
17454
+ hasEmbeddedFace: boolean().optional(),
17455
+ /**
17456
+ * This subject CONTAINS a folded rider — a person the rider-pairing step
17457
+ * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
17458
+ * so the passage is tracked once and as a VEHICLE.
17459
+ *
17460
+ * It exists because the fold's record was dishonest. D34 and the code both
17461
+ * said "the person is not lost — it is reported so both entities stay on the
17462
+ * record"; in fact the pair went into a per-processor RAM field behind an
17463
+ * accessor nobody called, and every durable surface said `vehicle`, full
17464
+ * stop. This is the composition note that makes the row true.
17465
+ *
17466
+ * A COMPOSITION, never a class and never a label. "This vehicle contains a
17467
+ * person" is not an answer to "what is this" — both label tiers would refuse
17468
+ * a macro token anyway (D89), and correctly. Nothing here changes what the
17469
+ * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
17470
+ * and a `person` rule still does not fire for someone cycling past.
17471
+ *
17472
+ * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
17473
+ * the column, and every hub that predates the field, omits it. Test
17474
+ * `=== true` and render nothing otherwise — never infer "no rider".
17475
+ */
17476
+ hasRider: boolean().optional(),
17477
+ ...TrackFlagFields,
17478
+ ...TrackRetrainFields
17479
+ });
17480
+ var BaseEventFields = {
17481
+ id: string(),
17528
17482
  deviceId: number(),
17529
- trackId: string(),
17530
- frameId: string()
17531
- }), object({
17532
- removed: boolean(),
17533
- removedAnnotations: number().int()
17534
- }), {
17535
- kind: "mutation",
17536
- auth: "admin"
17537
- }), method(object({ frameId: string() }), object({
17483
+ timestamp: number()
17484
+ };
17485
+ var MotionEventSchema = object({
17486
+ ...BaseEventFields,
17487
+ kind: literal("motion"),
17488
+ regionCount: number(),
17489
+ /** Heavy JSON array — omitted in slim projection. */
17490
+ regions: array(object({
17491
+ bbox: BoundingBoxSchema,
17492
+ pixelCount: number(),
17493
+ intensity: number()
17494
+ })).readonly().optional(),
17495
+ /** Omitted in slim projection. */
17496
+ frameWidth: number().optional(),
17497
+ /** Omitted in slim projection. */
17498
+ frameHeight: number().optional(),
17499
+ /** Populated by B5 (recording playback URL for this event). */
17500
+ mediaUrl: string().optional()
17501
+ });
17502
+ /**
17503
+ * Which detection SOURCE produced an object event. `pipeline` = the ML
17504
+ * detection pipeline (decoded-frame inference); `onboard` = the camera's
17505
+ * native on-device AI. Both flow through the SAME analysis layers (zoning,
17506
+ * tracking, per-kind persistence) but stay distinguishable so consumers
17507
+ * (advanced-notifier, occupancy, …) can select which source(s) to act on.
17508
+ * Absent on legacy rows ⇒ treat as `pipeline`.
17509
+ */
17510
+ var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
17511
+ /**
17512
+ * The confirmed zone crossing that produced an object event. Present ONLY on
17513
+ * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
17514
+ * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
17515
+ * appearance event carry none, so a rule asking for a direction fails closed
17516
+ * on them.
17517
+ *
17518
+ * Exactly ONE crossing per event: the emitter turns each confirmed crossing
17519
+ * into its own event, so a frame in which a track enters A while leaving B
17520
+ * produces two events with two directions — never one ambiguous row.
17521
+ *
17522
+ * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
17523
+ * membership the box has NOW, and by definition it no longer contains the zone
17524
+ * that was just left. Without the id here, a zone-scoped rule could never match
17525
+ * the exit it asked for.
17526
+ */
17527
+ var ZoneCrossingSchema = object({
17528
+ direction: _enum(["enter", "exit"]),
17529
+ /** Admin zone id crossed. */
17530
+ zoneId: string(),
17531
+ /** Zone display name at crossing time (falls back to the id). */
17532
+ zoneName: string().optional()
17533
+ });
17534
+ var ObjectEventSchema = object({
17535
+ ...BaseEventFields,
17536
+ kind: literal("object"),
17537
+ /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
17538
+ source: DetectionSourceSchema.optional(),
17539
+ /**
17540
+ * Inference-frame id shared by every object event emitted from the SAME frame
17541
+ * — the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
17542
+ * 2 people + 1 dog) under one full frame, and link a track's frames over time
17543
+ * (group by `trackId`, pick a representative `frameId` as the parent frame).
17544
+ * Optional for backward-compat with pre-existing rows / the slim projection
17545
+ * includes it (it is light). Absent on rows written before this field.
17546
+ */
17547
+ frameId: string().optional(),
17548
+ /** Omitted in slim projection. */
17549
+ trackId: string().optional(),
17550
+ className: string(),
17551
+ ...TieredLabelFields,
17552
+ /** Omitted in slim projection. */
17553
+ confidence: number().optional(),
17554
+ /** Heavy JSON — omitted in slim projection. */
17555
+ bbox: BoundingBoxSchema.optional(),
17556
+ /** Heavy JSON — omitted in slim projection. */
17557
+ zones: array(string()).readonly().optional(),
17558
+ /** Omitted in slim projection. */
17559
+ state: TrackStateSchema.optional(),
17560
+ /**
17561
+ * The zone crossing this event IS, when it is one. Absent on every other
17562
+ * event kind (movement state, appearance, package) — see
17563
+ * {@link ZoneCrossingSchema}. Omitted in slim projection.
17564
+ */
17565
+ zoneCrossing: ZoneCrossingSchema.optional(),
17566
+ /** Detection-frame dimensions in pixels — let consumers normalize the
17567
+ * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
17568
+ frameWidth: number().optional(),
17569
+ frameHeight: number().optional(),
17570
+ /** MediaStore key for the crop attached to this event (if any). */
17571
+ mediaKey: string().optional(),
17572
+ /** Design B: MediaStore key of the track's native-resolution key frame (the
17573
+ * best-detection full frame). Resolve via the event-media data-plane
17574
+ * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
17575
+ * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
17576
+ * sources — consumers fall back to `mediaKey` (the tight crop). */
17577
+ keyFrameMediaKey: string().optional(),
17578
+ /** Populated by B5 (recording playback URL for this event). */
17579
+ mediaUrl: string().optional(),
17580
+ /** The parent track's key-event importance [0,1], propagated to every object
17581
+ * event of the track (so an event row can be sorted by importance without a
17582
+ * track join). Absent on legacy rows / before the track was scored. */
17583
+ importance: number().optional()
17584
+ });
17585
+ var AudioEventSchema = object({
17586
+ ...BaseEventFields,
17587
+ kind: literal("audio"),
17588
+ rms: number(),
17589
+ dbfs: number(),
17590
+ classification: object({
17591
+ className: string(),
17592
+ originalClass: string().optional(),
17593
+ score: number()
17594
+ }).optional(),
17595
+ /** Populated by B5 (recording playback URL for this event). */
17596
+ mediaUrl: string().optional()
17597
+ });
17598
+ var MediaFileKindEnum = _enum([
17599
+ "crop",
17600
+ "thumbnail",
17601
+ "snapshot",
17602
+ "firstFrame",
17603
+ "lastFrame",
17604
+ "fullFrame",
17605
+ "fullFrameBoxed",
17606
+ "faceCrop",
17607
+ "plateCrop",
17608
+ "keyFrame",
17609
+ "keyFrameSmall",
17610
+ "thumbnailSmall"
17611
+ ]);
17612
+ var MediaFileSchema = object({
17613
+ key: string(),
17614
+ kind: MediaFileKindEnum,
17538
17615
  base64: string(),
17539
- width: number().int(),
17540
- height: number().int()
17541
- }), {
17542
- kind: "query",
17543
- auth: "admin"
17544
- }), method(object({
17545
- deviceId: number(),
17546
- trackId: string(),
17547
- frameId: string(),
17548
- subject: RetrainAssistSubjectSchema,
17549
- /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
17550
- nodeId: string().optional()
17551
- }), RetrainAssistResultSchema, {
17552
- kind: "mutation",
17553
- auth: "admin"
17554
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
17555
- kind: "query",
17556
- auth: "admin"
17557
- }), method(object({
17558
- deviceId: number(),
17616
+ sizeBytes: number(),
17617
+ timestamp: number()
17618
+ });
17619
+ /**
17620
+ * One media row WITHOUT its bytes.
17621
+ *
17622
+ * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
17623
+ * 140 s track), and a client that renders tiles from the media data plane needs
17624
+ * to know only WHAT EXISTS — the bytes then arrive per tile, lazily, over HTTP
17625
+ * with an immutable cache, instead of all at once inside a tRPC response that
17626
+ * blocks the whole view.
17627
+ *
17628
+ * `sizeBytes` is carried because it is what lets a client decide between the
17629
+ * stored blob and a `?variant=thumb` rendering without fetching either.
17630
+ */
17631
+ var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
17632
+ /**
17633
+ * The MACRO tier of an annotation — a CLOSED set.
17634
+ *
17635
+ * This is what the exported detector predicts, so a typo here is a new class
17636
+ * with one example in it. `label` and `subLabel` are open strings by contrast:
17637
+ * the whole point of the page is teaching the model things it does not know
17638
+ * yet, and constraining that vocabulary would make it useless.
17639
+ *
17640
+ * A macro class is NEVER a label. The provider refuses a write whose `label` or
17641
+ * `subLabel` is one of these values, in any casing, because once `person`
17642
+ * exists in both tiers "every person box" stops being answerable without
17643
+ * knowing every string anyone ever typed — and the damage is retroactive.
17644
+ */
17645
+ var RetrainMacroClassSchema = _enum([
17646
+ "person",
17647
+ "vehicle",
17648
+ "animal",
17649
+ "package",
17650
+ "face",
17651
+ "plate"
17652
+ ]);
17653
+ /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
17654
+ var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
17655
+ /** Did a human draw this box, or did the assist propose it? */
17656
+ var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
17657
+ /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
17658
+ var RetrainBboxSchema = object({
17659
+ x: number(),
17660
+ y: number(),
17661
+ w: number(),
17662
+ h: number()
17663
+ });
17664
+ /**
17665
+ * One annotated subject.
17666
+ *
17667
+ * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
17668
+ * (letterboxed root / zone-cropped package / subject-cropped classifier) are
17669
+ * derived from it at export and never stored — storing them is how one feature
17670
+ * space ends up holding two crops of the same subject (D52).
17671
+ */
17672
+ var RetrainAnnotationSchema = object({
17673
+ id: string(),
17559
17674
  trackId: string(),
17560
- frameId: string(),
17561
- annotations: array(RetrainAnnotationDraftSchema)
17562
- }), array(RetrainAnnotationSchema).readonly(), {
17563
- kind: "mutation",
17564
- auth: "admin"
17565
- }), method(object({
17566
- deviceId: number(),
17567
- trackId: string()
17568
- }), RetrainTransitionResultSchema, {
17569
- kind: "mutation",
17570
- auth: "admin"
17571
- }), method(object({
17572
17675
  deviceId: number(),
17573
- trackId: string()
17574
- }), RetrainTransitionResultSchema, {
17575
- kind: "mutation",
17576
- auth: "admin"
17577
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
17578
- kind: "query",
17579
- auth: "admin"
17580
- }), method(object({
17581
- eventId: string(),
17582
- kind: MediaFileKindEnum.optional(),
17583
- deviceId: number()
17584
- }), array(MediaFileSchema).readonly()), method(object({
17585
- trackId: string(),
17586
- kinds: array(MediaFileKindEnum).optional(),
17587
- deviceId: number()
17588
- }), array(MediaFileSchema).readonly()), method(object({
17676
+ /** The COPY in retrain storage — never the source track's media key. */
17677
+ mediaKey: string(),
17678
+ bbox: RetrainBboxSchema,
17679
+ macroClass: RetrainMacroClassSchema,
17680
+ label: string().optional(),
17681
+ subLabel: string().optional(),
17682
+ kind: RetrainAnnotationKindSchema,
17683
+ source: RetrainAnnotationSourceSchema,
17684
+ /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
17685
+ assistModelId: string().optional(),
17686
+ assistScore: number().optional(),
17687
+ exportedInBatch: string().optional(),
17688
+ createdAt: number()
17689
+ });
17690
+ /** The write form — the server owns `id`, `createdAt` and the frame binding. */
17691
+ var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
17692
+ id: true,
17693
+ trackId: true,
17694
+ deviceId: true,
17695
+ mediaKey: true,
17696
+ createdAt: true,
17697
+ exportedInBatch: true
17698
+ });
17699
+ /** A track sitting in `staging`, with everything the worklist needs to rank it. */
17700
+ var RetrainTrackSchema = object({
17589
17701
  trackId: string(),
17590
- deviceId: number()
17591
- }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
17592
- kind: "mutation",
17593
- auth: "admin"
17594
- }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
17595
- kind: "mutation",
17596
- auth: "admin"
17597
- }), method(object({}), RebuildStatusSchema), object({
17598
17702
  deviceId: number(),
17703
+ className: string(),
17704
+ label: string().optional(),
17705
+ firstSeen: number(),
17706
+ lastSeen: number(),
17707
+ /** How many frames the dataset already holds from this track. */
17708
+ frameCount: number().int(),
17709
+ /** How many subjects have been annotated on those frames. `0` with
17710
+ * `frameCount: 0` is exactly "staging, still to work". */
17711
+ annotationCount: number().int()
17712
+ });
17713
+ /** A frame the picker may offer — an index row, no blob was read to produce it. */
17714
+ var RetrainFrameCandidateSchema = object({
17715
+ mediaKey: string(),
17716
+ kind: MediaFileKindEnum,
17599
17717
  timestamp: number(),
17600
- frameWidth: number(),
17601
- frameHeight: number(),
17602
- detections: array(OverlayDetectionSchema).readonly()
17603
- }), object({
17718
+ sizeBytes: number().int(),
17719
+ /** A copy of this original already exists — selecting it is free and cannot
17720
+ * fail, whatever became of the original. */
17721
+ copied: boolean()
17722
+ });
17723
+ /** A frame the dataset OWNS: bytes copied at selection time. */
17724
+ var RetrainFrameSchema = object({
17725
+ frameId: string(),
17604
17726
  deviceId: number(),
17605
17727
  trackId: string(),
17606
- className: string()
17728
+ /** Provenance only. It may already point at nothing — that is expected. */
17729
+ sourceMediaKey: string(),
17730
+ sourceKind: MediaFileKindEnum,
17731
+ sizeBytes: number().int(),
17732
+ width: number().int(),
17733
+ height: number().int(),
17734
+ copiedAt: number()
17735
+ });
17736
+ /** Why a copy-on-select could not be honoured — named, never a silent skip. */
17737
+ var RetrainCopyRefusalSchema = _enum([
17738
+ "source-missing",
17739
+ "unreadable-image",
17740
+ "write-failed"
17741
+ ]);
17742
+ var RetrainFrameSelectionSchema = object({
17743
+ copied: array(RetrainFrameSchema).readonly(),
17744
+ refused: array(object({
17745
+ sourceMediaKey: string(),
17746
+ reason: RetrainCopyRefusalSchema
17747
+ })).readonly()
17748
+ });
17749
+ var RetrainFrameListSchema = object({
17750
+ candidates: array(RetrainFrameCandidateSchema).readonly(),
17751
+ copies: array(RetrainFrameSchema).readonly(),
17752
+ /** What the page pre-selects — the native key frame when one survives. */
17753
+ autoPickMediaKey: string().optional()
17754
+ });
17755
+ /** What the operator asked the assist to look for. */
17756
+ var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
17757
+ kind: literal("package"),
17758
+ zone: RetrainBboxSchema.optional()
17607
17759
  }), object({
17608
- deviceId: number(),
17609
- trackId: string(),
17610
- className: string(),
17611
- durationMs: number()
17760
+ kind: literal("objects"),
17761
+ modelId: string(),
17762
+ minScore: number().optional()
17763
+ })]);
17764
+ /**
17765
+ * The assist's answer — a discriminated union, because "the model saw nothing"
17766
+ * and "this node cannot run that model" lead to different next moves and a
17767
+ * nullable result cannot tell them apart.
17768
+ */
17769
+ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
17770
+ kind: literal("proposed"),
17771
+ modelId: string(),
17772
+ stepId: string(),
17773
+ minScore: number(),
17774
+ /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
17775
+ proposals: array(RetrainAnnotationDraftSchema).readonly(),
17776
+ /** Returned by the runner but removed by the threshold. */
17777
+ belowThreshold: number().int()
17612
17778
  }), object({
17779
+ kind: literal("refused"),
17780
+ /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
17781
+ reason: string(),
17782
+ detail: string().optional()
17783
+ })]);
17784
+ /** The outcome of a lifecycle move owned by the retrain page. */
17785
+ var RetrainTransitionResultSchema = object({
17786
+ trackId: string(),
17787
+ /** Where the track ended up, whatever happened. */
17788
+ retrainStatus: RetrainStatusSchema,
17789
+ /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
17790
+ changed: boolean(),
17791
+ reason: _enum([
17792
+ "unknown-track",
17793
+ "no-frames-copied",
17794
+ "not-staging",
17795
+ "not-trained",
17796
+ "unchanged"
17797
+ ]).optional()
17798
+ });
17799
+ var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
17800
+ var MAX_EVENT_QUERY_LIMIT = 5e3;
17801
+ var DeviceEventQueryInput = object({
17613
17802
  deviceId: number(),
17614
- kind: EventKindSchema,
17615
- eventId: string(),
17616
- timestamp: number()
17803
+ since: number().optional(),
17804
+ until: number().optional(),
17805
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
17806
+ /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
17807
+ * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
17808
+ * exact behaviour. Callers may omit this field — the store defaults to
17809
+ * `full` when not provided. */
17810
+ projection: _enum(["full", "slim"]).optional()
17617
17811
  });
17618
- /**
17619
- * Reference to the frame's retained NATIVE surface + the parent crop's placement
17620
- * within the frame, so the executor can re-cut a leaf child ROI at native
17621
- * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
17622
- */
17623
- var NativeCropRefSchema = object({
17624
- /** Handle keying the retained native surface (node-pinned to its owner). */
17625
- handle: FrameHandleSchema,
17626
- /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
17627
- cropFrameSpace: object({
17628
- x: number(),
17629
- y: number(),
17630
- w: number(),
17631
- h: number()
17632
- })
17812
+ var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
17813
+ var RecentTracksQueryInput = object({
17814
+ /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
17815
+ deviceIds: array(number()),
17816
+ /** Window lower bound on `lastSeen` (inclusive). */
17817
+ since: number().optional(),
17818
+ /** Window upper bound on `lastSeen` (inclusive). */
17819
+ until: number().optional(),
17820
+ /** Page size. Default 200, max 1000. */
17821
+ limit: number().int().min(1).max(1e3).default(200),
17822
+ /** Opaque continuation cursor from a previous page's `nextCursor`.
17823
+ * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
17824
+ cursor: string().optional(),
17825
+ /** See {@link TrackProjectionSchema}. Default `full`. */
17826
+ projection: TrackProjectionSchema.optional(),
17827
+ /** Include stationary-promoted rows (parked objects). Default false: the
17828
+ * feed lists passages; parking records live on the stationary registry. */
17829
+ includeStationary: boolean().optional()
17633
17830
  });
17634
- object({
17635
- crop: object({
17636
- left: number(),
17637
- top: number(),
17638
- width: number().positive(),
17639
- height: number().positive()
17640
- }).optional(),
17641
- content: object({
17642
- width: number().int().positive(),
17643
- height: number().int().positive()
17644
- }),
17645
- fit: _enum(["stretch", "contain"]),
17646
- format: _enum([
17647
- "rgb",
17648
- "gray",
17649
- "jpeg"
17650
- ])
17831
+ var RecentTracksPageSchema = object({
17832
+ /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
17833
+ tracks: array(TrackSchema).readonly(),
17834
+ /** Cursor for the next page, or null when this page is the last. */
17835
+ nextCursor: string().nullable()
17651
17836
  });
17652
- var FrameRefSchema = object({
17653
- registryId: string().min(1),
17654
- id: string().min(1),
17655
- width: number().int().positive(),
17656
- height: number().int().positive(),
17657
- format: _enum(["rgb", "gray"]),
17658
- timestamp: number(),
17659
- capturedAt: number().optional()
17837
+ var LIST_GROUPS_DEFAULT_LIMIT = 40;
17838
+ var LIST_GROUPS_MAX_LIMIT = 100;
17839
+ var AnalyticsGroupRecordSchema = object({
17840
+ id: string(),
17841
+ deviceId: number().int(),
17842
+ openedAt: number().int(),
17843
+ closedAt: number().int(),
17844
+ timestamp: number().int(),
17845
+ memberCount: number().int(),
17846
+ memberTrackIds: array(string()).readonly(),
17847
+ className: string(),
17848
+ classes: array(string()).readonly(),
17849
+ /** Relative event-media path, or null when the group has no picture yet. */
17850
+ mediaUrl: string().nullable(),
17851
+ singleton: boolean()
17660
17852
  });
17661
- var ModelFormatSchema$1 = _enum([
17662
- "onnx",
17663
- "coreml",
17664
- "openvino",
17665
- "tflite",
17666
- "pt",
17667
- "gguf"
17668
- ]);
17669
- var PipelineSlotSchema = _enum([
17670
- "detector",
17671
- "cropper",
17672
- "classifier",
17673
- "refiner",
17674
- "audio-classifier"
17675
- ]);
17676
- var PipelineEngineChoiceSchema = object({
17677
- runtime: _enum(["node", "python"]),
17678
- backend: string(),
17679
- format: ModelFormatSchema$1,
17680
- device: string().optional()
17853
+ var AnalyticsGroupMemberSchema = object({
17854
+ trackId: string(),
17855
+ deviceId: number().int(),
17856
+ className: string(),
17857
+ firstSeen: number().int(),
17858
+ lastSeen: number().int(),
17859
+ mediaUrl: string().nullable()
17681
17860
  });
17682
- var AvailableEngineSchema = object({
17683
- engine: PipelineEngineChoiceSchema,
17684
- devices: array(object({
17685
- id: string(),
17686
- label: string(),
17687
- description: string().optional()
17688
- })).readonly(),
17689
- defaultDevice: string()
17861
+ var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
17862
+ var ListGroupsQueryInput = object({
17863
+ /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
17864
+ deviceIds: array(number()),
17865
+ /** Window lower bound on `closedAt` (inclusive). */
17866
+ since: number().optional(),
17867
+ /** Window upper bound on `openedAt` (inclusive). */
17868
+ until: number().optional(),
17869
+ limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
17870
+ /** Opaque continuation cursor from a previous page's `nextCursor`. */
17871
+ cursor: string().optional()
17690
17872
  });
17691
- var PipelineDefaultStepSchema = lazy(() => object({
17692
- addonId: string(),
17693
- addonName: string(),
17694
- slot: PipelineSlotSchema,
17695
- inputClasses: array(string()).readonly(),
17696
- outputClasses: array(string()).readonly(),
17697
- enabled: boolean(),
17698
- modelId: string(),
17699
- children: array(PipelineDefaultStepSchema).readonly(),
17700
- group: string().optional(),
17701
- settings: record(string(), unknown()).optional()
17702
- }));
17703
- var PipelineTemplateStepSchema = lazy(() => object({
17704
- addonId: string(),
17705
- enabled: boolean(),
17706
- modelId: string(),
17707
- children: array(PipelineTemplateStepSchema).readonly(),
17708
- settings: record(string(), unknown()).optional()
17709
- }));
17710
- var PipelineTemplateSchema$1 = object({
17711
- id: string(),
17712
- name: string(),
17713
- createdAt: string(),
17714
- updatedAt: string(),
17715
- engine: PipelineEngineChoiceSchema,
17716
- steps: array(PipelineTemplateStepSchema).readonly()
17873
+ var ListGroupsPageSchema = object({
17874
+ groups: array(AnalyticsGroupRecordSchema).readonly(),
17875
+ nextCursor: string().nullable()
17876
+ });
17877
+ var KeyEventQueryInput = object({
17878
+ deviceId: number(),
17879
+ /** Window lower bound (track firstSeen ≥ since). */
17880
+ since: number(),
17881
+ /** Window upper bound (track firstSeen ≤ until). */
17882
+ until: number(),
17883
+ limit: number().int().min(1).max(200).default(50),
17884
+ /** Drop tracks scoring below this importance. */
17885
+ minImportance: number().min(0).max(1).optional(),
17886
+ /** Restrict to a single class (e.g. 'person'). */
17887
+ classFilter: string().optional()
17717
17888
  });
17718
- var PipelineModelOptionSchema = object({
17889
+ var KeyEventSchema = object({
17890
+ /** The representative event id (the track's best ObjectEvent, else its trackId). */
17719
17891
  id: string(),
17720
- name: string(),
17721
- formats: record(string(), object({
17722
- downloaded: boolean(),
17723
- sizeMB: number()
17724
- })),
17725
- group: ModelVariantGroupSchema.optional(),
17726
- legacy: boolean().optional(),
17727
- provider: ModelProviderIdSchema.optional()
17892
+ trackId: string(),
17893
+ /** Track start time (firstSeen). */
17894
+ timestamp: number(),
17895
+ className: string(),
17896
+ ...TieredLabelFields,
17897
+ importance: number(),
17898
+ /** Highest-confidence ObjectEvent id for the track (empty when none). */
17899
+ bestEventId: string(),
17900
+ /** Track lifetime in ms (lastSeen - firstSeen). */
17901
+ windowMs: number().optional(),
17902
+ ...TrackFlagFields,
17903
+ ...TrackRetrainFields
17728
17904
  });
17729
- var ConfigFieldBridge = custom();
17730
- var PipelineAddonSchemaSchema = object({
17731
- id: string(),
17732
- name: string(),
17733
- slot: PipelineSlotSchema,
17734
- inputClasses: array(string()).readonly(),
17735
- outputClasses: array(string()).readonly(),
17736
- childSlots: array(PipelineSlotSchema).readonly(),
17737
- models: array(PipelineModelOptionSchema).readonly(),
17738
- defaultModelId: string(),
17739
- defaultModelIdByFormat: record(string(), string()).optional(),
17740
- enabledByDefault: boolean().optional(),
17741
- backfillIntoExistingOverrides: boolean().optional(),
17742
- defaultConfidence: number(),
17743
- group: string().optional(),
17744
- configSchema: array(ConfigFieldBridge).readonly().optional()
17905
+ object({
17906
+ trackId: string(),
17907
+ className: string(),
17908
+ confidence: number(),
17909
+ bbox: BoundingBoxSchema,
17910
+ zones: array(string()).readonly(),
17911
+ state: TrackStateSchema
17745
17912
  });
17746
- var PipelineSlotSchemaSchema = object({
17747
- id: PipelineSlotSchema,
17748
- label: string(),
17749
- priority: number(),
17750
- parentSlot: PipelineSlotSchema.nullable(),
17751
- addons: array(PipelineAddonSchemaSchema).readonly()
17913
+ var OverlayDetectionSchema = looseObject({
17914
+ id: string(),
17915
+ kind: _enum(["first-level", "detail"]),
17916
+ macroClass: string(),
17917
+ score: number(),
17918
+ bbox: object({
17919
+ x: number(),
17920
+ y: number(),
17921
+ width: number(),
17922
+ height: number()
17923
+ }),
17924
+ labels: array(looseObject({
17925
+ label: string(),
17926
+ score: number()
17927
+ })).readonly(),
17928
+ parentId: string().optional()
17752
17929
  });
17753
- var PipelineSchemaSchema = object({
17754
- availableEngines: array(AvailableEngineSchema).readonly(),
17755
- selectedEngine: PipelineEngineChoiceSchema,
17756
- slots: array(PipelineSlotSchemaSchema).readonly()
17930
+ var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
17931
+ var SearchObjectEventsInput = object({
17932
+ text: string(),
17933
+ deviceId: number().optional(),
17934
+ since: number().optional(),
17935
+ until: number().optional(),
17936
+ classFilter: string().optional(),
17937
+ limit: number().default(50),
17938
+ minScore: number().min(0).max(1).default(.2)
17757
17939
  });
17758
- var EngineProvisioningSchema = object({
17759
- runtimeId: _enum([
17760
- "onnx",
17761
- "openvino",
17762
- "coreml",
17763
- "edgetpu"
17764
- ]).nullable(),
17765
- device: string().nullable(),
17766
- state: _enum([
17767
- "idle",
17768
- "installing",
17769
- "verifying",
17770
- "ready",
17771
- "failed"
17772
- ]),
17773
- progress: number().optional(),
17774
- error: string().optional(),
17775
- nextRetryAt: number().optional(),
17776
- /**
17777
- * Gate A (config-correctness gate at engine change): human-readable
17778
- * config issues surfaced EAGERLY when the node's engine changes — model
17779
- * substitutions ("chose X, running Y") and zero-build steps ("no model
17780
- * has a <format> build"). Additive/optional: informational only, never
17781
- * enforced here — `assertEngineReady` (readiness) still gates inference.
17782
- * Absent/empty when the node-default tree resolves cleanly.
17783
- */
17784
- configIssues: array(string()).optional()
17940
+ var TrackCascadeCountsSchema = object({
17941
+ /** Persisted track roots deleted (authoritative). */
17942
+ tracks: number().int(),
17943
+ /** Object events removed with their tracks (best-effort; see note above). */
17944
+ events: number().int(),
17945
+ /** Track/face/plate-owned media removed (best-effort). Never identity media. */
17946
+ media: number().int(),
17947
+ /** Unassigned (non-enrolled) face reads removed (best-effort). */
17948
+ faces: number().int(),
17949
+ /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
17950
+ plates: number().int(),
17951
+ /** Per-track CLIP search vectors removed (best-effort). */
17952
+ embeddings: number().int(),
17953
+ /** Group membership + group rows removed with their last member (best-effort). */
17954
+ groups: number().int()
17785
17955
  });
17786
- var PipelineStepInputSchema = lazy(() => object({
17787
- addonId: string(),
17788
- modelId: string().optional(),
17789
- enabled: boolean().default(true),
17790
- children: array(PipelineStepInputSchema).optional(),
17791
- settings: record(string(), unknown()).optional(),
17792
- jumpDeviceKey: string().optional()
17793
- }));
17794
- var ModelSubstitutionSchema = object({
17795
- addonId: string(),
17796
- chosen: string(),
17797
- running: string(),
17798
- format: string()
17956
+ /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
17957
+ var DiskReconcileCountsSchema = object({
17958
+ mediaDropped: number().int(),
17959
+ tracks: number().int(),
17960
+ events: number().int()
17799
17961
  });
17800
- var PipelineValidationIssueSchema = object({
17801
- addonId: string(),
17802
- kind: _enum(["unknown-addon", "no-format-build"]),
17803
- detail: string()
17962
+ /** Event-store footprint for one camera. */
17963
+ var EventStoreDeviceFootprintSchema = object({
17964
+ deviceId: number(),
17965
+ /** Persisted event rows (motion + object + audio) for the camera. */
17966
+ rows: number().int(),
17967
+ /** Event-owned media bytes on disk for the camera. */
17968
+ bytes: number().int()
17804
17969
  });
17805
- var PipelineValidationResultSchema = object({
17806
- ok: boolean(),
17807
- issues: array(PipelineValidationIssueSchema).readonly(),
17808
- substitutions: array(ModelSubstitutionSchema).readonly(),
17809
- /** The node's `currentEngine.format` this validation ran against. */
17810
- format: string()
17970
+ /** Aggregate event-store footprint: global totals + per-camera breakdown. */
17971
+ var EventStoreFootprintSchema = object({
17972
+ totalRows: number().int(),
17973
+ totalBytes: number().int(),
17974
+ devices: array(EventStoreDeviceFootprintSchema).readonly()
17811
17975
  });
17812
- var ReferenceImageEntrySchema = object({
17813
- filename: string(),
17814
- stepIds: array(string()).readonly().optional()
17976
+ /** Per-kind counts returned by the event-prune / device-delete mutations. */
17977
+ var EventPruneCountsSchema = object({
17978
+ motion: number().int(),
17979
+ object: number().int(),
17980
+ audio: number().int()
17815
17981
  });
17816
- var ReferenceImageBodySchema = object({
17817
- base64: string(),
17818
- filename: string()
17982
+ /**
17983
+ * Re-embed stored tracks from their key frames.
17984
+ *
17985
+ * The reason this is an operator-callable method and not a migration script:
17986
+ * every knob that decides what a vector MEANS — encoder model, crop margin,
17987
+ * squaring — is only changeable if the existing vectors can be regenerated.
17988
+ * Mixing feature spaces in one index makes cosine scores incomparable, and the
17989
+ * symptom is a quality regression with no visible cause.
17990
+ */
17991
+ var RebuildObjectEmbeddingsInput = object({
17992
+ /** Restrict to one camera. Omit for the whole fleet. */
17993
+ deviceId: number().optional(),
17994
+ since: number().optional(),
17995
+ until: number().optional(),
17996
+ /** Stop after this many tracks; the result reports whether more remain. */
17997
+ maxTracks: number().int().positive().optional(),
17998
+ /**
17999
+ * Run every embedding on THIS node instead of round-robining the fleet.
18000
+ *
18001
+ * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
18002
+ * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
18003
+ * calling it that would pin the rebuild REQUEST itself to that node — the
18004
+ * rebuild orchestration lives on the hub, and only the per-track step runs
18005
+ * remotely. This field is data; the per-track pin is applied inside.
18006
+ *
18007
+ * Absent ⇒ round-robin over every online node whose runner can serve the
18008
+ * pinned model.
18009
+ */
18010
+ executeOnNodeId: string().optional(),
18011
+ /**
18012
+ * Milliseconds to wait between tracks; omit for the built-in default, `0` to
18013
+ * run flat out.
18014
+ *
18015
+ * A rebuild is bulk maintenance on hub-main's single thread. Measured
18016
+ * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
18017
+ * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
18018
+ * force is logged at start and finish so a deliberately slow pass reads
18019
+ * differently from a stalled one.
18020
+ */
18021
+ pacingMs: number().int().nonnegative().optional()
17819
18022
  });
17820
- var ReferenceAudioEntrySchema = object({
17821
- filename: string(),
17822
- sizeKb: number()
18023
+ /**
18024
+ * Result of emptying the CLIP index.
18025
+ *
18026
+ * The clean slate before a policy change: a new crop margin or encoder model
18027
+ * leaves two feature spaces in one index whose cosine scores are not
18028
+ * comparable, so wiping and rebuilding is the only way to be sure every vector
18029
+ * means the same thing.
18030
+ */
18031
+ var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
18032
+ /**
18033
+ * Acknowledgement that a rebuild STARTED.
18034
+ *
18035
+ * The pass costs ~1s per track — 45 minutes for a 2,600-track fleet — so it
18036
+ * runs detached and this returns immediately. Waiting for it made the client
18037
+ * time out while the work carried on server-side, which is the worst of both:
18038
+ * no result and no way to know it was still going. Poll
18039
+ * `getObjectEmbeddingRebuildStatus` for progress.
18040
+ */
18041
+ var RebuildObjectEmbeddingsResultSchema = object({
18042
+ started: boolean(),
18043
+ /** True when a pass was already running; the new request is ignored. */
18044
+ alreadyRunning: boolean()
17823
18045
  });
17824
- var ReferenceAudioBodySchema = object({ base64: string() });
17825
- var AudioBackendSchema = object({
17826
- id: string(),
17827
- name: string(),
17828
- description: string(),
17829
- available: boolean(),
18046
+ var RebuildStatusSchema = object({
18047
+ running: boolean(),
18048
+ scanned: number(),
18049
+ rebuilt: number(),
18050
+ /** Tracks whose key frame is gone — nothing to re-embed from. */
18051
+ missingKeyFrame: number(),
18052
+ /** Tracks with no usable detection box. */
18053
+ missingBbox: number(),
18054
+ /**
18055
+ * Tracks an executing node REFUSED rather than broke on — an unreadable key
18056
+ * frame, a step that threw. Separate from `failed` because the remedy is
18057
+ * different, and because a whole camera silently contributing zero vectors
18058
+ * is the shape of failure a rebuild must never hide.
18059
+ */
18060
+ notRunnable: number(),
17830
18061
  /**
17831
- * Raw classifier labels this backend can emit (e.g. YAMNet's
17832
- * 521-class set or Apple SoundAnalysis's 303-class set). Used by
17833
- * the benchmark UI to populate the `enabledMicroClasses` filter
17834
- * specific to the selected backend without a separate fetch.
18062
+ * The pass stopped because NO node could serve the pinned model.
18063
+ *
18064
+ * Distinct from `notRunnable` on purpose: that one says "this track was
18065
+ * refused", this one says "the cluster cannot do this work at all" — every
18066
+ * candidate node either lacks the `clip-embedding` step, lacks a build of the
18067
+ * pinned model for its engine format, or dropped out. The remedy is a model /
18068
+ * engine change, not a per-camera one. Non-zero here always comes with
18069
+ * `complete: false`.
17835
18070
  */
17836
- rawLabels: array(string()).readonly().optional()
17837
- });
17838
- var AudioCapabilitiesSchema = object({
17839
- activeBackend: string(),
17840
- availableBackends: array(AudioBackendSchema).readonly(),
17841
- sampleRate: number(),
17842
- chunkDurationMs: number()
17843
- });
17844
- var DownloadModelResultSchema = object({
17845
- filePath: string(),
17846
- sizeMB: number(),
17847
- durationMs: number()
18071
+ noCapableNode: number(),
18072
+ failed: number(),
18073
+ /** Set once a pass ends: true only when EVERYTHING was covered. */
18074
+ complete: boolean().nullable(),
18075
+ startedAtMs: number().nullable(),
18076
+ finishedAtMs: number().nullable(),
18077
+ /** Present when the pass ended by throwing. */
18078
+ error: string().nullable()
17848
18079
  });
17849
- /**
17850
- * Wrapper carrying a single test run's result. Replaces the legacy
17851
- * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
17852
- * canonical `AudioResult` from the Phase 6 output rework: one
17853
- * `AudioDetection` per class above `minScore`, top-N candidates in
17854
- * `debug.alternateLabels['audio-classifier']`, per-source timings in
17855
- * `debug.stepTimings`. The outer `success`/`error` fields stay so the
17856
- * benchmark UI can still report a clean failure when the classifier
17857
- * cap isn't available.
17858
- */
17859
- var AudioTestResultSchema = object({
17860
- success: boolean(),
17861
- error: string().optional(),
17862
- frame: custom().optional()
18080
+ var ReplayFrameInputSchema = object({
18081
+ timestamp: number(),
18082
+ frame: PipelineRunResultBridge
17863
18083
  });
17864
- var PipelineConfigBridge = custom();
17865
- var ConfigUISchemaBridge = custom();
17866
- var ConfigUISchemaNullableBridge = custom();
17867
- var InferenceCapabilitiesBridge = custom();
17868
- var ModelAvailabilityListBridge = custom();
17869
- var PipelineRunResultBridge = custom();
17870
- method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
17871
- modelId: string(),
17872
- settings: record(string(), unknown()).readonly()
17873
- }))), method(object({ steps: record(string(), object({
17874
- modelId: string(),
17875
- settings: record(string(), unknown()).readonly()
17876
- })) }), object({ success: literal(true) }), {
18084
+ var RunReplayFrameProcessorResultSchema = object({ tracks: array(object({
18085
+ className: string(),
18086
+ firstSeenMs: number(),
18087
+ lastSeenMs: number(),
18088
+ /** Bbox of the track's FIRST matched detection, pixel-space in the clip's
18089
+ * frame — a representative box for the diff's `(className, window, IoU)`
18090
+ * pairing (`replay-diff.ts`). A replay does not need the full per-frame
18091
+ * trajectory production's `Track.positions` keeps. */
18092
+ bbox: BoundingBoxSchema,
18093
+ /** How many of the input frames this track matched a real detection on
18094
+ * (never a coasted/extrapolated frame) — the replay's own signal for "how
18095
+ * solid is this track", cheaper than re-deriving it from a trajectory. */
18096
+ framesMatched: number().int()
18097
+ })).readonly() });
18098
+ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
18099
+ deviceId: number(),
18100
+ trackId: string()
18101
+ }), TrackSchema.nullable()), method(object({
18102
+ deviceId: number(),
18103
+ since: number().optional(),
18104
+ until: number().optional(),
18105
+ limit: number().optional(),
18106
+ /** Spatial filter — only tracks whose trajectory intersects the zone
18107
+ * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
18108
+ * envelope columns, then precisely tested per position. Tracks with
18109
+ * an unknown envelope (no frame dims at persist time) always match. */
18110
+ zone: TrackZoneFilterSchema.optional(),
18111
+ /** See {@link TrackProjectionSchema}. Default `full` (backward
18112
+ * compatible — omitting the field keeps today's exact behaviour). */
18113
+ projection: TrackProjectionSchema.optional(),
18114
+ /** Include stationary-promoted rows (parked objects handed to the
18115
+ * stationary registry). Default false: the timeline lists passages,
18116
+ * not parking records (operator decision, 2026-08-15). */
18117
+ includeStationary: boolean().optional()
18118
+ }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
18119
+ deviceId: number(),
18120
+ groupId: string().min(1)
18121
+ }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
18122
+ kind: "mutation",
18123
+ auth: "admin"
18124
+ }), 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({
18125
+ deviceId: number(),
18126
+ since: number().optional(),
18127
+ until: number().optional(),
18128
+ kinds: array(string()).optional(),
18129
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
18130
+ }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
18131
+ deviceId: number(),
18132
+ since: number(),
18133
+ until: number(),
18134
+ bucketMs: number().int().positive()
18135
+ }), array(object({
18136
+ bucketStart: number(),
18137
+ motion: number().int(),
18138
+ object: number().int(),
18139
+ audio: number().int()
18140
+ })).readonly()), method(object({
18141
+ deviceId: number(),
18142
+ cutoffMs: number()
18143
+ }), object({
18144
+ motion: number().int(),
18145
+ object: number().int(),
18146
+ audio: number().int()
18147
+ }), {
18148
+ kind: "mutation",
18149
+ auth: "admin"
18150
+ }), method(object({
18151
+ deviceId: number(),
18152
+ cutoffMs: number()
18153
+ }), TrackCascadeCountsSchema, {
18154
+ kind: "mutation",
18155
+ auth: "admin"
18156
+ }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
18157
+ kind: "mutation",
18158
+ auth: "admin"
18159
+ }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
18160
+ kind: "mutation",
18161
+ auth: "admin"
18162
+ }), method(object({
18163
+ deviceId: number(),
18164
+ trackIds: array(string()).min(1)
18165
+ }), object({
18166
+ deleted: number().int(),
18167
+ failed: array(string()).readonly()
18168
+ }), {
18169
+ kind: "mutation",
18170
+ auth: "admin"
18171
+ }), method(object({
18172
+ /** Log/audit scope only — the trackId is globally unique on its own. */
18173
+ deviceId: number(),
18174
+ trackId: string(),
18175
+ flags: TrackFlagsPatchSchema
18176
+ }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
18177
+ kind: "query",
18178
+ auth: "admin"
18179
+ }), method(object({
18180
+ olderThanMs: number(),
18181
+ reason: OpsLogReasonSchema.optional()
18182
+ }), EventPruneCountsSchema, {
18183
+ kind: "mutation",
18184
+ auth: "admin"
18185
+ }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
18186
+ kind: "mutation",
18187
+ auth: "admin"
18188
+ }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
18189
+ kind: "mutation",
18190
+ auth: "admin"
18191
+ }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
18192
+ kind: "mutation",
18193
+ auth: "admin"
18194
+ }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
18195
+ kind: "mutation",
18196
+ auth: "admin"
18197
+ }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
18198
+ kind: "mutation",
18199
+ auth: "admin"
18200
+ }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18201
+ kind: "mutation",
18202
+ auth: "admin"
18203
+ }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
18204
+ kind: "mutation",
18205
+ auth: "admin"
18206
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
18207
+ kind: "query",
18208
+ auth: "admin"
18209
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18210
+ kind: "mutation",
18211
+ auth: "admin"
18212
+ }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
18213
+ kind: "query",
18214
+ auth: "admin"
18215
+ }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
18216
+ kind: "query",
18217
+ auth: "admin"
18218
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18219
+ kind: "query",
18220
+ auth: "admin"
18221
+ }), method(object({
18222
+ /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
18223
+ * `deviceId`, deliberately: `deviceId` would make this device-bound and
18224
+ * route it at one camera's owner, and "every camera" would stop being
18225
+ * expressible at all. */
18226
+ deviceIds: array(number()).optional(),
18227
+ limit: number().int().min(1).max(500).optional()
18228
+ }), array(RetrainTrackSchema).readonly(), {
18229
+ kind: "query",
18230
+ auth: "admin"
18231
+ }), method(object({ trackId: string() }), RetrainFrameListSchema, {
18232
+ kind: "query",
18233
+ auth: "admin"
18234
+ }), method(object({
18235
+ deviceId: number(),
18236
+ trackId: string(),
18237
+ mediaKeys: array(string()).min(1)
18238
+ }), RetrainFrameSelectionSchema, {
18239
+ kind: "mutation",
18240
+ auth: "admin"
18241
+ }), method(object({
18242
+ deviceId: number(),
18243
+ trackId: string(),
18244
+ frameId: string()
18245
+ }), object({
18246
+ removed: boolean(),
18247
+ removedAnnotations: number().int()
18248
+ }), {
18249
+ kind: "mutation",
18250
+ auth: "admin"
18251
+ }), method(object({ frameId: string() }), object({
18252
+ base64: string(),
18253
+ width: number().int(),
18254
+ height: number().int()
18255
+ }), {
18256
+ kind: "query",
18257
+ auth: "admin"
18258
+ }), method(object({
18259
+ deviceId: number(),
18260
+ trackId: string(),
18261
+ frameId: string(),
18262
+ subject: RetrainAssistSubjectSchema,
18263
+ /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
18264
+ nodeId: string().optional()
18265
+ }), RetrainAssistResultSchema, {
18266
+ kind: "mutation",
18267
+ auth: "admin"
18268
+ }), method(object({
18269
+ deviceId: number(),
18270
+ source: DetectionSourceSchema,
18271
+ zones: array(ZoneSchema).readonly().optional(),
18272
+ detectionRules: array(ZoneRuleSchema).readonly().optional(),
18273
+ zoneMembershipMinOverlap: number().min(0).max(1).optional(),
18274
+ frames: array(ReplayFrameInputSchema).min(1)
18275
+ }), RunReplayFrameProcessorResultSchema, {
18276
+ kind: "mutation",
18277
+ auth: "admin"
18278
+ }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
18279
+ kind: "query",
18280
+ auth: "admin"
18281
+ }), method(object({
18282
+ deviceId: number(),
18283
+ trackId: string(),
18284
+ frameId: string(),
18285
+ annotations: array(RetrainAnnotationDraftSchema)
18286
+ }), array(RetrainAnnotationSchema).readonly(), {
18287
+ kind: "mutation",
18288
+ auth: "admin"
18289
+ }), method(object({
18290
+ deviceId: number(),
18291
+ trackId: string()
18292
+ }), RetrainTransitionResultSchema, {
17877
18293
  kind: "mutation",
17878
18294
  auth: "admin"
17879
- }), method(object({ nodeId: string() }), object({
17880
- success: literal(true),
17881
- clearedDevices: number()
17882
- }), {
18295
+ }), method(object({
18296
+ deviceId: number(),
18297
+ trackId: string()
18298
+ }), RetrainTransitionResultSchema, {
17883
18299
  kind: "mutation",
17884
18300
  auth: "admin"
17885
- }), 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({
17886
- name: string(),
17887
- steps: array(PipelineTemplateStepSchema).readonly(),
17888
- engine: PipelineEngineChoiceSchema
17889
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
17890
- id: string(),
17891
- name: string().optional(),
17892
- steps: array(PipelineTemplateStepSchema).readonly().optional()
17893
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
17894
- addonId: string(),
17895
- modelId: string(),
17896
- format: ModelFormatSchema$1
17897
- }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
17898
- addonId: string(),
17899
- modelId: string(),
17900
- format: ModelFormatSchema$1
17901
- }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
17902
- engine: PipelineEngineChoiceSchema.optional(),
17903
- steps: array(PipelineStepInputSchema).min(1),
17904
- frame: FrameInputSchema.optional(),
17905
- /**
17906
- * Process-local lazy frame. Valid only when caller and provider resolve
17907
- * in the same execution-group process; split/cross-node callers use
17908
- * `frame`/`image` inline compatibility instead.
17909
- */
17910
- frameRef: FrameRefSchema.optional(),
17911
- /**
17912
- * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
17913
- * the decoded pixels live in. One more member of the one-of
17914
- * frame/frameHandle/image/imageBase64/referenceImage group.
17915
- */
17916
- frameHandle: FrameHandleSchema.optional(),
17917
- imageBase64: string().optional(),
17918
- /**
17919
- * Binary JPEG bytes — preferred over `imageBase64` on internal
17920
- * hops (hub → forked worker via Moleculer MsgPack) because it
17921
- * skips the 33% base64 overhead + the per-call base64 decode on
17922
- * the detection-pipeline worker. Callers can pass either; exactly
17923
- * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
17924
- */
17925
- image: _instanceof(Uint8Array).optional(),
17926
- referenceImage: string().optional(),
17927
- deviceId: number().optional(),
17928
- sessionId: string().optional(),
17929
- /**
17930
- * Execution plane. 'full' (default) runs the whole tree — benchmark,
17931
- * reference-image, and detail-subtree calls. 'frame' is the live
17932
- * per-frame dispatch: ONLY root-plane steps run; crop children
17933
- * (inputClasses ≠ null) are skipped and served per-track via
17934
- * pipelineRunner.runDetailSubtree (two-plane design).
17935
- */
17936
- plane: _enum(["full", "frame"]).optional(),
17937
- /**
17938
- * Inference-device selector (Phase 2 multi-device). Format
17939
- * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
17940
- * Omitted ⇒ the runner's default device (current single-engine
17941
- * behaviour). Selects WHICH device pool of the node runs the call.
17942
- */
17943
- deviceKey: string().optional(),
17944
- /**
17945
- * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
17946
- * when the parent crop was resolved from the frame's retained NATIVE
17947
- * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
17948
- * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
17949
- * resolution from that surface — the SAME quality path faces already
17950
- * had — instead of the downscaled parent tile. `handle` keys the native
17951
- * surface (node-pinned to its owner); `cropFrameSpace` is the parent
17952
- * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
17953
- * the executor's crop-normalized child ROI back into frame-normalized
17954
- * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
17955
- * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
17956
- * (today's behaviour on the fallback path).
17957
- */
17958
- nativeCropRef: NativeCropRefSchema.optional()
17959
- }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
17960
- engine: PipelineEngineChoiceSchema.optional(),
17961
- steps: array(PipelineStepInputSchema).min(1),
17962
- frames: array(FrameInputSchema).min(1).max(255),
17963
- deviceId: number().optional(),
17964
- sessionId: string().optional(),
17965
- /**
17966
- * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
17967
- * the batch to the Python pool's bench preprocess cache
17968
- * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
17969
- * preprocessed ONCE and every later inference is a pure-inference cache
17970
- * hit — the sustained-throughput run measures inference, not
17971
- * decode+preprocess+infer. Omitted/0 for live frames (all different →
17972
- * full preprocess every call, correct). Fresh per sustained run;
17973
- * released via `uncacheFrame`.
17974
- */
17975
- frameId: number().int().nonnegative().optional(),
17976
- /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
17977
- deviceKey: string().optional()
17978
- }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
17979
- data: _instanceof(Uint8Array),
17980
- width: number().int().positive(),
17981
- height: number().int().positive(),
17982
- format: _enum([
17983
- "rgb",
17984
- "bgr",
17985
- "gray"
17986
- ])
17987
- }), object({
17988
- frameId: number(),
17989
- width: number(),
17990
- height: number()
17991
- }), { kind: "mutation" }), method(object({
17992
- stepId: string(),
17993
- frameId: number().int()
17994
- }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
17995
- batchMode: string(),
17996
- windowMs: number(),
17997
- maxBatchSize: number(),
17998
- concurrency: number()
17999
- })), method(_void(), array(object({
18000
- engineKey: string(),
18001
- engine: PipelineEngineChoiceSchema,
18002
- modelsLoaded: array(string()).readonly(),
18003
- inUseByCameras: array(number()).readonly(),
18004
- /**
18005
- * Origin of this resident factory.
18006
- * - `runtime` — main camera-serving engine (no idle TTL).
18007
- * - `warm-override` — benchmark/test override held in the warm
18008
- * cache; auto-disposed after the idle TTL.
18009
- * - `device-pool` — a concurrent per-device pool (Phase 2
18010
- * multi-device, keyed by `deviceKey`) resolved
18011
- * via `resolveDeviceFactory`. Runs alongside the
18012
- * `runtime` engine on a DIFFERENT accelerator
18013
- * (NPU / iGPU / Coral) — this is how the
18014
- * Engines tab shows all pools running at once.
18015
- */
18016
- kind: _enum([
18017
- "runtime",
18018
- "warm-override",
18019
- "device-pool"
18020
- ]),
18021
- /** Native pid of the underlying Python pool (null when no pool). */
18022
- poolPid: number().nullable(),
18023
- /** ms since this factory was last used (null when not warm-tracked). */
18024
- idleMs: number().nullable(),
18025
- /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
18026
- idleTtlMs: number().nullable()
18027
- })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
18028
- kind: "mutation",
18301
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18302
+ kind: "query",
18029
18303
  auth: "admin"
18030
18304
  }), method(object({
18031
- engine: PipelineEngineChoiceSchema,
18032
- force: boolean().optional()
18033
- }), object({
18034
- success: boolean(),
18035
- reason: string().optional()
18036
- }), {
18305
+ eventId: string(),
18306
+ kind: MediaFileKindEnum.optional(),
18307
+ deviceId: number()
18308
+ }), array(MediaFileSchema).readonly()), method(object({
18309
+ trackId: string(),
18310
+ kinds: array(MediaFileKindEnum).optional(),
18311
+ deviceId: number()
18312
+ }), array(MediaFileSchema).readonly()), method(object({
18313
+ trackId: string(),
18314
+ deviceId: number()
18315
+ }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
18037
18316
  kind: "mutation",
18038
18317
  auth: "admin"
18039
- }), 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({
18040
- addonId: string(),
18041
- modelId: string(),
18042
- filename: string().optional(),
18043
- settings: record(string(), unknown()).optional()
18044
- }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
18318
+ }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
18319
+ kind: "mutation",
18320
+ auth: "admin"
18321
+ }), method(object({}), RebuildStatusSchema), object({
18322
+ deviceId: number(),
18323
+ timestamp: number(),
18324
+ frameWidth: number(),
18325
+ frameHeight: number(),
18326
+ detections: array(OverlayDetectionSchema).readonly()
18327
+ }), object({
18328
+ deviceId: number(),
18329
+ trackId: string(),
18330
+ className: string()
18331
+ }), object({
18332
+ deviceId: number(),
18333
+ trackId: string(),
18334
+ className: string(),
18335
+ durationMs: number()
18336
+ }), object({
18337
+ deviceId: number(),
18338
+ kind: EventKindSchema,
18339
+ eventId: string(),
18340
+ timestamp: number()
18341
+ });
18045
18342
  object({
18046
18343
  activeCameras: number(),
18047
18344
  throttledCameras: number(),
@@ -18053,119 +18350,19 @@ var CameraMetricsSchema = object({
18053
18350
  "disabled",
18054
18351
  "always-on",
18055
18352
  "on-motion"
18056
- ]),
18057
- configuredFps: number(),
18058
- actualFps: number(),
18059
- queueDepth: number(),
18060
- avgInferenceTimeMs: number(),
18061
- droppedFrames: number(),
18062
- phase: _enum([
18063
- "idle",
18064
- "watching",
18065
- "active"
18066
- ])
18067
- });
18068
- var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
18069
- /**
18070
- * Zone — pure geometry + identity. NO filtering behaviour.
18071
- *
18072
- * Zones describe **where** in the frame the operator wants to flag
18073
- * something; consumer-owned {@link ZoneRule} arrays describe **how**
18074
- * each pipeline stage uses them. Splitting the two means a single
18075
- * polygon "Driveway" can simultaneously back a motion-exclude rule,
18076
- * a detection-include rule on `['car']`, and an occupancy aggregate
18077
- * — without three duplicated polygons.
18078
- *
18079
- * Owned by the orchestrator addon (provider) and mirrored into the
18080
- * `zones` device-state slice on every mutation. Consumers
18081
- * (motion-wasm, pipeline-executor, analytics, admin UI) read either
18082
- * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
18083
- * mirror with `onChanged`).
18084
- *
18085
- * Coordinates are normalised fractions of the frame (0–1) so zones
18086
- * survive resolution changes and stream profile switches.
18087
- *
18088
- * `kind` discriminates between full polygons (closed regions used
18089
- * for intrusion / occupancy filters) and tripwires (open 2-point
18090
- * line segments used for cross events). Onboard / firmware-reported
18091
- * zones (Reolink, ONVIF) are out of scope for now — see the deferred
18092
- * task list.
18093
- */
18094
- var ZoneKindEnum = _enum(["polygon", "tripwire"]);
18095
- /** Polygon vertex in fraction-of-frame coordinates (0–1). */
18096
- var PolygonPointSchema = object({
18097
- x: number(),
18098
- y: number()
18099
- });
18100
- /** A camera detection zone — pure geometry/identity. */
18101
- var ZoneSchema = object({
18102
- id: string(),
18103
- name: string(),
18104
- kind: ZoneKindEnum.default("polygon"),
18105
- /** Polygon vertices, fraction of frame (0–1). */
18106
- polygon: array(PolygonPointSchema).readonly(),
18107
- /** Visual color for UI rendering. */
18108
- color: string().default("#3b82f6")
18353
+ ]),
18354
+ configuredFps: number(),
18355
+ actualFps: number(),
18356
+ queueDepth: number(),
18357
+ avgInferenceTimeMs: number(),
18358
+ droppedFrames: number(),
18359
+ phase: _enum([
18360
+ "idle",
18361
+ "watching",
18362
+ "active"
18363
+ ])
18109
18364
  });
18110
- /**
18111
- * Zones capability — per-camera CRUD over polygon detection zones.
18112
- *
18113
- * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
18114
- * to per-device settings and mirrors into the `zones` device-state
18115
- * slice on every mutation, so downstream consumers can subscribe via
18116
- * `dev.state.zones.onChanged`.
18117
- *
18118
- * The cap surface only handles geometry + identity; filtering
18119
- * behaviour (per-class, include/exclude, threshold) lives in the
18120
- * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
18121
- * `capabilities/schemas/zone-rule.js`.
18122
- */
18123
- var zonesCapability = {
18124
- name: "zones",
18125
- scope: "device",
18126
- mode: "singleton",
18127
- deviceTypes: [DeviceType.Camera],
18128
- methods: {
18129
- listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
18130
- addZone: method(object({
18131
- deviceId: number(),
18132
- zone: ZoneSchema
18133
- }), _void(), {
18134
- kind: "mutation",
18135
- auth: "admin"
18136
- }),
18137
- removeZone: method(object({
18138
- deviceId: number(),
18139
- zoneId: string()
18140
- }), _void(), {
18141
- kind: "mutation",
18142
- auth: "admin"
18143
- }),
18144
- updateZone: method(object({
18145
- deviceId: number(),
18146
- zone: ZoneSchema
18147
- }), _void(), {
18148
- kind: "mutation",
18149
- auth: "admin"
18150
- })
18151
- },
18152
- /**
18153
- * Runtime-state slice — the live zone catalogue mirrored by the
18154
- * orchestrator on every CRUD mutation. Consumers read via
18155
- * `device.state.zones.value` / `.watch(...)` without round-tripping
18156
- * the cap, and the codegen DeviceProxy auto-wires the reactive
18157
- * handle. Slice shape is `{ zones: Zone[] }` so future extensions
18158
- * (e.g. zone groupings) can sit alongside the polygon list.
18159
- */
18160
- runtimeState: object({ zones: array(ZoneSchema).readonly() }),
18161
- /**
18162
- * Runtime-state durability: **restored** — written only on operator mutation, so a camera that never had one has nothing to re-derive from. This is the slice `zone-mirror-hydration.ts` exists to paper over.
18163
- *
18164
- * See `RuntimeStateDurability`. Enforced by
18165
- * `scripts/check-runtime-state-durability.ts`.
18166
- */
18167
- durability: "restored"
18168
- };
18365
+ var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
18169
18366
  /**
18170
18367
  * A bounding box in NORMALIZED [0,1] frame coordinates for `getNativeCrop`. The
18171
18368
  * decode worker resolves it against the RETAINED native frame's real pixel dims,
@@ -19854,7 +20051,7 @@ method(object({
19854
20051
  * linking rather than produce an eternal token.
19855
20052
  */
19856
20053
  ttlSec: union([number().int().positive(), literal("never")]).optional()
19857
- }), object({ token: string() })), method(object({ token: string() }), SsoBridgeClaimsSchema.nullable());
20054
+ }), object({ token: string() }), { auth: "admin" }), method(object({ token: string() }), SsoBridgeClaimsSchema.nullable(), { auth: "admin" });
19858
20055
  var ProviderListEntrySchema = discriminatedUnion("shouldSaveDiskSpace", [object({
19859
20056
  providerId: string().min(1),
19860
20057
  displayName: string().min(1),
@@ -19949,10 +20146,13 @@ var EvictResultSchema = object({
19949
20146
  /** True when the provider has nothing left it is willing to drop on this location. */
19950
20147
  exhausted: boolean()
19951
20148
  });
19952
- method(object({ locationId: string() }), EvictableUsageSchema), method(object({
20149
+ method(object({ locationId: string() }), EvictableUsageSchema, { auth: "admin" }), method(object({
19953
20150
  locationId: string(),
19954
20151
  targetBytes: number().int().positive()
19955
- }), EvictResultSchema, { kind: "mutation" });
20152
+ }), EvictResultSchema, {
20153
+ kind: "mutation",
20154
+ auth: "admin"
20155
+ });
19956
20156
  method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin" }), method(StorageMigrationInputSchema, object({ jobId: string() }), {
19957
20157
  kind: "mutation",
19958
20158
  auth: "admin"
@@ -20012,26 +20212,50 @@ var ReadChunkInputSchema = object({
20012
20212
  length: number()
20013
20213
  });
20014
20214
  var EndDownloadInputSchema = object({ downloadId: string() });
20015
- method(_void(), ProviderInfoSchema), method(object({ config: record(string(), unknown()) }), TestLocationResultSchema, { auth: "admin" }), method(object({
20215
+ method(_void(), ProviderInfoSchema, { auth: "admin" }), method(object({ config: record(string(), unknown()) }), TestLocationResultSchema, { auth: "admin" }), method(object({
20016
20216
  location: StorageLocationSchema,
20017
20217
  relativePath: string()
20018
- }), string()), method(object({
20218
+ }), string(), { auth: "admin" }), method(object({
20019
20219
  location: StorageLocationSchema,
20020
20220
  relativePath: string(),
20021
20221
  data: _instanceof(Uint8Array)
20022
- }), _void(), { kind: "mutation" }), method(object({
20222
+ }), _void(), {
20223
+ kind: "mutation",
20224
+ auth: "admin"
20225
+ }), method(object({
20023
20226
  location: StorageLocationSchema,
20024
20227
  relativePath: string()
20025
- }), _instanceof(Uint8Array)), method(object({
20228
+ }), _instanceof(Uint8Array), { auth: "admin" }), method(object({
20026
20229
  location: StorageLocationSchema,
20027
20230
  relativePath: string()
20028
- }), boolean()), method(object({
20231
+ }), boolean(), { auth: "admin" }), method(object({
20029
20232
  location: StorageLocationSchema,
20030
20233
  prefix: string().optional()
20031
- }), array(string()).readonly()), method(object({
20234
+ }), array(string()).readonly(), { auth: "admin" }), method(object({
20032
20235
  location: StorageLocationSchema,
20033
20236
  relativePath: string()
20034
- }), _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" });
20237
+ }), _void(), {
20238
+ kind: "mutation",
20239
+ auth: "admin"
20240
+ }), method(object({ location: StorageLocationSchema }), number().nullable(), { auth: "admin" }), method(BeginUploadInputSchema, BeginUploadResultSchema, {
20241
+ kind: "mutation",
20242
+ auth: "admin"
20243
+ }), method(WriteChunkInputSchema, _void(), {
20244
+ kind: "mutation",
20245
+ auth: "admin"
20246
+ }), method(FinalizeUploadInputSchema, _void(), {
20247
+ kind: "mutation",
20248
+ auth: "admin"
20249
+ }), method(AbortUploadInputSchema, _void(), {
20250
+ kind: "mutation",
20251
+ auth: "admin"
20252
+ }), method(BeginDownloadInputSchema, BeginDownloadResultSchema, {
20253
+ kind: "mutation",
20254
+ auth: "admin"
20255
+ }), method(ReadChunkInputSchema, _instanceof(Uint8Array), { auth: "admin" }), method(EndDownloadInputSchema, _void(), {
20256
+ kind: "mutation",
20257
+ auth: "admin"
20258
+ });
20035
20259
  /** Profile-exported FormBuilder schema. Shape is ConfigUISchema at the UI. */
20036
20260
  var ProfileSettingsSchemaBridge = unknown().nullable();
20037
20261
  var ProfileSettingsBagSchema = record(string(), unknown());
@@ -20289,7 +20513,8 @@ method(object({
20289
20513
  access: "create"
20290
20514
  }), method(object({ userId: string().optional() }), object({ optionsJSON: record(string(), unknown()) }), {
20291
20515
  kind: "mutation",
20292
- access: "view"
20516
+ access: "view",
20517
+ auth: "admin"
20293
20518
  }), method(object({
20294
20519
  /** Required — the user the assertion belongs to (verified). */
20295
20520
  userId: string(),
@@ -20297,10 +20522,12 @@ method(object({
20297
20522
  response: record(string(), unknown())
20298
20523
  }), object({ verified: boolean() }), {
20299
20524
  kind: "mutation",
20300
- access: "view"
20525
+ access: "view",
20526
+ auth: "admin"
20301
20527
  }), method(object({}), object({ optionsJSON: record(string(), unknown()) }), {
20302
20528
  kind: "mutation",
20303
- access: "view"
20529
+ access: "view",
20530
+ auth: "admin"
20304
20531
  }), method(object({
20305
20532
  /** AuthenticationResponseJSON from the browser. */
20306
20533
  response: record(string(), unknown()) }), object({
@@ -20308,7 +20535,8 @@ response: record(string(), unknown()) }), object({
20308
20535
  userId: string().nullable()
20309
20536
  }), {
20310
20537
  kind: "mutation",
20311
- access: "view"
20538
+ access: "view",
20539
+ auth: "admin"
20312
20540
  }), method(object({ userId: string() }), array(PasskeySummarySchema), { auth: "admin" }), method(object({
20313
20541
  userId: string(),
20314
20542
  credentialId: string()
@@ -20480,7 +20708,19 @@ var VectorStatsResultSchema = object({
20480
20708
  /** False when the backend ranks approximately. */
20481
20709
  exact: boolean()
20482
20710
  });
20483
- 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);
20711
+ method(VectorDeclareIndexInputSchema, _void(), {
20712
+ kind: "mutation",
20713
+ auth: "admin"
20714
+ }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
20715
+ kind: "mutation",
20716
+ auth: "admin"
20717
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
20718
+ kind: "mutation",
20719
+ auth: "admin"
20720
+ }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
20721
+ kind: "mutation",
20722
+ auth: "admin"
20723
+ }), method(VectorStatsInputSchema, VectorStatsResultSchema, { auth: "admin" });
20484
20724
  var ClipSchema = object({
20485
20725
  /** Opaque, provider-namespaced id. The default provider encodes the time
20486
20726
  * window so `getClipPlayback` is self-contained (no event re-query). */
@@ -22950,7 +23190,27 @@ var MediaFileLiteSchema$1 = object({
22950
23190
  sizeBytes: number(),
22951
23191
  timestamp: number()
22952
23192
  });
22953
- method(_void(), array(IdentitySchema).readonly()), method(object({ name: string().min(1) }), IdentitySchema, {
23193
+ method(object({
23194
+ /**
23195
+ * Inline {@link IdentitySchema.coverBase64} on every row.
23196
+ *
23197
+ * Default `false`, the same inversion `listRecentFaces` and
23198
+ * `listPlates` took on 2026-08-25 (see `include-crops-default.ts` for
23199
+ * why the burden belongs on the caller that WANTS the bytes). Measured
23200
+ * on the live hub the same day: four identities cost 40,979 B with the
23201
+ * covers inline, ~10 KB of base64 per row, on a query this UI mounts
23202
+ * four times and the viewer holds at `staleTime: 30_000`.
23203
+ *
23204
+ * Nothing loses its avatar: `coverMediaKey` is already on every row and
23205
+ * the `event-media` plane serves that key `immutable` with an ETag.
23206
+ *
23207
+ * **This is an INPUT field, so it does not reach the addon until the
23208
+ * next train** — the hub router validates cap inputs against its own
23209
+ * compiled Zod and strips a key it does not know. Until then the
23210
+ * provider sees `undefined`, which resolves to `false`: the cheap shape
23211
+ * is what ships, and the opt-in becomes reachable when the train lands.
23212
+ */
23213
+ includeCrops: boolean().optional() }).optional(), array(IdentitySchema).readonly()), method(object({ name: string().min(1) }), IdentitySchema, {
22954
23214
  kind: "mutation",
22955
23215
  auth: "admin"
22956
23216
  }), method(object({
@@ -25840,8 +26100,10 @@ var PlateInfoSchema = object({
25840
26100
  keyFrameMediaKey: string().optional(),
25841
26101
  base64: string().optional(),
25842
26102
  /**
25843
- * Same crop as a data-plane URL. `getPlateByTrack` returns this and
25844
- * never inlines JPEG; `listPlates` still inlines for the admin-ui.
26103
+ * Same crop as a data-plane URL, always present when the plate has a stored
26104
+ * crop. `getPlateByTrack` returns this and never inlines JPEG; `listPlates`
26105
+ * and `searchPlates` inline the crop only when their `includeCrops` input is
26106
+ * left at its `true` default.
25845
26107
  */
25846
26108
  cropUrl: string().optional()
25847
26109
  });
@@ -25861,14 +26123,34 @@ var PlateClusterSchema = object({
25861
26123
  });
25862
26124
  method(object({
25863
26125
  deviceId: number().int().optional(),
25864
- limit: number().int().positive().optional()
26126
+ limit: number().int().positive().optional(),
26127
+ /**
26128
+ * Inline the base64 crop on every row. Default `true` — the existing
26129
+ * behaviour, kept so no caller breaks.
26130
+ *
26131
+ * Set `false` once the caller renders {@link PlateInfo.cropUrl}.
26132
+ * Measured on the live hub at the 500 rows the Plates view asks for:
26133
+ * 879,403 B and 27.7 s with the crops inline, against a few KiB of
26134
+ * metadata without them — and the browser then caches the images.
26135
+ *
26136
+ * This is the plate twin of `faceGallery.listRecentFaces`'s option;
26137
+ * plates were the one gallery list left without it.
26138
+ *
26139
+ * **This is an INPUT field, so it does not reach the addon until the
26140
+ * next train.** The hub router validates cap inputs against its own
26141
+ * compiled Zod and strips a key it does not know. Until the train
26142
+ * ships, sending `false` is harmless and keeps the crops inline.
26143
+ */
26144
+ includeCrops: boolean().optional()
25865
26145
  }).optional(), array(PlateInfoSchema).readonly()), method(object({
25866
26146
  deviceId: number().int(),
25867
26147
  trackId: string()
25868
26148
  }), PlateInfoSchema.nullable()), method(object({ plateId: string() }), array(MediaFileLiteSchema).readonly()), method(object({
25869
26149
  text: string().min(1),
25870
26150
  maxDistance: number().int().min(0).optional(),
25871
- limit: number().int().positive().optional()
26151
+ limit: number().int().positive().optional(),
26152
+ /** See `listPlates.includeCrops`. Default `true`. */
26153
+ includeCrops: boolean().optional()
25872
26154
  }), array(PlateInfoSchema).readonly()), method(object({
25873
26155
  maxDistance: number().int().min(0).optional(),
25874
26156
  minClusterSize: number().int().min(2).optional(),
@@ -25882,7 +26164,13 @@ method(object({
25882
26164
  }), method(object({ plateId: string() }), _void(), {
25883
26165
  kind: "mutation",
25884
26166
  auth: "admin"
25885
- }), method(_void(), array(VehicleSchema).readonly()), method(object({ name: string().min(1) }), VehicleSchema, {
26167
+ }), method(object({
26168
+ /** Inline {@link VehicleSchema.coverBase64} on every row. Default
26169
+ * `false` — the vehicle twin of `faceGallery.listIdentities`'s
26170
+ * option; `coverMediaKey` + the `event-media` plane carry the picture.
26171
+ * INPUT field: stripped by the hub router until the train ships, which
26172
+ * resolves to `false` and is exactly the intended default. */
26173
+ includeCrops: boolean().optional() }).optional(), array(VehicleSchema).readonly()), method(object({ name: string().min(1) }), VehicleSchema, {
25886
26174
  kind: "mutation",
25887
26175
  auth: "admin"
25888
26176
  }), method(object({
@@ -27403,92 +27691,6 @@ var sceneMonitorCapability = {
27403
27691
  durability: "session"
27404
27692
  };
27405
27693
  /**
27406
- * Per-stage gating mode applied to the zones a rule references.
27407
- *
27408
- * - `include`: the rule contributes to a **whitelist** for its stage.
27409
- * When at least one `include` rule fires for a stage, only entities
27410
- * inside one of those zones pass that stage.
27411
- * - `exclude`: the rule contributes to a **blacklist** for its stage.
27412
- * Entities inside one of those zones are dropped at that stage.
27413
- *
27414
- * `monitor`-style observation (count without filtering) is not a rule
27415
- * mode — zones without any matching rule are observed naturally by
27416
- * `zone-analytics` (live snapshot + history), so an "I just want to
27417
- * count, not filter" use case needs no rule at all.
27418
- */
27419
- var ZoneRuleModeEnum = _enum(["include", "exclude"]);
27420
- /**
27421
- * Per-consumer rule that references existing zones (geometry) and
27422
- * defines how a specific pipeline stage should treat them. Each
27423
- * consumer addon owns its own `ZoneRule[]` array in its per-device
27424
- * settings:
27425
- *
27426
- * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
27427
- * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
27428
- * - future: notification rules, audio gating, etc.
27429
- *
27430
- * One rule applies to N zones (`zoneIds[]`) so the operator can
27431
- * express "ignore motion in ALL of {garden, street}" with a single
27432
- * rule. `classFilter` narrows the rule to specific object classes —
27433
- * "drop person detections in the street, but keep cars" is one
27434
- * `exclude` rule with `classFilter: ['person']`.
27435
- *
27436
- * `enabled` is a soft toggle — the operator can keep the rule
27437
- * configured but inert without deleting it.
27438
- */
27439
- var ZoneRuleSchema = object({
27440
- /** Stable rule id — survives edits, used by the UI for diffing. */
27441
- id: string(),
27442
- /** Optional human-readable label rendered in the rule editor. */
27443
- name: string().optional(),
27444
- /** Zones this rule targets. The rule's `mode` applies to ALL
27445
- * listed zones (OR-set: a detection in any one of them counts).
27446
- * At least one zone id required — a rule with no targets is a
27447
- * configuration mistake and the form validator rejects it. */
27448
- zoneIds: array(string()).min(1).readonly(),
27449
- mode: ZoneRuleModeEnum,
27450
- /**
27451
- * Class names this rule applies to. Empty / undefined ⇒ rule
27452
- * applies to every class. Class strings match the `macroClass`
27453
- * field on detections (e.g. `person`, `car`, `dog`).
27454
- */
27455
- classFilter: array(string()).readonly().optional(),
27456
- /**
27457
- * Minimum bbox/mask overlap (0–1) with any of the rule's zones
27458
- * required to consider an entity "in the zone". Defaults to the
27459
- * consumer's stage default when omitted. Kept for back-compat with
27460
- * existing per-rule overrides; new operators pick the value via
27461
- * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
27462
- * set, the lower-level engine reads it as a 0–1 fraction.
27463
- */
27464
- overlapThreshold: number().min(0).max(1).optional(),
27465
- /**
27466
- * Operator-friendly version of `overlapThreshold` — the percentage
27467
- * of the detection's bbox that must lie inside the zone for the
27468
- * rule to match. Documented default is 85%; the engine substitutes
27469
- * that when the field is omitted (kept optional so existing rules
27470
- * stored without it stay valid).
27471
- *
27472
- * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
27473
- * rule, the engine prefers `bboxInclusionPct` because it's the
27474
- * field exposed in the UI. Internally both feed the same gate.
27475
- */
27476
- bboxInclusionPct: number().min(0).max(100).optional(),
27477
- /**
27478
- * When `true` and a detection has a segmentation mask, use the
27479
- * mask for overlap instead of the bbox. Detection-stage only;
27480
- * motion rules ignore this field.
27481
- */
27482
- preferMask: boolean().optional(),
27483
- /**
27484
- * Soft-toggle: `false` disables the rule without deleting it.
27485
- * Defaults to `true` so operators creating a rule via the UI
27486
- * see it active immediately.
27487
- */
27488
- enabled: boolean().default(true)
27489
- });
27490
- array(ZoneRuleSchema).readonly();
27491
- /**
27492
27694
  * Script-runner cap. Models HA `script.*` entities on
27493
27695
  * `DeviceType.Script`. A Script is a pre-recorded action sequence
27494
27696
  * that can be invoked imperatively — optionally with a variables
@@ -33143,6 +33345,12 @@ Object.freeze({
33143
33345
  addonId: null,
33144
33346
  access: "create"
33145
33347
  },
33348
+ "pipelineAnalytics.cancelRelocateMedia": {
33349
+ capName: "pipeline-analytics",
33350
+ capScope: "device",
33351
+ addonId: null,
33352
+ access: "create"
33353
+ },
33146
33354
  "pipelineAnalytics.cancelStorageMigrationMove": {
33147
33355
  capName: "pipeline-analytics",
33148
33356
  capScope: "device",
@@ -33317,6 +33525,12 @@ Object.freeze({
33317
33525
  addonId: null,
33318
33526
  access: "view"
33319
33527
  },
33528
+ "pipelineAnalytics.listRelocateMediaJobs": {
33529
+ capName: "pipeline-analytics",
33530
+ capScope: "device",
33531
+ addonId: null,
33532
+ access: "view"
33533
+ },
33320
33534
  "pipelineAnalytics.listRetrainAnnotations": {
33321
33535
  capName: "pipeline-analytics",
33322
33536
  capScope: "device",
@@ -33395,6 +33609,12 @@ Object.freeze({
33395
33609
  addonId: null,
33396
33610
  access: "create"
33397
33611
  },
33612
+ "pipelineAnalytics.relocateMedia": {
33613
+ capName: "pipeline-analytics",
33614
+ capScope: "device",
33615
+ addonId: null,
33616
+ access: "create"
33617
+ },
33398
33618
  "pipelineAnalytics.restageRetrainTrack": {
33399
33619
  capName: "pipeline-analytics",
33400
33620
  capScope: "device",
@@ -33407,6 +33627,12 @@ Object.freeze({
33407
33627
  addonId: null,
33408
33628
  access: "create"
33409
33629
  },
33630
+ "pipelineAnalytics.runReplayFrameProcessor": {
33631
+ capName: "pipeline-analytics",
33632
+ capScope: "device",
33633
+ addonId: null,
33634
+ access: "create"
33635
+ },
33410
33636
  "pipelineAnalytics.saveRetrainAnnotations": {
33411
33637
  capName: "pipeline-analytics",
33412
33638
  capScope: "device",
@@ -33539,6 +33765,12 @@ Object.freeze({
33539
33765
  addonId: null,
33540
33766
  access: "view"
33541
33767
  },
33768
+ "pipelineExecutor.getInferenceDeviceHealth": {
33769
+ capName: "pipeline-executor",
33770
+ capScope: "system",
33771
+ addonId: null,
33772
+ access: "view"
33773
+ },
33542
33774
  "pipelineExecutor.getOrchestratorConfigSchema": {
33543
33775
  capName: "pipeline-executor",
33544
33776
  capScope: "system",
@@ -33611,6 +33843,12 @@ Object.freeze({
33611
33843
  addonId: null,
33612
33844
  access: "view"
33613
33845
  },
33846
+ "pipelineExecutor.rearmInferenceDevice": {
33847
+ capName: "pipeline-executor",
33848
+ capScope: "system",
33849
+ addonId: null,
33850
+ access: "create"
33851
+ },
33614
33852
  "pipelineExecutor.runAudioTest": {
33615
33853
  capName: "pipeline-executor",
33616
33854
  capScope: "system",
@@ -36859,6 +37097,11 @@ Object.freeze({
36859
37097
  form: "single",
36860
37098
  optional: false
36861
37099
  }],
37100
+ "pipelineAnalytics.runReplayFrameProcessor": [{
37101
+ name: "deviceId",
37102
+ form: "single",
37103
+ optional: false
37104
+ }],
36862
37105
  "pipelineAnalytics.saveRetrainAnnotations": [{
36863
37106
  name: "deviceId",
36864
37107
  form: "single",