@camstack/addon-pipeline 1.2.129 → 1.2.131

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 (123) hide show
  1. package/dist/{addon-utils-CKB-2oM9.js → addon-utils-DCQ5AP_v.js} +1 -1
  2. package/dist/audio-analyzer/index.js +3 -3
  3. package/dist/audio-analyzer/index.mjs +2 -2
  4. package/dist/detection-pipeline/index.js +332 -20
  5. package/dist/detection-pipeline/index.mjs +330 -18
  6. package/dist/{dist-D9x2_csL.js → dist-CqoMNE1e.js} +2010 -1753
  7. package/dist/{dist-CMio-1qq.mjs → dist-DO0UVhOk.mjs} +2010 -1753
  8. package/dist/{event-loop-stall-monitor-B9dxYxyf.mjs → event-loop-stall-monitor-D0Juf7Dn.mjs} +1 -1
  9. package/dist/{event-loop-stall-monitor-UW8nsiMb.js → event-loop-stall-monitor-eM7_yYfn.js} +1 -1
  10. package/dist/{lazy-sharp-DrLwLKpg.js → lazy-sharp-BGrpS8yi.js} +1 -1
  11. package/dist/motion-wasm/index.js +2 -2
  12. package/dist/motion-wasm/index.mjs +1 -1
  13. package/dist/pipeline-runner/index.js +4 -4
  14. package/dist/pipeline-runner/index.mjs +3 -3
  15. package/dist/{process-memory-C6es8dMA.mjs → process-memory-Bac3FuG6.mjs} +1 -1
  16. package/dist/{process-memory-CSJ7-Wlp.js → process-memory-xAPjvSw9.js} +1 -1
  17. package/dist/recorder/index.js +560 -31
  18. package/dist/recorder/index.mjs +558 -30
  19. package/dist/{segment-demux-js-DiLDoV9_.js → segment-demux-js-Cu0oDMUL.js} +1 -1
  20. package/dist/{segment-demux-js-BRCjXbI0.mjs → segment-demux-js-skhsAZx6.mjs} +1 -1
  21. package/dist/session-decode/decode-worker-child.js +2 -2
  22. package/dist/session-decode/decode-worker-child.mjs +1 -1
  23. package/dist/stream-broker/_stub.js +2 -2
  24. package/dist/stream-broker/{_virtual_mf-localSharedImportMap___mfe_internal__addon_stream_broker_widgets-1O99xPTr.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_stream_broker_widgets-DGQkDEYw.mjs} +3 -3
  25. package/dist/stream-broker/_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-Bme2OZQp.mjs +26 -0
  26. package/dist/stream-broker/{_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-Do2DEtRt.mjs → _virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-CQKwHIHI.mjs} +1 -1
  27. package/dist/stream-broker/demux-worker-child.js +1 -1
  28. package/dist/stream-broker/demux-worker-child.mjs +1 -1
  29. package/dist/stream-broker/{hostInit-8scvCWua.mjs → hostInit-D7FwwZgj.mjs} +3 -3
  30. package/dist/stream-broker/index.js +426 -319
  31. package/dist/stream-broker/index.mjs +426 -319
  32. package/dist/stream-broker/remoteEntry.js +1 -1
  33. package/dist/{worker-protocol-BmBYCioC.js → worker-protocol-G3HXTY8z.js} +1 -1
  34. package/dist/{worker-protocol-BHNWB9Ve.mjs → worker-protocol-_Ujvj1hl.mjs} +1 -1
  35. package/package.json +1 -1
  36. package/python/__pycache__/inference_pool.cpython-312.pyc +0 -0
  37. package/python/__pycache__/inference_pool.cpython-313.pyc +0 -0
  38. package/python/__pycache__/inference_pool.cpython-314.pyc +0 -0
  39. package/python/__pycache__/test_inference_pool_backpressure.cpython-312-pytest-9.1.1.pyc +0 -0
  40. package/python/__pycache__/test_inference_pool_backpressure.cpython-312.pyc +0 -0
  41. package/python/__pycache__/test_inference_pool_backpressure.cpython-314.pyc +0 -0
  42. package/python/__pycache__/test_inference_pool_coreml_cache.cpython-312-pytest-9.1.1.pyc +0 -0
  43. package/python/__pycache__/test_inference_pool_coreml_cache.cpython-312.pyc +0 -0
  44. package/python/__pycache__/test_inference_pool_coreml_cache.cpython-314.pyc +0 -0
  45. package/python/__pycache__/test_inference_pool_device_selection.cpython-312-pytest-9.1.1.pyc +0 -0
  46. package/python/__pycache__/test_inference_pool_device_selection.cpython-312.pyc +0 -0
  47. package/python/__pycache__/test_inference_pool_device_selection.cpython-314.pyc +0 -0
  48. package/python/__pycache__/test_inference_pool_layout.cpython-312-pytest-9.1.1.pyc +0 -0
  49. package/python/__pycache__/test_inference_pool_layout.cpython-314.pyc +0 -0
  50. package/python/__pycache__/test_inference_pool_memstats.cpython-312-pytest-9.1.1.pyc +0 -0
  51. package/python/__pycache__/test_inference_pool_memstats.cpython-312.pyc +0 -0
  52. package/python/__pycache__/test_inference_pool_memstats.cpython-314.pyc +0 -0
  53. package/python/__pycache__/test_inference_pool_ov_ppp.cpython-312-pytest-9.1.1.pyc +0 -0
  54. package/python/__pycache__/test_inference_pool_ov_ppp.cpython-312.pyc +0 -0
  55. package/python/__pycache__/test_inference_pool_ov_ppp.cpython-314.pyc +0 -0
  56. package/python/__pycache__/test_inference_pool_preprocess.cpython-312-pytest-9.1.1.pyc +0 -0
  57. package/python/__pycache__/test_inference_pool_preprocess.cpython-314.pyc +0 -0
  58. package/python/__pycache__/test_inference_pool_reconfigure.cpython-314.pyc +0 -0
  59. package/python/__pycache__/test_inference_pool_static_batch.cpython-312-pytest-9.1.1.pyc +0 -0
  60. package/python/__pycache__/test_inference_pool_static_batch.cpython-312.pyc +0 -0
  61. package/python/__pycache__/test_inference_pool_static_batch.cpython-314.pyc +0 -0
  62. package/python/__pycache__/yamnet_audio.cpython-314.pyc +0 -0
  63. package/python/postprocessors/__pycache__/__init__.cpython-312.pyc +0 -0
  64. package/python/postprocessors/__pycache__/__init__.cpython-313.pyc +0 -0
  65. package/python/postprocessors/__pycache__/__init__.cpython-314.pyc +0 -0
  66. package/python/postprocessors/__pycache__/_safety.cpython-313.pyc +0 -0
  67. package/python/postprocessors/__pycache__/arcface.cpython-312.pyc +0 -0
  68. package/python/postprocessors/__pycache__/arcface.cpython-313.pyc +0 -0
  69. package/python/postprocessors/__pycache__/arcface.cpython-314.pyc +0 -0
  70. package/python/postprocessors/__pycache__/clip.cpython-312.pyc +0 -0
  71. package/python/postprocessors/__pycache__/clip.cpython-313.pyc +0 -0
  72. package/python/postprocessors/__pycache__/clip.cpython-314.pyc +0 -0
  73. package/python/postprocessors/__pycache__/ctc.cpython-312.pyc +0 -0
  74. package/python/postprocessors/__pycache__/ctc.cpython-313.pyc +0 -0
  75. package/python/postprocessors/__pycache__/ctc.cpython-314.pyc +0 -0
  76. package/python/postprocessors/__pycache__/plate_slots.cpython-312.pyc +0 -0
  77. package/python/postprocessors/__pycache__/plate_slots.cpython-314.pyc +0 -0
  78. package/python/postprocessors/__pycache__/rfdetr.cpython-312.pyc +0 -0
  79. package/python/postprocessors/__pycache__/rfdetr.cpython-314.pyc +0 -0
  80. package/python/postprocessors/__pycache__/saliency.cpython-312.pyc +0 -0
  81. package/python/postprocessors/__pycache__/saliency.cpython-313.pyc +0 -0
  82. package/python/postprocessors/__pycache__/saliency.cpython-314.pyc +0 -0
  83. package/python/postprocessors/__pycache__/scrfd.cpython-312.pyc +0 -0
  84. package/python/postprocessors/__pycache__/scrfd.cpython-313.pyc +0 -0
  85. package/python/postprocessors/__pycache__/scrfd.cpython-314.pyc +0 -0
  86. package/python/postprocessors/__pycache__/softmax.cpython-312.pyc +0 -0
  87. package/python/postprocessors/__pycache__/softmax.cpython-313.pyc +0 -0
  88. package/python/postprocessors/__pycache__/softmax.cpython-314.pyc +0 -0
  89. package/python/postprocessors/__pycache__/ssd.cpython-312.pyc +0 -0
  90. package/python/postprocessors/__pycache__/ssd.cpython-313.pyc +0 -0
  91. package/python/postprocessors/__pycache__/ssd.cpython-314.pyc +0 -0
  92. package/python/postprocessors/__pycache__/test_clip.cpython-312-pytest-9.1.1.pyc +0 -0
  93. package/python/postprocessors/__pycache__/test_clip.cpython-313-pytest-9.1.1.pyc +0 -0
  94. package/python/postprocessors/__pycache__/test_ctc.cpython-312-pytest-9.1.1.pyc +0 -0
  95. package/python/postprocessors/__pycache__/test_ctc.cpython-312.pyc +0 -0
  96. package/python/postprocessors/__pycache__/test_ctc.cpython-313-pytest-9.1.1.pyc +0 -0
  97. package/python/postprocessors/__pycache__/test_ctc.cpython-313.pyc +0 -0
  98. package/python/postprocessors/__pycache__/test_ctc.cpython-314.pyc +0 -0
  99. package/python/postprocessors/__pycache__/test_plate_slots.cpython-312-pytest-9.1.1.pyc +0 -0
  100. package/python/postprocessors/__pycache__/test_rfdetr.cpython-312-pytest-9.1.1.pyc +0 -0
  101. package/python/postprocessors/__pycache__/test_rfdetr.cpython-314.pyc +0 -0
  102. package/python/postprocessors/__pycache__/test_saliency.cpython-312-pytest-9.1.1.pyc +0 -0
  103. package/python/postprocessors/__pycache__/test_saliency.cpython-313-pytest-9.1.1.pyc +0 -0
  104. package/python/postprocessors/__pycache__/test_saliency.cpython-314.pyc +0 -0
  105. package/python/postprocessors/__pycache__/test_softmax.cpython-312-pytest-9.1.1.pyc +0 -0
  106. package/python/postprocessors/__pycache__/test_softmax.cpython-314.pyc +0 -0
  107. package/python/postprocessors/__pycache__/test_yolo_nms.cpython-312-pytest-9.1.1.pyc +0 -0
  108. package/python/postprocessors/__pycache__/test_yolo_nms.cpython-314.pyc +0 -0
  109. package/python/postprocessors/__pycache__/test_yolo_nms.cpython-39.pyc +0 -0
  110. package/python/postprocessors/__pycache__/test_yolonas.cpython-312-pytest-9.1.1.pyc +0 -0
  111. package/python/postprocessors/__pycache__/yamnet.cpython-312.pyc +0 -0
  112. package/python/postprocessors/__pycache__/yamnet.cpython-313.pyc +0 -0
  113. package/python/postprocessors/__pycache__/yamnet.cpython-314.pyc +0 -0
  114. package/python/postprocessors/__pycache__/yolo.cpython-312.pyc +0 -0
  115. package/python/postprocessors/__pycache__/yolo.cpython-313.pyc +0 -0
  116. package/python/postprocessors/__pycache__/yolo.cpython-314.pyc +0 -0
  117. package/python/postprocessors/__pycache__/yolo.cpython-39.pyc +0 -0
  118. package/python/postprocessors/__pycache__/yolo_seg.cpython-312.pyc +0 -0
  119. package/python/postprocessors/__pycache__/yolo_seg.cpython-313.pyc +0 -0
  120. package/python/postprocessors/__pycache__/yolo_seg.cpython-314.pyc +0 -0
  121. package/python/postprocessors/__pycache__/yolonas.cpython-312.pyc +0 -0
  122. package/python/postprocessors/__pycache__/yolonas.cpython-314.pyc +0 -0
  123. package/dist/stream-broker/_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-CxppPmXr.mjs +0 -26
@@ -6769,7 +6769,7 @@ function method(input, output, options) {
6769
6769
  input,
6770
6770
  output,
6771
6771
  kind: options?.kind ?? "query",
6772
- auth: options?.auth ?? "protected",
6772
+ ...options?.auth !== void 0 ? { auth: options.auth } : {},
6773
6773
  ...options?.access !== void 0 ? { access: options.access } : {},
6774
6774
  ...options?.caller !== void 0 ? { caller: options.caller } : {},
6775
6775
  timeoutMs: options?.timeoutMs
@@ -6793,7 +6793,7 @@ function event(data) {
6793
6793
  }
6794
6794
  var StaticDirOutputSchema$1 = object({ staticDir: string() });
6795
6795
  var VersionOutputSchema$1 = object({ version: string() });
6796
- method(_void(), StaticDirOutputSchema$1), method(_void(), VersionOutputSchema$1);
6796
+ method(_void(), StaticDirOutputSchema$1, { auth: "admin" }), method(_void(), VersionOutputSchema$1, { auth: "admin" });
6797
6797
  var DeviceType = /* @__PURE__ */ function(DeviceType) {
6798
6798
  DeviceType["Camera"] = "camera";
6799
6799
  DeviceType["Hub"] = "hub";
@@ -7114,7 +7114,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
7114
7114
  }({});
7115
7115
  var StaticDirOutputSchema = object({ staticDir: string() });
7116
7116
  var VersionOutputSchema = object({ version: string() });
7117
- method(_void(), StaticDirOutputSchema), method(_void(), VersionOutputSchema);
7117
+ method(_void(), StaticDirOutputSchema, { auth: "admin" }), method(_void(), VersionOutputSchema, { auth: "admin" });
7118
7118
  /**
7119
7119
  * device-ops — device-scoped cap that unifies the per-IDevice operations
7120
7120
  * previously routed through the `.device-ops` Moleculer bridge service.
@@ -8749,10 +8749,11 @@ var RelocateFootageInputSchema = object({
8749
8749
  * `RecordingConfig.enabled` or camera wrapper bindings. */
8750
8750
  var StorageMigrationLeaseInputSchema = object({ leaseId: string().min(1) });
8751
8751
  var StorageMigrationFootageMoveInputSchema = RelocateFootageInputSchema.extend({ leaseId: string().min(1) });
8752
- var StorageMigrationMediaMoveInputSchema = object({
8752
+ var RelocateMediaInputSchema = object({
8753
8753
  toLocationId: string(),
8754
8754
  throttleMbps: number().min(1).max(1e3).optional()
8755
- }).extend({ leaseId: string().min(1) });
8755
+ });
8756
+ var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
8756
8757
  /** The independently selectable logical storage classes. `recordings`
8757
8758
  * encompasses the high and mid segment profiles; `recordingsLow` is low
8758
8759
  * segments; `eventMedia` is post-analysis blobs. */
@@ -9047,7 +9048,26 @@ var LabelDefinitionSchema = object({
9047
9048
  description: string().optional(),
9048
9049
  icon: string().optional()
9049
9050
  });
9050
- var ClassMapDefinitionSchema = object({
9051
+ /**
9052
+ * Wire schema for a per-model CATALOG classMap override
9053
+ * (`ModelCatalogEntry.classMap` / `ModelConvertMetadata.classMap`) —
9054
+ * restricted to {@link CLASS_MAP_MACRO_TARGETS}, the only macros the
9055
+ * detection pipeline executor actually routes.
9056
+ *
9057
+ * This is deliberately a DIFFERENT, narrower shape than the general-purpose
9058
+ * `ClassMapDefinition` interface above (e.g. `IDetectionAddon.getClassMap()`
9059
+ * and the audio `YAMNET_TO_MACRO` catalog both use macro targets outside this
9060
+ * enum) — the two used to share the name `ClassMapDefinition`/
9061
+ * `ClassMapDefinitionSchema`, which made the schema-type-twin guard
9062
+ * (`scripts/check-schema-type-twins.ts`) flag them as a duplicated shape. They
9063
+ * are not: it is two different concepts colliding on a name. Keep this type
9064
+ * under its own name rather than reusing `ClassMapDefinition` — reusing it
9065
+ * would either narrow every `ClassMapDefinition` consumer to the four
9066
+ * detection macros (breaking `YAMNET_TO_MACRO`) or drop the validation this
9067
+ * schema exists for (see the "rejects a classMap whose target is not a
9068
+ * detection macro" test in `model-catalog-schema.test.ts`).
9069
+ */
9070
+ var DetectionCatalogClassMapSchema = object({
9051
9071
  mapping: record(string(), _enum([
9052
9072
  "person",
9053
9073
  "vehicle",
@@ -9265,7 +9285,7 @@ var ModelCatalogEntrySchema = object({
9265
9285
  * applies (Frigate / COCO public catalog). Set on a custom model whose raw
9266
9286
  * labels already ARE the CamStack macros (Scrypted identity map).
9267
9287
  */
9268
- classMap: ClassMapDefinitionSchema.optional()
9288
+ classMap: DetectionCatalogClassMapSchema.optional()
9269
9289
  });
9270
9290
  var ConvertTargetSchema = discriminatedUnion("format", [object({
9271
9291
  format: literal("openvino"),
@@ -9295,7 +9315,7 @@ var ModelConvertMetadataSchema = object({
9295
9315
  "segmentation"
9296
9316
  ]),
9297
9317
  faceAlignment: boolean().optional(),
9298
- classMap: ClassMapDefinitionSchema.optional()
9318
+ classMap: DetectionCatalogClassMapSchema.optional()
9299
9319
  });
9300
9320
  var ConvertResultSchema = object({
9301
9321
  entry: ModelCatalogEntrySchema,
@@ -10158,7 +10178,7 @@ var AddonPageDeclarationSchema = object({
10158
10178
  /** Display label for a CUSTOM `section` id (ignored for well-known ids). */
10159
10179
  sectionLabel: string().optional()
10160
10180
  });
10161
- method(_void(), array(AddonPageDeclarationSchema).readonly());
10181
+ method(_void(), array(AddonPageDeclarationSchema).readonly(), { auth: "admin" });
10162
10182
  var AddonHttpRouteSchema = object({
10163
10183
  method: _enum([
10164
10184
  "GET",
@@ -10398,7 +10418,20 @@ var addonWidgetsSourceCapability = {
10398
10418
  scope: "system",
10399
10419
  mode: "collection",
10400
10420
  internal: true,
10401
- methods: { listWidgets: method(_void(), array(WidgetMetadataSchema).readonly()) }
10421
+ methods: {
10422
+ /**
10423
+ * `internal: true` did not gate the mount (see the 2026-08-26 note on
10424
+ * `data-store-provider`) — this was reachable on the AppRouter by ANY
10425
+ * authenticated session at the default `auth: 'protected'`. The only
10426
+ * consumer, the `addon-widgets-aggregator` builtin, reads it via
10427
+ * `ctx.capabilities.getCollection('addon-widgets-source')` — LOCAL-PROCESS
10428
+ * only, never tRPC. The public, enriched listing admin-ui actually
10429
+ * consumes is the separate `addon-widgets` cap (`listWidgets` there is
10430
+ * gated separately, and a `preAuth: true` widget is surfaced through the
10431
+ * PUBLIC `auth.listLoginMethods` contribution channel instead) —
10432
+ * neither is affected by this change.
10433
+ */
10434
+ listWidgets: method(_void(), array(WidgetMetadataSchema).readonly(), { auth: "admin" }) }
10402
10435
  };
10403
10436
  /**
10404
10437
  * `addon-widgets` — system-scoped singleton aggregator cap. Public-facing
@@ -12334,7 +12367,7 @@ var CustomModelDescriptorSchema = object({
12334
12367
  stepId: string(),
12335
12368
  entry: ModelCatalogEntrySchema
12336
12369
  });
12337
- method(_void(), array(CustomModelDescriptorSchema).readonly());
12370
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
12338
12371
  /**
12339
12372
  * Query filter for settings-store collections.
12340
12373
  */
@@ -12485,56 +12518,87 @@ var EngineInfoSchema = object({
12485
12518
  kind: _enum(["relational", "vector"]),
12486
12519
  displayName: string()
12487
12520
  });
12488
- method(_void(), EngineInfoSchema), method(object({
12521
+ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
12489
12522
  namespace: string().optional(),
12490
12523
  collection: string(),
12491
12524
  key: string()
12492
- }), unknown()), method(object({
12525
+ }), unknown(), { auth: "admin" }), method(object({
12493
12526
  namespace: string().optional(),
12494
12527
  collection: string(),
12495
12528
  key: string(),
12496
12529
  value: unknown()
12497
- }), _void(), { kind: "mutation" }), method(object({
12530
+ }), _void(), {
12531
+ kind: "mutation",
12532
+ auth: "admin"
12533
+ }), method(object({
12498
12534
  namespace: string().optional(),
12499
12535
  collection: string(),
12500
12536
  filter: QueryFilterSchema.optional(),
12501
12537
  /**
12502
12538
  * SQL-level column projection — MUST mirror `settings-store.query`.
12503
12539
  *
12504
- * This is the second schema the same call passes through, and Zod
12505
- * objects STRIP what they do not declare: a field present on the door
12506
- * and absent here does not error, it silently disappears one hop before
12507
- * the engine, and the caller concludes the projection does nothing.
12508
- * `data-door-schema-parity.spec.ts` is what keeps the two in step.
12540
+ * An earlier version of this comment blamed Zod stripping, and that
12541
+ * was wrong corrected 2026-08-26 after the hop map
12542
+ * (`docs/design/2026-08-26-mappa-hop-argomenti.md`) traced the path.
12543
+ * There is **no Zod parse at all** between the door and the engine: the
12544
+ * dispatcher forwards the payload verbatim and UDS carries it whole. A
12545
+ * field declared here reaches `SqliteSettingsBackend` either way.
12546
+ *
12547
+ * What actually lost `columns` was the THIRD declaration of this shape:
12548
+ * `SettingsQueryInput` in `interfaces/storage.ts`, a hand-written TS
12549
+ * interface the engine destructures from. The field existed on both
12550
+ * schemas and the engine still never read it, because nothing checks a
12551
+ * registered provider against `InferProvider<cap>` —
12552
+ * `ProviderRegistration.provider` is typed `object`.
12553
+ *
12554
+ * It is declared here anyway, and must stay in step with
12555
+ * `settings-store.query`: a caller reading only the cap definitions has
12556
+ * to be able to see that this call carries a projection.
12557
+ * `data-door-schema-parity.spec.ts` keeps the two aligned.
12509
12558
  */
12510
12559
  columns: array(string()).readonly().optional()
12511
- }), array(SettingsRecordSchema).readonly()), method(object({
12560
+ }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
12512
12561
  namespace: string().optional(),
12513
12562
  collection: string(),
12514
12563
  record: SettingsRecordSchema
12515
- }), _void(), { kind: "mutation" }), method(object({
12564
+ }), _void(), {
12565
+ kind: "mutation",
12566
+ auth: "admin"
12567
+ }), method(object({
12516
12568
  namespace: string().optional(),
12517
12569
  collection: string(),
12518
12570
  id: string(),
12519
12571
  data: record(string(), unknown())
12520
- }), _void(), { kind: "mutation" }), method(object({
12572
+ }), _void(), {
12573
+ kind: "mutation",
12574
+ auth: "admin"
12575
+ }), method(object({
12521
12576
  namespace: string().optional(),
12522
12577
  collection: string(),
12523
12578
  key: string()
12524
- }), _void(), { kind: "mutation" }), method(object({
12579
+ }), _void(), {
12580
+ kind: "mutation",
12581
+ auth: "admin"
12582
+ }), method(object({
12525
12583
  namespace: string().optional(),
12526
12584
  collection: string(),
12527
12585
  filter: MutationFilterSchema
12528
- }), object({ deleted: number().int() }), { kind: "mutation" }), method(object({
12586
+ }), object({ deleted: number().int() }), {
12587
+ kind: "mutation",
12588
+ auth: "admin"
12589
+ }), method(object({
12529
12590
  namespace: string().optional(),
12530
12591
  collection: string(),
12531
12592
  filter: MutationFilterSchema,
12532
12593
  data: record(string(), unknown())
12533
- }), object({ updated: number().int() }), { kind: "mutation" }), method(object({
12594
+ }), object({ updated: number().int() }), {
12595
+ kind: "mutation",
12596
+ auth: "admin"
12597
+ }), method(object({
12534
12598
  namespace: string().optional(),
12535
12599
  collection: string(),
12536
12600
  filter: QueryFilterSchema.optional()
12537
- }), number()), method(object({
12601
+ }), number(), { auth: "admin" }), method(object({
12538
12602
  namespace: string().optional(),
12539
12603
  collection: string(),
12540
12604
  field: string(),
@@ -12544,15 +12608,18 @@ method(_void(), EngineInfoSchema), method(object({
12544
12608
  }), array(object({
12545
12609
  bucket: number().int(),
12546
12610
  count: number().int()
12547
- })).readonly()), method(object({
12611
+ })).readonly(), { auth: "admin" }), method(object({
12548
12612
  namespace: string().optional(),
12549
12613
  collection: string()
12550
- }), boolean()), method(object({
12614
+ }), boolean(), { auth: "admin" }), method(object({
12551
12615
  namespace: string().optional(),
12552
12616
  collection: string(),
12553
12617
  columns: array(CollectionColumnSchema).readonly(),
12554
12618
  indexes: array(CollectionIndexSchema).readonly().optional()
12555
- }), _void(), { kind: "mutation" });
12619
+ }), _void(), {
12620
+ kind: "mutation",
12621
+ auth: "admin"
12622
+ });
12556
12623
  /**
12557
12624
  * shm ring usage stats for a `frameSink: 'shm'` decoder session —
12558
12625
  * exposed via `decoder.getShmStats` so downstream consumers can
@@ -13711,7 +13778,7 @@ method(object({
13711
13778
  crop: _instanceof(Uint8Array),
13712
13779
  width: number(),
13713
13780
  height: number()
13714
- }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
13781
+ }), EmbeddingResultSchema, { auth: "admin" }), method(object({ text: string() }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" });
13715
13782
  /**
13716
13783
  * filesystem-browse — per-node capability for browsing the node's local
13717
13784
  * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
@@ -14004,19 +14071,22 @@ method(LlmGenerateBaseInputSchema.extend({
14004
14071
  runtime: ManagedRuntimeConfigSchema,
14005
14072
  /** The managed profile's timeout, threaded by the hub provider. */
14006
14073
  timeoutMs: number().int().positive().optional()
14007
- }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
14074
+ }), LlmGenerateResultSchema, {
14075
+ kind: "mutation",
14076
+ auth: "admin"
14077
+ }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
14008
14078
  kind: "mutation",
14009
14079
  auth: "admin"
14010
14080
  }), method(object({}), _void(), {
14011
14081
  kind: "mutation",
14012
14082
  auth: "admin"
14013
- }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
14083
+ }), method(object({}), LlmRuntimeStatusSchema, { auth: "admin" }), method(object({ model: ManagedModelRefSchema }), _void(), {
14014
14084
  kind: "mutation",
14015
14085
  auth: "admin"
14016
14086
  }), method(object({ file: string() }), _void(), {
14017
14087
  kind: "mutation",
14018
14088
  auth: "admin"
14019
- }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
14089
+ }), method(object({}), array(LlmNodeModelSchema), { auth: "admin" }), method(object({}), LlmRuntimeDiskUsageSchema, { auth: "admin" });
14020
14090
  /**
14021
14091
  * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
14022
14092
  * methods concat-fan across providers; single-row methods route to ONE
@@ -17832,1584 +17902,275 @@ var OauthIntegrationDescriptorSchema = object({
17832
17902
  */
17833
17903
  refreshTokenTtlSec: union([number().int().positive(), literal("never")]).optional()
17834
17904
  });
17835
- method(_void(), OauthIntegrationDescriptorSchema);
17905
+ method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
17836
17906
  /**
17837
- * pipeline-analytics device-scoped wrapper cap. Refines raw
17838
- * per-frame detections emitted by the pipeline runner into tracked
17839
- * objects, per-kind event collections (motion / object / audio), and
17840
- * persisted media. Owns the post-detection domain end-to-end:
17841
- *
17842
- * runner emits PipelineInferenceResult
17843
- * ↓ (event bus)
17844
- * pipeline-analytics subscriber
17845
- * ↓ SORT tracker + zone engine + state analyzer + event emitter
17846
- * → three DB collections (one per kind), one FS media tree, one
17847
- * unified event emitter (FrameTracked + TrackStarted/Ended +
17848
- * DetectionEvent on bus)
17849
- *
17850
- * Pure subscriber model. No `processFrame` cap method — the runner
17851
- * already publishes the raw frame on the bus. The cap surface is
17852
- * only QUERIES + per-device settings, bound on/off via
17853
- * `device-manager.setWrapperActive`. `defaultActive: true` because
17854
- * every camera with a detection pipeline wants its raw detections
17855
- * refined; operators opt out per-device via BindingsTab when needed.
17856
- *
17857
- * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
17858
- * (per-device surface) and `track-trail` caps — see P11 cleanup.
17907
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
17908
+ * within the frame, so the executor can re-cut a leaf child ROI at native
17909
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
17859
17910
  */
17860
- var TrackStateSchema = _enum([
17861
- "new",
17862
- "entered",
17863
- "left",
17864
- "moving",
17865
- "idle"
17866
- ]);
17867
- var EventKindSchema = _enum([
17868
- "motion",
17869
- "object",
17870
- "audio"
17871
- ]);
17911
+ var NativeCropRefSchema = object({
17912
+ /** Handle keying the retained native surface (node-pinned to its owner). */
17913
+ handle: FrameHandleSchema,
17914
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
17915
+ cropFrameSpace: object({
17916
+ x: number(),
17917
+ y: number(),
17918
+ w: number(),
17919
+ h: number()
17920
+ })
17921
+ });
17922
+ object({
17923
+ crop: object({
17924
+ left: number(),
17925
+ top: number(),
17926
+ width: number().positive(),
17927
+ height: number().positive()
17928
+ }).optional(),
17929
+ content: object({
17930
+ width: number().int().positive(),
17931
+ height: number().int().positive()
17932
+ }),
17933
+ fit: _enum(["stretch", "contain"]),
17934
+ format: _enum([
17935
+ "rgb",
17936
+ "gray",
17937
+ "jpeg"
17938
+ ])
17939
+ });
17872
17940
  /**
17873
- * Spatial filter for `listTracks` the rect + polygon variants of the shared
17874
- * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
17875
- * of the camera frame (top-left origin), matching the drawing-plane editor.
17941
+ * Process-local frame identity. It is serializable so it can ride an in-process
17942
+ * capability call, but `registryId` deliberately prevents resolution in any
17943
+ * other process or execution group.
17876
17944
  */
17877
- var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
17878
- /** Closed icon vocabulary so clients render a known glyph per kind. */
17879
- var EventKindIconSchema = _enum([
17880
- "motion",
17881
- "audio",
17882
- "person",
17883
- "vehicle",
17884
- "animal",
17885
- "door",
17886
- "pir",
17887
- "smoke",
17888
- "water",
17889
- "button",
17890
- "package",
17891
- "generic"
17945
+ var FrameRefSchema = object({
17946
+ registryId: string().min(1),
17947
+ id: string().min(1),
17948
+ width: number().int().positive(),
17949
+ height: number().int().positive(),
17950
+ format: _enum(["rgb", "gray"]),
17951
+ timestamp: number(),
17952
+ capturedAt: number().optional()
17953
+ });
17954
+ var ModelFormatSchema$1 = _enum([
17955
+ "onnx",
17956
+ "coreml",
17957
+ "openvino",
17958
+ "tflite",
17959
+ "pt",
17960
+ "gguf"
17892
17961
  ]);
17893
- var EventKindCategorySchema = _enum([
17894
- "motion",
17895
- "audio",
17896
- "detection",
17897
- "sensor",
17898
- "control",
17899
- "custom",
17900
- "package"
17962
+ var PipelineSlotSchema = _enum([
17963
+ "detector",
17964
+ "cropper",
17965
+ "classifier",
17966
+ "refiner",
17967
+ "audio-classifier"
17901
17968
  ]);
17902
- /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
17903
- var EventKindLevelSchema = _enum(["macro", "sub"]);
17904
- var EventKindDescriptorSchema = object({
17905
- /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
17906
- kind: string(),
17907
- /** i18n key resolved on the UI side; `label` is the English fallback. */
17908
- labelKey: string(),
17909
- /** English fallback label (kept for clients that don't translate). */
17910
- label: string(),
17911
- /** Hex color for timeline/legend rendering. */
17912
- color: string(),
17913
- /** Dictionary id → lucide component on the UI side. */
17914
- iconId: string(),
17915
- /** Legacy closed-vocab glyph — fallback for `iconId`. */
17916
- icon: EventKindIconSchema,
17917
- category: EventKindCategorySchema,
17918
- /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
17919
- parentKind: string().nullable(),
17920
- /** Derived from `parentKind`, explicit for the client tree. */
17921
- level: EventKindLevelSchema,
17922
- /** Which cap + device contributes this kind. For built-ins the camera
17923
- * itself; for sensor kinds the LINKED source device. */
17924
- source: object({
17925
- capName: string(),
17926
- deviceId: number()
17927
- })
17969
+ var PipelineEngineChoiceSchema = object({
17970
+ runtime: _enum(["node", "python"]),
17971
+ backend: string(),
17972
+ format: ModelFormatSchema$1,
17973
+ device: string().optional()
17928
17974
  });
17929
- /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
17930
- var EventKindsForDeviceSchema = object({
17931
- deviceId: number(),
17932
- kinds: array(EventKindDescriptorSchema).readonly()
17975
+ var AvailableEngineSchema = object({
17976
+ engine: PipelineEngineChoiceSchema,
17977
+ devices: array(object({
17978
+ id: string(),
17979
+ label: string(),
17980
+ description: string().optional()
17981
+ })).readonly(),
17982
+ defaultDevice: string()
17933
17983
  });
17934
- var SensorEventSchema = object({
17984
+ var PipelineDefaultStepSchema = lazy(() => object({
17985
+ addonId: string(),
17986
+ addonName: string(),
17987
+ slot: PipelineSlotSchema,
17988
+ inputClasses: array(string()).readonly(),
17989
+ outputClasses: array(string()).readonly(),
17990
+ enabled: boolean(),
17991
+ modelId: string(),
17992
+ children: array(PipelineDefaultStepSchema).readonly(),
17993
+ group: string().optional(),
17994
+ settings: record(string(), unknown()).optional()
17995
+ }));
17996
+ var PipelineTemplateStepSchema = lazy(() => object({
17997
+ addonId: string(),
17998
+ enabled: boolean(),
17999
+ modelId: string(),
18000
+ children: array(PipelineTemplateStepSchema).readonly(),
18001
+ settings: record(string(), unknown()).optional()
18002
+ }));
18003
+ var PipelineTemplateSchema$1 = object({
17935
18004
  id: string(),
17936
- /** The CAMERA the event is attributed to (a sensor linked to N cameras
17937
- * yields N rows, one per camera). */
17938
- deviceId: number(),
17939
- /** The linked sensor device whose state changed. */
17940
- sourceDeviceId: number(),
17941
- /** Event kind id — matches an `EventKindDescriptor.kind`. */
17942
- kind: string(),
17943
- /** Snapshot of the sensor cap's runtime-state slice at the change. */
17944
- value: record(string(), unknown()).nullable(),
17945
- timestamp: number()
18005
+ name: string(),
18006
+ createdAt: string(),
18007
+ updatedAt: string(),
18008
+ engine: PipelineEngineChoiceSchema,
18009
+ steps: array(PipelineTemplateStepSchema).readonly()
17946
18010
  });
17947
- var TrackPositionSchema = object({
17948
- x: number(),
17949
- y: number(),
17950
- timestamp: number(),
17951
- bbox: BoundingBoxSchema
18011
+ var PipelineModelOptionSchema = object({
18012
+ id: string(),
18013
+ name: string(),
18014
+ formats: record(string(), object({
18015
+ downloaded: boolean(),
18016
+ sizeMB: number()
18017
+ })),
18018
+ group: ModelVariantGroupSchema.optional(),
18019
+ legacy: boolean().optional(),
18020
+ provider: ModelProviderIdSchema.optional()
17952
18021
  });
17953
- var TrackSnapshotSchema = object({
17954
- timestamp: number(),
17955
- position: TrackPositionSchema,
17956
- /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
17957
- mediaKey: string()
17958
- });
17959
- /**
17960
- * Normalized 0..1 trajectory envelope (min/max over every position bbox,
17961
- * divided by the track's detection-frame dims), computed at persist time.
17962
- * Absent when the frame dims were unknown when the track was persisted
17963
- * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
17964
- */
17965
- var TrackEnvelopeSchema = object({
17966
- minX: number(),
17967
- minY: number(),
17968
- maxX: number(),
17969
- maxY: number()
18022
+ var ConfigFieldBridge = custom();
18023
+ var PipelineAddonSchemaSchema = object({
18024
+ id: string(),
18025
+ name: string(),
18026
+ slot: PipelineSlotSchema,
18027
+ inputClasses: array(string()).readonly(),
18028
+ outputClasses: array(string()).readonly(),
18029
+ childSlots: array(PipelineSlotSchema).readonly(),
18030
+ models: array(PipelineModelOptionSchema).readonly(),
18031
+ defaultModelId: string(),
18032
+ defaultModelIdByFormat: record(string(), string()).optional(),
18033
+ enabledByDefault: boolean().optional(),
18034
+ backfillIntoExistingOverrides: boolean().optional(),
18035
+ defaultConfidence: number(),
18036
+ group: string().optional(),
18037
+ configSchema: array(ConfigFieldBridge).readonly().optional()
17970
18038
  });
17971
- /**
17972
- * Row projection for track list queries. `full` (default) returns the
17973
- * complete Track including the frame-rate `positions[]` history and the
17974
- * `snapshots[]` references — megabytes across a page of tracks. `slim`
17975
- * keeps every scalar the list surfaces actually render (ids, class(es),
17976
- * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
17977
- * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
17978
- * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
17979
- * `getTrack`. Mirrors the event-store `projection` convention
17980
- * (`getObjectEvents` et al.).
17981
- */
17982
- var TrackProjectionSchema = _enum(["full", "slim"]);
17983
- /**
17984
- * One audio-classification label heard on the track's camera while the
17985
- * track was alive, aggregated per label. An "episode" is one persisted
17986
- * audio event (the confident-classification path: score ≥ the device's
17987
- * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
17988
- * one 32 ms inference chunk, so counts stay human-scaled.
17989
- */
17990
- var TrackAudioLabelSchema = object({
18039
+ var PipelineSlotSchemaSchema = object({
18040
+ id: PipelineSlotSchema,
17991
18041
  label: string(),
17992
- /** Highest classification score observed across the label's episodes. */
17993
- peakScore: number(),
17994
- /** Number of coalesced audio-event episodes carrying this label. */
17995
- count: number(),
17996
- firstAt: number(),
17997
- lastAt: number()
18042
+ priority: number(),
18043
+ parentSlot: PipelineSlotSchema.nullable(),
18044
+ addons: array(PipelineAddonSchemaSchema).readonly()
18045
+ });
18046
+ var PipelineSchemaSchema = object({
18047
+ availableEngines: array(AvailableEngineSchema).readonly(),
18048
+ selectedEngine: PipelineEngineChoiceSchema,
18049
+ slots: array(PipelineSlotSchemaSchema).readonly()
18050
+ });
18051
+ var EngineProvisioningSchema = object({
18052
+ runtimeId: _enum([
18053
+ "onnx",
18054
+ "openvino",
18055
+ "coreml",
18056
+ "edgetpu"
18057
+ ]).nullable(),
18058
+ device: string().nullable(),
18059
+ state: _enum([
18060
+ "idle",
18061
+ "installing",
18062
+ "verifying",
18063
+ "ready",
18064
+ "failed"
18065
+ ]),
18066
+ progress: number().optional(),
18067
+ error: string().optional(),
18068
+ nextRetryAt: number().optional(),
18069
+ /**
18070
+ * Gate A (config-correctness gate at engine change): human-readable
18071
+ * config issues surfaced EAGERLY when the node's engine changes — model
18072
+ * substitutions ("chose X, running Y") and zero-build steps ("no model
18073
+ * has a <format> build"). Additive/optional: informational only, never
18074
+ * enforced here — `assertEngineReady` (readiness) still gates inference.
18075
+ * Absent/empty when the node-default tree resolves cleanly.
18076
+ */
18077
+ configIssues: array(string()).optional()
18078
+ });
18079
+ var PipelineStepInputSchema = lazy(() => object({
18080
+ addonId: string(),
18081
+ modelId: string().optional(),
18082
+ enabled: boolean().default(true),
18083
+ children: array(PipelineStepInputSchema).optional(),
18084
+ settings: record(string(), unknown()).optional(),
18085
+ jumpDeviceKey: string().optional()
18086
+ }));
18087
+ var ModelSubstitutionSchema = object({
18088
+ addonId: string(),
18089
+ chosen: string(),
18090
+ running: string(),
18091
+ format: string()
18092
+ });
18093
+ var PipelineValidationIssueSchema = object({
18094
+ addonId: string(),
18095
+ kind: _enum(["unknown-addon", "no-format-build"]),
18096
+ detail: string()
18097
+ });
18098
+ var PipelineValidationResultSchema = object({
18099
+ ok: boolean(),
18100
+ issues: array(PipelineValidationIssueSchema).readonly(),
18101
+ substitutions: array(ModelSubstitutionSchema).readonly(),
18102
+ /** The node's `currentEngine.format` this validation ran against. */
18103
+ format: string()
18104
+ });
18105
+ var ReferenceImageEntrySchema = object({
18106
+ filename: string(),
18107
+ stepIds: array(string()).readonly().optional()
18108
+ });
18109
+ var ReferenceImageBodySchema = object({
18110
+ base64: string(),
18111
+ filename: string()
18112
+ });
18113
+ var ReferenceAudioEntrySchema = object({
18114
+ filename: string(),
18115
+ sizeKb: number()
18116
+ });
18117
+ var ReferenceAudioBodySchema = object({ base64: string() });
18118
+ var AudioBackendSchema = object({
18119
+ id: string(),
18120
+ name: string(),
18121
+ description: string(),
18122
+ available: boolean(),
18123
+ /**
18124
+ * Raw classifier labels this backend can emit (e.g. YAMNet's
18125
+ * 521-class set or Apple SoundAnalysis's 303-class set). Used by
18126
+ * the benchmark UI to populate the `enabledMicroClasses` filter
18127
+ * specific to the selected backend without a separate fetch.
18128
+ */
18129
+ rawLabels: array(string()).readonly().optional()
18130
+ });
18131
+ var AudioCapabilitiesSchema = object({
18132
+ activeBackend: string(),
18133
+ availableBackends: array(AudioBackendSchema).readonly(),
18134
+ sampleRate: number(),
18135
+ chunkDurationMs: number()
18136
+ });
18137
+ var DownloadModelResultSchema = object({
18138
+ filePath: string(),
18139
+ sizeMB: number(),
18140
+ durationMs: number()
17998
18141
  });
17999
18142
  /**
18000
- * How a track was produced. `pipeline` (default / absent) = the spatial
18001
- * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
18002
- * no positions, a single snapshot, and no bbox trajectory at all:
18003
- *
18004
- * - `sensor` a linked sensor/control device state change.
18005
- * - `audio` an audio event on the camera itself that was anomalous for
18006
- * THAT camera, loud, and heard while nothing visual was happening (D62).
18007
- *
18008
- * The spatial subsystems (tracker association, occupancy count, re-id /
18009
- * embedding, resurrection) MUST skip every synthetic source. Test for that
18010
- * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
18011
- * check silently readmits every source added after it was written.
18012
- */
18013
- var TrackSourceSchema = _enum([
18014
- "pipeline",
18015
- "sensor",
18016
- "audio"
18017
- ]);
18018
- /**
18019
- * Where a track sits in the RETRAIN lifecycle (D81).
18020
- *
18021
- * - `none` — never marked, or un-marked. Evictable.
18022
- * - `staging` — the operator wants this track as training material and has not
18023
- * finished with it. **This is the only state retention holds**: the track and
18024
- * everything it owns (object events, crops, keyframes, CLIP vector) survive
18025
- * the device's age window.
18026
- * - `trained` — the retrain page has taken what it needed. The frames it chose
18027
- * were COPIED into the retrain dataset at selection time, so the dataset no
18028
- * longer depends on the track's media and the track becomes EVICTABLE again.
18029
- * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
18030
- * a deliberate action of the retrain page, not a side effect of a checkbox.
18031
- *
18032
- * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
18033
- * the store's filter language has only positive equality and `whereIn` — no
18034
- * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
18035
- * would make the entire pre-column history immortal in one deploy.
18143
+ * Wrapper carrying a single test run's result. Replaces the legacy
18144
+ * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
18145
+ * canonical `AudioResult` from the Phase 6 output rework: one
18146
+ * `AudioDetection` per class above `minScore`, top-N candidates in
18147
+ * `debug.alternateLabels['audio-classifier']`, per-source timings in
18148
+ * `debug.stepTimings`. The outer `success`/`error` fields stay so the
18149
+ * benchmark UI can still report a clean failure when the classifier
18150
+ * cap isn't available.
18036
18151
  */
18037
- var RetrainStatusSchema = _enum([
18038
- "none",
18039
- "staging",
18040
- "trained"
18041
- ]);
18152
+ var AudioTestResultSchema = object({
18153
+ success: boolean(),
18154
+ error: string().optional(),
18155
+ frame: custom().optional()
18156
+ });
18157
+ var PipelineConfigBridge = custom();
18158
+ var ConfigUISchemaBridge = custom();
18159
+ var ConfigUISchemaNullableBridge = custom();
18160
+ var InferenceCapabilitiesBridge = custom();
18161
+ var ModelAvailabilityListBridge = custom();
18162
+ var PipelineRunResultBridge = custom();
18042
18163
  /**
18043
- * Per-track OPERATOR flags set by hand from the admin UI or the viewer, never
18044
- * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
18045
- * so the two surfaces cannot drift.
18046
- *
18047
- * **Absent ≠ false.** A track that has never been touched omits the field; an
18048
- * explicitly un-flagged track carries `false`. Legacy rows written before the
18049
- * columns existed read as absent, and a consumer that needs a boolean should say
18050
- * `flag === true`, not `flag !== false`.
18051
- *
18052
- * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
18053
- * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
18054
- * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
18055
- * `trained` track reports `false` while refusing both writes. The boolean is
18056
- * kept because three surfaces drive a toggle off it; anything that needs to tell
18057
- * "never marked" from "already trained" must read `retrainStatus`.
18164
+ * Pipeline executordetection engine + configuration + inference API.
18058
18165
  *
18059
- * `debug` does NOT pin; it is attention, not durability.
18166
+ * Merged from: pipeline-executor, pipeline-config, inference, detection-config.
18167
+ * Implemented by the detection-pipeline addon.
18060
18168
  *
18061
- * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
18062
- * A favourited track is skipped by retention the same way `staging` is, but
18063
- * it does not enter `none|staging|trained` and has no staging budget.
18064
- */
18065
- var TrackFlagFields = {
18066
- /** Operator marked this track as training material — i.e. `retrainStatus` is
18067
- * `'staging'`. */
18068
- markForTrain: boolean().optional(),
18069
- /** Operator marked this track for diagnostic attention. */
18070
- debug: boolean().optional(),
18071
- /** Operator favourited this track. Pins it against pruning. */
18072
- favourited: boolean().optional()
18073
- };
18074
- /**
18075
- * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
18076
- * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
18077
- * write patch, and the status is not something the toggle sets — it is what the
18078
- * toggle's boolean is derived from. Absent on an in-RAM track never touched;
18079
- * always present on a persisted row (the column default materialises `'none'`).
18080
- */
18081
- var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
18082
- /**
18083
- * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
18084
- * one flag can never clear the other — the toggles are independent and are
18085
- * driven from three surfaces that do not know about each other.
18086
- */
18087
- var TrackFlagsPatchSchema = object(TrackFlagFields);
18088
- /**
18089
- * The resolved flag state after a write. Both fields are REQUIRED here (absent
18090
- * collapses to `false`) so a caller can drive a toggle's checked state off the
18091
- * mutation result without a re-fetch.
18092
- */
18093
- var TrackFlagsSchema = object({
18094
- trackId: string(),
18095
- markForTrain: boolean(),
18096
- debug: boolean(),
18097
- favourited: boolean(),
18098
- /** The lifecycle state the boolean was derived from. Required here (unlike on
18099
- * a track row) because this shape is only ever produced by the write body,
18100
- * which always knows it — and a surface that has just written needs to render
18101
- * `trained` without a re-fetch. */
18102
- retrainStatus: RetrainStatusSchema
18103
- });
18104
- union([literal(1), literal(2)]);
18105
- /**
18106
- * WHO decided a label, and when. Carried per tier so a value can be traced to
18107
- * the step and model that produced it — which is what makes the write rule
18108
- * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
18109
- * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
18110
- *
18111
- * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
18112
- * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
18113
- * `migration:4g` for a value the 4g migration moved from the single-slot era —
18114
- * that value has no provenance, and the write rule lets ANY properly-attributed
18115
- * write of the same tier replace it regardless of score.
18116
- */
18117
- var LabelAttributionSchema = object({
18118
- stepId: string(),
18119
- modelId: string().optional(),
18120
- decidedAt: number(),
18121
- /**
18122
- * The GALLERY id behind a recognised tier-2 label — a face-gallery
18123
- * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
18124
- *
18125
- * The text alone is a DISPLAY NAME, and a display name is renameable: a
18126
- * notification rule authored on "Gianluca" stopped matching the moment the
18127
- * operator fixed the spelling in the gallery, and nothing said so. The id is
18128
- * the thing that does not move, so it is what a rule matches on
18129
- * (`NcConditions.identities`) and the text is what a human is shown.
18130
- *
18131
- * Absent when the label names no gallery row — a plate the OCR read but no
18132
- * vehicle claims, a sub-class, a species, any tier-1 value.
18133
- */
18134
- identityId: string().optional()
18135
- });
18136
- /**
18137
- * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
18138
- * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
18139
- * track and its events always answer the same question the same way.
18140
- *
18141
- * Two scalar columns, not an array: every consumer wants "the coarse one" or
18142
- * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
18143
- * is tier 2, and each carries its own score + attribution.
18144
- *
18145
- * **Reading it.** What a human should be shown is `subLabel ?? label` — the
18146
- * finest thing known. Before 4g the single `label` column held the finest
18147
- * value, so a consumer that has not been updated reads the tier-1 slot and
18148
- * shows nothing on a species-only row; that is why the migration puts every
18149
- * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
18150
- * and why the read surfaces were changed in the same train.
18151
- *
18152
- * **Writing it.** The slots are independent, which is the whole point: a
18153
- * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
18154
- * migratorius`), so fineness cannot regress by construction. Within a tier the
18155
- * higher score wins. One rule, one implementation — see
18156
- * `pipeline/label-tier.ts` in addon-post-analysis.
18157
- */
18158
- var TieredLabelFields = {
18159
- /** Tier 1 — the sub-class. See {@link LabelTierSchema}. */
18160
- label: string().optional(),
18161
- /** Confidence of the tier-1 value, as reported by the deciding step. */
18162
- labelScore: number().optional(),
18163
- /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
18164
- labelMeta: LabelAttributionSchema.optional(),
18165
- /** Tier 2 — the instance. See {@link LabelTierSchema}. */
18166
- subLabel: string().optional(),
18167
- /** Confidence of the tier-2 value, as reported by the deciding step. */
18168
- subLabelScore: number().optional(),
18169
- /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
18170
- subLabelMeta: LabelAttributionSchema.optional()
18171
- };
18172
- /** Per-camera slice of a training-export estimate. */
18173
- var TrainingExportDeviceTotalsSchema = object({
18174
- deviceId: number(),
18175
- tracks: number().int(),
18176
- files: number().int(),
18177
- bytes: number().int()
18178
- });
18179
- /**
18180
- * What a training export WOULD contain. Computed from media index rows only —
18181
- * no blob is read to produce this.
18182
- */
18183
- var TrainingExportSummarySchema = object({
18184
- generatedAt: number(),
18185
- trackCount: number().int(),
18186
- fileCount: number().int(),
18187
- byteCount: number().int(),
18188
- /** More marked tracks exist than a single pass carries. */
18189
- truncated: boolean(),
18190
- devices: array(TrainingExportDeviceTotalsSchema).readonly()
18191
- });
18192
- var TrackSchema = object({
18193
- trackId: string(),
18194
- deviceId: number(),
18195
- className: string(),
18196
- ...TieredLabelFields,
18197
- producingDeviceName: string().optional(),
18198
- /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
18199
- source: TrackSourceSchema.optional(),
18200
- firstSeen: number(),
18201
- lastSeen: number(),
18202
- /** Frame-rate position history (subject to maxPositionHistory cap). */
18203
- positions: array(TrackPositionSchema).readonly(),
18204
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
18205
- * saveThumbnails policy). */
18206
- snapshots: array(TrackSnapshotSchema).readonly(),
18207
- /** Deduplicated zones the track has entered at least once. Zone IDS. */
18208
- zonesVisited: array(string()).readonly(),
18209
- /**
18210
- * Human NAMES for {@link zonesVisited}, resolved at READ time against the
18211
- * `zones` capability.
18212
- *
18213
- * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
18214
- * and no card can render — so every free-text search surface was structurally
18215
- * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
18216
- * just returned nothing. Resolving here rather than in each client keeps ONE
18217
- * derivation and costs the clients no extra call (the `zones` cap is
18218
- * per-device, so a client-side resolve would be a per-camera fan-out on a
18219
- * surface built to avoid exactly that).
18220
- *
18221
- * Resolved, never invented: a zone deleted since the track was written has no
18222
- * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
18223
- * two are not positionally aligned. Absent when the track visited no zone, or
18224
- * when the zone catalogue could not be read.
18225
- */
18226
- zoneNames: array(string()).readonly().optional(),
18227
- /** Deduplicated set of detector classes observed for this track over its
18228
- * life (a track may be reclassified, e.g. person→vehicle). Absent on
18229
- * legacy rows written before class accumulation shipped. */
18230
- classes: array(string()).readonly().optional(),
18231
- /** Cumulative normalized distance travelled (0..1 units = full frame width). */
18232
- totalDistance: number(),
18233
- state: TrackStateSchema,
18234
- active: boolean(),
18235
- /** Deterministic key-event importance score in [0,1] (server-computed at
18236
- * track expiry, recomputed on late label). Absent on legacy rows written
18237
- * before scoring shipped — consumers degrade to absence / compute-on-read. */
18238
- importance: number().optional(),
18239
- /** Id of the track's highest-confidence ObjectEvent (its representative
18240
- * "best" frame). Absent when the track produced no object events. */
18241
- bestEventId: string().optional(),
18242
- /** Tag of the importance sub-signal that dominated the score
18243
- * (identity|dwell|proximity|class|confidence|travel|zone). */
18244
- importanceReason: string().optional(),
18245
- /** Audio-classification labels heard on the camera during the track's
18246
- * life (score ≥ device `classificationMinScore`), aggregated per label.
18247
- * Absent on legacy rows / tracks with no confident audio. */
18248
- audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
18249
- /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
18250
- * Populated from the persisted envelope columns on historical reads;
18251
- * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
18252
- envelope: TrackEnvelopeSchema.optional(),
18253
- /**
18254
- * A face DETECTOR found a face on this track — nothing more. It says the
18255
- * detail plane produced a `face` detail; it does NOT say the face was
18256
- * embedded, matched, above `minFacePx`, or that the recognizer was even
18257
- * enabled. Set once and never cleared.
18258
- *
18259
- * **This exists so "face present but not recognised" is expressible.** A
18260
- * recognised identity lands in `subLabel` (attributed to the face chain via
18261
- * `subLabelMeta.stepId`), so before this field a track with an unmatched face
18262
- * and a track with no face at all were byte-identical on the wire and no
18263
- * surface could tell them apart. The read is `hasFace === true && subLabel
18264
- * === undefined`.
18265
- *
18266
- * **Absent ≠ false.** Every row written before the column existed omits it,
18267
- * and so does every server that predates the field — a consumer must test
18268
- * `=== true` and render nothing otherwise, never infer "no face".
18269
- */
18270
- hasFace: boolean().optional(),
18271
- /**
18272
- * This track has a face row IN THE GALLERY: a crop **and** an embedding — a
18273
- * face an operator could ASSIGN to an identity.
18274
- *
18275
- * The STRICT twin of {@link hasFace}, and the pair only earns its keep
18276
- * because the two disagree. `hasFace` is stamped at the TOP of the face
18277
- * branch, before every gate, and means no more than "a face detector produced
18278
- * a face detail". This one is stamped at the single moment the gallery row
18279
- * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
18280
- * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
18281
- * candidate gate, the imageless-track drop (no crop was ever captured) and
18282
- * the crop-store drop. Everything between the detector and that insert can
18283
- * legitimately refuse the face, so a flag written any earlier promises the
18284
- * operator something to assign and delivers nothing.
18285
- *
18286
- * **Independent of recognition.** A face collected but never auto-matched is
18287
- * still assignable — it is in fact the face an operator most wants to reach —
18288
- * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
18289
- * `subLabel`; this says only that the raw material exists.
18290
- *
18291
- * **Set once, never cleared.** A track that produced a gallery row produced
18292
- * one; deleting the row later is the gallery's business, not this flag's.
18293
- *
18294
- * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
18295
- * before the column omits it, and so does every server that predates the
18296
- * field. A consumer must test `=== true` and render nothing otherwise —
18297
- * never infer "no assignable face".
18298
- */
18299
- hasEmbeddedFace: boolean().optional(),
18300
- /**
18301
- * This subject CONTAINS a folded rider — a person the rider-pairing step
18302
- * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
18303
- * so the passage is tracked once and as a VEHICLE.
18304
- *
18305
- * It exists because the fold's record was dishonest. D34 and the code both
18306
- * said "the person is not lost — it is reported so both entities stay on the
18307
- * record"; in fact the pair went into a per-processor RAM field behind an
18308
- * accessor nobody called, and every durable surface said `vehicle`, full
18309
- * stop. This is the composition note that makes the row true.
18310
- *
18311
- * A COMPOSITION, never a class and never a label. "This vehicle contains a
18312
- * person" is not an answer to "what is this" — both label tiers would refuse
18313
- * a macro token anyway (D89), and correctly. Nothing here changes what the
18314
- * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
18315
- * and a `person` rule still does not fire for someone cycling past.
18316
- *
18317
- * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
18318
- * the column, and every hub that predates the field, omits it. Test
18319
- * `=== true` and render nothing otherwise — never infer "no rider".
18320
- */
18321
- hasRider: boolean().optional(),
18322
- ...TrackFlagFields,
18323
- ...TrackRetrainFields
18324
- });
18325
- var BaseEventFields = {
18326
- id: string(),
18327
- deviceId: number(),
18328
- timestamp: number()
18329
- };
18330
- var MotionEventSchema = object({
18331
- ...BaseEventFields,
18332
- kind: literal("motion"),
18333
- regionCount: number(),
18334
- /** Heavy JSON array — omitted in slim projection. */
18335
- regions: array(object({
18336
- bbox: BoundingBoxSchema,
18337
- pixelCount: number(),
18338
- intensity: number()
18339
- })).readonly().optional(),
18340
- /** Omitted in slim projection. */
18341
- frameWidth: number().optional(),
18342
- /** Omitted in slim projection. */
18343
- frameHeight: number().optional(),
18344
- /** Populated by B5 (recording playback URL for this event). */
18345
- mediaUrl: string().optional()
18346
- });
18347
- /**
18348
- * Which detection SOURCE produced an object event. `pipeline` = the ML
18349
- * detection pipeline (decoded-frame inference); `onboard` = the camera's
18350
- * native on-device AI. Both flow through the SAME analysis layers (zoning,
18351
- * tracking, per-kind persistence) but stay distinguishable so consumers
18352
- * (advanced-notifier, occupancy, …) can select which source(s) to act on.
18353
- * Absent on legacy rows ⇒ treat as `pipeline`.
18354
- */
18355
- var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
18356
- /**
18357
- * The confirmed zone crossing that produced an object event. Present ONLY on
18358
- * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
18359
- * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
18360
- * appearance event carry none, so a rule asking for a direction fails closed
18361
- * on them.
18362
- *
18363
- * Exactly ONE crossing per event: the emitter turns each confirmed crossing
18364
- * into its own event, so a frame in which a track enters A while leaving B
18365
- * produces two events with two directions — never one ambiguous row.
18366
- *
18367
- * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
18368
- * membership the box has NOW, and by definition it no longer contains the zone
18369
- * that was just left. Without the id here, a zone-scoped rule could never match
18370
- * the exit it asked for.
18371
- */
18372
- var ZoneCrossingSchema = object({
18373
- direction: _enum(["enter", "exit"]),
18374
- /** Admin zone id crossed. */
18375
- zoneId: string(),
18376
- /** Zone display name at crossing time (falls back to the id). */
18377
- zoneName: string().optional()
18378
- });
18379
- var ObjectEventSchema = object({
18380
- ...BaseEventFields,
18381
- kind: literal("object"),
18382
- /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
18383
- source: DetectionSourceSchema.optional(),
18384
- /**
18385
- * Inference-frame id shared by every object event emitted from the SAME frame
18386
- * — the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
18387
- * 2 people + 1 dog) under one full frame, and link a track's frames over time
18388
- * (group by `trackId`, pick a representative `frameId` as the parent frame).
18389
- * Optional for backward-compat with pre-existing rows / the slim projection
18390
- * includes it (it is light). Absent on rows written before this field.
18391
- */
18392
- frameId: string().optional(),
18393
- /** Omitted in slim projection. */
18394
- trackId: string().optional(),
18395
- className: string(),
18396
- ...TieredLabelFields,
18397
- /** Omitted in slim projection. */
18398
- confidence: number().optional(),
18399
- /** Heavy JSON — omitted in slim projection. */
18400
- bbox: BoundingBoxSchema.optional(),
18401
- /** Heavy JSON — omitted in slim projection. */
18402
- zones: array(string()).readonly().optional(),
18403
- /** Omitted in slim projection. */
18404
- state: TrackStateSchema.optional(),
18405
- /**
18406
- * The zone crossing this event IS, when it is one. Absent on every other
18407
- * event kind (movement state, appearance, package) — see
18408
- * {@link ZoneCrossingSchema}. Omitted in slim projection.
18409
- */
18410
- zoneCrossing: ZoneCrossingSchema.optional(),
18411
- /** Detection-frame dimensions in pixels — let consumers normalize the
18412
- * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
18413
- frameWidth: number().optional(),
18414
- frameHeight: number().optional(),
18415
- /** MediaStore key for the crop attached to this event (if any). */
18416
- mediaKey: string().optional(),
18417
- /** Design B: MediaStore key of the track's native-resolution key frame (the
18418
- * best-detection full frame). Resolve via the event-media data-plane
18419
- * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
18420
- * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
18421
- * sources — consumers fall back to `mediaKey` (the tight crop). */
18422
- keyFrameMediaKey: string().optional(),
18423
- /** Populated by B5 (recording playback URL for this event). */
18424
- mediaUrl: string().optional(),
18425
- /** The parent track's key-event importance [0,1], propagated to every object
18426
- * event of the track (so an event row can be sorted by importance without a
18427
- * track join). Absent on legacy rows / before the track was scored. */
18428
- importance: number().optional()
18429
- });
18430
- var AudioEventSchema = object({
18431
- ...BaseEventFields,
18432
- kind: literal("audio"),
18433
- rms: number(),
18434
- dbfs: number(),
18435
- classification: object({
18436
- className: string(),
18437
- originalClass: string().optional(),
18438
- score: number()
18439
- }).optional(),
18440
- /** Populated by B5 (recording playback URL for this event). */
18441
- mediaUrl: string().optional()
18442
- });
18443
- var MediaFileKindEnum = _enum([
18444
- "crop",
18445
- "thumbnail",
18446
- "snapshot",
18447
- "firstFrame",
18448
- "lastFrame",
18449
- "fullFrame",
18450
- "fullFrameBoxed",
18451
- "faceCrop",
18452
- "plateCrop",
18453
- "keyFrame",
18454
- "keyFrameSmall",
18455
- "thumbnailSmall"
18456
- ]);
18457
- var MediaFileSchema = object({
18458
- key: string(),
18459
- kind: MediaFileKindEnum,
18460
- base64: string(),
18461
- sizeBytes: number(),
18462
- timestamp: number()
18463
- });
18464
- /**
18465
- * One media row WITHOUT its bytes.
18466
- *
18467
- * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
18468
- * 140 s track), and a client that renders tiles from the media data plane needs
18469
- * to know only WHAT EXISTS — the bytes then arrive per tile, lazily, over HTTP
18470
- * with an immutable cache, instead of all at once inside a tRPC response that
18471
- * blocks the whole view.
18472
- *
18473
- * `sizeBytes` is carried because it is what lets a client decide between the
18474
- * stored blob and a `?variant=thumb` rendering without fetching either.
18475
- */
18476
- var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
18477
- /**
18478
- * The MACRO tier of an annotation — a CLOSED set.
18479
- *
18480
- * This is what the exported detector predicts, so a typo here is a new class
18481
- * with one example in it. `label` and `subLabel` are open strings by contrast:
18482
- * the whole point of the page is teaching the model things it does not know
18483
- * yet, and constraining that vocabulary would make it useless.
18484
- *
18485
- * A macro class is NEVER a label. The provider refuses a write whose `label` or
18486
- * `subLabel` is one of these values, in any casing, because once `person`
18487
- * exists in both tiers "every person box" stops being answerable without
18488
- * knowing every string anyone ever typed — and the damage is retroactive.
18489
- */
18490
- var RetrainMacroClassSchema = _enum([
18491
- "person",
18492
- "vehicle",
18493
- "animal",
18494
- "package",
18495
- "face",
18496
- "plate"
18497
- ]);
18498
- /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
18499
- var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
18500
- /** Did a human draw this box, or did the assist propose it? */
18501
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
18502
- /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
18503
- var RetrainBboxSchema = object({
18504
- x: number(),
18505
- y: number(),
18506
- w: number(),
18507
- h: number()
18508
- });
18509
- /**
18510
- * One annotated subject.
18511
- *
18512
- * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
18513
- * (letterboxed root / zone-cropped package / subject-cropped classifier) are
18514
- * derived from it at export and never stored — storing them is how one feature
18515
- * space ends up holding two crops of the same subject (D52).
18516
- */
18517
- var RetrainAnnotationSchema = object({
18518
- id: string(),
18519
- trackId: string(),
18520
- deviceId: number(),
18521
- /** The COPY in retrain storage — never the source track's media key. */
18522
- mediaKey: string(),
18523
- bbox: RetrainBboxSchema,
18524
- macroClass: RetrainMacroClassSchema,
18525
- label: string().optional(),
18526
- subLabel: string().optional(),
18527
- kind: RetrainAnnotationKindSchema,
18528
- source: RetrainAnnotationSourceSchema,
18529
- /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
18530
- assistModelId: string().optional(),
18531
- assistScore: number().optional(),
18532
- exportedInBatch: string().optional(),
18533
- createdAt: number()
18534
- });
18535
- /** The write form — the server owns `id`, `createdAt` and the frame binding. */
18536
- var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
18537
- id: true,
18538
- trackId: true,
18539
- deviceId: true,
18540
- mediaKey: true,
18541
- createdAt: true,
18542
- exportedInBatch: true
18543
- });
18544
- /** A track sitting in `staging`, with everything the worklist needs to rank it. */
18545
- var RetrainTrackSchema = object({
18546
- trackId: string(),
18547
- deviceId: number(),
18548
- className: string(),
18549
- label: string().optional(),
18550
- firstSeen: number(),
18551
- lastSeen: number(),
18552
- /** How many frames the dataset already holds from this track. */
18553
- frameCount: number().int(),
18554
- /** How many subjects have been annotated on those frames. `0` with
18555
- * `frameCount: 0` is exactly "staging, still to work". */
18556
- annotationCount: number().int()
18557
- });
18558
- /** A frame the picker may offer — an index row, no blob was read to produce it. */
18559
- var RetrainFrameCandidateSchema = object({
18560
- mediaKey: string(),
18561
- kind: MediaFileKindEnum,
18562
- timestamp: number(),
18563
- sizeBytes: number().int(),
18564
- /** A copy of this original already exists — selecting it is free and cannot
18565
- * fail, whatever became of the original. */
18566
- copied: boolean()
18567
- });
18568
- /** A frame the dataset OWNS: bytes copied at selection time. */
18569
- var RetrainFrameSchema = object({
18570
- frameId: string(),
18571
- deviceId: number(),
18572
- trackId: string(),
18573
- /** Provenance only. It may already point at nothing — that is expected. */
18574
- sourceMediaKey: string(),
18575
- sourceKind: MediaFileKindEnum,
18576
- sizeBytes: number().int(),
18577
- width: number().int(),
18578
- height: number().int(),
18579
- copiedAt: number()
18580
- });
18581
- /** Why a copy-on-select could not be honoured — named, never a silent skip. */
18582
- var RetrainCopyRefusalSchema = _enum([
18583
- "source-missing",
18584
- "unreadable-image",
18585
- "write-failed"
18586
- ]);
18587
- var RetrainFrameSelectionSchema = object({
18588
- copied: array(RetrainFrameSchema).readonly(),
18589
- refused: array(object({
18590
- sourceMediaKey: string(),
18591
- reason: RetrainCopyRefusalSchema
18592
- })).readonly()
18593
- });
18594
- var RetrainFrameListSchema = object({
18595
- candidates: array(RetrainFrameCandidateSchema).readonly(),
18596
- copies: array(RetrainFrameSchema).readonly(),
18597
- /** What the page pre-selects — the native key frame when one survives. */
18598
- autoPickMediaKey: string().optional()
18599
- });
18600
- /** What the operator asked the assist to look for. */
18601
- var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
18602
- kind: literal("package"),
18603
- zone: RetrainBboxSchema.optional()
18604
- }), object({
18605
- kind: literal("objects"),
18606
- modelId: string(),
18607
- minScore: number().optional()
18608
- })]);
18609
- /**
18610
- * The assist's answer — a discriminated union, because "the model saw nothing"
18611
- * and "this node cannot run that model" lead to different next moves and a
18612
- * nullable result cannot tell them apart.
18613
- */
18614
- var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
18615
- kind: literal("proposed"),
18616
- modelId: string(),
18617
- stepId: string(),
18618
- minScore: number(),
18619
- /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
18620
- proposals: array(RetrainAnnotationDraftSchema).readonly(),
18621
- /** Returned by the runner but removed by the threshold. */
18622
- belowThreshold: number().int()
18623
- }), object({
18624
- kind: literal("refused"),
18625
- /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
18626
- reason: string(),
18627
- detail: string().optional()
18628
- })]);
18629
- /** The outcome of a lifecycle move owned by the retrain page. */
18630
- var RetrainTransitionResultSchema = object({
18631
- trackId: string(),
18632
- /** Where the track ended up, whatever happened. */
18633
- retrainStatus: RetrainStatusSchema,
18634
- /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
18635
- changed: boolean(),
18636
- reason: _enum([
18637
- "unknown-track",
18638
- "no-frames-copied",
18639
- "not-staging",
18640
- "not-trained",
18641
- "unchanged"
18642
- ]).optional()
18643
- });
18644
- var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
18645
- var MAX_EVENT_QUERY_LIMIT = 5e3;
18646
- var DeviceEventQueryInput = object({
18647
- deviceId: number(),
18648
- since: number().optional(),
18649
- until: number().optional(),
18650
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
18651
- /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
18652
- * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
18653
- * exact behaviour. Callers may omit this field — the store defaults to
18654
- * `full` when not provided. */
18655
- projection: _enum(["full", "slim"]).optional()
18656
- });
18657
- var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
18658
- var RecentTracksQueryInput = object({
18659
- /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
18660
- deviceIds: array(number()),
18661
- /** Window lower bound on `lastSeen` (inclusive). */
18662
- since: number().optional(),
18663
- /** Window upper bound on `lastSeen` (inclusive). */
18664
- until: number().optional(),
18665
- /** Page size. Default 200, max 1000. */
18666
- limit: number().int().min(1).max(1e3).default(200),
18667
- /** Opaque continuation cursor from a previous page's `nextCursor`.
18668
- * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
18669
- cursor: string().optional(),
18670
- /** See {@link TrackProjectionSchema}. Default `full`. */
18671
- projection: TrackProjectionSchema.optional(),
18672
- /** Include stationary-promoted rows (parked objects). Default false: the
18673
- * feed lists passages; parking records live on the stationary registry. */
18674
- includeStationary: boolean().optional()
18675
- });
18676
- var RecentTracksPageSchema = object({
18677
- /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
18678
- tracks: array(TrackSchema).readonly(),
18679
- /** Cursor for the next page, or null when this page is the last. */
18680
- nextCursor: string().nullable()
18681
- });
18682
- var LIST_GROUPS_DEFAULT_LIMIT = 40;
18683
- var LIST_GROUPS_MAX_LIMIT = 100;
18684
- var AnalyticsGroupRecordSchema = object({
18685
- id: string(),
18686
- deviceId: number().int(),
18687
- openedAt: number().int(),
18688
- closedAt: number().int(),
18689
- timestamp: number().int(),
18690
- memberCount: number().int(),
18691
- memberTrackIds: array(string()).readonly(),
18692
- className: string(),
18693
- classes: array(string()).readonly(),
18694
- /** Relative event-media path, or null when the group has no picture yet. */
18695
- mediaUrl: string().nullable(),
18696
- singleton: boolean()
18697
- });
18698
- var AnalyticsGroupMemberSchema = object({
18699
- trackId: string(),
18700
- deviceId: number().int(),
18701
- className: string(),
18702
- firstSeen: number().int(),
18703
- lastSeen: number().int(),
18704
- mediaUrl: string().nullable()
18705
- });
18706
- var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
18707
- var ListGroupsQueryInput = object({
18708
- /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
18709
- deviceIds: array(number()),
18710
- /** Window lower bound on `closedAt` (inclusive). */
18711
- since: number().optional(),
18712
- /** Window upper bound on `openedAt` (inclusive). */
18713
- until: number().optional(),
18714
- limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
18715
- /** Opaque continuation cursor from a previous page's `nextCursor`. */
18716
- cursor: string().optional()
18717
- });
18718
- var ListGroupsPageSchema = object({
18719
- groups: array(AnalyticsGroupRecordSchema).readonly(),
18720
- nextCursor: string().nullable()
18721
- });
18722
- var KeyEventQueryInput = object({
18723
- deviceId: number(),
18724
- /** Window lower bound (track firstSeen ≥ since). */
18725
- since: number(),
18726
- /** Window upper bound (track firstSeen ≤ until). */
18727
- until: number(),
18728
- limit: number().int().min(1).max(200).default(50),
18729
- /** Drop tracks scoring below this importance. */
18730
- minImportance: number().min(0).max(1).optional(),
18731
- /** Restrict to a single class (e.g. 'person'). */
18732
- classFilter: string().optional()
18733
- });
18734
- var KeyEventSchema = object({
18735
- /** The representative event id (the track's best ObjectEvent, else its trackId). */
18736
- id: string(),
18737
- trackId: string(),
18738
- /** Track start time (firstSeen). */
18739
- timestamp: number(),
18740
- className: string(),
18741
- ...TieredLabelFields,
18742
- importance: number(),
18743
- /** Highest-confidence ObjectEvent id for the track (empty when none). */
18744
- bestEventId: string(),
18745
- /** Track lifetime in ms (lastSeen - firstSeen). */
18746
- windowMs: number().optional(),
18747
- ...TrackFlagFields,
18748
- ...TrackRetrainFields
18749
- });
18750
- object({
18751
- trackId: string(),
18752
- className: string(),
18753
- confidence: number(),
18754
- bbox: BoundingBoxSchema,
18755
- zones: array(string()).readonly(),
18756
- state: TrackStateSchema
18757
- });
18758
- var OverlayDetectionSchema = looseObject({
18759
- id: string(),
18760
- kind: _enum(["first-level", "detail"]),
18761
- macroClass: string(),
18762
- score: number(),
18763
- bbox: object({
18764
- x: number(),
18765
- y: number(),
18766
- width: number(),
18767
- height: number()
18768
- }),
18769
- labels: array(looseObject({
18770
- label: string(),
18771
- score: number()
18772
- })).readonly(),
18773
- parentId: string().optional()
18774
- });
18775
- var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
18776
- var SearchObjectEventsInput = object({
18777
- text: string(),
18778
- deviceId: number().optional(),
18779
- since: number().optional(),
18780
- until: number().optional(),
18781
- classFilter: string().optional(),
18782
- limit: number().default(50),
18783
- minScore: number().min(0).max(1).default(.2)
18784
- });
18785
- var TrackCascadeCountsSchema = object({
18786
- /** Persisted track roots deleted (authoritative). */
18787
- tracks: number().int(),
18788
- /** Object events removed with their tracks (best-effort; see note above). */
18789
- events: number().int(),
18790
- /** Track/face/plate-owned media removed (best-effort). Never identity media. */
18791
- media: number().int(),
18792
- /** Unassigned (non-enrolled) face reads removed (best-effort). */
18793
- faces: number().int(),
18794
- /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
18795
- plates: number().int(),
18796
- /** Per-track CLIP search vectors removed (best-effort). */
18797
- embeddings: number().int(),
18798
- /** Group membership + group rows removed with their last member (best-effort). */
18799
- groups: number().int()
18800
- });
18801
- /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
18802
- var DiskReconcileCountsSchema = object({
18803
- mediaDropped: number().int(),
18804
- tracks: number().int(),
18805
- events: number().int()
18806
- });
18807
- /** Event-store footprint for one camera. */
18808
- var EventStoreDeviceFootprintSchema = object({
18809
- deviceId: number(),
18810
- /** Persisted event rows (motion + object + audio) for the camera. */
18811
- rows: number().int(),
18812
- /** Event-owned media bytes on disk for the camera. */
18813
- bytes: number().int()
18814
- });
18815
- /** Aggregate event-store footprint: global totals + per-camera breakdown. */
18816
- var EventStoreFootprintSchema = object({
18817
- totalRows: number().int(),
18818
- totalBytes: number().int(),
18819
- devices: array(EventStoreDeviceFootprintSchema).readonly()
18820
- });
18821
- /** Per-kind counts returned by the event-prune / device-delete mutations. */
18822
- var EventPruneCountsSchema = object({
18823
- motion: number().int(),
18824
- object: number().int(),
18825
- audio: number().int()
18826
- });
18827
- /**
18828
- * Re-embed stored tracks from their key frames.
18829
- *
18830
- * The reason this is an operator-callable method and not a migration script:
18831
- * every knob that decides what a vector MEANS — encoder model, crop margin,
18832
- * squaring — is only changeable if the existing vectors can be regenerated.
18833
- * Mixing feature spaces in one index makes cosine scores incomparable, and the
18834
- * symptom is a quality regression with no visible cause.
18835
- */
18836
- var RebuildObjectEmbeddingsInput = object({
18837
- /** Restrict to one camera. Omit for the whole fleet. */
18838
- deviceId: number().optional(),
18839
- since: number().optional(),
18840
- until: number().optional(),
18841
- /** Stop after this many tracks; the result reports whether more remain. */
18842
- maxTracks: number().int().positive().optional(),
18843
- /**
18844
- * Run every embedding on THIS node instead of round-robining the fleet.
18845
- *
18846
- * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
18847
- * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
18848
- * calling it that would pin the rebuild REQUEST itself to that node — the
18849
- * rebuild orchestration lives on the hub, and only the per-track step runs
18850
- * remotely. This field is data; the per-track pin is applied inside.
18851
- *
18852
- * Absent ⇒ round-robin over every online node whose runner can serve the
18853
- * pinned model.
18854
- */
18855
- executeOnNodeId: string().optional(),
18856
- /**
18857
- * Milliseconds to wait between tracks; omit for the built-in default, `0` to
18858
- * run flat out.
18859
- *
18860
- * A rebuild is bulk maintenance on hub-main's single thread. Measured
18861
- * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
18862
- * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
18863
- * force is logged at start and finish so a deliberately slow pass reads
18864
- * differently from a stalled one.
18865
- */
18866
- pacingMs: number().int().nonnegative().optional()
18867
- });
18868
- /**
18869
- * Result of emptying the CLIP index.
18870
- *
18871
- * The clean slate before a policy change: a new crop margin or encoder model
18872
- * leaves two feature spaces in one index whose cosine scores are not
18873
- * comparable, so wiping and rebuilding is the only way to be sure every vector
18874
- * means the same thing.
18875
- */
18876
- var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
18877
- /**
18878
- * Acknowledgement that a rebuild STARTED.
18879
- *
18880
- * The pass costs ~1s per track — 45 minutes for a 2,600-track fleet — so it
18881
- * runs detached and this returns immediately. Waiting for it made the client
18882
- * time out while the work carried on server-side, which is the worst of both:
18883
- * no result and no way to know it was still going. Poll
18884
- * `getObjectEmbeddingRebuildStatus` for progress.
18885
- */
18886
- var RebuildObjectEmbeddingsResultSchema = object({
18887
- started: boolean(),
18888
- /** True when a pass was already running; the new request is ignored. */
18889
- alreadyRunning: boolean()
18890
- });
18891
- var RebuildStatusSchema = object({
18892
- running: boolean(),
18893
- scanned: number(),
18894
- rebuilt: number(),
18895
- /** Tracks whose key frame is gone — nothing to re-embed from. */
18896
- missingKeyFrame: number(),
18897
- /** Tracks with no usable detection box. */
18898
- missingBbox: number(),
18899
- /**
18900
- * Tracks an executing node REFUSED rather than broke on — an unreadable key
18901
- * frame, a step that threw. Separate from `failed` because the remedy is
18902
- * different, and because a whole camera silently contributing zero vectors
18903
- * is the shape of failure a rebuild must never hide.
18904
- */
18905
- notRunnable: number(),
18906
- /**
18907
- * The pass stopped because NO node could serve the pinned model.
18908
- *
18909
- * Distinct from `notRunnable` on purpose: that one says "this track was
18910
- * refused", this one says "the cluster cannot do this work at all" — every
18911
- * candidate node either lacks the `clip-embedding` step, lacks a build of the
18912
- * pinned model for its engine format, or dropped out. The remedy is a model /
18913
- * engine change, not a per-camera one. Non-zero here always comes with
18914
- * `complete: false`.
18915
- */
18916
- noCapableNode: number(),
18917
- failed: number(),
18918
- /** Set once a pass ends: true only when EVERYTHING was covered. */
18919
- complete: boolean().nullable(),
18920
- startedAtMs: number().nullable(),
18921
- finishedAtMs: number().nullable(),
18922
- /** Present when the pass ended by throwing. */
18923
- error: string().nullable()
18924
- });
18925
- DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
18926
- deviceId: number(),
18927
- trackId: string()
18928
- }), TrackSchema.nullable()), method(object({
18929
- deviceId: number(),
18930
- since: number().optional(),
18931
- until: number().optional(),
18932
- limit: number().optional(),
18933
- /** Spatial filter — only tracks whose trajectory intersects the zone
18934
- * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
18935
- * envelope columns, then precisely tested per position. Tracks with
18936
- * an unknown envelope (no frame dims at persist time) always match. */
18937
- zone: TrackZoneFilterSchema.optional(),
18938
- /** See {@link TrackProjectionSchema}. Default `full` (backward
18939
- * compatible — omitting the field keeps today's exact behaviour). */
18940
- projection: TrackProjectionSchema.optional(),
18941
- /** Include stationary-promoted rows (parked objects handed to the
18942
- * stationary registry). Default false: the timeline lists passages,
18943
- * not parking records (operator decision, 2026-08-15). */
18944
- includeStationary: boolean().optional()
18945
- }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
18946
- deviceId: number(),
18947
- groupId: string().min(1)
18948
- }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
18949
- kind: "mutation",
18950
- auth: "admin"
18951
- }), 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({
18952
- deviceId: number(),
18953
- since: number().optional(),
18954
- until: number().optional(),
18955
- kinds: array(string()).optional(),
18956
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
18957
- }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
18958
- deviceId: number(),
18959
- since: number(),
18960
- until: number(),
18961
- bucketMs: number().int().positive()
18962
- }), array(object({
18963
- bucketStart: number(),
18964
- motion: number().int(),
18965
- object: number().int(),
18966
- audio: number().int()
18967
- })).readonly()), method(object({
18968
- deviceId: number(),
18969
- cutoffMs: number()
18970
- }), object({
18971
- motion: number().int(),
18972
- object: number().int(),
18973
- audio: number().int()
18974
- }), {
18975
- kind: "mutation",
18976
- auth: "admin"
18977
- }), method(object({
18978
- deviceId: number(),
18979
- cutoffMs: number()
18980
- }), TrackCascadeCountsSchema, {
18981
- kind: "mutation",
18982
- auth: "admin"
18983
- }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
18984
- kind: "mutation",
18985
- auth: "admin"
18986
- }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
18987
- kind: "mutation",
18988
- auth: "admin"
18989
- }), method(object({
18990
- deviceId: number(),
18991
- trackIds: array(string()).min(1)
18992
- }), object({
18993
- deleted: number().int(),
18994
- failed: array(string()).readonly()
18995
- }), {
18996
- kind: "mutation",
18997
- auth: "admin"
18998
- }), method(object({
18999
- /** Log/audit scope only — the trackId is globally unique on its own. */
19000
- deviceId: number(),
19001
- trackId: string(),
19002
- flags: TrackFlagsPatchSchema
19003
- }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
19004
- kind: "query",
19005
- auth: "admin"
19006
- }), method(object({
19007
- olderThanMs: number(),
19008
- reason: OpsLogReasonSchema.optional()
19009
- }), EventPruneCountsSchema, {
19010
- kind: "mutation",
19011
- auth: "admin"
19012
- }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
19013
- kind: "mutation",
19014
- auth: "admin"
19015
- }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
19016
- kind: "mutation",
19017
- auth: "admin"
19018
- }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
19019
- kind: "mutation",
19020
- auth: "admin"
19021
- }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
19022
- kind: "mutation",
19023
- auth: "admin"
19024
- }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
19025
- kind: "mutation",
19026
- auth: "admin"
19027
- }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
19028
- kind: "mutation",
19029
- auth: "admin"
19030
- }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
19031
- kind: "query",
19032
- auth: "admin"
19033
- }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
19034
- kind: "query",
19035
- auth: "admin"
19036
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
19037
- kind: "query",
19038
- auth: "admin"
19039
- }), method(object({
19040
- /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
19041
- * `deviceId`, deliberately: `deviceId` would make this device-bound and
19042
- * route it at one camera's owner, and "every camera" would stop being
19043
- * expressible at all. */
19044
- deviceIds: array(number()).optional(),
19045
- limit: number().int().min(1).max(500).optional()
19046
- }), array(RetrainTrackSchema).readonly(), {
19047
- kind: "query",
19048
- auth: "admin"
19049
- }), method(object({ trackId: string() }), RetrainFrameListSchema, {
19050
- kind: "query",
19051
- auth: "admin"
19052
- }), method(object({
19053
- deviceId: number(),
19054
- trackId: string(),
19055
- mediaKeys: array(string()).min(1)
19056
- }), RetrainFrameSelectionSchema, {
19057
- kind: "mutation",
19058
- auth: "admin"
19059
- }), method(object({
19060
- deviceId: number(),
19061
- trackId: string(),
19062
- frameId: string()
19063
- }), object({
19064
- removed: boolean(),
19065
- removedAnnotations: number().int()
19066
- }), {
19067
- kind: "mutation",
19068
- auth: "admin"
19069
- }), method(object({ frameId: string() }), object({
19070
- base64: string(),
19071
- width: number().int(),
19072
- height: number().int()
19073
- }), {
19074
- kind: "query",
19075
- auth: "admin"
19076
- }), method(object({
19077
- deviceId: number(),
19078
- trackId: string(),
19079
- frameId: string(),
19080
- subject: RetrainAssistSubjectSchema,
19081
- /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
19082
- nodeId: string().optional()
19083
- }), RetrainAssistResultSchema, {
19084
- kind: "mutation",
19085
- auth: "admin"
19086
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
19087
- kind: "query",
19088
- auth: "admin"
19089
- }), method(object({
19090
- deviceId: number(),
19091
- trackId: string(),
19092
- frameId: string(),
19093
- annotations: array(RetrainAnnotationDraftSchema)
19094
- }), array(RetrainAnnotationSchema).readonly(), {
19095
- kind: "mutation",
19096
- auth: "admin"
19097
- }), method(object({
19098
- deviceId: number(),
19099
- trackId: string()
19100
- }), RetrainTransitionResultSchema, {
19101
- kind: "mutation",
19102
- auth: "admin"
19103
- }), method(object({
19104
- deviceId: number(),
19105
- trackId: string()
19106
- }), RetrainTransitionResultSchema, {
19107
- kind: "mutation",
19108
- auth: "admin"
19109
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
19110
- kind: "query",
19111
- auth: "admin"
19112
- }), method(object({
19113
- eventId: string(),
19114
- kind: MediaFileKindEnum.optional(),
19115
- deviceId: number()
19116
- }), array(MediaFileSchema).readonly()), method(object({
19117
- trackId: string(),
19118
- kinds: array(MediaFileKindEnum).optional(),
19119
- deviceId: number()
19120
- }), array(MediaFileSchema).readonly()), method(object({
19121
- trackId: string(),
19122
- deviceId: number()
19123
- }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
19124
- kind: "mutation",
19125
- auth: "admin"
19126
- }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
19127
- kind: "mutation",
19128
- auth: "admin"
19129
- }), method(object({}), RebuildStatusSchema), object({
19130
- deviceId: number(),
19131
- timestamp: number(),
19132
- frameWidth: number(),
19133
- frameHeight: number(),
19134
- detections: array(OverlayDetectionSchema).readonly()
19135
- }), object({
19136
- deviceId: number(),
19137
- trackId: string(),
19138
- className: string()
19139
- }), object({
19140
- deviceId: number(),
19141
- trackId: string(),
19142
- className: string(),
19143
- durationMs: number()
19144
- }), object({
19145
- deviceId: number(),
19146
- kind: EventKindSchema,
19147
- eventId: string(),
19148
- timestamp: number()
19149
- });
19150
- /**
19151
- * Reference to the frame's retained NATIVE surface + the parent crop's placement
19152
- * within the frame, so the executor can re-cut a leaf child ROI at native
19153
- * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
19154
- */
19155
- var NativeCropRefSchema = object({
19156
- /** Handle keying the retained native surface (node-pinned to its owner). */
19157
- handle: FrameHandleSchema,
19158
- /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
19159
- cropFrameSpace: object({
19160
- x: number(),
19161
- y: number(),
19162
- w: number(),
19163
- h: number()
19164
- })
19165
- });
19166
- object({
19167
- crop: object({
19168
- left: number(),
19169
- top: number(),
19170
- width: number().positive(),
19171
- height: number().positive()
19172
- }).optional(),
19173
- content: object({
19174
- width: number().int().positive(),
19175
- height: number().int().positive()
19176
- }),
19177
- fit: _enum(["stretch", "contain"]),
19178
- format: _enum([
19179
- "rgb",
19180
- "gray",
19181
- "jpeg"
19182
- ])
19183
- });
19184
- var FrameRefSchema = object({
19185
- registryId: string().min(1),
19186
- id: string().min(1),
19187
- width: number().int().positive(),
19188
- height: number().int().positive(),
19189
- format: _enum(["rgb", "gray"]),
19190
- timestamp: number(),
19191
- capturedAt: number().optional()
19192
- });
19193
- var ModelFormatSchema$1 = _enum([
19194
- "onnx",
19195
- "coreml",
19196
- "openvino",
19197
- "tflite",
19198
- "pt",
19199
- "gguf"
19200
- ]);
19201
- var PipelineSlotSchema = _enum([
19202
- "detector",
19203
- "cropper",
19204
- "classifier",
19205
- "refiner",
19206
- "audio-classifier"
19207
- ]);
19208
- var PipelineEngineChoiceSchema = object({
19209
- runtime: _enum(["node", "python"]),
19210
- backend: string(),
19211
- format: ModelFormatSchema$1,
19212
- device: string().optional()
19213
- });
19214
- var AvailableEngineSchema = object({
19215
- engine: PipelineEngineChoiceSchema,
19216
- devices: array(object({
19217
- id: string(),
19218
- label: string(),
19219
- description: string().optional()
19220
- })).readonly(),
19221
- defaultDevice: string()
19222
- });
19223
- var PipelineDefaultStepSchema = lazy(() => object({
19224
- addonId: string(),
19225
- addonName: string(),
19226
- slot: PipelineSlotSchema,
19227
- inputClasses: array(string()).readonly(),
19228
- outputClasses: array(string()).readonly(),
19229
- enabled: boolean(),
19230
- modelId: string(),
19231
- children: array(PipelineDefaultStepSchema).readonly(),
19232
- group: string().optional(),
19233
- settings: record(string(), unknown()).optional()
19234
- }));
19235
- var PipelineTemplateStepSchema = lazy(() => object({
19236
- addonId: string(),
19237
- enabled: boolean(),
19238
- modelId: string(),
19239
- children: array(PipelineTemplateStepSchema).readonly(),
19240
- settings: record(string(), unknown()).optional()
19241
- }));
19242
- var PipelineTemplateSchema$1 = object({
19243
- id: string(),
19244
- name: string(),
19245
- createdAt: string(),
19246
- updatedAt: string(),
19247
- engine: PipelineEngineChoiceSchema,
19248
- steps: array(PipelineTemplateStepSchema).readonly()
19249
- });
19250
- var PipelineModelOptionSchema = object({
19251
- id: string(),
19252
- name: string(),
19253
- formats: record(string(), object({
19254
- downloaded: boolean(),
19255
- sizeMB: number()
19256
- })),
19257
- group: ModelVariantGroupSchema.optional(),
19258
- legacy: boolean().optional(),
19259
- provider: ModelProviderIdSchema.optional()
19260
- });
19261
- var ConfigFieldBridge = custom();
19262
- var PipelineAddonSchemaSchema = object({
19263
- id: string(),
19264
- name: string(),
19265
- slot: PipelineSlotSchema,
19266
- inputClasses: array(string()).readonly(),
19267
- outputClasses: array(string()).readonly(),
19268
- childSlots: array(PipelineSlotSchema).readonly(),
19269
- models: array(PipelineModelOptionSchema).readonly(),
19270
- defaultModelId: string(),
19271
- defaultModelIdByFormat: record(string(), string()).optional(),
19272
- enabledByDefault: boolean().optional(),
19273
- backfillIntoExistingOverrides: boolean().optional(),
19274
- defaultConfidence: number(),
19275
- group: string().optional(),
19276
- configSchema: array(ConfigFieldBridge).readonly().optional()
19277
- });
19278
- var PipelineSlotSchemaSchema = object({
19279
- id: PipelineSlotSchema,
19280
- label: string(),
19281
- priority: number(),
19282
- parentSlot: PipelineSlotSchema.nullable(),
19283
- addons: array(PipelineAddonSchemaSchema).readonly()
19284
- });
19285
- var PipelineSchemaSchema = object({
19286
- availableEngines: array(AvailableEngineSchema).readonly(),
19287
- selectedEngine: PipelineEngineChoiceSchema,
19288
- slots: array(PipelineSlotSchemaSchema).readonly()
19289
- });
19290
- var EngineProvisioningSchema = object({
19291
- runtimeId: _enum([
19292
- "onnx",
19293
- "openvino",
19294
- "coreml",
19295
- "edgetpu"
19296
- ]).nullable(),
19297
- device: string().nullable(),
19298
- state: _enum([
19299
- "idle",
19300
- "installing",
19301
- "verifying",
19302
- "ready",
19303
- "failed"
19304
- ]),
19305
- progress: number().optional(),
19306
- error: string().optional(),
19307
- nextRetryAt: number().optional(),
19308
- /**
19309
- * Gate A (config-correctness gate at engine change): human-readable
19310
- * config issues surfaced EAGERLY when the node's engine changes — model
19311
- * substitutions ("chose X, running Y") and zero-build steps ("no model
19312
- * has a <format> build"). Additive/optional: informational only, never
19313
- * enforced here — `assertEngineReady` (readiness) still gates inference.
19314
- * Absent/empty when the node-default tree resolves cleanly.
19315
- */
19316
- configIssues: array(string()).optional()
19317
- });
19318
- var PipelineStepInputSchema = lazy(() => object({
19319
- addonId: string(),
19320
- modelId: string().optional(),
19321
- enabled: boolean().default(true),
19322
- children: array(PipelineStepInputSchema).optional(),
19323
- settings: record(string(), unknown()).optional(),
19324
- jumpDeviceKey: string().optional()
19325
- }));
19326
- var ModelSubstitutionSchema = object({
19327
- addonId: string(),
19328
- chosen: string(),
19329
- running: string(),
19330
- format: string()
19331
- });
19332
- var PipelineValidationIssueSchema = object({
19333
- addonId: string(),
19334
- kind: _enum(["unknown-addon", "no-format-build"]),
19335
- detail: string()
19336
- });
19337
- var PipelineValidationResultSchema = object({
19338
- ok: boolean(),
19339
- issues: array(PipelineValidationIssueSchema).readonly(),
19340
- substitutions: array(ModelSubstitutionSchema).readonly(),
19341
- /** The node's `currentEngine.format` this validation ran against. */
19342
- format: string()
19343
- });
19344
- var ReferenceImageEntrySchema = object({
19345
- filename: string(),
19346
- stepIds: array(string()).readonly().optional()
19347
- });
19348
- var ReferenceImageBodySchema = object({
19349
- base64: string(),
19350
- filename: string()
19351
- });
19352
- var ReferenceAudioEntrySchema = object({
19353
- filename: string(),
19354
- sizeKb: number()
19355
- });
19356
- var ReferenceAudioBodySchema = object({ base64: string() });
19357
- var AudioBackendSchema = object({
19358
- id: string(),
19359
- name: string(),
19360
- description: string(),
19361
- available: boolean(),
19362
- /**
19363
- * Raw classifier labels this backend can emit (e.g. YAMNet's
19364
- * 521-class set or Apple SoundAnalysis's 303-class set). Used by
19365
- * the benchmark UI to populate the `enabledMicroClasses` filter
19366
- * specific to the selected backend without a separate fetch.
19367
- */
19368
- rawLabels: array(string()).readonly().optional()
19369
- });
19370
- var AudioCapabilitiesSchema = object({
19371
- activeBackend: string(),
19372
- availableBackends: array(AudioBackendSchema).readonly(),
19373
- sampleRate: number(),
19374
- chunkDurationMs: number()
19375
- });
19376
- var DownloadModelResultSchema = object({
19377
- filePath: string(),
19378
- sizeMB: number(),
19379
- durationMs: number()
19380
- });
19381
- /**
19382
- * Wrapper carrying a single test run's result. Replaces the legacy
19383
- * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
19384
- * canonical `AudioResult` from the Phase 6 output rework: one
19385
- * `AudioDetection` per class above `minScore`, top-N candidates in
19386
- * `debug.alternateLabels['audio-classifier']`, per-source timings in
19387
- * `debug.stepTimings`. The outer `success`/`error` fields stay so the
19388
- * benchmark UI can still report a clean failure when the classifier
19389
- * cap isn't available.
19390
- */
19391
- var AudioTestResultSchema = object({
19392
- success: boolean(),
19393
- error: string().optional(),
19394
- frame: custom().optional()
19395
- });
19396
- var PipelineConfigBridge = custom();
19397
- var ConfigUISchemaBridge = custom();
19398
- var ConfigUISchemaNullableBridge = custom();
19399
- var InferenceCapabilitiesBridge = custom();
19400
- var ModelAvailabilityListBridge = custom();
19401
- var PipelineRunResultBridge = custom();
19402
- /**
19403
- * Pipeline executor — detection engine + configuration + inference API.
19404
- *
19405
- * Merged from: pipeline-executor, pipeline-config, inference, detection-config.
19406
- * Implemented by the detection-pipeline addon.
19407
- *
19408
- * Per-device surface (DeviceSettingsContribution + the "is detection
19409
- * enabled for this camera?" toggle) lives on the paired
19410
- * `detection-pipeline` cap (device-scoped, singleton, wrapper
19411
- * defaultActive) — same split pattern used by stream-broker /
19412
- * camera-streams and audio-analyzer / audio-analysis.
18169
+ * Per-device surface (DeviceSettingsContribution + the "is detection
18170
+ * enabled for this camera?" toggle) lives on the paired
18171
+ * `detection-pipeline` cap (device-scoped, singleton, wrapper
18172
+ * defaultActive) — same split pattern used by stream-broker /
18173
+ * camera-streams and audio-analyzer / audio-analysis.
19413
18174
  */
19414
18175
  var pipelineExecutorCapability = {
19415
18176
  name: "pipeline-executor",
@@ -19461,6 +18222,60 @@ var pipelineExecutorCapability = {
19461
18222
  kind: "mutation",
19462
18223
  auth: "admin"
19463
18224
  }),
18225
+ /**
18226
+ * Which of THIS node's inference devices the executor currently refuses,
18227
+ * and why. `nodeId` is the ROUTING key (stripped by the generated router).
18228
+ *
18229
+ * The channel that did not exist. Pool health was known only inside the
18230
+ * detection addon and was an input to no routing decision anywhere: the
18231
+ * per-dispatch capability gate is keyed on model FORMAT and so can never
18232
+ * separate `openvino:gpu` from `openvino:npu`, and the orchestrator's live
18233
+ * eligibility probe (`platformProbe.getCapabilities`) answers about
18234
+ * HARDWARE — which was present throughout. So when the hub's `openvino:gpu`
18235
+ * Python worker was SIGABRT'd by the Intel GPU plugin on 2026-08-25, the
18236
+ * balancer went on handing that dead pool cameras by rotation for 31 hours:
18237
+ * ~370 000 `PoolWorker[w0]: not initialized` lines, every frame lost.
18238
+ *
18239
+ * Read semantics the caller depends on, and which the provider guarantees:
18240
+ * this is a synchronous read of in-memory state. It never probes hardware,
18241
+ * never spawns a pool and never throws — an EMPTY `unhealthy` means "asked,
18242
+ * nothing is refused", which is what re-admits a device. A read that FAILS
18243
+ * (node offline, version skew) must therefore be distinguishable from an
18244
+ * empty answer, and it is: it rejects.
18245
+ */
18246
+ getInferenceDeviceHealth: method(object({ nodeId: string() }), object({ unhealthy: array(object({
18247
+ /** `<backend>:<device>`, e.g. `openvino:gpu`. */
18248
+ deviceKey: string(),
18249
+ /**
18250
+ * `failed` — the per-device restart budget is exhausted; no pool
18251
+ * will be spawned until an operator re-arms it or the runner
18252
+ * respawns. `backoff` — under budget, waiting out the backoff (or
18253
+ * a cached pool observed dead and not yet condemned).
18254
+ */
18255
+ state: _enum(["failed", "backoff"]),
18256
+ /** Epoch ms of the death that produced this state. */
18257
+ since: number(),
18258
+ /** Pool deaths inside the current window. */
18259
+ deaths: number(),
18260
+ /** The last death's message. */
18261
+ lastError: string()
18262
+ })).readonly() })),
18263
+ /**
18264
+ * Re-arm a terminally `failed` inference device on `nodeId`: forget its
18265
+ * restart budget so the next dispatch builds a fresh pool.
18266
+ *
18267
+ * The terminal state is deliberate (the abort it bounds is deterministic —
18268
+ * an automatic probation would just respawn Python forever, more slowly),
18269
+ * and a terminal state an operator cannot leave is a silent fault. This is
18270
+ * the way out. `rearmed:false` means there was nothing to forget.
18271
+ */
18272
+ rearmInferenceDevice: method(object({
18273
+ nodeId: string(),
18274
+ deviceKey: string()
18275
+ }), object({ rearmed: boolean() }), {
18276
+ kind: "mutation",
18277
+ auth: "admin"
18278
+ }),
19464
18279
  getSchema: method(_void(), PipelineSchemaSchema),
19465
18280
  getGlobalSteps: method(_void(), array(PipelineDefaultStepSchema).readonly().nullable()),
19466
18281
  getGlobalPipelineConfig: method(_void(), PipelineConfigBridge),
@@ -19726,6 +18541,1503 @@ var pipelineExecutorCapability = {
19726
18541
  getDetectionConfigSchema: method(_void(), ConfigUISchemaNullableBridge)
19727
18542
  }
19728
18543
  };
18544
+ /**
18545
+ * Per-stage gating mode applied to the zones a rule references.
18546
+ *
18547
+ * - `include`: the rule contributes to a **whitelist** for its stage.
18548
+ * When at least one `include` rule fires for a stage, only entities
18549
+ * inside one of those zones pass that stage.
18550
+ * - `exclude`: the rule contributes to a **blacklist** for its stage.
18551
+ * Entities inside one of those zones are dropped at that stage.
18552
+ *
18553
+ * `monitor`-style observation (count without filtering) is not a rule
18554
+ * mode — zones without any matching rule are observed naturally by
18555
+ * `zone-analytics` (live snapshot + history), so an "I just want to
18556
+ * count, not filter" use case needs no rule at all.
18557
+ */
18558
+ var ZoneRuleModeEnum = _enum(["include", "exclude"]);
18559
+ /**
18560
+ * Per-consumer rule that references existing zones (geometry) and
18561
+ * defines how a specific pipeline stage should treat them. Each
18562
+ * consumer addon owns its own `ZoneRule[]` array in its per-device
18563
+ * settings:
18564
+ *
18565
+ * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
18566
+ * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
18567
+ * - future: notification rules, audio gating, etc.
18568
+ *
18569
+ * One rule applies to N zones (`zoneIds[]`) so the operator can
18570
+ * express "ignore motion in ALL of {garden, street}" with a single
18571
+ * rule. `classFilter` narrows the rule to specific object classes —
18572
+ * "drop person detections in the street, but keep cars" is one
18573
+ * `exclude` rule with `classFilter: ['person']`.
18574
+ *
18575
+ * `enabled` is a soft toggle — the operator can keep the rule
18576
+ * configured but inert without deleting it.
18577
+ */
18578
+ var ZoneRuleSchema = object({
18579
+ /** Stable rule id — survives edits, used by the UI for diffing. */
18580
+ id: string(),
18581
+ /** Optional human-readable label rendered in the rule editor. */
18582
+ name: string().optional(),
18583
+ /** Zones this rule targets. The rule's `mode` applies to ALL
18584
+ * listed zones (OR-set: a detection in any one of them counts).
18585
+ * At least one zone id required — a rule with no targets is a
18586
+ * configuration mistake and the form validator rejects it. */
18587
+ zoneIds: array(string()).min(1).readonly(),
18588
+ mode: ZoneRuleModeEnum,
18589
+ /**
18590
+ * Class names this rule applies to. Empty / undefined ⇒ rule
18591
+ * applies to every class. Class strings match the `macroClass`
18592
+ * field on detections (e.g. `person`, `car`, `dog`).
18593
+ */
18594
+ classFilter: array(string()).readonly().optional(),
18595
+ /**
18596
+ * Minimum bbox/mask overlap (0–1) with any of the rule's zones
18597
+ * required to consider an entity "in the zone". Defaults to the
18598
+ * consumer's stage default when omitted. Kept for back-compat with
18599
+ * existing per-rule overrides; new operators pick the value via
18600
+ * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
18601
+ * set, the lower-level engine reads it as a 0–1 fraction.
18602
+ */
18603
+ overlapThreshold: number().min(0).max(1).optional(),
18604
+ /**
18605
+ * Operator-friendly version of `overlapThreshold` — the percentage
18606
+ * of the detection's bbox that must lie inside the zone for the
18607
+ * rule to match. Documented default is 85%; the engine substitutes
18608
+ * that when the field is omitted (kept optional so existing rules
18609
+ * stored without it stay valid).
18610
+ *
18611
+ * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
18612
+ * rule, the engine prefers `bboxInclusionPct` because it's the
18613
+ * field exposed in the UI. Internally both feed the same gate.
18614
+ */
18615
+ bboxInclusionPct: number().min(0).max(100).optional(),
18616
+ /**
18617
+ * When `true` and a detection has a segmentation mask, use the
18618
+ * mask for overlap instead of the bbox. Detection-stage only;
18619
+ * motion rules ignore this field.
18620
+ */
18621
+ preferMask: boolean().optional(),
18622
+ /**
18623
+ * Soft-toggle: `false` disables the rule without deleting it.
18624
+ * Defaults to `true` so operators creating a rule via the UI
18625
+ * see it active immediately.
18626
+ */
18627
+ enabled: boolean().default(true)
18628
+ });
18629
+ array(ZoneRuleSchema).readonly();
18630
+ /**
18631
+ * Zone — pure geometry + identity. NO filtering behaviour.
18632
+ *
18633
+ * Zones describe **where** in the frame the operator wants to flag
18634
+ * something; consumer-owned {@link ZoneRule} arrays describe **how**
18635
+ * each pipeline stage uses them. Splitting the two means a single
18636
+ * polygon "Driveway" can simultaneously back a motion-exclude rule,
18637
+ * a detection-include rule on `['car']`, and an occupancy aggregate
18638
+ * — without three duplicated polygons.
18639
+ *
18640
+ * Owned by the orchestrator addon (provider) and mirrored into the
18641
+ * `zones` device-state slice on every mutation. Consumers
18642
+ * (motion-wasm, pipeline-executor, analytics, admin UI) read either
18643
+ * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
18644
+ * mirror with `onChanged`).
18645
+ *
18646
+ * Coordinates are normalised fractions of the frame (0–1) so zones
18647
+ * survive resolution changes and stream profile switches.
18648
+ *
18649
+ * `kind` discriminates between full polygons (closed regions used
18650
+ * for intrusion / occupancy filters) and tripwires (open 2-point
18651
+ * line segments used for cross events). Onboard / firmware-reported
18652
+ * zones (Reolink, ONVIF) are out of scope for now — see the deferred
18653
+ * task list.
18654
+ */
18655
+ var ZoneKindEnum = _enum(["polygon", "tripwire"]);
18656
+ /** Polygon vertex in fraction-of-frame coordinates (0–1). */
18657
+ var PolygonPointSchema = object({
18658
+ x: number(),
18659
+ y: number()
18660
+ });
18661
+ /** A camera detection zone — pure geometry/identity. */
18662
+ var ZoneSchema = object({
18663
+ id: string(),
18664
+ name: string(),
18665
+ kind: ZoneKindEnum.default("polygon"),
18666
+ /** Polygon vertices, fraction of frame (0–1). */
18667
+ polygon: array(PolygonPointSchema).readonly(),
18668
+ /** Visual color for UI rendering. */
18669
+ color: string().default("#3b82f6")
18670
+ });
18671
+ DeviceType.Camera, method(object({ deviceId: number() }), array(ZoneSchema).readonly()), method(object({
18672
+ deviceId: number(),
18673
+ zone: ZoneSchema
18674
+ }), _void(), {
18675
+ kind: "mutation",
18676
+ auth: "admin"
18677
+ }), method(object({
18678
+ deviceId: number(),
18679
+ zoneId: string()
18680
+ }), _void(), {
18681
+ kind: "mutation",
18682
+ auth: "admin"
18683
+ }), method(object({
18684
+ deviceId: number(),
18685
+ zone: ZoneSchema
18686
+ }), _void(), {
18687
+ kind: "mutation",
18688
+ auth: "admin"
18689
+ }), object({ zones: array(ZoneSchema).readonly() });
18690
+ /**
18691
+ * pipeline-analytics — device-scoped wrapper cap. Refines raw
18692
+ * per-frame detections emitted by the pipeline runner into tracked
18693
+ * objects, per-kind event collections (motion / object / audio), and
18694
+ * persisted media. Owns the post-detection domain end-to-end:
18695
+ *
18696
+ * runner emits PipelineInferenceResult
18697
+ * ↓ (event bus)
18698
+ * pipeline-analytics subscriber
18699
+ * ↓ SORT tracker + zone engine + state analyzer + event emitter
18700
+ * → three DB collections (one per kind), one FS media tree, one
18701
+ * unified event emitter (FrameTracked + TrackStarted/Ended +
18702
+ * DetectionEvent on bus)
18703
+ *
18704
+ * Pure subscriber model. No `processFrame` cap method — the runner
18705
+ * already publishes the raw frame on the bus. The cap surface is
18706
+ * only QUERIES + per-device settings, bound on/off via
18707
+ * `device-manager.setWrapperActive`. `defaultActive: true` because
18708
+ * every camera with a detection pipeline wants its raw detections
18709
+ * refined; operators opt out per-device via BindingsTab when needed.
18710
+ *
18711
+ * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
18712
+ * (per-device surface) and `track-trail` caps — see P11 cleanup.
18713
+ */
18714
+ var TrackStateSchema = _enum([
18715
+ "new",
18716
+ "entered",
18717
+ "left",
18718
+ "moving",
18719
+ "idle"
18720
+ ]);
18721
+ var EventKindSchema = _enum([
18722
+ "motion",
18723
+ "object",
18724
+ "audio"
18725
+ ]);
18726
+ /**
18727
+ * Spatial filter for `listTracks` — the rect + polygon variants of the shared
18728
+ * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
18729
+ * of the camera frame (top-left origin), matching the drawing-plane editor.
18730
+ */
18731
+ var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
18732
+ /** Closed icon vocabulary so clients render a known glyph per kind. */
18733
+ var EventKindIconSchema = _enum([
18734
+ "motion",
18735
+ "audio",
18736
+ "person",
18737
+ "vehicle",
18738
+ "animal",
18739
+ "door",
18740
+ "pir",
18741
+ "smoke",
18742
+ "water",
18743
+ "button",
18744
+ "package",
18745
+ "generic"
18746
+ ]);
18747
+ var EventKindCategorySchema = _enum([
18748
+ "motion",
18749
+ "audio",
18750
+ "detection",
18751
+ "sensor",
18752
+ "control",
18753
+ "custom",
18754
+ "package"
18755
+ ]);
18756
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
18757
+ var EventKindLevelSchema = _enum(["macro", "sub"]);
18758
+ var EventKindDescriptorSchema = object({
18759
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
18760
+ kind: string(),
18761
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
18762
+ labelKey: string(),
18763
+ /** English fallback label (kept for clients that don't translate). */
18764
+ label: string(),
18765
+ /** Hex color for timeline/legend rendering. */
18766
+ color: string(),
18767
+ /** Dictionary id → lucide component on the UI side. */
18768
+ iconId: string(),
18769
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
18770
+ icon: EventKindIconSchema,
18771
+ category: EventKindCategorySchema,
18772
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
18773
+ parentKind: string().nullable(),
18774
+ /** Derived from `parentKind`, explicit for the client tree. */
18775
+ level: EventKindLevelSchema,
18776
+ /** Which cap + device contributes this kind. For built-ins the camera
18777
+ * itself; for sensor kinds the LINKED source device. */
18778
+ source: object({
18779
+ capName: string(),
18780
+ deviceId: number()
18781
+ })
18782
+ });
18783
+ /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
18784
+ var EventKindsForDeviceSchema = object({
18785
+ deviceId: number(),
18786
+ kinds: array(EventKindDescriptorSchema).readonly()
18787
+ });
18788
+ var SensorEventSchema = object({
18789
+ id: string(),
18790
+ /** The CAMERA the event is attributed to (a sensor linked to N cameras
18791
+ * yields N rows, one per camera). */
18792
+ deviceId: number(),
18793
+ /** The linked sensor device whose state changed. */
18794
+ sourceDeviceId: number(),
18795
+ /** Event kind id — matches an `EventKindDescriptor.kind`. */
18796
+ kind: string(),
18797
+ /** Snapshot of the sensor cap's runtime-state slice at the change. */
18798
+ value: record(string(), unknown()).nullable(),
18799
+ timestamp: number()
18800
+ });
18801
+ var TrackPositionSchema = object({
18802
+ x: number(),
18803
+ y: number(),
18804
+ timestamp: number(),
18805
+ bbox: BoundingBoxSchema
18806
+ });
18807
+ var TrackSnapshotSchema = object({
18808
+ timestamp: number(),
18809
+ position: TrackPositionSchema,
18810
+ /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
18811
+ mediaKey: string()
18812
+ });
18813
+ /**
18814
+ * Normalized 0..1 trajectory envelope (min/max over every position bbox,
18815
+ * divided by the track's detection-frame dims), computed at persist time.
18816
+ * Absent when the frame dims were unknown when the track was persisted
18817
+ * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
18818
+ */
18819
+ var TrackEnvelopeSchema = object({
18820
+ minX: number(),
18821
+ minY: number(),
18822
+ maxX: number(),
18823
+ maxY: number()
18824
+ });
18825
+ /**
18826
+ * Row projection for track list queries. `full` (default) returns the
18827
+ * complete Track including the frame-rate `positions[]` history and the
18828
+ * `snapshots[]` references — megabytes across a page of tracks. `slim`
18829
+ * keeps every scalar the list surfaces actually render (ids, class(es),
18830
+ * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
18831
+ * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
18832
+ * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
18833
+ * `getTrack`. Mirrors the event-store `projection` convention
18834
+ * (`getObjectEvents` et al.).
18835
+ */
18836
+ var TrackProjectionSchema = _enum(["full", "slim"]);
18837
+ /**
18838
+ * One audio-classification label heard on the track's camera while the
18839
+ * track was alive, aggregated per label. An "episode" is one persisted
18840
+ * audio event (the confident-classification path: score ≥ the device's
18841
+ * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
18842
+ * one 32 ms inference chunk, so counts stay human-scaled.
18843
+ */
18844
+ var TrackAudioLabelSchema = object({
18845
+ label: string(),
18846
+ /** Highest classification score observed across the label's episodes. */
18847
+ peakScore: number(),
18848
+ /** Number of coalesced audio-event episodes carrying this label. */
18849
+ count: number(),
18850
+ firstAt: number(),
18851
+ lastAt: number()
18852
+ });
18853
+ /**
18854
+ * How a track was produced. `pipeline` (default / absent) = the spatial
18855
+ * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
18856
+ * no positions, a single snapshot, and no bbox trajectory at all:
18857
+ *
18858
+ * - `sensor` — a linked sensor/control device state change.
18859
+ * - `audio` — an audio event on the camera itself that was anomalous for
18860
+ * THAT camera, loud, and heard while nothing visual was happening (D62).
18861
+ *
18862
+ * The spatial subsystems (tracker association, occupancy count, re-id /
18863
+ * embedding, resurrection) MUST skip every synthetic source. Test for that
18864
+ * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
18865
+ * check silently readmits every source added after it was written.
18866
+ */
18867
+ var TrackSourceSchema = _enum([
18868
+ "pipeline",
18869
+ "sensor",
18870
+ "audio"
18871
+ ]);
18872
+ /**
18873
+ * Where a track sits in the RETRAIN lifecycle (D81).
18874
+ *
18875
+ * - `none` — never marked, or un-marked. Evictable.
18876
+ * - `staging` — the operator wants this track as training material and has not
18877
+ * finished with it. **This is the only state retention holds**: the track and
18878
+ * everything it owns (object events, crops, keyframes, CLIP vector) survive
18879
+ * the device's age window.
18880
+ * - `trained` — the retrain page has taken what it needed. The frames it chose
18881
+ * were COPIED into the retrain dataset at selection time, so the dataset no
18882
+ * longer depends on the track's media and the track becomes EVICTABLE again.
18883
+ * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
18884
+ * a deliberate action of the retrain page, not a side effect of a checkbox.
18885
+ *
18886
+ * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
18887
+ * the store's filter language has only positive equality and `whereIn` — no
18888
+ * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
18889
+ * would make the entire pre-column history immortal in one deploy.
18890
+ */
18891
+ var RetrainStatusSchema = _enum([
18892
+ "none",
18893
+ "staging",
18894
+ "trained"
18895
+ ]);
18896
+ /**
18897
+ * Per-track OPERATOR flags — set by hand from the admin UI or the viewer, never
18898
+ * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
18899
+ * so the two surfaces cannot drift.
18900
+ *
18901
+ * **Absent ≠ false.** A track that has never been touched omits the field; an
18902
+ * explicitly un-flagged track carries `false`. Legacy rows written before the
18903
+ * columns existed read as absent, and a consumer that needs a boolean should say
18904
+ * `flag === true`, not `flag !== false`.
18905
+ *
18906
+ * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
18907
+ * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
18908
+ * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
18909
+ * `trained` track reports `false` while refusing both writes. The boolean is
18910
+ * kept because three surfaces drive a toggle off it; anything that needs to tell
18911
+ * "never marked" from "already trained" must read `retrainStatus`.
18912
+ *
18913
+ * `debug` does NOT pin; it is attention, not durability.
18914
+ *
18915
+ * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
18916
+ * A favourited track is skipped by retention the same way `staging` is, but
18917
+ * it does not enter `none|staging|trained` and has no staging budget.
18918
+ */
18919
+ var TrackFlagFields = {
18920
+ /** Operator marked this track as training material — i.e. `retrainStatus` is
18921
+ * `'staging'`. */
18922
+ markForTrain: boolean().optional(),
18923
+ /** Operator marked this track for diagnostic attention. */
18924
+ debug: boolean().optional(),
18925
+ /** Operator favourited this track. Pins it against pruning. */
18926
+ favourited: boolean().optional()
18927
+ };
18928
+ /**
18929
+ * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
18930
+ * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
18931
+ * write patch, and the status is not something the toggle sets — it is what the
18932
+ * toggle's boolean is derived from. Absent on an in-RAM track never touched;
18933
+ * always present on a persisted row (the column default materialises `'none'`).
18934
+ */
18935
+ var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
18936
+ /**
18937
+ * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
18938
+ * one flag can never clear the other — the toggles are independent and are
18939
+ * driven from three surfaces that do not know about each other.
18940
+ */
18941
+ var TrackFlagsPatchSchema = object(TrackFlagFields);
18942
+ /**
18943
+ * The resolved flag state after a write. Both fields are REQUIRED here (absent
18944
+ * collapses to `false`) so a caller can drive a toggle's checked state off the
18945
+ * mutation result without a re-fetch.
18946
+ */
18947
+ var TrackFlagsSchema = object({
18948
+ trackId: string(),
18949
+ markForTrain: boolean(),
18950
+ debug: boolean(),
18951
+ favourited: boolean(),
18952
+ /** The lifecycle state the boolean was derived from. Required here (unlike on
18953
+ * a track row) because this shape is only ever produced by the write body,
18954
+ * which always knows it — and a surface that has just written needs to render
18955
+ * `trained` without a re-fetch. */
18956
+ retrainStatus: RetrainStatusSchema
18957
+ });
18958
+ union([literal(1), literal(2)]);
18959
+ /**
18960
+ * WHO decided a label, and when. Carried per tier so a value can be traced to
18961
+ * the step and model that produced it — which is what makes the write rule
18962
+ * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
18963
+ * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
18964
+ *
18965
+ * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
18966
+ * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
18967
+ * `migration:4g` for a value the 4g migration moved from the single-slot era —
18968
+ * that value has no provenance, and the write rule lets ANY properly-attributed
18969
+ * write of the same tier replace it regardless of score.
18970
+ */
18971
+ var LabelAttributionSchema = object({
18972
+ stepId: string(),
18973
+ modelId: string().optional(),
18974
+ decidedAt: number(),
18975
+ /**
18976
+ * The GALLERY id behind a recognised tier-2 label — a face-gallery
18977
+ * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
18978
+ *
18979
+ * The text alone is a DISPLAY NAME, and a display name is renameable: a
18980
+ * notification rule authored on "Gianluca" stopped matching the moment the
18981
+ * operator fixed the spelling in the gallery, and nothing said so. The id is
18982
+ * the thing that does not move, so it is what a rule matches on
18983
+ * (`NcConditions.identities`) and the text is what a human is shown.
18984
+ *
18985
+ * Absent when the label names no gallery row — a plate the OCR read but no
18986
+ * vehicle claims, a sub-class, a species, any tier-1 value.
18987
+ */
18988
+ identityId: string().optional()
18989
+ });
18990
+ /**
18991
+ * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
18992
+ * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
18993
+ * track and its events always answer the same question the same way.
18994
+ *
18995
+ * Two scalar columns, not an array: every consumer wants "the coarse one" or
18996
+ * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
18997
+ * is tier 2, and each carries its own score + attribution.
18998
+ *
18999
+ * **Reading it.** What a human should be shown is `subLabel ?? label` — the
19000
+ * finest thing known. Before 4g the single `label` column held the finest
19001
+ * value, so a consumer that has not been updated reads the tier-1 slot and
19002
+ * shows nothing on a species-only row; that is why the migration puts every
19003
+ * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
19004
+ * and why the read surfaces were changed in the same train.
19005
+ *
19006
+ * **Writing it.** The slots are independent, which is the whole point: a
19007
+ * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
19008
+ * migratorius`), so fineness cannot regress by construction. Within a tier the
19009
+ * higher score wins. One rule, one implementation — see
19010
+ * `pipeline/label-tier.ts` in addon-post-analysis.
19011
+ */
19012
+ var TieredLabelFields = {
19013
+ /** Tier 1 — the sub-class. See {@link LabelTierSchema}. */
19014
+ label: string().optional(),
19015
+ /** Confidence of the tier-1 value, as reported by the deciding step. */
19016
+ labelScore: number().optional(),
19017
+ /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
19018
+ labelMeta: LabelAttributionSchema.optional(),
19019
+ /** Tier 2 — the instance. See {@link LabelTierSchema}. */
19020
+ subLabel: string().optional(),
19021
+ /** Confidence of the tier-2 value, as reported by the deciding step. */
19022
+ subLabelScore: number().optional(),
19023
+ /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
19024
+ subLabelMeta: LabelAttributionSchema.optional()
19025
+ };
19026
+ /** Per-camera slice of a training-export estimate. */
19027
+ var TrainingExportDeviceTotalsSchema = object({
19028
+ deviceId: number(),
19029
+ tracks: number().int(),
19030
+ files: number().int(),
19031
+ bytes: number().int()
19032
+ });
19033
+ /**
19034
+ * What a training export WOULD contain. Computed from media index rows only —
19035
+ * no blob is read to produce this.
19036
+ */
19037
+ var TrainingExportSummarySchema = object({
19038
+ generatedAt: number(),
19039
+ trackCount: number().int(),
19040
+ fileCount: number().int(),
19041
+ byteCount: number().int(),
19042
+ /** More marked tracks exist than a single pass carries. */
19043
+ truncated: boolean(),
19044
+ devices: array(TrainingExportDeviceTotalsSchema).readonly()
19045
+ });
19046
+ var TrackSchema = object({
19047
+ trackId: string(),
19048
+ deviceId: number(),
19049
+ className: string(),
19050
+ ...TieredLabelFields,
19051
+ producingDeviceName: string().optional(),
19052
+ /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
19053
+ source: TrackSourceSchema.optional(),
19054
+ firstSeen: number(),
19055
+ lastSeen: number(),
19056
+ /** Frame-rate position history (subject to maxPositionHistory cap). */
19057
+ positions: array(TrackPositionSchema).readonly(),
19058
+ /** Periodic snapshots at snapshotIntervalMs cadence (subject to
19059
+ * saveThumbnails policy). */
19060
+ snapshots: array(TrackSnapshotSchema).readonly(),
19061
+ /** Deduplicated zones the track has entered at least once. Zone IDS. */
19062
+ zonesVisited: array(string()).readonly(),
19063
+ /**
19064
+ * Human NAMES for {@link zonesVisited}, resolved at READ time against the
19065
+ * `zones` capability.
19066
+ *
19067
+ * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
19068
+ * and no card can render — so every free-text search surface was structurally
19069
+ * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
19070
+ * just returned nothing. Resolving here rather than in each client keeps ONE
19071
+ * derivation and costs the clients no extra call (the `zones` cap is
19072
+ * per-device, so a client-side resolve would be a per-camera fan-out on a
19073
+ * surface built to avoid exactly that).
19074
+ *
19075
+ * Resolved, never invented: a zone deleted since the track was written has no
19076
+ * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
19077
+ * two are not positionally aligned. Absent when the track visited no zone, or
19078
+ * when the zone catalogue could not be read.
19079
+ */
19080
+ zoneNames: array(string()).readonly().optional(),
19081
+ /** Deduplicated set of detector classes observed for this track over its
19082
+ * life (a track may be reclassified, e.g. person→vehicle). Absent on
19083
+ * legacy rows written before class accumulation shipped. */
19084
+ classes: array(string()).readonly().optional(),
19085
+ /** Cumulative normalized distance travelled (0..1 units = full frame width). */
19086
+ totalDistance: number(),
19087
+ state: TrackStateSchema,
19088
+ active: boolean(),
19089
+ /** Deterministic key-event importance score in [0,1] (server-computed at
19090
+ * track expiry, recomputed on late label). Absent on legacy rows written
19091
+ * before scoring shipped — consumers degrade to absence / compute-on-read. */
19092
+ importance: number().optional(),
19093
+ /** Id of the track's highest-confidence ObjectEvent (its representative
19094
+ * "best" frame). Absent when the track produced no object events. */
19095
+ bestEventId: string().optional(),
19096
+ /** Tag of the importance sub-signal that dominated the score
19097
+ * (identity|dwell|proximity|class|confidence|travel|zone). */
19098
+ importanceReason: string().optional(),
19099
+ /** Audio-classification labels heard on the camera during the track's
19100
+ * life (score ≥ device `classificationMinScore`), aggregated per label.
19101
+ * Absent on legacy rows / tracks with no confident audio. */
19102
+ audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
19103
+ /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
19104
+ * Populated from the persisted envelope columns on historical reads;
19105
+ * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
19106
+ envelope: TrackEnvelopeSchema.optional(),
19107
+ /**
19108
+ * A face DETECTOR found a face on this track — nothing more. It says the
19109
+ * detail plane produced a `face` detail; it does NOT say the face was
19110
+ * embedded, matched, above `minFacePx`, or that the recognizer was even
19111
+ * enabled. Set once and never cleared.
19112
+ *
19113
+ * **This exists so "face present but not recognised" is expressible.** A
19114
+ * recognised identity lands in `subLabel` (attributed to the face chain via
19115
+ * `subLabelMeta.stepId`), so before this field a track with an unmatched face
19116
+ * and a track with no face at all were byte-identical on the wire and no
19117
+ * surface could tell them apart. The read is `hasFace === true && subLabel
19118
+ * === undefined`.
19119
+ *
19120
+ * **Absent ≠ false.** Every row written before the column existed omits it,
19121
+ * and so does every server that predates the field — a consumer must test
19122
+ * `=== true` and render nothing otherwise, never infer "no face".
19123
+ */
19124
+ hasFace: boolean().optional(),
19125
+ /**
19126
+ * This track has a face row IN THE GALLERY: a crop **and** an embedding — a
19127
+ * face an operator could ASSIGN to an identity.
19128
+ *
19129
+ * The STRICT twin of {@link hasFace}, and the pair only earns its keep
19130
+ * because the two disagree. `hasFace` is stamped at the TOP of the face
19131
+ * branch, before every gate, and means no more than "a face detector produced
19132
+ * a face detail". This one is stamped at the single moment the gallery row
19133
+ * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
19134
+ * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
19135
+ * candidate gate, the imageless-track drop (no crop was ever captured) and
19136
+ * the crop-store drop. Everything between the detector and that insert can
19137
+ * legitimately refuse the face, so a flag written any earlier promises the
19138
+ * operator something to assign and delivers nothing.
19139
+ *
19140
+ * **Independent of recognition.** A face collected but never auto-matched is
19141
+ * still assignable — it is in fact the face an operator most wants to reach —
19142
+ * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
19143
+ * `subLabel`; this says only that the raw material exists.
19144
+ *
19145
+ * **Set once, never cleared.** A track that produced a gallery row produced
19146
+ * one; deleting the row later is the gallery's business, not this flag's.
19147
+ *
19148
+ * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
19149
+ * before the column omits it, and so does every server that predates the
19150
+ * field. A consumer must test `=== true` and render nothing otherwise —
19151
+ * never infer "no assignable face".
19152
+ */
19153
+ hasEmbeddedFace: boolean().optional(),
19154
+ /**
19155
+ * This subject CONTAINS a folded rider — a person the rider-pairing step
19156
+ * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
19157
+ * so the passage is tracked once and as a VEHICLE.
19158
+ *
19159
+ * It exists because the fold's record was dishonest. D34 and the code both
19160
+ * said "the person is not lost — it is reported so both entities stay on the
19161
+ * record"; in fact the pair went into a per-processor RAM field behind an
19162
+ * accessor nobody called, and every durable surface said `vehicle`, full
19163
+ * stop. This is the composition note that makes the row true.
19164
+ *
19165
+ * A COMPOSITION, never a class and never a label. "This vehicle contains a
19166
+ * person" is not an answer to "what is this" — both label tiers would refuse
19167
+ * a macro token anyway (D89), and correctly. Nothing here changes what the
19168
+ * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
19169
+ * and a `person` rule still does not fire for someone cycling past.
19170
+ *
19171
+ * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
19172
+ * the column, and every hub that predates the field, omits it. Test
19173
+ * `=== true` and render nothing otherwise — never infer "no rider".
19174
+ */
19175
+ hasRider: boolean().optional(),
19176
+ ...TrackFlagFields,
19177
+ ...TrackRetrainFields
19178
+ });
19179
+ var BaseEventFields = {
19180
+ id: string(),
19181
+ deviceId: number(),
19182
+ timestamp: number()
19183
+ };
19184
+ var MotionEventSchema = object({
19185
+ ...BaseEventFields,
19186
+ kind: literal("motion"),
19187
+ regionCount: number(),
19188
+ /** Heavy JSON array — omitted in slim projection. */
19189
+ regions: array(object({
19190
+ bbox: BoundingBoxSchema,
19191
+ pixelCount: number(),
19192
+ intensity: number()
19193
+ })).readonly().optional(),
19194
+ /** Omitted in slim projection. */
19195
+ frameWidth: number().optional(),
19196
+ /** Omitted in slim projection. */
19197
+ frameHeight: number().optional(),
19198
+ /** Populated by B5 (recording playback URL for this event). */
19199
+ mediaUrl: string().optional()
19200
+ });
19201
+ /**
19202
+ * Which detection SOURCE produced an object event. `pipeline` = the ML
19203
+ * detection pipeline (decoded-frame inference); `onboard` = the camera's
19204
+ * native on-device AI. Both flow through the SAME analysis layers (zoning,
19205
+ * tracking, per-kind persistence) but stay distinguishable so consumers
19206
+ * (advanced-notifier, occupancy, …) can select which source(s) to act on.
19207
+ * Absent on legacy rows ⇒ treat as `pipeline`.
19208
+ */
19209
+ var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
19210
+ /**
19211
+ * The confirmed zone crossing that produced an object event. Present ONLY on
19212
+ * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
19213
+ * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
19214
+ * appearance event carry none, so a rule asking for a direction fails closed
19215
+ * on them.
19216
+ *
19217
+ * Exactly ONE crossing per event: the emitter turns each confirmed crossing
19218
+ * into its own event, so a frame in which a track enters A while leaving B
19219
+ * produces two events with two directions — never one ambiguous row.
19220
+ *
19221
+ * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
19222
+ * membership the box has NOW, and by definition it no longer contains the zone
19223
+ * that was just left. Without the id here, a zone-scoped rule could never match
19224
+ * the exit it asked for.
19225
+ */
19226
+ var ZoneCrossingSchema = object({
19227
+ direction: _enum(["enter", "exit"]),
19228
+ /** Admin zone id crossed. */
19229
+ zoneId: string(),
19230
+ /** Zone display name at crossing time (falls back to the id). */
19231
+ zoneName: string().optional()
19232
+ });
19233
+ var ObjectEventSchema = object({
19234
+ ...BaseEventFields,
19235
+ kind: literal("object"),
19236
+ /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
19237
+ source: DetectionSourceSchema.optional(),
19238
+ /**
19239
+ * Inference-frame id shared by every object event emitted from the SAME frame
19240
+ * — the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
19241
+ * 2 people + 1 dog) under one full frame, and link a track's frames over time
19242
+ * (group by `trackId`, pick a representative `frameId` as the parent frame).
19243
+ * Optional for backward-compat with pre-existing rows / the slim projection
19244
+ * includes it (it is light). Absent on rows written before this field.
19245
+ */
19246
+ frameId: string().optional(),
19247
+ /** Omitted in slim projection. */
19248
+ trackId: string().optional(),
19249
+ className: string(),
19250
+ ...TieredLabelFields,
19251
+ /** Omitted in slim projection. */
19252
+ confidence: number().optional(),
19253
+ /** Heavy JSON — omitted in slim projection. */
19254
+ bbox: BoundingBoxSchema.optional(),
19255
+ /** Heavy JSON — omitted in slim projection. */
19256
+ zones: array(string()).readonly().optional(),
19257
+ /** Omitted in slim projection. */
19258
+ state: TrackStateSchema.optional(),
19259
+ /**
19260
+ * The zone crossing this event IS, when it is one. Absent on every other
19261
+ * event kind (movement state, appearance, package) — see
19262
+ * {@link ZoneCrossingSchema}. Omitted in slim projection.
19263
+ */
19264
+ zoneCrossing: ZoneCrossingSchema.optional(),
19265
+ /** Detection-frame dimensions in pixels — let consumers normalize the
19266
+ * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
19267
+ frameWidth: number().optional(),
19268
+ frameHeight: number().optional(),
19269
+ /** MediaStore key for the crop attached to this event (if any). */
19270
+ mediaKey: string().optional(),
19271
+ /** Design B: MediaStore key of the track's native-resolution key frame (the
19272
+ * best-detection full frame). Resolve via the event-media data-plane
19273
+ * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
19274
+ * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
19275
+ * sources — consumers fall back to `mediaKey` (the tight crop). */
19276
+ keyFrameMediaKey: string().optional(),
19277
+ /** Populated by B5 (recording playback URL for this event). */
19278
+ mediaUrl: string().optional(),
19279
+ /** The parent track's key-event importance [0,1], propagated to every object
19280
+ * event of the track (so an event row can be sorted by importance without a
19281
+ * track join). Absent on legacy rows / before the track was scored. */
19282
+ importance: number().optional()
19283
+ });
19284
+ var AudioEventSchema = object({
19285
+ ...BaseEventFields,
19286
+ kind: literal("audio"),
19287
+ rms: number(),
19288
+ dbfs: number(),
19289
+ classification: object({
19290
+ className: string(),
19291
+ originalClass: string().optional(),
19292
+ score: number()
19293
+ }).optional(),
19294
+ /** Populated by B5 (recording playback URL for this event). */
19295
+ mediaUrl: string().optional()
19296
+ });
19297
+ var MediaFileKindEnum = _enum([
19298
+ "crop",
19299
+ "thumbnail",
19300
+ "snapshot",
19301
+ "firstFrame",
19302
+ "lastFrame",
19303
+ "fullFrame",
19304
+ "fullFrameBoxed",
19305
+ "faceCrop",
19306
+ "plateCrop",
19307
+ "keyFrame",
19308
+ "keyFrameSmall",
19309
+ "thumbnailSmall"
19310
+ ]);
19311
+ var MediaFileSchema = object({
19312
+ key: string(),
19313
+ kind: MediaFileKindEnum,
19314
+ base64: string(),
19315
+ sizeBytes: number(),
19316
+ timestamp: number()
19317
+ });
19318
+ /**
19319
+ * One media row WITHOUT its bytes.
19320
+ *
19321
+ * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
19322
+ * 140 s track), and a client that renders tiles from the media data plane needs
19323
+ * to know only WHAT EXISTS — the bytes then arrive per tile, lazily, over HTTP
19324
+ * with an immutable cache, instead of all at once inside a tRPC response that
19325
+ * blocks the whole view.
19326
+ *
19327
+ * `sizeBytes` is carried because it is what lets a client decide between the
19328
+ * stored blob and a `?variant=thumb` rendering without fetching either.
19329
+ */
19330
+ var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
19331
+ /**
19332
+ * The MACRO tier of an annotation — a CLOSED set.
19333
+ *
19334
+ * This is what the exported detector predicts, so a typo here is a new class
19335
+ * with one example in it. `label` and `subLabel` are open strings by contrast:
19336
+ * the whole point of the page is teaching the model things it does not know
19337
+ * yet, and constraining that vocabulary would make it useless.
19338
+ *
19339
+ * A macro class is NEVER a label. The provider refuses a write whose `label` or
19340
+ * `subLabel` is one of these values, in any casing, because once `person`
19341
+ * exists in both tiers "every person box" stops being answerable without
19342
+ * knowing every string anyone ever typed — and the damage is retroactive.
19343
+ */
19344
+ var RetrainMacroClassSchema = _enum([
19345
+ "person",
19346
+ "vehicle",
19347
+ "animal",
19348
+ "package",
19349
+ "face",
19350
+ "plate"
19351
+ ]);
19352
+ /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
19353
+ var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
19354
+ /** Did a human draw this box, or did the assist propose it? */
19355
+ var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
19356
+ /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
19357
+ var RetrainBboxSchema = object({
19358
+ x: number(),
19359
+ y: number(),
19360
+ w: number(),
19361
+ h: number()
19362
+ });
19363
+ /**
19364
+ * One annotated subject.
19365
+ *
19366
+ * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
19367
+ * (letterboxed root / zone-cropped package / subject-cropped classifier) are
19368
+ * derived from it at export and never stored — storing them is how one feature
19369
+ * space ends up holding two crops of the same subject (D52).
19370
+ */
19371
+ var RetrainAnnotationSchema = object({
19372
+ id: string(),
19373
+ trackId: string(),
19374
+ deviceId: number(),
19375
+ /** The COPY in retrain storage — never the source track's media key. */
19376
+ mediaKey: string(),
19377
+ bbox: RetrainBboxSchema,
19378
+ macroClass: RetrainMacroClassSchema,
19379
+ label: string().optional(),
19380
+ subLabel: string().optional(),
19381
+ kind: RetrainAnnotationKindSchema,
19382
+ source: RetrainAnnotationSourceSchema,
19383
+ /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
19384
+ assistModelId: string().optional(),
19385
+ assistScore: number().optional(),
19386
+ exportedInBatch: string().optional(),
19387
+ createdAt: number()
19388
+ });
19389
+ /** The write form — the server owns `id`, `createdAt` and the frame binding. */
19390
+ var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
19391
+ id: true,
19392
+ trackId: true,
19393
+ deviceId: true,
19394
+ mediaKey: true,
19395
+ createdAt: true,
19396
+ exportedInBatch: true
19397
+ });
19398
+ /** A track sitting in `staging`, with everything the worklist needs to rank it. */
19399
+ var RetrainTrackSchema = object({
19400
+ trackId: string(),
19401
+ deviceId: number(),
19402
+ className: string(),
19403
+ label: string().optional(),
19404
+ firstSeen: number(),
19405
+ lastSeen: number(),
19406
+ /** How many frames the dataset already holds from this track. */
19407
+ frameCount: number().int(),
19408
+ /** How many subjects have been annotated on those frames. `0` with
19409
+ * `frameCount: 0` is exactly "staging, still to work". */
19410
+ annotationCount: number().int()
19411
+ });
19412
+ /** A frame the picker may offer — an index row, no blob was read to produce it. */
19413
+ var RetrainFrameCandidateSchema = object({
19414
+ mediaKey: string(),
19415
+ kind: MediaFileKindEnum,
19416
+ timestamp: number(),
19417
+ sizeBytes: number().int(),
19418
+ /** A copy of this original already exists — selecting it is free and cannot
19419
+ * fail, whatever became of the original. */
19420
+ copied: boolean()
19421
+ });
19422
+ /** A frame the dataset OWNS: bytes copied at selection time. */
19423
+ var RetrainFrameSchema = object({
19424
+ frameId: string(),
19425
+ deviceId: number(),
19426
+ trackId: string(),
19427
+ /** Provenance only. It may already point at nothing — that is expected. */
19428
+ sourceMediaKey: string(),
19429
+ sourceKind: MediaFileKindEnum,
19430
+ sizeBytes: number().int(),
19431
+ width: number().int(),
19432
+ height: number().int(),
19433
+ copiedAt: number()
19434
+ });
19435
+ /** Why a copy-on-select could not be honoured — named, never a silent skip. */
19436
+ var RetrainCopyRefusalSchema = _enum([
19437
+ "source-missing",
19438
+ "unreadable-image",
19439
+ "write-failed"
19440
+ ]);
19441
+ var RetrainFrameSelectionSchema = object({
19442
+ copied: array(RetrainFrameSchema).readonly(),
19443
+ refused: array(object({
19444
+ sourceMediaKey: string(),
19445
+ reason: RetrainCopyRefusalSchema
19446
+ })).readonly()
19447
+ });
19448
+ var RetrainFrameListSchema = object({
19449
+ candidates: array(RetrainFrameCandidateSchema).readonly(),
19450
+ copies: array(RetrainFrameSchema).readonly(),
19451
+ /** What the page pre-selects — the native key frame when one survives. */
19452
+ autoPickMediaKey: string().optional()
19453
+ });
19454
+ /** What the operator asked the assist to look for. */
19455
+ var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
19456
+ kind: literal("package"),
19457
+ zone: RetrainBboxSchema.optional()
19458
+ }), object({
19459
+ kind: literal("objects"),
19460
+ modelId: string(),
19461
+ minScore: number().optional()
19462
+ })]);
19463
+ /**
19464
+ * The assist's answer — a discriminated union, because "the model saw nothing"
19465
+ * and "this node cannot run that model" lead to different next moves and a
19466
+ * nullable result cannot tell them apart.
19467
+ */
19468
+ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
19469
+ kind: literal("proposed"),
19470
+ modelId: string(),
19471
+ stepId: string(),
19472
+ minScore: number(),
19473
+ /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
19474
+ proposals: array(RetrainAnnotationDraftSchema).readonly(),
19475
+ /** Returned by the runner but removed by the threshold. */
19476
+ belowThreshold: number().int()
19477
+ }), object({
19478
+ kind: literal("refused"),
19479
+ /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
19480
+ reason: string(),
19481
+ detail: string().optional()
19482
+ })]);
19483
+ /** The outcome of a lifecycle move owned by the retrain page. */
19484
+ var RetrainTransitionResultSchema = object({
19485
+ trackId: string(),
19486
+ /** Where the track ended up, whatever happened. */
19487
+ retrainStatus: RetrainStatusSchema,
19488
+ /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
19489
+ changed: boolean(),
19490
+ reason: _enum([
19491
+ "unknown-track",
19492
+ "no-frames-copied",
19493
+ "not-staging",
19494
+ "not-trained",
19495
+ "unchanged"
19496
+ ]).optional()
19497
+ });
19498
+ var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
19499
+ var MAX_EVENT_QUERY_LIMIT = 5e3;
19500
+ var DeviceEventQueryInput = object({
19501
+ deviceId: number(),
19502
+ since: number().optional(),
19503
+ until: number().optional(),
19504
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
19505
+ /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
19506
+ * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
19507
+ * exact behaviour. Callers may omit this field — the store defaults to
19508
+ * `full` when not provided. */
19509
+ projection: _enum(["full", "slim"]).optional()
19510
+ });
19511
+ var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
19512
+ var RecentTracksQueryInput = object({
19513
+ /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
19514
+ deviceIds: array(number()),
19515
+ /** Window lower bound on `lastSeen` (inclusive). */
19516
+ since: number().optional(),
19517
+ /** Window upper bound on `lastSeen` (inclusive). */
19518
+ until: number().optional(),
19519
+ /** Page size. Default 200, max 1000. */
19520
+ limit: number().int().min(1).max(1e3).default(200),
19521
+ /** Opaque continuation cursor from a previous page's `nextCursor`.
19522
+ * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
19523
+ cursor: string().optional(),
19524
+ /** See {@link TrackProjectionSchema}. Default `full`. */
19525
+ projection: TrackProjectionSchema.optional(),
19526
+ /** Include stationary-promoted rows (parked objects). Default false: the
19527
+ * feed lists passages; parking records live on the stationary registry. */
19528
+ includeStationary: boolean().optional()
19529
+ });
19530
+ var RecentTracksPageSchema = object({
19531
+ /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
19532
+ tracks: array(TrackSchema).readonly(),
19533
+ /** Cursor for the next page, or null when this page is the last. */
19534
+ nextCursor: string().nullable()
19535
+ });
19536
+ var LIST_GROUPS_DEFAULT_LIMIT = 40;
19537
+ var LIST_GROUPS_MAX_LIMIT = 100;
19538
+ var AnalyticsGroupRecordSchema = object({
19539
+ id: string(),
19540
+ deviceId: number().int(),
19541
+ openedAt: number().int(),
19542
+ closedAt: number().int(),
19543
+ timestamp: number().int(),
19544
+ memberCount: number().int(),
19545
+ memberTrackIds: array(string()).readonly(),
19546
+ className: string(),
19547
+ classes: array(string()).readonly(),
19548
+ /** Relative event-media path, or null when the group has no picture yet. */
19549
+ mediaUrl: string().nullable(),
19550
+ singleton: boolean()
19551
+ });
19552
+ var AnalyticsGroupMemberSchema = object({
19553
+ trackId: string(),
19554
+ deviceId: number().int(),
19555
+ className: string(),
19556
+ firstSeen: number().int(),
19557
+ lastSeen: number().int(),
19558
+ mediaUrl: string().nullable()
19559
+ });
19560
+ var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
19561
+ var ListGroupsQueryInput = object({
19562
+ /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
19563
+ deviceIds: array(number()),
19564
+ /** Window lower bound on `closedAt` (inclusive). */
19565
+ since: number().optional(),
19566
+ /** Window upper bound on `openedAt` (inclusive). */
19567
+ until: number().optional(),
19568
+ limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
19569
+ /** Opaque continuation cursor from a previous page's `nextCursor`. */
19570
+ cursor: string().optional()
19571
+ });
19572
+ var ListGroupsPageSchema = object({
19573
+ groups: array(AnalyticsGroupRecordSchema).readonly(),
19574
+ nextCursor: string().nullable()
19575
+ });
19576
+ var KeyEventQueryInput = object({
19577
+ deviceId: number(),
19578
+ /** Window lower bound (track firstSeen ≥ since). */
19579
+ since: number(),
19580
+ /** Window upper bound (track firstSeen ≤ until). */
19581
+ until: number(),
19582
+ limit: number().int().min(1).max(200).default(50),
19583
+ /** Drop tracks scoring below this importance. */
19584
+ minImportance: number().min(0).max(1).optional(),
19585
+ /** Restrict to a single class (e.g. 'person'). */
19586
+ classFilter: string().optional()
19587
+ });
19588
+ var KeyEventSchema = object({
19589
+ /** The representative event id (the track's best ObjectEvent, else its trackId). */
19590
+ id: string(),
19591
+ trackId: string(),
19592
+ /** Track start time (firstSeen). */
19593
+ timestamp: number(),
19594
+ className: string(),
19595
+ ...TieredLabelFields,
19596
+ importance: number(),
19597
+ /** Highest-confidence ObjectEvent id for the track (empty when none). */
19598
+ bestEventId: string(),
19599
+ /** Track lifetime in ms (lastSeen - firstSeen). */
19600
+ windowMs: number().optional(),
19601
+ ...TrackFlagFields,
19602
+ ...TrackRetrainFields
19603
+ });
19604
+ object({
19605
+ trackId: string(),
19606
+ className: string(),
19607
+ confidence: number(),
19608
+ bbox: BoundingBoxSchema,
19609
+ zones: array(string()).readonly(),
19610
+ state: TrackStateSchema
19611
+ });
19612
+ var OverlayDetectionSchema = looseObject({
19613
+ id: string(),
19614
+ kind: _enum(["first-level", "detail"]),
19615
+ macroClass: string(),
19616
+ score: number(),
19617
+ bbox: object({
19618
+ x: number(),
19619
+ y: number(),
19620
+ width: number(),
19621
+ height: number()
19622
+ }),
19623
+ labels: array(looseObject({
19624
+ label: string(),
19625
+ score: number()
19626
+ })).readonly(),
19627
+ parentId: string().optional()
19628
+ });
19629
+ var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
19630
+ var SearchObjectEventsInput = object({
19631
+ text: string(),
19632
+ deviceId: number().optional(),
19633
+ since: number().optional(),
19634
+ until: number().optional(),
19635
+ classFilter: string().optional(),
19636
+ limit: number().default(50),
19637
+ minScore: number().min(0).max(1).default(.2)
19638
+ });
19639
+ var TrackCascadeCountsSchema = object({
19640
+ /** Persisted track roots deleted (authoritative). */
19641
+ tracks: number().int(),
19642
+ /** Object events removed with their tracks (best-effort; see note above). */
19643
+ events: number().int(),
19644
+ /** Track/face/plate-owned media removed (best-effort). Never identity media. */
19645
+ media: number().int(),
19646
+ /** Unassigned (non-enrolled) face reads removed (best-effort). */
19647
+ faces: number().int(),
19648
+ /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
19649
+ plates: number().int(),
19650
+ /** Per-track CLIP search vectors removed (best-effort). */
19651
+ embeddings: number().int(),
19652
+ /** Group membership + group rows removed with their last member (best-effort). */
19653
+ groups: number().int()
19654
+ });
19655
+ /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
19656
+ var DiskReconcileCountsSchema = object({
19657
+ mediaDropped: number().int(),
19658
+ tracks: number().int(),
19659
+ events: number().int()
19660
+ });
19661
+ /** Event-store footprint for one camera. */
19662
+ var EventStoreDeviceFootprintSchema = object({
19663
+ deviceId: number(),
19664
+ /** Persisted event rows (motion + object + audio) for the camera. */
19665
+ rows: number().int(),
19666
+ /** Event-owned media bytes on disk for the camera. */
19667
+ bytes: number().int()
19668
+ });
19669
+ /** Aggregate event-store footprint: global totals + per-camera breakdown. */
19670
+ var EventStoreFootprintSchema = object({
19671
+ totalRows: number().int(),
19672
+ totalBytes: number().int(),
19673
+ devices: array(EventStoreDeviceFootprintSchema).readonly()
19674
+ });
19675
+ /** Per-kind counts returned by the event-prune / device-delete mutations. */
19676
+ var EventPruneCountsSchema = object({
19677
+ motion: number().int(),
19678
+ object: number().int(),
19679
+ audio: number().int()
19680
+ });
19681
+ /**
19682
+ * Re-embed stored tracks from their key frames.
19683
+ *
19684
+ * The reason this is an operator-callable method and not a migration script:
19685
+ * every knob that decides what a vector MEANS — encoder model, crop margin,
19686
+ * squaring — is only changeable if the existing vectors can be regenerated.
19687
+ * Mixing feature spaces in one index makes cosine scores incomparable, and the
19688
+ * symptom is a quality regression with no visible cause.
19689
+ */
19690
+ var RebuildObjectEmbeddingsInput = object({
19691
+ /** Restrict to one camera. Omit for the whole fleet. */
19692
+ deviceId: number().optional(),
19693
+ since: number().optional(),
19694
+ until: number().optional(),
19695
+ /** Stop after this many tracks; the result reports whether more remain. */
19696
+ maxTracks: number().int().positive().optional(),
19697
+ /**
19698
+ * Run every embedding on THIS node instead of round-robining the fleet.
19699
+ *
19700
+ * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
19701
+ * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
19702
+ * calling it that would pin the rebuild REQUEST itself to that node — the
19703
+ * rebuild orchestration lives on the hub, and only the per-track step runs
19704
+ * remotely. This field is data; the per-track pin is applied inside.
19705
+ *
19706
+ * Absent ⇒ round-robin over every online node whose runner can serve the
19707
+ * pinned model.
19708
+ */
19709
+ executeOnNodeId: string().optional(),
19710
+ /**
19711
+ * Milliseconds to wait between tracks; omit for the built-in default, `0` to
19712
+ * run flat out.
19713
+ *
19714
+ * A rebuild is bulk maintenance on hub-main's single thread. Measured
19715
+ * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
19716
+ * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
19717
+ * force is logged at start and finish so a deliberately slow pass reads
19718
+ * differently from a stalled one.
19719
+ */
19720
+ pacingMs: number().int().nonnegative().optional()
19721
+ });
19722
+ /**
19723
+ * Result of emptying the CLIP index.
19724
+ *
19725
+ * The clean slate before a policy change: a new crop margin or encoder model
19726
+ * leaves two feature spaces in one index whose cosine scores are not
19727
+ * comparable, so wiping and rebuilding is the only way to be sure every vector
19728
+ * means the same thing.
19729
+ */
19730
+ var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
19731
+ /**
19732
+ * Acknowledgement that a rebuild STARTED.
19733
+ *
19734
+ * The pass costs ~1s per track — 45 minutes for a 2,600-track fleet — so it
19735
+ * runs detached and this returns immediately. Waiting for it made the client
19736
+ * time out while the work carried on server-side, which is the worst of both:
19737
+ * no result and no way to know it was still going. Poll
19738
+ * `getObjectEmbeddingRebuildStatus` for progress.
19739
+ */
19740
+ var RebuildObjectEmbeddingsResultSchema = object({
19741
+ started: boolean(),
19742
+ /** True when a pass was already running; the new request is ignored. */
19743
+ alreadyRunning: boolean()
19744
+ });
19745
+ var RebuildStatusSchema = object({
19746
+ running: boolean(),
19747
+ scanned: number(),
19748
+ rebuilt: number(),
19749
+ /** Tracks whose key frame is gone — nothing to re-embed from. */
19750
+ missingKeyFrame: number(),
19751
+ /** Tracks with no usable detection box. */
19752
+ missingBbox: number(),
19753
+ /**
19754
+ * Tracks an executing node REFUSED rather than broke on — an unreadable key
19755
+ * frame, a step that threw. Separate from `failed` because the remedy is
19756
+ * different, and because a whole camera silently contributing zero vectors
19757
+ * is the shape of failure a rebuild must never hide.
19758
+ */
19759
+ notRunnable: number(),
19760
+ /**
19761
+ * The pass stopped because NO node could serve the pinned model.
19762
+ *
19763
+ * Distinct from `notRunnable` on purpose: that one says "this track was
19764
+ * refused", this one says "the cluster cannot do this work at all" — every
19765
+ * candidate node either lacks the `clip-embedding` step, lacks a build of the
19766
+ * pinned model for its engine format, or dropped out. The remedy is a model /
19767
+ * engine change, not a per-camera one. Non-zero here always comes with
19768
+ * `complete: false`.
19769
+ */
19770
+ noCapableNode: number(),
19771
+ failed: number(),
19772
+ /** Set once a pass ends: true only when EVERYTHING was covered. */
19773
+ complete: boolean().nullable(),
19774
+ startedAtMs: number().nullable(),
19775
+ finishedAtMs: number().nullable(),
19776
+ /** Present when the pass ended by throwing. */
19777
+ error: string().nullable()
19778
+ });
19779
+ var ReplayFrameInputSchema = object({
19780
+ timestamp: number(),
19781
+ frame: PipelineRunResultBridge
19782
+ });
19783
+ var RunReplayFrameProcessorResultSchema = object({ tracks: array(object({
19784
+ className: string(),
19785
+ firstSeenMs: number(),
19786
+ lastSeenMs: number(),
19787
+ /** Bbox of the track's FIRST matched detection, pixel-space in the clip's
19788
+ * frame — a representative box for the diff's `(className, window, IoU)`
19789
+ * pairing (`replay-diff.ts`). A replay does not need the full per-frame
19790
+ * trajectory production's `Track.positions` keeps. */
19791
+ bbox: BoundingBoxSchema,
19792
+ /** How many of the input frames this track matched a real detection on
19793
+ * (never a coasted/extrapolated frame) — the replay's own signal for "how
19794
+ * solid is this track", cheaper than re-deriving it from a trajectory. */
19795
+ framesMatched: number().int()
19796
+ })).readonly() });
19797
+ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
19798
+ deviceId: number(),
19799
+ trackId: string()
19800
+ }), TrackSchema.nullable()), method(object({
19801
+ deviceId: number(),
19802
+ since: number().optional(),
19803
+ until: number().optional(),
19804
+ limit: number().optional(),
19805
+ /** Spatial filter — only tracks whose trajectory intersects the zone
19806
+ * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
19807
+ * envelope columns, then precisely tested per position. Tracks with
19808
+ * an unknown envelope (no frame dims at persist time) always match. */
19809
+ zone: TrackZoneFilterSchema.optional(),
19810
+ /** See {@link TrackProjectionSchema}. Default `full` (backward
19811
+ * compatible — omitting the field keeps today's exact behaviour). */
19812
+ projection: TrackProjectionSchema.optional(),
19813
+ /** Include stationary-promoted rows (parked objects handed to the
19814
+ * stationary registry). Default false: the timeline lists passages,
19815
+ * not parking records (operator decision, 2026-08-15). */
19816
+ includeStationary: boolean().optional()
19817
+ }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
19818
+ deviceId: number(),
19819
+ groupId: string().min(1)
19820
+ }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
19821
+ kind: "mutation",
19822
+ auth: "admin"
19823
+ }), 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({
19824
+ deviceId: number(),
19825
+ since: number().optional(),
19826
+ until: number().optional(),
19827
+ kinds: array(string()).optional(),
19828
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
19829
+ }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
19830
+ deviceId: number(),
19831
+ since: number(),
19832
+ until: number(),
19833
+ bucketMs: number().int().positive()
19834
+ }), array(object({
19835
+ bucketStart: number(),
19836
+ motion: number().int(),
19837
+ object: number().int(),
19838
+ audio: number().int()
19839
+ })).readonly()), method(object({
19840
+ deviceId: number(),
19841
+ cutoffMs: number()
19842
+ }), object({
19843
+ motion: number().int(),
19844
+ object: number().int(),
19845
+ audio: number().int()
19846
+ }), {
19847
+ kind: "mutation",
19848
+ auth: "admin"
19849
+ }), method(object({
19850
+ deviceId: number(),
19851
+ cutoffMs: number()
19852
+ }), TrackCascadeCountsSchema, {
19853
+ kind: "mutation",
19854
+ auth: "admin"
19855
+ }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
19856
+ kind: "mutation",
19857
+ auth: "admin"
19858
+ }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
19859
+ kind: "mutation",
19860
+ auth: "admin"
19861
+ }), method(object({
19862
+ deviceId: number(),
19863
+ trackIds: array(string()).min(1)
19864
+ }), object({
19865
+ deleted: number().int(),
19866
+ failed: array(string()).readonly()
19867
+ }), {
19868
+ kind: "mutation",
19869
+ auth: "admin"
19870
+ }), method(object({
19871
+ /** Log/audit scope only — the trackId is globally unique on its own. */
19872
+ deviceId: number(),
19873
+ trackId: string(),
19874
+ flags: TrackFlagsPatchSchema
19875
+ }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
19876
+ kind: "query",
19877
+ auth: "admin"
19878
+ }), method(object({
19879
+ olderThanMs: number(),
19880
+ reason: OpsLogReasonSchema.optional()
19881
+ }), EventPruneCountsSchema, {
19882
+ kind: "mutation",
19883
+ auth: "admin"
19884
+ }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
19885
+ kind: "mutation",
19886
+ auth: "admin"
19887
+ }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
19888
+ kind: "mutation",
19889
+ auth: "admin"
19890
+ }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
19891
+ kind: "mutation",
19892
+ auth: "admin"
19893
+ }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
19894
+ kind: "mutation",
19895
+ auth: "admin"
19896
+ }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
19897
+ kind: "mutation",
19898
+ auth: "admin"
19899
+ }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
19900
+ kind: "mutation",
19901
+ auth: "admin"
19902
+ }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
19903
+ kind: "mutation",
19904
+ auth: "admin"
19905
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
19906
+ kind: "query",
19907
+ auth: "admin"
19908
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
19909
+ kind: "mutation",
19910
+ auth: "admin"
19911
+ }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
19912
+ kind: "query",
19913
+ auth: "admin"
19914
+ }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
19915
+ kind: "query",
19916
+ auth: "admin"
19917
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
19918
+ kind: "query",
19919
+ auth: "admin"
19920
+ }), method(object({
19921
+ /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
19922
+ * `deviceId`, deliberately: `deviceId` would make this device-bound and
19923
+ * route it at one camera's owner, and "every camera" would stop being
19924
+ * expressible at all. */
19925
+ deviceIds: array(number()).optional(),
19926
+ limit: number().int().min(1).max(500).optional()
19927
+ }), array(RetrainTrackSchema).readonly(), {
19928
+ kind: "query",
19929
+ auth: "admin"
19930
+ }), method(object({ trackId: string() }), RetrainFrameListSchema, {
19931
+ kind: "query",
19932
+ auth: "admin"
19933
+ }), method(object({
19934
+ deviceId: number(),
19935
+ trackId: string(),
19936
+ mediaKeys: array(string()).min(1)
19937
+ }), RetrainFrameSelectionSchema, {
19938
+ kind: "mutation",
19939
+ auth: "admin"
19940
+ }), method(object({
19941
+ deviceId: number(),
19942
+ trackId: string(),
19943
+ frameId: string()
19944
+ }), object({
19945
+ removed: boolean(),
19946
+ removedAnnotations: number().int()
19947
+ }), {
19948
+ kind: "mutation",
19949
+ auth: "admin"
19950
+ }), method(object({ frameId: string() }), object({
19951
+ base64: string(),
19952
+ width: number().int(),
19953
+ height: number().int()
19954
+ }), {
19955
+ kind: "query",
19956
+ auth: "admin"
19957
+ }), method(object({
19958
+ deviceId: number(),
19959
+ trackId: string(),
19960
+ frameId: string(),
19961
+ subject: RetrainAssistSubjectSchema,
19962
+ /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
19963
+ nodeId: string().optional()
19964
+ }), RetrainAssistResultSchema, {
19965
+ kind: "mutation",
19966
+ auth: "admin"
19967
+ }), method(object({
19968
+ deviceId: number(),
19969
+ source: DetectionSourceSchema,
19970
+ zones: array(ZoneSchema).readonly().optional(),
19971
+ detectionRules: array(ZoneRuleSchema).readonly().optional(),
19972
+ zoneMembershipMinOverlap: number().min(0).max(1).optional(),
19973
+ frames: array(ReplayFrameInputSchema).min(1)
19974
+ }), RunReplayFrameProcessorResultSchema, {
19975
+ kind: "mutation",
19976
+ auth: "admin"
19977
+ }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
19978
+ kind: "query",
19979
+ auth: "admin"
19980
+ }), method(object({
19981
+ deviceId: number(),
19982
+ trackId: string(),
19983
+ frameId: string(),
19984
+ annotations: array(RetrainAnnotationDraftSchema)
19985
+ }), array(RetrainAnnotationSchema).readonly(), {
19986
+ kind: "mutation",
19987
+ auth: "admin"
19988
+ }), method(object({
19989
+ deviceId: number(),
19990
+ trackId: string()
19991
+ }), RetrainTransitionResultSchema, {
19992
+ kind: "mutation",
19993
+ auth: "admin"
19994
+ }), method(object({
19995
+ deviceId: number(),
19996
+ trackId: string()
19997
+ }), RetrainTransitionResultSchema, {
19998
+ kind: "mutation",
19999
+ auth: "admin"
20000
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
20001
+ kind: "query",
20002
+ auth: "admin"
20003
+ }), method(object({
20004
+ eventId: string(),
20005
+ kind: MediaFileKindEnum.optional(),
20006
+ deviceId: number()
20007
+ }), array(MediaFileSchema).readonly()), method(object({
20008
+ trackId: string(),
20009
+ kinds: array(MediaFileKindEnum).optional(),
20010
+ deviceId: number()
20011
+ }), array(MediaFileSchema).readonly()), method(object({
20012
+ trackId: string(),
20013
+ deviceId: number()
20014
+ }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
20015
+ kind: "mutation",
20016
+ auth: "admin"
20017
+ }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
20018
+ kind: "mutation",
20019
+ auth: "admin"
20020
+ }), method(object({}), RebuildStatusSchema), object({
20021
+ deviceId: number(),
20022
+ timestamp: number(),
20023
+ frameWidth: number(),
20024
+ frameHeight: number(),
20025
+ detections: array(OverlayDetectionSchema).readonly()
20026
+ }), object({
20027
+ deviceId: number(),
20028
+ trackId: string(),
20029
+ className: string()
20030
+ }), object({
20031
+ deviceId: number(),
20032
+ trackId: string(),
20033
+ className: string(),
20034
+ durationMs: number()
20035
+ }), object({
20036
+ deviceId: number(),
20037
+ kind: EventKindSchema,
20038
+ eventId: string(),
20039
+ timestamp: number()
20040
+ });
19729
20041
  object({
19730
20042
  activeCameras: number(),
19731
20043
  throttledCameras: number(),
@@ -19751,66 +20063,6 @@ var CameraMetricsSchema = object({
19751
20063
  });
19752
20064
  var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
19753
20065
  /**
19754
- * Zone — pure geometry + identity. NO filtering behaviour.
19755
- *
19756
- * Zones describe **where** in the frame the operator wants to flag
19757
- * something; consumer-owned {@link ZoneRule} arrays describe **how**
19758
- * each pipeline stage uses them. Splitting the two means a single
19759
- * polygon "Driveway" can simultaneously back a motion-exclude rule,
19760
- * a detection-include rule on `['car']`, and an occupancy aggregate
19761
- * — without three duplicated polygons.
19762
- *
19763
- * Owned by the orchestrator addon (provider) and mirrored into the
19764
- * `zones` device-state slice on every mutation. Consumers
19765
- * (motion-wasm, pipeline-executor, analytics, admin UI) read either
19766
- * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
19767
- * mirror with `onChanged`).
19768
- *
19769
- * Coordinates are normalised fractions of the frame (0–1) so zones
19770
- * survive resolution changes and stream profile switches.
19771
- *
19772
- * `kind` discriminates between full polygons (closed regions used
19773
- * for intrusion / occupancy filters) and tripwires (open 2-point
19774
- * line segments used for cross events). Onboard / firmware-reported
19775
- * zones (Reolink, ONVIF) are out of scope for now — see the deferred
19776
- * task list.
19777
- */
19778
- var ZoneKindEnum = _enum(["polygon", "tripwire"]);
19779
- /** Polygon vertex in fraction-of-frame coordinates (0–1). */
19780
- var PolygonPointSchema = object({
19781
- x: number(),
19782
- y: number()
19783
- });
19784
- /** A camera detection zone — pure geometry/identity. */
19785
- var ZoneSchema = object({
19786
- id: string(),
19787
- name: string(),
19788
- kind: ZoneKindEnum.default("polygon"),
19789
- /** Polygon vertices, fraction of frame (0–1). */
19790
- polygon: array(PolygonPointSchema).readonly(),
19791
- /** Visual color for UI rendering. */
19792
- color: string().default("#3b82f6")
19793
- });
19794
- DeviceType.Camera, method(object({ deviceId: number() }), array(ZoneSchema).readonly()), method(object({
19795
- deviceId: number(),
19796
- zone: ZoneSchema
19797
- }), _void(), {
19798
- kind: "mutation",
19799
- auth: "admin"
19800
- }), method(object({
19801
- deviceId: number(),
19802
- zoneId: string()
19803
- }), _void(), {
19804
- kind: "mutation",
19805
- auth: "admin"
19806
- }), method(object({
19807
- deviceId: number(),
19808
- zone: ZoneSchema
19809
- }), _void(), {
19810
- kind: "mutation",
19811
- auth: "admin"
19812
- }), object({ zones: array(ZoneSchema).readonly() });
19813
- /**
19814
20066
  * A bounding box in NORMALIZED [0,1] frame coordinates for `getNativeCrop`. The
19815
20067
  * decode worker resolves it against the RETAINED native frame's real pixel dims,
19816
20068
  * so the caller supplies only the detection-res bbox divided by the detection
@@ -21640,7 +21892,7 @@ method(object({
21640
21892
  * linking rather than produce an eternal token.
21641
21893
  */
21642
21894
  ttlSec: union([number().int().positive(), literal("never")]).optional()
21643
- }), object({ token: string() })), method(object({ token: string() }), SsoBridgeClaimsSchema.nullable());
21895
+ }), object({ token: string() }), { auth: "admin" }), method(object({ token: string() }), SsoBridgeClaimsSchema.nullable(), { auth: "admin" });
21644
21896
  var ProviderListEntrySchema = discriminatedUnion("shouldSaveDiskSpace", [object({
21645
21897
  providerId: string().min(1),
21646
21898
  displayName: string().min(1),
@@ -21741,8 +21993,15 @@ var storageEvictableCapability = {
21741
21993
  mode: "collection",
21742
21994
  internal: true,
21743
21995
  methods: {
21996
+ /**
21997
+ * `internal: true` did not gate the mount (see the 2026-08-26 note on
21998
+ * `data-store-provider`) — this was reachable on the AppRouter by ANY
21999
+ * authenticated session at the default `auth: 'protected'`. The only
22000
+ * consumer is the orchestrator's `StoragePressureManager`, which calls
22001
+ * `ctx.api` — never tRPC — so `auth: 'admin'` costs it nothing.
22002
+ */
21744
22003
  /** Bytes this provider holds on the given location — drives proportional fan-out. */
21745
- getEvictableUsage: method(object({ locationId: string() }), EvictableUsageSchema),
22004
+ getEvictableUsage: method(object({ locationId: string() }), EvictableUsageSchema, { auth: "admin" }),
21746
22005
  /**
21747
22006
  * Free approximately `targetBytes` of this provider's OWN least-valuable
21748
22007
  * data on the location (oldest footage, expired clips, …). Returns what it
@@ -21751,7 +22010,10 @@ var storageEvictableCapability = {
21751
22010
  evict: method(object({
21752
22011
  locationId: string(),
21753
22012
  targetBytes: number().int().positive()
21754
- }), EvictResultSchema, { kind: "mutation" })
22013
+ }), EvictResultSchema, {
22014
+ kind: "mutation",
22015
+ auth: "admin"
22016
+ })
21755
22017
  }
21756
22018
  };
21757
22019
  method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin" }), method(StorageMigrationInputSchema, object({ jobId: string() }), {
@@ -21813,26 +22075,50 @@ var ReadChunkInputSchema = object({
21813
22075
  length: number()
21814
22076
  });
21815
22077
  var EndDownloadInputSchema = object({ downloadId: string() });
21816
- method(_void(), ProviderInfoSchema), method(object({ config: record(string(), unknown()) }), TestLocationResultSchema, { auth: "admin" }), method(object({
22078
+ method(_void(), ProviderInfoSchema, { auth: "admin" }), method(object({ config: record(string(), unknown()) }), TestLocationResultSchema, { auth: "admin" }), method(object({
21817
22079
  location: StorageLocationSchema,
21818
22080
  relativePath: string()
21819
- }), string()), method(object({
22081
+ }), string(), { auth: "admin" }), method(object({
21820
22082
  location: StorageLocationSchema,
21821
22083
  relativePath: string(),
21822
22084
  data: _instanceof(Uint8Array)
21823
- }), _void(), { kind: "mutation" }), method(object({
22085
+ }), _void(), {
22086
+ kind: "mutation",
22087
+ auth: "admin"
22088
+ }), method(object({
21824
22089
  location: StorageLocationSchema,
21825
22090
  relativePath: string()
21826
- }), _instanceof(Uint8Array)), method(object({
22091
+ }), _instanceof(Uint8Array), { auth: "admin" }), method(object({
21827
22092
  location: StorageLocationSchema,
21828
22093
  relativePath: string()
21829
- }), boolean()), method(object({
22094
+ }), boolean(), { auth: "admin" }), method(object({
21830
22095
  location: StorageLocationSchema,
21831
22096
  prefix: string().optional()
21832
- }), array(string()).readonly()), method(object({
22097
+ }), array(string()).readonly(), { auth: "admin" }), method(object({
21833
22098
  location: StorageLocationSchema,
21834
22099
  relativePath: string()
21835
- }), _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" });
22100
+ }), _void(), {
22101
+ kind: "mutation",
22102
+ auth: "admin"
22103
+ }), method(object({ location: StorageLocationSchema }), number().nullable(), { auth: "admin" }), method(BeginUploadInputSchema, BeginUploadResultSchema, {
22104
+ kind: "mutation",
22105
+ auth: "admin"
22106
+ }), method(WriteChunkInputSchema, _void(), {
22107
+ kind: "mutation",
22108
+ auth: "admin"
22109
+ }), method(FinalizeUploadInputSchema, _void(), {
22110
+ kind: "mutation",
22111
+ auth: "admin"
22112
+ }), method(AbortUploadInputSchema, _void(), {
22113
+ kind: "mutation",
22114
+ auth: "admin"
22115
+ }), method(BeginDownloadInputSchema, BeginDownloadResultSchema, {
22116
+ kind: "mutation",
22117
+ auth: "admin"
22118
+ }), method(ReadChunkInputSchema, _instanceof(Uint8Array), { auth: "admin" }), method(EndDownloadInputSchema, _void(), {
22119
+ kind: "mutation",
22120
+ auth: "admin"
22121
+ });
21836
22122
  /** Profile-exported FormBuilder schema. Shape is ConfigUISchema at the UI. */
21837
22123
  var ProfileSettingsSchemaBridge = unknown().nullable();
21838
22124
  var ProfileSettingsBagSchema = record(string(), unknown());
@@ -22090,7 +22376,8 @@ method(object({
22090
22376
  access: "create"
22091
22377
  }), method(object({ userId: string().optional() }), object({ optionsJSON: record(string(), unknown()) }), {
22092
22378
  kind: "mutation",
22093
- access: "view"
22379
+ access: "view",
22380
+ auth: "admin"
22094
22381
  }), method(object({
22095
22382
  /** Required — the user the assertion belongs to (verified). */
22096
22383
  userId: string(),
@@ -22098,10 +22385,12 @@ method(object({
22098
22385
  response: record(string(), unknown())
22099
22386
  }), object({ verified: boolean() }), {
22100
22387
  kind: "mutation",
22101
- access: "view"
22388
+ access: "view",
22389
+ auth: "admin"
22102
22390
  }), method(object({}), object({ optionsJSON: record(string(), unknown()) }), {
22103
22391
  kind: "mutation",
22104
- access: "view"
22392
+ access: "view",
22393
+ auth: "admin"
22105
22394
  }), method(object({
22106
22395
  /** AuthenticationResponseJSON from the browser. */
22107
22396
  response: record(string(), unknown()) }), object({
@@ -22109,7 +22398,8 @@ response: record(string(), unknown()) }), object({
22109
22398
  userId: string().nullable()
22110
22399
  }), {
22111
22400
  kind: "mutation",
22112
- access: "view"
22401
+ access: "view",
22402
+ auth: "admin"
22113
22403
  }), method(object({ userId: string() }), array(PasskeySummarySchema), { auth: "admin" }), method(object({
22114
22404
  userId: string(),
22115
22405
  credentialId: string()
@@ -22281,7 +22571,19 @@ var VectorStatsResultSchema = object({
22281
22571
  /** False when the backend ranks approximately. */
22282
22572
  exact: boolean()
22283
22573
  });
22284
- 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);
22574
+ method(VectorDeclareIndexInputSchema, _void(), {
22575
+ kind: "mutation",
22576
+ auth: "admin"
22577
+ }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
22578
+ kind: "mutation",
22579
+ auth: "admin"
22580
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
22581
+ kind: "mutation",
22582
+ auth: "admin"
22583
+ }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
22584
+ kind: "mutation",
22585
+ auth: "admin"
22586
+ }), method(VectorStatsInputSchema, VectorStatsResultSchema, { auth: "admin" });
22285
22587
  var ClipSchema = object({
22286
22588
  /** Opaque, provider-namespaced id. The default provider encodes the time
22287
22589
  * window so `getClipPlayback` is self-contained (no event re-query). */
@@ -27806,92 +28108,6 @@ DeviceType.Camera, method(object({ deviceId: number() }), SceneMonitorStatusSche
27806
28108
  kind: "mutation",
27807
28109
  auth: "admin"
27808
28110
  });
27809
- /**
27810
- * Per-stage gating mode applied to the zones a rule references.
27811
- *
27812
- * - `include`: the rule contributes to a **whitelist** for its stage.
27813
- * When at least one `include` rule fires for a stage, only entities
27814
- * inside one of those zones pass that stage.
27815
- * - `exclude`: the rule contributes to a **blacklist** for its stage.
27816
- * Entities inside one of those zones are dropped at that stage.
27817
- *
27818
- * `monitor`-style observation (count without filtering) is not a rule
27819
- * mode — zones without any matching rule are observed naturally by
27820
- * `zone-analytics` (live snapshot + history), so an "I just want to
27821
- * count, not filter" use case needs no rule at all.
27822
- */
27823
- var ZoneRuleModeEnum = _enum(["include", "exclude"]);
27824
- /**
27825
- * Per-consumer rule that references existing zones (geometry) and
27826
- * defines how a specific pipeline stage should treat them. Each
27827
- * consumer addon owns its own `ZoneRule[]` array in its per-device
27828
- * settings:
27829
- *
27830
- * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
27831
- * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
27832
- * - future: notification rules, audio gating, etc.
27833
- *
27834
- * One rule applies to N zones (`zoneIds[]`) so the operator can
27835
- * express "ignore motion in ALL of {garden, street}" with a single
27836
- * rule. `classFilter` narrows the rule to specific object classes —
27837
- * "drop person detections in the street, but keep cars" is one
27838
- * `exclude` rule with `classFilter: ['person']`.
27839
- *
27840
- * `enabled` is a soft toggle — the operator can keep the rule
27841
- * configured but inert without deleting it.
27842
- */
27843
- var ZoneRuleSchema = object({
27844
- /** Stable rule id — survives edits, used by the UI for diffing. */
27845
- id: string(),
27846
- /** Optional human-readable label rendered in the rule editor. */
27847
- name: string().optional(),
27848
- /** Zones this rule targets. The rule's `mode` applies to ALL
27849
- * listed zones (OR-set: a detection in any one of them counts).
27850
- * At least one zone id required — a rule with no targets is a
27851
- * configuration mistake and the form validator rejects it. */
27852
- zoneIds: array(string()).min(1).readonly(),
27853
- mode: ZoneRuleModeEnum,
27854
- /**
27855
- * Class names this rule applies to. Empty / undefined ⇒ rule
27856
- * applies to every class. Class strings match the `macroClass`
27857
- * field on detections (e.g. `person`, `car`, `dog`).
27858
- */
27859
- classFilter: array(string()).readonly().optional(),
27860
- /**
27861
- * Minimum bbox/mask overlap (0–1) with any of the rule's zones
27862
- * required to consider an entity "in the zone". Defaults to the
27863
- * consumer's stage default when omitted. Kept for back-compat with
27864
- * existing per-rule overrides; new operators pick the value via
27865
- * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
27866
- * set, the lower-level engine reads it as a 0–1 fraction.
27867
- */
27868
- overlapThreshold: number().min(0).max(1).optional(),
27869
- /**
27870
- * Operator-friendly version of `overlapThreshold` — the percentage
27871
- * of the detection's bbox that must lie inside the zone for the
27872
- * rule to match. Documented default is 85%; the engine substitutes
27873
- * that when the field is omitted (kept optional so existing rules
27874
- * stored without it stay valid).
27875
- *
27876
- * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
27877
- * rule, the engine prefers `bboxInclusionPct` because it's the
27878
- * field exposed in the UI. Internally both feed the same gate.
27879
- */
27880
- bboxInclusionPct: number().min(0).max(100).optional(),
27881
- /**
27882
- * When `true` and a detection has a segmentation mask, use the
27883
- * mask for overlap instead of the bbox. Detection-stage only;
27884
- * motion rules ignore this field.
27885
- */
27886
- preferMask: boolean().optional(),
27887
- /**
27888
- * Soft-toggle: `false` disables the rule without deleting it.
27889
- * Defaults to `true` so operators creating a rule via the UI
27890
- * see it active immediately.
27891
- */
27892
- enabled: boolean().default(true)
27893
- });
27894
- array(ZoneRuleSchema).readonly();
27895
28111
  object({
27896
28112
  /** Whether the script is currently executing. */
27897
28113
  isRunning: boolean(),
@@ -31937,6 +32153,12 @@ Object.freeze({
31937
32153
  addonId: null,
31938
32154
  access: "create"
31939
32155
  },
32156
+ "pipelineAnalytics.cancelRelocateMedia": {
32157
+ capName: "pipeline-analytics",
32158
+ capScope: "device",
32159
+ addonId: null,
32160
+ access: "create"
32161
+ },
31940
32162
  "pipelineAnalytics.cancelStorageMigrationMove": {
31941
32163
  capName: "pipeline-analytics",
31942
32164
  capScope: "device",
@@ -32111,6 +32333,12 @@ Object.freeze({
32111
32333
  addonId: null,
32112
32334
  access: "view"
32113
32335
  },
32336
+ "pipelineAnalytics.listRelocateMediaJobs": {
32337
+ capName: "pipeline-analytics",
32338
+ capScope: "device",
32339
+ addonId: null,
32340
+ access: "view"
32341
+ },
32114
32342
  "pipelineAnalytics.listRetrainAnnotations": {
32115
32343
  capName: "pipeline-analytics",
32116
32344
  capScope: "device",
@@ -32189,6 +32417,12 @@ Object.freeze({
32189
32417
  addonId: null,
32190
32418
  access: "create"
32191
32419
  },
32420
+ "pipelineAnalytics.relocateMedia": {
32421
+ capName: "pipeline-analytics",
32422
+ capScope: "device",
32423
+ addonId: null,
32424
+ access: "create"
32425
+ },
32192
32426
  "pipelineAnalytics.restageRetrainTrack": {
32193
32427
  capName: "pipeline-analytics",
32194
32428
  capScope: "device",
@@ -32201,6 +32435,12 @@ Object.freeze({
32201
32435
  addonId: null,
32202
32436
  access: "create"
32203
32437
  },
32438
+ "pipelineAnalytics.runReplayFrameProcessor": {
32439
+ capName: "pipeline-analytics",
32440
+ capScope: "device",
32441
+ addonId: null,
32442
+ access: "create"
32443
+ },
32204
32444
  "pipelineAnalytics.saveRetrainAnnotations": {
32205
32445
  capName: "pipeline-analytics",
32206
32446
  capScope: "device",
@@ -32333,6 +32573,12 @@ Object.freeze({
32333
32573
  addonId: null,
32334
32574
  access: "view"
32335
32575
  },
32576
+ "pipelineExecutor.getInferenceDeviceHealth": {
32577
+ capName: "pipeline-executor",
32578
+ capScope: "system",
32579
+ addonId: null,
32580
+ access: "view"
32581
+ },
32336
32582
  "pipelineExecutor.getOrchestratorConfigSchema": {
32337
32583
  capName: "pipeline-executor",
32338
32584
  capScope: "system",
@@ -32405,6 +32651,12 @@ Object.freeze({
32405
32651
  addonId: null,
32406
32652
  access: "view"
32407
32653
  },
32654
+ "pipelineExecutor.rearmInferenceDevice": {
32655
+ capName: "pipeline-executor",
32656
+ capScope: "system",
32657
+ addonId: null,
32658
+ access: "create"
32659
+ },
32408
32660
  "pipelineExecutor.runAudioTest": {
32409
32661
  capName: "pipeline-executor",
32410
32662
  capScope: "system",
@@ -35653,6 +35905,11 @@ Object.freeze({
35653
35905
  form: "single",
35654
35906
  optional: false
35655
35907
  }],
35908
+ "pipelineAnalytics.runReplayFrameProcessor": [{
35909
+ name: "deviceId",
35910
+ form: "single",
35911
+ optional: false
35912
+ }],
35656
35913
  "pipelineAnalytics.saveRetrainAnnotations": [{
35657
35914
  name: "deviceId",
35658
35915
  form: "single",