@camstack/addon-provider-tuya 0.2.28 → 0.2.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/addon.js +2135 -1892
  2. package/dist/addon.mjs +2135 -1892
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -7450,7 +7450,7 @@ function method(input, output, options) {
7450
7450
  input,
7451
7451
  output,
7452
7452
  kind: options?.kind ?? "query",
7453
- auth: options?.auth ?? "protected",
7453
+ ...options?.auth !== void 0 ? { auth: options.auth } : {},
7454
7454
  ...options?.access !== void 0 ? { access: options.access } : {},
7455
7455
  ...options?.caller !== void 0 ? { caller: options.caller } : {},
7456
7456
  timeoutMs: options?.timeoutMs
@@ -7474,7 +7474,7 @@ function event(data) {
7474
7474
  }
7475
7475
  var StaticDirOutputSchema$1 = object({ staticDir: string() });
7476
7476
  var VersionOutputSchema$1 = object({ version: string() });
7477
- method(_void(), StaticDirOutputSchema$1), method(_void(), VersionOutputSchema$1);
7477
+ method(_void(), StaticDirOutputSchema$1, { auth: "admin" }), method(_void(), VersionOutputSchema$1, { auth: "admin" });
7478
7478
  var DeviceType = /* @__PURE__ */ function(DeviceType) {
7479
7479
  DeviceType["Camera"] = "camera";
7480
7480
  DeviceType["Hub"] = "hub";
@@ -7795,7 +7795,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
7795
7795
  }({});
7796
7796
  var StaticDirOutputSchema = object({ staticDir: string() });
7797
7797
  var VersionOutputSchema = object({ version: string() });
7798
- method(_void(), StaticDirOutputSchema), method(_void(), VersionOutputSchema);
7798
+ method(_void(), StaticDirOutputSchema, { auth: "admin" }), method(_void(), VersionOutputSchema, { auth: "admin" });
7799
7799
  /**
7800
7800
  * device-ops — device-scoped cap that unifies the per-IDevice operations
7801
7801
  * previously routed through the `.device-ops` Moleculer bridge service.
@@ -8421,24 +8421,6 @@ var RecordingRetentionSchema = object({
8421
8421
  maxSizeGb: number().min(0).optional()
8422
8422
  });
8423
8423
  /**
8424
- * Scrub-thumbnail fidelity preset — the single per-camera selector bundling the
8425
- * sprite tile RESOLUTION + JPEG QUALITY the recorder packs timeline-scrub
8426
- * previews at. Five graduated steps; absent on a config = `standard` (the
8427
- * shipped default, matching `sheet-geometry`/`sheet-composer`).
8428
- *
8429
- * Existing sheets are IMMUTABLE — a changed preset applies to NEW windows only.
8430
- * Each window's index sidecar carries its own tile dims, so a camera whose
8431
- * preset changed over time renders every historical window at the dims it was
8432
- * written with.
8433
- */
8434
- var ScrubThumbnailPresetSchema = _enum([
8435
- "minimal",
8436
- "low",
8437
- "standard",
8438
- "high",
8439
- "max"
8440
- ]);
8441
- /**
8442
8424
  * The full per-camera recording intent — the wire shape of a RecordingTarget.
8443
8425
  *
8444
8426
  * `bands` is the ONLY authored recording intent: what to record, when, and on
@@ -8446,7 +8428,11 @@ var ScrubThumbnailPresetSchema = _enum([
8446
8428
  * other field is a storage knob (profiles, segment length, retention, scrub).
8447
8429
  *
8448
8430
  * STRICT on purpose: the legacy authoring surface (`schedule`/`schedules`/
8449
- * `triggers`/`preBufferSec`/`postBufferSec`/`rules`) was retired 2026-07-30.
8431
+ * `triggers`/`preBufferSec`/`postBufferSec`/`rules`) was retired 2026-07-30,
8432
+ * and `scrubThumbnails` — a five-step fidelity knob for a sprite tier that was
8433
+ * deleted on 2026-07-24 and had ZERO consumers in the recorder — on 2026-08-25
8434
+ * (D62: a switch that writes a store nobody reads is worse than no switch).
8435
+ * Stored rows keep loading: the READ schema is `.strip()` (config-store.ts).
8450
8436
  * A stale caller must fail loudly — silently stripping its legacy intent would
8451
8437
  * persist a band-less config, i.e. silently stop recording the camera.
8452
8438
  */
@@ -8469,14 +8455,7 @@ var RecordingConfigSchema = object({
8469
8455
  * "off" is the absence of a covering band, never a band value.
8470
8456
  */
8471
8457
  bands: array(RecordingBandSchema).default([]),
8472
- retention: RecordingRetentionSchema.optional(),
8473
- /**
8474
- * Per-camera scrub-thumbnail fidelity preset (resolution + JPEG quality for
8475
- * timeline-scrub sprite previews). Absent = `standard`. Applies to NEW
8476
- * windows only — existing sheets are immutable, and each window's index
8477
- * carries its own tile dims so mixed-preset history renders correctly.
8478
- */
8479
- scrubThumbnails: ScrubThumbnailPresetSchema.optional()
8458
+ retention: RecordingRetentionSchema.optional()
8480
8459
  }).strict();
8481
8460
  /**
8482
8461
  * Entity-relocation job state (storage entity-routing spec, Phase 4).
@@ -8552,10 +8531,11 @@ var RelocateFootageInputSchema = object({
8552
8531
  * `RecordingConfig.enabled` or camera wrapper bindings. */
8553
8532
  var StorageMigrationLeaseInputSchema = object({ leaseId: string().min(1) });
8554
8533
  var StorageMigrationFootageMoveInputSchema = RelocateFootageInputSchema.extend({ leaseId: string().min(1) });
8555
- var StorageMigrationMediaMoveInputSchema = object({
8534
+ var RelocateMediaInputSchema = object({
8556
8535
  toLocationId: string(),
8557
8536
  throttleMbps: number().min(1).max(1e3).optional()
8558
- }).extend({ leaseId: string().min(1) });
8537
+ });
8538
+ var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
8559
8539
  /** The independently selectable logical storage classes. `recordings`
8560
8540
  * encompasses the high and mid segment profiles; `recordingsLow` is low
8561
8541
  * segments; `eventMedia` is post-analysis blobs. */
@@ -8850,7 +8830,26 @@ var LabelDefinitionSchema = object({
8850
8830
  description: string().optional(),
8851
8831
  icon: string().optional()
8852
8832
  });
8853
- var ClassMapDefinitionSchema = object({
8833
+ /**
8834
+ * Wire schema for a per-model CATALOG classMap override
8835
+ * (`ModelCatalogEntry.classMap` / `ModelConvertMetadata.classMap`) —
8836
+ * restricted to {@link CLASS_MAP_MACRO_TARGETS}, the only macros the
8837
+ * detection pipeline executor actually routes.
8838
+ *
8839
+ * This is deliberately a DIFFERENT, narrower shape than the general-purpose
8840
+ * `ClassMapDefinition` interface above (e.g. `IDetectionAddon.getClassMap()`
8841
+ * and the audio `YAMNET_TO_MACRO` catalog both use macro targets outside this
8842
+ * enum) — the two used to share the name `ClassMapDefinition`/
8843
+ * `ClassMapDefinitionSchema`, which made the schema-type-twin guard
8844
+ * (`scripts/check-schema-type-twins.ts`) flag them as a duplicated shape. They
8845
+ * are not: it is two different concepts colliding on a name. Keep this type
8846
+ * under its own name rather than reusing `ClassMapDefinition` — reusing it
8847
+ * would either narrow every `ClassMapDefinition` consumer to the four
8848
+ * detection macros (breaking `YAMNET_TO_MACRO`) or drop the validation this
8849
+ * schema exists for (see the "rejects a classMap whose target is not a
8850
+ * detection macro" test in `model-catalog-schema.test.ts`).
8851
+ */
8852
+ var DetectionCatalogClassMapSchema = object({
8854
8853
  mapping: record(string(), _enum([
8855
8854
  "person",
8856
8855
  "vehicle",
@@ -9055,7 +9054,7 @@ var ModelCatalogEntrySchema = object({
9055
9054
  * applies (Frigate / COCO public catalog). Set on a custom model whose raw
9056
9055
  * labels already ARE the CamStack macros (Scrypted identity map).
9057
9056
  */
9058
- classMap: ClassMapDefinitionSchema.optional()
9057
+ classMap: DetectionCatalogClassMapSchema.optional()
9059
9058
  });
9060
9059
  var ConvertTargetSchema = discriminatedUnion("format", [object({
9061
9060
  format: literal("openvino"),
@@ -9085,7 +9084,7 @@ var ModelConvertMetadataSchema = object({
9085
9084
  "segmentation"
9086
9085
  ]),
9087
9086
  faceAlignment: boolean().optional(),
9088
- classMap: ClassMapDefinitionSchema.optional()
9087
+ classMap: DetectionCatalogClassMapSchema.optional()
9089
9088
  });
9090
9089
  var ConvertResultSchema = object({
9091
9090
  entry: ModelCatalogEntrySchema,
@@ -9948,7 +9947,7 @@ var AddonPageDeclarationSchema = object({
9948
9947
  /** Display label for a CUSTOM `section` id (ignored for well-known ids). */
9949
9948
  sectionLabel: string().optional()
9950
9949
  });
9951
- method(_void(), array(AddonPageDeclarationSchema).readonly());
9950
+ method(_void(), array(AddonPageDeclarationSchema).readonly(), { auth: "admin" });
9952
9951
  var AddonHttpRouteSchema = object({
9953
9952
  method: _enum([
9954
9953
  "GET",
@@ -10183,7 +10182,7 @@ var WidgetMetadataSchema = object({
10183
10182
  defaultColumns: number().int().min(1).max(12).default(6),
10184
10183
  defaultRows: number().int().min(1).max(12).default(1)
10185
10184
  });
10186
- method(_void(), array(WidgetMetadataSchema).readonly());
10185
+ method(_void(), array(WidgetMetadataSchema).readonly(), { auth: "admin" });
10187
10186
  /**
10188
10187
  * `addon-widgets` — system-scoped singleton aggregator cap. Public-facing
10189
10188
  * surface that admin-ui consumes through `useAddonWidgetsListWidgets()`.
@@ -11807,7 +11806,7 @@ var CustomModelDescriptorSchema = object({
11807
11806
  stepId: string(),
11808
11807
  entry: ModelCatalogEntrySchema
11809
11808
  });
11810
- method(_void(), array(CustomModelDescriptorSchema).readonly());
11809
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
11811
11810
  /**
11812
11811
  * Query filter for settings-store collections.
11813
11812
  */
@@ -11894,7 +11893,8 @@ method(object({
11894
11893
  }), _void(), { kind: "mutation" }), method(object({
11895
11894
  namespace: string().optional(),
11896
11895
  collection: string(),
11897
- filter: QueryFilterSchema.optional()
11896
+ filter: QueryFilterSchema.optional(),
11897
+ columns: array(string()).readonly().optional()
11898
11898
  }), array(SettingsRecordSchema).readonly()), method(object({
11899
11899
  namespace: string().optional(),
11900
11900
  collection: string(),
@@ -11957,46 +11957,87 @@ var EngineInfoSchema = object({
11957
11957
  kind: _enum(["relational", "vector"]),
11958
11958
  displayName: string()
11959
11959
  });
11960
- method(_void(), EngineInfoSchema), method(object({
11960
+ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
11961
11961
  namespace: string().optional(),
11962
11962
  collection: string(),
11963
11963
  key: string()
11964
- }), unknown()), method(object({
11964
+ }), unknown(), { auth: "admin" }), method(object({
11965
11965
  namespace: string().optional(),
11966
11966
  collection: string(),
11967
11967
  key: string(),
11968
11968
  value: unknown()
11969
- }), _void(), { kind: "mutation" }), method(object({
11969
+ }), _void(), {
11970
+ kind: "mutation",
11971
+ auth: "admin"
11972
+ }), method(object({
11970
11973
  namespace: string().optional(),
11971
11974
  collection: string(),
11972
- filter: QueryFilterSchema.optional()
11973
- }), array(SettingsRecordSchema).readonly()), method(object({
11975
+ filter: QueryFilterSchema.optional(),
11976
+ /**
11977
+ * SQL-level column projection — MUST mirror `settings-store.query`.
11978
+ *
11979
+ * ⚠ An earlier version of this comment blamed Zod stripping, and that
11980
+ * was wrong — corrected 2026-08-26 after the hop map
11981
+ * (`docs/design/2026-08-26-mappa-hop-argomenti.md`) traced the path.
11982
+ * There is **no Zod parse at all** between the door and the engine: the
11983
+ * dispatcher forwards the payload verbatim and UDS carries it whole. A
11984
+ * field declared here reaches `SqliteSettingsBackend` either way.
11985
+ *
11986
+ * What actually lost `columns` was the THIRD declaration of this shape:
11987
+ * `SettingsQueryInput` in `interfaces/storage.ts`, a hand-written TS
11988
+ * interface the engine destructures from. The field existed on both
11989
+ * schemas and the engine still never read it, because nothing checks a
11990
+ * registered provider against `InferProvider<cap>` —
11991
+ * `ProviderRegistration.provider` is typed `object`.
11992
+ *
11993
+ * It is declared here anyway, and must stay in step with
11994
+ * `settings-store.query`: a caller reading only the cap definitions has
11995
+ * to be able to see that this call carries a projection.
11996
+ * `data-door-schema-parity.spec.ts` keeps the two aligned.
11997
+ */
11998
+ columns: array(string()).readonly().optional()
11999
+ }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
11974
12000
  namespace: string().optional(),
11975
12001
  collection: string(),
11976
12002
  record: SettingsRecordSchema
11977
- }), _void(), { kind: "mutation" }), method(object({
12003
+ }), _void(), {
12004
+ kind: "mutation",
12005
+ auth: "admin"
12006
+ }), method(object({
11978
12007
  namespace: string().optional(),
11979
12008
  collection: string(),
11980
12009
  id: string(),
11981
12010
  data: record(string(), unknown())
11982
- }), _void(), { kind: "mutation" }), method(object({
12011
+ }), _void(), {
12012
+ kind: "mutation",
12013
+ auth: "admin"
12014
+ }), method(object({
11983
12015
  namespace: string().optional(),
11984
12016
  collection: string(),
11985
12017
  key: string()
11986
- }), _void(), { kind: "mutation" }), method(object({
12018
+ }), _void(), {
12019
+ kind: "mutation",
12020
+ auth: "admin"
12021
+ }), method(object({
11987
12022
  namespace: string().optional(),
11988
12023
  collection: string(),
11989
12024
  filter: MutationFilterSchema
11990
- }), object({ deleted: number().int() }), { kind: "mutation" }), method(object({
12025
+ }), object({ deleted: number().int() }), {
12026
+ kind: "mutation",
12027
+ auth: "admin"
12028
+ }), method(object({
11991
12029
  namespace: string().optional(),
11992
12030
  collection: string(),
11993
12031
  filter: MutationFilterSchema,
11994
12032
  data: record(string(), unknown())
11995
- }), object({ updated: number().int() }), { kind: "mutation" }), method(object({
12033
+ }), object({ updated: number().int() }), {
12034
+ kind: "mutation",
12035
+ auth: "admin"
12036
+ }), method(object({
11996
12037
  namespace: string().optional(),
11997
12038
  collection: string(),
11998
12039
  filter: QueryFilterSchema.optional()
11999
- }), number()), method(object({
12040
+ }), number(), { auth: "admin" }), method(object({
12000
12041
  namespace: string().optional(),
12001
12042
  collection: string(),
12002
12043
  field: string(),
@@ -12006,15 +12047,18 @@ method(_void(), EngineInfoSchema), method(object({
12006
12047
  }), array(object({
12007
12048
  bucket: number().int(),
12008
12049
  count: number().int()
12009
- })).readonly()), method(object({
12050
+ })).readonly(), { auth: "admin" }), method(object({
12010
12051
  namespace: string().optional(),
12011
12052
  collection: string()
12012
- }), boolean()), method(object({
12053
+ }), boolean(), { auth: "admin" }), method(object({
12013
12054
  namespace: string().optional(),
12014
12055
  collection: string(),
12015
12056
  columns: array(CollectionColumnSchema).readonly(),
12016
12057
  indexes: array(CollectionIndexSchema).readonly().optional()
12017
- }), _void(), { kind: "mutation" });
12058
+ }), _void(), {
12059
+ kind: "mutation",
12060
+ auth: "admin"
12061
+ });
12018
12062
  /**
12019
12063
  * shm ring usage stats for a `frameSink: 'shm'` decoder session —
12020
12064
  * exposed via `decoder.getShmStats` so downstream consumers can
@@ -13321,7 +13365,7 @@ method(object({
13321
13365
  crop: _instanceof(Uint8Array),
13322
13366
  width: number(),
13323
13367
  height: number()
13324
- }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
13368
+ }), EmbeddingResultSchema, { auth: "admin" }), method(object({ text: string() }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" });
13325
13369
  /**
13326
13370
  * filesystem-browse — per-node capability for browsing the node's local
13327
13371
  * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
@@ -13614,19 +13658,22 @@ method(LlmGenerateBaseInputSchema.extend({
13614
13658
  runtime: ManagedRuntimeConfigSchema,
13615
13659
  /** The managed profile's timeout, threaded by the hub provider. */
13616
13660
  timeoutMs: number().int().positive().optional()
13617
- }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
13661
+ }), LlmGenerateResultSchema, {
13662
+ kind: "mutation",
13663
+ auth: "admin"
13664
+ }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
13618
13665
  kind: "mutation",
13619
13666
  auth: "admin"
13620
13667
  }), method(object({}), _void(), {
13621
13668
  kind: "mutation",
13622
13669
  auth: "admin"
13623
- }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
13670
+ }), method(object({}), LlmRuntimeStatusSchema, { auth: "admin" }), method(object({ model: ManagedModelRefSchema }), _void(), {
13624
13671
  kind: "mutation",
13625
13672
  auth: "admin"
13626
13673
  }), method(object({ file: string() }), _void(), {
13627
13674
  kind: "mutation",
13628
13675
  auth: "admin"
13629
- }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
13676
+ }), method(object({}), array(LlmNodeModelSchema), { auth: "admin" }), method(object({}), LlmRuntimeDiskUsageSchema, { auth: "admin" });
13630
13677
  /**
13631
13678
  * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
13632
13679
  * methods concat-fan across providers; single-row methods route to ONE
@@ -17137,1748 +17184,1998 @@ var OauthIntegrationDescriptorSchema = object({
17137
17184
  */
17138
17185
  refreshTokenTtlSec: union([number().int().positive(), literal("never")]).optional()
17139
17186
  });
17140
- method(_void(), OauthIntegrationDescriptorSchema);
17187
+ method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
17141
17188
  /**
17142
- * pipeline-analytics — device-scoped wrapper cap. Refines raw
17143
- * per-frame detections emitted by the pipeline runner into tracked
17144
- * objects, per-kind event collections (motion / object / audio), and
17145
- * persisted media. Owns the post-detection domain end-to-end:
17146
- *
17147
- * runner emits PipelineInferenceResult
17148
- * ↓ (event bus)
17149
- * pipeline-analytics subscriber
17150
- * ↓ SORT tracker + zone engine + state analyzer + event emitter
17151
- * → three DB collections (one per kind), one FS media tree, one
17152
- * unified event emitter (FrameTracked + TrackStarted/Ended +
17153
- * DetectionEvent on bus)
17154
- *
17155
- * Pure subscriber model. No `processFrame` cap method — the runner
17156
- * already publishes the raw frame on the bus. The cap surface is
17157
- * only QUERIES + per-device settings, bound on/off via
17158
- * `device-manager.setWrapperActive`. `defaultActive: true` because
17159
- * every camera with a detection pipeline wants its raw detections
17160
- * refined; operators opt out per-device via BindingsTab when needed.
17161
- *
17162
- * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
17163
- * (per-device surface) and `track-trail` caps — see P11 cleanup.
17189
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
17190
+ * within the frame, so the executor can re-cut a leaf child ROI at native
17191
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
17164
17192
  */
17165
- var TrackStateSchema = _enum([
17166
- "new",
17167
- "entered",
17168
- "left",
17169
- "moving",
17170
- "idle"
17171
- ]);
17172
- var EventKindSchema = _enum([
17173
- "motion",
17174
- "object",
17175
- "audio"
17176
- ]);
17193
+ var NativeCropRefSchema = object({
17194
+ /** Handle keying the retained native surface (node-pinned to its owner). */
17195
+ handle: FrameHandleSchema,
17196
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
17197
+ cropFrameSpace: object({
17198
+ x: number(),
17199
+ y: number(),
17200
+ w: number(),
17201
+ h: number()
17202
+ })
17203
+ });
17204
+ object({
17205
+ crop: object({
17206
+ left: number(),
17207
+ top: number(),
17208
+ width: number().positive(),
17209
+ height: number().positive()
17210
+ }).optional(),
17211
+ content: object({
17212
+ width: number().int().positive(),
17213
+ height: number().int().positive()
17214
+ }),
17215
+ fit: _enum(["stretch", "contain"]),
17216
+ format: _enum([
17217
+ "rgb",
17218
+ "gray",
17219
+ "jpeg"
17220
+ ])
17221
+ });
17177
17222
  /**
17178
- * Spatial filter for `listTracks` — the rect + polygon variants of the shared
17179
- * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
17180
- * of the camera frame (top-left origin), matching the drawing-plane editor.
17223
+ * Process-local frame identity. It is serializable so it can ride an in-process
17224
+ * capability call, but `registryId` deliberately prevents resolution in any
17225
+ * other process or execution group.
17181
17226
  */
17182
- var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
17183
- /** Closed icon vocabulary so clients render a known glyph per kind. */
17184
- var EventKindIconSchema = _enum([
17185
- "motion",
17186
- "audio",
17187
- "person",
17188
- "vehicle",
17189
- "animal",
17190
- "door",
17191
- "pir",
17192
- "smoke",
17193
- "water",
17194
- "button",
17195
- "package",
17196
- "generic"
17227
+ var FrameRefSchema = object({
17228
+ registryId: string().min(1),
17229
+ id: string().min(1),
17230
+ width: number().int().positive(),
17231
+ height: number().int().positive(),
17232
+ format: _enum(["rgb", "gray"]),
17233
+ timestamp: number(),
17234
+ capturedAt: number().optional()
17235
+ });
17236
+ var ModelFormatSchema$1 = _enum([
17237
+ "onnx",
17238
+ "coreml",
17239
+ "openvino",
17240
+ "tflite",
17241
+ "pt",
17242
+ "gguf"
17197
17243
  ]);
17198
- var EventKindCategorySchema = _enum([
17199
- "motion",
17200
- "audio",
17201
- "detection",
17202
- "sensor",
17203
- "control",
17204
- "custom",
17205
- "package"
17244
+ var PipelineSlotSchema = _enum([
17245
+ "detector",
17246
+ "cropper",
17247
+ "classifier",
17248
+ "refiner",
17249
+ "audio-classifier"
17206
17250
  ]);
17207
- /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
17208
- var EventKindLevelSchema = _enum(["macro", "sub"]);
17209
- var EventKindDescriptorSchema = object({
17210
- /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
17211
- kind: string(),
17212
- /** i18n key resolved on the UI side; `label` is the English fallback. */
17213
- labelKey: string(),
17214
- /** English fallback label (kept for clients that don't translate). */
17215
- label: string(),
17216
- /** Hex color for timeline/legend rendering. */
17217
- color: string(),
17218
- /** Dictionary id → lucide component on the UI side. */
17219
- iconId: string(),
17220
- /** Legacy closed-vocab glyph — fallback for `iconId`. */
17221
- icon: EventKindIconSchema,
17222
- category: EventKindCategorySchema,
17223
- /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
17224
- parentKind: string().nullable(),
17225
- /** Derived from `parentKind`, explicit for the client tree. */
17226
- level: EventKindLevelSchema,
17227
- /** Which cap + device contributes this kind. For built-ins the camera
17228
- * itself; for sensor kinds the LINKED source device. */
17229
- source: object({
17230
- capName: string(),
17231
- deviceId: number()
17232
- })
17251
+ var PipelineEngineChoiceSchema = object({
17252
+ runtime: _enum(["node", "python"]),
17253
+ backend: string(),
17254
+ format: ModelFormatSchema$1,
17255
+ device: string().optional()
17233
17256
  });
17234
- /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
17235
- var EventKindsForDeviceSchema = object({
17236
- deviceId: number(),
17237
- kinds: array(EventKindDescriptorSchema).readonly()
17257
+ var AvailableEngineSchema = object({
17258
+ engine: PipelineEngineChoiceSchema,
17259
+ devices: array(object({
17260
+ id: string(),
17261
+ label: string(),
17262
+ description: string().optional()
17263
+ })).readonly(),
17264
+ defaultDevice: string()
17238
17265
  });
17239
- var SensorEventSchema = object({
17266
+ var PipelineDefaultStepSchema = lazy(() => object({
17267
+ addonId: string(),
17268
+ addonName: string(),
17269
+ slot: PipelineSlotSchema,
17270
+ inputClasses: array(string()).readonly(),
17271
+ outputClasses: array(string()).readonly(),
17272
+ enabled: boolean(),
17273
+ modelId: string(),
17274
+ children: array(PipelineDefaultStepSchema).readonly(),
17275
+ group: string().optional(),
17276
+ settings: record(string(), unknown()).optional()
17277
+ }));
17278
+ var PipelineTemplateStepSchema = lazy(() => object({
17279
+ addonId: string(),
17280
+ enabled: boolean(),
17281
+ modelId: string(),
17282
+ children: array(PipelineTemplateStepSchema).readonly(),
17283
+ settings: record(string(), unknown()).optional()
17284
+ }));
17285
+ var PipelineTemplateSchema$1 = object({
17240
17286
  id: string(),
17241
- /** The CAMERA the event is attributed to (a sensor linked to N cameras
17242
- * yields N rows, one per camera). */
17243
- deviceId: number(),
17244
- /** The linked sensor device whose state changed. */
17245
- sourceDeviceId: number(),
17246
- /** Event kind id — matches an `EventKindDescriptor.kind`. */
17247
- kind: string(),
17248
- /** Snapshot of the sensor cap's runtime-state slice at the change. */
17249
- value: record(string(), unknown()).nullable(),
17250
- timestamp: number()
17251
- });
17252
- var TrackPositionSchema = object({
17253
- x: number(),
17254
- y: number(),
17255
- timestamp: number(),
17256
- bbox: BoundingBoxSchema
17287
+ name: string(),
17288
+ createdAt: string(),
17289
+ updatedAt: string(),
17290
+ engine: PipelineEngineChoiceSchema,
17291
+ steps: array(PipelineTemplateStepSchema).readonly()
17257
17292
  });
17258
- var TrackSnapshotSchema = object({
17259
- timestamp: number(),
17260
- position: TrackPositionSchema,
17261
- /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
17262
- mediaKey: string()
17293
+ var PipelineModelOptionSchema = object({
17294
+ id: string(),
17295
+ name: string(),
17296
+ formats: record(string(), object({
17297
+ downloaded: boolean(),
17298
+ sizeMB: number()
17299
+ })),
17300
+ group: ModelVariantGroupSchema.optional(),
17301
+ legacy: boolean().optional(),
17302
+ provider: ModelProviderIdSchema.optional()
17263
17303
  });
17264
- /**
17265
- * Normalized 0..1 trajectory envelope (min/max over every position bbox,
17266
- * divided by the track's detection-frame dims), computed at persist time.
17267
- * Absent when the frame dims were unknown when the track was persisted
17268
- * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
17269
- */
17270
- var TrackEnvelopeSchema = object({
17271
- minX: number(),
17272
- minY: number(),
17273
- maxX: number(),
17274
- maxY: number()
17304
+ var ConfigFieldBridge = custom();
17305
+ var PipelineAddonSchemaSchema = object({
17306
+ id: string(),
17307
+ name: string(),
17308
+ slot: PipelineSlotSchema,
17309
+ inputClasses: array(string()).readonly(),
17310
+ outputClasses: array(string()).readonly(),
17311
+ childSlots: array(PipelineSlotSchema).readonly(),
17312
+ models: array(PipelineModelOptionSchema).readonly(),
17313
+ defaultModelId: string(),
17314
+ defaultModelIdByFormat: record(string(), string()).optional(),
17315
+ enabledByDefault: boolean().optional(),
17316
+ backfillIntoExistingOverrides: boolean().optional(),
17317
+ defaultConfidence: number(),
17318
+ group: string().optional(),
17319
+ configSchema: array(ConfigFieldBridge).readonly().optional()
17275
17320
  });
17276
- /**
17277
- * Row projection for track list queries. `full` (default) returns the
17278
- * complete Track including the frame-rate `positions[]` history and the
17279
- * `snapshots[]` references — megabytes across a page of tracks. `slim`
17280
- * keeps every scalar the list surfaces actually render (ids, class(es),
17281
- * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
17282
- * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
17283
- * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
17284
- * `getTrack`. Mirrors the event-store `projection` convention
17285
- * (`getObjectEvents` et al.).
17286
- */
17287
- var TrackProjectionSchema = _enum(["full", "slim"]);
17288
- /**
17289
- * One audio-classification label heard on the track's camera while the
17290
- * track was alive, aggregated per label. An "episode" is one persisted
17291
- * audio event (the confident-classification path: score ≥ the device's
17292
- * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
17293
- * one 32 ms inference chunk, so counts stay human-scaled.
17294
- */
17295
- var TrackAudioLabelSchema = object({
17321
+ var PipelineSlotSchemaSchema = object({
17322
+ id: PipelineSlotSchema,
17296
17323
  label: string(),
17297
- /** Highest classification score observed across the label's episodes. */
17298
- peakScore: number(),
17299
- /** Number of coalesced audio-event episodes carrying this label. */
17300
- count: number(),
17301
- firstAt: number(),
17302
- lastAt: number()
17324
+ priority: number(),
17325
+ parentSlot: PipelineSlotSchema.nullable(),
17326
+ addons: array(PipelineAddonSchemaSchema).readonly()
17303
17327
  });
17304
- /**
17305
- * How a track was produced. `pipeline` (default / absent) = the spatial
17306
- * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
17307
- * no positions, a single snapshot, and no bbox trajectory at all:
17308
- *
17309
- * - `sensor` — a linked sensor/control device state change.
17310
- * - `audio` — an audio event on the camera itself that was anomalous for
17311
- * THAT camera, loud, and heard while nothing visual was happening (D62).
17312
- *
17313
- * The spatial subsystems (tracker association, occupancy count, re-id /
17314
- * embedding, resurrection) MUST skip every synthetic source. Test for that
17315
- * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
17316
- * check silently readmits every source added after it was written.
17317
- */
17318
- var TrackSourceSchema = _enum([
17319
- "pipeline",
17320
- "sensor",
17321
- "audio"
17322
- ]);
17323
- /**
17324
- * Where a track sits in the RETRAIN lifecycle (D81).
17325
- *
17326
- * - `none` — never marked, or un-marked. Evictable.
17327
- * - `staging` — the operator wants this track as training material and has not
17328
- * finished with it. **This is the only state retention holds**: the track and
17329
- * everything it owns (object events, crops, keyframes, CLIP vector) survive
17330
- * the device's age window.
17331
- * - `trained` — the retrain page has taken what it needed. The frames it chose
17332
- * were COPIED into the retrain dataset at selection time, so the dataset no
17333
- * longer depends on the track's media and the track becomes EVICTABLE again.
17334
- * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
17335
- * a deliberate action of the retrain page, not a side effect of a checkbox.
17336
- *
17337
- * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
17338
- * the store's filter language has only positive equality and `whereIn` — no
17339
- * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
17340
- * would make the entire pre-column history immortal in one deploy.
17341
- */
17342
- var RetrainStatusSchema = _enum([
17343
- "none",
17344
- "staging",
17345
- "trained"
17346
- ]);
17347
- /**
17348
- * Per-track OPERATOR flags — set by hand from the admin UI or the viewer, never
17349
- * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
17350
- * so the two surfaces cannot drift.
17351
- *
17352
- * **Absent ≠ false.** A track that has never been touched omits the field; an
17353
- * explicitly un-flagged track carries `false`. Legacy rows written before the
17354
- * columns existed read as absent, and a consumer that needs a boolean should say
17355
- * `flag === true`, not `flag !== false`.
17356
- *
17357
- * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
17358
- * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
17359
- * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
17360
- * `trained` track reports `false` while refusing both writes. The boolean is
17361
- * kept because three surfaces drive a toggle off it; anything that needs to tell
17362
- * "never marked" from "already trained" must read `retrainStatus`.
17363
- *
17364
- * `debug` does NOT pin; it is attention, not durability.
17365
- *
17366
- * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
17367
- * A favourited track is skipped by retention the same way `staging` is, but
17368
- * it does not enter `none|staging|trained` and has no staging budget.
17369
- */
17370
- var TrackFlagFields = {
17371
- /** Operator marked this track as training material — i.e. `retrainStatus` is
17372
- * `'staging'`. */
17373
- markForTrain: boolean().optional(),
17374
- /** Operator marked this track for diagnostic attention. */
17375
- debug: boolean().optional(),
17376
- /** Operator favourited this track. Pins it against pruning. */
17377
- favourited: boolean().optional()
17378
- };
17379
- /**
17380
- * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
17381
- * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
17382
- * write patch, and the status is not something the toggle sets — it is what the
17383
- * toggle's boolean is derived from. Absent on an in-RAM track never touched;
17384
- * always present on a persisted row (the column default materialises `'none'`).
17385
- */
17386
- var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
17387
- /**
17388
- * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
17389
- * one flag can never clear the other — the toggles are independent and are
17390
- * driven from three surfaces that do not know about each other.
17391
- */
17392
- var TrackFlagsPatchSchema = object(TrackFlagFields);
17393
- /**
17394
- * The resolved flag state after a write. Both fields are REQUIRED here (absent
17395
- * collapses to `false`) so a caller can drive a toggle's checked state off the
17396
- * mutation result without a re-fetch.
17397
- */
17398
- var TrackFlagsSchema = object({
17399
- trackId: string(),
17400
- markForTrain: boolean(),
17401
- debug: boolean(),
17402
- favourited: boolean(),
17403
- /** The lifecycle state the boolean was derived from. Required here (unlike on
17404
- * a track row) because this shape is only ever produced by the write body,
17405
- * which always knows it — and a surface that has just written needs to render
17406
- * `trained` without a re-fetch. */
17407
- retrainStatus: RetrainStatusSchema
17328
+ var PipelineSchemaSchema = object({
17329
+ availableEngines: array(AvailableEngineSchema).readonly(),
17330
+ selectedEngine: PipelineEngineChoiceSchema,
17331
+ slots: array(PipelineSlotSchemaSchema).readonly()
17408
17332
  });
17409
- union([literal(1), literal(2)]);
17410
- /**
17411
- * WHO decided a label, and when. Carried per tier so a value can be traced to
17412
- * the step and model that produced it — which is what makes the write rule
17413
- * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
17414
- * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
17415
- *
17416
- * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
17417
- * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
17418
- * `migration:4g` for a value the 4g migration moved from the single-slot era —
17419
- * that value has no provenance, and the write rule lets ANY properly-attributed
17420
- * write of the same tier replace it regardless of score.
17421
- */
17422
- var LabelAttributionSchema = object({
17423
- stepId: string(),
17424
- modelId: string().optional(),
17425
- decidedAt: number(),
17333
+ var EngineProvisioningSchema = object({
17334
+ runtimeId: _enum([
17335
+ "onnx",
17336
+ "openvino",
17337
+ "coreml",
17338
+ "edgetpu"
17339
+ ]).nullable(),
17340
+ device: string().nullable(),
17341
+ state: _enum([
17342
+ "idle",
17343
+ "installing",
17344
+ "verifying",
17345
+ "ready",
17346
+ "failed"
17347
+ ]),
17348
+ progress: number().optional(),
17349
+ error: string().optional(),
17350
+ nextRetryAt: number().optional(),
17426
17351
  /**
17427
- * The GALLERY id behind a recognised tier-2 label — a face-gallery
17428
- * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
17429
- *
17430
- * The text alone is a DISPLAY NAME, and a display name is renameable: a
17431
- * notification rule authored on "Gianluca" stopped matching the moment the
17432
- * operator fixed the spelling in the gallery, and nothing said so. The id is
17433
- * the thing that does not move, so it is what a rule matches on
17434
- * (`NcConditions.identities`) and the text is what a human is shown.
17435
- *
17436
- * Absent when the label names no gallery row — a plate the OCR read but no
17437
- * vehicle claims, a sub-class, a species, any tier-1 value.
17352
+ * Gate A (config-correctness gate at engine change): human-readable
17353
+ * config issues surfaced EAGERLY when the node's engine changes — model
17354
+ * substitutions ("chose X, running Y") and zero-build steps ("no model
17355
+ * has a <format> build"). Additive/optional: informational only, never
17356
+ * enforced here — `assertEngineReady` (readiness) still gates inference.
17357
+ * Absent/empty when the node-default tree resolves cleanly.
17438
17358
  */
17439
- identityId: string().optional()
17359
+ configIssues: array(string()).optional()
17440
17360
  });
17441
- /**
17442
- * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
17443
- * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
17444
- * track and its events always answer the same question the same way.
17445
- *
17446
- * Two scalar columns, not an array: every consumer wants "the coarse one" or
17447
- * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
17448
- * is tier 2, and each carries its own score + attribution.
17449
- *
17450
- * **Reading it.** What a human should be shown is `subLabel ?? label` — the
17451
- * finest thing known. Before 4g the single `label` column held the finest
17452
- * value, so a consumer that has not been updated reads the tier-1 slot and
17453
- * shows nothing on a species-only row; that is why the migration puts every
17454
- * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
17455
- * and why the read surfaces were changed in the same train.
17456
- *
17457
- * **Writing it.** The slots are independent, which is the whole point: a
17458
- * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
17459
- * migratorius`), so fineness cannot regress by construction. Within a tier the
17460
- * higher score wins. One rule, one implementation — see
17461
- * `pipeline/label-tier.ts` in addon-post-analysis.
17462
- */
17463
- var TieredLabelFields = {
17464
- /** Tier 1 — the sub-class. See {@link LabelTierSchema}. */
17465
- label: string().optional(),
17466
- /** Confidence of the tier-1 value, as reported by the deciding step. */
17467
- labelScore: number().optional(),
17468
- /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
17469
- labelMeta: LabelAttributionSchema.optional(),
17470
- /** Tier 2 — the instance. See {@link LabelTierSchema}. */
17471
- subLabel: string().optional(),
17472
- /** Confidence of the tier-2 value, as reported by the deciding step. */
17473
- subLabelScore: number().optional(),
17474
- /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
17475
- subLabelMeta: LabelAttributionSchema.optional()
17476
- };
17477
- /** Per-camera slice of a training-export estimate. */
17478
- var TrainingExportDeviceTotalsSchema = object({
17479
- deviceId: number(),
17480
- tracks: number().int(),
17481
- files: number().int(),
17482
- bytes: number().int()
17361
+ var PipelineStepInputSchema = lazy(() => object({
17362
+ addonId: string(),
17363
+ modelId: string().optional(),
17364
+ enabled: boolean().default(true),
17365
+ children: array(PipelineStepInputSchema).optional(),
17366
+ settings: record(string(), unknown()).optional(),
17367
+ jumpDeviceKey: string().optional()
17368
+ }));
17369
+ var ModelSubstitutionSchema = object({
17370
+ addonId: string(),
17371
+ chosen: string(),
17372
+ running: string(),
17373
+ format: string()
17374
+ });
17375
+ var PipelineValidationIssueSchema = object({
17376
+ addonId: string(),
17377
+ kind: _enum(["unknown-addon", "no-format-build"]),
17378
+ detail: string()
17379
+ });
17380
+ var PipelineValidationResultSchema = object({
17381
+ ok: boolean(),
17382
+ issues: array(PipelineValidationIssueSchema).readonly(),
17383
+ substitutions: array(ModelSubstitutionSchema).readonly(),
17384
+ /** The node's `currentEngine.format` this validation ran against. */
17385
+ format: string()
17386
+ });
17387
+ var ReferenceImageEntrySchema = object({
17388
+ filename: string(),
17389
+ stepIds: array(string()).readonly().optional()
17390
+ });
17391
+ var ReferenceImageBodySchema = object({
17392
+ base64: string(),
17393
+ filename: string()
17394
+ });
17395
+ var ReferenceAudioEntrySchema = object({
17396
+ filename: string(),
17397
+ sizeKb: number()
17398
+ });
17399
+ var ReferenceAudioBodySchema = object({ base64: string() });
17400
+ var AudioBackendSchema = object({
17401
+ id: string(),
17402
+ name: string(),
17403
+ description: string(),
17404
+ available: boolean(),
17405
+ /**
17406
+ * Raw classifier labels this backend can emit (e.g. YAMNet's
17407
+ * 521-class set or Apple SoundAnalysis's 303-class set). Used by
17408
+ * the benchmark UI to populate the `enabledMicroClasses` filter
17409
+ * specific to the selected backend without a separate fetch.
17410
+ */
17411
+ rawLabels: array(string()).readonly().optional()
17412
+ });
17413
+ var AudioCapabilitiesSchema = object({
17414
+ activeBackend: string(),
17415
+ availableBackends: array(AudioBackendSchema).readonly(),
17416
+ sampleRate: number(),
17417
+ chunkDurationMs: number()
17418
+ });
17419
+ var DownloadModelResultSchema = object({
17420
+ filePath: string(),
17421
+ sizeMB: number(),
17422
+ durationMs: number()
17483
17423
  });
17484
17424
  /**
17485
- * What a training export WOULD contain. Computed from media index rows only —
17486
- * no blob is read to produce this.
17425
+ * Wrapper carrying a single test run's result. Replaces the legacy
17426
+ * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
17427
+ * canonical `AudioResult` from the Phase 6 output rework: one
17428
+ * `AudioDetection` per class above `minScore`, top-N candidates in
17429
+ * `debug.alternateLabels['audio-classifier']`, per-source timings in
17430
+ * `debug.stepTimings`. The outer `success`/`error` fields stay so the
17431
+ * benchmark UI can still report a clean failure when the classifier
17432
+ * cap isn't available.
17487
17433
  */
17488
- var TrainingExportSummarySchema = object({
17489
- generatedAt: number(),
17490
- trackCount: number().int(),
17491
- fileCount: number().int(),
17492
- byteCount: number().int(),
17493
- /** More marked tracks exist than a single pass carries. */
17494
- truncated: boolean(),
17495
- devices: array(TrainingExportDeviceTotalsSchema).readonly()
17434
+ var AudioTestResultSchema = object({
17435
+ success: boolean(),
17436
+ error: string().optional(),
17437
+ frame: custom().optional()
17496
17438
  });
17497
- var TrackSchema = object({
17498
- trackId: string(),
17499
- deviceId: number(),
17500
- className: string(),
17501
- ...TieredLabelFields,
17502
- producingDeviceName: string().optional(),
17503
- /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
17504
- source: TrackSourceSchema.optional(),
17505
- firstSeen: number(),
17506
- lastSeen: number(),
17507
- /** Frame-rate position history (subject to maxPositionHistory cap). */
17508
- positions: array(TrackPositionSchema).readonly(),
17509
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
17510
- * saveThumbnails policy). */
17511
- snapshots: array(TrackSnapshotSchema).readonly(),
17512
- /** Deduplicated zones the track has entered at least once. Zone IDS. */
17513
- zonesVisited: array(string()).readonly(),
17439
+ var PipelineConfigBridge = custom();
17440
+ var ConfigUISchemaBridge = custom();
17441
+ var ConfigUISchemaNullableBridge = custom();
17442
+ var InferenceCapabilitiesBridge = custom();
17443
+ var ModelAvailabilityListBridge = custom();
17444
+ var PipelineRunResultBridge = custom();
17445
+ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
17446
+ modelId: string(),
17447
+ settings: record(string(), unknown()).readonly()
17448
+ }))), method(object({ steps: record(string(), object({
17449
+ modelId: string(),
17450
+ settings: record(string(), unknown()).readonly()
17451
+ })) }), object({ success: literal(true) }), {
17452
+ kind: "mutation",
17453
+ auth: "admin"
17454
+ }), method(object({ nodeId: string() }), object({
17455
+ success: literal(true),
17456
+ clearedDevices: number()
17457
+ }), {
17458
+ kind: "mutation",
17459
+ auth: "admin"
17460
+ }), method(object({ nodeId: string() }), object({ unhealthy: array(object({
17461
+ /** `<backend>:<device>`, e.g. `openvino:gpu`. */
17462
+ deviceKey: string(),
17514
17463
  /**
17515
- * Human NAMES for {@link zonesVisited}, resolved at READ time against the
17516
- * `zones` capability.
17517
- *
17518
- * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
17519
- * and no card can render — so every free-text search surface was structurally
17520
- * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
17521
- * just returned nothing. Resolving here rather than in each client keeps ONE
17522
- * derivation and costs the clients no extra call (the `zones` cap is
17523
- * per-device, so a client-side resolve would be a per-camera fan-out on a
17524
- * surface built to avoid exactly that).
17525
- *
17526
- * Resolved, never invented: a zone deleted since the track was written has no
17527
- * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
17528
- * two are not positionally aligned. Absent when the track visited no zone, or
17529
- * when the zone catalogue could not be read.
17464
+ * `failed` — the per-device restart budget is exhausted; no pool
17465
+ * will be spawned until an operator re-arms it or the runner
17466
+ * respawns. `backoff` — under budget, waiting out the backoff (or
17467
+ * a cached pool observed dead and not yet condemned).
17530
17468
  */
17531
- zoneNames: array(string()).readonly().optional(),
17532
- /** Deduplicated set of detector classes observed for this track over its
17533
- * life (a track may be reclassified, e.g. person→vehicle). Absent on
17534
- * legacy rows written before class accumulation shipped. */
17535
- classes: array(string()).readonly().optional(),
17536
- /** Cumulative normalized distance travelled (0..1 units = full frame width). */
17537
- totalDistance: number(),
17538
- state: TrackStateSchema,
17539
- active: boolean(),
17540
- /** Deterministic key-event importance score in [0,1] (server-computed at
17541
- * track expiry, recomputed on late label). Absent on legacy rows written
17542
- * before scoring shipped — consumers degrade to absence / compute-on-read. */
17543
- importance: number().optional(),
17544
- /** Id of the track's highest-confidence ObjectEvent (its representative
17545
- * "best" frame). Absent when the track produced no object events. */
17546
- bestEventId: string().optional(),
17547
- /** Tag of the importance sub-signal that dominated the score
17548
- * (identity|dwell|proximity|class|confidence|travel|zone). */
17549
- importanceReason: string().optional(),
17550
- /** Audio-classification labels heard on the camera during the track's
17551
- * life (score ≥ device `classificationMinScore`), aggregated per label.
17552
- * Absent on legacy rows / tracks with no confident audio. */
17553
- audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
17554
- /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
17555
- * Populated from the persisted envelope columns on historical reads;
17556
- * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
17557
- envelope: TrackEnvelopeSchema.optional(),
17469
+ state: _enum(["failed", "backoff"]),
17470
+ /** Epoch ms of the death that produced this state. */
17471
+ since: number(),
17472
+ /** Pool deaths inside the current window. */
17473
+ deaths: number(),
17474
+ /** The last death's message. */
17475
+ lastError: string()
17476
+ })).readonly() })), method(object({
17477
+ nodeId: string(),
17478
+ deviceKey: string()
17479
+ }), object({ rearmed: boolean() }), {
17480
+ kind: "mutation",
17481
+ auth: "admin"
17482
+ }), 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({
17483
+ name: string(),
17484
+ steps: array(PipelineTemplateStepSchema).readonly(),
17485
+ engine: PipelineEngineChoiceSchema
17486
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
17487
+ id: string(),
17488
+ name: string().optional(),
17489
+ steps: array(PipelineTemplateStepSchema).readonly().optional()
17490
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
17491
+ addonId: string(),
17492
+ modelId: string(),
17493
+ format: ModelFormatSchema$1
17494
+ }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
17495
+ addonId: string(),
17496
+ modelId: string(),
17497
+ format: ModelFormatSchema$1
17498
+ }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
17499
+ engine: PipelineEngineChoiceSchema.optional(),
17500
+ steps: array(PipelineStepInputSchema).min(1),
17501
+ frame: FrameInputSchema.optional(),
17558
17502
  /**
17559
- * A face DETECTOR found a face on this track — nothing more. It says the
17560
- * detail plane produced a `face` detail; it does NOT say the face was
17561
- * embedded, matched, above `minFacePx`, or that the recognizer was even
17562
- * enabled. Set once and never cleared.
17563
- *
17564
- * **This exists so "face present but not recognised" is expressible.** A
17565
- * recognised identity lands in `subLabel` (attributed to the face chain via
17566
- * `subLabelMeta.stepId`), so before this field a track with an unmatched face
17567
- * and a track with no face at all were byte-identical on the wire and no
17568
- * surface could tell them apart. The read is `hasFace === true && subLabel
17569
- * === undefined`.
17570
- *
17571
- * **Absent ≠ false.** Every row written before the column existed omits it,
17572
- * and so does every server that predates the field — a consumer must test
17573
- * `=== true` and render nothing otherwise, never infer "no face".
17503
+ * Process-local lazy frame. Valid only when caller and provider resolve
17504
+ * in the same execution-group process; split/cross-node callers use
17505
+ * `frame`/`image` inline compatibility instead.
17574
17506
  */
17575
- hasFace: boolean().optional(),
17507
+ frameRef: FrameRefSchema.optional(),
17576
17508
  /**
17577
- * This track has a face row IN THE GALLERY: a crop **and** an embedding — a
17578
- * face an operator could ASSIGN to an identity.
17579
- *
17580
- * The STRICT twin of {@link hasFace}, and the pair only earns its keep
17581
- * because the two disagree. `hasFace` is stamped at the TOP of the face
17582
- * branch, before every gate, and means no more than "a face detector produced
17583
- * a face detail". This one is stamped at the single moment the gallery row
17584
- * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
17585
- * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
17586
- * candidate gate, the imageless-track drop (no crop was ever captured) and
17587
- * the crop-store drop. Everything between the detector and that insert can
17588
- * legitimately refuse the face, so a flag written any earlier promises the
17589
- * operator something to assign and delivers nothing.
17590
- *
17591
- * **Independent of recognition.** A face collected but never auto-matched is
17592
- * still assignable — it is in fact the face an operator most wants to reach —
17593
- * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
17594
- * `subLabel`; this says only that the raw material exists.
17595
- *
17596
- * **Set once, never cleared.** A track that produced a gallery row produced
17597
- * one; deleting the row later is the gallery's business, not this flag's.
17598
- *
17599
- * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
17600
- * before the column omits it, and so does every server that predates the
17601
- * field. A consumer must test `=== true` and render nothing otherwise —
17602
- * never infer "no assignable face".
17509
+ * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
17510
+ * the decoded pixels live in. One more member of the one-of
17511
+ * frame/frameHandle/image/imageBase64/referenceImage group.
17603
17512
  */
17604
- hasEmbeddedFace: boolean().optional(),
17513
+ frameHandle: FrameHandleSchema.optional(),
17514
+ imageBase64: string().optional(),
17605
17515
  /**
17606
- * This subject CONTAINS a folded rider — a person the rider-pairing step
17607
- * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
17608
- * so the passage is tracked once and as a VEHICLE.
17609
- *
17610
- * It exists because the fold's record was dishonest. D34 and the code both
17611
- * said "the person is not lost — it is reported so both entities stay on the
17612
- * record"; in fact the pair went into a per-processor RAM field behind an
17613
- * accessor nobody called, and every durable surface said `vehicle`, full
17614
- * stop. This is the composition note that makes the row true.
17615
- *
17616
- * A COMPOSITION, never a class and never a label. "This vehicle contains a
17617
- * person" is not an answer to "what is this" — both label tiers would refuse
17618
- * a macro token anyway (D89), and correctly. Nothing here changes what the
17619
- * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
17620
- * and a `person` rule still does not fire for someone cycling past.
17621
- *
17622
- * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
17623
- * the column, and every hub that predates the field, omits it. Test
17624
- * `=== true` and render nothing otherwise — never infer "no rider".
17516
+ * Binary JPEG bytes — preferred over `imageBase64` on internal
17517
+ * hops (hub → forked worker via Moleculer MsgPack) because it
17518
+ * skips the 33% base64 overhead + the per-call base64 decode on
17519
+ * the detection-pipeline worker. Callers can pass either; exactly
17520
+ * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
17625
17521
  */
17626
- hasRider: boolean().optional(),
17627
- ...TrackFlagFields,
17628
- ...TrackRetrainFields
17629
- });
17630
- var BaseEventFields = {
17631
- id: string(),
17632
- deviceId: number(),
17633
- timestamp: number()
17634
- };
17635
- var MotionEventSchema = object({
17636
- ...BaseEventFields,
17637
- kind: literal("motion"),
17638
- regionCount: number(),
17639
- /** Heavy JSON array — omitted in slim projection. */
17640
- regions: array(object({
17641
- bbox: BoundingBoxSchema,
17642
- pixelCount: number(),
17643
- intensity: number()
17644
- })).readonly().optional(),
17645
- /** Omitted in slim projection. */
17646
- frameWidth: number().optional(),
17647
- /** Omitted in slim projection. */
17648
- frameHeight: number().optional(),
17649
- /** Populated by B5 (recording playback URL for this event). */
17650
- mediaUrl: string().optional()
17651
- });
17522
+ image: _instanceof(Uint8Array).optional(),
17523
+ referenceImage: string().optional(),
17524
+ deviceId: number().optional(),
17525
+ sessionId: string().optional(),
17526
+ /**
17527
+ * Execution plane. 'full' (default) runs the whole tree — benchmark,
17528
+ * reference-image, and detail-subtree calls. 'frame' is the live
17529
+ * per-frame dispatch: ONLY root-plane steps run; crop children
17530
+ * (inputClasses ≠ null) are skipped and served per-track via
17531
+ * pipelineRunner.runDetailSubtree (two-plane design).
17532
+ */
17533
+ plane: _enum(["full", "frame"]).optional(),
17534
+ /**
17535
+ * Inference-device selector (Phase 2 multi-device). Format
17536
+ * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
17537
+ * Omitted ⇒ the runner's default device (current single-engine
17538
+ * behaviour). Selects WHICH device pool of the node runs the call.
17539
+ */
17540
+ deviceKey: string().optional(),
17541
+ /**
17542
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
17543
+ * when the parent crop was resolved from the frame's retained NATIVE
17544
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
17545
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
17546
+ * resolution from that surface — the SAME quality path faces already
17547
+ * had — instead of the downscaled parent tile. `handle` keys the native
17548
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
17549
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
17550
+ * the executor's crop-normalized child ROI back into frame-normalized
17551
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
17552
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
17553
+ * (today's behaviour on the fallback path).
17554
+ */
17555
+ nativeCropRef: NativeCropRefSchema.optional()
17556
+ }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
17557
+ engine: PipelineEngineChoiceSchema.optional(),
17558
+ steps: array(PipelineStepInputSchema).min(1),
17559
+ frames: array(FrameInputSchema).min(1).max(255),
17560
+ deviceId: number().optional(),
17561
+ sessionId: string().optional(),
17562
+ /**
17563
+ * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
17564
+ * the batch to the Python pool's bench preprocess cache
17565
+ * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
17566
+ * preprocessed ONCE and every later inference is a pure-inference cache
17567
+ * hit — the sustained-throughput run measures inference, not
17568
+ * decode+preprocess+infer. Omitted/0 for live frames (all different →
17569
+ * full preprocess every call, correct). Fresh per sustained run;
17570
+ * released via `uncacheFrame`.
17571
+ */
17572
+ frameId: number().int().nonnegative().optional(),
17573
+ /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
17574
+ deviceKey: string().optional()
17575
+ }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
17576
+ data: _instanceof(Uint8Array),
17577
+ width: number().int().positive(),
17578
+ height: number().int().positive(),
17579
+ format: _enum([
17580
+ "rgb",
17581
+ "bgr",
17582
+ "gray"
17583
+ ])
17584
+ }), object({
17585
+ frameId: number(),
17586
+ width: number(),
17587
+ height: number()
17588
+ }), { kind: "mutation" }), method(object({
17589
+ stepId: string(),
17590
+ frameId: number().int()
17591
+ }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
17592
+ batchMode: string(),
17593
+ windowMs: number(),
17594
+ maxBatchSize: number(),
17595
+ concurrency: number()
17596
+ })), method(_void(), array(object({
17597
+ engineKey: string(),
17598
+ engine: PipelineEngineChoiceSchema,
17599
+ modelsLoaded: array(string()).readonly(),
17600
+ inUseByCameras: array(number()).readonly(),
17601
+ /**
17602
+ * Origin of this resident factory.
17603
+ * - `runtime` — main camera-serving engine (no idle TTL).
17604
+ * - `warm-override` — benchmark/test override held in the warm
17605
+ * cache; auto-disposed after the idle TTL.
17606
+ * - `device-pool` — a concurrent per-device pool (Phase 2
17607
+ * multi-device, keyed by `deviceKey`) resolved
17608
+ * via `resolveDeviceFactory`. Runs alongside the
17609
+ * `runtime` engine on a DIFFERENT accelerator
17610
+ * (NPU / iGPU / Coral) — this is how the
17611
+ * Engines tab shows all pools running at once.
17612
+ */
17613
+ kind: _enum([
17614
+ "runtime",
17615
+ "warm-override",
17616
+ "device-pool"
17617
+ ]),
17618
+ /** Native pid of the underlying Python pool (null when no pool). */
17619
+ poolPid: number().nullable(),
17620
+ /** ms since this factory was last used (null when not warm-tracked). */
17621
+ idleMs: number().nullable(),
17622
+ /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
17623
+ idleTtlMs: number().nullable()
17624
+ })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
17625
+ kind: "mutation",
17626
+ auth: "admin"
17627
+ }), method(object({
17628
+ engine: PipelineEngineChoiceSchema,
17629
+ force: boolean().optional()
17630
+ }), object({
17631
+ success: boolean(),
17632
+ reason: string().optional()
17633
+ }), {
17634
+ kind: "mutation",
17635
+ auth: "admin"
17636
+ }), 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({
17637
+ addonId: string(),
17638
+ modelId: string(),
17639
+ filename: string().optional(),
17640
+ settings: record(string(), unknown()).optional()
17641
+ }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
17652
17642
  /**
17653
- * Which detection SOURCE produced an object event. `pipeline` = the ML
17654
- * detection pipeline (decoded-frame inference); `onboard` = the camera's
17655
- * native on-device AI. Both flow through the SAME analysis layers (zoning,
17656
- * tracking, per-kind persistence) but stay distinguishable so consumers
17657
- * (advanced-notifier, occupancy, …) can select which source(s) to act on.
17658
- * Absent on legacy rows ⇒ treat as `pipeline`.
17643
+ * Per-stage gating mode applied to the zones a rule references.
17644
+ *
17645
+ * - `include`: the rule contributes to a **whitelist** for its stage.
17646
+ * When at least one `include` rule fires for a stage, only entities
17647
+ * inside one of those zones pass that stage.
17648
+ * - `exclude`: the rule contributes to a **blacklist** for its stage.
17649
+ * Entities inside one of those zones are dropped at that stage.
17650
+ *
17651
+ * `monitor`-style observation (count without filtering) is not a rule
17652
+ * mode — zones without any matching rule are observed naturally by
17653
+ * `zone-analytics` (live snapshot + history), so an "I just want to
17654
+ * count, not filter" use case needs no rule at all.
17659
17655
  */
17660
- var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
17656
+ var ZoneRuleModeEnum = _enum(["include", "exclude"]);
17661
17657
  /**
17662
- * The confirmed zone crossing that produced an object event. Present ONLY on
17663
- * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
17664
- * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
17665
- * appearance event carry none, so a rule asking for a direction fails closed
17666
- * on them.
17658
+ * Per-consumer rule that references existing zones (geometry) and
17659
+ * defines how a specific pipeline stage should treat them. Each
17660
+ * consumer addon owns its own `ZoneRule[]` array in its per-device
17661
+ * settings:
17667
17662
  *
17668
- * Exactly ONE crossing per event: the emitter turns each confirmed crossing
17669
- * into its own event, so a frame in which a track enters A while leaving B
17670
- * produces two events with two directions — never one ambiguous row.
17663
+ * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
17664
+ * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
17665
+ * - future: notification rules, audio gating, etc.
17671
17666
  *
17672
- * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
17673
- * membership the box has NOW, and by definition it no longer contains the zone
17674
- * that was just left. Without the id here, a zone-scoped rule could never match
17675
- * the exit it asked for.
17667
+ * One rule applies to N zones (`zoneIds[]`) so the operator can
17668
+ * express "ignore motion in ALL of {garden, street}" with a single
17669
+ * rule. `classFilter` narrows the rule to specific object classes —
17670
+ * "drop person detections in the street, but keep cars" is one
17671
+ * `exclude` rule with `classFilter: ['person']`.
17672
+ *
17673
+ * `enabled` is a soft toggle — the operator can keep the rule
17674
+ * configured but inert without deleting it.
17676
17675
  */
17677
- var ZoneCrossingSchema = object({
17678
- direction: _enum(["enter", "exit"]),
17679
- /** Admin zone id crossed. */
17680
- zoneId: string(),
17681
- /** Zone display name at crossing time (falls back to the id). */
17682
- zoneName: string().optional()
17683
- });
17684
- var ObjectEventSchema = object({
17685
- ...BaseEventFields,
17686
- kind: literal("object"),
17687
- /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
17688
- source: DetectionSourceSchema.optional(),
17676
+ var ZoneRuleSchema = object({
17677
+ /** Stable rule id — survives edits, used by the UI for diffing. */
17678
+ id: string(),
17679
+ /** Optional human-readable label rendered in the rule editor. */
17680
+ name: string().optional(),
17681
+ /** Zones this rule targets. The rule's `mode` applies to ALL
17682
+ * listed zones (OR-set: a detection in any one of them counts).
17683
+ * At least one zone id required — a rule with no targets is a
17684
+ * configuration mistake and the form validator rejects it. */
17685
+ zoneIds: array(string()).min(1).readonly(),
17686
+ mode: ZoneRuleModeEnum,
17689
17687
  /**
17690
- * Inference-frame id shared by every object event emitted from the SAME frame
17691
- * — the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
17692
- * 2 people + 1 dog) under one full frame, and link a track's frames over time
17693
- * (group by `trackId`, pick a representative `frameId` as the parent frame).
17694
- * Optional for backward-compat with pre-existing rows / the slim projection
17695
- * includes it (it is light). Absent on rows written before this field.
17688
+ * Class names this rule applies to. Empty / undefined ⇒ rule
17689
+ * applies to every class. Class strings match the `macroClass`
17690
+ * field on detections (e.g. `person`, `car`, `dog`).
17696
17691
  */
17697
- frameId: string().optional(),
17698
- /** Omitted in slim projection. */
17699
- trackId: string().optional(),
17700
- className: string(),
17701
- ...TieredLabelFields,
17702
- /** Omitted in slim projection. */
17703
- confidence: number().optional(),
17704
- /** Heavy JSON — omitted in slim projection. */
17705
- bbox: BoundingBoxSchema.optional(),
17706
- /** Heavy JSON — omitted in slim projection. */
17707
- zones: array(string()).readonly().optional(),
17708
- /** Omitted in slim projection. */
17709
- state: TrackStateSchema.optional(),
17692
+ classFilter: array(string()).readonly().optional(),
17710
17693
  /**
17711
- * The zone crossing this event IS, when it is one. Absent on every other
17712
- * event kind (movement state, appearance, package) — see
17713
- * {@link ZoneCrossingSchema}. Omitted in slim projection.
17694
+ * Minimum bbox/mask overlap (0–1) with any of the rule's zones
17695
+ * required to consider an entity "in the zone". Defaults to the
17696
+ * consumer's stage default when omitted. Kept for back-compat with
17697
+ * existing per-rule overrides; new operators pick the value via
17698
+ * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
17699
+ * set, the lower-level engine reads it as a 0–1 fraction.
17714
17700
  */
17715
- zoneCrossing: ZoneCrossingSchema.optional(),
17716
- /** Detection-frame dimensions in pixels — let consumers normalize the
17717
- * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
17718
- frameWidth: number().optional(),
17719
- frameHeight: number().optional(),
17720
- /** MediaStore key for the crop attached to this event (if any). */
17721
- mediaKey: string().optional(),
17722
- /** Design B: MediaStore key of the track's native-resolution key frame (the
17723
- * best-detection full frame). Resolve via the event-media data-plane
17724
- * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
17725
- * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
17726
- * sources — consumers fall back to `mediaKey` (the tight crop). */
17727
- keyFrameMediaKey: string().optional(),
17728
- /** Populated by B5 (recording playback URL for this event). */
17729
- mediaUrl: string().optional(),
17730
- /** The parent track's key-event importance [0,1], propagated to every object
17731
- * event of the track (so an event row can be sorted by importance without a
17732
- * track join). Absent on legacy rows / before the track was scored. */
17733
- importance: number().optional()
17701
+ overlapThreshold: number().min(0).max(1).optional(),
17702
+ /**
17703
+ * Operator-friendly version of `overlapThreshold` — the percentage
17704
+ * of the detection's bbox that must lie inside the zone for the
17705
+ * rule to match. Documented default is 85%; the engine substitutes
17706
+ * that when the field is omitted (kept optional so existing rules
17707
+ * stored without it stay valid).
17708
+ *
17709
+ * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
17710
+ * rule, the engine prefers `bboxInclusionPct` because it's the
17711
+ * field exposed in the UI. Internally both feed the same gate.
17712
+ */
17713
+ bboxInclusionPct: number().min(0).max(100).optional(),
17714
+ /**
17715
+ * When `true` and a detection has a segmentation mask, use the
17716
+ * mask for overlap instead of the bbox. Detection-stage only;
17717
+ * motion rules ignore this field.
17718
+ */
17719
+ preferMask: boolean().optional(),
17720
+ /**
17721
+ * Soft-toggle: `false` disables the rule without deleting it.
17722
+ * Defaults to `true` so operators creating a rule via the UI
17723
+ * see it active immediately.
17724
+ */
17725
+ enabled: boolean().default(true)
17734
17726
  });
17735
- var AudioEventSchema = object({
17736
- ...BaseEventFields,
17737
- kind: literal("audio"),
17738
- rms: number(),
17739
- dbfs: number(),
17740
- classification: object({
17741
- className: string(),
17742
- originalClass: string().optional(),
17743
- score: number()
17744
- }).optional(),
17745
- /** Populated by B5 (recording playback URL for this event). */
17746
- mediaUrl: string().optional()
17727
+ array(ZoneRuleSchema).readonly();
17728
+ /**
17729
+ * Zone — pure geometry + identity. NO filtering behaviour.
17730
+ *
17731
+ * Zones describe **where** in the frame the operator wants to flag
17732
+ * something; consumer-owned {@link ZoneRule} arrays describe **how**
17733
+ * each pipeline stage uses them. Splitting the two means a single
17734
+ * polygon "Driveway" can simultaneously back a motion-exclude rule,
17735
+ * a detection-include rule on `['car']`, and an occupancy aggregate
17736
+ * — without three duplicated polygons.
17737
+ *
17738
+ * Owned by the orchestrator addon (provider) and mirrored into the
17739
+ * `zones` device-state slice on every mutation. Consumers
17740
+ * (motion-wasm, pipeline-executor, analytics, admin UI) read either
17741
+ * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
17742
+ * mirror with `onChanged`).
17743
+ *
17744
+ * Coordinates are normalised fractions of the frame (0–1) so zones
17745
+ * survive resolution changes and stream profile switches.
17746
+ *
17747
+ * `kind` discriminates between full polygons (closed regions used
17748
+ * for intrusion / occupancy filters) and tripwires (open 2-point
17749
+ * line segments used for cross events). Onboard / firmware-reported
17750
+ * zones (Reolink, ONVIF) are out of scope for now — see the deferred
17751
+ * task list.
17752
+ */
17753
+ var ZoneKindEnum = _enum(["polygon", "tripwire"]);
17754
+ /** Polygon vertex in fraction-of-frame coordinates (0–1). */
17755
+ var PolygonPointSchema = object({
17756
+ x: number(),
17757
+ y: number()
17747
17758
  });
17748
- var MediaFileKindEnum = _enum([
17749
- "crop",
17750
- "thumbnail",
17751
- "snapshot",
17752
- "firstFrame",
17753
- "lastFrame",
17754
- "fullFrame",
17755
- "fullFrameBoxed",
17756
- "faceCrop",
17757
- "plateCrop",
17758
- "keyFrame",
17759
- "keyFrameSmall",
17760
- "thumbnailSmall"
17761
- ]);
17762
- var MediaFileSchema = object({
17763
- key: string(),
17764
- kind: MediaFileKindEnum,
17765
- base64: string(),
17766
- sizeBytes: number(),
17767
- timestamp: number()
17759
+ /** A camera detection zone — pure geometry/identity. */
17760
+ var ZoneSchema = object({
17761
+ id: string(),
17762
+ name: string(),
17763
+ kind: ZoneKindEnum.default("polygon"),
17764
+ /** Polygon vertices, fraction of frame (0–1). */
17765
+ polygon: array(PolygonPointSchema).readonly(),
17766
+ /** Visual color for UI rendering. */
17767
+ color: string().default("#3b82f6")
17768
17768
  });
17769
17769
  /**
17770
- * One media row WITHOUT its bytes.
17770
+ * Zones capability — per-camera CRUD over polygon detection zones.
17771
17771
  *
17772
- * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
17773
- * 140 s track), and a client that renders tiles from the media data plane needs
17774
- * to know only WHAT EXISTS — the bytes then arrive per tile, lazily, over HTTP
17775
- * with an immutable cache, instead of all at once inside a tRPC response that
17776
- * blocks the whole view.
17772
+ * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
17773
+ * to per-device settings and mirrors into the `zones` device-state
17774
+ * slice on every mutation, so downstream consumers can subscribe via
17775
+ * `dev.state.zones.onChanged`.
17777
17776
  *
17778
- * `sizeBytes` is carried because it is what lets a client decide between the
17779
- * stored blob and a `?variant=thumb` rendering without fetching either.
17777
+ * The cap surface only handles geometry + identity; filtering
17778
+ * behaviour (per-class, include/exclude, threshold) lives in the
17779
+ * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
17780
+ * `capabilities/schemas/zone-rule.js`.
17780
17781
  */
17781
- var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
17782
+ var zonesCapability = {
17783
+ name: "zones",
17784
+ scope: "device",
17785
+ mode: "singleton",
17786
+ deviceTypes: [DeviceType.Camera],
17787
+ methods: {
17788
+ listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
17789
+ addZone: method(object({
17790
+ deviceId: number(),
17791
+ zone: ZoneSchema
17792
+ }), _void(), {
17793
+ kind: "mutation",
17794
+ auth: "admin"
17795
+ }),
17796
+ removeZone: method(object({
17797
+ deviceId: number(),
17798
+ zoneId: string()
17799
+ }), _void(), {
17800
+ kind: "mutation",
17801
+ auth: "admin"
17802
+ }),
17803
+ updateZone: method(object({
17804
+ deviceId: number(),
17805
+ zone: ZoneSchema
17806
+ }), _void(), {
17807
+ kind: "mutation",
17808
+ auth: "admin"
17809
+ })
17810
+ },
17811
+ /**
17812
+ * Runtime-state slice — the live zone catalogue mirrored by the
17813
+ * orchestrator on every CRUD mutation. Consumers read via
17814
+ * `device.state.zones.value` / `.watch(...)` without round-tripping
17815
+ * the cap, and the codegen DeviceProxy auto-wires the reactive
17816
+ * handle. Slice shape is `{ zones: Zone[] }` so future extensions
17817
+ * (e.g. zone groupings) can sit alongside the polygon list.
17818
+ */
17819
+ runtimeState: object({ zones: array(ZoneSchema).readonly() }),
17820
+ /**
17821
+ * Runtime-state durability: **restored** — written only on operator mutation, so a camera that never had one has nothing to re-derive from. This is the slice `zone-mirror-hydration.ts` exists to paper over.
17822
+ *
17823
+ * See `RuntimeStateDurability`. Enforced by
17824
+ * `scripts/check-runtime-state-durability.ts`.
17825
+ */
17826
+ durability: "restored"
17827
+ };
17782
17828
  /**
17783
- * The MACRO tier of an annotation — a CLOSED set.
17829
+ * pipeline-analytics — device-scoped wrapper cap. Refines raw
17830
+ * per-frame detections emitted by the pipeline runner into tracked
17831
+ * objects, per-kind event collections (motion / object / audio), and
17832
+ * persisted media. Owns the post-detection domain end-to-end:
17784
17833
  *
17785
- * This is what the exported detector predicts, so a typo here is a new class
17786
- * with one example in it. `label` and `subLabel` are open strings by contrast:
17787
- * the whole point of the page is teaching the model things it does not know
17788
- * yet, and constraining that vocabulary would make it useless.
17834
+ * runner emits PipelineInferenceResult
17835
+ * ↓ (event bus)
17836
+ * pipeline-analytics subscriber
17837
+ * ↓ SORT tracker + zone engine + state analyzer + event emitter
17838
+ * → three DB collections (one per kind), one FS media tree, one
17839
+ * unified event emitter (FrameTracked + TrackStarted/Ended +
17840
+ * DetectionEvent on bus)
17789
17841
  *
17790
- * A macro class is NEVER a label. The provider refuses a write whose `label` or
17791
- * `subLabel` is one of these values, in any casing, because once `person`
17792
- * exists in both tiers "every person box" stops being answerable without
17793
- * knowing every string anyone ever typed — and the damage is retroactive.
17842
+ * Pure subscriber model. No `processFrame` cap method — the runner
17843
+ * already publishes the raw frame on the bus. The cap surface is
17844
+ * only QUERIES + per-device settings, bound on/off via
17845
+ * `device-manager.setWrapperActive`. `defaultActive: true` because
17846
+ * every camera with a detection pipeline wants its raw detections
17847
+ * refined; operators opt out per-device via BindingsTab when needed.
17848
+ *
17849
+ * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
17850
+ * (per-device surface) and `track-trail` caps — see P11 cleanup.
17794
17851
  */
17795
- var RetrainMacroClassSchema = _enum([
17852
+ var TrackStateSchema = _enum([
17853
+ "new",
17854
+ "entered",
17855
+ "left",
17856
+ "moving",
17857
+ "idle"
17858
+ ]);
17859
+ var EventKindSchema = _enum([
17860
+ "motion",
17861
+ "object",
17862
+ "audio"
17863
+ ]);
17864
+ /**
17865
+ * Spatial filter for `listTracks` — the rect + polygon variants of the shared
17866
+ * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
17867
+ * of the camera frame (top-left origin), matching the drawing-plane editor.
17868
+ */
17869
+ var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
17870
+ /** Closed icon vocabulary so clients render a known glyph per kind. */
17871
+ var EventKindIconSchema = _enum([
17872
+ "motion",
17873
+ "audio",
17796
17874
  "person",
17797
17875
  "vehicle",
17798
17876
  "animal",
17877
+ "door",
17878
+ "pir",
17879
+ "smoke",
17880
+ "water",
17881
+ "button",
17799
17882
  "package",
17800
- "face",
17801
- "plate"
17883
+ "generic"
17802
17884
  ]);
17803
- /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
17804
- var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
17805
- /** Did a human draw this box, or did the assist propose it? */
17806
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
17807
- /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
17808
- var RetrainBboxSchema = object({
17809
- x: number(),
17810
- y: number(),
17811
- w: number(),
17812
- h: number()
17885
+ var EventKindCategorySchema = _enum([
17886
+ "motion",
17887
+ "audio",
17888
+ "detection",
17889
+ "sensor",
17890
+ "control",
17891
+ "custom",
17892
+ "package"
17893
+ ]);
17894
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
17895
+ var EventKindLevelSchema = _enum(["macro", "sub"]);
17896
+ var EventKindDescriptorSchema = object({
17897
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
17898
+ kind: string(),
17899
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
17900
+ labelKey: string(),
17901
+ /** English fallback label (kept for clients that don't translate). */
17902
+ label: string(),
17903
+ /** Hex color for timeline/legend rendering. */
17904
+ color: string(),
17905
+ /** Dictionary id → lucide component on the UI side. */
17906
+ iconId: string(),
17907
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
17908
+ icon: EventKindIconSchema,
17909
+ category: EventKindCategorySchema,
17910
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
17911
+ parentKind: string().nullable(),
17912
+ /** Derived from `parentKind`, explicit for the client tree. */
17913
+ level: EventKindLevelSchema,
17914
+ /** Which cap + device contributes this kind. For built-ins the camera
17915
+ * itself; for sensor kinds the LINKED source device. */
17916
+ source: object({
17917
+ capName: string(),
17918
+ deviceId: number()
17919
+ })
17813
17920
  });
17814
- /**
17815
- * One annotated subject.
17816
- *
17817
- * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
17818
- * (letterboxed root / zone-cropped package / subject-cropped classifier) are
17819
- * derived from it at export and never stored — storing them is how one feature
17820
- * space ends up holding two crops of the same subject (D52).
17821
- */
17822
- var RetrainAnnotationSchema = object({
17823
- id: string(),
17824
- trackId: string(),
17921
+ /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
17922
+ var EventKindsForDeviceSchema = object({
17825
17923
  deviceId: number(),
17826
- /** The COPY in retrain storage — never the source track's media key. */
17827
- mediaKey: string(),
17828
- bbox: RetrainBboxSchema,
17829
- macroClass: RetrainMacroClassSchema,
17830
- label: string().optional(),
17831
- subLabel: string().optional(),
17832
- kind: RetrainAnnotationKindSchema,
17833
- source: RetrainAnnotationSourceSchema,
17834
- /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
17835
- assistModelId: string().optional(),
17836
- assistScore: number().optional(),
17837
- exportedInBatch: string().optional(),
17838
- createdAt: number()
17839
- });
17840
- /** The write form — the server owns `id`, `createdAt` and the frame binding. */
17841
- var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
17842
- id: true,
17843
- trackId: true,
17844
- deviceId: true,
17845
- mediaKey: true,
17846
- createdAt: true,
17847
- exportedInBatch: true
17924
+ kinds: array(EventKindDescriptorSchema).readonly()
17848
17925
  });
17849
- /** A track sitting in `staging`, with everything the worklist needs to rank it. */
17850
- var RetrainTrackSchema = object({
17851
- trackId: string(),
17926
+ var SensorEventSchema = object({
17927
+ id: string(),
17928
+ /** The CAMERA the event is attributed to (a sensor linked to N cameras
17929
+ * yields N rows, one per camera). */
17852
17930
  deviceId: number(),
17853
- className: string(),
17854
- label: string().optional(),
17855
- firstSeen: number(),
17856
- lastSeen: number(),
17857
- /** How many frames the dataset already holds from this track. */
17858
- frameCount: number().int(),
17859
- /** How many subjects have been annotated on those frames. `0` with
17860
- * `frameCount: 0` is exactly "staging, still to work". */
17861
- annotationCount: number().int()
17931
+ /** The linked sensor device whose state changed. */
17932
+ sourceDeviceId: number(),
17933
+ /** Event kind id — matches an `EventKindDescriptor.kind`. */
17934
+ kind: string(),
17935
+ /** Snapshot of the sensor cap's runtime-state slice at the change. */
17936
+ value: record(string(), unknown()).nullable(),
17937
+ timestamp: number()
17862
17938
  });
17863
- /** A frame the picker may offer — an index row, no blob was read to produce it. */
17864
- var RetrainFrameCandidateSchema = object({
17865
- mediaKey: string(),
17866
- kind: MediaFileKindEnum,
17939
+ var TrackPositionSchema = object({
17940
+ x: number(),
17941
+ y: number(),
17867
17942
  timestamp: number(),
17868
- sizeBytes: number().int(),
17869
- /** A copy of this original already exists — selecting it is free and cannot
17870
- * fail, whatever became of the original. */
17871
- copied: boolean()
17872
- });
17873
- /** A frame the dataset OWNS: bytes copied at selection time. */
17874
- var RetrainFrameSchema = object({
17875
- frameId: string(),
17876
- deviceId: number(),
17877
- trackId: string(),
17878
- /** Provenance only. It may already point at nothing — that is expected. */
17879
- sourceMediaKey: string(),
17880
- sourceKind: MediaFileKindEnum,
17881
- sizeBytes: number().int(),
17882
- width: number().int(),
17883
- height: number().int(),
17884
- copiedAt: number()
17885
- });
17886
- /** Why a copy-on-select could not be honoured — named, never a silent skip. */
17887
- var RetrainCopyRefusalSchema = _enum([
17888
- "source-missing",
17889
- "unreadable-image",
17890
- "write-failed"
17891
- ]);
17892
- var RetrainFrameSelectionSchema = object({
17893
- copied: array(RetrainFrameSchema).readonly(),
17894
- refused: array(object({
17895
- sourceMediaKey: string(),
17896
- reason: RetrainCopyRefusalSchema
17897
- })).readonly()
17943
+ bbox: BoundingBoxSchema
17898
17944
  });
17899
- var RetrainFrameListSchema = object({
17900
- candidates: array(RetrainFrameCandidateSchema).readonly(),
17901
- copies: array(RetrainFrameSchema).readonly(),
17902
- /** What the page pre-selects — the native key frame when one survives. */
17903
- autoPickMediaKey: string().optional()
17945
+ var TrackSnapshotSchema = object({
17946
+ timestamp: number(),
17947
+ position: TrackPositionSchema,
17948
+ /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
17949
+ mediaKey: string()
17904
17950
  });
17905
- /** What the operator asked the assist to look for. */
17906
- var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
17907
- kind: literal("package"),
17908
- zone: RetrainBboxSchema.optional()
17909
- }), object({
17910
- kind: literal("objects"),
17911
- modelId: string(),
17912
- minScore: number().optional()
17913
- })]);
17914
17951
  /**
17915
- * The assist's answer — a discriminated union, because "the model saw nothing"
17916
- * and "this node cannot run that model" lead to different next moves and a
17917
- * nullable result cannot tell them apart.
17952
+ * Normalized 0..1 trajectory envelope (min/max over every position bbox,
17953
+ * divided by the track's detection-frame dims), computed at persist time.
17954
+ * Absent when the frame dims were unknown when the track was persisted
17955
+ * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
17918
17956
  */
17919
- var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
17920
- kind: literal("proposed"),
17921
- modelId: string(),
17922
- stepId: string(),
17923
- minScore: number(),
17924
- /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
17925
- proposals: array(RetrainAnnotationDraftSchema).readonly(),
17926
- /** Returned by the runner but removed by the threshold. */
17927
- belowThreshold: number().int()
17928
- }), object({
17929
- kind: literal("refused"),
17930
- /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
17931
- reason: string(),
17932
- detail: string().optional()
17933
- })]);
17934
- /** The outcome of a lifecycle move owned by the retrain page. */
17935
- var RetrainTransitionResultSchema = object({
17936
- trackId: string(),
17937
- /** Where the track ended up, whatever happened. */
17938
- retrainStatus: RetrainStatusSchema,
17939
- /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
17940
- changed: boolean(),
17941
- reason: _enum([
17942
- "unknown-track",
17943
- "no-frames-copied",
17944
- "not-staging",
17945
- "not-trained",
17946
- "unchanged"
17947
- ]).optional()
17957
+ var TrackEnvelopeSchema = object({
17958
+ minX: number(),
17959
+ minY: number(),
17960
+ maxX: number(),
17961
+ maxY: number()
17948
17962
  });
17949
- var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
17950
- var MAX_EVENT_QUERY_LIMIT = 5e3;
17951
- var DeviceEventQueryInput = object({
17952
- deviceId: number(),
17953
- since: number().optional(),
17954
- until: number().optional(),
17955
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
17956
- /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
17957
- * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
17958
- * exact behaviour. Callers may omit this field — the store defaults to
17959
- * `full` when not provided. */
17960
- projection: _enum(["full", "slim"]).optional()
17961
- });
17962
- var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
17963
- var RecentTracksQueryInput = object({
17964
- /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
17965
- deviceIds: array(number()),
17966
- /** Window lower bound on `lastSeen` (inclusive). */
17967
- since: number().optional(),
17968
- /** Window upper bound on `lastSeen` (inclusive). */
17969
- until: number().optional(),
17970
- /** Page size. Default 200, max 1000. */
17971
- limit: number().int().min(1).max(1e3).default(200),
17972
- /** Opaque continuation cursor from a previous page's `nextCursor`.
17973
- * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
17974
- cursor: string().optional(),
17975
- /** See {@link TrackProjectionSchema}. Default `full`. */
17976
- projection: TrackProjectionSchema.optional(),
17977
- /** Include stationary-promoted rows (parked objects). Default false: the
17978
- * feed lists passages; parking records live on the stationary registry. */
17979
- includeStationary: boolean().optional()
17980
- });
17981
- var RecentTracksPageSchema = object({
17982
- /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
17983
- tracks: array(TrackSchema).readonly(),
17984
- /** Cursor for the next page, or null when this page is the last. */
17985
- nextCursor: string().nullable()
17986
- });
17987
- var LIST_GROUPS_DEFAULT_LIMIT = 40;
17988
- var LIST_GROUPS_MAX_LIMIT = 100;
17989
- var AnalyticsGroupRecordSchema = object({
17990
- id: string(),
17991
- deviceId: number().int(),
17992
- openedAt: number().int(),
17993
- closedAt: number().int(),
17994
- timestamp: number().int(),
17995
- memberCount: number().int(),
17996
- memberTrackIds: array(string()).readonly(),
17997
- className: string(),
17998
- classes: array(string()).readonly(),
17999
- /** Relative event-media path, or null when the group has no picture yet. */
18000
- mediaUrl: string().nullable(),
18001
- singleton: boolean()
18002
- });
18003
- var AnalyticsGroupMemberSchema = object({
18004
- trackId: string(),
18005
- deviceId: number().int(),
18006
- className: string(),
18007
- firstSeen: number().int(),
18008
- lastSeen: number().int(),
18009
- mediaUrl: string().nullable()
18010
- });
18011
- var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
18012
- var ListGroupsQueryInput = object({
18013
- /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
18014
- deviceIds: array(number()),
18015
- /** Window lower bound on `closedAt` (inclusive). */
18016
- since: number().optional(),
18017
- /** Window upper bound on `openedAt` (inclusive). */
18018
- until: number().optional(),
18019
- limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
18020
- /** Opaque continuation cursor from a previous page's `nextCursor`. */
18021
- cursor: string().optional()
18022
- });
18023
- var ListGroupsPageSchema = object({
18024
- groups: array(AnalyticsGroupRecordSchema).readonly(),
18025
- nextCursor: string().nullable()
18026
- });
18027
- var KeyEventQueryInput = object({
18028
- deviceId: number(),
18029
- /** Window lower bound (track firstSeen ≥ since). */
18030
- since: number(),
18031
- /** Window upper bound (track firstSeen ≤ until). */
18032
- until: number(),
18033
- limit: number().int().min(1).max(200).default(50),
18034
- /** Drop tracks scoring below this importance. */
18035
- minImportance: number().min(0).max(1).optional(),
18036
- /** Restrict to a single class (e.g. 'person'). */
18037
- classFilter: string().optional()
18038
- });
18039
- var KeyEventSchema = object({
18040
- /** The representative event id (the track's best ObjectEvent, else its trackId). */
18041
- id: string(),
18042
- trackId: string(),
18043
- /** Track start time (firstSeen). */
18044
- timestamp: number(),
18045
- className: string(),
18046
- ...TieredLabelFields,
18047
- importance: number(),
18048
- /** Highest-confidence ObjectEvent id for the track (empty when none). */
18049
- bestEventId: string(),
18050
- /** Track lifetime in ms (lastSeen - firstSeen). */
18051
- windowMs: number().optional(),
18052
- ...TrackFlagFields,
18053
- ...TrackRetrainFields
18054
- });
18055
- object({
18056
- trackId: string(),
18057
- className: string(),
18058
- confidence: number(),
18059
- bbox: BoundingBoxSchema,
18060
- zones: array(string()).readonly(),
18061
- state: TrackStateSchema
18062
- });
18063
- var OverlayDetectionSchema = looseObject({
18064
- id: string(),
18065
- kind: _enum(["first-level", "detail"]),
18066
- macroClass: string(),
18067
- score: number(),
18068
- bbox: object({
18069
- x: number(),
18070
- y: number(),
18071
- width: number(),
18072
- height: number()
18073
- }),
18074
- labels: array(looseObject({
18075
- label: string(),
18076
- score: number()
18077
- })).readonly(),
18078
- parentId: string().optional()
18079
- });
18080
- var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
18081
- var SearchObjectEventsInput = object({
18082
- text: string(),
18083
- deviceId: number().optional(),
18084
- since: number().optional(),
18085
- until: number().optional(),
18086
- classFilter: string().optional(),
18087
- limit: number().default(50),
18088
- minScore: number().min(0).max(1).default(.2)
18089
- });
18090
- var TrackCascadeCountsSchema = object({
18091
- /** Persisted track roots deleted (authoritative). */
18092
- tracks: number().int(),
18093
- /** Object events removed with their tracks (best-effort; see note above). */
18094
- events: number().int(),
18095
- /** Track/face/plate-owned media removed (best-effort). Never identity media. */
18096
- media: number().int(),
18097
- /** Unassigned (non-enrolled) face reads removed (best-effort). */
18098
- faces: number().int(),
18099
- /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
18100
- plates: number().int(),
18101
- /** Per-track CLIP search vectors removed (best-effort). */
18102
- embeddings: number().int(),
18103
- /** Group membership + group rows removed with their last member (best-effort). */
18104
- groups: number().int()
18105
- });
18106
- /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
18107
- var DiskReconcileCountsSchema = object({
18108
- mediaDropped: number().int(),
18109
- tracks: number().int(),
18110
- events: number().int()
18111
- });
18112
- /** Event-store footprint for one camera. */
18113
- var EventStoreDeviceFootprintSchema = object({
18114
- deviceId: number(),
18115
- /** Persisted event rows (motion + object + audio) for the camera. */
18116
- rows: number().int(),
18117
- /** Event-owned media bytes on disk for the camera. */
18118
- bytes: number().int()
18119
- });
18120
- /** Aggregate event-store footprint: global totals + per-camera breakdown. */
18121
- var EventStoreFootprintSchema = object({
18122
- totalRows: number().int(),
18123
- totalBytes: number().int(),
18124
- devices: array(EventStoreDeviceFootprintSchema).readonly()
18125
- });
18126
- /** Per-kind counts returned by the event-prune / device-delete mutations. */
18127
- var EventPruneCountsSchema = object({
18128
- motion: number().int(),
18129
- object: number().int(),
18130
- audio: number().int()
17963
+ /**
17964
+ * Row projection for track list queries. `full` (default) returns the
17965
+ * complete Track including the frame-rate `positions[]` history and the
17966
+ * `snapshots[]` references — megabytes across a page of tracks. `slim`
17967
+ * keeps every scalar the list surfaces actually render (ids, class(es),
17968
+ * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
17969
+ * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
17970
+ * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
17971
+ * `getTrack`. Mirrors the event-store `projection` convention
17972
+ * (`getObjectEvents` et al.).
17973
+ */
17974
+ var TrackProjectionSchema = _enum(["full", "slim"]);
17975
+ /**
17976
+ * One audio-classification label heard on the track's camera while the
17977
+ * track was alive, aggregated per label. An "episode" is one persisted
17978
+ * audio event (the confident-classification path: score ≥ the device's
17979
+ * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
17980
+ * one 32 ms inference chunk, so counts stay human-scaled.
17981
+ */
17982
+ var TrackAudioLabelSchema = object({
17983
+ label: string(),
17984
+ /** Highest classification score observed across the label's episodes. */
17985
+ peakScore: number(),
17986
+ /** Number of coalesced audio-event episodes carrying this label. */
17987
+ count: number(),
17988
+ firstAt: number(),
17989
+ lastAt: number()
18131
17990
  });
18132
17991
  /**
18133
- * Re-embed stored tracks from their key frames.
17992
+ * How a track was produced. `pipeline` (default / absent) = the spatial
17993
+ * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
17994
+ * no positions, a single snapshot, and no bbox trajectory at all:
18134
17995
  *
18135
- * The reason this is an operator-callable method and not a migration script:
18136
- * every knob that decides what a vector MEANS — encoder model, crop margin,
18137
- * squaring — is only changeable if the existing vectors can be regenerated.
18138
- * Mixing feature spaces in one index makes cosine scores incomparable, and the
18139
- * symptom is a quality regression with no visible cause.
17996
+ * - `sensor` — a linked sensor/control device state change.
17997
+ * - `audio` — an audio event on the camera itself that was anomalous for
17998
+ * THAT camera, loud, and heard while nothing visual was happening (D62).
17999
+ *
18000
+ * The spatial subsystems (tracker association, occupancy count, re-id /
18001
+ * embedding, resurrection) MUST skip every synthetic source. Test for that
18002
+ * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
18003
+ * check silently readmits every source added after it was written.
18140
18004
  */
18141
- var RebuildObjectEmbeddingsInput = object({
18142
- /** Restrict to one camera. Omit for the whole fleet. */
18143
- deviceId: number().optional(),
18144
- since: number().optional(),
18145
- until: number().optional(),
18146
- /** Stop after this many tracks; the result reports whether more remain. */
18147
- maxTracks: number().int().positive().optional(),
18148
- /**
18149
- * Run every embedding on THIS node instead of round-robining the fleet.
18150
- *
18151
- * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
18152
- * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
18153
- * calling it that would pin the rebuild REQUEST itself to that node — the
18154
- * rebuild orchestration lives on the hub, and only the per-track step runs
18155
- * remotely. This field is data; the per-track pin is applied inside.
18156
- *
18157
- * Absent ⇒ round-robin over every online node whose runner can serve the
18158
- * pinned model.
18159
- */
18160
- executeOnNodeId: string().optional(),
18161
- /**
18162
- * Milliseconds to wait between tracks; omit for the built-in default, `0` to
18163
- * run flat out.
18164
- *
18165
- * A rebuild is bulk maintenance on hub-main's single thread. Measured
18166
- * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
18167
- * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
18168
- * force is logged at start and finish so a deliberately slow pass reads
18169
- * differently from a stalled one.
18170
- */
18171
- pacingMs: number().int().nonnegative().optional()
18172
- });
18005
+ var TrackSourceSchema = _enum([
18006
+ "pipeline",
18007
+ "sensor",
18008
+ "audio"
18009
+ ]);
18173
18010
  /**
18174
- * Result of emptying the CLIP index.
18011
+ * Where a track sits in the RETRAIN lifecycle (D81).
18175
18012
  *
18176
- * The clean slate before a policy change: a new crop margin or encoder model
18177
- * leaves two feature spaces in one index whose cosine scores are not
18178
- * comparable, so wiping and rebuilding is the only way to be sure every vector
18179
- * means the same thing.
18013
+ * - `none` — never marked, or un-marked. Evictable.
18014
+ * - `staging` — the operator wants this track as training material and has not
18015
+ * finished with it. **This is the only state retention holds**: the track and
18016
+ * everything it owns (object events, crops, keyframes, CLIP vector) survive
18017
+ * the device's age window.
18018
+ * - `trained` — the retrain page has taken what it needed. The frames it chose
18019
+ * were COPIED into the retrain dataset at selection time, so the dataset no
18020
+ * longer depends on the track's media and the track becomes EVICTABLE again.
18021
+ * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
18022
+ * a deliberate action of the retrain page, not a side effect of a checkbox.
18023
+ *
18024
+ * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
18025
+ * the store's filter language has only positive equality and `whereIn` — no
18026
+ * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
18027
+ * would make the entire pre-column history immortal in one deploy.
18180
18028
  */
18181
- var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
18029
+ var RetrainStatusSchema = _enum([
18030
+ "none",
18031
+ "staging",
18032
+ "trained"
18033
+ ]);
18182
18034
  /**
18183
- * Acknowledgement that a rebuild STARTED.
18035
+ * Per-track OPERATOR flags — set by hand from the admin UI or the viewer, never
18036
+ * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
18037
+ * so the two surfaces cannot drift.
18184
18038
  *
18185
- * The pass costs ~1s per track — 45 minutes for a 2,600-track fleet — so it
18186
- * runs detached and this returns immediately. Waiting for it made the client
18187
- * time out while the work carried on server-side, which is the worst of both:
18188
- * no result and no way to know it was still going. Poll
18189
- * `getObjectEmbeddingRebuildStatus` for progress.
18190
- */
18191
- var RebuildObjectEmbeddingsResultSchema = object({
18192
- started: boolean(),
18193
- /** True when a pass was already running; the new request is ignored. */
18194
- alreadyRunning: boolean()
18195
- });
18196
- var RebuildStatusSchema = object({
18197
- running: boolean(),
18198
- scanned: number(),
18199
- rebuilt: number(),
18200
- /** Tracks whose key frame is gone — nothing to re-embed from. */
18201
- missingKeyFrame: number(),
18202
- /** Tracks with no usable detection box. */
18203
- missingBbox: number(),
18204
- /**
18205
- * Tracks an executing node REFUSED rather than broke on — an unreadable key
18206
- * frame, a step that threw. Separate from `failed` because the remedy is
18207
- * different, and because a whole camera silently contributing zero vectors
18208
- * is the shape of failure a rebuild must never hide.
18209
- */
18210
- notRunnable: number(),
18039
+ * **Absent ≠ false.** A track that has never been touched omits the field; an
18040
+ * explicitly un-flagged track carries `false`. Legacy rows written before the
18041
+ * columns existed read as absent, and a consumer that needs a boolean should say
18042
+ * `flag === true`, not `flag !== false`.
18043
+ *
18044
+ * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
18045
+ * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
18046
+ * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
18047
+ * `trained` track reports `false` while refusing both writes. The boolean is
18048
+ * kept because three surfaces drive a toggle off it; anything that needs to tell
18049
+ * "never marked" from "already trained" must read `retrainStatus`.
18050
+ *
18051
+ * `debug` does NOT pin; it is attention, not durability.
18052
+ *
18053
+ * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
18054
+ * A favourited track is skipped by retention the same way `staging` is, but
18055
+ * it does not enter `none|staging|trained` and has no staging budget.
18056
+ */
18057
+ var TrackFlagFields = {
18058
+ /** Operator marked this track as training material — i.e. `retrainStatus` is
18059
+ * `'staging'`. */
18060
+ markForTrain: boolean().optional(),
18061
+ /** Operator marked this track for diagnostic attention. */
18062
+ debug: boolean().optional(),
18063
+ /** Operator favourited this track. Pins it against pruning. */
18064
+ favourited: boolean().optional()
18065
+ };
18066
+ /**
18067
+ * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
18068
+ * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
18069
+ * write patch, and the status is not something the toggle sets — it is what the
18070
+ * toggle's boolean is derived from. Absent on an in-RAM track never touched;
18071
+ * always present on a persisted row (the column default materialises `'none'`).
18072
+ */
18073
+ var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
18074
+ /**
18075
+ * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
18076
+ * one flag can never clear the other — the toggles are independent and are
18077
+ * driven from three surfaces that do not know about each other.
18078
+ */
18079
+ var TrackFlagsPatchSchema = object(TrackFlagFields);
18080
+ /**
18081
+ * The resolved flag state after a write. Both fields are REQUIRED here (absent
18082
+ * collapses to `false`) so a caller can drive a toggle's checked state off the
18083
+ * mutation result without a re-fetch.
18084
+ */
18085
+ var TrackFlagsSchema = object({
18086
+ trackId: string(),
18087
+ markForTrain: boolean(),
18088
+ debug: boolean(),
18089
+ favourited: boolean(),
18090
+ /** The lifecycle state the boolean was derived from. Required here (unlike on
18091
+ * a track row) because this shape is only ever produced by the write body,
18092
+ * which always knows it — and a surface that has just written needs to render
18093
+ * `trained` without a re-fetch. */
18094
+ retrainStatus: RetrainStatusSchema
18095
+ });
18096
+ union([literal(1), literal(2)]);
18097
+ /**
18098
+ * WHO decided a label, and when. Carried per tier so a value can be traced to
18099
+ * the step and model that produced it — which is what makes the write rule
18100
+ * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
18101
+ * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
18102
+ *
18103
+ * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
18104
+ * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
18105
+ * `migration:4g` for a value the 4g migration moved from the single-slot era —
18106
+ * that value has no provenance, and the write rule lets ANY properly-attributed
18107
+ * write of the same tier replace it regardless of score.
18108
+ */
18109
+ var LabelAttributionSchema = object({
18110
+ stepId: string(),
18111
+ modelId: string().optional(),
18112
+ decidedAt: number(),
18211
18113
  /**
18212
- * The pass stopped because NO node could serve the pinned model.
18114
+ * The GALLERY id behind a recognised tier-2 label — a face-gallery
18115
+ * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
18213
18116
  *
18214
- * Distinct from `notRunnable` on purpose: that one says "this track was
18215
- * refused", this one says "the cluster cannot do this work at all" — every
18216
- * candidate node either lacks the `clip-embedding` step, lacks a build of the
18217
- * pinned model for its engine format, or dropped out. The remedy is a model /
18218
- * engine change, not a per-camera one. Non-zero here always comes with
18219
- * `complete: false`.
18117
+ * The text alone is a DISPLAY NAME, and a display name is renameable: a
18118
+ * notification rule authored on "Gianluca" stopped matching the moment the
18119
+ * operator fixed the spelling in the gallery, and nothing said so. The id is
18120
+ * the thing that does not move, so it is what a rule matches on
18121
+ * (`NcConditions.identities`) and the text is what a human is shown.
18122
+ *
18123
+ * Absent when the label names no gallery row — a plate the OCR read but no
18124
+ * vehicle claims, a sub-class, a species, any tier-1 value.
18220
18125
  */
18221
- noCapableNode: number(),
18222
- failed: number(),
18223
- /** Set once a pass ends: true only when EVERYTHING was covered. */
18224
- complete: boolean().nullable(),
18225
- startedAtMs: number().nullable(),
18226
- finishedAtMs: number().nullable(),
18227
- /** Present when the pass ended by throwing. */
18228
- error: string().nullable()
18126
+ identityId: string().optional()
18229
18127
  });
18230
- DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
18231
- deviceId: number(),
18232
- trackId: string()
18233
- }), TrackSchema.nullable()), method(object({
18234
- deviceId: number(),
18235
- since: number().optional(),
18236
- until: number().optional(),
18237
- limit: number().optional(),
18238
- /** Spatial filter — only tracks whose trajectory intersects the zone
18239
- * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
18240
- * envelope columns, then precisely tested per position. Tracks with
18241
- * an unknown envelope (no frame dims at persist time) always match. */
18242
- zone: TrackZoneFilterSchema.optional(),
18243
- /** See {@link TrackProjectionSchema}. Default `full` (backward
18244
- * compatible — omitting the field keeps today's exact behaviour). */
18245
- projection: TrackProjectionSchema.optional(),
18246
- /** Include stationary-promoted rows (parked objects handed to the
18247
- * stationary registry). Default false: the timeline lists passages,
18248
- * not parking records (operator decision, 2026-08-15). */
18249
- includeStationary: boolean().optional()
18250
- }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
18251
- deviceId: number(),
18252
- groupId: string().min(1)
18253
- }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
18254
- kind: "mutation",
18255
- auth: "admin"
18256
- }), method(DeviceEventQueryInput, array(MotionEventSchema).readonly()), method(ObjectEventQueryInput, array(ObjectEventSchema).readonly()), method(DeviceEventQueryInput, array(AudioEventSchema).readonly()), method(object({ deviceId: number() }), array(EventKindDescriptorSchema).readonly()), method(object({ deviceIds: array(number()).min(1).max(200) }), array(EventKindsForDeviceSchema).readonly()), method(object({
18257
- deviceId: number(),
18258
- since: number().optional(),
18259
- until: number().optional(),
18260
- kinds: array(string()).optional(),
18261
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
18262
- }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
18263
- deviceId: number(),
18264
- since: number(),
18265
- until: number(),
18266
- bucketMs: number().int().positive()
18267
- }), array(object({
18268
- bucketStart: number(),
18269
- motion: number().int(),
18270
- object: number().int(),
18271
- audio: number().int()
18272
- })).readonly()), method(object({
18273
- deviceId: number(),
18274
- cutoffMs: number()
18275
- }), object({
18276
- motion: number().int(),
18277
- object: number().int(),
18278
- audio: number().int()
18279
- }), {
18280
- kind: "mutation",
18281
- auth: "admin"
18282
- }), method(object({
18283
- deviceId: number(),
18284
- cutoffMs: number()
18285
- }), TrackCascadeCountsSchema, {
18286
- kind: "mutation",
18287
- auth: "admin"
18288
- }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
18289
- kind: "mutation",
18290
- auth: "admin"
18291
- }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
18292
- kind: "mutation",
18293
- auth: "admin"
18294
- }), method(object({
18295
- deviceId: number(),
18296
- trackIds: array(string()).min(1)
18297
- }), object({
18298
- deleted: number().int(),
18299
- failed: array(string()).readonly()
18300
- }), {
18301
- kind: "mutation",
18302
- auth: "admin"
18303
- }), method(object({
18304
- /** Log/audit scope only — the trackId is globally unique on its own. */
18128
+ /**
18129
+ * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
18130
+ * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
18131
+ * track and its events always answer the same question the same way.
18132
+ *
18133
+ * Two scalar columns, not an array: every consumer wants "the coarse one" or
18134
+ * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
18135
+ * is tier 2, and each carries its own score + attribution.
18136
+ *
18137
+ * **Reading it.** What a human should be shown is `subLabel ?? label` — the
18138
+ * finest thing known. Before 4g the single `label` column held the finest
18139
+ * value, so a consumer that has not been updated reads the tier-1 slot and
18140
+ * shows nothing on a species-only row; that is why the migration puts every
18141
+ * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
18142
+ * and why the read surfaces were changed in the same train.
18143
+ *
18144
+ * **Writing it.** The slots are independent, which is the whole point: a
18145
+ * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
18146
+ * migratorius`), so fineness cannot regress by construction. Within a tier the
18147
+ * higher score wins. One rule, one implementation — see
18148
+ * `pipeline/label-tier.ts` in addon-post-analysis.
18149
+ */
18150
+ var TieredLabelFields = {
18151
+ /** Tier 1 — the sub-class. See {@link LabelTierSchema}. */
18152
+ label: string().optional(),
18153
+ /** Confidence of the tier-1 value, as reported by the deciding step. */
18154
+ labelScore: number().optional(),
18155
+ /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
18156
+ labelMeta: LabelAttributionSchema.optional(),
18157
+ /** Tier 2 — the instance. See {@link LabelTierSchema}. */
18158
+ subLabel: string().optional(),
18159
+ /** Confidence of the tier-2 value, as reported by the deciding step. */
18160
+ subLabelScore: number().optional(),
18161
+ /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
18162
+ subLabelMeta: LabelAttributionSchema.optional()
18163
+ };
18164
+ /** Per-camera slice of a training-export estimate. */
18165
+ var TrainingExportDeviceTotalsSchema = object({
18305
18166
  deviceId: number(),
18167
+ tracks: number().int(),
18168
+ files: number().int(),
18169
+ bytes: number().int()
18170
+ });
18171
+ /**
18172
+ * What a training export WOULD contain. Computed from media index rows only —
18173
+ * no blob is read to produce this.
18174
+ */
18175
+ var TrainingExportSummarySchema = object({
18176
+ generatedAt: number(),
18177
+ trackCount: number().int(),
18178
+ fileCount: number().int(),
18179
+ byteCount: number().int(),
18180
+ /** More marked tracks exist than a single pass carries. */
18181
+ truncated: boolean(),
18182
+ devices: array(TrainingExportDeviceTotalsSchema).readonly()
18183
+ });
18184
+ var TrackSchema = object({
18306
18185
  trackId: string(),
18307
- flags: TrackFlagsPatchSchema
18308
- }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
18309
- kind: "query",
18310
- auth: "admin"
18311
- }), method(object({
18312
- olderThanMs: number(),
18313
- reason: OpsLogReasonSchema.optional()
18314
- }), EventPruneCountsSchema, {
18315
- kind: "mutation",
18316
- auth: "admin"
18317
- }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
18318
- kind: "mutation",
18319
- auth: "admin"
18320
- }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
18321
- kind: "mutation",
18322
- auth: "admin"
18323
- }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
18324
- kind: "mutation",
18325
- auth: "admin"
18326
- }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
18327
- kind: "mutation",
18328
- auth: "admin"
18329
- }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
18330
- kind: "mutation",
18331
- auth: "admin"
18332
- }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18333
- kind: "mutation",
18334
- auth: "admin"
18335
- }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
18336
- kind: "query",
18337
- auth: "admin"
18338
- }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
18339
- kind: "query",
18340
- auth: "admin"
18341
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18342
- kind: "query",
18343
- auth: "admin"
18344
- }), method(object({
18345
- /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
18346
- * `deviceId`, deliberately: `deviceId` would make this device-bound and
18347
- * route it at one camera's owner, and "every camera" would stop being
18348
- * expressible at all. */
18349
- deviceIds: array(number()).optional(),
18350
- limit: number().int().min(1).max(500).optional()
18351
- }), array(RetrainTrackSchema).readonly(), {
18352
- kind: "query",
18353
- auth: "admin"
18354
- }), method(object({ trackId: string() }), RetrainFrameListSchema, {
18355
- kind: "query",
18356
- auth: "admin"
18357
- }), method(object({
18358
18186
  deviceId: number(),
18359
- trackId: string(),
18360
- mediaKeys: array(string()).min(1)
18361
- }), RetrainFrameSelectionSchema, {
18362
- kind: "mutation",
18363
- auth: "admin"
18364
- }), method(object({
18187
+ className: string(),
18188
+ ...TieredLabelFields,
18189
+ producingDeviceName: string().optional(),
18190
+ /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
18191
+ source: TrackSourceSchema.optional(),
18192
+ firstSeen: number(),
18193
+ lastSeen: number(),
18194
+ /** Frame-rate position history (subject to maxPositionHistory cap). */
18195
+ positions: array(TrackPositionSchema).readonly(),
18196
+ /** Periodic snapshots at snapshotIntervalMs cadence (subject to
18197
+ * saveThumbnails policy). */
18198
+ snapshots: array(TrackSnapshotSchema).readonly(),
18199
+ /** Deduplicated zones the track has entered at least once. Zone IDS. */
18200
+ zonesVisited: array(string()).readonly(),
18201
+ /**
18202
+ * Human NAMES for {@link zonesVisited}, resolved at READ time against the
18203
+ * `zones` capability.
18204
+ *
18205
+ * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
18206
+ * and no card can render — so every free-text search surface was structurally
18207
+ * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
18208
+ * just returned nothing. Resolving here rather than in each client keeps ONE
18209
+ * derivation and costs the clients no extra call (the `zones` cap is
18210
+ * per-device, so a client-side resolve would be a per-camera fan-out on a
18211
+ * surface built to avoid exactly that).
18212
+ *
18213
+ * Resolved, never invented: a zone deleted since the track was written has no
18214
+ * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
18215
+ * two are not positionally aligned. Absent when the track visited no zone, or
18216
+ * when the zone catalogue could not be read.
18217
+ */
18218
+ zoneNames: array(string()).readonly().optional(),
18219
+ /** Deduplicated set of detector classes observed for this track over its
18220
+ * life (a track may be reclassified, e.g. person→vehicle). Absent on
18221
+ * legacy rows written before class accumulation shipped. */
18222
+ classes: array(string()).readonly().optional(),
18223
+ /** Cumulative normalized distance travelled (0..1 units = full frame width). */
18224
+ totalDistance: number(),
18225
+ state: TrackStateSchema,
18226
+ active: boolean(),
18227
+ /** Deterministic key-event importance score in [0,1] (server-computed at
18228
+ * track expiry, recomputed on late label). Absent on legacy rows written
18229
+ * before scoring shipped — consumers degrade to absence / compute-on-read. */
18230
+ importance: number().optional(),
18231
+ /** Id of the track's highest-confidence ObjectEvent (its representative
18232
+ * "best" frame). Absent when the track produced no object events. */
18233
+ bestEventId: string().optional(),
18234
+ /** Tag of the importance sub-signal that dominated the score
18235
+ * (identity|dwell|proximity|class|confidence|travel|zone). */
18236
+ importanceReason: string().optional(),
18237
+ /** Audio-classification labels heard on the camera during the track's
18238
+ * life (score ≥ device `classificationMinScore`), aggregated per label.
18239
+ * Absent on legacy rows / tracks with no confident audio. */
18240
+ audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
18241
+ /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
18242
+ * Populated from the persisted envelope columns on historical reads;
18243
+ * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
18244
+ envelope: TrackEnvelopeSchema.optional(),
18245
+ /**
18246
+ * A face DETECTOR found a face on this track — nothing more. It says the
18247
+ * detail plane produced a `face` detail; it does NOT say the face was
18248
+ * embedded, matched, above `minFacePx`, or that the recognizer was even
18249
+ * enabled. Set once and never cleared.
18250
+ *
18251
+ * **This exists so "face present but not recognised" is expressible.** A
18252
+ * recognised identity lands in `subLabel` (attributed to the face chain via
18253
+ * `subLabelMeta.stepId`), so before this field a track with an unmatched face
18254
+ * and a track with no face at all were byte-identical on the wire and no
18255
+ * surface could tell them apart. The read is `hasFace === true && subLabel
18256
+ * === undefined`.
18257
+ *
18258
+ * **Absent ≠ false.** Every row written before the column existed omits it,
18259
+ * and so does every server that predates the field — a consumer must test
18260
+ * `=== true` and render nothing otherwise, never infer "no face".
18261
+ */
18262
+ hasFace: boolean().optional(),
18263
+ /**
18264
+ * This track has a face row IN THE GALLERY: a crop **and** an embedding — a
18265
+ * face an operator could ASSIGN to an identity.
18266
+ *
18267
+ * The STRICT twin of {@link hasFace}, and the pair only earns its keep
18268
+ * because the two disagree. `hasFace` is stamped at the TOP of the face
18269
+ * branch, before every gate, and means no more than "a face detector produced
18270
+ * a face detail". This one is stamped at the single moment the gallery row
18271
+ * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
18272
+ * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
18273
+ * candidate gate, the imageless-track drop (no crop was ever captured) and
18274
+ * the crop-store drop. Everything between the detector and that insert can
18275
+ * legitimately refuse the face, so a flag written any earlier promises the
18276
+ * operator something to assign and delivers nothing.
18277
+ *
18278
+ * **Independent of recognition.** A face collected but never auto-matched is
18279
+ * still assignable — it is in fact the face an operator most wants to reach —
18280
+ * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
18281
+ * `subLabel`; this says only that the raw material exists.
18282
+ *
18283
+ * **Set once, never cleared.** A track that produced a gallery row produced
18284
+ * one; deleting the row later is the gallery's business, not this flag's.
18285
+ *
18286
+ * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
18287
+ * before the column omits it, and so does every server that predates the
18288
+ * field. A consumer must test `=== true` and render nothing otherwise —
18289
+ * never infer "no assignable face".
18290
+ */
18291
+ hasEmbeddedFace: boolean().optional(),
18292
+ /**
18293
+ * This subject CONTAINS a folded rider — a person the rider-pairing step
18294
+ * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
18295
+ * so the passage is tracked once and as a VEHICLE.
18296
+ *
18297
+ * It exists because the fold's record was dishonest. D34 and the code both
18298
+ * said "the person is not lost — it is reported so both entities stay on the
18299
+ * record"; in fact the pair went into a per-processor RAM field behind an
18300
+ * accessor nobody called, and every durable surface said `vehicle`, full
18301
+ * stop. This is the composition note that makes the row true.
18302
+ *
18303
+ * A COMPOSITION, never a class and never a label. "This vehicle contains a
18304
+ * person" is not an answer to "what is this" — both label tiers would refuse
18305
+ * a macro token anyway (D89), and correctly. Nothing here changes what the
18306
+ * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
18307
+ * and a `person` rule still does not fire for someone cycling past.
18308
+ *
18309
+ * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
18310
+ * the column, and every hub that predates the field, omits it. Test
18311
+ * `=== true` and render nothing otherwise — never infer "no rider".
18312
+ */
18313
+ hasRider: boolean().optional(),
18314
+ ...TrackFlagFields,
18315
+ ...TrackRetrainFields
18316
+ });
18317
+ var BaseEventFields = {
18318
+ id: string(),
18365
18319
  deviceId: number(),
18366
- trackId: string(),
18367
- frameId: string()
18368
- }), object({
18369
- removed: boolean(),
18370
- removedAnnotations: number().int()
18371
- }), {
18372
- kind: "mutation",
18373
- auth: "admin"
18374
- }), method(object({ frameId: string() }), object({
18320
+ timestamp: number()
18321
+ };
18322
+ var MotionEventSchema = object({
18323
+ ...BaseEventFields,
18324
+ kind: literal("motion"),
18325
+ regionCount: number(),
18326
+ /** Heavy JSON array — omitted in slim projection. */
18327
+ regions: array(object({
18328
+ bbox: BoundingBoxSchema,
18329
+ pixelCount: number(),
18330
+ intensity: number()
18331
+ })).readonly().optional(),
18332
+ /** Omitted in slim projection. */
18333
+ frameWidth: number().optional(),
18334
+ /** Omitted in slim projection. */
18335
+ frameHeight: number().optional(),
18336
+ /** Populated by B5 (recording playback URL for this event). */
18337
+ mediaUrl: string().optional()
18338
+ });
18339
+ /**
18340
+ * Which detection SOURCE produced an object event. `pipeline` = the ML
18341
+ * detection pipeline (decoded-frame inference); `onboard` = the camera's
18342
+ * native on-device AI. Both flow through the SAME analysis layers (zoning,
18343
+ * tracking, per-kind persistence) but stay distinguishable so consumers
18344
+ * (advanced-notifier, occupancy, …) can select which source(s) to act on.
18345
+ * Absent on legacy rows ⇒ treat as `pipeline`.
18346
+ */
18347
+ var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
18348
+ /**
18349
+ * The confirmed zone crossing that produced an object event. Present ONLY on
18350
+ * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
18351
+ * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
18352
+ * appearance event carry none, so a rule asking for a direction fails closed
18353
+ * on them.
18354
+ *
18355
+ * Exactly ONE crossing per event: the emitter turns each confirmed crossing
18356
+ * into its own event, so a frame in which a track enters A while leaving B
18357
+ * produces two events with two directions — never one ambiguous row.
18358
+ *
18359
+ * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
18360
+ * membership the box has NOW, and by definition it no longer contains the zone
18361
+ * that was just left. Without the id here, a zone-scoped rule could never match
18362
+ * the exit it asked for.
18363
+ */
18364
+ var ZoneCrossingSchema = object({
18365
+ direction: _enum(["enter", "exit"]),
18366
+ /** Admin zone id crossed. */
18367
+ zoneId: string(),
18368
+ /** Zone display name at crossing time (falls back to the id). */
18369
+ zoneName: string().optional()
18370
+ });
18371
+ var ObjectEventSchema = object({
18372
+ ...BaseEventFields,
18373
+ kind: literal("object"),
18374
+ /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
18375
+ source: DetectionSourceSchema.optional(),
18376
+ /**
18377
+ * Inference-frame id shared by every object event emitted from the SAME frame
18378
+ * — the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
18379
+ * 2 people + 1 dog) under one full frame, and link a track's frames over time
18380
+ * (group by `trackId`, pick a representative `frameId` as the parent frame).
18381
+ * Optional for backward-compat with pre-existing rows / the slim projection
18382
+ * includes it (it is light). Absent on rows written before this field.
18383
+ */
18384
+ frameId: string().optional(),
18385
+ /** Omitted in slim projection. */
18386
+ trackId: string().optional(),
18387
+ className: string(),
18388
+ ...TieredLabelFields,
18389
+ /** Omitted in slim projection. */
18390
+ confidence: number().optional(),
18391
+ /** Heavy JSON — omitted in slim projection. */
18392
+ bbox: BoundingBoxSchema.optional(),
18393
+ /** Heavy JSON — omitted in slim projection. */
18394
+ zones: array(string()).readonly().optional(),
18395
+ /** Omitted in slim projection. */
18396
+ state: TrackStateSchema.optional(),
18397
+ /**
18398
+ * The zone crossing this event IS, when it is one. Absent on every other
18399
+ * event kind (movement state, appearance, package) — see
18400
+ * {@link ZoneCrossingSchema}. Omitted in slim projection.
18401
+ */
18402
+ zoneCrossing: ZoneCrossingSchema.optional(),
18403
+ /** Detection-frame dimensions in pixels — let consumers normalize the
18404
+ * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
18405
+ frameWidth: number().optional(),
18406
+ frameHeight: number().optional(),
18407
+ /** MediaStore key for the crop attached to this event (if any). */
18408
+ mediaKey: string().optional(),
18409
+ /** Design B: MediaStore key of the track's native-resolution key frame (the
18410
+ * best-detection full frame). Resolve via the event-media data-plane
18411
+ * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
18412
+ * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
18413
+ * sources — consumers fall back to `mediaKey` (the tight crop). */
18414
+ keyFrameMediaKey: string().optional(),
18415
+ /** Populated by B5 (recording playback URL for this event). */
18416
+ mediaUrl: string().optional(),
18417
+ /** The parent track's key-event importance [0,1], propagated to every object
18418
+ * event of the track (so an event row can be sorted by importance without a
18419
+ * track join). Absent on legacy rows / before the track was scored. */
18420
+ importance: number().optional()
18421
+ });
18422
+ var AudioEventSchema = object({
18423
+ ...BaseEventFields,
18424
+ kind: literal("audio"),
18425
+ rms: number(),
18426
+ dbfs: number(),
18427
+ classification: object({
18428
+ className: string(),
18429
+ originalClass: string().optional(),
18430
+ score: number()
18431
+ }).optional(),
18432
+ /** Populated by B5 (recording playback URL for this event). */
18433
+ mediaUrl: string().optional()
18434
+ });
18435
+ var MediaFileKindEnum = _enum([
18436
+ "crop",
18437
+ "thumbnail",
18438
+ "snapshot",
18439
+ "firstFrame",
18440
+ "lastFrame",
18441
+ "fullFrame",
18442
+ "fullFrameBoxed",
18443
+ "faceCrop",
18444
+ "plateCrop",
18445
+ "keyFrame",
18446
+ "keyFrameSmall",
18447
+ "thumbnailSmall"
18448
+ ]);
18449
+ var MediaFileSchema = object({
18450
+ key: string(),
18451
+ kind: MediaFileKindEnum,
18375
18452
  base64: string(),
18376
- width: number().int(),
18377
- height: number().int()
18378
- }), {
18379
- kind: "query",
18380
- auth: "admin"
18381
- }), method(object({
18382
- deviceId: number(),
18383
- trackId: string(),
18384
- frameId: string(),
18385
- subject: RetrainAssistSubjectSchema,
18386
- /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
18387
- nodeId: string().optional()
18388
- }), RetrainAssistResultSchema, {
18389
- kind: "mutation",
18390
- auth: "admin"
18391
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
18392
- kind: "query",
18393
- auth: "admin"
18394
- }), method(object({
18395
- deviceId: number(),
18453
+ sizeBytes: number(),
18454
+ timestamp: number()
18455
+ });
18456
+ /**
18457
+ * One media row WITHOUT its bytes.
18458
+ *
18459
+ * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
18460
+ * 140 s track), and a client that renders tiles from the media data plane needs
18461
+ * to know only WHAT EXISTS — the bytes then arrive per tile, lazily, over HTTP
18462
+ * with an immutable cache, instead of all at once inside a tRPC response that
18463
+ * blocks the whole view.
18464
+ *
18465
+ * `sizeBytes` is carried because it is what lets a client decide between the
18466
+ * stored blob and a `?variant=thumb` rendering without fetching either.
18467
+ */
18468
+ var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
18469
+ /**
18470
+ * The MACRO tier of an annotation — a CLOSED set.
18471
+ *
18472
+ * This is what the exported detector predicts, so a typo here is a new class
18473
+ * with one example in it. `label` and `subLabel` are open strings by contrast:
18474
+ * the whole point of the page is teaching the model things it does not know
18475
+ * yet, and constraining that vocabulary would make it useless.
18476
+ *
18477
+ * A macro class is NEVER a label. The provider refuses a write whose `label` or
18478
+ * `subLabel` is one of these values, in any casing, because once `person`
18479
+ * exists in both tiers "every person box" stops being answerable without
18480
+ * knowing every string anyone ever typed — and the damage is retroactive.
18481
+ */
18482
+ var RetrainMacroClassSchema = _enum([
18483
+ "person",
18484
+ "vehicle",
18485
+ "animal",
18486
+ "package",
18487
+ "face",
18488
+ "plate"
18489
+ ]);
18490
+ /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
18491
+ var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
18492
+ /** Did a human draw this box, or did the assist propose it? */
18493
+ var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
18494
+ /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
18495
+ var RetrainBboxSchema = object({
18496
+ x: number(),
18497
+ y: number(),
18498
+ w: number(),
18499
+ h: number()
18500
+ });
18501
+ /**
18502
+ * One annotated subject.
18503
+ *
18504
+ * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
18505
+ * (letterboxed root / zone-cropped package / subject-cropped classifier) are
18506
+ * derived from it at export and never stored — storing them is how one feature
18507
+ * space ends up holding two crops of the same subject (D52).
18508
+ */
18509
+ var RetrainAnnotationSchema = object({
18510
+ id: string(),
18396
18511
  trackId: string(),
18397
- frameId: string(),
18398
- annotations: array(RetrainAnnotationDraftSchema)
18399
- }), array(RetrainAnnotationSchema).readonly(), {
18400
- kind: "mutation",
18401
- auth: "admin"
18402
- }), method(object({
18403
- deviceId: number(),
18404
- trackId: string()
18405
- }), RetrainTransitionResultSchema, {
18406
- kind: "mutation",
18407
- auth: "admin"
18408
- }), method(object({
18409
18512
  deviceId: number(),
18410
- trackId: string()
18411
- }), RetrainTransitionResultSchema, {
18412
- kind: "mutation",
18413
- auth: "admin"
18414
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18415
- kind: "query",
18416
- auth: "admin"
18417
- }), method(object({
18418
- eventId: string(),
18419
- kind: MediaFileKindEnum.optional(),
18420
- deviceId: number()
18421
- }), array(MediaFileSchema).readonly()), method(object({
18422
- trackId: string(),
18423
- kinds: array(MediaFileKindEnum).optional(),
18424
- deviceId: number()
18425
- }), array(MediaFileSchema).readonly()), method(object({
18513
+ /** The COPY in retrain storage — never the source track's media key. */
18514
+ mediaKey: string(),
18515
+ bbox: RetrainBboxSchema,
18516
+ macroClass: RetrainMacroClassSchema,
18517
+ label: string().optional(),
18518
+ subLabel: string().optional(),
18519
+ kind: RetrainAnnotationKindSchema,
18520
+ source: RetrainAnnotationSourceSchema,
18521
+ /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
18522
+ assistModelId: string().optional(),
18523
+ assistScore: number().optional(),
18524
+ exportedInBatch: string().optional(),
18525
+ createdAt: number()
18526
+ });
18527
+ /** The write form — the server owns `id`, `createdAt` and the frame binding. */
18528
+ var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
18529
+ id: true,
18530
+ trackId: true,
18531
+ deviceId: true,
18532
+ mediaKey: true,
18533
+ createdAt: true,
18534
+ exportedInBatch: true
18535
+ });
18536
+ /** A track sitting in `staging`, with everything the worklist needs to rank it. */
18537
+ var RetrainTrackSchema = object({
18426
18538
  trackId: string(),
18427
- deviceId: number()
18428
- }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
18429
- kind: "mutation",
18430
- auth: "admin"
18431
- }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
18432
- kind: "mutation",
18433
- auth: "admin"
18434
- }), method(object({}), RebuildStatusSchema), object({
18435
18539
  deviceId: number(),
18540
+ className: string(),
18541
+ label: string().optional(),
18542
+ firstSeen: number(),
18543
+ lastSeen: number(),
18544
+ /** How many frames the dataset already holds from this track. */
18545
+ frameCount: number().int(),
18546
+ /** How many subjects have been annotated on those frames. `0` with
18547
+ * `frameCount: 0` is exactly "staging, still to work". */
18548
+ annotationCount: number().int()
18549
+ });
18550
+ /** A frame the picker may offer — an index row, no blob was read to produce it. */
18551
+ var RetrainFrameCandidateSchema = object({
18552
+ mediaKey: string(),
18553
+ kind: MediaFileKindEnum,
18436
18554
  timestamp: number(),
18437
- frameWidth: number(),
18438
- frameHeight: number(),
18439
- detections: array(OverlayDetectionSchema).readonly()
18440
- }), object({
18555
+ sizeBytes: number().int(),
18556
+ /** A copy of this original already exists — selecting it is free and cannot
18557
+ * fail, whatever became of the original. */
18558
+ copied: boolean()
18559
+ });
18560
+ /** A frame the dataset OWNS: bytes copied at selection time. */
18561
+ var RetrainFrameSchema = object({
18562
+ frameId: string(),
18441
18563
  deviceId: number(),
18442
18564
  trackId: string(),
18443
- className: string()
18565
+ /** Provenance only. It may already point at nothing — that is expected. */
18566
+ sourceMediaKey: string(),
18567
+ sourceKind: MediaFileKindEnum,
18568
+ sizeBytes: number().int(),
18569
+ width: number().int(),
18570
+ height: number().int(),
18571
+ copiedAt: number()
18572
+ });
18573
+ /** Why a copy-on-select could not be honoured — named, never a silent skip. */
18574
+ var RetrainCopyRefusalSchema = _enum([
18575
+ "source-missing",
18576
+ "unreadable-image",
18577
+ "write-failed"
18578
+ ]);
18579
+ var RetrainFrameSelectionSchema = object({
18580
+ copied: array(RetrainFrameSchema).readonly(),
18581
+ refused: array(object({
18582
+ sourceMediaKey: string(),
18583
+ reason: RetrainCopyRefusalSchema
18584
+ })).readonly()
18585
+ });
18586
+ var RetrainFrameListSchema = object({
18587
+ candidates: array(RetrainFrameCandidateSchema).readonly(),
18588
+ copies: array(RetrainFrameSchema).readonly(),
18589
+ /** What the page pre-selects — the native key frame when one survives. */
18590
+ autoPickMediaKey: string().optional()
18591
+ });
18592
+ /** What the operator asked the assist to look for. */
18593
+ var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
18594
+ kind: literal("package"),
18595
+ zone: RetrainBboxSchema.optional()
18444
18596
  }), object({
18445
- deviceId: number(),
18446
- trackId: string(),
18447
- className: string(),
18448
- durationMs: number()
18597
+ kind: literal("objects"),
18598
+ modelId: string(),
18599
+ minScore: number().optional()
18600
+ })]);
18601
+ /**
18602
+ * The assist's answer — a discriminated union, because "the model saw nothing"
18603
+ * and "this node cannot run that model" lead to different next moves and a
18604
+ * nullable result cannot tell them apart.
18605
+ */
18606
+ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
18607
+ kind: literal("proposed"),
18608
+ modelId: string(),
18609
+ stepId: string(),
18610
+ minScore: number(),
18611
+ /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
18612
+ proposals: array(RetrainAnnotationDraftSchema).readonly(),
18613
+ /** Returned by the runner but removed by the threshold. */
18614
+ belowThreshold: number().int()
18449
18615
  }), object({
18616
+ kind: literal("refused"),
18617
+ /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
18618
+ reason: string(),
18619
+ detail: string().optional()
18620
+ })]);
18621
+ /** The outcome of a lifecycle move owned by the retrain page. */
18622
+ var RetrainTransitionResultSchema = object({
18623
+ trackId: string(),
18624
+ /** Where the track ended up, whatever happened. */
18625
+ retrainStatus: RetrainStatusSchema,
18626
+ /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
18627
+ changed: boolean(),
18628
+ reason: _enum([
18629
+ "unknown-track",
18630
+ "no-frames-copied",
18631
+ "not-staging",
18632
+ "not-trained",
18633
+ "unchanged"
18634
+ ]).optional()
18635
+ });
18636
+ var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
18637
+ var MAX_EVENT_QUERY_LIMIT = 5e3;
18638
+ var DeviceEventQueryInput = object({
18450
18639
  deviceId: number(),
18451
- kind: EventKindSchema,
18452
- eventId: string(),
18453
- timestamp: number()
18640
+ since: number().optional(),
18641
+ until: number().optional(),
18642
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
18643
+ /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
18644
+ * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
18645
+ * exact behaviour. Callers may omit this field — the store defaults to
18646
+ * `full` when not provided. */
18647
+ projection: _enum(["full", "slim"]).optional()
18454
18648
  });
18455
- /**
18456
- * Reference to the frame's retained NATIVE surface + the parent crop's placement
18457
- * within the frame, so the executor can re-cut a leaf child ROI at native
18458
- * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
18459
- */
18460
- var NativeCropRefSchema = object({
18461
- /** Handle keying the retained native surface (node-pinned to its owner). */
18462
- handle: FrameHandleSchema,
18463
- /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
18464
- cropFrameSpace: object({
18465
- x: number(),
18466
- y: number(),
18467
- w: number(),
18468
- h: number()
18469
- })
18649
+ var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
18650
+ var RecentTracksQueryInput = object({
18651
+ /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
18652
+ deviceIds: array(number()),
18653
+ /** Window lower bound on `lastSeen` (inclusive). */
18654
+ since: number().optional(),
18655
+ /** Window upper bound on `lastSeen` (inclusive). */
18656
+ until: number().optional(),
18657
+ /** Page size. Default 200, max 1000. */
18658
+ limit: number().int().min(1).max(1e3).default(200),
18659
+ /** Opaque continuation cursor from a previous page's `nextCursor`.
18660
+ * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
18661
+ cursor: string().optional(),
18662
+ /** See {@link TrackProjectionSchema}. Default `full`. */
18663
+ projection: TrackProjectionSchema.optional(),
18664
+ /** Include stationary-promoted rows (parked objects). Default false: the
18665
+ * feed lists passages; parking records live on the stationary registry. */
18666
+ includeStationary: boolean().optional()
18470
18667
  });
18471
- object({
18472
- crop: object({
18473
- left: number(),
18474
- top: number(),
18475
- width: number().positive(),
18476
- height: number().positive()
18477
- }).optional(),
18478
- content: object({
18479
- width: number().int().positive(),
18480
- height: number().int().positive()
18481
- }),
18482
- fit: _enum(["stretch", "contain"]),
18483
- format: _enum([
18484
- "rgb",
18485
- "gray",
18486
- "jpeg"
18487
- ])
18668
+ var RecentTracksPageSchema = object({
18669
+ /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
18670
+ tracks: array(TrackSchema).readonly(),
18671
+ /** Cursor for the next page, or null when this page is the last. */
18672
+ nextCursor: string().nullable()
18488
18673
  });
18489
- var FrameRefSchema = object({
18490
- registryId: string().min(1),
18491
- id: string().min(1),
18492
- width: number().int().positive(),
18493
- height: number().int().positive(),
18494
- format: _enum(["rgb", "gray"]),
18495
- timestamp: number(),
18496
- capturedAt: number().optional()
18674
+ var LIST_GROUPS_DEFAULT_LIMIT = 40;
18675
+ var LIST_GROUPS_MAX_LIMIT = 100;
18676
+ var AnalyticsGroupRecordSchema = object({
18677
+ id: string(),
18678
+ deviceId: number().int(),
18679
+ openedAt: number().int(),
18680
+ closedAt: number().int(),
18681
+ timestamp: number().int(),
18682
+ memberCount: number().int(),
18683
+ memberTrackIds: array(string()).readonly(),
18684
+ className: string(),
18685
+ classes: array(string()).readonly(),
18686
+ /** Relative event-media path, or null when the group has no picture yet. */
18687
+ mediaUrl: string().nullable(),
18688
+ singleton: boolean()
18497
18689
  });
18498
- var ModelFormatSchema$1 = _enum([
18499
- "onnx",
18500
- "coreml",
18501
- "openvino",
18502
- "tflite",
18503
- "pt",
18504
- "gguf"
18505
- ]);
18506
- var PipelineSlotSchema = _enum([
18507
- "detector",
18508
- "cropper",
18509
- "classifier",
18510
- "refiner",
18511
- "audio-classifier"
18512
- ]);
18513
- var PipelineEngineChoiceSchema = object({
18514
- runtime: _enum(["node", "python"]),
18515
- backend: string(),
18516
- format: ModelFormatSchema$1,
18517
- device: string().optional()
18690
+ var AnalyticsGroupMemberSchema = object({
18691
+ trackId: string(),
18692
+ deviceId: number().int(),
18693
+ className: string(),
18694
+ firstSeen: number().int(),
18695
+ lastSeen: number().int(),
18696
+ mediaUrl: string().nullable()
18518
18697
  });
18519
- var AvailableEngineSchema = object({
18520
- engine: PipelineEngineChoiceSchema,
18521
- devices: array(object({
18522
- id: string(),
18523
- label: string(),
18524
- description: string().optional()
18525
- })).readonly(),
18526
- defaultDevice: string()
18698
+ var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
18699
+ var ListGroupsQueryInput = object({
18700
+ /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
18701
+ deviceIds: array(number()),
18702
+ /** Window lower bound on `closedAt` (inclusive). */
18703
+ since: number().optional(),
18704
+ /** Window upper bound on `openedAt` (inclusive). */
18705
+ until: number().optional(),
18706
+ limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
18707
+ /** Opaque continuation cursor from a previous page's `nextCursor`. */
18708
+ cursor: string().optional()
18527
18709
  });
18528
- var PipelineDefaultStepSchema = lazy(() => object({
18529
- addonId: string(),
18530
- addonName: string(),
18531
- slot: PipelineSlotSchema,
18532
- inputClasses: array(string()).readonly(),
18533
- outputClasses: array(string()).readonly(),
18534
- enabled: boolean(),
18535
- modelId: string(),
18536
- children: array(PipelineDefaultStepSchema).readonly(),
18537
- group: string().optional(),
18538
- settings: record(string(), unknown()).optional()
18539
- }));
18540
- var PipelineTemplateStepSchema = lazy(() => object({
18541
- addonId: string(),
18542
- enabled: boolean(),
18543
- modelId: string(),
18544
- children: array(PipelineTemplateStepSchema).readonly(),
18545
- settings: record(string(), unknown()).optional()
18546
- }));
18547
- var PipelineTemplateSchema$1 = object({
18548
- id: string(),
18549
- name: string(),
18550
- createdAt: string(),
18551
- updatedAt: string(),
18552
- engine: PipelineEngineChoiceSchema,
18553
- steps: array(PipelineTemplateStepSchema).readonly()
18710
+ var ListGroupsPageSchema = object({
18711
+ groups: array(AnalyticsGroupRecordSchema).readonly(),
18712
+ nextCursor: string().nullable()
18713
+ });
18714
+ var KeyEventQueryInput = object({
18715
+ deviceId: number(),
18716
+ /** Window lower bound (track firstSeen ≥ since). */
18717
+ since: number(),
18718
+ /** Window upper bound (track firstSeen ≤ until). */
18719
+ until: number(),
18720
+ limit: number().int().min(1).max(200).default(50),
18721
+ /** Drop tracks scoring below this importance. */
18722
+ minImportance: number().min(0).max(1).optional(),
18723
+ /** Restrict to a single class (e.g. 'person'). */
18724
+ classFilter: string().optional()
18554
18725
  });
18555
- var PipelineModelOptionSchema = object({
18726
+ var KeyEventSchema = object({
18727
+ /** The representative event id (the track's best ObjectEvent, else its trackId). */
18556
18728
  id: string(),
18557
- name: string(),
18558
- formats: record(string(), object({
18559
- downloaded: boolean(),
18560
- sizeMB: number()
18561
- })),
18562
- group: ModelVariantGroupSchema.optional(),
18563
- legacy: boolean().optional(),
18564
- provider: ModelProviderIdSchema.optional()
18729
+ trackId: string(),
18730
+ /** Track start time (firstSeen). */
18731
+ timestamp: number(),
18732
+ className: string(),
18733
+ ...TieredLabelFields,
18734
+ importance: number(),
18735
+ /** Highest-confidence ObjectEvent id for the track (empty when none). */
18736
+ bestEventId: string(),
18737
+ /** Track lifetime in ms (lastSeen - firstSeen). */
18738
+ windowMs: number().optional(),
18739
+ ...TrackFlagFields,
18740
+ ...TrackRetrainFields
18565
18741
  });
18566
- var ConfigFieldBridge = custom();
18567
- var PipelineAddonSchemaSchema = object({
18568
- id: string(),
18569
- name: string(),
18570
- slot: PipelineSlotSchema,
18571
- inputClasses: array(string()).readonly(),
18572
- outputClasses: array(string()).readonly(),
18573
- childSlots: array(PipelineSlotSchema).readonly(),
18574
- models: array(PipelineModelOptionSchema).readonly(),
18575
- defaultModelId: string(),
18576
- defaultModelIdByFormat: record(string(), string()).optional(),
18577
- enabledByDefault: boolean().optional(),
18578
- backfillIntoExistingOverrides: boolean().optional(),
18579
- defaultConfidence: number(),
18580
- group: string().optional(),
18581
- configSchema: array(ConfigFieldBridge).readonly().optional()
18742
+ object({
18743
+ trackId: string(),
18744
+ className: string(),
18745
+ confidence: number(),
18746
+ bbox: BoundingBoxSchema,
18747
+ zones: array(string()).readonly(),
18748
+ state: TrackStateSchema
18582
18749
  });
18583
- var PipelineSlotSchemaSchema = object({
18584
- id: PipelineSlotSchema,
18585
- label: string(),
18586
- priority: number(),
18587
- parentSlot: PipelineSlotSchema.nullable(),
18588
- addons: array(PipelineAddonSchemaSchema).readonly()
18750
+ var OverlayDetectionSchema = looseObject({
18751
+ id: string(),
18752
+ kind: _enum(["first-level", "detail"]),
18753
+ macroClass: string(),
18754
+ score: number(),
18755
+ bbox: object({
18756
+ x: number(),
18757
+ y: number(),
18758
+ width: number(),
18759
+ height: number()
18760
+ }),
18761
+ labels: array(looseObject({
18762
+ label: string(),
18763
+ score: number()
18764
+ })).readonly(),
18765
+ parentId: string().optional()
18589
18766
  });
18590
- var PipelineSchemaSchema = object({
18591
- availableEngines: array(AvailableEngineSchema).readonly(),
18592
- selectedEngine: PipelineEngineChoiceSchema,
18593
- slots: array(PipelineSlotSchemaSchema).readonly()
18767
+ var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
18768
+ var SearchObjectEventsInput = object({
18769
+ text: string(),
18770
+ deviceId: number().optional(),
18771
+ since: number().optional(),
18772
+ until: number().optional(),
18773
+ classFilter: string().optional(),
18774
+ limit: number().default(50),
18775
+ minScore: number().min(0).max(1).default(.2)
18594
18776
  });
18595
- var EngineProvisioningSchema = object({
18596
- runtimeId: _enum([
18597
- "onnx",
18598
- "openvino",
18599
- "coreml",
18600
- "edgetpu"
18601
- ]).nullable(),
18602
- device: string().nullable(),
18603
- state: _enum([
18604
- "idle",
18605
- "installing",
18606
- "verifying",
18607
- "ready",
18608
- "failed"
18609
- ]),
18610
- progress: number().optional(),
18611
- error: string().optional(),
18612
- nextRetryAt: number().optional(),
18613
- /**
18614
- * Gate A (config-correctness gate at engine change): human-readable
18615
- * config issues surfaced EAGERLY when the node's engine changes — model
18616
- * substitutions ("chose X, running Y") and zero-build steps ("no model
18617
- * has a <format> build"). Additive/optional: informational only, never
18618
- * enforced here — `assertEngineReady` (readiness) still gates inference.
18619
- * Absent/empty when the node-default tree resolves cleanly.
18620
- */
18621
- configIssues: array(string()).optional()
18777
+ var TrackCascadeCountsSchema = object({
18778
+ /** Persisted track roots deleted (authoritative). */
18779
+ tracks: number().int(),
18780
+ /** Object events removed with their tracks (best-effort; see note above). */
18781
+ events: number().int(),
18782
+ /** Track/face/plate-owned media removed (best-effort). Never identity media. */
18783
+ media: number().int(),
18784
+ /** Unassigned (non-enrolled) face reads removed (best-effort). */
18785
+ faces: number().int(),
18786
+ /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
18787
+ plates: number().int(),
18788
+ /** Per-track CLIP search vectors removed (best-effort). */
18789
+ embeddings: number().int(),
18790
+ /** Group membership + group rows removed with their last member (best-effort). */
18791
+ groups: number().int()
18622
18792
  });
18623
- var PipelineStepInputSchema = lazy(() => object({
18624
- addonId: string(),
18625
- modelId: string().optional(),
18626
- enabled: boolean().default(true),
18627
- children: array(PipelineStepInputSchema).optional(),
18628
- settings: record(string(), unknown()).optional(),
18629
- jumpDeviceKey: string().optional()
18630
- }));
18631
- var ModelSubstitutionSchema = object({
18632
- addonId: string(),
18633
- chosen: string(),
18634
- running: string(),
18635
- format: string()
18793
+ /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
18794
+ var DiskReconcileCountsSchema = object({
18795
+ mediaDropped: number().int(),
18796
+ tracks: number().int(),
18797
+ events: number().int()
18636
18798
  });
18637
- var PipelineValidationIssueSchema = object({
18638
- addonId: string(),
18639
- kind: _enum(["unknown-addon", "no-format-build"]),
18640
- detail: string()
18799
+ /** Event-store footprint for one camera. */
18800
+ var EventStoreDeviceFootprintSchema = object({
18801
+ deviceId: number(),
18802
+ /** Persisted event rows (motion + object + audio) for the camera. */
18803
+ rows: number().int(),
18804
+ /** Event-owned media bytes on disk for the camera. */
18805
+ bytes: number().int()
18641
18806
  });
18642
- var PipelineValidationResultSchema = object({
18643
- ok: boolean(),
18644
- issues: array(PipelineValidationIssueSchema).readonly(),
18645
- substitutions: array(ModelSubstitutionSchema).readonly(),
18646
- /** The node's `currentEngine.format` this validation ran against. */
18647
- format: string()
18807
+ /** Aggregate event-store footprint: global totals + per-camera breakdown. */
18808
+ var EventStoreFootprintSchema = object({
18809
+ totalRows: number().int(),
18810
+ totalBytes: number().int(),
18811
+ devices: array(EventStoreDeviceFootprintSchema).readonly()
18648
18812
  });
18649
- var ReferenceImageEntrySchema = object({
18650
- filename: string(),
18651
- stepIds: array(string()).readonly().optional()
18813
+ /** Per-kind counts returned by the event-prune / device-delete mutations. */
18814
+ var EventPruneCountsSchema = object({
18815
+ motion: number().int(),
18816
+ object: number().int(),
18817
+ audio: number().int()
18652
18818
  });
18653
- var ReferenceImageBodySchema = object({
18654
- base64: string(),
18655
- filename: string()
18819
+ /**
18820
+ * Re-embed stored tracks from their key frames.
18821
+ *
18822
+ * The reason this is an operator-callable method and not a migration script:
18823
+ * every knob that decides what a vector MEANS — encoder model, crop margin,
18824
+ * squaring — is only changeable if the existing vectors can be regenerated.
18825
+ * Mixing feature spaces in one index makes cosine scores incomparable, and the
18826
+ * symptom is a quality regression with no visible cause.
18827
+ */
18828
+ var RebuildObjectEmbeddingsInput = object({
18829
+ /** Restrict to one camera. Omit for the whole fleet. */
18830
+ deviceId: number().optional(),
18831
+ since: number().optional(),
18832
+ until: number().optional(),
18833
+ /** Stop after this many tracks; the result reports whether more remain. */
18834
+ maxTracks: number().int().positive().optional(),
18835
+ /**
18836
+ * Run every embedding on THIS node instead of round-robining the fleet.
18837
+ *
18838
+ * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
18839
+ * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
18840
+ * calling it that would pin the rebuild REQUEST itself to that node — the
18841
+ * rebuild orchestration lives on the hub, and only the per-track step runs
18842
+ * remotely. This field is data; the per-track pin is applied inside.
18843
+ *
18844
+ * Absent ⇒ round-robin over every online node whose runner can serve the
18845
+ * pinned model.
18846
+ */
18847
+ executeOnNodeId: string().optional(),
18848
+ /**
18849
+ * Milliseconds to wait between tracks; omit for the built-in default, `0` to
18850
+ * run flat out.
18851
+ *
18852
+ * A rebuild is bulk maintenance on hub-main's single thread. Measured
18853
+ * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
18854
+ * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
18855
+ * force is logged at start and finish so a deliberately slow pass reads
18856
+ * differently from a stalled one.
18857
+ */
18858
+ pacingMs: number().int().nonnegative().optional()
18656
18859
  });
18657
- var ReferenceAudioEntrySchema = object({
18658
- filename: string(),
18659
- sizeKb: number()
18860
+ /**
18861
+ * Result of emptying the CLIP index.
18862
+ *
18863
+ * The clean slate before a policy change: a new crop margin or encoder model
18864
+ * leaves two feature spaces in one index whose cosine scores are not
18865
+ * comparable, so wiping and rebuilding is the only way to be sure every vector
18866
+ * means the same thing.
18867
+ */
18868
+ var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
18869
+ /**
18870
+ * Acknowledgement that a rebuild STARTED.
18871
+ *
18872
+ * The pass costs ~1s per track — 45 minutes for a 2,600-track fleet — so it
18873
+ * runs detached and this returns immediately. Waiting for it made the client
18874
+ * time out while the work carried on server-side, which is the worst of both:
18875
+ * no result and no way to know it was still going. Poll
18876
+ * `getObjectEmbeddingRebuildStatus` for progress.
18877
+ */
18878
+ var RebuildObjectEmbeddingsResultSchema = object({
18879
+ started: boolean(),
18880
+ /** True when a pass was already running; the new request is ignored. */
18881
+ alreadyRunning: boolean()
18660
18882
  });
18661
- var ReferenceAudioBodySchema = object({ base64: string() });
18662
- var AudioBackendSchema = object({
18663
- id: string(),
18664
- name: string(),
18665
- description: string(),
18666
- available: boolean(),
18883
+ var RebuildStatusSchema = object({
18884
+ running: boolean(),
18885
+ scanned: number(),
18886
+ rebuilt: number(),
18887
+ /** Tracks whose key frame is gone — nothing to re-embed from. */
18888
+ missingKeyFrame: number(),
18889
+ /** Tracks with no usable detection box. */
18890
+ missingBbox: number(),
18891
+ /**
18892
+ * Tracks an executing node REFUSED rather than broke on — an unreadable key
18893
+ * frame, a step that threw. Separate from `failed` because the remedy is
18894
+ * different, and because a whole camera silently contributing zero vectors
18895
+ * is the shape of failure a rebuild must never hide.
18896
+ */
18897
+ notRunnable: number(),
18667
18898
  /**
18668
- * Raw classifier labels this backend can emit (e.g. YAMNet's
18669
- * 521-class set or Apple SoundAnalysis's 303-class set). Used by
18670
- * the benchmark UI to populate the `enabledMicroClasses` filter
18671
- * specific to the selected backend without a separate fetch.
18899
+ * The pass stopped because NO node could serve the pinned model.
18900
+ *
18901
+ * Distinct from `notRunnable` on purpose: that one says "this track was
18902
+ * refused", this one says "the cluster cannot do this work at all" — every
18903
+ * candidate node either lacks the `clip-embedding` step, lacks a build of the
18904
+ * pinned model for its engine format, or dropped out. The remedy is a model /
18905
+ * engine change, not a per-camera one. Non-zero here always comes with
18906
+ * `complete: false`.
18672
18907
  */
18673
- rawLabels: array(string()).readonly().optional()
18674
- });
18675
- var AudioCapabilitiesSchema = object({
18676
- activeBackend: string(),
18677
- availableBackends: array(AudioBackendSchema).readonly(),
18678
- sampleRate: number(),
18679
- chunkDurationMs: number()
18680
- });
18681
- var DownloadModelResultSchema = object({
18682
- filePath: string(),
18683
- sizeMB: number(),
18684
- durationMs: number()
18908
+ noCapableNode: number(),
18909
+ failed: number(),
18910
+ /** Set once a pass ends: true only when EVERYTHING was covered. */
18911
+ complete: boolean().nullable(),
18912
+ startedAtMs: number().nullable(),
18913
+ finishedAtMs: number().nullable(),
18914
+ /** Present when the pass ended by throwing. */
18915
+ error: string().nullable()
18685
18916
  });
18686
- /**
18687
- * Wrapper carrying a single test run's result. Replaces the legacy
18688
- * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
18689
- * canonical `AudioResult` from the Phase 6 output rework: one
18690
- * `AudioDetection` per class above `minScore`, top-N candidates in
18691
- * `debug.alternateLabels['audio-classifier']`, per-source timings in
18692
- * `debug.stepTimings`. The outer `success`/`error` fields stay so the
18693
- * benchmark UI can still report a clean failure when the classifier
18694
- * cap isn't available.
18695
- */
18696
- var AudioTestResultSchema = object({
18697
- success: boolean(),
18698
- error: string().optional(),
18699
- frame: custom().optional()
18917
+ var ReplayFrameInputSchema = object({
18918
+ timestamp: number(),
18919
+ frame: PipelineRunResultBridge
18700
18920
  });
18701
- var PipelineConfigBridge = custom();
18702
- var ConfigUISchemaBridge = custom();
18703
- var ConfigUISchemaNullableBridge = custom();
18704
- var InferenceCapabilitiesBridge = custom();
18705
- var ModelAvailabilityListBridge = custom();
18706
- var PipelineRunResultBridge = custom();
18707
- method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
18708
- modelId: string(),
18709
- settings: record(string(), unknown()).readonly()
18710
- }))), method(object({ steps: record(string(), object({
18711
- modelId: string(),
18712
- settings: record(string(), unknown()).readonly()
18713
- })) }), object({ success: literal(true) }), {
18921
+ var RunReplayFrameProcessorResultSchema = object({ tracks: array(object({
18922
+ className: string(),
18923
+ firstSeenMs: number(),
18924
+ lastSeenMs: number(),
18925
+ /** Bbox of the track's FIRST matched detection, pixel-space in the clip's
18926
+ * frame — a representative box for the diff's `(className, window, IoU)`
18927
+ * pairing (`replay-diff.ts`). A replay does not need the full per-frame
18928
+ * trajectory production's `Track.positions` keeps. */
18929
+ bbox: BoundingBoxSchema,
18930
+ /** How many of the input frames this track matched a real detection on
18931
+ * (never a coasted/extrapolated frame) — the replay's own signal for "how
18932
+ * solid is this track", cheaper than re-deriving it from a trajectory. */
18933
+ framesMatched: number().int()
18934
+ })).readonly() });
18935
+ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
18936
+ deviceId: number(),
18937
+ trackId: string()
18938
+ }), TrackSchema.nullable()), method(object({
18939
+ deviceId: number(),
18940
+ since: number().optional(),
18941
+ until: number().optional(),
18942
+ limit: number().optional(),
18943
+ /** Spatial filter — only tracks whose trajectory intersects the zone
18944
+ * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
18945
+ * envelope columns, then precisely tested per position. Tracks with
18946
+ * an unknown envelope (no frame dims at persist time) always match. */
18947
+ zone: TrackZoneFilterSchema.optional(),
18948
+ /** See {@link TrackProjectionSchema}. Default `full` (backward
18949
+ * compatible — omitting the field keeps today's exact behaviour). */
18950
+ projection: TrackProjectionSchema.optional(),
18951
+ /** Include stationary-promoted rows (parked objects handed to the
18952
+ * stationary registry). Default false: the timeline lists passages,
18953
+ * not parking records (operator decision, 2026-08-15). */
18954
+ includeStationary: boolean().optional()
18955
+ }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
18956
+ deviceId: number(),
18957
+ groupId: string().min(1)
18958
+ }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
18959
+ kind: "mutation",
18960
+ auth: "admin"
18961
+ }), method(DeviceEventQueryInput, array(MotionEventSchema).readonly()), method(ObjectEventQueryInput, array(ObjectEventSchema).readonly()), method(DeviceEventQueryInput, array(AudioEventSchema).readonly()), method(object({ deviceId: number() }), array(EventKindDescriptorSchema).readonly()), method(object({ deviceIds: array(number()).min(1).max(200) }), array(EventKindsForDeviceSchema).readonly()), method(object({
18962
+ deviceId: number(),
18963
+ since: number().optional(),
18964
+ until: number().optional(),
18965
+ kinds: array(string()).optional(),
18966
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
18967
+ }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
18968
+ deviceId: number(),
18969
+ since: number(),
18970
+ until: number(),
18971
+ bucketMs: number().int().positive()
18972
+ }), array(object({
18973
+ bucketStart: number(),
18974
+ motion: number().int(),
18975
+ object: number().int(),
18976
+ audio: number().int()
18977
+ })).readonly()), method(object({
18978
+ deviceId: number(),
18979
+ cutoffMs: number()
18980
+ }), object({
18981
+ motion: number().int(),
18982
+ object: number().int(),
18983
+ audio: number().int()
18984
+ }), {
18985
+ kind: "mutation",
18986
+ auth: "admin"
18987
+ }), method(object({
18988
+ deviceId: number(),
18989
+ cutoffMs: number()
18990
+ }), TrackCascadeCountsSchema, {
18991
+ kind: "mutation",
18992
+ auth: "admin"
18993
+ }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
18994
+ kind: "mutation",
18995
+ auth: "admin"
18996
+ }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
18997
+ kind: "mutation",
18998
+ auth: "admin"
18999
+ }), method(object({
19000
+ deviceId: number(),
19001
+ trackIds: array(string()).min(1)
19002
+ }), object({
19003
+ deleted: number().int(),
19004
+ failed: array(string()).readonly()
19005
+ }), {
19006
+ kind: "mutation",
19007
+ auth: "admin"
19008
+ }), method(object({
19009
+ /** Log/audit scope only — the trackId is globally unique on its own. */
19010
+ deviceId: number(),
19011
+ trackId: string(),
19012
+ flags: TrackFlagsPatchSchema
19013
+ }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
19014
+ kind: "query",
19015
+ auth: "admin"
19016
+ }), method(object({
19017
+ olderThanMs: number(),
19018
+ reason: OpsLogReasonSchema.optional()
19019
+ }), EventPruneCountsSchema, {
19020
+ kind: "mutation",
19021
+ auth: "admin"
19022
+ }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
19023
+ kind: "mutation",
19024
+ auth: "admin"
19025
+ }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
19026
+ kind: "mutation",
19027
+ auth: "admin"
19028
+ }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
19029
+ kind: "mutation",
19030
+ auth: "admin"
19031
+ }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
19032
+ kind: "mutation",
19033
+ auth: "admin"
19034
+ }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
19035
+ kind: "mutation",
19036
+ auth: "admin"
19037
+ }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
19038
+ kind: "mutation",
19039
+ auth: "admin"
19040
+ }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
19041
+ kind: "mutation",
19042
+ auth: "admin"
19043
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
19044
+ kind: "query",
19045
+ auth: "admin"
19046
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
19047
+ kind: "mutation",
19048
+ auth: "admin"
19049
+ }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
19050
+ kind: "query",
19051
+ auth: "admin"
19052
+ }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
19053
+ kind: "query",
19054
+ auth: "admin"
19055
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
19056
+ kind: "query",
19057
+ auth: "admin"
19058
+ }), method(object({
19059
+ /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
19060
+ * `deviceId`, deliberately: `deviceId` would make this device-bound and
19061
+ * route it at one camera's owner, and "every camera" would stop being
19062
+ * expressible at all. */
19063
+ deviceIds: array(number()).optional(),
19064
+ limit: number().int().min(1).max(500).optional()
19065
+ }), array(RetrainTrackSchema).readonly(), {
19066
+ kind: "query",
19067
+ auth: "admin"
19068
+ }), method(object({ trackId: string() }), RetrainFrameListSchema, {
19069
+ kind: "query",
19070
+ auth: "admin"
19071
+ }), method(object({
19072
+ deviceId: number(),
19073
+ trackId: string(),
19074
+ mediaKeys: array(string()).min(1)
19075
+ }), RetrainFrameSelectionSchema, {
19076
+ kind: "mutation",
19077
+ auth: "admin"
19078
+ }), method(object({
19079
+ deviceId: number(),
19080
+ trackId: string(),
19081
+ frameId: string()
19082
+ }), object({
19083
+ removed: boolean(),
19084
+ removedAnnotations: number().int()
19085
+ }), {
19086
+ kind: "mutation",
19087
+ auth: "admin"
19088
+ }), method(object({ frameId: string() }), object({
19089
+ base64: string(),
19090
+ width: number().int(),
19091
+ height: number().int()
19092
+ }), {
19093
+ kind: "query",
19094
+ auth: "admin"
19095
+ }), method(object({
19096
+ deviceId: number(),
19097
+ trackId: string(),
19098
+ frameId: string(),
19099
+ subject: RetrainAssistSubjectSchema,
19100
+ /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
19101
+ nodeId: string().optional()
19102
+ }), RetrainAssistResultSchema, {
19103
+ kind: "mutation",
19104
+ auth: "admin"
19105
+ }), method(object({
19106
+ deviceId: number(),
19107
+ source: DetectionSourceSchema,
19108
+ zones: array(ZoneSchema).readonly().optional(),
19109
+ detectionRules: array(ZoneRuleSchema).readonly().optional(),
19110
+ zoneMembershipMinOverlap: number().min(0).max(1).optional(),
19111
+ frames: array(ReplayFrameInputSchema).min(1)
19112
+ }), RunReplayFrameProcessorResultSchema, {
19113
+ kind: "mutation",
19114
+ auth: "admin"
19115
+ }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
19116
+ kind: "query",
19117
+ auth: "admin"
19118
+ }), method(object({
19119
+ deviceId: number(),
19120
+ trackId: string(),
19121
+ frameId: string(),
19122
+ annotations: array(RetrainAnnotationDraftSchema)
19123
+ }), array(RetrainAnnotationSchema).readonly(), {
19124
+ kind: "mutation",
19125
+ auth: "admin"
19126
+ }), method(object({
19127
+ deviceId: number(),
19128
+ trackId: string()
19129
+ }), RetrainTransitionResultSchema, {
18714
19130
  kind: "mutation",
18715
19131
  auth: "admin"
18716
- }), method(object({ nodeId: string() }), object({
18717
- success: literal(true),
18718
- clearedDevices: number()
18719
- }), {
19132
+ }), method(object({
19133
+ deviceId: number(),
19134
+ trackId: string()
19135
+ }), RetrainTransitionResultSchema, {
18720
19136
  kind: "mutation",
18721
19137
  auth: "admin"
18722
- }), 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({
18723
- name: string(),
18724
- steps: array(PipelineTemplateStepSchema).readonly(),
18725
- engine: PipelineEngineChoiceSchema
18726
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
18727
- id: string(),
18728
- name: string().optional(),
18729
- steps: array(PipelineTemplateStepSchema).readonly().optional()
18730
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
18731
- addonId: string(),
18732
- modelId: string(),
18733
- format: ModelFormatSchema$1
18734
- }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
18735
- addonId: string(),
18736
- modelId: string(),
18737
- format: ModelFormatSchema$1
18738
- }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
18739
- engine: PipelineEngineChoiceSchema.optional(),
18740
- steps: array(PipelineStepInputSchema).min(1),
18741
- frame: FrameInputSchema.optional(),
18742
- /**
18743
- * Process-local lazy frame. Valid only when caller and provider resolve
18744
- * in the same execution-group process; split/cross-node callers use
18745
- * `frame`/`image` inline compatibility instead.
18746
- */
18747
- frameRef: FrameRefSchema.optional(),
18748
- /**
18749
- * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
18750
- * the decoded pixels live in. One more member of the one-of
18751
- * frame/frameHandle/image/imageBase64/referenceImage group.
18752
- */
18753
- frameHandle: FrameHandleSchema.optional(),
18754
- imageBase64: string().optional(),
18755
- /**
18756
- * Binary JPEG bytes — preferred over `imageBase64` on internal
18757
- * hops (hub → forked worker via Moleculer MsgPack) because it
18758
- * skips the 33% base64 overhead + the per-call base64 decode on
18759
- * the detection-pipeline worker. Callers can pass either; exactly
18760
- * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
18761
- */
18762
- image: _instanceof(Uint8Array).optional(),
18763
- referenceImage: string().optional(),
18764
- deviceId: number().optional(),
18765
- sessionId: string().optional(),
18766
- /**
18767
- * Execution plane. 'full' (default) runs the whole tree — benchmark,
18768
- * reference-image, and detail-subtree calls. 'frame' is the live
18769
- * per-frame dispatch: ONLY root-plane steps run; crop children
18770
- * (inputClasses ≠ null) are skipped and served per-track via
18771
- * pipelineRunner.runDetailSubtree (two-plane design).
18772
- */
18773
- plane: _enum(["full", "frame"]).optional(),
18774
- /**
18775
- * Inference-device selector (Phase 2 multi-device). Format
18776
- * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
18777
- * Omitted ⇒ the runner's default device (current single-engine
18778
- * behaviour). Selects WHICH device pool of the node runs the call.
18779
- */
18780
- deviceKey: string().optional(),
18781
- /**
18782
- * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
18783
- * when the parent crop was resolved from the frame's retained NATIVE
18784
- * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
18785
- * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
18786
- * resolution from that surface — the SAME quality path faces already
18787
- * had — instead of the downscaled parent tile. `handle` keys the native
18788
- * surface (node-pinned to its owner); `cropFrameSpace` is the parent
18789
- * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
18790
- * the executor's crop-normalized child ROI back into frame-normalized
18791
- * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
18792
- * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
18793
- * (today's behaviour on the fallback path).
18794
- */
18795
- nativeCropRef: NativeCropRefSchema.optional()
18796
- }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
18797
- engine: PipelineEngineChoiceSchema.optional(),
18798
- steps: array(PipelineStepInputSchema).min(1),
18799
- frames: array(FrameInputSchema).min(1).max(255),
18800
- deviceId: number().optional(),
18801
- sessionId: string().optional(),
18802
- /**
18803
- * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
18804
- * the batch to the Python pool's bench preprocess cache
18805
- * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
18806
- * preprocessed ONCE and every later inference is a pure-inference cache
18807
- * hit — the sustained-throughput run measures inference, not
18808
- * decode+preprocess+infer. Omitted/0 for live frames (all different →
18809
- * full preprocess every call, correct). Fresh per sustained run;
18810
- * released via `uncacheFrame`.
18811
- */
18812
- frameId: number().int().nonnegative().optional(),
18813
- /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
18814
- deviceKey: string().optional()
18815
- }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
18816
- data: _instanceof(Uint8Array),
18817
- width: number().int().positive(),
18818
- height: number().int().positive(),
18819
- format: _enum([
18820
- "rgb",
18821
- "bgr",
18822
- "gray"
18823
- ])
18824
- }), object({
18825
- frameId: number(),
18826
- width: number(),
18827
- height: number()
18828
- }), { kind: "mutation" }), method(object({
18829
- stepId: string(),
18830
- frameId: number().int()
18831
- }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
18832
- batchMode: string(),
18833
- windowMs: number(),
18834
- maxBatchSize: number(),
18835
- concurrency: number()
18836
- })), method(_void(), array(object({
18837
- engineKey: string(),
18838
- engine: PipelineEngineChoiceSchema,
18839
- modelsLoaded: array(string()).readonly(),
18840
- inUseByCameras: array(number()).readonly(),
18841
- /**
18842
- * Origin of this resident factory.
18843
- * - `runtime` — main camera-serving engine (no idle TTL).
18844
- * - `warm-override` — benchmark/test override held in the warm
18845
- * cache; auto-disposed after the idle TTL.
18846
- * - `device-pool` — a concurrent per-device pool (Phase 2
18847
- * multi-device, keyed by `deviceKey`) resolved
18848
- * via `resolveDeviceFactory`. Runs alongside the
18849
- * `runtime` engine on a DIFFERENT accelerator
18850
- * (NPU / iGPU / Coral) — this is how the
18851
- * Engines tab shows all pools running at once.
18852
- */
18853
- kind: _enum([
18854
- "runtime",
18855
- "warm-override",
18856
- "device-pool"
18857
- ]),
18858
- /** Native pid of the underlying Python pool (null when no pool). */
18859
- poolPid: number().nullable(),
18860
- /** ms since this factory was last used (null when not warm-tracked). */
18861
- idleMs: number().nullable(),
18862
- /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
18863
- idleTtlMs: number().nullable()
18864
- })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
18865
- kind: "mutation",
19138
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
19139
+ kind: "query",
18866
19140
  auth: "admin"
18867
19141
  }), method(object({
18868
- engine: PipelineEngineChoiceSchema,
18869
- force: boolean().optional()
18870
- }), object({
18871
- success: boolean(),
18872
- reason: string().optional()
18873
- }), {
19142
+ eventId: string(),
19143
+ kind: MediaFileKindEnum.optional(),
19144
+ deviceId: number()
19145
+ }), array(MediaFileSchema).readonly()), method(object({
19146
+ trackId: string(),
19147
+ kinds: array(MediaFileKindEnum).optional(),
19148
+ deviceId: number()
19149
+ }), array(MediaFileSchema).readonly()), method(object({
19150
+ trackId: string(),
19151
+ deviceId: number()
19152
+ }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
18874
19153
  kind: "mutation",
18875
19154
  auth: "admin"
18876
- }), 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({
18877
- addonId: string(),
18878
- modelId: string(),
18879
- filename: string().optional(),
18880
- settings: record(string(), unknown()).optional()
18881
- }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
19155
+ }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
19156
+ kind: "mutation",
19157
+ auth: "admin"
19158
+ }), method(object({}), RebuildStatusSchema), object({
19159
+ deviceId: number(),
19160
+ timestamp: number(),
19161
+ frameWidth: number(),
19162
+ frameHeight: number(),
19163
+ detections: array(OverlayDetectionSchema).readonly()
19164
+ }), object({
19165
+ deviceId: number(),
19166
+ trackId: string(),
19167
+ className: string()
19168
+ }), object({
19169
+ deviceId: number(),
19170
+ trackId: string(),
19171
+ className: string(),
19172
+ durationMs: number()
19173
+ }), object({
19174
+ deviceId: number(),
19175
+ kind: EventKindSchema,
19176
+ eventId: string(),
19177
+ timestamp: number()
19178
+ });
18882
19179
  object({
18883
19180
  activeCameras: number(),
18884
19181
  throttledCameras: number(),
@@ -18890,119 +19187,19 @@ var CameraMetricsSchema = object({
18890
19187
  "disabled",
18891
19188
  "always-on",
18892
19189
  "on-motion"
18893
- ]),
18894
- configuredFps: number(),
18895
- actualFps: number(),
18896
- queueDepth: number(),
18897
- avgInferenceTimeMs: number(),
18898
- droppedFrames: number(),
18899
- phase: _enum([
18900
- "idle",
18901
- "watching",
18902
- "active"
18903
- ])
18904
- });
18905
- var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
18906
- /**
18907
- * Zone — pure geometry + identity. NO filtering behaviour.
18908
- *
18909
- * Zones describe **where** in the frame the operator wants to flag
18910
- * something; consumer-owned {@link ZoneRule} arrays describe **how**
18911
- * each pipeline stage uses them. Splitting the two means a single
18912
- * polygon "Driveway" can simultaneously back a motion-exclude rule,
18913
- * a detection-include rule on `['car']`, and an occupancy aggregate
18914
- * — without three duplicated polygons.
18915
- *
18916
- * Owned by the orchestrator addon (provider) and mirrored into the
18917
- * `zones` device-state slice on every mutation. Consumers
18918
- * (motion-wasm, pipeline-executor, analytics, admin UI) read either
18919
- * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
18920
- * mirror with `onChanged`).
18921
- *
18922
- * Coordinates are normalised fractions of the frame (0–1) so zones
18923
- * survive resolution changes and stream profile switches.
18924
- *
18925
- * `kind` discriminates between full polygons (closed regions used
18926
- * for intrusion / occupancy filters) and tripwires (open 2-point
18927
- * line segments used for cross events). Onboard / firmware-reported
18928
- * zones (Reolink, ONVIF) are out of scope for now — see the deferred
18929
- * task list.
18930
- */
18931
- var ZoneKindEnum = _enum(["polygon", "tripwire"]);
18932
- /** Polygon vertex in fraction-of-frame coordinates (0–1). */
18933
- var PolygonPointSchema = object({
18934
- x: number(),
18935
- y: number()
18936
- });
18937
- /** A camera detection zone — pure geometry/identity. */
18938
- var ZoneSchema = object({
18939
- id: string(),
18940
- name: string(),
18941
- kind: ZoneKindEnum.default("polygon"),
18942
- /** Polygon vertices, fraction of frame (0–1). */
18943
- polygon: array(PolygonPointSchema).readonly(),
18944
- /** Visual color for UI rendering. */
18945
- color: string().default("#3b82f6")
19190
+ ]),
19191
+ configuredFps: number(),
19192
+ actualFps: number(),
19193
+ queueDepth: number(),
19194
+ avgInferenceTimeMs: number(),
19195
+ droppedFrames: number(),
19196
+ phase: _enum([
19197
+ "idle",
19198
+ "watching",
19199
+ "active"
19200
+ ])
18946
19201
  });
18947
- /**
18948
- * Zones capability — per-camera CRUD over polygon detection zones.
18949
- *
18950
- * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
18951
- * to per-device settings and mirrors into the `zones` device-state
18952
- * slice on every mutation, so downstream consumers can subscribe via
18953
- * `dev.state.zones.onChanged`.
18954
- *
18955
- * The cap surface only handles geometry + identity; filtering
18956
- * behaviour (per-class, include/exclude, threshold) lives in the
18957
- * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
18958
- * `capabilities/schemas/zone-rule.js`.
18959
- */
18960
- var zonesCapability = {
18961
- name: "zones",
18962
- scope: "device",
18963
- mode: "singleton",
18964
- deviceTypes: [DeviceType.Camera],
18965
- methods: {
18966
- listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
18967
- addZone: method(object({
18968
- deviceId: number(),
18969
- zone: ZoneSchema
18970
- }), _void(), {
18971
- kind: "mutation",
18972
- auth: "admin"
18973
- }),
18974
- removeZone: method(object({
18975
- deviceId: number(),
18976
- zoneId: string()
18977
- }), _void(), {
18978
- kind: "mutation",
18979
- auth: "admin"
18980
- }),
18981
- updateZone: method(object({
18982
- deviceId: number(),
18983
- zone: ZoneSchema
18984
- }), _void(), {
18985
- kind: "mutation",
18986
- auth: "admin"
18987
- })
18988
- },
18989
- /**
18990
- * Runtime-state slice — the live zone catalogue mirrored by the
18991
- * orchestrator on every CRUD mutation. Consumers read via
18992
- * `device.state.zones.value` / `.watch(...)` without round-tripping
18993
- * the cap, and the codegen DeviceProxy auto-wires the reactive
18994
- * handle. Slice shape is `{ zones: Zone[] }` so future extensions
18995
- * (e.g. zone groupings) can sit alongside the polygon list.
18996
- */
18997
- runtimeState: object({ zones: array(ZoneSchema).readonly() }),
18998
- /**
18999
- * Runtime-state durability: **restored** — written only on operator mutation, so a camera that never had one has nothing to re-derive from. This is the slice `zone-mirror-hydration.ts` exists to paper over.
19000
- *
19001
- * See `RuntimeStateDurability`. Enforced by
19002
- * `scripts/check-runtime-state-durability.ts`.
19003
- */
19004
- durability: "restored"
19005
- };
19202
+ var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
19006
19203
  /**
19007
19204
  * A bounding box in NORMALIZED [0,1] frame coordinates for `getNativeCrop`. The
19008
19205
  * decode worker resolves it against the RETAINED native frame's real pixel dims,
@@ -20691,7 +20888,7 @@ method(object({
20691
20888
  * linking rather than produce an eternal token.
20692
20889
  */
20693
20890
  ttlSec: union([number().int().positive(), literal("never")]).optional()
20694
- }), object({ token: string() })), method(object({ token: string() }), SsoBridgeClaimsSchema.nullable());
20891
+ }), object({ token: string() }), { auth: "admin" }), method(object({ token: string() }), SsoBridgeClaimsSchema.nullable(), { auth: "admin" });
20695
20892
  var ProviderListEntrySchema = discriminatedUnion("shouldSaveDiskSpace", [object({
20696
20893
  providerId: string().min(1),
20697
20894
  displayName: string().min(1),
@@ -20786,10 +20983,13 @@ var EvictResultSchema = object({
20786
20983
  /** True when the provider has nothing left it is willing to drop on this location. */
20787
20984
  exhausted: boolean()
20788
20985
  });
20789
- method(object({ locationId: string() }), EvictableUsageSchema), method(object({
20986
+ method(object({ locationId: string() }), EvictableUsageSchema, { auth: "admin" }), method(object({
20790
20987
  locationId: string(),
20791
20988
  targetBytes: number().int().positive()
20792
- }), EvictResultSchema, { kind: "mutation" });
20989
+ }), EvictResultSchema, {
20990
+ kind: "mutation",
20991
+ auth: "admin"
20992
+ });
20793
20993
  method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin" }), method(StorageMigrationInputSchema, object({ jobId: string() }), {
20794
20994
  kind: "mutation",
20795
20995
  auth: "admin"
@@ -20849,26 +21049,50 @@ var ReadChunkInputSchema = object({
20849
21049
  length: number()
20850
21050
  });
20851
21051
  var EndDownloadInputSchema = object({ downloadId: string() });
20852
- method(_void(), ProviderInfoSchema), method(object({ config: record(string(), unknown()) }), TestLocationResultSchema, { auth: "admin" }), method(object({
21052
+ method(_void(), ProviderInfoSchema, { auth: "admin" }), method(object({ config: record(string(), unknown()) }), TestLocationResultSchema, { auth: "admin" }), method(object({
20853
21053
  location: StorageLocationSchema,
20854
21054
  relativePath: string()
20855
- }), string()), method(object({
21055
+ }), string(), { auth: "admin" }), method(object({
20856
21056
  location: StorageLocationSchema,
20857
21057
  relativePath: string(),
20858
21058
  data: _instanceof(Uint8Array)
20859
- }), _void(), { kind: "mutation" }), method(object({
21059
+ }), _void(), {
21060
+ kind: "mutation",
21061
+ auth: "admin"
21062
+ }), method(object({
20860
21063
  location: StorageLocationSchema,
20861
21064
  relativePath: string()
20862
- }), _instanceof(Uint8Array)), method(object({
21065
+ }), _instanceof(Uint8Array), { auth: "admin" }), method(object({
20863
21066
  location: StorageLocationSchema,
20864
21067
  relativePath: string()
20865
- }), boolean()), method(object({
21068
+ }), boolean(), { auth: "admin" }), method(object({
20866
21069
  location: StorageLocationSchema,
20867
21070
  prefix: string().optional()
20868
- }), array(string()).readonly()), method(object({
21071
+ }), array(string()).readonly(), { auth: "admin" }), method(object({
20869
21072
  location: StorageLocationSchema,
20870
21073
  relativePath: string()
20871
- }), _void(), { kind: "mutation" }), method(object({ location: StorageLocationSchema }), number().nullable()), method(BeginUploadInputSchema, BeginUploadResultSchema, { kind: "mutation" }), method(WriteChunkInputSchema, _void(), { kind: "mutation" }), method(FinalizeUploadInputSchema, _void(), { kind: "mutation" }), method(AbortUploadInputSchema, _void(), { kind: "mutation" }), method(BeginDownloadInputSchema, BeginDownloadResultSchema, { kind: "mutation" }), method(ReadChunkInputSchema, _instanceof(Uint8Array)), method(EndDownloadInputSchema, _void(), { kind: "mutation" });
21074
+ }), _void(), {
21075
+ kind: "mutation",
21076
+ auth: "admin"
21077
+ }), method(object({ location: StorageLocationSchema }), number().nullable(), { auth: "admin" }), method(BeginUploadInputSchema, BeginUploadResultSchema, {
21078
+ kind: "mutation",
21079
+ auth: "admin"
21080
+ }), method(WriteChunkInputSchema, _void(), {
21081
+ kind: "mutation",
21082
+ auth: "admin"
21083
+ }), method(FinalizeUploadInputSchema, _void(), {
21084
+ kind: "mutation",
21085
+ auth: "admin"
21086
+ }), method(AbortUploadInputSchema, _void(), {
21087
+ kind: "mutation",
21088
+ auth: "admin"
21089
+ }), method(BeginDownloadInputSchema, BeginDownloadResultSchema, {
21090
+ kind: "mutation",
21091
+ auth: "admin"
21092
+ }), method(ReadChunkInputSchema, _instanceof(Uint8Array), { auth: "admin" }), method(EndDownloadInputSchema, _void(), {
21093
+ kind: "mutation",
21094
+ auth: "admin"
21095
+ });
20872
21096
  /** Profile-exported FormBuilder schema. Shape is ConfigUISchema at the UI. */
20873
21097
  var ProfileSettingsSchemaBridge = unknown().nullable();
20874
21098
  var ProfileSettingsBagSchema = record(string(), unknown());
@@ -21126,7 +21350,8 @@ method(object({
21126
21350
  access: "create"
21127
21351
  }), method(object({ userId: string().optional() }), object({ optionsJSON: record(string(), unknown()) }), {
21128
21352
  kind: "mutation",
21129
- access: "view"
21353
+ access: "view",
21354
+ auth: "admin"
21130
21355
  }), method(object({
21131
21356
  /** Required — the user the assertion belongs to (verified). */
21132
21357
  userId: string(),
@@ -21134,10 +21359,12 @@ method(object({
21134
21359
  response: record(string(), unknown())
21135
21360
  }), object({ verified: boolean() }), {
21136
21361
  kind: "mutation",
21137
- access: "view"
21362
+ access: "view",
21363
+ auth: "admin"
21138
21364
  }), method(object({}), object({ optionsJSON: record(string(), unknown()) }), {
21139
21365
  kind: "mutation",
21140
- access: "view"
21366
+ access: "view",
21367
+ auth: "admin"
21141
21368
  }), method(object({
21142
21369
  /** AuthenticationResponseJSON from the browser. */
21143
21370
  response: record(string(), unknown()) }), object({
@@ -21145,7 +21372,8 @@ response: record(string(), unknown()) }), object({
21145
21372
  userId: string().nullable()
21146
21373
  }), {
21147
21374
  kind: "mutation",
21148
- access: "view"
21375
+ access: "view",
21376
+ auth: "admin"
21149
21377
  }), method(object({ userId: string() }), array(PasskeySummarySchema), { auth: "admin" }), method(object({
21150
21378
  userId: string(),
21151
21379
  credentialId: string()
@@ -21317,7 +21545,19 @@ var VectorStatsResultSchema = object({
21317
21545
  /** False when the backend ranks approximately. */
21318
21546
  exact: boolean()
21319
21547
  });
21320
- 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);
21548
+ method(VectorDeclareIndexInputSchema, _void(), {
21549
+ kind: "mutation",
21550
+ auth: "admin"
21551
+ }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
21552
+ kind: "mutation",
21553
+ auth: "admin"
21554
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
21555
+ kind: "mutation",
21556
+ auth: "admin"
21557
+ }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
21558
+ kind: "mutation",
21559
+ auth: "admin"
21560
+ }), method(VectorStatsInputSchema, VectorStatsResultSchema, { auth: "admin" });
21321
21561
  var ClipSchema = object({
21322
21562
  /** Opaque, provider-namespaced id. The default provider encodes the time
21323
21563
  * window so `getClipPlayback` is self-contained (no event re-query). */
@@ -23778,7 +24018,27 @@ var MediaFileLiteSchema$1 = object({
23778
24018
  sizeBytes: number(),
23779
24019
  timestamp: number()
23780
24020
  });
23781
- method(_void(), array(IdentitySchema).readonly()), method(object({ name: string().min(1) }), IdentitySchema, {
24021
+ method(object({
24022
+ /**
24023
+ * Inline {@link IdentitySchema.coverBase64} on every row.
24024
+ *
24025
+ * Default `false`, the same inversion `listRecentFaces` and
24026
+ * `listPlates` took on 2026-08-25 (see `include-crops-default.ts` for
24027
+ * why the burden belongs on the caller that WANTS the bytes). Measured
24028
+ * on the live hub the same day: four identities cost 40,979 B with the
24029
+ * covers inline, ~10 KB of base64 per row, on a query this UI mounts
24030
+ * four times and the viewer holds at `staleTime: 30_000`.
24031
+ *
24032
+ * Nothing loses its avatar: `coverMediaKey` is already on every row and
24033
+ * the `event-media` plane serves that key `immutable` with an ETag.
24034
+ *
24035
+ * **This is an INPUT field, so it does not reach the addon until the
24036
+ * next train** — the hub router validates cap inputs against its own
24037
+ * compiled Zod and strips a key it does not know. Until then the
24038
+ * provider sees `undefined`, which resolves to `false`: the cheap shape
24039
+ * is what ships, and the opt-in becomes reachable when the train lands.
24040
+ */
24041
+ includeCrops: boolean().optional() }).optional(), array(IdentitySchema).readonly()), method(object({ name: string().min(1) }), IdentitySchema, {
23782
24042
  kind: "mutation",
23783
24043
  auth: "admin"
23784
24044
  }), method(object({
@@ -26668,8 +26928,10 @@ var PlateInfoSchema = object({
26668
26928
  keyFrameMediaKey: string().optional(),
26669
26929
  base64: string().optional(),
26670
26930
  /**
26671
- * Same crop as a data-plane URL. `getPlateByTrack` returns this and
26672
- * never inlines JPEG; `listPlates` still inlines for the admin-ui.
26931
+ * Same crop as a data-plane URL, always present when the plate has a stored
26932
+ * crop. `getPlateByTrack` returns this and never inlines JPEG; `listPlates`
26933
+ * and `searchPlates` inline the crop only when their `includeCrops` input is
26934
+ * left at its `true` default.
26673
26935
  */
26674
26936
  cropUrl: string().optional()
26675
26937
  });
@@ -26689,14 +26951,34 @@ var PlateClusterSchema = object({
26689
26951
  });
26690
26952
  method(object({
26691
26953
  deviceId: number().int().optional(),
26692
- limit: number().int().positive().optional()
26954
+ limit: number().int().positive().optional(),
26955
+ /**
26956
+ * Inline the base64 crop on every row. Default `true` — the existing
26957
+ * behaviour, kept so no caller breaks.
26958
+ *
26959
+ * Set `false` once the caller renders {@link PlateInfo.cropUrl}.
26960
+ * Measured on the live hub at the 500 rows the Plates view asks for:
26961
+ * 879,403 B and 27.7 s with the crops inline, against a few KiB of
26962
+ * metadata without them — and the browser then caches the images.
26963
+ *
26964
+ * This is the plate twin of `faceGallery.listRecentFaces`'s option;
26965
+ * plates were the one gallery list left without it.
26966
+ *
26967
+ * **This is an INPUT field, so it does not reach the addon until the
26968
+ * next train.** The hub router validates cap inputs against its own
26969
+ * compiled Zod and strips a key it does not know. Until the train
26970
+ * ships, sending `false` is harmless and keeps the crops inline.
26971
+ */
26972
+ includeCrops: boolean().optional()
26693
26973
  }).optional(), array(PlateInfoSchema).readonly()), method(object({
26694
26974
  deviceId: number().int(),
26695
26975
  trackId: string()
26696
26976
  }), PlateInfoSchema.nullable()), method(object({ plateId: string() }), array(MediaFileLiteSchema).readonly()), method(object({
26697
26977
  text: string().min(1),
26698
26978
  maxDistance: number().int().min(0).optional(),
26699
- limit: number().int().positive().optional()
26979
+ limit: number().int().positive().optional(),
26980
+ /** See `listPlates.includeCrops`. Default `true`. */
26981
+ includeCrops: boolean().optional()
26700
26982
  }), array(PlateInfoSchema).readonly()), method(object({
26701
26983
  maxDistance: number().int().min(0).optional(),
26702
26984
  minClusterSize: number().int().min(2).optional(),
@@ -26710,7 +26992,13 @@ method(object({
26710
26992
  }), method(object({ plateId: string() }), _void(), {
26711
26993
  kind: "mutation",
26712
26994
  auth: "admin"
26713
- }), method(_void(), array(VehicleSchema).readonly()), method(object({ name: string().min(1) }), VehicleSchema, {
26995
+ }), method(object({
26996
+ /** Inline {@link VehicleSchema.coverBase64} on every row. Default
26997
+ * `false` — the vehicle twin of `faceGallery.listIdentities`'s
26998
+ * option; `coverMediaKey` + the `event-media` plane carry the picture.
26999
+ * INPUT field: stripped by the hub router until the train ships, which
27000
+ * resolves to `false` and is exactly the intended default. */
27001
+ includeCrops: boolean().optional() }).optional(), array(VehicleSchema).readonly()), method(object({ name: string().min(1) }), VehicleSchema, {
26714
27002
  kind: "mutation",
26715
27003
  auth: "admin"
26716
27004
  }), method(object({
@@ -28231,92 +28519,6 @@ var sceneMonitorCapability = {
28231
28519
  durability: "session"
28232
28520
  };
28233
28521
  /**
28234
- * Per-stage gating mode applied to the zones a rule references.
28235
- *
28236
- * - `include`: the rule contributes to a **whitelist** for its stage.
28237
- * When at least one `include` rule fires for a stage, only entities
28238
- * inside one of those zones pass that stage.
28239
- * - `exclude`: the rule contributes to a **blacklist** for its stage.
28240
- * Entities inside one of those zones are dropped at that stage.
28241
- *
28242
- * `monitor`-style observation (count without filtering) is not a rule
28243
- * mode — zones without any matching rule are observed naturally by
28244
- * `zone-analytics` (live snapshot + history), so an "I just want to
28245
- * count, not filter" use case needs no rule at all.
28246
- */
28247
- var ZoneRuleModeEnum = _enum(["include", "exclude"]);
28248
- /**
28249
- * Per-consumer rule that references existing zones (geometry) and
28250
- * defines how a specific pipeline stage should treat them. Each
28251
- * consumer addon owns its own `ZoneRule[]` array in its per-device
28252
- * settings:
28253
- *
28254
- * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
28255
- * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
28256
- * - future: notification rules, audio gating, etc.
28257
- *
28258
- * One rule applies to N zones (`zoneIds[]`) so the operator can
28259
- * express "ignore motion in ALL of {garden, street}" with a single
28260
- * rule. `classFilter` narrows the rule to specific object classes —
28261
- * "drop person detections in the street, but keep cars" is one
28262
- * `exclude` rule with `classFilter: ['person']`.
28263
- *
28264
- * `enabled` is a soft toggle — the operator can keep the rule
28265
- * configured but inert without deleting it.
28266
- */
28267
- var ZoneRuleSchema = object({
28268
- /** Stable rule id — survives edits, used by the UI for diffing. */
28269
- id: string(),
28270
- /** Optional human-readable label rendered in the rule editor. */
28271
- name: string().optional(),
28272
- /** Zones this rule targets. The rule's `mode` applies to ALL
28273
- * listed zones (OR-set: a detection in any one of them counts).
28274
- * At least one zone id required — a rule with no targets is a
28275
- * configuration mistake and the form validator rejects it. */
28276
- zoneIds: array(string()).min(1).readonly(),
28277
- mode: ZoneRuleModeEnum,
28278
- /**
28279
- * Class names this rule applies to. Empty / undefined ⇒ rule
28280
- * applies to every class. Class strings match the `macroClass`
28281
- * field on detections (e.g. `person`, `car`, `dog`).
28282
- */
28283
- classFilter: array(string()).readonly().optional(),
28284
- /**
28285
- * Minimum bbox/mask overlap (0–1) with any of the rule's zones
28286
- * required to consider an entity "in the zone". Defaults to the
28287
- * consumer's stage default when omitted. Kept for back-compat with
28288
- * existing per-rule overrides; new operators pick the value via
28289
- * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
28290
- * set, the lower-level engine reads it as a 0–1 fraction.
28291
- */
28292
- overlapThreshold: number().min(0).max(1).optional(),
28293
- /**
28294
- * Operator-friendly version of `overlapThreshold` — the percentage
28295
- * of the detection's bbox that must lie inside the zone for the
28296
- * rule to match. Documented default is 85%; the engine substitutes
28297
- * that when the field is omitted (kept optional so existing rules
28298
- * stored without it stay valid).
28299
- *
28300
- * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
28301
- * rule, the engine prefers `bboxInclusionPct` because it's the
28302
- * field exposed in the UI. Internally both feed the same gate.
28303
- */
28304
- bboxInclusionPct: number().min(0).max(100).optional(),
28305
- /**
28306
- * When `true` and a detection has a segmentation mask, use the
28307
- * mask for overlap instead of the bbox. Detection-stage only;
28308
- * motion rules ignore this field.
28309
- */
28310
- preferMask: boolean().optional(),
28311
- /**
28312
- * Soft-toggle: `false` disables the rule without deleting it.
28313
- * Defaults to `true` so operators creating a rule via the UI
28314
- * see it active immediately.
28315
- */
28316
- enabled: boolean().default(true)
28317
- });
28318
- array(ZoneRuleSchema).readonly();
28319
- /**
28320
28522
  * Script-runner cap. Models HA `script.*` entities on
28321
28523
  * `DeviceType.Script`. A Script is a pre-recorded action sequence
28322
28524
  * that can be invoked imperatively — optionally with a variables
@@ -33971,6 +34173,12 @@ Object.freeze({
33971
34173
  addonId: null,
33972
34174
  access: "create"
33973
34175
  },
34176
+ "pipelineAnalytics.cancelRelocateMedia": {
34177
+ capName: "pipeline-analytics",
34178
+ capScope: "device",
34179
+ addonId: null,
34180
+ access: "create"
34181
+ },
33974
34182
  "pipelineAnalytics.cancelStorageMigrationMove": {
33975
34183
  capName: "pipeline-analytics",
33976
34184
  capScope: "device",
@@ -34145,6 +34353,12 @@ Object.freeze({
34145
34353
  addonId: null,
34146
34354
  access: "view"
34147
34355
  },
34356
+ "pipelineAnalytics.listRelocateMediaJobs": {
34357
+ capName: "pipeline-analytics",
34358
+ capScope: "device",
34359
+ addonId: null,
34360
+ access: "view"
34361
+ },
34148
34362
  "pipelineAnalytics.listRetrainAnnotations": {
34149
34363
  capName: "pipeline-analytics",
34150
34364
  capScope: "device",
@@ -34223,6 +34437,12 @@ Object.freeze({
34223
34437
  addonId: null,
34224
34438
  access: "create"
34225
34439
  },
34440
+ "pipelineAnalytics.relocateMedia": {
34441
+ capName: "pipeline-analytics",
34442
+ capScope: "device",
34443
+ addonId: null,
34444
+ access: "create"
34445
+ },
34226
34446
  "pipelineAnalytics.restageRetrainTrack": {
34227
34447
  capName: "pipeline-analytics",
34228
34448
  capScope: "device",
@@ -34235,6 +34455,12 @@ Object.freeze({
34235
34455
  addonId: null,
34236
34456
  access: "create"
34237
34457
  },
34458
+ "pipelineAnalytics.runReplayFrameProcessor": {
34459
+ capName: "pipeline-analytics",
34460
+ capScope: "device",
34461
+ addonId: null,
34462
+ access: "create"
34463
+ },
34238
34464
  "pipelineAnalytics.saveRetrainAnnotations": {
34239
34465
  capName: "pipeline-analytics",
34240
34466
  capScope: "device",
@@ -34367,6 +34593,12 @@ Object.freeze({
34367
34593
  addonId: null,
34368
34594
  access: "view"
34369
34595
  },
34596
+ "pipelineExecutor.getInferenceDeviceHealth": {
34597
+ capName: "pipeline-executor",
34598
+ capScope: "system",
34599
+ addonId: null,
34600
+ access: "view"
34601
+ },
34370
34602
  "pipelineExecutor.getOrchestratorConfigSchema": {
34371
34603
  capName: "pipeline-executor",
34372
34604
  capScope: "system",
@@ -34439,6 +34671,12 @@ Object.freeze({
34439
34671
  addonId: null,
34440
34672
  access: "view"
34441
34673
  },
34674
+ "pipelineExecutor.rearmInferenceDevice": {
34675
+ capName: "pipeline-executor",
34676
+ capScope: "system",
34677
+ addonId: null,
34678
+ access: "create"
34679
+ },
34442
34680
  "pipelineExecutor.runAudioTest": {
34443
34681
  capName: "pipeline-executor",
34444
34682
  capScope: "system",
@@ -37687,6 +37925,11 @@ Object.freeze({
37687
37925
  form: "single",
37688
37926
  optional: false
37689
37927
  }],
37928
+ "pipelineAnalytics.runReplayFrameProcessor": [{
37929
+ name: "deviceId",
37930
+ form: "single",
37931
+ optional: false
37932
+ }],
37690
37933
  "pipelineAnalytics.saveRetrainAnnotations": [{
37691
37934
  name: "deviceId",
37692
37935
  form: "single",