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