@camstack/system 1.2.303 → 1.2.304

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 (55) hide show
  1. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  2. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  3. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  4. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  5. package/dist/builtins/alerts/alerts.addon.js +1 -1
  6. package/dist/builtins/alerts/alerts.addon.mjs +1 -1
  7. package/dist/builtins/autotrack/index.js +1 -1
  8. package/dist/builtins/autotrack/index.mjs +1 -1
  9. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +1 -1
  10. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +1 -1
  11. package/dist/builtins/camera-grid/index.js +1 -1
  12. package/dist/builtins/camera-grid/index.mjs +1 -1
  13. package/dist/builtins/console-logging/index.js +1 -1
  14. package/dist/builtins/console-logging/index.mjs +1 -1
  15. package/dist/builtins/core-blocks/core-blocks.addon.js +1 -1
  16. package/dist/builtins/core-blocks/core-blocks.addon.mjs +1 -1
  17. package/dist/builtins/device-manager/device-manager.addon.js +2 -2
  18. package/dist/builtins/device-manager/device-manager.addon.mjs +2 -2
  19. package/dist/builtins/doorbell/virtual-doorbell.addon.js +1 -1
  20. package/dist/builtins/doorbell/virtual-doorbell.addon.mjs +1 -1
  21. package/dist/builtins/hub-forwarder/index.js +1 -1
  22. package/dist/builtins/hub-forwarder/index.mjs +1 -1
  23. package/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  24. package/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  25. package/dist/builtins/local-auth/local-auth.addon.js +1 -1
  26. package/dist/builtins/local-auth/local-auth.addon.mjs +1 -1
  27. package/dist/builtins/local-network/local-network.addon.js +1 -1
  28. package/dist/builtins/local-network/local-network.addon.mjs +1 -1
  29. package/dist/builtins/loki-logging/index.js +1 -1
  30. package/dist/builtins/loki-logging/index.mjs +1 -1
  31. package/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  32. package/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  33. package/dist/builtins/platform-probe/index.js +3 -3
  34. package/dist/builtins/platform-probe/index.mjs +3 -3
  35. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  36. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  37. package/dist/builtins/snapshot/index.js +1 -1
  38. package/dist/builtins/snapshot/index.mjs +1 -1
  39. package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  40. package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  41. package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +0 -0
  42. package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +0 -0
  43. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  44. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  45. package/dist/builtins/system-config/system-config.addon.js +1 -1
  46. package/dist/builtins/system-config/system-config.addon.mjs +1 -1
  47. package/dist/builtins/winston-logging/index.js +1 -1
  48. package/dist/builtins/winston-logging/index.mjs +1 -1
  49. package/dist/{dist-DzHjDpU7.js → dist-C571Y95Z.js} +1723 -1365
  50. package/dist/{dist-FwpS07w3.mjs → dist-Duqf80QM.mjs} +1723 -1365
  51. package/dist/index.js +1 -1
  52. package/dist/index.mjs +1 -1
  53. package/dist/{retired-settings-keys-CNcKBSQS.js → retired-settings-keys-0j8rNoa8.js} +1 -1
  54. package/dist/{retired-settings-keys-rDPn2MMp.mjs → retired-settings-keys-CeO_dBHU.mjs} +1 -1
  55. package/package.json +1 -1
@@ -691,7 +691,7 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
691
691
  return EventCategory;
692
692
  }({});
693
693
  //#endregion
694
- //#region ../types/dist/sleep-DU7mu4wb.mjs
694
+ //#region ../types/dist/sleep-BaRu0bS5.mjs
695
695
  /**
696
696
  * The audio chunk plane's byte format, and the ONE expansion from a coded
697
697
  * window to float samples (D455).
@@ -6417,7 +6417,7 @@ var ModelFormatEntrySchema = zod.z.object({
6417
6417
  /** Multi-file payload (directory members or sibling files). */
6418
6418
  files: zod.z.array(zod.z.string()).readonly().optional(),
6419
6419
  /** Runtime(s) that can use this format. If omitted, inferred from ModelFormat key */
6420
- runtimes: zod.z.array(zod.z.enum(["node", "python"])).readonly().optional()
6420
+ runtimes: zod.z.array(zod.z.enum(["python"])).readonly().optional()
6421
6421
  });
6422
6422
  /**
6423
6423
  * Extra file that must be downloaded alongside the model (e.g., labels JSON, dict.txt).
@@ -16914,6 +16914,29 @@ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
16914
16914
  ]);
16915
16915
  NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
16916
16916
  /**
16917
+ * The panel's transitions, as ONE list.
16918
+ *
16919
+ * Named here rather than spelled out at each of the four sites that need them
16920
+ * (the emitter, the intake, the editor group, the combined-notification gate),
16921
+ * because a transition added to the enum and forgotten at one of them is an
16922
+ * alarm state nobody can be notified about. That is exactly what this list
16923
+ * failed to prevent while it held three: `alarm-arming` was the fourth.
16924
+ *
16925
+ * In LIFECYCLE order, which is the order an editor lists them in and the order
16926
+ * a person experiences them — not the order they were added.
16927
+ */
16928
+ var NC_ALARM_SYSTEM_EVENT_KINDS = [
16929
+ "alarm-arm-refused",
16930
+ "alarm-check-failed",
16931
+ "alarm-arming",
16932
+ "alarm-armed",
16933
+ "alarm-pending",
16934
+ "alarm-triggered",
16935
+ "alarm-rearmed",
16936
+ "alarm-sensor-bypass",
16937
+ "alarm-disarmed"
16938
+ ];
16939
+ /**
16917
16940
  * One coherent system-event condition. `kinds` is the required opt-in safety
16918
16941
  * gate; the remaining lists are optional narrowing filters relevant to the
16919
16942
  * selected kinds.
@@ -16982,6 +17005,25 @@ var NcScheduleSchema = zod.z.object({
16982
17005
  /** Active OUTSIDE the windows (e.g. "only outside business hours"). */
16983
17006
  invert: zod.z.boolean().optional()
16984
17007
  });
17008
+ /**
17009
+ * How a system-event rule of the `device-events` or `system` family speaks
17010
+ * (D647): at once, per event (`instant`, the only behaviour before D647), or
17011
+ * as a STATE SUMMARY at the end of each window of `schedule`.
17012
+ */
17013
+ var NcSystemEventDeliveryModeSchema = zod.z.enum(["instant", "summary"]);
17014
+ /**
17015
+ * `summary`: the rule sends NOTHING per event. When a window of `schedule`
17016
+ * CLOSES, it sends one notification with the current state of its kinds
17017
+ * (low batteries, consumables to replace, devices offline, updates
17018
+ * available, ...), after its own filters. Nothing to report sends nothing.
17019
+ * The schedule is the ordinary `NcSchedule` (weekly windows, IANA timezone,
17020
+ * midnight crossing); the send time is each window's END. Refused on the
17021
+ * `alarm` family, which stays instant (`systemEventDeliveryProblems`).
17022
+ */
17023
+ var NcSystemEventDeliverySchema = zod.z.discriminatedUnion("mode", [zod.z.object({ mode: zod.z.literal("instant") }), zod.z.object({
17024
+ mode: zod.z.literal("summary"),
17025
+ schedule: NcScheduleSchema
17026
+ })]);
16985
17027
  /** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
16986
17028
  var NcPlateMatcherSchema = zod.z.object({
16987
17029
  /**
@@ -17717,6 +17759,16 @@ var NcRuleInputSchema = zod.z.object({
17717
17759
  delivery: NcDeliverySchema,
17718
17760
  conditions: NcConditionsSchema.default({}),
17719
17761
  schedule: NcScheduleSchema.optional(),
17762
+ /**
17763
+ * A `device-events` / `system` rule's delivery (D647): absent or `instant`
17764
+ * is a notification per event; `summary` is one state summary per closed
17765
+ * window of its schedule. `.optional()` and never defaulted: absent must
17766
+ * keep meaning what every rule authored before D647 meant, with no
17767
+ * migration. Top-level rather than inside `conditions.systemEvent`, so a
17768
+ * client that does not know it (an older viewer re-sending `conditions`
17769
+ * whole) leaves it standing through the store's patch merge.
17770
+ */
17771
+ systemEventDelivery: NcSystemEventDeliverySchema.optional(),
17720
17772
  /** May be empty when `targetUsers` addresses at least one user — the
17721
17773
  * "at least one addressee" invariant is enforced by the provider, because
17722
17774
  * a cross-field refine here would break `NcRulePatchSchema.partial()`. */
@@ -17945,6 +17997,28 @@ var NcRuleSchema = NcRuleInputSchema.extend({
17945
17997
  */
17946
17998
  disabledTargetIds: zod.z.array(zod.z.string()).default([])
17947
17999
  });
18000
+ /** One section of a previewed state summary. `unavailable` = its state could not be read. */
18001
+ var NcStateSummaryPreviewSectionSchema = zod.z.object({
18002
+ id: zod.z.string(),
18003
+ status: zod.z.enum(["read", "unavailable"]),
18004
+ items: zod.z.number().int().nonnegative(),
18005
+ reason: zod.z.string().optional()
18006
+ });
18007
+ /**
18008
+ * The summary a rule would send now. `empty` = nothing to report and every
18009
+ * section read: such a summary is NOT sent. `dropped` counts the open states
18010
+ * the rule's own filters (or a camera mute) left out, by reason.
18011
+ * `excludedGroups` names the kind groups selected that have no state to report
18012
+ * (backups & exports).
18013
+ */
18014
+ var NcStateSummaryPreviewSchema = zod.z.object({
18015
+ empty: zod.z.boolean(),
18016
+ count: zod.z.number().int().nonnegative(),
18017
+ text: zod.z.string(),
18018
+ sections: zod.z.array(NcStateSummaryPreviewSectionSchema),
18019
+ dropped: zod.z.record(zod.z.string(), zod.z.number().int().nonnegative()),
18020
+ excludedGroups: zod.z.array(zod.z.string())
18021
+ });
17948
18022
  var NcTestResultSchema = zod.z.object({
17949
18023
  recordId: zod.z.string(),
17950
18024
  recordKind: zod.z.enum([
@@ -18036,6 +18110,13 @@ var NcTemplateVarDescriptorSchema = zod.z.object({
18036
18110
  kinds: zod.z.array(NcTemplateVarKindSchema).optional(),
18037
18111
  deliveries: zod.z.array(NcDeliverySchema).optional(),
18038
18112
  systemEventKinds: zod.z.array(NcSystemEventKindSchema).optional(),
18113
+ /**
18114
+ * Which system-event DELIVERY has a value for it (D647). Absent = an
18115
+ * instant row only when the descriptor names `systemEventKinds` (a
18116
+ * per-event fact: a summary row has no single device), and both otherwise.
18117
+ * `['summary']` marks the state-summary vocabulary (`{{summaryText}}`, ...).
18118
+ */
18119
+ systemEventDeliveries: zod.z.array(NcSystemEventDeliveryModeSchema).optional(),
18039
18120
  dynamic: zod.z.object({
18040
18121
  prefix: zod.z.literal("count_"),
18041
18122
  from: zod.z.literal("classes")
@@ -18047,7 +18128,9 @@ var NcTemplateVarContextSchema = zod.z.object({
18047
18128
  field: NcTemplateFieldSchema,
18048
18129
  kind: NcRuleKindSchema.optional(),
18049
18130
  delivery: NcDeliverySchema.optional(),
18050
- systemEventKinds: zod.z.array(NcSystemEventKindSchema).optional()
18131
+ systemEventKinds: zod.z.array(NcSystemEventKindSchema).optional(),
18132
+ /** The rule's system-event delivery (D647); absent = instant. */
18133
+ systemEventDelivery: NcSystemEventDeliveryModeSchema.optional()
18051
18134
  });
18052
18135
  /** Input to `previewTemplate` — the editor's own context, plus the draft text. */
18053
18136
  var NcTemplatePreviewInputSchema = zod.z.object({
@@ -18658,6 +18741,17 @@ var notificationRulesCapability = {
18658
18741
  auth: "admin"
18659
18742
  }),
18660
18743
  /**
18744
+ * The STATE SUMMARY a system rule would send now (D647) — for a saved rule
18745
+ * or an unsaved draft. Pure: sends nothing, stamps nothing. A MUTATION
18746
+ * only for transport (a whole rule does not belong in a GET URL). Admin,
18747
+ * like `testRule`: it names devices and nodes across the installation.
18748
+ */
18749
+ previewStateSummary: method(zod.z.object({ rule: NcRuleInputSchema }), NcStateSummaryPreviewSchema, {
18750
+ kind: "mutation",
18751
+ auth: "admin",
18752
+ access: "view"
18753
+ }),
18754
+ /**
18661
18755
  * The machine-readable condition surface a rule editor renders from, plus
18662
18756
  * the picker VOCABULARY those conditions draw on.
18663
18757
  *
@@ -19118,1037 +19212,212 @@ var oauthIntegrationCapability = {
19118
19212
  getDescriptor: method(zod.z.void(), OauthIntegrationDescriptorSchema, { auth: "admin" }) }
19119
19213
  };
19120
19214
  /**
19121
- * Reference to the frame's retained NATIVE surface + the parent crop's placement
19122
- * within the frame, so the executor can re-cut a leaf child ROI at native
19123
- * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
19215
+ * pipeline-analytics — device-scoped wrapper cap. Refines raw
19216
+ * per-frame detections emitted by the pipeline runner into tracked
19217
+ * objects, per-kind event collections (motion / object / audio), and
19218
+ * persisted media. Owns the post-detection domain end-to-end:
19219
+ *
19220
+ * runner emits PipelineInferenceResult
19221
+ * ↓ (event bus)
19222
+ * pipeline-analytics subscriber
19223
+ * ↓ SORT tracker + zone engine + state analyzer + event emitter
19224
+ * → three DB collections (one per kind), one FS media tree, one
19225
+ * unified event emitter (FrameTracked + TrackStarted/Ended +
19226
+ * DetectionEvent on bus)
19227
+ *
19228
+ * Pure subscriber model. No `processFrame` cap method — the runner
19229
+ * already publishes the raw frame on the bus. The cap surface is
19230
+ * only QUERIES + per-device settings, bound on/off via
19231
+ * `device-manager.setWrapperActive`. `defaultActive: true` because
19232
+ * every camera with a detection pipeline wants its raw detections
19233
+ * refined; operators opt out per-device via BindingsTab when needed.
19234
+ *
19235
+ * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
19236
+ * (per-device surface) and `track-trail` caps — see P11 cleanup.
19124
19237
  */
19125
- var NativeCropRefSchema = zod.z.object({
19126
- /** Handle keying the retained native surface (node-pinned to its owner). */
19127
- handle: FrameHandleSchema,
19128
- /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
19129
- cropFrameSpace: zod.z.object({
19130
- x: zod.z.number(),
19131
- y: zod.z.number(),
19132
- w: zod.z.number(),
19133
- h: zod.z.number()
19134
- })
19135
- });
19136
- zod.z.object({
19137
- crop: zod.z.object({
19138
- left: zod.z.number(),
19139
- top: zod.z.number(),
19140
- width: zod.z.number().positive(),
19141
- height: zod.z.number().positive()
19142
- }).optional(),
19143
- content: zod.z.object({
19144
- width: zod.z.number().int().positive(),
19145
- height: zod.z.number().int().positive()
19146
- }),
19147
- fit: zod.z.enum(["stretch", "contain"]),
19148
- format: zod.z.enum([
19149
- "rgb",
19150
- "gray",
19151
- "jpeg"
19152
- ])
19153
- });
19238
+ var TrackStateSchema = zod.z.enum([
19239
+ "new",
19240
+ "entered",
19241
+ "left",
19242
+ "moving",
19243
+ "idle"
19244
+ ]);
19245
+ var EventKindSchema = zod.z.enum([
19246
+ "motion",
19247
+ "object",
19248
+ "audio"
19249
+ ]);
19154
19250
  /**
19155
- * Process-local frame identity. It is serializable so it can ride an in-process
19156
- * capability call, but `registryId` deliberately prevents resolution in any
19157
- * other process or execution group.
19251
+ * Spatial filter for `listTracks` — the rect + polygon variants of the shared
19252
+ * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
19253
+ * of the camera frame (top-left origin), matching the drawing-plane editor.
19158
19254
  */
19159
- var FrameRefSchema = zod.z.object({
19160
- registryId: zod.z.string().min(1),
19161
- id: zod.z.string().min(1),
19162
- width: zod.z.number().int().positive(),
19163
- height: zod.z.number().int().positive(),
19164
- format: zod.z.enum(["rgb", "gray"]),
19165
- timestamp: zod.z.number(),
19166
- capturedAt: zod.z.number().optional()
19167
- });
19168
- var ModelFormatSchema$1 = zod.z.enum([
19169
- "onnx",
19170
- "coreml",
19171
- "openvino",
19172
- "tflite",
19173
- "pt",
19174
- "gguf"
19255
+ var TrackZoneFilterSchema = zod.z.discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
19256
+ /** Closed icon vocabulary so clients render a known glyph per kind. */
19257
+ var EventKindIconSchema = zod.z.enum([
19258
+ "motion",
19259
+ "audio",
19260
+ "person",
19261
+ "vehicle",
19262
+ "animal",
19263
+ "door",
19264
+ "pir",
19265
+ "smoke",
19266
+ "water",
19267
+ "button",
19268
+ "package",
19269
+ "generic"
19175
19270
  ]);
19176
- var PipelineSlotSchema = zod.z.enum([
19177
- "detector",
19178
- "cropper",
19179
- "classifier",
19180
- "refiner",
19181
- "audio-classifier"
19271
+ var EventKindCategorySchema = zod.z.enum([
19272
+ "motion",
19273
+ "audio",
19274
+ "detection",
19275
+ "sensor",
19276
+ "control",
19277
+ "custom",
19278
+ "package"
19182
19279
  ]);
19183
- var PipelineEngineChoiceSchema = zod.z.object({
19184
- runtime: zod.z.enum(["node", "python"]),
19185
- backend: zod.z.string(),
19186
- format: ModelFormatSchema$1,
19187
- device: zod.z.string().optional()
19188
- });
19189
- var EngineDeviceInfoSchema = zod.z.object({
19190
- id: zod.z.string(),
19280
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
19281
+ var EventKindLevelSchema = zod.z.enum(["macro", "sub"]);
19282
+ var EventKindDescriptorSchema = zod.z.object({
19283
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
19284
+ kind: zod.z.string(),
19285
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
19286
+ labelKey: zod.z.string(),
19287
+ /** English fallback label (kept for clients that don't translate). */
19191
19288
  label: zod.z.string(),
19192
- description: zod.z.string().optional()
19193
- });
19194
- var AvailableEngineSchema = zod.z.object({
19195
- engine: PipelineEngineChoiceSchema,
19196
- devices: zod.z.array(EngineDeviceInfoSchema).readonly(),
19197
- defaultDevice: zod.z.string()
19198
- });
19199
- var PipelineDefaultStepSchema = zod.z.lazy(() => zod.z.object({
19200
- addonId: zod.z.string(),
19201
- addonName: zod.z.string(),
19202
- slot: PipelineSlotSchema,
19203
- inputClasses: zod.z.array(zod.z.string()).readonly(),
19204
- outputClasses: zod.z.array(zod.z.string()).readonly(),
19205
- enabled: zod.z.boolean(),
19206
- modelId: zod.z.string(),
19207
- children: zod.z.array(PipelineDefaultStepSchema).readonly(),
19208
- group: zod.z.string().optional(),
19209
- settings: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
19210
- }));
19211
- var PipelineTemplateStepSchema = zod.z.lazy(() => zod.z.object({
19212
- addonId: zod.z.string(),
19213
- enabled: zod.z.boolean(),
19214
- modelId: zod.z.string(),
19215
- children: zod.z.array(PipelineTemplateStepSchema).readonly(),
19216
- settings: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
19217
- }));
19218
- var PipelineTemplateSchema$1 = zod.z.object({
19219
- id: zod.z.string(),
19220
- name: zod.z.string(),
19221
- createdAt: zod.z.string(),
19222
- updatedAt: zod.z.string(),
19223
- engine: PipelineEngineChoiceSchema,
19224
- steps: zod.z.array(PipelineTemplateStepSchema).readonly()
19289
+ /** Hex color for timeline/legend rendering. */
19290
+ color: zod.z.string(),
19291
+ /** Dictionary id → lucide component on the UI side. */
19292
+ iconId: zod.z.string(),
19293
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
19294
+ icon: EventKindIconSchema,
19295
+ category: EventKindCategorySchema,
19296
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
19297
+ parentKind: zod.z.string().nullable(),
19298
+ /** Derived from `parentKind`, explicit for the client tree. */
19299
+ level: EventKindLevelSchema,
19300
+ /** Which cap + device contributes this kind. For built-ins the camera
19301
+ * itself; for sensor kinds the LINKED source device. */
19302
+ source: zod.z.object({
19303
+ capName: zod.z.string(),
19304
+ deviceId: zod.z.number()
19305
+ })
19225
19306
  });
19226
- var PipelineModelOptionSchema = zod.z.object({
19227
- id: zod.z.string(),
19228
- name: zod.z.string(),
19229
- formats: zod.z.record(zod.z.string(), zod.z.object({
19230
- downloaded: zod.z.boolean(),
19231
- sizeMB: zod.z.number()
19232
- })),
19233
- group: ModelVariantGroupSchema.optional(),
19234
- legacy: zod.z.boolean().optional(),
19235
- provider: ModelProviderIdSchema.optional()
19307
+ /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
19308
+ var EventKindsForDeviceSchema = zod.z.object({
19309
+ deviceId: zod.z.number(),
19310
+ kinds: zod.z.array(EventKindDescriptorSchema).readonly()
19236
19311
  });
19237
- var ConfigFieldBridge = zod.z.custom();
19238
- var PipelineAddonSchemaSchema = zod.z.object({
19312
+ var SensorEventSchema = zod.z.object({
19239
19313
  id: zod.z.string(),
19240
- name: zod.z.string(),
19241
- slot: PipelineSlotSchema,
19242
- inputClasses: zod.z.array(zod.z.string()).readonly(),
19243
- outputClasses: zod.z.array(zod.z.string()).readonly(),
19244
- childSlots: zod.z.array(PipelineSlotSchema).readonly(),
19245
- models: zod.z.array(PipelineModelOptionSchema).readonly(),
19246
- defaultModelId: zod.z.string(),
19247
- defaultModelIdByFormat: zod.z.record(zod.z.string(), zod.z.string()).optional(),
19248
- enabledByDefault: zod.z.boolean().optional(),
19249
- backfillIntoExistingOverrides: zod.z.boolean().optional(),
19250
- defaultConfidence: zod.z.number(),
19251
- group: zod.z.string().optional(),
19252
- configSchema: zod.z.array(ConfigFieldBridge).readonly().optional()
19253
- });
19254
- var PipelineSlotSchemaSchema = zod.z.object({
19255
- id: PipelineSlotSchema,
19256
- label: zod.z.string(),
19257
- priority: zod.z.number(),
19258
- parentSlot: PipelineSlotSchema.nullable(),
19259
- addons: zod.z.array(PipelineAddonSchemaSchema).readonly()
19260
- });
19261
- var PipelineSchemaSchema = zod.z.object({
19262
- availableEngines: zod.z.array(AvailableEngineSchema).readonly(),
19263
- selectedEngine: PipelineEngineChoiceSchema,
19264
- slots: zod.z.array(PipelineSlotSchemaSchema).readonly()
19265
- });
19266
- var EngineProvisioningSchema = zod.z.object({
19267
- runtimeId: zod.z.enum([
19268
- "onnx",
19269
- "openvino",
19270
- "coreml",
19271
- "edgetpu"
19272
- ]).nullable(),
19273
- device: zod.z.string().nullable(),
19274
- state: zod.z.enum([
19275
- "idle",
19276
- "installing",
19277
- "verifying",
19278
- "ready",
19279
- "failed"
19280
- ]),
19281
- progress: zod.z.number().optional(),
19282
- error: zod.z.string().optional(),
19283
- nextRetryAt: zod.z.number().optional(),
19284
- /**
19285
- * Gate A (config-correctness gate at engine change): human-readable
19286
- * config issues surfaced EAGERLY when the node's engine changes — model
19287
- * substitutions ("chose X, running Y") and zero-build steps ("no model
19288
- * has a <format> build"). Additive/optional: informational only, never
19289
- * enforced here — `assertEngineReady` (readiness) still gates inference.
19290
- * Absent/empty when the node-default tree resolves cleanly.
19291
- */
19292
- configIssues: zod.z.array(zod.z.string()).optional()
19293
- });
19294
- var PipelineStepInputSchema = zod.z.lazy(() => zod.z.object({
19295
- addonId: zod.z.string(),
19296
- modelId: zod.z.string().optional(),
19297
- enabled: zod.z.boolean().default(true),
19298
- children: zod.z.array(PipelineStepInputSchema).optional(),
19299
- settings: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
19300
- jumpDeviceKey: zod.z.string().optional()
19301
- }));
19302
- var ModelSubstitutionSchema = zod.z.object({
19303
- addonId: zod.z.string(),
19304
- chosen: zod.z.string(),
19305
- running: zod.z.string(),
19306
- format: zod.z.string()
19307
- });
19308
- var PipelineValidationIssueSchema = zod.z.object({
19309
- addonId: zod.z.string(),
19310
- kind: zod.z.enum(["unknown-addon", "no-format-build"]),
19311
- detail: zod.z.string()
19312
- });
19313
- var PipelineValidationResultSchema = zod.z.object({
19314
- ok: zod.z.boolean(),
19315
- issues: zod.z.array(PipelineValidationIssueSchema).readonly(),
19316
- substitutions: zod.z.array(ModelSubstitutionSchema).readonly(),
19317
- /** The node's `currentEngine.format` this validation ran against. */
19318
- format: zod.z.string()
19319
- });
19320
- var ReferenceImageEntrySchema = zod.z.object({
19321
- filename: zod.z.string(),
19322
- stepIds: zod.z.array(zod.z.string()).readonly().optional()
19323
- });
19324
- var ReferenceImageBodySchema = zod.z.object({
19325
- base64: zod.z.string(),
19326
- filename: zod.z.string()
19327
- });
19328
- var ReferenceAudioEntrySchema = zod.z.object({
19329
- filename: zod.z.string(),
19330
- sizeKb: zod.z.number()
19314
+ /** The CAMERA the event is attributed to (a sensor linked to N cameras
19315
+ * yields N rows, one per camera). */
19316
+ deviceId: zod.z.number(),
19317
+ /** The linked sensor device whose state changed. */
19318
+ sourceDeviceId: zod.z.number(),
19319
+ /** Event kind id — matches an `EventKindDescriptor.kind`. */
19320
+ kind: zod.z.string(),
19321
+ /** Snapshot of the sensor cap's runtime-state slice at the change. */
19322
+ value: zod.z.record(zod.z.string(), zod.z.unknown()).nullable(),
19323
+ timestamp: zod.z.number()
19331
19324
  });
19332
- var ReferenceAudioBodySchema = zod.z.object({ base64: zod.z.string() });
19333
- var AudioBackendSchema = zod.z.object({
19334
- id: zod.z.string(),
19335
- name: zod.z.string(),
19336
- description: zod.z.string(),
19337
- available: zod.z.boolean(),
19325
+ /**
19326
+ * One stored sighting on a track's trajectory.
19327
+ *
19328
+ * The array these live in is returned in TIME order (D399) — it is APPENDED in
19329
+ * arrival order, and the two detector passes interleave, so a consumer must not
19330
+ * assume the two are the same on a row written by an older build.
19331
+ */
19332
+ var TrackPositionSchema = zod.z.object({
19333
+ x: zod.z.number(),
19334
+ y: zod.z.number(),
19335
+ timestamp: zod.z.number(),
19336
+ bbox: BoundingBoxSchema,
19338
19337
  /**
19339
- * Raw classifier labels this backend can emit (e.g. YAMNet's
19340
- * 521-class set or Apple SoundAnalysis's 303-class set). Used by
19341
- * the benchmark UI to populate the `enabledMicroClasses` filter
19342
- * specific to the selected backend without a separate fetch.
19338
+ * Which detector pass measured this box (D399): `frame` is the full-frame
19339
+ * pass on the analysis raster, `recovery` is the native-resolution
19340
+ * small-subject second pass (D377/D378). Both write into one array, and until
19341
+ * this field existed the only way to tell them apart was that full-frame boxes
19342
+ * are exact multiples of 1.2 while recovery boxes are full-precision floats.
19343
+ * Absent on rows written before D399.
19343
19344
  */
19344
- rawLabels: zod.z.array(zod.z.string()).readonly().optional()
19345
+ source: zod.z.enum(["frame", "recovery"]).optional(),
19346
+ /** Detection score of this box, so a position can be weighed and not only
19347
+ * plotted. Absent on rows written before D399. */
19348
+ score: zod.z.number().optional()
19345
19349
  });
19346
- var AudioCapabilitiesSchema = zod.z.object({
19347
- activeBackend: zod.z.string(),
19348
- availableBackends: zod.z.array(AudioBackendSchema).readonly(),
19349
- sampleRate: zod.z.number(),
19350
- chunkDurationMs: zod.z.number()
19350
+ var TrackSnapshotSchema = zod.z.object({
19351
+ timestamp: zod.z.number(),
19352
+ position: TrackPositionSchema,
19353
+ /** The snapshot's media row id (D482); resolve via `listTrackMedia({ trackId })`. */
19354
+ mediaId: zod.z.number().int()
19351
19355
  });
19352
- var DownloadModelResultSchema = zod.z.object({
19353
- filePath: zod.z.string(),
19354
- sizeMB: zod.z.number(),
19355
- durationMs: zod.z.number()
19356
+ /**
19357
+ * Normalized 0..1 trajectory envelope (min/max over every position bbox,
19358
+ * divided by the track's detection-frame dims), computed at persist time.
19359
+ * Absent when the frame dims were unknown when the track was persisted
19360
+ * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
19361
+ */
19362
+ var TrackEnvelopeSchema = zod.z.object({
19363
+ minX: zod.z.number(),
19364
+ minY: zod.z.number(),
19365
+ maxX: zod.z.number(),
19366
+ maxY: zod.z.number()
19356
19367
  });
19357
19368
  /**
19358
- * Wrapper carrying a single test run's result. Replaces the legacy
19359
- * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
19360
- * canonical `AudioResult` from the Phase 6 output rework: one
19361
- * `AudioDetection` per class above `minScore`, top-N candidates in
19362
- * `debug.alternateLabels['audio-classifier']`, per-source timings in
19363
- * `debug.stepTimings`. The outer `success`/`error` fields stay so the
19364
- * benchmark UI can still report a clean failure when the classifier
19365
- * cap isn't available.
19369
+ * Row projection for track list queries. `full` (default) returns the
19370
+ * complete Track including the frame-rate `positions[]` history and the
19371
+ * `snapshots[]` references — megabytes across a page of tracks. `slim`
19372
+ * keeps every scalar the list surfaces actually render (ids, class(es),
19373
+ * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
19374
+ * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
19375
+ * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
19376
+ * `getTrack`. Mirrors the event-store `projection` convention
19377
+ * (`getObjectEvents` et al.).
19366
19378
  */
19367
- var AudioTestResultSchema = zod.z.object({
19368
- success: zod.z.boolean(),
19369
- error: zod.z.string().optional(),
19370
- frame: zod.z.custom().optional()
19379
+ var TrackProjectionSchema = zod.z.enum(["full", "slim"]);
19380
+ /**
19381
+ * One audio-classification label heard on the track's camera while the
19382
+ * track was alive, aggregated per label. An "episode" is one persisted
19383
+ * audio event (the confident-classification path: score ≥ the device's
19384
+ * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
19385
+ * one 32 ms inference chunk, so counts stay human-scaled.
19386
+ */
19387
+ var TrackAudioLabelSchema = zod.z.object({
19388
+ label: zod.z.string(),
19389
+ /** Highest classification score observed across the label's episodes. */
19390
+ peakScore: zod.z.number(),
19391
+ /** Number of coalesced audio-event episodes carrying this label. */
19392
+ count: zod.z.number(),
19393
+ firstAt: zod.z.number(),
19394
+ lastAt: zod.z.number()
19371
19395
  });
19372
- var PipelineConfigBridge = zod.z.custom();
19373
- var ConfigUISchemaBridge = zod.z.custom();
19374
- var ConfigUISchemaNullableBridge = zod.z.custom();
19375
- var InferenceCapabilitiesBridge = zod.z.custom();
19376
- var ModelAvailabilityListBridge = zod.z.custom();
19377
- var PipelineRunResultBridge = zod.z.custom();
19378
19396
  /**
19379
- * Pipeline executor — detection engine + configuration + inference API.
19397
+ * How a track was produced. `pipeline` (default / absent) = the spatial
19398
+ * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
19399
+ * no positions, a single snapshot, and no bbox trajectory at all:
19380
19400
  *
19381
- * Merged from: pipeline-executor, pipeline-config, inference, detection-config.
19382
- * Implemented by the detection-pipeline addon.
19401
+ * - `sensor` — a linked sensor/control device state change.
19402
+ * - `audio` — an audio event on the camera itself that was anomalous for
19403
+ * THAT camera, loud, and heard while nothing visual was happening (D62).
19383
19404
  *
19384
- * Per-device surface (DeviceSettingsContribution + the "is detection
19385
- * enabled for this camera?" toggle) lives on the paired
19386
- * `detection-pipeline` cap (device-scoped, singleton, wrapper
19387
- * defaultActive) — same split pattern used by stream-broker /
19388
- * camera-streams and audio-analyzer / audio-analysis.
19389
- */
19390
- var pipelineExecutorCapability = {
19391
- name: "pipeline-executor",
19392
- scope: "system",
19393
- mode: "singleton",
19394
- methods: {
19395
- getAvailableEngines: method(zod.z.void(), zod.z.array(PipelineEngineChoiceSchema)),
19396
- getSelectedEngine: method(zod.z.void(), PipelineEngineChoiceSchema),
19397
- getDefaultSteps: method(PipelineEngineChoiceSchema, zod.z.array(PipelineDefaultStepSchema)),
19398
- /**
19399
- * Per-node detection-engine provisioning snapshot. Returns the live
19400
- * state of the lazy runtime-provisioning machine on `nodeId`
19401
- * (idle / installing / verifying / ready / failed). The UI pairs this
19402
- * one-shot query with the `pipeline.engine-provisioning` live event
19403
- * (emitted on every transition) to drive a per-node "engine ready?"
19404
- * indicator without polling. Phase 2.
19405
- */
19406
- getEngineProvisioning: method(zod.z.object({ nodeId: zod.z.string() }), EngineProvisioningSchema),
19407
- getVideoPipelineSteps: method(zod.z.void(), zod.z.record(zod.z.string(), zod.z.object({
19408
- modelId: zod.z.string(),
19409
- settings: zod.z.record(zod.z.string(), zod.z.unknown()).readonly()
19410
- }))),
19411
- setVideoPipelineSteps: method(zod.z.object({ steps: zod.z.record(zod.z.string(), zod.z.object({
19412
- modelId: zod.z.string(),
19413
- settings: zod.z.record(zod.z.string(), zod.z.unknown()).readonly()
19414
- })) }), zod.z.object({ success: zod.z.literal(true) }), {
19415
- kind: "mutation",
19416
- auth: "admin"
19417
- }),
19418
- /**
19419
- * Clear THIS node's executor-side PER-DEVICE settings stores (the
19420
- * per-camera step overrides the object-detection root reads via
19421
- * `applyDeviceOverridesToTree`). `nodeId` is the ROUTING key — the
19422
- * generated cap-router strips it (default `nodeIdMode: 'routing'`) and
19423
- * dispatches to that node, so the provider method runs ON the target
19424
- * node and receives no `nodeId`.
19425
- *
19426
- * This is the slimmed executor leg of the orchestrator's
19427
- * `resetNodePipelineDefaults` flow (which owns the real reset: node
19428
- * addonDefaults pins + per-camera orchestrator overrides). The legacy
19429
- * `resetToDefault` — which reset a persisted global step-tree seed
19430
- * nothing in the live per-camera path read — was removed together with
19431
- * that seed.
19432
- */
19433
- clearDeviceOverrides: method(zod.z.object({ nodeId: zod.z.string() }), zod.z.object({
19434
- success: zod.z.literal(true),
19435
- clearedDevices: zod.z.number()
19436
- }), {
19437
- kind: "mutation",
19438
- auth: "admin"
19439
- }),
19440
- /**
19441
- * Which of THIS node's inference devices the executor currently refuses,
19442
- * and why. `nodeId` is the ROUTING key (stripped by the generated router).
19443
- *
19444
- * The channel that did not exist. Pool health was known only inside the
19445
- * detection addon and was an input to no routing decision anywhere: the
19446
- * per-dispatch capability gate is keyed on model FORMAT and so can never
19447
- * separate `openvino:gpu` from `openvino:npu`, and the orchestrator's live
19448
- * eligibility probe (`platformProbe.getCapabilities`) answers about
19449
- * HARDWARE — which was present throughout. So when the hub's `openvino:gpu`
19450
- * Python worker was SIGABRT'd by the Intel GPU plugin on 2026-08-25, the
19451
- * balancer went on handing that dead pool cameras by rotation for 31 hours:
19452
- * ~370 000 `PoolWorker[w0]: not initialized` lines, every frame lost.
19453
- *
19454
- * Read semantics the caller depends on, and which the provider guarantees:
19455
- * this is a synchronous read of in-memory state. It never probes hardware,
19456
- * never spawns a pool and never throws — an EMPTY `unhealthy` means "asked,
19457
- * nothing is refused", which is what re-admits a device. A read that FAILS
19458
- * (node offline, version skew) must therefore be distinguishable from an
19459
- * empty answer, and it is: it rejects.
19460
- */
19461
- getInferenceDeviceHealth: method(zod.z.object({ nodeId: zod.z.string() }), zod.z.object({ unhealthy: zod.z.array(zod.z.object({
19462
- /** `<backend>:<device>`, e.g. `openvino:gpu`. */
19463
- deviceKey: zod.z.string(),
19464
- /**
19465
- * `failed` — the per-device restart budget is exhausted; no pool
19466
- * will be spawned until an operator re-arms it or the runner
19467
- * respawns. `backoff` — under budget, waiting out the backoff (or
19468
- * a cached pool observed dead and not yet condemned).
19469
- */
19470
- state: zod.z.enum(["failed", "backoff"]),
19471
- /** Epoch ms of the death that produced this state. */
19472
- since: zod.z.number(),
19473
- /** Pool deaths inside the current window. */
19474
- deaths: zod.z.number(),
19475
- /** The last death's message. */
19476
- lastError: zod.z.string()
19477
- })).readonly() })),
19478
- /**
19479
- * Re-arm a terminally `failed` inference device on `nodeId`: forget its
19480
- * restart budget so the next dispatch builds a fresh pool.
19481
- *
19482
- * The terminal state is deliberate (the abort it bounds is deterministic —
19483
- * an automatic probation would just respawn Python forever, more slowly),
19484
- * and a terminal state an operator cannot leave is a silent fault. This is
19485
- * the way out. `rearmed:false` means there was nothing to forget.
19486
- */
19487
- rearmInferenceDevice: method(zod.z.object({
19488
- nodeId: zod.z.string(),
19489
- deviceKey: zod.z.string()
19490
- }), zod.z.object({ rearmed: zod.z.boolean() }), {
19491
- kind: "mutation",
19492
- auth: "admin"
19493
- }),
19494
- getSchema: method(zod.z.void(), PipelineSchemaSchema),
19495
- getGlobalSteps: method(zod.z.void(), zod.z.array(PipelineDefaultStepSchema).readonly().nullable()),
19496
- getGlobalPipelineConfig: method(zod.z.void(), PipelineConfigBridge),
19497
- getOrchestratorConfigSchema: method(zod.z.void(), ConfigUISchemaBridge),
19498
- /**
19499
- * Gate B (pre-init config-correctness gate). PURE COMPUTE against this
19500
- * node's `currentEngine.format` — resolves `steps` the same way the
19501
- * runtime dispatch path would, and reports what WOULD happen without
19502
- * touching any node-global state. Called by the orchestrator at attach
19503
- * time (`attachOn`), node-pinned to the TARGET node, so config problems
19504
- * surface BEFORE `pipelineRunner.attachCamera` rather than at the first
19505
- * per-frame resolve. `ok` is false iff `issues` is non-empty (both
19506
- * `unknown-addon` and `no-format-build` are HARD issues); `substitutions`
19507
- * is informational (a degraded-but-loadable model swap) and never
19508
- * affects `ok`. Never throws.
19509
- */
19510
- validatePipeline: method(zod.z.object({ steps: zod.z.array(PipelineStepInputSchema) }), PipelineValidationResultSchema),
19511
- listTemplates: method(zod.z.void(), zod.z.array(PipelineTemplateSchema$1).readonly()),
19512
- saveTemplate: method(zod.z.object({
19513
- name: zod.z.string(),
19514
- steps: zod.z.array(PipelineTemplateStepSchema).readonly(),
19515
- engine: PipelineEngineChoiceSchema
19516
- }), PipelineTemplateSchema$1, { kind: "mutation" }),
19517
- updateTemplate: method(zod.z.object({
19518
- id: zod.z.string(),
19519
- name: zod.z.string().optional(),
19520
- steps: zod.z.array(PipelineTemplateStepSchema).readonly().optional()
19521
- }), PipelineTemplateSchema$1, { kind: "mutation" }),
19522
- deleteTemplate: method(zod.z.object({ id: zod.z.string() }), zod.z.void(), { kind: "mutation" }),
19523
- getCapabilities: method(zod.z.void(), InferenceCapabilitiesBridge),
19524
- getAddonModels: method(zod.z.object({ addonId: zod.z.string() }), ModelAvailabilityListBridge),
19525
- downloadModel: method(zod.z.object({
19526
- addonId: zod.z.string(),
19527
- modelId: zod.z.string(),
19528
- format: ModelFormatSchema$1
19529
- }), DownloadModelResultSchema, { kind: "mutation" }),
19530
- deleteModel: method(zod.z.object({
19531
- addonId: zod.z.string(),
19532
- modelId: zod.z.string(),
19533
- format: ModelFormatSchema$1
19534
- }), zod.z.object({ success: zod.z.literal(true) }), { kind: "mutation" }),
19535
- /**
19536
- * Stateless single-frame execution. Callers (runner, benchmark) pass
19537
- * the complete `engine` + `steps` tree; the executor holds no state
19538
- * about cameras or saved pipelines.
19539
- *
19540
- * `engine` is optional during the migration window to preserve the
19541
- * legacy call shape used by existing benchmark code; once all
19542
- * callers pass it explicitly we make it required.
19543
- *
19544
- * Exactly one of `frame`, `frameRef`, `frameHandle`, `imageBase64`,
19545
- * `referenceImage` must be provided:
19546
- * - `frame`: runtime dispatch path (runner → decoded broker frame).
19547
- * Carries the raw buffer, dimensions, and format; the executor
19548
- * uses it directly without base64 round-tripping.
19549
- * - `frameHandle` (CB5): a zero-pixel shm `FrameHandle` for the SAME
19550
- * decoded frame. Both runner and executor are hub-local processes
19551
- * sharing `/dev/shm`, so the executor maps the named segment and
19552
- * reads the pixels back zero-copy — eliminating the ~1.2MB
19553
- * re-serialisation over UDS/MsgPack the `frame` path pays per call.
19554
- * High-risk: the FrameRing is a latest-wins seqlock with no
19555
- * refcount, so a recycled slot yields a null read; the executor
19556
- * then degrades to an empty result and the runner ships pixels via
19557
- * `frame` as the fallback (queue-depth gated on the runner side).
19558
- * - `imageBase64`: one-shot test path (benchmark ImageTab).
19559
- * - `referenceImage`: named file from the reference-image store.
19560
- */
19561
- runPipeline: method(zod.z.object({
19562
- engine: PipelineEngineChoiceSchema.optional(),
19563
- steps: zod.z.array(PipelineStepInputSchema).min(1),
19564
- frame: FrameInputSchema.optional(),
19565
- /**
19566
- * Process-local lazy frame. Valid only when caller and provider resolve
19567
- * in the same execution-group process; split/cross-node callers use
19568
- * `frame`/`image` inline compatibility instead.
19569
- */
19570
- frameRef: FrameRefSchema.optional(),
19571
- /**
19572
- * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
19573
- * the decoded pixels live in. One more member of the one-of
19574
- * frame/frameHandle/image/imageBase64/referenceImage group.
19575
- */
19576
- frameHandle: FrameHandleSchema.optional(),
19577
- imageBase64: zod.z.string().optional(),
19578
- /**
19579
- * Binary JPEG bytes — preferred over `imageBase64` on internal
19580
- * hops (hub → forked worker via Moleculer MsgPack) because it
19581
- * skips the 33% base64 overhead + the per-call base64 decode on
19582
- * the detection-pipeline worker. Callers can pass either; exactly
19583
- * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
19584
- */
19585
- image: zod.z.instanceof(Uint8Array).optional(),
19586
- referenceImage: zod.z.string().optional(),
19587
- deviceId: zod.z.number().optional(),
19588
- sessionId: zod.z.string().optional(),
19589
- /**
19590
- * Execution plane. 'full' (default) runs the whole tree — benchmark,
19591
- * reference-image, and detail-subtree calls. 'frame' is the live
19592
- * per-frame dispatch: ONLY root-plane steps run; crop children
19593
- * (inputClasses ≠ null) are skipped and served per-track via
19594
- * pipelineRunner.runDetailSubtree (two-plane design).
19595
- */
19596
- plane: zod.z.enum(["full", "frame"]).optional(),
19597
- /**
19598
- * Inference-device selector (Phase 2 multi-device). Format
19599
- * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
19600
- * Omitted ⇒ the runner's default device (current single-engine
19601
- * behaviour). Selects WHICH device pool of the node runs the call.
19602
- */
19603
- deviceKey: zod.z.string().optional(),
19604
- /**
19605
- * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
19606
- * when the parent crop was resolved from the frame's retained NATIVE
19607
- * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
19608
- * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
19609
- * resolution from that surface — the SAME quality path faces already
19610
- * had — instead of the downscaled parent tile. `handle` keys the native
19611
- * surface (node-pinned to its owner); `cropFrameSpace` is the parent
19612
- * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
19613
- * the executor's crop-normalized child ROI back into frame-normalized
19614
- * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
19615
- * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
19616
- * (today's behaviour on the fallback path).
19617
- */
19618
- nativeCropRef: NativeCropRefSchema.optional()
19619
- }), PipelineRunResultBridge, { kind: "mutation" }),
19620
- /**
19621
- * Batched run — N raw frames packed into one cap call. The provider
19622
- * routes the batch through `SharedInferencePool.inferBatch`
19623
- * (`MSG_INFER_BATCH = 0x03`) so the IPC framing and JSON response
19624
- * envelope cost is amortised N:1 vs N concurrent `runPipeline`
19625
- * calls. Single root step + uniform model assumed; trees with crop
19626
- * children fall back to sequential execution.
19627
- *
19628
- * Used by `scripts/bench-batch-style.mts` for batch benchmarking —
19629
- * N frames in one call to amortise per-call IPC overhead.
19630
- */
19631
- runPipelineBatch: method(zod.z.object({
19632
- engine: PipelineEngineChoiceSchema.optional(),
19633
- steps: zod.z.array(PipelineStepInputSchema).min(1),
19634
- frames: zod.z.array(FrameInputSchema).min(1).max(255),
19635
- deviceId: zod.z.number().optional(),
19636
- sessionId: zod.z.string().optional(),
19637
- /**
19638
- * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
19639
- * the batch to the Python pool's bench preprocess cache
19640
- * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
19641
- * preprocessed ONCE and every later inference is a pure-inference cache
19642
- * hit — the sustained-throughput run measures inference, not
19643
- * decode+preprocess+infer. Omitted/0 for live frames (all different →
19644
- * full preprocess every call, correct). Fresh per sustained run;
19645
- * released via `uncacheFrame`.
19646
- */
19647
- frameId: zod.z.number().int().nonnegative().optional(),
19648
- /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
19649
- deviceKey: zod.z.string().optional()
19650
- }), zod.z.object({ results: zod.z.array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }),
19651
- /**
19652
- * Cache a raw frame inside the Python inference pool's memory.
19653
- * Returns a numeric `frameId` that `inferCached` references —
19654
- * subsequent calls send only 5 bytes through the pipe instead of
19655
- * 1.2MB raw data, eliminating the pipe transfer bottleneck.
19656
- */
19657
- cacheFrameInPool: method(zod.z.object({
19658
- data: zod.z.instanceof(Uint8Array),
19659
- width: zod.z.number().int().positive(),
19660
- height: zod.z.number().int().positive(),
19661
- format: zod.z.enum([
19662
- "rgb",
19663
- "bgr",
19664
- "gray"
19665
- ])
19666
- }), zod.z.object({
19667
- frameId: zod.z.number(),
19668
- width: zod.z.number(),
19669
- height: zod.z.number()
19670
- }), { kind: "mutation" }),
19671
- /**
19672
- * Run inference on a previously cached frame. Sends only 5 bytes
19673
- * (model_idx + frameId) through the IPC pipe — eliminates the
19674
- * ~35ms per-call overhead of transferring 1.2MB raw data.
19675
- */
19676
- inferCached: method(zod.z.object({
19677
- stepId: zod.z.string(),
19678
- frameId: zod.z.number().int()
19679
- }), zod.z.record(zod.z.string(), zod.z.unknown()), { kind: "mutation" }),
19680
- /**
19681
- * Release a cached frame from the Python pool's memory.
19682
- */
19683
- uncacheFrame: method(zod.z.object({ frameId: zod.z.number().int() }), zod.z.void(), { kind: "mutation" }),
19684
- /** Returns the effective pool tuning (resolved from user overrides + backend defaults). */
19685
- getEffectiveTuning: method(zod.z.void(), zod.z.object({
19686
- batchMode: zod.z.string(),
19687
- windowMs: zod.z.number(),
19688
- maxBatchSize: zod.z.number(),
19689
- concurrency: zod.z.number()
19690
- })),
19691
- /**
19692
- * List every EngineFactory currently loaded in this executor's RAM,
19693
- * with the models resident and a coarse "in use" marker derived from
19694
- * ongoing inference activity. Used by the Pipeline page Engines tab.
19695
- */
19696
- listLoadedEngines: method(zod.z.void(), zod.z.array(zod.z.object({
19697
- engineKey: zod.z.string(),
19698
- engine: PipelineEngineChoiceSchema,
19699
- modelsLoaded: zod.z.array(zod.z.string()).readonly(),
19700
- inUseByCameras: zod.z.array(zod.z.number()).readonly(),
19701
- /**
19702
- * Origin of this resident factory.
19703
- * - `runtime` — main camera-serving engine (no idle TTL).
19704
- * - `warm-override` — benchmark/test override held in the warm
19705
- * cache; auto-disposed after the idle TTL.
19706
- * - `device-pool` — a concurrent per-device pool (Phase 2
19707
- * multi-device, keyed by `deviceKey`) resolved
19708
- * via `resolveDeviceFactory`. Runs alongside the
19709
- * `runtime` engine on a DIFFERENT accelerator
19710
- * (NPU / iGPU / Coral) — this is how the
19711
- * Engines tab shows all pools running at once.
19712
- */
19713
- kind: zod.z.enum([
19714
- "runtime",
19715
- "warm-override",
19716
- "device-pool"
19717
- ]),
19718
- /** Native pid of the underlying Python pool (null when no pool). */
19719
- poolPid: zod.z.number().nullable(),
19720
- /** ms since this factory was last used (null when not warm-tracked). */
19721
- idleMs: zod.z.number().nullable(),
19722
- /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
19723
- idleTtlMs: zod.z.number().nullable()
19724
- })).readonly()),
19725
- /** Warm up an engine without running a frame. No-op if already loaded. */
19726
- spinEngine: method(zod.z.object({ engine: PipelineEngineChoiceSchema }), zod.z.object({ success: zod.z.literal(true) }), {
19727
- kind: "mutation",
19728
- auth: "admin"
19729
- }),
19730
- /**
19731
- * Unload an engine from RAM. `force:true` unloads even when cameras
19732
- * are actively using it (they re-spin on next frame). Default is
19733
- * gated — returns `{success:false, reason}` when in use.
19734
- */
19735
- killEngine: method(zod.z.object({
19736
- engine: PipelineEngineChoiceSchema,
19737
- force: zod.z.boolean().optional()
19738
- }), zod.z.object({
19739
- success: zod.z.boolean(),
19740
- reason: zod.z.string().optional()
19741
- }), {
19742
- kind: "mutation",
19743
- auth: "admin"
19744
- }),
19745
- listReferenceImages: method(zod.z.void(), zod.z.array(ReferenceImageEntrySchema).readonly()),
19746
- getReferenceImage: method(zod.z.object({ filename: zod.z.string() }), ReferenceImageBodySchema.nullable()),
19747
- getReferenceAudioFiles: method(zod.z.void(), zod.z.array(ReferenceAudioEntrySchema).readonly()),
19748
- getReferenceAudio: method(zod.z.object({ filename: zod.z.string() }), ReferenceAudioBodySchema.nullable()),
19749
- getAudioCapabilities: method(zod.z.void(), AudioCapabilitiesSchema),
19750
- runAudioTest: method(zod.z.object({
19751
- addonId: zod.z.string(),
19752
- modelId: zod.z.string(),
19753
- filename: zod.z.string().optional(),
19754
- settings: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
19755
- }), AudioTestResultSchema, { kind: "mutation" }),
19756
- getDetectionConfigSchema: method(zod.z.void(), ConfigUISchemaNullableBridge)
19757
- }
19758
- };
19759
- /**
19760
- * Per-stage gating mode applied to the zones a rule references.
19761
- *
19762
- * - `include`: the rule contributes to a **whitelist** for its stage.
19763
- * When at least one `include` rule fires for a stage, only entities
19764
- * inside one of those zones pass that stage.
19765
- * - `exclude`: the rule contributes to a **blacklist** for its stage.
19766
- * Entities inside one of those zones are dropped at that stage.
19767
- *
19768
- * `monitor`-style observation (count without filtering) is not a rule
19769
- * mode — zones without any matching rule are observed naturally by
19770
- * `zone-analytics` (live snapshot + history), so an "I just want to
19771
- * count, not filter" use case needs no rule at all.
19772
- */
19773
- var ZoneRuleModeEnum = zod.z.enum(["include", "exclude"]);
19774
- /**
19775
- * Per-consumer rule that references existing zones (geometry) and
19776
- * defines how a specific pipeline stage should treat them. Each
19777
- * consumer addon owns its own `ZoneRule[]` array in its per-device
19778
- * settings:
19779
- *
19780
- * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
19781
- * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
19782
- * - future: notification rules, audio gating, etc.
19783
- *
19784
- * One rule applies to N zones (`zoneIds[]`) so the operator can
19785
- * express "ignore motion in ALL of {garden, street}" with a single
19786
- * rule. `classFilter` narrows the rule to specific object classes —
19787
- * "drop person detections in the street, but keep cars" is one
19788
- * `exclude` rule with `classFilter: ['person']`.
19789
- *
19790
- * `enabled` is a soft toggle — the operator can keep the rule
19791
- * configured but inert without deleting it.
19792
- */
19793
- var ZoneRuleSchema = zod.z.object({
19794
- /** Stable rule id — survives edits, used by the UI for diffing. */
19795
- id: zod.z.string(),
19796
- /** Optional human-readable label rendered in the rule editor. */
19797
- name: zod.z.string().optional(),
19798
- /** Zones this rule targets. The rule's `mode` applies to ALL
19799
- * listed zones (OR-set: a detection in any one of them counts).
19800
- * At least one zone id required — a rule with no targets is a
19801
- * configuration mistake and the form validator rejects it. */
19802
- zoneIds: zod.z.array(zod.z.string()).min(1).readonly(),
19803
- mode: ZoneRuleModeEnum,
19804
- /**
19805
- * Class names this rule applies to. Empty / undefined ⇒ rule
19806
- * applies to every class. Class strings match the `macroClass`
19807
- * field on detections (e.g. `person`, `car`, `dog`).
19808
- */
19809
- classFilter: zod.z.array(zod.z.string()).readonly().optional(),
19810
- /**
19811
- * Minimum bbox/mask overlap (0–1) with any of the rule's zones
19812
- * required to consider an entity "in the zone". Defaults to the
19813
- * consumer's stage default when omitted. Kept for back-compat with
19814
- * existing per-rule overrides; new operators pick the value via
19815
- * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
19816
- * set, the lower-level engine reads it as a 0–1 fraction.
19817
- */
19818
- overlapThreshold: zod.z.number().min(0).max(1).optional(),
19819
- /**
19820
- * Operator-friendly version of `overlapThreshold` — the percentage
19821
- * of the detection's bbox that must lie inside the zone for the
19822
- * rule to match. Documented default is 85%; the engine substitutes
19823
- * that when the field is omitted (kept optional so existing rules
19824
- * stored without it stay valid).
19825
- *
19826
- * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
19827
- * rule, the engine prefers `bboxInclusionPct` because it's the
19828
- * field exposed in the UI. Internally both feed the same gate.
19829
- */
19830
- bboxInclusionPct: zod.z.number().min(0).max(100).optional(),
19831
- /**
19832
- * When `true` and a detection has a segmentation mask, use the
19833
- * mask for overlap instead of the bbox. Detection-stage only;
19834
- * motion rules ignore this field.
19835
- */
19836
- preferMask: zod.z.boolean().optional(),
19837
- /**
19838
- * Soft-toggle: `false` disables the rule without deleting it.
19839
- * Defaults to `true` so operators creating a rule via the UI
19840
- * see it active immediately.
19841
- */
19842
- enabled: zod.z.boolean().default(true)
19843
- });
19844
- zod.z.array(ZoneRuleSchema).readonly();
19845
- /**
19846
- * Zone — pure geometry + identity. NO filtering behaviour.
19847
- *
19848
- * Zones describe **where** in the frame the operator wants to flag
19849
- * something; consumer-owned {@link ZoneRule} arrays describe **how**
19850
- * each pipeline stage uses them. Splitting the two means a single
19851
- * polygon "Driveway" can simultaneously back a motion-exclude rule,
19852
- * a detection-include rule on `['car']`, and an occupancy aggregate
19853
- * — without three duplicated polygons.
19854
- *
19855
- * Owned by the orchestrator addon (provider) and mirrored into the
19856
- * `zones` device-state slice on every mutation. Consumers
19857
- * (motion-wasm, pipeline-executor, analytics, admin UI) read either
19858
- * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
19859
- * mirror with `onChanged`).
19860
- *
19861
- * Coordinates are normalised fractions of the frame (0–1) so zones
19862
- * survive resolution changes and stream profile switches.
19863
- *
19864
- * `kind` discriminates between full polygons (closed regions used
19865
- * for intrusion / occupancy filters) and tripwires (open 2-point
19866
- * line segments used for cross events). Onboard / firmware-reported
19867
- * zones (Reolink, ONVIF) are out of scope for now — see the deferred
19868
- * task list.
19869
- */
19870
- var ZoneKindEnum = zod.z.enum(["polygon", "tripwire"]);
19871
- /** Polygon vertex in fraction-of-frame coordinates (0–1). */
19872
- var PolygonPointSchema = zod.z.object({
19873
- x: zod.z.number(),
19874
- y: zod.z.number()
19875
- });
19876
- /** A camera detection zone — pure geometry/identity. */
19877
- var ZoneSchema = zod.z.object({
19878
- id: zod.z.string(),
19879
- name: zod.z.string(),
19880
- kind: ZoneKindEnum.default("polygon"),
19881
- /** Polygon vertices, fraction of frame (0–1). */
19882
- polygon: zod.z.array(PolygonPointSchema).readonly(),
19883
- /** Visual color for UI rendering. */
19884
- color: zod.z.string().default("#3b82f6")
19885
- });
19886
- /**
19887
- * Zones capability — per-camera CRUD over polygon detection zones.
19888
- *
19889
- * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
19890
- * to per-device settings and mirrors into the `zones` device-state
19891
- * slice on every mutation, so downstream consumers can subscribe via
19892
- * `dev.state.zones.onChanged`.
19893
- *
19894
- * The cap surface only handles geometry + identity; filtering
19895
- * behaviour (per-class, include/exclude, threshold) lives in the
19896
- * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
19897
- * `capabilities/schemas/zone-rule.js`.
19898
- */
19899
- var zonesCapability = {
19900
- name: "zones",
19901
- scope: "device",
19902
- mode: "singleton",
19903
- deviceTypes: [DeviceType.Camera],
19904
- methods: {
19905
- listZones: method(zod.z.object({ deviceId: zod.z.number() }), zod.z.array(ZoneSchema).readonly()),
19906
- addZone: method(zod.z.object({
19907
- deviceId: zod.z.number(),
19908
- zone: ZoneSchema
19909
- }), zod.z.void(), {
19910
- kind: "mutation",
19911
- auth: "admin"
19912
- }),
19913
- removeZone: method(zod.z.object({
19914
- deviceId: zod.z.number(),
19915
- zoneId: zod.z.string()
19916
- }), zod.z.void(), {
19917
- kind: "mutation",
19918
- auth: "admin"
19919
- }),
19920
- updateZone: method(zod.z.object({
19921
- deviceId: zod.z.number(),
19922
- zone: ZoneSchema
19923
- }), zod.z.void(), {
19924
- kind: "mutation",
19925
- auth: "admin"
19926
- })
19927
- },
19928
- /**
19929
- * Runtime-state slice — the live zone catalogue mirrored by the
19930
- * orchestrator on every CRUD mutation. Consumers read via
19931
- * `device.state.zones.value` / `.watch(...)` without round-tripping
19932
- * the cap, and the codegen DeviceProxy auto-wires the reactive
19933
- * handle. Slice shape is `{ zones: Zone[] }` so future extensions
19934
- * (e.g. zone groupings) can sit alongside the polygon list.
19935
- */
19936
- runtimeState: zod.z.object({ zones: zod.z.array(ZoneSchema).readonly() }),
19937
- /**
19938
- * Runtime-state durability: **restored** — written only on operator mutation, so a camera that never had one has nothing to re-derive from. This is the slice `zone-mirror-hydration.ts` exists to paper over.
19939
- *
19940
- * See `RuntimeStateDurability`. Enforced by
19941
- * `scripts/check-runtime-state-durability.ts`.
19942
- */
19943
- durability: "restored"
19944
- };
19945
- /**
19946
- * pipeline-analytics — device-scoped wrapper cap. Refines raw
19947
- * per-frame detections emitted by the pipeline runner into tracked
19948
- * objects, per-kind event collections (motion / object / audio), and
19949
- * persisted media. Owns the post-detection domain end-to-end:
19950
- *
19951
- * runner emits PipelineInferenceResult
19952
- * ↓ (event bus)
19953
- * pipeline-analytics subscriber
19954
- * ↓ SORT tracker + zone engine + state analyzer + event emitter
19955
- * → three DB collections (one per kind), one FS media tree, one
19956
- * unified event emitter (FrameTracked + TrackStarted/Ended +
19957
- * DetectionEvent on bus)
19958
- *
19959
- * Pure subscriber model. No `processFrame` cap method — the runner
19960
- * already publishes the raw frame on the bus. The cap surface is
19961
- * only QUERIES + per-device settings, bound on/off via
19962
- * `device-manager.setWrapperActive`. `defaultActive: true` because
19963
- * every camera with a detection pipeline wants its raw detections
19964
- * refined; operators opt out per-device via BindingsTab when needed.
19965
- *
19966
- * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
19967
- * (per-device surface) and `track-trail` caps — see P11 cleanup.
19968
- */
19969
- var TrackStateSchema = zod.z.enum([
19970
- "new",
19971
- "entered",
19972
- "left",
19973
- "moving",
19974
- "idle"
19975
- ]);
19976
- var EventKindSchema = zod.z.enum([
19977
- "motion",
19978
- "object",
19979
- "audio"
19980
- ]);
19981
- /**
19982
- * Spatial filter for `listTracks` — the rect + polygon variants of the shared
19983
- * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
19984
- * of the camera frame (top-left origin), matching the drawing-plane editor.
19985
- */
19986
- var TrackZoneFilterSchema = zod.z.discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
19987
- /** Closed icon vocabulary so clients render a known glyph per kind. */
19988
- var EventKindIconSchema = zod.z.enum([
19989
- "motion",
19990
- "audio",
19991
- "person",
19992
- "vehicle",
19993
- "animal",
19994
- "door",
19995
- "pir",
19996
- "smoke",
19997
- "water",
19998
- "button",
19999
- "package",
20000
- "generic"
20001
- ]);
20002
- var EventKindCategorySchema = zod.z.enum([
20003
- "motion",
20004
- "audio",
20005
- "detection",
20006
- "sensor",
20007
- "control",
20008
- "custom",
20009
- "package"
20010
- ]);
20011
- /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
20012
- var EventKindLevelSchema = zod.z.enum(["macro", "sub"]);
20013
- var EventKindDescriptorSchema = zod.z.object({
20014
- /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
20015
- kind: zod.z.string(),
20016
- /** i18n key resolved on the UI side; `label` is the English fallback. */
20017
- labelKey: zod.z.string(),
20018
- /** English fallback label (kept for clients that don't translate). */
20019
- label: zod.z.string(),
20020
- /** Hex color for timeline/legend rendering. */
20021
- color: zod.z.string(),
20022
- /** Dictionary id → lucide component on the UI side. */
20023
- iconId: zod.z.string(),
20024
- /** Legacy closed-vocab glyph — fallback for `iconId`. */
20025
- icon: EventKindIconSchema,
20026
- category: EventKindCategorySchema,
20027
- /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
20028
- parentKind: zod.z.string().nullable(),
20029
- /** Derived from `parentKind`, explicit for the client tree. */
20030
- level: EventKindLevelSchema,
20031
- /** Which cap + device contributes this kind. For built-ins the camera
20032
- * itself; for sensor kinds the LINKED source device. */
20033
- source: zod.z.object({
20034
- capName: zod.z.string(),
20035
- deviceId: zod.z.number()
20036
- })
20037
- });
20038
- /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
20039
- var EventKindsForDeviceSchema = zod.z.object({
20040
- deviceId: zod.z.number(),
20041
- kinds: zod.z.array(EventKindDescriptorSchema).readonly()
20042
- });
20043
- var SensorEventSchema = zod.z.object({
20044
- id: zod.z.string(),
20045
- /** The CAMERA the event is attributed to (a sensor linked to N cameras
20046
- * yields N rows, one per camera). */
20047
- deviceId: zod.z.number(),
20048
- /** The linked sensor device whose state changed. */
20049
- sourceDeviceId: zod.z.number(),
20050
- /** Event kind id — matches an `EventKindDescriptor.kind`. */
20051
- kind: zod.z.string(),
20052
- /** Snapshot of the sensor cap's runtime-state slice at the change. */
20053
- value: zod.z.record(zod.z.string(), zod.z.unknown()).nullable(),
20054
- timestamp: zod.z.number()
20055
- });
20056
- /**
20057
- * One stored sighting on a track's trajectory.
20058
- *
20059
- * The array these live in is returned in TIME order (D399) — it is APPENDED in
20060
- * arrival order, and the two detector passes interleave, so a consumer must not
20061
- * assume the two are the same on a row written by an older build.
20062
- */
20063
- var TrackPositionSchema = zod.z.object({
20064
- x: zod.z.number(),
20065
- y: zod.z.number(),
20066
- timestamp: zod.z.number(),
20067
- bbox: BoundingBoxSchema,
20068
- /**
20069
- * Which detector pass measured this box (D399): `frame` is the full-frame
20070
- * pass on the analysis raster, `recovery` is the native-resolution
20071
- * small-subject second pass (D377/D378). Both write into one array, and until
20072
- * this field existed the only way to tell them apart was that full-frame boxes
20073
- * are exact multiples of 1.2 while recovery boxes are full-precision floats.
20074
- * Absent on rows written before D399.
20075
- */
20076
- source: zod.z.enum(["frame", "recovery"]).optional(),
20077
- /** Detection score of this box, so a position can be weighed and not only
20078
- * plotted. Absent on rows written before D399. */
20079
- score: zod.z.number().optional()
20080
- });
20081
- var TrackSnapshotSchema = zod.z.object({
20082
- timestamp: zod.z.number(),
20083
- position: TrackPositionSchema,
20084
- /** The snapshot's media row id (D482); resolve via `listTrackMedia({ trackId })`. */
20085
- mediaId: zod.z.number().int()
20086
- });
20087
- /**
20088
- * Normalized 0..1 trajectory envelope (min/max over every position bbox,
20089
- * divided by the track's detection-frame dims), computed at persist time.
20090
- * Absent when the frame dims were unknown when the track was persisted
20091
- * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
20092
- */
20093
- var TrackEnvelopeSchema = zod.z.object({
20094
- minX: zod.z.number(),
20095
- minY: zod.z.number(),
20096
- maxX: zod.z.number(),
20097
- maxY: zod.z.number()
20098
- });
20099
- /**
20100
- * Row projection for track list queries. `full` (default) returns the
20101
- * complete Track including the frame-rate `positions[]` history and the
20102
- * `snapshots[]` references — megabytes across a page of tracks. `slim`
20103
- * keeps every scalar the list surfaces actually render (ids, class(es),
20104
- * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
20105
- * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
20106
- * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
20107
- * `getTrack`. Mirrors the event-store `projection` convention
20108
- * (`getObjectEvents` et al.).
20109
- */
20110
- var TrackProjectionSchema = zod.z.enum(["full", "slim"]);
20111
- /**
20112
- * One audio-classification label heard on the track's camera while the
20113
- * track was alive, aggregated per label. An "episode" is one persisted
20114
- * audio event (the confident-classification path: score ≥ the device's
20115
- * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
20116
- * one 32 ms inference chunk, so counts stay human-scaled.
20117
- */
20118
- var TrackAudioLabelSchema = zod.z.object({
20119
- label: zod.z.string(),
20120
- /** Highest classification score observed across the label's episodes. */
20121
- peakScore: zod.z.number(),
20122
- /** Number of coalesced audio-event episodes carrying this label. */
20123
- count: zod.z.number(),
20124
- firstAt: zod.z.number(),
20125
- lastAt: zod.z.number()
20126
- });
20127
- /**
20128
- * How a track was produced. `pipeline` (default / absent) = the spatial
20129
- * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
20130
- * no positions, a single snapshot, and no bbox trajectory at all:
20131
- *
20132
- * - `sensor` — a linked sensor/control device state change.
20133
- * - `audio` — an audio event on the camera itself that was anomalous for
20134
- * THAT camera, loud, and heard while nothing visual was happening (D62).
20135
- *
20136
- * - `onboard` — the CAMERA's own firmware, paired with a decoded frame in
20137
- * that frame's pixel space. A real root detector and a SPATIAL one: its
20138
- * boxes are the same kind of fact `pipeline`'s are, produced by a different
20139
- * detector.
20140
- *
20141
- * `onboard` was missing here while `DetectionSourceSchema` already had it, so
20142
- * a persisted onboard track failed `safeParse` on read and came back with NO
20143
- * source at all — which `isSpatialTrack` then admitted by accident, through the
20144
- * `undefined` arm rather than by anybody's decision, and which `excludeSources`
20145
- * could not name.
20146
- *
20147
- * The spatial subsystems (tracker association, occupancy count, re-id /
20148
- * embedding, resurrection) MUST skip every synthetic source. Test for that
20149
- * with `isSpatialTrack`, which allow-lists the spatial sources explicitly — a
20150
- * `!== 'sensor'` check silently readmits every source added after it was
20151
- * written.
19405
+ * - `onboard` — the CAMERA's own firmware, paired with a decoded frame in
19406
+ * that frame's pixel space. A real root detector and a SPATIAL one: its
19407
+ * boxes are the same kind of fact `pipeline`'s are, produced by a different
19408
+ * detector.
19409
+ *
19410
+ * `onboard` was missing here while `DetectionSourceSchema` already had it, so
19411
+ * a persisted onboard track failed `safeParse` on read and came back with NO
19412
+ * source at all — which `isSpatialTrack` then admitted by accident, through the
19413
+ * `undefined` arm rather than by anybody's decision, and which `excludeSources`
19414
+ * could not name.
19415
+ *
19416
+ * The spatial subsystems (tracker association, occupancy count, re-id /
19417
+ * embedding, resurrection) MUST skip every synthetic source. Test for that
19418
+ * with `isSpatialTrack`, which allow-lists the spatial sources explicitly — a
19419
+ * `!== 'sensor'` check silently readmits every source added after it was
19420
+ * written.
20152
19421
  */
20153
19422
  var TrackSourceSchema = zod.z.enum([
20154
19423
  "pipeline",
@@ -20513,6 +19782,22 @@ var TrackSchema = zod.z.object({
20513
19782
  * omit it. Render nothing when absent.
20514
19783
  */
20515
19784
  previewMissReason: zod.z.string().optional(),
19785
+ /**
19786
+ * The ROOT model that produced this track — the `FrameResult.rootModelId` of
19787
+ * the frame it was BORN on (D646). What a later replay compares against, so
19788
+ * "the original model" is named rather than assumed. A birth fact: never
19789
+ * rewritten by a later frame. **Absent ≠ unknown-model**: a row from before
19790
+ * the column, and a track the camera's own detector produced, carry none.
19791
+ */
19792
+ modelId: zod.z.string().optional(),
19793
+ /**
19794
+ * Size (px) of the detection frame this track's `positions[].bbox` live in —
19795
+ * the frame it was born on, else the camera's latest analysis frame at
19796
+ * persist time. Divide a position by these to normalise it. Absent when the
19797
+ * size was never known.
19798
+ */
19799
+ frameWidth: zod.z.number().optional(),
19800
+ frameHeight: zod.z.number().optional(),
20516
19801
  ...TrackFlagFields,
20517
19802
  ...TrackRetrainFields
20518
19803
  });
@@ -21537,25 +20822,6 @@ var MediaReclaimStatusSchema = zod.z.object({
21537
20822
  finishedAtMs: zod.z.number().nullable(),
21538
20823
  error: zod.z.string().nullable()
21539
20824
  });
21540
- var ReplayFrameInputSchema = zod.z.object({
21541
- timestamp: zod.z.number(),
21542
- frame: PipelineRunResultBridge
21543
- });
21544
- var ReplayTrackSchema = zod.z.object({
21545
- className: zod.z.string(),
21546
- firstSeenMs: zod.z.number(),
21547
- lastSeenMs: zod.z.number(),
21548
- /** Bbox of the track's FIRST matched detection, pixel-space in the clip's
21549
- * frame — a representative box for the diff's `(className, window, IoU)`
21550
- * pairing (`replay-diff.ts`). A replay does not need the full per-frame
21551
- * trajectory production's `Track.positions` keeps. */
21552
- bbox: BoundingBoxSchema,
21553
- /** How many of the input frames this track matched a real detection on
21554
- * (never a coasted/extrapolated frame) — the replay's own signal for "how
21555
- * solid is this track", cheaper than re-deriving it from a trajectory. */
21556
- framesMatched: zod.z.number().int()
21557
- });
21558
- var RunReplayFrameProcessorResultSchema = zod.z.object({ tracks: zod.z.array(ReplayTrackSchema).readonly() });
21559
20825
  /**
21560
20826
  * The long-term series a camera produces. A closed union so a typo cannot
21561
20827
  * invent one, and the ONE declaration of it — the addon's `AnalyticsLtsSeries`
@@ -22144,392 +21410,1035 @@ var pipelineAnalyticsCapability = {
22144
21410
  * VERBATIM under `tracks/<deviceId>/<trackId>/…`. No crop is derived and no
22145
21411
  * model is run: a training set's pixels must be the pixels the pipeline saw.
22146
21412
  */
22147
- getTrainingExportUrl: method(zod.z.object({ deviceIds: zod.z.array(zod.z.number()).optional() }), zod.z.object({ url: zod.z.string() }), {
21413
+ getTrainingExportUrl: method(zod.z.object({ deviceIds: zod.z.array(zod.z.number()).optional() }), zod.z.object({ url: zod.z.string() }), {
21414
+ kind: "query",
21415
+ auth: "admin"
21416
+ }),
21417
+ /**
21418
+ * The staging worklist for one camera, or for every camera that has one.
21419
+ *
21420
+ * Fetched ON DEMAND, over the staging set only — the page never scans
21421
+ * history, because making the working set small is the entire purpose of
21422
+ * the mark. Each row carries how many frames the dataset already holds from
21423
+ * the track and how many subjects were annotated on them, so
21424
+ * `frameCount: 0` reads as "still to work" without a second call per track.
21425
+ *
21426
+ * `auth: 'admin'`, unlike the viewer-level mark itself: marking a track is
21427
+ * curation you do while looking at it, but building the training set the
21428
+ * fleet's models are fine-tuned on is not.
21429
+ */
21430
+ listRetrainStaging: method(zod.z.object({
21431
+ /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
21432
+ * `deviceId`, deliberately: `deviceId` would make this device-bound and
21433
+ * route it at one camera's owner, and "every camera" would stop being
21434
+ * expressible at all. */
21435
+ deviceIds: zod.z.array(zod.z.number()).optional(),
21436
+ limit: zod.z.number().int().min(1).max(500).optional()
21437
+ }), zod.z.array(RetrainTrackSchema).readonly(), {
21438
+ kind: "query",
21439
+ auth: "admin"
21440
+ }),
21441
+ /**
21442
+ * What a track can contribute, and what it already has.
21443
+ *
21444
+ * `candidates` are the track's whole, unannotated frames — index rows only,
21445
+ * so this is cheap. `copies` are the frames already inside the dataset, and
21446
+ * a candidate whose copy exists is marked `copied: true`: selecting it again
21447
+ * is free and CANNOT fail, whatever became of the original.
21448
+ *
21449
+ * A crop, a thumbnail and `fullFrameBoxed` are never candidates. The last
21450
+ * one matters most: it has the model's own rectangle burned into the pixels,
21451
+ * and a detector trained on it learns to find a green line.
21452
+ */
21453
+ listRetrainFrames: method(zod.z.object({ trackId: zod.z.string() }), RetrainFrameListSchema, {
21454
+ kind: "query",
21455
+ auth: "admin"
21456
+ }),
21457
+ /**
21458
+ * COPY-ON-SELECT — the write that makes `trained` safe to evict.
21459
+ *
21460
+ * Selecting a frame copies its bytes into retrain storage immediately: not
21461
+ * a reference, not a lease. Once the copy exists the dataset no longer
21462
+ * depends on the track's media, which is exactly what lets D81 hand a
21463
+ * `trained` track back to retention.
21464
+ *
21465
+ * The order inside is load-bearing and is pinned by a test: an EXISTING
21466
+ * copy is returned without touching the source, so an original that
21467
+ * evaporated blocks the selection of THAT ORIGINAL and never the copy
21468
+ * already taken. Every refusal comes back named — a dropped selection is
21469
+ * never silent, on the wire or in the log.
21470
+ */
21471
+ selectRetrainFrames: method(zod.z.object({
21472
+ deviceId: zod.z.number(),
21473
+ trackId: zod.z.string(),
21474
+ mediaIds: zod.z.array(zod.z.number().int()).min(1)
21475
+ }), RetrainFrameSelectionSchema, {
21476
+ kind: "mutation",
21477
+ auth: "admin"
21478
+ }),
21479
+ /** Un-select a frame: its annotations go first, then the copy and its blob.
21480
+ * Deliberately destructive and deliberately explicit — it is the only way
21481
+ * a frame leaves the dataset before export. */
21482
+ deselectRetrainFrame: method(zod.z.object({
21483
+ deviceId: zod.z.number(),
21484
+ trackId: zod.z.string(),
21485
+ frameId: zod.z.string()
21486
+ }), zod.z.object({
21487
+ removed: zod.z.boolean(),
21488
+ removedAnnotations: zod.z.number().int()
21489
+ }), {
21490
+ kind: "mutation",
21491
+ auth: "admin"
21492
+ }),
21493
+ /**
21494
+ * The pixels of ONE copied frame, base64.
21495
+ *
21496
+ * Through the cap rather than a data plane because it is genuinely one
21497
+ * frame at a time, on demand, at human speed — the shape D9/D18 permit
21498
+ * (what they forbid is frames crossing a boundary at frame RATE). The
21499
+ * annotation canvas needs the image and its exact dimensions in the same
21500
+ * answer: a canvas that places a normalised box against a size it guessed
21501
+ * draws every box in the wrong place.
21502
+ */
21503
+ getRetrainFrameImage: method(zod.z.object({ frameId: zod.z.string() }), zod.z.object({
21504
+ base64: zod.z.string(),
21505
+ width: zod.z.number().int(),
21506
+ height: zod.z.number().int()
21507
+ }), {
21508
+ kind: "query",
21509
+ auth: "admin"
21510
+ }),
21511
+ /**
21512
+ * Ask the pipeline what it sees, as a PROPOSAL.
21513
+ *
21514
+ * Runs through `pipelineRunner.runStatelessStep` on the COPIED frame, and
21515
+ * every box comes back as a draft with `source: 'assist'` plus the model and
21516
+ * score that produced it. The operator confirms, edits, adds and deletes;
21517
+ * nothing is stored until `saveRetrainAnnotations`.
21518
+ *
21519
+ * For packages the request is `rfdetr-package` on the ZONE CROP at 0.35 —
21520
+ * never the whole frame, where a package detector at that threshold proposes
21521
+ * furniture. A package request with no zone is REFUSED rather than widened,
21522
+ * because the silent widening would look like a bad model for as long as
21523
+ * nobody checked which rectangle it ran on.
21524
+ */
21525
+ proposeRetrainAnnotations: method(zod.z.object({
21526
+ deviceId: zod.z.number(),
21527
+ trackId: zod.z.string(),
21528
+ frameId: zod.z.string(),
21529
+ subject: RetrainAssistSubjectSchema,
21530
+ /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
21531
+ nodeId: zod.z.string().optional()
21532
+ }), RetrainAssistResultSchema, {
21533
+ kind: "mutation",
21534
+ auth: "admin"
21535
+ }),
21536
+ /** Every annotation on a track, oldest first. */
21537
+ listRetrainAnnotations: method(zod.z.object({ trackId: zod.z.string() }), zod.z.array(RetrainAnnotationSchema).readonly(), {
21538
+ kind: "query",
21539
+ auth: "admin"
21540
+ }),
21541
+ /**
21542
+ * Replace EVERY annotation on one frame with the supplied set.
21543
+ *
21544
+ * Whole-frame replacement, not per-box upsert: the unit of ground truth is
21545
+ * the frame, and "the operator deleted a box" must be the same durable
21546
+ * outcome as "the operator never drew it". A per-box patch would let a frame
21547
+ * keep a box the operator removed on a surface that only knew about the
21548
+ * boxes it sent.
21549
+ *
21550
+ * Refuses a macro class typed into `label` or `subLabel` — the tiers are
21551
+ * separate and the guard is at the WRITE, because a mixed taxonomy cannot
21552
+ * be un-mixed by reading it.
21553
+ */
21554
+ saveRetrainAnnotations: method(zod.z.object({
21555
+ deviceId: zod.z.number(),
21556
+ trackId: zod.z.string(),
21557
+ frameId: zod.z.string(),
21558
+ annotations: zod.z.array(RetrainAnnotationDraftSchema)
21559
+ }), zod.z.array(RetrainAnnotationSchema).readonly(), {
21560
+ kind: "mutation",
21561
+ auth: "admin"
21562
+ }),
21563
+ /**
21564
+ * Finish with a track: `staging → trained`. **The only writer of that
21565
+ * state** — D81 shipped the column with it deliberately unreachable.
21566
+ *
21567
+ * Refuses a track the dataset holds no copies from. `trained` un-pins the
21568
+ * track's media, so completing without a copy is a delete order for material
21569
+ * nothing ever extracted anything from; that refusal IS the safety argument
21570
+ * of D81, expressed as a precondition.
21571
+ */
21572
+ completeRetrainTrack: method(zod.z.object({
21573
+ deviceId: zod.z.number(),
21574
+ trackId: zod.z.string()
21575
+ }), RetrainTransitionResultSchema, {
21576
+ kind: "mutation",
21577
+ auth: "admin"
21578
+ }),
21579
+ /**
21580
+ * The deliberate return: `trained → staging`, for the rare case.
21581
+ *
21582
+ * The generic `setTrackFlags` toggle refuses this in both directions by
21583
+ * design (D81) — re-staging from a checkbox is how the same material gets
21584
+ * annotated twice under two ground truths. Doing it here means the operator
21585
+ * is looking at the annotations that already exist while they decide, and
21586
+ * those annotations are LEFT ALONE: "put this back" must not be a
21587
+ * destructive act wearing a navigational name.
21588
+ */
21589
+ restageRetrainTrack: method(zod.z.object({
21590
+ deviceId: zod.z.number(),
21591
+ trackId: zod.z.string()
21592
+ }), RetrainTransitionResultSchema, {
21593
+ kind: "mutation",
21594
+ auth: "admin"
21595
+ }),
21596
+ /**
21597
+ * Where to download the ANNOTATED dataset.
21598
+ *
21599
+ * The sibling of `getTrainingExportUrl` and deliberately not the same
21600
+ * archive: that one streams a marked track's stored media verbatim, this one
21601
+ * streams the retrain COPIES plus an `annotations.json` carrying, for every
21602
+ * subject, the canonical full-frame box AND the geometry derived for each
21603
+ * model shape (letterboxed root / zone-cropped package / subject-cropped
21604
+ * classifier). Derived at export, never stored — one box in, three shapes
21605
+ * out, so two crops of the same subject can never end up in one feature
21606
+ * space (D52).
21607
+ */
21608
+ getRetrainExportUrl: method(zod.z.object({ deviceIds: zod.z.array(zod.z.number()).optional() }), zod.z.object({ url: zod.z.string() }), {
22148
21609
  kind: "query",
22149
21610
  auth: "admin"
22150
21611
  }),
22151
21612
  /**
22152
- * The staging worklist for one camera, or for every camera that has one.
21613
+ * The media an EVENT owns.
22153
21614
  *
22154
- * Fetched ON DEMAND, over the staging set only — the page never scans
22155
- * history, because making the working set small is the entire purpose of
22156
- * the mark. Each row carries how many frames the dataset already holds from
22157
- * the track and how many subjects were annotated on them, so
22158
- * `frameCount: 0` reads as "still to work" without a second call per track.
21615
+ * `ownerType` is REQUIRED, and that is the whole correction (D482). An
21616
+ * event is a row in ONE of three tables, and since D474 each numbers from
21617
+ * 1 independently: `motion:101314` and `object:101314` both exist. This
21618
+ * method took a bare `eventId` and the provider probed motion → object →
21619
+ * audio, stopping at the first hit — so on the live hub, where object
21620
+ * events own no media of their own and 299 883 of 300 559 media rows are
21621
+ * motion-owned, EVERY object event resolved to its motion namesake. A
21622
+ * track from 17:34 on camera 615 was served a snapshot from 22:35 eleven
21623
+ * days earlier, silently.
22159
21624
  *
22160
- * `auth: 'admin'`, unlike the viewer-level mark itself: marking a track is
22161
- * curation you do while looking at it, but building the training set the
22162
- * fleet's models are fine-tuned on is not.
21625
+ * D476 had already disambiguated the KEY (`motion:` vs `object:`); this is
21626
+ * the API catching up to it. Naming the table is not a "qualification" of
21627
+ * the ambiguity — a listing BY OWNER has no address to make surrogate: the
21628
+ * owner IS (table, id), and half of it is not a question.
22163
21629
  */
22164
- listRetrainStaging: method(zod.z.object({
22165
- /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
22166
- * `deviceId`, deliberately: `deviceId` would make this device-bound and
22167
- * route it at one camera's owner, and "every camera" would stop being
22168
- * expressible at all. */
22169
- deviceIds: zod.z.array(zod.z.number()).optional(),
22170
- limit: zod.z.number().int().min(1).max(500).optional()
22171
- }), zod.z.array(RetrainTrackSchema).readonly(), {
22172
- kind: "query",
22173
- auth: "admin"
22174
- }),
21630
+ getEventMedia: method(zod.z.object({
21631
+ /** Which of the three event tables owns the row. */
21632
+ ownerType: EventOwnerTypeSchema,
21633
+ /** The event's rowid in that table (D474: an event id is a number). */
21634
+ eventId: zod.z.number().int(),
21635
+ kind: MediaFileKindEnum.optional(),
21636
+ deviceId: zod.z.number()
21637
+ }), zod.z.array(MediaFileSchema).readonly()),
21638
+ /** All media rows owned by a track. `kinds` narrows to a kind subset so a
21639
+ * client can fetch the SMALL display variants on open and pull the
21640
+ * multi-MB native variants only on demand (mirrors `getEventMedia.kind`).
21641
+ * Absent ⇒ every kind (back-compat). */
21642
+ getTrackMedia: method(zod.z.object({
21643
+ trackId: zod.z.string(),
21644
+ kinds: zod.z.array(MediaFileKindEnum).optional(),
21645
+ deviceId: zod.z.number()
21646
+ }), zod.z.array(MediaFileSchema).readonly()),
22175
21647
  /**
22176
- * What a track can contribute, and what it already has.
21648
+ * What media a track HAS, without any of it.
22177
21649
  *
22178
- * `candidates` are the track's whole, unannotated frames — index rows only,
22179
- * so this is cheap. `copies` are the frames already inside the dataset, and
22180
- * a candidate whose copy exists is marked `copied: true`: selecting it again
22181
- * is free and CANNOT fail, whatever became of the original.
21650
+ * The detail view needs the shape of a track's media to build its strip —
21651
+ * which kinds exist, in what order, at what size — and then wants each tile
21652
+ * fetched as an image, not as base64 inside this response. Measured: the
21653
+ * full `getTrackMedia` is 5.3-7.7 MB and blocks the view; this manifest is
21654
+ * ~2 KB.
22182
21655
  *
22183
- * A crop, a thumbnail and `fullFrameBoxed` are never candidates. The last
22184
- * one matters most: it has the model's own rectangle burned into the pixels,
22185
- * and a detector trained on it learns to find a green line.
21656
+ * It also restores a fact a `kinds` filter destroys: filtering
21657
+ * `getTrackMedia` drops whole ROWS, taking `kind` and `sizeBytes` with
21658
+ * them, so a client that fetched only the small variants could no longer
21659
+ * tell a full-resolution variant existed — and the affordance that opens it
21660
+ * would silently disappear.
22186
21661
  */
22187
- listRetrainFrames: method(zod.z.object({ trackId: zod.z.string() }), RetrainFrameListSchema, {
22188
- kind: "query",
22189
- auth: "admin"
22190
- }),
21662
+ listTrackMedia: method(zod.z.object({
21663
+ trackId: zod.z.string(),
21664
+ deviceId: zod.z.number()
21665
+ }), zod.z.array(MediaFileInfoSchema).readonly()),
22191
21666
  /**
22192
- * COPY-ON-SELECT — the write that makes `trained` safe to evict.
21667
+ * What media an EVENT has, without any of it — the twin `getEventMedia`
21668
+ * never had.
22193
21669
  *
22194
- * Selecting a frame copies its bytes into retrain storage immediately: not
22195
- * a reference, not a lease. Once the copy exists the dataset no longer
22196
- * depends on the track's media, which is exactly what lets D81 hand a
22197
- * `trained` track back to retention.
21670
+ * `listTrackMedia` above got this treatment because a track's media is
21671
+ * 5-8 MB. An event's is worse per row, not better: an old-style event owns
21672
+ * a `crop` AND a native-resolution `fullFrameBoxed`, and the track DETAIL
21673
+ * modal — the one surface that legitimately shows the big kinds — unions
21674
+ * both listings to build its filmstrip. It then renders every tile from
21675
+ * the `event-media` plane by key and throws the bytes away. Measured on
21676
+ * the live hub: one event's `fullFrameBoxed` is 2 824 077 B, base64'd to
21677
+ * ~3.8 MB, allocated whole in hub-main's heap, for a list of keys.
22198
21678
  *
22199
- * The order inside is load-bearing and is pinned by a test: an EXISTING
22200
- * copy is returned without touching the source, so an original that
22201
- * evaporated blocks the selection of THAT ORIGINAL and never the copy
22202
- * already taken. Every refusal comes back named — a dropped selection is
22203
- * never silent, on the wire or in the log.
21679
+ * Same `deviceId` authorization subject as `getEventMedia`, the same
21680
+ * REQUIRED `ownerType` (read that method's docblock for the night-time
21681
+ * thumbnail this closes — D482), and the same rows: this is a projection
21682
+ * of that method, never a different question.
22204
21683
  */
22205
- selectRetrainFrames: method(zod.z.object({
21684
+ listEventMedia: method(zod.z.object({
21685
+ ownerType: EventOwnerTypeSchema,
21686
+ eventId: zod.z.number().int(),
21687
+ deviceId: zod.z.number()
21688
+ }), zod.z.array(MediaFileInfoSchema).readonly()),
21689
+ /**
21690
+ * Which of `ownerIds` hold at least ONE media row — an INDEX read, never a
21691
+ * blob read, and the LICENCE `videoclips` needs to publish a `thumbnail`.
21692
+ *
21693
+ * The event-media URL is stamped from a template for every event in the
21694
+ * system, so "the plane is up" was being served as "there are bytes": 64 of
21695
+ * one camera's 179 clips pointed at a 404 (device 3836, 2026-08-17). This
21696
+ * is the question that turns the stamp into a claim.
21697
+ *
21698
+ * It is on the WIRE because the clip source is registered by the addon that
21699
+ * owns the FOOTAGE, not by this one (D560) — the probe used to be an
21700
+ * in-process `MediaStore` read. One call per OWNER KIND, never one per
21701
+ * owner: that N+1 is what `MediaStore.ownersWithMedia` was written to
21702
+ * prevent, and crossing a process boundary makes it worse, not better.
21703
+ * `ownerIds` is bounded at the same 5 000 the annotation fetch is bounded
21704
+ * at, so one pathological camera-day cannot mint an unbounded request.
21705
+ *
21706
+ * THROWS rather than answering partially. A probe that quietly
21707
+ * under-reports reads as "these owners have nothing" and the caller drops
21708
+ * thumbnails that exist — the opposite failure to the one above, and
21709
+ * equally invisible.
21710
+ *
21711
+ * `deviceId` is the authorization subject, exactly as on `getEventMedia`.
21712
+ */
21713
+ ownersWithMedia: method(zod.z.object({
22206
21714
  deviceId: zod.z.number(),
22207
- trackId: zod.z.string(),
22208
- mediaIds: zod.z.array(zod.z.number().int()).min(1)
22209
- }), RetrainFrameSelectionSchema, {
21715
+ ownerKind: MediaPresenceOwnerKindSchema,
21716
+ ownerIds: zod.z.array(zod.z.string()).max(5e3)
21717
+ }), zod.z.array(zod.z.string()).readonly()),
21718
+ /**
21719
+ * Search object events by text query using CLIP cosine similarity.
21720
+ * Encodes `text` via the `embedding-encoder` cap, queries the
21721
+ * `ObjectEmbeddingStore` with optional prefilters, ranks all matching
21722
+ * embeddings by cosine similarity, and joins winners to their
21723
+ * ObjectEvents by trackId. Returns up to `limit` events scored ≥
21724
+ * `minScore`, sorted descending by score.
21725
+ */
21726
+ searchObjectEvents: method(SearchObjectEventsInput, zod.z.array(ScoredObjectEventSchema).readonly()),
21727
+ wipeObjectEmbeddings: method(zod.z.object({}), WipeObjectEmbeddingsResultSchema, {
22210
21728
  kind: "mutation",
22211
21729
  auth: "admin"
22212
21730
  }),
22213
- /** Un-select a frame: its annotations go first, then the copy and its blob.
22214
- * Deliberately destructive and deliberately explicit — it is the only way
22215
- * a frame leaves the dataset before export. */
22216
- deselectRetrainFrame: method(zod.z.object({
22217
- deviceId: zod.z.number(),
22218
- trackId: zod.z.string(),
22219
- frameId: zod.z.string()
22220
- }), zod.z.object({
22221
- removed: zod.z.boolean(),
22222
- removedAnnotations: zod.z.number().int()
22223
- }), {
21731
+ rebuildObjectEmbeddings: method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
22224
21732
  kind: "mutation",
22225
21733
  auth: "admin"
22226
21734
  }),
21735
+ getObjectEmbeddingRebuildStatus: method(zod.z.object({}), RebuildStatusSchema)
21736
+ },
21737
+ events: {
22227
21738
  /**
22228
- * The pixels of ONE copied frame, base64.
22229
- *
22230
- * Through the cap rather than a data plane because it is genuinely one
22231
- * frame at a time, on demand, at human speed — the shape D9/D18 permit
22232
- * (what they forbid is frames crossing a boundary at frame RATE). The
22233
- * annotation canvas needs the image and its exact dimensions in the same
22234
- * answer: a canvas that places a normalised box against a size it guessed
22235
- * draws every box in the wrong place.
21739
+ * Enriched frame emitted after refinement — the live-overlay source of
21740
+ * truth (two-plane re-injection). Carries the frame's detections in the
21741
+ * `ObjectDetection` wire shape: first-level roots (with track info +
21742
+ * enrichment labels) plus synthesized `kind:'detail'` face/plate entries
21743
+ * re-projected from per-track detail state, so stream overlays render
21744
+ * boxes + recognized names without querying full Track state.
22236
21745
  */
22237
- getRetrainFrameImage: method(zod.z.object({ frameId: zod.z.string() }), zod.z.object({
22238
- base64: zod.z.string(),
22239
- width: zod.z.number().int(),
22240
- height: zod.z.number().int()
22241
- }), {
22242
- kind: "query",
22243
- auth: "admin"
22244
- }),
22245
- /**
22246
- * Ask the pipeline what it sees, as a PROPOSAL.
22247
- *
22248
- * Runs through `pipelineRunner.runStatelessStep` on the COPIED frame, and
22249
- * every box comes back as a draft with `source: 'assist'` plus the model and
22250
- * score that produced it. The operator confirms, edits, adds and deletes;
22251
- * nothing is stored until `saveRetrainAnnotations`.
22252
- *
22253
- * For packages the request is `rfdetr-package` on the ZONE CROP at 0.35 —
22254
- * never the whole frame, where a package detector at that threshold proposes
22255
- * furniture. A package request with no zone is REFUSED rather than widened,
22256
- * because the silent widening would look like a bad model for as long as
22257
- * nobody checked which rectangle it ran on.
21746
+ onFrameTracked: { data: zod.z.object({
21747
+ deviceId: zod.z.number(),
21748
+ timestamp: zod.z.number(),
21749
+ frameWidth: zod.z.number(),
21750
+ frameHeight: zod.z.number(),
21751
+ detections: zod.z.array(OverlayDetectionSchema).readonly()
21752
+ }) },
21753
+ /** Track entered active state (first-seen). */
21754
+ onTrackStarted: { data: zod.z.object({
21755
+ deviceId: zod.z.number(),
21756
+ trackId: zod.z.string(),
21757
+ className: zod.z.string()
21758
+ }) },
21759
+ /** Track expired (TTL reached after last detection). */
21760
+ onTrackEnded: { data: zod.z.object({
21761
+ deviceId: zod.z.number(),
21762
+ trackId: zod.z.string(),
21763
+ className: zod.z.string(),
21764
+ durationMs: zod.z.number()
21765
+ }) },
21766
+ /** Canonical "something happened at device X" event, per-kind. */
21767
+ onDetectionEvent: { data: zod.z.object({
21768
+ deviceId: zod.z.number(),
21769
+ kind: EventKindSchema,
21770
+ eventId: zod.z.string(),
21771
+ timestamp: zod.z.number()
21772
+ }) }
21773
+ }
21774
+ };
21775
+ /**
21776
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
21777
+ * within the frame, so the executor can re-cut a leaf child ROI at native
21778
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
21779
+ */
21780
+ var NativeCropRefSchema = zod.z.object({
21781
+ /** Handle keying the retained native surface (node-pinned to its owner). */
21782
+ handle: FrameHandleSchema,
21783
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
21784
+ cropFrameSpace: zod.z.object({
21785
+ x: zod.z.number(),
21786
+ y: zod.z.number(),
21787
+ w: zod.z.number(),
21788
+ h: zod.z.number()
21789
+ })
21790
+ });
21791
+ zod.z.object({
21792
+ crop: zod.z.object({
21793
+ left: zod.z.number(),
21794
+ top: zod.z.number(),
21795
+ width: zod.z.number().positive(),
21796
+ height: zod.z.number().positive()
21797
+ }).optional(),
21798
+ content: zod.z.object({
21799
+ width: zod.z.number().int().positive(),
21800
+ height: zod.z.number().int().positive()
21801
+ }),
21802
+ fit: zod.z.enum(["stretch", "contain"]),
21803
+ format: zod.z.enum([
21804
+ "rgb",
21805
+ "gray",
21806
+ "jpeg"
21807
+ ])
21808
+ });
21809
+ /**
21810
+ * Process-local frame identity. It is serializable so it can ride an in-process
21811
+ * capability call, but `registryId` deliberately prevents resolution in any
21812
+ * other process or execution group.
21813
+ */
21814
+ var FrameRefSchema = zod.z.object({
21815
+ registryId: zod.z.string().min(1),
21816
+ id: zod.z.string().min(1),
21817
+ width: zod.z.number().int().positive(),
21818
+ height: zod.z.number().int().positive(),
21819
+ format: zod.z.enum(["rgb", "gray"]),
21820
+ timestamp: zod.z.number(),
21821
+ capturedAt: zod.z.number().optional()
21822
+ });
21823
+ var ModelFormatSchema$1 = zod.z.enum([
21824
+ "onnx",
21825
+ "coreml",
21826
+ "openvino",
21827
+ "tflite",
21828
+ "pt",
21829
+ "gguf"
21830
+ ]);
21831
+ var PipelineSlotSchema = zod.z.enum([
21832
+ "detector",
21833
+ "cropper",
21834
+ "classifier",
21835
+ "refiner",
21836
+ "audio-classifier"
21837
+ ]);
21838
+ var PipelineEngineChoiceSchema = zod.z.object({
21839
+ runtime: zod.z.literal("python"),
21840
+ backend: zod.z.string(),
21841
+ format: ModelFormatSchema$1,
21842
+ device: zod.z.string().optional()
21843
+ });
21844
+ /**
21845
+ * One pool's resolved provisioning (`getEffectiveTuning`). `numWorkers` is the
21846
+ * knob that lifts a saturated pool (`inference-devices.md`); `concurrency` is
21847
+ * per-worker in-flight requests. `deviceKey` echoes the pool asked about —
21848
+ * `null` for the node-default pool.
21849
+ */
21850
+ var EffectiveTuningSchema = zod.z.object({
21851
+ deviceKey: zod.z.string().nullable(),
21852
+ runtime: zod.z.string(),
21853
+ batchMode: zod.z.string(),
21854
+ windowMs: zod.z.number(),
21855
+ maxBatchSize: zod.z.number(),
21856
+ concurrency: zod.z.number(),
21857
+ numWorkers: zod.z.number()
21858
+ });
21859
+ var EngineDeviceInfoSchema = zod.z.object({
21860
+ id: zod.z.string(),
21861
+ label: zod.z.string(),
21862
+ description: zod.z.string().optional()
21863
+ });
21864
+ var AvailableEngineSchema = zod.z.object({
21865
+ engine: PipelineEngineChoiceSchema,
21866
+ devices: zod.z.array(EngineDeviceInfoSchema).readonly(),
21867
+ defaultDevice: zod.z.string()
21868
+ });
21869
+ var PipelineDefaultStepSchema = zod.z.lazy(() => zod.z.object({
21870
+ addonId: zod.z.string(),
21871
+ addonName: zod.z.string(),
21872
+ slot: PipelineSlotSchema,
21873
+ inputClasses: zod.z.array(zod.z.string()).readonly(),
21874
+ outputClasses: zod.z.array(zod.z.string()).readonly(),
21875
+ enabled: zod.z.boolean(),
21876
+ modelId: zod.z.string(),
21877
+ children: zod.z.array(PipelineDefaultStepSchema).readonly(),
21878
+ group: zod.z.string().optional(),
21879
+ settings: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
21880
+ }));
21881
+ var PipelineTemplateStepSchema = zod.z.lazy(() => zod.z.object({
21882
+ addonId: zod.z.string(),
21883
+ enabled: zod.z.boolean(),
21884
+ modelId: zod.z.string(),
21885
+ children: zod.z.array(PipelineTemplateStepSchema).readonly(),
21886
+ settings: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
21887
+ }));
21888
+ var PipelineTemplateSchema$1 = zod.z.object({
21889
+ id: zod.z.string(),
21890
+ name: zod.z.string(),
21891
+ createdAt: zod.z.string(),
21892
+ updatedAt: zod.z.string(),
21893
+ engine: PipelineEngineChoiceSchema,
21894
+ steps: zod.z.array(PipelineTemplateStepSchema).readonly()
21895
+ });
21896
+ var PipelineModelOptionSchema = zod.z.object({
21897
+ id: zod.z.string(),
21898
+ name: zod.z.string(),
21899
+ formats: zod.z.record(zod.z.string(), zod.z.object({
21900
+ downloaded: zod.z.boolean(),
21901
+ sizeMB: zod.z.number()
21902
+ })),
21903
+ group: ModelVariantGroupSchema.optional(),
21904
+ legacy: zod.z.boolean().optional(),
21905
+ provider: ModelProviderIdSchema.optional()
21906
+ });
21907
+ var ConfigFieldBridge = zod.z.custom();
21908
+ var PipelineAddonSchemaSchema = zod.z.object({
21909
+ id: zod.z.string(),
21910
+ name: zod.z.string(),
21911
+ slot: PipelineSlotSchema,
21912
+ inputClasses: zod.z.array(zod.z.string()).readonly(),
21913
+ outputClasses: zod.z.array(zod.z.string()).readonly(),
21914
+ childSlots: zod.z.array(PipelineSlotSchema).readonly(),
21915
+ models: zod.z.array(PipelineModelOptionSchema).readonly(),
21916
+ defaultModelId: zod.z.string(),
21917
+ defaultModelIdByFormat: zod.z.record(zod.z.string(), zod.z.string()).optional(),
21918
+ enabledByDefault: zod.z.boolean().optional(),
21919
+ backfillIntoExistingOverrides: zod.z.boolean().optional(),
21920
+ defaultConfidence: zod.z.number(),
21921
+ group: zod.z.string().optional(),
21922
+ configSchema: zod.z.array(ConfigFieldBridge).readonly().optional()
21923
+ });
21924
+ var PipelineSlotSchemaSchema = zod.z.object({
21925
+ id: PipelineSlotSchema,
21926
+ label: zod.z.string(),
21927
+ priority: zod.z.number(),
21928
+ parentSlot: PipelineSlotSchema.nullable(),
21929
+ addons: zod.z.array(PipelineAddonSchemaSchema).readonly()
21930
+ });
21931
+ var PipelineSchemaSchema = zod.z.object({
21932
+ availableEngines: zod.z.array(AvailableEngineSchema).readonly(),
21933
+ selectedEngine: PipelineEngineChoiceSchema,
21934
+ slots: zod.z.array(PipelineSlotSchemaSchema).readonly()
21935
+ });
21936
+ var EngineProvisioningSchema = zod.z.object({
21937
+ runtimeId: zod.z.enum([
21938
+ "onnx",
21939
+ "openvino",
21940
+ "coreml",
21941
+ "edgetpu"
21942
+ ]).nullable(),
21943
+ device: zod.z.string().nullable(),
21944
+ state: zod.z.enum([
21945
+ "idle",
21946
+ "installing",
21947
+ "verifying",
21948
+ "ready",
21949
+ "failed"
21950
+ ]),
21951
+ progress: zod.z.number().optional(),
21952
+ error: zod.z.string().optional(),
21953
+ nextRetryAt: zod.z.number().optional(),
21954
+ /**
21955
+ * Gate A (config-correctness gate at engine change): human-readable
21956
+ * config issues surfaced EAGERLY when the node's engine changes — model
21957
+ * substitutions ("chose X, running Y") and zero-build steps ("no model
21958
+ * has a <format> build"). Additive/optional: informational only, never
21959
+ * enforced here — `assertEngineReady` (readiness) still gates inference.
21960
+ * Absent/empty when the node-default tree resolves cleanly.
21961
+ */
21962
+ configIssues: zod.z.array(zod.z.string()).optional()
21963
+ });
21964
+ var PipelineStepInputSchema = zod.z.lazy(() => zod.z.object({
21965
+ addonId: zod.z.string(),
21966
+ modelId: zod.z.string().optional(),
21967
+ enabled: zod.z.boolean().default(true),
21968
+ children: zod.z.array(PipelineStepInputSchema).optional(),
21969
+ settings: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
21970
+ jumpDeviceKey: zod.z.string().optional()
21971
+ }));
21972
+ var ModelSubstitutionSchema = zod.z.object({
21973
+ addonId: zod.z.string(),
21974
+ chosen: zod.z.string(),
21975
+ running: zod.z.string(),
21976
+ format: zod.z.string()
21977
+ });
21978
+ var PipelineValidationIssueSchema = zod.z.object({
21979
+ addonId: zod.z.string(),
21980
+ kind: zod.z.enum([
21981
+ "unknown-addon",
21982
+ "no-format-build",
21983
+ "unknown-device"
21984
+ ]),
21985
+ detail: zod.z.string()
21986
+ });
21987
+ var PipelineValidationResultSchema = zod.z.object({
21988
+ ok: zod.z.boolean(),
21989
+ issues: zod.z.array(PipelineValidationIssueSchema).readonly(),
21990
+ substitutions: zod.z.array(ModelSubstitutionSchema).readonly(),
21991
+ /** The node's `currentEngine.format` this validation ran against. */
21992
+ format: zod.z.string()
21993
+ });
21994
+ var ReferenceImageEntrySchema = zod.z.object({
21995
+ filename: zod.z.string(),
21996
+ stepIds: zod.z.array(zod.z.string()).readonly().optional()
21997
+ });
21998
+ var ReferenceImageBodySchema = zod.z.object({
21999
+ base64: zod.z.string(),
22000
+ filename: zod.z.string()
22001
+ });
22002
+ var ReferenceAudioEntrySchema = zod.z.object({
22003
+ filename: zod.z.string(),
22004
+ sizeKb: zod.z.number()
22005
+ });
22006
+ var ReferenceAudioBodySchema = zod.z.object({ base64: zod.z.string() });
22007
+ var AudioBackendSchema = zod.z.object({
22008
+ id: zod.z.string(),
22009
+ name: zod.z.string(),
22010
+ description: zod.z.string(),
22011
+ available: zod.z.boolean(),
22012
+ /**
22013
+ * Raw classifier labels this backend can emit (e.g. YAMNet's
22014
+ * 521-class set or Apple SoundAnalysis's 303-class set). Used by
22015
+ * the benchmark UI to populate the `enabledMicroClasses` filter
22016
+ * specific to the selected backend without a separate fetch.
22017
+ */
22018
+ rawLabels: zod.z.array(zod.z.string()).readonly().optional()
22019
+ });
22020
+ var AudioCapabilitiesSchema = zod.z.object({
22021
+ activeBackend: zod.z.string(),
22022
+ availableBackends: zod.z.array(AudioBackendSchema).readonly(),
22023
+ sampleRate: zod.z.number(),
22024
+ chunkDurationMs: zod.z.number()
22025
+ });
22026
+ var DownloadModelResultSchema = zod.z.object({
22027
+ filePath: zod.z.string(),
22028
+ sizeMB: zod.z.number(),
22029
+ durationMs: zod.z.number()
22030
+ });
22031
+ /**
22032
+ * Wrapper carrying a single test run's result. Replaces the legacy
22033
+ * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
22034
+ * canonical `AudioResult` from the Phase 6 output rework: one
22035
+ * `AudioDetection` per class above `minScore`, top-N candidates in
22036
+ * `debug.alternateLabels['audio-classifier']`, per-source timings in
22037
+ * `debug.stepTimings`. The outer `success`/`error` fields stay so the
22038
+ * benchmark UI can still report a clean failure when the classifier
22039
+ * cap isn't available.
22040
+ */
22041
+ var AudioTestResultSchema = zod.z.object({
22042
+ success: zod.z.boolean(),
22043
+ error: zod.z.string().optional(),
22044
+ frame: zod.z.custom().optional()
22045
+ });
22046
+ var PipelineConfigBridge = zod.z.custom();
22047
+ var ConfigUISchemaBridge = zod.z.custom();
22048
+ var ConfigUISchemaNullableBridge = zod.z.custom();
22049
+ var InferenceCapabilitiesBridge = zod.z.custom();
22050
+ var ModelAvailabilityListBridge = zod.z.custom();
22051
+ var PipelineRunResultBridge = zod.z.custom();
22052
+ /**
22053
+ * Pipeline executor — detection engine + configuration + inference API.
22054
+ *
22055
+ * Merged from: pipeline-executor, pipeline-config, inference, detection-config.
22056
+ * Implemented by the detection-pipeline addon.
22057
+ *
22058
+ * Per-device surface (DeviceSettingsContribution + the "is detection
22059
+ * enabled for this camera?" toggle) lives on the paired
22060
+ * `detection-pipeline` cap (device-scoped, singleton, wrapper
22061
+ * defaultActive) — same split pattern used by stream-broker /
22062
+ * camera-streams and audio-analyzer / audio-analysis.
22063
+ */
22064
+ var pipelineExecutorCapability = {
22065
+ name: "pipeline-executor",
22066
+ scope: "system",
22067
+ mode: "singleton",
22068
+ methods: {
22069
+ getAvailableEngines: method(zod.z.void(), zod.z.array(PipelineEngineChoiceSchema)),
22070
+ getSelectedEngine: method(zod.z.void(), PipelineEngineChoiceSchema),
22071
+ getDefaultSteps: method(PipelineEngineChoiceSchema, zod.z.array(PipelineDefaultStepSchema)),
22072
+ /**
22073
+ * Per-node detection-engine provisioning snapshot. Returns the live
22074
+ * state of the lazy runtime-provisioning machine on `nodeId`
22075
+ * (idle / installing / verifying / ready / failed). The UI pairs this
22076
+ * one-shot query with the `pipeline.engine-provisioning` live event
22077
+ * (emitted on every transition) to drive a per-node "engine ready?"
22078
+ * indicator without polling. Phase 2.
22258
22079
  */
22259
- proposeRetrainAnnotations: method(zod.z.object({
22260
- deviceId: zod.z.number(),
22261
- trackId: zod.z.string(),
22262
- frameId: zod.z.string(),
22263
- subject: RetrainAssistSubjectSchema,
22264
- /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
22265
- nodeId: zod.z.string().optional()
22266
- }), RetrainAssistResultSchema, {
22080
+ getEngineProvisioning: method(zod.z.object({ nodeId: zod.z.string() }), EngineProvisioningSchema),
22081
+ getVideoPipelineSteps: method(zod.z.void(), zod.z.record(zod.z.string(), zod.z.object({
22082
+ modelId: zod.z.string(),
22083
+ settings: zod.z.record(zod.z.string(), zod.z.unknown()).readonly()
22084
+ }))),
22085
+ setVideoPipelineSteps: method(zod.z.object({ steps: zod.z.record(zod.z.string(), zod.z.object({
22086
+ modelId: zod.z.string(),
22087
+ settings: zod.z.record(zod.z.string(), zod.z.unknown()).readonly()
22088
+ })) }), zod.z.object({ success: zod.z.literal(true) }), {
22267
22089
  kind: "mutation",
22268
22090
  auth: "admin"
22269
22091
  }),
22270
22092
  /**
22271
- * The FrameProcessor pass of a replay run — see the `Replay` section
22272
- * above this capability's definition for why this is not the
22273
- * `processFrame` method this file's header says pipeline-analytics does
22274
- * not have.
22093
+ * Clear THIS node's executor-side PER-DEVICE settings stores (the
22094
+ * per-camera step overrides the object-detection root reads via
22095
+ * `applyDeviceOverridesToTree`). `nodeId` is the ROUTING key — the
22096
+ * generated cap-router strips it (default `nodeIdMode: 'routing'`) and
22097
+ * dispatches to that node, so the provider method runs ON the target
22098
+ * node and receives no `nodeId`.
22275
22099
  *
22276
- * Constructs a FRESH `FrameProcessor` for `(deviceId, source)`, feeds it
22277
- * `frames` IN THE ORDER GIVEN (the caller is responsible for time
22278
- * ordering — this method does not sort), and returns the tracks it
22279
- * produced. Zero persistence: no `TrackStore`, no event bus, no media
22280
- * capture. `zones` / `detectionRules` are the run's OWN zone set —
22281
- * typically the camera's real zones plus an ephemeral overlay
22282
- * (`addon-benchmark`'s `replay-plan.ts`), never read from or written to
22283
- * the `zones` capability by this method itself.
22100
+ * This is the slimmed executor leg of the orchestrator's
22101
+ * `resetNodePipelineDefaults` flow (which owns the real reset: node
22102
+ * addonDefaults pins + per-camera orchestrator overrides). The legacy
22103
+ * `resetToDefault` — which reset a persisted global step-tree seed
22104
+ * nothing in the live per-camera path read — was removed together with
22105
+ * that seed.
22284
22106
  */
22285
- runReplayFrameProcessor: method(zod.z.object({
22286
- deviceId: zod.z.number(),
22287
- source: DetectionSourceSchema,
22288
- zones: zod.z.array(ZoneSchema).readonly().optional(),
22289
- detectionRules: zod.z.array(ZoneRuleSchema).readonly().optional(),
22290
- zoneMembershipMinOverlap: zod.z.number().min(0).max(1).optional(),
22291
- frames: zod.z.array(ReplayFrameInputSchema).min(1)
22292
- }), RunReplayFrameProcessorResultSchema, {
22107
+ clearDeviceOverrides: method(zod.z.object({ nodeId: zod.z.string() }), zod.z.object({
22108
+ success: zod.z.literal(true),
22109
+ clearedDevices: zod.z.number()
22110
+ }), {
22293
22111
  kind: "mutation",
22294
22112
  auth: "admin"
22295
22113
  }),
22296
- /** Every annotation on a track, oldest first. */
22297
- listRetrainAnnotations: method(zod.z.object({ trackId: zod.z.string() }), zod.z.array(RetrainAnnotationSchema).readonly(), {
22298
- kind: "query",
22299
- auth: "admin"
22300
- }),
22301
22114
  /**
22302
- * Replace EVERY annotation on one frame with the supplied set.
22115
+ * Which of THIS node's inference devices the executor currently refuses,
22116
+ * and why. `nodeId` is the ROUTING key (stripped by the generated router).
22303
22117
  *
22304
- * Whole-frame replacement, not per-box upsert: the unit of ground truth is
22305
- * the frame, and "the operator deleted a box" must be the same durable
22306
- * outcome as "the operator never drew it". A per-box patch would let a frame
22307
- * keep a box the operator removed on a surface that only knew about the
22308
- * boxes it sent.
22118
+ * The channel that did not exist. Pool health was known only inside the
22119
+ * detection addon and was an input to no routing decision anywhere: the
22120
+ * per-dispatch capability gate is keyed on model FORMAT and so can never
22121
+ * separate `openvino:gpu` from `openvino:npu`, and the orchestrator's live
22122
+ * eligibility probe (`platformProbe.getCapabilities`) answers about
22123
+ * HARDWARE — which was present throughout. So when the hub's `openvino:gpu`
22124
+ * Python worker was SIGABRT'd by the Intel GPU plugin on 2026-08-25, the
22125
+ * balancer went on handing that dead pool cameras by rotation for 31 hours:
22126
+ * ~370 000 `PoolWorker[w0]: not initialized` lines, every frame lost.
22309
22127
  *
22310
- * Refuses a macro class typed into `label` or `subLabel` — the tiers are
22311
- * separate and the guard is at the WRITE, because a mixed taxonomy cannot
22312
- * be un-mixed by reading it.
22128
+ * Read semantics the caller depends on, and which the provider guarantees:
22129
+ * this is a synchronous read of in-memory state. It never probes hardware,
22130
+ * never spawns a pool and never throws — an EMPTY `unhealthy` means "asked,
22131
+ * nothing is refused", which is what re-admits a device. A read that FAILS
22132
+ * (node offline, version skew) must therefore be distinguishable from an
22133
+ * empty answer, and it is: it rejects.
22313
22134
  */
22314
- saveRetrainAnnotations: method(zod.z.object({
22315
- deviceId: zod.z.number(),
22316
- trackId: zod.z.string(),
22317
- frameId: zod.z.string(),
22318
- annotations: zod.z.array(RetrainAnnotationDraftSchema)
22319
- }), zod.z.array(RetrainAnnotationSchema).readonly(), {
22320
- kind: "mutation",
22321
- auth: "admin"
22322
- }),
22135
+ getInferenceDeviceHealth: method(zod.z.object({ nodeId: zod.z.string() }), zod.z.object({ unhealthy: zod.z.array(zod.z.object({
22136
+ /** `<backend>:<device>`, e.g. `openvino:gpu`. */
22137
+ deviceKey: zod.z.string(),
22138
+ /**
22139
+ * `failed` — the per-device restart budget is exhausted; no pool
22140
+ * will be spawned until an operator re-arms it or the runner
22141
+ * respawns. `backoff` — under budget, waiting out the backoff (or
22142
+ * a cached pool observed dead and not yet condemned).
22143
+ */
22144
+ state: zod.z.enum(["failed", "backoff"]),
22145
+ /** Epoch ms of the death that produced this state. */
22146
+ since: zod.z.number(),
22147
+ /** Pool deaths inside the current window. */
22148
+ deaths: zod.z.number(),
22149
+ /** The last death's message. */
22150
+ lastError: zod.z.string()
22151
+ })).readonly() })),
22323
22152
  /**
22324
- * Finish with a track: `staging → trained`. **The only writer of that
22325
- * state** — D81 shipped the column with it deliberately unreachable.
22153
+ * Re-arm a terminally `failed` inference device on `nodeId`: forget its
22154
+ * restart budget so the next dispatch builds a fresh pool.
22326
22155
  *
22327
- * Refuses a track the dataset holds no copies from. `trained` un-pins the
22328
- * track's media, so completing without a copy is a delete order for material
22329
- * nothing ever extracted anything from; that refusal IS the safety argument
22330
- * of D81, expressed as a precondition.
22156
+ * The terminal state is deliberate (the abort it bounds is deterministic —
22157
+ * an automatic probation would just respawn Python forever, more slowly),
22158
+ * and a terminal state an operator cannot leave is a silent fault. This is
22159
+ * the way out. `rearmed:false` means there was nothing to forget.
22331
22160
  */
22332
- completeRetrainTrack: method(zod.z.object({
22333
- deviceId: zod.z.number(),
22334
- trackId: zod.z.string()
22335
- }), RetrainTransitionResultSchema, {
22161
+ rearmInferenceDevice: method(zod.z.object({
22162
+ nodeId: zod.z.string(),
22163
+ deviceKey: zod.z.string()
22164
+ }), zod.z.object({ rearmed: zod.z.boolean() }), {
22336
22165
  kind: "mutation",
22337
22166
  auth: "admin"
22338
22167
  }),
22168
+ getSchema: method(zod.z.void(), PipelineSchemaSchema),
22169
+ getGlobalSteps: method(zod.z.void(), zod.z.array(PipelineDefaultStepSchema).readonly().nullable()),
22170
+ getGlobalPipelineConfig: method(zod.z.void(), PipelineConfigBridge),
22171
+ getOrchestratorConfigSchema: method(zod.z.void(), ConfigUISchemaBridge),
22339
22172
  /**
22340
- * The deliberate return: `trained → staging`, for the rare case.
22173
+ * Gate B (pre-init config-correctness gate). PURE COMPUTE against this
22174
+ * node's `currentEngine.format` — resolves `steps` the same way the
22175
+ * runtime dispatch path would, and reports what WOULD happen without
22176
+ * touching any node-global state. Called by the orchestrator at attach
22177
+ * time (`attachOn`), node-pinned to the TARGET node, so config problems
22178
+ * surface BEFORE `pipelineRunner.attachCamera` rather than at the first
22179
+ * per-frame resolve. `ok` is false iff `issues` is non-empty (both
22180
+ * `unknown-addon` and `no-format-build` are HARD issues); `substitutions`
22181
+ * is informational (a degraded-but-loadable model swap) and never
22182
+ * affects `ok`. Never throws.
22341
22183
  *
22342
- * The generic `setTrackFlags` toggle refuses this in both directions by
22343
- * design (D81) — re-staging from a checkbox is how the same material gets
22344
- * annotated twice under two ground truths. Doing it here means the operator
22345
- * is looking at the annotations that already exist while they decide, and
22346
- * those annotations are LEFT ALONE: "put this back" must not be a
22347
- * destructive act wearing a navigational name.
22184
+ * `deviceKey` validates against THAT device pool's format instead of the
22185
+ * node default (D646) — the cheap question a pinned replay asks before it
22186
+ * reads any media: can this (node, deviceKey) run exactly this model?
22348
22187
  */
22349
- restageRetrainTrack: method(zod.z.object({
22350
- deviceId: zod.z.number(),
22351
- trackId: zod.z.string()
22352
- }), RetrainTransitionResultSchema, {
22353
- kind: "mutation",
22354
- auth: "admin"
22355
- }),
22188
+ validatePipeline: method(zod.z.object({
22189
+ steps: zod.z.array(PipelineStepInputSchema),
22190
+ deviceKey: zod.z.string().optional()
22191
+ }), PipelineValidationResultSchema),
22192
+ listTemplates: method(zod.z.void(), zod.z.array(PipelineTemplateSchema$1).readonly()),
22193
+ saveTemplate: method(zod.z.object({
22194
+ name: zod.z.string(),
22195
+ steps: zod.z.array(PipelineTemplateStepSchema).readonly(),
22196
+ engine: PipelineEngineChoiceSchema
22197
+ }), PipelineTemplateSchema$1, { kind: "mutation" }),
22198
+ updateTemplate: method(zod.z.object({
22199
+ id: zod.z.string(),
22200
+ name: zod.z.string().optional(),
22201
+ steps: zod.z.array(PipelineTemplateStepSchema).readonly().optional()
22202
+ }), PipelineTemplateSchema$1, { kind: "mutation" }),
22203
+ deleteTemplate: method(zod.z.object({ id: zod.z.string() }), zod.z.void(), { kind: "mutation" }),
22204
+ getCapabilities: method(zod.z.void(), InferenceCapabilitiesBridge),
22205
+ getAddonModels: method(zod.z.object({ addonId: zod.z.string() }), ModelAvailabilityListBridge),
22206
+ downloadModel: method(zod.z.object({
22207
+ addonId: zod.z.string(),
22208
+ modelId: zod.z.string(),
22209
+ format: ModelFormatSchema$1
22210
+ }), DownloadModelResultSchema, { kind: "mutation" }),
22211
+ deleteModel: method(zod.z.object({
22212
+ addonId: zod.z.string(),
22213
+ modelId: zod.z.string(),
22214
+ format: ModelFormatSchema$1
22215
+ }), zod.z.object({ success: zod.z.literal(true) }), { kind: "mutation" }),
22356
22216
  /**
22357
- * Where to download the ANNOTATED dataset.
22217
+ * Stateless single-frame execution. Callers (runner, benchmark) pass
22218
+ * the complete `steps` tree; the executor holds no state about cameras
22219
+ * or saved pipelines. WHICH pool answers is the node's own engine, or the
22220
+ * `deviceKey` pool when one is named.
22358
22221
  *
22359
- * The sibling of `getTrainingExportUrl` and deliberately not the same
22360
- * archive: that one streams a marked track's stored media verbatim, this one
22361
- * streams the retrain COPIES plus an `annotations.json` carrying, for every
22362
- * subject, the canonical full-frame box AND the geometry derived for each
22363
- * model shape (letterboxed root / zone-cropped package / subject-cropped
22364
- * classifier). Derived at export, never stored — one box in, three shapes
22365
- * out, so two crops of the same subject can never end up in one feature
22366
- * space (D52).
22222
+ * There is no `engine` field (D646). It existed for the benchmark and was
22223
+ * honoured by swapping the SHARED provider's engine, factory and executor
22224
+ * for the duration of the call, on a node serving live cameras. A caller
22225
+ * that still sends the key has it stripped here and changes nothing.
22226
+ *
22227
+ * Exactly one of `frame`, `frameRef`, `frameHandle`, `imageBase64`,
22228
+ * `referenceImage` must be provided:
22229
+ * - `frame`: runtime dispatch path (runner → decoded broker frame).
22230
+ * Carries the raw buffer, dimensions, and format; the executor
22231
+ * uses it directly without base64 round-tripping.
22232
+ * - `frameHandle` (CB5): a zero-pixel shm `FrameHandle` for the SAME
22233
+ * decoded frame. Both runner and executor are hub-local processes
22234
+ * sharing `/dev/shm`, so the executor maps the named segment and
22235
+ * reads the pixels back zero-copy — eliminating the ~1.2MB
22236
+ * re-serialisation over UDS/MsgPack the `frame` path pays per call.
22237
+ * High-risk: the FrameRing is a latest-wins seqlock with no
22238
+ * refcount, so a recycled slot yields a null read; the executor
22239
+ * then degrades to an empty result and the runner ships pixels via
22240
+ * `frame` as the fallback (queue-depth gated on the runner side).
22241
+ * - `imageBase64`: one-shot test path (benchmark ImageTab).
22242
+ * - `referenceImage`: named file from the reference-image store.
22367
22243
  */
22368
- getRetrainExportUrl: method(zod.z.object({ deviceIds: zod.z.array(zod.z.number()).optional() }), zod.z.object({ url: zod.z.string() }), {
22369
- kind: "query",
22370
- auth: "admin"
22371
- }),
22244
+ runPipeline: method(zod.z.object({
22245
+ steps: zod.z.array(PipelineStepInputSchema).min(1),
22246
+ frame: FrameInputSchema.optional(),
22247
+ /**
22248
+ * Process-local lazy frame. Valid only when caller and provider resolve
22249
+ * in the same execution-group process; split/cross-node callers use
22250
+ * `frame`/`image` inline compatibility instead.
22251
+ */
22252
+ frameRef: FrameRefSchema.optional(),
22253
+ /**
22254
+ * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
22255
+ * the decoded pixels live in. One more member of the one-of
22256
+ * frame/frameHandle/image/imageBase64/referenceImage group.
22257
+ */
22258
+ frameHandle: FrameHandleSchema.optional(),
22259
+ imageBase64: zod.z.string().optional(),
22260
+ /**
22261
+ * Binary JPEG bytes — preferred over `imageBase64` on internal
22262
+ * hops (hub → forked worker via Moleculer MsgPack) because it
22263
+ * skips the 33% base64 overhead + the per-call base64 decode on
22264
+ * the detection-pipeline worker. Callers can pass either; exactly
22265
+ * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
22266
+ */
22267
+ image: zod.z.instanceof(Uint8Array).optional(),
22268
+ referenceImage: zod.z.string().optional(),
22269
+ deviceId: zod.z.number().optional(),
22270
+ sessionId: zod.z.string().optional(),
22271
+ /**
22272
+ * Execution plane. 'full' (default) runs the whole tree — benchmark,
22273
+ * reference-image, and detail-subtree calls. 'frame' is the live
22274
+ * per-frame dispatch: ONLY root-plane steps run; crop children
22275
+ * (inputClasses ≠ null) are skipped and served per-track via
22276
+ * pipelineRunner.runDetailSubtree (two-plane design).
22277
+ */
22278
+ plane: zod.z.enum(["full", "frame"]).optional(),
22279
+ /**
22280
+ * Inference-device selector (Phase 2 multi-device). Format
22281
+ * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
22282
+ * Omitted ⇒ the runner's default device (current single-engine
22283
+ * behaviour). Selects WHICH device pool of the node runs the call.
22284
+ */
22285
+ deviceKey: zod.z.string().optional(),
22286
+ /**
22287
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
22288
+ * when the parent crop was resolved from the frame's retained NATIVE
22289
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
22290
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
22291
+ * resolution from that surface — the SAME quality path faces already
22292
+ * had — instead of the downscaled parent tile. `handle` keys the native
22293
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
22294
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
22295
+ * the executor's crop-normalized child ROI back into frame-normalized
22296
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
22297
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
22298
+ * (today's behaviour on the fallback path).
22299
+ */
22300
+ nativeCropRef: NativeCropRefSchema.optional(),
22301
+ /**
22302
+ * Offline REPLAY of stored media for `deviceId` (D56, D646): the
22303
+ * camera's zone gate and overrides apply as live, every executing
22304
+ * step runs EXACTLY the model it names on the `deviceKey` pool it
22305
+ * names or the call refuses (`model-not-servable` /
22306
+ * `device-not-servable`), and nothing reaches the camera's live
22307
+ * trace stream. Absent ⇒ unchanged behaviour.
22308
+ */
22309
+ replay: zod.z.literal(true).optional()
22310
+ }), PipelineRunResultBridge, { kind: "mutation" }),
22372
22311
  /**
22373
- * The media an EVENT owns.
22374
- *
22375
- * `ownerType` is REQUIRED, and that is the whole correction (D482). An
22376
- * event is a row in ONE of three tables, and since D474 each numbers from
22377
- * 1 independently: `motion:101314` and `object:101314` both exist. This
22378
- * method took a bare `eventId` and the provider probed motion → object →
22379
- * audio, stopping at the first hit — so on the live hub, where object
22380
- * events own no media of their own and 299 883 of 300 559 media rows are
22381
- * motion-owned, EVERY object event resolved to its motion namesake. A
22382
- * track from 17:34 on camera 615 was served a snapshot from 22:35 eleven
22383
- * days earlier, silently.
22312
+ * Batched run — N raw frames packed into one cap call. The provider
22313
+ * routes the batch through `SharedInferencePool.inferBatch`
22314
+ * (`MSG_INFER_BATCH = 0x03`) so the IPC framing and JSON response
22315
+ * envelope cost is amortised N:1 vs N concurrent `runPipeline`
22316
+ * calls. Single root step + uniform model assumed; trees with crop
22317
+ * children fall back to sequential execution.
22384
22318
  *
22385
- * D476 had already disambiguated the KEY (`motion:` vs `object:`); this is
22386
- * the API catching up to it. Naming the table is not a "qualification" of
22387
- * the ambiguity — a listing BY OWNER has no address to make surrogate: the
22388
- * owner IS (table, id), and half of it is not a question.
22319
+ * Used by `scripts/bench-batch-style.mts` for batch benchmarking —
22320
+ * N frames in one call to amortise per-call IPC overhead.
22389
22321
  */
22390
- getEventMedia: method(zod.z.object({
22391
- /** Which of the three event tables owns the row. */
22392
- ownerType: EventOwnerTypeSchema,
22393
- /** The event's rowid in that table (D474: an event id is a number). */
22394
- eventId: zod.z.number().int(),
22395
- kind: MediaFileKindEnum.optional(),
22396
- deviceId: zod.z.number()
22397
- }), zod.z.array(MediaFileSchema).readonly()),
22398
- /** All media rows owned by a track. `kinds` narrows to a kind subset so a
22399
- * client can fetch the SMALL display variants on open and pull the
22400
- * multi-MB native variants only on demand (mirrors `getEventMedia.kind`).
22401
- * Absent ⇒ every kind (back-compat). */
22402
- getTrackMedia: method(zod.z.object({
22403
- trackId: zod.z.string(),
22404
- kinds: zod.z.array(MediaFileKindEnum).optional(),
22405
- deviceId: zod.z.number()
22406
- }), zod.z.array(MediaFileSchema).readonly()),
22322
+ runPipelineBatch: method(zod.z.object({
22323
+ steps: zod.z.array(PipelineStepInputSchema).min(1),
22324
+ frames: zod.z.array(FrameInputSchema).min(1).max(255),
22325
+ deviceId: zod.z.number().optional(),
22326
+ sessionId: zod.z.string().optional(),
22327
+ /**
22328
+ * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
22329
+ * the batch to the Python pool's bench preprocess cache
22330
+ * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
22331
+ * preprocessed ONCE and every later inference is a pure-inference cache
22332
+ * hit — the sustained-throughput run measures inference, not
22333
+ * decode+preprocess+infer. Omitted/0 for live frames (all different →
22334
+ * full preprocess every call, correct). Fresh per sustained run;
22335
+ * released via `uncacheFrame`.
22336
+ */
22337
+ frameId: zod.z.number().int().nonnegative().optional(),
22338
+ /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
22339
+ deviceKey: zod.z.string().optional()
22340
+ }), zod.z.object({ results: zod.z.array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }),
22407
22341
  /**
22408
- * What media a track HAS, without any of it.
22409
- *
22410
- * The detail view needs the shape of a track's media to build its strip —
22411
- * which kinds exist, in what order, at what size — and then wants each tile
22412
- * fetched as an image, not as base64 inside this response. Measured: the
22413
- * full `getTrackMedia` is 5.3-7.7 MB and blocks the view; this manifest is
22414
- * ~2 KB.
22415
- *
22416
- * It also restores a fact a `kinds` filter destroys: filtering
22417
- * `getTrackMedia` drops whole ROWS, taking `kind` and `sizeBytes` with
22418
- * them, so a client that fetched only the small variants could no longer
22419
- * tell a full-resolution variant existed — and the affordance that opens it
22420
- * would silently disappear.
22342
+ * Cache a raw frame inside the Python inference pool's memory.
22343
+ * Returns a numeric `frameId` that `inferCached` references —
22344
+ * subsequent calls send only 5 bytes through the pipe instead of
22345
+ * 1.2MB raw data, eliminating the pipe transfer bottleneck.
22421
22346
  */
22422
- listTrackMedia: method(zod.z.object({
22423
- trackId: zod.z.string(),
22424
- deviceId: zod.z.number()
22425
- }), zod.z.array(MediaFileInfoSchema).readonly()),
22347
+ cacheFrameInPool: method(zod.z.object({
22348
+ data: zod.z.instanceof(Uint8Array),
22349
+ width: zod.z.number().int().positive(),
22350
+ height: zod.z.number().int().positive(),
22351
+ format: zod.z.enum([
22352
+ "rgb",
22353
+ "bgr",
22354
+ "gray"
22355
+ ])
22356
+ }), zod.z.object({
22357
+ frameId: zod.z.number(),
22358
+ width: zod.z.number(),
22359
+ height: zod.z.number()
22360
+ }), { kind: "mutation" }),
22426
22361
  /**
22427
- * What media an EVENT has, without any of it — the twin `getEventMedia`
22428
- * never had.
22429
- *
22430
- * `listTrackMedia` above got this treatment because a track's media is
22431
- * 5-8 MB. An event's is worse per row, not better: an old-style event owns
22432
- * a `crop` AND a native-resolution `fullFrameBoxed`, and the track DETAIL
22433
- * modal — the one surface that legitimately shows the big kinds — unions
22434
- * both listings to build its filmstrip. It then renders every tile from
22435
- * the `event-media` plane by key and throws the bytes away. Measured on
22436
- * the live hub: one event's `fullFrameBoxed` is 2 824 077 B, base64'd to
22437
- * ~3.8 MB, allocated whole in hub-main's heap, for a list of keys.
22438
- *
22439
- * Same `deviceId` authorization subject as `getEventMedia`, the same
22440
- * REQUIRED `ownerType` (read that method's docblock for the night-time
22441
- * thumbnail this closes — D482), and the same rows: this is a projection
22442
- * of that method, never a different question.
22362
+ * Run inference on a previously cached frame. Sends only 5 bytes
22363
+ * (model_idx + frameId) through the IPC pipe — eliminates the
22364
+ * ~35ms per-call overhead of transferring 1.2MB raw data.
22443
22365
  */
22444
- listEventMedia: method(zod.z.object({
22445
- ownerType: EventOwnerTypeSchema,
22446
- eventId: zod.z.number().int(),
22447
- deviceId: zod.z.number()
22448
- }), zod.z.array(MediaFileInfoSchema).readonly()),
22366
+ inferCached: method(zod.z.object({
22367
+ stepId: zod.z.string(),
22368
+ frameId: zod.z.number().int()
22369
+ }), zod.z.record(zod.z.string(), zod.z.unknown()), { kind: "mutation" }),
22449
22370
  /**
22450
- * Which of `ownerIds` hold at least ONE media row — an INDEX read, never a
22451
- * blob read, and the LICENCE `videoclips` needs to publish a `thumbnail`.
22452
- *
22453
- * The event-media URL is stamped from a template for every event in the
22454
- * system, so "the plane is up" was being served as "there are bytes": 64 of
22455
- * one camera's 179 clips pointed at a 404 (device 3836, 2026-08-17). This
22456
- * is the question that turns the stamp into a claim.
22457
- *
22458
- * It is on the WIRE because the clip source is registered by the addon that
22459
- * owns the FOOTAGE, not by this one (D560) — the probe used to be an
22460
- * in-process `MediaStore` read. One call per OWNER KIND, never one per
22461
- * owner: that N+1 is what `MediaStore.ownersWithMedia` was written to
22462
- * prevent, and crossing a process boundary makes it worse, not better.
22463
- * `ownerIds` is bounded at the same 5 000 the annotation fetch is bounded
22464
- * at, so one pathological camera-day cannot mint an unbounded request.
22465
- *
22466
- * THROWS rather than answering partially. A probe that quietly
22467
- * under-reports reads as "these owners have nothing" and the caller drops
22468
- * thumbnails that exist — the opposite failure to the one above, and
22469
- * equally invisible.
22470
- *
22471
- * `deviceId` is the authorization subject, exactly as on `getEventMedia`.
22371
+ * Release a cached frame from the Python pool's memory.
22472
22372
  */
22473
- ownersWithMedia: method(zod.z.object({
22474
- deviceId: zod.z.number(),
22475
- ownerKind: MediaPresenceOwnerKindSchema,
22476
- ownerIds: zod.z.array(zod.z.string()).max(5e3)
22477
- }), zod.z.array(zod.z.string()).readonly()),
22373
+ uncacheFrame: method(zod.z.object({ frameId: zod.z.number().int() }), zod.z.void(), { kind: "mutation" }),
22478
22374
  /**
22479
- * Search object events by text query using CLIP cosine similarity.
22480
- * Encodes `text` via the `embedding-encoder` cap, queries the
22481
- * `ObjectEmbeddingStore` with optional prefilters, ranks all matching
22482
- * embeddings by cosine similarity, and joins winners to their
22483
- * ObjectEvents by trackId. Returns up to `limit` events scored ≥
22484
- * `minScore`, sorted descending by score.
22375
+ * The effective provisioning of ONE pool of this node (operator override →
22376
+ * the pool's own runtime row). `deviceKey` names the device pool; absent is
22377
+ * the node-default pool. It answered only for the node default until
22378
+ * D646, so a benchmark on `openvino:npu` recorded the onnx pool's tuning
22379
+ * beside an NPU measurement.
22485
22380
  */
22486
- searchObjectEvents: method(SearchObjectEventsInput, zod.z.array(ScoredObjectEventSchema).readonly()),
22487
- wipeObjectEmbeddings: method(zod.z.object({}), WipeObjectEmbeddingsResultSchema, {
22381
+ getEffectiveTuning: method(zod.z.object({ deviceKey: zod.z.string().optional() }), EffectiveTuningSchema),
22382
+ /**
22383
+ * List every EngineFactory currently loaded in this executor's RAM,
22384
+ * with the models resident and a coarse "in use" marker derived from
22385
+ * ongoing inference activity. Used by the Pipeline page Engines tab.
22386
+ */
22387
+ listLoadedEngines: method(zod.z.void(), zod.z.array(zod.z.object({
22388
+ engineKey: zod.z.string(),
22389
+ engine: PipelineEngineChoiceSchema,
22390
+ modelsLoaded: zod.z.array(zod.z.string()).readonly(),
22391
+ inUseByCameras: zod.z.array(zod.z.number()).readonly(),
22392
+ /**
22393
+ * Origin of this resident factory.
22394
+ * - `runtime` — main camera-serving engine (no idle TTL).
22395
+ * - `device-pool` — a concurrent per-device pool (Phase 2
22396
+ * multi-device, keyed by `deviceKey`) resolved
22397
+ * via `resolveDeviceFactory`. Runs alongside the
22398
+ * `runtime` engine on a DIFFERENT accelerator
22399
+ * (NPU / iGPU / Coral) — this is how the
22400
+ * Engines tab shows all pools running at once.
22401
+ */
22402
+ kind: zod.z.enum(["runtime", "device-pool"]),
22403
+ /** Native pid of the underlying Python pool (null when no pool). */
22404
+ poolPid: zod.z.number().nullable(),
22405
+ /** ms since this factory was last used (null when not warm-tracked). */
22406
+ idleMs: zod.z.number().nullable(),
22407
+ /** Idle TTL after which the factory self-evicts (null when not applicable). */
22408
+ idleTtlMs: zod.z.number().nullable()
22409
+ })).readonly()),
22410
+ /** Warm up an engine without running a frame. No-op if already loaded. */
22411
+ spinEngine: method(zod.z.object({ engine: PipelineEngineChoiceSchema }), zod.z.object({ success: zod.z.literal(true) }), {
22488
22412
  kind: "mutation",
22489
22413
  auth: "admin"
22490
22414
  }),
22491
- rebuildObjectEmbeddings: method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
22415
+ /**
22416
+ * Unload an engine from RAM. `force:true` unloads even when cameras
22417
+ * are actively using it (they re-spin on next frame). Default is
22418
+ * gated — returns `{success:false, reason}` when in use.
22419
+ */
22420
+ killEngine: method(zod.z.object({
22421
+ engine: PipelineEngineChoiceSchema,
22422
+ force: zod.z.boolean().optional()
22423
+ }), zod.z.object({
22424
+ success: zod.z.boolean(),
22425
+ reason: zod.z.string().optional()
22426
+ }), {
22492
22427
  kind: "mutation",
22493
22428
  auth: "admin"
22494
22429
  }),
22495
- getObjectEmbeddingRebuildStatus: method(zod.z.object({}), RebuildStatusSchema)
22496
- },
22497
- events: {
22498
- /**
22499
- * Enriched frame emitted after refinement — the live-overlay source of
22500
- * truth (two-plane re-injection). Carries the frame's detections in the
22501
- * `ObjectDetection` wire shape: first-level roots (with track info +
22502
- * enrichment labels) plus synthesized `kind:'detail'` face/plate entries
22503
- * re-projected from per-track detail state, so stream overlays render
22504
- * boxes + recognized names without querying full Track state.
22505
- */
22506
- onFrameTracked: { data: zod.z.object({
22507
- deviceId: zod.z.number(),
22508
- timestamp: zod.z.number(),
22509
- frameWidth: zod.z.number(),
22510
- frameHeight: zod.z.number(),
22511
- detections: zod.z.array(OverlayDetectionSchema).readonly()
22512
- }) },
22513
- /** Track entered active state (first-seen). */
22514
- onTrackStarted: { data: zod.z.object({
22515
- deviceId: zod.z.number(),
22516
- trackId: zod.z.string(),
22517
- className: zod.z.string()
22518
- }) },
22519
- /** Track expired (TTL reached after last detection). */
22520
- onTrackEnded: { data: zod.z.object({
22521
- deviceId: zod.z.number(),
22522
- trackId: zod.z.string(),
22523
- className: zod.z.string(),
22524
- durationMs: zod.z.number()
22525
- }) },
22526
- /** Canonical "something happened at device X" event, per-kind. */
22527
- onDetectionEvent: { data: zod.z.object({
22528
- deviceId: zod.z.number(),
22529
- kind: EventKindSchema,
22530
- eventId: zod.z.string(),
22531
- timestamp: zod.z.number()
22532
- }) }
22430
+ listReferenceImages: method(zod.z.void(), zod.z.array(ReferenceImageEntrySchema).readonly()),
22431
+ getReferenceImage: method(zod.z.object({ filename: zod.z.string() }), ReferenceImageBodySchema.nullable()),
22432
+ getReferenceAudioFiles: method(zod.z.void(), zod.z.array(ReferenceAudioEntrySchema).readonly()),
22433
+ getReferenceAudio: method(zod.z.object({ filename: zod.z.string() }), ReferenceAudioBodySchema.nullable()),
22434
+ getAudioCapabilities: method(zod.z.void(), AudioCapabilitiesSchema),
22435
+ runAudioTest: method(zod.z.object({
22436
+ addonId: zod.z.string(),
22437
+ modelId: zod.z.string(),
22438
+ filename: zod.z.string().optional(),
22439
+ settings: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
22440
+ }), AudioTestResultSchema, { kind: "mutation" }),
22441
+ getDetectionConfigSchema: method(zod.z.void(), ConfigUISchemaNullableBridge)
22533
22442
  }
22534
22443
  };
22535
22444
  zod.z.object({
@@ -22557,6 +22466,106 @@ var CameraMetricsSchema = zod.z.object({
22557
22466
  });
22558
22467
  var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: zod.z.number() });
22559
22468
  /**
22469
+ * Zone — pure geometry + identity. NO filtering behaviour.
22470
+ *
22471
+ * Zones describe **where** in the frame the operator wants to flag
22472
+ * something; consumer-owned {@link ZoneRule} arrays describe **how**
22473
+ * each pipeline stage uses them. Splitting the two means a single
22474
+ * polygon "Driveway" can simultaneously back a motion-exclude rule,
22475
+ * a detection-include rule on `['car']`, and an occupancy aggregate
22476
+ * — without three duplicated polygons.
22477
+ *
22478
+ * Owned by the orchestrator addon (provider) and mirrored into the
22479
+ * `zones` device-state slice on every mutation. Consumers
22480
+ * (motion-wasm, pipeline-executor, analytics, admin UI) read either
22481
+ * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
22482
+ * mirror with `onChanged`).
22483
+ *
22484
+ * Coordinates are normalised fractions of the frame (0–1) so zones
22485
+ * survive resolution changes and stream profile switches.
22486
+ *
22487
+ * `kind` discriminates between full polygons (closed regions used
22488
+ * for intrusion / occupancy filters) and tripwires (open 2-point
22489
+ * line segments used for cross events). Onboard / firmware-reported
22490
+ * zones (Reolink, ONVIF) are out of scope for now — see the deferred
22491
+ * task list.
22492
+ */
22493
+ var ZoneKindEnum = zod.z.enum(["polygon", "tripwire"]);
22494
+ /** Polygon vertex in fraction-of-frame coordinates (0–1). */
22495
+ var PolygonPointSchema = zod.z.object({
22496
+ x: zod.z.number(),
22497
+ y: zod.z.number()
22498
+ });
22499
+ /** A camera detection zone — pure geometry/identity. */
22500
+ var ZoneSchema = zod.z.object({
22501
+ id: zod.z.string(),
22502
+ name: zod.z.string(),
22503
+ kind: ZoneKindEnum.default("polygon"),
22504
+ /** Polygon vertices, fraction of frame (0–1). */
22505
+ polygon: zod.z.array(PolygonPointSchema).readonly(),
22506
+ /** Visual color for UI rendering. */
22507
+ color: zod.z.string().default("#3b82f6")
22508
+ });
22509
+ /**
22510
+ * Zones capability — per-camera CRUD over polygon detection zones.
22511
+ *
22512
+ * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
22513
+ * to per-device settings and mirrors into the `zones` device-state
22514
+ * slice on every mutation, so downstream consumers can subscribe via
22515
+ * `dev.state.zones.onChanged`.
22516
+ *
22517
+ * The cap surface only handles geometry + identity; filtering
22518
+ * behaviour (per-class, include/exclude, threshold) lives in the
22519
+ * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
22520
+ * `capabilities/schemas/zone-rule.js`.
22521
+ */
22522
+ var zonesCapability = {
22523
+ name: "zones",
22524
+ scope: "device",
22525
+ mode: "singleton",
22526
+ deviceTypes: [DeviceType.Camera],
22527
+ methods: {
22528
+ listZones: method(zod.z.object({ deviceId: zod.z.number() }), zod.z.array(ZoneSchema).readonly()),
22529
+ addZone: method(zod.z.object({
22530
+ deviceId: zod.z.number(),
22531
+ zone: ZoneSchema
22532
+ }), zod.z.void(), {
22533
+ kind: "mutation",
22534
+ auth: "admin"
22535
+ }),
22536
+ removeZone: method(zod.z.object({
22537
+ deviceId: zod.z.number(),
22538
+ zoneId: zod.z.string()
22539
+ }), zod.z.void(), {
22540
+ kind: "mutation",
22541
+ auth: "admin"
22542
+ }),
22543
+ updateZone: method(zod.z.object({
22544
+ deviceId: zod.z.number(),
22545
+ zone: ZoneSchema
22546
+ }), zod.z.void(), {
22547
+ kind: "mutation",
22548
+ auth: "admin"
22549
+ })
22550
+ },
22551
+ /**
22552
+ * Runtime-state slice — the live zone catalogue mirrored by the
22553
+ * orchestrator on every CRUD mutation. Consumers read via
22554
+ * `device.state.zones.value` / `.watch(...)` without round-tripping
22555
+ * the cap, and the codegen DeviceProxy auto-wires the reactive
22556
+ * handle. Slice shape is `{ zones: Zone[] }` so future extensions
22557
+ * (e.g. zone groupings) can sit alongside the polygon list.
22558
+ */
22559
+ runtimeState: zod.z.object({ zones: zod.z.array(ZoneSchema).readonly() }),
22560
+ /**
22561
+ * Runtime-state durability: **restored** — written only on operator mutation, so a camera that never had one has nothing to re-derive from. This is the slice `zone-mirror-hydration.ts` exists to paper over.
22562
+ *
22563
+ * See `RuntimeStateDurability`. Enforced by
22564
+ * `scripts/check-runtime-state-durability.ts`.
22565
+ */
22566
+ durability: "restored"
22567
+ };
22568
+ /**
22560
22569
  * A bounding box in NORMALIZED [0,1] frame coordinates for `getNativeCrop`. The
22561
22570
  * decode worker resolves it against the RETAINED native frame's real pixel dims,
22562
22571
  * so the caller supplies only the detection-res bbox divided by the detection
@@ -34992,7 +35001,7 @@ var HardwareInfoSchema = zod.z.object({
34992
35001
  coral: CoralInfoSchema.nullable().optional()
34993
35002
  });
34994
35003
  var PlatformScoreSchema = zod.z.object({
34995
- runtime: zod.z.enum(["node", "python"]),
35004
+ runtime: zod.z.literal("python"),
34996
35005
  backend: zod.z.string(),
34997
35006
  format: zod.z.enum([
34998
35007
  "onnx",
@@ -35029,7 +35038,7 @@ var ModelRequirementSchema = zod.z.object({
35029
35038
  });
35030
35039
  var ResolvedInferenceConfigSchema = zod.z.object({
35031
35040
  modelId: zod.z.string(),
35032
- runtime: zod.z.enum(["node", "python"]),
35041
+ runtime: zod.z.literal("python"),
35033
35042
  backend: zod.z.string(),
35034
35043
  format: ModelFormatSchema,
35035
35044
  reason: zod.z.string()
@@ -38152,6 +38161,92 @@ var sceneMonitorCapability = {
38152
38161
  durability: "session"
38153
38162
  };
38154
38163
  /**
38164
+ * Per-stage gating mode applied to the zones a rule references.
38165
+ *
38166
+ * - `include`: the rule contributes to a **whitelist** for its stage.
38167
+ * When at least one `include` rule fires for a stage, only entities
38168
+ * inside one of those zones pass that stage.
38169
+ * - `exclude`: the rule contributes to a **blacklist** for its stage.
38170
+ * Entities inside one of those zones are dropped at that stage.
38171
+ *
38172
+ * `monitor`-style observation (count without filtering) is not a rule
38173
+ * mode — zones without any matching rule are observed naturally by
38174
+ * `zone-analytics` (live snapshot + history), so an "I just want to
38175
+ * count, not filter" use case needs no rule at all.
38176
+ */
38177
+ var ZoneRuleModeEnum = zod.z.enum(["include", "exclude"]);
38178
+ /**
38179
+ * Per-consumer rule that references existing zones (geometry) and
38180
+ * defines how a specific pipeline stage should treat them. Each
38181
+ * consumer addon owns its own `ZoneRule[]` array in its per-device
38182
+ * settings:
38183
+ *
38184
+ * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
38185
+ * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
38186
+ * - future: notification rules, audio gating, etc.
38187
+ *
38188
+ * One rule applies to N zones (`zoneIds[]`) so the operator can
38189
+ * express "ignore motion in ALL of {garden, street}" with a single
38190
+ * rule. `classFilter` narrows the rule to specific object classes —
38191
+ * "drop person detections in the street, but keep cars" is one
38192
+ * `exclude` rule with `classFilter: ['person']`.
38193
+ *
38194
+ * `enabled` is a soft toggle — the operator can keep the rule
38195
+ * configured but inert without deleting it.
38196
+ */
38197
+ var ZoneRuleSchema = zod.z.object({
38198
+ /** Stable rule id — survives edits, used by the UI for diffing. */
38199
+ id: zod.z.string(),
38200
+ /** Optional human-readable label rendered in the rule editor. */
38201
+ name: zod.z.string().optional(),
38202
+ /** Zones this rule targets. The rule's `mode` applies to ALL
38203
+ * listed zones (OR-set: a detection in any one of them counts).
38204
+ * At least one zone id required — a rule with no targets is a
38205
+ * configuration mistake and the form validator rejects it. */
38206
+ zoneIds: zod.z.array(zod.z.string()).min(1).readonly(),
38207
+ mode: ZoneRuleModeEnum,
38208
+ /**
38209
+ * Class names this rule applies to. Empty / undefined ⇒ rule
38210
+ * applies to every class. Class strings match the `macroClass`
38211
+ * field on detections (e.g. `person`, `car`, `dog`).
38212
+ */
38213
+ classFilter: zod.z.array(zod.z.string()).readonly().optional(),
38214
+ /**
38215
+ * Minimum bbox/mask overlap (0–1) with any of the rule's zones
38216
+ * required to consider an entity "in the zone". Defaults to the
38217
+ * consumer's stage default when omitted. Kept for back-compat with
38218
+ * existing per-rule overrides; new operators pick the value via
38219
+ * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
38220
+ * set, the lower-level engine reads it as a 0–1 fraction.
38221
+ */
38222
+ overlapThreshold: zod.z.number().min(0).max(1).optional(),
38223
+ /**
38224
+ * Operator-friendly version of `overlapThreshold` — the percentage
38225
+ * of the detection's bbox that must lie inside the zone for the
38226
+ * rule to match. Documented default is 85%; the engine substitutes
38227
+ * that when the field is omitted (kept optional so existing rules
38228
+ * stored without it stay valid).
38229
+ *
38230
+ * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
38231
+ * rule, the engine prefers `bboxInclusionPct` because it's the
38232
+ * field exposed in the UI. Internally both feed the same gate.
38233
+ */
38234
+ bboxInclusionPct: zod.z.number().min(0).max(100).optional(),
38235
+ /**
38236
+ * When `true` and a detection has a segmentation mask, use the
38237
+ * mask for overlap instead of the bbox. Detection-stage only;
38238
+ * motion rules ignore this field.
38239
+ */
38240
+ preferMask: zod.z.boolean().optional(),
38241
+ /**
38242
+ * Soft-toggle: `false` disables the rule without deleting it.
38243
+ * Defaults to `true` so operators creating a rule via the UI
38244
+ * see it active immediately.
38245
+ */
38246
+ enabled: zod.z.boolean().default(true)
38247
+ });
38248
+ zod.z.array(ZoneRuleSchema).readonly();
38249
+ /**
38155
38250
  * Script-runner cap. Models HA `script.*` entities on
38156
38251
  * `DeviceType.Script`. A Script is a pre-recorded action sequence
38157
38252
  * that can be invoked imperatively — optionally with a variables
@@ -47330,6 +47425,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
47330
47425
  addonId: null,
47331
47426
  access: "view"
47332
47427
  },
47428
+ "notificationRules.previewStateSummary": {
47429
+ capName: "notification-rules",
47430
+ capScope: "system",
47431
+ addonId: null,
47432
+ access: "view"
47433
+ },
47333
47434
  "notificationRules.previewTemplate": {
47334
47435
  capName: "notification-rules",
47335
47436
  capScope: "system",
@@ -47906,12 +48007,6 @@ var METHOD_ACCESS_MAP = Object.freeze({
47906
48007
  addonId: null,
47907
48008
  access: "create"
47908
48009
  },
47909
- "pipelineAnalytics.runReplayFrameProcessor": {
47910
- capName: "pipeline-analytics",
47911
- capScope: "device",
47912
- addonId: null,
47913
- access: "create"
47914
- },
47915
48010
  "pipelineAnalytics.saveRetrainAnnotations": {
47916
48011
  capName: "pipeline-analytics",
47917
48012
  capScope: "device",
@@ -52009,11 +52104,6 @@ Object.freeze({
52009
52104
  form: "single",
52010
52105
  optional: false
52011
52106
  }],
52012
- "pipelineAnalytics.runReplayFrameProcessor": [{
52013
- name: "deviceId",
52014
- form: "single",
52015
- optional: false
52016
- }],
52017
52107
  "pipelineAnalytics.saveRetrainAnnotations": [{
52018
52108
  name: "deviceId",
52019
52109
  form: "single",
@@ -53293,6 +53383,98 @@ new Map(Object.entries({
53293
53383
  "camera-enabled": null
53294
53384
  }));
53295
53385
  [...NC_SYSTEM_EVENT_FILTER_KEYS];
53386
+ var NC_SYSTEM_EVENT_KIND_GROUP_SPECS = [
53387
+ {
53388
+ id: "device-state",
53389
+ family: "device-events",
53390
+ label: "Device state",
53391
+ kinds: [
53392
+ "device-offline",
53393
+ "device-online",
53394
+ "device-disabled",
53395
+ "device-enabled"
53396
+ ]
53397
+ },
53398
+ {
53399
+ id: "streams",
53400
+ family: "device-events",
53401
+ label: "Streams",
53402
+ kinds: ["stream-offline", "stream-online"]
53403
+ },
53404
+ {
53405
+ id: "battery",
53406
+ family: "device-events",
53407
+ label: "Battery",
53408
+ kinds: ["device-battery-low", "device-battery-normal"]
53409
+ },
53410
+ {
53411
+ id: "consumables",
53412
+ family: "device-events",
53413
+ label: "Consumables",
53414
+ kinds: ["device-consumable-low", "device-consumable-normal"]
53415
+ },
53416
+ {
53417
+ id: "tanks",
53418
+ family: "device-events",
53419
+ label: "Tanks",
53420
+ kinds: [
53421
+ "device-tank-low",
53422
+ "device-tank-full",
53423
+ "device-tank-normal"
53424
+ ]
53425
+ },
53426
+ {
53427
+ id: "detection-blind",
53428
+ family: "device-events",
53429
+ label: "Detecting nothing",
53430
+ kinds: ["detection-blind"]
53431
+ },
53432
+ {
53433
+ id: "nodes",
53434
+ family: "system",
53435
+ label: "Nodes",
53436
+ kinds: [
53437
+ "node-offline",
53438
+ "node-online",
53439
+ "node-inference-unavailable"
53440
+ ]
53441
+ },
53442
+ {
53443
+ id: "addons",
53444
+ family: "system",
53445
+ label: "Addons",
53446
+ kinds: [
53447
+ "addon-crash-loop",
53448
+ "addon-update-available",
53449
+ "addon-updated"
53450
+ ]
53451
+ },
53452
+ {
53453
+ id: "updates",
53454
+ family: "system",
53455
+ label: "Server & container updates",
53456
+ kinds: [
53457
+ "server-update-available",
53458
+ "server-updated",
53459
+ "wrapper-update-available"
53460
+ ]
53461
+ },
53462
+ {
53463
+ id: "backups-exports",
53464
+ family: "system",
53465
+ label: "Backups & exports",
53466
+ kinds: ["backup-completed", "export-completed"]
53467
+ },
53468
+ {
53469
+ id: "alarm",
53470
+ family: "alarm",
53471
+ label: "Alarm",
53472
+ kinds: NC_ALARM_SYSTEM_EVENT_KINDS
53473
+ }
53474
+ ];
53475
+ function systemEventKindsOfFamily(family) {
53476
+ return NC_SYSTEM_EVENT_KIND_GROUP_SPECS.filter((g) => g.family === family).flatMap((g) => g.kinds);
53477
+ }
53296
53478
  NC_AUDIO_DEFAULTS.hitPercent, NC_AUDIO_DEFAULTS.samplingSeconds;
53297
53479
  /**
53298
53480
  * WHICH WAY A BOOLEAN SENSOR MOVED — read off the one slice a sensor event
@@ -53367,7 +53549,183 @@ var DEVICE_EVENTS = [
53367
53549
  "detection-blind",
53368
53550
  ...ALARM
53369
53551
  ];
53370
- [...DEVICE_EVENTS], [...RULE_TEXT], [...COMBINED_ALARM], [...RULE_TEXT], [...COMBINED_ALARM], [...RULE_TEXT], [...RULE_TEXT], [...COMBINED_ALARM], [...RULE_TEXT], [...PACKAGE_UPDATES], [...RULE_TEXT], [...RULE_TEXT], [...COMBINED_ALARM], [...RULE_TEXT], [...COMBINED_ALARM], [...RULE_TEXT], [...COMBINED_ALARM], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_BODY_ONLY], [...RULE_TEXT], [...RULE_TEXT], [...DEVICE_EVENTS], [...RULE_TEXT], [...DEVICE_EVENTS], [...RULE_TEXT], [...BATTERY, ...CONSUMABLE], [...RULE_TEXT], [...CONSUMABLE], [...RULE_TEXT], [...TANK], [...RULE_TEXT], [...RULE_TEXT], [...UPDATES], [...RULE_TEXT], [...UPDATES], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...UPDATES], [...RULE_TEXT], [...PACKAGE_UPDATES], [...RULE_TEXT], [...PACKAGE_UPDATES], [...RULE_TEXT], [...UPDATES], [...RULE_TEXT], [...UPDATES], [...RULE_TEXT], [...PACKAGE_UPDATES], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT], [...RULE_TEXT];
53552
+ /** Every kind a summary may speak about — the two summarisable families. */
53553
+ var SUMMARISABLE = [...systemEventKindsOfFamily("device-events"), ...systemEventKindsOfFamily("system")];
53554
+ /** One per summary SECTION (`NC_STATE_SUMMARY_SECTIONS` in the notification
53555
+ * centre): the section's lines, offered when one of its kinds is selected. */
53556
+ var STATE_SUMMARY_SECTION_VARS = [
53557
+ {
53558
+ name: "summaryDevices",
53559
+ label: "Summary: devices offline / switched off",
53560
+ example: "Garage — offline since 07:12",
53561
+ kinds: [
53562
+ "device-offline",
53563
+ "device-online",
53564
+ "device-disabled",
53565
+ "device-enabled"
53566
+ ]
53567
+ },
53568
+ {
53569
+ name: "summaryStreams",
53570
+ label: "Summary: streams offline",
53571
+ example: "Ingresso (high) — since 06:40",
53572
+ kinds: ["stream-offline", "stream-online"]
53573
+ },
53574
+ {
53575
+ name: "summaryBattery",
53576
+ label: "Summary: low batteries",
53577
+ example: "Sensore porta — 8 %",
53578
+ kinds: BATTERY
53579
+ },
53580
+ {
53581
+ name: "summaryConsumables",
53582
+ label: "Summary: consumables",
53583
+ example: "Robot — filter 10 %",
53584
+ kinds: CONSUMABLE
53585
+ },
53586
+ {
53587
+ name: "summaryTanks",
53588
+ label: "Summary: tanks",
53589
+ example: "Robot — clean water low",
53590
+ kinds: TANK
53591
+ },
53592
+ {
53593
+ name: "summaryDetection",
53594
+ label: "Summary: cameras detecting nothing",
53595
+ example: "Ingresso — since 05:10",
53596
+ kinds: ["detection-blind"]
53597
+ },
53598
+ {
53599
+ name: "summaryNodes",
53600
+ label: "Summary: nodes",
53601
+ example: "little-unraid — offline since 03:00",
53602
+ kinds: [
53603
+ "node-offline",
53604
+ "node-online",
53605
+ "node-inference-unavailable"
53606
+ ]
53607
+ },
53608
+ {
53609
+ name: "summaryAddons",
53610
+ label: "Summary: addons",
53611
+ example: "@camstack/addon-recorder 1.2.3 → 1.2.4",
53612
+ kinds: [
53613
+ "addon-crash-loop",
53614
+ "addon-update-available",
53615
+ "addon-updated"
53616
+ ]
53617
+ },
53618
+ {
53619
+ name: "summaryUpdates",
53620
+ label: "Summary: server & container updates",
53621
+ example: "server 1.2.377 → 1.2.378",
53622
+ kinds: [
53623
+ "server-update-available",
53624
+ "server-updated",
53625
+ "wrapper-update-available"
53626
+ ]
53627
+ }
53628
+ ];
53629
+ var STATE_SUMMARY_VARS = [
53630
+ {
53631
+ name: "summaryText",
53632
+ label: "Summary: every section",
53633
+ description: "One block per section with something to report, one line per item.",
53634
+ example: "Batterie scariche: Sensore porta — 8 %",
53635
+ group: "system",
53636
+ families: ["rule"],
53637
+ fields: [...RULE_TEXT],
53638
+ kinds: ["system"],
53639
+ systemEventKinds: [...SUMMARISABLE],
53640
+ systemEventDeliveries: ["summary"]
53641
+ },
53642
+ {
53643
+ name: "summaryCount",
53644
+ label: "Summary: items reported",
53645
+ example: "3",
53646
+ group: "system",
53647
+ families: ["rule"],
53648
+ fields: [...RULE_TEXT],
53649
+ kinds: ["system"],
53650
+ systemEventKinds: [...SUMMARISABLE],
53651
+ systemEventDeliveries: ["summary"]
53652
+ },
53653
+ ...STATE_SUMMARY_SECTION_VARS.map((v) => ({
53654
+ name: v.name,
53655
+ label: v.label,
53656
+ example: v.example,
53657
+ group: "system",
53658
+ families: ["rule"],
53659
+ fields: [...RULE_TEXT],
53660
+ kinds: ["system"],
53661
+ systemEventKinds: [...v.kinds],
53662
+ systemEventDeliveries: ["summary"]
53663
+ }))
53664
+ ];
53665
+ [
53666
+ [...DEVICE_EVENTS],
53667
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
53668
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
53669
+ [...RULE_TEXT],
53670
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
53671
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
53672
+ [...RULE_TEXT],
53673
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
53674
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
53675
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
53676
+ [...RULE_TEXT],
53677
+ [...RULE_TEXT],
53678
+ [...RULE_TEXT],
53679
+ [...RULE_TEXT],
53680
+ [...RULE_TEXT],
53681
+ [...RULE_TEXT],
53682
+ [...RULE_TEXT],
53683
+ [...RULE_TEXT],
53684
+ [...RULE_BODY_ONLY],
53685
+ [...RULE_TEXT],
53686
+ ([...RULE_TEXT], [...DEVICE_EVENTS]),
53687
+ ([...RULE_TEXT], [...DEVICE_EVENTS]),
53688
+ ([...RULE_TEXT], [...BATTERY, ...CONSUMABLE]),
53689
+ ([...RULE_TEXT], [...CONSUMABLE]),
53690
+ ([...RULE_TEXT], [...TANK]),
53691
+ [...RULE_TEXT],
53692
+ ([...RULE_TEXT], [...UPDATES]),
53693
+ ([...RULE_TEXT], [...UPDATES]),
53694
+ [...RULE_TEXT],
53695
+ [...RULE_TEXT],
53696
+ [...RULE_TEXT],
53697
+ ([...RULE_TEXT], [...UPDATES]),
53698
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
53699
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
53700
+ ([...RULE_TEXT], [...UPDATES]),
53701
+ ([...RULE_TEXT], [...UPDATES]),
53702
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
53703
+ [...RULE_TEXT],
53704
+ [...RULE_TEXT],
53705
+ [...RULE_TEXT],
53706
+ [...RULE_TEXT],
53707
+ [...RULE_TEXT],
53708
+ [...RULE_TEXT],
53709
+ [...RULE_TEXT],
53710
+ [...RULE_TEXT],
53711
+ [...RULE_TEXT],
53712
+ [...RULE_TEXT],
53713
+ [...RULE_TEXT],
53714
+ [...RULE_TEXT],
53715
+ [...RULE_TEXT],
53716
+ [...RULE_TEXT],
53717
+ [...RULE_TEXT],
53718
+ [...RULE_TEXT],
53719
+ [...RULE_TEXT],
53720
+ [...RULE_TEXT],
53721
+ [...RULE_TEXT],
53722
+ [...RULE_TEXT],
53723
+ [...RULE_TEXT],
53724
+ [...RULE_TEXT],
53725
+ [...RULE_TEXT],
53726
+ [...RULE_TEXT],
53727
+ ...STATE_SUMMARY_VARS
53728
+ ];
53371
53729
  /**
53372
53730
  * TimelapseRule — the STANDALONE scheduled timelapse producer's rule model.
53373
53731
  *