@camstack/addon-provider-dreo 0.2.28 → 0.2.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/addon.js +2135 -1892
  2. package/dist/addon.mjs +2135 -1892
  3. package/package.json +1 -1
package/dist/addon.mjs CHANGED
@@ -6667,7 +6667,7 @@ function method(input, output, options) {
6667
6667
  input,
6668
6668
  output,
6669
6669
  kind: options?.kind ?? "query",
6670
- auth: options?.auth ?? "protected",
6670
+ ...options?.auth !== void 0 ? { auth: options.auth } : {},
6671
6671
  ...options?.access !== void 0 ? { access: options.access } : {},
6672
6672
  ...options?.caller !== void 0 ? { caller: options.caller } : {},
6673
6673
  timeoutMs: options?.timeoutMs
@@ -6691,7 +6691,7 @@ function event(data) {
6691
6691
  }
6692
6692
  var StaticDirOutputSchema$1 = object({ staticDir: string() });
6693
6693
  var VersionOutputSchema$1 = object({ version: string() });
6694
- method(_void(), StaticDirOutputSchema$1), method(_void(), VersionOutputSchema$1);
6694
+ method(_void(), StaticDirOutputSchema$1, { auth: "admin" }), method(_void(), VersionOutputSchema$1, { auth: "admin" });
6695
6695
  var DeviceType = /* @__PURE__ */ function(DeviceType) {
6696
6696
  DeviceType["Camera"] = "camera";
6697
6697
  DeviceType["Hub"] = "hub";
@@ -7012,7 +7012,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
7012
7012
  }({});
7013
7013
  var StaticDirOutputSchema = object({ staticDir: string() });
7014
7014
  var VersionOutputSchema = object({ version: string() });
7015
- method(_void(), StaticDirOutputSchema), method(_void(), VersionOutputSchema);
7015
+ method(_void(), StaticDirOutputSchema, { auth: "admin" }), method(_void(), VersionOutputSchema, { auth: "admin" });
7016
7016
  /**
7017
7017
  * device-ops — device-scoped cap that unifies the per-IDevice operations
7018
7018
  * previously routed through the `.device-ops` Moleculer bridge service.
@@ -7638,24 +7638,6 @@ var RecordingRetentionSchema = object({
7638
7638
  maxSizeGb: number().min(0).optional()
7639
7639
  });
7640
7640
  /**
7641
- * Scrub-thumbnail fidelity preset — the single per-camera selector bundling the
7642
- * sprite tile RESOLUTION + JPEG QUALITY the recorder packs timeline-scrub
7643
- * previews at. Five graduated steps; absent on a config = `standard` (the
7644
- * shipped default, matching `sheet-geometry`/`sheet-composer`).
7645
- *
7646
- * Existing sheets are IMMUTABLE — a changed preset applies to NEW windows only.
7647
- * Each window's index sidecar carries its own tile dims, so a camera whose
7648
- * preset changed over time renders every historical window at the dims it was
7649
- * written with.
7650
- */
7651
- var ScrubThumbnailPresetSchema = _enum([
7652
- "minimal",
7653
- "low",
7654
- "standard",
7655
- "high",
7656
- "max"
7657
- ]);
7658
- /**
7659
7641
  * The full per-camera recording intent — the wire shape of a RecordingTarget.
7660
7642
  *
7661
7643
  * `bands` is the ONLY authored recording intent: what to record, when, and on
@@ -7663,7 +7645,11 @@ var ScrubThumbnailPresetSchema = _enum([
7663
7645
  * other field is a storage knob (profiles, segment length, retention, scrub).
7664
7646
  *
7665
7647
  * STRICT on purpose: the legacy authoring surface (`schedule`/`schedules`/
7666
- * `triggers`/`preBufferSec`/`postBufferSec`/`rules`) was retired 2026-07-30.
7648
+ * `triggers`/`preBufferSec`/`postBufferSec`/`rules`) was retired 2026-07-30,
7649
+ * and `scrubThumbnails` — a five-step fidelity knob for a sprite tier that was
7650
+ * deleted on 2026-07-24 and had ZERO consumers in the recorder — on 2026-08-25
7651
+ * (D62: a switch that writes a store nobody reads is worse than no switch).
7652
+ * Stored rows keep loading: the READ schema is `.strip()` (config-store.ts).
7667
7653
  * A stale caller must fail loudly — silently stripping its legacy intent would
7668
7654
  * persist a band-less config, i.e. silently stop recording the camera.
7669
7655
  */
@@ -7686,14 +7672,7 @@ var RecordingConfigSchema = object({
7686
7672
  * "off" is the absence of a covering band, never a band value.
7687
7673
  */
7688
7674
  bands: array(RecordingBandSchema).default([]),
7689
- retention: RecordingRetentionSchema.optional(),
7690
- /**
7691
- * Per-camera scrub-thumbnail fidelity preset (resolution + JPEG quality for
7692
- * timeline-scrub sprite previews). Absent = `standard`. Applies to NEW
7693
- * windows only — existing sheets are immutable, and each window's index
7694
- * carries its own tile dims so mixed-preset history renders correctly.
7695
- */
7696
- scrubThumbnails: ScrubThumbnailPresetSchema.optional()
7675
+ retention: RecordingRetentionSchema.optional()
7697
7676
  }).strict();
7698
7677
  /**
7699
7678
  * Entity-relocation job state (storage entity-routing spec, Phase 4).
@@ -7769,10 +7748,11 @@ var RelocateFootageInputSchema = object({
7769
7748
  * `RecordingConfig.enabled` or camera wrapper bindings. */
7770
7749
  var StorageMigrationLeaseInputSchema = object({ leaseId: string().min(1) });
7771
7750
  var StorageMigrationFootageMoveInputSchema = RelocateFootageInputSchema.extend({ leaseId: string().min(1) });
7772
- var StorageMigrationMediaMoveInputSchema = object({
7751
+ var RelocateMediaInputSchema = object({
7773
7752
  toLocationId: string(),
7774
7753
  throttleMbps: number().min(1).max(1e3).optional()
7775
- }).extend({ leaseId: string().min(1) });
7754
+ });
7755
+ var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
7776
7756
  /** The independently selectable logical storage classes. `recordings`
7777
7757
  * encompasses the high and mid segment profiles; `recordingsLow` is low
7778
7758
  * segments; `eventMedia` is post-analysis blobs. */
@@ -8067,7 +8047,26 @@ var LabelDefinitionSchema = object({
8067
8047
  description: string().optional(),
8068
8048
  icon: string().optional()
8069
8049
  });
8070
- var ClassMapDefinitionSchema = object({
8050
+ /**
8051
+ * Wire schema for a per-model CATALOG classMap override
8052
+ * (`ModelCatalogEntry.classMap` / `ModelConvertMetadata.classMap`) —
8053
+ * restricted to {@link CLASS_MAP_MACRO_TARGETS}, the only macros the
8054
+ * detection pipeline executor actually routes.
8055
+ *
8056
+ * This is deliberately a DIFFERENT, narrower shape than the general-purpose
8057
+ * `ClassMapDefinition` interface above (e.g. `IDetectionAddon.getClassMap()`
8058
+ * and the audio `YAMNET_TO_MACRO` catalog both use macro targets outside this
8059
+ * enum) — the two used to share the name `ClassMapDefinition`/
8060
+ * `ClassMapDefinitionSchema`, which made the schema-type-twin guard
8061
+ * (`scripts/check-schema-type-twins.ts`) flag them as a duplicated shape. They
8062
+ * are not: it is two different concepts colliding on a name. Keep this type
8063
+ * under its own name rather than reusing `ClassMapDefinition` — reusing it
8064
+ * would either narrow every `ClassMapDefinition` consumer to the four
8065
+ * detection macros (breaking `YAMNET_TO_MACRO`) or drop the validation this
8066
+ * schema exists for (see the "rejects a classMap whose target is not a
8067
+ * detection macro" test in `model-catalog-schema.test.ts`).
8068
+ */
8069
+ var DetectionCatalogClassMapSchema = object({
8071
8070
  mapping: record(string(), _enum([
8072
8071
  "person",
8073
8072
  "vehicle",
@@ -8272,7 +8271,7 @@ var ModelCatalogEntrySchema = object({
8272
8271
  * applies (Frigate / COCO public catalog). Set on a custom model whose raw
8273
8272
  * labels already ARE the CamStack macros (Scrypted identity map).
8274
8273
  */
8275
- classMap: ClassMapDefinitionSchema.optional()
8274
+ classMap: DetectionCatalogClassMapSchema.optional()
8276
8275
  });
8277
8276
  var ConvertTargetSchema = discriminatedUnion("format", [object({
8278
8277
  format: literal("openvino"),
@@ -8302,7 +8301,7 @@ var ModelConvertMetadataSchema = object({
8302
8301
  "segmentation"
8303
8302
  ]),
8304
8303
  faceAlignment: boolean().optional(),
8305
- classMap: ClassMapDefinitionSchema.optional()
8304
+ classMap: DetectionCatalogClassMapSchema.optional()
8306
8305
  });
8307
8306
  var ConvertResultSchema = object({
8308
8307
  entry: ModelCatalogEntrySchema,
@@ -9165,7 +9164,7 @@ var AddonPageDeclarationSchema = object({
9165
9164
  /** Display label for a CUSTOM `section` id (ignored for well-known ids). */
9166
9165
  sectionLabel: string().optional()
9167
9166
  });
9168
- method(_void(), array(AddonPageDeclarationSchema).readonly());
9167
+ method(_void(), array(AddonPageDeclarationSchema).readonly(), { auth: "admin" });
9169
9168
  var AddonHttpRouteSchema = object({
9170
9169
  method: _enum([
9171
9170
  "GET",
@@ -9400,7 +9399,7 @@ var WidgetMetadataSchema = object({
9400
9399
  defaultColumns: number().int().min(1).max(12).default(6),
9401
9400
  defaultRows: number().int().min(1).max(12).default(1)
9402
9401
  });
9403
- method(_void(), array(WidgetMetadataSchema).readonly());
9402
+ method(_void(), array(WidgetMetadataSchema).readonly(), { auth: "admin" });
9404
9403
  /**
9405
9404
  * `addon-widgets` — system-scoped singleton aggregator cap. Public-facing
9406
9405
  * surface that admin-ui consumes through `useAddonWidgetsListWidgets()`.
@@ -11024,7 +11023,7 @@ var CustomModelDescriptorSchema = object({
11024
11023
  stepId: string(),
11025
11024
  entry: ModelCatalogEntrySchema
11026
11025
  });
11027
- method(_void(), array(CustomModelDescriptorSchema).readonly());
11026
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
11028
11027
  /**
11029
11028
  * Query filter for settings-store collections.
11030
11029
  */
@@ -11111,7 +11110,8 @@ method(object({
11111
11110
  }), _void(), { kind: "mutation" }), method(object({
11112
11111
  namespace: string().optional(),
11113
11112
  collection: string(),
11114
- filter: QueryFilterSchema.optional()
11113
+ filter: QueryFilterSchema.optional(),
11114
+ columns: array(string()).readonly().optional()
11115
11115
  }), array(SettingsRecordSchema).readonly()), method(object({
11116
11116
  namespace: string().optional(),
11117
11117
  collection: string(),
@@ -11174,46 +11174,87 @@ var EngineInfoSchema = object({
11174
11174
  kind: _enum(["relational", "vector"]),
11175
11175
  displayName: string()
11176
11176
  });
11177
- method(_void(), EngineInfoSchema), method(object({
11177
+ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
11178
11178
  namespace: string().optional(),
11179
11179
  collection: string(),
11180
11180
  key: string()
11181
- }), unknown()), method(object({
11181
+ }), unknown(), { auth: "admin" }), method(object({
11182
11182
  namespace: string().optional(),
11183
11183
  collection: string(),
11184
11184
  key: string(),
11185
11185
  value: unknown()
11186
- }), _void(), { kind: "mutation" }), method(object({
11186
+ }), _void(), {
11187
+ kind: "mutation",
11188
+ auth: "admin"
11189
+ }), method(object({
11187
11190
  namespace: string().optional(),
11188
11191
  collection: string(),
11189
- filter: QueryFilterSchema.optional()
11190
- }), array(SettingsRecordSchema).readonly()), method(object({
11192
+ filter: QueryFilterSchema.optional(),
11193
+ /**
11194
+ * SQL-level column projection — MUST mirror `settings-store.query`.
11195
+ *
11196
+ * ⚠ An earlier version of this comment blamed Zod stripping, and that
11197
+ * was wrong — corrected 2026-08-26 after the hop map
11198
+ * (`docs/design/2026-08-26-mappa-hop-argomenti.md`) traced the path.
11199
+ * There is **no Zod parse at all** between the door and the engine: the
11200
+ * dispatcher forwards the payload verbatim and UDS carries it whole. A
11201
+ * field declared here reaches `SqliteSettingsBackend` either way.
11202
+ *
11203
+ * What actually lost `columns` was the THIRD declaration of this shape:
11204
+ * `SettingsQueryInput` in `interfaces/storage.ts`, a hand-written TS
11205
+ * interface the engine destructures from. The field existed on both
11206
+ * schemas and the engine still never read it, because nothing checks a
11207
+ * registered provider against `InferProvider<cap>` —
11208
+ * `ProviderRegistration.provider` is typed `object`.
11209
+ *
11210
+ * It is declared here anyway, and must stay in step with
11211
+ * `settings-store.query`: a caller reading only the cap definitions has
11212
+ * to be able to see that this call carries a projection.
11213
+ * `data-door-schema-parity.spec.ts` keeps the two aligned.
11214
+ */
11215
+ columns: array(string()).readonly().optional()
11216
+ }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
11191
11217
  namespace: string().optional(),
11192
11218
  collection: string(),
11193
11219
  record: SettingsRecordSchema
11194
- }), _void(), { kind: "mutation" }), method(object({
11220
+ }), _void(), {
11221
+ kind: "mutation",
11222
+ auth: "admin"
11223
+ }), method(object({
11195
11224
  namespace: string().optional(),
11196
11225
  collection: string(),
11197
11226
  id: string(),
11198
11227
  data: record(string(), unknown())
11199
- }), _void(), { kind: "mutation" }), method(object({
11228
+ }), _void(), {
11229
+ kind: "mutation",
11230
+ auth: "admin"
11231
+ }), method(object({
11200
11232
  namespace: string().optional(),
11201
11233
  collection: string(),
11202
11234
  key: string()
11203
- }), _void(), { kind: "mutation" }), method(object({
11235
+ }), _void(), {
11236
+ kind: "mutation",
11237
+ auth: "admin"
11238
+ }), method(object({
11204
11239
  namespace: string().optional(),
11205
11240
  collection: string(),
11206
11241
  filter: MutationFilterSchema
11207
- }), object({ deleted: number().int() }), { kind: "mutation" }), method(object({
11242
+ }), object({ deleted: number().int() }), {
11243
+ kind: "mutation",
11244
+ auth: "admin"
11245
+ }), method(object({
11208
11246
  namespace: string().optional(),
11209
11247
  collection: string(),
11210
11248
  filter: MutationFilterSchema,
11211
11249
  data: record(string(), unknown())
11212
- }), object({ updated: number().int() }), { kind: "mutation" }), method(object({
11250
+ }), object({ updated: number().int() }), {
11251
+ kind: "mutation",
11252
+ auth: "admin"
11253
+ }), method(object({
11213
11254
  namespace: string().optional(),
11214
11255
  collection: string(),
11215
11256
  filter: QueryFilterSchema.optional()
11216
- }), number()), method(object({
11257
+ }), number(), { auth: "admin" }), method(object({
11217
11258
  namespace: string().optional(),
11218
11259
  collection: string(),
11219
11260
  field: string(),
@@ -11223,15 +11264,18 @@ method(_void(), EngineInfoSchema), method(object({
11223
11264
  }), array(object({
11224
11265
  bucket: number().int(),
11225
11266
  count: number().int()
11226
- })).readonly()), method(object({
11267
+ })).readonly(), { auth: "admin" }), method(object({
11227
11268
  namespace: string().optional(),
11228
11269
  collection: string()
11229
- }), boolean()), method(object({
11270
+ }), boolean(), { auth: "admin" }), method(object({
11230
11271
  namespace: string().optional(),
11231
11272
  collection: string(),
11232
11273
  columns: array(CollectionColumnSchema).readonly(),
11233
11274
  indexes: array(CollectionIndexSchema).readonly().optional()
11234
- }), _void(), { kind: "mutation" });
11275
+ }), _void(), {
11276
+ kind: "mutation",
11277
+ auth: "admin"
11278
+ });
11235
11279
  /**
11236
11280
  * shm ring usage stats for a `frameSink: 'shm'` decoder session —
11237
11281
  * exposed via `decoder.getShmStats` so downstream consumers can
@@ -12538,7 +12582,7 @@ method(object({
12538
12582
  crop: _instanceof(Uint8Array),
12539
12583
  width: number(),
12540
12584
  height: number()
12541
- }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
12585
+ }), EmbeddingResultSchema, { auth: "admin" }), method(object({ text: string() }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" });
12542
12586
  /**
12543
12587
  * filesystem-browse — per-node capability for browsing the node's local
12544
12588
  * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
@@ -12831,19 +12875,22 @@ method(LlmGenerateBaseInputSchema.extend({
12831
12875
  runtime: ManagedRuntimeConfigSchema,
12832
12876
  /** The managed profile's timeout, threaded by the hub provider. */
12833
12877
  timeoutMs: number().int().positive().optional()
12834
- }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
12878
+ }), LlmGenerateResultSchema, {
12879
+ kind: "mutation",
12880
+ auth: "admin"
12881
+ }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
12835
12882
  kind: "mutation",
12836
12883
  auth: "admin"
12837
12884
  }), method(object({}), _void(), {
12838
12885
  kind: "mutation",
12839
12886
  auth: "admin"
12840
- }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
12887
+ }), method(object({}), LlmRuntimeStatusSchema, { auth: "admin" }), method(object({ model: ManagedModelRefSchema }), _void(), {
12841
12888
  kind: "mutation",
12842
12889
  auth: "admin"
12843
12890
  }), method(object({ file: string() }), _void(), {
12844
12891
  kind: "mutation",
12845
12892
  auth: "admin"
12846
- }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
12893
+ }), method(object({}), array(LlmNodeModelSchema), { auth: "admin" }), method(object({}), LlmRuntimeDiskUsageSchema, { auth: "admin" });
12847
12894
  /**
12848
12895
  * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
12849
12896
  * methods concat-fan across providers; single-row methods route to ONE
@@ -16354,1748 +16401,1998 @@ var OauthIntegrationDescriptorSchema = object({
16354
16401
  */
16355
16402
  refreshTokenTtlSec: union([number().int().positive(), literal("never")]).optional()
16356
16403
  });
16357
- method(_void(), OauthIntegrationDescriptorSchema);
16404
+ method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
16358
16405
  /**
16359
- * pipeline-analytics — device-scoped wrapper cap. Refines raw
16360
- * per-frame detections emitted by the pipeline runner into tracked
16361
- * objects, per-kind event collections (motion / object / audio), and
16362
- * persisted media. Owns the post-detection domain end-to-end:
16363
- *
16364
- * runner emits PipelineInferenceResult
16365
- * ↓ (event bus)
16366
- * pipeline-analytics subscriber
16367
- * ↓ SORT tracker + zone engine + state analyzer + event emitter
16368
- * → three DB collections (one per kind), one FS media tree, one
16369
- * unified event emitter (FrameTracked + TrackStarted/Ended +
16370
- * DetectionEvent on bus)
16371
- *
16372
- * Pure subscriber model. No `processFrame` cap method — the runner
16373
- * already publishes the raw frame on the bus. The cap surface is
16374
- * only QUERIES + per-device settings, bound on/off via
16375
- * `device-manager.setWrapperActive`. `defaultActive: true` because
16376
- * every camera with a detection pipeline wants its raw detections
16377
- * refined; operators opt out per-device via BindingsTab when needed.
16378
- *
16379
- * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
16380
- * (per-device surface) and `track-trail` caps — see P11 cleanup.
16406
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
16407
+ * within the frame, so the executor can re-cut a leaf child ROI at native
16408
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
16381
16409
  */
16382
- var TrackStateSchema = _enum([
16383
- "new",
16384
- "entered",
16385
- "left",
16386
- "moving",
16387
- "idle"
16388
- ]);
16389
- var EventKindSchema = _enum([
16390
- "motion",
16391
- "object",
16392
- "audio"
16393
- ]);
16410
+ var NativeCropRefSchema = object({
16411
+ /** Handle keying the retained native surface (node-pinned to its owner). */
16412
+ handle: FrameHandleSchema,
16413
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
16414
+ cropFrameSpace: object({
16415
+ x: number(),
16416
+ y: number(),
16417
+ w: number(),
16418
+ h: number()
16419
+ })
16420
+ });
16421
+ object({
16422
+ crop: object({
16423
+ left: number(),
16424
+ top: number(),
16425
+ width: number().positive(),
16426
+ height: number().positive()
16427
+ }).optional(),
16428
+ content: object({
16429
+ width: number().int().positive(),
16430
+ height: number().int().positive()
16431
+ }),
16432
+ fit: _enum(["stretch", "contain"]),
16433
+ format: _enum([
16434
+ "rgb",
16435
+ "gray",
16436
+ "jpeg"
16437
+ ])
16438
+ });
16394
16439
  /**
16395
- * Spatial filter for `listTracks` — the rect + polygon variants of the shared
16396
- * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
16397
- * of the camera frame (top-left origin), matching the drawing-plane editor.
16440
+ * Process-local frame identity. It is serializable so it can ride an in-process
16441
+ * capability call, but `registryId` deliberately prevents resolution in any
16442
+ * other process or execution group.
16398
16443
  */
16399
- var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
16400
- /** Closed icon vocabulary so clients render a known glyph per kind. */
16401
- var EventKindIconSchema = _enum([
16402
- "motion",
16403
- "audio",
16404
- "person",
16405
- "vehicle",
16406
- "animal",
16407
- "door",
16408
- "pir",
16409
- "smoke",
16410
- "water",
16411
- "button",
16412
- "package",
16413
- "generic"
16444
+ var FrameRefSchema = object({
16445
+ registryId: string().min(1),
16446
+ id: string().min(1),
16447
+ width: number().int().positive(),
16448
+ height: number().int().positive(),
16449
+ format: _enum(["rgb", "gray"]),
16450
+ timestamp: number(),
16451
+ capturedAt: number().optional()
16452
+ });
16453
+ var ModelFormatSchema$1 = _enum([
16454
+ "onnx",
16455
+ "coreml",
16456
+ "openvino",
16457
+ "tflite",
16458
+ "pt",
16459
+ "gguf"
16414
16460
  ]);
16415
- var EventKindCategorySchema = _enum([
16416
- "motion",
16417
- "audio",
16418
- "detection",
16419
- "sensor",
16420
- "control",
16421
- "custom",
16422
- "package"
16461
+ var PipelineSlotSchema = _enum([
16462
+ "detector",
16463
+ "cropper",
16464
+ "classifier",
16465
+ "refiner",
16466
+ "audio-classifier"
16423
16467
  ]);
16424
- /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
16425
- var EventKindLevelSchema = _enum(["macro", "sub"]);
16426
- var EventKindDescriptorSchema = object({
16427
- /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
16428
- kind: string(),
16429
- /** i18n key resolved on the UI side; `label` is the English fallback. */
16430
- labelKey: string(),
16431
- /** English fallback label (kept for clients that don't translate). */
16432
- label: string(),
16433
- /** Hex color for timeline/legend rendering. */
16434
- color: string(),
16435
- /** Dictionary id → lucide component on the UI side. */
16436
- iconId: string(),
16437
- /** Legacy closed-vocab glyph — fallback for `iconId`. */
16438
- icon: EventKindIconSchema,
16439
- category: EventKindCategorySchema,
16440
- /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
16441
- parentKind: string().nullable(),
16442
- /** Derived from `parentKind`, explicit for the client tree. */
16443
- level: EventKindLevelSchema,
16444
- /** Which cap + device contributes this kind. For built-ins the camera
16445
- * itself; for sensor kinds the LINKED source device. */
16446
- source: object({
16447
- capName: string(),
16448
- deviceId: number()
16449
- })
16468
+ var PipelineEngineChoiceSchema = object({
16469
+ runtime: _enum(["node", "python"]),
16470
+ backend: string(),
16471
+ format: ModelFormatSchema$1,
16472
+ device: string().optional()
16450
16473
  });
16451
- /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
16452
- var EventKindsForDeviceSchema = object({
16453
- deviceId: number(),
16454
- kinds: array(EventKindDescriptorSchema).readonly()
16474
+ var AvailableEngineSchema = object({
16475
+ engine: PipelineEngineChoiceSchema,
16476
+ devices: array(object({
16477
+ id: string(),
16478
+ label: string(),
16479
+ description: string().optional()
16480
+ })).readonly(),
16481
+ defaultDevice: string()
16455
16482
  });
16456
- var SensorEventSchema = object({
16483
+ var PipelineDefaultStepSchema = lazy(() => object({
16484
+ addonId: string(),
16485
+ addonName: string(),
16486
+ slot: PipelineSlotSchema,
16487
+ inputClasses: array(string()).readonly(),
16488
+ outputClasses: array(string()).readonly(),
16489
+ enabled: boolean(),
16490
+ modelId: string(),
16491
+ children: array(PipelineDefaultStepSchema).readonly(),
16492
+ group: string().optional(),
16493
+ settings: record(string(), unknown()).optional()
16494
+ }));
16495
+ var PipelineTemplateStepSchema = lazy(() => object({
16496
+ addonId: string(),
16497
+ enabled: boolean(),
16498
+ modelId: string(),
16499
+ children: array(PipelineTemplateStepSchema).readonly(),
16500
+ settings: record(string(), unknown()).optional()
16501
+ }));
16502
+ var PipelineTemplateSchema$1 = object({
16457
16503
  id: string(),
16458
- /** The CAMERA the event is attributed to (a sensor linked to N cameras
16459
- * yields N rows, one per camera). */
16460
- deviceId: number(),
16461
- /** The linked sensor device whose state changed. */
16462
- sourceDeviceId: number(),
16463
- /** Event kind id — matches an `EventKindDescriptor.kind`. */
16464
- kind: string(),
16465
- /** Snapshot of the sensor cap's runtime-state slice at the change. */
16466
- value: record(string(), unknown()).nullable(),
16467
- timestamp: number()
16468
- });
16469
- var TrackPositionSchema = object({
16470
- x: number(),
16471
- y: number(),
16472
- timestamp: number(),
16473
- bbox: BoundingBoxSchema
16504
+ name: string(),
16505
+ createdAt: string(),
16506
+ updatedAt: string(),
16507
+ engine: PipelineEngineChoiceSchema,
16508
+ steps: array(PipelineTemplateStepSchema).readonly()
16474
16509
  });
16475
- var TrackSnapshotSchema = object({
16476
- timestamp: number(),
16477
- position: TrackPositionSchema,
16478
- /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
16479
- mediaKey: string()
16510
+ var PipelineModelOptionSchema = object({
16511
+ id: string(),
16512
+ name: string(),
16513
+ formats: record(string(), object({
16514
+ downloaded: boolean(),
16515
+ sizeMB: number()
16516
+ })),
16517
+ group: ModelVariantGroupSchema.optional(),
16518
+ legacy: boolean().optional(),
16519
+ provider: ModelProviderIdSchema.optional()
16480
16520
  });
16481
- /**
16482
- * Normalized 0..1 trajectory envelope (min/max over every position bbox,
16483
- * divided by the track's detection-frame dims), computed at persist time.
16484
- * Absent when the frame dims were unknown when the track was persisted
16485
- * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
16486
- */
16487
- var TrackEnvelopeSchema = object({
16488
- minX: number(),
16489
- minY: number(),
16490
- maxX: number(),
16491
- maxY: number()
16521
+ var ConfigFieldBridge = custom();
16522
+ var PipelineAddonSchemaSchema = object({
16523
+ id: string(),
16524
+ name: string(),
16525
+ slot: PipelineSlotSchema,
16526
+ inputClasses: array(string()).readonly(),
16527
+ outputClasses: array(string()).readonly(),
16528
+ childSlots: array(PipelineSlotSchema).readonly(),
16529
+ models: array(PipelineModelOptionSchema).readonly(),
16530
+ defaultModelId: string(),
16531
+ defaultModelIdByFormat: record(string(), string()).optional(),
16532
+ enabledByDefault: boolean().optional(),
16533
+ backfillIntoExistingOverrides: boolean().optional(),
16534
+ defaultConfidence: number(),
16535
+ group: string().optional(),
16536
+ configSchema: array(ConfigFieldBridge).readonly().optional()
16492
16537
  });
16493
- /**
16494
- * Row projection for track list queries. `full` (default) returns the
16495
- * complete Track including the frame-rate `positions[]` history and the
16496
- * `snapshots[]` references — megabytes across a page of tracks. `slim`
16497
- * keeps every scalar the list surfaces actually render (ids, class(es),
16498
- * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
16499
- * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
16500
- * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
16501
- * `getTrack`. Mirrors the event-store `projection` convention
16502
- * (`getObjectEvents` et al.).
16503
- */
16504
- var TrackProjectionSchema = _enum(["full", "slim"]);
16505
- /**
16506
- * One audio-classification label heard on the track's camera while the
16507
- * track was alive, aggregated per label. An "episode" is one persisted
16508
- * audio event (the confident-classification path: score ≥ the device's
16509
- * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
16510
- * one 32 ms inference chunk, so counts stay human-scaled.
16511
- */
16512
- var TrackAudioLabelSchema = object({
16538
+ var PipelineSlotSchemaSchema = object({
16539
+ id: PipelineSlotSchema,
16513
16540
  label: string(),
16514
- /** Highest classification score observed across the label's episodes. */
16515
- peakScore: number(),
16516
- /** Number of coalesced audio-event episodes carrying this label. */
16517
- count: number(),
16518
- firstAt: number(),
16519
- lastAt: number()
16541
+ priority: number(),
16542
+ parentSlot: PipelineSlotSchema.nullable(),
16543
+ addons: array(PipelineAddonSchemaSchema).readonly()
16520
16544
  });
16521
- /**
16522
- * How a track was produced. `pipeline` (default / absent) = the spatial
16523
- * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
16524
- * no positions, a single snapshot, and no bbox trajectory at all:
16525
- *
16526
- * - `sensor` — a linked sensor/control device state change.
16527
- * - `audio` — an audio event on the camera itself that was anomalous for
16528
- * THAT camera, loud, and heard while nothing visual was happening (D62).
16529
- *
16530
- * The spatial subsystems (tracker association, occupancy count, re-id /
16531
- * embedding, resurrection) MUST skip every synthetic source. Test for that
16532
- * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
16533
- * check silently readmits every source added after it was written.
16534
- */
16535
- var TrackSourceSchema = _enum([
16536
- "pipeline",
16537
- "sensor",
16538
- "audio"
16539
- ]);
16540
- /**
16541
- * Where a track sits in the RETRAIN lifecycle (D81).
16542
- *
16543
- * - `none` — never marked, or un-marked. Evictable.
16544
- * - `staging` — the operator wants this track as training material and has not
16545
- * finished with it. **This is the only state retention holds**: the track and
16546
- * everything it owns (object events, crops, keyframes, CLIP vector) survive
16547
- * the device's age window.
16548
- * - `trained` — the retrain page has taken what it needed. The frames it chose
16549
- * were COPIED into the retrain dataset at selection time, so the dataset no
16550
- * longer depends on the track's media and the track becomes EVICTABLE again.
16551
- * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
16552
- * a deliberate action of the retrain page, not a side effect of a checkbox.
16553
- *
16554
- * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
16555
- * the store's filter language has only positive equality and `whereIn` — no
16556
- * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
16557
- * would make the entire pre-column history immortal in one deploy.
16558
- */
16559
- var RetrainStatusSchema = _enum([
16560
- "none",
16561
- "staging",
16562
- "trained"
16563
- ]);
16564
- /**
16565
- * Per-track OPERATOR flags — set by hand from the admin UI or the viewer, never
16566
- * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
16567
- * so the two surfaces cannot drift.
16568
- *
16569
- * **Absent ≠ false.** A track that has never been touched omits the field; an
16570
- * explicitly un-flagged track carries `false`. Legacy rows written before the
16571
- * columns existed read as absent, and a consumer that needs a boolean should say
16572
- * `flag === true`, not `flag !== false`.
16573
- *
16574
- * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
16575
- * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
16576
- * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
16577
- * `trained` track reports `false` while refusing both writes. The boolean is
16578
- * kept because three surfaces drive a toggle off it; anything that needs to tell
16579
- * "never marked" from "already trained" must read `retrainStatus`.
16580
- *
16581
- * `debug` does NOT pin; it is attention, not durability.
16582
- *
16583
- * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
16584
- * A favourited track is skipped by retention the same way `staging` is, but
16585
- * it does not enter `none|staging|trained` and has no staging budget.
16586
- */
16587
- var TrackFlagFields = {
16588
- /** Operator marked this track as training material — i.e. `retrainStatus` is
16589
- * `'staging'`. */
16590
- markForTrain: boolean().optional(),
16591
- /** Operator marked this track for diagnostic attention. */
16592
- debug: boolean().optional(),
16593
- /** Operator favourited this track. Pins it against pruning. */
16594
- favourited: boolean().optional()
16595
- };
16596
- /**
16597
- * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
16598
- * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
16599
- * write patch, and the status is not something the toggle sets — it is what the
16600
- * toggle's boolean is derived from. Absent on an in-RAM track never touched;
16601
- * always present on a persisted row (the column default materialises `'none'`).
16602
- */
16603
- var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
16604
- /**
16605
- * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
16606
- * one flag can never clear the other — the toggles are independent and are
16607
- * driven from three surfaces that do not know about each other.
16608
- */
16609
- var TrackFlagsPatchSchema = object(TrackFlagFields);
16610
- /**
16611
- * The resolved flag state after a write. Both fields are REQUIRED here (absent
16612
- * collapses to `false`) so a caller can drive a toggle's checked state off the
16613
- * mutation result without a re-fetch.
16614
- */
16615
- var TrackFlagsSchema = object({
16616
- trackId: string(),
16617
- markForTrain: boolean(),
16618
- debug: boolean(),
16619
- favourited: boolean(),
16620
- /** The lifecycle state the boolean was derived from. Required here (unlike on
16621
- * a track row) because this shape is only ever produced by the write body,
16622
- * which always knows it — and a surface that has just written needs to render
16623
- * `trained` without a re-fetch. */
16624
- retrainStatus: RetrainStatusSchema
16545
+ var PipelineSchemaSchema = object({
16546
+ availableEngines: array(AvailableEngineSchema).readonly(),
16547
+ selectedEngine: PipelineEngineChoiceSchema,
16548
+ slots: array(PipelineSlotSchemaSchema).readonly()
16625
16549
  });
16626
- union([literal(1), literal(2)]);
16627
- /**
16628
- * WHO decided a label, and when. Carried per tier so a value can be traced to
16629
- * the step and model that produced it — which is what makes the write rule
16630
- * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
16631
- * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
16632
- *
16633
- * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
16634
- * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
16635
- * `migration:4g` for a value the 4g migration moved from the single-slot era —
16636
- * that value has no provenance, and the write rule lets ANY properly-attributed
16637
- * write of the same tier replace it regardless of score.
16638
- */
16639
- var LabelAttributionSchema = object({
16640
- stepId: string(),
16641
- modelId: string().optional(),
16642
- decidedAt: number(),
16550
+ var EngineProvisioningSchema = object({
16551
+ runtimeId: _enum([
16552
+ "onnx",
16553
+ "openvino",
16554
+ "coreml",
16555
+ "edgetpu"
16556
+ ]).nullable(),
16557
+ device: string().nullable(),
16558
+ state: _enum([
16559
+ "idle",
16560
+ "installing",
16561
+ "verifying",
16562
+ "ready",
16563
+ "failed"
16564
+ ]),
16565
+ progress: number().optional(),
16566
+ error: string().optional(),
16567
+ nextRetryAt: number().optional(),
16643
16568
  /**
16644
- * The GALLERY id behind a recognised tier-2 label — a face-gallery
16645
- * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
16646
- *
16647
- * The text alone is a DISPLAY NAME, and a display name is renameable: a
16648
- * notification rule authored on "Gianluca" stopped matching the moment the
16649
- * operator fixed the spelling in the gallery, and nothing said so. The id is
16650
- * the thing that does not move, so it is what a rule matches on
16651
- * (`NcConditions.identities`) and the text is what a human is shown.
16652
- *
16653
- * Absent when the label names no gallery row — a plate the OCR read but no
16654
- * vehicle claims, a sub-class, a species, any tier-1 value.
16569
+ * Gate A (config-correctness gate at engine change): human-readable
16570
+ * config issues surfaced EAGERLY when the node's engine changes — model
16571
+ * substitutions ("chose X, running Y") and zero-build steps ("no model
16572
+ * has a <format> build"). Additive/optional: informational only, never
16573
+ * enforced here — `assertEngineReady` (readiness) still gates inference.
16574
+ * Absent/empty when the node-default tree resolves cleanly.
16655
16575
  */
16656
- identityId: string().optional()
16576
+ configIssues: array(string()).optional()
16657
16577
  });
16658
- /**
16659
- * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
16660
- * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
16661
- * track and its events always answer the same question the same way.
16662
- *
16663
- * Two scalar columns, not an array: every consumer wants "the coarse one" or
16664
- * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
16665
- * is tier 2, and each carries its own score + attribution.
16666
- *
16667
- * **Reading it.** What a human should be shown is `subLabel ?? label` — the
16668
- * finest thing known. Before 4g the single `label` column held the finest
16669
- * value, so a consumer that has not been updated reads the tier-1 slot and
16670
- * shows nothing on a species-only row; that is why the migration puts every
16671
- * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
16672
- * and why the read surfaces were changed in the same train.
16673
- *
16674
- * **Writing it.** The slots are independent, which is the whole point: a
16675
- * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
16676
- * migratorius`), so fineness cannot regress by construction. Within a tier the
16677
- * higher score wins. One rule, one implementation — see
16678
- * `pipeline/label-tier.ts` in addon-post-analysis.
16679
- */
16680
- var TieredLabelFields = {
16681
- /** Tier 1 — the sub-class. See {@link LabelTierSchema}. */
16682
- label: string().optional(),
16683
- /** Confidence of the tier-1 value, as reported by the deciding step. */
16684
- labelScore: number().optional(),
16685
- /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
16686
- labelMeta: LabelAttributionSchema.optional(),
16687
- /** Tier 2 — the instance. See {@link LabelTierSchema}. */
16688
- subLabel: string().optional(),
16689
- /** Confidence of the tier-2 value, as reported by the deciding step. */
16690
- subLabelScore: number().optional(),
16691
- /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
16692
- subLabelMeta: LabelAttributionSchema.optional()
16693
- };
16694
- /** Per-camera slice of a training-export estimate. */
16695
- var TrainingExportDeviceTotalsSchema = object({
16696
- deviceId: number(),
16697
- tracks: number().int(),
16698
- files: number().int(),
16699
- bytes: number().int()
16578
+ var PipelineStepInputSchema = lazy(() => object({
16579
+ addonId: string(),
16580
+ modelId: string().optional(),
16581
+ enabled: boolean().default(true),
16582
+ children: array(PipelineStepInputSchema).optional(),
16583
+ settings: record(string(), unknown()).optional(),
16584
+ jumpDeviceKey: string().optional()
16585
+ }));
16586
+ var ModelSubstitutionSchema = object({
16587
+ addonId: string(),
16588
+ chosen: string(),
16589
+ running: string(),
16590
+ format: string()
16591
+ });
16592
+ var PipelineValidationIssueSchema = object({
16593
+ addonId: string(),
16594
+ kind: _enum(["unknown-addon", "no-format-build"]),
16595
+ detail: string()
16596
+ });
16597
+ var PipelineValidationResultSchema = object({
16598
+ ok: boolean(),
16599
+ issues: array(PipelineValidationIssueSchema).readonly(),
16600
+ substitutions: array(ModelSubstitutionSchema).readonly(),
16601
+ /** The node's `currentEngine.format` this validation ran against. */
16602
+ format: string()
16603
+ });
16604
+ var ReferenceImageEntrySchema = object({
16605
+ filename: string(),
16606
+ stepIds: array(string()).readonly().optional()
16607
+ });
16608
+ var ReferenceImageBodySchema = object({
16609
+ base64: string(),
16610
+ filename: string()
16611
+ });
16612
+ var ReferenceAudioEntrySchema = object({
16613
+ filename: string(),
16614
+ sizeKb: number()
16615
+ });
16616
+ var ReferenceAudioBodySchema = object({ base64: string() });
16617
+ var AudioBackendSchema = object({
16618
+ id: string(),
16619
+ name: string(),
16620
+ description: string(),
16621
+ available: boolean(),
16622
+ /**
16623
+ * Raw classifier labels this backend can emit (e.g. YAMNet's
16624
+ * 521-class set or Apple SoundAnalysis's 303-class set). Used by
16625
+ * the benchmark UI to populate the `enabledMicroClasses` filter
16626
+ * specific to the selected backend without a separate fetch.
16627
+ */
16628
+ rawLabels: array(string()).readonly().optional()
16629
+ });
16630
+ var AudioCapabilitiesSchema = object({
16631
+ activeBackend: string(),
16632
+ availableBackends: array(AudioBackendSchema).readonly(),
16633
+ sampleRate: number(),
16634
+ chunkDurationMs: number()
16635
+ });
16636
+ var DownloadModelResultSchema = object({
16637
+ filePath: string(),
16638
+ sizeMB: number(),
16639
+ durationMs: number()
16700
16640
  });
16701
16641
  /**
16702
- * What a training export WOULD contain. Computed from media index rows only —
16703
- * no blob is read to produce this.
16642
+ * Wrapper carrying a single test run's result. Replaces the legacy
16643
+ * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
16644
+ * canonical `AudioResult` from the Phase 6 output rework: one
16645
+ * `AudioDetection` per class above `minScore`, top-N candidates in
16646
+ * `debug.alternateLabels['audio-classifier']`, per-source timings in
16647
+ * `debug.stepTimings`. The outer `success`/`error` fields stay so the
16648
+ * benchmark UI can still report a clean failure when the classifier
16649
+ * cap isn't available.
16704
16650
  */
16705
- var TrainingExportSummarySchema = object({
16706
- generatedAt: number(),
16707
- trackCount: number().int(),
16708
- fileCount: number().int(),
16709
- byteCount: number().int(),
16710
- /** More marked tracks exist than a single pass carries. */
16711
- truncated: boolean(),
16712
- devices: array(TrainingExportDeviceTotalsSchema).readonly()
16651
+ var AudioTestResultSchema = object({
16652
+ success: boolean(),
16653
+ error: string().optional(),
16654
+ frame: custom().optional()
16713
16655
  });
16714
- var TrackSchema = object({
16715
- trackId: string(),
16716
- deviceId: number(),
16717
- className: string(),
16718
- ...TieredLabelFields,
16719
- producingDeviceName: string().optional(),
16720
- /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
16721
- source: TrackSourceSchema.optional(),
16722
- firstSeen: number(),
16723
- lastSeen: number(),
16724
- /** Frame-rate position history (subject to maxPositionHistory cap). */
16725
- positions: array(TrackPositionSchema).readonly(),
16726
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
16727
- * saveThumbnails policy). */
16728
- snapshots: array(TrackSnapshotSchema).readonly(),
16729
- /** Deduplicated zones the track has entered at least once. Zone IDS. */
16730
- zonesVisited: array(string()).readonly(),
16656
+ var PipelineConfigBridge = custom();
16657
+ var ConfigUISchemaBridge = custom();
16658
+ var ConfigUISchemaNullableBridge = custom();
16659
+ var InferenceCapabilitiesBridge = custom();
16660
+ var ModelAvailabilityListBridge = custom();
16661
+ var PipelineRunResultBridge = custom();
16662
+ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
16663
+ modelId: string(),
16664
+ settings: record(string(), unknown()).readonly()
16665
+ }))), method(object({ steps: record(string(), object({
16666
+ modelId: string(),
16667
+ settings: record(string(), unknown()).readonly()
16668
+ })) }), object({ success: literal(true) }), {
16669
+ kind: "mutation",
16670
+ auth: "admin"
16671
+ }), method(object({ nodeId: string() }), object({
16672
+ success: literal(true),
16673
+ clearedDevices: number()
16674
+ }), {
16675
+ kind: "mutation",
16676
+ auth: "admin"
16677
+ }), method(object({ nodeId: string() }), object({ unhealthy: array(object({
16678
+ /** `<backend>:<device>`, e.g. `openvino:gpu`. */
16679
+ deviceKey: string(),
16731
16680
  /**
16732
- * Human NAMES for {@link zonesVisited}, resolved at READ time against the
16733
- * `zones` capability.
16734
- *
16735
- * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
16736
- * and no card can render — so every free-text search surface was structurally
16737
- * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
16738
- * just returned nothing. Resolving here rather than in each client keeps ONE
16739
- * derivation and costs the clients no extra call (the `zones` cap is
16740
- * per-device, so a client-side resolve would be a per-camera fan-out on a
16741
- * surface built to avoid exactly that).
16742
- *
16743
- * Resolved, never invented: a zone deleted since the track was written has no
16744
- * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
16745
- * two are not positionally aligned. Absent when the track visited no zone, or
16746
- * when the zone catalogue could not be read.
16681
+ * `failed` — the per-device restart budget is exhausted; no pool
16682
+ * will be spawned until an operator re-arms it or the runner
16683
+ * respawns. `backoff` — under budget, waiting out the backoff (or
16684
+ * a cached pool observed dead and not yet condemned).
16747
16685
  */
16748
- zoneNames: array(string()).readonly().optional(),
16749
- /** Deduplicated set of detector classes observed for this track over its
16750
- * life (a track may be reclassified, e.g. person→vehicle). Absent on
16751
- * legacy rows written before class accumulation shipped. */
16752
- classes: array(string()).readonly().optional(),
16753
- /** Cumulative normalized distance travelled (0..1 units = full frame width). */
16754
- totalDistance: number(),
16755
- state: TrackStateSchema,
16756
- active: boolean(),
16757
- /** Deterministic key-event importance score in [0,1] (server-computed at
16758
- * track expiry, recomputed on late label). Absent on legacy rows written
16759
- * before scoring shipped — consumers degrade to absence / compute-on-read. */
16760
- importance: number().optional(),
16761
- /** Id of the track's highest-confidence ObjectEvent (its representative
16762
- * "best" frame). Absent when the track produced no object events. */
16763
- bestEventId: string().optional(),
16764
- /** Tag of the importance sub-signal that dominated the score
16765
- * (identity|dwell|proximity|class|confidence|travel|zone). */
16766
- importanceReason: string().optional(),
16767
- /** Audio-classification labels heard on the camera during the track's
16768
- * life (score ≥ device `classificationMinScore`), aggregated per label.
16769
- * Absent on legacy rows / tracks with no confident audio. */
16770
- audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
16771
- /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
16772
- * Populated from the persisted envelope columns on historical reads;
16773
- * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
16774
- envelope: TrackEnvelopeSchema.optional(),
16686
+ state: _enum(["failed", "backoff"]),
16687
+ /** Epoch ms of the death that produced this state. */
16688
+ since: number(),
16689
+ /** Pool deaths inside the current window. */
16690
+ deaths: number(),
16691
+ /** The last death's message. */
16692
+ lastError: string()
16693
+ })).readonly() })), method(object({
16694
+ nodeId: string(),
16695
+ deviceKey: string()
16696
+ }), object({ rearmed: boolean() }), {
16697
+ kind: "mutation",
16698
+ auth: "admin"
16699
+ }), 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({
16700
+ name: string(),
16701
+ steps: array(PipelineTemplateStepSchema).readonly(),
16702
+ engine: PipelineEngineChoiceSchema
16703
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
16704
+ id: string(),
16705
+ name: string().optional(),
16706
+ steps: array(PipelineTemplateStepSchema).readonly().optional()
16707
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
16708
+ addonId: string(),
16709
+ modelId: string(),
16710
+ format: ModelFormatSchema$1
16711
+ }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
16712
+ addonId: string(),
16713
+ modelId: string(),
16714
+ format: ModelFormatSchema$1
16715
+ }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
16716
+ engine: PipelineEngineChoiceSchema.optional(),
16717
+ steps: array(PipelineStepInputSchema).min(1),
16718
+ frame: FrameInputSchema.optional(),
16775
16719
  /**
16776
- * A face DETECTOR found a face on this track — nothing more. It says the
16777
- * detail plane produced a `face` detail; it does NOT say the face was
16778
- * embedded, matched, above `minFacePx`, or that the recognizer was even
16779
- * enabled. Set once and never cleared.
16780
- *
16781
- * **This exists so "face present but not recognised" is expressible.** A
16782
- * recognised identity lands in `subLabel` (attributed to the face chain via
16783
- * `subLabelMeta.stepId`), so before this field a track with an unmatched face
16784
- * and a track with no face at all were byte-identical on the wire and no
16785
- * surface could tell them apart. The read is `hasFace === true && subLabel
16786
- * === undefined`.
16787
- *
16788
- * **Absent ≠ false.** Every row written before the column existed omits it,
16789
- * and so does every server that predates the field — a consumer must test
16790
- * `=== true` and render nothing otherwise, never infer "no face".
16720
+ * Process-local lazy frame. Valid only when caller and provider resolve
16721
+ * in the same execution-group process; split/cross-node callers use
16722
+ * `frame`/`image` inline compatibility instead.
16791
16723
  */
16792
- hasFace: boolean().optional(),
16724
+ frameRef: FrameRefSchema.optional(),
16793
16725
  /**
16794
- * This track has a face row IN THE GALLERY: a crop **and** an embedding — a
16795
- * face an operator could ASSIGN to an identity.
16796
- *
16797
- * The STRICT twin of {@link hasFace}, and the pair only earns its keep
16798
- * because the two disagree. `hasFace` is stamped at the TOP of the face
16799
- * branch, before every gate, and means no more than "a face detector produced
16800
- * a face detail". This one is stamped at the single moment the gallery row
16801
- * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
16802
- * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
16803
- * candidate gate, the imageless-track drop (no crop was ever captured) and
16804
- * the crop-store drop. Everything between the detector and that insert can
16805
- * legitimately refuse the face, so a flag written any earlier promises the
16806
- * operator something to assign and delivers nothing.
16807
- *
16808
- * **Independent of recognition.** A face collected but never auto-matched is
16809
- * still assignable — it is in fact the face an operator most wants to reach —
16810
- * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
16811
- * `subLabel`; this says only that the raw material exists.
16812
- *
16813
- * **Set once, never cleared.** A track that produced a gallery row produced
16814
- * one; deleting the row later is the gallery's business, not this flag's.
16815
- *
16816
- * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
16817
- * before the column omits it, and so does every server that predates the
16818
- * field. A consumer must test `=== true` and render nothing otherwise —
16819
- * never infer "no assignable face".
16726
+ * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
16727
+ * the decoded pixels live in. One more member of the one-of
16728
+ * frame/frameHandle/image/imageBase64/referenceImage group.
16820
16729
  */
16821
- hasEmbeddedFace: boolean().optional(),
16730
+ frameHandle: FrameHandleSchema.optional(),
16731
+ imageBase64: string().optional(),
16822
16732
  /**
16823
- * This subject CONTAINS a folded rider — a person the rider-pairing step
16824
- * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
16825
- * so the passage is tracked once and as a VEHICLE.
16826
- *
16827
- * It exists because the fold's record was dishonest. D34 and the code both
16828
- * said "the person is not lost — it is reported so both entities stay on the
16829
- * record"; in fact the pair went into a per-processor RAM field behind an
16830
- * accessor nobody called, and every durable surface said `vehicle`, full
16831
- * stop. This is the composition note that makes the row true.
16832
- *
16833
- * A COMPOSITION, never a class and never a label. "This vehicle contains a
16834
- * person" is not an answer to "what is this" — both label tiers would refuse
16835
- * a macro token anyway (D89), and correctly. Nothing here changes what the
16836
- * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
16837
- * and a `person` rule still does not fire for someone cycling past.
16838
- *
16839
- * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
16840
- * the column, and every hub that predates the field, omits it. Test
16841
- * `=== true` and render nothing otherwise — never infer "no rider".
16733
+ * Binary JPEG bytes — preferred over `imageBase64` on internal
16734
+ * hops (hub → forked worker via Moleculer MsgPack) because it
16735
+ * skips the 33% base64 overhead + the per-call base64 decode on
16736
+ * the detection-pipeline worker. Callers can pass either; exactly
16737
+ * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
16842
16738
  */
16843
- hasRider: boolean().optional(),
16844
- ...TrackFlagFields,
16845
- ...TrackRetrainFields
16846
- });
16847
- var BaseEventFields = {
16848
- id: string(),
16849
- deviceId: number(),
16850
- timestamp: number()
16851
- };
16852
- var MotionEventSchema = object({
16853
- ...BaseEventFields,
16854
- kind: literal("motion"),
16855
- regionCount: number(),
16856
- /** Heavy JSON array — omitted in slim projection. */
16857
- regions: array(object({
16858
- bbox: BoundingBoxSchema,
16859
- pixelCount: number(),
16860
- intensity: number()
16861
- })).readonly().optional(),
16862
- /** Omitted in slim projection. */
16863
- frameWidth: number().optional(),
16864
- /** Omitted in slim projection. */
16865
- frameHeight: number().optional(),
16866
- /** Populated by B5 (recording playback URL for this event). */
16867
- mediaUrl: string().optional()
16868
- });
16739
+ image: _instanceof(Uint8Array).optional(),
16740
+ referenceImage: string().optional(),
16741
+ deviceId: number().optional(),
16742
+ sessionId: string().optional(),
16743
+ /**
16744
+ * Execution plane. 'full' (default) runs the whole tree — benchmark,
16745
+ * reference-image, and detail-subtree calls. 'frame' is the live
16746
+ * per-frame dispatch: ONLY root-plane steps run; crop children
16747
+ * (inputClasses ≠ null) are skipped and served per-track via
16748
+ * pipelineRunner.runDetailSubtree (two-plane design).
16749
+ */
16750
+ plane: _enum(["full", "frame"]).optional(),
16751
+ /**
16752
+ * Inference-device selector (Phase 2 multi-device). Format
16753
+ * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
16754
+ * Omitted ⇒ the runner's default device (current single-engine
16755
+ * behaviour). Selects WHICH device pool of the node runs the call.
16756
+ */
16757
+ deviceKey: string().optional(),
16758
+ /**
16759
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
16760
+ * when the parent crop was resolved from the frame's retained NATIVE
16761
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
16762
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
16763
+ * resolution from that surface — the SAME quality path faces already
16764
+ * had — instead of the downscaled parent tile. `handle` keys the native
16765
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
16766
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
16767
+ * the executor's crop-normalized child ROI back into frame-normalized
16768
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
16769
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
16770
+ * (today's behaviour on the fallback path).
16771
+ */
16772
+ nativeCropRef: NativeCropRefSchema.optional()
16773
+ }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
16774
+ engine: PipelineEngineChoiceSchema.optional(),
16775
+ steps: array(PipelineStepInputSchema).min(1),
16776
+ frames: array(FrameInputSchema).min(1).max(255),
16777
+ deviceId: number().optional(),
16778
+ sessionId: string().optional(),
16779
+ /**
16780
+ * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
16781
+ * the batch to the Python pool's bench preprocess cache
16782
+ * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
16783
+ * preprocessed ONCE and every later inference is a pure-inference cache
16784
+ * hit — the sustained-throughput run measures inference, not
16785
+ * decode+preprocess+infer. Omitted/0 for live frames (all different →
16786
+ * full preprocess every call, correct). Fresh per sustained run;
16787
+ * released via `uncacheFrame`.
16788
+ */
16789
+ frameId: number().int().nonnegative().optional(),
16790
+ /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
16791
+ deviceKey: string().optional()
16792
+ }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
16793
+ data: _instanceof(Uint8Array),
16794
+ width: number().int().positive(),
16795
+ height: number().int().positive(),
16796
+ format: _enum([
16797
+ "rgb",
16798
+ "bgr",
16799
+ "gray"
16800
+ ])
16801
+ }), object({
16802
+ frameId: number(),
16803
+ width: number(),
16804
+ height: number()
16805
+ }), { kind: "mutation" }), method(object({
16806
+ stepId: string(),
16807
+ frameId: number().int()
16808
+ }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
16809
+ batchMode: string(),
16810
+ windowMs: number(),
16811
+ maxBatchSize: number(),
16812
+ concurrency: number()
16813
+ })), method(_void(), array(object({
16814
+ engineKey: string(),
16815
+ engine: PipelineEngineChoiceSchema,
16816
+ modelsLoaded: array(string()).readonly(),
16817
+ inUseByCameras: array(number()).readonly(),
16818
+ /**
16819
+ * Origin of this resident factory.
16820
+ * - `runtime` — main camera-serving engine (no idle TTL).
16821
+ * - `warm-override` — benchmark/test override held in the warm
16822
+ * cache; auto-disposed after the idle TTL.
16823
+ * - `device-pool` — a concurrent per-device pool (Phase 2
16824
+ * multi-device, keyed by `deviceKey`) resolved
16825
+ * via `resolveDeviceFactory`. Runs alongside the
16826
+ * `runtime` engine on a DIFFERENT accelerator
16827
+ * (NPU / iGPU / Coral) — this is how the
16828
+ * Engines tab shows all pools running at once.
16829
+ */
16830
+ kind: _enum([
16831
+ "runtime",
16832
+ "warm-override",
16833
+ "device-pool"
16834
+ ]),
16835
+ /** Native pid of the underlying Python pool (null when no pool). */
16836
+ poolPid: number().nullable(),
16837
+ /** ms since this factory was last used (null when not warm-tracked). */
16838
+ idleMs: number().nullable(),
16839
+ /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
16840
+ idleTtlMs: number().nullable()
16841
+ })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
16842
+ kind: "mutation",
16843
+ auth: "admin"
16844
+ }), method(object({
16845
+ engine: PipelineEngineChoiceSchema,
16846
+ force: boolean().optional()
16847
+ }), object({
16848
+ success: boolean(),
16849
+ reason: string().optional()
16850
+ }), {
16851
+ kind: "mutation",
16852
+ auth: "admin"
16853
+ }), 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({
16854
+ addonId: string(),
16855
+ modelId: string(),
16856
+ filename: string().optional(),
16857
+ settings: record(string(), unknown()).optional()
16858
+ }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
16869
16859
  /**
16870
- * Which detection SOURCE produced an object event. `pipeline` = the ML
16871
- * detection pipeline (decoded-frame inference); `onboard` = the camera's
16872
- * native on-device AI. Both flow through the SAME analysis layers (zoning,
16873
- * tracking, per-kind persistence) but stay distinguishable so consumers
16874
- * (advanced-notifier, occupancy, …) can select which source(s) to act on.
16875
- * Absent on legacy rows ⇒ treat as `pipeline`.
16860
+ * Per-stage gating mode applied to the zones a rule references.
16861
+ *
16862
+ * - `include`: the rule contributes to a **whitelist** for its stage.
16863
+ * When at least one `include` rule fires for a stage, only entities
16864
+ * inside one of those zones pass that stage.
16865
+ * - `exclude`: the rule contributes to a **blacklist** for its stage.
16866
+ * Entities inside one of those zones are dropped at that stage.
16867
+ *
16868
+ * `monitor`-style observation (count without filtering) is not a rule
16869
+ * mode — zones without any matching rule are observed naturally by
16870
+ * `zone-analytics` (live snapshot + history), so an "I just want to
16871
+ * count, not filter" use case needs no rule at all.
16876
16872
  */
16877
- var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
16873
+ var ZoneRuleModeEnum = _enum(["include", "exclude"]);
16878
16874
  /**
16879
- * The confirmed zone crossing that produced an object event. Present ONLY on
16880
- * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
16881
- * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
16882
- * appearance event carry none, so a rule asking for a direction fails closed
16883
- * on them.
16875
+ * Per-consumer rule that references existing zones (geometry) and
16876
+ * defines how a specific pipeline stage should treat them. Each
16877
+ * consumer addon owns its own `ZoneRule[]` array in its per-device
16878
+ * settings:
16884
16879
  *
16885
- * Exactly ONE crossing per event: the emitter turns each confirmed crossing
16886
- * into its own event, so a frame in which a track enters A while leaving B
16887
- * produces two events with two directions — never one ambiguous row.
16880
+ * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
16881
+ * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
16882
+ * - future: notification rules, audio gating, etc.
16888
16883
  *
16889
- * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
16890
- * membership the box has NOW, and by definition it no longer contains the zone
16891
- * that was just left. Without the id here, a zone-scoped rule could never match
16892
- * the exit it asked for.
16884
+ * One rule applies to N zones (`zoneIds[]`) so the operator can
16885
+ * express "ignore motion in ALL of {garden, street}" with a single
16886
+ * rule. `classFilter` narrows the rule to specific object classes —
16887
+ * "drop person detections in the street, but keep cars" is one
16888
+ * `exclude` rule with `classFilter: ['person']`.
16889
+ *
16890
+ * `enabled` is a soft toggle — the operator can keep the rule
16891
+ * configured but inert without deleting it.
16893
16892
  */
16894
- var ZoneCrossingSchema = object({
16895
- direction: _enum(["enter", "exit"]),
16896
- /** Admin zone id crossed. */
16897
- zoneId: string(),
16898
- /** Zone display name at crossing time (falls back to the id). */
16899
- zoneName: string().optional()
16900
- });
16901
- var ObjectEventSchema = object({
16902
- ...BaseEventFields,
16903
- kind: literal("object"),
16904
- /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
16905
- source: DetectionSourceSchema.optional(),
16893
+ var ZoneRuleSchema = object({
16894
+ /** Stable rule id — survives edits, used by the UI for diffing. */
16895
+ id: string(),
16896
+ /** Optional human-readable label rendered in the rule editor. */
16897
+ name: string().optional(),
16898
+ /** Zones this rule targets. The rule's `mode` applies to ALL
16899
+ * listed zones (OR-set: a detection in any one of them counts).
16900
+ * At least one zone id required — a rule with no targets is a
16901
+ * configuration mistake and the form validator rejects it. */
16902
+ zoneIds: array(string()).min(1).readonly(),
16903
+ mode: ZoneRuleModeEnum,
16906
16904
  /**
16907
- * Inference-frame id shared by every object event emitted from the SAME frame
16908
- * — the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
16909
- * 2 people + 1 dog) under one full frame, and link a track's frames over time
16910
- * (group by `trackId`, pick a representative `frameId` as the parent frame).
16911
- * Optional for backward-compat with pre-existing rows / the slim projection
16912
- * includes it (it is light). Absent on rows written before this field.
16905
+ * Class names this rule applies to. Empty / undefined ⇒ rule
16906
+ * applies to every class. Class strings match the `macroClass`
16907
+ * field on detections (e.g. `person`, `car`, `dog`).
16913
16908
  */
16914
- frameId: string().optional(),
16915
- /** Omitted in slim projection. */
16916
- trackId: string().optional(),
16917
- className: string(),
16918
- ...TieredLabelFields,
16919
- /** Omitted in slim projection. */
16920
- confidence: number().optional(),
16921
- /** Heavy JSON — omitted in slim projection. */
16922
- bbox: BoundingBoxSchema.optional(),
16923
- /** Heavy JSON — omitted in slim projection. */
16924
- zones: array(string()).readonly().optional(),
16925
- /** Omitted in slim projection. */
16926
- state: TrackStateSchema.optional(),
16909
+ classFilter: array(string()).readonly().optional(),
16927
16910
  /**
16928
- * The zone crossing this event IS, when it is one. Absent on every other
16929
- * event kind (movement state, appearance, package) — see
16930
- * {@link ZoneCrossingSchema}. Omitted in slim projection.
16911
+ * Minimum bbox/mask overlap (0–1) with any of the rule's zones
16912
+ * required to consider an entity "in the zone". Defaults to the
16913
+ * consumer's stage default when omitted. Kept for back-compat with
16914
+ * existing per-rule overrides; new operators pick the value via
16915
+ * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
16916
+ * set, the lower-level engine reads it as a 0–1 fraction.
16931
16917
  */
16932
- zoneCrossing: ZoneCrossingSchema.optional(),
16933
- /** Detection-frame dimensions in pixels — let consumers normalize the
16934
- * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
16935
- frameWidth: number().optional(),
16936
- frameHeight: number().optional(),
16937
- /** MediaStore key for the crop attached to this event (if any). */
16938
- mediaKey: string().optional(),
16939
- /** Design B: MediaStore key of the track's native-resolution key frame (the
16940
- * best-detection full frame). Resolve via the event-media data-plane
16941
- * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
16942
- * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
16943
- * sources — consumers fall back to `mediaKey` (the tight crop). */
16944
- keyFrameMediaKey: string().optional(),
16945
- /** Populated by B5 (recording playback URL for this event). */
16946
- mediaUrl: string().optional(),
16947
- /** The parent track's key-event importance [0,1], propagated to every object
16948
- * event of the track (so an event row can be sorted by importance without a
16949
- * track join). Absent on legacy rows / before the track was scored. */
16950
- importance: number().optional()
16918
+ overlapThreshold: number().min(0).max(1).optional(),
16919
+ /**
16920
+ * Operator-friendly version of `overlapThreshold` — the percentage
16921
+ * of the detection's bbox that must lie inside the zone for the
16922
+ * rule to match. Documented default is 85%; the engine substitutes
16923
+ * that when the field is omitted (kept optional so existing rules
16924
+ * stored without it stay valid).
16925
+ *
16926
+ * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
16927
+ * rule, the engine prefers `bboxInclusionPct` because it's the
16928
+ * field exposed in the UI. Internally both feed the same gate.
16929
+ */
16930
+ bboxInclusionPct: number().min(0).max(100).optional(),
16931
+ /**
16932
+ * When `true` and a detection has a segmentation mask, use the
16933
+ * mask for overlap instead of the bbox. Detection-stage only;
16934
+ * motion rules ignore this field.
16935
+ */
16936
+ preferMask: boolean().optional(),
16937
+ /**
16938
+ * Soft-toggle: `false` disables the rule without deleting it.
16939
+ * Defaults to `true` so operators creating a rule via the UI
16940
+ * see it active immediately.
16941
+ */
16942
+ enabled: boolean().default(true)
16951
16943
  });
16952
- var AudioEventSchema = object({
16953
- ...BaseEventFields,
16954
- kind: literal("audio"),
16955
- rms: number(),
16956
- dbfs: number(),
16957
- classification: object({
16958
- className: string(),
16959
- originalClass: string().optional(),
16960
- score: number()
16961
- }).optional(),
16962
- /** Populated by B5 (recording playback URL for this event). */
16963
- mediaUrl: string().optional()
16944
+ array(ZoneRuleSchema).readonly();
16945
+ /**
16946
+ * Zone — pure geometry + identity. NO filtering behaviour.
16947
+ *
16948
+ * Zones describe **where** in the frame the operator wants to flag
16949
+ * something; consumer-owned {@link ZoneRule} arrays describe **how**
16950
+ * each pipeline stage uses them. Splitting the two means a single
16951
+ * polygon "Driveway" can simultaneously back a motion-exclude rule,
16952
+ * a detection-include rule on `['car']`, and an occupancy aggregate
16953
+ * — without three duplicated polygons.
16954
+ *
16955
+ * Owned by the orchestrator addon (provider) and mirrored into the
16956
+ * `zones` device-state slice on every mutation. Consumers
16957
+ * (motion-wasm, pipeline-executor, analytics, admin UI) read either
16958
+ * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
16959
+ * mirror with `onChanged`).
16960
+ *
16961
+ * Coordinates are normalised fractions of the frame (0–1) so zones
16962
+ * survive resolution changes and stream profile switches.
16963
+ *
16964
+ * `kind` discriminates between full polygons (closed regions used
16965
+ * for intrusion / occupancy filters) and tripwires (open 2-point
16966
+ * line segments used for cross events). Onboard / firmware-reported
16967
+ * zones (Reolink, ONVIF) are out of scope for now — see the deferred
16968
+ * task list.
16969
+ */
16970
+ var ZoneKindEnum = _enum(["polygon", "tripwire"]);
16971
+ /** Polygon vertex in fraction-of-frame coordinates (0–1). */
16972
+ var PolygonPointSchema = object({
16973
+ x: number(),
16974
+ y: number()
16964
16975
  });
16965
- var MediaFileKindEnum = _enum([
16966
- "crop",
16967
- "thumbnail",
16968
- "snapshot",
16969
- "firstFrame",
16970
- "lastFrame",
16971
- "fullFrame",
16972
- "fullFrameBoxed",
16973
- "faceCrop",
16974
- "plateCrop",
16975
- "keyFrame",
16976
- "keyFrameSmall",
16977
- "thumbnailSmall"
16978
- ]);
16979
- var MediaFileSchema = object({
16980
- key: string(),
16981
- kind: MediaFileKindEnum,
16982
- base64: string(),
16983
- sizeBytes: number(),
16984
- timestamp: number()
16976
+ /** A camera detection zone — pure geometry/identity. */
16977
+ var ZoneSchema = object({
16978
+ id: string(),
16979
+ name: string(),
16980
+ kind: ZoneKindEnum.default("polygon"),
16981
+ /** Polygon vertices, fraction of frame (0–1). */
16982
+ polygon: array(PolygonPointSchema).readonly(),
16983
+ /** Visual color for UI rendering. */
16984
+ color: string().default("#3b82f6")
16985
16985
  });
16986
16986
  /**
16987
- * One media row WITHOUT its bytes.
16987
+ * Zones capability — per-camera CRUD over polygon detection zones.
16988
16988
  *
16989
- * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
16990
- * 140 s track), and a client that renders tiles from the media data plane needs
16991
- * to know only WHAT EXISTS — the bytes then arrive per tile, lazily, over HTTP
16992
- * with an immutable cache, instead of all at once inside a tRPC response that
16993
- * blocks the whole view.
16989
+ * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
16990
+ * to per-device settings and mirrors into the `zones` device-state
16991
+ * slice on every mutation, so downstream consumers can subscribe via
16992
+ * `dev.state.zones.onChanged`.
16994
16993
  *
16995
- * `sizeBytes` is carried because it is what lets a client decide between the
16996
- * stored blob and a `?variant=thumb` rendering without fetching either.
16994
+ * The cap surface only handles geometry + identity; filtering
16995
+ * behaviour (per-class, include/exclude, threshold) lives in the
16996
+ * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
16997
+ * `capabilities/schemas/zone-rule.js`.
16997
16998
  */
16998
- var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
16999
+ var zonesCapability = {
17000
+ name: "zones",
17001
+ scope: "device",
17002
+ mode: "singleton",
17003
+ deviceTypes: [DeviceType.Camera],
17004
+ methods: {
17005
+ listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
17006
+ addZone: method(object({
17007
+ deviceId: number(),
17008
+ zone: ZoneSchema
17009
+ }), _void(), {
17010
+ kind: "mutation",
17011
+ auth: "admin"
17012
+ }),
17013
+ removeZone: method(object({
17014
+ deviceId: number(),
17015
+ zoneId: string()
17016
+ }), _void(), {
17017
+ kind: "mutation",
17018
+ auth: "admin"
17019
+ }),
17020
+ updateZone: method(object({
17021
+ deviceId: number(),
17022
+ zone: ZoneSchema
17023
+ }), _void(), {
17024
+ kind: "mutation",
17025
+ auth: "admin"
17026
+ })
17027
+ },
17028
+ /**
17029
+ * Runtime-state slice — the live zone catalogue mirrored by the
17030
+ * orchestrator on every CRUD mutation. Consumers read via
17031
+ * `device.state.zones.value` / `.watch(...)` without round-tripping
17032
+ * the cap, and the codegen DeviceProxy auto-wires the reactive
17033
+ * handle. Slice shape is `{ zones: Zone[] }` so future extensions
17034
+ * (e.g. zone groupings) can sit alongside the polygon list.
17035
+ */
17036
+ runtimeState: object({ zones: array(ZoneSchema).readonly() }),
17037
+ /**
17038
+ * 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.
17039
+ *
17040
+ * See `RuntimeStateDurability`. Enforced by
17041
+ * `scripts/check-runtime-state-durability.ts`.
17042
+ */
17043
+ durability: "restored"
17044
+ };
16999
17045
  /**
17000
- * The MACRO tier of an annotation — a CLOSED set.
17046
+ * pipeline-analytics — device-scoped wrapper cap. Refines raw
17047
+ * per-frame detections emitted by the pipeline runner into tracked
17048
+ * objects, per-kind event collections (motion / object / audio), and
17049
+ * persisted media. Owns the post-detection domain end-to-end:
17001
17050
  *
17002
- * This is what the exported detector predicts, so a typo here is a new class
17003
- * with one example in it. `label` and `subLabel` are open strings by contrast:
17004
- * the whole point of the page is teaching the model things it does not know
17005
- * yet, and constraining that vocabulary would make it useless.
17051
+ * runner emits PipelineInferenceResult
17052
+ * ↓ (event bus)
17053
+ * pipeline-analytics subscriber
17054
+ * ↓ SORT tracker + zone engine + state analyzer + event emitter
17055
+ * → three DB collections (one per kind), one FS media tree, one
17056
+ * unified event emitter (FrameTracked + TrackStarted/Ended +
17057
+ * DetectionEvent on bus)
17006
17058
  *
17007
- * A macro class is NEVER a label. The provider refuses a write whose `label` or
17008
- * `subLabel` is one of these values, in any casing, because once `person`
17009
- * exists in both tiers "every person box" stops being answerable without
17010
- * knowing every string anyone ever typed — and the damage is retroactive.
17059
+ * Pure subscriber model. No `processFrame` cap method — the runner
17060
+ * already publishes the raw frame on the bus. The cap surface is
17061
+ * only QUERIES + per-device settings, bound on/off via
17062
+ * `device-manager.setWrapperActive`. `defaultActive: true` because
17063
+ * every camera with a detection pipeline wants its raw detections
17064
+ * refined; operators opt out per-device via BindingsTab when needed.
17065
+ *
17066
+ * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
17067
+ * (per-device surface) and `track-trail` caps — see P11 cleanup.
17011
17068
  */
17012
- var RetrainMacroClassSchema = _enum([
17069
+ var TrackStateSchema = _enum([
17070
+ "new",
17071
+ "entered",
17072
+ "left",
17073
+ "moving",
17074
+ "idle"
17075
+ ]);
17076
+ var EventKindSchema = _enum([
17077
+ "motion",
17078
+ "object",
17079
+ "audio"
17080
+ ]);
17081
+ /**
17082
+ * Spatial filter for `listTracks` — the rect + polygon variants of the shared
17083
+ * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
17084
+ * of the camera frame (top-left origin), matching the drawing-plane editor.
17085
+ */
17086
+ var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
17087
+ /** Closed icon vocabulary so clients render a known glyph per kind. */
17088
+ var EventKindIconSchema = _enum([
17089
+ "motion",
17090
+ "audio",
17013
17091
  "person",
17014
17092
  "vehicle",
17015
17093
  "animal",
17094
+ "door",
17095
+ "pir",
17096
+ "smoke",
17097
+ "water",
17098
+ "button",
17016
17099
  "package",
17017
- "face",
17018
- "plate"
17100
+ "generic"
17019
17101
  ]);
17020
- /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
17021
- var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
17022
- /** Did a human draw this box, or did the assist propose it? */
17023
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
17024
- /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
17025
- var RetrainBboxSchema = object({
17026
- x: number(),
17027
- y: number(),
17028
- w: number(),
17029
- h: number()
17102
+ var EventKindCategorySchema = _enum([
17103
+ "motion",
17104
+ "audio",
17105
+ "detection",
17106
+ "sensor",
17107
+ "control",
17108
+ "custom",
17109
+ "package"
17110
+ ]);
17111
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
17112
+ var EventKindLevelSchema = _enum(["macro", "sub"]);
17113
+ var EventKindDescriptorSchema = object({
17114
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
17115
+ kind: string(),
17116
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
17117
+ labelKey: string(),
17118
+ /** English fallback label (kept for clients that don't translate). */
17119
+ label: string(),
17120
+ /** Hex color for timeline/legend rendering. */
17121
+ color: string(),
17122
+ /** Dictionary id → lucide component on the UI side. */
17123
+ iconId: string(),
17124
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
17125
+ icon: EventKindIconSchema,
17126
+ category: EventKindCategorySchema,
17127
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
17128
+ parentKind: string().nullable(),
17129
+ /** Derived from `parentKind`, explicit for the client tree. */
17130
+ level: EventKindLevelSchema,
17131
+ /** Which cap + device contributes this kind. For built-ins the camera
17132
+ * itself; for sensor kinds the LINKED source device. */
17133
+ source: object({
17134
+ capName: string(),
17135
+ deviceId: number()
17136
+ })
17030
17137
  });
17031
- /**
17032
- * One annotated subject.
17033
- *
17034
- * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
17035
- * (letterboxed root / zone-cropped package / subject-cropped classifier) are
17036
- * derived from it at export and never stored — storing them is how one feature
17037
- * space ends up holding two crops of the same subject (D52).
17038
- */
17039
- var RetrainAnnotationSchema = object({
17040
- id: string(),
17041
- trackId: string(),
17138
+ /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
17139
+ var EventKindsForDeviceSchema = object({
17042
17140
  deviceId: number(),
17043
- /** The COPY in retrain storage — never the source track's media key. */
17044
- mediaKey: string(),
17045
- bbox: RetrainBboxSchema,
17046
- macroClass: RetrainMacroClassSchema,
17047
- label: string().optional(),
17048
- subLabel: string().optional(),
17049
- kind: RetrainAnnotationKindSchema,
17050
- source: RetrainAnnotationSourceSchema,
17051
- /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
17052
- assistModelId: string().optional(),
17053
- assistScore: number().optional(),
17054
- exportedInBatch: string().optional(),
17055
- createdAt: number()
17056
- });
17057
- /** The write form — the server owns `id`, `createdAt` and the frame binding. */
17058
- var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
17059
- id: true,
17060
- trackId: true,
17061
- deviceId: true,
17062
- mediaKey: true,
17063
- createdAt: true,
17064
- exportedInBatch: true
17141
+ kinds: array(EventKindDescriptorSchema).readonly()
17065
17142
  });
17066
- /** A track sitting in `staging`, with everything the worklist needs to rank it. */
17067
- var RetrainTrackSchema = object({
17068
- trackId: string(),
17143
+ var SensorEventSchema = object({
17144
+ id: string(),
17145
+ /** The CAMERA the event is attributed to (a sensor linked to N cameras
17146
+ * yields N rows, one per camera). */
17069
17147
  deviceId: number(),
17070
- className: string(),
17071
- label: string().optional(),
17072
- firstSeen: number(),
17073
- lastSeen: number(),
17074
- /** How many frames the dataset already holds from this track. */
17075
- frameCount: number().int(),
17076
- /** How many subjects have been annotated on those frames. `0` with
17077
- * `frameCount: 0` is exactly "staging, still to work". */
17078
- annotationCount: number().int()
17148
+ /** The linked sensor device whose state changed. */
17149
+ sourceDeviceId: number(),
17150
+ /** Event kind id — matches an `EventKindDescriptor.kind`. */
17151
+ kind: string(),
17152
+ /** Snapshot of the sensor cap's runtime-state slice at the change. */
17153
+ value: record(string(), unknown()).nullable(),
17154
+ timestamp: number()
17079
17155
  });
17080
- /** A frame the picker may offer — an index row, no blob was read to produce it. */
17081
- var RetrainFrameCandidateSchema = object({
17082
- mediaKey: string(),
17083
- kind: MediaFileKindEnum,
17156
+ var TrackPositionSchema = object({
17157
+ x: number(),
17158
+ y: number(),
17084
17159
  timestamp: number(),
17085
- sizeBytes: number().int(),
17086
- /** A copy of this original already exists — selecting it is free and cannot
17087
- * fail, whatever became of the original. */
17088
- copied: boolean()
17089
- });
17090
- /** A frame the dataset OWNS: bytes copied at selection time. */
17091
- var RetrainFrameSchema = object({
17092
- frameId: string(),
17093
- deviceId: number(),
17094
- trackId: string(),
17095
- /** Provenance only. It may already point at nothing — that is expected. */
17096
- sourceMediaKey: string(),
17097
- sourceKind: MediaFileKindEnum,
17098
- sizeBytes: number().int(),
17099
- width: number().int(),
17100
- height: number().int(),
17101
- copiedAt: number()
17102
- });
17103
- /** Why a copy-on-select could not be honoured — named, never a silent skip. */
17104
- var RetrainCopyRefusalSchema = _enum([
17105
- "source-missing",
17106
- "unreadable-image",
17107
- "write-failed"
17108
- ]);
17109
- var RetrainFrameSelectionSchema = object({
17110
- copied: array(RetrainFrameSchema).readonly(),
17111
- refused: array(object({
17112
- sourceMediaKey: string(),
17113
- reason: RetrainCopyRefusalSchema
17114
- })).readonly()
17160
+ bbox: BoundingBoxSchema
17115
17161
  });
17116
- var RetrainFrameListSchema = object({
17117
- candidates: array(RetrainFrameCandidateSchema).readonly(),
17118
- copies: array(RetrainFrameSchema).readonly(),
17119
- /** What the page pre-selects — the native key frame when one survives. */
17120
- autoPickMediaKey: string().optional()
17162
+ var TrackSnapshotSchema = object({
17163
+ timestamp: number(),
17164
+ position: TrackPositionSchema,
17165
+ /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
17166
+ mediaKey: string()
17121
17167
  });
17122
- /** What the operator asked the assist to look for. */
17123
- var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
17124
- kind: literal("package"),
17125
- zone: RetrainBboxSchema.optional()
17126
- }), object({
17127
- kind: literal("objects"),
17128
- modelId: string(),
17129
- minScore: number().optional()
17130
- })]);
17131
17168
  /**
17132
- * The assist's answer — a discriminated union, because "the model saw nothing"
17133
- * and "this node cannot run that model" lead to different next moves and a
17134
- * nullable result cannot tell them apart.
17169
+ * Normalized 0..1 trajectory envelope (min/max over every position bbox,
17170
+ * divided by the track's detection-frame dims), computed at persist time.
17171
+ * Absent when the frame dims were unknown when the track was persisted
17172
+ * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
17135
17173
  */
17136
- var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
17137
- kind: literal("proposed"),
17138
- modelId: string(),
17139
- stepId: string(),
17140
- minScore: number(),
17141
- /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
17142
- proposals: array(RetrainAnnotationDraftSchema).readonly(),
17143
- /** Returned by the runner but removed by the threshold. */
17144
- belowThreshold: number().int()
17145
- }), object({
17146
- kind: literal("refused"),
17147
- /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
17148
- reason: string(),
17149
- detail: string().optional()
17150
- })]);
17151
- /** The outcome of a lifecycle move owned by the retrain page. */
17152
- var RetrainTransitionResultSchema = object({
17153
- trackId: string(),
17154
- /** Where the track ended up, whatever happened. */
17155
- retrainStatus: RetrainStatusSchema,
17156
- /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
17157
- changed: boolean(),
17158
- reason: _enum([
17159
- "unknown-track",
17160
- "no-frames-copied",
17161
- "not-staging",
17162
- "not-trained",
17163
- "unchanged"
17164
- ]).optional()
17174
+ var TrackEnvelopeSchema = object({
17175
+ minX: number(),
17176
+ minY: number(),
17177
+ maxX: number(),
17178
+ maxY: number()
17165
17179
  });
17166
- var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
17167
- var MAX_EVENT_QUERY_LIMIT = 5e3;
17168
- var DeviceEventQueryInput = object({
17169
- deviceId: number(),
17170
- since: number().optional(),
17171
- until: number().optional(),
17172
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
17173
- /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
17174
- * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
17175
- * exact behaviour. Callers may omit this field — the store defaults to
17176
- * `full` when not provided. */
17177
- projection: _enum(["full", "slim"]).optional()
17178
- });
17179
- var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
17180
- var RecentTracksQueryInput = object({
17181
- /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
17182
- deviceIds: array(number()),
17183
- /** Window lower bound on `lastSeen` (inclusive). */
17184
- since: number().optional(),
17185
- /** Window upper bound on `lastSeen` (inclusive). */
17186
- until: number().optional(),
17187
- /** Page size. Default 200, max 1000. */
17188
- limit: number().int().min(1).max(1e3).default(200),
17189
- /** Opaque continuation cursor from a previous page's `nextCursor`.
17190
- * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
17191
- cursor: string().optional(),
17192
- /** See {@link TrackProjectionSchema}. Default `full`. */
17193
- projection: TrackProjectionSchema.optional(),
17194
- /** Include stationary-promoted rows (parked objects). Default false: the
17195
- * feed lists passages; parking records live on the stationary registry. */
17196
- includeStationary: boolean().optional()
17197
- });
17198
- var RecentTracksPageSchema = object({
17199
- /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
17200
- tracks: array(TrackSchema).readonly(),
17201
- /** Cursor for the next page, or null when this page is the last. */
17202
- nextCursor: string().nullable()
17203
- });
17204
- var LIST_GROUPS_DEFAULT_LIMIT = 40;
17205
- var LIST_GROUPS_MAX_LIMIT = 100;
17206
- var AnalyticsGroupRecordSchema = object({
17207
- id: string(),
17208
- deviceId: number().int(),
17209
- openedAt: number().int(),
17210
- closedAt: number().int(),
17211
- timestamp: number().int(),
17212
- memberCount: number().int(),
17213
- memberTrackIds: array(string()).readonly(),
17214
- className: string(),
17215
- classes: array(string()).readonly(),
17216
- /** Relative event-media path, or null when the group has no picture yet. */
17217
- mediaUrl: string().nullable(),
17218
- singleton: boolean()
17219
- });
17220
- var AnalyticsGroupMemberSchema = object({
17221
- trackId: string(),
17222
- deviceId: number().int(),
17223
- className: string(),
17224
- firstSeen: number().int(),
17225
- lastSeen: number().int(),
17226
- mediaUrl: string().nullable()
17227
- });
17228
- var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
17229
- var ListGroupsQueryInput = object({
17230
- /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
17231
- deviceIds: array(number()),
17232
- /** Window lower bound on `closedAt` (inclusive). */
17233
- since: number().optional(),
17234
- /** Window upper bound on `openedAt` (inclusive). */
17235
- until: number().optional(),
17236
- limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
17237
- /** Opaque continuation cursor from a previous page's `nextCursor`. */
17238
- cursor: string().optional()
17239
- });
17240
- var ListGroupsPageSchema = object({
17241
- groups: array(AnalyticsGroupRecordSchema).readonly(),
17242
- nextCursor: string().nullable()
17243
- });
17244
- var KeyEventQueryInput = object({
17245
- deviceId: number(),
17246
- /** Window lower bound (track firstSeen ≥ since). */
17247
- since: number(),
17248
- /** Window upper bound (track firstSeen ≤ until). */
17249
- until: number(),
17250
- limit: number().int().min(1).max(200).default(50),
17251
- /** Drop tracks scoring below this importance. */
17252
- minImportance: number().min(0).max(1).optional(),
17253
- /** Restrict to a single class (e.g. 'person'). */
17254
- classFilter: string().optional()
17255
- });
17256
- var KeyEventSchema = object({
17257
- /** The representative event id (the track's best ObjectEvent, else its trackId). */
17258
- id: string(),
17259
- trackId: string(),
17260
- /** Track start time (firstSeen). */
17261
- timestamp: number(),
17262
- className: string(),
17263
- ...TieredLabelFields,
17264
- importance: number(),
17265
- /** Highest-confidence ObjectEvent id for the track (empty when none). */
17266
- bestEventId: string(),
17267
- /** Track lifetime in ms (lastSeen - firstSeen). */
17268
- windowMs: number().optional(),
17269
- ...TrackFlagFields,
17270
- ...TrackRetrainFields
17271
- });
17272
- object({
17273
- trackId: string(),
17274
- className: string(),
17275
- confidence: number(),
17276
- bbox: BoundingBoxSchema,
17277
- zones: array(string()).readonly(),
17278
- state: TrackStateSchema
17279
- });
17280
- var OverlayDetectionSchema = looseObject({
17281
- id: string(),
17282
- kind: _enum(["first-level", "detail"]),
17283
- macroClass: string(),
17284
- score: number(),
17285
- bbox: object({
17286
- x: number(),
17287
- y: number(),
17288
- width: number(),
17289
- height: number()
17290
- }),
17291
- labels: array(looseObject({
17292
- label: string(),
17293
- score: number()
17294
- })).readonly(),
17295
- parentId: string().optional()
17296
- });
17297
- var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
17298
- var SearchObjectEventsInput = object({
17299
- text: string(),
17300
- deviceId: number().optional(),
17301
- since: number().optional(),
17302
- until: number().optional(),
17303
- classFilter: string().optional(),
17304
- limit: number().default(50),
17305
- minScore: number().min(0).max(1).default(.2)
17306
- });
17307
- var TrackCascadeCountsSchema = object({
17308
- /** Persisted track roots deleted (authoritative). */
17309
- tracks: number().int(),
17310
- /** Object events removed with their tracks (best-effort; see note above). */
17311
- events: number().int(),
17312
- /** Track/face/plate-owned media removed (best-effort). Never identity media. */
17313
- media: number().int(),
17314
- /** Unassigned (non-enrolled) face reads removed (best-effort). */
17315
- faces: number().int(),
17316
- /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
17317
- plates: number().int(),
17318
- /** Per-track CLIP search vectors removed (best-effort). */
17319
- embeddings: number().int(),
17320
- /** Group membership + group rows removed with their last member (best-effort). */
17321
- groups: number().int()
17322
- });
17323
- /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
17324
- var DiskReconcileCountsSchema = object({
17325
- mediaDropped: number().int(),
17326
- tracks: number().int(),
17327
- events: number().int()
17328
- });
17329
- /** Event-store footprint for one camera. */
17330
- var EventStoreDeviceFootprintSchema = object({
17331
- deviceId: number(),
17332
- /** Persisted event rows (motion + object + audio) for the camera. */
17333
- rows: number().int(),
17334
- /** Event-owned media bytes on disk for the camera. */
17335
- bytes: number().int()
17336
- });
17337
- /** Aggregate event-store footprint: global totals + per-camera breakdown. */
17338
- var EventStoreFootprintSchema = object({
17339
- totalRows: number().int(),
17340
- totalBytes: number().int(),
17341
- devices: array(EventStoreDeviceFootprintSchema).readonly()
17342
- });
17343
- /** Per-kind counts returned by the event-prune / device-delete mutations. */
17344
- var EventPruneCountsSchema = object({
17345
- motion: number().int(),
17346
- object: number().int(),
17347
- audio: number().int()
17180
+ /**
17181
+ * Row projection for track list queries. `full` (default) returns the
17182
+ * complete Track including the frame-rate `positions[]` history and the
17183
+ * `snapshots[]` references — megabytes across a page of tracks. `slim`
17184
+ * keeps every scalar the list surfaces actually render (ids, class(es),
17185
+ * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
17186
+ * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
17187
+ * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
17188
+ * `getTrack`. Mirrors the event-store `projection` convention
17189
+ * (`getObjectEvents` et al.).
17190
+ */
17191
+ var TrackProjectionSchema = _enum(["full", "slim"]);
17192
+ /**
17193
+ * One audio-classification label heard on the track's camera while the
17194
+ * track was alive, aggregated per label. An "episode" is one persisted
17195
+ * audio event (the confident-classification path: score ≥ the device's
17196
+ * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
17197
+ * one 32 ms inference chunk, so counts stay human-scaled.
17198
+ */
17199
+ var TrackAudioLabelSchema = object({
17200
+ label: string(),
17201
+ /** Highest classification score observed across the label's episodes. */
17202
+ peakScore: number(),
17203
+ /** Number of coalesced audio-event episodes carrying this label. */
17204
+ count: number(),
17205
+ firstAt: number(),
17206
+ lastAt: number()
17348
17207
  });
17349
17208
  /**
17350
- * Re-embed stored tracks from their key frames.
17209
+ * How a track was produced. `pipeline` (default / absent) = the spatial
17210
+ * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
17211
+ * no positions, a single snapshot, and no bbox trajectory at all:
17351
17212
  *
17352
- * The reason this is an operator-callable method and not a migration script:
17353
- * every knob that decides what a vector MEANS — encoder model, crop margin,
17354
- * squaring — is only changeable if the existing vectors can be regenerated.
17355
- * Mixing feature spaces in one index makes cosine scores incomparable, and the
17356
- * symptom is a quality regression with no visible cause.
17213
+ * - `sensor` — a linked sensor/control device state change.
17214
+ * - `audio` — an audio event on the camera itself that was anomalous for
17215
+ * THAT camera, loud, and heard while nothing visual was happening (D62).
17216
+ *
17217
+ * The spatial subsystems (tracker association, occupancy count, re-id /
17218
+ * embedding, resurrection) MUST skip every synthetic source. Test for that
17219
+ * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
17220
+ * check silently readmits every source added after it was written.
17357
17221
  */
17358
- var RebuildObjectEmbeddingsInput = object({
17359
- /** Restrict to one camera. Omit for the whole fleet. */
17360
- deviceId: number().optional(),
17361
- since: number().optional(),
17362
- until: number().optional(),
17363
- /** Stop after this many tracks; the result reports whether more remain. */
17364
- maxTracks: number().int().positive().optional(),
17365
- /**
17366
- * Run every embedding on THIS node instead of round-robining the fleet.
17367
- *
17368
- * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
17369
- * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
17370
- * calling it that would pin the rebuild REQUEST itself to that node — the
17371
- * rebuild orchestration lives on the hub, and only the per-track step runs
17372
- * remotely. This field is data; the per-track pin is applied inside.
17373
- *
17374
- * Absent ⇒ round-robin over every online node whose runner can serve the
17375
- * pinned model.
17376
- */
17377
- executeOnNodeId: string().optional(),
17378
- /**
17379
- * Milliseconds to wait between tracks; omit for the built-in default, `0` to
17380
- * run flat out.
17381
- *
17382
- * A rebuild is bulk maintenance on hub-main's single thread. Measured
17383
- * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
17384
- * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
17385
- * force is logged at start and finish so a deliberately slow pass reads
17386
- * differently from a stalled one.
17387
- */
17388
- pacingMs: number().int().nonnegative().optional()
17389
- });
17222
+ var TrackSourceSchema = _enum([
17223
+ "pipeline",
17224
+ "sensor",
17225
+ "audio"
17226
+ ]);
17390
17227
  /**
17391
- * Result of emptying the CLIP index.
17228
+ * Where a track sits in the RETRAIN lifecycle (D81).
17392
17229
  *
17393
- * The clean slate before a policy change: a new crop margin or encoder model
17394
- * leaves two feature spaces in one index whose cosine scores are not
17395
- * comparable, so wiping and rebuilding is the only way to be sure every vector
17396
- * means the same thing.
17230
+ * - `none` — never marked, or un-marked. Evictable.
17231
+ * - `staging` — the operator wants this track as training material and has not
17232
+ * finished with it. **This is the only state retention holds**: the track and
17233
+ * everything it owns (object events, crops, keyframes, CLIP vector) survive
17234
+ * the device's age window.
17235
+ * - `trained` — the retrain page has taken what it needed. The frames it chose
17236
+ * were COPIED into the retrain dataset at selection time, so the dataset no
17237
+ * longer depends on the track's media and the track becomes EVICTABLE again.
17238
+ * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
17239
+ * a deliberate action of the retrain page, not a side effect of a checkbox.
17240
+ *
17241
+ * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
17242
+ * the store's filter language has only positive equality and `whereIn` — no
17243
+ * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
17244
+ * would make the entire pre-column history immortal in one deploy.
17397
17245
  */
17398
- var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
17246
+ var RetrainStatusSchema = _enum([
17247
+ "none",
17248
+ "staging",
17249
+ "trained"
17250
+ ]);
17399
17251
  /**
17400
- * Acknowledgement that a rebuild STARTED.
17252
+ * Per-track OPERATOR flags — set by hand from the admin UI or the viewer, never
17253
+ * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
17254
+ * so the two surfaces cannot drift.
17401
17255
  *
17402
- * The pass costs ~1s per track — 45 minutes for a 2,600-track fleet — so it
17403
- * runs detached and this returns immediately. Waiting for it made the client
17404
- * time out while the work carried on server-side, which is the worst of both:
17405
- * no result and no way to know it was still going. Poll
17406
- * `getObjectEmbeddingRebuildStatus` for progress.
17407
- */
17408
- var RebuildObjectEmbeddingsResultSchema = object({
17409
- started: boolean(),
17410
- /** True when a pass was already running; the new request is ignored. */
17411
- alreadyRunning: boolean()
17412
- });
17413
- var RebuildStatusSchema = object({
17414
- running: boolean(),
17415
- scanned: number(),
17416
- rebuilt: number(),
17417
- /** Tracks whose key frame is gone — nothing to re-embed from. */
17418
- missingKeyFrame: number(),
17419
- /** Tracks with no usable detection box. */
17420
- missingBbox: number(),
17421
- /**
17422
- * Tracks an executing node REFUSED rather than broke on — an unreadable key
17423
- * frame, a step that threw. Separate from `failed` because the remedy is
17424
- * different, and because a whole camera silently contributing zero vectors
17425
- * is the shape of failure a rebuild must never hide.
17426
- */
17427
- notRunnable: number(),
17256
+ * **Absent ≠ false.** A track that has never been touched omits the field; an
17257
+ * explicitly un-flagged track carries `false`. Legacy rows written before the
17258
+ * columns existed read as absent, and a consumer that needs a boolean should say
17259
+ * `flag === true`, not `flag !== false`.
17260
+ *
17261
+ * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
17262
+ * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
17263
+ * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
17264
+ * `trained` track reports `false` while refusing both writes. The boolean is
17265
+ * kept because three surfaces drive a toggle off it; anything that needs to tell
17266
+ * "never marked" from "already trained" must read `retrainStatus`.
17267
+ *
17268
+ * `debug` does NOT pin; it is attention, not durability.
17269
+ *
17270
+ * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
17271
+ * A favourited track is skipped by retention the same way `staging` is, but
17272
+ * it does not enter `none|staging|trained` and has no staging budget.
17273
+ */
17274
+ var TrackFlagFields = {
17275
+ /** Operator marked this track as training material — i.e. `retrainStatus` is
17276
+ * `'staging'`. */
17277
+ markForTrain: boolean().optional(),
17278
+ /** Operator marked this track for diagnostic attention. */
17279
+ debug: boolean().optional(),
17280
+ /** Operator favourited this track. Pins it against pruning. */
17281
+ favourited: boolean().optional()
17282
+ };
17283
+ /**
17284
+ * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
17285
+ * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
17286
+ * write patch, and the status is not something the toggle sets — it is what the
17287
+ * toggle's boolean is derived from. Absent on an in-RAM track never touched;
17288
+ * always present on a persisted row (the column default materialises `'none'`).
17289
+ */
17290
+ var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
17291
+ /**
17292
+ * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
17293
+ * one flag can never clear the other — the toggles are independent and are
17294
+ * driven from three surfaces that do not know about each other.
17295
+ */
17296
+ var TrackFlagsPatchSchema = object(TrackFlagFields);
17297
+ /**
17298
+ * The resolved flag state after a write. Both fields are REQUIRED here (absent
17299
+ * collapses to `false`) so a caller can drive a toggle's checked state off the
17300
+ * mutation result without a re-fetch.
17301
+ */
17302
+ var TrackFlagsSchema = object({
17303
+ trackId: string(),
17304
+ markForTrain: boolean(),
17305
+ debug: boolean(),
17306
+ favourited: boolean(),
17307
+ /** The lifecycle state the boolean was derived from. Required here (unlike on
17308
+ * a track row) because this shape is only ever produced by the write body,
17309
+ * which always knows it — and a surface that has just written needs to render
17310
+ * `trained` without a re-fetch. */
17311
+ retrainStatus: RetrainStatusSchema
17312
+ });
17313
+ union([literal(1), literal(2)]);
17314
+ /**
17315
+ * WHO decided a label, and when. Carried per tier so a value can be traced to
17316
+ * the step and model that produced it — which is what makes the write rule
17317
+ * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
17318
+ * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
17319
+ *
17320
+ * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
17321
+ * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
17322
+ * `migration:4g` for a value the 4g migration moved from the single-slot era —
17323
+ * that value has no provenance, and the write rule lets ANY properly-attributed
17324
+ * write of the same tier replace it regardless of score.
17325
+ */
17326
+ var LabelAttributionSchema = object({
17327
+ stepId: string(),
17328
+ modelId: string().optional(),
17329
+ decidedAt: number(),
17428
17330
  /**
17429
- * The pass stopped because NO node could serve the pinned model.
17331
+ * The GALLERY id behind a recognised tier-2 label — a face-gallery
17332
+ * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
17430
17333
  *
17431
- * Distinct from `notRunnable` on purpose: that one says "this track was
17432
- * refused", this one says "the cluster cannot do this work at all" — every
17433
- * candidate node either lacks the `clip-embedding` step, lacks a build of the
17434
- * pinned model for its engine format, or dropped out. The remedy is a model /
17435
- * engine change, not a per-camera one. Non-zero here always comes with
17436
- * `complete: false`.
17334
+ * The text alone is a DISPLAY NAME, and a display name is renameable: a
17335
+ * notification rule authored on "Gianluca" stopped matching the moment the
17336
+ * operator fixed the spelling in the gallery, and nothing said so. The id is
17337
+ * the thing that does not move, so it is what a rule matches on
17338
+ * (`NcConditions.identities`) and the text is what a human is shown.
17339
+ *
17340
+ * Absent when the label names no gallery row — a plate the OCR read but no
17341
+ * vehicle claims, a sub-class, a species, any tier-1 value.
17437
17342
  */
17438
- noCapableNode: number(),
17439
- failed: number(),
17440
- /** Set once a pass ends: true only when EVERYTHING was covered. */
17441
- complete: boolean().nullable(),
17442
- startedAtMs: number().nullable(),
17443
- finishedAtMs: number().nullable(),
17444
- /** Present when the pass ended by throwing. */
17445
- error: string().nullable()
17343
+ identityId: string().optional()
17446
17344
  });
17447
- DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
17448
- deviceId: number(),
17449
- trackId: string()
17450
- }), TrackSchema.nullable()), method(object({
17451
- deviceId: number(),
17452
- since: number().optional(),
17453
- until: number().optional(),
17454
- limit: number().optional(),
17455
- /** Spatial filter — only tracks whose trajectory intersects the zone
17456
- * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
17457
- * envelope columns, then precisely tested per position. Tracks with
17458
- * an unknown envelope (no frame dims at persist time) always match. */
17459
- zone: TrackZoneFilterSchema.optional(),
17460
- /** See {@link TrackProjectionSchema}. Default `full` (backward
17461
- * compatible — omitting the field keeps today's exact behaviour). */
17462
- projection: TrackProjectionSchema.optional(),
17463
- /** Include stationary-promoted rows (parked objects handed to the
17464
- * stationary registry). Default false: the timeline lists passages,
17465
- * not parking records (operator decision, 2026-08-15). */
17466
- includeStationary: boolean().optional()
17467
- }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
17468
- deviceId: number(),
17469
- groupId: string().min(1)
17470
- }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
17471
- kind: "mutation",
17472
- auth: "admin"
17473
- }), 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({
17474
- deviceId: number(),
17475
- since: number().optional(),
17476
- until: number().optional(),
17477
- kinds: array(string()).optional(),
17478
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
17479
- }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
17480
- deviceId: number(),
17481
- since: number(),
17482
- until: number(),
17483
- bucketMs: number().int().positive()
17484
- }), array(object({
17485
- bucketStart: number(),
17486
- motion: number().int(),
17487
- object: number().int(),
17488
- audio: number().int()
17489
- })).readonly()), method(object({
17490
- deviceId: number(),
17491
- cutoffMs: number()
17492
- }), object({
17493
- motion: number().int(),
17494
- object: number().int(),
17495
- audio: number().int()
17496
- }), {
17497
- kind: "mutation",
17498
- auth: "admin"
17499
- }), method(object({
17500
- deviceId: number(),
17501
- cutoffMs: number()
17502
- }), TrackCascadeCountsSchema, {
17503
- kind: "mutation",
17504
- auth: "admin"
17505
- }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
17506
- kind: "mutation",
17507
- auth: "admin"
17508
- }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
17509
- kind: "mutation",
17510
- auth: "admin"
17511
- }), method(object({
17512
- deviceId: number(),
17513
- trackIds: array(string()).min(1)
17514
- }), object({
17515
- deleted: number().int(),
17516
- failed: array(string()).readonly()
17517
- }), {
17518
- kind: "mutation",
17519
- auth: "admin"
17520
- }), method(object({
17521
- /** Log/audit scope only — the trackId is globally unique on its own. */
17345
+ /**
17346
+ * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
17347
+ * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
17348
+ * track and its events always answer the same question the same way.
17349
+ *
17350
+ * Two scalar columns, not an array: every consumer wants "the coarse one" or
17351
+ * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
17352
+ * is tier 2, and each carries its own score + attribution.
17353
+ *
17354
+ * **Reading it.** What a human should be shown is `subLabel ?? label` — the
17355
+ * finest thing known. Before 4g the single `label` column held the finest
17356
+ * value, so a consumer that has not been updated reads the tier-1 slot and
17357
+ * shows nothing on a species-only row; that is why the migration puts every
17358
+ * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
17359
+ * and why the read surfaces were changed in the same train.
17360
+ *
17361
+ * **Writing it.** The slots are independent, which is the whole point: a
17362
+ * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
17363
+ * migratorius`), so fineness cannot regress by construction. Within a tier the
17364
+ * higher score wins. One rule, one implementation — see
17365
+ * `pipeline/label-tier.ts` in addon-post-analysis.
17366
+ */
17367
+ var TieredLabelFields = {
17368
+ /** Tier 1 — the sub-class. See {@link LabelTierSchema}. */
17369
+ label: string().optional(),
17370
+ /** Confidence of the tier-1 value, as reported by the deciding step. */
17371
+ labelScore: number().optional(),
17372
+ /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
17373
+ labelMeta: LabelAttributionSchema.optional(),
17374
+ /** Tier 2 — the instance. See {@link LabelTierSchema}. */
17375
+ subLabel: string().optional(),
17376
+ /** Confidence of the tier-2 value, as reported by the deciding step. */
17377
+ subLabelScore: number().optional(),
17378
+ /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
17379
+ subLabelMeta: LabelAttributionSchema.optional()
17380
+ };
17381
+ /** Per-camera slice of a training-export estimate. */
17382
+ var TrainingExportDeviceTotalsSchema = object({
17522
17383
  deviceId: number(),
17384
+ tracks: number().int(),
17385
+ files: number().int(),
17386
+ bytes: number().int()
17387
+ });
17388
+ /**
17389
+ * What a training export WOULD contain. Computed from media index rows only —
17390
+ * no blob is read to produce this.
17391
+ */
17392
+ var TrainingExportSummarySchema = object({
17393
+ generatedAt: number(),
17394
+ trackCount: number().int(),
17395
+ fileCount: number().int(),
17396
+ byteCount: number().int(),
17397
+ /** More marked tracks exist than a single pass carries. */
17398
+ truncated: boolean(),
17399
+ devices: array(TrainingExportDeviceTotalsSchema).readonly()
17400
+ });
17401
+ var TrackSchema = object({
17523
17402
  trackId: string(),
17524
- flags: TrackFlagsPatchSchema
17525
- }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
17526
- kind: "query",
17527
- auth: "admin"
17528
- }), method(object({
17529
- olderThanMs: number(),
17530
- reason: OpsLogReasonSchema.optional()
17531
- }), EventPruneCountsSchema, {
17532
- kind: "mutation",
17533
- auth: "admin"
17534
- }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
17535
- kind: "mutation",
17536
- auth: "admin"
17537
- }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
17538
- kind: "mutation",
17539
- auth: "admin"
17540
- }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
17541
- kind: "mutation",
17542
- auth: "admin"
17543
- }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
17544
- kind: "mutation",
17545
- auth: "admin"
17546
- }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
17547
- kind: "mutation",
17548
- auth: "admin"
17549
- }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
17550
- kind: "mutation",
17551
- auth: "admin"
17552
- }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
17553
- kind: "query",
17554
- auth: "admin"
17555
- }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
17556
- kind: "query",
17557
- auth: "admin"
17558
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
17559
- kind: "query",
17560
- auth: "admin"
17561
- }), method(object({
17562
- /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
17563
- * `deviceId`, deliberately: `deviceId` would make this device-bound and
17564
- * route it at one camera's owner, and "every camera" would stop being
17565
- * expressible at all. */
17566
- deviceIds: array(number()).optional(),
17567
- limit: number().int().min(1).max(500).optional()
17568
- }), array(RetrainTrackSchema).readonly(), {
17569
- kind: "query",
17570
- auth: "admin"
17571
- }), method(object({ trackId: string() }), RetrainFrameListSchema, {
17572
- kind: "query",
17573
- auth: "admin"
17574
- }), method(object({
17575
17403
  deviceId: number(),
17576
- trackId: string(),
17577
- mediaKeys: array(string()).min(1)
17578
- }), RetrainFrameSelectionSchema, {
17579
- kind: "mutation",
17580
- auth: "admin"
17581
- }), method(object({
17404
+ className: string(),
17405
+ ...TieredLabelFields,
17406
+ producingDeviceName: string().optional(),
17407
+ /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
17408
+ source: TrackSourceSchema.optional(),
17409
+ firstSeen: number(),
17410
+ lastSeen: number(),
17411
+ /** Frame-rate position history (subject to maxPositionHistory cap). */
17412
+ positions: array(TrackPositionSchema).readonly(),
17413
+ /** Periodic snapshots at snapshotIntervalMs cadence (subject to
17414
+ * saveThumbnails policy). */
17415
+ snapshots: array(TrackSnapshotSchema).readonly(),
17416
+ /** Deduplicated zones the track has entered at least once. Zone IDS. */
17417
+ zonesVisited: array(string()).readonly(),
17418
+ /**
17419
+ * Human NAMES for {@link zonesVisited}, resolved at READ time against the
17420
+ * `zones` capability.
17421
+ *
17422
+ * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
17423
+ * and no card can render — so every free-text search surface was structurally
17424
+ * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
17425
+ * just returned nothing. Resolving here rather than in each client keeps ONE
17426
+ * derivation and costs the clients no extra call (the `zones` cap is
17427
+ * per-device, so a client-side resolve would be a per-camera fan-out on a
17428
+ * surface built to avoid exactly that).
17429
+ *
17430
+ * Resolved, never invented: a zone deleted since the track was written has no
17431
+ * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
17432
+ * two are not positionally aligned. Absent when the track visited no zone, or
17433
+ * when the zone catalogue could not be read.
17434
+ */
17435
+ zoneNames: array(string()).readonly().optional(),
17436
+ /** Deduplicated set of detector classes observed for this track over its
17437
+ * life (a track may be reclassified, e.g. person→vehicle). Absent on
17438
+ * legacy rows written before class accumulation shipped. */
17439
+ classes: array(string()).readonly().optional(),
17440
+ /** Cumulative normalized distance travelled (0..1 units = full frame width). */
17441
+ totalDistance: number(),
17442
+ state: TrackStateSchema,
17443
+ active: boolean(),
17444
+ /** Deterministic key-event importance score in [0,1] (server-computed at
17445
+ * track expiry, recomputed on late label). Absent on legacy rows written
17446
+ * before scoring shipped — consumers degrade to absence / compute-on-read. */
17447
+ importance: number().optional(),
17448
+ /** Id of the track's highest-confidence ObjectEvent (its representative
17449
+ * "best" frame). Absent when the track produced no object events. */
17450
+ bestEventId: string().optional(),
17451
+ /** Tag of the importance sub-signal that dominated the score
17452
+ * (identity|dwell|proximity|class|confidence|travel|zone). */
17453
+ importanceReason: string().optional(),
17454
+ /** Audio-classification labels heard on the camera during the track's
17455
+ * life (score ≥ device `classificationMinScore`), aggregated per label.
17456
+ * Absent on legacy rows / tracks with no confident audio. */
17457
+ audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
17458
+ /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
17459
+ * Populated from the persisted envelope columns on historical reads;
17460
+ * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
17461
+ envelope: TrackEnvelopeSchema.optional(),
17462
+ /**
17463
+ * A face DETECTOR found a face on this track — nothing more. It says the
17464
+ * detail plane produced a `face` detail; it does NOT say the face was
17465
+ * embedded, matched, above `minFacePx`, or that the recognizer was even
17466
+ * enabled. Set once and never cleared.
17467
+ *
17468
+ * **This exists so "face present but not recognised" is expressible.** A
17469
+ * recognised identity lands in `subLabel` (attributed to the face chain via
17470
+ * `subLabelMeta.stepId`), so before this field a track with an unmatched face
17471
+ * and a track with no face at all were byte-identical on the wire and no
17472
+ * surface could tell them apart. The read is `hasFace === true && subLabel
17473
+ * === undefined`.
17474
+ *
17475
+ * **Absent ≠ false.** Every row written before the column existed omits it,
17476
+ * and so does every server that predates the field — a consumer must test
17477
+ * `=== true` and render nothing otherwise, never infer "no face".
17478
+ */
17479
+ hasFace: boolean().optional(),
17480
+ /**
17481
+ * This track has a face row IN THE GALLERY: a crop **and** an embedding — a
17482
+ * face an operator could ASSIGN to an identity.
17483
+ *
17484
+ * The STRICT twin of {@link hasFace}, and the pair only earns its keep
17485
+ * because the two disagree. `hasFace` is stamped at the TOP of the face
17486
+ * branch, before every gate, and means no more than "a face detector produced
17487
+ * a face detail". This one is stamped at the single moment the gallery row
17488
+ * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
17489
+ * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
17490
+ * candidate gate, the imageless-track drop (no crop was ever captured) and
17491
+ * the crop-store drop. Everything between the detector and that insert can
17492
+ * legitimately refuse the face, so a flag written any earlier promises the
17493
+ * operator something to assign and delivers nothing.
17494
+ *
17495
+ * **Independent of recognition.** A face collected but never auto-matched is
17496
+ * still assignable — it is in fact the face an operator most wants to reach —
17497
+ * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
17498
+ * `subLabel`; this says only that the raw material exists.
17499
+ *
17500
+ * **Set once, never cleared.** A track that produced a gallery row produced
17501
+ * one; deleting the row later is the gallery's business, not this flag's.
17502
+ *
17503
+ * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
17504
+ * before the column omits it, and so does every server that predates the
17505
+ * field. A consumer must test `=== true` and render nothing otherwise —
17506
+ * never infer "no assignable face".
17507
+ */
17508
+ hasEmbeddedFace: boolean().optional(),
17509
+ /**
17510
+ * This subject CONTAINS a folded rider — a person the rider-pairing step
17511
+ * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
17512
+ * so the passage is tracked once and as a VEHICLE.
17513
+ *
17514
+ * It exists because the fold's record was dishonest. D34 and the code both
17515
+ * said "the person is not lost — it is reported so both entities stay on the
17516
+ * record"; in fact the pair went into a per-processor RAM field behind an
17517
+ * accessor nobody called, and every durable surface said `vehicle`, full
17518
+ * stop. This is the composition note that makes the row true.
17519
+ *
17520
+ * A COMPOSITION, never a class and never a label. "This vehicle contains a
17521
+ * person" is not an answer to "what is this" — both label tiers would refuse
17522
+ * a macro token anyway (D89), and correctly. Nothing here changes what the
17523
+ * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
17524
+ * and a `person` rule still does not fire for someone cycling past.
17525
+ *
17526
+ * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
17527
+ * the column, and every hub that predates the field, omits it. Test
17528
+ * `=== true` and render nothing otherwise — never infer "no rider".
17529
+ */
17530
+ hasRider: boolean().optional(),
17531
+ ...TrackFlagFields,
17532
+ ...TrackRetrainFields
17533
+ });
17534
+ var BaseEventFields = {
17535
+ id: string(),
17582
17536
  deviceId: number(),
17583
- trackId: string(),
17584
- frameId: string()
17585
- }), object({
17586
- removed: boolean(),
17587
- removedAnnotations: number().int()
17588
- }), {
17589
- kind: "mutation",
17590
- auth: "admin"
17591
- }), method(object({ frameId: string() }), object({
17537
+ timestamp: number()
17538
+ };
17539
+ var MotionEventSchema = object({
17540
+ ...BaseEventFields,
17541
+ kind: literal("motion"),
17542
+ regionCount: number(),
17543
+ /** Heavy JSON array — omitted in slim projection. */
17544
+ regions: array(object({
17545
+ bbox: BoundingBoxSchema,
17546
+ pixelCount: number(),
17547
+ intensity: number()
17548
+ })).readonly().optional(),
17549
+ /** Omitted in slim projection. */
17550
+ frameWidth: number().optional(),
17551
+ /** Omitted in slim projection. */
17552
+ frameHeight: number().optional(),
17553
+ /** Populated by B5 (recording playback URL for this event). */
17554
+ mediaUrl: string().optional()
17555
+ });
17556
+ /**
17557
+ * Which detection SOURCE produced an object event. `pipeline` = the ML
17558
+ * detection pipeline (decoded-frame inference); `onboard` = the camera's
17559
+ * native on-device AI. Both flow through the SAME analysis layers (zoning,
17560
+ * tracking, per-kind persistence) but stay distinguishable so consumers
17561
+ * (advanced-notifier, occupancy, …) can select which source(s) to act on.
17562
+ * Absent on legacy rows ⇒ treat as `pipeline`.
17563
+ */
17564
+ var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
17565
+ /**
17566
+ * The confirmed zone crossing that produced an object event. Present ONLY on
17567
+ * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
17568
+ * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
17569
+ * appearance event carry none, so a rule asking for a direction fails closed
17570
+ * on them.
17571
+ *
17572
+ * Exactly ONE crossing per event: the emitter turns each confirmed crossing
17573
+ * into its own event, so a frame in which a track enters A while leaving B
17574
+ * produces two events with two directions — never one ambiguous row.
17575
+ *
17576
+ * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
17577
+ * membership the box has NOW, and by definition it no longer contains the zone
17578
+ * that was just left. Without the id here, a zone-scoped rule could never match
17579
+ * the exit it asked for.
17580
+ */
17581
+ var ZoneCrossingSchema = object({
17582
+ direction: _enum(["enter", "exit"]),
17583
+ /** Admin zone id crossed. */
17584
+ zoneId: string(),
17585
+ /** Zone display name at crossing time (falls back to the id). */
17586
+ zoneName: string().optional()
17587
+ });
17588
+ var ObjectEventSchema = object({
17589
+ ...BaseEventFields,
17590
+ kind: literal("object"),
17591
+ /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
17592
+ source: DetectionSourceSchema.optional(),
17593
+ /**
17594
+ * Inference-frame id shared by every object event emitted from the SAME frame
17595
+ * — the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
17596
+ * 2 people + 1 dog) under one full frame, and link a track's frames over time
17597
+ * (group by `trackId`, pick a representative `frameId` as the parent frame).
17598
+ * Optional for backward-compat with pre-existing rows / the slim projection
17599
+ * includes it (it is light). Absent on rows written before this field.
17600
+ */
17601
+ frameId: string().optional(),
17602
+ /** Omitted in slim projection. */
17603
+ trackId: string().optional(),
17604
+ className: string(),
17605
+ ...TieredLabelFields,
17606
+ /** Omitted in slim projection. */
17607
+ confidence: number().optional(),
17608
+ /** Heavy JSON — omitted in slim projection. */
17609
+ bbox: BoundingBoxSchema.optional(),
17610
+ /** Heavy JSON — omitted in slim projection. */
17611
+ zones: array(string()).readonly().optional(),
17612
+ /** Omitted in slim projection. */
17613
+ state: TrackStateSchema.optional(),
17614
+ /**
17615
+ * The zone crossing this event IS, when it is one. Absent on every other
17616
+ * event kind (movement state, appearance, package) — see
17617
+ * {@link ZoneCrossingSchema}. Omitted in slim projection.
17618
+ */
17619
+ zoneCrossing: ZoneCrossingSchema.optional(),
17620
+ /** Detection-frame dimensions in pixels — let consumers normalize the
17621
+ * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
17622
+ frameWidth: number().optional(),
17623
+ frameHeight: number().optional(),
17624
+ /** MediaStore key for the crop attached to this event (if any). */
17625
+ mediaKey: string().optional(),
17626
+ /** Design B: MediaStore key of the track's native-resolution key frame (the
17627
+ * best-detection full frame). Resolve via the event-media data-plane
17628
+ * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
17629
+ * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
17630
+ * sources — consumers fall back to `mediaKey` (the tight crop). */
17631
+ keyFrameMediaKey: string().optional(),
17632
+ /** Populated by B5 (recording playback URL for this event). */
17633
+ mediaUrl: string().optional(),
17634
+ /** The parent track's key-event importance [0,1], propagated to every object
17635
+ * event of the track (so an event row can be sorted by importance without a
17636
+ * track join). Absent on legacy rows / before the track was scored. */
17637
+ importance: number().optional()
17638
+ });
17639
+ var AudioEventSchema = object({
17640
+ ...BaseEventFields,
17641
+ kind: literal("audio"),
17642
+ rms: number(),
17643
+ dbfs: number(),
17644
+ classification: object({
17645
+ className: string(),
17646
+ originalClass: string().optional(),
17647
+ score: number()
17648
+ }).optional(),
17649
+ /** Populated by B5 (recording playback URL for this event). */
17650
+ mediaUrl: string().optional()
17651
+ });
17652
+ var MediaFileKindEnum = _enum([
17653
+ "crop",
17654
+ "thumbnail",
17655
+ "snapshot",
17656
+ "firstFrame",
17657
+ "lastFrame",
17658
+ "fullFrame",
17659
+ "fullFrameBoxed",
17660
+ "faceCrop",
17661
+ "plateCrop",
17662
+ "keyFrame",
17663
+ "keyFrameSmall",
17664
+ "thumbnailSmall"
17665
+ ]);
17666
+ var MediaFileSchema = object({
17667
+ key: string(),
17668
+ kind: MediaFileKindEnum,
17592
17669
  base64: string(),
17593
- width: number().int(),
17594
- height: number().int()
17595
- }), {
17596
- kind: "query",
17597
- auth: "admin"
17598
- }), method(object({
17599
- deviceId: number(),
17600
- trackId: string(),
17601
- frameId: string(),
17602
- subject: RetrainAssistSubjectSchema,
17603
- /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
17604
- nodeId: string().optional()
17605
- }), RetrainAssistResultSchema, {
17606
- kind: "mutation",
17607
- auth: "admin"
17608
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
17609
- kind: "query",
17610
- auth: "admin"
17611
- }), method(object({
17612
- deviceId: number(),
17670
+ sizeBytes: number(),
17671
+ timestamp: number()
17672
+ });
17673
+ /**
17674
+ * One media row WITHOUT its bytes.
17675
+ *
17676
+ * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
17677
+ * 140 s track), and a client that renders tiles from the media data plane needs
17678
+ * to know only WHAT EXISTS — the bytes then arrive per tile, lazily, over HTTP
17679
+ * with an immutable cache, instead of all at once inside a tRPC response that
17680
+ * blocks the whole view.
17681
+ *
17682
+ * `sizeBytes` is carried because it is what lets a client decide between the
17683
+ * stored blob and a `?variant=thumb` rendering without fetching either.
17684
+ */
17685
+ var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
17686
+ /**
17687
+ * The MACRO tier of an annotation — a CLOSED set.
17688
+ *
17689
+ * This is what the exported detector predicts, so a typo here is a new class
17690
+ * with one example in it. `label` and `subLabel` are open strings by contrast:
17691
+ * the whole point of the page is teaching the model things it does not know
17692
+ * yet, and constraining that vocabulary would make it useless.
17693
+ *
17694
+ * A macro class is NEVER a label. The provider refuses a write whose `label` or
17695
+ * `subLabel` is one of these values, in any casing, because once `person`
17696
+ * exists in both tiers "every person box" stops being answerable without
17697
+ * knowing every string anyone ever typed — and the damage is retroactive.
17698
+ */
17699
+ var RetrainMacroClassSchema = _enum([
17700
+ "person",
17701
+ "vehicle",
17702
+ "animal",
17703
+ "package",
17704
+ "face",
17705
+ "plate"
17706
+ ]);
17707
+ /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
17708
+ var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
17709
+ /** Did a human draw this box, or did the assist propose it? */
17710
+ var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
17711
+ /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
17712
+ var RetrainBboxSchema = object({
17713
+ x: number(),
17714
+ y: number(),
17715
+ w: number(),
17716
+ h: number()
17717
+ });
17718
+ /**
17719
+ * One annotated subject.
17720
+ *
17721
+ * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
17722
+ * (letterboxed root / zone-cropped package / subject-cropped classifier) are
17723
+ * derived from it at export and never stored — storing them is how one feature
17724
+ * space ends up holding two crops of the same subject (D52).
17725
+ */
17726
+ var RetrainAnnotationSchema = object({
17727
+ id: string(),
17613
17728
  trackId: string(),
17614
- frameId: string(),
17615
- annotations: array(RetrainAnnotationDraftSchema)
17616
- }), array(RetrainAnnotationSchema).readonly(), {
17617
- kind: "mutation",
17618
- auth: "admin"
17619
- }), method(object({
17620
- deviceId: number(),
17621
- trackId: string()
17622
- }), RetrainTransitionResultSchema, {
17623
- kind: "mutation",
17624
- auth: "admin"
17625
- }), method(object({
17626
17729
  deviceId: number(),
17627
- trackId: string()
17628
- }), RetrainTransitionResultSchema, {
17629
- kind: "mutation",
17630
- auth: "admin"
17631
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
17632
- kind: "query",
17633
- auth: "admin"
17634
- }), method(object({
17635
- eventId: string(),
17636
- kind: MediaFileKindEnum.optional(),
17637
- deviceId: number()
17638
- }), array(MediaFileSchema).readonly()), method(object({
17639
- trackId: string(),
17640
- kinds: array(MediaFileKindEnum).optional(),
17641
- deviceId: number()
17642
- }), array(MediaFileSchema).readonly()), method(object({
17730
+ /** The COPY in retrain storage — never the source track's media key. */
17731
+ mediaKey: string(),
17732
+ bbox: RetrainBboxSchema,
17733
+ macroClass: RetrainMacroClassSchema,
17734
+ label: string().optional(),
17735
+ subLabel: string().optional(),
17736
+ kind: RetrainAnnotationKindSchema,
17737
+ source: RetrainAnnotationSourceSchema,
17738
+ /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
17739
+ assistModelId: string().optional(),
17740
+ assistScore: number().optional(),
17741
+ exportedInBatch: string().optional(),
17742
+ createdAt: number()
17743
+ });
17744
+ /** The write form — the server owns `id`, `createdAt` and the frame binding. */
17745
+ var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
17746
+ id: true,
17747
+ trackId: true,
17748
+ deviceId: true,
17749
+ mediaKey: true,
17750
+ createdAt: true,
17751
+ exportedInBatch: true
17752
+ });
17753
+ /** A track sitting in `staging`, with everything the worklist needs to rank it. */
17754
+ var RetrainTrackSchema = object({
17643
17755
  trackId: string(),
17644
- deviceId: number()
17645
- }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
17646
- kind: "mutation",
17647
- auth: "admin"
17648
- }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
17649
- kind: "mutation",
17650
- auth: "admin"
17651
- }), method(object({}), RebuildStatusSchema), object({
17652
17756
  deviceId: number(),
17757
+ className: string(),
17758
+ label: string().optional(),
17759
+ firstSeen: number(),
17760
+ lastSeen: number(),
17761
+ /** How many frames the dataset already holds from this track. */
17762
+ frameCount: number().int(),
17763
+ /** How many subjects have been annotated on those frames. `0` with
17764
+ * `frameCount: 0` is exactly "staging, still to work". */
17765
+ annotationCount: number().int()
17766
+ });
17767
+ /** A frame the picker may offer — an index row, no blob was read to produce it. */
17768
+ var RetrainFrameCandidateSchema = object({
17769
+ mediaKey: string(),
17770
+ kind: MediaFileKindEnum,
17653
17771
  timestamp: number(),
17654
- frameWidth: number(),
17655
- frameHeight: number(),
17656
- detections: array(OverlayDetectionSchema).readonly()
17657
- }), object({
17772
+ sizeBytes: number().int(),
17773
+ /** A copy of this original already exists — selecting it is free and cannot
17774
+ * fail, whatever became of the original. */
17775
+ copied: boolean()
17776
+ });
17777
+ /** A frame the dataset OWNS: bytes copied at selection time. */
17778
+ var RetrainFrameSchema = object({
17779
+ frameId: string(),
17658
17780
  deviceId: number(),
17659
17781
  trackId: string(),
17660
- className: string()
17782
+ /** Provenance only. It may already point at nothing — that is expected. */
17783
+ sourceMediaKey: string(),
17784
+ sourceKind: MediaFileKindEnum,
17785
+ sizeBytes: number().int(),
17786
+ width: number().int(),
17787
+ height: number().int(),
17788
+ copiedAt: number()
17789
+ });
17790
+ /** Why a copy-on-select could not be honoured — named, never a silent skip. */
17791
+ var RetrainCopyRefusalSchema = _enum([
17792
+ "source-missing",
17793
+ "unreadable-image",
17794
+ "write-failed"
17795
+ ]);
17796
+ var RetrainFrameSelectionSchema = object({
17797
+ copied: array(RetrainFrameSchema).readonly(),
17798
+ refused: array(object({
17799
+ sourceMediaKey: string(),
17800
+ reason: RetrainCopyRefusalSchema
17801
+ })).readonly()
17802
+ });
17803
+ var RetrainFrameListSchema = object({
17804
+ candidates: array(RetrainFrameCandidateSchema).readonly(),
17805
+ copies: array(RetrainFrameSchema).readonly(),
17806
+ /** What the page pre-selects — the native key frame when one survives. */
17807
+ autoPickMediaKey: string().optional()
17808
+ });
17809
+ /** What the operator asked the assist to look for. */
17810
+ var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
17811
+ kind: literal("package"),
17812
+ zone: RetrainBboxSchema.optional()
17661
17813
  }), object({
17662
- deviceId: number(),
17663
- trackId: string(),
17664
- className: string(),
17665
- durationMs: number()
17814
+ kind: literal("objects"),
17815
+ modelId: string(),
17816
+ minScore: number().optional()
17817
+ })]);
17818
+ /**
17819
+ * The assist's answer — a discriminated union, because "the model saw nothing"
17820
+ * and "this node cannot run that model" lead to different next moves and a
17821
+ * nullable result cannot tell them apart.
17822
+ */
17823
+ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
17824
+ kind: literal("proposed"),
17825
+ modelId: string(),
17826
+ stepId: string(),
17827
+ minScore: number(),
17828
+ /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
17829
+ proposals: array(RetrainAnnotationDraftSchema).readonly(),
17830
+ /** Returned by the runner but removed by the threshold. */
17831
+ belowThreshold: number().int()
17666
17832
  }), object({
17833
+ kind: literal("refused"),
17834
+ /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
17835
+ reason: string(),
17836
+ detail: string().optional()
17837
+ })]);
17838
+ /** The outcome of a lifecycle move owned by the retrain page. */
17839
+ var RetrainTransitionResultSchema = object({
17840
+ trackId: string(),
17841
+ /** Where the track ended up, whatever happened. */
17842
+ retrainStatus: RetrainStatusSchema,
17843
+ /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
17844
+ changed: boolean(),
17845
+ reason: _enum([
17846
+ "unknown-track",
17847
+ "no-frames-copied",
17848
+ "not-staging",
17849
+ "not-trained",
17850
+ "unchanged"
17851
+ ]).optional()
17852
+ });
17853
+ var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
17854
+ var MAX_EVENT_QUERY_LIMIT = 5e3;
17855
+ var DeviceEventQueryInput = object({
17667
17856
  deviceId: number(),
17668
- kind: EventKindSchema,
17669
- eventId: string(),
17670
- timestamp: number()
17857
+ since: number().optional(),
17858
+ until: number().optional(),
17859
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
17860
+ /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
17861
+ * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
17862
+ * exact behaviour. Callers may omit this field — the store defaults to
17863
+ * `full` when not provided. */
17864
+ projection: _enum(["full", "slim"]).optional()
17671
17865
  });
17672
- /**
17673
- * Reference to the frame's retained NATIVE surface + the parent crop's placement
17674
- * within the frame, so the executor can re-cut a leaf child ROI at native
17675
- * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
17676
- */
17677
- var NativeCropRefSchema = object({
17678
- /** Handle keying the retained native surface (node-pinned to its owner). */
17679
- handle: FrameHandleSchema,
17680
- /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
17681
- cropFrameSpace: object({
17682
- x: number(),
17683
- y: number(),
17684
- w: number(),
17685
- h: number()
17686
- })
17866
+ var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
17867
+ var RecentTracksQueryInput = object({
17868
+ /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
17869
+ deviceIds: array(number()),
17870
+ /** Window lower bound on `lastSeen` (inclusive). */
17871
+ since: number().optional(),
17872
+ /** Window upper bound on `lastSeen` (inclusive). */
17873
+ until: number().optional(),
17874
+ /** Page size. Default 200, max 1000. */
17875
+ limit: number().int().min(1).max(1e3).default(200),
17876
+ /** Opaque continuation cursor from a previous page's `nextCursor`.
17877
+ * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
17878
+ cursor: string().optional(),
17879
+ /** See {@link TrackProjectionSchema}. Default `full`. */
17880
+ projection: TrackProjectionSchema.optional(),
17881
+ /** Include stationary-promoted rows (parked objects). Default false: the
17882
+ * feed lists passages; parking records live on the stationary registry. */
17883
+ includeStationary: boolean().optional()
17687
17884
  });
17688
- object({
17689
- crop: object({
17690
- left: number(),
17691
- top: number(),
17692
- width: number().positive(),
17693
- height: number().positive()
17694
- }).optional(),
17695
- content: object({
17696
- width: number().int().positive(),
17697
- height: number().int().positive()
17698
- }),
17699
- fit: _enum(["stretch", "contain"]),
17700
- format: _enum([
17701
- "rgb",
17702
- "gray",
17703
- "jpeg"
17704
- ])
17885
+ var RecentTracksPageSchema = object({
17886
+ /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
17887
+ tracks: array(TrackSchema).readonly(),
17888
+ /** Cursor for the next page, or null when this page is the last. */
17889
+ nextCursor: string().nullable()
17705
17890
  });
17706
- var FrameRefSchema = object({
17707
- registryId: string().min(1),
17708
- id: string().min(1),
17709
- width: number().int().positive(),
17710
- height: number().int().positive(),
17711
- format: _enum(["rgb", "gray"]),
17712
- timestamp: number(),
17713
- capturedAt: number().optional()
17891
+ var LIST_GROUPS_DEFAULT_LIMIT = 40;
17892
+ var LIST_GROUPS_MAX_LIMIT = 100;
17893
+ var AnalyticsGroupRecordSchema = object({
17894
+ id: string(),
17895
+ deviceId: number().int(),
17896
+ openedAt: number().int(),
17897
+ closedAt: number().int(),
17898
+ timestamp: number().int(),
17899
+ memberCount: number().int(),
17900
+ memberTrackIds: array(string()).readonly(),
17901
+ className: string(),
17902
+ classes: array(string()).readonly(),
17903
+ /** Relative event-media path, or null when the group has no picture yet. */
17904
+ mediaUrl: string().nullable(),
17905
+ singleton: boolean()
17714
17906
  });
17715
- var ModelFormatSchema$1 = _enum([
17716
- "onnx",
17717
- "coreml",
17718
- "openvino",
17719
- "tflite",
17720
- "pt",
17721
- "gguf"
17722
- ]);
17723
- var PipelineSlotSchema = _enum([
17724
- "detector",
17725
- "cropper",
17726
- "classifier",
17727
- "refiner",
17728
- "audio-classifier"
17729
- ]);
17730
- var PipelineEngineChoiceSchema = object({
17731
- runtime: _enum(["node", "python"]),
17732
- backend: string(),
17733
- format: ModelFormatSchema$1,
17734
- device: string().optional()
17907
+ var AnalyticsGroupMemberSchema = object({
17908
+ trackId: string(),
17909
+ deviceId: number().int(),
17910
+ className: string(),
17911
+ firstSeen: number().int(),
17912
+ lastSeen: number().int(),
17913
+ mediaUrl: string().nullable()
17735
17914
  });
17736
- var AvailableEngineSchema = object({
17737
- engine: PipelineEngineChoiceSchema,
17738
- devices: array(object({
17739
- id: string(),
17740
- label: string(),
17741
- description: string().optional()
17742
- })).readonly(),
17743
- defaultDevice: string()
17915
+ var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
17916
+ var ListGroupsQueryInput = object({
17917
+ /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
17918
+ deviceIds: array(number()),
17919
+ /** Window lower bound on `closedAt` (inclusive). */
17920
+ since: number().optional(),
17921
+ /** Window upper bound on `openedAt` (inclusive). */
17922
+ until: number().optional(),
17923
+ limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
17924
+ /** Opaque continuation cursor from a previous page's `nextCursor`. */
17925
+ cursor: string().optional()
17744
17926
  });
17745
- var PipelineDefaultStepSchema = lazy(() => object({
17746
- addonId: string(),
17747
- addonName: string(),
17748
- slot: PipelineSlotSchema,
17749
- inputClasses: array(string()).readonly(),
17750
- outputClasses: array(string()).readonly(),
17751
- enabled: boolean(),
17752
- modelId: string(),
17753
- children: array(PipelineDefaultStepSchema).readonly(),
17754
- group: string().optional(),
17755
- settings: record(string(), unknown()).optional()
17756
- }));
17757
- var PipelineTemplateStepSchema = lazy(() => object({
17758
- addonId: string(),
17759
- enabled: boolean(),
17760
- modelId: string(),
17761
- children: array(PipelineTemplateStepSchema).readonly(),
17762
- settings: record(string(), unknown()).optional()
17763
- }));
17764
- var PipelineTemplateSchema$1 = object({
17765
- id: string(),
17766
- name: string(),
17767
- createdAt: string(),
17768
- updatedAt: string(),
17769
- engine: PipelineEngineChoiceSchema,
17770
- steps: array(PipelineTemplateStepSchema).readonly()
17927
+ var ListGroupsPageSchema = object({
17928
+ groups: array(AnalyticsGroupRecordSchema).readonly(),
17929
+ nextCursor: string().nullable()
17930
+ });
17931
+ var KeyEventQueryInput = object({
17932
+ deviceId: number(),
17933
+ /** Window lower bound (track firstSeen ≥ since). */
17934
+ since: number(),
17935
+ /** Window upper bound (track firstSeen ≤ until). */
17936
+ until: number(),
17937
+ limit: number().int().min(1).max(200).default(50),
17938
+ /** Drop tracks scoring below this importance. */
17939
+ minImportance: number().min(0).max(1).optional(),
17940
+ /** Restrict to a single class (e.g. 'person'). */
17941
+ classFilter: string().optional()
17771
17942
  });
17772
- var PipelineModelOptionSchema = object({
17943
+ var KeyEventSchema = object({
17944
+ /** The representative event id (the track's best ObjectEvent, else its trackId). */
17773
17945
  id: string(),
17774
- name: string(),
17775
- formats: record(string(), object({
17776
- downloaded: boolean(),
17777
- sizeMB: number()
17778
- })),
17779
- group: ModelVariantGroupSchema.optional(),
17780
- legacy: boolean().optional(),
17781
- provider: ModelProviderIdSchema.optional()
17946
+ trackId: string(),
17947
+ /** Track start time (firstSeen). */
17948
+ timestamp: number(),
17949
+ className: string(),
17950
+ ...TieredLabelFields,
17951
+ importance: number(),
17952
+ /** Highest-confidence ObjectEvent id for the track (empty when none). */
17953
+ bestEventId: string(),
17954
+ /** Track lifetime in ms (lastSeen - firstSeen). */
17955
+ windowMs: number().optional(),
17956
+ ...TrackFlagFields,
17957
+ ...TrackRetrainFields
17782
17958
  });
17783
- var ConfigFieldBridge = custom();
17784
- var PipelineAddonSchemaSchema = object({
17785
- id: string(),
17786
- name: string(),
17787
- slot: PipelineSlotSchema,
17788
- inputClasses: array(string()).readonly(),
17789
- outputClasses: array(string()).readonly(),
17790
- childSlots: array(PipelineSlotSchema).readonly(),
17791
- models: array(PipelineModelOptionSchema).readonly(),
17792
- defaultModelId: string(),
17793
- defaultModelIdByFormat: record(string(), string()).optional(),
17794
- enabledByDefault: boolean().optional(),
17795
- backfillIntoExistingOverrides: boolean().optional(),
17796
- defaultConfidence: number(),
17797
- group: string().optional(),
17798
- configSchema: array(ConfigFieldBridge).readonly().optional()
17959
+ object({
17960
+ trackId: string(),
17961
+ className: string(),
17962
+ confidence: number(),
17963
+ bbox: BoundingBoxSchema,
17964
+ zones: array(string()).readonly(),
17965
+ state: TrackStateSchema
17799
17966
  });
17800
- var PipelineSlotSchemaSchema = object({
17801
- id: PipelineSlotSchema,
17802
- label: string(),
17803
- priority: number(),
17804
- parentSlot: PipelineSlotSchema.nullable(),
17805
- addons: array(PipelineAddonSchemaSchema).readonly()
17967
+ var OverlayDetectionSchema = looseObject({
17968
+ id: string(),
17969
+ kind: _enum(["first-level", "detail"]),
17970
+ macroClass: string(),
17971
+ score: number(),
17972
+ bbox: object({
17973
+ x: number(),
17974
+ y: number(),
17975
+ width: number(),
17976
+ height: number()
17977
+ }),
17978
+ labels: array(looseObject({
17979
+ label: string(),
17980
+ score: number()
17981
+ })).readonly(),
17982
+ parentId: string().optional()
17806
17983
  });
17807
- var PipelineSchemaSchema = object({
17808
- availableEngines: array(AvailableEngineSchema).readonly(),
17809
- selectedEngine: PipelineEngineChoiceSchema,
17810
- slots: array(PipelineSlotSchemaSchema).readonly()
17984
+ var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
17985
+ var SearchObjectEventsInput = object({
17986
+ text: string(),
17987
+ deviceId: number().optional(),
17988
+ since: number().optional(),
17989
+ until: number().optional(),
17990
+ classFilter: string().optional(),
17991
+ limit: number().default(50),
17992
+ minScore: number().min(0).max(1).default(.2)
17811
17993
  });
17812
- var EngineProvisioningSchema = object({
17813
- runtimeId: _enum([
17814
- "onnx",
17815
- "openvino",
17816
- "coreml",
17817
- "edgetpu"
17818
- ]).nullable(),
17819
- device: string().nullable(),
17820
- state: _enum([
17821
- "idle",
17822
- "installing",
17823
- "verifying",
17824
- "ready",
17825
- "failed"
17826
- ]),
17827
- progress: number().optional(),
17828
- error: string().optional(),
17829
- nextRetryAt: number().optional(),
17830
- /**
17831
- * Gate A (config-correctness gate at engine change): human-readable
17832
- * config issues surfaced EAGERLY when the node's engine changes — model
17833
- * substitutions ("chose X, running Y") and zero-build steps ("no model
17834
- * has a <format> build"). Additive/optional: informational only, never
17835
- * enforced here — `assertEngineReady` (readiness) still gates inference.
17836
- * Absent/empty when the node-default tree resolves cleanly.
17837
- */
17838
- configIssues: array(string()).optional()
17994
+ var TrackCascadeCountsSchema = object({
17995
+ /** Persisted track roots deleted (authoritative). */
17996
+ tracks: number().int(),
17997
+ /** Object events removed with their tracks (best-effort; see note above). */
17998
+ events: number().int(),
17999
+ /** Track/face/plate-owned media removed (best-effort). Never identity media. */
18000
+ media: number().int(),
18001
+ /** Unassigned (non-enrolled) face reads removed (best-effort). */
18002
+ faces: number().int(),
18003
+ /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
18004
+ plates: number().int(),
18005
+ /** Per-track CLIP search vectors removed (best-effort). */
18006
+ embeddings: number().int(),
18007
+ /** Group membership + group rows removed with their last member (best-effort). */
18008
+ groups: number().int()
17839
18009
  });
17840
- var PipelineStepInputSchema = lazy(() => object({
17841
- addonId: string(),
17842
- modelId: string().optional(),
17843
- enabled: boolean().default(true),
17844
- children: array(PipelineStepInputSchema).optional(),
17845
- settings: record(string(), unknown()).optional(),
17846
- jumpDeviceKey: string().optional()
17847
- }));
17848
- var ModelSubstitutionSchema = object({
17849
- addonId: string(),
17850
- chosen: string(),
17851
- running: string(),
17852
- format: string()
18010
+ /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
18011
+ var DiskReconcileCountsSchema = object({
18012
+ mediaDropped: number().int(),
18013
+ tracks: number().int(),
18014
+ events: number().int()
17853
18015
  });
17854
- var PipelineValidationIssueSchema = object({
17855
- addonId: string(),
17856
- kind: _enum(["unknown-addon", "no-format-build"]),
17857
- detail: string()
18016
+ /** Event-store footprint for one camera. */
18017
+ var EventStoreDeviceFootprintSchema = object({
18018
+ deviceId: number(),
18019
+ /** Persisted event rows (motion + object + audio) for the camera. */
18020
+ rows: number().int(),
18021
+ /** Event-owned media bytes on disk for the camera. */
18022
+ bytes: number().int()
17858
18023
  });
17859
- var PipelineValidationResultSchema = object({
17860
- ok: boolean(),
17861
- issues: array(PipelineValidationIssueSchema).readonly(),
17862
- substitutions: array(ModelSubstitutionSchema).readonly(),
17863
- /** The node's `currentEngine.format` this validation ran against. */
17864
- format: string()
18024
+ /** Aggregate event-store footprint: global totals + per-camera breakdown. */
18025
+ var EventStoreFootprintSchema = object({
18026
+ totalRows: number().int(),
18027
+ totalBytes: number().int(),
18028
+ devices: array(EventStoreDeviceFootprintSchema).readonly()
17865
18029
  });
17866
- var ReferenceImageEntrySchema = object({
17867
- filename: string(),
17868
- stepIds: array(string()).readonly().optional()
18030
+ /** Per-kind counts returned by the event-prune / device-delete mutations. */
18031
+ var EventPruneCountsSchema = object({
18032
+ motion: number().int(),
18033
+ object: number().int(),
18034
+ audio: number().int()
17869
18035
  });
17870
- var ReferenceImageBodySchema = object({
17871
- base64: string(),
17872
- filename: string()
18036
+ /**
18037
+ * Re-embed stored tracks from their key frames.
18038
+ *
18039
+ * The reason this is an operator-callable method and not a migration script:
18040
+ * every knob that decides what a vector MEANS — encoder model, crop margin,
18041
+ * squaring — is only changeable if the existing vectors can be regenerated.
18042
+ * Mixing feature spaces in one index makes cosine scores incomparable, and the
18043
+ * symptom is a quality regression with no visible cause.
18044
+ */
18045
+ var RebuildObjectEmbeddingsInput = object({
18046
+ /** Restrict to one camera. Omit for the whole fleet. */
18047
+ deviceId: number().optional(),
18048
+ since: number().optional(),
18049
+ until: number().optional(),
18050
+ /** Stop after this many tracks; the result reports whether more remain. */
18051
+ maxTracks: number().int().positive().optional(),
18052
+ /**
18053
+ * Run every embedding on THIS node instead of round-robining the fleet.
18054
+ *
18055
+ * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
18056
+ * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
18057
+ * calling it that would pin the rebuild REQUEST itself to that node — the
18058
+ * rebuild orchestration lives on the hub, and only the per-track step runs
18059
+ * remotely. This field is data; the per-track pin is applied inside.
18060
+ *
18061
+ * Absent ⇒ round-robin over every online node whose runner can serve the
18062
+ * pinned model.
18063
+ */
18064
+ executeOnNodeId: string().optional(),
18065
+ /**
18066
+ * Milliseconds to wait between tracks; omit for the built-in default, `0` to
18067
+ * run flat out.
18068
+ *
18069
+ * A rebuild is bulk maintenance on hub-main's single thread. Measured
18070
+ * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
18071
+ * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
18072
+ * force is logged at start and finish so a deliberately slow pass reads
18073
+ * differently from a stalled one.
18074
+ */
18075
+ pacingMs: number().int().nonnegative().optional()
17873
18076
  });
17874
- var ReferenceAudioEntrySchema = object({
17875
- filename: string(),
17876
- sizeKb: number()
18077
+ /**
18078
+ * Result of emptying the CLIP index.
18079
+ *
18080
+ * The clean slate before a policy change: a new crop margin or encoder model
18081
+ * leaves two feature spaces in one index whose cosine scores are not
18082
+ * comparable, so wiping and rebuilding is the only way to be sure every vector
18083
+ * means the same thing.
18084
+ */
18085
+ var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
18086
+ /**
18087
+ * Acknowledgement that a rebuild STARTED.
18088
+ *
18089
+ * The pass costs ~1s per track — 45 minutes for a 2,600-track fleet — so it
18090
+ * runs detached and this returns immediately. Waiting for it made the client
18091
+ * time out while the work carried on server-side, which is the worst of both:
18092
+ * no result and no way to know it was still going. Poll
18093
+ * `getObjectEmbeddingRebuildStatus` for progress.
18094
+ */
18095
+ var RebuildObjectEmbeddingsResultSchema = object({
18096
+ started: boolean(),
18097
+ /** True when a pass was already running; the new request is ignored. */
18098
+ alreadyRunning: boolean()
17877
18099
  });
17878
- var ReferenceAudioBodySchema = object({ base64: string() });
17879
- var AudioBackendSchema = object({
17880
- id: string(),
17881
- name: string(),
17882
- description: string(),
17883
- available: boolean(),
18100
+ var RebuildStatusSchema = object({
18101
+ running: boolean(),
18102
+ scanned: number(),
18103
+ rebuilt: number(),
18104
+ /** Tracks whose key frame is gone — nothing to re-embed from. */
18105
+ missingKeyFrame: number(),
18106
+ /** Tracks with no usable detection box. */
18107
+ missingBbox: number(),
18108
+ /**
18109
+ * Tracks an executing node REFUSED rather than broke on — an unreadable key
18110
+ * frame, a step that threw. Separate from `failed` because the remedy is
18111
+ * different, and because a whole camera silently contributing zero vectors
18112
+ * is the shape of failure a rebuild must never hide.
18113
+ */
18114
+ notRunnable: number(),
17884
18115
  /**
17885
- * Raw classifier labels this backend can emit (e.g. YAMNet's
17886
- * 521-class set or Apple SoundAnalysis's 303-class set). Used by
17887
- * the benchmark UI to populate the `enabledMicroClasses` filter
17888
- * specific to the selected backend without a separate fetch.
18116
+ * The pass stopped because NO node could serve the pinned model.
18117
+ *
18118
+ * Distinct from `notRunnable` on purpose: that one says "this track was
18119
+ * refused", this one says "the cluster cannot do this work at all" — every
18120
+ * candidate node either lacks the `clip-embedding` step, lacks a build of the
18121
+ * pinned model for its engine format, or dropped out. The remedy is a model /
18122
+ * engine change, not a per-camera one. Non-zero here always comes with
18123
+ * `complete: false`.
17889
18124
  */
17890
- rawLabels: array(string()).readonly().optional()
17891
- });
17892
- var AudioCapabilitiesSchema = object({
17893
- activeBackend: string(),
17894
- availableBackends: array(AudioBackendSchema).readonly(),
17895
- sampleRate: number(),
17896
- chunkDurationMs: number()
17897
- });
17898
- var DownloadModelResultSchema = object({
17899
- filePath: string(),
17900
- sizeMB: number(),
17901
- durationMs: number()
18125
+ noCapableNode: number(),
18126
+ failed: number(),
18127
+ /** Set once a pass ends: true only when EVERYTHING was covered. */
18128
+ complete: boolean().nullable(),
18129
+ startedAtMs: number().nullable(),
18130
+ finishedAtMs: number().nullable(),
18131
+ /** Present when the pass ended by throwing. */
18132
+ error: string().nullable()
17902
18133
  });
17903
- /**
17904
- * Wrapper carrying a single test run's result. Replaces the legacy
17905
- * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
17906
- * canonical `AudioResult` from the Phase 6 output rework: one
17907
- * `AudioDetection` per class above `minScore`, top-N candidates in
17908
- * `debug.alternateLabels['audio-classifier']`, per-source timings in
17909
- * `debug.stepTimings`. The outer `success`/`error` fields stay so the
17910
- * benchmark UI can still report a clean failure when the classifier
17911
- * cap isn't available.
17912
- */
17913
- var AudioTestResultSchema = object({
17914
- success: boolean(),
17915
- error: string().optional(),
17916
- frame: custom().optional()
18134
+ var ReplayFrameInputSchema = object({
18135
+ timestamp: number(),
18136
+ frame: PipelineRunResultBridge
17917
18137
  });
17918
- var PipelineConfigBridge = custom();
17919
- var ConfigUISchemaBridge = custom();
17920
- var ConfigUISchemaNullableBridge = custom();
17921
- var InferenceCapabilitiesBridge = custom();
17922
- var ModelAvailabilityListBridge = custom();
17923
- var PipelineRunResultBridge = custom();
17924
- method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
17925
- modelId: string(),
17926
- settings: record(string(), unknown()).readonly()
17927
- }))), method(object({ steps: record(string(), object({
17928
- modelId: string(),
17929
- settings: record(string(), unknown()).readonly()
17930
- })) }), object({ success: literal(true) }), {
18138
+ var RunReplayFrameProcessorResultSchema = object({ tracks: array(object({
18139
+ className: string(),
18140
+ firstSeenMs: number(),
18141
+ lastSeenMs: number(),
18142
+ /** Bbox of the track's FIRST matched detection, pixel-space in the clip's
18143
+ * frame — a representative box for the diff's `(className, window, IoU)`
18144
+ * pairing (`replay-diff.ts`). A replay does not need the full per-frame
18145
+ * trajectory production's `Track.positions` keeps. */
18146
+ bbox: BoundingBoxSchema,
18147
+ /** How many of the input frames this track matched a real detection on
18148
+ * (never a coasted/extrapolated frame) — the replay's own signal for "how
18149
+ * solid is this track", cheaper than re-deriving it from a trajectory. */
18150
+ framesMatched: number().int()
18151
+ })).readonly() });
18152
+ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
18153
+ deviceId: number(),
18154
+ trackId: string()
18155
+ }), TrackSchema.nullable()), method(object({
18156
+ deviceId: number(),
18157
+ since: number().optional(),
18158
+ until: number().optional(),
18159
+ limit: number().optional(),
18160
+ /** Spatial filter — only tracks whose trajectory intersects the zone
18161
+ * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
18162
+ * envelope columns, then precisely tested per position. Tracks with
18163
+ * an unknown envelope (no frame dims at persist time) always match. */
18164
+ zone: TrackZoneFilterSchema.optional(),
18165
+ /** See {@link TrackProjectionSchema}. Default `full` (backward
18166
+ * compatible — omitting the field keeps today's exact behaviour). */
18167
+ projection: TrackProjectionSchema.optional(),
18168
+ /** Include stationary-promoted rows (parked objects handed to the
18169
+ * stationary registry). Default false: the timeline lists passages,
18170
+ * not parking records (operator decision, 2026-08-15). */
18171
+ includeStationary: boolean().optional()
18172
+ }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
18173
+ deviceId: number(),
18174
+ groupId: string().min(1)
18175
+ }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
18176
+ kind: "mutation",
18177
+ auth: "admin"
18178
+ }), 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({
18179
+ deviceId: number(),
18180
+ since: number().optional(),
18181
+ until: number().optional(),
18182
+ kinds: array(string()).optional(),
18183
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
18184
+ }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
18185
+ deviceId: number(),
18186
+ since: number(),
18187
+ until: number(),
18188
+ bucketMs: number().int().positive()
18189
+ }), array(object({
18190
+ bucketStart: number(),
18191
+ motion: number().int(),
18192
+ object: number().int(),
18193
+ audio: number().int()
18194
+ })).readonly()), method(object({
18195
+ deviceId: number(),
18196
+ cutoffMs: number()
18197
+ }), object({
18198
+ motion: number().int(),
18199
+ object: number().int(),
18200
+ audio: number().int()
18201
+ }), {
18202
+ kind: "mutation",
18203
+ auth: "admin"
18204
+ }), method(object({
18205
+ deviceId: number(),
18206
+ cutoffMs: number()
18207
+ }), TrackCascadeCountsSchema, {
18208
+ kind: "mutation",
18209
+ auth: "admin"
18210
+ }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
18211
+ kind: "mutation",
18212
+ auth: "admin"
18213
+ }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
18214
+ kind: "mutation",
18215
+ auth: "admin"
18216
+ }), method(object({
18217
+ deviceId: number(),
18218
+ trackIds: array(string()).min(1)
18219
+ }), object({
18220
+ deleted: number().int(),
18221
+ failed: array(string()).readonly()
18222
+ }), {
18223
+ kind: "mutation",
18224
+ auth: "admin"
18225
+ }), method(object({
18226
+ /** Log/audit scope only — the trackId is globally unique on its own. */
18227
+ deviceId: number(),
18228
+ trackId: string(),
18229
+ flags: TrackFlagsPatchSchema
18230
+ }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
18231
+ kind: "query",
18232
+ auth: "admin"
18233
+ }), method(object({
18234
+ olderThanMs: number(),
18235
+ reason: OpsLogReasonSchema.optional()
18236
+ }), EventPruneCountsSchema, {
18237
+ kind: "mutation",
18238
+ auth: "admin"
18239
+ }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
18240
+ kind: "mutation",
18241
+ auth: "admin"
18242
+ }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
18243
+ kind: "mutation",
18244
+ auth: "admin"
18245
+ }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
18246
+ kind: "mutation",
18247
+ auth: "admin"
18248
+ }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
18249
+ kind: "mutation",
18250
+ auth: "admin"
18251
+ }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
18252
+ kind: "mutation",
18253
+ auth: "admin"
18254
+ }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18255
+ kind: "mutation",
18256
+ auth: "admin"
18257
+ }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
18258
+ kind: "mutation",
18259
+ auth: "admin"
18260
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
18261
+ kind: "query",
18262
+ auth: "admin"
18263
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18264
+ kind: "mutation",
18265
+ auth: "admin"
18266
+ }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
18267
+ kind: "query",
18268
+ auth: "admin"
18269
+ }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
18270
+ kind: "query",
18271
+ auth: "admin"
18272
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18273
+ kind: "query",
18274
+ auth: "admin"
18275
+ }), method(object({
18276
+ /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
18277
+ * `deviceId`, deliberately: `deviceId` would make this device-bound and
18278
+ * route it at one camera's owner, and "every camera" would stop being
18279
+ * expressible at all. */
18280
+ deviceIds: array(number()).optional(),
18281
+ limit: number().int().min(1).max(500).optional()
18282
+ }), array(RetrainTrackSchema).readonly(), {
18283
+ kind: "query",
18284
+ auth: "admin"
18285
+ }), method(object({ trackId: string() }), RetrainFrameListSchema, {
18286
+ kind: "query",
18287
+ auth: "admin"
18288
+ }), method(object({
18289
+ deviceId: number(),
18290
+ trackId: string(),
18291
+ mediaKeys: array(string()).min(1)
18292
+ }), RetrainFrameSelectionSchema, {
18293
+ kind: "mutation",
18294
+ auth: "admin"
18295
+ }), method(object({
18296
+ deviceId: number(),
18297
+ trackId: string(),
18298
+ frameId: string()
18299
+ }), object({
18300
+ removed: boolean(),
18301
+ removedAnnotations: number().int()
18302
+ }), {
18303
+ kind: "mutation",
18304
+ auth: "admin"
18305
+ }), method(object({ frameId: string() }), object({
18306
+ base64: string(),
18307
+ width: number().int(),
18308
+ height: number().int()
18309
+ }), {
18310
+ kind: "query",
18311
+ auth: "admin"
18312
+ }), method(object({
18313
+ deviceId: number(),
18314
+ trackId: string(),
18315
+ frameId: string(),
18316
+ subject: RetrainAssistSubjectSchema,
18317
+ /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
18318
+ nodeId: string().optional()
18319
+ }), RetrainAssistResultSchema, {
18320
+ kind: "mutation",
18321
+ auth: "admin"
18322
+ }), method(object({
18323
+ deviceId: number(),
18324
+ source: DetectionSourceSchema,
18325
+ zones: array(ZoneSchema).readonly().optional(),
18326
+ detectionRules: array(ZoneRuleSchema).readonly().optional(),
18327
+ zoneMembershipMinOverlap: number().min(0).max(1).optional(),
18328
+ frames: array(ReplayFrameInputSchema).min(1)
18329
+ }), RunReplayFrameProcessorResultSchema, {
18330
+ kind: "mutation",
18331
+ auth: "admin"
18332
+ }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
18333
+ kind: "query",
18334
+ auth: "admin"
18335
+ }), method(object({
18336
+ deviceId: number(),
18337
+ trackId: string(),
18338
+ frameId: string(),
18339
+ annotations: array(RetrainAnnotationDraftSchema)
18340
+ }), array(RetrainAnnotationSchema).readonly(), {
18341
+ kind: "mutation",
18342
+ auth: "admin"
18343
+ }), method(object({
18344
+ deviceId: number(),
18345
+ trackId: string()
18346
+ }), RetrainTransitionResultSchema, {
17931
18347
  kind: "mutation",
17932
18348
  auth: "admin"
17933
- }), method(object({ nodeId: string() }), object({
17934
- success: literal(true),
17935
- clearedDevices: number()
17936
- }), {
18349
+ }), method(object({
18350
+ deviceId: number(),
18351
+ trackId: string()
18352
+ }), RetrainTransitionResultSchema, {
17937
18353
  kind: "mutation",
17938
18354
  auth: "admin"
17939
- }), 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({
17940
- name: string(),
17941
- steps: array(PipelineTemplateStepSchema).readonly(),
17942
- engine: PipelineEngineChoiceSchema
17943
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
17944
- id: string(),
17945
- name: string().optional(),
17946
- steps: array(PipelineTemplateStepSchema).readonly().optional()
17947
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
17948
- addonId: string(),
17949
- modelId: string(),
17950
- format: ModelFormatSchema$1
17951
- }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
17952
- addonId: string(),
17953
- modelId: string(),
17954
- format: ModelFormatSchema$1
17955
- }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
17956
- engine: PipelineEngineChoiceSchema.optional(),
17957
- steps: array(PipelineStepInputSchema).min(1),
17958
- frame: FrameInputSchema.optional(),
17959
- /**
17960
- * Process-local lazy frame. Valid only when caller and provider resolve
17961
- * in the same execution-group process; split/cross-node callers use
17962
- * `frame`/`image` inline compatibility instead.
17963
- */
17964
- frameRef: FrameRefSchema.optional(),
17965
- /**
17966
- * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
17967
- * the decoded pixels live in. One more member of the one-of
17968
- * frame/frameHandle/image/imageBase64/referenceImage group.
17969
- */
17970
- frameHandle: FrameHandleSchema.optional(),
17971
- imageBase64: string().optional(),
17972
- /**
17973
- * Binary JPEG bytes — preferred over `imageBase64` on internal
17974
- * hops (hub → forked worker via Moleculer MsgPack) because it
17975
- * skips the 33% base64 overhead + the per-call base64 decode on
17976
- * the detection-pipeline worker. Callers can pass either; exactly
17977
- * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
17978
- */
17979
- image: _instanceof(Uint8Array).optional(),
17980
- referenceImage: string().optional(),
17981
- deviceId: number().optional(),
17982
- sessionId: string().optional(),
17983
- /**
17984
- * Execution plane. 'full' (default) runs the whole tree — benchmark,
17985
- * reference-image, and detail-subtree calls. 'frame' is the live
17986
- * per-frame dispatch: ONLY root-plane steps run; crop children
17987
- * (inputClasses ≠ null) are skipped and served per-track via
17988
- * pipelineRunner.runDetailSubtree (two-plane design).
17989
- */
17990
- plane: _enum(["full", "frame"]).optional(),
17991
- /**
17992
- * Inference-device selector (Phase 2 multi-device). Format
17993
- * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
17994
- * Omitted ⇒ the runner's default device (current single-engine
17995
- * behaviour). Selects WHICH device pool of the node runs the call.
17996
- */
17997
- deviceKey: string().optional(),
17998
- /**
17999
- * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
18000
- * when the parent crop was resolved from the frame's retained NATIVE
18001
- * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
18002
- * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
18003
- * resolution from that surface — the SAME quality path faces already
18004
- * had — instead of the downscaled parent tile. `handle` keys the native
18005
- * surface (node-pinned to its owner); `cropFrameSpace` is the parent
18006
- * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
18007
- * the executor's crop-normalized child ROI back into frame-normalized
18008
- * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
18009
- * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
18010
- * (today's behaviour on the fallback path).
18011
- */
18012
- nativeCropRef: NativeCropRefSchema.optional()
18013
- }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
18014
- engine: PipelineEngineChoiceSchema.optional(),
18015
- steps: array(PipelineStepInputSchema).min(1),
18016
- frames: array(FrameInputSchema).min(1).max(255),
18017
- deviceId: number().optional(),
18018
- sessionId: string().optional(),
18019
- /**
18020
- * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
18021
- * the batch to the Python pool's bench preprocess cache
18022
- * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
18023
- * preprocessed ONCE and every later inference is a pure-inference cache
18024
- * hit — the sustained-throughput run measures inference, not
18025
- * decode+preprocess+infer. Omitted/0 for live frames (all different →
18026
- * full preprocess every call, correct). Fresh per sustained run;
18027
- * released via `uncacheFrame`.
18028
- */
18029
- frameId: number().int().nonnegative().optional(),
18030
- /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
18031
- deviceKey: string().optional()
18032
- }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
18033
- data: _instanceof(Uint8Array),
18034
- width: number().int().positive(),
18035
- height: number().int().positive(),
18036
- format: _enum([
18037
- "rgb",
18038
- "bgr",
18039
- "gray"
18040
- ])
18041
- }), object({
18042
- frameId: number(),
18043
- width: number(),
18044
- height: number()
18045
- }), { kind: "mutation" }), method(object({
18046
- stepId: string(),
18047
- frameId: number().int()
18048
- }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
18049
- batchMode: string(),
18050
- windowMs: number(),
18051
- maxBatchSize: number(),
18052
- concurrency: number()
18053
- })), method(_void(), array(object({
18054
- engineKey: string(),
18055
- engine: PipelineEngineChoiceSchema,
18056
- modelsLoaded: array(string()).readonly(),
18057
- inUseByCameras: array(number()).readonly(),
18058
- /**
18059
- * Origin of this resident factory.
18060
- * - `runtime` — main camera-serving engine (no idle TTL).
18061
- * - `warm-override` — benchmark/test override held in the warm
18062
- * cache; auto-disposed after the idle TTL.
18063
- * - `device-pool` — a concurrent per-device pool (Phase 2
18064
- * multi-device, keyed by `deviceKey`) resolved
18065
- * via `resolveDeviceFactory`. Runs alongside the
18066
- * `runtime` engine on a DIFFERENT accelerator
18067
- * (NPU / iGPU / Coral) — this is how the
18068
- * Engines tab shows all pools running at once.
18069
- */
18070
- kind: _enum([
18071
- "runtime",
18072
- "warm-override",
18073
- "device-pool"
18074
- ]),
18075
- /** Native pid of the underlying Python pool (null when no pool). */
18076
- poolPid: number().nullable(),
18077
- /** ms since this factory was last used (null when not warm-tracked). */
18078
- idleMs: number().nullable(),
18079
- /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
18080
- idleTtlMs: number().nullable()
18081
- })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
18082
- kind: "mutation",
18355
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18356
+ kind: "query",
18083
18357
  auth: "admin"
18084
18358
  }), method(object({
18085
- engine: PipelineEngineChoiceSchema,
18086
- force: boolean().optional()
18087
- }), object({
18088
- success: boolean(),
18089
- reason: string().optional()
18090
- }), {
18359
+ eventId: string(),
18360
+ kind: MediaFileKindEnum.optional(),
18361
+ deviceId: number()
18362
+ }), array(MediaFileSchema).readonly()), method(object({
18363
+ trackId: string(),
18364
+ kinds: array(MediaFileKindEnum).optional(),
18365
+ deviceId: number()
18366
+ }), array(MediaFileSchema).readonly()), method(object({
18367
+ trackId: string(),
18368
+ deviceId: number()
18369
+ }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
18091
18370
  kind: "mutation",
18092
18371
  auth: "admin"
18093
- }), 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({
18094
- addonId: string(),
18095
- modelId: string(),
18096
- filename: string().optional(),
18097
- settings: record(string(), unknown()).optional()
18098
- }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
18372
+ }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
18373
+ kind: "mutation",
18374
+ auth: "admin"
18375
+ }), method(object({}), RebuildStatusSchema), object({
18376
+ deviceId: number(),
18377
+ timestamp: number(),
18378
+ frameWidth: number(),
18379
+ frameHeight: number(),
18380
+ detections: array(OverlayDetectionSchema).readonly()
18381
+ }), object({
18382
+ deviceId: number(),
18383
+ trackId: string(),
18384
+ className: string()
18385
+ }), object({
18386
+ deviceId: number(),
18387
+ trackId: string(),
18388
+ className: string(),
18389
+ durationMs: number()
18390
+ }), object({
18391
+ deviceId: number(),
18392
+ kind: EventKindSchema,
18393
+ eventId: string(),
18394
+ timestamp: number()
18395
+ });
18099
18396
  object({
18100
18397
  activeCameras: number(),
18101
18398
  throttledCameras: number(),
@@ -18107,119 +18404,19 @@ var CameraMetricsSchema = object({
18107
18404
  "disabled",
18108
18405
  "always-on",
18109
18406
  "on-motion"
18110
- ]),
18111
- configuredFps: number(),
18112
- actualFps: number(),
18113
- queueDepth: number(),
18114
- avgInferenceTimeMs: number(),
18115
- droppedFrames: number(),
18116
- phase: _enum([
18117
- "idle",
18118
- "watching",
18119
- "active"
18120
- ])
18121
- });
18122
- var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
18123
- /**
18124
- * Zone — pure geometry + identity. NO filtering behaviour.
18125
- *
18126
- * Zones describe **where** in the frame the operator wants to flag
18127
- * something; consumer-owned {@link ZoneRule} arrays describe **how**
18128
- * each pipeline stage uses them. Splitting the two means a single
18129
- * polygon "Driveway" can simultaneously back a motion-exclude rule,
18130
- * a detection-include rule on `['car']`, and an occupancy aggregate
18131
- * — without three duplicated polygons.
18132
- *
18133
- * Owned by the orchestrator addon (provider) and mirrored into the
18134
- * `zones` device-state slice on every mutation. Consumers
18135
- * (motion-wasm, pipeline-executor, analytics, admin UI) read either
18136
- * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
18137
- * mirror with `onChanged`).
18138
- *
18139
- * Coordinates are normalised fractions of the frame (0–1) so zones
18140
- * survive resolution changes and stream profile switches.
18141
- *
18142
- * `kind` discriminates between full polygons (closed regions used
18143
- * for intrusion / occupancy filters) and tripwires (open 2-point
18144
- * line segments used for cross events). Onboard / firmware-reported
18145
- * zones (Reolink, ONVIF) are out of scope for now — see the deferred
18146
- * task list.
18147
- */
18148
- var ZoneKindEnum = _enum(["polygon", "tripwire"]);
18149
- /** Polygon vertex in fraction-of-frame coordinates (0–1). */
18150
- var PolygonPointSchema = object({
18151
- x: number(),
18152
- y: number()
18153
- });
18154
- /** A camera detection zone — pure geometry/identity. */
18155
- var ZoneSchema = object({
18156
- id: string(),
18157
- name: string(),
18158
- kind: ZoneKindEnum.default("polygon"),
18159
- /** Polygon vertices, fraction of frame (0–1). */
18160
- polygon: array(PolygonPointSchema).readonly(),
18161
- /** Visual color for UI rendering. */
18162
- color: string().default("#3b82f6")
18407
+ ]),
18408
+ configuredFps: number(),
18409
+ actualFps: number(),
18410
+ queueDepth: number(),
18411
+ avgInferenceTimeMs: number(),
18412
+ droppedFrames: number(),
18413
+ phase: _enum([
18414
+ "idle",
18415
+ "watching",
18416
+ "active"
18417
+ ])
18163
18418
  });
18164
- /**
18165
- * Zones capability — per-camera CRUD over polygon detection zones.
18166
- *
18167
- * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
18168
- * to per-device settings and mirrors into the `zones` device-state
18169
- * slice on every mutation, so downstream consumers can subscribe via
18170
- * `dev.state.zones.onChanged`.
18171
- *
18172
- * The cap surface only handles geometry + identity; filtering
18173
- * behaviour (per-class, include/exclude, threshold) lives in the
18174
- * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
18175
- * `capabilities/schemas/zone-rule.js`.
18176
- */
18177
- var zonesCapability = {
18178
- name: "zones",
18179
- scope: "device",
18180
- mode: "singleton",
18181
- deviceTypes: [DeviceType.Camera],
18182
- methods: {
18183
- listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
18184
- addZone: method(object({
18185
- deviceId: number(),
18186
- zone: ZoneSchema
18187
- }), _void(), {
18188
- kind: "mutation",
18189
- auth: "admin"
18190
- }),
18191
- removeZone: method(object({
18192
- deviceId: number(),
18193
- zoneId: string()
18194
- }), _void(), {
18195
- kind: "mutation",
18196
- auth: "admin"
18197
- }),
18198
- updateZone: method(object({
18199
- deviceId: number(),
18200
- zone: ZoneSchema
18201
- }), _void(), {
18202
- kind: "mutation",
18203
- auth: "admin"
18204
- })
18205
- },
18206
- /**
18207
- * Runtime-state slice — the live zone catalogue mirrored by the
18208
- * orchestrator on every CRUD mutation. Consumers read via
18209
- * `device.state.zones.value` / `.watch(...)` without round-tripping
18210
- * the cap, and the codegen DeviceProxy auto-wires the reactive
18211
- * handle. Slice shape is `{ zones: Zone[] }` so future extensions
18212
- * (e.g. zone groupings) can sit alongside the polygon list.
18213
- */
18214
- runtimeState: object({ zones: array(ZoneSchema).readonly() }),
18215
- /**
18216
- * 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.
18217
- *
18218
- * See `RuntimeStateDurability`. Enforced by
18219
- * `scripts/check-runtime-state-durability.ts`.
18220
- */
18221
- durability: "restored"
18222
- };
18419
+ var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
18223
18420
  /**
18224
18421
  * A bounding box in NORMALIZED [0,1] frame coordinates for `getNativeCrop`. The
18225
18422
  * decode worker resolves it against the RETAINED native frame's real pixel dims,
@@ -19908,7 +20105,7 @@ method(object({
19908
20105
  * linking rather than produce an eternal token.
19909
20106
  */
19910
20107
  ttlSec: union([number().int().positive(), literal("never")]).optional()
19911
- }), object({ token: string() })), method(object({ token: string() }), SsoBridgeClaimsSchema.nullable());
20108
+ }), object({ token: string() }), { auth: "admin" }), method(object({ token: string() }), SsoBridgeClaimsSchema.nullable(), { auth: "admin" });
19912
20109
  var ProviderListEntrySchema = discriminatedUnion("shouldSaveDiskSpace", [object({
19913
20110
  providerId: string().min(1),
19914
20111
  displayName: string().min(1),
@@ -20003,10 +20200,13 @@ var EvictResultSchema = object({
20003
20200
  /** True when the provider has nothing left it is willing to drop on this location. */
20004
20201
  exhausted: boolean()
20005
20202
  });
20006
- method(object({ locationId: string() }), EvictableUsageSchema), method(object({
20203
+ method(object({ locationId: string() }), EvictableUsageSchema, { auth: "admin" }), method(object({
20007
20204
  locationId: string(),
20008
20205
  targetBytes: number().int().positive()
20009
- }), EvictResultSchema, { kind: "mutation" });
20206
+ }), EvictResultSchema, {
20207
+ kind: "mutation",
20208
+ auth: "admin"
20209
+ });
20010
20210
  method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin" }), method(StorageMigrationInputSchema, object({ jobId: string() }), {
20011
20211
  kind: "mutation",
20012
20212
  auth: "admin"
@@ -20066,26 +20266,50 @@ var ReadChunkInputSchema = object({
20066
20266
  length: number()
20067
20267
  });
20068
20268
  var EndDownloadInputSchema = object({ downloadId: string() });
20069
- method(_void(), ProviderInfoSchema), method(object({ config: record(string(), unknown()) }), TestLocationResultSchema, { auth: "admin" }), method(object({
20269
+ method(_void(), ProviderInfoSchema, { auth: "admin" }), method(object({ config: record(string(), unknown()) }), TestLocationResultSchema, { auth: "admin" }), method(object({
20070
20270
  location: StorageLocationSchema,
20071
20271
  relativePath: string()
20072
- }), string()), method(object({
20272
+ }), string(), { auth: "admin" }), method(object({
20073
20273
  location: StorageLocationSchema,
20074
20274
  relativePath: string(),
20075
20275
  data: _instanceof(Uint8Array)
20076
- }), _void(), { kind: "mutation" }), method(object({
20276
+ }), _void(), {
20277
+ kind: "mutation",
20278
+ auth: "admin"
20279
+ }), method(object({
20077
20280
  location: StorageLocationSchema,
20078
20281
  relativePath: string()
20079
- }), _instanceof(Uint8Array)), method(object({
20282
+ }), _instanceof(Uint8Array), { auth: "admin" }), method(object({
20080
20283
  location: StorageLocationSchema,
20081
20284
  relativePath: string()
20082
- }), boolean()), method(object({
20285
+ }), boolean(), { auth: "admin" }), method(object({
20083
20286
  location: StorageLocationSchema,
20084
20287
  prefix: string().optional()
20085
- }), array(string()).readonly()), method(object({
20288
+ }), array(string()).readonly(), { auth: "admin" }), method(object({
20086
20289
  location: StorageLocationSchema,
20087
20290
  relativePath: string()
20088
- }), _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" });
20291
+ }), _void(), {
20292
+ kind: "mutation",
20293
+ auth: "admin"
20294
+ }), method(object({ location: StorageLocationSchema }), number().nullable(), { auth: "admin" }), method(BeginUploadInputSchema, BeginUploadResultSchema, {
20295
+ kind: "mutation",
20296
+ auth: "admin"
20297
+ }), method(WriteChunkInputSchema, _void(), {
20298
+ kind: "mutation",
20299
+ auth: "admin"
20300
+ }), method(FinalizeUploadInputSchema, _void(), {
20301
+ kind: "mutation",
20302
+ auth: "admin"
20303
+ }), method(AbortUploadInputSchema, _void(), {
20304
+ kind: "mutation",
20305
+ auth: "admin"
20306
+ }), method(BeginDownloadInputSchema, BeginDownloadResultSchema, {
20307
+ kind: "mutation",
20308
+ auth: "admin"
20309
+ }), method(ReadChunkInputSchema, _instanceof(Uint8Array), { auth: "admin" }), method(EndDownloadInputSchema, _void(), {
20310
+ kind: "mutation",
20311
+ auth: "admin"
20312
+ });
20089
20313
  /** Profile-exported FormBuilder schema. Shape is ConfigUISchema at the UI. */
20090
20314
  var ProfileSettingsSchemaBridge = unknown().nullable();
20091
20315
  var ProfileSettingsBagSchema = record(string(), unknown());
@@ -20343,7 +20567,8 @@ method(object({
20343
20567
  access: "create"
20344
20568
  }), method(object({ userId: string().optional() }), object({ optionsJSON: record(string(), unknown()) }), {
20345
20569
  kind: "mutation",
20346
- access: "view"
20570
+ access: "view",
20571
+ auth: "admin"
20347
20572
  }), method(object({
20348
20573
  /** Required — the user the assertion belongs to (verified). */
20349
20574
  userId: string(),
@@ -20351,10 +20576,12 @@ method(object({
20351
20576
  response: record(string(), unknown())
20352
20577
  }), object({ verified: boolean() }), {
20353
20578
  kind: "mutation",
20354
- access: "view"
20579
+ access: "view",
20580
+ auth: "admin"
20355
20581
  }), method(object({}), object({ optionsJSON: record(string(), unknown()) }), {
20356
20582
  kind: "mutation",
20357
- access: "view"
20583
+ access: "view",
20584
+ auth: "admin"
20358
20585
  }), method(object({
20359
20586
  /** AuthenticationResponseJSON from the browser. */
20360
20587
  response: record(string(), unknown()) }), object({
@@ -20362,7 +20589,8 @@ response: record(string(), unknown()) }), object({
20362
20589
  userId: string().nullable()
20363
20590
  }), {
20364
20591
  kind: "mutation",
20365
- access: "view"
20592
+ access: "view",
20593
+ auth: "admin"
20366
20594
  }), method(object({ userId: string() }), array(PasskeySummarySchema), { auth: "admin" }), method(object({
20367
20595
  userId: string(),
20368
20596
  credentialId: string()
@@ -20534,7 +20762,19 @@ var VectorStatsResultSchema = object({
20534
20762
  /** False when the backend ranks approximately. */
20535
20763
  exact: boolean()
20536
20764
  });
20537
- 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);
20765
+ method(VectorDeclareIndexInputSchema, _void(), {
20766
+ kind: "mutation",
20767
+ auth: "admin"
20768
+ }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
20769
+ kind: "mutation",
20770
+ auth: "admin"
20771
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
20772
+ kind: "mutation",
20773
+ auth: "admin"
20774
+ }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
20775
+ kind: "mutation",
20776
+ auth: "admin"
20777
+ }), method(VectorStatsInputSchema, VectorStatsResultSchema, { auth: "admin" });
20538
20778
  var ClipSchema = object({
20539
20779
  /** Opaque, provider-namespaced id. The default provider encodes the time
20540
20780
  * window so `getClipPlayback` is self-contained (no event re-query). */
@@ -22995,7 +23235,27 @@ var MediaFileLiteSchema$1 = object({
22995
23235
  sizeBytes: number(),
22996
23236
  timestamp: number()
22997
23237
  });
22998
- method(_void(), array(IdentitySchema).readonly()), method(object({ name: string().min(1) }), IdentitySchema, {
23238
+ method(object({
23239
+ /**
23240
+ * Inline {@link IdentitySchema.coverBase64} on every row.
23241
+ *
23242
+ * Default `false`, the same inversion `listRecentFaces` and
23243
+ * `listPlates` took on 2026-08-25 (see `include-crops-default.ts` for
23244
+ * why the burden belongs on the caller that WANTS the bytes). Measured
23245
+ * on the live hub the same day: four identities cost 40,979 B with the
23246
+ * covers inline, ~10 KB of base64 per row, on a query this UI mounts
23247
+ * four times and the viewer holds at `staleTime: 30_000`.
23248
+ *
23249
+ * Nothing loses its avatar: `coverMediaKey` is already on every row and
23250
+ * the `event-media` plane serves that key `immutable` with an ETag.
23251
+ *
23252
+ * **This is an INPUT field, so it does not reach the addon until the
23253
+ * next train** — the hub router validates cap inputs against its own
23254
+ * compiled Zod and strips a key it does not know. Until then the
23255
+ * provider sees `undefined`, which resolves to `false`: the cheap shape
23256
+ * is what ships, and the opt-in becomes reachable when the train lands.
23257
+ */
23258
+ includeCrops: boolean().optional() }).optional(), array(IdentitySchema).readonly()), method(object({ name: string().min(1) }), IdentitySchema, {
22999
23259
  kind: "mutation",
23000
23260
  auth: "admin"
23001
23261
  }), method(object({
@@ -25885,8 +26145,10 @@ var PlateInfoSchema = object({
25885
26145
  keyFrameMediaKey: string().optional(),
25886
26146
  base64: string().optional(),
25887
26147
  /**
25888
- * Same crop as a data-plane URL. `getPlateByTrack` returns this and
25889
- * never inlines JPEG; `listPlates` still inlines for the admin-ui.
26148
+ * Same crop as a data-plane URL, always present when the plate has a stored
26149
+ * crop. `getPlateByTrack` returns this and never inlines JPEG; `listPlates`
26150
+ * and `searchPlates` inline the crop only when their `includeCrops` input is
26151
+ * left at its `true` default.
25890
26152
  */
25891
26153
  cropUrl: string().optional()
25892
26154
  });
@@ -25906,14 +26168,34 @@ var PlateClusterSchema = object({
25906
26168
  });
25907
26169
  method(object({
25908
26170
  deviceId: number().int().optional(),
25909
- limit: number().int().positive().optional()
26171
+ limit: number().int().positive().optional(),
26172
+ /**
26173
+ * Inline the base64 crop on every row. Default `true` — the existing
26174
+ * behaviour, kept so no caller breaks.
26175
+ *
26176
+ * Set `false` once the caller renders {@link PlateInfo.cropUrl}.
26177
+ * Measured on the live hub at the 500 rows the Plates view asks for:
26178
+ * 879,403 B and 27.7 s with the crops inline, against a few KiB of
26179
+ * metadata without them — and the browser then caches the images.
26180
+ *
26181
+ * This is the plate twin of `faceGallery.listRecentFaces`'s option;
26182
+ * plates were the one gallery list left without it.
26183
+ *
26184
+ * **This is an INPUT field, so it does not reach the addon until the
26185
+ * next train.** The hub router validates cap inputs against its own
26186
+ * compiled Zod and strips a key it does not know. Until the train
26187
+ * ships, sending `false` is harmless and keeps the crops inline.
26188
+ */
26189
+ includeCrops: boolean().optional()
25910
26190
  }).optional(), array(PlateInfoSchema).readonly()), method(object({
25911
26191
  deviceId: number().int(),
25912
26192
  trackId: string()
25913
26193
  }), PlateInfoSchema.nullable()), method(object({ plateId: string() }), array(MediaFileLiteSchema).readonly()), method(object({
25914
26194
  text: string().min(1),
25915
26195
  maxDistance: number().int().min(0).optional(),
25916
- limit: number().int().positive().optional()
26196
+ limit: number().int().positive().optional(),
26197
+ /** See `listPlates.includeCrops`. Default `true`. */
26198
+ includeCrops: boolean().optional()
25917
26199
  }), array(PlateInfoSchema).readonly()), method(object({
25918
26200
  maxDistance: number().int().min(0).optional(),
25919
26201
  minClusterSize: number().int().min(2).optional(),
@@ -25927,7 +26209,13 @@ method(object({
25927
26209
  }), method(object({ plateId: string() }), _void(), {
25928
26210
  kind: "mutation",
25929
26211
  auth: "admin"
25930
- }), method(_void(), array(VehicleSchema).readonly()), method(object({ name: string().min(1) }), VehicleSchema, {
26212
+ }), method(object({
26213
+ /** Inline {@link VehicleSchema.coverBase64} on every row. Default
26214
+ * `false` — the vehicle twin of `faceGallery.listIdentities`'s
26215
+ * option; `coverMediaKey` + the `event-media` plane carry the picture.
26216
+ * INPUT field: stripped by the hub router until the train ships, which
26217
+ * resolves to `false` and is exactly the intended default. */
26218
+ includeCrops: boolean().optional() }).optional(), array(VehicleSchema).readonly()), method(object({ name: string().min(1) }), VehicleSchema, {
25931
26219
  kind: "mutation",
25932
26220
  auth: "admin"
25933
26221
  }), method(object({
@@ -27448,92 +27736,6 @@ var sceneMonitorCapability = {
27448
27736
  durability: "session"
27449
27737
  };
27450
27738
  /**
27451
- * Per-stage gating mode applied to the zones a rule references.
27452
- *
27453
- * - `include`: the rule contributes to a **whitelist** for its stage.
27454
- * When at least one `include` rule fires for a stage, only entities
27455
- * inside one of those zones pass that stage.
27456
- * - `exclude`: the rule contributes to a **blacklist** for its stage.
27457
- * Entities inside one of those zones are dropped at that stage.
27458
- *
27459
- * `monitor`-style observation (count without filtering) is not a rule
27460
- * mode — zones without any matching rule are observed naturally by
27461
- * `zone-analytics` (live snapshot + history), so an "I just want to
27462
- * count, not filter" use case needs no rule at all.
27463
- */
27464
- var ZoneRuleModeEnum = _enum(["include", "exclude"]);
27465
- /**
27466
- * Per-consumer rule that references existing zones (geometry) and
27467
- * defines how a specific pipeline stage should treat them. Each
27468
- * consumer addon owns its own `ZoneRule[]` array in its per-device
27469
- * settings:
27470
- *
27471
- * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
27472
- * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
27473
- * - future: notification rules, audio gating, etc.
27474
- *
27475
- * One rule applies to N zones (`zoneIds[]`) so the operator can
27476
- * express "ignore motion in ALL of {garden, street}" with a single
27477
- * rule. `classFilter` narrows the rule to specific object classes —
27478
- * "drop person detections in the street, but keep cars" is one
27479
- * `exclude` rule with `classFilter: ['person']`.
27480
- *
27481
- * `enabled` is a soft toggle — the operator can keep the rule
27482
- * configured but inert without deleting it.
27483
- */
27484
- var ZoneRuleSchema = object({
27485
- /** Stable rule id — survives edits, used by the UI for diffing. */
27486
- id: string(),
27487
- /** Optional human-readable label rendered in the rule editor. */
27488
- name: string().optional(),
27489
- /** Zones this rule targets. The rule's `mode` applies to ALL
27490
- * listed zones (OR-set: a detection in any one of them counts).
27491
- * At least one zone id required — a rule with no targets is a
27492
- * configuration mistake and the form validator rejects it. */
27493
- zoneIds: array(string()).min(1).readonly(),
27494
- mode: ZoneRuleModeEnum,
27495
- /**
27496
- * Class names this rule applies to. Empty / undefined ⇒ rule
27497
- * applies to every class. Class strings match the `macroClass`
27498
- * field on detections (e.g. `person`, `car`, `dog`).
27499
- */
27500
- classFilter: array(string()).readonly().optional(),
27501
- /**
27502
- * Minimum bbox/mask overlap (0–1) with any of the rule's zones
27503
- * required to consider an entity "in the zone". Defaults to the
27504
- * consumer's stage default when omitted. Kept for back-compat with
27505
- * existing per-rule overrides; new operators pick the value via
27506
- * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
27507
- * set, the lower-level engine reads it as a 0–1 fraction.
27508
- */
27509
- overlapThreshold: number().min(0).max(1).optional(),
27510
- /**
27511
- * Operator-friendly version of `overlapThreshold` — the percentage
27512
- * of the detection's bbox that must lie inside the zone for the
27513
- * rule to match. Documented default is 85%; the engine substitutes
27514
- * that when the field is omitted (kept optional so existing rules
27515
- * stored without it stay valid).
27516
- *
27517
- * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
27518
- * rule, the engine prefers `bboxInclusionPct` because it's the
27519
- * field exposed in the UI. Internally both feed the same gate.
27520
- */
27521
- bboxInclusionPct: number().min(0).max(100).optional(),
27522
- /**
27523
- * When `true` and a detection has a segmentation mask, use the
27524
- * mask for overlap instead of the bbox. Detection-stage only;
27525
- * motion rules ignore this field.
27526
- */
27527
- preferMask: boolean().optional(),
27528
- /**
27529
- * Soft-toggle: `false` disables the rule without deleting it.
27530
- * Defaults to `true` so operators creating a rule via the UI
27531
- * see it active immediately.
27532
- */
27533
- enabled: boolean().default(true)
27534
- });
27535
- array(ZoneRuleSchema).readonly();
27536
- /**
27537
27739
  * Script-runner cap. Models HA `script.*` entities on
27538
27740
  * `DeviceType.Script`. A Script is a pre-recorded action sequence
27539
27741
  * that can be invoked imperatively — optionally with a variables
@@ -33188,6 +33390,12 @@ Object.freeze({
33188
33390
  addonId: null,
33189
33391
  access: "create"
33190
33392
  },
33393
+ "pipelineAnalytics.cancelRelocateMedia": {
33394
+ capName: "pipeline-analytics",
33395
+ capScope: "device",
33396
+ addonId: null,
33397
+ access: "create"
33398
+ },
33191
33399
  "pipelineAnalytics.cancelStorageMigrationMove": {
33192
33400
  capName: "pipeline-analytics",
33193
33401
  capScope: "device",
@@ -33362,6 +33570,12 @@ Object.freeze({
33362
33570
  addonId: null,
33363
33571
  access: "view"
33364
33572
  },
33573
+ "pipelineAnalytics.listRelocateMediaJobs": {
33574
+ capName: "pipeline-analytics",
33575
+ capScope: "device",
33576
+ addonId: null,
33577
+ access: "view"
33578
+ },
33365
33579
  "pipelineAnalytics.listRetrainAnnotations": {
33366
33580
  capName: "pipeline-analytics",
33367
33581
  capScope: "device",
@@ -33440,6 +33654,12 @@ Object.freeze({
33440
33654
  addonId: null,
33441
33655
  access: "create"
33442
33656
  },
33657
+ "pipelineAnalytics.relocateMedia": {
33658
+ capName: "pipeline-analytics",
33659
+ capScope: "device",
33660
+ addonId: null,
33661
+ access: "create"
33662
+ },
33443
33663
  "pipelineAnalytics.restageRetrainTrack": {
33444
33664
  capName: "pipeline-analytics",
33445
33665
  capScope: "device",
@@ -33452,6 +33672,12 @@ Object.freeze({
33452
33672
  addonId: null,
33453
33673
  access: "create"
33454
33674
  },
33675
+ "pipelineAnalytics.runReplayFrameProcessor": {
33676
+ capName: "pipeline-analytics",
33677
+ capScope: "device",
33678
+ addonId: null,
33679
+ access: "create"
33680
+ },
33455
33681
  "pipelineAnalytics.saveRetrainAnnotations": {
33456
33682
  capName: "pipeline-analytics",
33457
33683
  capScope: "device",
@@ -33584,6 +33810,12 @@ Object.freeze({
33584
33810
  addonId: null,
33585
33811
  access: "view"
33586
33812
  },
33813
+ "pipelineExecutor.getInferenceDeviceHealth": {
33814
+ capName: "pipeline-executor",
33815
+ capScope: "system",
33816
+ addonId: null,
33817
+ access: "view"
33818
+ },
33587
33819
  "pipelineExecutor.getOrchestratorConfigSchema": {
33588
33820
  capName: "pipeline-executor",
33589
33821
  capScope: "system",
@@ -33656,6 +33888,12 @@ Object.freeze({
33656
33888
  addonId: null,
33657
33889
  access: "view"
33658
33890
  },
33891
+ "pipelineExecutor.rearmInferenceDevice": {
33892
+ capName: "pipeline-executor",
33893
+ capScope: "system",
33894
+ addonId: null,
33895
+ access: "create"
33896
+ },
33659
33897
  "pipelineExecutor.runAudioTest": {
33660
33898
  capName: "pipeline-executor",
33661
33899
  capScope: "system",
@@ -36904,6 +37142,11 @@ Object.freeze({
36904
37142
  form: "single",
36905
37143
  optional: false
36906
37144
  }],
37145
+ "pipelineAnalytics.runReplayFrameProcessor": [{
37146
+ name: "deviceId",
37147
+ form: "single",
37148
+ optional: false
37149
+ }],
36907
37150
  "pipelineAnalytics.saveRetrainAnnotations": [{
36908
37151
  name: "deviceId",
36909
37152
  form: "single",