@camstack/addon-ai 0.4.21 → 0.4.23

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 +2098 -1842
  2. package/dist/addon.mjs +2098 -1842
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -6852,7 +6852,7 @@ function method(input, output, options) {
6852
6852
  input,
6853
6853
  output,
6854
6854
  kind: options?.kind ?? "query",
6855
- auth: options?.auth ?? "protected",
6855
+ ...options?.auth !== void 0 ? { auth: options.auth } : {},
6856
6856
  ...options?.access !== void 0 ? { access: options.access } : {},
6857
6857
  ...options?.caller !== void 0 ? { caller: options.caller } : {},
6858
6858
  timeoutMs: options?.timeoutMs
@@ -6872,7 +6872,7 @@ function systemMethod(input, output, options) {
6872
6872
  }
6873
6873
  var StaticDirOutputSchema$1 = object({ staticDir: string() });
6874
6874
  var VersionOutputSchema$1 = object({ version: string() });
6875
- method(_void(), StaticDirOutputSchema$1), method(_void(), VersionOutputSchema$1);
6875
+ method(_void(), StaticDirOutputSchema$1, { auth: "admin" }), method(_void(), VersionOutputSchema$1, { auth: "admin" });
6876
6876
  var DeviceType = /* @__PURE__ */ function(DeviceType) {
6877
6877
  DeviceType["Camera"] = "camera";
6878
6878
  DeviceType["Hub"] = "hub";
@@ -7193,7 +7193,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
7193
7193
  }({});
7194
7194
  var StaticDirOutputSchema = object({ staticDir: string() });
7195
7195
  var VersionOutputSchema = object({ version: string() });
7196
- method(_void(), StaticDirOutputSchema), method(_void(), VersionOutputSchema);
7196
+ method(_void(), StaticDirOutputSchema, { auth: "admin" }), method(_void(), VersionOutputSchema, { auth: "admin" });
7197
7197
  /**
7198
7198
  * device-ops — device-scoped cap that unifies the per-IDevice operations
7199
7199
  * previously routed through the `.device-ops` Moleculer bridge service.
@@ -7807,24 +7807,6 @@ var RecordingRetentionSchema = object({
7807
7807
  maxSizeGb: number$1().min(0).optional()
7808
7808
  });
7809
7809
  /**
7810
- * Scrub-thumbnail fidelity preset — the single per-camera selector bundling the
7811
- * sprite tile RESOLUTION + JPEG QUALITY the recorder packs timeline-scrub
7812
- * previews at. Five graduated steps; absent on a config = `standard` (the
7813
- * shipped default, matching `sheet-geometry`/`sheet-composer`).
7814
- *
7815
- * Existing sheets are IMMUTABLE — a changed preset applies to NEW windows only.
7816
- * Each window's index sidecar carries its own tile dims, so a camera whose
7817
- * preset changed over time renders every historical window at the dims it was
7818
- * written with.
7819
- */
7820
- var ScrubThumbnailPresetSchema = _enum([
7821
- "minimal",
7822
- "low",
7823
- "standard",
7824
- "high",
7825
- "max"
7826
- ]);
7827
- /**
7828
7810
  * The full per-camera recording intent — the wire shape of a RecordingTarget.
7829
7811
  *
7830
7812
  * `bands` is the ONLY authored recording intent: what to record, when, and on
@@ -7832,7 +7814,11 @@ var ScrubThumbnailPresetSchema = _enum([
7832
7814
  * other field is a storage knob (profiles, segment length, retention, scrub).
7833
7815
  *
7834
7816
  * STRICT on purpose: the legacy authoring surface (`schedule`/`schedules`/
7835
- * `triggers`/`preBufferSec`/`postBufferSec`/`rules`) was retired 2026-07-30.
7817
+ * `triggers`/`preBufferSec`/`postBufferSec`/`rules`) was retired 2026-07-30,
7818
+ * and `scrubThumbnails` — a five-step fidelity knob for a sprite tier that was
7819
+ * deleted on 2026-07-24 and had ZERO consumers in the recorder — on 2026-08-25
7820
+ * (D62: a switch that writes a store nobody reads is worse than no switch).
7821
+ * Stored rows keep loading: the READ schema is `.strip()` (config-store.ts).
7836
7822
  * A stale caller must fail loudly — silently stripping its legacy intent would
7837
7823
  * persist a band-less config, i.e. silently stop recording the camera.
7838
7824
  */
@@ -7855,14 +7841,7 @@ var RecordingConfigSchema = object({
7855
7841
  * "off" is the absence of a covering band, never a band value.
7856
7842
  */
7857
7843
  bands: array(RecordingBandSchema).default([]),
7858
- retention: RecordingRetentionSchema.optional(),
7859
- /**
7860
- * Per-camera scrub-thumbnail fidelity preset (resolution + JPEG quality for
7861
- * timeline-scrub sprite previews). Absent = `standard`. Applies to NEW
7862
- * windows only — existing sheets are immutable, and each window's index
7863
- * carries its own tile dims so mixed-preset history renders correctly.
7864
- */
7865
- scrubThumbnails: ScrubThumbnailPresetSchema.optional()
7844
+ retention: RecordingRetentionSchema.optional()
7866
7845
  }).strict();
7867
7846
  /**
7868
7847
  * Entity-relocation job state (storage entity-routing spec, Phase 4).
@@ -7938,10 +7917,11 @@ var RelocateFootageInputSchema = object({
7938
7917
  * `RecordingConfig.enabled` or camera wrapper bindings. */
7939
7918
  var StorageMigrationLeaseInputSchema = object({ leaseId: string().min(1) });
7940
7919
  var StorageMigrationFootageMoveInputSchema = RelocateFootageInputSchema.extend({ leaseId: string().min(1) });
7941
- var StorageMigrationMediaMoveInputSchema = object({
7920
+ var RelocateMediaInputSchema = object({
7942
7921
  toLocationId: string(),
7943
7922
  throttleMbps: number$1().min(1).max(1e3).optional()
7944
- }).extend({ leaseId: string().min(1) });
7923
+ });
7924
+ var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
7945
7925
  /** The independently selectable logical storage classes. `recordings`
7946
7926
  * encompasses the high and mid segment profiles; `recordingsLow` is low
7947
7927
  * segments; `eventMedia` is post-analysis blobs. */
@@ -8236,7 +8216,26 @@ var LabelDefinitionSchema = object({
8236
8216
  description: string().optional(),
8237
8217
  icon: string().optional()
8238
8218
  });
8239
- var ClassMapDefinitionSchema = object({
8219
+ /**
8220
+ * Wire schema for a per-model CATALOG classMap override
8221
+ * (`ModelCatalogEntry.classMap` / `ModelConvertMetadata.classMap`) —
8222
+ * restricted to {@link CLASS_MAP_MACRO_TARGETS}, the only macros the
8223
+ * detection pipeline executor actually routes.
8224
+ *
8225
+ * This is deliberately a DIFFERENT, narrower shape than the general-purpose
8226
+ * `ClassMapDefinition` interface above (e.g. `IDetectionAddon.getClassMap()`
8227
+ * and the audio `YAMNET_TO_MACRO` catalog both use macro targets outside this
8228
+ * enum) — the two used to share the name `ClassMapDefinition`/
8229
+ * `ClassMapDefinitionSchema`, which made the schema-type-twin guard
8230
+ * (`scripts/check-schema-type-twins.ts`) flag them as a duplicated shape. They
8231
+ * are not: it is two different concepts colliding on a name. Keep this type
8232
+ * under its own name rather than reusing `ClassMapDefinition` — reusing it
8233
+ * would either narrow every `ClassMapDefinition` consumer to the four
8234
+ * detection macros (breaking `YAMNET_TO_MACRO`) or drop the validation this
8235
+ * schema exists for (see the "rejects a classMap whose target is not a
8236
+ * detection macro" test in `model-catalog-schema.test.ts`).
8237
+ */
8238
+ var DetectionCatalogClassMapSchema = object({
8240
8239
  mapping: record(string(), _enum([
8241
8240
  "person",
8242
8241
  "vehicle",
@@ -8441,7 +8440,7 @@ var ModelCatalogEntrySchema = object({
8441
8440
  * applies (Frigate / COCO public catalog). Set on a custom model whose raw
8442
8441
  * labels already ARE the CamStack macros (Scrypted identity map).
8443
8442
  */
8444
- classMap: ClassMapDefinitionSchema.optional()
8443
+ classMap: DetectionCatalogClassMapSchema.optional()
8445
8444
  });
8446
8445
  var ConvertTargetSchema = discriminatedUnion("format", [object({
8447
8446
  format: literal("openvino"),
@@ -8471,7 +8470,7 @@ var ModelConvertMetadataSchema = object({
8471
8470
  "segmentation"
8472
8471
  ]),
8473
8472
  faceAlignment: boolean().optional(),
8474
- classMap: ClassMapDefinitionSchema.optional()
8473
+ classMap: DetectionCatalogClassMapSchema.optional()
8475
8474
  });
8476
8475
  var ConvertResultSchema = object({
8477
8476
  entry: ModelCatalogEntrySchema,
@@ -9334,7 +9333,7 @@ var AddonPageDeclarationSchema = object({
9334
9333
  /** Display label for a CUSTOM `section` id (ignored for well-known ids). */
9335
9334
  sectionLabel: string().optional()
9336
9335
  });
9337
- method(_void(), array(AddonPageDeclarationSchema).readonly());
9336
+ method(_void(), array(AddonPageDeclarationSchema).readonly(), { auth: "admin" });
9338
9337
  var AddonHttpRouteSchema = object({
9339
9338
  method: _enum([
9340
9339
  "GET",
@@ -9569,7 +9568,7 @@ var WidgetMetadataSchema = object({
9569
9568
  defaultColumns: number$1().int().min(1).max(12).default(6),
9570
9569
  defaultRows: number$1().int().min(1).max(12).default(1)
9571
9570
  });
9572
- method(_void(), array(WidgetMetadataSchema).readonly());
9571
+ method(_void(), array(WidgetMetadataSchema).readonly(), { auth: "admin" });
9573
9572
  /**
9574
9573
  * `addon-widgets` — system-scoped singleton aggregator cap. Public-facing
9575
9574
  * surface that admin-ui consumes through `useAddonWidgetsListWidgets()`.
@@ -11091,7 +11090,7 @@ var CustomModelDescriptorSchema = object({
11091
11090
  stepId: string(),
11092
11091
  entry: ModelCatalogEntrySchema
11093
11092
  });
11094
- method(_void(), array(CustomModelDescriptorSchema).readonly());
11093
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
11095
11094
  /**
11096
11095
  * Query filter for settings-store collections.
11097
11096
  */
@@ -11178,7 +11177,8 @@ method(object({
11178
11177
  }), _void(), { kind: "mutation" }), method(object({
11179
11178
  namespace: string().optional(),
11180
11179
  collection: string(),
11181
- filter: QueryFilterSchema.optional()
11180
+ filter: QueryFilterSchema.optional(),
11181
+ columns: array(string()).readonly().optional()
11182
11182
  }), array(SettingsRecordSchema).readonly()), method(object({
11183
11183
  namespace: string().optional(),
11184
11184
  collection: string(),
@@ -11241,46 +11241,87 @@ var EngineInfoSchema = object({
11241
11241
  kind: _enum(["relational", "vector"]),
11242
11242
  displayName: string()
11243
11243
  });
11244
- method(_void(), EngineInfoSchema), method(object({
11244
+ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
11245
11245
  namespace: string().optional(),
11246
11246
  collection: string(),
11247
11247
  key: string()
11248
- }), unknown()), method(object({
11248
+ }), unknown(), { auth: "admin" }), method(object({
11249
11249
  namespace: string().optional(),
11250
11250
  collection: string(),
11251
11251
  key: string(),
11252
11252
  value: unknown()
11253
- }), _void(), { kind: "mutation" }), method(object({
11253
+ }), _void(), {
11254
+ kind: "mutation",
11255
+ auth: "admin"
11256
+ }), method(object({
11254
11257
  namespace: string().optional(),
11255
11258
  collection: string(),
11256
- filter: QueryFilterSchema.optional()
11257
- }), array(SettingsRecordSchema).readonly()), method(object({
11259
+ filter: QueryFilterSchema.optional(),
11260
+ /**
11261
+ * SQL-level column projection — MUST mirror `settings-store.query`.
11262
+ *
11263
+ * ⚠ An earlier version of this comment blamed Zod stripping, and that
11264
+ * was wrong — corrected 2026-08-26 after the hop map
11265
+ * (`docs/design/2026-08-26-mappa-hop-argomenti.md`) traced the path.
11266
+ * There is **no Zod parse at all** between the door and the engine: the
11267
+ * dispatcher forwards the payload verbatim and UDS carries it whole. A
11268
+ * field declared here reaches `SqliteSettingsBackend` either way.
11269
+ *
11270
+ * What actually lost `columns` was the THIRD declaration of this shape:
11271
+ * `SettingsQueryInput` in `interfaces/storage.ts`, a hand-written TS
11272
+ * interface the engine destructures from. The field existed on both
11273
+ * schemas and the engine still never read it, because nothing checks a
11274
+ * registered provider against `InferProvider<cap>` —
11275
+ * `ProviderRegistration.provider` is typed `object`.
11276
+ *
11277
+ * It is declared here anyway, and must stay in step with
11278
+ * `settings-store.query`: a caller reading only the cap definitions has
11279
+ * to be able to see that this call carries a projection.
11280
+ * `data-door-schema-parity.spec.ts` keeps the two aligned.
11281
+ */
11282
+ columns: array(string()).readonly().optional()
11283
+ }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
11258
11284
  namespace: string().optional(),
11259
11285
  collection: string(),
11260
11286
  record: SettingsRecordSchema
11261
- }), _void(), { kind: "mutation" }), method(object({
11287
+ }), _void(), {
11288
+ kind: "mutation",
11289
+ auth: "admin"
11290
+ }), method(object({
11262
11291
  namespace: string().optional(),
11263
11292
  collection: string(),
11264
11293
  id: string(),
11265
11294
  data: record(string(), unknown())
11266
- }), _void(), { kind: "mutation" }), method(object({
11295
+ }), _void(), {
11296
+ kind: "mutation",
11297
+ auth: "admin"
11298
+ }), method(object({
11267
11299
  namespace: string().optional(),
11268
11300
  collection: string(),
11269
11301
  key: string()
11270
- }), _void(), { kind: "mutation" }), method(object({
11302
+ }), _void(), {
11303
+ kind: "mutation",
11304
+ auth: "admin"
11305
+ }), method(object({
11271
11306
  namespace: string().optional(),
11272
11307
  collection: string(),
11273
11308
  filter: MutationFilterSchema
11274
- }), object({ deleted: number$1().int() }), { kind: "mutation" }), method(object({
11309
+ }), object({ deleted: number$1().int() }), {
11310
+ kind: "mutation",
11311
+ auth: "admin"
11312
+ }), method(object({
11275
11313
  namespace: string().optional(),
11276
11314
  collection: string(),
11277
11315
  filter: MutationFilterSchema,
11278
11316
  data: record(string(), unknown())
11279
- }), object({ updated: number$1().int() }), { kind: "mutation" }), method(object({
11317
+ }), object({ updated: number$1().int() }), {
11318
+ kind: "mutation",
11319
+ auth: "admin"
11320
+ }), method(object({
11280
11321
  namespace: string().optional(),
11281
11322
  collection: string(),
11282
11323
  filter: QueryFilterSchema.optional()
11283
- }), number$1()), method(object({
11324
+ }), number$1(), { auth: "admin" }), method(object({
11284
11325
  namespace: string().optional(),
11285
11326
  collection: string(),
11286
11327
  field: string(),
@@ -11290,15 +11331,18 @@ method(_void(), EngineInfoSchema), method(object({
11290
11331
  }), array(object({
11291
11332
  bucket: number$1().int(),
11292
11333
  count: number$1().int()
11293
- })).readonly()), method(object({
11334
+ })).readonly(), { auth: "admin" }), method(object({
11294
11335
  namespace: string().optional(),
11295
11336
  collection: string()
11296
- }), boolean()), method(object({
11337
+ }), boolean(), { auth: "admin" }), method(object({
11297
11338
  namespace: string().optional(),
11298
11339
  collection: string(),
11299
11340
  columns: array(CollectionColumnSchema).readonly(),
11300
11341
  indexes: array(CollectionIndexSchema).readonly().optional()
11301
- }), _void(), { kind: "mutation" });
11342
+ }), _void(), {
11343
+ kind: "mutation",
11344
+ auth: "admin"
11345
+ });
11302
11346
  /**
11303
11347
  * shm ring usage stats for a `frameSink: 'shm'` decoder session —
11304
11348
  * exposed via `decoder.getShmStats` so downstream consumers can
@@ -12426,7 +12470,7 @@ method(object({
12426
12470
  crop: _instanceof(Uint8Array),
12427
12471
  width: number$1(),
12428
12472
  height: number$1()
12429
- }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
12473
+ }), EmbeddingResultSchema, { auth: "admin" }), method(object({ text: string() }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" });
12430
12474
  /**
12431
12475
  * filesystem-browse — per-node capability for browsing the node's local
12432
12476
  * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
@@ -12738,12 +12782,28 @@ var llmRuntimeCapability = {
12738
12782
  mode: "singleton",
12739
12783
  internal: true,
12740
12784
  methods: {
12785
+ /**
12786
+ * `complete`, `status`, `listLocalModels` and `getDiskUsage` had NO
12787
+ * `auth` override — `internal: true` did not gate the mount (see the
12788
+ * 2026-08-26 note on `data-store-provider`), so they were reachable on
12789
+ * the AppRouter by ANY authenticated session at the default
12790
+ * `auth: 'protected'`, inconsistent with the rest of this cap (already
12791
+ * `auth: 'admin'`) and with this file's own docblock: "the operator
12792
+ * reaches this only through the `llm` cap's methods." The sole caller,
12793
+ * `addon-ai`'s `runtime-client.ts`, reaches every method here via
12794
+ * `ctx.api` + `nodePin` — never tRPC — so `auth: 'admin'` costs it
12795
+ * nothing; the public `llm` cap (which end users and non-admin sessions
12796
+ * legitimately call for chat/generation) is untouched.
12797
+ */
12741
12798
  complete: method(LlmGenerateBaseInputSchema.extend({
12742
12799
  images: array(LlmImageSchema).optional(),
12743
12800
  runtime: ManagedRuntimeConfigSchema,
12744
12801
  /** The managed profile's timeout, threaded by the hub provider. */
12745
12802
  timeoutMs: number$1().int().positive().optional()
12746
- }), LlmGenerateResultSchema, { kind: "mutation" }),
12803
+ }), LlmGenerateResultSchema, {
12804
+ kind: "mutation",
12805
+ auth: "admin"
12806
+ }),
12747
12807
  ensureStarted: method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
12748
12808
  kind: "mutation",
12749
12809
  auth: "admin"
@@ -12752,7 +12812,7 @@ var llmRuntimeCapability = {
12752
12812
  kind: "mutation",
12753
12813
  auth: "admin"
12754
12814
  }),
12755
- status: method(object({}), LlmRuntimeStatusSchema),
12815
+ status: method(object({}), LlmRuntimeStatusSchema, { auth: "admin" }),
12756
12816
  installModel: method(object({ model: ManagedModelRefSchema }), _void(), {
12757
12817
  kind: "mutation",
12758
12818
  auth: "admin"
@@ -12761,8 +12821,8 @@ var llmRuntimeCapability = {
12761
12821
  kind: "mutation",
12762
12822
  auth: "admin"
12763
12823
  }),
12764
- listLocalModels: method(object({}), array(LlmNodeModelSchema)),
12765
- getDiskUsage: method(object({}), LlmRuntimeDiskUsageSchema)
12824
+ listLocalModels: method(object({}), array(LlmNodeModelSchema), { auth: "admin" }),
12825
+ getDiskUsage: method(object({}), LlmRuntimeDiskUsageSchema, { auth: "admin" })
12766
12826
  }
12767
12827
  };
12768
12828
  /**
@@ -16285,1748 +16345,1958 @@ var OauthIntegrationDescriptorSchema = object({
16285
16345
  */
16286
16346
  refreshTokenTtlSec: union([number$1().int().positive(), literal("never")]).optional()
16287
16347
  });
16288
- method(_void(), OauthIntegrationDescriptorSchema);
16348
+ method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
16289
16349
  /**
16290
- * pipeline-analytics — device-scoped wrapper cap. Refines raw
16291
- * per-frame detections emitted by the pipeline runner into tracked
16292
- * objects, per-kind event collections (motion / object / audio), and
16293
- * persisted media. Owns the post-detection domain end-to-end:
16294
- *
16295
- * runner emits PipelineInferenceResult
16296
- * ↓ (event bus)
16297
- * pipeline-analytics subscriber
16298
- * ↓ SORT tracker + zone engine + state analyzer + event emitter
16299
- * → three DB collections (one per kind), one FS media tree, one
16300
- * unified event emitter (FrameTracked + TrackStarted/Ended +
16301
- * DetectionEvent on bus)
16302
- *
16303
- * Pure subscriber model. No `processFrame` cap method — the runner
16304
- * already publishes the raw frame on the bus. The cap surface is
16305
- * only QUERIES + per-device settings, bound on/off via
16306
- * `device-manager.setWrapperActive`. `defaultActive: true` because
16307
- * every camera with a detection pipeline wants its raw detections
16308
- * refined; operators opt out per-device via BindingsTab when needed.
16309
- *
16310
- * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
16311
- * (per-device surface) and `track-trail` caps — see P11 cleanup.
16350
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
16351
+ * within the frame, so the executor can re-cut a leaf child ROI at native
16352
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
16312
16353
  */
16313
- var TrackStateSchema = _enum([
16314
- "new",
16315
- "entered",
16316
- "left",
16317
- "moving",
16318
- "idle"
16319
- ]);
16320
- var EventKindSchema = _enum([
16321
- "motion",
16322
- "object",
16323
- "audio"
16324
- ]);
16354
+ var NativeCropRefSchema = object({
16355
+ /** Handle keying the retained native surface (node-pinned to its owner). */
16356
+ handle: FrameHandleSchema,
16357
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
16358
+ cropFrameSpace: object({
16359
+ x: number$1(),
16360
+ y: number$1(),
16361
+ w: number$1(),
16362
+ h: number$1()
16363
+ })
16364
+ });
16365
+ object({
16366
+ crop: object({
16367
+ left: number$1(),
16368
+ top: number$1(),
16369
+ width: number$1().positive(),
16370
+ height: number$1().positive()
16371
+ }).optional(),
16372
+ content: object({
16373
+ width: number$1().int().positive(),
16374
+ height: number$1().int().positive()
16375
+ }),
16376
+ fit: _enum(["stretch", "contain"]),
16377
+ format: _enum([
16378
+ "rgb",
16379
+ "gray",
16380
+ "jpeg"
16381
+ ])
16382
+ });
16325
16383
  /**
16326
- * Spatial filter for `listTracks` — the rect + polygon variants of the shared
16327
- * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
16328
- * of the camera frame (top-left origin), matching the drawing-plane editor.
16384
+ * Process-local frame identity. It is serializable so it can ride an in-process
16385
+ * capability call, but `registryId` deliberately prevents resolution in any
16386
+ * other process or execution group.
16329
16387
  */
16330
- var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
16331
- /** Closed icon vocabulary so clients render a known glyph per kind. */
16332
- var EventKindIconSchema = _enum([
16333
- "motion",
16334
- "audio",
16335
- "person",
16336
- "vehicle",
16337
- "animal",
16338
- "door",
16339
- "pir",
16340
- "smoke",
16341
- "water",
16342
- "button",
16343
- "package",
16344
- "generic"
16388
+ var FrameRefSchema = object({
16389
+ registryId: string().min(1),
16390
+ id: string().min(1),
16391
+ width: number$1().int().positive(),
16392
+ height: number$1().int().positive(),
16393
+ format: _enum(["rgb", "gray"]),
16394
+ timestamp: number$1(),
16395
+ capturedAt: number$1().optional()
16396
+ });
16397
+ var ModelFormatSchema$1 = _enum([
16398
+ "onnx",
16399
+ "coreml",
16400
+ "openvino",
16401
+ "tflite",
16402
+ "pt",
16403
+ "gguf"
16345
16404
  ]);
16346
- var EventKindCategorySchema = _enum([
16347
- "motion",
16348
- "audio",
16349
- "detection",
16350
- "sensor",
16351
- "control",
16352
- "custom",
16353
- "package"
16405
+ var PipelineSlotSchema = _enum([
16406
+ "detector",
16407
+ "cropper",
16408
+ "classifier",
16409
+ "refiner",
16410
+ "audio-classifier"
16354
16411
  ]);
16355
- /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
16356
- var EventKindLevelSchema = _enum(["macro", "sub"]);
16357
- var EventKindDescriptorSchema = object({
16358
- /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
16359
- kind: string(),
16360
- /** i18n key resolved on the UI side; `label` is the English fallback. */
16361
- labelKey: string(),
16362
- /** English fallback label (kept for clients that don't translate). */
16363
- label: string(),
16364
- /** Hex color for timeline/legend rendering. */
16365
- color: string(),
16366
- /** Dictionary id → lucide component on the UI side. */
16367
- iconId: string(),
16368
- /** Legacy closed-vocab glyph — fallback for `iconId`. */
16369
- icon: EventKindIconSchema,
16370
- category: EventKindCategorySchema,
16371
- /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
16372
- parentKind: string().nullable(),
16373
- /** Derived from `parentKind`, explicit for the client tree. */
16374
- level: EventKindLevelSchema,
16375
- /** Which cap + device contributes this kind. For built-ins the camera
16376
- * itself; for sensor kinds the LINKED source device. */
16377
- source: object({
16378
- capName: string(),
16379
- deviceId: number$1()
16380
- })
16412
+ var PipelineEngineChoiceSchema = object({
16413
+ runtime: _enum(["node", "python"]),
16414
+ backend: string(),
16415
+ format: ModelFormatSchema$1,
16416
+ device: string().optional()
16381
16417
  });
16382
- /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
16383
- var EventKindsForDeviceSchema = object({
16384
- deviceId: number$1(),
16385
- kinds: array(EventKindDescriptorSchema).readonly()
16418
+ var AvailableEngineSchema = object({
16419
+ engine: PipelineEngineChoiceSchema,
16420
+ devices: array(object({
16421
+ id: string(),
16422
+ label: string(),
16423
+ description: string().optional()
16424
+ })).readonly(),
16425
+ defaultDevice: string()
16386
16426
  });
16387
- var SensorEventSchema = object({
16427
+ var PipelineDefaultStepSchema = lazy(() => object({
16428
+ addonId: string(),
16429
+ addonName: string(),
16430
+ slot: PipelineSlotSchema,
16431
+ inputClasses: array(string()).readonly(),
16432
+ outputClasses: array(string()).readonly(),
16433
+ enabled: boolean(),
16434
+ modelId: string(),
16435
+ children: array(PipelineDefaultStepSchema).readonly(),
16436
+ group: string().optional(),
16437
+ settings: record(string(), unknown()).optional()
16438
+ }));
16439
+ var PipelineTemplateStepSchema = lazy(() => object({
16440
+ addonId: string(),
16441
+ enabled: boolean(),
16442
+ modelId: string(),
16443
+ children: array(PipelineTemplateStepSchema).readonly(),
16444
+ settings: record(string(), unknown()).optional()
16445
+ }));
16446
+ var PipelineTemplateSchema$1 = object({
16388
16447
  id: string(),
16389
- /** The CAMERA the event is attributed to (a sensor linked to N cameras
16390
- * yields N rows, one per camera). */
16391
- deviceId: number$1(),
16392
- /** The linked sensor device whose state changed. */
16393
- sourceDeviceId: number$1(),
16394
- /** Event kind id — matches an `EventKindDescriptor.kind`. */
16395
- kind: string(),
16396
- /** Snapshot of the sensor cap's runtime-state slice at the change. */
16397
- value: record(string(), unknown()).nullable(),
16398
- timestamp: number$1()
16448
+ name: string(),
16449
+ createdAt: string(),
16450
+ updatedAt: string(),
16451
+ engine: PipelineEngineChoiceSchema,
16452
+ steps: array(PipelineTemplateStepSchema).readonly()
16399
16453
  });
16400
- var TrackPositionSchema = object({
16401
- x: number$1(),
16402
- y: number$1(),
16403
- timestamp: number$1(),
16404
- bbox: BoundingBoxSchema
16405
- });
16406
- var TrackSnapshotSchema = object({
16407
- timestamp: number$1(),
16408
- position: TrackPositionSchema,
16409
- /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
16410
- mediaKey: string()
16454
+ var PipelineModelOptionSchema = object({
16455
+ id: string(),
16456
+ name: string(),
16457
+ formats: record(string(), object({
16458
+ downloaded: boolean(),
16459
+ sizeMB: number$1()
16460
+ })),
16461
+ group: ModelVariantGroupSchema.optional(),
16462
+ legacy: boolean().optional(),
16463
+ provider: ModelProviderIdSchema.optional()
16411
16464
  });
16412
- /**
16413
- * Normalized 0..1 trajectory envelope (min/max over every position bbox,
16414
- * divided by the track's detection-frame dims), computed at persist time.
16415
- * Absent when the frame dims were unknown when the track was persisted
16416
- * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
16417
- */
16418
- var TrackEnvelopeSchema = object({
16419
- minX: number$1(),
16420
- minY: number$1(),
16421
- maxX: number$1(),
16422
- maxY: number$1()
16465
+ var ConfigFieldBridge = custom();
16466
+ var PipelineAddonSchemaSchema = object({
16467
+ id: string(),
16468
+ name: string(),
16469
+ slot: PipelineSlotSchema,
16470
+ inputClasses: array(string()).readonly(),
16471
+ outputClasses: array(string()).readonly(),
16472
+ childSlots: array(PipelineSlotSchema).readonly(),
16473
+ models: array(PipelineModelOptionSchema).readonly(),
16474
+ defaultModelId: string(),
16475
+ defaultModelIdByFormat: record(string(), string()).optional(),
16476
+ enabledByDefault: boolean().optional(),
16477
+ backfillIntoExistingOverrides: boolean().optional(),
16478
+ defaultConfidence: number$1(),
16479
+ group: string().optional(),
16480
+ configSchema: array(ConfigFieldBridge).readonly().optional()
16423
16481
  });
16424
- /**
16425
- * Row projection for track list queries. `full` (default) returns the
16426
- * complete Track including the frame-rate `positions[]` history and the
16427
- * `snapshots[]` references — megabytes across a page of tracks. `slim`
16428
- * keeps every scalar the list surfaces actually render (ids, class(es),
16429
- * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
16430
- * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
16431
- * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
16432
- * `getTrack`. Mirrors the event-store `projection` convention
16433
- * (`getObjectEvents` et al.).
16434
- */
16435
- var TrackProjectionSchema = _enum(["full", "slim"]);
16436
- /**
16437
- * One audio-classification label heard on the track's camera while the
16438
- * track was alive, aggregated per label. An "episode" is one persisted
16439
- * audio event (the confident-classification path: score ≥ the device's
16440
- * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
16441
- * one 32 ms inference chunk, so counts stay human-scaled.
16442
- */
16443
- var TrackAudioLabelSchema = object({
16482
+ var PipelineSlotSchemaSchema = object({
16483
+ id: PipelineSlotSchema,
16444
16484
  label: string(),
16445
- /** Highest classification score observed across the label's episodes. */
16446
- peakScore: number$1(),
16447
- /** Number of coalesced audio-event episodes carrying this label. */
16448
- count: number$1(),
16449
- firstAt: number$1(),
16450
- lastAt: number$1()
16485
+ priority: number$1(),
16486
+ parentSlot: PipelineSlotSchema.nullable(),
16487
+ addons: array(PipelineAddonSchemaSchema).readonly()
16451
16488
  });
16452
- /**
16453
- * How a track was produced. `pipeline` (default / absent) = the spatial
16454
- * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
16455
- * no positions, a single snapshot, and no bbox trajectory at all:
16456
- *
16457
- * - `sensor` — a linked sensor/control device state change.
16458
- * - `audio` — an audio event on the camera itself that was anomalous for
16459
- * THAT camera, loud, and heard while nothing visual was happening (D62).
16460
- *
16461
- * The spatial subsystems (tracker association, occupancy count, re-id /
16462
- * embedding, resurrection) MUST skip every synthetic source. Test for that
16463
- * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
16464
- * check silently readmits every source added after it was written.
16465
- */
16466
- var TrackSourceSchema = _enum([
16467
- "pipeline",
16468
- "sensor",
16469
- "audio"
16470
- ]);
16471
- /**
16472
- * Where a track sits in the RETRAIN lifecycle (D81).
16473
- *
16474
- * - `none` — never marked, or un-marked. Evictable.
16475
- * - `staging` — the operator wants this track as training material and has not
16476
- * finished with it. **This is the only state retention holds**: the track and
16477
- * everything it owns (object events, crops, keyframes, CLIP vector) survive
16478
- * the device's age window.
16479
- * - `trained` — the retrain page has taken what it needed. The frames it chose
16480
- * were COPIED into the retrain dataset at selection time, so the dataset no
16481
- * longer depends on the track's media and the track becomes EVICTABLE again.
16482
- * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
16483
- * a deliberate action of the retrain page, not a side effect of a checkbox.
16484
- *
16485
- * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
16486
- * the store's filter language has only positive equality and `whereIn` — no
16487
- * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
16488
- * would make the entire pre-column history immortal in one deploy.
16489
- */
16490
- var RetrainStatusSchema = _enum([
16491
- "none",
16492
- "staging",
16493
- "trained"
16494
- ]);
16495
- /**
16496
- * Per-track OPERATOR flags — set by hand from the admin UI or the viewer, never
16497
- * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
16498
- * so the two surfaces cannot drift.
16499
- *
16500
- * **Absent ≠ false.** A track that has never been touched omits the field; an
16501
- * explicitly un-flagged track carries `false`. Legacy rows written before the
16502
- * columns existed read as absent, and a consumer that needs a boolean should say
16503
- * `flag === true`, not `flag !== false`.
16504
- *
16505
- * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
16506
- * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
16507
- * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
16508
- * `trained` track reports `false` while refusing both writes. The boolean is
16509
- * kept because three surfaces drive a toggle off it; anything that needs to tell
16510
- * "never marked" from "already trained" must read `retrainStatus`.
16511
- *
16512
- * `debug` does NOT pin; it is attention, not durability.
16513
- *
16514
- * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
16515
- * A favourited track is skipped by retention the same way `staging` is, but
16516
- * it does not enter `none|staging|trained` and has no staging budget.
16517
- */
16518
- var TrackFlagFields = {
16519
- /** Operator marked this track as training material — i.e. `retrainStatus` is
16520
- * `'staging'`. */
16521
- markForTrain: boolean().optional(),
16522
- /** Operator marked this track for diagnostic attention. */
16523
- debug: boolean().optional(),
16524
- /** Operator favourited this track. Pins it against pruning. */
16525
- favourited: boolean().optional()
16526
- };
16527
- /**
16528
- * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
16529
- * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
16530
- * write patch, and the status is not something the toggle sets — it is what the
16531
- * toggle's boolean is derived from. Absent on an in-RAM track never touched;
16532
- * always present on a persisted row (the column default materialises `'none'`).
16533
- */
16534
- var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
16535
- /**
16536
- * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
16537
- * one flag can never clear the other — the toggles are independent and are
16538
- * driven from three surfaces that do not know about each other.
16539
- */
16540
- var TrackFlagsPatchSchema = object(TrackFlagFields);
16541
- /**
16542
- * The resolved flag state after a write. Both fields are REQUIRED here (absent
16543
- * collapses to `false`) so a caller can drive a toggle's checked state off the
16544
- * mutation result without a re-fetch.
16545
- */
16546
- var TrackFlagsSchema = object({
16547
- trackId: string(),
16548
- markForTrain: boolean(),
16549
- debug: boolean(),
16550
- favourited: boolean(),
16551
- /** The lifecycle state the boolean was derived from. Required here (unlike on
16552
- * a track row) because this shape is only ever produced by the write body,
16553
- * which always knows it — and a surface that has just written needs to render
16554
- * `trained` without a re-fetch. */
16555
- retrainStatus: RetrainStatusSchema
16489
+ var PipelineSchemaSchema = object({
16490
+ availableEngines: array(AvailableEngineSchema).readonly(),
16491
+ selectedEngine: PipelineEngineChoiceSchema,
16492
+ slots: array(PipelineSlotSchemaSchema).readonly()
16556
16493
  });
16557
- union([literal(1), literal(2)]);
16558
- /**
16559
- * WHO decided a label, and when. Carried per tier so a value can be traced to
16560
- * the step and model that produced it — which is what makes the write rule
16561
- * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
16562
- * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
16563
- *
16564
- * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
16565
- * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
16566
- * `migration:4g` for a value the 4g migration moved from the single-slot era —
16567
- * that value has no provenance, and the write rule lets ANY properly-attributed
16568
- * write of the same tier replace it regardless of score.
16569
- */
16570
- var LabelAttributionSchema = object({
16571
- stepId: string(),
16572
- modelId: string().optional(),
16573
- decidedAt: number$1(),
16494
+ var EngineProvisioningSchema = object({
16495
+ runtimeId: _enum([
16496
+ "onnx",
16497
+ "openvino",
16498
+ "coreml",
16499
+ "edgetpu"
16500
+ ]).nullable(),
16501
+ device: string().nullable(),
16502
+ state: _enum([
16503
+ "idle",
16504
+ "installing",
16505
+ "verifying",
16506
+ "ready",
16507
+ "failed"
16508
+ ]),
16509
+ progress: number$1().optional(),
16510
+ error: string().optional(),
16511
+ nextRetryAt: number$1().optional(),
16574
16512
  /**
16575
- * The GALLERY id behind a recognised tier-2 label — a face-gallery
16576
- * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
16577
- *
16578
- * The text alone is a DISPLAY NAME, and a display name is renameable: a
16579
- * notification rule authored on "Gianluca" stopped matching the moment the
16580
- * operator fixed the spelling in the gallery, and nothing said so. The id is
16581
- * the thing that does not move, so it is what a rule matches on
16582
- * (`NcConditions.identities`) and the text is what a human is shown.
16583
- *
16584
- * Absent when the label names no gallery row — a plate the OCR read but no
16585
- * vehicle claims, a sub-class, a species, any tier-1 value.
16513
+ * Gate A (config-correctness gate at engine change): human-readable
16514
+ * config issues surfaced EAGERLY when the node's engine changes — model
16515
+ * substitutions ("chose X, running Y") and zero-build steps ("no model
16516
+ * has a <format> build"). Additive/optional: informational only, never
16517
+ * enforced here — `assertEngineReady` (readiness) still gates inference.
16518
+ * Absent/empty when the node-default tree resolves cleanly.
16586
16519
  */
16587
- identityId: string().optional()
16520
+ configIssues: array(string()).optional()
16588
16521
  });
16589
- /**
16590
- * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
16591
- * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
16592
- * track and its events always answer the same question the same way.
16593
- *
16594
- * Two scalar columns, not an array: every consumer wants "the coarse one" or
16595
- * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
16596
- * is tier 2, and each carries its own score + attribution.
16597
- *
16598
- * **Reading it.** What a human should be shown is `subLabel ?? label` — the
16599
- * finest thing known. Before 4g the single `label` column held the finest
16600
- * value, so a consumer that has not been updated reads the tier-1 slot and
16601
- * shows nothing on a species-only row; that is why the migration puts every
16602
- * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
16603
- * and why the read surfaces were changed in the same train.
16604
- *
16605
- * **Writing it.** The slots are independent, which is the whole point: a
16606
- * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
16607
- * migratorius`), so fineness cannot regress by construction. Within a tier the
16608
- * higher score wins. One rule, one implementation — see
16609
- * `pipeline/label-tier.ts` in addon-post-analysis.
16610
- */
16611
- var TieredLabelFields = {
16612
- /** Tier 1 — the sub-class. See {@link LabelTierSchema}. */
16613
- label: string().optional(),
16614
- /** Confidence of the tier-1 value, as reported by the deciding step. */
16615
- labelScore: number$1().optional(),
16616
- /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
16617
- labelMeta: LabelAttributionSchema.optional(),
16618
- /** Tier 2 — the instance. See {@link LabelTierSchema}. */
16619
- subLabel: string().optional(),
16620
- /** Confidence of the tier-2 value, as reported by the deciding step. */
16621
- subLabelScore: number$1().optional(),
16622
- /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
16623
- subLabelMeta: LabelAttributionSchema.optional()
16624
- };
16625
- /** Per-camera slice of a training-export estimate. */
16626
- var TrainingExportDeviceTotalsSchema = object({
16627
- deviceId: number$1(),
16628
- tracks: number$1().int(),
16629
- files: number$1().int(),
16630
- bytes: number$1().int()
16522
+ var PipelineStepInputSchema = lazy(() => object({
16523
+ addonId: string(),
16524
+ modelId: string().optional(),
16525
+ enabled: boolean().default(true),
16526
+ children: array(PipelineStepInputSchema).optional(),
16527
+ settings: record(string(), unknown()).optional(),
16528
+ jumpDeviceKey: string().optional()
16529
+ }));
16530
+ var ModelSubstitutionSchema = object({
16531
+ addonId: string(),
16532
+ chosen: string(),
16533
+ running: string(),
16534
+ format: string()
16535
+ });
16536
+ var PipelineValidationIssueSchema = object({
16537
+ addonId: string(),
16538
+ kind: _enum(["unknown-addon", "no-format-build"]),
16539
+ detail: string()
16540
+ });
16541
+ var PipelineValidationResultSchema = object({
16542
+ ok: boolean(),
16543
+ issues: array(PipelineValidationIssueSchema).readonly(),
16544
+ substitutions: array(ModelSubstitutionSchema).readonly(),
16545
+ /** The node's `currentEngine.format` this validation ran against. */
16546
+ format: string()
16547
+ });
16548
+ var ReferenceImageEntrySchema = object({
16549
+ filename: string(),
16550
+ stepIds: array(string()).readonly().optional()
16551
+ });
16552
+ var ReferenceImageBodySchema = object({
16553
+ base64: string(),
16554
+ filename: string()
16555
+ });
16556
+ var ReferenceAudioEntrySchema = object({
16557
+ filename: string(),
16558
+ sizeKb: number$1()
16559
+ });
16560
+ var ReferenceAudioBodySchema = object({ base64: string() });
16561
+ var AudioBackendSchema = object({
16562
+ id: string(),
16563
+ name: string(),
16564
+ description: string(),
16565
+ available: boolean(),
16566
+ /**
16567
+ * Raw classifier labels this backend can emit (e.g. YAMNet's
16568
+ * 521-class set or Apple SoundAnalysis's 303-class set). Used by
16569
+ * the benchmark UI to populate the `enabledMicroClasses` filter
16570
+ * specific to the selected backend without a separate fetch.
16571
+ */
16572
+ rawLabels: array(string()).readonly().optional()
16573
+ });
16574
+ var AudioCapabilitiesSchema = object({
16575
+ activeBackend: string(),
16576
+ availableBackends: array(AudioBackendSchema).readonly(),
16577
+ sampleRate: number$1(),
16578
+ chunkDurationMs: number$1()
16579
+ });
16580
+ var DownloadModelResultSchema = object({
16581
+ filePath: string(),
16582
+ sizeMB: number$1(),
16583
+ durationMs: number$1()
16631
16584
  });
16632
16585
  /**
16633
- * What a training export WOULD contain. Computed from media index rows only —
16634
- * no blob is read to produce this.
16586
+ * Wrapper carrying a single test run's result. Replaces the legacy
16587
+ * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
16588
+ * canonical `AudioResult` from the Phase 6 output rework: one
16589
+ * `AudioDetection` per class above `minScore`, top-N candidates in
16590
+ * `debug.alternateLabels['audio-classifier']`, per-source timings in
16591
+ * `debug.stepTimings`. The outer `success`/`error` fields stay so the
16592
+ * benchmark UI can still report a clean failure when the classifier
16593
+ * cap isn't available.
16635
16594
  */
16636
- var TrainingExportSummarySchema = object({
16637
- generatedAt: number$1(),
16638
- trackCount: number$1().int(),
16639
- fileCount: number$1().int(),
16640
- byteCount: number$1().int(),
16641
- /** More marked tracks exist than a single pass carries. */
16642
- truncated: boolean(),
16643
- devices: array(TrainingExportDeviceTotalsSchema).readonly()
16595
+ var AudioTestResultSchema = object({
16596
+ success: boolean(),
16597
+ error: string().optional(),
16598
+ frame: custom().optional()
16644
16599
  });
16645
- var TrackSchema = object({
16646
- trackId: string(),
16647
- deviceId: number$1(),
16648
- className: string(),
16649
- ...TieredLabelFields,
16650
- producingDeviceName: string().optional(),
16651
- /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
16652
- source: TrackSourceSchema.optional(),
16653
- firstSeen: number$1(),
16654
- lastSeen: number$1(),
16655
- /** Frame-rate position history (subject to maxPositionHistory cap). */
16656
- positions: array(TrackPositionSchema).readonly(),
16657
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
16658
- * saveThumbnails policy). */
16659
- snapshots: array(TrackSnapshotSchema).readonly(),
16660
- /** Deduplicated zones the track has entered at least once. Zone IDS. */
16661
- zonesVisited: array(string()).readonly(),
16600
+ var PipelineConfigBridge = custom();
16601
+ var ConfigUISchemaBridge = custom();
16602
+ var ConfigUISchemaNullableBridge = custom();
16603
+ var InferenceCapabilitiesBridge = custom();
16604
+ var ModelAvailabilityListBridge = custom();
16605
+ var PipelineRunResultBridge = custom();
16606
+ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
16607
+ modelId: string(),
16608
+ settings: record(string(), unknown()).readonly()
16609
+ }))), method(object({ steps: record(string(), object({
16610
+ modelId: string(),
16611
+ settings: record(string(), unknown()).readonly()
16612
+ })) }), object({ success: literal(true) }), {
16613
+ kind: "mutation",
16614
+ auth: "admin"
16615
+ }), method(object({ nodeId: string() }), object({
16616
+ success: literal(true),
16617
+ clearedDevices: number$1()
16618
+ }), {
16619
+ kind: "mutation",
16620
+ auth: "admin"
16621
+ }), method(object({ nodeId: string() }), object({ unhealthy: array(object({
16622
+ /** `<backend>:<device>`, e.g. `openvino:gpu`. */
16623
+ deviceKey: string(),
16662
16624
  /**
16663
- * Human NAMES for {@link zonesVisited}, resolved at READ time against the
16664
- * `zones` capability.
16665
- *
16666
- * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
16667
- * and no card can render — so every free-text search surface was structurally
16668
- * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
16669
- * just returned nothing. Resolving here rather than in each client keeps ONE
16670
- * derivation and costs the clients no extra call (the `zones` cap is
16671
- * per-device, so a client-side resolve would be a per-camera fan-out on a
16672
- * surface built to avoid exactly that).
16673
- *
16674
- * Resolved, never invented: a zone deleted since the track was written has no
16675
- * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
16676
- * two are not positionally aligned. Absent when the track visited no zone, or
16677
- * when the zone catalogue could not be read.
16625
+ * `failed` — the per-device restart budget is exhausted; no pool
16626
+ * will be spawned until an operator re-arms it or the runner
16627
+ * respawns. `backoff` — under budget, waiting out the backoff (or
16628
+ * a cached pool observed dead and not yet condemned).
16678
16629
  */
16679
- zoneNames: array(string()).readonly().optional(),
16680
- /** Deduplicated set of detector classes observed for this track over its
16681
- * life (a track may be reclassified, e.g. person→vehicle). Absent on
16682
- * legacy rows written before class accumulation shipped. */
16683
- classes: array(string()).readonly().optional(),
16684
- /** Cumulative normalized distance travelled (0..1 units = full frame width). */
16685
- totalDistance: number$1(),
16686
- state: TrackStateSchema,
16687
- active: boolean(),
16688
- /** Deterministic key-event importance score in [0,1] (server-computed at
16689
- * track expiry, recomputed on late label). Absent on legacy rows written
16690
- * before scoring shipped — consumers degrade to absence / compute-on-read. */
16691
- importance: number$1().optional(),
16692
- /** Id of the track's highest-confidence ObjectEvent (its representative
16693
- * "best" frame). Absent when the track produced no object events. */
16694
- bestEventId: string().optional(),
16695
- /** Tag of the importance sub-signal that dominated the score
16696
- * (identity|dwell|proximity|class|confidence|travel|zone). */
16697
- importanceReason: string().optional(),
16698
- /** Audio-classification labels heard on the camera during the track's
16699
- * life (score ≥ device `classificationMinScore`), aggregated per label.
16700
- * Absent on legacy rows / tracks with no confident audio. */
16701
- audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
16702
- /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
16703
- * Populated from the persisted envelope columns on historical reads;
16704
- * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
16705
- envelope: TrackEnvelopeSchema.optional(),
16630
+ state: _enum(["failed", "backoff"]),
16631
+ /** Epoch ms of the death that produced this state. */
16632
+ since: number$1(),
16633
+ /** Pool deaths inside the current window. */
16634
+ deaths: number$1(),
16635
+ /** The last death's message. */
16636
+ lastError: string()
16637
+ })).readonly() })), method(object({
16638
+ nodeId: string(),
16639
+ deviceKey: string()
16640
+ }), object({ rearmed: boolean() }), {
16641
+ kind: "mutation",
16642
+ auth: "admin"
16643
+ }), 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({
16644
+ name: string(),
16645
+ steps: array(PipelineTemplateStepSchema).readonly(),
16646
+ engine: PipelineEngineChoiceSchema
16647
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
16648
+ id: string(),
16649
+ name: string().optional(),
16650
+ steps: array(PipelineTemplateStepSchema).readonly().optional()
16651
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
16652
+ addonId: string(),
16653
+ modelId: string(),
16654
+ format: ModelFormatSchema$1
16655
+ }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
16656
+ addonId: string(),
16657
+ modelId: string(),
16658
+ format: ModelFormatSchema$1
16659
+ }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
16660
+ engine: PipelineEngineChoiceSchema.optional(),
16661
+ steps: array(PipelineStepInputSchema).min(1),
16662
+ frame: FrameInputSchema.optional(),
16706
16663
  /**
16707
- * A face DETECTOR found a face on this track — nothing more. It says the
16708
- * detail plane produced a `face` detail; it does NOT say the face was
16709
- * embedded, matched, above `minFacePx`, or that the recognizer was even
16710
- * enabled. Set once and never cleared.
16711
- *
16712
- * **This exists so "face present but not recognised" is expressible.** A
16713
- * recognised identity lands in `subLabel` (attributed to the face chain via
16714
- * `subLabelMeta.stepId`), so before this field a track with an unmatched face
16715
- * and a track with no face at all were byte-identical on the wire and no
16716
- * surface could tell them apart. The read is `hasFace === true && subLabel
16717
- * === undefined`.
16718
- *
16719
- * **Absent ≠ false.** Every row written before the column existed omits it,
16720
- * and so does every server that predates the field — a consumer must test
16721
- * `=== true` and render nothing otherwise, never infer "no face".
16664
+ * Process-local lazy frame. Valid only when caller and provider resolve
16665
+ * in the same execution-group process; split/cross-node callers use
16666
+ * `frame`/`image` inline compatibility instead.
16722
16667
  */
16723
- hasFace: boolean().optional(),
16668
+ frameRef: FrameRefSchema.optional(),
16724
16669
  /**
16725
- * This track has a face row IN THE GALLERY: a crop **and** an embedding — a
16726
- * face an operator could ASSIGN to an identity.
16727
- *
16728
- * The STRICT twin of {@link hasFace}, and the pair only earns its keep
16729
- * because the two disagree. `hasFace` is stamped at the TOP of the face
16730
- * branch, before every gate, and means no more than "a face detector produced
16731
- * a face detail". This one is stamped at the single moment the gallery row
16732
- * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
16733
- * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
16734
- * candidate gate, the imageless-track drop (no crop was ever captured) and
16735
- * the crop-store drop. Everything between the detector and that insert can
16736
- * legitimately refuse the face, so a flag written any earlier promises the
16737
- * operator something to assign and delivers nothing.
16738
- *
16739
- * **Independent of recognition.** A face collected but never auto-matched is
16740
- * still assignable — it is in fact the face an operator most wants to reach —
16741
- * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
16742
- * `subLabel`; this says only that the raw material exists.
16743
- *
16744
- * **Set once, never cleared.** A track that produced a gallery row produced
16745
- * one; deleting the row later is the gallery's business, not this flag's.
16746
- *
16747
- * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
16748
- * before the column omits it, and so does every server that predates the
16749
- * field. A consumer must test `=== true` and render nothing otherwise —
16750
- * never infer "no assignable face".
16670
+ * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
16671
+ * the decoded pixels live in. One more member of the one-of
16672
+ * frame/frameHandle/image/imageBase64/referenceImage group.
16751
16673
  */
16752
- hasEmbeddedFace: boolean().optional(),
16674
+ frameHandle: FrameHandleSchema.optional(),
16675
+ imageBase64: string().optional(),
16753
16676
  /**
16754
- * This subject CONTAINS a folded rider — a person the rider-pairing step
16755
- * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
16756
- * so the passage is tracked once and as a VEHICLE.
16757
- *
16758
- * It exists because the fold's record was dishonest. D34 and the code both
16759
- * said "the person is not lost — it is reported so both entities stay on the
16760
- * record"; in fact the pair went into a per-processor RAM field behind an
16761
- * accessor nobody called, and every durable surface said `vehicle`, full
16762
- * stop. This is the composition note that makes the row true.
16763
- *
16764
- * A COMPOSITION, never a class and never a label. "This vehicle contains a
16765
- * person" is not an answer to "what is this" — both label tiers would refuse
16766
- * a macro token anyway (D89), and correctly. Nothing here changes what the
16767
- * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
16768
- * and a `person` rule still does not fire for someone cycling past.
16769
- *
16770
- * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
16771
- * the column, and every hub that predates the field, omits it. Test
16772
- * `=== true` and render nothing otherwise — never infer "no rider".
16677
+ * Binary JPEG bytes — preferred over `imageBase64` on internal
16678
+ * hops (hub → forked worker via Moleculer MsgPack) because it
16679
+ * skips the 33% base64 overhead + the per-call base64 decode on
16680
+ * the detection-pipeline worker. Callers can pass either; exactly
16681
+ * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
16773
16682
  */
16774
- hasRider: boolean().optional(),
16775
- ...TrackFlagFields,
16776
- ...TrackRetrainFields
16777
- });
16778
- var BaseEventFields = {
16779
- id: string(),
16780
- deviceId: number$1(),
16781
- timestamp: number$1()
16782
- };
16783
- var MotionEventSchema = object({
16784
- ...BaseEventFields,
16785
- kind: literal("motion"),
16786
- regionCount: number$1(),
16787
- /** Heavy JSON array — omitted in slim projection. */
16788
- regions: array(object({
16789
- bbox: BoundingBoxSchema,
16790
- pixelCount: number$1(),
16791
- intensity: number$1()
16792
- })).readonly().optional(),
16793
- /** Omitted in slim projection. */
16794
- frameWidth: number$1().optional(),
16795
- /** Omitted in slim projection. */
16796
- frameHeight: number$1().optional(),
16797
- /** Populated by B5 (recording playback URL for this event). */
16798
- mediaUrl: string().optional()
16799
- });
16683
+ image: _instanceof(Uint8Array).optional(),
16684
+ referenceImage: string().optional(),
16685
+ deviceId: number$1().optional(),
16686
+ sessionId: string().optional(),
16687
+ /**
16688
+ * Execution plane. 'full' (default) runs the whole tree — benchmark,
16689
+ * reference-image, and detail-subtree calls. 'frame' is the live
16690
+ * per-frame dispatch: ONLY root-plane steps run; crop children
16691
+ * (inputClasses ≠ null) are skipped and served per-track via
16692
+ * pipelineRunner.runDetailSubtree (two-plane design).
16693
+ */
16694
+ plane: _enum(["full", "frame"]).optional(),
16695
+ /**
16696
+ * Inference-device selector (Phase 2 multi-device). Format
16697
+ * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
16698
+ * Omitted ⇒ the runner's default device (current single-engine
16699
+ * behaviour). Selects WHICH device pool of the node runs the call.
16700
+ */
16701
+ deviceKey: string().optional(),
16702
+ /**
16703
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
16704
+ * when the parent crop was resolved from the frame's retained NATIVE
16705
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
16706
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
16707
+ * resolution from that surface — the SAME quality path faces already
16708
+ * had — instead of the downscaled parent tile. `handle` keys the native
16709
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
16710
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
16711
+ * the executor's crop-normalized child ROI back into frame-normalized
16712
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
16713
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
16714
+ * (today's behaviour on the fallback path).
16715
+ */
16716
+ nativeCropRef: NativeCropRefSchema.optional()
16717
+ }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
16718
+ engine: PipelineEngineChoiceSchema.optional(),
16719
+ steps: array(PipelineStepInputSchema).min(1),
16720
+ frames: array(FrameInputSchema).min(1).max(255),
16721
+ deviceId: number$1().optional(),
16722
+ sessionId: string().optional(),
16723
+ /**
16724
+ * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
16725
+ * the batch to the Python pool's bench preprocess cache
16726
+ * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
16727
+ * preprocessed ONCE and every later inference is a pure-inference cache
16728
+ * hit — the sustained-throughput run measures inference, not
16729
+ * decode+preprocess+infer. Omitted/0 for live frames (all different →
16730
+ * full preprocess every call, correct). Fresh per sustained run;
16731
+ * released via `uncacheFrame`.
16732
+ */
16733
+ frameId: number$1().int().nonnegative().optional(),
16734
+ /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
16735
+ deviceKey: string().optional()
16736
+ }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
16737
+ data: _instanceof(Uint8Array),
16738
+ width: number$1().int().positive(),
16739
+ height: number$1().int().positive(),
16740
+ format: _enum([
16741
+ "rgb",
16742
+ "bgr",
16743
+ "gray"
16744
+ ])
16745
+ }), object({
16746
+ frameId: number$1(),
16747
+ width: number$1(),
16748
+ height: number$1()
16749
+ }), { kind: "mutation" }), method(object({
16750
+ stepId: string(),
16751
+ frameId: number$1().int()
16752
+ }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number$1().int() }), _void(), { kind: "mutation" }), method(_void(), object({
16753
+ batchMode: string(),
16754
+ windowMs: number$1(),
16755
+ maxBatchSize: number$1(),
16756
+ concurrency: number$1()
16757
+ })), method(_void(), array(object({
16758
+ engineKey: string(),
16759
+ engine: PipelineEngineChoiceSchema,
16760
+ modelsLoaded: array(string()).readonly(),
16761
+ inUseByCameras: array(number$1()).readonly(),
16762
+ /**
16763
+ * Origin of this resident factory.
16764
+ * - `runtime` — main camera-serving engine (no idle TTL).
16765
+ * - `warm-override` — benchmark/test override held in the warm
16766
+ * cache; auto-disposed after the idle TTL.
16767
+ * - `device-pool` — a concurrent per-device pool (Phase 2
16768
+ * multi-device, keyed by `deviceKey`) resolved
16769
+ * via `resolveDeviceFactory`. Runs alongside the
16770
+ * `runtime` engine on a DIFFERENT accelerator
16771
+ * (NPU / iGPU / Coral) — this is how the
16772
+ * Engines tab shows all pools running at once.
16773
+ */
16774
+ kind: _enum([
16775
+ "runtime",
16776
+ "warm-override",
16777
+ "device-pool"
16778
+ ]),
16779
+ /** Native pid of the underlying Python pool (null when no pool). */
16780
+ poolPid: number$1().nullable(),
16781
+ /** ms since this factory was last used (null when not warm-tracked). */
16782
+ idleMs: number$1().nullable(),
16783
+ /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
16784
+ idleTtlMs: number$1().nullable()
16785
+ })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
16786
+ kind: "mutation",
16787
+ auth: "admin"
16788
+ }), method(object({
16789
+ engine: PipelineEngineChoiceSchema,
16790
+ force: boolean().optional()
16791
+ }), object({
16792
+ success: boolean(),
16793
+ reason: string().optional()
16794
+ }), {
16795
+ kind: "mutation",
16796
+ auth: "admin"
16797
+ }), 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({
16798
+ addonId: string(),
16799
+ modelId: string(),
16800
+ filename: string().optional(),
16801
+ settings: record(string(), unknown()).optional()
16802
+ }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
16800
16803
  /**
16801
- * Which detection SOURCE produced an object event. `pipeline` = the ML
16802
- * detection pipeline (decoded-frame inference); `onboard` = the camera's
16803
- * native on-device AI. Both flow through the SAME analysis layers (zoning,
16804
- * tracking, per-kind persistence) but stay distinguishable so consumers
16805
- * (advanced-notifier, occupancy, …) can select which source(s) to act on.
16806
- * Absent on legacy rows ⇒ treat as `pipeline`.
16804
+ * Per-stage gating mode applied to the zones a rule references.
16805
+ *
16806
+ * - `include`: the rule contributes to a **whitelist** for its stage.
16807
+ * When at least one `include` rule fires for a stage, only entities
16808
+ * inside one of those zones pass that stage.
16809
+ * - `exclude`: the rule contributes to a **blacklist** for its stage.
16810
+ * Entities inside one of those zones are dropped at that stage.
16811
+ *
16812
+ * `monitor`-style observation (count without filtering) is not a rule
16813
+ * mode — zones without any matching rule are observed naturally by
16814
+ * `zone-analytics` (live snapshot + history), so an "I just want to
16815
+ * count, not filter" use case needs no rule at all.
16807
16816
  */
16808
- var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
16817
+ var ZoneRuleModeEnum = _enum(["include", "exclude"]);
16809
16818
  /**
16810
- * The confirmed zone crossing that produced an object event. Present ONLY on
16811
- * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
16812
- * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
16813
- * appearance event carry none, so a rule asking for a direction fails closed
16814
- * on them.
16819
+ * Per-consumer rule that references existing zones (geometry) and
16820
+ * defines how a specific pipeline stage should treat them. Each
16821
+ * consumer addon owns its own `ZoneRule[]` array in its per-device
16822
+ * settings:
16815
16823
  *
16816
- * Exactly ONE crossing per event: the emitter turns each confirmed crossing
16817
- * into its own event, so a frame in which a track enters A while leaving B
16818
- * produces two events with two directions — never one ambiguous row.
16824
+ * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
16825
+ * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
16826
+ * - future: notification rules, audio gating, etc.
16819
16827
  *
16820
- * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
16821
- * membership the box has NOW, and by definition it no longer contains the zone
16822
- * that was just left. Without the id here, a zone-scoped rule could never match
16823
- * the exit it asked for.
16828
+ * One rule applies to N zones (`zoneIds[]`) so the operator can
16829
+ * express "ignore motion in ALL of {garden, street}" with a single
16830
+ * rule. `classFilter` narrows the rule to specific object classes —
16831
+ * "drop person detections in the street, but keep cars" is one
16832
+ * `exclude` rule with `classFilter: ['person']`.
16833
+ *
16834
+ * `enabled` is a soft toggle — the operator can keep the rule
16835
+ * configured but inert without deleting it.
16824
16836
  */
16825
- var ZoneCrossingSchema = object({
16826
- direction: _enum(["enter", "exit"]),
16827
- /** Admin zone id crossed. */
16828
- zoneId: string(),
16829
- /** Zone display name at crossing time (falls back to the id). */
16830
- zoneName: string().optional()
16831
- });
16832
- var ObjectEventSchema = object({
16833
- ...BaseEventFields,
16834
- kind: literal("object"),
16835
- /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
16836
- source: DetectionSourceSchema.optional(),
16837
+ var ZoneRuleSchema = object({
16838
+ /** Stable rule id — survives edits, used by the UI for diffing. */
16839
+ id: string(),
16840
+ /** Optional human-readable label rendered in the rule editor. */
16841
+ name: string().optional(),
16842
+ /** Zones this rule targets. The rule's `mode` applies to ALL
16843
+ * listed zones (OR-set: a detection in any one of them counts).
16844
+ * At least one zone id required — a rule with no targets is a
16845
+ * configuration mistake and the form validator rejects it. */
16846
+ zoneIds: array(string()).min(1).readonly(),
16847
+ mode: ZoneRuleModeEnum,
16837
16848
  /**
16838
- * Inference-frame id shared by every object event emitted from the SAME frame
16839
- * — the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
16840
- * 2 people + 1 dog) under one full frame, and link a track's frames over time
16841
- * (group by `trackId`, pick a representative `frameId` as the parent frame).
16842
- * Optional for backward-compat with pre-existing rows / the slim projection
16843
- * includes it (it is light). Absent on rows written before this field.
16849
+ * Class names this rule applies to. Empty / undefined ⇒ rule
16850
+ * applies to every class. Class strings match the `macroClass`
16851
+ * field on detections (e.g. `person`, `car`, `dog`).
16844
16852
  */
16845
- frameId: string().optional(),
16846
- /** Omitted in slim projection. */
16847
- trackId: string().optional(),
16848
- className: string(),
16849
- ...TieredLabelFields,
16850
- /** Omitted in slim projection. */
16851
- confidence: number$1().optional(),
16852
- /** Heavy JSON — omitted in slim projection. */
16853
- bbox: BoundingBoxSchema.optional(),
16854
- /** Heavy JSON — omitted in slim projection. */
16855
- zones: array(string()).readonly().optional(),
16856
- /** Omitted in slim projection. */
16857
- state: TrackStateSchema.optional(),
16853
+ classFilter: array(string()).readonly().optional(),
16858
16854
  /**
16859
- * The zone crossing this event IS, when it is one. Absent on every other
16860
- * event kind (movement state, appearance, package) — see
16861
- * {@link ZoneCrossingSchema}. Omitted in slim projection.
16855
+ * Minimum bbox/mask overlap (0–1) with any of the rule's zones
16856
+ * required to consider an entity "in the zone". Defaults to the
16857
+ * consumer's stage default when omitted. Kept for back-compat with
16858
+ * existing per-rule overrides; new operators pick the value via
16859
+ * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
16860
+ * set, the lower-level engine reads it as a 0–1 fraction.
16862
16861
  */
16863
- zoneCrossing: ZoneCrossingSchema.optional(),
16864
- /** Detection-frame dimensions in pixels — let consumers normalize the
16865
- * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
16866
- frameWidth: number$1().optional(),
16867
- frameHeight: number$1().optional(),
16868
- /** MediaStore key for the crop attached to this event (if any). */
16869
- mediaKey: string().optional(),
16870
- /** Design B: MediaStore key of the track's native-resolution key frame (the
16871
- * best-detection full frame). Resolve via the event-media data-plane
16872
- * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
16873
- * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
16874
- * sources — consumers fall back to `mediaKey` (the tight crop). */
16875
- keyFrameMediaKey: string().optional(),
16876
- /** Populated by B5 (recording playback URL for this event). */
16877
- mediaUrl: string().optional(),
16878
- /** The parent track's key-event importance [0,1], propagated to every object
16879
- * event of the track (so an event row can be sorted by importance without a
16880
- * track join). Absent on legacy rows / before the track was scored. */
16881
- importance: number$1().optional()
16882
- });
16883
- var AudioEventSchema = object({
16884
- ...BaseEventFields,
16885
- kind: literal("audio"),
16886
- rms: number$1(),
16887
- dbfs: number$1(),
16888
- classification: object({
16889
- className: string(),
16890
- originalClass: string().optional(),
16891
- score: number$1()
16892
- }).optional(),
16893
- /** Populated by B5 (recording playback URL for this event). */
16894
- mediaUrl: string().optional()
16895
- });
16896
- var MediaFileKindEnum = _enum([
16897
- "crop",
16898
- "thumbnail",
16899
- "snapshot",
16900
- "firstFrame",
16901
- "lastFrame",
16902
- "fullFrame",
16903
- "fullFrameBoxed",
16904
- "faceCrop",
16905
- "plateCrop",
16906
- "keyFrame",
16907
- "keyFrameSmall",
16908
- "thumbnailSmall"
16909
- ]);
16910
- var MediaFileSchema = object({
16911
- key: string(),
16912
- kind: MediaFileKindEnum,
16913
- base64: string(),
16914
- sizeBytes: number$1(),
16915
- timestamp: number$1()
16862
+ overlapThreshold: number$1().min(0).max(1).optional(),
16863
+ /**
16864
+ * Operator-friendly version of `overlapThreshold` — the percentage
16865
+ * of the detection's bbox that must lie inside the zone for the
16866
+ * rule to match. Documented default is 85%; the engine substitutes
16867
+ * that when the field is omitted (kept optional so existing rules
16868
+ * stored without it stay valid).
16869
+ *
16870
+ * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
16871
+ * rule, the engine prefers `bboxInclusionPct` because it's the
16872
+ * field exposed in the UI. Internally both feed the same gate.
16873
+ */
16874
+ bboxInclusionPct: number$1().min(0).max(100).optional(),
16875
+ /**
16876
+ * When `true` and a detection has a segmentation mask, use the
16877
+ * mask for overlap instead of the bbox. Detection-stage only;
16878
+ * motion rules ignore this field.
16879
+ */
16880
+ preferMask: boolean().optional(),
16881
+ /**
16882
+ * Soft-toggle: `false` disables the rule without deleting it.
16883
+ * Defaults to `true` so operators creating a rule via the UI
16884
+ * see it active immediately.
16885
+ */
16886
+ enabled: boolean().default(true)
16916
16887
  });
16888
+ array(ZoneRuleSchema).readonly();
16917
16889
  /**
16918
- * One media row WITHOUT its bytes.
16890
+ * Zone — pure geometry + identity. NO filtering behaviour.
16919
16891
  *
16920
- * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
16921
- * 140 s track), and a client that renders tiles from the media data plane needs
16922
- * to know only WHAT EXISTS — the bytes then arrive per tile, lazily, over HTTP
16923
- * with an immutable cache, instead of all at once inside a tRPC response that
16924
- * blocks the whole view.
16892
+ * Zones describe **where** in the frame the operator wants to flag
16893
+ * something; consumer-owned {@link ZoneRule} arrays describe **how**
16894
+ * each pipeline stage uses them. Splitting the two means a single
16895
+ * polygon "Driveway" can simultaneously back a motion-exclude rule,
16896
+ * a detection-include rule on `['car']`, and an occupancy aggregate
16897
+ * — without three duplicated polygons.
16925
16898
  *
16926
- * `sizeBytes` is carried because it is what lets a client decide between the
16927
- * stored blob and a `?variant=thumb` rendering without fetching either.
16899
+ * Owned by the orchestrator addon (provider) and mirrored into the
16900
+ * `zones` device-state slice on every mutation. Consumers
16901
+ * (motion-wasm, pipeline-executor, analytics, admin UI) read either
16902
+ * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
16903
+ * mirror with `onChanged`).
16904
+ *
16905
+ * Coordinates are normalised fractions of the frame (0–1) so zones
16906
+ * survive resolution changes and stream profile switches.
16907
+ *
16908
+ * `kind` discriminates between full polygons (closed regions used
16909
+ * for intrusion / occupancy filters) and tripwires (open 2-point
16910
+ * line segments used for cross events). Onboard / firmware-reported
16911
+ * zones (Reolink, ONVIF) are out of scope for now — see the deferred
16912
+ * task list.
16928
16913
  */
16929
- var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
16914
+ var ZoneKindEnum = _enum(["polygon", "tripwire"]);
16915
+ /** Polygon vertex in fraction-of-frame coordinates (0–1). */
16916
+ var PolygonPointSchema = object({
16917
+ x: number$1(),
16918
+ y: number$1()
16919
+ });
16920
+ /** A camera detection zone — pure geometry/identity. */
16921
+ var ZoneSchema = object({
16922
+ id: string(),
16923
+ name: string(),
16924
+ kind: ZoneKindEnum.default("polygon"),
16925
+ /** Polygon vertices, fraction of frame (0–1). */
16926
+ polygon: array(PolygonPointSchema).readonly(),
16927
+ /** Visual color for UI rendering. */
16928
+ color: string().default("#3b82f6")
16929
+ });
16930
+ DeviceType.Camera, method(object({ deviceId: number$1() }), array(ZoneSchema).readonly()), method(object({
16931
+ deviceId: number$1(),
16932
+ zone: ZoneSchema
16933
+ }), _void(), {
16934
+ kind: "mutation",
16935
+ auth: "admin"
16936
+ }), method(object({
16937
+ deviceId: number$1(),
16938
+ zoneId: string()
16939
+ }), _void(), {
16940
+ kind: "mutation",
16941
+ auth: "admin"
16942
+ }), method(object({
16943
+ deviceId: number$1(),
16944
+ zone: ZoneSchema
16945
+ }), _void(), {
16946
+ kind: "mutation",
16947
+ auth: "admin"
16948
+ }), object({ zones: array(ZoneSchema).readonly() });
16930
16949
  /**
16931
- * The MACRO tier of an annotation — a CLOSED set.
16950
+ * pipeline-analytics — device-scoped wrapper cap. Refines raw
16951
+ * per-frame detections emitted by the pipeline runner into tracked
16952
+ * objects, per-kind event collections (motion / object / audio), and
16953
+ * persisted media. Owns the post-detection domain end-to-end:
16932
16954
  *
16933
- * This is what the exported detector predicts, so a typo here is a new class
16934
- * with one example in it. `label` and `subLabel` are open strings by contrast:
16935
- * the whole point of the page is teaching the model things it does not know
16936
- * yet, and constraining that vocabulary would make it useless.
16955
+ * runner emits PipelineInferenceResult
16956
+ * ↓ (event bus)
16957
+ * pipeline-analytics subscriber
16958
+ * ↓ SORT tracker + zone engine + state analyzer + event emitter
16959
+ * → three DB collections (one per kind), one FS media tree, one
16960
+ * unified event emitter (FrameTracked + TrackStarted/Ended +
16961
+ * DetectionEvent on bus)
16937
16962
  *
16938
- * A macro class is NEVER a label. The provider refuses a write whose `label` or
16939
- * `subLabel` is one of these values, in any casing, because once `person`
16940
- * exists in both tiers "every person box" stops being answerable without
16941
- * knowing every string anyone ever typed — and the damage is retroactive.
16963
+ * Pure subscriber model. No `processFrame` cap method — the runner
16964
+ * already publishes the raw frame on the bus. The cap surface is
16965
+ * only QUERIES + per-device settings, bound on/off via
16966
+ * `device-manager.setWrapperActive`. `defaultActive: true` because
16967
+ * every camera with a detection pipeline wants its raw detections
16968
+ * refined; operators opt out per-device via BindingsTab when needed.
16969
+ *
16970
+ * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
16971
+ * (per-device surface) and `track-trail` caps — see P11 cleanup.
16942
16972
  */
16943
- var RetrainMacroClassSchema = _enum([
16973
+ var TrackStateSchema = _enum([
16974
+ "new",
16975
+ "entered",
16976
+ "left",
16977
+ "moving",
16978
+ "idle"
16979
+ ]);
16980
+ var EventKindSchema = _enum([
16981
+ "motion",
16982
+ "object",
16983
+ "audio"
16984
+ ]);
16985
+ /**
16986
+ * Spatial filter for `listTracks` — the rect + polygon variants of the shared
16987
+ * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
16988
+ * of the camera frame (top-left origin), matching the drawing-plane editor.
16989
+ */
16990
+ var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
16991
+ /** Closed icon vocabulary so clients render a known glyph per kind. */
16992
+ var EventKindIconSchema = _enum([
16993
+ "motion",
16994
+ "audio",
16944
16995
  "person",
16945
16996
  "vehicle",
16946
16997
  "animal",
16998
+ "door",
16999
+ "pir",
17000
+ "smoke",
17001
+ "water",
17002
+ "button",
16947
17003
  "package",
16948
- "face",
16949
- "plate"
17004
+ "generic"
16950
17005
  ]);
16951
- /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
16952
- var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
16953
- /** Did a human draw this box, or did the assist propose it? */
16954
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
16955
- /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
16956
- var RetrainBboxSchema = object({
16957
- x: number$1(),
16958
- y: number$1(),
16959
- w: number$1(),
16960
- h: number$1()
16961
- });
16962
- /**
16963
- * One annotated subject.
16964
- *
16965
- * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
16966
- * (letterboxed root / zone-cropped package / subject-cropped classifier) are
16967
- * derived from it at export and never stored — storing them is how one feature
16968
- * space ends up holding two crops of the same subject (D52).
16969
- */
16970
- var RetrainAnnotationSchema = object({
16971
- id: string(),
16972
- trackId: string(),
16973
- deviceId: number$1(),
16974
- /** The COPY in retrain storage — never the source track's media key. */
16975
- mediaKey: string(),
16976
- bbox: RetrainBboxSchema,
16977
- macroClass: RetrainMacroClassSchema,
16978
- label: string().optional(),
16979
- subLabel: string().optional(),
16980
- kind: RetrainAnnotationKindSchema,
16981
- source: RetrainAnnotationSourceSchema,
16982
- /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
16983
- assistModelId: string().optional(),
16984
- assistScore: number$1().optional(),
16985
- exportedInBatch: string().optional(),
16986
- createdAt: number$1()
16987
- });
16988
- /** The write form — the server owns `id`, `createdAt` and the frame binding. */
16989
- var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
16990
- id: true,
16991
- trackId: true,
16992
- deviceId: true,
16993
- mediaKey: true,
16994
- createdAt: true,
16995
- exportedInBatch: true
17006
+ var EventKindCategorySchema = _enum([
17007
+ "motion",
17008
+ "audio",
17009
+ "detection",
17010
+ "sensor",
17011
+ "control",
17012
+ "custom",
17013
+ "package"
17014
+ ]);
17015
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
17016
+ var EventKindLevelSchema = _enum(["macro", "sub"]);
17017
+ var EventKindDescriptorSchema = object({
17018
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
17019
+ kind: string(),
17020
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
17021
+ labelKey: string(),
17022
+ /** English fallback label (kept for clients that don't translate). */
17023
+ label: string(),
17024
+ /** Hex color for timeline/legend rendering. */
17025
+ color: string(),
17026
+ /** Dictionary id → lucide component on the UI side. */
17027
+ iconId: string(),
17028
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
17029
+ icon: EventKindIconSchema,
17030
+ category: EventKindCategorySchema,
17031
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
17032
+ parentKind: string().nullable(),
17033
+ /** Derived from `parentKind`, explicit for the client tree. */
17034
+ level: EventKindLevelSchema,
17035
+ /** Which cap + device contributes this kind. For built-ins the camera
17036
+ * itself; for sensor kinds the LINKED source device. */
17037
+ source: object({
17038
+ capName: string(),
17039
+ deviceId: number$1()
17040
+ })
16996
17041
  });
16997
- /** A track sitting in `staging`, with everything the worklist needs to rank it. */
16998
- var RetrainTrackSchema = object({
16999
- trackId: string(),
17042
+ /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
17043
+ var EventKindsForDeviceSchema = object({
17000
17044
  deviceId: number$1(),
17001
- className: string(),
17002
- label: string().optional(),
17003
- firstSeen: number$1(),
17004
- lastSeen: number$1(),
17005
- /** How many frames the dataset already holds from this track. */
17006
- frameCount: number$1().int(),
17007
- /** How many subjects have been annotated on those frames. `0` with
17008
- * `frameCount: 0` is exactly "staging, still to work". */
17009
- annotationCount: number$1().int()
17010
- });
17011
- /** A frame the picker may offer — an index row, no blob was read to produce it. */
17012
- var RetrainFrameCandidateSchema = object({
17013
- mediaKey: string(),
17014
- kind: MediaFileKindEnum,
17015
- timestamp: number$1(),
17016
- sizeBytes: number$1().int(),
17017
- /** A copy of this original already exists — selecting it is free and cannot
17018
- * fail, whatever became of the original. */
17019
- copied: boolean()
17045
+ kinds: array(EventKindDescriptorSchema).readonly()
17020
17046
  });
17021
- /** A frame the dataset OWNS: bytes copied at selection time. */
17022
- var RetrainFrameSchema = object({
17023
- frameId: string(),
17047
+ var SensorEventSchema = object({
17048
+ id: string(),
17049
+ /** The CAMERA the event is attributed to (a sensor linked to N cameras
17050
+ * yields N rows, one per camera). */
17024
17051
  deviceId: number$1(),
17025
- trackId: string(),
17026
- /** Provenance only. It may already point at nothing — that is expected. */
17027
- sourceMediaKey: string(),
17028
- sourceKind: MediaFileKindEnum,
17029
- sizeBytes: number$1().int(),
17030
- width: number$1().int(),
17031
- height: number$1().int(),
17032
- copiedAt: number$1()
17052
+ /** The linked sensor device whose state changed. */
17053
+ sourceDeviceId: number$1(),
17054
+ /** Event kind id — matches an `EventKindDescriptor.kind`. */
17055
+ kind: string(),
17056
+ /** Snapshot of the sensor cap's runtime-state slice at the change. */
17057
+ value: record(string(), unknown()).nullable(),
17058
+ timestamp: number$1()
17033
17059
  });
17034
- /** Why a copy-on-select could not be honoured — named, never a silent skip. */
17035
- var RetrainCopyRefusalSchema = _enum([
17036
- "source-missing",
17037
- "unreadable-image",
17038
- "write-failed"
17039
- ]);
17040
- var RetrainFrameSelectionSchema = object({
17041
- copied: array(RetrainFrameSchema).readonly(),
17042
- refused: array(object({
17043
- sourceMediaKey: string(),
17044
- reason: RetrainCopyRefusalSchema
17045
- })).readonly()
17060
+ var TrackPositionSchema = object({
17061
+ x: number$1(),
17062
+ y: number$1(),
17063
+ timestamp: number$1(),
17064
+ bbox: BoundingBoxSchema
17046
17065
  });
17047
- var RetrainFrameListSchema = object({
17048
- candidates: array(RetrainFrameCandidateSchema).readonly(),
17049
- copies: array(RetrainFrameSchema).readonly(),
17050
- /** What the page pre-selects — the native key frame when one survives. */
17051
- autoPickMediaKey: string().optional()
17066
+ var TrackSnapshotSchema = object({
17067
+ timestamp: number$1(),
17068
+ position: TrackPositionSchema,
17069
+ /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
17070
+ mediaKey: string()
17052
17071
  });
17053
- /** What the operator asked the assist to look for. */
17054
- var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
17055
- kind: literal("package"),
17056
- zone: RetrainBboxSchema.optional()
17057
- }), object({
17058
- kind: literal("objects"),
17059
- modelId: string(),
17060
- minScore: number$1().optional()
17061
- })]);
17062
17072
  /**
17063
- * The assist's answer — a discriminated union, because "the model saw nothing"
17064
- * and "this node cannot run that model" lead to different next moves and a
17065
- * nullable result cannot tell them apart.
17073
+ * Normalized 0..1 trajectory envelope (min/max over every position bbox,
17074
+ * divided by the track's detection-frame dims), computed at persist time.
17075
+ * Absent when the frame dims were unknown when the track was persisted
17076
+ * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
17066
17077
  */
17067
- var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
17068
- kind: literal("proposed"),
17069
- modelId: string(),
17070
- stepId: string(),
17071
- minScore: number$1(),
17072
- /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
17073
- proposals: array(RetrainAnnotationDraftSchema).readonly(),
17074
- /** Returned by the runner but removed by the threshold. */
17075
- belowThreshold: number$1().int()
17076
- }), object({
17077
- kind: literal("refused"),
17078
- /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
17079
- reason: string(),
17080
- detail: string().optional()
17081
- })]);
17082
- /** The outcome of a lifecycle move owned by the retrain page. */
17083
- var RetrainTransitionResultSchema = object({
17084
- trackId: string(),
17085
- /** Where the track ended up, whatever happened. */
17086
- retrainStatus: RetrainStatusSchema,
17087
- /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
17088
- changed: boolean(),
17089
- reason: _enum([
17090
- "unknown-track",
17091
- "no-frames-copied",
17092
- "not-staging",
17093
- "not-trained",
17094
- "unchanged"
17095
- ]).optional()
17096
- });
17097
- var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
17098
- var MAX_EVENT_QUERY_LIMIT = 5e3;
17099
- var DeviceEventQueryInput = object({
17100
- deviceId: number$1(),
17101
- since: number$1().optional(),
17102
- until: number$1().optional(),
17103
- limit: number$1().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
17104
- /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
17105
- * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
17106
- * exact behaviour. Callers may omit this field — the store defaults to
17107
- * `full` when not provided. */
17108
- projection: _enum(["full", "slim"]).optional()
17109
- });
17110
- var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
17111
- var RecentTracksQueryInput = object({
17112
- /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
17113
- deviceIds: array(number$1()),
17114
- /** Window lower bound on `lastSeen` (inclusive). */
17115
- since: number$1().optional(),
17116
- /** Window upper bound on `lastSeen` (inclusive). */
17117
- until: number$1().optional(),
17118
- /** Page size. Default 200, max 1000. */
17119
- limit: number$1().int().min(1).max(1e3).default(200),
17120
- /** Opaque continuation cursor from a previous page's `nextCursor`.
17121
- * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
17122
- cursor: string().optional(),
17123
- /** See {@link TrackProjectionSchema}. Default `full`. */
17124
- projection: TrackProjectionSchema.optional(),
17125
- /** Include stationary-promoted rows (parked objects). Default false: the
17126
- * feed lists passages; parking records live on the stationary registry. */
17127
- includeStationary: boolean().optional()
17078
+ var TrackEnvelopeSchema = object({
17079
+ minX: number$1(),
17080
+ minY: number$1(),
17081
+ maxX: number$1(),
17082
+ maxY: number$1()
17128
17083
  });
17129
- var RecentTracksPageSchema = object({
17130
- /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
17131
- tracks: array(TrackSchema).readonly(),
17132
- /** Cursor for the next page, or null when this page is the last. */
17133
- nextCursor: string().nullable()
17134
- });
17135
- var LIST_GROUPS_DEFAULT_LIMIT = 40;
17136
- var LIST_GROUPS_MAX_LIMIT = 100;
17137
- var AnalyticsGroupRecordSchema = object({
17138
- id: string(),
17139
- deviceId: number$1().int(),
17140
- openedAt: number$1().int(),
17141
- closedAt: number$1().int(),
17142
- timestamp: number$1().int(),
17143
- memberCount: number$1().int(),
17144
- memberTrackIds: array(string()).readonly(),
17145
- className: string(),
17146
- classes: array(string()).readonly(),
17147
- /** Relative event-media path, or null when the group has no picture yet. */
17148
- mediaUrl: string().nullable(),
17149
- singleton: boolean()
17150
- });
17151
- var AnalyticsGroupMemberSchema = object({
17152
- trackId: string(),
17153
- deviceId: number$1().int(),
17154
- className: string(),
17155
- firstSeen: number$1().int(),
17156
- lastSeen: number$1().int(),
17157
- mediaUrl: string().nullable()
17158
- });
17159
- var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
17160
- var ListGroupsQueryInput = object({
17161
- /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
17162
- deviceIds: array(number$1()),
17163
- /** Window lower bound on `closedAt` (inclusive). */
17164
- since: number$1().optional(),
17165
- /** Window upper bound on `openedAt` (inclusive). */
17166
- until: number$1().optional(),
17167
- limit: number$1().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
17168
- /** Opaque continuation cursor from a previous page's `nextCursor`. */
17169
- cursor: string().optional()
17170
- });
17171
- var ListGroupsPageSchema = object({
17172
- groups: array(AnalyticsGroupRecordSchema).readonly(),
17173
- nextCursor: string().nullable()
17174
- });
17175
- var KeyEventQueryInput = object({
17176
- deviceId: number$1(),
17177
- /** Window lower bound (track firstSeen ≥ since). */
17178
- since: number$1(),
17179
- /** Window upper bound (track firstSeen ≤ until). */
17180
- until: number$1(),
17181
- limit: number$1().int().min(1).max(200).default(50),
17182
- /** Drop tracks scoring below this importance. */
17183
- minImportance: number$1().min(0).max(1).optional(),
17184
- /** Restrict to a single class (e.g. 'person'). */
17185
- classFilter: string().optional()
17186
- });
17187
- var KeyEventSchema = object({
17188
- /** The representative event id (the track's best ObjectEvent, else its trackId). */
17189
- id: string(),
17190
- trackId: string(),
17191
- /** Track start time (firstSeen). */
17192
- timestamp: number$1(),
17193
- className: string(),
17194
- ...TieredLabelFields,
17195
- importance: number$1(),
17196
- /** Highest-confidence ObjectEvent id for the track (empty when none). */
17197
- bestEventId: string(),
17198
- /** Track lifetime in ms (lastSeen - firstSeen). */
17199
- windowMs: number$1().optional(),
17200
- ...TrackFlagFields,
17201
- ...TrackRetrainFields
17202
- });
17203
- object({
17204
- trackId: string(),
17205
- className: string(),
17206
- confidence: number$1(),
17207
- bbox: BoundingBoxSchema,
17208
- zones: array(string()).readonly(),
17209
- state: TrackStateSchema
17210
- });
17211
- var OverlayDetectionSchema = looseObject({
17212
- id: string(),
17213
- kind: _enum(["first-level", "detail"]),
17214
- macroClass: string(),
17215
- score: number$1(),
17216
- bbox: object({
17217
- x: number$1(),
17218
- y: number$1(),
17219
- width: number$1(),
17220
- height: number$1()
17221
- }),
17222
- labels: array(looseObject({
17223
- label: string(),
17224
- score: number$1()
17225
- })).readonly(),
17226
- parentId: string().optional()
17227
- });
17228
- var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number$1() });
17229
- var SearchObjectEventsInput = object({
17230
- text: string(),
17231
- deviceId: number$1().optional(),
17232
- since: number$1().optional(),
17233
- until: number$1().optional(),
17234
- classFilter: string().optional(),
17235
- limit: number$1().default(50),
17236
- minScore: number$1().min(0).max(1).default(.2)
17237
- });
17238
- var TrackCascadeCountsSchema = object({
17239
- /** Persisted track roots deleted (authoritative). */
17240
- tracks: number$1().int(),
17241
- /** Object events removed with their tracks (best-effort; see note above). */
17242
- events: number$1().int(),
17243
- /** Track/face/plate-owned media removed (best-effort). Never identity media. */
17244
- media: number$1().int(),
17245
- /** Unassigned (non-enrolled) face reads removed (best-effort). */
17246
- faces: number$1().int(),
17247
- /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
17248
- plates: number$1().int(),
17249
- /** Per-track CLIP search vectors removed (best-effort). */
17250
- embeddings: number$1().int(),
17251
- /** Group membership + group rows removed with their last member (best-effort). */
17252
- groups: number$1().int()
17253
- });
17254
- /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
17255
- var DiskReconcileCountsSchema = object({
17256
- mediaDropped: number$1().int(),
17257
- tracks: number$1().int(),
17258
- events: number$1().int()
17259
- });
17260
- /** Event-store footprint for one camera. */
17261
- var EventStoreDeviceFootprintSchema = object({
17262
- deviceId: number$1(),
17263
- /** Persisted event rows (motion + object + audio) for the camera. */
17264
- rows: number$1().int(),
17265
- /** Event-owned media bytes on disk for the camera. */
17266
- bytes: number$1().int()
17267
- });
17268
- /** Aggregate event-store footprint: global totals + per-camera breakdown. */
17269
- var EventStoreFootprintSchema = object({
17270
- totalRows: number$1().int(),
17271
- totalBytes: number$1().int(),
17272
- devices: array(EventStoreDeviceFootprintSchema).readonly()
17273
- });
17274
- /** Per-kind counts returned by the event-prune / device-delete mutations. */
17275
- var EventPruneCountsSchema = object({
17276
- motion: number$1().int(),
17277
- object: number$1().int(),
17278
- audio: number$1().int()
17084
+ /**
17085
+ * Row projection for track list queries. `full` (default) returns the
17086
+ * complete Track including the frame-rate `positions[]` history and the
17087
+ * `snapshots[]` references — megabytes across a page of tracks. `slim`
17088
+ * keeps every scalar the list surfaces actually render (ids, class(es),
17089
+ * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
17090
+ * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
17091
+ * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
17092
+ * `getTrack`. Mirrors the event-store `projection` convention
17093
+ * (`getObjectEvents` et al.).
17094
+ */
17095
+ var TrackProjectionSchema = _enum(["full", "slim"]);
17096
+ /**
17097
+ * One audio-classification label heard on the track's camera while the
17098
+ * track was alive, aggregated per label. An "episode" is one persisted
17099
+ * audio event (the confident-classification path: score ≥ the device's
17100
+ * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
17101
+ * one 32 ms inference chunk, so counts stay human-scaled.
17102
+ */
17103
+ var TrackAudioLabelSchema = object({
17104
+ label: string(),
17105
+ /** Highest classification score observed across the label's episodes. */
17106
+ peakScore: number$1(),
17107
+ /** Number of coalesced audio-event episodes carrying this label. */
17108
+ count: number$1(),
17109
+ firstAt: number$1(),
17110
+ lastAt: number$1()
17279
17111
  });
17280
17112
  /**
17281
- * Re-embed stored tracks from their key frames.
17113
+ * How a track was produced. `pipeline` (default / absent) = the spatial
17114
+ * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
17115
+ * no positions, a single snapshot, and no bbox trajectory at all:
17282
17116
  *
17283
- * The reason this is an operator-callable method and not a migration script:
17284
- * every knob that decides what a vector MEANS — encoder model, crop margin,
17285
- * squaring — is only changeable if the existing vectors can be regenerated.
17286
- * Mixing feature spaces in one index makes cosine scores incomparable, and the
17287
- * symptom is a quality regression with no visible cause.
17117
+ * - `sensor` — a linked sensor/control device state change.
17118
+ * - `audio` — an audio event on the camera itself that was anomalous for
17119
+ * THAT camera, loud, and heard while nothing visual was happening (D62).
17120
+ *
17121
+ * The spatial subsystems (tracker association, occupancy count, re-id /
17122
+ * embedding, resurrection) MUST skip every synthetic source. Test for that
17123
+ * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
17124
+ * check silently readmits every source added after it was written.
17288
17125
  */
17289
- var RebuildObjectEmbeddingsInput = object({
17290
- /** Restrict to one camera. Omit for the whole fleet. */
17291
- deviceId: number$1().optional(),
17292
- since: number$1().optional(),
17293
- until: number$1().optional(),
17294
- /** Stop after this many tracks; the result reports whether more remain. */
17295
- maxTracks: number$1().int().positive().optional(),
17296
- /**
17297
- * Run every embedding on THIS node instead of round-robining the fleet.
17298
- *
17299
- * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
17300
- * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
17301
- * calling it that would pin the rebuild REQUEST itself to that node — the
17302
- * rebuild orchestration lives on the hub, and only the per-track step runs
17303
- * remotely. This field is data; the per-track pin is applied inside.
17304
- *
17305
- * Absent ⇒ round-robin over every online node whose runner can serve the
17306
- * pinned model.
17307
- */
17308
- executeOnNodeId: string().optional(),
17309
- /**
17310
- * Milliseconds to wait between tracks; omit for the built-in default, `0` to
17311
- * run flat out.
17312
- *
17313
- * A rebuild is bulk maintenance on hub-main's single thread. Measured
17314
- * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
17315
- * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
17316
- * force is logged at start and finish so a deliberately slow pass reads
17317
- * differently from a stalled one.
17318
- */
17319
- pacingMs: number$1().int().nonnegative().optional()
17320
- });
17126
+ var TrackSourceSchema = _enum([
17127
+ "pipeline",
17128
+ "sensor",
17129
+ "audio"
17130
+ ]);
17321
17131
  /**
17322
- * Result of emptying the CLIP index.
17132
+ * Where a track sits in the RETRAIN lifecycle (D81).
17323
17133
  *
17324
- * The clean slate before a policy change: a new crop margin or encoder model
17325
- * leaves two feature spaces in one index whose cosine scores are not
17326
- * comparable, so wiping and rebuilding is the only way to be sure every vector
17327
- * means the same thing.
17134
+ * - `none` — never marked, or un-marked. Evictable.
17135
+ * - `staging` — the operator wants this track as training material and has not
17136
+ * finished with it. **This is the only state retention holds**: the track and
17137
+ * everything it owns (object events, crops, keyframes, CLIP vector) survive
17138
+ * the device's age window.
17139
+ * - `trained` — the retrain page has taken what it needed. The frames it chose
17140
+ * were COPIED into the retrain dataset at selection time, so the dataset no
17141
+ * longer depends on the track's media and the track becomes EVICTABLE again.
17142
+ * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
17143
+ * a deliberate action of the retrain page, not a side effect of a checkbox.
17144
+ *
17145
+ * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
17146
+ * the store's filter language has only positive equality and `whereIn` — no
17147
+ * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
17148
+ * would make the entire pre-column history immortal in one deploy.
17328
17149
  */
17329
- var WipeObjectEmbeddingsResultSchema = object({ deleted: number$1() });
17150
+ var RetrainStatusSchema = _enum([
17151
+ "none",
17152
+ "staging",
17153
+ "trained"
17154
+ ]);
17330
17155
  /**
17331
- * Acknowledgement that a rebuild STARTED.
17156
+ * Per-track OPERATOR flags — set by hand from the admin UI or the viewer, never
17157
+ * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
17158
+ * so the two surfaces cannot drift.
17332
17159
  *
17333
- * The pass costs ~1s per track — 45 minutes for a 2,600-track fleet — so it
17334
- * runs detached and this returns immediately. Waiting for it made the client
17335
- * time out while the work carried on server-side, which is the worst of both:
17336
- * no result and no way to know it was still going. Poll
17337
- * `getObjectEmbeddingRebuildStatus` for progress.
17160
+ * **Absent ≠ false.** A track that has never been touched omits the field; an
17161
+ * explicitly un-flagged track carries `false`. Legacy rows written before the
17162
+ * columns existed read as absent, and a consumer that needs a boolean should say
17163
+ * `flag === true`, not `flag !== false`.
17164
+ *
17165
+ * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
17166
+ * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
17167
+ * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
17168
+ * `trained` track reports `false` while refusing both writes. The boolean is
17169
+ * kept because three surfaces drive a toggle off it; anything that needs to tell
17170
+ * "never marked" from "already trained" must read `retrainStatus`.
17171
+ *
17172
+ * `debug` does NOT pin; it is attention, not durability.
17173
+ *
17174
+ * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
17175
+ * A favourited track is skipped by retention the same way `staging` is, but
17176
+ * it does not enter `none|staging|trained` and has no staging budget.
17338
17177
  */
17339
- var RebuildObjectEmbeddingsResultSchema = object({
17340
- started: boolean(),
17341
- /** True when a pass was already running; the new request is ignored. */
17342
- alreadyRunning: boolean()
17343
- });
17344
- var RebuildStatusSchema = object({
17345
- running: boolean(),
17346
- scanned: number$1(),
17347
- rebuilt: number$1(),
17348
- /** Tracks whose key frame is gone — nothing to re-embed from. */
17349
- missingKeyFrame: number$1(),
17350
- /** Tracks with no usable detection box. */
17351
- missingBbox: number$1(),
17352
- /**
17353
- * Tracks an executing node REFUSED rather than broke on — an unreadable key
17354
- * frame, a step that threw. Separate from `failed` because the remedy is
17355
- * different, and because a whole camera silently contributing zero vectors
17356
- * is the shape of failure a rebuild must never hide.
17357
- */
17358
- notRunnable: number$1(),
17178
+ var TrackFlagFields = {
17179
+ /** Operator marked this track as training material — i.e. `retrainStatus` is
17180
+ * `'staging'`. */
17181
+ markForTrain: boolean().optional(),
17182
+ /** Operator marked this track for diagnostic attention. */
17183
+ debug: boolean().optional(),
17184
+ /** Operator favourited this track. Pins it against pruning. */
17185
+ favourited: boolean().optional()
17186
+ };
17187
+ /**
17188
+ * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
17189
+ * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
17190
+ * write patch, and the status is not something the toggle sets — it is what the
17191
+ * toggle's boolean is derived from. Absent on an in-RAM track never touched;
17192
+ * always present on a persisted row (the column default materialises `'none'`).
17193
+ */
17194
+ var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
17195
+ /**
17196
+ * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
17197
+ * one flag can never clear the other — the toggles are independent and are
17198
+ * driven from three surfaces that do not know about each other.
17199
+ */
17200
+ var TrackFlagsPatchSchema = object(TrackFlagFields);
17201
+ /**
17202
+ * The resolved flag state after a write. Both fields are REQUIRED here (absent
17203
+ * collapses to `false`) so a caller can drive a toggle's checked state off the
17204
+ * mutation result without a re-fetch.
17205
+ */
17206
+ var TrackFlagsSchema = object({
17207
+ trackId: string(),
17208
+ markForTrain: boolean(),
17209
+ debug: boolean(),
17210
+ favourited: boolean(),
17211
+ /** The lifecycle state the boolean was derived from. Required here (unlike on
17212
+ * a track row) because this shape is only ever produced by the write body,
17213
+ * which always knows it — and a surface that has just written needs to render
17214
+ * `trained` without a re-fetch. */
17215
+ retrainStatus: RetrainStatusSchema
17216
+ });
17217
+ union([literal(1), literal(2)]);
17218
+ /**
17219
+ * WHO decided a label, and when. Carried per tier so a value can be traced to
17220
+ * the step and model that produced it — which is what makes the write rule
17221
+ * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
17222
+ * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
17223
+ *
17224
+ * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
17225
+ * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
17226
+ * `migration:4g` for a value the 4g migration moved from the single-slot era —
17227
+ * that value has no provenance, and the write rule lets ANY properly-attributed
17228
+ * write of the same tier replace it regardless of score.
17229
+ */
17230
+ var LabelAttributionSchema = object({
17231
+ stepId: string(),
17232
+ modelId: string().optional(),
17233
+ decidedAt: number$1(),
17359
17234
  /**
17360
- * The pass stopped because NO node could serve the pinned model.
17235
+ * The GALLERY id behind a recognised tier-2 label — a face-gallery
17236
+ * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
17361
17237
  *
17362
- * Distinct from `notRunnable` on purpose: that one says "this track was
17363
- * refused", this one says "the cluster cannot do this work at all" — every
17364
- * candidate node either lacks the `clip-embedding` step, lacks a build of the
17365
- * pinned model for its engine format, or dropped out. The remedy is a model /
17366
- * engine change, not a per-camera one. Non-zero here always comes with
17367
- * `complete: false`.
17238
+ * The text alone is a DISPLAY NAME, and a display name is renameable: a
17239
+ * notification rule authored on "Gianluca" stopped matching the moment the
17240
+ * operator fixed the spelling in the gallery, and nothing said so. The id is
17241
+ * the thing that does not move, so it is what a rule matches on
17242
+ * (`NcConditions.identities`) and the text is what a human is shown.
17243
+ *
17244
+ * Absent when the label names no gallery row — a plate the OCR read but no
17245
+ * vehicle claims, a sub-class, a species, any tier-1 value.
17368
17246
  */
17369
- noCapableNode: number$1(),
17370
- failed: number$1(),
17371
- /** Set once a pass ends: true only when EVERYTHING was covered. */
17372
- complete: boolean().nullable(),
17373
- startedAtMs: number$1().nullable(),
17374
- finishedAtMs: number$1().nullable(),
17375
- /** Present when the pass ended by throwing. */
17376
- error: string().nullable()
17247
+ identityId: string().optional()
17377
17248
  });
17378
- DeviceType.Camera, method(object({ deviceId: number$1() }), array(TrackSchema).readonly()), method(object({
17379
- deviceId: number$1(),
17380
- trackId: string()
17381
- }), TrackSchema.nullable()), method(object({
17382
- deviceId: number$1(),
17383
- since: number$1().optional(),
17384
- until: number$1().optional(),
17385
- limit: number$1().optional(),
17386
- /** Spatial filter — only tracks whose trajectory intersects the zone
17387
- * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
17388
- * envelope columns, then precisely tested per position. Tracks with
17389
- * an unknown envelope (no frame dims at persist time) always match. */
17390
- zone: TrackZoneFilterSchema.optional(),
17391
- /** See {@link TrackProjectionSchema}. Default `full` (backward
17392
- * compatible — omitting the field keeps today's exact behaviour). */
17393
- projection: TrackProjectionSchema.optional(),
17394
- /** Include stationary-promoted rows (parked objects handed to the
17395
- * stationary registry). Default false: the timeline lists passages,
17396
- * not parking records (operator decision, 2026-08-15). */
17397
- includeStationary: boolean().optional()
17398
- }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
17399
- deviceId: number$1(),
17400
- groupId: string().min(1)
17401
- }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number$1() }), _void(), {
17402
- kind: "mutation",
17403
- auth: "admin"
17404
- }), method(DeviceEventQueryInput, array(MotionEventSchema).readonly()), method(ObjectEventQueryInput, array(ObjectEventSchema).readonly()), method(DeviceEventQueryInput, array(AudioEventSchema).readonly()), method(object({ deviceId: number$1() }), array(EventKindDescriptorSchema).readonly()), method(object({ deviceIds: array(number$1()).min(1).max(200) }), array(EventKindsForDeviceSchema).readonly()), method(object({
17405
- deviceId: number$1(),
17406
- since: number$1().optional(),
17407
- until: number$1().optional(),
17408
- kinds: array(string()).optional(),
17409
- limit: number$1().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
17410
- }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
17411
- deviceId: number$1(),
17412
- since: number$1(),
17413
- until: number$1(),
17414
- bucketMs: number$1().int().positive()
17415
- }), array(object({
17416
- bucketStart: number$1(),
17417
- motion: number$1().int(),
17418
- object: number$1().int(),
17419
- audio: number$1().int()
17420
- })).readonly()), method(object({
17421
- deviceId: number$1(),
17422
- cutoffMs: number$1()
17423
- }), object({
17424
- motion: number$1().int(),
17425
- object: number$1().int(),
17426
- audio: number$1().int()
17427
- }), {
17428
- kind: "mutation",
17429
- auth: "admin"
17430
- }), method(object({
17431
- deviceId: number$1(),
17432
- cutoffMs: number$1()
17433
- }), TrackCascadeCountsSchema, {
17434
- kind: "mutation",
17435
- auth: "admin"
17436
- }), method(object({ deviceId: number$1() }), TrackCascadeCountsSchema, {
17437
- kind: "mutation",
17438
- auth: "admin"
17439
- }), method(object({ deviceId: number$1() }), DiskReconcileCountsSchema, {
17440
- kind: "mutation",
17441
- auth: "admin"
17442
- }), method(object({
17443
- deviceId: number$1(),
17444
- trackIds: array(string()).min(1)
17445
- }), object({
17446
- deleted: number$1().int(),
17447
- failed: array(string()).readonly()
17448
- }), {
17449
- kind: "mutation",
17450
- auth: "admin"
17451
- }), method(object({
17452
- /** Log/audit scope only — the trackId is globally unique on its own. */
17249
+ /**
17250
+ * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
17251
+ * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
17252
+ * track and its events always answer the same question the same way.
17253
+ *
17254
+ * Two scalar columns, not an array: every consumer wants "the coarse one" or
17255
+ * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
17256
+ * is tier 2, and each carries its own score + attribution.
17257
+ *
17258
+ * **Reading it.** What a human should be shown is `subLabel ?? label` — the
17259
+ * finest thing known. Before 4g the single `label` column held the finest
17260
+ * value, so a consumer that has not been updated reads the tier-1 slot and
17261
+ * shows nothing on a species-only row; that is why the migration puts every
17262
+ * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
17263
+ * and why the read surfaces were changed in the same train.
17264
+ *
17265
+ * **Writing it.** The slots are independent, which is the whole point: a
17266
+ * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
17267
+ * migratorius`), so fineness cannot regress by construction. Within a tier the
17268
+ * higher score wins. One rule, one implementation — see
17269
+ * `pipeline/label-tier.ts` in addon-post-analysis.
17270
+ */
17271
+ var TieredLabelFields = {
17272
+ /** Tier 1 — the sub-class. See {@link LabelTierSchema}. */
17273
+ label: string().optional(),
17274
+ /** Confidence of the tier-1 value, as reported by the deciding step. */
17275
+ labelScore: number$1().optional(),
17276
+ /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
17277
+ labelMeta: LabelAttributionSchema.optional(),
17278
+ /** Tier 2 — the instance. See {@link LabelTierSchema}. */
17279
+ subLabel: string().optional(),
17280
+ /** Confidence of the tier-2 value, as reported by the deciding step. */
17281
+ subLabelScore: number$1().optional(),
17282
+ /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
17283
+ subLabelMeta: LabelAttributionSchema.optional()
17284
+ };
17285
+ /** Per-camera slice of a training-export estimate. */
17286
+ var TrainingExportDeviceTotalsSchema = object({
17453
17287
  deviceId: number$1(),
17288
+ tracks: number$1().int(),
17289
+ files: number$1().int(),
17290
+ bytes: number$1().int()
17291
+ });
17292
+ /**
17293
+ * What a training export WOULD contain. Computed from media index rows only —
17294
+ * no blob is read to produce this.
17295
+ */
17296
+ var TrainingExportSummarySchema = object({
17297
+ generatedAt: number$1(),
17298
+ trackCount: number$1().int(),
17299
+ fileCount: number$1().int(),
17300
+ byteCount: number$1().int(),
17301
+ /** More marked tracks exist than a single pass carries. */
17302
+ truncated: boolean(),
17303
+ devices: array(TrainingExportDeviceTotalsSchema).readonly()
17304
+ });
17305
+ var TrackSchema = object({
17454
17306
  trackId: string(),
17455
- flags: TrackFlagsPatchSchema
17456
- }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
17457
- kind: "query",
17458
- auth: "admin"
17459
- }), method(object({
17460
- olderThanMs: number$1(),
17461
- reason: OpsLogReasonSchema.optional()
17462
- }), EventPruneCountsSchema, {
17463
- kind: "mutation",
17464
- auth: "admin"
17465
- }), method(object({ deviceId: number$1() }), EventPruneCountsSchema, {
17466
- kind: "mutation",
17467
- auth: "admin"
17468
- }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
17469
- kind: "mutation",
17470
- auth: "admin"
17471
- }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
17472
- kind: "mutation",
17473
- auth: "admin"
17474
- }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
17475
- kind: "mutation",
17476
- auth: "admin"
17477
- }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
17478
- kind: "mutation",
17479
- auth: "admin"
17480
- }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
17481
- kind: "mutation",
17482
- auth: "admin"
17483
- }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
17484
- kind: "query",
17485
- auth: "admin"
17486
- }), method(object({ deviceIds: array(number$1()).optional() }), TrainingExportSummarySchema, {
17487
- kind: "query",
17488
- auth: "admin"
17489
- }), method(object({ deviceIds: array(number$1()).optional() }), object({ url: string() }), {
17490
- kind: "query",
17491
- auth: "admin"
17492
- }), method(object({
17493
- /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
17494
- * `deviceId`, deliberately: `deviceId` would make this device-bound and
17495
- * route it at one camera's owner, and "every camera" would stop being
17496
- * expressible at all. */
17497
- deviceIds: array(number$1()).optional(),
17498
- limit: number$1().int().min(1).max(500).optional()
17499
- }), array(RetrainTrackSchema).readonly(), {
17500
- kind: "query",
17501
- auth: "admin"
17502
- }), method(object({ trackId: string() }), RetrainFrameListSchema, {
17503
- kind: "query",
17504
- auth: "admin"
17505
- }), method(object({
17506
17307
  deviceId: number$1(),
17507
- trackId: string(),
17508
- mediaKeys: array(string()).min(1)
17509
- }), RetrainFrameSelectionSchema, {
17510
- kind: "mutation",
17511
- auth: "admin"
17512
- }), method(object({
17308
+ className: string(),
17309
+ ...TieredLabelFields,
17310
+ producingDeviceName: string().optional(),
17311
+ /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
17312
+ source: TrackSourceSchema.optional(),
17313
+ firstSeen: number$1(),
17314
+ lastSeen: number$1(),
17315
+ /** Frame-rate position history (subject to maxPositionHistory cap). */
17316
+ positions: array(TrackPositionSchema).readonly(),
17317
+ /** Periodic snapshots at snapshotIntervalMs cadence (subject to
17318
+ * saveThumbnails policy). */
17319
+ snapshots: array(TrackSnapshotSchema).readonly(),
17320
+ /** Deduplicated zones the track has entered at least once. Zone IDS. */
17321
+ zonesVisited: array(string()).readonly(),
17322
+ /**
17323
+ * Human NAMES for {@link zonesVisited}, resolved at READ time against the
17324
+ * `zones` capability.
17325
+ *
17326
+ * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
17327
+ * and no card can render — so every free-text search surface was structurally
17328
+ * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
17329
+ * just returned nothing. Resolving here rather than in each client keeps ONE
17330
+ * derivation and costs the clients no extra call (the `zones` cap is
17331
+ * per-device, so a client-side resolve would be a per-camera fan-out on a
17332
+ * surface built to avoid exactly that).
17333
+ *
17334
+ * Resolved, never invented: a zone deleted since the track was written has no
17335
+ * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
17336
+ * two are not positionally aligned. Absent when the track visited no zone, or
17337
+ * when the zone catalogue could not be read.
17338
+ */
17339
+ zoneNames: array(string()).readonly().optional(),
17340
+ /** Deduplicated set of detector classes observed for this track over its
17341
+ * life (a track may be reclassified, e.g. person→vehicle). Absent on
17342
+ * legacy rows written before class accumulation shipped. */
17343
+ classes: array(string()).readonly().optional(),
17344
+ /** Cumulative normalized distance travelled (0..1 units = full frame width). */
17345
+ totalDistance: number$1(),
17346
+ state: TrackStateSchema,
17347
+ active: boolean(),
17348
+ /** Deterministic key-event importance score in [0,1] (server-computed at
17349
+ * track expiry, recomputed on late label). Absent on legacy rows written
17350
+ * before scoring shipped — consumers degrade to absence / compute-on-read. */
17351
+ importance: number$1().optional(),
17352
+ /** Id of the track's highest-confidence ObjectEvent (its representative
17353
+ * "best" frame). Absent when the track produced no object events. */
17354
+ bestEventId: string().optional(),
17355
+ /** Tag of the importance sub-signal that dominated the score
17356
+ * (identity|dwell|proximity|class|confidence|travel|zone). */
17357
+ importanceReason: string().optional(),
17358
+ /** Audio-classification labels heard on the camera during the track's
17359
+ * life (score ≥ device `classificationMinScore`), aggregated per label.
17360
+ * Absent on legacy rows / tracks with no confident audio. */
17361
+ audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
17362
+ /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
17363
+ * Populated from the persisted envelope columns on historical reads;
17364
+ * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
17365
+ envelope: TrackEnvelopeSchema.optional(),
17366
+ /**
17367
+ * A face DETECTOR found a face on this track — nothing more. It says the
17368
+ * detail plane produced a `face` detail; it does NOT say the face was
17369
+ * embedded, matched, above `minFacePx`, or that the recognizer was even
17370
+ * enabled. Set once and never cleared.
17371
+ *
17372
+ * **This exists so "face present but not recognised" is expressible.** A
17373
+ * recognised identity lands in `subLabel` (attributed to the face chain via
17374
+ * `subLabelMeta.stepId`), so before this field a track with an unmatched face
17375
+ * and a track with no face at all were byte-identical on the wire and no
17376
+ * surface could tell them apart. The read is `hasFace === true && subLabel
17377
+ * === undefined`.
17378
+ *
17379
+ * **Absent ≠ false.** Every row written before the column existed omits it,
17380
+ * and so does every server that predates the field — a consumer must test
17381
+ * `=== true` and render nothing otherwise, never infer "no face".
17382
+ */
17383
+ hasFace: boolean().optional(),
17384
+ /**
17385
+ * This track has a face row IN THE GALLERY: a crop **and** an embedding — a
17386
+ * face an operator could ASSIGN to an identity.
17387
+ *
17388
+ * The STRICT twin of {@link hasFace}, and the pair only earns its keep
17389
+ * because the two disagree. `hasFace` is stamped at the TOP of the face
17390
+ * branch, before every gate, and means no more than "a face detector produced
17391
+ * a face detail". This one is stamped at the single moment the gallery row
17392
+ * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
17393
+ * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
17394
+ * candidate gate, the imageless-track drop (no crop was ever captured) and
17395
+ * the crop-store drop. Everything between the detector and that insert can
17396
+ * legitimately refuse the face, so a flag written any earlier promises the
17397
+ * operator something to assign and delivers nothing.
17398
+ *
17399
+ * **Independent of recognition.** A face collected but never auto-matched is
17400
+ * still assignable — it is in fact the face an operator most wants to reach —
17401
+ * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
17402
+ * `subLabel`; this says only that the raw material exists.
17403
+ *
17404
+ * **Set once, never cleared.** A track that produced a gallery row produced
17405
+ * one; deleting the row later is the gallery's business, not this flag's.
17406
+ *
17407
+ * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
17408
+ * before the column omits it, and so does every server that predates the
17409
+ * field. A consumer must test `=== true` and render nothing otherwise —
17410
+ * never infer "no assignable face".
17411
+ */
17412
+ hasEmbeddedFace: boolean().optional(),
17413
+ /**
17414
+ * This subject CONTAINS a folded rider — a person the rider-pairing step
17415
+ * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
17416
+ * so the passage is tracked once and as a VEHICLE.
17417
+ *
17418
+ * It exists because the fold's record was dishonest. D34 and the code both
17419
+ * said "the person is not lost — it is reported so both entities stay on the
17420
+ * record"; in fact the pair went into a per-processor RAM field behind an
17421
+ * accessor nobody called, and every durable surface said `vehicle`, full
17422
+ * stop. This is the composition note that makes the row true.
17423
+ *
17424
+ * A COMPOSITION, never a class and never a label. "This vehicle contains a
17425
+ * person" is not an answer to "what is this" — both label tiers would refuse
17426
+ * a macro token anyway (D89), and correctly. Nothing here changes what the
17427
+ * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
17428
+ * and a `person` rule still does not fire for someone cycling past.
17429
+ *
17430
+ * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
17431
+ * the column, and every hub that predates the field, omits it. Test
17432
+ * `=== true` and render nothing otherwise — never infer "no rider".
17433
+ */
17434
+ hasRider: boolean().optional(),
17435
+ ...TrackFlagFields,
17436
+ ...TrackRetrainFields
17437
+ });
17438
+ var BaseEventFields = {
17439
+ id: string(),
17513
17440
  deviceId: number$1(),
17514
- trackId: string(),
17515
- frameId: string()
17516
- }), object({
17517
- removed: boolean(),
17518
- removedAnnotations: number$1().int()
17519
- }), {
17520
- kind: "mutation",
17521
- auth: "admin"
17522
- }), method(object({ frameId: string() }), object({
17441
+ timestamp: number$1()
17442
+ };
17443
+ var MotionEventSchema = object({
17444
+ ...BaseEventFields,
17445
+ kind: literal("motion"),
17446
+ regionCount: number$1(),
17447
+ /** Heavy JSON array — omitted in slim projection. */
17448
+ regions: array(object({
17449
+ bbox: BoundingBoxSchema,
17450
+ pixelCount: number$1(),
17451
+ intensity: number$1()
17452
+ })).readonly().optional(),
17453
+ /** Omitted in slim projection. */
17454
+ frameWidth: number$1().optional(),
17455
+ /** Omitted in slim projection. */
17456
+ frameHeight: number$1().optional(),
17457
+ /** Populated by B5 (recording playback URL for this event). */
17458
+ mediaUrl: string().optional()
17459
+ });
17460
+ /**
17461
+ * Which detection SOURCE produced an object event. `pipeline` = the ML
17462
+ * detection pipeline (decoded-frame inference); `onboard` = the camera's
17463
+ * native on-device AI. Both flow through the SAME analysis layers (zoning,
17464
+ * tracking, per-kind persistence) but stay distinguishable so consumers
17465
+ * (advanced-notifier, occupancy, …) can select which source(s) to act on.
17466
+ * Absent on legacy rows ⇒ treat as `pipeline`.
17467
+ */
17468
+ var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
17469
+ /**
17470
+ * The confirmed zone crossing that produced an object event. Present ONLY on
17471
+ * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
17472
+ * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
17473
+ * appearance event carry none, so a rule asking for a direction fails closed
17474
+ * on them.
17475
+ *
17476
+ * Exactly ONE crossing per event: the emitter turns each confirmed crossing
17477
+ * into its own event, so a frame in which a track enters A while leaving B
17478
+ * produces two events with two directions — never one ambiguous row.
17479
+ *
17480
+ * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
17481
+ * membership the box has NOW, and by definition it no longer contains the zone
17482
+ * that was just left. Without the id here, a zone-scoped rule could never match
17483
+ * the exit it asked for.
17484
+ */
17485
+ var ZoneCrossingSchema = object({
17486
+ direction: _enum(["enter", "exit"]),
17487
+ /** Admin zone id crossed. */
17488
+ zoneId: string(),
17489
+ /** Zone display name at crossing time (falls back to the id). */
17490
+ zoneName: string().optional()
17491
+ });
17492
+ var ObjectEventSchema = object({
17493
+ ...BaseEventFields,
17494
+ kind: literal("object"),
17495
+ /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
17496
+ source: DetectionSourceSchema.optional(),
17497
+ /**
17498
+ * Inference-frame id shared by every object event emitted from the SAME frame
17499
+ * — the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
17500
+ * 2 people + 1 dog) under one full frame, and link a track's frames over time
17501
+ * (group by `trackId`, pick a representative `frameId` as the parent frame).
17502
+ * Optional for backward-compat with pre-existing rows / the slim projection
17503
+ * includes it (it is light). Absent on rows written before this field.
17504
+ */
17505
+ frameId: string().optional(),
17506
+ /** Omitted in slim projection. */
17507
+ trackId: string().optional(),
17508
+ className: string(),
17509
+ ...TieredLabelFields,
17510
+ /** Omitted in slim projection. */
17511
+ confidence: number$1().optional(),
17512
+ /** Heavy JSON — omitted in slim projection. */
17513
+ bbox: BoundingBoxSchema.optional(),
17514
+ /** Heavy JSON — omitted in slim projection. */
17515
+ zones: array(string()).readonly().optional(),
17516
+ /** Omitted in slim projection. */
17517
+ state: TrackStateSchema.optional(),
17518
+ /**
17519
+ * The zone crossing this event IS, when it is one. Absent on every other
17520
+ * event kind (movement state, appearance, package) — see
17521
+ * {@link ZoneCrossingSchema}. Omitted in slim projection.
17522
+ */
17523
+ zoneCrossing: ZoneCrossingSchema.optional(),
17524
+ /** Detection-frame dimensions in pixels — let consumers normalize the
17525
+ * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
17526
+ frameWidth: number$1().optional(),
17527
+ frameHeight: number$1().optional(),
17528
+ /** MediaStore key for the crop attached to this event (if any). */
17529
+ mediaKey: string().optional(),
17530
+ /** Design B: MediaStore key of the track's native-resolution key frame (the
17531
+ * best-detection full frame). Resolve via the event-media data-plane
17532
+ * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
17533
+ * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
17534
+ * sources — consumers fall back to `mediaKey` (the tight crop). */
17535
+ keyFrameMediaKey: string().optional(),
17536
+ /** Populated by B5 (recording playback URL for this event). */
17537
+ mediaUrl: string().optional(),
17538
+ /** The parent track's key-event importance [0,1], propagated to every object
17539
+ * event of the track (so an event row can be sorted by importance without a
17540
+ * track join). Absent on legacy rows / before the track was scored. */
17541
+ importance: number$1().optional()
17542
+ });
17543
+ var AudioEventSchema = object({
17544
+ ...BaseEventFields,
17545
+ kind: literal("audio"),
17546
+ rms: number$1(),
17547
+ dbfs: number$1(),
17548
+ classification: object({
17549
+ className: string(),
17550
+ originalClass: string().optional(),
17551
+ score: number$1()
17552
+ }).optional(),
17553
+ /** Populated by B5 (recording playback URL for this event). */
17554
+ mediaUrl: string().optional()
17555
+ });
17556
+ var MediaFileKindEnum = _enum([
17557
+ "crop",
17558
+ "thumbnail",
17559
+ "snapshot",
17560
+ "firstFrame",
17561
+ "lastFrame",
17562
+ "fullFrame",
17563
+ "fullFrameBoxed",
17564
+ "faceCrop",
17565
+ "plateCrop",
17566
+ "keyFrame",
17567
+ "keyFrameSmall",
17568
+ "thumbnailSmall"
17569
+ ]);
17570
+ var MediaFileSchema = object({
17571
+ key: string(),
17572
+ kind: MediaFileKindEnum,
17523
17573
  base64: string(),
17524
- width: number$1().int(),
17525
- height: number$1().int()
17526
- }), {
17527
- kind: "query",
17528
- auth: "admin"
17529
- }), method(object({
17530
- deviceId: number$1(),
17531
- trackId: string(),
17532
- frameId: string(),
17533
- subject: RetrainAssistSubjectSchema,
17534
- /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
17535
- nodeId: string().optional()
17536
- }), RetrainAssistResultSchema, {
17537
- kind: "mutation",
17538
- auth: "admin"
17539
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
17540
- kind: "query",
17541
- auth: "admin"
17542
- }), method(object({
17543
- deviceId: number$1(),
17544
- trackId: string(),
17545
- frameId: string(),
17546
- annotations: array(RetrainAnnotationDraftSchema)
17547
- }), array(RetrainAnnotationSchema).readonly(), {
17548
- kind: "mutation",
17549
- auth: "admin"
17550
- }), method(object({
17551
- deviceId: number$1(),
17552
- trackId: string()
17553
- }), RetrainTransitionResultSchema, {
17554
- kind: "mutation",
17555
- auth: "admin"
17556
- }), method(object({
17557
- deviceId: number$1(),
17558
- trackId: string()
17559
- }), RetrainTransitionResultSchema, {
17560
- kind: "mutation",
17561
- auth: "admin"
17562
- }), method(object({ deviceIds: array(number$1()).optional() }), object({ url: string() }), {
17563
- kind: "query",
17564
- auth: "admin"
17565
- }), method(object({
17566
- eventId: string(),
17567
- kind: MediaFileKindEnum.optional(),
17568
- deviceId: number$1()
17569
- }), array(MediaFileSchema).readonly()), method(object({
17570
- trackId: string(),
17571
- kinds: array(MediaFileKindEnum).optional(),
17572
- deviceId: number$1()
17573
- }), array(MediaFileSchema).readonly()), method(object({
17574
+ sizeBytes: number$1(),
17575
+ timestamp: number$1()
17576
+ });
17577
+ /**
17578
+ * One media row WITHOUT its bytes.
17579
+ *
17580
+ * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
17581
+ * 140 s track), and a client that renders tiles from the media data plane needs
17582
+ * to know only WHAT EXISTS — the bytes then arrive per tile, lazily, over HTTP
17583
+ * with an immutable cache, instead of all at once inside a tRPC response that
17584
+ * blocks the whole view.
17585
+ *
17586
+ * `sizeBytes` is carried because it is what lets a client decide between the
17587
+ * stored blob and a `?variant=thumb` rendering without fetching either.
17588
+ */
17589
+ var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
17590
+ /**
17591
+ * The MACRO tier of an annotation — a CLOSED set.
17592
+ *
17593
+ * This is what the exported detector predicts, so a typo here is a new class
17594
+ * with one example in it. `label` and `subLabel` are open strings by contrast:
17595
+ * the whole point of the page is teaching the model things it does not know
17596
+ * yet, and constraining that vocabulary would make it useless.
17597
+ *
17598
+ * A macro class is NEVER a label. The provider refuses a write whose `label` or
17599
+ * `subLabel` is one of these values, in any casing, because once `person`
17600
+ * exists in both tiers "every person box" stops being answerable without
17601
+ * knowing every string anyone ever typed — and the damage is retroactive.
17602
+ */
17603
+ var RetrainMacroClassSchema = _enum([
17604
+ "person",
17605
+ "vehicle",
17606
+ "animal",
17607
+ "package",
17608
+ "face",
17609
+ "plate"
17610
+ ]);
17611
+ /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
17612
+ var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
17613
+ /** Did a human draw this box, or did the assist propose it? */
17614
+ var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
17615
+ /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
17616
+ var RetrainBboxSchema = object({
17617
+ x: number$1(),
17618
+ y: number$1(),
17619
+ w: number$1(),
17620
+ h: number$1()
17621
+ });
17622
+ /**
17623
+ * One annotated subject.
17624
+ *
17625
+ * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
17626
+ * (letterboxed root / zone-cropped package / subject-cropped classifier) are
17627
+ * derived from it at export and never stored — storing them is how one feature
17628
+ * space ends up holding two crops of the same subject (D52).
17629
+ */
17630
+ var RetrainAnnotationSchema = object({
17631
+ id: string(),
17574
17632
  trackId: string(),
17575
- deviceId: number$1()
17576
- }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
17577
- kind: "mutation",
17578
- auth: "admin"
17579
- }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
17580
- kind: "mutation",
17581
- auth: "admin"
17582
- }), method(object({}), RebuildStatusSchema), object({
17583
- deviceId: number$1(),
17584
- timestamp: number$1(),
17585
- frameWidth: number$1(),
17586
- frameHeight: number$1(),
17587
- detections: array(OverlayDetectionSchema).readonly()
17588
- }), object({
17589
17633
  deviceId: number$1(),
17634
+ /** The COPY in retrain storage — never the source track's media key. */
17635
+ mediaKey: string(),
17636
+ bbox: RetrainBboxSchema,
17637
+ macroClass: RetrainMacroClassSchema,
17638
+ label: string().optional(),
17639
+ subLabel: string().optional(),
17640
+ kind: RetrainAnnotationKindSchema,
17641
+ source: RetrainAnnotationSourceSchema,
17642
+ /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
17643
+ assistModelId: string().optional(),
17644
+ assistScore: number$1().optional(),
17645
+ exportedInBatch: string().optional(),
17646
+ createdAt: number$1()
17647
+ });
17648
+ /** The write form — the server owns `id`, `createdAt` and the frame binding. */
17649
+ var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
17650
+ id: true,
17651
+ trackId: true,
17652
+ deviceId: true,
17653
+ mediaKey: true,
17654
+ createdAt: true,
17655
+ exportedInBatch: true
17656
+ });
17657
+ /** A track sitting in `staging`, with everything the worklist needs to rank it. */
17658
+ var RetrainTrackSchema = object({
17590
17659
  trackId: string(),
17591
- className: string()
17592
- }), object({
17593
17660
  deviceId: number$1(),
17594
- trackId: string(),
17595
17661
  className: string(),
17596
- durationMs: number$1()
17597
- }), object({
17662
+ label: string().optional(),
17663
+ firstSeen: number$1(),
17664
+ lastSeen: number$1(),
17665
+ /** How many frames the dataset already holds from this track. */
17666
+ frameCount: number$1().int(),
17667
+ /** How many subjects have been annotated on those frames. `0` with
17668
+ * `frameCount: 0` is exactly "staging, still to work". */
17669
+ annotationCount: number$1().int()
17670
+ });
17671
+ /** A frame the picker may offer — an index row, no blob was read to produce it. */
17672
+ var RetrainFrameCandidateSchema = object({
17673
+ mediaKey: string(),
17674
+ kind: MediaFileKindEnum,
17675
+ timestamp: number$1(),
17676
+ sizeBytes: number$1().int(),
17677
+ /** A copy of this original already exists — selecting it is free and cannot
17678
+ * fail, whatever became of the original. */
17679
+ copied: boolean()
17680
+ });
17681
+ /** A frame the dataset OWNS: bytes copied at selection time. */
17682
+ var RetrainFrameSchema = object({
17683
+ frameId: string(),
17598
17684
  deviceId: number$1(),
17599
- kind: EventKindSchema,
17600
- eventId: string(),
17601
- timestamp: number$1()
17685
+ trackId: string(),
17686
+ /** Provenance only. It may already point at nothing — that is expected. */
17687
+ sourceMediaKey: string(),
17688
+ sourceKind: MediaFileKindEnum,
17689
+ sizeBytes: number$1().int(),
17690
+ width: number$1().int(),
17691
+ height: number$1().int(),
17692
+ copiedAt: number$1()
17693
+ });
17694
+ /** Why a copy-on-select could not be honoured — named, never a silent skip. */
17695
+ var RetrainCopyRefusalSchema = _enum([
17696
+ "source-missing",
17697
+ "unreadable-image",
17698
+ "write-failed"
17699
+ ]);
17700
+ var RetrainFrameSelectionSchema = object({
17701
+ copied: array(RetrainFrameSchema).readonly(),
17702
+ refused: array(object({
17703
+ sourceMediaKey: string(),
17704
+ reason: RetrainCopyRefusalSchema
17705
+ })).readonly()
17602
17706
  });
17707
+ var RetrainFrameListSchema = object({
17708
+ candidates: array(RetrainFrameCandidateSchema).readonly(),
17709
+ copies: array(RetrainFrameSchema).readonly(),
17710
+ /** What the page pre-selects — the native key frame when one survives. */
17711
+ autoPickMediaKey: string().optional()
17712
+ });
17713
+ /** What the operator asked the assist to look for. */
17714
+ var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
17715
+ kind: literal("package"),
17716
+ zone: RetrainBboxSchema.optional()
17717
+ }), object({
17718
+ kind: literal("objects"),
17719
+ modelId: string(),
17720
+ minScore: number$1().optional()
17721
+ })]);
17603
17722
  /**
17604
- * Reference to the frame's retained NATIVE surface + the parent crop's placement
17605
- * within the frame, so the executor can re-cut a leaf child ROI at native
17606
- * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
17723
+ * The assist's answer — a discriminated union, because "the model saw nothing"
17724
+ * and "this node cannot run that model" lead to different next moves and a
17725
+ * nullable result cannot tell them apart.
17607
17726
  */
17608
- var NativeCropRefSchema = object({
17609
- /** Handle keying the retained native surface (node-pinned to its owner). */
17610
- handle: FrameHandleSchema,
17611
- /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
17612
- cropFrameSpace: object({
17613
- x: number$1(),
17614
- y: number$1(),
17615
- w: number$1(),
17616
- h: number$1()
17617
- })
17727
+ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
17728
+ kind: literal("proposed"),
17729
+ modelId: string(),
17730
+ stepId: string(),
17731
+ minScore: number$1(),
17732
+ /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
17733
+ proposals: array(RetrainAnnotationDraftSchema).readonly(),
17734
+ /** Returned by the runner but removed by the threshold. */
17735
+ belowThreshold: number$1().int()
17736
+ }), object({
17737
+ kind: literal("refused"),
17738
+ /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
17739
+ reason: string(),
17740
+ detail: string().optional()
17741
+ })]);
17742
+ /** The outcome of a lifecycle move owned by the retrain page. */
17743
+ var RetrainTransitionResultSchema = object({
17744
+ trackId: string(),
17745
+ /** Where the track ended up, whatever happened. */
17746
+ retrainStatus: RetrainStatusSchema,
17747
+ /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
17748
+ changed: boolean(),
17749
+ reason: _enum([
17750
+ "unknown-track",
17751
+ "no-frames-copied",
17752
+ "not-staging",
17753
+ "not-trained",
17754
+ "unchanged"
17755
+ ]).optional()
17618
17756
  });
17619
- object({
17620
- crop: object({
17621
- left: number$1(),
17622
- top: number$1(),
17623
- width: number$1().positive(),
17624
- height: number$1().positive()
17625
- }).optional(),
17626
- content: object({
17627
- width: number$1().int().positive(),
17628
- height: number$1().int().positive()
17629
- }),
17630
- fit: _enum(["stretch", "contain"]),
17631
- format: _enum([
17632
- "rgb",
17633
- "gray",
17634
- "jpeg"
17635
- ])
17757
+ var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
17758
+ var MAX_EVENT_QUERY_LIMIT = 5e3;
17759
+ var DeviceEventQueryInput = object({
17760
+ deviceId: number$1(),
17761
+ since: number$1().optional(),
17762
+ until: number$1().optional(),
17763
+ limit: number$1().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
17764
+ /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
17765
+ * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
17766
+ * exact behaviour. Callers may omit this field — the store defaults to
17767
+ * `full` when not provided. */
17768
+ projection: _enum(["full", "slim"]).optional()
17636
17769
  });
17637
- var FrameRefSchema = object({
17638
- registryId: string().min(1),
17639
- id: string().min(1),
17640
- width: number$1().int().positive(),
17641
- height: number$1().int().positive(),
17642
- format: _enum(["rgb", "gray"]),
17643
- timestamp: number$1(),
17644
- capturedAt: number$1().optional()
17770
+ var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
17771
+ var RecentTracksQueryInput = object({
17772
+ /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
17773
+ deviceIds: array(number$1()),
17774
+ /** Window lower bound on `lastSeen` (inclusive). */
17775
+ since: number$1().optional(),
17776
+ /** Window upper bound on `lastSeen` (inclusive). */
17777
+ until: number$1().optional(),
17778
+ /** Page size. Default 200, max 1000. */
17779
+ limit: number$1().int().min(1).max(1e3).default(200),
17780
+ /** Opaque continuation cursor from a previous page's `nextCursor`.
17781
+ * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
17782
+ cursor: string().optional(),
17783
+ /** See {@link TrackProjectionSchema}. Default `full`. */
17784
+ projection: TrackProjectionSchema.optional(),
17785
+ /** Include stationary-promoted rows (parked objects). Default false: the
17786
+ * feed lists passages; parking records live on the stationary registry. */
17787
+ includeStationary: boolean().optional()
17645
17788
  });
17646
- var ModelFormatSchema$1 = _enum([
17647
- "onnx",
17648
- "coreml",
17649
- "openvino",
17650
- "tflite",
17651
- "pt",
17652
- "gguf"
17653
- ]);
17654
- var PipelineSlotSchema = _enum([
17655
- "detector",
17656
- "cropper",
17657
- "classifier",
17658
- "refiner",
17659
- "audio-classifier"
17660
- ]);
17661
- var PipelineEngineChoiceSchema = object({
17662
- runtime: _enum(["node", "python"]),
17663
- backend: string(),
17664
- format: ModelFormatSchema$1,
17665
- device: string().optional()
17789
+ var RecentTracksPageSchema = object({
17790
+ /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
17791
+ tracks: array(TrackSchema).readonly(),
17792
+ /** Cursor for the next page, or null when this page is the last. */
17793
+ nextCursor: string().nullable()
17794
+ });
17795
+ var LIST_GROUPS_DEFAULT_LIMIT = 40;
17796
+ var LIST_GROUPS_MAX_LIMIT = 100;
17797
+ var AnalyticsGroupRecordSchema = object({
17798
+ id: string(),
17799
+ deviceId: number$1().int(),
17800
+ openedAt: number$1().int(),
17801
+ closedAt: number$1().int(),
17802
+ timestamp: number$1().int(),
17803
+ memberCount: number$1().int(),
17804
+ memberTrackIds: array(string()).readonly(),
17805
+ className: string(),
17806
+ classes: array(string()).readonly(),
17807
+ /** Relative event-media path, or null when the group has no picture yet. */
17808
+ mediaUrl: string().nullable(),
17809
+ singleton: boolean()
17666
17810
  });
17667
- var AvailableEngineSchema = object({
17668
- engine: PipelineEngineChoiceSchema,
17669
- devices: array(object({
17670
- id: string(),
17671
- label: string(),
17672
- description: string().optional()
17673
- })).readonly(),
17674
- defaultDevice: string()
17811
+ var AnalyticsGroupMemberSchema = object({
17812
+ trackId: string(),
17813
+ deviceId: number$1().int(),
17814
+ className: string(),
17815
+ firstSeen: number$1().int(),
17816
+ lastSeen: number$1().int(),
17817
+ mediaUrl: string().nullable()
17675
17818
  });
17676
- var PipelineDefaultStepSchema = lazy(() => object({
17677
- addonId: string(),
17678
- addonName: string(),
17679
- slot: PipelineSlotSchema,
17680
- inputClasses: array(string()).readonly(),
17681
- outputClasses: array(string()).readonly(),
17682
- enabled: boolean(),
17683
- modelId: string(),
17684
- children: array(PipelineDefaultStepSchema).readonly(),
17685
- group: string().optional(),
17686
- settings: record(string(), unknown()).optional()
17687
- }));
17688
- var PipelineTemplateStepSchema = lazy(() => object({
17689
- addonId: string(),
17690
- enabled: boolean(),
17691
- modelId: string(),
17692
- children: array(PipelineTemplateStepSchema).readonly(),
17693
- settings: record(string(), unknown()).optional()
17694
- }));
17695
- var PipelineTemplateSchema$1 = object({
17696
- id: string(),
17697
- name: string(),
17698
- createdAt: string(),
17699
- updatedAt: string(),
17700
- engine: PipelineEngineChoiceSchema,
17701
- steps: array(PipelineTemplateStepSchema).readonly()
17819
+ var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
17820
+ var ListGroupsQueryInput = object({
17821
+ /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
17822
+ deviceIds: array(number$1()),
17823
+ /** Window lower bound on `closedAt` (inclusive). */
17824
+ since: number$1().optional(),
17825
+ /** Window upper bound on `openedAt` (inclusive). */
17826
+ until: number$1().optional(),
17827
+ limit: number$1().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
17828
+ /** Opaque continuation cursor from a previous page's `nextCursor`. */
17829
+ cursor: string().optional()
17702
17830
  });
17703
- var PipelineModelOptionSchema = object({
17704
- id: string(),
17705
- name: string(),
17706
- formats: record(string(), object({
17707
- downloaded: boolean(),
17708
- sizeMB: number$1()
17709
- })),
17710
- group: ModelVariantGroupSchema.optional(),
17711
- legacy: boolean().optional(),
17712
- provider: ModelProviderIdSchema.optional()
17831
+ var ListGroupsPageSchema = object({
17832
+ groups: array(AnalyticsGroupRecordSchema).readonly(),
17833
+ nextCursor: string().nullable()
17713
17834
  });
17714
- var ConfigFieldBridge = custom();
17715
- var PipelineAddonSchemaSchema = object({
17716
- id: string(),
17717
- name: string(),
17718
- slot: PipelineSlotSchema,
17719
- inputClasses: array(string()).readonly(),
17720
- outputClasses: array(string()).readonly(),
17721
- childSlots: array(PipelineSlotSchema).readonly(),
17722
- models: array(PipelineModelOptionSchema).readonly(),
17723
- defaultModelId: string(),
17724
- defaultModelIdByFormat: record(string(), string()).optional(),
17725
- enabledByDefault: boolean().optional(),
17726
- backfillIntoExistingOverrides: boolean().optional(),
17727
- defaultConfidence: number$1(),
17728
- group: string().optional(),
17729
- configSchema: array(ConfigFieldBridge).readonly().optional()
17835
+ var KeyEventQueryInput = object({
17836
+ deviceId: number$1(),
17837
+ /** Window lower bound (track firstSeen ≥ since). */
17838
+ since: number$1(),
17839
+ /** Window upper bound (track firstSeen ≤ until). */
17840
+ until: number$1(),
17841
+ limit: number$1().int().min(1).max(200).default(50),
17842
+ /** Drop tracks scoring below this importance. */
17843
+ minImportance: number$1().min(0).max(1).optional(),
17844
+ /** Restrict to a single class (e.g. 'person'). */
17845
+ classFilter: string().optional()
17730
17846
  });
17731
- var PipelineSlotSchemaSchema = object({
17732
- id: PipelineSlotSchema,
17733
- label: string(),
17734
- priority: number$1(),
17735
- parentSlot: PipelineSlotSchema.nullable(),
17736
- addons: array(PipelineAddonSchemaSchema).readonly()
17847
+ var KeyEventSchema = object({
17848
+ /** The representative event id (the track's best ObjectEvent, else its trackId). */
17849
+ id: string(),
17850
+ trackId: string(),
17851
+ /** Track start time (firstSeen). */
17852
+ timestamp: number$1(),
17853
+ className: string(),
17854
+ ...TieredLabelFields,
17855
+ importance: number$1(),
17856
+ /** Highest-confidence ObjectEvent id for the track (empty when none). */
17857
+ bestEventId: string(),
17858
+ /** Track lifetime in ms (lastSeen - firstSeen). */
17859
+ windowMs: number$1().optional(),
17860
+ ...TrackFlagFields,
17861
+ ...TrackRetrainFields
17737
17862
  });
17738
- var PipelineSchemaSchema = object({
17739
- availableEngines: array(AvailableEngineSchema).readonly(),
17740
- selectedEngine: PipelineEngineChoiceSchema,
17741
- slots: array(PipelineSlotSchemaSchema).readonly()
17863
+ object({
17864
+ trackId: string(),
17865
+ className: string(),
17866
+ confidence: number$1(),
17867
+ bbox: BoundingBoxSchema,
17868
+ zones: array(string()).readonly(),
17869
+ state: TrackStateSchema
17742
17870
  });
17743
- var EngineProvisioningSchema = object({
17744
- runtimeId: _enum([
17745
- "onnx",
17746
- "openvino",
17747
- "coreml",
17748
- "edgetpu"
17749
- ]).nullable(),
17750
- device: string().nullable(),
17751
- state: _enum([
17752
- "idle",
17753
- "installing",
17754
- "verifying",
17755
- "ready",
17756
- "failed"
17757
- ]),
17758
- progress: number$1().optional(),
17759
- error: string().optional(),
17760
- nextRetryAt: number$1().optional(),
17761
- /**
17762
- * Gate A (config-correctness gate at engine change): human-readable
17763
- * config issues surfaced EAGERLY when the node's engine changes — model
17764
- * substitutions ("chose X, running Y") and zero-build steps ("no model
17765
- * has a <format> build"). Additive/optional: informational only, never
17766
- * enforced here — `assertEngineReady` (readiness) still gates inference.
17767
- * Absent/empty when the node-default tree resolves cleanly.
17768
- */
17769
- configIssues: array(string()).optional()
17871
+ var OverlayDetectionSchema = looseObject({
17872
+ id: string(),
17873
+ kind: _enum(["first-level", "detail"]),
17874
+ macroClass: string(),
17875
+ score: number$1(),
17876
+ bbox: object({
17877
+ x: number$1(),
17878
+ y: number$1(),
17879
+ width: number$1(),
17880
+ height: number$1()
17881
+ }),
17882
+ labels: array(looseObject({
17883
+ label: string(),
17884
+ score: number$1()
17885
+ })).readonly(),
17886
+ parentId: string().optional()
17770
17887
  });
17771
- var PipelineStepInputSchema = lazy(() => object({
17772
- addonId: string(),
17773
- modelId: string().optional(),
17774
- enabled: boolean().default(true),
17775
- children: array(PipelineStepInputSchema).optional(),
17776
- settings: record(string(), unknown()).optional(),
17777
- jumpDeviceKey: string().optional()
17778
- }));
17779
- var ModelSubstitutionSchema = object({
17780
- addonId: string(),
17781
- chosen: string(),
17782
- running: string(),
17783
- format: string()
17888
+ var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number$1() });
17889
+ var SearchObjectEventsInput = object({
17890
+ text: string(),
17891
+ deviceId: number$1().optional(),
17892
+ since: number$1().optional(),
17893
+ until: number$1().optional(),
17894
+ classFilter: string().optional(),
17895
+ limit: number$1().default(50),
17896
+ minScore: number$1().min(0).max(1).default(.2)
17784
17897
  });
17785
- var PipelineValidationIssueSchema = object({
17786
- addonId: string(),
17787
- kind: _enum(["unknown-addon", "no-format-build"]),
17788
- detail: string()
17898
+ var TrackCascadeCountsSchema = object({
17899
+ /** Persisted track roots deleted (authoritative). */
17900
+ tracks: number$1().int(),
17901
+ /** Object events removed with their tracks (best-effort; see note above). */
17902
+ events: number$1().int(),
17903
+ /** Track/face/plate-owned media removed (best-effort). Never identity media. */
17904
+ media: number$1().int(),
17905
+ /** Unassigned (non-enrolled) face reads removed (best-effort). */
17906
+ faces: number$1().int(),
17907
+ /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
17908
+ plates: number$1().int(),
17909
+ /** Per-track CLIP search vectors removed (best-effort). */
17910
+ embeddings: number$1().int(),
17911
+ /** Group membership + group rows removed with their last member (best-effort). */
17912
+ groups: number$1().int()
17789
17913
  });
17790
- var PipelineValidationResultSchema = object({
17791
- ok: boolean(),
17792
- issues: array(PipelineValidationIssueSchema).readonly(),
17793
- substitutions: array(ModelSubstitutionSchema).readonly(),
17794
- /** The node's `currentEngine.format` this validation ran against. */
17795
- format: string()
17914
+ /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
17915
+ var DiskReconcileCountsSchema = object({
17916
+ mediaDropped: number$1().int(),
17917
+ tracks: number$1().int(),
17918
+ events: number$1().int()
17796
17919
  });
17797
- var ReferenceImageEntrySchema = object({
17798
- filename: string(),
17799
- stepIds: array(string()).readonly().optional()
17920
+ /** Event-store footprint for one camera. */
17921
+ var EventStoreDeviceFootprintSchema = object({
17922
+ deviceId: number$1(),
17923
+ /** Persisted event rows (motion + object + audio) for the camera. */
17924
+ rows: number$1().int(),
17925
+ /** Event-owned media bytes on disk for the camera. */
17926
+ bytes: number$1().int()
17800
17927
  });
17801
- var ReferenceImageBodySchema = object({
17802
- base64: string(),
17803
- filename: string()
17928
+ /** Aggregate event-store footprint: global totals + per-camera breakdown. */
17929
+ var EventStoreFootprintSchema = object({
17930
+ totalRows: number$1().int(),
17931
+ totalBytes: number$1().int(),
17932
+ devices: array(EventStoreDeviceFootprintSchema).readonly()
17804
17933
  });
17805
- var ReferenceAudioEntrySchema = object({
17806
- filename: string(),
17807
- sizeKb: number$1()
17934
+ /** Per-kind counts returned by the event-prune / device-delete mutations. */
17935
+ var EventPruneCountsSchema = object({
17936
+ motion: number$1().int(),
17937
+ object: number$1().int(),
17938
+ audio: number$1().int()
17808
17939
  });
17809
- var ReferenceAudioBodySchema = object({ base64: string() });
17810
- var AudioBackendSchema = object({
17811
- id: string(),
17812
- name: string(),
17813
- description: string(),
17814
- available: boolean(),
17940
+ /**
17941
+ * Re-embed stored tracks from their key frames.
17942
+ *
17943
+ * The reason this is an operator-callable method and not a migration script:
17944
+ * every knob that decides what a vector MEANS — encoder model, crop margin,
17945
+ * squaring — is only changeable if the existing vectors can be regenerated.
17946
+ * Mixing feature spaces in one index makes cosine scores incomparable, and the
17947
+ * symptom is a quality regression with no visible cause.
17948
+ */
17949
+ var RebuildObjectEmbeddingsInput = object({
17950
+ /** Restrict to one camera. Omit for the whole fleet. */
17951
+ deviceId: number$1().optional(),
17952
+ since: number$1().optional(),
17953
+ until: number$1().optional(),
17954
+ /** Stop after this many tracks; the result reports whether more remain. */
17955
+ maxTracks: number$1().int().positive().optional(),
17815
17956
  /**
17816
- * Raw classifier labels this backend can emit (e.g. YAMNet's
17817
- * 521-class set or Apple SoundAnalysis's 303-class set). Used by
17818
- * the benchmark UI to populate the `enabledMicroClasses` filter
17819
- * specific to the selected backend without a separate fetch.
17957
+ * Run every embedding on THIS node instead of round-robining the fleet.
17958
+ *
17959
+ * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
17960
+ * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
17961
+ * calling it that would pin the rebuild REQUEST itself to that node — the
17962
+ * rebuild orchestration lives on the hub, and only the per-track step runs
17963
+ * remotely. This field is data; the per-track pin is applied inside.
17964
+ *
17965
+ * Absent ⇒ round-robin over every online node whose runner can serve the
17966
+ * pinned model.
17820
17967
  */
17821
- rawLabels: array(string()).readonly().optional()
17822
- });
17823
- var AudioCapabilitiesSchema = object({
17824
- activeBackend: string(),
17825
- availableBackends: array(AudioBackendSchema).readonly(),
17826
- sampleRate: number$1(),
17827
- chunkDurationMs: number$1()
17828
- });
17829
- var DownloadModelResultSchema = object({
17830
- filePath: string(),
17831
- sizeMB: number$1(),
17832
- durationMs: number$1()
17968
+ executeOnNodeId: string().optional(),
17969
+ /**
17970
+ * Milliseconds to wait between tracks; omit for the built-in default, `0` to
17971
+ * run flat out.
17972
+ *
17973
+ * A rebuild is bulk maintenance on hub-main's single thread. Measured
17974
+ * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
17975
+ * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
17976
+ * force is logged at start and finish so a deliberately slow pass reads
17977
+ * differently from a stalled one.
17978
+ */
17979
+ pacingMs: number$1().int().nonnegative().optional()
17833
17980
  });
17834
17981
  /**
17835
- * Wrapper carrying a single test run's result. Replaces the legacy
17836
- * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
17837
- * canonical `AudioResult` from the Phase 6 output rework: one
17838
- * `AudioDetection` per class above `minScore`, top-N candidates in
17839
- * `debug.alternateLabels['audio-classifier']`, per-source timings in
17840
- * `debug.stepTimings`. The outer `success`/`error` fields stay so the
17841
- * benchmark UI can still report a clean failure when the classifier
17842
- * cap isn't available.
17982
+ * Result of emptying the CLIP index.
17983
+ *
17984
+ * The clean slate before a policy change: a new crop margin or encoder model
17985
+ * leaves two feature spaces in one index whose cosine scores are not
17986
+ * comparable, so wiping and rebuilding is the only way to be sure every vector
17987
+ * means the same thing.
17843
17988
  */
17844
- var AudioTestResultSchema = object({
17845
- success: boolean(),
17846
- error: string().optional(),
17847
- frame: custom().optional()
17989
+ var WipeObjectEmbeddingsResultSchema = object({ deleted: number$1() });
17990
+ /**
17991
+ * Acknowledgement that a rebuild STARTED.
17992
+ *
17993
+ * The pass costs ~1s per track — 45 minutes for a 2,600-track fleet — so it
17994
+ * runs detached and this returns immediately. Waiting for it made the client
17995
+ * time out while the work carried on server-side, which is the worst of both:
17996
+ * no result and no way to know it was still going. Poll
17997
+ * `getObjectEmbeddingRebuildStatus` for progress.
17998
+ */
17999
+ var RebuildObjectEmbeddingsResultSchema = object({
18000
+ started: boolean(),
18001
+ /** True when a pass was already running; the new request is ignored. */
18002
+ alreadyRunning: boolean()
17848
18003
  });
17849
- var PipelineConfigBridge = custom();
17850
- var ConfigUISchemaBridge = custom();
17851
- var ConfigUISchemaNullableBridge = custom();
17852
- var InferenceCapabilitiesBridge = custom();
17853
- var ModelAvailabilityListBridge = custom();
17854
- var PipelineRunResultBridge = custom();
17855
- method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
17856
- modelId: string(),
17857
- settings: record(string(), unknown()).readonly()
17858
- }))), method(object({ steps: record(string(), object({
17859
- modelId: string(),
17860
- settings: record(string(), unknown()).readonly()
17861
- })) }), object({ success: literal(true) }), {
18004
+ var RebuildStatusSchema = object({
18005
+ running: boolean(),
18006
+ scanned: number$1(),
18007
+ rebuilt: number$1(),
18008
+ /** Tracks whose key frame is gone — nothing to re-embed from. */
18009
+ missingKeyFrame: number$1(),
18010
+ /** Tracks with no usable detection box. */
18011
+ missingBbox: number$1(),
18012
+ /**
18013
+ * Tracks an executing node REFUSED rather than broke on — an unreadable key
18014
+ * frame, a step that threw. Separate from `failed` because the remedy is
18015
+ * different, and because a whole camera silently contributing zero vectors
18016
+ * is the shape of failure a rebuild must never hide.
18017
+ */
18018
+ notRunnable: number$1(),
18019
+ /**
18020
+ * The pass stopped because NO node could serve the pinned model.
18021
+ *
18022
+ * Distinct from `notRunnable` on purpose: that one says "this track was
18023
+ * refused", this one says "the cluster cannot do this work at all" — every
18024
+ * candidate node either lacks the `clip-embedding` step, lacks a build of the
18025
+ * pinned model for its engine format, or dropped out. The remedy is a model /
18026
+ * engine change, not a per-camera one. Non-zero here always comes with
18027
+ * `complete: false`.
18028
+ */
18029
+ noCapableNode: number$1(),
18030
+ failed: number$1(),
18031
+ /** Set once a pass ends: true only when EVERYTHING was covered. */
18032
+ complete: boolean().nullable(),
18033
+ startedAtMs: number$1().nullable(),
18034
+ finishedAtMs: number$1().nullable(),
18035
+ /** Present when the pass ended by throwing. */
18036
+ error: string().nullable()
18037
+ });
18038
+ var ReplayFrameInputSchema = object({
18039
+ timestamp: number$1(),
18040
+ frame: PipelineRunResultBridge
18041
+ });
18042
+ var RunReplayFrameProcessorResultSchema = object({ tracks: array(object({
18043
+ className: string(),
18044
+ firstSeenMs: number$1(),
18045
+ lastSeenMs: number$1(),
18046
+ /** Bbox of the track's FIRST matched detection, pixel-space in the clip's
18047
+ * frame — a representative box for the diff's `(className, window, IoU)`
18048
+ * pairing (`replay-diff.ts`). A replay does not need the full per-frame
18049
+ * trajectory production's `Track.positions` keeps. */
18050
+ bbox: BoundingBoxSchema,
18051
+ /** How many of the input frames this track matched a real detection on
18052
+ * (never a coasted/extrapolated frame) — the replay's own signal for "how
18053
+ * solid is this track", cheaper than re-deriving it from a trajectory. */
18054
+ framesMatched: number$1().int()
18055
+ })).readonly() });
18056
+ DeviceType.Camera, method(object({ deviceId: number$1() }), array(TrackSchema).readonly()), method(object({
18057
+ deviceId: number$1(),
18058
+ trackId: string()
18059
+ }), TrackSchema.nullable()), method(object({
18060
+ deviceId: number$1(),
18061
+ since: number$1().optional(),
18062
+ until: number$1().optional(),
18063
+ limit: number$1().optional(),
18064
+ /** Spatial filter — only tracks whose trajectory intersects the zone
18065
+ * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
18066
+ * envelope columns, then precisely tested per position. Tracks with
18067
+ * an unknown envelope (no frame dims at persist time) always match. */
18068
+ zone: TrackZoneFilterSchema.optional(),
18069
+ /** See {@link TrackProjectionSchema}. Default `full` (backward
18070
+ * compatible — omitting the field keeps today's exact behaviour). */
18071
+ projection: TrackProjectionSchema.optional(),
18072
+ /** Include stationary-promoted rows (parked objects handed to the
18073
+ * stationary registry). Default false: the timeline lists passages,
18074
+ * not parking records (operator decision, 2026-08-15). */
18075
+ includeStationary: boolean().optional()
18076
+ }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
18077
+ deviceId: number$1(),
18078
+ groupId: string().min(1)
18079
+ }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number$1() }), _void(), {
18080
+ kind: "mutation",
18081
+ auth: "admin"
18082
+ }), method(DeviceEventQueryInput, array(MotionEventSchema).readonly()), method(ObjectEventQueryInput, array(ObjectEventSchema).readonly()), method(DeviceEventQueryInput, array(AudioEventSchema).readonly()), method(object({ deviceId: number$1() }), array(EventKindDescriptorSchema).readonly()), method(object({ deviceIds: array(number$1()).min(1).max(200) }), array(EventKindsForDeviceSchema).readonly()), method(object({
18083
+ deviceId: number$1(),
18084
+ since: number$1().optional(),
18085
+ until: number$1().optional(),
18086
+ kinds: array(string()).optional(),
18087
+ limit: number$1().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
18088
+ }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
18089
+ deviceId: number$1(),
18090
+ since: number$1(),
18091
+ until: number$1(),
18092
+ bucketMs: number$1().int().positive()
18093
+ }), array(object({
18094
+ bucketStart: number$1(),
18095
+ motion: number$1().int(),
18096
+ object: number$1().int(),
18097
+ audio: number$1().int()
18098
+ })).readonly()), method(object({
18099
+ deviceId: number$1(),
18100
+ cutoffMs: number$1()
18101
+ }), object({
18102
+ motion: number$1().int(),
18103
+ object: number$1().int(),
18104
+ audio: number$1().int()
18105
+ }), {
18106
+ kind: "mutation",
18107
+ auth: "admin"
18108
+ }), method(object({
18109
+ deviceId: number$1(),
18110
+ cutoffMs: number$1()
18111
+ }), TrackCascadeCountsSchema, {
18112
+ kind: "mutation",
18113
+ auth: "admin"
18114
+ }), method(object({ deviceId: number$1() }), TrackCascadeCountsSchema, {
18115
+ kind: "mutation",
18116
+ auth: "admin"
18117
+ }), method(object({ deviceId: number$1() }), DiskReconcileCountsSchema, {
18118
+ kind: "mutation",
18119
+ auth: "admin"
18120
+ }), method(object({
18121
+ deviceId: number$1(),
18122
+ trackIds: array(string()).min(1)
18123
+ }), object({
18124
+ deleted: number$1().int(),
18125
+ failed: array(string()).readonly()
18126
+ }), {
18127
+ kind: "mutation",
18128
+ auth: "admin"
18129
+ }), method(object({
18130
+ /** Log/audit scope only — the trackId is globally unique on its own. */
18131
+ deviceId: number$1(),
18132
+ trackId: string(),
18133
+ flags: TrackFlagsPatchSchema
18134
+ }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
18135
+ kind: "query",
18136
+ auth: "admin"
18137
+ }), method(object({
18138
+ olderThanMs: number$1(),
18139
+ reason: OpsLogReasonSchema.optional()
18140
+ }), EventPruneCountsSchema, {
18141
+ kind: "mutation",
18142
+ auth: "admin"
18143
+ }), method(object({ deviceId: number$1() }), EventPruneCountsSchema, {
18144
+ kind: "mutation",
18145
+ auth: "admin"
18146
+ }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
18147
+ kind: "mutation",
18148
+ auth: "admin"
18149
+ }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
18150
+ kind: "mutation",
18151
+ auth: "admin"
18152
+ }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
18153
+ kind: "mutation",
18154
+ auth: "admin"
18155
+ }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
18156
+ kind: "mutation",
18157
+ auth: "admin"
18158
+ }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18159
+ kind: "mutation",
18160
+ auth: "admin"
18161
+ }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
18162
+ kind: "mutation",
18163
+ auth: "admin"
18164
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
18165
+ kind: "query",
18166
+ auth: "admin"
18167
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18168
+ kind: "mutation",
18169
+ auth: "admin"
18170
+ }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
18171
+ kind: "query",
18172
+ auth: "admin"
18173
+ }), method(object({ deviceIds: array(number$1()).optional() }), TrainingExportSummarySchema, {
18174
+ kind: "query",
18175
+ auth: "admin"
18176
+ }), method(object({ deviceIds: array(number$1()).optional() }), object({ url: string() }), {
18177
+ kind: "query",
18178
+ auth: "admin"
18179
+ }), method(object({
18180
+ /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
18181
+ * `deviceId`, deliberately: `deviceId` would make this device-bound and
18182
+ * route it at one camera's owner, and "every camera" would stop being
18183
+ * expressible at all. */
18184
+ deviceIds: array(number$1()).optional(),
18185
+ limit: number$1().int().min(1).max(500).optional()
18186
+ }), array(RetrainTrackSchema).readonly(), {
18187
+ kind: "query",
18188
+ auth: "admin"
18189
+ }), method(object({ trackId: string() }), RetrainFrameListSchema, {
18190
+ kind: "query",
18191
+ auth: "admin"
18192
+ }), method(object({
18193
+ deviceId: number$1(),
18194
+ trackId: string(),
18195
+ mediaKeys: array(string()).min(1)
18196
+ }), RetrainFrameSelectionSchema, {
17862
18197
  kind: "mutation",
17863
18198
  auth: "admin"
17864
- }), method(object({ nodeId: string() }), object({
17865
- success: literal(true),
17866
- clearedDevices: number$1()
18199
+ }), method(object({
18200
+ deviceId: number$1(),
18201
+ trackId: string(),
18202
+ frameId: string()
18203
+ }), object({
18204
+ removed: boolean(),
18205
+ removedAnnotations: number$1().int()
17867
18206
  }), {
17868
18207
  kind: "mutation",
17869
18208
  auth: "admin"
17870
- }), 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({
17871
- name: string(),
17872
- steps: array(PipelineTemplateStepSchema).readonly(),
17873
- engine: PipelineEngineChoiceSchema
17874
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
17875
- id: string(),
17876
- name: string().optional(),
17877
- steps: array(PipelineTemplateStepSchema).readonly().optional()
17878
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
17879
- addonId: string(),
17880
- modelId: string(),
17881
- format: ModelFormatSchema$1
17882
- }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
17883
- addonId: string(),
17884
- modelId: string(),
17885
- format: ModelFormatSchema$1
17886
- }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
17887
- engine: PipelineEngineChoiceSchema.optional(),
17888
- steps: array(PipelineStepInputSchema).min(1),
17889
- frame: FrameInputSchema.optional(),
17890
- /**
17891
- * Process-local lazy frame. Valid only when caller and provider resolve
17892
- * in the same execution-group process; split/cross-node callers use
17893
- * `frame`/`image` inline compatibility instead.
17894
- */
17895
- frameRef: FrameRefSchema.optional(),
17896
- /**
17897
- * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
17898
- * the decoded pixels live in. One more member of the one-of
17899
- * frame/frameHandle/image/imageBase64/referenceImage group.
17900
- */
17901
- frameHandle: FrameHandleSchema.optional(),
17902
- imageBase64: string().optional(),
17903
- /**
17904
- * Binary JPEG bytes — preferred over `imageBase64` on internal
17905
- * hops (hub → forked worker via Moleculer MsgPack) because it
17906
- * skips the 33% base64 overhead + the per-call base64 decode on
17907
- * the detection-pipeline worker. Callers can pass either; exactly
17908
- * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
17909
- */
17910
- image: _instanceof(Uint8Array).optional(),
17911
- referenceImage: string().optional(),
17912
- deviceId: number$1().optional(),
17913
- sessionId: string().optional(),
17914
- /**
17915
- * Execution plane. 'full' (default) runs the whole tree — benchmark,
17916
- * reference-image, and detail-subtree calls. 'frame' is the live
17917
- * per-frame dispatch: ONLY root-plane steps run; crop children
17918
- * (inputClasses ≠ null) are skipped and served per-track via
17919
- * pipelineRunner.runDetailSubtree (two-plane design).
17920
- */
17921
- plane: _enum(["full", "frame"]).optional(),
17922
- /**
17923
- * Inference-device selector (Phase 2 multi-device). Format
17924
- * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
17925
- * Omitted ⇒ the runner's default device (current single-engine
17926
- * behaviour). Selects WHICH device pool of the node runs the call.
17927
- */
17928
- deviceKey: string().optional(),
17929
- /**
17930
- * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
17931
- * when the parent crop was resolved from the frame's retained NATIVE
17932
- * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
17933
- * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
17934
- * resolution from that surface — the SAME quality path faces already
17935
- * had — instead of the downscaled parent tile. `handle` keys the native
17936
- * surface (node-pinned to its owner); `cropFrameSpace` is the parent
17937
- * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
17938
- * the executor's crop-normalized child ROI back into frame-normalized
17939
- * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
17940
- * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
17941
- * (today's behaviour on the fallback path).
17942
- */
17943
- nativeCropRef: NativeCropRefSchema.optional()
17944
- }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
17945
- engine: PipelineEngineChoiceSchema.optional(),
17946
- steps: array(PipelineStepInputSchema).min(1),
17947
- frames: array(FrameInputSchema).min(1).max(255),
17948
- deviceId: number$1().optional(),
17949
- sessionId: string().optional(),
17950
- /**
17951
- * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
17952
- * the batch to the Python pool's bench preprocess cache
17953
- * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
17954
- * preprocessed ONCE and every later inference is a pure-inference cache
17955
- * hit — the sustained-throughput run measures inference, not
17956
- * decode+preprocess+infer. Omitted/0 for live frames (all different →
17957
- * full preprocess every call, correct). Fresh per sustained run;
17958
- * released via `uncacheFrame`.
17959
- */
17960
- frameId: number$1().int().nonnegative().optional(),
17961
- /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
17962
- deviceKey: string().optional()
17963
- }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
17964
- data: _instanceof(Uint8Array),
17965
- width: number$1().int().positive(),
17966
- height: number$1().int().positive(),
17967
- format: _enum([
17968
- "rgb",
17969
- "bgr",
17970
- "gray"
17971
- ])
17972
- }), object({
17973
- frameId: number$1(),
17974
- width: number$1(),
17975
- height: number$1()
17976
- }), { kind: "mutation" }), method(object({
17977
- stepId: string(),
17978
- frameId: number$1().int()
17979
- }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number$1().int() }), _void(), { kind: "mutation" }), method(_void(), object({
17980
- batchMode: string(),
17981
- windowMs: number$1(),
17982
- maxBatchSize: number$1(),
17983
- concurrency: number$1()
17984
- })), method(_void(), array(object({
17985
- engineKey: string(),
17986
- engine: PipelineEngineChoiceSchema,
17987
- modelsLoaded: array(string()).readonly(),
17988
- inUseByCameras: array(number$1()).readonly(),
17989
- /**
17990
- * Origin of this resident factory.
17991
- * - `runtime` — main camera-serving engine (no idle TTL).
17992
- * - `warm-override` — benchmark/test override held in the warm
17993
- * cache; auto-disposed after the idle TTL.
17994
- * - `device-pool` — a concurrent per-device pool (Phase 2
17995
- * multi-device, keyed by `deviceKey`) resolved
17996
- * via `resolveDeviceFactory`. Runs alongside the
17997
- * `runtime` engine on a DIFFERENT accelerator
17998
- * (NPU / iGPU / Coral) — this is how the
17999
- * Engines tab shows all pools running at once.
18000
- */
18001
- kind: _enum([
18002
- "runtime",
18003
- "warm-override",
18004
- "device-pool"
18005
- ]),
18006
- /** Native pid of the underlying Python pool (null when no pool). */
18007
- poolPid: number$1().nullable(),
18008
- /** ms since this factory was last used (null when not warm-tracked). */
18009
- idleMs: number$1().nullable(),
18010
- /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
18011
- idleTtlMs: number$1().nullable()
18012
- })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
18209
+ }), method(object({ frameId: string() }), object({
18210
+ base64: string(),
18211
+ width: number$1().int(),
18212
+ height: number$1().int()
18213
+ }), {
18214
+ kind: "query",
18215
+ auth: "admin"
18216
+ }), method(object({
18217
+ deviceId: number$1(),
18218
+ trackId: string(),
18219
+ frameId: string(),
18220
+ subject: RetrainAssistSubjectSchema,
18221
+ /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
18222
+ nodeId: string().optional()
18223
+ }), RetrainAssistResultSchema, {
18013
18224
  kind: "mutation",
18014
18225
  auth: "admin"
18015
18226
  }), method(object({
18016
- engine: PipelineEngineChoiceSchema,
18017
- force: boolean().optional()
18018
- }), object({
18019
- success: boolean(),
18020
- reason: string().optional()
18021
- }), {
18227
+ deviceId: number$1(),
18228
+ source: DetectionSourceSchema,
18229
+ zones: array(ZoneSchema).readonly().optional(),
18230
+ detectionRules: array(ZoneRuleSchema).readonly().optional(),
18231
+ zoneMembershipMinOverlap: number$1().min(0).max(1).optional(),
18232
+ frames: array(ReplayFrameInputSchema).min(1)
18233
+ }), RunReplayFrameProcessorResultSchema, {
18022
18234
  kind: "mutation",
18023
18235
  auth: "admin"
18024
- }), 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({
18025
- addonId: string(),
18026
- modelId: string(),
18027
- filename: string().optional(),
18028
- settings: record(string(), unknown()).optional()
18029
- }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
18236
+ }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
18237
+ kind: "query",
18238
+ auth: "admin"
18239
+ }), method(object({
18240
+ deviceId: number$1(),
18241
+ trackId: string(),
18242
+ frameId: string(),
18243
+ annotations: array(RetrainAnnotationDraftSchema)
18244
+ }), array(RetrainAnnotationSchema).readonly(), {
18245
+ kind: "mutation",
18246
+ auth: "admin"
18247
+ }), method(object({
18248
+ deviceId: number$1(),
18249
+ trackId: string()
18250
+ }), RetrainTransitionResultSchema, {
18251
+ kind: "mutation",
18252
+ auth: "admin"
18253
+ }), method(object({
18254
+ deviceId: number$1(),
18255
+ trackId: string()
18256
+ }), RetrainTransitionResultSchema, {
18257
+ kind: "mutation",
18258
+ auth: "admin"
18259
+ }), method(object({ deviceIds: array(number$1()).optional() }), object({ url: string() }), {
18260
+ kind: "query",
18261
+ auth: "admin"
18262
+ }), method(object({
18263
+ eventId: string(),
18264
+ kind: MediaFileKindEnum.optional(),
18265
+ deviceId: number$1()
18266
+ }), array(MediaFileSchema).readonly()), method(object({
18267
+ trackId: string(),
18268
+ kinds: array(MediaFileKindEnum).optional(),
18269
+ deviceId: number$1()
18270
+ }), array(MediaFileSchema).readonly()), method(object({
18271
+ trackId: string(),
18272
+ deviceId: number$1()
18273
+ }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
18274
+ kind: "mutation",
18275
+ auth: "admin"
18276
+ }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
18277
+ kind: "mutation",
18278
+ auth: "admin"
18279
+ }), method(object({}), RebuildStatusSchema), object({
18280
+ deviceId: number$1(),
18281
+ timestamp: number$1(),
18282
+ frameWidth: number$1(),
18283
+ frameHeight: number$1(),
18284
+ detections: array(OverlayDetectionSchema).readonly()
18285
+ }), object({
18286
+ deviceId: number$1(),
18287
+ trackId: string(),
18288
+ className: string()
18289
+ }), object({
18290
+ deviceId: number$1(),
18291
+ trackId: string(),
18292
+ className: string(),
18293
+ durationMs: number$1()
18294
+ }), object({
18295
+ deviceId: number$1(),
18296
+ kind: EventKindSchema,
18297
+ eventId: string(),
18298
+ timestamp: number$1()
18299
+ });
18030
18300
  object({
18031
18301
  activeCameras: number$1(),
18032
18302
  throttledCameras: number$1(),
@@ -18052,66 +18322,6 @@ var CameraMetricsSchema = object({
18052
18322
  });
18053
18323
  var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number$1() });
18054
18324
  /**
18055
- * Zone — pure geometry + identity. NO filtering behaviour.
18056
- *
18057
- * Zones describe **where** in the frame the operator wants to flag
18058
- * something; consumer-owned {@link ZoneRule} arrays describe **how**
18059
- * each pipeline stage uses them. Splitting the two means a single
18060
- * polygon "Driveway" can simultaneously back a motion-exclude rule,
18061
- * a detection-include rule on `['car']`, and an occupancy aggregate
18062
- * — without three duplicated polygons.
18063
- *
18064
- * Owned by the orchestrator addon (provider) and mirrored into the
18065
- * `zones` device-state slice on every mutation. Consumers
18066
- * (motion-wasm, pipeline-executor, analytics, admin UI) read either
18067
- * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
18068
- * mirror with `onChanged`).
18069
- *
18070
- * Coordinates are normalised fractions of the frame (0–1) so zones
18071
- * survive resolution changes and stream profile switches.
18072
- *
18073
- * `kind` discriminates between full polygons (closed regions used
18074
- * for intrusion / occupancy filters) and tripwires (open 2-point
18075
- * line segments used for cross events). Onboard / firmware-reported
18076
- * zones (Reolink, ONVIF) are out of scope for now — see the deferred
18077
- * task list.
18078
- */
18079
- var ZoneKindEnum = _enum(["polygon", "tripwire"]);
18080
- /** Polygon vertex in fraction-of-frame coordinates (0–1). */
18081
- var PolygonPointSchema = object({
18082
- x: number$1(),
18083
- y: number$1()
18084
- });
18085
- /** A camera detection zone — pure geometry/identity. */
18086
- var ZoneSchema = object({
18087
- id: string(),
18088
- name: string(),
18089
- kind: ZoneKindEnum.default("polygon"),
18090
- /** Polygon vertices, fraction of frame (0–1). */
18091
- polygon: array(PolygonPointSchema).readonly(),
18092
- /** Visual color for UI rendering. */
18093
- color: string().default("#3b82f6")
18094
- });
18095
- DeviceType.Camera, method(object({ deviceId: number$1() }), array(ZoneSchema).readonly()), method(object({
18096
- deviceId: number$1(),
18097
- zone: ZoneSchema
18098
- }), _void(), {
18099
- kind: "mutation",
18100
- auth: "admin"
18101
- }), method(object({
18102
- deviceId: number$1(),
18103
- zoneId: string()
18104
- }), _void(), {
18105
- kind: "mutation",
18106
- auth: "admin"
18107
- }), method(object({
18108
- deviceId: number$1(),
18109
- zone: ZoneSchema
18110
- }), _void(), {
18111
- kind: "mutation",
18112
- auth: "admin"
18113
- }), object({ zones: array(ZoneSchema).readonly() });
18114
- /**
18115
18325
  * A bounding box in NORMALIZED [0,1] frame coordinates for `getNativeCrop`. The
18116
18326
  * decode worker resolves it against the RETAINED native frame's real pixel dims,
18117
18327
  * so the caller supplies only the detection-res bbox divided by the detection
@@ -19799,7 +20009,7 @@ method(object({
19799
20009
  * linking rather than produce an eternal token.
19800
20010
  */
19801
20011
  ttlSec: union([number$1().int().positive(), literal("never")]).optional()
19802
- }), object({ token: string() })), method(object({ token: string() }), SsoBridgeClaimsSchema.nullable());
20012
+ }), object({ token: string() }), { auth: "admin" }), method(object({ token: string() }), SsoBridgeClaimsSchema.nullable(), { auth: "admin" });
19803
20013
  var ProviderListEntrySchema = discriminatedUnion("shouldSaveDiskSpace", [object({
19804
20014
  providerId: string().min(1),
19805
20015
  displayName: string().min(1),
@@ -19894,10 +20104,13 @@ var EvictResultSchema = object({
19894
20104
  /** True when the provider has nothing left it is willing to drop on this location. */
19895
20105
  exhausted: boolean()
19896
20106
  });
19897
- method(object({ locationId: string() }), EvictableUsageSchema), method(object({
20107
+ method(object({ locationId: string() }), EvictableUsageSchema, { auth: "admin" }), method(object({
19898
20108
  locationId: string(),
19899
20109
  targetBytes: number$1().int().positive()
19900
- }), EvictResultSchema, { kind: "mutation" });
20110
+ }), EvictResultSchema, {
20111
+ kind: "mutation",
20112
+ auth: "admin"
20113
+ });
19901
20114
  method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin" }), method(StorageMigrationInputSchema, object({ jobId: string() }), {
19902
20115
  kind: "mutation",
19903
20116
  auth: "admin"
@@ -19957,26 +20170,50 @@ var ReadChunkInputSchema = object({
19957
20170
  length: number$1()
19958
20171
  });
19959
20172
  var EndDownloadInputSchema = object({ downloadId: string() });
19960
- method(_void(), ProviderInfoSchema), method(object({ config: record(string(), unknown()) }), TestLocationResultSchema, { auth: "admin" }), method(object({
20173
+ method(_void(), ProviderInfoSchema, { auth: "admin" }), method(object({ config: record(string(), unknown()) }), TestLocationResultSchema, { auth: "admin" }), method(object({
19961
20174
  location: StorageLocationSchema,
19962
20175
  relativePath: string()
19963
- }), string()), method(object({
20176
+ }), string(), { auth: "admin" }), method(object({
19964
20177
  location: StorageLocationSchema,
19965
20178
  relativePath: string(),
19966
20179
  data: _instanceof(Uint8Array)
19967
- }), _void(), { kind: "mutation" }), method(object({
20180
+ }), _void(), {
20181
+ kind: "mutation",
20182
+ auth: "admin"
20183
+ }), method(object({
19968
20184
  location: StorageLocationSchema,
19969
20185
  relativePath: string()
19970
- }), _instanceof(Uint8Array)), method(object({
20186
+ }), _instanceof(Uint8Array), { auth: "admin" }), method(object({
19971
20187
  location: StorageLocationSchema,
19972
20188
  relativePath: string()
19973
- }), boolean()), method(object({
20189
+ }), boolean(), { auth: "admin" }), method(object({
19974
20190
  location: StorageLocationSchema,
19975
20191
  prefix: string().optional()
19976
- }), array(string()).readonly()), method(object({
20192
+ }), array(string()).readonly(), { auth: "admin" }), method(object({
19977
20193
  location: StorageLocationSchema,
19978
20194
  relativePath: string()
19979
- }), _void(), { kind: "mutation" }), method(object({ location: StorageLocationSchema }), number$1().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" });
20195
+ }), _void(), {
20196
+ kind: "mutation",
20197
+ auth: "admin"
20198
+ }), method(object({ location: StorageLocationSchema }), number$1().nullable(), { auth: "admin" }), method(BeginUploadInputSchema, BeginUploadResultSchema, {
20199
+ kind: "mutation",
20200
+ auth: "admin"
20201
+ }), method(WriteChunkInputSchema, _void(), {
20202
+ kind: "mutation",
20203
+ auth: "admin"
20204
+ }), method(FinalizeUploadInputSchema, _void(), {
20205
+ kind: "mutation",
20206
+ auth: "admin"
20207
+ }), method(AbortUploadInputSchema, _void(), {
20208
+ kind: "mutation",
20209
+ auth: "admin"
20210
+ }), method(BeginDownloadInputSchema, BeginDownloadResultSchema, {
20211
+ kind: "mutation",
20212
+ auth: "admin"
20213
+ }), method(ReadChunkInputSchema, _instanceof(Uint8Array), { auth: "admin" }), method(EndDownloadInputSchema, _void(), {
20214
+ kind: "mutation",
20215
+ auth: "admin"
20216
+ });
19980
20217
  /** Profile-exported FormBuilder schema. Shape is ConfigUISchema at the UI. */
19981
20218
  var ProfileSettingsSchemaBridge = unknown().nullable();
19982
20219
  var ProfileSettingsBagSchema = record(string(), unknown());
@@ -20234,7 +20471,8 @@ method(object({
20234
20471
  access: "create"
20235
20472
  }), method(object({ userId: string().optional() }), object({ optionsJSON: record(string(), unknown()) }), {
20236
20473
  kind: "mutation",
20237
- access: "view"
20474
+ access: "view",
20475
+ auth: "admin"
20238
20476
  }), method(object({
20239
20477
  /** Required — the user the assertion belongs to (verified). */
20240
20478
  userId: string(),
@@ -20242,10 +20480,12 @@ method(object({
20242
20480
  response: record(string(), unknown())
20243
20481
  }), object({ verified: boolean() }), {
20244
20482
  kind: "mutation",
20245
- access: "view"
20483
+ access: "view",
20484
+ auth: "admin"
20246
20485
  }), method(object({}), object({ optionsJSON: record(string(), unknown()) }), {
20247
20486
  kind: "mutation",
20248
- access: "view"
20487
+ access: "view",
20488
+ auth: "admin"
20249
20489
  }), method(object({
20250
20490
  /** AuthenticationResponseJSON from the browser. */
20251
20491
  response: record(string(), unknown()) }), object({
@@ -20253,7 +20493,8 @@ response: record(string(), unknown()) }), object({
20253
20493
  userId: string().nullable()
20254
20494
  }), {
20255
20495
  kind: "mutation",
20256
- access: "view"
20496
+ access: "view",
20497
+ auth: "admin"
20257
20498
  }), method(object({ userId: string() }), array(PasskeySummarySchema), { auth: "admin" }), method(object({
20258
20499
  userId: string(),
20259
20500
  credentialId: string()
@@ -20425,7 +20666,19 @@ var VectorStatsResultSchema = object({
20425
20666
  /** False when the backend ranks approximately. */
20426
20667
  exact: boolean()
20427
20668
  });
20428
- 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);
20669
+ method(VectorDeclareIndexInputSchema, _void(), {
20670
+ kind: "mutation",
20671
+ auth: "admin"
20672
+ }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
20673
+ kind: "mutation",
20674
+ auth: "admin"
20675
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
20676
+ kind: "mutation",
20677
+ auth: "admin"
20678
+ }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
20679
+ kind: "mutation",
20680
+ auth: "admin"
20681
+ }), method(VectorStatsInputSchema, VectorStatsResultSchema, { auth: "admin" });
20429
20682
  var ClipSchema = object({
20430
20683
  /** Opaque, provider-namespaced id. The default provider encodes the time
20431
20684
  * window so `getClipPlayback` is self-contained (no event re-query). */
@@ -22148,7 +22401,27 @@ var MediaFileLiteSchema$1 = object({
22148
22401
  sizeBytes: number$1(),
22149
22402
  timestamp: number$1()
22150
22403
  });
22151
- method(_void(), array(IdentitySchema).readonly()), method(object({ name: string().min(1) }), IdentitySchema, {
22404
+ method(object({
22405
+ /**
22406
+ * Inline {@link IdentitySchema.coverBase64} on every row.
22407
+ *
22408
+ * Default `false`, the same inversion `listRecentFaces` and
22409
+ * `listPlates` took on 2026-08-25 (see `include-crops-default.ts` for
22410
+ * why the burden belongs on the caller that WANTS the bytes). Measured
22411
+ * on the live hub the same day: four identities cost 40,979 B with the
22412
+ * covers inline, ~10 KB of base64 per row, on a query this UI mounts
22413
+ * four times and the viewer holds at `staleTime: 30_000`.
22414
+ *
22415
+ * Nothing loses its avatar: `coverMediaKey` is already on every row and
22416
+ * the `event-media` plane serves that key `immutable` with an ETag.
22417
+ *
22418
+ * **This is an INPUT field, so it does not reach the addon until the
22419
+ * next train** — the hub router validates cap inputs against its own
22420
+ * compiled Zod and strips a key it does not know. Until then the
22421
+ * provider sees `undefined`, which resolves to `false`: the cheap shape
22422
+ * is what ships, and the opt-in becomes reachable when the train lands.
22423
+ */
22424
+ includeCrops: boolean().optional() }).optional(), array(IdentitySchema).readonly()), method(object({ name: string().min(1) }), IdentitySchema, {
22152
22425
  kind: "mutation",
22153
22426
  auth: "admin"
22154
22427
  }), method(object({
@@ -24295,8 +24568,10 @@ var PlateInfoSchema = object({
24295
24568
  keyFrameMediaKey: string().optional(),
24296
24569
  base64: string().optional(),
24297
24570
  /**
24298
- * Same crop as a data-plane URL. `getPlateByTrack` returns this and
24299
- * never inlines JPEG; `listPlates` still inlines for the admin-ui.
24571
+ * Same crop as a data-plane URL, always present when the plate has a stored
24572
+ * crop. `getPlateByTrack` returns this and never inlines JPEG; `listPlates`
24573
+ * and `searchPlates` inline the crop only when their `includeCrops` input is
24574
+ * left at its `true` default.
24300
24575
  */
24301
24576
  cropUrl: string().optional()
24302
24577
  });
@@ -24316,14 +24591,34 @@ var PlateClusterSchema = object({
24316
24591
  });
24317
24592
  method(object({
24318
24593
  deviceId: number$1().int().optional(),
24319
- limit: number$1().int().positive().optional()
24594
+ limit: number$1().int().positive().optional(),
24595
+ /**
24596
+ * Inline the base64 crop on every row. Default `true` — the existing
24597
+ * behaviour, kept so no caller breaks.
24598
+ *
24599
+ * Set `false` once the caller renders {@link PlateInfo.cropUrl}.
24600
+ * Measured on the live hub at the 500 rows the Plates view asks for:
24601
+ * 879,403 B and 27.7 s with the crops inline, against a few KiB of
24602
+ * metadata without them — and the browser then caches the images.
24603
+ *
24604
+ * This is the plate twin of `faceGallery.listRecentFaces`'s option;
24605
+ * plates were the one gallery list left without it.
24606
+ *
24607
+ * **This is an INPUT field, so it does not reach the addon until the
24608
+ * next train.** The hub router validates cap inputs against its own
24609
+ * compiled Zod and strips a key it does not know. Until the train
24610
+ * ships, sending `false` is harmless and keeps the crops inline.
24611
+ */
24612
+ includeCrops: boolean().optional()
24320
24613
  }).optional(), array(PlateInfoSchema).readonly()), method(object({
24321
24614
  deviceId: number$1().int(),
24322
24615
  trackId: string()
24323
24616
  }), PlateInfoSchema.nullable()), method(object({ plateId: string() }), array(MediaFileLiteSchema).readonly()), method(object({
24324
24617
  text: string().min(1),
24325
24618
  maxDistance: number$1().int().min(0).optional(),
24326
- limit: number$1().int().positive().optional()
24619
+ limit: number$1().int().positive().optional(),
24620
+ /** See `listPlates.includeCrops`. Default `true`. */
24621
+ includeCrops: boolean().optional()
24327
24622
  }), array(PlateInfoSchema).readonly()), method(object({
24328
24623
  maxDistance: number$1().int().min(0).optional(),
24329
24624
  minClusterSize: number$1().int().min(2).optional(),
@@ -24337,7 +24632,13 @@ method(object({
24337
24632
  }), method(object({ plateId: string() }), _void(), {
24338
24633
  kind: "mutation",
24339
24634
  auth: "admin"
24340
- }), method(_void(), array(VehicleSchema).readonly()), method(object({ name: string().min(1) }), VehicleSchema, {
24635
+ }), method(object({
24636
+ /** Inline {@link VehicleSchema.coverBase64} on every row. Default
24637
+ * `false` — the vehicle twin of `faceGallery.listIdentities`'s
24638
+ * option; `coverMediaKey` + the `event-media` plane carry the picture.
24639
+ * INPUT field: stripped by the hub router until the train ships, which
24640
+ * resolves to `false` and is exactly the intended default. */
24641
+ includeCrops: boolean().optional() }).optional(), array(VehicleSchema).readonly()), method(object({ name: string().min(1) }), VehicleSchema, {
24341
24642
  kind: "mutation",
24342
24643
  auth: "admin"
24343
24644
  }), method(object({
@@ -25602,92 +25903,6 @@ DeviceType.Camera, method(object({ deviceId: number$1() }), SceneMonitorStatusSc
25602
25903
  kind: "mutation",
25603
25904
  auth: "admin"
25604
25905
  });
25605
- /**
25606
- * Per-stage gating mode applied to the zones a rule references.
25607
- *
25608
- * - `include`: the rule contributes to a **whitelist** for its stage.
25609
- * When at least one `include` rule fires for a stage, only entities
25610
- * inside one of those zones pass that stage.
25611
- * - `exclude`: the rule contributes to a **blacklist** for its stage.
25612
- * Entities inside one of those zones are dropped at that stage.
25613
- *
25614
- * `monitor`-style observation (count without filtering) is not a rule
25615
- * mode — zones without any matching rule are observed naturally by
25616
- * `zone-analytics` (live snapshot + history), so an "I just want to
25617
- * count, not filter" use case needs no rule at all.
25618
- */
25619
- var ZoneRuleModeEnum = _enum(["include", "exclude"]);
25620
- /**
25621
- * Per-consumer rule that references existing zones (geometry) and
25622
- * defines how a specific pipeline stage should treat them. Each
25623
- * consumer addon owns its own `ZoneRule[]` array in its per-device
25624
- * settings:
25625
- *
25626
- * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
25627
- * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
25628
- * - future: notification rules, audio gating, etc.
25629
- *
25630
- * One rule applies to N zones (`zoneIds[]`) so the operator can
25631
- * express "ignore motion in ALL of {garden, street}" with a single
25632
- * rule. `classFilter` narrows the rule to specific object classes —
25633
- * "drop person detections in the street, but keep cars" is one
25634
- * `exclude` rule with `classFilter: ['person']`.
25635
- *
25636
- * `enabled` is a soft toggle — the operator can keep the rule
25637
- * configured but inert without deleting it.
25638
- */
25639
- var ZoneRuleSchema = object({
25640
- /** Stable rule id — survives edits, used by the UI for diffing. */
25641
- id: string(),
25642
- /** Optional human-readable label rendered in the rule editor. */
25643
- name: string().optional(),
25644
- /** Zones this rule targets. The rule's `mode` applies to ALL
25645
- * listed zones (OR-set: a detection in any one of them counts).
25646
- * At least one zone id required — a rule with no targets is a
25647
- * configuration mistake and the form validator rejects it. */
25648
- zoneIds: array(string()).min(1).readonly(),
25649
- mode: ZoneRuleModeEnum,
25650
- /**
25651
- * Class names this rule applies to. Empty / undefined ⇒ rule
25652
- * applies to every class. Class strings match the `macroClass`
25653
- * field on detections (e.g. `person`, `car`, `dog`).
25654
- */
25655
- classFilter: array(string()).readonly().optional(),
25656
- /**
25657
- * Minimum bbox/mask overlap (0–1) with any of the rule's zones
25658
- * required to consider an entity "in the zone". Defaults to the
25659
- * consumer's stage default when omitted. Kept for back-compat with
25660
- * existing per-rule overrides; new operators pick the value via
25661
- * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
25662
- * set, the lower-level engine reads it as a 0–1 fraction.
25663
- */
25664
- overlapThreshold: number$1().min(0).max(1).optional(),
25665
- /**
25666
- * Operator-friendly version of `overlapThreshold` — the percentage
25667
- * of the detection's bbox that must lie inside the zone for the
25668
- * rule to match. Documented default is 85%; the engine substitutes
25669
- * that when the field is omitted (kept optional so existing rules
25670
- * stored without it stay valid).
25671
- *
25672
- * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
25673
- * rule, the engine prefers `bboxInclusionPct` because it's the
25674
- * field exposed in the UI. Internally both feed the same gate.
25675
- */
25676
- bboxInclusionPct: number$1().min(0).max(100).optional(),
25677
- /**
25678
- * When `true` and a detection has a segmentation mask, use the
25679
- * mask for overlap instead of the bbox. Detection-stage only;
25680
- * motion rules ignore this field.
25681
- */
25682
- preferMask: boolean().optional(),
25683
- /**
25684
- * Soft-toggle: `false` disables the rule without deleting it.
25685
- * Defaults to `true` so operators creating a rule via the UI
25686
- * see it active immediately.
25687
- */
25688
- enabled: boolean().default(true)
25689
- });
25690
- array(ZoneRuleSchema).readonly();
25691
25906
  object({
25692
25907
  /** Whether the script is currently executing. */
25693
25908
  isRunning: boolean(),
@@ -29714,6 +29929,12 @@ Object.freeze({
29714
29929
  addonId: null,
29715
29930
  access: "create"
29716
29931
  },
29932
+ "pipelineAnalytics.cancelRelocateMedia": {
29933
+ capName: "pipeline-analytics",
29934
+ capScope: "device",
29935
+ addonId: null,
29936
+ access: "create"
29937
+ },
29717
29938
  "pipelineAnalytics.cancelStorageMigrationMove": {
29718
29939
  capName: "pipeline-analytics",
29719
29940
  capScope: "device",
@@ -29888,6 +30109,12 @@ Object.freeze({
29888
30109
  addonId: null,
29889
30110
  access: "view"
29890
30111
  },
30112
+ "pipelineAnalytics.listRelocateMediaJobs": {
30113
+ capName: "pipeline-analytics",
30114
+ capScope: "device",
30115
+ addonId: null,
30116
+ access: "view"
30117
+ },
29891
30118
  "pipelineAnalytics.listRetrainAnnotations": {
29892
30119
  capName: "pipeline-analytics",
29893
30120
  capScope: "device",
@@ -29966,6 +30193,12 @@ Object.freeze({
29966
30193
  addonId: null,
29967
30194
  access: "create"
29968
30195
  },
30196
+ "pipelineAnalytics.relocateMedia": {
30197
+ capName: "pipeline-analytics",
30198
+ capScope: "device",
30199
+ addonId: null,
30200
+ access: "create"
30201
+ },
29969
30202
  "pipelineAnalytics.restageRetrainTrack": {
29970
30203
  capName: "pipeline-analytics",
29971
30204
  capScope: "device",
@@ -29978,6 +30211,12 @@ Object.freeze({
29978
30211
  addonId: null,
29979
30212
  access: "create"
29980
30213
  },
30214
+ "pipelineAnalytics.runReplayFrameProcessor": {
30215
+ capName: "pipeline-analytics",
30216
+ capScope: "device",
30217
+ addonId: null,
30218
+ access: "create"
30219
+ },
29981
30220
  "pipelineAnalytics.saveRetrainAnnotations": {
29982
30221
  capName: "pipeline-analytics",
29983
30222
  capScope: "device",
@@ -30110,6 +30349,12 @@ Object.freeze({
30110
30349
  addonId: null,
30111
30350
  access: "view"
30112
30351
  },
30352
+ "pipelineExecutor.getInferenceDeviceHealth": {
30353
+ capName: "pipeline-executor",
30354
+ capScope: "system",
30355
+ addonId: null,
30356
+ access: "view"
30357
+ },
30113
30358
  "pipelineExecutor.getOrchestratorConfigSchema": {
30114
30359
  capName: "pipeline-executor",
30115
30360
  capScope: "system",
@@ -30182,6 +30427,12 @@ Object.freeze({
30182
30427
  addonId: null,
30183
30428
  access: "view"
30184
30429
  },
30430
+ "pipelineExecutor.rearmInferenceDevice": {
30431
+ capName: "pipeline-executor",
30432
+ capScope: "system",
30433
+ addonId: null,
30434
+ access: "create"
30435
+ },
30185
30436
  "pipelineExecutor.runAudioTest": {
30186
30437
  capName: "pipeline-executor",
30187
30438
  capScope: "system",
@@ -33430,6 +33681,11 @@ Object.freeze({
33430
33681
  form: "single",
33431
33682
  optional: false
33432
33683
  }],
33684
+ "pipelineAnalytics.runReplayFrameProcessor": [{
33685
+ name: "deviceId",
33686
+ form: "single",
33687
+ optional: false
33688
+ }],
33433
33689
  "pipelineAnalytics.saveRetrainAnnotations": [{
33434
33690
  name: "deviceId",
33435
33691
  form: "single",