@camstack/addon-provider-gree 0.2.27 → 0.2.29

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