@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.mjs CHANGED
@@ -6878,7 +6878,7 @@ function method(input, output, options) {
6878
6878
  input,
6879
6879
  output,
6880
6880
  kind: options?.kind ?? "query",
6881
- auth: options?.auth ?? "protected",
6881
+ ...options?.auth !== void 0 ? { auth: options.auth } : {},
6882
6882
  ...options?.access !== void 0 ? { access: options.access } : {},
6883
6883
  ...options?.caller !== void 0 ? { caller: options.caller } : {},
6884
6884
  timeoutMs: options?.timeoutMs
@@ -6898,7 +6898,7 @@ function systemMethod(input, output, options) {
6898
6898
  }
6899
6899
  var StaticDirOutputSchema$1 = object({ staticDir: string() });
6900
6900
  var VersionOutputSchema$1 = object({ version: string() });
6901
- method(_void(), StaticDirOutputSchema$1), method(_void(), VersionOutputSchema$1);
6901
+ method(_void(), StaticDirOutputSchema$1, { auth: "admin" }), method(_void(), VersionOutputSchema$1, { auth: "admin" });
6902
6902
  var DeviceType = /* @__PURE__ */ function(DeviceType) {
6903
6903
  DeviceType["Camera"] = "camera";
6904
6904
  DeviceType["Hub"] = "hub";
@@ -7219,7 +7219,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
7219
7219
  }({});
7220
7220
  var StaticDirOutputSchema = object({ staticDir: string() });
7221
7221
  var VersionOutputSchema = object({ version: string() });
7222
- method(_void(), StaticDirOutputSchema), method(_void(), VersionOutputSchema);
7222
+ method(_void(), StaticDirOutputSchema, { auth: "admin" }), method(_void(), VersionOutputSchema, { auth: "admin" });
7223
7223
  /**
7224
7224
  * device-ops — device-scoped cap that unifies the per-IDevice operations
7225
7225
  * previously routed through the `.device-ops` Moleculer bridge service.
@@ -7833,24 +7833,6 @@ var RecordingRetentionSchema = object({
7833
7833
  maxSizeGb: number$1().min(0).optional()
7834
7834
  });
7835
7835
  /**
7836
- * Scrub-thumbnail fidelity preset — the single per-camera selector bundling the
7837
- * sprite tile RESOLUTION + JPEG QUALITY the recorder packs timeline-scrub
7838
- * previews at. Five graduated steps; absent on a config = `standard` (the
7839
- * shipped default, matching `sheet-geometry`/`sheet-composer`).
7840
- *
7841
- * Existing sheets are IMMUTABLE — a changed preset applies to NEW windows only.
7842
- * Each window's index sidecar carries its own tile dims, so a camera whose
7843
- * preset changed over time renders every historical window at the dims it was
7844
- * written with.
7845
- */
7846
- var ScrubThumbnailPresetSchema = _enum([
7847
- "minimal",
7848
- "low",
7849
- "standard",
7850
- "high",
7851
- "max"
7852
- ]);
7853
- /**
7854
7836
  * The full per-camera recording intent — the wire shape of a RecordingTarget.
7855
7837
  *
7856
7838
  * `bands` is the ONLY authored recording intent: what to record, when, and on
@@ -7858,7 +7840,11 @@ var ScrubThumbnailPresetSchema = _enum([
7858
7840
  * other field is a storage knob (profiles, segment length, retention, scrub).
7859
7841
  *
7860
7842
  * STRICT on purpose: the legacy authoring surface (`schedule`/`schedules`/
7861
- * `triggers`/`preBufferSec`/`postBufferSec`/`rules`) was retired 2026-07-30.
7843
+ * `triggers`/`preBufferSec`/`postBufferSec`/`rules`) was retired 2026-07-30,
7844
+ * and `scrubThumbnails` — a five-step fidelity knob for a sprite tier that was
7845
+ * deleted on 2026-07-24 and had ZERO consumers in the recorder — on 2026-08-25
7846
+ * (D62: a switch that writes a store nobody reads is worse than no switch).
7847
+ * Stored rows keep loading: the READ schema is `.strip()` (config-store.ts).
7862
7848
  * A stale caller must fail loudly — silently stripping its legacy intent would
7863
7849
  * persist a band-less config, i.e. silently stop recording the camera.
7864
7850
  */
@@ -7881,14 +7867,7 @@ var RecordingConfigSchema = object({
7881
7867
  * "off" is the absence of a covering band, never a band value.
7882
7868
  */
7883
7869
  bands: array(RecordingBandSchema).default([]),
7884
- retention: RecordingRetentionSchema.optional(),
7885
- /**
7886
- * Per-camera scrub-thumbnail fidelity preset (resolution + JPEG quality for
7887
- * timeline-scrub sprite previews). Absent = `standard`. Applies to NEW
7888
- * windows only — existing sheets are immutable, and each window's index
7889
- * carries its own tile dims so mixed-preset history renders correctly.
7890
- */
7891
- scrubThumbnails: ScrubThumbnailPresetSchema.optional()
7870
+ retention: RecordingRetentionSchema.optional()
7892
7871
  }).strict();
7893
7872
  /**
7894
7873
  * Entity-relocation job state (storage entity-routing spec, Phase 4).
@@ -7964,10 +7943,11 @@ var RelocateFootageInputSchema = object({
7964
7943
  * `RecordingConfig.enabled` or camera wrapper bindings. */
7965
7944
  var StorageMigrationLeaseInputSchema = object({ leaseId: string().min(1) });
7966
7945
  var StorageMigrationFootageMoveInputSchema = RelocateFootageInputSchema.extend({ leaseId: string().min(1) });
7967
- var StorageMigrationMediaMoveInputSchema = object({
7946
+ var RelocateMediaInputSchema = object({
7968
7947
  toLocationId: string(),
7969
7948
  throttleMbps: number$1().min(1).max(1e3).optional()
7970
- }).extend({ leaseId: string().min(1) });
7949
+ });
7950
+ var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
7971
7951
  /** The independently selectable logical storage classes. `recordings`
7972
7952
  * encompasses the high and mid segment profiles; `recordingsLow` is low
7973
7953
  * segments; `eventMedia` is post-analysis blobs. */
@@ -8262,7 +8242,26 @@ var LabelDefinitionSchema = object({
8262
8242
  description: string().optional(),
8263
8243
  icon: string().optional()
8264
8244
  });
8265
- var ClassMapDefinitionSchema = object({
8245
+ /**
8246
+ * Wire schema for a per-model CATALOG classMap override
8247
+ * (`ModelCatalogEntry.classMap` / `ModelConvertMetadata.classMap`) —
8248
+ * restricted to {@link CLASS_MAP_MACRO_TARGETS}, the only macros the
8249
+ * detection pipeline executor actually routes.
8250
+ *
8251
+ * This is deliberately a DIFFERENT, narrower shape than the general-purpose
8252
+ * `ClassMapDefinition` interface above (e.g. `IDetectionAddon.getClassMap()`
8253
+ * and the audio `YAMNET_TO_MACRO` catalog both use macro targets outside this
8254
+ * enum) — the two used to share the name `ClassMapDefinition`/
8255
+ * `ClassMapDefinitionSchema`, which made the schema-type-twin guard
8256
+ * (`scripts/check-schema-type-twins.ts`) flag them as a duplicated shape. They
8257
+ * are not: it is two different concepts colliding on a name. Keep this type
8258
+ * under its own name rather than reusing `ClassMapDefinition` — reusing it
8259
+ * would either narrow every `ClassMapDefinition` consumer to the four
8260
+ * detection macros (breaking `YAMNET_TO_MACRO`) or drop the validation this
8261
+ * schema exists for (see the "rejects a classMap whose target is not a
8262
+ * detection macro" test in `model-catalog-schema.test.ts`).
8263
+ */
8264
+ var DetectionCatalogClassMapSchema = object({
8266
8265
  mapping: record(string(), _enum([
8267
8266
  "person",
8268
8267
  "vehicle",
@@ -8467,7 +8466,7 @@ var ModelCatalogEntrySchema = object({
8467
8466
  * applies (Frigate / COCO public catalog). Set on a custom model whose raw
8468
8467
  * labels already ARE the CamStack macros (Scrypted identity map).
8469
8468
  */
8470
- classMap: ClassMapDefinitionSchema.optional()
8469
+ classMap: DetectionCatalogClassMapSchema.optional()
8471
8470
  });
8472
8471
  var ConvertTargetSchema = discriminatedUnion("format", [object({
8473
8472
  format: literal("openvino"),
@@ -8497,7 +8496,7 @@ var ModelConvertMetadataSchema = object({
8497
8496
  "segmentation"
8498
8497
  ]),
8499
8498
  faceAlignment: boolean().optional(),
8500
- classMap: ClassMapDefinitionSchema.optional()
8499
+ classMap: DetectionCatalogClassMapSchema.optional()
8501
8500
  });
8502
8501
  var ConvertResultSchema = object({
8503
8502
  entry: ModelCatalogEntrySchema,
@@ -9360,7 +9359,7 @@ var AddonPageDeclarationSchema = object({
9360
9359
  /** Display label for a CUSTOM `section` id (ignored for well-known ids). */
9361
9360
  sectionLabel: string().optional()
9362
9361
  });
9363
- method(_void(), array(AddonPageDeclarationSchema).readonly());
9362
+ method(_void(), array(AddonPageDeclarationSchema).readonly(), { auth: "admin" });
9364
9363
  var AddonHttpRouteSchema = object({
9365
9364
  method: _enum([
9366
9365
  "GET",
@@ -9595,7 +9594,7 @@ var WidgetMetadataSchema = object({
9595
9594
  defaultColumns: number$1().int().min(1).max(12).default(6),
9596
9595
  defaultRows: number$1().int().min(1).max(12).default(1)
9597
9596
  });
9598
- method(_void(), array(WidgetMetadataSchema).readonly());
9597
+ method(_void(), array(WidgetMetadataSchema).readonly(), { auth: "admin" });
9599
9598
  /**
9600
9599
  * `addon-widgets` — system-scoped singleton aggregator cap. Public-facing
9601
9600
  * surface that admin-ui consumes through `useAddonWidgetsListWidgets()`.
@@ -11117,7 +11116,7 @@ var CustomModelDescriptorSchema = object({
11117
11116
  stepId: string(),
11118
11117
  entry: ModelCatalogEntrySchema
11119
11118
  });
11120
- method(_void(), array(CustomModelDescriptorSchema).readonly());
11119
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
11121
11120
  /**
11122
11121
  * Query filter for settings-store collections.
11123
11122
  */
@@ -11204,7 +11203,8 @@ method(object({
11204
11203
  }), _void(), { kind: "mutation" }), method(object({
11205
11204
  namespace: string().optional(),
11206
11205
  collection: string(),
11207
- filter: QueryFilterSchema.optional()
11206
+ filter: QueryFilterSchema.optional(),
11207
+ columns: array(string()).readonly().optional()
11208
11208
  }), array(SettingsRecordSchema).readonly()), method(object({
11209
11209
  namespace: string().optional(),
11210
11210
  collection: string(),
@@ -11267,46 +11267,87 @@ var EngineInfoSchema = object({
11267
11267
  kind: _enum(["relational", "vector"]),
11268
11268
  displayName: string()
11269
11269
  });
11270
- method(_void(), EngineInfoSchema), method(object({
11270
+ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
11271
11271
  namespace: string().optional(),
11272
11272
  collection: string(),
11273
11273
  key: string()
11274
- }), unknown()), method(object({
11274
+ }), unknown(), { auth: "admin" }), method(object({
11275
11275
  namespace: string().optional(),
11276
11276
  collection: string(),
11277
11277
  key: string(),
11278
11278
  value: unknown()
11279
- }), _void(), { kind: "mutation" }), method(object({
11279
+ }), _void(), {
11280
+ kind: "mutation",
11281
+ auth: "admin"
11282
+ }), method(object({
11280
11283
  namespace: string().optional(),
11281
11284
  collection: string(),
11282
- filter: QueryFilterSchema.optional()
11283
- }), array(SettingsRecordSchema).readonly()), method(object({
11285
+ filter: QueryFilterSchema.optional(),
11286
+ /**
11287
+ * SQL-level column projection — MUST mirror `settings-store.query`.
11288
+ *
11289
+ * ⚠ An earlier version of this comment blamed Zod stripping, and that
11290
+ * was wrong — corrected 2026-08-26 after the hop map
11291
+ * (`docs/design/2026-08-26-mappa-hop-argomenti.md`) traced the path.
11292
+ * There is **no Zod parse at all** between the door and the engine: the
11293
+ * dispatcher forwards the payload verbatim and UDS carries it whole. A
11294
+ * field declared here reaches `SqliteSettingsBackend` either way.
11295
+ *
11296
+ * What actually lost `columns` was the THIRD declaration of this shape:
11297
+ * `SettingsQueryInput` in `interfaces/storage.ts`, a hand-written TS
11298
+ * interface the engine destructures from. The field existed on both
11299
+ * schemas and the engine still never read it, because nothing checks a
11300
+ * registered provider against `InferProvider<cap>` —
11301
+ * `ProviderRegistration.provider` is typed `object`.
11302
+ *
11303
+ * It is declared here anyway, and must stay in step with
11304
+ * `settings-store.query`: a caller reading only the cap definitions has
11305
+ * to be able to see that this call carries a projection.
11306
+ * `data-door-schema-parity.spec.ts` keeps the two aligned.
11307
+ */
11308
+ columns: array(string()).readonly().optional()
11309
+ }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
11284
11310
  namespace: string().optional(),
11285
11311
  collection: string(),
11286
11312
  record: SettingsRecordSchema
11287
- }), _void(), { kind: "mutation" }), method(object({
11313
+ }), _void(), {
11314
+ kind: "mutation",
11315
+ auth: "admin"
11316
+ }), method(object({
11288
11317
  namespace: string().optional(),
11289
11318
  collection: string(),
11290
11319
  id: string(),
11291
11320
  data: record(string(), unknown())
11292
- }), _void(), { kind: "mutation" }), method(object({
11321
+ }), _void(), {
11322
+ kind: "mutation",
11323
+ auth: "admin"
11324
+ }), method(object({
11293
11325
  namespace: string().optional(),
11294
11326
  collection: string(),
11295
11327
  key: string()
11296
- }), _void(), { kind: "mutation" }), method(object({
11328
+ }), _void(), {
11329
+ kind: "mutation",
11330
+ auth: "admin"
11331
+ }), method(object({
11297
11332
  namespace: string().optional(),
11298
11333
  collection: string(),
11299
11334
  filter: MutationFilterSchema
11300
- }), object({ deleted: number$1().int() }), { kind: "mutation" }), method(object({
11335
+ }), object({ deleted: number$1().int() }), {
11336
+ kind: "mutation",
11337
+ auth: "admin"
11338
+ }), method(object({
11301
11339
  namespace: string().optional(),
11302
11340
  collection: string(),
11303
11341
  filter: MutationFilterSchema,
11304
11342
  data: record(string(), unknown())
11305
- }), object({ updated: number$1().int() }), { kind: "mutation" }), method(object({
11343
+ }), object({ updated: number$1().int() }), {
11344
+ kind: "mutation",
11345
+ auth: "admin"
11346
+ }), method(object({
11306
11347
  namespace: string().optional(),
11307
11348
  collection: string(),
11308
11349
  filter: QueryFilterSchema.optional()
11309
- }), number$1()), method(object({
11350
+ }), number$1(), { auth: "admin" }), method(object({
11310
11351
  namespace: string().optional(),
11311
11352
  collection: string(),
11312
11353
  field: string(),
@@ -11316,15 +11357,18 @@ method(_void(), EngineInfoSchema), method(object({
11316
11357
  }), array(object({
11317
11358
  bucket: number$1().int(),
11318
11359
  count: number$1().int()
11319
- })).readonly()), method(object({
11360
+ })).readonly(), { auth: "admin" }), method(object({
11320
11361
  namespace: string().optional(),
11321
11362
  collection: string()
11322
- }), boolean()), method(object({
11363
+ }), boolean(), { auth: "admin" }), method(object({
11323
11364
  namespace: string().optional(),
11324
11365
  collection: string(),
11325
11366
  columns: array(CollectionColumnSchema).readonly(),
11326
11367
  indexes: array(CollectionIndexSchema).readonly().optional()
11327
- }), _void(), { kind: "mutation" });
11368
+ }), _void(), {
11369
+ kind: "mutation",
11370
+ auth: "admin"
11371
+ });
11328
11372
  /**
11329
11373
  * shm ring usage stats for a `frameSink: 'shm'` decoder session —
11330
11374
  * exposed via `decoder.getShmStats` so downstream consumers can
@@ -12452,7 +12496,7 @@ method(object({
12452
12496
  crop: _instanceof(Uint8Array),
12453
12497
  width: number$1(),
12454
12498
  height: number$1()
12455
- }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
12499
+ }), EmbeddingResultSchema, { auth: "admin" }), method(object({ text: string() }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" });
12456
12500
  /**
12457
12501
  * filesystem-browse — per-node capability for browsing the node's local
12458
12502
  * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
@@ -12764,12 +12808,28 @@ var llmRuntimeCapability = {
12764
12808
  mode: "singleton",
12765
12809
  internal: true,
12766
12810
  methods: {
12811
+ /**
12812
+ * `complete`, `status`, `listLocalModels` and `getDiskUsage` had NO
12813
+ * `auth` override — `internal: true` did not gate the mount (see the
12814
+ * 2026-08-26 note on `data-store-provider`), so they were reachable on
12815
+ * the AppRouter by ANY authenticated session at the default
12816
+ * `auth: 'protected'`, inconsistent with the rest of this cap (already
12817
+ * `auth: 'admin'`) and with this file's own docblock: "the operator
12818
+ * reaches this only through the `llm` cap's methods." The sole caller,
12819
+ * `addon-ai`'s `runtime-client.ts`, reaches every method here via
12820
+ * `ctx.api` + `nodePin` — never tRPC — so `auth: 'admin'` costs it
12821
+ * nothing; the public `llm` cap (which end users and non-admin sessions
12822
+ * legitimately call for chat/generation) is untouched.
12823
+ */
12767
12824
  complete: method(LlmGenerateBaseInputSchema.extend({
12768
12825
  images: array(LlmImageSchema).optional(),
12769
12826
  runtime: ManagedRuntimeConfigSchema,
12770
12827
  /** The managed profile's timeout, threaded by the hub provider. */
12771
12828
  timeoutMs: number$1().int().positive().optional()
12772
- }), LlmGenerateResultSchema, { kind: "mutation" }),
12829
+ }), LlmGenerateResultSchema, {
12830
+ kind: "mutation",
12831
+ auth: "admin"
12832
+ }),
12773
12833
  ensureStarted: method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
12774
12834
  kind: "mutation",
12775
12835
  auth: "admin"
@@ -12778,7 +12838,7 @@ var llmRuntimeCapability = {
12778
12838
  kind: "mutation",
12779
12839
  auth: "admin"
12780
12840
  }),
12781
- status: method(object({}), LlmRuntimeStatusSchema),
12841
+ status: method(object({}), LlmRuntimeStatusSchema, { auth: "admin" }),
12782
12842
  installModel: method(object({ model: ManagedModelRefSchema }), _void(), {
12783
12843
  kind: "mutation",
12784
12844
  auth: "admin"
@@ -12787,8 +12847,8 @@ var llmRuntimeCapability = {
12787
12847
  kind: "mutation",
12788
12848
  auth: "admin"
12789
12849
  }),
12790
- listLocalModels: method(object({}), array(LlmNodeModelSchema)),
12791
- getDiskUsage: method(object({}), LlmRuntimeDiskUsageSchema)
12850
+ listLocalModels: method(object({}), array(LlmNodeModelSchema), { auth: "admin" }),
12851
+ getDiskUsage: method(object({}), LlmRuntimeDiskUsageSchema, { auth: "admin" })
12792
12852
  }
12793
12853
  };
12794
12854
  /**
@@ -16311,1748 +16371,1958 @@ var OauthIntegrationDescriptorSchema = object({
16311
16371
  */
16312
16372
  refreshTokenTtlSec: union([number$1().int().positive(), literal("never")]).optional()
16313
16373
  });
16314
- method(_void(), OauthIntegrationDescriptorSchema);
16374
+ method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
16315
16375
  /**
16316
- * pipeline-analytics — device-scoped wrapper cap. Refines raw
16317
- * per-frame detections emitted by the pipeline runner into tracked
16318
- * objects, per-kind event collections (motion / object / audio), and
16319
- * persisted media. Owns the post-detection domain end-to-end:
16320
- *
16321
- * runner emits PipelineInferenceResult
16322
- * ↓ (event bus)
16323
- * pipeline-analytics subscriber
16324
- * ↓ SORT tracker + zone engine + state analyzer + event emitter
16325
- * → three DB collections (one per kind), one FS media tree, one
16326
- * unified event emitter (FrameTracked + TrackStarted/Ended +
16327
- * DetectionEvent on bus)
16328
- *
16329
- * Pure subscriber model. No `processFrame` cap method — the runner
16330
- * already publishes the raw frame on the bus. The cap surface is
16331
- * only QUERIES + per-device settings, bound on/off via
16332
- * `device-manager.setWrapperActive`. `defaultActive: true` because
16333
- * every camera with a detection pipeline wants its raw detections
16334
- * refined; operators opt out per-device via BindingsTab when needed.
16335
- *
16336
- * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
16337
- * (per-device surface) and `track-trail` caps — see P11 cleanup.
16376
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
16377
+ * within the frame, so the executor can re-cut a leaf child ROI at native
16378
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
16338
16379
  */
16339
- var TrackStateSchema = _enum([
16340
- "new",
16341
- "entered",
16342
- "left",
16343
- "moving",
16344
- "idle"
16345
- ]);
16346
- var EventKindSchema = _enum([
16347
- "motion",
16348
- "object",
16349
- "audio"
16350
- ]);
16380
+ var NativeCropRefSchema = object({
16381
+ /** Handle keying the retained native surface (node-pinned to its owner). */
16382
+ handle: FrameHandleSchema,
16383
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
16384
+ cropFrameSpace: object({
16385
+ x: number$1(),
16386
+ y: number$1(),
16387
+ w: number$1(),
16388
+ h: number$1()
16389
+ })
16390
+ });
16391
+ object({
16392
+ crop: object({
16393
+ left: number$1(),
16394
+ top: number$1(),
16395
+ width: number$1().positive(),
16396
+ height: number$1().positive()
16397
+ }).optional(),
16398
+ content: object({
16399
+ width: number$1().int().positive(),
16400
+ height: number$1().int().positive()
16401
+ }),
16402
+ fit: _enum(["stretch", "contain"]),
16403
+ format: _enum([
16404
+ "rgb",
16405
+ "gray",
16406
+ "jpeg"
16407
+ ])
16408
+ });
16351
16409
  /**
16352
- * Spatial filter for `listTracks` — the rect + polygon variants of the shared
16353
- * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
16354
- * of the camera frame (top-left origin), matching the drawing-plane editor.
16410
+ * Process-local frame identity. It is serializable so it can ride an in-process
16411
+ * capability call, but `registryId` deliberately prevents resolution in any
16412
+ * other process or execution group.
16355
16413
  */
16356
- var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
16357
- /** Closed icon vocabulary so clients render a known glyph per kind. */
16358
- var EventKindIconSchema = _enum([
16359
- "motion",
16360
- "audio",
16361
- "person",
16362
- "vehicle",
16363
- "animal",
16364
- "door",
16365
- "pir",
16366
- "smoke",
16367
- "water",
16368
- "button",
16369
- "package",
16370
- "generic"
16414
+ var FrameRefSchema = object({
16415
+ registryId: string().min(1),
16416
+ id: string().min(1),
16417
+ width: number$1().int().positive(),
16418
+ height: number$1().int().positive(),
16419
+ format: _enum(["rgb", "gray"]),
16420
+ timestamp: number$1(),
16421
+ capturedAt: number$1().optional()
16422
+ });
16423
+ var ModelFormatSchema$1 = _enum([
16424
+ "onnx",
16425
+ "coreml",
16426
+ "openvino",
16427
+ "tflite",
16428
+ "pt",
16429
+ "gguf"
16371
16430
  ]);
16372
- var EventKindCategorySchema = _enum([
16373
- "motion",
16374
- "audio",
16375
- "detection",
16376
- "sensor",
16377
- "control",
16378
- "custom",
16379
- "package"
16431
+ var PipelineSlotSchema = _enum([
16432
+ "detector",
16433
+ "cropper",
16434
+ "classifier",
16435
+ "refiner",
16436
+ "audio-classifier"
16380
16437
  ]);
16381
- /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
16382
- var EventKindLevelSchema = _enum(["macro", "sub"]);
16383
- var EventKindDescriptorSchema = object({
16384
- /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
16385
- kind: string(),
16386
- /** i18n key resolved on the UI side; `label` is the English fallback. */
16387
- labelKey: string(),
16388
- /** English fallback label (kept for clients that don't translate). */
16389
- label: string(),
16390
- /** Hex color for timeline/legend rendering. */
16391
- color: string(),
16392
- /** Dictionary id → lucide component on the UI side. */
16393
- iconId: string(),
16394
- /** Legacy closed-vocab glyph — fallback for `iconId`. */
16395
- icon: EventKindIconSchema,
16396
- category: EventKindCategorySchema,
16397
- /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
16398
- parentKind: string().nullable(),
16399
- /** Derived from `parentKind`, explicit for the client tree. */
16400
- level: EventKindLevelSchema,
16401
- /** Which cap + device contributes this kind. For built-ins the camera
16402
- * itself; for sensor kinds the LINKED source device. */
16403
- source: object({
16404
- capName: string(),
16405
- deviceId: number$1()
16406
- })
16438
+ var PipelineEngineChoiceSchema = object({
16439
+ runtime: _enum(["node", "python"]),
16440
+ backend: string(),
16441
+ format: ModelFormatSchema$1,
16442
+ device: string().optional()
16407
16443
  });
16408
- /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
16409
- var EventKindsForDeviceSchema = object({
16410
- deviceId: number$1(),
16411
- kinds: array(EventKindDescriptorSchema).readonly()
16444
+ var AvailableEngineSchema = object({
16445
+ engine: PipelineEngineChoiceSchema,
16446
+ devices: array(object({
16447
+ id: string(),
16448
+ label: string(),
16449
+ description: string().optional()
16450
+ })).readonly(),
16451
+ defaultDevice: string()
16412
16452
  });
16413
- var SensorEventSchema = object({
16453
+ var PipelineDefaultStepSchema = lazy(() => object({
16454
+ addonId: string(),
16455
+ addonName: string(),
16456
+ slot: PipelineSlotSchema,
16457
+ inputClasses: array(string()).readonly(),
16458
+ outputClasses: array(string()).readonly(),
16459
+ enabled: boolean(),
16460
+ modelId: string(),
16461
+ children: array(PipelineDefaultStepSchema).readonly(),
16462
+ group: string().optional(),
16463
+ settings: record(string(), unknown()).optional()
16464
+ }));
16465
+ var PipelineTemplateStepSchema = lazy(() => object({
16466
+ addonId: string(),
16467
+ enabled: boolean(),
16468
+ modelId: string(),
16469
+ children: array(PipelineTemplateStepSchema).readonly(),
16470
+ settings: record(string(), unknown()).optional()
16471
+ }));
16472
+ var PipelineTemplateSchema$1 = object({
16414
16473
  id: string(),
16415
- /** The CAMERA the event is attributed to (a sensor linked to N cameras
16416
- * yields N rows, one per camera). */
16417
- deviceId: number$1(),
16418
- /** The linked sensor device whose state changed. */
16419
- sourceDeviceId: number$1(),
16420
- /** Event kind id — matches an `EventKindDescriptor.kind`. */
16421
- kind: string(),
16422
- /** Snapshot of the sensor cap's runtime-state slice at the change. */
16423
- value: record(string(), unknown()).nullable(),
16424
- timestamp: number$1()
16474
+ name: string(),
16475
+ createdAt: string(),
16476
+ updatedAt: string(),
16477
+ engine: PipelineEngineChoiceSchema,
16478
+ steps: array(PipelineTemplateStepSchema).readonly()
16425
16479
  });
16426
- var TrackPositionSchema = object({
16427
- x: number$1(),
16428
- y: number$1(),
16429
- timestamp: number$1(),
16430
- bbox: BoundingBoxSchema
16431
- });
16432
- var TrackSnapshotSchema = object({
16433
- timestamp: number$1(),
16434
- position: TrackPositionSchema,
16435
- /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
16436
- mediaKey: string()
16480
+ var PipelineModelOptionSchema = object({
16481
+ id: string(),
16482
+ name: string(),
16483
+ formats: record(string(), object({
16484
+ downloaded: boolean(),
16485
+ sizeMB: number$1()
16486
+ })),
16487
+ group: ModelVariantGroupSchema.optional(),
16488
+ legacy: boolean().optional(),
16489
+ provider: ModelProviderIdSchema.optional()
16437
16490
  });
16438
- /**
16439
- * Normalized 0..1 trajectory envelope (min/max over every position bbox,
16440
- * divided by the track's detection-frame dims), computed at persist time.
16441
- * Absent when the frame dims were unknown when the track was persisted
16442
- * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
16443
- */
16444
- var TrackEnvelopeSchema = object({
16445
- minX: number$1(),
16446
- minY: number$1(),
16447
- maxX: number$1(),
16448
- maxY: number$1()
16491
+ var ConfigFieldBridge = custom();
16492
+ var PipelineAddonSchemaSchema = object({
16493
+ id: string(),
16494
+ name: string(),
16495
+ slot: PipelineSlotSchema,
16496
+ inputClasses: array(string()).readonly(),
16497
+ outputClasses: array(string()).readonly(),
16498
+ childSlots: array(PipelineSlotSchema).readonly(),
16499
+ models: array(PipelineModelOptionSchema).readonly(),
16500
+ defaultModelId: string(),
16501
+ defaultModelIdByFormat: record(string(), string()).optional(),
16502
+ enabledByDefault: boolean().optional(),
16503
+ backfillIntoExistingOverrides: boolean().optional(),
16504
+ defaultConfidence: number$1(),
16505
+ group: string().optional(),
16506
+ configSchema: array(ConfigFieldBridge).readonly().optional()
16449
16507
  });
16450
- /**
16451
- * Row projection for track list queries. `full` (default) returns the
16452
- * complete Track including the frame-rate `positions[]` history and the
16453
- * `snapshots[]` references — megabytes across a page of tracks. `slim`
16454
- * keeps every scalar the list surfaces actually render (ids, class(es),
16455
- * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
16456
- * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
16457
- * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
16458
- * `getTrack`. Mirrors the event-store `projection` convention
16459
- * (`getObjectEvents` et al.).
16460
- */
16461
- var TrackProjectionSchema = _enum(["full", "slim"]);
16462
- /**
16463
- * One audio-classification label heard on the track's camera while the
16464
- * track was alive, aggregated per label. An "episode" is one persisted
16465
- * audio event (the confident-classification path: score ≥ the device's
16466
- * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
16467
- * one 32 ms inference chunk, so counts stay human-scaled.
16468
- */
16469
- var TrackAudioLabelSchema = object({
16508
+ var PipelineSlotSchemaSchema = object({
16509
+ id: PipelineSlotSchema,
16470
16510
  label: string(),
16471
- /** Highest classification score observed across the label's episodes. */
16472
- peakScore: number$1(),
16473
- /** Number of coalesced audio-event episodes carrying this label. */
16474
- count: number$1(),
16475
- firstAt: number$1(),
16476
- lastAt: number$1()
16511
+ priority: number$1(),
16512
+ parentSlot: PipelineSlotSchema.nullable(),
16513
+ addons: array(PipelineAddonSchemaSchema).readonly()
16477
16514
  });
16478
- /**
16479
- * How a track was produced. `pipeline` (default / absent) = the spatial
16480
- * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
16481
- * no positions, a single snapshot, and no bbox trajectory at all:
16482
- *
16483
- * - `sensor` — a linked sensor/control device state change.
16484
- * - `audio` — an audio event on the camera itself that was anomalous for
16485
- * THAT camera, loud, and heard while nothing visual was happening (D62).
16486
- *
16487
- * The spatial subsystems (tracker association, occupancy count, re-id /
16488
- * embedding, resurrection) MUST skip every synthetic source. Test for that
16489
- * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
16490
- * check silently readmits every source added after it was written.
16491
- */
16492
- var TrackSourceSchema = _enum([
16493
- "pipeline",
16494
- "sensor",
16495
- "audio"
16496
- ]);
16497
- /**
16498
- * Where a track sits in the RETRAIN lifecycle (D81).
16499
- *
16500
- * - `none` — never marked, or un-marked. Evictable.
16501
- * - `staging` — the operator wants this track as training material and has not
16502
- * finished with it. **This is the only state retention holds**: the track and
16503
- * everything it owns (object events, crops, keyframes, CLIP vector) survive
16504
- * the device's age window.
16505
- * - `trained` — the retrain page has taken what it needed. The frames it chose
16506
- * were COPIED into the retrain dataset at selection time, so the dataset no
16507
- * longer depends on the track's media and the track becomes EVICTABLE again.
16508
- * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
16509
- * a deliberate action of the retrain page, not a side effect of a checkbox.
16510
- *
16511
- * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
16512
- * the store's filter language has only positive equality and `whereIn` — no
16513
- * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
16514
- * would make the entire pre-column history immortal in one deploy.
16515
- */
16516
- var RetrainStatusSchema = _enum([
16517
- "none",
16518
- "staging",
16519
- "trained"
16520
- ]);
16521
- /**
16522
- * Per-track OPERATOR flags — set by hand from the admin UI or the viewer, never
16523
- * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
16524
- * so the two surfaces cannot drift.
16525
- *
16526
- * **Absent ≠ false.** A track that has never been touched omits the field; an
16527
- * explicitly un-flagged track carries `false`. Legacy rows written before the
16528
- * columns existed read as absent, and a consumer that needs a boolean should say
16529
- * `flag === true`, not `flag !== false`.
16530
- *
16531
- * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
16532
- * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
16533
- * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
16534
- * `trained` track reports `false` while refusing both writes. The boolean is
16535
- * kept because three surfaces drive a toggle off it; anything that needs to tell
16536
- * "never marked" from "already trained" must read `retrainStatus`.
16537
- *
16538
- * `debug` does NOT pin; it is attention, not durability.
16539
- *
16540
- * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
16541
- * A favourited track is skipped by retention the same way `staging` is, but
16542
- * it does not enter `none|staging|trained` and has no staging budget.
16543
- */
16544
- var TrackFlagFields = {
16545
- /** Operator marked this track as training material — i.e. `retrainStatus` is
16546
- * `'staging'`. */
16547
- markForTrain: boolean().optional(),
16548
- /** Operator marked this track for diagnostic attention. */
16549
- debug: boolean().optional(),
16550
- /** Operator favourited this track. Pins it against pruning. */
16551
- favourited: boolean().optional()
16552
- };
16553
- /**
16554
- * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
16555
- * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
16556
- * write patch, and the status is not something the toggle sets — it is what the
16557
- * toggle's boolean is derived from. Absent on an in-RAM track never touched;
16558
- * always present on a persisted row (the column default materialises `'none'`).
16559
- */
16560
- var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
16561
- /**
16562
- * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
16563
- * one flag can never clear the other — the toggles are independent and are
16564
- * driven from three surfaces that do not know about each other.
16565
- */
16566
- var TrackFlagsPatchSchema = object(TrackFlagFields);
16567
- /**
16568
- * The resolved flag state after a write. Both fields are REQUIRED here (absent
16569
- * collapses to `false`) so a caller can drive a toggle's checked state off the
16570
- * mutation result without a re-fetch.
16571
- */
16572
- var TrackFlagsSchema = object({
16573
- trackId: string(),
16574
- markForTrain: boolean(),
16575
- debug: boolean(),
16576
- favourited: boolean(),
16577
- /** The lifecycle state the boolean was derived from. Required here (unlike on
16578
- * a track row) because this shape is only ever produced by the write body,
16579
- * which always knows it — and a surface that has just written needs to render
16580
- * `trained` without a re-fetch. */
16581
- retrainStatus: RetrainStatusSchema
16515
+ var PipelineSchemaSchema = object({
16516
+ availableEngines: array(AvailableEngineSchema).readonly(),
16517
+ selectedEngine: PipelineEngineChoiceSchema,
16518
+ slots: array(PipelineSlotSchemaSchema).readonly()
16582
16519
  });
16583
- union([literal(1), literal(2)]);
16584
- /**
16585
- * WHO decided a label, and when. Carried per tier so a value can be traced to
16586
- * the step and model that produced it — which is what makes the write rule
16587
- * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
16588
- * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
16589
- *
16590
- * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
16591
- * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
16592
- * `migration:4g` for a value the 4g migration moved from the single-slot era —
16593
- * that value has no provenance, and the write rule lets ANY properly-attributed
16594
- * write of the same tier replace it regardless of score.
16595
- */
16596
- var LabelAttributionSchema = object({
16597
- stepId: string(),
16598
- modelId: string().optional(),
16599
- decidedAt: number$1(),
16520
+ var EngineProvisioningSchema = object({
16521
+ runtimeId: _enum([
16522
+ "onnx",
16523
+ "openvino",
16524
+ "coreml",
16525
+ "edgetpu"
16526
+ ]).nullable(),
16527
+ device: string().nullable(),
16528
+ state: _enum([
16529
+ "idle",
16530
+ "installing",
16531
+ "verifying",
16532
+ "ready",
16533
+ "failed"
16534
+ ]),
16535
+ progress: number$1().optional(),
16536
+ error: string().optional(),
16537
+ nextRetryAt: number$1().optional(),
16600
16538
  /**
16601
- * The GALLERY id behind a recognised tier-2 label — a face-gallery
16602
- * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
16603
- *
16604
- * The text alone is a DISPLAY NAME, and a display name is renameable: a
16605
- * notification rule authored on "Gianluca" stopped matching the moment the
16606
- * operator fixed the spelling in the gallery, and nothing said so. The id is
16607
- * the thing that does not move, so it is what a rule matches on
16608
- * (`NcConditions.identities`) and the text is what a human is shown.
16609
- *
16610
- * Absent when the label names no gallery row — a plate the OCR read but no
16611
- * vehicle claims, a sub-class, a species, any tier-1 value.
16539
+ * Gate A (config-correctness gate at engine change): human-readable
16540
+ * config issues surfaced EAGERLY when the node's engine changes — model
16541
+ * substitutions ("chose X, running Y") and zero-build steps ("no model
16542
+ * has a <format> build"). Additive/optional: informational only, never
16543
+ * enforced here — `assertEngineReady` (readiness) still gates inference.
16544
+ * Absent/empty when the node-default tree resolves cleanly.
16612
16545
  */
16613
- identityId: string().optional()
16546
+ configIssues: array(string()).optional()
16614
16547
  });
16615
- /**
16616
- * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
16617
- * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
16618
- * track and its events always answer the same question the same way.
16619
- *
16620
- * Two scalar columns, not an array: every consumer wants "the coarse one" or
16621
- * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
16622
- * is tier 2, and each carries its own score + attribution.
16623
- *
16624
- * **Reading it.** What a human should be shown is `subLabel ?? label` — the
16625
- * finest thing known. Before 4g the single `label` column held the finest
16626
- * value, so a consumer that has not been updated reads the tier-1 slot and
16627
- * shows nothing on a species-only row; that is why the migration puts every
16628
- * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
16629
- * and why the read surfaces were changed in the same train.
16630
- *
16631
- * **Writing it.** The slots are independent, which is the whole point: a
16632
- * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
16633
- * migratorius`), so fineness cannot regress by construction. Within a tier the
16634
- * higher score wins. One rule, one implementation — see
16635
- * `pipeline/label-tier.ts` in addon-post-analysis.
16636
- */
16637
- var TieredLabelFields = {
16638
- /** Tier 1 — the sub-class. See {@link LabelTierSchema}. */
16639
- label: string().optional(),
16640
- /** Confidence of the tier-1 value, as reported by the deciding step. */
16641
- labelScore: number$1().optional(),
16642
- /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
16643
- labelMeta: LabelAttributionSchema.optional(),
16644
- /** Tier 2 — the instance. See {@link LabelTierSchema}. */
16645
- subLabel: string().optional(),
16646
- /** Confidence of the tier-2 value, as reported by the deciding step. */
16647
- subLabelScore: number$1().optional(),
16648
- /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
16649
- subLabelMeta: LabelAttributionSchema.optional()
16650
- };
16651
- /** Per-camera slice of a training-export estimate. */
16652
- var TrainingExportDeviceTotalsSchema = object({
16653
- deviceId: number$1(),
16654
- tracks: number$1().int(),
16655
- files: number$1().int(),
16656
- bytes: number$1().int()
16548
+ var PipelineStepInputSchema = lazy(() => object({
16549
+ addonId: string(),
16550
+ modelId: string().optional(),
16551
+ enabled: boolean().default(true),
16552
+ children: array(PipelineStepInputSchema).optional(),
16553
+ settings: record(string(), unknown()).optional(),
16554
+ jumpDeviceKey: string().optional()
16555
+ }));
16556
+ var ModelSubstitutionSchema = object({
16557
+ addonId: string(),
16558
+ chosen: string(),
16559
+ running: string(),
16560
+ format: string()
16561
+ });
16562
+ var PipelineValidationIssueSchema = object({
16563
+ addonId: string(),
16564
+ kind: _enum(["unknown-addon", "no-format-build"]),
16565
+ detail: string()
16566
+ });
16567
+ var PipelineValidationResultSchema = object({
16568
+ ok: boolean(),
16569
+ issues: array(PipelineValidationIssueSchema).readonly(),
16570
+ substitutions: array(ModelSubstitutionSchema).readonly(),
16571
+ /** The node's `currentEngine.format` this validation ran against. */
16572
+ format: string()
16573
+ });
16574
+ var ReferenceImageEntrySchema = object({
16575
+ filename: string(),
16576
+ stepIds: array(string()).readonly().optional()
16577
+ });
16578
+ var ReferenceImageBodySchema = object({
16579
+ base64: string(),
16580
+ filename: string()
16581
+ });
16582
+ var ReferenceAudioEntrySchema = object({
16583
+ filename: string(),
16584
+ sizeKb: number$1()
16585
+ });
16586
+ var ReferenceAudioBodySchema = object({ base64: string() });
16587
+ var AudioBackendSchema = object({
16588
+ id: string(),
16589
+ name: string(),
16590
+ description: string(),
16591
+ available: boolean(),
16592
+ /**
16593
+ * Raw classifier labels this backend can emit (e.g. YAMNet's
16594
+ * 521-class set or Apple SoundAnalysis's 303-class set). Used by
16595
+ * the benchmark UI to populate the `enabledMicroClasses` filter
16596
+ * specific to the selected backend without a separate fetch.
16597
+ */
16598
+ rawLabels: array(string()).readonly().optional()
16599
+ });
16600
+ var AudioCapabilitiesSchema = object({
16601
+ activeBackend: string(),
16602
+ availableBackends: array(AudioBackendSchema).readonly(),
16603
+ sampleRate: number$1(),
16604
+ chunkDurationMs: number$1()
16605
+ });
16606
+ var DownloadModelResultSchema = object({
16607
+ filePath: string(),
16608
+ sizeMB: number$1(),
16609
+ durationMs: number$1()
16657
16610
  });
16658
16611
  /**
16659
- * What a training export WOULD contain. Computed from media index rows only —
16660
- * no blob is read to produce this.
16612
+ * Wrapper carrying a single test run's result. Replaces the legacy
16613
+ * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
16614
+ * canonical `AudioResult` from the Phase 6 output rework: one
16615
+ * `AudioDetection` per class above `minScore`, top-N candidates in
16616
+ * `debug.alternateLabels['audio-classifier']`, per-source timings in
16617
+ * `debug.stepTimings`. The outer `success`/`error` fields stay so the
16618
+ * benchmark UI can still report a clean failure when the classifier
16619
+ * cap isn't available.
16661
16620
  */
16662
- var TrainingExportSummarySchema = object({
16663
- generatedAt: number$1(),
16664
- trackCount: number$1().int(),
16665
- fileCount: number$1().int(),
16666
- byteCount: number$1().int(),
16667
- /** More marked tracks exist than a single pass carries. */
16668
- truncated: boolean(),
16669
- devices: array(TrainingExportDeviceTotalsSchema).readonly()
16621
+ var AudioTestResultSchema = object({
16622
+ success: boolean(),
16623
+ error: string().optional(),
16624
+ frame: custom().optional()
16670
16625
  });
16671
- var TrackSchema = object({
16672
- trackId: string(),
16673
- deviceId: number$1(),
16674
- className: string(),
16675
- ...TieredLabelFields,
16676
- producingDeviceName: string().optional(),
16677
- /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
16678
- source: TrackSourceSchema.optional(),
16679
- firstSeen: number$1(),
16680
- lastSeen: number$1(),
16681
- /** Frame-rate position history (subject to maxPositionHistory cap). */
16682
- positions: array(TrackPositionSchema).readonly(),
16683
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
16684
- * saveThumbnails policy). */
16685
- snapshots: array(TrackSnapshotSchema).readonly(),
16686
- /** Deduplicated zones the track has entered at least once. Zone IDS. */
16687
- zonesVisited: array(string()).readonly(),
16626
+ var PipelineConfigBridge = custom();
16627
+ var ConfigUISchemaBridge = custom();
16628
+ var ConfigUISchemaNullableBridge = custom();
16629
+ var InferenceCapabilitiesBridge = custom();
16630
+ var ModelAvailabilityListBridge = custom();
16631
+ var PipelineRunResultBridge = custom();
16632
+ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
16633
+ modelId: string(),
16634
+ settings: record(string(), unknown()).readonly()
16635
+ }))), method(object({ steps: record(string(), object({
16636
+ modelId: string(),
16637
+ settings: record(string(), unknown()).readonly()
16638
+ })) }), object({ success: literal(true) }), {
16639
+ kind: "mutation",
16640
+ auth: "admin"
16641
+ }), method(object({ nodeId: string() }), object({
16642
+ success: literal(true),
16643
+ clearedDevices: number$1()
16644
+ }), {
16645
+ kind: "mutation",
16646
+ auth: "admin"
16647
+ }), method(object({ nodeId: string() }), object({ unhealthy: array(object({
16648
+ /** `<backend>:<device>`, e.g. `openvino:gpu`. */
16649
+ deviceKey: string(),
16688
16650
  /**
16689
- * Human NAMES for {@link zonesVisited}, resolved at READ time against the
16690
- * `zones` capability.
16691
- *
16692
- * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
16693
- * and no card can render — so every free-text search surface was structurally
16694
- * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
16695
- * just returned nothing. Resolving here rather than in each client keeps ONE
16696
- * derivation and costs the clients no extra call (the `zones` cap is
16697
- * per-device, so a client-side resolve would be a per-camera fan-out on a
16698
- * surface built to avoid exactly that).
16699
- *
16700
- * Resolved, never invented: a zone deleted since the track was written has no
16701
- * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
16702
- * two are not positionally aligned. Absent when the track visited no zone, or
16703
- * when the zone catalogue could not be read.
16651
+ * `failed` — the per-device restart budget is exhausted; no pool
16652
+ * will be spawned until an operator re-arms it or the runner
16653
+ * respawns. `backoff` — under budget, waiting out the backoff (or
16654
+ * a cached pool observed dead and not yet condemned).
16704
16655
  */
16705
- zoneNames: array(string()).readonly().optional(),
16706
- /** Deduplicated set of detector classes observed for this track over its
16707
- * life (a track may be reclassified, e.g. person→vehicle). Absent on
16708
- * legacy rows written before class accumulation shipped. */
16709
- classes: array(string()).readonly().optional(),
16710
- /** Cumulative normalized distance travelled (0..1 units = full frame width). */
16711
- totalDistance: number$1(),
16712
- state: TrackStateSchema,
16713
- active: boolean(),
16714
- /** Deterministic key-event importance score in [0,1] (server-computed at
16715
- * track expiry, recomputed on late label). Absent on legacy rows written
16716
- * before scoring shipped — consumers degrade to absence / compute-on-read. */
16717
- importance: number$1().optional(),
16718
- /** Id of the track's highest-confidence ObjectEvent (its representative
16719
- * "best" frame). Absent when the track produced no object events. */
16720
- bestEventId: string().optional(),
16721
- /** Tag of the importance sub-signal that dominated the score
16722
- * (identity|dwell|proximity|class|confidence|travel|zone). */
16723
- importanceReason: string().optional(),
16724
- /** Audio-classification labels heard on the camera during the track's
16725
- * life (score ≥ device `classificationMinScore`), aggregated per label.
16726
- * Absent on legacy rows / tracks with no confident audio. */
16727
- audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
16728
- /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
16729
- * Populated from the persisted envelope columns on historical reads;
16730
- * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
16731
- envelope: TrackEnvelopeSchema.optional(),
16656
+ state: _enum(["failed", "backoff"]),
16657
+ /** Epoch ms of the death that produced this state. */
16658
+ since: number$1(),
16659
+ /** Pool deaths inside the current window. */
16660
+ deaths: number$1(),
16661
+ /** The last death's message. */
16662
+ lastError: string()
16663
+ })).readonly() })), method(object({
16664
+ nodeId: string(),
16665
+ deviceKey: string()
16666
+ }), object({ rearmed: boolean() }), {
16667
+ kind: "mutation",
16668
+ auth: "admin"
16669
+ }), 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({
16670
+ name: string(),
16671
+ steps: array(PipelineTemplateStepSchema).readonly(),
16672
+ engine: PipelineEngineChoiceSchema
16673
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
16674
+ id: string(),
16675
+ name: string().optional(),
16676
+ steps: array(PipelineTemplateStepSchema).readonly().optional()
16677
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
16678
+ addonId: string(),
16679
+ modelId: string(),
16680
+ format: ModelFormatSchema$1
16681
+ }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
16682
+ addonId: string(),
16683
+ modelId: string(),
16684
+ format: ModelFormatSchema$1
16685
+ }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
16686
+ engine: PipelineEngineChoiceSchema.optional(),
16687
+ steps: array(PipelineStepInputSchema).min(1),
16688
+ frame: FrameInputSchema.optional(),
16732
16689
  /**
16733
- * A face DETECTOR found a face on this track — nothing more. It says the
16734
- * detail plane produced a `face` detail; it does NOT say the face was
16735
- * embedded, matched, above `minFacePx`, or that the recognizer was even
16736
- * enabled. Set once and never cleared.
16737
- *
16738
- * **This exists so "face present but not recognised" is expressible.** A
16739
- * recognised identity lands in `subLabel` (attributed to the face chain via
16740
- * `subLabelMeta.stepId`), so before this field a track with an unmatched face
16741
- * and a track with no face at all were byte-identical on the wire and no
16742
- * surface could tell them apart. The read is `hasFace === true && subLabel
16743
- * === undefined`.
16744
- *
16745
- * **Absent ≠ false.** Every row written before the column existed omits it,
16746
- * and so does every server that predates the field — a consumer must test
16747
- * `=== true` and render nothing otherwise, never infer "no face".
16690
+ * Process-local lazy frame. Valid only when caller and provider resolve
16691
+ * in the same execution-group process; split/cross-node callers use
16692
+ * `frame`/`image` inline compatibility instead.
16748
16693
  */
16749
- hasFace: boolean().optional(),
16694
+ frameRef: FrameRefSchema.optional(),
16750
16695
  /**
16751
- * This track has a face row IN THE GALLERY: a crop **and** an embedding — a
16752
- * face an operator could ASSIGN to an identity.
16753
- *
16754
- * The STRICT twin of {@link hasFace}, and the pair only earns its keep
16755
- * because the two disagree. `hasFace` is stamped at the TOP of the face
16756
- * branch, before every gate, and means no more than "a face detector produced
16757
- * a face detail". This one is stamped at the single moment the gallery row
16758
- * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
16759
- * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
16760
- * candidate gate, the imageless-track drop (no crop was ever captured) and
16761
- * the crop-store drop. Everything between the detector and that insert can
16762
- * legitimately refuse the face, so a flag written any earlier promises the
16763
- * operator something to assign and delivers nothing.
16764
- *
16765
- * **Independent of recognition.** A face collected but never auto-matched is
16766
- * still assignable — it is in fact the face an operator most wants to reach —
16767
- * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
16768
- * `subLabel`; this says only that the raw material exists.
16769
- *
16770
- * **Set once, never cleared.** A track that produced a gallery row produced
16771
- * one; deleting the row later is the gallery's business, not this flag's.
16772
- *
16773
- * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
16774
- * before the column omits it, and so does every server that predates the
16775
- * field. A consumer must test `=== true` and render nothing otherwise —
16776
- * never infer "no assignable face".
16696
+ * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
16697
+ * the decoded pixels live in. One more member of the one-of
16698
+ * frame/frameHandle/image/imageBase64/referenceImage group.
16777
16699
  */
16778
- hasEmbeddedFace: boolean().optional(),
16700
+ frameHandle: FrameHandleSchema.optional(),
16701
+ imageBase64: string().optional(),
16779
16702
  /**
16780
- * This subject CONTAINS a folded rider — a person the rider-pairing step
16781
- * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
16782
- * so the passage is tracked once and as a VEHICLE.
16783
- *
16784
- * It exists because the fold's record was dishonest. D34 and the code both
16785
- * said "the person is not lost — it is reported so both entities stay on the
16786
- * record"; in fact the pair went into a per-processor RAM field behind an
16787
- * accessor nobody called, and every durable surface said `vehicle`, full
16788
- * stop. This is the composition note that makes the row true.
16789
- *
16790
- * A COMPOSITION, never a class and never a label. "This vehicle contains a
16791
- * person" is not an answer to "what is this" — both label tiers would refuse
16792
- * a macro token anyway (D89), and correctly. Nothing here changes what the
16793
- * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
16794
- * and a `person` rule still does not fire for someone cycling past.
16795
- *
16796
- * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
16797
- * the column, and every hub that predates the field, omits it. Test
16798
- * `=== true` and render nothing otherwise — never infer "no rider".
16703
+ * Binary JPEG bytes — preferred over `imageBase64` on internal
16704
+ * hops (hub → forked worker via Moleculer MsgPack) because it
16705
+ * skips the 33% base64 overhead + the per-call base64 decode on
16706
+ * the detection-pipeline worker. Callers can pass either; exactly
16707
+ * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
16799
16708
  */
16800
- hasRider: boolean().optional(),
16801
- ...TrackFlagFields,
16802
- ...TrackRetrainFields
16803
- });
16804
- var BaseEventFields = {
16805
- id: string(),
16806
- deviceId: number$1(),
16807
- timestamp: number$1()
16808
- };
16809
- var MotionEventSchema = object({
16810
- ...BaseEventFields,
16811
- kind: literal("motion"),
16812
- regionCount: number$1(),
16813
- /** Heavy JSON array — omitted in slim projection. */
16814
- regions: array(object({
16815
- bbox: BoundingBoxSchema,
16816
- pixelCount: number$1(),
16817
- intensity: number$1()
16818
- })).readonly().optional(),
16819
- /** Omitted in slim projection. */
16820
- frameWidth: number$1().optional(),
16821
- /** Omitted in slim projection. */
16822
- frameHeight: number$1().optional(),
16823
- /** Populated by B5 (recording playback URL for this event). */
16824
- mediaUrl: string().optional()
16825
- });
16709
+ image: _instanceof(Uint8Array).optional(),
16710
+ referenceImage: string().optional(),
16711
+ deviceId: number$1().optional(),
16712
+ sessionId: string().optional(),
16713
+ /**
16714
+ * Execution plane. 'full' (default) runs the whole tree — benchmark,
16715
+ * reference-image, and detail-subtree calls. 'frame' is the live
16716
+ * per-frame dispatch: ONLY root-plane steps run; crop children
16717
+ * (inputClasses ≠ null) are skipped and served per-track via
16718
+ * pipelineRunner.runDetailSubtree (two-plane design).
16719
+ */
16720
+ plane: _enum(["full", "frame"]).optional(),
16721
+ /**
16722
+ * Inference-device selector (Phase 2 multi-device). Format
16723
+ * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
16724
+ * Omitted ⇒ the runner's default device (current single-engine
16725
+ * behaviour). Selects WHICH device pool of the node runs the call.
16726
+ */
16727
+ deviceKey: string().optional(),
16728
+ /**
16729
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
16730
+ * when the parent crop was resolved from the frame's retained NATIVE
16731
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
16732
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
16733
+ * resolution from that surface — the SAME quality path faces already
16734
+ * had — instead of the downscaled parent tile. `handle` keys the native
16735
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
16736
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
16737
+ * the executor's crop-normalized child ROI back into frame-normalized
16738
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
16739
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
16740
+ * (today's behaviour on the fallback path).
16741
+ */
16742
+ nativeCropRef: NativeCropRefSchema.optional()
16743
+ }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
16744
+ engine: PipelineEngineChoiceSchema.optional(),
16745
+ steps: array(PipelineStepInputSchema).min(1),
16746
+ frames: array(FrameInputSchema).min(1).max(255),
16747
+ deviceId: number$1().optional(),
16748
+ sessionId: string().optional(),
16749
+ /**
16750
+ * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
16751
+ * the batch to the Python pool's bench preprocess cache
16752
+ * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
16753
+ * preprocessed ONCE and every later inference is a pure-inference cache
16754
+ * hit — the sustained-throughput run measures inference, not
16755
+ * decode+preprocess+infer. Omitted/0 for live frames (all different →
16756
+ * full preprocess every call, correct). Fresh per sustained run;
16757
+ * released via `uncacheFrame`.
16758
+ */
16759
+ frameId: number$1().int().nonnegative().optional(),
16760
+ /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
16761
+ deviceKey: string().optional()
16762
+ }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
16763
+ data: _instanceof(Uint8Array),
16764
+ width: number$1().int().positive(),
16765
+ height: number$1().int().positive(),
16766
+ format: _enum([
16767
+ "rgb",
16768
+ "bgr",
16769
+ "gray"
16770
+ ])
16771
+ }), object({
16772
+ frameId: number$1(),
16773
+ width: number$1(),
16774
+ height: number$1()
16775
+ }), { kind: "mutation" }), method(object({
16776
+ stepId: string(),
16777
+ frameId: number$1().int()
16778
+ }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number$1().int() }), _void(), { kind: "mutation" }), method(_void(), object({
16779
+ batchMode: string(),
16780
+ windowMs: number$1(),
16781
+ maxBatchSize: number$1(),
16782
+ concurrency: number$1()
16783
+ })), method(_void(), array(object({
16784
+ engineKey: string(),
16785
+ engine: PipelineEngineChoiceSchema,
16786
+ modelsLoaded: array(string()).readonly(),
16787
+ inUseByCameras: array(number$1()).readonly(),
16788
+ /**
16789
+ * Origin of this resident factory.
16790
+ * - `runtime` — main camera-serving engine (no idle TTL).
16791
+ * - `warm-override` — benchmark/test override held in the warm
16792
+ * cache; auto-disposed after the idle TTL.
16793
+ * - `device-pool` — a concurrent per-device pool (Phase 2
16794
+ * multi-device, keyed by `deviceKey`) resolved
16795
+ * via `resolveDeviceFactory`. Runs alongside the
16796
+ * `runtime` engine on a DIFFERENT accelerator
16797
+ * (NPU / iGPU / Coral) — this is how the
16798
+ * Engines tab shows all pools running at once.
16799
+ */
16800
+ kind: _enum([
16801
+ "runtime",
16802
+ "warm-override",
16803
+ "device-pool"
16804
+ ]),
16805
+ /** Native pid of the underlying Python pool (null when no pool). */
16806
+ poolPid: number$1().nullable(),
16807
+ /** ms since this factory was last used (null when not warm-tracked). */
16808
+ idleMs: number$1().nullable(),
16809
+ /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
16810
+ idleTtlMs: number$1().nullable()
16811
+ })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
16812
+ kind: "mutation",
16813
+ auth: "admin"
16814
+ }), method(object({
16815
+ engine: PipelineEngineChoiceSchema,
16816
+ force: boolean().optional()
16817
+ }), object({
16818
+ success: boolean(),
16819
+ reason: string().optional()
16820
+ }), {
16821
+ kind: "mutation",
16822
+ auth: "admin"
16823
+ }), 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({
16824
+ addonId: string(),
16825
+ modelId: string(),
16826
+ filename: string().optional(),
16827
+ settings: record(string(), unknown()).optional()
16828
+ }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
16826
16829
  /**
16827
- * Which detection SOURCE produced an object event. `pipeline` = the ML
16828
- * detection pipeline (decoded-frame inference); `onboard` = the camera's
16829
- * native on-device AI. Both flow through the SAME analysis layers (zoning,
16830
- * tracking, per-kind persistence) but stay distinguishable so consumers
16831
- * (advanced-notifier, occupancy, …) can select which source(s) to act on.
16832
- * Absent on legacy rows ⇒ treat as `pipeline`.
16830
+ * Per-stage gating mode applied to the zones a rule references.
16831
+ *
16832
+ * - `include`: the rule contributes to a **whitelist** for its stage.
16833
+ * When at least one `include` rule fires for a stage, only entities
16834
+ * inside one of those zones pass that stage.
16835
+ * - `exclude`: the rule contributes to a **blacklist** for its stage.
16836
+ * Entities inside one of those zones are dropped at that stage.
16837
+ *
16838
+ * `monitor`-style observation (count without filtering) is not a rule
16839
+ * mode — zones without any matching rule are observed naturally by
16840
+ * `zone-analytics` (live snapshot + history), so an "I just want to
16841
+ * count, not filter" use case needs no rule at all.
16833
16842
  */
16834
- var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
16843
+ var ZoneRuleModeEnum = _enum(["include", "exclude"]);
16835
16844
  /**
16836
- * The confirmed zone crossing that produced an object event. Present ONLY on
16837
- * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
16838
- * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
16839
- * appearance event carry none, so a rule asking for a direction fails closed
16840
- * on them.
16845
+ * Per-consumer rule that references existing zones (geometry) and
16846
+ * defines how a specific pipeline stage should treat them. Each
16847
+ * consumer addon owns its own `ZoneRule[]` array in its per-device
16848
+ * settings:
16841
16849
  *
16842
- * Exactly ONE crossing per event: the emitter turns each confirmed crossing
16843
- * into its own event, so a frame in which a track enters A while leaving B
16844
- * produces two events with two directions — never one ambiguous row.
16850
+ * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
16851
+ * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
16852
+ * - future: notification rules, audio gating, etc.
16845
16853
  *
16846
- * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
16847
- * membership the box has NOW, and by definition it no longer contains the zone
16848
- * that was just left. Without the id here, a zone-scoped rule could never match
16849
- * the exit it asked for.
16854
+ * One rule applies to N zones (`zoneIds[]`) so the operator can
16855
+ * express "ignore motion in ALL of {garden, street}" with a single
16856
+ * rule. `classFilter` narrows the rule to specific object classes —
16857
+ * "drop person detections in the street, but keep cars" is one
16858
+ * `exclude` rule with `classFilter: ['person']`.
16859
+ *
16860
+ * `enabled` is a soft toggle — the operator can keep the rule
16861
+ * configured but inert without deleting it.
16850
16862
  */
16851
- var ZoneCrossingSchema = object({
16852
- direction: _enum(["enter", "exit"]),
16853
- /** Admin zone id crossed. */
16854
- zoneId: string(),
16855
- /** Zone display name at crossing time (falls back to the id). */
16856
- zoneName: string().optional()
16857
- });
16858
- var ObjectEventSchema = object({
16859
- ...BaseEventFields,
16860
- kind: literal("object"),
16861
- /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
16862
- source: DetectionSourceSchema.optional(),
16863
+ var ZoneRuleSchema = object({
16864
+ /** Stable rule id — survives edits, used by the UI for diffing. */
16865
+ id: string(),
16866
+ /** Optional human-readable label rendered in the rule editor. */
16867
+ name: string().optional(),
16868
+ /** Zones this rule targets. The rule's `mode` applies to ALL
16869
+ * listed zones (OR-set: a detection in any one of them counts).
16870
+ * At least one zone id required — a rule with no targets is a
16871
+ * configuration mistake and the form validator rejects it. */
16872
+ zoneIds: array(string()).min(1).readonly(),
16873
+ mode: ZoneRuleModeEnum,
16863
16874
  /**
16864
- * Inference-frame id shared by every object event emitted from the SAME frame
16865
- * — the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
16866
- * 2 people + 1 dog) under one full frame, and link a track's frames over time
16867
- * (group by `trackId`, pick a representative `frameId` as the parent frame).
16868
- * Optional for backward-compat with pre-existing rows / the slim projection
16869
- * includes it (it is light). Absent on rows written before this field.
16875
+ * Class names this rule applies to. Empty / undefined ⇒ rule
16876
+ * applies to every class. Class strings match the `macroClass`
16877
+ * field on detections (e.g. `person`, `car`, `dog`).
16870
16878
  */
16871
- frameId: string().optional(),
16872
- /** Omitted in slim projection. */
16873
- trackId: string().optional(),
16874
- className: string(),
16875
- ...TieredLabelFields,
16876
- /** Omitted in slim projection. */
16877
- confidence: number$1().optional(),
16878
- /** Heavy JSON — omitted in slim projection. */
16879
- bbox: BoundingBoxSchema.optional(),
16880
- /** Heavy JSON — omitted in slim projection. */
16881
- zones: array(string()).readonly().optional(),
16882
- /** Omitted in slim projection. */
16883
- state: TrackStateSchema.optional(),
16879
+ classFilter: array(string()).readonly().optional(),
16884
16880
  /**
16885
- * The zone crossing this event IS, when it is one. Absent on every other
16886
- * event kind (movement state, appearance, package) — see
16887
- * {@link ZoneCrossingSchema}. Omitted in slim projection.
16881
+ * Minimum bbox/mask overlap (0–1) with any of the rule's zones
16882
+ * required to consider an entity "in the zone". Defaults to the
16883
+ * consumer's stage default when omitted. Kept for back-compat with
16884
+ * existing per-rule overrides; new operators pick the value via
16885
+ * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
16886
+ * set, the lower-level engine reads it as a 0–1 fraction.
16888
16887
  */
16889
- zoneCrossing: ZoneCrossingSchema.optional(),
16890
- /** Detection-frame dimensions in pixels — let consumers normalize the
16891
- * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
16892
- frameWidth: number$1().optional(),
16893
- frameHeight: number$1().optional(),
16894
- /** MediaStore key for the crop attached to this event (if any). */
16895
- mediaKey: string().optional(),
16896
- /** Design B: MediaStore key of the track's native-resolution key frame (the
16897
- * best-detection full frame). Resolve via the event-media data-plane
16898
- * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
16899
- * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
16900
- * sources — consumers fall back to `mediaKey` (the tight crop). */
16901
- keyFrameMediaKey: string().optional(),
16902
- /** Populated by B5 (recording playback URL for this event). */
16903
- mediaUrl: string().optional(),
16904
- /** The parent track's key-event importance [0,1], propagated to every object
16905
- * event of the track (so an event row can be sorted by importance without a
16906
- * track join). Absent on legacy rows / before the track was scored. */
16907
- importance: number$1().optional()
16908
- });
16909
- var AudioEventSchema = object({
16910
- ...BaseEventFields,
16911
- kind: literal("audio"),
16912
- rms: number$1(),
16913
- dbfs: number$1(),
16914
- classification: object({
16915
- className: string(),
16916
- originalClass: string().optional(),
16917
- score: number$1()
16918
- }).optional(),
16919
- /** Populated by B5 (recording playback URL for this event). */
16920
- mediaUrl: string().optional()
16921
- });
16922
- var MediaFileKindEnum = _enum([
16923
- "crop",
16924
- "thumbnail",
16925
- "snapshot",
16926
- "firstFrame",
16927
- "lastFrame",
16928
- "fullFrame",
16929
- "fullFrameBoxed",
16930
- "faceCrop",
16931
- "plateCrop",
16932
- "keyFrame",
16933
- "keyFrameSmall",
16934
- "thumbnailSmall"
16935
- ]);
16936
- var MediaFileSchema = object({
16937
- key: string(),
16938
- kind: MediaFileKindEnum,
16939
- base64: string(),
16940
- sizeBytes: number$1(),
16941
- timestamp: number$1()
16888
+ overlapThreshold: number$1().min(0).max(1).optional(),
16889
+ /**
16890
+ * Operator-friendly version of `overlapThreshold` — the percentage
16891
+ * of the detection's bbox that must lie inside the zone for the
16892
+ * rule to match. Documented default is 85%; the engine substitutes
16893
+ * that when the field is omitted (kept optional so existing rules
16894
+ * stored without it stay valid).
16895
+ *
16896
+ * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
16897
+ * rule, the engine prefers `bboxInclusionPct` because it's the
16898
+ * field exposed in the UI. Internally both feed the same gate.
16899
+ */
16900
+ bboxInclusionPct: number$1().min(0).max(100).optional(),
16901
+ /**
16902
+ * When `true` and a detection has a segmentation mask, use the
16903
+ * mask for overlap instead of the bbox. Detection-stage only;
16904
+ * motion rules ignore this field.
16905
+ */
16906
+ preferMask: boolean().optional(),
16907
+ /**
16908
+ * Soft-toggle: `false` disables the rule without deleting it.
16909
+ * Defaults to `true` so operators creating a rule via the UI
16910
+ * see it active immediately.
16911
+ */
16912
+ enabled: boolean().default(true)
16942
16913
  });
16914
+ array(ZoneRuleSchema).readonly();
16943
16915
  /**
16944
- * One media row WITHOUT its bytes.
16916
+ * Zone — pure geometry + identity. NO filtering behaviour.
16945
16917
  *
16946
- * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
16947
- * 140 s track), and a client that renders tiles from the media data plane needs
16948
- * to know only WHAT EXISTS — the bytes then arrive per tile, lazily, over HTTP
16949
- * with an immutable cache, instead of all at once inside a tRPC response that
16950
- * blocks the whole view.
16918
+ * Zones describe **where** in the frame the operator wants to flag
16919
+ * something; consumer-owned {@link ZoneRule} arrays describe **how**
16920
+ * each pipeline stage uses them. Splitting the two means a single
16921
+ * polygon "Driveway" can simultaneously back a motion-exclude rule,
16922
+ * a detection-include rule on `['car']`, and an occupancy aggregate
16923
+ * — without three duplicated polygons.
16951
16924
  *
16952
- * `sizeBytes` is carried because it is what lets a client decide between the
16953
- * stored blob and a `?variant=thumb` rendering without fetching either.
16925
+ * Owned by the orchestrator addon (provider) and mirrored into the
16926
+ * `zones` device-state slice on every mutation. Consumers
16927
+ * (motion-wasm, pipeline-executor, analytics, admin UI) read either
16928
+ * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
16929
+ * mirror with `onChanged`).
16930
+ *
16931
+ * Coordinates are normalised fractions of the frame (0–1) so zones
16932
+ * survive resolution changes and stream profile switches.
16933
+ *
16934
+ * `kind` discriminates between full polygons (closed regions used
16935
+ * for intrusion / occupancy filters) and tripwires (open 2-point
16936
+ * line segments used for cross events). Onboard / firmware-reported
16937
+ * zones (Reolink, ONVIF) are out of scope for now — see the deferred
16938
+ * task list.
16954
16939
  */
16955
- var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
16940
+ var ZoneKindEnum = _enum(["polygon", "tripwire"]);
16941
+ /** Polygon vertex in fraction-of-frame coordinates (0–1). */
16942
+ var PolygonPointSchema = object({
16943
+ x: number$1(),
16944
+ y: number$1()
16945
+ });
16946
+ /** A camera detection zone — pure geometry/identity. */
16947
+ var ZoneSchema = object({
16948
+ id: string(),
16949
+ name: string(),
16950
+ kind: ZoneKindEnum.default("polygon"),
16951
+ /** Polygon vertices, fraction of frame (0–1). */
16952
+ polygon: array(PolygonPointSchema).readonly(),
16953
+ /** Visual color for UI rendering. */
16954
+ color: string().default("#3b82f6")
16955
+ });
16956
+ DeviceType.Camera, method(object({ deviceId: number$1() }), array(ZoneSchema).readonly()), method(object({
16957
+ deviceId: number$1(),
16958
+ zone: ZoneSchema
16959
+ }), _void(), {
16960
+ kind: "mutation",
16961
+ auth: "admin"
16962
+ }), method(object({
16963
+ deviceId: number$1(),
16964
+ zoneId: string()
16965
+ }), _void(), {
16966
+ kind: "mutation",
16967
+ auth: "admin"
16968
+ }), method(object({
16969
+ deviceId: number$1(),
16970
+ zone: ZoneSchema
16971
+ }), _void(), {
16972
+ kind: "mutation",
16973
+ auth: "admin"
16974
+ }), object({ zones: array(ZoneSchema).readonly() });
16956
16975
  /**
16957
- * The MACRO tier of an annotation — a CLOSED set.
16976
+ * pipeline-analytics — device-scoped wrapper cap. Refines raw
16977
+ * per-frame detections emitted by the pipeline runner into tracked
16978
+ * objects, per-kind event collections (motion / object / audio), and
16979
+ * persisted media. Owns the post-detection domain end-to-end:
16958
16980
  *
16959
- * This is what the exported detector predicts, so a typo here is a new class
16960
- * with one example in it. `label` and `subLabel` are open strings by contrast:
16961
- * the whole point of the page is teaching the model things it does not know
16962
- * yet, and constraining that vocabulary would make it useless.
16981
+ * runner emits PipelineInferenceResult
16982
+ * ↓ (event bus)
16983
+ * pipeline-analytics subscriber
16984
+ * ↓ SORT tracker + zone engine + state analyzer + event emitter
16985
+ * → three DB collections (one per kind), one FS media tree, one
16986
+ * unified event emitter (FrameTracked + TrackStarted/Ended +
16987
+ * DetectionEvent on bus)
16963
16988
  *
16964
- * A macro class is NEVER a label. The provider refuses a write whose `label` or
16965
- * `subLabel` is one of these values, in any casing, because once `person`
16966
- * exists in both tiers "every person box" stops being answerable without
16967
- * knowing every string anyone ever typed — and the damage is retroactive.
16989
+ * Pure subscriber model. No `processFrame` cap method — the runner
16990
+ * already publishes the raw frame on the bus. The cap surface is
16991
+ * only QUERIES + per-device settings, bound on/off via
16992
+ * `device-manager.setWrapperActive`. `defaultActive: true` because
16993
+ * every camera with a detection pipeline wants its raw detections
16994
+ * refined; operators opt out per-device via BindingsTab when needed.
16995
+ *
16996
+ * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
16997
+ * (per-device surface) and `track-trail` caps — see P11 cleanup.
16968
16998
  */
16969
- var RetrainMacroClassSchema = _enum([
16999
+ var TrackStateSchema = _enum([
17000
+ "new",
17001
+ "entered",
17002
+ "left",
17003
+ "moving",
17004
+ "idle"
17005
+ ]);
17006
+ var EventKindSchema = _enum([
17007
+ "motion",
17008
+ "object",
17009
+ "audio"
17010
+ ]);
17011
+ /**
17012
+ * Spatial filter for `listTracks` — the rect + polygon variants of the shared
17013
+ * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
17014
+ * of the camera frame (top-left origin), matching the drawing-plane editor.
17015
+ */
17016
+ var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
17017
+ /** Closed icon vocabulary so clients render a known glyph per kind. */
17018
+ var EventKindIconSchema = _enum([
17019
+ "motion",
17020
+ "audio",
16970
17021
  "person",
16971
17022
  "vehicle",
16972
17023
  "animal",
17024
+ "door",
17025
+ "pir",
17026
+ "smoke",
17027
+ "water",
17028
+ "button",
16973
17029
  "package",
16974
- "face",
16975
- "plate"
17030
+ "generic"
16976
17031
  ]);
16977
- /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
16978
- var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
16979
- /** Did a human draw this box, or did the assist propose it? */
16980
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
16981
- /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
16982
- var RetrainBboxSchema = object({
16983
- x: number$1(),
16984
- y: number$1(),
16985
- w: number$1(),
16986
- h: number$1()
16987
- });
16988
- /**
16989
- * One annotated subject.
16990
- *
16991
- * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
16992
- * (letterboxed root / zone-cropped package / subject-cropped classifier) are
16993
- * derived from it at export and never stored — storing them is how one feature
16994
- * space ends up holding two crops of the same subject (D52).
16995
- */
16996
- var RetrainAnnotationSchema = object({
16997
- id: string(),
16998
- trackId: string(),
16999
- deviceId: number$1(),
17000
- /** The COPY in retrain storage — never the source track's media key. */
17001
- mediaKey: string(),
17002
- bbox: RetrainBboxSchema,
17003
- macroClass: RetrainMacroClassSchema,
17004
- label: string().optional(),
17005
- subLabel: string().optional(),
17006
- kind: RetrainAnnotationKindSchema,
17007
- source: RetrainAnnotationSourceSchema,
17008
- /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
17009
- assistModelId: string().optional(),
17010
- assistScore: number$1().optional(),
17011
- exportedInBatch: string().optional(),
17012
- createdAt: number$1()
17013
- });
17014
- /** The write form — the server owns `id`, `createdAt` and the frame binding. */
17015
- var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
17016
- id: true,
17017
- trackId: true,
17018
- deviceId: true,
17019
- mediaKey: true,
17020
- createdAt: true,
17021
- exportedInBatch: true
17032
+ var EventKindCategorySchema = _enum([
17033
+ "motion",
17034
+ "audio",
17035
+ "detection",
17036
+ "sensor",
17037
+ "control",
17038
+ "custom",
17039
+ "package"
17040
+ ]);
17041
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
17042
+ var EventKindLevelSchema = _enum(["macro", "sub"]);
17043
+ var EventKindDescriptorSchema = object({
17044
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
17045
+ kind: string(),
17046
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
17047
+ labelKey: string(),
17048
+ /** English fallback label (kept for clients that don't translate). */
17049
+ label: string(),
17050
+ /** Hex color for timeline/legend rendering. */
17051
+ color: string(),
17052
+ /** Dictionary id → lucide component on the UI side. */
17053
+ iconId: string(),
17054
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
17055
+ icon: EventKindIconSchema,
17056
+ category: EventKindCategorySchema,
17057
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
17058
+ parentKind: string().nullable(),
17059
+ /** Derived from `parentKind`, explicit for the client tree. */
17060
+ level: EventKindLevelSchema,
17061
+ /** Which cap + device contributes this kind. For built-ins the camera
17062
+ * itself; for sensor kinds the LINKED source device. */
17063
+ source: object({
17064
+ capName: string(),
17065
+ deviceId: number$1()
17066
+ })
17022
17067
  });
17023
- /** A track sitting in `staging`, with everything the worklist needs to rank it. */
17024
- var RetrainTrackSchema = object({
17025
- trackId: string(),
17068
+ /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
17069
+ var EventKindsForDeviceSchema = object({
17026
17070
  deviceId: number$1(),
17027
- className: string(),
17028
- label: string().optional(),
17029
- firstSeen: number$1(),
17030
- lastSeen: number$1(),
17031
- /** How many frames the dataset already holds from this track. */
17032
- frameCount: number$1().int(),
17033
- /** How many subjects have been annotated on those frames. `0` with
17034
- * `frameCount: 0` is exactly "staging, still to work". */
17035
- annotationCount: number$1().int()
17036
- });
17037
- /** A frame the picker may offer — an index row, no blob was read to produce it. */
17038
- var RetrainFrameCandidateSchema = object({
17039
- mediaKey: string(),
17040
- kind: MediaFileKindEnum,
17041
- timestamp: number$1(),
17042
- sizeBytes: number$1().int(),
17043
- /** A copy of this original already exists — selecting it is free and cannot
17044
- * fail, whatever became of the original. */
17045
- copied: boolean()
17071
+ kinds: array(EventKindDescriptorSchema).readonly()
17046
17072
  });
17047
- /** A frame the dataset OWNS: bytes copied at selection time. */
17048
- var RetrainFrameSchema = object({
17049
- frameId: string(),
17073
+ var SensorEventSchema = object({
17074
+ id: string(),
17075
+ /** The CAMERA the event is attributed to (a sensor linked to N cameras
17076
+ * yields N rows, one per camera). */
17050
17077
  deviceId: number$1(),
17051
- trackId: string(),
17052
- /** Provenance only. It may already point at nothing — that is expected. */
17053
- sourceMediaKey: string(),
17054
- sourceKind: MediaFileKindEnum,
17055
- sizeBytes: number$1().int(),
17056
- width: number$1().int(),
17057
- height: number$1().int(),
17058
- copiedAt: number$1()
17078
+ /** The linked sensor device whose state changed. */
17079
+ sourceDeviceId: number$1(),
17080
+ /** Event kind id — matches an `EventKindDescriptor.kind`. */
17081
+ kind: string(),
17082
+ /** Snapshot of the sensor cap's runtime-state slice at the change. */
17083
+ value: record(string(), unknown()).nullable(),
17084
+ timestamp: number$1()
17059
17085
  });
17060
- /** Why a copy-on-select could not be honoured — named, never a silent skip. */
17061
- var RetrainCopyRefusalSchema = _enum([
17062
- "source-missing",
17063
- "unreadable-image",
17064
- "write-failed"
17065
- ]);
17066
- var RetrainFrameSelectionSchema = object({
17067
- copied: array(RetrainFrameSchema).readonly(),
17068
- refused: array(object({
17069
- sourceMediaKey: string(),
17070
- reason: RetrainCopyRefusalSchema
17071
- })).readonly()
17086
+ var TrackPositionSchema = object({
17087
+ x: number$1(),
17088
+ y: number$1(),
17089
+ timestamp: number$1(),
17090
+ bbox: BoundingBoxSchema
17072
17091
  });
17073
- var RetrainFrameListSchema = object({
17074
- candidates: array(RetrainFrameCandidateSchema).readonly(),
17075
- copies: array(RetrainFrameSchema).readonly(),
17076
- /** What the page pre-selects — the native key frame when one survives. */
17077
- autoPickMediaKey: string().optional()
17092
+ var TrackSnapshotSchema = object({
17093
+ timestamp: number$1(),
17094
+ position: TrackPositionSchema,
17095
+ /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
17096
+ mediaKey: string()
17078
17097
  });
17079
- /** What the operator asked the assist to look for. */
17080
- var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
17081
- kind: literal("package"),
17082
- zone: RetrainBboxSchema.optional()
17083
- }), object({
17084
- kind: literal("objects"),
17085
- modelId: string(),
17086
- minScore: number$1().optional()
17087
- })]);
17088
17098
  /**
17089
- * The assist's answer — a discriminated union, because "the model saw nothing"
17090
- * and "this node cannot run that model" lead to different next moves and a
17091
- * nullable result cannot tell them apart.
17099
+ * Normalized 0..1 trajectory envelope (min/max over every position bbox,
17100
+ * divided by the track's detection-frame dims), computed at persist time.
17101
+ * Absent when the frame dims were unknown when the track was persisted
17102
+ * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
17092
17103
  */
17093
- var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
17094
- kind: literal("proposed"),
17095
- modelId: string(),
17096
- stepId: string(),
17097
- minScore: number$1(),
17098
- /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
17099
- proposals: array(RetrainAnnotationDraftSchema).readonly(),
17100
- /** Returned by the runner but removed by the threshold. */
17101
- belowThreshold: number$1().int()
17102
- }), object({
17103
- kind: literal("refused"),
17104
- /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
17105
- reason: string(),
17106
- detail: string().optional()
17107
- })]);
17108
- /** The outcome of a lifecycle move owned by the retrain page. */
17109
- var RetrainTransitionResultSchema = object({
17110
- trackId: string(),
17111
- /** Where the track ended up, whatever happened. */
17112
- retrainStatus: RetrainStatusSchema,
17113
- /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
17114
- changed: boolean(),
17115
- reason: _enum([
17116
- "unknown-track",
17117
- "no-frames-copied",
17118
- "not-staging",
17119
- "not-trained",
17120
- "unchanged"
17121
- ]).optional()
17122
- });
17123
- var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
17124
- var MAX_EVENT_QUERY_LIMIT = 5e3;
17125
- var DeviceEventQueryInput = object({
17126
- deviceId: number$1(),
17127
- since: number$1().optional(),
17128
- until: number$1().optional(),
17129
- limit: number$1().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
17130
- /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
17131
- * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
17132
- * exact behaviour. Callers may omit this field — the store defaults to
17133
- * `full` when not provided. */
17134
- projection: _enum(["full", "slim"]).optional()
17135
- });
17136
- var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
17137
- var RecentTracksQueryInput = object({
17138
- /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
17139
- deviceIds: array(number$1()),
17140
- /** Window lower bound on `lastSeen` (inclusive). */
17141
- since: number$1().optional(),
17142
- /** Window upper bound on `lastSeen` (inclusive). */
17143
- until: number$1().optional(),
17144
- /** Page size. Default 200, max 1000. */
17145
- limit: number$1().int().min(1).max(1e3).default(200),
17146
- /** Opaque continuation cursor from a previous page's `nextCursor`.
17147
- * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
17148
- cursor: string().optional(),
17149
- /** See {@link TrackProjectionSchema}. Default `full`. */
17150
- projection: TrackProjectionSchema.optional(),
17151
- /** Include stationary-promoted rows (parked objects). Default false: the
17152
- * feed lists passages; parking records live on the stationary registry. */
17153
- includeStationary: boolean().optional()
17104
+ var TrackEnvelopeSchema = object({
17105
+ minX: number$1(),
17106
+ minY: number$1(),
17107
+ maxX: number$1(),
17108
+ maxY: number$1()
17154
17109
  });
17155
- var RecentTracksPageSchema = object({
17156
- /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
17157
- tracks: array(TrackSchema).readonly(),
17158
- /** Cursor for the next page, or null when this page is the last. */
17159
- nextCursor: string().nullable()
17160
- });
17161
- var LIST_GROUPS_DEFAULT_LIMIT = 40;
17162
- var LIST_GROUPS_MAX_LIMIT = 100;
17163
- var AnalyticsGroupRecordSchema = object({
17164
- id: string(),
17165
- deviceId: number$1().int(),
17166
- openedAt: number$1().int(),
17167
- closedAt: number$1().int(),
17168
- timestamp: number$1().int(),
17169
- memberCount: number$1().int(),
17170
- memberTrackIds: array(string()).readonly(),
17171
- className: string(),
17172
- classes: array(string()).readonly(),
17173
- /** Relative event-media path, or null when the group has no picture yet. */
17174
- mediaUrl: string().nullable(),
17175
- singleton: boolean()
17176
- });
17177
- var AnalyticsGroupMemberSchema = object({
17178
- trackId: string(),
17179
- deviceId: number$1().int(),
17180
- className: string(),
17181
- firstSeen: number$1().int(),
17182
- lastSeen: number$1().int(),
17183
- mediaUrl: string().nullable()
17184
- });
17185
- var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
17186
- var ListGroupsQueryInput = object({
17187
- /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
17188
- deviceIds: array(number$1()),
17189
- /** Window lower bound on `closedAt` (inclusive). */
17190
- since: number$1().optional(),
17191
- /** Window upper bound on `openedAt` (inclusive). */
17192
- until: number$1().optional(),
17193
- limit: number$1().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
17194
- /** Opaque continuation cursor from a previous page's `nextCursor`. */
17195
- cursor: string().optional()
17196
- });
17197
- var ListGroupsPageSchema = object({
17198
- groups: array(AnalyticsGroupRecordSchema).readonly(),
17199
- nextCursor: string().nullable()
17200
- });
17201
- var KeyEventQueryInput = object({
17202
- deviceId: number$1(),
17203
- /** Window lower bound (track firstSeen ≥ since). */
17204
- since: number$1(),
17205
- /** Window upper bound (track firstSeen ≤ until). */
17206
- until: number$1(),
17207
- limit: number$1().int().min(1).max(200).default(50),
17208
- /** Drop tracks scoring below this importance. */
17209
- minImportance: number$1().min(0).max(1).optional(),
17210
- /** Restrict to a single class (e.g. 'person'). */
17211
- classFilter: string().optional()
17212
- });
17213
- var KeyEventSchema = object({
17214
- /** The representative event id (the track's best ObjectEvent, else its trackId). */
17215
- id: string(),
17216
- trackId: string(),
17217
- /** Track start time (firstSeen). */
17218
- timestamp: number$1(),
17219
- className: string(),
17220
- ...TieredLabelFields,
17221
- importance: number$1(),
17222
- /** Highest-confidence ObjectEvent id for the track (empty when none). */
17223
- bestEventId: string(),
17224
- /** Track lifetime in ms (lastSeen - firstSeen). */
17225
- windowMs: number$1().optional(),
17226
- ...TrackFlagFields,
17227
- ...TrackRetrainFields
17228
- });
17229
- object({
17230
- trackId: string(),
17231
- className: string(),
17232
- confidence: number$1(),
17233
- bbox: BoundingBoxSchema,
17234
- zones: array(string()).readonly(),
17235
- state: TrackStateSchema
17236
- });
17237
- var OverlayDetectionSchema = looseObject({
17238
- id: string(),
17239
- kind: _enum(["first-level", "detail"]),
17240
- macroClass: string(),
17241
- score: number$1(),
17242
- bbox: object({
17243
- x: number$1(),
17244
- y: number$1(),
17245
- width: number$1(),
17246
- height: number$1()
17247
- }),
17248
- labels: array(looseObject({
17249
- label: string(),
17250
- score: number$1()
17251
- })).readonly(),
17252
- parentId: string().optional()
17253
- });
17254
- var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number$1() });
17255
- var SearchObjectEventsInput = object({
17256
- text: string(),
17257
- deviceId: number$1().optional(),
17258
- since: number$1().optional(),
17259
- until: number$1().optional(),
17260
- classFilter: string().optional(),
17261
- limit: number$1().default(50),
17262
- minScore: number$1().min(0).max(1).default(.2)
17263
- });
17264
- var TrackCascadeCountsSchema = object({
17265
- /** Persisted track roots deleted (authoritative). */
17266
- tracks: number$1().int(),
17267
- /** Object events removed with their tracks (best-effort; see note above). */
17268
- events: number$1().int(),
17269
- /** Track/face/plate-owned media removed (best-effort). Never identity media. */
17270
- media: number$1().int(),
17271
- /** Unassigned (non-enrolled) face reads removed (best-effort). */
17272
- faces: number$1().int(),
17273
- /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
17274
- plates: number$1().int(),
17275
- /** Per-track CLIP search vectors removed (best-effort). */
17276
- embeddings: number$1().int(),
17277
- /** Group membership + group rows removed with their last member (best-effort). */
17278
- groups: number$1().int()
17279
- });
17280
- /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
17281
- var DiskReconcileCountsSchema = object({
17282
- mediaDropped: number$1().int(),
17283
- tracks: number$1().int(),
17284
- events: number$1().int()
17285
- });
17286
- /** Event-store footprint for one camera. */
17287
- var EventStoreDeviceFootprintSchema = object({
17288
- deviceId: number$1(),
17289
- /** Persisted event rows (motion + object + audio) for the camera. */
17290
- rows: number$1().int(),
17291
- /** Event-owned media bytes on disk for the camera. */
17292
- bytes: number$1().int()
17293
- });
17294
- /** Aggregate event-store footprint: global totals + per-camera breakdown. */
17295
- var EventStoreFootprintSchema = object({
17296
- totalRows: number$1().int(),
17297
- totalBytes: number$1().int(),
17298
- devices: array(EventStoreDeviceFootprintSchema).readonly()
17299
- });
17300
- /** Per-kind counts returned by the event-prune / device-delete mutations. */
17301
- var EventPruneCountsSchema = object({
17302
- motion: number$1().int(),
17303
- object: number$1().int(),
17304
- audio: number$1().int()
17110
+ /**
17111
+ * Row projection for track list queries. `full` (default) returns the
17112
+ * complete Track including the frame-rate `positions[]` history and the
17113
+ * `snapshots[]` references — megabytes across a page of tracks. `slim`
17114
+ * keeps every scalar the list surfaces actually render (ids, class(es),
17115
+ * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
17116
+ * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
17117
+ * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
17118
+ * `getTrack`. Mirrors the event-store `projection` convention
17119
+ * (`getObjectEvents` et al.).
17120
+ */
17121
+ var TrackProjectionSchema = _enum(["full", "slim"]);
17122
+ /**
17123
+ * One audio-classification label heard on the track's camera while the
17124
+ * track was alive, aggregated per label. An "episode" is one persisted
17125
+ * audio event (the confident-classification path: score ≥ the device's
17126
+ * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
17127
+ * one 32 ms inference chunk, so counts stay human-scaled.
17128
+ */
17129
+ var TrackAudioLabelSchema = object({
17130
+ label: string(),
17131
+ /** Highest classification score observed across the label's episodes. */
17132
+ peakScore: number$1(),
17133
+ /** Number of coalesced audio-event episodes carrying this label. */
17134
+ count: number$1(),
17135
+ firstAt: number$1(),
17136
+ lastAt: number$1()
17305
17137
  });
17306
17138
  /**
17307
- * Re-embed stored tracks from their key frames.
17139
+ * How a track was produced. `pipeline` (default / absent) = the spatial
17140
+ * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
17141
+ * no positions, a single snapshot, and no bbox trajectory at all:
17308
17142
  *
17309
- * The reason this is an operator-callable method and not a migration script:
17310
- * every knob that decides what a vector MEANS — encoder model, crop margin,
17311
- * squaring — is only changeable if the existing vectors can be regenerated.
17312
- * Mixing feature spaces in one index makes cosine scores incomparable, and the
17313
- * symptom is a quality regression with no visible cause.
17143
+ * - `sensor` — a linked sensor/control device state change.
17144
+ * - `audio` — an audio event on the camera itself that was anomalous for
17145
+ * THAT camera, loud, and heard while nothing visual was happening (D62).
17146
+ *
17147
+ * The spatial subsystems (tracker association, occupancy count, re-id /
17148
+ * embedding, resurrection) MUST skip every synthetic source. Test for that
17149
+ * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
17150
+ * check silently readmits every source added after it was written.
17314
17151
  */
17315
- var RebuildObjectEmbeddingsInput = object({
17316
- /** Restrict to one camera. Omit for the whole fleet. */
17317
- deviceId: number$1().optional(),
17318
- since: number$1().optional(),
17319
- until: number$1().optional(),
17320
- /** Stop after this many tracks; the result reports whether more remain. */
17321
- maxTracks: number$1().int().positive().optional(),
17322
- /**
17323
- * Run every embedding on THIS node instead of round-robining the fleet.
17324
- *
17325
- * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
17326
- * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
17327
- * calling it that would pin the rebuild REQUEST itself to that node — the
17328
- * rebuild orchestration lives on the hub, and only the per-track step runs
17329
- * remotely. This field is data; the per-track pin is applied inside.
17330
- *
17331
- * Absent ⇒ round-robin over every online node whose runner can serve the
17332
- * pinned model.
17333
- */
17334
- executeOnNodeId: string().optional(),
17335
- /**
17336
- * Milliseconds to wait between tracks; omit for the built-in default, `0` to
17337
- * run flat out.
17338
- *
17339
- * A rebuild is bulk maintenance on hub-main's single thread. Measured
17340
- * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
17341
- * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
17342
- * force is logged at start and finish so a deliberately slow pass reads
17343
- * differently from a stalled one.
17344
- */
17345
- pacingMs: number$1().int().nonnegative().optional()
17346
- });
17152
+ var TrackSourceSchema = _enum([
17153
+ "pipeline",
17154
+ "sensor",
17155
+ "audio"
17156
+ ]);
17347
17157
  /**
17348
- * Result of emptying the CLIP index.
17158
+ * Where a track sits in the RETRAIN lifecycle (D81).
17349
17159
  *
17350
- * The clean slate before a policy change: a new crop margin or encoder model
17351
- * leaves two feature spaces in one index whose cosine scores are not
17352
- * comparable, so wiping and rebuilding is the only way to be sure every vector
17353
- * means the same thing.
17160
+ * - `none` — never marked, or un-marked. Evictable.
17161
+ * - `staging` — the operator wants this track as training material and has not
17162
+ * finished with it. **This is the only state retention holds**: the track and
17163
+ * everything it owns (object events, crops, keyframes, CLIP vector) survive
17164
+ * the device's age window.
17165
+ * - `trained` — the retrain page has taken what it needed. The frames it chose
17166
+ * were COPIED into the retrain dataset at selection time, so the dataset no
17167
+ * longer depends on the track's media and the track becomes EVICTABLE again.
17168
+ * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
17169
+ * a deliberate action of the retrain page, not a side effect of a checkbox.
17170
+ *
17171
+ * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
17172
+ * the store's filter language has only positive equality and `whereIn` — no
17173
+ * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
17174
+ * would make the entire pre-column history immortal in one deploy.
17354
17175
  */
17355
- var WipeObjectEmbeddingsResultSchema = object({ deleted: number$1() });
17176
+ var RetrainStatusSchema = _enum([
17177
+ "none",
17178
+ "staging",
17179
+ "trained"
17180
+ ]);
17356
17181
  /**
17357
- * Acknowledgement that a rebuild STARTED.
17182
+ * Per-track OPERATOR flags — set by hand from the admin UI or the viewer, never
17183
+ * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
17184
+ * so the two surfaces cannot drift.
17358
17185
  *
17359
- * The pass costs ~1s per track — 45 minutes for a 2,600-track fleet — so it
17360
- * runs detached and this returns immediately. Waiting for it made the client
17361
- * time out while the work carried on server-side, which is the worst of both:
17362
- * no result and no way to know it was still going. Poll
17363
- * `getObjectEmbeddingRebuildStatus` for progress.
17186
+ * **Absent ≠ false.** A track that has never been touched omits the field; an
17187
+ * explicitly un-flagged track carries `false`. Legacy rows written before the
17188
+ * columns existed read as absent, and a consumer that needs a boolean should say
17189
+ * `flag === true`, not `flag !== false`.
17190
+ *
17191
+ * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
17192
+ * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
17193
+ * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
17194
+ * `trained` track reports `false` while refusing both writes. The boolean is
17195
+ * kept because three surfaces drive a toggle off it; anything that needs to tell
17196
+ * "never marked" from "already trained" must read `retrainStatus`.
17197
+ *
17198
+ * `debug` does NOT pin; it is attention, not durability.
17199
+ *
17200
+ * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
17201
+ * A favourited track is skipped by retention the same way `staging` is, but
17202
+ * it does not enter `none|staging|trained` and has no staging budget.
17364
17203
  */
17365
- var RebuildObjectEmbeddingsResultSchema = object({
17366
- started: boolean(),
17367
- /** True when a pass was already running; the new request is ignored. */
17368
- alreadyRunning: boolean()
17369
- });
17370
- var RebuildStatusSchema = object({
17371
- running: boolean(),
17372
- scanned: number$1(),
17373
- rebuilt: number$1(),
17374
- /** Tracks whose key frame is gone — nothing to re-embed from. */
17375
- missingKeyFrame: number$1(),
17376
- /** Tracks with no usable detection box. */
17377
- missingBbox: number$1(),
17378
- /**
17379
- * Tracks an executing node REFUSED rather than broke on — an unreadable key
17380
- * frame, a step that threw. Separate from `failed` because the remedy is
17381
- * different, and because a whole camera silently contributing zero vectors
17382
- * is the shape of failure a rebuild must never hide.
17383
- */
17384
- notRunnable: number$1(),
17204
+ var TrackFlagFields = {
17205
+ /** Operator marked this track as training material — i.e. `retrainStatus` is
17206
+ * `'staging'`. */
17207
+ markForTrain: boolean().optional(),
17208
+ /** Operator marked this track for diagnostic attention. */
17209
+ debug: boolean().optional(),
17210
+ /** Operator favourited this track. Pins it against pruning. */
17211
+ favourited: boolean().optional()
17212
+ };
17213
+ /**
17214
+ * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
17215
+ * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
17216
+ * write patch, and the status is not something the toggle sets — it is what the
17217
+ * toggle's boolean is derived from. Absent on an in-RAM track never touched;
17218
+ * always present on a persisted row (the column default materialises `'none'`).
17219
+ */
17220
+ var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
17221
+ /**
17222
+ * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
17223
+ * one flag can never clear the other — the toggles are independent and are
17224
+ * driven from three surfaces that do not know about each other.
17225
+ */
17226
+ var TrackFlagsPatchSchema = object(TrackFlagFields);
17227
+ /**
17228
+ * The resolved flag state after a write. Both fields are REQUIRED here (absent
17229
+ * collapses to `false`) so a caller can drive a toggle's checked state off the
17230
+ * mutation result without a re-fetch.
17231
+ */
17232
+ var TrackFlagsSchema = object({
17233
+ trackId: string(),
17234
+ markForTrain: boolean(),
17235
+ debug: boolean(),
17236
+ favourited: boolean(),
17237
+ /** The lifecycle state the boolean was derived from. Required here (unlike on
17238
+ * a track row) because this shape is only ever produced by the write body,
17239
+ * which always knows it — and a surface that has just written needs to render
17240
+ * `trained` without a re-fetch. */
17241
+ retrainStatus: RetrainStatusSchema
17242
+ });
17243
+ union([literal(1), literal(2)]);
17244
+ /**
17245
+ * WHO decided a label, and when. Carried per tier so a value can be traced to
17246
+ * the step and model that produced it — which is what makes the write rule
17247
+ * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
17248
+ * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
17249
+ *
17250
+ * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
17251
+ * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
17252
+ * `migration:4g` for a value the 4g migration moved from the single-slot era —
17253
+ * that value has no provenance, and the write rule lets ANY properly-attributed
17254
+ * write of the same tier replace it regardless of score.
17255
+ */
17256
+ var LabelAttributionSchema = object({
17257
+ stepId: string(),
17258
+ modelId: string().optional(),
17259
+ decidedAt: number$1(),
17385
17260
  /**
17386
- * The pass stopped because NO node could serve the pinned model.
17261
+ * The GALLERY id behind a recognised tier-2 label — a face-gallery
17262
+ * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
17387
17263
  *
17388
- * Distinct from `notRunnable` on purpose: that one says "this track was
17389
- * refused", this one says "the cluster cannot do this work at all" — every
17390
- * candidate node either lacks the `clip-embedding` step, lacks a build of the
17391
- * pinned model for its engine format, or dropped out. The remedy is a model /
17392
- * engine change, not a per-camera one. Non-zero here always comes with
17393
- * `complete: false`.
17264
+ * The text alone is a DISPLAY NAME, and a display name is renameable: a
17265
+ * notification rule authored on "Gianluca" stopped matching the moment the
17266
+ * operator fixed the spelling in the gallery, and nothing said so. The id is
17267
+ * the thing that does not move, so it is what a rule matches on
17268
+ * (`NcConditions.identities`) and the text is what a human is shown.
17269
+ *
17270
+ * Absent when the label names no gallery row — a plate the OCR read but no
17271
+ * vehicle claims, a sub-class, a species, any tier-1 value.
17394
17272
  */
17395
- noCapableNode: number$1(),
17396
- failed: number$1(),
17397
- /** Set once a pass ends: true only when EVERYTHING was covered. */
17398
- complete: boolean().nullable(),
17399
- startedAtMs: number$1().nullable(),
17400
- finishedAtMs: number$1().nullable(),
17401
- /** Present when the pass ended by throwing. */
17402
- error: string().nullable()
17273
+ identityId: string().optional()
17403
17274
  });
17404
- DeviceType.Camera, method(object({ deviceId: number$1() }), array(TrackSchema).readonly()), method(object({
17405
- deviceId: number$1(),
17406
- trackId: string()
17407
- }), TrackSchema.nullable()), method(object({
17408
- deviceId: number$1(),
17409
- since: number$1().optional(),
17410
- until: number$1().optional(),
17411
- limit: number$1().optional(),
17412
- /** Spatial filter — only tracks whose trajectory intersects the zone
17413
- * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
17414
- * envelope columns, then precisely tested per position. Tracks with
17415
- * an unknown envelope (no frame dims at persist time) always match. */
17416
- zone: TrackZoneFilterSchema.optional(),
17417
- /** See {@link TrackProjectionSchema}. Default `full` (backward
17418
- * compatible — omitting the field keeps today's exact behaviour). */
17419
- projection: TrackProjectionSchema.optional(),
17420
- /** Include stationary-promoted rows (parked objects handed to the
17421
- * stationary registry). Default false: the timeline lists passages,
17422
- * not parking records (operator decision, 2026-08-15). */
17423
- includeStationary: boolean().optional()
17424
- }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
17425
- deviceId: number$1(),
17426
- groupId: string().min(1)
17427
- }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number$1() }), _void(), {
17428
- kind: "mutation",
17429
- auth: "admin"
17430
- }), 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({
17431
- deviceId: number$1(),
17432
- since: number$1().optional(),
17433
- until: number$1().optional(),
17434
- kinds: array(string()).optional(),
17435
- limit: number$1().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
17436
- }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
17437
- deviceId: number$1(),
17438
- since: number$1(),
17439
- until: number$1(),
17440
- bucketMs: number$1().int().positive()
17441
- }), array(object({
17442
- bucketStart: number$1(),
17443
- motion: number$1().int(),
17444
- object: number$1().int(),
17445
- audio: number$1().int()
17446
- })).readonly()), method(object({
17447
- deviceId: number$1(),
17448
- cutoffMs: number$1()
17449
- }), object({
17450
- motion: number$1().int(),
17451
- object: number$1().int(),
17452
- audio: number$1().int()
17453
- }), {
17454
- kind: "mutation",
17455
- auth: "admin"
17456
- }), method(object({
17457
- deviceId: number$1(),
17458
- cutoffMs: number$1()
17459
- }), TrackCascadeCountsSchema, {
17460
- kind: "mutation",
17461
- auth: "admin"
17462
- }), method(object({ deviceId: number$1() }), TrackCascadeCountsSchema, {
17463
- kind: "mutation",
17464
- auth: "admin"
17465
- }), method(object({ deviceId: number$1() }), DiskReconcileCountsSchema, {
17466
- kind: "mutation",
17467
- auth: "admin"
17468
- }), method(object({
17469
- deviceId: number$1(),
17470
- trackIds: array(string()).min(1)
17471
- }), object({
17472
- deleted: number$1().int(),
17473
- failed: array(string()).readonly()
17474
- }), {
17475
- kind: "mutation",
17476
- auth: "admin"
17477
- }), method(object({
17478
- /** Log/audit scope only — the trackId is globally unique on its own. */
17275
+ /**
17276
+ * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
17277
+ * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
17278
+ * track and its events always answer the same question the same way.
17279
+ *
17280
+ * Two scalar columns, not an array: every consumer wants "the coarse one" or
17281
+ * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
17282
+ * is tier 2, and each carries its own score + attribution.
17283
+ *
17284
+ * **Reading it.** What a human should be shown is `subLabel ?? label` — the
17285
+ * finest thing known. Before 4g the single `label` column held the finest
17286
+ * value, so a consumer that has not been updated reads the tier-1 slot and
17287
+ * shows nothing on a species-only row; that is why the migration puts every
17288
+ * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
17289
+ * and why the read surfaces were changed in the same train.
17290
+ *
17291
+ * **Writing it.** The slots are independent, which is the whole point: a
17292
+ * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
17293
+ * migratorius`), so fineness cannot regress by construction. Within a tier the
17294
+ * higher score wins. One rule, one implementation — see
17295
+ * `pipeline/label-tier.ts` in addon-post-analysis.
17296
+ */
17297
+ var TieredLabelFields = {
17298
+ /** Tier 1 — the sub-class. See {@link LabelTierSchema}. */
17299
+ label: string().optional(),
17300
+ /** Confidence of the tier-1 value, as reported by the deciding step. */
17301
+ labelScore: number$1().optional(),
17302
+ /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
17303
+ labelMeta: LabelAttributionSchema.optional(),
17304
+ /** Tier 2 — the instance. See {@link LabelTierSchema}. */
17305
+ subLabel: string().optional(),
17306
+ /** Confidence of the tier-2 value, as reported by the deciding step. */
17307
+ subLabelScore: number$1().optional(),
17308
+ /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
17309
+ subLabelMeta: LabelAttributionSchema.optional()
17310
+ };
17311
+ /** Per-camera slice of a training-export estimate. */
17312
+ var TrainingExportDeviceTotalsSchema = object({
17479
17313
  deviceId: number$1(),
17314
+ tracks: number$1().int(),
17315
+ files: number$1().int(),
17316
+ bytes: number$1().int()
17317
+ });
17318
+ /**
17319
+ * What a training export WOULD contain. Computed from media index rows only —
17320
+ * no blob is read to produce this.
17321
+ */
17322
+ var TrainingExportSummarySchema = object({
17323
+ generatedAt: number$1(),
17324
+ trackCount: number$1().int(),
17325
+ fileCount: number$1().int(),
17326
+ byteCount: number$1().int(),
17327
+ /** More marked tracks exist than a single pass carries. */
17328
+ truncated: boolean(),
17329
+ devices: array(TrainingExportDeviceTotalsSchema).readonly()
17330
+ });
17331
+ var TrackSchema = object({
17480
17332
  trackId: string(),
17481
- flags: TrackFlagsPatchSchema
17482
- }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
17483
- kind: "query",
17484
- auth: "admin"
17485
- }), method(object({
17486
- olderThanMs: number$1(),
17487
- reason: OpsLogReasonSchema.optional()
17488
- }), EventPruneCountsSchema, {
17489
- kind: "mutation",
17490
- auth: "admin"
17491
- }), method(object({ deviceId: number$1() }), EventPruneCountsSchema, {
17492
- kind: "mutation",
17493
- auth: "admin"
17494
- }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
17495
- kind: "mutation",
17496
- auth: "admin"
17497
- }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
17498
- kind: "mutation",
17499
- auth: "admin"
17500
- }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
17501
- kind: "mutation",
17502
- auth: "admin"
17503
- }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
17504
- kind: "mutation",
17505
- auth: "admin"
17506
- }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
17507
- kind: "mutation",
17508
- auth: "admin"
17509
- }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
17510
- kind: "query",
17511
- auth: "admin"
17512
- }), method(object({ deviceIds: array(number$1()).optional() }), TrainingExportSummarySchema, {
17513
- kind: "query",
17514
- auth: "admin"
17515
- }), method(object({ deviceIds: array(number$1()).optional() }), object({ url: string() }), {
17516
- kind: "query",
17517
- auth: "admin"
17518
- }), method(object({
17519
- /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
17520
- * `deviceId`, deliberately: `deviceId` would make this device-bound and
17521
- * route it at one camera's owner, and "every camera" would stop being
17522
- * expressible at all. */
17523
- deviceIds: array(number$1()).optional(),
17524
- limit: number$1().int().min(1).max(500).optional()
17525
- }), array(RetrainTrackSchema).readonly(), {
17526
- kind: "query",
17527
- auth: "admin"
17528
- }), method(object({ trackId: string() }), RetrainFrameListSchema, {
17529
- kind: "query",
17530
- auth: "admin"
17531
- }), method(object({
17532
17333
  deviceId: number$1(),
17533
- trackId: string(),
17534
- mediaKeys: array(string()).min(1)
17535
- }), RetrainFrameSelectionSchema, {
17536
- kind: "mutation",
17537
- auth: "admin"
17538
- }), method(object({
17334
+ className: string(),
17335
+ ...TieredLabelFields,
17336
+ producingDeviceName: string().optional(),
17337
+ /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
17338
+ source: TrackSourceSchema.optional(),
17339
+ firstSeen: number$1(),
17340
+ lastSeen: number$1(),
17341
+ /** Frame-rate position history (subject to maxPositionHistory cap). */
17342
+ positions: array(TrackPositionSchema).readonly(),
17343
+ /** Periodic snapshots at snapshotIntervalMs cadence (subject to
17344
+ * saveThumbnails policy). */
17345
+ snapshots: array(TrackSnapshotSchema).readonly(),
17346
+ /** Deduplicated zones the track has entered at least once. Zone IDS. */
17347
+ zonesVisited: array(string()).readonly(),
17348
+ /**
17349
+ * Human NAMES for {@link zonesVisited}, resolved at READ time against the
17350
+ * `zones` capability.
17351
+ *
17352
+ * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
17353
+ * and no card can render — so every free-text search surface was structurally
17354
+ * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
17355
+ * just returned nothing. Resolving here rather than in each client keeps ONE
17356
+ * derivation and costs the clients no extra call (the `zones` cap is
17357
+ * per-device, so a client-side resolve would be a per-camera fan-out on a
17358
+ * surface built to avoid exactly that).
17359
+ *
17360
+ * Resolved, never invented: a zone deleted since the track was written has no
17361
+ * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
17362
+ * two are not positionally aligned. Absent when the track visited no zone, or
17363
+ * when the zone catalogue could not be read.
17364
+ */
17365
+ zoneNames: array(string()).readonly().optional(),
17366
+ /** Deduplicated set of detector classes observed for this track over its
17367
+ * life (a track may be reclassified, e.g. person→vehicle). Absent on
17368
+ * legacy rows written before class accumulation shipped. */
17369
+ classes: array(string()).readonly().optional(),
17370
+ /** Cumulative normalized distance travelled (0..1 units = full frame width). */
17371
+ totalDistance: number$1(),
17372
+ state: TrackStateSchema,
17373
+ active: boolean(),
17374
+ /** Deterministic key-event importance score in [0,1] (server-computed at
17375
+ * track expiry, recomputed on late label). Absent on legacy rows written
17376
+ * before scoring shipped — consumers degrade to absence / compute-on-read. */
17377
+ importance: number$1().optional(),
17378
+ /** Id of the track's highest-confidence ObjectEvent (its representative
17379
+ * "best" frame). Absent when the track produced no object events. */
17380
+ bestEventId: string().optional(),
17381
+ /** Tag of the importance sub-signal that dominated the score
17382
+ * (identity|dwell|proximity|class|confidence|travel|zone). */
17383
+ importanceReason: string().optional(),
17384
+ /** Audio-classification labels heard on the camera during the track's
17385
+ * life (score ≥ device `classificationMinScore`), aggregated per label.
17386
+ * Absent on legacy rows / tracks with no confident audio. */
17387
+ audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
17388
+ /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
17389
+ * Populated from the persisted envelope columns on historical reads;
17390
+ * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
17391
+ envelope: TrackEnvelopeSchema.optional(),
17392
+ /**
17393
+ * A face DETECTOR found a face on this track — nothing more. It says the
17394
+ * detail plane produced a `face` detail; it does NOT say the face was
17395
+ * embedded, matched, above `minFacePx`, or that the recognizer was even
17396
+ * enabled. Set once and never cleared.
17397
+ *
17398
+ * **This exists so "face present but not recognised" is expressible.** A
17399
+ * recognised identity lands in `subLabel` (attributed to the face chain via
17400
+ * `subLabelMeta.stepId`), so before this field a track with an unmatched face
17401
+ * and a track with no face at all were byte-identical on the wire and no
17402
+ * surface could tell them apart. The read is `hasFace === true && subLabel
17403
+ * === undefined`.
17404
+ *
17405
+ * **Absent ≠ false.** Every row written before the column existed omits it,
17406
+ * and so does every server that predates the field — a consumer must test
17407
+ * `=== true` and render nothing otherwise, never infer "no face".
17408
+ */
17409
+ hasFace: boolean().optional(),
17410
+ /**
17411
+ * This track has a face row IN THE GALLERY: a crop **and** an embedding — a
17412
+ * face an operator could ASSIGN to an identity.
17413
+ *
17414
+ * The STRICT twin of {@link hasFace}, and the pair only earns its keep
17415
+ * because the two disagree. `hasFace` is stamped at the TOP of the face
17416
+ * branch, before every gate, and means no more than "a face detector produced
17417
+ * a face detail". This one is stamped at the single moment the gallery row
17418
+ * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
17419
+ * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
17420
+ * candidate gate, the imageless-track drop (no crop was ever captured) and
17421
+ * the crop-store drop. Everything between the detector and that insert can
17422
+ * legitimately refuse the face, so a flag written any earlier promises the
17423
+ * operator something to assign and delivers nothing.
17424
+ *
17425
+ * **Independent of recognition.** A face collected but never auto-matched is
17426
+ * still assignable — it is in fact the face an operator most wants to reach —
17427
+ * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
17428
+ * `subLabel`; this says only that the raw material exists.
17429
+ *
17430
+ * **Set once, never cleared.** A track that produced a gallery row produced
17431
+ * one; deleting the row later is the gallery's business, not this flag's.
17432
+ *
17433
+ * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
17434
+ * before the column omits it, and so does every server that predates the
17435
+ * field. A consumer must test `=== true` and render nothing otherwise —
17436
+ * never infer "no assignable face".
17437
+ */
17438
+ hasEmbeddedFace: boolean().optional(),
17439
+ /**
17440
+ * This subject CONTAINS a folded rider — a person the rider-pairing step
17441
+ * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
17442
+ * so the passage is tracked once and as a VEHICLE.
17443
+ *
17444
+ * It exists because the fold's record was dishonest. D34 and the code both
17445
+ * said "the person is not lost — it is reported so both entities stay on the
17446
+ * record"; in fact the pair went into a per-processor RAM field behind an
17447
+ * accessor nobody called, and every durable surface said `vehicle`, full
17448
+ * stop. This is the composition note that makes the row true.
17449
+ *
17450
+ * A COMPOSITION, never a class and never a label. "This vehicle contains a
17451
+ * person" is not an answer to "what is this" — both label tiers would refuse
17452
+ * a macro token anyway (D89), and correctly. Nothing here changes what the
17453
+ * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
17454
+ * and a `person` rule still does not fire for someone cycling past.
17455
+ *
17456
+ * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
17457
+ * the column, and every hub that predates the field, omits it. Test
17458
+ * `=== true` and render nothing otherwise — never infer "no rider".
17459
+ */
17460
+ hasRider: boolean().optional(),
17461
+ ...TrackFlagFields,
17462
+ ...TrackRetrainFields
17463
+ });
17464
+ var BaseEventFields = {
17465
+ id: string(),
17539
17466
  deviceId: number$1(),
17540
- trackId: string(),
17541
- frameId: string()
17542
- }), object({
17543
- removed: boolean(),
17544
- removedAnnotations: number$1().int()
17545
- }), {
17546
- kind: "mutation",
17547
- auth: "admin"
17548
- }), method(object({ frameId: string() }), object({
17467
+ timestamp: number$1()
17468
+ };
17469
+ var MotionEventSchema = object({
17470
+ ...BaseEventFields,
17471
+ kind: literal("motion"),
17472
+ regionCount: number$1(),
17473
+ /** Heavy JSON array — omitted in slim projection. */
17474
+ regions: array(object({
17475
+ bbox: BoundingBoxSchema,
17476
+ pixelCount: number$1(),
17477
+ intensity: number$1()
17478
+ })).readonly().optional(),
17479
+ /** Omitted in slim projection. */
17480
+ frameWidth: number$1().optional(),
17481
+ /** Omitted in slim projection. */
17482
+ frameHeight: number$1().optional(),
17483
+ /** Populated by B5 (recording playback URL for this event). */
17484
+ mediaUrl: string().optional()
17485
+ });
17486
+ /**
17487
+ * Which detection SOURCE produced an object event. `pipeline` = the ML
17488
+ * detection pipeline (decoded-frame inference); `onboard` = the camera's
17489
+ * native on-device AI. Both flow through the SAME analysis layers (zoning,
17490
+ * tracking, per-kind persistence) but stay distinguishable so consumers
17491
+ * (advanced-notifier, occupancy, …) can select which source(s) to act on.
17492
+ * Absent on legacy rows ⇒ treat as `pipeline`.
17493
+ */
17494
+ var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
17495
+ /**
17496
+ * The confirmed zone crossing that produced an object event. Present ONLY on
17497
+ * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
17498
+ * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
17499
+ * appearance event carry none, so a rule asking for a direction fails closed
17500
+ * on them.
17501
+ *
17502
+ * Exactly ONE crossing per event: the emitter turns each confirmed crossing
17503
+ * into its own event, so a frame in which a track enters A while leaving B
17504
+ * produces two events with two directions — never one ambiguous row.
17505
+ *
17506
+ * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
17507
+ * membership the box has NOW, and by definition it no longer contains the zone
17508
+ * that was just left. Without the id here, a zone-scoped rule could never match
17509
+ * the exit it asked for.
17510
+ */
17511
+ var ZoneCrossingSchema = object({
17512
+ direction: _enum(["enter", "exit"]),
17513
+ /** Admin zone id crossed. */
17514
+ zoneId: string(),
17515
+ /** Zone display name at crossing time (falls back to the id). */
17516
+ zoneName: string().optional()
17517
+ });
17518
+ var ObjectEventSchema = object({
17519
+ ...BaseEventFields,
17520
+ kind: literal("object"),
17521
+ /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
17522
+ source: DetectionSourceSchema.optional(),
17523
+ /**
17524
+ * Inference-frame id shared by every object event emitted from the SAME frame
17525
+ * — the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
17526
+ * 2 people + 1 dog) under one full frame, and link a track's frames over time
17527
+ * (group by `trackId`, pick a representative `frameId` as the parent frame).
17528
+ * Optional for backward-compat with pre-existing rows / the slim projection
17529
+ * includes it (it is light). Absent on rows written before this field.
17530
+ */
17531
+ frameId: string().optional(),
17532
+ /** Omitted in slim projection. */
17533
+ trackId: string().optional(),
17534
+ className: string(),
17535
+ ...TieredLabelFields,
17536
+ /** Omitted in slim projection. */
17537
+ confidence: number$1().optional(),
17538
+ /** Heavy JSON — omitted in slim projection. */
17539
+ bbox: BoundingBoxSchema.optional(),
17540
+ /** Heavy JSON — omitted in slim projection. */
17541
+ zones: array(string()).readonly().optional(),
17542
+ /** Omitted in slim projection. */
17543
+ state: TrackStateSchema.optional(),
17544
+ /**
17545
+ * The zone crossing this event IS, when it is one. Absent on every other
17546
+ * event kind (movement state, appearance, package) — see
17547
+ * {@link ZoneCrossingSchema}. Omitted in slim projection.
17548
+ */
17549
+ zoneCrossing: ZoneCrossingSchema.optional(),
17550
+ /** Detection-frame dimensions in pixels — let consumers normalize the
17551
+ * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
17552
+ frameWidth: number$1().optional(),
17553
+ frameHeight: number$1().optional(),
17554
+ /** MediaStore key for the crop attached to this event (if any). */
17555
+ mediaKey: string().optional(),
17556
+ /** Design B: MediaStore key of the track's native-resolution key frame (the
17557
+ * best-detection full frame). Resolve via the event-media data-plane
17558
+ * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
17559
+ * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
17560
+ * sources — consumers fall back to `mediaKey` (the tight crop). */
17561
+ keyFrameMediaKey: string().optional(),
17562
+ /** Populated by B5 (recording playback URL for this event). */
17563
+ mediaUrl: string().optional(),
17564
+ /** The parent track's key-event importance [0,1], propagated to every object
17565
+ * event of the track (so an event row can be sorted by importance without a
17566
+ * track join). Absent on legacy rows / before the track was scored. */
17567
+ importance: number$1().optional()
17568
+ });
17569
+ var AudioEventSchema = object({
17570
+ ...BaseEventFields,
17571
+ kind: literal("audio"),
17572
+ rms: number$1(),
17573
+ dbfs: number$1(),
17574
+ classification: object({
17575
+ className: string(),
17576
+ originalClass: string().optional(),
17577
+ score: number$1()
17578
+ }).optional(),
17579
+ /** Populated by B5 (recording playback URL for this event). */
17580
+ mediaUrl: string().optional()
17581
+ });
17582
+ var MediaFileKindEnum = _enum([
17583
+ "crop",
17584
+ "thumbnail",
17585
+ "snapshot",
17586
+ "firstFrame",
17587
+ "lastFrame",
17588
+ "fullFrame",
17589
+ "fullFrameBoxed",
17590
+ "faceCrop",
17591
+ "plateCrop",
17592
+ "keyFrame",
17593
+ "keyFrameSmall",
17594
+ "thumbnailSmall"
17595
+ ]);
17596
+ var MediaFileSchema = object({
17597
+ key: string(),
17598
+ kind: MediaFileKindEnum,
17549
17599
  base64: string(),
17550
- width: number$1().int(),
17551
- height: number$1().int()
17552
- }), {
17553
- kind: "query",
17554
- auth: "admin"
17555
- }), method(object({
17556
- deviceId: number$1(),
17557
- trackId: string(),
17558
- frameId: string(),
17559
- subject: RetrainAssistSubjectSchema,
17560
- /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
17561
- nodeId: string().optional()
17562
- }), RetrainAssistResultSchema, {
17563
- kind: "mutation",
17564
- auth: "admin"
17565
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
17566
- kind: "query",
17567
- auth: "admin"
17568
- }), method(object({
17569
- deviceId: number$1(),
17570
- trackId: string(),
17571
- frameId: string(),
17572
- annotations: array(RetrainAnnotationDraftSchema)
17573
- }), array(RetrainAnnotationSchema).readonly(), {
17574
- kind: "mutation",
17575
- auth: "admin"
17576
- }), method(object({
17577
- deviceId: number$1(),
17578
- trackId: string()
17579
- }), RetrainTransitionResultSchema, {
17580
- kind: "mutation",
17581
- auth: "admin"
17582
- }), method(object({
17583
- deviceId: number$1(),
17584
- trackId: string()
17585
- }), RetrainTransitionResultSchema, {
17586
- kind: "mutation",
17587
- auth: "admin"
17588
- }), method(object({ deviceIds: array(number$1()).optional() }), object({ url: string() }), {
17589
- kind: "query",
17590
- auth: "admin"
17591
- }), method(object({
17592
- eventId: string(),
17593
- kind: MediaFileKindEnum.optional(),
17594
- deviceId: number$1()
17595
- }), array(MediaFileSchema).readonly()), method(object({
17596
- trackId: string(),
17597
- kinds: array(MediaFileKindEnum).optional(),
17598
- deviceId: number$1()
17599
- }), array(MediaFileSchema).readonly()), method(object({
17600
+ sizeBytes: number$1(),
17601
+ timestamp: number$1()
17602
+ });
17603
+ /**
17604
+ * One media row WITHOUT its bytes.
17605
+ *
17606
+ * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
17607
+ * 140 s track), and a client that renders tiles from the media data plane needs
17608
+ * to know only WHAT EXISTS — the bytes then arrive per tile, lazily, over HTTP
17609
+ * with an immutable cache, instead of all at once inside a tRPC response that
17610
+ * blocks the whole view.
17611
+ *
17612
+ * `sizeBytes` is carried because it is what lets a client decide between the
17613
+ * stored blob and a `?variant=thumb` rendering without fetching either.
17614
+ */
17615
+ var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
17616
+ /**
17617
+ * The MACRO tier of an annotation — a CLOSED set.
17618
+ *
17619
+ * This is what the exported detector predicts, so a typo here is a new class
17620
+ * with one example in it. `label` and `subLabel` are open strings by contrast:
17621
+ * the whole point of the page is teaching the model things it does not know
17622
+ * yet, and constraining that vocabulary would make it useless.
17623
+ *
17624
+ * A macro class is NEVER a label. The provider refuses a write whose `label` or
17625
+ * `subLabel` is one of these values, in any casing, because once `person`
17626
+ * exists in both tiers "every person box" stops being answerable without
17627
+ * knowing every string anyone ever typed — and the damage is retroactive.
17628
+ */
17629
+ var RetrainMacroClassSchema = _enum([
17630
+ "person",
17631
+ "vehicle",
17632
+ "animal",
17633
+ "package",
17634
+ "face",
17635
+ "plate"
17636
+ ]);
17637
+ /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
17638
+ var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
17639
+ /** Did a human draw this box, or did the assist propose it? */
17640
+ var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
17641
+ /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
17642
+ var RetrainBboxSchema = object({
17643
+ x: number$1(),
17644
+ y: number$1(),
17645
+ w: number$1(),
17646
+ h: number$1()
17647
+ });
17648
+ /**
17649
+ * One annotated subject.
17650
+ *
17651
+ * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
17652
+ * (letterboxed root / zone-cropped package / subject-cropped classifier) are
17653
+ * derived from it at export and never stored — storing them is how one feature
17654
+ * space ends up holding two crops of the same subject (D52).
17655
+ */
17656
+ var RetrainAnnotationSchema = object({
17657
+ id: string(),
17600
17658
  trackId: string(),
17601
- deviceId: number$1()
17602
- }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
17603
- kind: "mutation",
17604
- auth: "admin"
17605
- }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
17606
- kind: "mutation",
17607
- auth: "admin"
17608
- }), method(object({}), RebuildStatusSchema), object({
17609
- deviceId: number$1(),
17610
- timestamp: number$1(),
17611
- frameWidth: number$1(),
17612
- frameHeight: number$1(),
17613
- detections: array(OverlayDetectionSchema).readonly()
17614
- }), object({
17615
17659
  deviceId: number$1(),
17660
+ /** The COPY in retrain storage — never the source track's media key. */
17661
+ mediaKey: string(),
17662
+ bbox: RetrainBboxSchema,
17663
+ macroClass: RetrainMacroClassSchema,
17664
+ label: string().optional(),
17665
+ subLabel: string().optional(),
17666
+ kind: RetrainAnnotationKindSchema,
17667
+ source: RetrainAnnotationSourceSchema,
17668
+ /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
17669
+ assistModelId: string().optional(),
17670
+ assistScore: number$1().optional(),
17671
+ exportedInBatch: string().optional(),
17672
+ createdAt: number$1()
17673
+ });
17674
+ /** The write form — the server owns `id`, `createdAt` and the frame binding. */
17675
+ var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
17676
+ id: true,
17677
+ trackId: true,
17678
+ deviceId: true,
17679
+ mediaKey: true,
17680
+ createdAt: true,
17681
+ exportedInBatch: true
17682
+ });
17683
+ /** A track sitting in `staging`, with everything the worklist needs to rank it. */
17684
+ var RetrainTrackSchema = object({
17616
17685
  trackId: string(),
17617
- className: string()
17618
- }), object({
17619
17686
  deviceId: number$1(),
17620
- trackId: string(),
17621
17687
  className: string(),
17622
- durationMs: number$1()
17623
- }), object({
17688
+ label: string().optional(),
17689
+ firstSeen: number$1(),
17690
+ lastSeen: number$1(),
17691
+ /** How many frames the dataset already holds from this track. */
17692
+ frameCount: number$1().int(),
17693
+ /** How many subjects have been annotated on those frames. `0` with
17694
+ * `frameCount: 0` is exactly "staging, still to work". */
17695
+ annotationCount: number$1().int()
17696
+ });
17697
+ /** A frame the picker may offer — an index row, no blob was read to produce it. */
17698
+ var RetrainFrameCandidateSchema = object({
17699
+ mediaKey: string(),
17700
+ kind: MediaFileKindEnum,
17701
+ timestamp: number$1(),
17702
+ sizeBytes: number$1().int(),
17703
+ /** A copy of this original already exists — selecting it is free and cannot
17704
+ * fail, whatever became of the original. */
17705
+ copied: boolean()
17706
+ });
17707
+ /** A frame the dataset OWNS: bytes copied at selection time. */
17708
+ var RetrainFrameSchema = object({
17709
+ frameId: string(),
17624
17710
  deviceId: number$1(),
17625
- kind: EventKindSchema,
17626
- eventId: string(),
17627
- timestamp: number$1()
17711
+ trackId: string(),
17712
+ /** Provenance only. It may already point at nothing — that is expected. */
17713
+ sourceMediaKey: string(),
17714
+ sourceKind: MediaFileKindEnum,
17715
+ sizeBytes: number$1().int(),
17716
+ width: number$1().int(),
17717
+ height: number$1().int(),
17718
+ copiedAt: number$1()
17719
+ });
17720
+ /** Why a copy-on-select could not be honoured — named, never a silent skip. */
17721
+ var RetrainCopyRefusalSchema = _enum([
17722
+ "source-missing",
17723
+ "unreadable-image",
17724
+ "write-failed"
17725
+ ]);
17726
+ var RetrainFrameSelectionSchema = object({
17727
+ copied: array(RetrainFrameSchema).readonly(),
17728
+ refused: array(object({
17729
+ sourceMediaKey: string(),
17730
+ reason: RetrainCopyRefusalSchema
17731
+ })).readonly()
17628
17732
  });
17733
+ var RetrainFrameListSchema = object({
17734
+ candidates: array(RetrainFrameCandidateSchema).readonly(),
17735
+ copies: array(RetrainFrameSchema).readonly(),
17736
+ /** What the page pre-selects — the native key frame when one survives. */
17737
+ autoPickMediaKey: string().optional()
17738
+ });
17739
+ /** What the operator asked the assist to look for. */
17740
+ var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
17741
+ kind: literal("package"),
17742
+ zone: RetrainBboxSchema.optional()
17743
+ }), object({
17744
+ kind: literal("objects"),
17745
+ modelId: string(),
17746
+ minScore: number$1().optional()
17747
+ })]);
17629
17748
  /**
17630
- * Reference to the frame's retained NATIVE surface + the parent crop's placement
17631
- * within the frame, so the executor can re-cut a leaf child ROI at native
17632
- * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
17749
+ * The assist's answer — a discriminated union, because "the model saw nothing"
17750
+ * and "this node cannot run that model" lead to different next moves and a
17751
+ * nullable result cannot tell them apart.
17633
17752
  */
17634
- var NativeCropRefSchema = object({
17635
- /** Handle keying the retained native surface (node-pinned to its owner). */
17636
- handle: FrameHandleSchema,
17637
- /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
17638
- cropFrameSpace: object({
17639
- x: number$1(),
17640
- y: number$1(),
17641
- w: number$1(),
17642
- h: number$1()
17643
- })
17753
+ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
17754
+ kind: literal("proposed"),
17755
+ modelId: string(),
17756
+ stepId: string(),
17757
+ minScore: number$1(),
17758
+ /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
17759
+ proposals: array(RetrainAnnotationDraftSchema).readonly(),
17760
+ /** Returned by the runner but removed by the threshold. */
17761
+ belowThreshold: number$1().int()
17762
+ }), object({
17763
+ kind: literal("refused"),
17764
+ /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
17765
+ reason: string(),
17766
+ detail: string().optional()
17767
+ })]);
17768
+ /** The outcome of a lifecycle move owned by the retrain page. */
17769
+ var RetrainTransitionResultSchema = object({
17770
+ trackId: string(),
17771
+ /** Where the track ended up, whatever happened. */
17772
+ retrainStatus: RetrainStatusSchema,
17773
+ /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
17774
+ changed: boolean(),
17775
+ reason: _enum([
17776
+ "unknown-track",
17777
+ "no-frames-copied",
17778
+ "not-staging",
17779
+ "not-trained",
17780
+ "unchanged"
17781
+ ]).optional()
17644
17782
  });
17645
- object({
17646
- crop: object({
17647
- left: number$1(),
17648
- top: number$1(),
17649
- width: number$1().positive(),
17650
- height: number$1().positive()
17651
- }).optional(),
17652
- content: object({
17653
- width: number$1().int().positive(),
17654
- height: number$1().int().positive()
17655
- }),
17656
- fit: _enum(["stretch", "contain"]),
17657
- format: _enum([
17658
- "rgb",
17659
- "gray",
17660
- "jpeg"
17661
- ])
17783
+ var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
17784
+ var MAX_EVENT_QUERY_LIMIT = 5e3;
17785
+ var DeviceEventQueryInput = object({
17786
+ deviceId: number$1(),
17787
+ since: number$1().optional(),
17788
+ until: number$1().optional(),
17789
+ limit: number$1().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
17790
+ /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
17791
+ * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
17792
+ * exact behaviour. Callers may omit this field — the store defaults to
17793
+ * `full` when not provided. */
17794
+ projection: _enum(["full", "slim"]).optional()
17662
17795
  });
17663
- var FrameRefSchema = object({
17664
- registryId: string().min(1),
17665
- id: string().min(1),
17666
- width: number$1().int().positive(),
17667
- height: number$1().int().positive(),
17668
- format: _enum(["rgb", "gray"]),
17669
- timestamp: number$1(),
17670
- capturedAt: number$1().optional()
17796
+ var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
17797
+ var RecentTracksQueryInput = object({
17798
+ /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
17799
+ deviceIds: array(number$1()),
17800
+ /** Window lower bound on `lastSeen` (inclusive). */
17801
+ since: number$1().optional(),
17802
+ /** Window upper bound on `lastSeen` (inclusive). */
17803
+ until: number$1().optional(),
17804
+ /** Page size. Default 200, max 1000. */
17805
+ limit: number$1().int().min(1).max(1e3).default(200),
17806
+ /** Opaque continuation cursor from a previous page's `nextCursor`.
17807
+ * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
17808
+ cursor: string().optional(),
17809
+ /** See {@link TrackProjectionSchema}. Default `full`. */
17810
+ projection: TrackProjectionSchema.optional(),
17811
+ /** Include stationary-promoted rows (parked objects). Default false: the
17812
+ * feed lists passages; parking records live on the stationary registry. */
17813
+ includeStationary: boolean().optional()
17671
17814
  });
17672
- var ModelFormatSchema$1 = _enum([
17673
- "onnx",
17674
- "coreml",
17675
- "openvino",
17676
- "tflite",
17677
- "pt",
17678
- "gguf"
17679
- ]);
17680
- var PipelineSlotSchema = _enum([
17681
- "detector",
17682
- "cropper",
17683
- "classifier",
17684
- "refiner",
17685
- "audio-classifier"
17686
- ]);
17687
- var PipelineEngineChoiceSchema = object({
17688
- runtime: _enum(["node", "python"]),
17689
- backend: string(),
17690
- format: ModelFormatSchema$1,
17691
- device: string().optional()
17815
+ var RecentTracksPageSchema = object({
17816
+ /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
17817
+ tracks: array(TrackSchema).readonly(),
17818
+ /** Cursor for the next page, or null when this page is the last. */
17819
+ nextCursor: string().nullable()
17820
+ });
17821
+ var LIST_GROUPS_DEFAULT_LIMIT = 40;
17822
+ var LIST_GROUPS_MAX_LIMIT = 100;
17823
+ var AnalyticsGroupRecordSchema = object({
17824
+ id: string(),
17825
+ deviceId: number$1().int(),
17826
+ openedAt: number$1().int(),
17827
+ closedAt: number$1().int(),
17828
+ timestamp: number$1().int(),
17829
+ memberCount: number$1().int(),
17830
+ memberTrackIds: array(string()).readonly(),
17831
+ className: string(),
17832
+ classes: array(string()).readonly(),
17833
+ /** Relative event-media path, or null when the group has no picture yet. */
17834
+ mediaUrl: string().nullable(),
17835
+ singleton: boolean()
17692
17836
  });
17693
- var AvailableEngineSchema = object({
17694
- engine: PipelineEngineChoiceSchema,
17695
- devices: array(object({
17696
- id: string(),
17697
- label: string(),
17698
- description: string().optional()
17699
- })).readonly(),
17700
- defaultDevice: string()
17837
+ var AnalyticsGroupMemberSchema = object({
17838
+ trackId: string(),
17839
+ deviceId: number$1().int(),
17840
+ className: string(),
17841
+ firstSeen: number$1().int(),
17842
+ lastSeen: number$1().int(),
17843
+ mediaUrl: string().nullable()
17701
17844
  });
17702
- var PipelineDefaultStepSchema = lazy(() => object({
17703
- addonId: string(),
17704
- addonName: string(),
17705
- slot: PipelineSlotSchema,
17706
- inputClasses: array(string()).readonly(),
17707
- outputClasses: array(string()).readonly(),
17708
- enabled: boolean(),
17709
- modelId: string(),
17710
- children: array(PipelineDefaultStepSchema).readonly(),
17711
- group: string().optional(),
17712
- settings: record(string(), unknown()).optional()
17713
- }));
17714
- var PipelineTemplateStepSchema = lazy(() => object({
17715
- addonId: string(),
17716
- enabled: boolean(),
17717
- modelId: string(),
17718
- children: array(PipelineTemplateStepSchema).readonly(),
17719
- settings: record(string(), unknown()).optional()
17720
- }));
17721
- var PipelineTemplateSchema$1 = object({
17722
- id: string(),
17723
- name: string(),
17724
- createdAt: string(),
17725
- updatedAt: string(),
17726
- engine: PipelineEngineChoiceSchema,
17727
- steps: array(PipelineTemplateStepSchema).readonly()
17845
+ var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
17846
+ var ListGroupsQueryInput = object({
17847
+ /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
17848
+ deviceIds: array(number$1()),
17849
+ /** Window lower bound on `closedAt` (inclusive). */
17850
+ since: number$1().optional(),
17851
+ /** Window upper bound on `openedAt` (inclusive). */
17852
+ until: number$1().optional(),
17853
+ limit: number$1().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
17854
+ /** Opaque continuation cursor from a previous page's `nextCursor`. */
17855
+ cursor: string().optional()
17728
17856
  });
17729
- var PipelineModelOptionSchema = object({
17730
- id: string(),
17731
- name: string(),
17732
- formats: record(string(), object({
17733
- downloaded: boolean(),
17734
- sizeMB: number$1()
17735
- })),
17736
- group: ModelVariantGroupSchema.optional(),
17737
- legacy: boolean().optional(),
17738
- provider: ModelProviderIdSchema.optional()
17857
+ var ListGroupsPageSchema = object({
17858
+ groups: array(AnalyticsGroupRecordSchema).readonly(),
17859
+ nextCursor: string().nullable()
17739
17860
  });
17740
- var ConfigFieldBridge = custom();
17741
- var PipelineAddonSchemaSchema = object({
17742
- id: string(),
17743
- name: string(),
17744
- slot: PipelineSlotSchema,
17745
- inputClasses: array(string()).readonly(),
17746
- outputClasses: array(string()).readonly(),
17747
- childSlots: array(PipelineSlotSchema).readonly(),
17748
- models: array(PipelineModelOptionSchema).readonly(),
17749
- defaultModelId: string(),
17750
- defaultModelIdByFormat: record(string(), string()).optional(),
17751
- enabledByDefault: boolean().optional(),
17752
- backfillIntoExistingOverrides: boolean().optional(),
17753
- defaultConfidence: number$1(),
17754
- group: string().optional(),
17755
- configSchema: array(ConfigFieldBridge).readonly().optional()
17861
+ var KeyEventQueryInput = object({
17862
+ deviceId: number$1(),
17863
+ /** Window lower bound (track firstSeen ≥ since). */
17864
+ since: number$1(),
17865
+ /** Window upper bound (track firstSeen ≤ until). */
17866
+ until: number$1(),
17867
+ limit: number$1().int().min(1).max(200).default(50),
17868
+ /** Drop tracks scoring below this importance. */
17869
+ minImportance: number$1().min(0).max(1).optional(),
17870
+ /** Restrict to a single class (e.g. 'person'). */
17871
+ classFilter: string().optional()
17756
17872
  });
17757
- var PipelineSlotSchemaSchema = object({
17758
- id: PipelineSlotSchema,
17759
- label: string(),
17760
- priority: number$1(),
17761
- parentSlot: PipelineSlotSchema.nullable(),
17762
- addons: array(PipelineAddonSchemaSchema).readonly()
17873
+ var KeyEventSchema = object({
17874
+ /** The representative event id (the track's best ObjectEvent, else its trackId). */
17875
+ id: string(),
17876
+ trackId: string(),
17877
+ /** Track start time (firstSeen). */
17878
+ timestamp: number$1(),
17879
+ className: string(),
17880
+ ...TieredLabelFields,
17881
+ importance: number$1(),
17882
+ /** Highest-confidence ObjectEvent id for the track (empty when none). */
17883
+ bestEventId: string(),
17884
+ /** Track lifetime in ms (lastSeen - firstSeen). */
17885
+ windowMs: number$1().optional(),
17886
+ ...TrackFlagFields,
17887
+ ...TrackRetrainFields
17763
17888
  });
17764
- var PipelineSchemaSchema = object({
17765
- availableEngines: array(AvailableEngineSchema).readonly(),
17766
- selectedEngine: PipelineEngineChoiceSchema,
17767
- slots: array(PipelineSlotSchemaSchema).readonly()
17889
+ object({
17890
+ trackId: string(),
17891
+ className: string(),
17892
+ confidence: number$1(),
17893
+ bbox: BoundingBoxSchema,
17894
+ zones: array(string()).readonly(),
17895
+ state: TrackStateSchema
17768
17896
  });
17769
- var EngineProvisioningSchema = object({
17770
- runtimeId: _enum([
17771
- "onnx",
17772
- "openvino",
17773
- "coreml",
17774
- "edgetpu"
17775
- ]).nullable(),
17776
- device: string().nullable(),
17777
- state: _enum([
17778
- "idle",
17779
- "installing",
17780
- "verifying",
17781
- "ready",
17782
- "failed"
17783
- ]),
17784
- progress: number$1().optional(),
17785
- error: string().optional(),
17786
- nextRetryAt: number$1().optional(),
17787
- /**
17788
- * Gate A (config-correctness gate at engine change): human-readable
17789
- * config issues surfaced EAGERLY when the node's engine changes — model
17790
- * substitutions ("chose X, running Y") and zero-build steps ("no model
17791
- * has a <format> build"). Additive/optional: informational only, never
17792
- * enforced here — `assertEngineReady` (readiness) still gates inference.
17793
- * Absent/empty when the node-default tree resolves cleanly.
17794
- */
17795
- configIssues: array(string()).optional()
17897
+ var OverlayDetectionSchema = looseObject({
17898
+ id: string(),
17899
+ kind: _enum(["first-level", "detail"]),
17900
+ macroClass: string(),
17901
+ score: number$1(),
17902
+ bbox: object({
17903
+ x: number$1(),
17904
+ y: number$1(),
17905
+ width: number$1(),
17906
+ height: number$1()
17907
+ }),
17908
+ labels: array(looseObject({
17909
+ label: string(),
17910
+ score: number$1()
17911
+ })).readonly(),
17912
+ parentId: string().optional()
17796
17913
  });
17797
- var PipelineStepInputSchema = lazy(() => object({
17798
- addonId: string(),
17799
- modelId: string().optional(),
17800
- enabled: boolean().default(true),
17801
- children: array(PipelineStepInputSchema).optional(),
17802
- settings: record(string(), unknown()).optional(),
17803
- jumpDeviceKey: string().optional()
17804
- }));
17805
- var ModelSubstitutionSchema = object({
17806
- addonId: string(),
17807
- chosen: string(),
17808
- running: string(),
17809
- format: string()
17914
+ var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number$1() });
17915
+ var SearchObjectEventsInput = object({
17916
+ text: string(),
17917
+ deviceId: number$1().optional(),
17918
+ since: number$1().optional(),
17919
+ until: number$1().optional(),
17920
+ classFilter: string().optional(),
17921
+ limit: number$1().default(50),
17922
+ minScore: number$1().min(0).max(1).default(.2)
17810
17923
  });
17811
- var PipelineValidationIssueSchema = object({
17812
- addonId: string(),
17813
- kind: _enum(["unknown-addon", "no-format-build"]),
17814
- detail: string()
17924
+ var TrackCascadeCountsSchema = object({
17925
+ /** Persisted track roots deleted (authoritative). */
17926
+ tracks: number$1().int(),
17927
+ /** Object events removed with their tracks (best-effort; see note above). */
17928
+ events: number$1().int(),
17929
+ /** Track/face/plate-owned media removed (best-effort). Never identity media. */
17930
+ media: number$1().int(),
17931
+ /** Unassigned (non-enrolled) face reads removed (best-effort). */
17932
+ faces: number$1().int(),
17933
+ /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
17934
+ plates: number$1().int(),
17935
+ /** Per-track CLIP search vectors removed (best-effort). */
17936
+ embeddings: number$1().int(),
17937
+ /** Group membership + group rows removed with their last member (best-effort). */
17938
+ groups: number$1().int()
17815
17939
  });
17816
- var PipelineValidationResultSchema = object({
17817
- ok: boolean(),
17818
- issues: array(PipelineValidationIssueSchema).readonly(),
17819
- substitutions: array(ModelSubstitutionSchema).readonly(),
17820
- /** The node's `currentEngine.format` this validation ran against. */
17821
- format: string()
17940
+ /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
17941
+ var DiskReconcileCountsSchema = object({
17942
+ mediaDropped: number$1().int(),
17943
+ tracks: number$1().int(),
17944
+ events: number$1().int()
17822
17945
  });
17823
- var ReferenceImageEntrySchema = object({
17824
- filename: string(),
17825
- stepIds: array(string()).readonly().optional()
17946
+ /** Event-store footprint for one camera. */
17947
+ var EventStoreDeviceFootprintSchema = object({
17948
+ deviceId: number$1(),
17949
+ /** Persisted event rows (motion + object + audio) for the camera. */
17950
+ rows: number$1().int(),
17951
+ /** Event-owned media bytes on disk for the camera. */
17952
+ bytes: number$1().int()
17826
17953
  });
17827
- var ReferenceImageBodySchema = object({
17828
- base64: string(),
17829
- filename: string()
17954
+ /** Aggregate event-store footprint: global totals + per-camera breakdown. */
17955
+ var EventStoreFootprintSchema = object({
17956
+ totalRows: number$1().int(),
17957
+ totalBytes: number$1().int(),
17958
+ devices: array(EventStoreDeviceFootprintSchema).readonly()
17830
17959
  });
17831
- var ReferenceAudioEntrySchema = object({
17832
- filename: string(),
17833
- sizeKb: number$1()
17960
+ /** Per-kind counts returned by the event-prune / device-delete mutations. */
17961
+ var EventPruneCountsSchema = object({
17962
+ motion: number$1().int(),
17963
+ object: number$1().int(),
17964
+ audio: number$1().int()
17834
17965
  });
17835
- var ReferenceAudioBodySchema = object({ base64: string() });
17836
- var AudioBackendSchema = object({
17837
- id: string(),
17838
- name: string(),
17839
- description: string(),
17840
- available: boolean(),
17966
+ /**
17967
+ * Re-embed stored tracks from their key frames.
17968
+ *
17969
+ * The reason this is an operator-callable method and not a migration script:
17970
+ * every knob that decides what a vector MEANS — encoder model, crop margin,
17971
+ * squaring — is only changeable if the existing vectors can be regenerated.
17972
+ * Mixing feature spaces in one index makes cosine scores incomparable, and the
17973
+ * symptom is a quality regression with no visible cause.
17974
+ */
17975
+ var RebuildObjectEmbeddingsInput = object({
17976
+ /** Restrict to one camera. Omit for the whole fleet. */
17977
+ deviceId: number$1().optional(),
17978
+ since: number$1().optional(),
17979
+ until: number$1().optional(),
17980
+ /** Stop after this many tracks; the result reports whether more remain. */
17981
+ maxTracks: number$1().int().positive().optional(),
17841
17982
  /**
17842
- * Raw classifier labels this backend can emit (e.g. YAMNet's
17843
- * 521-class set or Apple SoundAnalysis's 303-class set). Used by
17844
- * the benchmark UI to populate the `enabledMicroClasses` filter
17845
- * specific to the selected backend without a separate fetch.
17983
+ * Run every embedding on THIS node instead of round-robining the fleet.
17984
+ *
17985
+ * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
17986
+ * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
17987
+ * calling it that would pin the rebuild REQUEST itself to that node — the
17988
+ * rebuild orchestration lives on the hub, and only the per-track step runs
17989
+ * remotely. This field is data; the per-track pin is applied inside.
17990
+ *
17991
+ * Absent ⇒ round-robin over every online node whose runner can serve the
17992
+ * pinned model.
17846
17993
  */
17847
- rawLabels: array(string()).readonly().optional()
17848
- });
17849
- var AudioCapabilitiesSchema = object({
17850
- activeBackend: string(),
17851
- availableBackends: array(AudioBackendSchema).readonly(),
17852
- sampleRate: number$1(),
17853
- chunkDurationMs: number$1()
17854
- });
17855
- var DownloadModelResultSchema = object({
17856
- filePath: string(),
17857
- sizeMB: number$1(),
17858
- durationMs: number$1()
17994
+ executeOnNodeId: string().optional(),
17995
+ /**
17996
+ * Milliseconds to wait between tracks; omit for the built-in default, `0` to
17997
+ * run flat out.
17998
+ *
17999
+ * A rebuild is bulk maintenance on hub-main's single thread. Measured
18000
+ * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
18001
+ * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
18002
+ * force is logged at start and finish so a deliberately slow pass reads
18003
+ * differently from a stalled one.
18004
+ */
18005
+ pacingMs: number$1().int().nonnegative().optional()
17859
18006
  });
17860
18007
  /**
17861
- * Wrapper carrying a single test run's result. Replaces the legacy
17862
- * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
17863
- * canonical `AudioResult` from the Phase 6 output rework: one
17864
- * `AudioDetection` per class above `minScore`, top-N candidates in
17865
- * `debug.alternateLabels['audio-classifier']`, per-source timings in
17866
- * `debug.stepTimings`. The outer `success`/`error` fields stay so the
17867
- * benchmark UI can still report a clean failure when the classifier
17868
- * cap isn't available.
18008
+ * Result of emptying the CLIP index.
18009
+ *
18010
+ * The clean slate before a policy change: a new crop margin or encoder model
18011
+ * leaves two feature spaces in one index whose cosine scores are not
18012
+ * comparable, so wiping and rebuilding is the only way to be sure every vector
18013
+ * means the same thing.
17869
18014
  */
17870
- var AudioTestResultSchema = object({
17871
- success: boolean(),
17872
- error: string().optional(),
17873
- frame: custom().optional()
18015
+ var WipeObjectEmbeddingsResultSchema = object({ deleted: number$1() });
18016
+ /**
18017
+ * Acknowledgement that a rebuild STARTED.
18018
+ *
18019
+ * The pass costs ~1s per track — 45 minutes for a 2,600-track fleet — so it
18020
+ * runs detached and this returns immediately. Waiting for it made the client
18021
+ * time out while the work carried on server-side, which is the worst of both:
18022
+ * no result and no way to know it was still going. Poll
18023
+ * `getObjectEmbeddingRebuildStatus` for progress.
18024
+ */
18025
+ var RebuildObjectEmbeddingsResultSchema = object({
18026
+ started: boolean(),
18027
+ /** True when a pass was already running; the new request is ignored. */
18028
+ alreadyRunning: boolean()
17874
18029
  });
17875
- var PipelineConfigBridge = custom();
17876
- var ConfigUISchemaBridge = custom();
17877
- var ConfigUISchemaNullableBridge = custom();
17878
- var InferenceCapabilitiesBridge = custom();
17879
- var ModelAvailabilityListBridge = custom();
17880
- var PipelineRunResultBridge = custom();
17881
- method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
17882
- modelId: string(),
17883
- settings: record(string(), unknown()).readonly()
17884
- }))), method(object({ steps: record(string(), object({
17885
- modelId: string(),
17886
- settings: record(string(), unknown()).readonly()
17887
- })) }), object({ success: literal(true) }), {
18030
+ var RebuildStatusSchema = object({
18031
+ running: boolean(),
18032
+ scanned: number$1(),
18033
+ rebuilt: number$1(),
18034
+ /** Tracks whose key frame is gone — nothing to re-embed from. */
18035
+ missingKeyFrame: number$1(),
18036
+ /** Tracks with no usable detection box. */
18037
+ missingBbox: number$1(),
18038
+ /**
18039
+ * Tracks an executing node REFUSED rather than broke on — an unreadable key
18040
+ * frame, a step that threw. Separate from `failed` because the remedy is
18041
+ * different, and because a whole camera silently contributing zero vectors
18042
+ * is the shape of failure a rebuild must never hide.
18043
+ */
18044
+ notRunnable: number$1(),
18045
+ /**
18046
+ * The pass stopped because NO node could serve the pinned model.
18047
+ *
18048
+ * Distinct from `notRunnable` on purpose: that one says "this track was
18049
+ * refused", this one says "the cluster cannot do this work at all" — every
18050
+ * candidate node either lacks the `clip-embedding` step, lacks a build of the
18051
+ * pinned model for its engine format, or dropped out. The remedy is a model /
18052
+ * engine change, not a per-camera one. Non-zero here always comes with
18053
+ * `complete: false`.
18054
+ */
18055
+ noCapableNode: number$1(),
18056
+ failed: number$1(),
18057
+ /** Set once a pass ends: true only when EVERYTHING was covered. */
18058
+ complete: boolean().nullable(),
18059
+ startedAtMs: number$1().nullable(),
18060
+ finishedAtMs: number$1().nullable(),
18061
+ /** Present when the pass ended by throwing. */
18062
+ error: string().nullable()
18063
+ });
18064
+ var ReplayFrameInputSchema = object({
18065
+ timestamp: number$1(),
18066
+ frame: PipelineRunResultBridge
18067
+ });
18068
+ var RunReplayFrameProcessorResultSchema = object({ tracks: array(object({
18069
+ className: string(),
18070
+ firstSeenMs: number$1(),
18071
+ lastSeenMs: number$1(),
18072
+ /** Bbox of the track's FIRST matched detection, pixel-space in the clip's
18073
+ * frame — a representative box for the diff's `(className, window, IoU)`
18074
+ * pairing (`replay-diff.ts`). A replay does not need the full per-frame
18075
+ * trajectory production's `Track.positions` keeps. */
18076
+ bbox: BoundingBoxSchema,
18077
+ /** How many of the input frames this track matched a real detection on
18078
+ * (never a coasted/extrapolated frame) — the replay's own signal for "how
18079
+ * solid is this track", cheaper than re-deriving it from a trajectory. */
18080
+ framesMatched: number$1().int()
18081
+ })).readonly() });
18082
+ DeviceType.Camera, method(object({ deviceId: number$1() }), array(TrackSchema).readonly()), method(object({
18083
+ deviceId: number$1(),
18084
+ trackId: string()
18085
+ }), TrackSchema.nullable()), method(object({
18086
+ deviceId: number$1(),
18087
+ since: number$1().optional(),
18088
+ until: number$1().optional(),
18089
+ limit: number$1().optional(),
18090
+ /** Spatial filter — only tracks whose trajectory intersects the zone
18091
+ * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
18092
+ * envelope columns, then precisely tested per position. Tracks with
18093
+ * an unknown envelope (no frame dims at persist time) always match. */
18094
+ zone: TrackZoneFilterSchema.optional(),
18095
+ /** See {@link TrackProjectionSchema}. Default `full` (backward
18096
+ * compatible — omitting the field keeps today's exact behaviour). */
18097
+ projection: TrackProjectionSchema.optional(),
18098
+ /** Include stationary-promoted rows (parked objects handed to the
18099
+ * stationary registry). Default false: the timeline lists passages,
18100
+ * not parking records (operator decision, 2026-08-15). */
18101
+ includeStationary: boolean().optional()
18102
+ }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
18103
+ deviceId: number$1(),
18104
+ groupId: string().min(1)
18105
+ }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number$1() }), _void(), {
18106
+ kind: "mutation",
18107
+ auth: "admin"
18108
+ }), 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({
18109
+ deviceId: number$1(),
18110
+ since: number$1().optional(),
18111
+ until: number$1().optional(),
18112
+ kinds: array(string()).optional(),
18113
+ limit: number$1().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
18114
+ }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
18115
+ deviceId: number$1(),
18116
+ since: number$1(),
18117
+ until: number$1(),
18118
+ bucketMs: number$1().int().positive()
18119
+ }), array(object({
18120
+ bucketStart: number$1(),
18121
+ motion: number$1().int(),
18122
+ object: number$1().int(),
18123
+ audio: number$1().int()
18124
+ })).readonly()), method(object({
18125
+ deviceId: number$1(),
18126
+ cutoffMs: number$1()
18127
+ }), object({
18128
+ motion: number$1().int(),
18129
+ object: number$1().int(),
18130
+ audio: number$1().int()
18131
+ }), {
18132
+ kind: "mutation",
18133
+ auth: "admin"
18134
+ }), method(object({
18135
+ deviceId: number$1(),
18136
+ cutoffMs: number$1()
18137
+ }), TrackCascadeCountsSchema, {
18138
+ kind: "mutation",
18139
+ auth: "admin"
18140
+ }), method(object({ deviceId: number$1() }), TrackCascadeCountsSchema, {
18141
+ kind: "mutation",
18142
+ auth: "admin"
18143
+ }), method(object({ deviceId: number$1() }), DiskReconcileCountsSchema, {
18144
+ kind: "mutation",
18145
+ auth: "admin"
18146
+ }), method(object({
18147
+ deviceId: number$1(),
18148
+ trackIds: array(string()).min(1)
18149
+ }), object({
18150
+ deleted: number$1().int(),
18151
+ failed: array(string()).readonly()
18152
+ }), {
18153
+ kind: "mutation",
18154
+ auth: "admin"
18155
+ }), method(object({
18156
+ /** Log/audit scope only — the trackId is globally unique on its own. */
18157
+ deviceId: number$1(),
18158
+ trackId: string(),
18159
+ flags: TrackFlagsPatchSchema
18160
+ }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
18161
+ kind: "query",
18162
+ auth: "admin"
18163
+ }), method(object({
18164
+ olderThanMs: number$1(),
18165
+ reason: OpsLogReasonSchema.optional()
18166
+ }), EventPruneCountsSchema, {
18167
+ kind: "mutation",
18168
+ auth: "admin"
18169
+ }), method(object({ deviceId: number$1() }), EventPruneCountsSchema, {
18170
+ kind: "mutation",
18171
+ auth: "admin"
18172
+ }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
18173
+ kind: "mutation",
18174
+ auth: "admin"
18175
+ }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
18176
+ kind: "mutation",
18177
+ auth: "admin"
18178
+ }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
18179
+ kind: "mutation",
18180
+ auth: "admin"
18181
+ }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
18182
+ kind: "mutation",
18183
+ auth: "admin"
18184
+ }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18185
+ kind: "mutation",
18186
+ auth: "admin"
18187
+ }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
18188
+ kind: "mutation",
18189
+ auth: "admin"
18190
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
18191
+ kind: "query",
18192
+ auth: "admin"
18193
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18194
+ kind: "mutation",
18195
+ auth: "admin"
18196
+ }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
18197
+ kind: "query",
18198
+ auth: "admin"
18199
+ }), method(object({ deviceIds: array(number$1()).optional() }), TrainingExportSummarySchema, {
18200
+ kind: "query",
18201
+ auth: "admin"
18202
+ }), method(object({ deviceIds: array(number$1()).optional() }), object({ url: string() }), {
18203
+ kind: "query",
18204
+ auth: "admin"
18205
+ }), method(object({
18206
+ /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
18207
+ * `deviceId`, deliberately: `deviceId` would make this device-bound and
18208
+ * route it at one camera's owner, and "every camera" would stop being
18209
+ * expressible at all. */
18210
+ deviceIds: array(number$1()).optional(),
18211
+ limit: number$1().int().min(1).max(500).optional()
18212
+ }), array(RetrainTrackSchema).readonly(), {
18213
+ kind: "query",
18214
+ auth: "admin"
18215
+ }), method(object({ trackId: string() }), RetrainFrameListSchema, {
18216
+ kind: "query",
18217
+ auth: "admin"
18218
+ }), method(object({
18219
+ deviceId: number$1(),
18220
+ trackId: string(),
18221
+ mediaKeys: array(string()).min(1)
18222
+ }), RetrainFrameSelectionSchema, {
17888
18223
  kind: "mutation",
17889
18224
  auth: "admin"
17890
- }), method(object({ nodeId: string() }), object({
17891
- success: literal(true),
17892
- clearedDevices: number$1()
18225
+ }), method(object({
18226
+ deviceId: number$1(),
18227
+ trackId: string(),
18228
+ frameId: string()
18229
+ }), object({
18230
+ removed: boolean(),
18231
+ removedAnnotations: number$1().int()
17893
18232
  }), {
17894
18233
  kind: "mutation",
17895
18234
  auth: "admin"
17896
- }), 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({
17897
- name: string(),
17898
- steps: array(PipelineTemplateStepSchema).readonly(),
17899
- engine: PipelineEngineChoiceSchema
17900
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
17901
- id: string(),
17902
- name: string().optional(),
17903
- steps: array(PipelineTemplateStepSchema).readonly().optional()
17904
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
17905
- addonId: string(),
17906
- modelId: string(),
17907
- format: ModelFormatSchema$1
17908
- }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
17909
- addonId: string(),
17910
- modelId: string(),
17911
- format: ModelFormatSchema$1
17912
- }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
17913
- engine: PipelineEngineChoiceSchema.optional(),
17914
- steps: array(PipelineStepInputSchema).min(1),
17915
- frame: FrameInputSchema.optional(),
17916
- /**
17917
- * Process-local lazy frame. Valid only when caller and provider resolve
17918
- * in the same execution-group process; split/cross-node callers use
17919
- * `frame`/`image` inline compatibility instead.
17920
- */
17921
- frameRef: FrameRefSchema.optional(),
17922
- /**
17923
- * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
17924
- * the decoded pixels live in. One more member of the one-of
17925
- * frame/frameHandle/image/imageBase64/referenceImage group.
17926
- */
17927
- frameHandle: FrameHandleSchema.optional(),
17928
- imageBase64: string().optional(),
17929
- /**
17930
- * Binary JPEG bytes — preferred over `imageBase64` on internal
17931
- * hops (hub → forked worker via Moleculer MsgPack) because it
17932
- * skips the 33% base64 overhead + the per-call base64 decode on
17933
- * the detection-pipeline worker. Callers can pass either; exactly
17934
- * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
17935
- */
17936
- image: _instanceof(Uint8Array).optional(),
17937
- referenceImage: string().optional(),
17938
- deviceId: number$1().optional(),
17939
- sessionId: string().optional(),
17940
- /**
17941
- * Execution plane. 'full' (default) runs the whole tree — benchmark,
17942
- * reference-image, and detail-subtree calls. 'frame' is the live
17943
- * per-frame dispatch: ONLY root-plane steps run; crop children
17944
- * (inputClasses ≠ null) are skipped and served per-track via
17945
- * pipelineRunner.runDetailSubtree (two-plane design).
17946
- */
17947
- plane: _enum(["full", "frame"]).optional(),
17948
- /**
17949
- * Inference-device selector (Phase 2 multi-device). Format
17950
- * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
17951
- * Omitted ⇒ the runner's default device (current single-engine
17952
- * behaviour). Selects WHICH device pool of the node runs the call.
17953
- */
17954
- deviceKey: string().optional(),
17955
- /**
17956
- * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
17957
- * when the parent crop was resolved from the frame's retained NATIVE
17958
- * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
17959
- * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
17960
- * resolution from that surface — the SAME quality path faces already
17961
- * had — instead of the downscaled parent tile. `handle` keys the native
17962
- * surface (node-pinned to its owner); `cropFrameSpace` is the parent
17963
- * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
17964
- * the executor's crop-normalized child ROI back into frame-normalized
17965
- * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
17966
- * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
17967
- * (today's behaviour on the fallback path).
17968
- */
17969
- nativeCropRef: NativeCropRefSchema.optional()
17970
- }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
17971
- engine: PipelineEngineChoiceSchema.optional(),
17972
- steps: array(PipelineStepInputSchema).min(1),
17973
- frames: array(FrameInputSchema).min(1).max(255),
17974
- deviceId: number$1().optional(),
17975
- sessionId: string().optional(),
17976
- /**
17977
- * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
17978
- * the batch to the Python pool's bench preprocess cache
17979
- * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
17980
- * preprocessed ONCE and every later inference is a pure-inference cache
17981
- * hit — the sustained-throughput run measures inference, not
17982
- * decode+preprocess+infer. Omitted/0 for live frames (all different →
17983
- * full preprocess every call, correct). Fresh per sustained run;
17984
- * released via `uncacheFrame`.
17985
- */
17986
- frameId: number$1().int().nonnegative().optional(),
17987
- /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
17988
- deviceKey: string().optional()
17989
- }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
17990
- data: _instanceof(Uint8Array),
17991
- width: number$1().int().positive(),
17992
- height: number$1().int().positive(),
17993
- format: _enum([
17994
- "rgb",
17995
- "bgr",
17996
- "gray"
17997
- ])
17998
- }), object({
17999
- frameId: number$1(),
18000
- width: number$1(),
18001
- height: number$1()
18002
- }), { kind: "mutation" }), method(object({
18003
- stepId: string(),
18004
- frameId: number$1().int()
18005
- }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number$1().int() }), _void(), { kind: "mutation" }), method(_void(), object({
18006
- batchMode: string(),
18007
- windowMs: number$1(),
18008
- maxBatchSize: number$1(),
18009
- concurrency: number$1()
18010
- })), method(_void(), array(object({
18011
- engineKey: string(),
18012
- engine: PipelineEngineChoiceSchema,
18013
- modelsLoaded: array(string()).readonly(),
18014
- inUseByCameras: array(number$1()).readonly(),
18015
- /**
18016
- * Origin of this resident factory.
18017
- * - `runtime` — main camera-serving engine (no idle TTL).
18018
- * - `warm-override` — benchmark/test override held in the warm
18019
- * cache; auto-disposed after the idle TTL.
18020
- * - `device-pool` — a concurrent per-device pool (Phase 2
18021
- * multi-device, keyed by `deviceKey`) resolved
18022
- * via `resolveDeviceFactory`. Runs alongside the
18023
- * `runtime` engine on a DIFFERENT accelerator
18024
- * (NPU / iGPU / Coral) — this is how the
18025
- * Engines tab shows all pools running at once.
18026
- */
18027
- kind: _enum([
18028
- "runtime",
18029
- "warm-override",
18030
- "device-pool"
18031
- ]),
18032
- /** Native pid of the underlying Python pool (null when no pool). */
18033
- poolPid: number$1().nullable(),
18034
- /** ms since this factory was last used (null when not warm-tracked). */
18035
- idleMs: number$1().nullable(),
18036
- /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
18037
- idleTtlMs: number$1().nullable()
18038
- })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
18235
+ }), method(object({ frameId: string() }), object({
18236
+ base64: string(),
18237
+ width: number$1().int(),
18238
+ height: number$1().int()
18239
+ }), {
18240
+ kind: "query",
18241
+ auth: "admin"
18242
+ }), method(object({
18243
+ deviceId: number$1(),
18244
+ trackId: string(),
18245
+ frameId: string(),
18246
+ subject: RetrainAssistSubjectSchema,
18247
+ /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
18248
+ nodeId: string().optional()
18249
+ }), RetrainAssistResultSchema, {
18039
18250
  kind: "mutation",
18040
18251
  auth: "admin"
18041
18252
  }), method(object({
18042
- engine: PipelineEngineChoiceSchema,
18043
- force: boolean().optional()
18044
- }), object({
18045
- success: boolean(),
18046
- reason: string().optional()
18047
- }), {
18253
+ deviceId: number$1(),
18254
+ source: DetectionSourceSchema,
18255
+ zones: array(ZoneSchema).readonly().optional(),
18256
+ detectionRules: array(ZoneRuleSchema).readonly().optional(),
18257
+ zoneMembershipMinOverlap: number$1().min(0).max(1).optional(),
18258
+ frames: array(ReplayFrameInputSchema).min(1)
18259
+ }), RunReplayFrameProcessorResultSchema, {
18048
18260
  kind: "mutation",
18049
18261
  auth: "admin"
18050
- }), 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({
18051
- addonId: string(),
18052
- modelId: string(),
18053
- filename: string().optional(),
18054
- settings: record(string(), unknown()).optional()
18055
- }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
18262
+ }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
18263
+ kind: "query",
18264
+ auth: "admin"
18265
+ }), method(object({
18266
+ deviceId: number$1(),
18267
+ trackId: string(),
18268
+ frameId: string(),
18269
+ annotations: array(RetrainAnnotationDraftSchema)
18270
+ }), array(RetrainAnnotationSchema).readonly(), {
18271
+ kind: "mutation",
18272
+ auth: "admin"
18273
+ }), method(object({
18274
+ deviceId: number$1(),
18275
+ trackId: string()
18276
+ }), RetrainTransitionResultSchema, {
18277
+ kind: "mutation",
18278
+ auth: "admin"
18279
+ }), method(object({
18280
+ deviceId: number$1(),
18281
+ trackId: string()
18282
+ }), RetrainTransitionResultSchema, {
18283
+ kind: "mutation",
18284
+ auth: "admin"
18285
+ }), method(object({ deviceIds: array(number$1()).optional() }), object({ url: string() }), {
18286
+ kind: "query",
18287
+ auth: "admin"
18288
+ }), method(object({
18289
+ eventId: string(),
18290
+ kind: MediaFileKindEnum.optional(),
18291
+ deviceId: number$1()
18292
+ }), array(MediaFileSchema).readonly()), method(object({
18293
+ trackId: string(),
18294
+ kinds: array(MediaFileKindEnum).optional(),
18295
+ deviceId: number$1()
18296
+ }), array(MediaFileSchema).readonly()), method(object({
18297
+ trackId: string(),
18298
+ deviceId: number$1()
18299
+ }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
18300
+ kind: "mutation",
18301
+ auth: "admin"
18302
+ }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
18303
+ kind: "mutation",
18304
+ auth: "admin"
18305
+ }), method(object({}), RebuildStatusSchema), object({
18306
+ deviceId: number$1(),
18307
+ timestamp: number$1(),
18308
+ frameWidth: number$1(),
18309
+ frameHeight: number$1(),
18310
+ detections: array(OverlayDetectionSchema).readonly()
18311
+ }), object({
18312
+ deviceId: number$1(),
18313
+ trackId: string(),
18314
+ className: string()
18315
+ }), object({
18316
+ deviceId: number$1(),
18317
+ trackId: string(),
18318
+ className: string(),
18319
+ durationMs: number$1()
18320
+ }), object({
18321
+ deviceId: number$1(),
18322
+ kind: EventKindSchema,
18323
+ eventId: string(),
18324
+ timestamp: number$1()
18325
+ });
18056
18326
  object({
18057
18327
  activeCameras: number$1(),
18058
18328
  throttledCameras: number$1(),
@@ -18078,66 +18348,6 @@ var CameraMetricsSchema = object({
18078
18348
  });
18079
18349
  var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number$1() });
18080
18350
  /**
18081
- * Zone — pure geometry + identity. NO filtering behaviour.
18082
- *
18083
- * Zones describe **where** in the frame the operator wants to flag
18084
- * something; consumer-owned {@link ZoneRule} arrays describe **how**
18085
- * each pipeline stage uses them. Splitting the two means a single
18086
- * polygon "Driveway" can simultaneously back a motion-exclude rule,
18087
- * a detection-include rule on `['car']`, and an occupancy aggregate
18088
- * — without three duplicated polygons.
18089
- *
18090
- * Owned by the orchestrator addon (provider) and mirrored into the
18091
- * `zones` device-state slice on every mutation. Consumers
18092
- * (motion-wasm, pipeline-executor, analytics, admin UI) read either
18093
- * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
18094
- * mirror with `onChanged`).
18095
- *
18096
- * Coordinates are normalised fractions of the frame (0–1) so zones
18097
- * survive resolution changes and stream profile switches.
18098
- *
18099
- * `kind` discriminates between full polygons (closed regions used
18100
- * for intrusion / occupancy filters) and tripwires (open 2-point
18101
- * line segments used for cross events). Onboard / firmware-reported
18102
- * zones (Reolink, ONVIF) are out of scope for now — see the deferred
18103
- * task list.
18104
- */
18105
- var ZoneKindEnum = _enum(["polygon", "tripwire"]);
18106
- /** Polygon vertex in fraction-of-frame coordinates (0–1). */
18107
- var PolygonPointSchema = object({
18108
- x: number$1(),
18109
- y: number$1()
18110
- });
18111
- /** A camera detection zone — pure geometry/identity. */
18112
- var ZoneSchema = object({
18113
- id: string(),
18114
- name: string(),
18115
- kind: ZoneKindEnum.default("polygon"),
18116
- /** Polygon vertices, fraction of frame (0–1). */
18117
- polygon: array(PolygonPointSchema).readonly(),
18118
- /** Visual color for UI rendering. */
18119
- color: string().default("#3b82f6")
18120
- });
18121
- DeviceType.Camera, method(object({ deviceId: number$1() }), array(ZoneSchema).readonly()), method(object({
18122
- deviceId: number$1(),
18123
- zone: ZoneSchema
18124
- }), _void(), {
18125
- kind: "mutation",
18126
- auth: "admin"
18127
- }), method(object({
18128
- deviceId: number$1(),
18129
- zoneId: string()
18130
- }), _void(), {
18131
- kind: "mutation",
18132
- auth: "admin"
18133
- }), method(object({
18134
- deviceId: number$1(),
18135
- zone: ZoneSchema
18136
- }), _void(), {
18137
- kind: "mutation",
18138
- auth: "admin"
18139
- }), object({ zones: array(ZoneSchema).readonly() });
18140
- /**
18141
18351
  * A bounding box in NORMALIZED [0,1] frame coordinates for `getNativeCrop`. The
18142
18352
  * decode worker resolves it against the RETAINED native frame's real pixel dims,
18143
18353
  * so the caller supplies only the detection-res bbox divided by the detection
@@ -19825,7 +20035,7 @@ method(object({
19825
20035
  * linking rather than produce an eternal token.
19826
20036
  */
19827
20037
  ttlSec: union([number$1().int().positive(), literal("never")]).optional()
19828
- }), object({ token: string() })), method(object({ token: string() }), SsoBridgeClaimsSchema.nullable());
20038
+ }), object({ token: string() }), { auth: "admin" }), method(object({ token: string() }), SsoBridgeClaimsSchema.nullable(), { auth: "admin" });
19829
20039
  var ProviderListEntrySchema = discriminatedUnion("shouldSaveDiskSpace", [object({
19830
20040
  providerId: string().min(1),
19831
20041
  displayName: string().min(1),
@@ -19920,10 +20130,13 @@ var EvictResultSchema = object({
19920
20130
  /** True when the provider has nothing left it is willing to drop on this location. */
19921
20131
  exhausted: boolean()
19922
20132
  });
19923
- method(object({ locationId: string() }), EvictableUsageSchema), method(object({
20133
+ method(object({ locationId: string() }), EvictableUsageSchema, { auth: "admin" }), method(object({
19924
20134
  locationId: string(),
19925
20135
  targetBytes: number$1().int().positive()
19926
- }), EvictResultSchema, { kind: "mutation" });
20136
+ }), EvictResultSchema, {
20137
+ kind: "mutation",
20138
+ auth: "admin"
20139
+ });
19927
20140
  method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin" }), method(StorageMigrationInputSchema, object({ jobId: string() }), {
19928
20141
  kind: "mutation",
19929
20142
  auth: "admin"
@@ -19983,26 +20196,50 @@ var ReadChunkInputSchema = object({
19983
20196
  length: number$1()
19984
20197
  });
19985
20198
  var EndDownloadInputSchema = object({ downloadId: string() });
19986
- method(_void(), ProviderInfoSchema), method(object({ config: record(string(), unknown()) }), TestLocationResultSchema, { auth: "admin" }), method(object({
20199
+ method(_void(), ProviderInfoSchema, { auth: "admin" }), method(object({ config: record(string(), unknown()) }), TestLocationResultSchema, { auth: "admin" }), method(object({
19987
20200
  location: StorageLocationSchema,
19988
20201
  relativePath: string()
19989
- }), string()), method(object({
20202
+ }), string(), { auth: "admin" }), method(object({
19990
20203
  location: StorageLocationSchema,
19991
20204
  relativePath: string(),
19992
20205
  data: _instanceof(Uint8Array)
19993
- }), _void(), { kind: "mutation" }), method(object({
20206
+ }), _void(), {
20207
+ kind: "mutation",
20208
+ auth: "admin"
20209
+ }), method(object({
19994
20210
  location: StorageLocationSchema,
19995
20211
  relativePath: string()
19996
- }), _instanceof(Uint8Array)), method(object({
20212
+ }), _instanceof(Uint8Array), { auth: "admin" }), method(object({
19997
20213
  location: StorageLocationSchema,
19998
20214
  relativePath: string()
19999
- }), boolean()), method(object({
20215
+ }), boolean(), { auth: "admin" }), method(object({
20000
20216
  location: StorageLocationSchema,
20001
20217
  prefix: string().optional()
20002
- }), array(string()).readonly()), method(object({
20218
+ }), array(string()).readonly(), { auth: "admin" }), method(object({
20003
20219
  location: StorageLocationSchema,
20004
20220
  relativePath: string()
20005
- }), _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" });
20221
+ }), _void(), {
20222
+ kind: "mutation",
20223
+ auth: "admin"
20224
+ }), method(object({ location: StorageLocationSchema }), number$1().nullable(), { auth: "admin" }), method(BeginUploadInputSchema, BeginUploadResultSchema, {
20225
+ kind: "mutation",
20226
+ auth: "admin"
20227
+ }), method(WriteChunkInputSchema, _void(), {
20228
+ kind: "mutation",
20229
+ auth: "admin"
20230
+ }), method(FinalizeUploadInputSchema, _void(), {
20231
+ kind: "mutation",
20232
+ auth: "admin"
20233
+ }), method(AbortUploadInputSchema, _void(), {
20234
+ kind: "mutation",
20235
+ auth: "admin"
20236
+ }), method(BeginDownloadInputSchema, BeginDownloadResultSchema, {
20237
+ kind: "mutation",
20238
+ auth: "admin"
20239
+ }), method(ReadChunkInputSchema, _instanceof(Uint8Array), { auth: "admin" }), method(EndDownloadInputSchema, _void(), {
20240
+ kind: "mutation",
20241
+ auth: "admin"
20242
+ });
20006
20243
  /** Profile-exported FormBuilder schema. Shape is ConfigUISchema at the UI. */
20007
20244
  var ProfileSettingsSchemaBridge = unknown().nullable();
20008
20245
  var ProfileSettingsBagSchema = record(string(), unknown());
@@ -20260,7 +20497,8 @@ method(object({
20260
20497
  access: "create"
20261
20498
  }), method(object({ userId: string().optional() }), object({ optionsJSON: record(string(), unknown()) }), {
20262
20499
  kind: "mutation",
20263
- access: "view"
20500
+ access: "view",
20501
+ auth: "admin"
20264
20502
  }), method(object({
20265
20503
  /** Required — the user the assertion belongs to (verified). */
20266
20504
  userId: string(),
@@ -20268,10 +20506,12 @@ method(object({
20268
20506
  response: record(string(), unknown())
20269
20507
  }), object({ verified: boolean() }), {
20270
20508
  kind: "mutation",
20271
- access: "view"
20509
+ access: "view",
20510
+ auth: "admin"
20272
20511
  }), method(object({}), object({ optionsJSON: record(string(), unknown()) }), {
20273
20512
  kind: "mutation",
20274
- access: "view"
20513
+ access: "view",
20514
+ auth: "admin"
20275
20515
  }), method(object({
20276
20516
  /** AuthenticationResponseJSON from the browser. */
20277
20517
  response: record(string(), unknown()) }), object({
@@ -20279,7 +20519,8 @@ response: record(string(), unknown()) }), object({
20279
20519
  userId: string().nullable()
20280
20520
  }), {
20281
20521
  kind: "mutation",
20282
- access: "view"
20522
+ access: "view",
20523
+ auth: "admin"
20283
20524
  }), method(object({ userId: string() }), array(PasskeySummarySchema), { auth: "admin" }), method(object({
20284
20525
  userId: string(),
20285
20526
  credentialId: string()
@@ -20451,7 +20692,19 @@ var VectorStatsResultSchema = object({
20451
20692
  /** False when the backend ranks approximately. */
20452
20693
  exact: boolean()
20453
20694
  });
20454
- 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);
20695
+ method(VectorDeclareIndexInputSchema, _void(), {
20696
+ kind: "mutation",
20697
+ auth: "admin"
20698
+ }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
20699
+ kind: "mutation",
20700
+ auth: "admin"
20701
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
20702
+ kind: "mutation",
20703
+ auth: "admin"
20704
+ }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
20705
+ kind: "mutation",
20706
+ auth: "admin"
20707
+ }), method(VectorStatsInputSchema, VectorStatsResultSchema, { auth: "admin" });
20455
20708
  var ClipSchema = object({
20456
20709
  /** Opaque, provider-namespaced id. The default provider encodes the time
20457
20710
  * window so `getClipPlayback` is self-contained (no event re-query). */
@@ -22174,7 +22427,27 @@ var MediaFileLiteSchema$1 = object({
22174
22427
  sizeBytes: number$1(),
22175
22428
  timestamp: number$1()
22176
22429
  });
22177
- method(_void(), array(IdentitySchema).readonly()), method(object({ name: string().min(1) }), IdentitySchema, {
22430
+ method(object({
22431
+ /**
22432
+ * Inline {@link IdentitySchema.coverBase64} on every row.
22433
+ *
22434
+ * Default `false`, the same inversion `listRecentFaces` and
22435
+ * `listPlates` took on 2026-08-25 (see `include-crops-default.ts` for
22436
+ * why the burden belongs on the caller that WANTS the bytes). Measured
22437
+ * on the live hub the same day: four identities cost 40,979 B with the
22438
+ * covers inline, ~10 KB of base64 per row, on a query this UI mounts
22439
+ * four times and the viewer holds at `staleTime: 30_000`.
22440
+ *
22441
+ * Nothing loses its avatar: `coverMediaKey` is already on every row and
22442
+ * the `event-media` plane serves that key `immutable` with an ETag.
22443
+ *
22444
+ * **This is an INPUT field, so it does not reach the addon until the
22445
+ * next train** — the hub router validates cap inputs against its own
22446
+ * compiled Zod and strips a key it does not know. Until then the
22447
+ * provider sees `undefined`, which resolves to `false`: the cheap shape
22448
+ * is what ships, and the opt-in becomes reachable when the train lands.
22449
+ */
22450
+ includeCrops: boolean().optional() }).optional(), array(IdentitySchema).readonly()), method(object({ name: string().min(1) }), IdentitySchema, {
22178
22451
  kind: "mutation",
22179
22452
  auth: "admin"
22180
22453
  }), method(object({
@@ -24321,8 +24594,10 @@ var PlateInfoSchema = object({
24321
24594
  keyFrameMediaKey: string().optional(),
24322
24595
  base64: string().optional(),
24323
24596
  /**
24324
- * Same crop as a data-plane URL. `getPlateByTrack` returns this and
24325
- * never inlines JPEG; `listPlates` still inlines for the admin-ui.
24597
+ * Same crop as a data-plane URL, always present when the plate has a stored
24598
+ * crop. `getPlateByTrack` returns this and never inlines JPEG; `listPlates`
24599
+ * and `searchPlates` inline the crop only when their `includeCrops` input is
24600
+ * left at its `true` default.
24326
24601
  */
24327
24602
  cropUrl: string().optional()
24328
24603
  });
@@ -24342,14 +24617,34 @@ var PlateClusterSchema = object({
24342
24617
  });
24343
24618
  method(object({
24344
24619
  deviceId: number$1().int().optional(),
24345
- limit: number$1().int().positive().optional()
24620
+ limit: number$1().int().positive().optional(),
24621
+ /**
24622
+ * Inline the base64 crop on every row. Default `true` — the existing
24623
+ * behaviour, kept so no caller breaks.
24624
+ *
24625
+ * Set `false` once the caller renders {@link PlateInfo.cropUrl}.
24626
+ * Measured on the live hub at the 500 rows the Plates view asks for:
24627
+ * 879,403 B and 27.7 s with the crops inline, against a few KiB of
24628
+ * metadata without them — and the browser then caches the images.
24629
+ *
24630
+ * This is the plate twin of `faceGallery.listRecentFaces`'s option;
24631
+ * plates were the one gallery list left without it.
24632
+ *
24633
+ * **This is an INPUT field, so it does not reach the addon until the
24634
+ * next train.** The hub router validates cap inputs against its own
24635
+ * compiled Zod and strips a key it does not know. Until the train
24636
+ * ships, sending `false` is harmless and keeps the crops inline.
24637
+ */
24638
+ includeCrops: boolean().optional()
24346
24639
  }).optional(), array(PlateInfoSchema).readonly()), method(object({
24347
24640
  deviceId: number$1().int(),
24348
24641
  trackId: string()
24349
24642
  }), PlateInfoSchema.nullable()), method(object({ plateId: string() }), array(MediaFileLiteSchema).readonly()), method(object({
24350
24643
  text: string().min(1),
24351
24644
  maxDistance: number$1().int().min(0).optional(),
24352
- limit: number$1().int().positive().optional()
24645
+ limit: number$1().int().positive().optional(),
24646
+ /** See `listPlates.includeCrops`. Default `true`. */
24647
+ includeCrops: boolean().optional()
24353
24648
  }), array(PlateInfoSchema).readonly()), method(object({
24354
24649
  maxDistance: number$1().int().min(0).optional(),
24355
24650
  minClusterSize: number$1().int().min(2).optional(),
@@ -24363,7 +24658,13 @@ method(object({
24363
24658
  }), method(object({ plateId: string() }), _void(), {
24364
24659
  kind: "mutation",
24365
24660
  auth: "admin"
24366
- }), method(_void(), array(VehicleSchema).readonly()), method(object({ name: string().min(1) }), VehicleSchema, {
24661
+ }), method(object({
24662
+ /** Inline {@link VehicleSchema.coverBase64} on every row. Default
24663
+ * `false` — the vehicle twin of `faceGallery.listIdentities`'s
24664
+ * option; `coverMediaKey` + the `event-media` plane carry the picture.
24665
+ * INPUT field: stripped by the hub router until the train ships, which
24666
+ * resolves to `false` and is exactly the intended default. */
24667
+ includeCrops: boolean().optional() }).optional(), array(VehicleSchema).readonly()), method(object({ name: string().min(1) }), VehicleSchema, {
24367
24668
  kind: "mutation",
24368
24669
  auth: "admin"
24369
24670
  }), method(object({
@@ -25628,92 +25929,6 @@ DeviceType.Camera, method(object({ deviceId: number$1() }), SceneMonitorStatusSc
25628
25929
  kind: "mutation",
25629
25930
  auth: "admin"
25630
25931
  });
25631
- /**
25632
- * Per-stage gating mode applied to the zones a rule references.
25633
- *
25634
- * - `include`: the rule contributes to a **whitelist** for its stage.
25635
- * When at least one `include` rule fires for a stage, only entities
25636
- * inside one of those zones pass that stage.
25637
- * - `exclude`: the rule contributes to a **blacklist** for its stage.
25638
- * Entities inside one of those zones are dropped at that stage.
25639
- *
25640
- * `monitor`-style observation (count without filtering) is not a rule
25641
- * mode — zones without any matching rule are observed naturally by
25642
- * `zone-analytics` (live snapshot + history), so an "I just want to
25643
- * count, not filter" use case needs no rule at all.
25644
- */
25645
- var ZoneRuleModeEnum = _enum(["include", "exclude"]);
25646
- /**
25647
- * Per-consumer rule that references existing zones (geometry) and
25648
- * defines how a specific pipeline stage should treat them. Each
25649
- * consumer addon owns its own `ZoneRule[]` array in its per-device
25650
- * settings:
25651
- *
25652
- * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
25653
- * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
25654
- * - future: notification rules, audio gating, etc.
25655
- *
25656
- * One rule applies to N zones (`zoneIds[]`) so the operator can
25657
- * express "ignore motion in ALL of {garden, street}" with a single
25658
- * rule. `classFilter` narrows the rule to specific object classes —
25659
- * "drop person detections in the street, but keep cars" is one
25660
- * `exclude` rule with `classFilter: ['person']`.
25661
- *
25662
- * `enabled` is a soft toggle — the operator can keep the rule
25663
- * configured but inert without deleting it.
25664
- */
25665
- var ZoneRuleSchema = object({
25666
- /** Stable rule id — survives edits, used by the UI for diffing. */
25667
- id: string(),
25668
- /** Optional human-readable label rendered in the rule editor. */
25669
- name: string().optional(),
25670
- /** Zones this rule targets. The rule's `mode` applies to ALL
25671
- * listed zones (OR-set: a detection in any one of them counts).
25672
- * At least one zone id required — a rule with no targets is a
25673
- * configuration mistake and the form validator rejects it. */
25674
- zoneIds: array(string()).min(1).readonly(),
25675
- mode: ZoneRuleModeEnum,
25676
- /**
25677
- * Class names this rule applies to. Empty / undefined ⇒ rule
25678
- * applies to every class. Class strings match the `macroClass`
25679
- * field on detections (e.g. `person`, `car`, `dog`).
25680
- */
25681
- classFilter: array(string()).readonly().optional(),
25682
- /**
25683
- * Minimum bbox/mask overlap (0–1) with any of the rule's zones
25684
- * required to consider an entity "in the zone". Defaults to the
25685
- * consumer's stage default when omitted. Kept for back-compat with
25686
- * existing per-rule overrides; new operators pick the value via
25687
- * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
25688
- * set, the lower-level engine reads it as a 0–1 fraction.
25689
- */
25690
- overlapThreshold: number$1().min(0).max(1).optional(),
25691
- /**
25692
- * Operator-friendly version of `overlapThreshold` — the percentage
25693
- * of the detection's bbox that must lie inside the zone for the
25694
- * rule to match. Documented default is 85%; the engine substitutes
25695
- * that when the field is omitted (kept optional so existing rules
25696
- * stored without it stay valid).
25697
- *
25698
- * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
25699
- * rule, the engine prefers `bboxInclusionPct` because it's the
25700
- * field exposed in the UI. Internally both feed the same gate.
25701
- */
25702
- bboxInclusionPct: number$1().min(0).max(100).optional(),
25703
- /**
25704
- * When `true` and a detection has a segmentation mask, use the
25705
- * mask for overlap instead of the bbox. Detection-stage only;
25706
- * motion rules ignore this field.
25707
- */
25708
- preferMask: boolean().optional(),
25709
- /**
25710
- * Soft-toggle: `false` disables the rule without deleting it.
25711
- * Defaults to `true` so operators creating a rule via the UI
25712
- * see it active immediately.
25713
- */
25714
- enabled: boolean().default(true)
25715
- });
25716
- array(ZoneRuleSchema).readonly();
25717
25932
  object({
25718
25933
  /** Whether the script is currently executing. */
25719
25934
  isRunning: boolean(),
@@ -29740,6 +29955,12 @@ Object.freeze({
29740
29955
  addonId: null,
29741
29956
  access: "create"
29742
29957
  },
29958
+ "pipelineAnalytics.cancelRelocateMedia": {
29959
+ capName: "pipeline-analytics",
29960
+ capScope: "device",
29961
+ addonId: null,
29962
+ access: "create"
29963
+ },
29743
29964
  "pipelineAnalytics.cancelStorageMigrationMove": {
29744
29965
  capName: "pipeline-analytics",
29745
29966
  capScope: "device",
@@ -29914,6 +30135,12 @@ Object.freeze({
29914
30135
  addonId: null,
29915
30136
  access: "view"
29916
30137
  },
30138
+ "pipelineAnalytics.listRelocateMediaJobs": {
30139
+ capName: "pipeline-analytics",
30140
+ capScope: "device",
30141
+ addonId: null,
30142
+ access: "view"
30143
+ },
29917
30144
  "pipelineAnalytics.listRetrainAnnotations": {
29918
30145
  capName: "pipeline-analytics",
29919
30146
  capScope: "device",
@@ -29992,6 +30219,12 @@ Object.freeze({
29992
30219
  addonId: null,
29993
30220
  access: "create"
29994
30221
  },
30222
+ "pipelineAnalytics.relocateMedia": {
30223
+ capName: "pipeline-analytics",
30224
+ capScope: "device",
30225
+ addonId: null,
30226
+ access: "create"
30227
+ },
29995
30228
  "pipelineAnalytics.restageRetrainTrack": {
29996
30229
  capName: "pipeline-analytics",
29997
30230
  capScope: "device",
@@ -30004,6 +30237,12 @@ Object.freeze({
30004
30237
  addonId: null,
30005
30238
  access: "create"
30006
30239
  },
30240
+ "pipelineAnalytics.runReplayFrameProcessor": {
30241
+ capName: "pipeline-analytics",
30242
+ capScope: "device",
30243
+ addonId: null,
30244
+ access: "create"
30245
+ },
30007
30246
  "pipelineAnalytics.saveRetrainAnnotations": {
30008
30247
  capName: "pipeline-analytics",
30009
30248
  capScope: "device",
@@ -30136,6 +30375,12 @@ Object.freeze({
30136
30375
  addonId: null,
30137
30376
  access: "view"
30138
30377
  },
30378
+ "pipelineExecutor.getInferenceDeviceHealth": {
30379
+ capName: "pipeline-executor",
30380
+ capScope: "system",
30381
+ addonId: null,
30382
+ access: "view"
30383
+ },
30139
30384
  "pipelineExecutor.getOrchestratorConfigSchema": {
30140
30385
  capName: "pipeline-executor",
30141
30386
  capScope: "system",
@@ -30208,6 +30453,12 @@ Object.freeze({
30208
30453
  addonId: null,
30209
30454
  access: "view"
30210
30455
  },
30456
+ "pipelineExecutor.rearmInferenceDevice": {
30457
+ capName: "pipeline-executor",
30458
+ capScope: "system",
30459
+ addonId: null,
30460
+ access: "create"
30461
+ },
30211
30462
  "pipelineExecutor.runAudioTest": {
30212
30463
  capName: "pipeline-executor",
30213
30464
  capScope: "system",
@@ -33456,6 +33707,11 @@ Object.freeze({
33456
33707
  form: "single",
33457
33708
  optional: false
33458
33709
  }],
33710
+ "pipelineAnalytics.runReplayFrameProcessor": [{
33711
+ name: "deviceId",
33712
+ form: "single",
33713
+ optional: false
33714
+ }],
33459
33715
  "pipelineAnalytics.saveRetrainAnnotations": [{
33460
33716
  name: "deviceId",
33461
33717
  form: "single",