@camstack/addon-osd-manager 0.1.138 → 0.1.140

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 (18) hide show
  1. package/dist/{MotionZonesSettings-DAj9BKEa.mjs → MotionZonesSettings-C80efbgF.mjs} +2 -2
  2. package/dist/{PrivacyMaskSettings-vXcp9vB2.mjs → PrivacyMaskSettings-CvVdYFwr.mjs} +4 -4
  3. package/dist/{SceneMonitorEditor-DT_0sAwx.mjs → SceneMonitorEditor-CkIz3-13.mjs} +3 -3
  4. package/dist/_stub.js +11 -11
  5. package/dist/{_virtual_mf-localSharedImportMap___mfe_internal__addon_osd_manager_page-CMdv28lH.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_osd_manager_page-DaUqGaKC.mjs} +3 -3
  6. package/dist/_virtual_mf___mfe_internal__addon_osd_manager_page__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-DG3UFggb.mjs +26 -0
  7. package/dist/{hostInit-VlmwYq1r.mjs → hostInit-Bkk-9STE.mjs} +2 -2
  8. package/dist/index.js +2047 -1364
  9. package/dist/index.mjs +2047 -1364
  10. package/dist/{player-overlays-C-UoK7-y.mjs → player-overlays-CbLYEs-S.mjs} +1 -1
  11. package/dist/remoteEntry.js +1 -1
  12. package/dist/{responsive--rRptNaI.mjs → responsive-BghmipTp.mjs} +1 -1
  13. package/dist/{scene-monitor-copy-CODV9mw1.mjs → scene-monitor-copy-Cpz17vjT.mjs} +1 -1
  14. package/dist/{square-BZnt2TOu.mjs → square-D-Qx_njd.mjs} +1 -1
  15. package/dist/{trash-2-C1vqC31x.mjs → trash-2-cC4gYobQ.mjs} +1 -1
  16. package/dist/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_osd_manager_page__remoteEntry_js-D-_aQIjJ.mjs → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_osd_manager_page__remoteEntry_js-Dao979S_.mjs} +1 -1
  17. package/package.json +1 -1
  18. package/dist/_virtual_mf___mfe_internal__addon_osd_manager_page__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-CsJH8KoP.mjs +0 -26
package/dist/index.mjs CHANGED
@@ -5359,7 +5359,7 @@ var ZodIssueCode = {
5359
5359
  var ZodFirstPartyTypeKind;
5360
5360
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5361
5361
  //#endregion
5362
- //#region ../types/dist/sleep-D_4W7xuQ.mjs
5362
+ //#region ../types/dist/sleep-BaRu0bS5.mjs
5363
5363
  /**
5364
5364
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5365
5365
  * window to float samples (D455).
@@ -9526,7 +9526,7 @@ var ModelFormatEntrySchema = object({
9526
9526
  /** Multi-file payload (directory members or sibling files). */
9527
9527
  files: array(string()).readonly().optional(),
9528
9528
  /** Runtime(s) that can use this format. If omitted, inferred from ModelFormat key */
9529
- runtimes: array(_enum(["node", "python"])).readonly().optional()
9529
+ runtimes: array(_enum(["python"])).readonly().optional()
9530
9530
  });
9531
9531
  /**
9532
9532
  * Extra file that must be downloaded alongside the model (e.g., labels JSON, dict.txt).
@@ -9607,10 +9607,17 @@ var ModelCatalogEntrySchema = object({
9607
9607
  inputChannels: number().int().positive().optional(),
9608
9608
  labels: array(LabelDefinitionSchema).readonly(),
9609
9609
  inputLayout: _enum(["nchw", "nhwc"]).optional(),
9610
+ /**
9611
+ * `'scrfd'` applies InsightFace's SCRFD input contract, `(x - 127.5) / 128`
9612
+ * (upstream `insightface/model_zoo/scrfd.py`), instead of the historical
9613
+ * plain `/255`. Measured against COCO GT: 188 → 196 faces found on the
9614
+ * `scrfd-2.5g` catalog entry (2026-09-26 model-replacement spike, §2.4-2).
9615
+ */
9610
9616
  inputNormalization: _enum([
9611
9617
  "zero-one",
9612
9618
  "imagenet",
9613
- "none"
9619
+ "none",
9620
+ "scrfd"
9614
9621
  ]).optional(),
9615
9622
  /**
9616
9623
  * The model already applies softmax IN-GRAPH — its raw output is a
@@ -9712,7 +9719,8 @@ var ModelConvertMetadataSchema = object({
9712
9719
  inputNormalization: _enum([
9713
9720
  "zero-one",
9714
9721
  "imagenet",
9715
- "none"
9722
+ "none",
9723
+ "scrfd"
9716
9724
  ]).optional(),
9717
9725
  preprocessMode: _enum(["letterbox", "resize"]).optional(),
9718
9726
  outputFormat: _enum([
@@ -19527,6 +19535,9 @@ var NcSystemEventKindSchema = _enum([
19527
19535
  "device-battery-normal",
19528
19536
  "device-consumable-low",
19529
19537
  "device-consumable-normal",
19538
+ "device-tank-low",
19539
+ "device-tank-full",
19540
+ "device-tank-normal",
19530
19541
  "stream-online",
19531
19542
  "stream-offline",
19532
19543
  "node-online",
@@ -19564,6 +19575,29 @@ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
19564
19575
  ]);
19565
19576
  NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
19566
19577
  /**
19578
+ * The panel's transitions, as ONE list.
19579
+ *
19580
+ * Named here rather than spelled out at each of the four sites that need them
19581
+ * (the emitter, the intake, the editor group, the combined-notification gate),
19582
+ * because a transition added to the enum and forgotten at one of them is an
19583
+ * alarm state nobody can be notified about. That is exactly what this list
19584
+ * failed to prevent while it held three: `alarm-arming` was the fourth.
19585
+ *
19586
+ * In LIFECYCLE order, which is the order an editor lists them in and the order
19587
+ * a person experiences them — not the order they were added.
19588
+ */
19589
+ var NC_ALARM_SYSTEM_EVENT_KINDS = [
19590
+ "alarm-arm-refused",
19591
+ "alarm-check-failed",
19592
+ "alarm-arming",
19593
+ "alarm-armed",
19594
+ "alarm-pending",
19595
+ "alarm-triggered",
19596
+ "alarm-rearmed",
19597
+ "alarm-sensor-bypass",
19598
+ "alarm-disarmed"
19599
+ ];
19600
+ /**
19567
19601
  * One coherent system-event condition. `kinds` is the required opt-in safety
19568
19602
  * gate; the remaining lists are optional narrowing filters relevant to the
19569
19603
  * selected kinds.
@@ -19597,7 +19631,22 @@ var NcSystemEventConditionSchema = object({
19597
19631
  */
19598
19632
  excludeDeviceIds: array(number().int()).min(1).optional(),
19599
19633
  nodeIds: array(string().min(1)).min(1).optional(),
19600
- packageNames: array(string().min(1)).min(1).optional()
19634
+ packageNames: array(string().min(1)).min(1).optional(),
19635
+ /**
19636
+ * At or below this remaining-life %, a consumable is LOW for THIS rule
19637
+ * (D642). Absent = {@link NC_CONSUMABLE_LOW_PERCENT_DEFAULT}; at most
19638
+ * {@link NC_CONSUMABLE_LOW_PERCENT_MAX}, so every episode can recover. Scoped to the
19639
+ * consumable kinds (`systemEventFilterApplies`) and to the device-events
19640
+ * family; ignored on every other kind.
19641
+ *
19642
+ * It is a property of the RULE because the operator decided so: a rule at
19643
+ * 25 must be told about a filter at 20 %, a rule at 10 must not. The hub
19644
+ * keeps one episode per (threshold, device, item) — its own hysteresis, its
19645
+ * own reminder — and a rule hears only the episode judged at ITS threshold,
19646
+ * exactly as an occupancy rule hears only the edge of its own count. A
19647
+ * provider's own `replace` verdict is low at every threshold.
19648
+ */
19649
+ consumableLowPercent: number().int().min(1).max(95).optional()
19601
19650
  });
19602
19651
  /** Hard ceiling on a window (24h). A snooze that could not expire would be an
19603
19652
  * outage the operator asked for once and forgot. */
@@ -19615,6 +19664,25 @@ var NcScheduleSchema = object({
19615
19664
  /** Active OUTSIDE the windows (e.g. "only outside business hours"). */
19616
19665
  invert: boolean().optional()
19617
19666
  });
19667
+ /**
19668
+ * How a system-event rule of the `device-events` or `system` family speaks
19669
+ * (D647): at once, per event (`instant`, the only behaviour before D647), or
19670
+ * as a STATE SUMMARY at the end of each window of `schedule`.
19671
+ */
19672
+ var NcSystemEventDeliveryModeSchema = _enum(["instant", "summary"]);
19673
+ /**
19674
+ * `summary`: the rule sends NOTHING per event. When a window of `schedule`
19675
+ * CLOSES, it sends one notification with the current state of its kinds
19676
+ * (low batteries, consumables to replace, devices offline, updates
19677
+ * available, ...), after its own filters. Nothing to report sends nothing.
19678
+ * The schedule is the ordinary `NcSchedule` (weekly windows, IANA timezone,
19679
+ * midnight crossing); the send time is each window's END. Refused on the
19680
+ * `alarm` family, which stays instant (`systemEventDeliveryProblems`).
19681
+ */
19682
+ var NcSystemEventDeliverySchema = discriminatedUnion("mode", [object({ mode: literal("instant") }), object({
19683
+ mode: literal("summary"),
19684
+ schedule: NcScheduleSchema
19685
+ })]);
19618
19686
  /** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
19619
19687
  var NcPlateMatcherSchema = object({
19620
19688
  /**
@@ -19740,6 +19808,16 @@ var NcCrossingSchema = _enum([
19740
19808
  "exit",
19741
19809
  "any"
19742
19810
  ]);
19811
+ /**
19812
+ * Which edge of a BOOLEAN sensor fires a device-event rule (D640).
19813
+ * - `raised` — the sensor went high: water detected, smoke, open, tampered.
19814
+ * - `cleared` — it went back: dry, clear, closed.
19815
+ * - absent — both edges, which is what every rule authored before this did.
19816
+ *
19817
+ * There is no third member for "both": absence already says it, and a value
19818
+ * that means the same as absence is a second way to write one rule.
19819
+ */
19820
+ var NcSensorTransitionSchema = _enum(["raised", "cleared"]);
19743
19821
  /** Admin-zone membership condition (zone IDs as stamped by the ZoneEngine). */
19744
19822
  var NcZoneConditionSchema = object({
19745
19823
  ids: array(string().min(1)).min(1),
@@ -19929,6 +20007,20 @@ var NcConditionsSchema = object({
19929
20007
  scene: NcSceneConditionSchema.optional(),
19930
20008
  /** Device scope — absent = all devices. */
19931
20009
  devices: array(number()).optional(),
20010
+ /**
20011
+ * Device EXCLUSION (D641) — "every device except these". Judged on the SAME
20012
+ * subject ids {@link devices} is judged on (the camera, the sensor that
20013
+ * fired, a linked set's sensor and row cameras), so a sensor fanned out per
20014
+ * linked camera is excluded exactly where an include would have tested it.
20015
+ * `min(1)`: an empty exclusion excludes nothing and is written as absent.
20016
+ *
20017
+ * Not for `system-event` rules — those carry their own
20018
+ * `systemEvent.excludeDeviceIds` (D636), and the hub refuses this key there.
20019
+ * Editors present the two lists as ONE field (All | Only these | All except
20020
+ * these); the engine evaluates each independently, so a legacy rule
20021
+ * carrying both still means "these, minus those".
20022
+ */
20023
+ devicesExclude: array(number()).min(1).optional(),
19932
20024
  /** Detector class names (any overlap with the record's class set). */
19933
20025
  classes: array(string().min(1)).optional(),
19934
20026
  /** Veto classes — any overlap fails the rule. */
@@ -20062,6 +20154,16 @@ var NcConditionsSchema = object({
20062
20154
  */
20063
20155
  sensorKinds: array(string().min(1)).optional(),
20064
20156
  /**
20157
+ * DEVICE-EVENT only (D640). Fire on one edge of a boolean sensor —
20158
+ * {@link NcSensorTransitionSchema}. Which field of the slice means "raised"
20159
+ * is `@camstack/types` → `notification/sensor-raised.ts`. A reading the
20160
+ * engine cannot place (a kind with no raise, an unreadable slice) PASSES:
20161
+ * the condition fails open towards notifying, never towards silence. Editors
20162
+ * offer it only when every chosen {@link sensorKinds} member has a raise
20163
+ * (`sensorTransitionOffered`), and the hub refuses it on any other delivery.
20164
+ */
20165
+ sensorTransition: NcSensorTransitionSchema.optional(),
20166
+ /**
20065
20167
  * PACKAGE-EVENT only. Which package phase fires the rule — `delivered`
20066
20168
  * (a parked parcel appeared), `picked-up` (it departed), or `both`. Fails
20067
20169
  * when the subject's phase does not match (a subject always carries a phase
@@ -20316,6 +20418,16 @@ var NcRuleInputSchema = object({
20316
20418
  delivery: NcDeliverySchema,
20317
20419
  conditions: NcConditionsSchema.default({}),
20318
20420
  schedule: NcScheduleSchema.optional(),
20421
+ /**
20422
+ * A `device-events` / `system` rule's delivery (D647): absent or `instant`
20423
+ * is a notification per event; `summary` is one state summary per closed
20424
+ * window of its schedule. `.optional()` and never defaulted: absent must
20425
+ * keep meaning what every rule authored before D647 meant, with no
20426
+ * migration. Top-level rather than inside `conditions.systemEvent`, so a
20427
+ * client that does not know it (an older viewer re-sending `conditions`
20428
+ * whole) leaves it standing through the store's patch merge.
20429
+ */
20430
+ systemEventDelivery: NcSystemEventDeliverySchema.optional(),
20319
20431
  /** May be empty when `targetUsers` addresses at least one user — the
20320
20432
  * "at least one addressee" invariant is enforced by the provider, because
20321
20433
  * a cross-field refine here would break `NcRulePatchSchema.partial()`. */
@@ -20544,6 +20656,28 @@ var NcRuleSchema = NcRuleInputSchema.extend({
20544
20656
  */
20545
20657
  disabledTargetIds: array(string()).default([])
20546
20658
  });
20659
+ /** One section of a previewed state summary. `unavailable` = its state could not be read. */
20660
+ var NcStateSummaryPreviewSectionSchema = object({
20661
+ id: string(),
20662
+ status: _enum(["read", "unavailable"]),
20663
+ items: number().int().nonnegative(),
20664
+ reason: string().optional()
20665
+ });
20666
+ /**
20667
+ * The summary a rule would send now. `empty` = nothing to report and every
20668
+ * section read: such a summary is NOT sent. `dropped` counts the open states
20669
+ * the rule's own filters (or a camera mute) left out, by reason.
20670
+ * `excludedGroups` names the kind groups selected that have no state to report
20671
+ * (backups & exports).
20672
+ */
20673
+ var NcStateSummaryPreviewSchema = object({
20674
+ empty: boolean(),
20675
+ count: number().int().nonnegative(),
20676
+ text: string(),
20677
+ sections: array(NcStateSummaryPreviewSectionSchema),
20678
+ dropped: record(string(), number().int().nonnegative()),
20679
+ excludedGroups: array(string())
20680
+ });
20547
20681
  var NcTestResultSchema = object({
20548
20682
  recordId: string(),
20549
20683
  recordKind: _enum([
@@ -20635,6 +20769,13 @@ var NcTemplateVarDescriptorSchema = object({
20635
20769
  kinds: array(NcTemplateVarKindSchema).optional(),
20636
20770
  deliveries: array(NcDeliverySchema).optional(),
20637
20771
  systemEventKinds: array(NcSystemEventKindSchema).optional(),
20772
+ /**
20773
+ * Which system-event DELIVERY has a value for it (D647). Absent = an
20774
+ * instant row only when the descriptor names `systemEventKinds` (a
20775
+ * per-event fact: a summary row has no single device), and both otherwise.
20776
+ * `['summary']` marks the state-summary vocabulary (`{{summaryText}}`, ...).
20777
+ */
20778
+ systemEventDeliveries: array(NcSystemEventDeliveryModeSchema).optional(),
20638
20779
  dynamic: object({
20639
20780
  prefix: literal("count_"),
20640
20781
  from: literal("classes")
@@ -20647,7 +20788,9 @@ var NcTemplatePreviewInputSchema = object({
20647
20788
  field: NcTemplateFieldSchema,
20648
20789
  kind: NcRuleKindSchema.optional(),
20649
20790
  delivery: NcDeliverySchema.optional(),
20650
- systemEventKinds: array(NcSystemEventKindSchema).optional()
20791
+ systemEventKinds: array(NcSystemEventKindSchema).optional(),
20792
+ /** The rule's system-event delivery (D647); absent = instant. */
20793
+ systemEventDelivery: NcSystemEventDeliveryModeSchema.optional()
20651
20794
  }),
20652
20795
  template: object({
20653
20796
  title: string().max(500).optional(),
@@ -20680,6 +20823,7 @@ var NcConditionDescriptorSchema = object({
20680
20823
  /** Editor widget the UI renders — never hardcode per-condition forms. */
20681
20824
  valueType: _enum([
20682
20825
  "deviceIdList",
20826
+ "deviceIdExcludeList",
20683
20827
  "stringList",
20684
20828
  "number01",
20685
20829
  "number",
@@ -20690,6 +20834,7 @@ var NcConditionDescriptorSchema = object({
20690
20834
  "plateMatcher",
20691
20835
  "packagePhase",
20692
20836
  "crossingSelect",
20837
+ "sensorTransition",
20693
20838
  "polygonDraw",
20694
20839
  "occupancy",
20695
20840
  "audio",
@@ -20823,6 +20968,18 @@ var NC_CONDITION_CATALOG = [
20823
20968
  value: "device-consumable-normal",
20824
20969
  label: "Consumable replaced"
20825
20970
  },
20971
+ {
20972
+ value: "device-tank-low",
20973
+ label: "Tank low (water, detergent)"
20974
+ },
20975
+ {
20976
+ value: "device-tank-full",
20977
+ label: "Tank full (dirty water, dust)"
20978
+ },
20979
+ {
20980
+ value: "device-tank-normal",
20981
+ label: "Tank back to normal"
20982
+ },
20826
20983
  {
20827
20984
  value: "export-completed",
20828
20985
  label: "Export completed"
@@ -20888,6 +21045,21 @@ var NC_CONDITION_CATALOG = [
20888
21045
  phase: "P1",
20889
21046
  description: "Restrict the rule to these devices; absent = all devices. A sensor event matches either the SENSOR that fired or the camera it is attributed to, so a rule may name either one."
20890
21047
  },
21048
+ {
21049
+ id: "devicesExclude",
21050
+ group: "scope",
21051
+ label: "Excluded devices",
21052
+ valueType: "deviceIdExcludeList",
21053
+ operator: "notIn",
21054
+ appliesTo: [
21055
+ "immediate",
21056
+ "track-end",
21057
+ "device-event",
21058
+ "package-event"
21059
+ ],
21060
+ phase: "P1",
21061
+ description: "Every device except these. Judged on the same device ids as Devices: a sensor event is excluded by the SENSOR that fired or by the camera it is attributed to."
21062
+ },
20891
21063
  {
20892
21064
  id: "classes",
20893
21065
  group: "class",
@@ -21144,6 +21316,33 @@ var NC_CONDITION_CATALOG = [
21144
21316
  phase: "P1",
21145
21317
  description: "Raw device event-type tokens (e.g. doorbell press / press_long) from the event-emitter slice; absent on doorbell-pulse / passive sensors."
21146
21318
  },
21319
+ {
21320
+ id: "sensorTransition",
21321
+ group: "device",
21322
+ label: "Notify when",
21323
+ valueType: "sensorTransition",
21324
+ options: [
21325
+ {
21326
+ value: "",
21327
+ label: "It triggers and when it clears",
21328
+ hint: "Every change: water detected, and back to dry."
21329
+ },
21330
+ {
21331
+ value: "raised",
21332
+ label: "Only when it triggers",
21333
+ hint: "Water detected, smoke, a contact opening — never the return to normal."
21334
+ },
21335
+ {
21336
+ value: "cleared",
21337
+ label: "Only when it clears",
21338
+ hint: "Back to dry, smoke gone, a contact closing — never the alert itself."
21339
+ }
21340
+ ],
21341
+ operator: "in",
21342
+ appliesTo: ["device-event"],
21343
+ phase: "P2",
21344
+ description: "Fire on one edge of a boolean sensor. Offered only when every chosen sensor kind raises and clears; a reading that cannot be placed still notifies."
21345
+ },
21147
21346
  {
21148
21347
  id: "packagePhase",
21149
21348
  group: "package",
@@ -21327,6 +21526,28 @@ var NcHistoryFilterSchema = object({
21327
21526
  limit: number().int().min(1).max(500).default(100)
21328
21527
  });
21329
21528
  /**
21529
+ * Every rule's last run, in one answer.
21530
+ *
21531
+ * A rule ABSENT from `runs` produced no delivery inside `horizonMs` — how far
21532
+ * back this answer looked, in ms before the hub's now. It is the outbox prune
21533
+ * window (7 days by default, operator-configurable), NARROWED when the read hit
21534
+ * its row bound: the answer never claims a window it did not read. `null` means
21535
+ * the operator keeps the outbox forever AND the read reached its end, so absent
21536
+ * means "never on record". A UI derives its "not in the last N days" from this
21537
+ * value, never from a constant — and only when the call ANSWERED (D315).
21538
+ */
21539
+ var NcRuleLastRunsSchema = object({
21540
+ runs: array(object({
21541
+ ruleId: string(),
21542
+ /** Fire time of the newest row (`createdAt`, epoch ms). */
21543
+ lastAt: number(),
21544
+ status: NcHistoryStatusSchema,
21545
+ /** The camera/device of that row (a digest row files under its first camera). */
21546
+ deviceId: number()
21547
+ })),
21548
+ horizonMs: number().nonnegative().nullable()
21549
+ });
21550
+ /**
21330
21551
  * What a snooze covers. Broader scopes win when several overlap, so one window
21331
21552
  * leaves ONE digest rather than a rule snooze and a whole-feed snooze both
21332
21553
  * summarising the same silence.
@@ -21507,6 +21728,14 @@ var NcAlarmModeCoverageSchema = object({
21507
21728
  /** Ids named by the covering rules. A SUBSET when `allDevices` is true. */
21508
21729
  deviceIds: array(number().int()),
21509
21730
  /**
21731
+ * D641: the ids NOT covered although `allDevices` is true — every unscoped
21732
+ * covering rule EXCLUDES them (`conditions.devicesExclude`) and no named rule
21733
+ * covers them. Always `[]` when `allDevices` is false. Excluded by the rules,
21734
+ * which is not the same as skipped by a switch: never in `skippedDevices`.
21735
+ * Defaulted so an answer computed before this field parses as "none".
21736
+ */
21737
+ allDevicesExcept: array(number().int()).default([]),
21738
+ /**
21510
21739
  * Devices this mode NAMES but cannot actually arm, each with the switch that
21511
21740
  * excludes it.
21512
21741
  *
@@ -21694,6 +21923,17 @@ var notificationRulesCapability = {
21694
21923
  auth: "admin"
21695
21924
  }),
21696
21925
  /**
21926
+ * The STATE SUMMARY a system rule would send now (D647) — for a saved rule
21927
+ * or an unsaved draft. Pure: sends nothing, stamps nothing. A MUTATION
21928
+ * only for transport (a whole rule does not belong in a GET URL). Admin,
21929
+ * like `testRule`: it names devices and nodes across the installation.
21930
+ */
21931
+ previewStateSummary: method(object({ rule: NcRuleInputSchema }), NcStateSummaryPreviewSchema, {
21932
+ kind: "mutation",
21933
+ auth: "admin",
21934
+ access: "view"
21935
+ }),
21936
+ /**
21697
21937
  * The machine-readable condition surface a rule editor renders from, plus
21698
21938
  * the picker VOCABULARY those conditions draw on.
21699
21939
  *
@@ -21730,6 +21970,15 @@ var notificationRulesCapability = {
21730
21970
  */
21731
21971
  getHistory: method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" }),
21732
21972
  /**
21973
+ * The newest delivery of every rule, in ONE bounded read of the outbox —
21974
+ * the "Last run" column. Never a `getHistory` per rule. A rule with no
21975
+ * delivery inside `horizonMs` is absent from `runs`; see
21976
+ * {@link NcRuleLastRunsSchema} for what absent means. A store that cannot
21977
+ * answer FAILS the call rather than answering "nothing ran". Admin-only,
21978
+ * like `getHistory`, of which it is a projection.
21979
+ */
21980
+ getRuleLastRuns: method(object({}), NcRuleLastRunsSchema, { auth: "admin" }),
21981
+ /**
21733
21982
  * Mint a fresh, externally-reachable URL for one artefact a history row
21734
21983
  * named in {@link NcHistoryEntrySchema.shape.artifactIds} — the SAME
21735
21984
  * signed-link mechanism the dispatcher uses to attach media to an
@@ -22145,1019 +22394,195 @@ var oauthIntegrationCapability = {
22145
22394
  getDescriptor: method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" }) }
22146
22395
  };
22147
22396
  /**
22148
- * Reference to the frame's retained NATIVE surface + the parent crop's placement
22149
- * within the frame, so the executor can re-cut a leaf child ROI at native
22150
- * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
22397
+ * pipeline-analytics — device-scoped wrapper cap. Refines raw
22398
+ * per-frame detections emitted by the pipeline runner into tracked
22399
+ * objects, per-kind event collections (motion / object / audio), and
22400
+ * persisted media. Owns the post-detection domain end-to-end:
22401
+ *
22402
+ * runner emits PipelineInferenceResult
22403
+ * ↓ (event bus)
22404
+ * pipeline-analytics subscriber
22405
+ * ↓ SORT tracker + zone engine + state analyzer + event emitter
22406
+ * → three DB collections (one per kind), one FS media tree, one
22407
+ * unified event emitter (FrameTracked + TrackStarted/Ended +
22408
+ * DetectionEvent on bus)
22409
+ *
22410
+ * Pure subscriber model. No `processFrame` cap method — the runner
22411
+ * already publishes the raw frame on the bus. The cap surface is
22412
+ * only QUERIES + per-device settings, bound on/off via
22413
+ * `device-manager.setWrapperActive`. `defaultActive: true` because
22414
+ * every camera with a detection pipeline wants its raw detections
22415
+ * refined; operators opt out per-device via BindingsTab when needed.
22416
+ *
22417
+ * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
22418
+ * (per-device surface) and `track-trail` caps — see P11 cleanup.
22151
22419
  */
22152
- var NativeCropRefSchema = object({
22153
- /** Handle keying the retained native surface (node-pinned to its owner). */
22154
- handle: FrameHandleSchema,
22155
- /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
22156
- cropFrameSpace: object({
22157
- x: number(),
22158
- y: number(),
22159
- w: number(),
22160
- h: number()
22161
- })
22162
- });
22163
- object({
22164
- crop: object({
22165
- left: number(),
22166
- top: number(),
22167
- width: number().positive(),
22168
- height: number().positive()
22169
- }).optional(),
22170
- content: object({
22171
- width: number().int().positive(),
22172
- height: number().int().positive()
22173
- }),
22174
- fit: _enum(["stretch", "contain"]),
22175
- format: _enum([
22176
- "rgb",
22177
- "gray",
22178
- "jpeg"
22179
- ])
22180
- });
22420
+ var TrackStateSchema = _enum([
22421
+ "new",
22422
+ "entered",
22423
+ "left",
22424
+ "moving",
22425
+ "idle"
22426
+ ]);
22427
+ var EventKindSchema = _enum([
22428
+ "motion",
22429
+ "object",
22430
+ "audio"
22431
+ ]);
22181
22432
  /**
22182
- * Process-local frame identity. It is serializable so it can ride an in-process
22183
- * capability call, but `registryId` deliberately prevents resolution in any
22184
- * other process or execution group.
22433
+ * Spatial filter for `listTracks` — the rect + polygon variants of the shared
22434
+ * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
22435
+ * of the camera frame (top-left origin), matching the drawing-plane editor.
22185
22436
  */
22186
- var FrameRefSchema = object({
22187
- registryId: string().min(1),
22188
- id: string().min(1),
22189
- width: number().int().positive(),
22190
- height: number().int().positive(),
22191
- format: _enum(["rgb", "gray"]),
22192
- timestamp: number(),
22193
- capturedAt: number().optional()
22194
- });
22195
- var ModelFormatSchema$1 = _enum([
22196
- "onnx",
22197
- "coreml",
22198
- "openvino",
22199
- "tflite",
22200
- "pt",
22201
- "gguf"
22437
+ var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
22438
+ /** Closed icon vocabulary so clients render a known glyph per kind. */
22439
+ var EventKindIconSchema = _enum([
22440
+ "motion",
22441
+ "audio",
22442
+ "person",
22443
+ "vehicle",
22444
+ "animal",
22445
+ "door",
22446
+ "pir",
22447
+ "smoke",
22448
+ "water",
22449
+ "button",
22450
+ "package",
22451
+ "generic"
22202
22452
  ]);
22203
- var PipelineSlotSchema = _enum([
22204
- "detector",
22205
- "cropper",
22206
- "classifier",
22207
- "refiner",
22208
- "audio-classifier"
22453
+ var EventKindCategorySchema = _enum([
22454
+ "motion",
22455
+ "audio",
22456
+ "detection",
22457
+ "sensor",
22458
+ "control",
22459
+ "custom",
22460
+ "package"
22209
22461
  ]);
22210
- var PipelineEngineChoiceSchema = object({
22211
- runtime: _enum(["node", "python"]),
22212
- backend: string(),
22213
- format: ModelFormatSchema$1,
22214
- device: string().optional()
22215
- });
22216
- var AvailableEngineSchema = object({
22217
- engine: PipelineEngineChoiceSchema,
22218
- devices: array(object({
22219
- id: string(),
22220
- label: string(),
22221
- description: string().optional()
22222
- })).readonly(),
22223
- defaultDevice: string()
22224
- });
22225
- var PipelineDefaultStepSchema = lazy(() => object({
22226
- addonId: string(),
22227
- addonName: string(),
22228
- slot: PipelineSlotSchema,
22229
- inputClasses: array(string()).readonly(),
22230
- outputClasses: array(string()).readonly(),
22231
- enabled: boolean(),
22232
- modelId: string(),
22233
- children: array(PipelineDefaultStepSchema).readonly(),
22234
- group: string().optional(),
22235
- settings: record(string(), unknown()).optional()
22236
- }));
22237
- var PipelineTemplateStepSchema = lazy(() => object({
22238
- addonId: string(),
22239
- enabled: boolean(),
22240
- modelId: string(),
22241
- children: array(PipelineTemplateStepSchema).readonly(),
22242
- settings: record(string(), unknown()).optional()
22243
- }));
22244
- var PipelineTemplateSchema$1 = object({
22245
- id: string(),
22246
- name: string(),
22247
- createdAt: string(),
22248
- updatedAt: string(),
22249
- engine: PipelineEngineChoiceSchema,
22250
- steps: array(PipelineTemplateStepSchema).readonly()
22251
- });
22252
- var PipelineModelOptionSchema = object({
22253
- id: string(),
22254
- name: string(),
22255
- formats: record(string(), object({
22256
- downloaded: boolean(),
22257
- sizeMB: number()
22258
- })),
22259
- group: ModelVariantGroupSchema.optional(),
22260
- legacy: boolean().optional(),
22261
- provider: ModelProviderIdSchema.optional()
22262
- });
22263
- var ConfigFieldBridge = custom();
22264
- var PipelineAddonSchemaSchema = object({
22265
- id: string(),
22266
- name: string(),
22267
- slot: PipelineSlotSchema,
22268
- inputClasses: array(string()).readonly(),
22269
- outputClasses: array(string()).readonly(),
22270
- childSlots: array(PipelineSlotSchema).readonly(),
22271
- models: array(PipelineModelOptionSchema).readonly(),
22272
- defaultModelId: string(),
22273
- defaultModelIdByFormat: record(string(), string()).optional(),
22274
- enabledByDefault: boolean().optional(),
22275
- backfillIntoExistingOverrides: boolean().optional(),
22276
- defaultConfidence: number(),
22277
- group: string().optional(),
22278
- configSchema: array(ConfigFieldBridge).readonly().optional()
22279
- });
22280
- var PipelineSlotSchemaSchema = object({
22281
- id: PipelineSlotSchema,
22462
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
22463
+ var EventKindLevelSchema = _enum(["macro", "sub"]);
22464
+ var EventKindDescriptorSchema = object({
22465
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
22466
+ kind: string(),
22467
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
22468
+ labelKey: string(),
22469
+ /** English fallback label (kept for clients that don't translate). */
22282
22470
  label: string(),
22283
- priority: number(),
22284
- parentSlot: PipelineSlotSchema.nullable(),
22285
- addons: array(PipelineAddonSchemaSchema).readonly()
22286
- });
22287
- var PipelineSchemaSchema = object({
22288
- availableEngines: array(AvailableEngineSchema).readonly(),
22289
- selectedEngine: PipelineEngineChoiceSchema,
22290
- slots: array(PipelineSlotSchemaSchema).readonly()
22291
- });
22292
- var EngineProvisioningSchema = object({
22293
- runtimeId: _enum([
22294
- "onnx",
22295
- "openvino",
22296
- "coreml",
22297
- "edgetpu"
22298
- ]).nullable(),
22299
- device: string().nullable(),
22300
- state: _enum([
22301
- "idle",
22302
- "installing",
22303
- "verifying",
22304
- "ready",
22305
- "failed"
22306
- ]),
22307
- progress: number().optional(),
22308
- error: string().optional(),
22309
- nextRetryAt: number().optional(),
22310
- /**
22311
- * Gate A (config-correctness gate at engine change): human-readable
22312
- * config issues surfaced EAGERLY when the node's engine changes — model
22313
- * substitutions ("chose X, running Y") and zero-build steps ("no model
22314
- * has a <format> build"). Additive/optional: informational only, never
22315
- * enforced here — `assertEngineReady` (readiness) still gates inference.
22316
- * Absent/empty when the node-default tree resolves cleanly.
22317
- */
22318
- configIssues: array(string()).optional()
22319
- });
22320
- var PipelineStepInputSchema = lazy(() => object({
22321
- addonId: string(),
22322
- modelId: string().optional(),
22323
- enabled: boolean().default(true),
22324
- children: array(PipelineStepInputSchema).optional(),
22325
- settings: record(string(), unknown()).optional(),
22326
- jumpDeviceKey: string().optional()
22327
- }));
22328
- var ModelSubstitutionSchema = object({
22329
- addonId: string(),
22330
- chosen: string(),
22331
- running: string(),
22332
- format: string()
22333
- });
22334
- var PipelineValidationIssueSchema = object({
22335
- addonId: string(),
22336
- kind: _enum(["unknown-addon", "no-format-build"]),
22337
- detail: string()
22338
- });
22339
- var PipelineValidationResultSchema = object({
22340
- ok: boolean(),
22341
- issues: array(PipelineValidationIssueSchema).readonly(),
22342
- substitutions: array(ModelSubstitutionSchema).readonly(),
22343
- /** The node's `currentEngine.format` this validation ran against. */
22344
- format: string()
22345
- });
22346
- var ReferenceImageEntrySchema = object({
22347
- filename: string(),
22348
- stepIds: array(string()).readonly().optional()
22349
- });
22350
- var ReferenceImageBodySchema = object({
22351
- base64: string(),
22352
- filename: string()
22471
+ /** Hex color for timeline/legend rendering. */
22472
+ color: string(),
22473
+ /** Dictionary id → lucide component on the UI side. */
22474
+ iconId: string(),
22475
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
22476
+ icon: EventKindIconSchema,
22477
+ category: EventKindCategorySchema,
22478
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
22479
+ parentKind: string().nullable(),
22480
+ /** Derived from `parentKind`, explicit for the client tree. */
22481
+ level: EventKindLevelSchema,
22482
+ /** Which cap + device contributes this kind. For built-ins the camera
22483
+ * itself; for sensor kinds the LINKED source device. */
22484
+ source: object({
22485
+ capName: string(),
22486
+ deviceId: number()
22487
+ })
22353
22488
  });
22354
- var ReferenceAudioEntrySchema = object({
22355
- filename: string(),
22356
- sizeKb: number()
22489
+ /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
22490
+ var EventKindsForDeviceSchema = object({
22491
+ deviceId: number(),
22492
+ kinds: array(EventKindDescriptorSchema).readonly()
22357
22493
  });
22358
- var ReferenceAudioBodySchema = object({ base64: string() });
22359
- var AudioBackendSchema = object({
22494
+ var SensorEventSchema = object({
22360
22495
  id: string(),
22361
- name: string(),
22362
- description: string(),
22363
- available: boolean(),
22496
+ /** The CAMERA the event is attributed to (a sensor linked to N cameras
22497
+ * yields N rows, one per camera). */
22498
+ deviceId: number(),
22499
+ /** The linked sensor device whose state changed. */
22500
+ sourceDeviceId: number(),
22501
+ /** Event kind id — matches an `EventKindDescriptor.kind`. */
22502
+ kind: string(),
22503
+ /** Snapshot of the sensor cap's runtime-state slice at the change. */
22504
+ value: record(string(), unknown()).nullable(),
22505
+ timestamp: number()
22506
+ });
22507
+ /**
22508
+ * One stored sighting on a track's trajectory.
22509
+ *
22510
+ * The array these live in is returned in TIME order (D399) — it is APPENDED in
22511
+ * arrival order, and the two detector passes interleave, so a consumer must not
22512
+ * assume the two are the same on a row written by an older build.
22513
+ */
22514
+ var TrackPositionSchema = object({
22515
+ x: number(),
22516
+ y: number(),
22517
+ timestamp: number(),
22518
+ bbox: BoundingBoxSchema,
22364
22519
  /**
22365
- * Raw classifier labels this backend can emit (e.g. YAMNet's
22366
- * 521-class set or Apple SoundAnalysis's 303-class set). Used by
22367
- * the benchmark UI to populate the `enabledMicroClasses` filter
22368
- * specific to the selected backend without a separate fetch.
22520
+ * Which detector pass measured this box (D399): `frame` is the full-frame
22521
+ * pass on the analysis raster, `recovery` is the native-resolution
22522
+ * small-subject second pass (D377/D378). Both write into one array, and until
22523
+ * this field existed the only way to tell them apart was that full-frame boxes
22524
+ * are exact multiples of 1.2 while recovery boxes are full-precision floats.
22525
+ * Absent on rows written before D399.
22369
22526
  */
22370
- rawLabels: array(string()).readonly().optional()
22527
+ source: _enum(["frame", "recovery"]).optional(),
22528
+ /** Detection score of this box, so a position can be weighed and not only
22529
+ * plotted. Absent on rows written before D399. */
22530
+ score: number().optional()
22371
22531
  });
22372
- var AudioCapabilitiesSchema = object({
22373
- activeBackend: string(),
22374
- availableBackends: array(AudioBackendSchema).readonly(),
22375
- sampleRate: number(),
22376
- chunkDurationMs: number()
22532
+ var TrackSnapshotSchema = object({
22533
+ timestamp: number(),
22534
+ position: TrackPositionSchema,
22535
+ /** The snapshot's media row id (D482); resolve via `listTrackMedia({ trackId })`. */
22536
+ mediaId: number().int()
22377
22537
  });
22378
- var DownloadModelResultSchema = object({
22379
- filePath: string(),
22380
- sizeMB: number(),
22381
- durationMs: number()
22538
+ /**
22539
+ * Normalized 0..1 trajectory envelope (min/max over every position bbox,
22540
+ * divided by the track's detection-frame dims), computed at persist time.
22541
+ * Absent when the frame dims were unknown when the track was persisted
22542
+ * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
22543
+ */
22544
+ var TrackEnvelopeSchema = object({
22545
+ minX: number(),
22546
+ minY: number(),
22547
+ maxX: number(),
22548
+ maxY: number()
22382
22549
  });
22383
22550
  /**
22384
- * Wrapper carrying a single test run's result. Replaces the legacy
22385
- * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
22386
- * canonical `AudioResult` from the Phase 6 output rework: one
22387
- * `AudioDetection` per class above `minScore`, top-N candidates in
22388
- * `debug.alternateLabels['audio-classifier']`, per-source timings in
22389
- * `debug.stepTimings`. The outer `success`/`error` fields stay so the
22390
- * benchmark UI can still report a clean failure when the classifier
22391
- * cap isn't available.
22551
+ * Row projection for track list queries. `full` (default) returns the
22552
+ * complete Track including the frame-rate `positions[]` history and the
22553
+ * `snapshots[]` references — megabytes across a page of tracks. `slim`
22554
+ * keeps every scalar the list surfaces actually render (ids, class(es),
22555
+ * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
22556
+ * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
22557
+ * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
22558
+ * `getTrack`. Mirrors the event-store `projection` convention
22559
+ * (`getObjectEvents` et al.).
22392
22560
  */
22393
- var AudioTestResultSchema = object({
22394
- success: boolean(),
22395
- error: string().optional(),
22396
- frame: custom().optional()
22561
+ var TrackProjectionSchema = _enum(["full", "slim"]);
22562
+ /**
22563
+ * One audio-classification label heard on the track's camera while the
22564
+ * track was alive, aggregated per label. An "episode" is one persisted
22565
+ * audio event (the confident-classification path: score ≥ the device's
22566
+ * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
22567
+ * one 32 ms inference chunk, so counts stay human-scaled.
22568
+ */
22569
+ var TrackAudioLabelSchema = object({
22570
+ label: string(),
22571
+ /** Highest classification score observed across the label's episodes. */
22572
+ peakScore: number(),
22573
+ /** Number of coalesced audio-event episodes carrying this label. */
22574
+ count: number(),
22575
+ firstAt: number(),
22576
+ lastAt: number()
22397
22577
  });
22398
- var PipelineConfigBridge = custom();
22399
- var ConfigUISchemaBridge = custom();
22400
- var ConfigUISchemaNullableBridge = custom();
22401
- var InferenceCapabilitiesBridge = custom();
22402
- var ModelAvailabilityListBridge = custom();
22403
- var PipelineRunResultBridge = custom();
22404
22578
  /**
22405
- * Pipeline executor — detection engine + configuration + inference API.
22579
+ * How a track was produced. `pipeline` (default / absent) = the spatial
22580
+ * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
22581
+ * no positions, a single snapshot, and no bbox trajectory at all:
22406
22582
  *
22407
- * Merged from: pipeline-executor, pipeline-config, inference, detection-config.
22408
- * Implemented by the detection-pipeline addon.
22409
- *
22410
- * Per-device surface (DeviceSettingsContribution + the "is detection
22411
- * enabled for this camera?" toggle) lives on the paired
22412
- * `detection-pipeline` cap (device-scoped, singleton, wrapper
22413
- * defaultActive) — same split pattern used by stream-broker /
22414
- * camera-streams and audio-analyzer / audio-analysis.
22415
- */
22416
- var pipelineExecutorCapability = {
22417
- name: "pipeline-executor",
22418
- scope: "system",
22419
- mode: "singleton",
22420
- methods: {
22421
- getAvailableEngines: method(_void(), array(PipelineEngineChoiceSchema)),
22422
- getSelectedEngine: method(_void(), PipelineEngineChoiceSchema),
22423
- getDefaultSteps: method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)),
22424
- /**
22425
- * Per-node detection-engine provisioning snapshot. Returns the live
22426
- * state of the lazy runtime-provisioning machine on `nodeId`
22427
- * (idle / installing / verifying / ready / failed). The UI pairs this
22428
- * one-shot query with the `pipeline.engine-provisioning` live event
22429
- * (emitted on every transition) to drive a per-node "engine ready?"
22430
- * indicator without polling. Phase 2.
22431
- */
22432
- getEngineProvisioning: method(object({ nodeId: string() }), EngineProvisioningSchema),
22433
- getVideoPipelineSteps: method(_void(), record(string(), object({
22434
- modelId: string(),
22435
- settings: record(string(), unknown()).readonly()
22436
- }))),
22437
- setVideoPipelineSteps: method(object({ steps: record(string(), object({
22438
- modelId: string(),
22439
- settings: record(string(), unknown()).readonly()
22440
- })) }), object({ success: literal(true) }), {
22441
- kind: "mutation",
22442
- auth: "admin"
22443
- }),
22444
- /**
22445
- * Clear THIS node's executor-side PER-DEVICE settings stores (the
22446
- * per-camera step overrides the object-detection root reads via
22447
- * `applyDeviceOverridesToTree`). `nodeId` is the ROUTING key — the
22448
- * generated cap-router strips it (default `nodeIdMode: 'routing'`) and
22449
- * dispatches to that node, so the provider method runs ON the target
22450
- * node and receives no `nodeId`.
22451
- *
22452
- * This is the slimmed executor leg of the orchestrator's
22453
- * `resetNodePipelineDefaults` flow (which owns the real reset: node
22454
- * addonDefaults pins + per-camera orchestrator overrides). The legacy
22455
- * `resetToDefault` — which reset a persisted global step-tree seed
22456
- * nothing in the live per-camera path read — was removed together with
22457
- * that seed.
22458
- */
22459
- clearDeviceOverrides: method(object({ nodeId: string() }), object({
22460
- success: literal(true),
22461
- clearedDevices: number()
22462
- }), {
22463
- kind: "mutation",
22464
- auth: "admin"
22465
- }),
22466
- /**
22467
- * Which of THIS node's inference devices the executor currently refuses,
22468
- * and why. `nodeId` is the ROUTING key (stripped by the generated router).
22469
- *
22470
- * The channel that did not exist. Pool health was known only inside the
22471
- * detection addon and was an input to no routing decision anywhere: the
22472
- * per-dispatch capability gate is keyed on model FORMAT and so can never
22473
- * separate `openvino:gpu` from `openvino:npu`, and the orchestrator's live
22474
- * eligibility probe (`platformProbe.getCapabilities`) answers about
22475
- * HARDWARE — which was present throughout. So when the hub's `openvino:gpu`
22476
- * Python worker was SIGABRT'd by the Intel GPU plugin on 2026-08-25, the
22477
- * balancer went on handing that dead pool cameras by rotation for 31 hours:
22478
- * ~370 000 `PoolWorker[w0]: not initialized` lines, every frame lost.
22479
- *
22480
- * Read semantics the caller depends on, and which the provider guarantees:
22481
- * this is a synchronous read of in-memory state. It never probes hardware,
22482
- * never spawns a pool and never throws — an EMPTY `unhealthy` means "asked,
22483
- * nothing is refused", which is what re-admits a device. A read that FAILS
22484
- * (node offline, version skew) must therefore be distinguishable from an
22485
- * empty answer, and it is: it rejects.
22486
- */
22487
- getInferenceDeviceHealth: method(object({ nodeId: string() }), object({ unhealthy: array(object({
22488
- /** `<backend>:<device>`, e.g. `openvino:gpu`. */
22489
- deviceKey: string(),
22490
- /**
22491
- * `failed` — the per-device restart budget is exhausted; no pool
22492
- * will be spawned until an operator re-arms it or the runner
22493
- * respawns. `backoff` — under budget, waiting out the backoff (or
22494
- * a cached pool observed dead and not yet condemned).
22495
- */
22496
- state: _enum(["failed", "backoff"]),
22497
- /** Epoch ms of the death that produced this state. */
22498
- since: number(),
22499
- /** Pool deaths inside the current window. */
22500
- deaths: number(),
22501
- /** The last death's message. */
22502
- lastError: string()
22503
- })).readonly() })),
22504
- /**
22505
- * Re-arm a terminally `failed` inference device on `nodeId`: forget its
22506
- * restart budget so the next dispatch builds a fresh pool.
22507
- *
22508
- * The terminal state is deliberate (the abort it bounds is deterministic —
22509
- * an automatic probation would just respawn Python forever, more slowly),
22510
- * and a terminal state an operator cannot leave is a silent fault. This is
22511
- * the way out. `rearmed:false` means there was nothing to forget.
22512
- */
22513
- rearmInferenceDevice: method(object({
22514
- nodeId: string(),
22515
- deviceKey: string()
22516
- }), object({ rearmed: boolean() }), {
22517
- kind: "mutation",
22518
- auth: "admin"
22519
- }),
22520
- getSchema: method(_void(), PipelineSchemaSchema),
22521
- getGlobalSteps: method(_void(), array(PipelineDefaultStepSchema).readonly().nullable()),
22522
- getGlobalPipelineConfig: method(_void(), PipelineConfigBridge),
22523
- getOrchestratorConfigSchema: method(_void(), ConfigUISchemaBridge),
22524
- /**
22525
- * Gate B (pre-init config-correctness gate). PURE COMPUTE against this
22526
- * node's `currentEngine.format` — resolves `steps` the same way the
22527
- * runtime dispatch path would, and reports what WOULD happen without
22528
- * touching any node-global state. Called by the orchestrator at attach
22529
- * time (`attachOn`), node-pinned to the TARGET node, so config problems
22530
- * surface BEFORE `pipelineRunner.attachCamera` rather than at the first
22531
- * per-frame resolve. `ok` is false iff `issues` is non-empty (both
22532
- * `unknown-addon` and `no-format-build` are HARD issues); `substitutions`
22533
- * is informational (a degraded-but-loadable model swap) and never
22534
- * affects `ok`. Never throws.
22535
- */
22536
- validatePipeline: method(object({ steps: array(PipelineStepInputSchema) }), PipelineValidationResultSchema),
22537
- listTemplates: method(_void(), array(PipelineTemplateSchema$1).readonly()),
22538
- saveTemplate: method(object({
22539
- name: string(),
22540
- steps: array(PipelineTemplateStepSchema).readonly(),
22541
- engine: PipelineEngineChoiceSchema
22542
- }), PipelineTemplateSchema$1, { kind: "mutation" }),
22543
- updateTemplate: method(object({
22544
- id: string(),
22545
- name: string().optional(),
22546
- steps: array(PipelineTemplateStepSchema).readonly().optional()
22547
- }), PipelineTemplateSchema$1, { kind: "mutation" }),
22548
- deleteTemplate: method(object({ id: string() }), _void(), { kind: "mutation" }),
22549
- getCapabilities: method(_void(), InferenceCapabilitiesBridge),
22550
- getAddonModels: method(object({ addonId: string() }), ModelAvailabilityListBridge),
22551
- downloadModel: method(object({
22552
- addonId: string(),
22553
- modelId: string(),
22554
- format: ModelFormatSchema$1
22555
- }), DownloadModelResultSchema, { kind: "mutation" }),
22556
- deleteModel: method(object({
22557
- addonId: string(),
22558
- modelId: string(),
22559
- format: ModelFormatSchema$1
22560
- }), object({ success: literal(true) }), { kind: "mutation" }),
22561
- /**
22562
- * Stateless single-frame execution. Callers (runner, benchmark) pass
22563
- * the complete `engine` + `steps` tree; the executor holds no state
22564
- * about cameras or saved pipelines.
22565
- *
22566
- * `engine` is optional during the migration window to preserve the
22567
- * legacy call shape used by existing benchmark code; once all
22568
- * callers pass it explicitly we make it required.
22569
- *
22570
- * Exactly one of `frame`, `frameRef`, `frameHandle`, `imageBase64`,
22571
- * `referenceImage` must be provided:
22572
- * - `frame`: runtime dispatch path (runner → decoded broker frame).
22573
- * Carries the raw buffer, dimensions, and format; the executor
22574
- * uses it directly without base64 round-tripping.
22575
- * - `frameHandle` (CB5): a zero-pixel shm `FrameHandle` for the SAME
22576
- * decoded frame. Both runner and executor are hub-local processes
22577
- * sharing `/dev/shm`, so the executor maps the named segment and
22578
- * reads the pixels back zero-copy — eliminating the ~1.2MB
22579
- * re-serialisation over UDS/MsgPack the `frame` path pays per call.
22580
- * High-risk: the FrameRing is a latest-wins seqlock with no
22581
- * refcount, so a recycled slot yields a null read; the executor
22582
- * then degrades to an empty result and the runner ships pixels via
22583
- * `frame` as the fallback (queue-depth gated on the runner side).
22584
- * - `imageBase64`: one-shot test path (benchmark ImageTab).
22585
- * - `referenceImage`: named file from the reference-image store.
22586
- */
22587
- runPipeline: method(object({
22588
- engine: PipelineEngineChoiceSchema.optional(),
22589
- steps: array(PipelineStepInputSchema).min(1),
22590
- frame: FrameInputSchema.optional(),
22591
- /**
22592
- * Process-local lazy frame. Valid only when caller and provider resolve
22593
- * in the same execution-group process; split/cross-node callers use
22594
- * `frame`/`image` inline compatibility instead.
22595
- */
22596
- frameRef: FrameRefSchema.optional(),
22597
- /**
22598
- * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
22599
- * the decoded pixels live in. One more member of the one-of
22600
- * frame/frameHandle/image/imageBase64/referenceImage group.
22601
- */
22602
- frameHandle: FrameHandleSchema.optional(),
22603
- imageBase64: string().optional(),
22604
- /**
22605
- * Binary JPEG bytes — preferred over `imageBase64` on internal
22606
- * hops (hub → forked worker via Moleculer MsgPack) because it
22607
- * skips the 33% base64 overhead + the per-call base64 decode on
22608
- * the detection-pipeline worker. Callers can pass either; exactly
22609
- * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
22610
- */
22611
- image: _instanceof(Uint8Array).optional(),
22612
- referenceImage: string().optional(),
22613
- deviceId: number().optional(),
22614
- sessionId: string().optional(),
22615
- /**
22616
- * Execution plane. 'full' (default) runs the whole tree — benchmark,
22617
- * reference-image, and detail-subtree calls. 'frame' is the live
22618
- * per-frame dispatch: ONLY root-plane steps run; crop children
22619
- * (inputClasses ≠ null) are skipped and served per-track via
22620
- * pipelineRunner.runDetailSubtree (two-plane design).
22621
- */
22622
- plane: _enum(["full", "frame"]).optional(),
22623
- /**
22624
- * Inference-device selector (Phase 2 multi-device). Format
22625
- * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
22626
- * Omitted ⇒ the runner's default device (current single-engine
22627
- * behaviour). Selects WHICH device pool of the node runs the call.
22628
- */
22629
- deviceKey: string().optional(),
22630
- /**
22631
- * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
22632
- * when the parent crop was resolved from the frame's retained NATIVE
22633
- * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
22634
- * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
22635
- * resolution from that surface — the SAME quality path faces already
22636
- * had — instead of the downscaled parent tile. `handle` keys the native
22637
- * surface (node-pinned to its owner); `cropFrameSpace` is the parent
22638
- * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
22639
- * the executor's crop-normalized child ROI back into frame-normalized
22640
- * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
22641
- * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
22642
- * (today's behaviour on the fallback path).
22643
- */
22644
- nativeCropRef: NativeCropRefSchema.optional()
22645
- }), PipelineRunResultBridge, { kind: "mutation" }),
22646
- /**
22647
- * Batched run — N raw frames packed into one cap call. The provider
22648
- * routes the batch through `SharedInferencePool.inferBatch`
22649
- * (`MSG_INFER_BATCH = 0x03`) so the IPC framing and JSON response
22650
- * envelope cost is amortised N:1 vs N concurrent `runPipeline`
22651
- * calls. Single root step + uniform model assumed; trees with crop
22652
- * children fall back to sequential execution.
22653
- *
22654
- * Used by `scripts/bench-batch-style.mts` for batch benchmarking —
22655
- * N frames in one call to amortise per-call IPC overhead.
22656
- */
22657
- runPipelineBatch: method(object({
22658
- engine: PipelineEngineChoiceSchema.optional(),
22659
- steps: array(PipelineStepInputSchema).min(1),
22660
- frames: array(FrameInputSchema).min(1).max(255),
22661
- deviceId: number().optional(),
22662
- sessionId: string().optional(),
22663
- /**
22664
- * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
22665
- * the batch to the Python pool's bench preprocess cache
22666
- * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
22667
- * preprocessed ONCE and every later inference is a pure-inference cache
22668
- * hit — the sustained-throughput run measures inference, not
22669
- * decode+preprocess+infer. Omitted/0 for live frames (all different →
22670
- * full preprocess every call, correct). Fresh per sustained run;
22671
- * released via `uncacheFrame`.
22672
- */
22673
- frameId: number().int().nonnegative().optional(),
22674
- /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
22675
- deviceKey: string().optional()
22676
- }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }),
22677
- /**
22678
- * Cache a raw frame inside the Python inference pool's memory.
22679
- * Returns a numeric `frameId` that `inferCached` references —
22680
- * subsequent calls send only 5 bytes through the pipe instead of
22681
- * 1.2MB raw data, eliminating the pipe transfer bottleneck.
22682
- */
22683
- cacheFrameInPool: method(object({
22684
- data: _instanceof(Uint8Array),
22685
- width: number().int().positive(),
22686
- height: number().int().positive(),
22687
- format: _enum([
22688
- "rgb",
22689
- "bgr",
22690
- "gray"
22691
- ])
22692
- }), object({
22693
- frameId: number(),
22694
- width: number(),
22695
- height: number()
22696
- }), { kind: "mutation" }),
22697
- /**
22698
- * Run inference on a previously cached frame. Sends only 5 bytes
22699
- * (model_idx + frameId) through the IPC pipe — eliminates the
22700
- * ~35ms per-call overhead of transferring 1.2MB raw data.
22701
- */
22702
- inferCached: method(object({
22703
- stepId: string(),
22704
- frameId: number().int()
22705
- }), record(string(), unknown()), { kind: "mutation" }),
22706
- /**
22707
- * Release a cached frame from the Python pool's memory.
22708
- */
22709
- uncacheFrame: method(object({ frameId: number().int() }), _void(), { kind: "mutation" }),
22710
- /** Returns the effective pool tuning (resolved from user overrides + backend defaults). */
22711
- getEffectiveTuning: method(_void(), object({
22712
- batchMode: string(),
22713
- windowMs: number(),
22714
- maxBatchSize: number(),
22715
- concurrency: number()
22716
- })),
22717
- /**
22718
- * List every EngineFactory currently loaded in this executor's RAM,
22719
- * with the models resident and a coarse "in use" marker derived from
22720
- * ongoing inference activity. Used by the Pipeline page Engines tab.
22721
- */
22722
- listLoadedEngines: method(_void(), array(object({
22723
- engineKey: string(),
22724
- engine: PipelineEngineChoiceSchema,
22725
- modelsLoaded: array(string()).readonly(),
22726
- inUseByCameras: array(number()).readonly(),
22727
- /**
22728
- * Origin of this resident factory.
22729
- * - `runtime` — main camera-serving engine (no idle TTL).
22730
- * - `warm-override` — benchmark/test override held in the warm
22731
- * cache; auto-disposed after the idle TTL.
22732
- * - `device-pool` — a concurrent per-device pool (Phase 2
22733
- * multi-device, keyed by `deviceKey`) resolved
22734
- * via `resolveDeviceFactory`. Runs alongside the
22735
- * `runtime` engine on a DIFFERENT accelerator
22736
- * (NPU / iGPU / Coral) — this is how the
22737
- * Engines tab shows all pools running at once.
22738
- */
22739
- kind: _enum([
22740
- "runtime",
22741
- "warm-override",
22742
- "device-pool"
22743
- ]),
22744
- /** Native pid of the underlying Python pool (null when no pool). */
22745
- poolPid: number().nullable(),
22746
- /** ms since this factory was last used (null when not warm-tracked). */
22747
- idleMs: number().nullable(),
22748
- /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
22749
- idleTtlMs: number().nullable()
22750
- })).readonly()),
22751
- /** Warm up an engine without running a frame. No-op if already loaded. */
22752
- spinEngine: method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
22753
- kind: "mutation",
22754
- auth: "admin"
22755
- }),
22756
- /**
22757
- * Unload an engine from RAM. `force:true` unloads even when cameras
22758
- * are actively using it (they re-spin on next frame). Default is
22759
- * gated — returns `{success:false, reason}` when in use.
22760
- */
22761
- killEngine: method(object({
22762
- engine: PipelineEngineChoiceSchema,
22763
- force: boolean().optional()
22764
- }), object({
22765
- success: boolean(),
22766
- reason: string().optional()
22767
- }), {
22768
- kind: "mutation",
22769
- auth: "admin"
22770
- }),
22771
- listReferenceImages: method(_void(), array(ReferenceImageEntrySchema).readonly()),
22772
- getReferenceImage: method(object({ filename: string() }), ReferenceImageBodySchema.nullable()),
22773
- getReferenceAudioFiles: method(_void(), array(ReferenceAudioEntrySchema).readonly()),
22774
- getReferenceAudio: method(object({ filename: string() }), ReferenceAudioBodySchema.nullable()),
22775
- getAudioCapabilities: method(_void(), AudioCapabilitiesSchema),
22776
- runAudioTest: method(object({
22777
- addonId: string(),
22778
- modelId: string(),
22779
- filename: string().optional(),
22780
- settings: record(string(), unknown()).optional()
22781
- }), AudioTestResultSchema, { kind: "mutation" }),
22782
- getDetectionConfigSchema: method(_void(), ConfigUISchemaNullableBridge)
22783
- }
22784
- };
22785
- /**
22786
- * Per-stage gating mode applied to the zones a rule references.
22787
- *
22788
- * - `include`: the rule contributes to a **whitelist** for its stage.
22789
- * When at least one `include` rule fires for a stage, only entities
22790
- * inside one of those zones pass that stage.
22791
- * - `exclude`: the rule contributes to a **blacklist** for its stage.
22792
- * Entities inside one of those zones are dropped at that stage.
22793
- *
22794
- * `monitor`-style observation (count without filtering) is not a rule
22795
- * mode — zones without any matching rule are observed naturally by
22796
- * `zone-analytics` (live snapshot + history), so an "I just want to
22797
- * count, not filter" use case needs no rule at all.
22798
- */
22799
- var ZoneRuleModeEnum = _enum(["include", "exclude"]);
22800
- /**
22801
- * Per-consumer rule that references existing zones (geometry) and
22802
- * defines how a specific pipeline stage should treat them. Each
22803
- * consumer addon owns its own `ZoneRule[]` array in its per-device
22804
- * settings:
22805
- *
22806
- * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
22807
- * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
22808
- * - future: notification rules, audio gating, etc.
22809
- *
22810
- * One rule applies to N zones (`zoneIds[]`) so the operator can
22811
- * express "ignore motion in ALL of {garden, street}" with a single
22812
- * rule. `classFilter` narrows the rule to specific object classes —
22813
- * "drop person detections in the street, but keep cars" is one
22814
- * `exclude` rule with `classFilter: ['person']`.
22815
- *
22816
- * `enabled` is a soft toggle — the operator can keep the rule
22817
- * configured but inert without deleting it.
22818
- */
22819
- var ZoneRuleSchema = object({
22820
- /** Stable rule id — survives edits, used by the UI for diffing. */
22821
- id: string(),
22822
- /** Optional human-readable label rendered in the rule editor. */
22823
- name: string().optional(),
22824
- /** Zones this rule targets. The rule's `mode` applies to ALL
22825
- * listed zones (OR-set: a detection in any one of them counts).
22826
- * At least one zone id required — a rule with no targets is a
22827
- * configuration mistake and the form validator rejects it. */
22828
- zoneIds: array(string()).min(1).readonly(),
22829
- mode: ZoneRuleModeEnum,
22830
- /**
22831
- * Class names this rule applies to. Empty / undefined ⇒ rule
22832
- * applies to every class. Class strings match the `macroClass`
22833
- * field on detections (e.g. `person`, `car`, `dog`).
22834
- */
22835
- classFilter: array(string()).readonly().optional(),
22836
- /**
22837
- * Minimum bbox/mask overlap (0–1) with any of the rule's zones
22838
- * required to consider an entity "in the zone". Defaults to the
22839
- * consumer's stage default when omitted. Kept for back-compat with
22840
- * existing per-rule overrides; new operators pick the value via
22841
- * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
22842
- * set, the lower-level engine reads it as a 0–1 fraction.
22843
- */
22844
- overlapThreshold: number().min(0).max(1).optional(),
22845
- /**
22846
- * Operator-friendly version of `overlapThreshold` — the percentage
22847
- * of the detection's bbox that must lie inside the zone for the
22848
- * rule to match. Documented default is 85%; the engine substitutes
22849
- * that when the field is omitted (kept optional so existing rules
22850
- * stored without it stay valid).
22851
- *
22852
- * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
22853
- * rule, the engine prefers `bboxInclusionPct` because it's the
22854
- * field exposed in the UI. Internally both feed the same gate.
22855
- */
22856
- bboxInclusionPct: number().min(0).max(100).optional(),
22857
- /**
22858
- * When `true` and a detection has a segmentation mask, use the
22859
- * mask for overlap instead of the bbox. Detection-stage only;
22860
- * motion rules ignore this field.
22861
- */
22862
- preferMask: boolean().optional(),
22863
- /**
22864
- * Soft-toggle: `false` disables the rule without deleting it.
22865
- * Defaults to `true` so operators creating a rule via the UI
22866
- * see it active immediately.
22867
- */
22868
- enabled: boolean().default(true)
22869
- });
22870
- array(ZoneRuleSchema).readonly();
22871
- /**
22872
- * Zone — pure geometry + identity. NO filtering behaviour.
22873
- *
22874
- * Zones describe **where** in the frame the operator wants to flag
22875
- * something; consumer-owned {@link ZoneRule} arrays describe **how**
22876
- * each pipeline stage uses them. Splitting the two means a single
22877
- * polygon "Driveway" can simultaneously back a motion-exclude rule,
22878
- * a detection-include rule on `['car']`, and an occupancy aggregate
22879
- * — without three duplicated polygons.
22880
- *
22881
- * Owned by the orchestrator addon (provider) and mirrored into the
22882
- * `zones` device-state slice on every mutation. Consumers
22883
- * (motion-wasm, pipeline-executor, analytics, admin UI) read either
22884
- * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
22885
- * mirror with `onChanged`).
22886
- *
22887
- * Coordinates are normalised fractions of the frame (0–1) so zones
22888
- * survive resolution changes and stream profile switches.
22889
- *
22890
- * `kind` discriminates between full polygons (closed regions used
22891
- * for intrusion / occupancy filters) and tripwires (open 2-point
22892
- * line segments used for cross events). Onboard / firmware-reported
22893
- * zones (Reolink, ONVIF) are out of scope for now — see the deferred
22894
- * task list.
22895
- */
22896
- var ZoneKindEnum = _enum(["polygon", "tripwire"]);
22897
- /** Polygon vertex in fraction-of-frame coordinates (0–1). */
22898
- var PolygonPointSchema = object({
22899
- x: number(),
22900
- y: number()
22901
- });
22902
- /** A camera detection zone — pure geometry/identity. */
22903
- var ZoneSchema = object({
22904
- id: string(),
22905
- name: string(),
22906
- kind: ZoneKindEnum.default("polygon"),
22907
- /** Polygon vertices, fraction of frame (0–1). */
22908
- polygon: array(PolygonPointSchema).readonly(),
22909
- /** Visual color for UI rendering. */
22910
- color: string().default("#3b82f6")
22911
- });
22912
- /**
22913
- * Zones capability — per-camera CRUD over polygon detection zones.
22914
- *
22915
- * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
22916
- * to per-device settings and mirrors into the `zones` device-state
22917
- * slice on every mutation, so downstream consumers can subscribe via
22918
- * `dev.state.zones.onChanged`.
22919
- *
22920
- * The cap surface only handles geometry + identity; filtering
22921
- * behaviour (per-class, include/exclude, threshold) lives in the
22922
- * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
22923
- * `capabilities/schemas/zone-rule.js`.
22924
- */
22925
- var zonesCapability = {
22926
- name: "zones",
22927
- scope: "device",
22928
- mode: "singleton",
22929
- deviceTypes: [DeviceType.Camera],
22930
- methods: {
22931
- listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
22932
- addZone: method(object({
22933
- deviceId: number(),
22934
- zone: ZoneSchema
22935
- }), _void(), {
22936
- kind: "mutation",
22937
- auth: "admin"
22938
- }),
22939
- removeZone: method(object({
22940
- deviceId: number(),
22941
- zoneId: string()
22942
- }), _void(), {
22943
- kind: "mutation",
22944
- auth: "admin"
22945
- }),
22946
- updateZone: method(object({
22947
- deviceId: number(),
22948
- zone: ZoneSchema
22949
- }), _void(), {
22950
- kind: "mutation",
22951
- auth: "admin"
22952
- })
22953
- },
22954
- /**
22955
- * Runtime-state slice — the live zone catalogue mirrored by the
22956
- * orchestrator on every CRUD mutation. Consumers read via
22957
- * `device.state.zones.value` / `.watch(...)` without round-tripping
22958
- * the cap, and the codegen DeviceProxy auto-wires the reactive
22959
- * handle. Slice shape is `{ zones: Zone[] }` so future extensions
22960
- * (e.g. zone groupings) can sit alongside the polygon list.
22961
- */
22962
- runtimeState: object({ zones: array(ZoneSchema).readonly() }),
22963
- /**
22964
- * 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.
22965
- *
22966
- * See `RuntimeStateDurability`. Enforced by
22967
- * `scripts/check-runtime-state-durability.ts`.
22968
- */
22969
- durability: "restored"
22970
- };
22971
- /**
22972
- * pipeline-analytics — device-scoped wrapper cap. Refines raw
22973
- * per-frame detections emitted by the pipeline runner into tracked
22974
- * objects, per-kind event collections (motion / object / audio), and
22975
- * persisted media. Owns the post-detection domain end-to-end:
22976
- *
22977
- * runner emits PipelineInferenceResult
22978
- * ↓ (event bus)
22979
- * pipeline-analytics subscriber
22980
- * ↓ SORT tracker + zone engine + state analyzer + event emitter
22981
- * → three DB collections (one per kind), one FS media tree, one
22982
- * unified event emitter (FrameTracked + TrackStarted/Ended +
22983
- * DetectionEvent on bus)
22984
- *
22985
- * Pure subscriber model. No `processFrame` cap method — the runner
22986
- * already publishes the raw frame on the bus. The cap surface is
22987
- * only QUERIES + per-device settings, bound on/off via
22988
- * `device-manager.setWrapperActive`. `defaultActive: true` because
22989
- * every camera with a detection pipeline wants its raw detections
22990
- * refined; operators opt out per-device via BindingsTab when needed.
22991
- *
22992
- * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
22993
- * (per-device surface) and `track-trail` caps — see P11 cleanup.
22994
- */
22995
- var TrackStateSchema = _enum([
22996
- "new",
22997
- "entered",
22998
- "left",
22999
- "moving",
23000
- "idle"
23001
- ]);
23002
- var EventKindSchema = _enum([
23003
- "motion",
23004
- "object",
23005
- "audio"
23006
- ]);
23007
- /**
23008
- * Spatial filter for `listTracks` — the rect + polygon variants of the shared
23009
- * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
23010
- * of the camera frame (top-left origin), matching the drawing-plane editor.
23011
- */
23012
- var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
23013
- /** Closed icon vocabulary so clients render a known glyph per kind. */
23014
- var EventKindIconSchema = _enum([
23015
- "motion",
23016
- "audio",
23017
- "person",
23018
- "vehicle",
23019
- "animal",
23020
- "door",
23021
- "pir",
23022
- "smoke",
23023
- "water",
23024
- "button",
23025
- "package",
23026
- "generic"
23027
- ]);
23028
- var EventKindCategorySchema = _enum([
23029
- "motion",
23030
- "audio",
23031
- "detection",
23032
- "sensor",
23033
- "control",
23034
- "custom",
23035
- "package"
23036
- ]);
23037
- /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
23038
- var EventKindLevelSchema = _enum(["macro", "sub"]);
23039
- var EventKindDescriptorSchema = object({
23040
- /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
23041
- kind: string(),
23042
- /** i18n key resolved on the UI side; `label` is the English fallback. */
23043
- labelKey: string(),
23044
- /** English fallback label (kept for clients that don't translate). */
23045
- label: string(),
23046
- /** Hex color for timeline/legend rendering. */
23047
- color: string(),
23048
- /** Dictionary id → lucide component on the UI side. */
23049
- iconId: string(),
23050
- /** Legacy closed-vocab glyph — fallback for `iconId`. */
23051
- icon: EventKindIconSchema,
23052
- category: EventKindCategorySchema,
23053
- /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
23054
- parentKind: string().nullable(),
23055
- /** Derived from `parentKind`, explicit for the client tree. */
23056
- level: EventKindLevelSchema,
23057
- /** Which cap + device contributes this kind. For built-ins the camera
23058
- * itself; for sensor kinds the LINKED source device. */
23059
- source: object({
23060
- capName: string(),
23061
- deviceId: number()
23062
- })
23063
- });
23064
- /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
23065
- var EventKindsForDeviceSchema = object({
23066
- deviceId: number(),
23067
- kinds: array(EventKindDescriptorSchema).readonly()
23068
- });
23069
- var SensorEventSchema = object({
23070
- id: string(),
23071
- /** The CAMERA the event is attributed to (a sensor linked to N cameras
23072
- * yields N rows, one per camera). */
23073
- deviceId: number(),
23074
- /** The linked sensor device whose state changed. */
23075
- sourceDeviceId: number(),
23076
- /** Event kind id — matches an `EventKindDescriptor.kind`. */
23077
- kind: string(),
23078
- /** Snapshot of the sensor cap's runtime-state slice at the change. */
23079
- value: record(string(), unknown()).nullable(),
23080
- timestamp: number()
23081
- });
23082
- /**
23083
- * One stored sighting on a track's trajectory.
23084
- *
23085
- * The array these live in is returned in TIME order (D399) — it is APPENDED in
23086
- * arrival order, and the two detector passes interleave, so a consumer must not
23087
- * assume the two are the same on a row written by an older build.
23088
- */
23089
- var TrackPositionSchema = object({
23090
- x: number(),
23091
- y: number(),
23092
- timestamp: number(),
23093
- bbox: BoundingBoxSchema,
23094
- /**
23095
- * Which detector pass measured this box (D399): `frame` is the full-frame
23096
- * pass on the analysis raster, `recovery` is the native-resolution
23097
- * small-subject second pass (D377/D378). Both write into one array, and until
23098
- * this field existed the only way to tell them apart was that full-frame boxes
23099
- * are exact multiples of 1.2 while recovery boxes are full-precision floats.
23100
- * Absent on rows written before D399.
23101
- */
23102
- source: _enum(["frame", "recovery"]).optional(),
23103
- /** Detection score of this box, so a position can be weighed and not only
23104
- * plotted. Absent on rows written before D399. */
23105
- score: number().optional()
23106
- });
23107
- var TrackSnapshotSchema = object({
23108
- timestamp: number(),
23109
- position: TrackPositionSchema,
23110
- /** The snapshot's media row id (D482); resolve via `listTrackMedia({ trackId })`. */
23111
- mediaId: number().int()
23112
- });
23113
- /**
23114
- * Normalized 0..1 trajectory envelope (min/max over every position bbox,
23115
- * divided by the track's detection-frame dims), computed at persist time.
23116
- * Absent when the frame dims were unknown when the track was persisted
23117
- * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
23118
- */
23119
- var TrackEnvelopeSchema = object({
23120
- minX: number(),
23121
- minY: number(),
23122
- maxX: number(),
23123
- maxY: number()
23124
- });
23125
- /**
23126
- * Row projection for track list queries. `full` (default) returns the
23127
- * complete Track including the frame-rate `positions[]` history and the
23128
- * `snapshots[]` references — megabytes across a page of tracks. `slim`
23129
- * keeps every scalar the list surfaces actually render (ids, class(es),
23130
- * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
23131
- * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
23132
- * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
23133
- * `getTrack`. Mirrors the event-store `projection` convention
23134
- * (`getObjectEvents` et al.).
23135
- */
23136
- var TrackProjectionSchema = _enum(["full", "slim"]);
23137
- /**
23138
- * One audio-classification label heard on the track's camera while the
23139
- * track was alive, aggregated per label. An "episode" is one persisted
23140
- * audio event (the confident-classification path: score ≥ the device's
23141
- * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
23142
- * one 32 ms inference chunk, so counts stay human-scaled.
23143
- */
23144
- var TrackAudioLabelSchema = object({
23145
- label: string(),
23146
- /** Highest classification score observed across the label's episodes. */
23147
- peakScore: number(),
23148
- /** Number of coalesced audio-event episodes carrying this label. */
23149
- count: number(),
23150
- firstAt: number(),
23151
- lastAt: number()
23152
- });
23153
- /**
23154
- * How a track was produced. `pipeline` (default / absent) = the spatial
23155
- * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
23156
- * no positions, a single snapshot, and no bbox trajectory at all:
23157
- *
23158
- * - `sensor` — a linked sensor/control device state change.
23159
- * - `audio` — an audio event on the camera itself that was anomalous for
23160
- * THAT camera, loud, and heard while nothing visual was happening (D62).
22583
+ * - `sensor` — a linked sensor/control device state change.
22584
+ * - `audio` — an audio event on the camera itself that was anomalous for
22585
+ * THAT camera, loud, and heard while nothing visual was happening (D62).
23161
22586
  *
23162
22587
  * - `onboard` — the CAMERA's own firmware, paired with a decoded frame in
23163
22588
  * that frame's pixel space. A real root detector and a SPATIAL one: its
@@ -23539,6 +22964,22 @@ var TrackSchema = object({
23539
22964
  * omit it. Render nothing when absent.
23540
22965
  */
23541
22966
  previewMissReason: string().optional(),
22967
+ /**
22968
+ * The ROOT model that produced this track — the `FrameResult.rootModelId` of
22969
+ * the frame it was BORN on (D646). What a later replay compares against, so
22970
+ * "the original model" is named rather than assumed. A birth fact: never
22971
+ * rewritten by a later frame. **Absent ≠ unknown-model**: a row from before
22972
+ * the column, and a track the camera's own detector produced, carry none.
22973
+ */
22974
+ modelId: string().optional(),
22975
+ /**
22976
+ * Size (px) of the detection frame this track's `positions[].bbox` live in —
22977
+ * the frame it was born on, else the camera's latest analysis frame at
22978
+ * persist time. Divide a position by these to normalise it. Absent when the
22979
+ * size was never known.
22980
+ */
22981
+ frameWidth: number().optional(),
22982
+ frameHeight: number().optional(),
23542
22983
  ...TrackFlagFields,
23543
22984
  ...TrackRetrainFields
23544
22985
  });
@@ -24545,24 +23986,6 @@ var MediaReclaimStatusSchema = object({
24545
23986
  finishedAtMs: number().nullable(),
24546
23987
  error: string().nullable()
24547
23988
  });
24548
- var ReplayFrameInputSchema = object({
24549
- timestamp: number(),
24550
- frame: PipelineRunResultBridge
24551
- });
24552
- var RunReplayFrameProcessorResultSchema = object({ tracks: array(object({
24553
- className: string(),
24554
- firstSeenMs: number(),
24555
- lastSeenMs: number(),
24556
- /** Bbox of the track's FIRST matched detection, pixel-space in the clip's
24557
- * frame — a representative box for the diff's `(className, window, IoU)`
24558
- * pairing (`replay-diff.ts`). A replay does not need the full per-frame
24559
- * trajectory production's `Track.positions` keeps. */
24560
- bbox: BoundingBoxSchema,
24561
- /** How many of the input frames this track matched a real detection on
24562
- * (never a coasted/extrapolated frame) — the replay's own signal for "how
24563
- * solid is this track", cheaper than re-deriving it from a trajectory. */
24564
- framesMatched: number().int()
24565
- })).readonly() });
24566
23989
  /**
24567
23990
  * The long-term series a camera produces. A closed union so a typo cannot
24568
23991
  * invent one, and the ONE declaration of it — the addon's `AnalyticsLtsSeries`
@@ -25151,392 +24574,1034 @@ var pipelineAnalyticsCapability = {
25151
24574
  * VERBATIM under `tracks/<deviceId>/<trackId>/…`. No crop is derived and no
25152
24575
  * model is run: a training set's pixels must be the pixels the pipeline saw.
25153
24576
  */
25154
- getTrainingExportUrl: method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
24577
+ getTrainingExportUrl: method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
24578
+ kind: "query",
24579
+ auth: "admin"
24580
+ }),
24581
+ /**
24582
+ * The staging worklist for one camera, or for every camera that has one.
24583
+ *
24584
+ * Fetched ON DEMAND, over the staging set only — the page never scans
24585
+ * history, because making the working set small is the entire purpose of
24586
+ * the mark. Each row carries how many frames the dataset already holds from
24587
+ * the track and how many subjects were annotated on them, so
24588
+ * `frameCount: 0` reads as "still to work" without a second call per track.
24589
+ *
24590
+ * `auth: 'admin'`, unlike the viewer-level mark itself: marking a track is
24591
+ * curation you do while looking at it, but building the training set the
24592
+ * fleet's models are fine-tuned on is not.
24593
+ */
24594
+ listRetrainStaging: method(object({
24595
+ /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
24596
+ * `deviceId`, deliberately: `deviceId` would make this device-bound and
24597
+ * route it at one camera's owner, and "every camera" would stop being
24598
+ * expressible at all. */
24599
+ deviceIds: array(number()).optional(),
24600
+ limit: number().int().min(1).max(500).optional()
24601
+ }), array(RetrainTrackSchema).readonly(), {
24602
+ kind: "query",
24603
+ auth: "admin"
24604
+ }),
24605
+ /**
24606
+ * What a track can contribute, and what it already has.
24607
+ *
24608
+ * `candidates` are the track's whole, unannotated frames — index rows only,
24609
+ * so this is cheap. `copies` are the frames already inside the dataset, and
24610
+ * a candidate whose copy exists is marked `copied: true`: selecting it again
24611
+ * is free and CANNOT fail, whatever became of the original.
24612
+ *
24613
+ * A crop, a thumbnail and `fullFrameBoxed` are never candidates. The last
24614
+ * one matters most: it has the model's own rectangle burned into the pixels,
24615
+ * and a detector trained on it learns to find a green line.
24616
+ */
24617
+ listRetrainFrames: method(object({ trackId: string() }), RetrainFrameListSchema, {
24618
+ kind: "query",
24619
+ auth: "admin"
24620
+ }),
24621
+ /**
24622
+ * COPY-ON-SELECT — the write that makes `trained` safe to evict.
24623
+ *
24624
+ * Selecting a frame copies its bytes into retrain storage immediately: not
24625
+ * a reference, not a lease. Once the copy exists the dataset no longer
24626
+ * depends on the track's media, which is exactly what lets D81 hand a
24627
+ * `trained` track back to retention.
24628
+ *
24629
+ * The order inside is load-bearing and is pinned by a test: an EXISTING
24630
+ * copy is returned without touching the source, so an original that
24631
+ * evaporated blocks the selection of THAT ORIGINAL and never the copy
24632
+ * already taken. Every refusal comes back named — a dropped selection is
24633
+ * never silent, on the wire or in the log.
24634
+ */
24635
+ selectRetrainFrames: method(object({
24636
+ deviceId: number(),
24637
+ trackId: string(),
24638
+ mediaIds: array(number().int()).min(1)
24639
+ }), RetrainFrameSelectionSchema, {
24640
+ kind: "mutation",
24641
+ auth: "admin"
24642
+ }),
24643
+ /** Un-select a frame: its annotations go first, then the copy and its blob.
24644
+ * Deliberately destructive and deliberately explicit — it is the only way
24645
+ * a frame leaves the dataset before export. */
24646
+ deselectRetrainFrame: method(object({
24647
+ deviceId: number(),
24648
+ trackId: string(),
24649
+ frameId: string()
24650
+ }), object({
24651
+ removed: boolean(),
24652
+ removedAnnotations: number().int()
24653
+ }), {
24654
+ kind: "mutation",
24655
+ auth: "admin"
24656
+ }),
24657
+ /**
24658
+ * The pixels of ONE copied frame, base64.
24659
+ *
24660
+ * Through the cap rather than a data plane because it is genuinely one
24661
+ * frame at a time, on demand, at human speed — the shape D9/D18 permit
24662
+ * (what they forbid is frames crossing a boundary at frame RATE). The
24663
+ * annotation canvas needs the image and its exact dimensions in the same
24664
+ * answer: a canvas that places a normalised box against a size it guessed
24665
+ * draws every box in the wrong place.
24666
+ */
24667
+ getRetrainFrameImage: method(object({ frameId: string() }), object({
24668
+ base64: string(),
24669
+ width: number().int(),
24670
+ height: number().int()
24671
+ }), {
24672
+ kind: "query",
24673
+ auth: "admin"
24674
+ }),
24675
+ /**
24676
+ * Ask the pipeline what it sees, as a PROPOSAL.
24677
+ *
24678
+ * Runs through `pipelineRunner.runStatelessStep` on the COPIED frame, and
24679
+ * every box comes back as a draft with `source: 'assist'` plus the model and
24680
+ * score that produced it. The operator confirms, edits, adds and deletes;
24681
+ * nothing is stored until `saveRetrainAnnotations`.
24682
+ *
24683
+ * For packages the request is `rfdetr-package` on the ZONE CROP at 0.35 —
24684
+ * never the whole frame, where a package detector at that threshold proposes
24685
+ * furniture. A package request with no zone is REFUSED rather than widened,
24686
+ * because the silent widening would look like a bad model for as long as
24687
+ * nobody checked which rectangle it ran on.
24688
+ */
24689
+ proposeRetrainAnnotations: method(object({
24690
+ deviceId: number(),
24691
+ trackId: string(),
24692
+ frameId: string(),
24693
+ subject: RetrainAssistSubjectSchema,
24694
+ /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
24695
+ nodeId: string().optional()
24696
+ }), RetrainAssistResultSchema, {
24697
+ kind: "mutation",
24698
+ auth: "admin"
24699
+ }),
24700
+ /** Every annotation on a track, oldest first. */
24701
+ listRetrainAnnotations: method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
24702
+ kind: "query",
24703
+ auth: "admin"
24704
+ }),
24705
+ /**
24706
+ * Replace EVERY annotation on one frame with the supplied set.
24707
+ *
24708
+ * Whole-frame replacement, not per-box upsert: the unit of ground truth is
24709
+ * the frame, and "the operator deleted a box" must be the same durable
24710
+ * outcome as "the operator never drew it". A per-box patch would let a frame
24711
+ * keep a box the operator removed on a surface that only knew about the
24712
+ * boxes it sent.
24713
+ *
24714
+ * Refuses a macro class typed into `label` or `subLabel` — the tiers are
24715
+ * separate and the guard is at the WRITE, because a mixed taxonomy cannot
24716
+ * be un-mixed by reading it.
24717
+ */
24718
+ saveRetrainAnnotations: method(object({
24719
+ deviceId: number(),
24720
+ trackId: string(),
24721
+ frameId: string(),
24722
+ annotations: array(RetrainAnnotationDraftSchema)
24723
+ }), array(RetrainAnnotationSchema).readonly(), {
24724
+ kind: "mutation",
24725
+ auth: "admin"
24726
+ }),
24727
+ /**
24728
+ * Finish with a track: `staging → trained`. **The only writer of that
24729
+ * state** — D81 shipped the column with it deliberately unreachable.
24730
+ *
24731
+ * Refuses a track the dataset holds no copies from. `trained` un-pins the
24732
+ * track's media, so completing without a copy is a delete order for material
24733
+ * nothing ever extracted anything from; that refusal IS the safety argument
24734
+ * of D81, expressed as a precondition.
24735
+ */
24736
+ completeRetrainTrack: method(object({
24737
+ deviceId: number(),
24738
+ trackId: string()
24739
+ }), RetrainTransitionResultSchema, {
24740
+ kind: "mutation",
24741
+ auth: "admin"
24742
+ }),
24743
+ /**
24744
+ * The deliberate return: `trained → staging`, for the rare case.
24745
+ *
24746
+ * The generic `setTrackFlags` toggle refuses this in both directions by
24747
+ * design (D81) — re-staging from a checkbox is how the same material gets
24748
+ * annotated twice under two ground truths. Doing it here means the operator
24749
+ * is looking at the annotations that already exist while they decide, and
24750
+ * those annotations are LEFT ALONE: "put this back" must not be a
24751
+ * destructive act wearing a navigational name.
24752
+ */
24753
+ restageRetrainTrack: method(object({
24754
+ deviceId: number(),
24755
+ trackId: string()
24756
+ }), RetrainTransitionResultSchema, {
24757
+ kind: "mutation",
24758
+ auth: "admin"
24759
+ }),
24760
+ /**
24761
+ * Where to download the ANNOTATED dataset.
24762
+ *
24763
+ * The sibling of `getTrainingExportUrl` and deliberately not the same
24764
+ * archive: that one streams a marked track's stored media verbatim, this one
24765
+ * streams the retrain COPIES plus an `annotations.json` carrying, for every
24766
+ * subject, the canonical full-frame box AND the geometry derived for each
24767
+ * model shape (letterboxed root / zone-cropped package / subject-cropped
24768
+ * classifier). Derived at export, never stored — one box in, three shapes
24769
+ * out, so two crops of the same subject can never end up in one feature
24770
+ * space (D52).
24771
+ */
24772
+ getRetrainExportUrl: method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
25155
24773
  kind: "query",
25156
24774
  auth: "admin"
25157
24775
  }),
25158
24776
  /**
25159
- * The staging worklist for one camera, or for every camera that has one.
24777
+ * The media an EVENT owns.
25160
24778
  *
25161
- * Fetched ON DEMAND, over the staging set only — the page never scans
25162
- * history, because making the working set small is the entire purpose of
25163
- * the mark. Each row carries how many frames the dataset already holds from
25164
- * the track and how many subjects were annotated on them, so
25165
- * `frameCount: 0` reads as "still to work" without a second call per track.
24779
+ * `ownerType` is REQUIRED, and that is the whole correction (D482). An
24780
+ * event is a row in ONE of three tables, and since D474 each numbers from
24781
+ * 1 independently: `motion:101314` and `object:101314` both exist. This
24782
+ * method took a bare `eventId` and the provider probed motion → object →
24783
+ * audio, stopping at the first hit — so on the live hub, where object
24784
+ * events own no media of their own and 299 883 of 300 559 media rows are
24785
+ * motion-owned, EVERY object event resolved to its motion namesake. A
24786
+ * track from 17:34 on camera 615 was served a snapshot from 22:35 eleven
24787
+ * days earlier, silently.
25166
24788
  *
25167
- * `auth: 'admin'`, unlike the viewer-level mark itself: marking a track is
25168
- * curation you do while looking at it, but building the training set the
25169
- * fleet's models are fine-tuned on is not.
24789
+ * D476 had already disambiguated the KEY (`motion:` vs `object:`); this is
24790
+ * the API catching up to it. Naming the table is not a "qualification" of
24791
+ * the ambiguity — a listing BY OWNER has no address to make surrogate: the
24792
+ * owner IS (table, id), and half of it is not a question.
25170
24793
  */
25171
- listRetrainStaging: method(object({
25172
- /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
25173
- * `deviceId`, deliberately: `deviceId` would make this device-bound and
25174
- * route it at one camera's owner, and "every camera" would stop being
25175
- * expressible at all. */
25176
- deviceIds: array(number()).optional(),
25177
- limit: number().int().min(1).max(500).optional()
25178
- }), array(RetrainTrackSchema).readonly(), {
25179
- kind: "query",
25180
- auth: "admin"
25181
- }),
24794
+ getEventMedia: method(object({
24795
+ /** Which of the three event tables owns the row. */
24796
+ ownerType: EventOwnerTypeSchema,
24797
+ /** The event's rowid in that table (D474: an event id is a number). */
24798
+ eventId: number().int(),
24799
+ kind: MediaFileKindEnum.optional(),
24800
+ deviceId: number()
24801
+ }), array(MediaFileSchema).readonly()),
24802
+ /** All media rows owned by a track. `kinds` narrows to a kind subset so a
24803
+ * client can fetch the SMALL display variants on open and pull the
24804
+ * multi-MB native variants only on demand (mirrors `getEventMedia.kind`).
24805
+ * Absent ⇒ every kind (back-compat). */
24806
+ getTrackMedia: method(object({
24807
+ trackId: string(),
24808
+ kinds: array(MediaFileKindEnum).optional(),
24809
+ deviceId: number()
24810
+ }), array(MediaFileSchema).readonly()),
25182
24811
  /**
25183
- * What a track can contribute, and what it already has.
24812
+ * What media a track HAS, without any of it.
25184
24813
  *
25185
- * `candidates` are the track's whole, unannotated frames — index rows only,
25186
- * so this is cheap. `copies` are the frames already inside the dataset, and
25187
- * a candidate whose copy exists is marked `copied: true`: selecting it again
25188
- * is free and CANNOT fail, whatever became of the original.
24814
+ * The detail view needs the shape of a track's media to build its strip —
24815
+ * which kinds exist, in what order, at what size — and then wants each tile
24816
+ * fetched as an image, not as base64 inside this response. Measured: the
24817
+ * full `getTrackMedia` is 5.3-7.7 MB and blocks the view; this manifest is
24818
+ * ~2 KB.
25189
24819
  *
25190
- * A crop, a thumbnail and `fullFrameBoxed` are never candidates. The last
25191
- * one matters most: it has the model's own rectangle burned into the pixels,
25192
- * and a detector trained on it learns to find a green line.
24820
+ * It also restores a fact a `kinds` filter destroys: filtering
24821
+ * `getTrackMedia` drops whole ROWS, taking `kind` and `sizeBytes` with
24822
+ * them, so a client that fetched only the small variants could no longer
24823
+ * tell a full-resolution variant existed — and the affordance that opens it
24824
+ * would silently disappear.
25193
24825
  */
25194
- listRetrainFrames: method(object({ trackId: string() }), RetrainFrameListSchema, {
25195
- kind: "query",
25196
- auth: "admin"
25197
- }),
24826
+ listTrackMedia: method(object({
24827
+ trackId: string(),
24828
+ deviceId: number()
24829
+ }), array(MediaFileInfoSchema).readonly()),
25198
24830
  /**
25199
- * COPY-ON-SELECT — the write that makes `trained` safe to evict.
24831
+ * What media an EVENT has, without any of it — the twin `getEventMedia`
24832
+ * never had.
25200
24833
  *
25201
- * Selecting a frame copies its bytes into retrain storage immediately: not
25202
- * a reference, not a lease. Once the copy exists the dataset no longer
25203
- * depends on the track's media, which is exactly what lets D81 hand a
25204
- * `trained` track back to retention.
24834
+ * `listTrackMedia` above got this treatment because a track's media is
24835
+ * 5-8 MB. An event's is worse per row, not better: an old-style event owns
24836
+ * a `crop` AND a native-resolution `fullFrameBoxed`, and the track DETAIL
24837
+ * modal — the one surface that legitimately shows the big kinds — unions
24838
+ * both listings to build its filmstrip. It then renders every tile from
24839
+ * the `event-media` plane by key and throws the bytes away. Measured on
24840
+ * the live hub: one event's `fullFrameBoxed` is 2 824 077 B, base64'd to
24841
+ * ~3.8 MB, allocated whole in hub-main's heap, for a list of keys.
25205
24842
  *
25206
- * The order inside is load-bearing and is pinned by a test: an EXISTING
25207
- * copy is returned without touching the source, so an original that
25208
- * evaporated blocks the selection of THAT ORIGINAL and never the copy
25209
- * already taken. Every refusal comes back named — a dropped selection is
25210
- * never silent, on the wire or in the log.
24843
+ * Same `deviceId` authorization subject as `getEventMedia`, the same
24844
+ * REQUIRED `ownerType` (read that method's docblock for the night-time
24845
+ * thumbnail this closes — D482), and the same rows: this is a projection
24846
+ * of that method, never a different question.
25211
24847
  */
25212
- selectRetrainFrames: method(object({
24848
+ listEventMedia: method(object({
24849
+ ownerType: EventOwnerTypeSchema,
24850
+ eventId: number().int(),
24851
+ deviceId: number()
24852
+ }), array(MediaFileInfoSchema).readonly()),
24853
+ /**
24854
+ * Which of `ownerIds` hold at least ONE media row — an INDEX read, never a
24855
+ * blob read, and the LICENCE `videoclips` needs to publish a `thumbnail`.
24856
+ *
24857
+ * The event-media URL is stamped from a template for every event in the
24858
+ * system, so "the plane is up" was being served as "there are bytes": 64 of
24859
+ * one camera's 179 clips pointed at a 404 (device 3836, 2026-08-17). This
24860
+ * is the question that turns the stamp into a claim.
24861
+ *
24862
+ * It is on the WIRE because the clip source is registered by the addon that
24863
+ * owns the FOOTAGE, not by this one (D560) — the probe used to be an
24864
+ * in-process `MediaStore` read. One call per OWNER KIND, never one per
24865
+ * owner: that N+1 is what `MediaStore.ownersWithMedia` was written to
24866
+ * prevent, and crossing a process boundary makes it worse, not better.
24867
+ * `ownerIds` is bounded at the same 5 000 the annotation fetch is bounded
24868
+ * at, so one pathological camera-day cannot mint an unbounded request.
24869
+ *
24870
+ * THROWS rather than answering partially. A probe that quietly
24871
+ * under-reports reads as "these owners have nothing" and the caller drops
24872
+ * thumbnails that exist — the opposite failure to the one above, and
24873
+ * equally invisible.
24874
+ *
24875
+ * `deviceId` is the authorization subject, exactly as on `getEventMedia`.
24876
+ */
24877
+ ownersWithMedia: method(object({
25213
24878
  deviceId: number(),
25214
- trackId: string(),
25215
- mediaIds: array(number().int()).min(1)
25216
- }), RetrainFrameSelectionSchema, {
24879
+ ownerKind: MediaPresenceOwnerKindSchema,
24880
+ ownerIds: array(string()).max(5e3)
24881
+ }), array(string()).readonly()),
24882
+ /**
24883
+ * Search object events by text query using CLIP cosine similarity.
24884
+ * Encodes `text` via the `embedding-encoder` cap, queries the
24885
+ * `ObjectEmbeddingStore` with optional prefilters, ranks all matching
24886
+ * embeddings by cosine similarity, and joins winners to their
24887
+ * ObjectEvents by trackId. Returns up to `limit` events scored ≥
24888
+ * `minScore`, sorted descending by score.
24889
+ */
24890
+ searchObjectEvents: method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()),
24891
+ wipeObjectEmbeddings: method(object({}), WipeObjectEmbeddingsResultSchema, {
25217
24892
  kind: "mutation",
25218
24893
  auth: "admin"
25219
24894
  }),
25220
- /** Un-select a frame: its annotations go first, then the copy and its blob.
25221
- * Deliberately destructive and deliberately explicit — it is the only way
25222
- * a frame leaves the dataset before export. */
25223
- deselectRetrainFrame: method(object({
25224
- deviceId: number(),
25225
- trackId: string(),
25226
- frameId: string()
25227
- }), object({
25228
- removed: boolean(),
25229
- removedAnnotations: number().int()
25230
- }), {
24895
+ rebuildObjectEmbeddings: method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
25231
24896
  kind: "mutation",
25232
24897
  auth: "admin"
25233
24898
  }),
24899
+ getObjectEmbeddingRebuildStatus: method(object({}), RebuildStatusSchema)
24900
+ },
24901
+ events: {
25234
24902
  /**
25235
- * The pixels of ONE copied frame, base64.
25236
- *
25237
- * Through the cap rather than a data plane because it is genuinely one
25238
- * frame at a time, on demand, at human speed — the shape D9/D18 permit
25239
- * (what they forbid is frames crossing a boundary at frame RATE). The
25240
- * annotation canvas needs the image and its exact dimensions in the same
25241
- * answer: a canvas that places a normalised box against a size it guessed
25242
- * draws every box in the wrong place.
24903
+ * Enriched frame emitted after refinement — the live-overlay source of
24904
+ * truth (two-plane re-injection). Carries the frame's detections in the
24905
+ * `ObjectDetection` wire shape: first-level roots (with track info +
24906
+ * enrichment labels) plus synthesized `kind:'detail'` face/plate entries
24907
+ * re-projected from per-track detail state, so stream overlays render
24908
+ * boxes + recognized names without querying full Track state.
25243
24909
  */
25244
- getRetrainFrameImage: method(object({ frameId: string() }), object({
25245
- base64: string(),
25246
- width: number().int(),
25247
- height: number().int()
25248
- }), {
25249
- kind: "query",
25250
- auth: "admin"
25251
- }),
25252
- /**
25253
- * Ask the pipeline what it sees, as a PROPOSAL.
25254
- *
25255
- * Runs through `pipelineRunner.runStatelessStep` on the COPIED frame, and
25256
- * every box comes back as a draft with `source: 'assist'` plus the model and
25257
- * score that produced it. The operator confirms, edits, adds and deletes;
25258
- * nothing is stored until `saveRetrainAnnotations`.
25259
- *
25260
- * For packages the request is `rfdetr-package` on the ZONE CROP at 0.35 —
25261
- * never the whole frame, where a package detector at that threshold proposes
25262
- * furniture. A package request with no zone is REFUSED rather than widened,
25263
- * because the silent widening would look like a bad model for as long as
25264
- * nobody checked which rectangle it ran on.
24910
+ onFrameTracked: { data: object({
24911
+ deviceId: number(),
24912
+ timestamp: number(),
24913
+ frameWidth: number(),
24914
+ frameHeight: number(),
24915
+ detections: array(OverlayDetectionSchema).readonly()
24916
+ }) },
24917
+ /** Track entered active state (first-seen). */
24918
+ onTrackStarted: { data: object({
24919
+ deviceId: number(),
24920
+ trackId: string(),
24921
+ className: string()
24922
+ }) },
24923
+ /** Track expired (TTL reached after last detection). */
24924
+ onTrackEnded: { data: object({
24925
+ deviceId: number(),
24926
+ trackId: string(),
24927
+ className: string(),
24928
+ durationMs: number()
24929
+ }) },
24930
+ /** Canonical "something happened at device X" event, per-kind. */
24931
+ onDetectionEvent: { data: object({
24932
+ deviceId: number(),
24933
+ kind: EventKindSchema,
24934
+ eventId: string(),
24935
+ timestamp: number()
24936
+ }) }
24937
+ }
24938
+ };
24939
+ /**
24940
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
24941
+ * within the frame, so the executor can re-cut a leaf child ROI at native
24942
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
24943
+ */
24944
+ var NativeCropRefSchema = object({
24945
+ /** Handle keying the retained native surface (node-pinned to its owner). */
24946
+ handle: FrameHandleSchema,
24947
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
24948
+ cropFrameSpace: object({
24949
+ x: number(),
24950
+ y: number(),
24951
+ w: number(),
24952
+ h: number()
24953
+ })
24954
+ });
24955
+ object({
24956
+ crop: object({
24957
+ left: number(),
24958
+ top: number(),
24959
+ width: number().positive(),
24960
+ height: number().positive()
24961
+ }).optional(),
24962
+ content: object({
24963
+ width: number().int().positive(),
24964
+ height: number().int().positive()
24965
+ }),
24966
+ fit: _enum(["stretch", "contain"]),
24967
+ format: _enum([
24968
+ "rgb",
24969
+ "gray",
24970
+ "jpeg"
24971
+ ])
24972
+ });
24973
+ /**
24974
+ * Process-local frame identity. It is serializable so it can ride an in-process
24975
+ * capability call, but `registryId` deliberately prevents resolution in any
24976
+ * other process or execution group.
24977
+ */
24978
+ var FrameRefSchema = object({
24979
+ registryId: string().min(1),
24980
+ id: string().min(1),
24981
+ width: number().int().positive(),
24982
+ height: number().int().positive(),
24983
+ format: _enum(["rgb", "gray"]),
24984
+ timestamp: number(),
24985
+ capturedAt: number().optional()
24986
+ });
24987
+ var ModelFormatSchema$1 = _enum([
24988
+ "onnx",
24989
+ "coreml",
24990
+ "openvino",
24991
+ "tflite",
24992
+ "pt",
24993
+ "gguf"
24994
+ ]);
24995
+ var PipelineSlotSchema = _enum([
24996
+ "detector",
24997
+ "cropper",
24998
+ "classifier",
24999
+ "refiner",
25000
+ "audio-classifier"
25001
+ ]);
25002
+ var PipelineEngineChoiceSchema = object({
25003
+ runtime: literal("python"),
25004
+ backend: string(),
25005
+ format: ModelFormatSchema$1,
25006
+ device: string().optional()
25007
+ });
25008
+ /**
25009
+ * One pool's resolved provisioning (`getEffectiveTuning`). `numWorkers` is the
25010
+ * knob that lifts a saturated pool (`inference-devices.md`); `concurrency` is
25011
+ * per-worker in-flight requests. `deviceKey` echoes the pool asked about —
25012
+ * `null` for the node-default pool.
25013
+ */
25014
+ var EffectiveTuningSchema = object({
25015
+ deviceKey: string().nullable(),
25016
+ runtime: string(),
25017
+ batchMode: string(),
25018
+ windowMs: number(),
25019
+ maxBatchSize: number(),
25020
+ concurrency: number(),
25021
+ numWorkers: number()
25022
+ });
25023
+ var AvailableEngineSchema = object({
25024
+ engine: PipelineEngineChoiceSchema,
25025
+ devices: array(object({
25026
+ id: string(),
25027
+ label: string(),
25028
+ description: string().optional()
25029
+ })).readonly(),
25030
+ defaultDevice: string()
25031
+ });
25032
+ var PipelineDefaultStepSchema = lazy(() => object({
25033
+ addonId: string(),
25034
+ addonName: string(),
25035
+ slot: PipelineSlotSchema,
25036
+ inputClasses: array(string()).readonly(),
25037
+ outputClasses: array(string()).readonly(),
25038
+ enabled: boolean(),
25039
+ modelId: string(),
25040
+ children: array(PipelineDefaultStepSchema).readonly(),
25041
+ group: string().optional(),
25042
+ settings: record(string(), unknown()).optional()
25043
+ }));
25044
+ var PipelineTemplateStepSchema = lazy(() => object({
25045
+ addonId: string(),
25046
+ enabled: boolean(),
25047
+ modelId: string(),
25048
+ children: array(PipelineTemplateStepSchema).readonly(),
25049
+ settings: record(string(), unknown()).optional()
25050
+ }));
25051
+ var PipelineTemplateSchema$1 = object({
25052
+ id: string(),
25053
+ name: string(),
25054
+ createdAt: string(),
25055
+ updatedAt: string(),
25056
+ engine: PipelineEngineChoiceSchema,
25057
+ steps: array(PipelineTemplateStepSchema).readonly()
25058
+ });
25059
+ var PipelineModelOptionSchema = object({
25060
+ id: string(),
25061
+ name: string(),
25062
+ formats: record(string(), object({
25063
+ downloaded: boolean(),
25064
+ sizeMB: number()
25065
+ })),
25066
+ group: ModelVariantGroupSchema.optional(),
25067
+ legacy: boolean().optional(),
25068
+ provider: ModelProviderIdSchema.optional()
25069
+ });
25070
+ var ConfigFieldBridge = custom();
25071
+ var PipelineAddonSchemaSchema = object({
25072
+ id: string(),
25073
+ name: string(),
25074
+ slot: PipelineSlotSchema,
25075
+ inputClasses: array(string()).readonly(),
25076
+ outputClasses: array(string()).readonly(),
25077
+ childSlots: array(PipelineSlotSchema).readonly(),
25078
+ models: array(PipelineModelOptionSchema).readonly(),
25079
+ defaultModelId: string(),
25080
+ defaultModelIdByFormat: record(string(), string()).optional(),
25081
+ enabledByDefault: boolean().optional(),
25082
+ backfillIntoExistingOverrides: boolean().optional(),
25083
+ defaultConfidence: number(),
25084
+ group: string().optional(),
25085
+ configSchema: array(ConfigFieldBridge).readonly().optional()
25086
+ });
25087
+ var PipelineSlotSchemaSchema = object({
25088
+ id: PipelineSlotSchema,
25089
+ label: string(),
25090
+ priority: number(),
25091
+ parentSlot: PipelineSlotSchema.nullable(),
25092
+ addons: array(PipelineAddonSchemaSchema).readonly()
25093
+ });
25094
+ var PipelineSchemaSchema = object({
25095
+ availableEngines: array(AvailableEngineSchema).readonly(),
25096
+ selectedEngine: PipelineEngineChoiceSchema,
25097
+ slots: array(PipelineSlotSchemaSchema).readonly()
25098
+ });
25099
+ var EngineProvisioningSchema = object({
25100
+ runtimeId: _enum([
25101
+ "onnx",
25102
+ "openvino",
25103
+ "coreml",
25104
+ "edgetpu"
25105
+ ]).nullable(),
25106
+ device: string().nullable(),
25107
+ state: _enum([
25108
+ "idle",
25109
+ "installing",
25110
+ "verifying",
25111
+ "ready",
25112
+ "failed"
25113
+ ]),
25114
+ progress: number().optional(),
25115
+ error: string().optional(),
25116
+ nextRetryAt: number().optional(),
25117
+ /**
25118
+ * Gate A (config-correctness gate at engine change): human-readable
25119
+ * config issues surfaced EAGERLY when the node's engine changes — model
25120
+ * substitutions ("chose X, running Y") and zero-build steps ("no model
25121
+ * has a <format> build"). Additive/optional: informational only, never
25122
+ * enforced here — `assertEngineReady` (readiness) still gates inference.
25123
+ * Absent/empty when the node-default tree resolves cleanly.
25124
+ */
25125
+ configIssues: array(string()).optional()
25126
+ });
25127
+ var PipelineStepInputSchema = lazy(() => object({
25128
+ addonId: string(),
25129
+ modelId: string().optional(),
25130
+ enabled: boolean().default(true),
25131
+ children: array(PipelineStepInputSchema).optional(),
25132
+ settings: record(string(), unknown()).optional(),
25133
+ jumpDeviceKey: string().optional()
25134
+ }));
25135
+ var ModelSubstitutionSchema = object({
25136
+ addonId: string(),
25137
+ chosen: string(),
25138
+ running: string(),
25139
+ format: string()
25140
+ });
25141
+ var PipelineValidationIssueSchema = object({
25142
+ addonId: string(),
25143
+ kind: _enum([
25144
+ "unknown-addon",
25145
+ "no-format-build",
25146
+ "unknown-device"
25147
+ ]),
25148
+ detail: string()
25149
+ });
25150
+ var PipelineValidationResultSchema = object({
25151
+ ok: boolean(),
25152
+ issues: array(PipelineValidationIssueSchema).readonly(),
25153
+ substitutions: array(ModelSubstitutionSchema).readonly(),
25154
+ /** The node's `currentEngine.format` this validation ran against. */
25155
+ format: string()
25156
+ });
25157
+ var ReferenceImageEntrySchema = object({
25158
+ filename: string(),
25159
+ stepIds: array(string()).readonly().optional()
25160
+ });
25161
+ var ReferenceImageBodySchema = object({
25162
+ base64: string(),
25163
+ filename: string()
25164
+ });
25165
+ var ReferenceAudioEntrySchema = object({
25166
+ filename: string(),
25167
+ sizeKb: number()
25168
+ });
25169
+ var ReferenceAudioBodySchema = object({ base64: string() });
25170
+ var AudioBackendSchema = object({
25171
+ id: string(),
25172
+ name: string(),
25173
+ description: string(),
25174
+ available: boolean(),
25175
+ /**
25176
+ * Raw classifier labels this backend can emit (e.g. YAMNet's
25177
+ * 521-class set or Apple SoundAnalysis's 303-class set). Used by
25178
+ * the benchmark UI to populate the `enabledMicroClasses` filter
25179
+ * specific to the selected backend without a separate fetch.
25180
+ */
25181
+ rawLabels: array(string()).readonly().optional()
25182
+ });
25183
+ var AudioCapabilitiesSchema = object({
25184
+ activeBackend: string(),
25185
+ availableBackends: array(AudioBackendSchema).readonly(),
25186
+ sampleRate: number(),
25187
+ chunkDurationMs: number()
25188
+ });
25189
+ var DownloadModelResultSchema = object({
25190
+ filePath: string(),
25191
+ sizeMB: number(),
25192
+ durationMs: number()
25193
+ });
25194
+ /**
25195
+ * Wrapper carrying a single test run's result. Replaces the legacy
25196
+ * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
25197
+ * canonical `AudioResult` from the Phase 6 output rework: one
25198
+ * `AudioDetection` per class above `minScore`, top-N candidates in
25199
+ * `debug.alternateLabels['audio-classifier']`, per-source timings in
25200
+ * `debug.stepTimings`. The outer `success`/`error` fields stay so the
25201
+ * benchmark UI can still report a clean failure when the classifier
25202
+ * cap isn't available.
25203
+ */
25204
+ var AudioTestResultSchema = object({
25205
+ success: boolean(),
25206
+ error: string().optional(),
25207
+ frame: custom().optional()
25208
+ });
25209
+ var PipelineConfigBridge = custom();
25210
+ var ConfigUISchemaBridge = custom();
25211
+ var ConfigUISchemaNullableBridge = custom();
25212
+ var InferenceCapabilitiesBridge = custom();
25213
+ var ModelAvailabilityListBridge = custom();
25214
+ var PipelineRunResultBridge = custom();
25215
+ /**
25216
+ * Pipeline executor — detection engine + configuration + inference API.
25217
+ *
25218
+ * Merged from: pipeline-executor, pipeline-config, inference, detection-config.
25219
+ * Implemented by the detection-pipeline addon.
25220
+ *
25221
+ * Per-device surface (DeviceSettingsContribution + the "is detection
25222
+ * enabled for this camera?" toggle) lives on the paired
25223
+ * `detection-pipeline` cap (device-scoped, singleton, wrapper
25224
+ * defaultActive) — same split pattern used by stream-broker /
25225
+ * camera-streams and audio-analyzer / audio-analysis.
25226
+ */
25227
+ var pipelineExecutorCapability = {
25228
+ name: "pipeline-executor",
25229
+ scope: "system",
25230
+ mode: "singleton",
25231
+ methods: {
25232
+ getAvailableEngines: method(_void(), array(PipelineEngineChoiceSchema)),
25233
+ getSelectedEngine: method(_void(), PipelineEngineChoiceSchema),
25234
+ getDefaultSteps: method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)),
25235
+ /**
25236
+ * Per-node detection-engine provisioning snapshot. Returns the live
25237
+ * state of the lazy runtime-provisioning machine on `nodeId`
25238
+ * (idle / installing / verifying / ready / failed). The UI pairs this
25239
+ * one-shot query with the `pipeline.engine-provisioning` live event
25240
+ * (emitted on every transition) to drive a per-node "engine ready?"
25241
+ * indicator without polling. Phase 2.
25265
25242
  */
25266
- proposeRetrainAnnotations: method(object({
25267
- deviceId: number(),
25268
- trackId: string(),
25269
- frameId: string(),
25270
- subject: RetrainAssistSubjectSchema,
25271
- /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
25272
- nodeId: string().optional()
25273
- }), RetrainAssistResultSchema, {
25243
+ getEngineProvisioning: method(object({ nodeId: string() }), EngineProvisioningSchema),
25244
+ getVideoPipelineSteps: method(_void(), record(string(), object({
25245
+ modelId: string(),
25246
+ settings: record(string(), unknown()).readonly()
25247
+ }))),
25248
+ setVideoPipelineSteps: method(object({ steps: record(string(), object({
25249
+ modelId: string(),
25250
+ settings: record(string(), unknown()).readonly()
25251
+ })) }), object({ success: literal(true) }), {
25274
25252
  kind: "mutation",
25275
25253
  auth: "admin"
25276
25254
  }),
25277
25255
  /**
25278
- * The FrameProcessor pass of a replay run — see the `Replay` section
25279
- * above this capability's definition for why this is not the
25280
- * `processFrame` method this file's header says pipeline-analytics does
25281
- * not have.
25256
+ * Clear THIS node's executor-side PER-DEVICE settings stores (the
25257
+ * per-camera step overrides the object-detection root reads via
25258
+ * `applyDeviceOverridesToTree`). `nodeId` is the ROUTING key — the
25259
+ * generated cap-router strips it (default `nodeIdMode: 'routing'`) and
25260
+ * dispatches to that node, so the provider method runs ON the target
25261
+ * node and receives no `nodeId`.
25282
25262
  *
25283
- * Constructs a FRESH `FrameProcessor` for `(deviceId, source)`, feeds it
25284
- * `frames` IN THE ORDER GIVEN (the caller is responsible for time
25285
- * ordering — this method does not sort), and returns the tracks it
25286
- * produced. Zero persistence: no `TrackStore`, no event bus, no media
25287
- * capture. `zones` / `detectionRules` are the run's OWN zone set —
25288
- * typically the camera's real zones plus an ephemeral overlay
25289
- * (`addon-benchmark`'s `replay-plan.ts`), never read from or written to
25290
- * the `zones` capability by this method itself.
25263
+ * This is the slimmed executor leg of the orchestrator's
25264
+ * `resetNodePipelineDefaults` flow (which owns the real reset: node
25265
+ * addonDefaults pins + per-camera orchestrator overrides). The legacy
25266
+ * `resetToDefault` — which reset a persisted global step-tree seed
25267
+ * nothing in the live per-camera path read — was removed together with
25268
+ * that seed.
25291
25269
  */
25292
- runReplayFrameProcessor: method(object({
25293
- deviceId: number(),
25294
- source: DetectionSourceSchema,
25295
- zones: array(ZoneSchema).readonly().optional(),
25296
- detectionRules: array(ZoneRuleSchema).readonly().optional(),
25297
- zoneMembershipMinOverlap: number().min(0).max(1).optional(),
25298
- frames: array(ReplayFrameInputSchema).min(1)
25299
- }), RunReplayFrameProcessorResultSchema, {
25270
+ clearDeviceOverrides: method(object({ nodeId: string() }), object({
25271
+ success: literal(true),
25272
+ clearedDevices: number()
25273
+ }), {
25300
25274
  kind: "mutation",
25301
25275
  auth: "admin"
25302
25276
  }),
25303
- /** Every annotation on a track, oldest first. */
25304
- listRetrainAnnotations: method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
25305
- kind: "query",
25306
- auth: "admin"
25307
- }),
25308
25277
  /**
25309
- * Replace EVERY annotation on one frame with the supplied set.
25278
+ * Which of THIS node's inference devices the executor currently refuses,
25279
+ * and why. `nodeId` is the ROUTING key (stripped by the generated router).
25310
25280
  *
25311
- * Whole-frame replacement, not per-box upsert: the unit of ground truth is
25312
- * the frame, and "the operator deleted a box" must be the same durable
25313
- * outcome as "the operator never drew it". A per-box patch would let a frame
25314
- * keep a box the operator removed on a surface that only knew about the
25315
- * boxes it sent.
25281
+ * The channel that did not exist. Pool health was known only inside the
25282
+ * detection addon and was an input to no routing decision anywhere: the
25283
+ * per-dispatch capability gate is keyed on model FORMAT and so can never
25284
+ * separate `openvino:gpu` from `openvino:npu`, and the orchestrator's live
25285
+ * eligibility probe (`platformProbe.getCapabilities`) answers about
25286
+ * HARDWARE — which was present throughout. So when the hub's `openvino:gpu`
25287
+ * Python worker was SIGABRT'd by the Intel GPU plugin on 2026-08-25, the
25288
+ * balancer went on handing that dead pool cameras by rotation for 31 hours:
25289
+ * ~370 000 `PoolWorker[w0]: not initialized` lines, every frame lost.
25316
25290
  *
25317
- * Refuses a macro class typed into `label` or `subLabel` — the tiers are
25318
- * separate and the guard is at the WRITE, because a mixed taxonomy cannot
25319
- * be un-mixed by reading it.
25291
+ * Read semantics the caller depends on, and which the provider guarantees:
25292
+ * this is a synchronous read of in-memory state. It never probes hardware,
25293
+ * never spawns a pool and never throws — an EMPTY `unhealthy` means "asked,
25294
+ * nothing is refused", which is what re-admits a device. A read that FAILS
25295
+ * (node offline, version skew) must therefore be distinguishable from an
25296
+ * empty answer, and it is: it rejects.
25320
25297
  */
25321
- saveRetrainAnnotations: method(object({
25322
- deviceId: number(),
25323
- trackId: string(),
25324
- frameId: string(),
25325
- annotations: array(RetrainAnnotationDraftSchema)
25326
- }), array(RetrainAnnotationSchema).readonly(), {
25327
- kind: "mutation",
25328
- auth: "admin"
25329
- }),
25298
+ getInferenceDeviceHealth: method(object({ nodeId: string() }), object({ unhealthy: array(object({
25299
+ /** `<backend>:<device>`, e.g. `openvino:gpu`. */
25300
+ deviceKey: string(),
25301
+ /**
25302
+ * `failed` — the per-device restart budget is exhausted; no pool
25303
+ * will be spawned until an operator re-arms it or the runner
25304
+ * respawns. `backoff` — under budget, waiting out the backoff (or
25305
+ * a cached pool observed dead and not yet condemned).
25306
+ */
25307
+ state: _enum(["failed", "backoff"]),
25308
+ /** Epoch ms of the death that produced this state. */
25309
+ since: number(),
25310
+ /** Pool deaths inside the current window. */
25311
+ deaths: number(),
25312
+ /** The last death's message. */
25313
+ lastError: string()
25314
+ })).readonly() })),
25330
25315
  /**
25331
- * Finish with a track: `staging → trained`. **The only writer of that
25332
- * state** — D81 shipped the column with it deliberately unreachable.
25316
+ * Re-arm a terminally `failed` inference device on `nodeId`: forget its
25317
+ * restart budget so the next dispatch builds a fresh pool.
25333
25318
  *
25334
- * Refuses a track the dataset holds no copies from. `trained` un-pins the
25335
- * track's media, so completing without a copy is a delete order for material
25336
- * nothing ever extracted anything from; that refusal IS the safety argument
25337
- * of D81, expressed as a precondition.
25319
+ * The terminal state is deliberate (the abort it bounds is deterministic —
25320
+ * an automatic probation would just respawn Python forever, more slowly),
25321
+ * and a terminal state an operator cannot leave is a silent fault. This is
25322
+ * the way out. `rearmed:false` means there was nothing to forget.
25338
25323
  */
25339
- completeRetrainTrack: method(object({
25340
- deviceId: number(),
25341
- trackId: string()
25342
- }), RetrainTransitionResultSchema, {
25324
+ rearmInferenceDevice: method(object({
25325
+ nodeId: string(),
25326
+ deviceKey: string()
25327
+ }), object({ rearmed: boolean() }), {
25343
25328
  kind: "mutation",
25344
25329
  auth: "admin"
25345
25330
  }),
25331
+ getSchema: method(_void(), PipelineSchemaSchema),
25332
+ getGlobalSteps: method(_void(), array(PipelineDefaultStepSchema).readonly().nullable()),
25333
+ getGlobalPipelineConfig: method(_void(), PipelineConfigBridge),
25334
+ getOrchestratorConfigSchema: method(_void(), ConfigUISchemaBridge),
25346
25335
  /**
25347
- * The deliberate return: `trained → staging`, for the rare case.
25336
+ * Gate B (pre-init config-correctness gate). PURE COMPUTE against this
25337
+ * node's `currentEngine.format` — resolves `steps` the same way the
25338
+ * runtime dispatch path would, and reports what WOULD happen without
25339
+ * touching any node-global state. Called by the orchestrator at attach
25340
+ * time (`attachOn`), node-pinned to the TARGET node, so config problems
25341
+ * surface BEFORE `pipelineRunner.attachCamera` rather than at the first
25342
+ * per-frame resolve. `ok` is false iff `issues` is non-empty (both
25343
+ * `unknown-addon` and `no-format-build` are HARD issues); `substitutions`
25344
+ * is informational (a degraded-but-loadable model swap) and never
25345
+ * affects `ok`. Never throws.
25348
25346
  *
25349
- * The generic `setTrackFlags` toggle refuses this in both directions by
25350
- * design (D81) — re-staging from a checkbox is how the same material gets
25351
- * annotated twice under two ground truths. Doing it here means the operator
25352
- * is looking at the annotations that already exist while they decide, and
25353
- * those annotations are LEFT ALONE: "put this back" must not be a
25354
- * destructive act wearing a navigational name.
25347
+ * `deviceKey` validates against THAT device pool's format instead of the
25348
+ * node default (D646) — the cheap question a pinned replay asks before it
25349
+ * reads any media: can this (node, deviceKey) run exactly this model?
25355
25350
  */
25356
- restageRetrainTrack: method(object({
25357
- deviceId: number(),
25358
- trackId: string()
25359
- }), RetrainTransitionResultSchema, {
25360
- kind: "mutation",
25361
- auth: "admin"
25362
- }),
25351
+ validatePipeline: method(object({
25352
+ steps: array(PipelineStepInputSchema),
25353
+ deviceKey: string().optional()
25354
+ }), PipelineValidationResultSchema),
25355
+ listTemplates: method(_void(), array(PipelineTemplateSchema$1).readonly()),
25356
+ saveTemplate: method(object({
25357
+ name: string(),
25358
+ steps: array(PipelineTemplateStepSchema).readonly(),
25359
+ engine: PipelineEngineChoiceSchema
25360
+ }), PipelineTemplateSchema$1, { kind: "mutation" }),
25361
+ updateTemplate: method(object({
25362
+ id: string(),
25363
+ name: string().optional(),
25364
+ steps: array(PipelineTemplateStepSchema).readonly().optional()
25365
+ }), PipelineTemplateSchema$1, { kind: "mutation" }),
25366
+ deleteTemplate: method(object({ id: string() }), _void(), { kind: "mutation" }),
25367
+ getCapabilities: method(_void(), InferenceCapabilitiesBridge),
25368
+ getAddonModels: method(object({ addonId: string() }), ModelAvailabilityListBridge),
25369
+ downloadModel: method(object({
25370
+ addonId: string(),
25371
+ modelId: string(),
25372
+ format: ModelFormatSchema$1
25373
+ }), DownloadModelResultSchema, { kind: "mutation" }),
25374
+ deleteModel: method(object({
25375
+ addonId: string(),
25376
+ modelId: string(),
25377
+ format: ModelFormatSchema$1
25378
+ }), object({ success: literal(true) }), { kind: "mutation" }),
25363
25379
  /**
25364
- * Where to download the ANNOTATED dataset.
25380
+ * Stateless single-frame execution. Callers (runner, benchmark) pass
25381
+ * the complete `steps` tree; the executor holds no state about cameras
25382
+ * or saved pipelines. WHICH pool answers is the node's own engine, or the
25383
+ * `deviceKey` pool when one is named.
25365
25384
  *
25366
- * The sibling of `getTrainingExportUrl` and deliberately not the same
25367
- * archive: that one streams a marked track's stored media verbatim, this one
25368
- * streams the retrain COPIES plus an `annotations.json` carrying, for every
25369
- * subject, the canonical full-frame box AND the geometry derived for each
25370
- * model shape (letterboxed root / zone-cropped package / subject-cropped
25371
- * classifier). Derived at export, never stored — one box in, three shapes
25372
- * out, so two crops of the same subject can never end up in one feature
25373
- * space (D52).
25385
+ * There is no `engine` field (D646). It existed for the benchmark and was
25386
+ * honoured by swapping the SHARED provider's engine, factory and executor
25387
+ * for the duration of the call, on a node serving live cameras. A caller
25388
+ * that still sends the key has it stripped here and changes nothing.
25389
+ *
25390
+ * Exactly one of `frame`, `frameRef`, `frameHandle`, `imageBase64`,
25391
+ * `referenceImage` must be provided:
25392
+ * - `frame`: runtime dispatch path (runner → decoded broker frame).
25393
+ * Carries the raw buffer, dimensions, and format; the executor
25394
+ * uses it directly without base64 round-tripping.
25395
+ * - `frameHandle` (CB5): a zero-pixel shm `FrameHandle` for the SAME
25396
+ * decoded frame. Both runner and executor are hub-local processes
25397
+ * sharing `/dev/shm`, so the executor maps the named segment and
25398
+ * reads the pixels back zero-copy — eliminating the ~1.2MB
25399
+ * re-serialisation over UDS/MsgPack the `frame` path pays per call.
25400
+ * High-risk: the FrameRing is a latest-wins seqlock with no
25401
+ * refcount, so a recycled slot yields a null read; the executor
25402
+ * then degrades to an empty result and the runner ships pixels via
25403
+ * `frame` as the fallback (queue-depth gated on the runner side).
25404
+ * - `imageBase64`: one-shot test path (benchmark ImageTab).
25405
+ * - `referenceImage`: named file from the reference-image store.
25374
25406
  */
25375
- getRetrainExportUrl: method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
25376
- kind: "query",
25377
- auth: "admin"
25378
- }),
25407
+ runPipeline: method(object({
25408
+ steps: array(PipelineStepInputSchema).min(1),
25409
+ frame: FrameInputSchema.optional(),
25410
+ /**
25411
+ * Process-local lazy frame. Valid only when caller and provider resolve
25412
+ * in the same execution-group process; split/cross-node callers use
25413
+ * `frame`/`image` inline compatibility instead.
25414
+ */
25415
+ frameRef: FrameRefSchema.optional(),
25416
+ /**
25417
+ * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
25418
+ * the decoded pixels live in. One more member of the one-of
25419
+ * frame/frameHandle/image/imageBase64/referenceImage group.
25420
+ */
25421
+ frameHandle: FrameHandleSchema.optional(),
25422
+ imageBase64: string().optional(),
25423
+ /**
25424
+ * Binary JPEG bytes — preferred over `imageBase64` on internal
25425
+ * hops (hub → forked worker via Moleculer MsgPack) because it
25426
+ * skips the 33% base64 overhead + the per-call base64 decode on
25427
+ * the detection-pipeline worker. Callers can pass either; exactly
25428
+ * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
25429
+ */
25430
+ image: _instanceof(Uint8Array).optional(),
25431
+ referenceImage: string().optional(),
25432
+ deviceId: number().optional(),
25433
+ sessionId: string().optional(),
25434
+ /**
25435
+ * Execution plane. 'full' (default) runs the whole tree — benchmark,
25436
+ * reference-image, and detail-subtree calls. 'frame' is the live
25437
+ * per-frame dispatch: ONLY root-plane steps run; crop children
25438
+ * (inputClasses ≠ null) are skipped and served per-track via
25439
+ * pipelineRunner.runDetailSubtree (two-plane design).
25440
+ */
25441
+ plane: _enum(["full", "frame"]).optional(),
25442
+ /**
25443
+ * Inference-device selector (Phase 2 multi-device). Format
25444
+ * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
25445
+ * Omitted ⇒ the runner's default device (current single-engine
25446
+ * behaviour). Selects WHICH device pool of the node runs the call.
25447
+ */
25448
+ deviceKey: string().optional(),
25449
+ /**
25450
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
25451
+ * when the parent crop was resolved from the frame's retained NATIVE
25452
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
25453
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
25454
+ * resolution from that surface — the SAME quality path faces already
25455
+ * had — instead of the downscaled parent tile. `handle` keys the native
25456
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
25457
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
25458
+ * the executor's crop-normalized child ROI back into frame-normalized
25459
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
25460
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
25461
+ * (today's behaviour on the fallback path).
25462
+ */
25463
+ nativeCropRef: NativeCropRefSchema.optional(),
25464
+ /**
25465
+ * Offline REPLAY of stored media for `deviceId` (D56, D646): the
25466
+ * camera's zone gate and overrides apply as live, every executing
25467
+ * step runs EXACTLY the model it names on the `deviceKey` pool it
25468
+ * names or the call refuses (`model-not-servable` /
25469
+ * `device-not-servable`), and nothing reaches the camera's live
25470
+ * trace stream. Absent ⇒ unchanged behaviour.
25471
+ */
25472
+ replay: literal(true).optional()
25473
+ }), PipelineRunResultBridge, { kind: "mutation" }),
25379
25474
  /**
25380
- * The media an EVENT owns.
25381
- *
25382
- * `ownerType` is REQUIRED, and that is the whole correction (D482). An
25383
- * event is a row in ONE of three tables, and since D474 each numbers from
25384
- * 1 independently: `motion:101314` and `object:101314` both exist. This
25385
- * method took a bare `eventId` and the provider probed motion → object →
25386
- * audio, stopping at the first hit — so on the live hub, where object
25387
- * events own no media of their own and 299 883 of 300 559 media rows are
25388
- * motion-owned, EVERY object event resolved to its motion namesake. A
25389
- * track from 17:34 on camera 615 was served a snapshot from 22:35 eleven
25390
- * days earlier, silently.
25475
+ * Batched run — N raw frames packed into one cap call. The provider
25476
+ * routes the batch through `SharedInferencePool.inferBatch`
25477
+ * (`MSG_INFER_BATCH = 0x03`) so the IPC framing and JSON response
25478
+ * envelope cost is amortised N:1 vs N concurrent `runPipeline`
25479
+ * calls. Single root step + uniform model assumed; trees with crop
25480
+ * children fall back to sequential execution.
25391
25481
  *
25392
- * D476 had already disambiguated the KEY (`motion:` vs `object:`); this is
25393
- * the API catching up to it. Naming the table is not a "qualification" of
25394
- * the ambiguity — a listing BY OWNER has no address to make surrogate: the
25395
- * owner IS (table, id), and half of it is not a question.
25482
+ * Used by `scripts/bench-batch-style.mts` for batch benchmarking —
25483
+ * N frames in one call to amortise per-call IPC overhead.
25396
25484
  */
25397
- getEventMedia: method(object({
25398
- /** Which of the three event tables owns the row. */
25399
- ownerType: EventOwnerTypeSchema,
25400
- /** The event's rowid in that table (D474: an event id is a number). */
25401
- eventId: number().int(),
25402
- kind: MediaFileKindEnum.optional(),
25403
- deviceId: number()
25404
- }), array(MediaFileSchema).readonly()),
25405
- /** All media rows owned by a track. `kinds` narrows to a kind subset so a
25406
- * client can fetch the SMALL display variants on open and pull the
25407
- * multi-MB native variants only on demand (mirrors `getEventMedia.kind`).
25408
- * Absent ⇒ every kind (back-compat). */
25409
- getTrackMedia: method(object({
25410
- trackId: string(),
25411
- kinds: array(MediaFileKindEnum).optional(),
25412
- deviceId: number()
25413
- }), array(MediaFileSchema).readonly()),
25485
+ runPipelineBatch: method(object({
25486
+ steps: array(PipelineStepInputSchema).min(1),
25487
+ frames: array(FrameInputSchema).min(1).max(255),
25488
+ deviceId: number().optional(),
25489
+ sessionId: string().optional(),
25490
+ /**
25491
+ * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
25492
+ * the batch to the Python pool's bench preprocess cache
25493
+ * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
25494
+ * preprocessed ONCE and every later inference is a pure-inference cache
25495
+ * hit — the sustained-throughput run measures inference, not
25496
+ * decode+preprocess+infer. Omitted/0 for live frames (all different →
25497
+ * full preprocess every call, correct). Fresh per sustained run;
25498
+ * released via `uncacheFrame`.
25499
+ */
25500
+ frameId: number().int().nonnegative().optional(),
25501
+ /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
25502
+ deviceKey: string().optional()
25503
+ }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }),
25414
25504
  /**
25415
- * What media a track HAS, without any of it.
25416
- *
25417
- * The detail view needs the shape of a track's media to build its strip —
25418
- * which kinds exist, in what order, at what size — and then wants each tile
25419
- * fetched as an image, not as base64 inside this response. Measured: the
25420
- * full `getTrackMedia` is 5.3-7.7 MB and blocks the view; this manifest is
25421
- * ~2 KB.
25422
- *
25423
- * It also restores a fact a `kinds` filter destroys: filtering
25424
- * `getTrackMedia` drops whole ROWS, taking `kind` and `sizeBytes` with
25425
- * them, so a client that fetched only the small variants could no longer
25426
- * tell a full-resolution variant existed — and the affordance that opens it
25427
- * would silently disappear.
25505
+ * Cache a raw frame inside the Python inference pool's memory.
25506
+ * Returns a numeric `frameId` that `inferCached` references —
25507
+ * subsequent calls send only 5 bytes through the pipe instead of
25508
+ * 1.2MB raw data, eliminating the pipe transfer bottleneck.
25428
25509
  */
25429
- listTrackMedia: method(object({
25430
- trackId: string(),
25431
- deviceId: number()
25432
- }), array(MediaFileInfoSchema).readonly()),
25510
+ cacheFrameInPool: method(object({
25511
+ data: _instanceof(Uint8Array),
25512
+ width: number().int().positive(),
25513
+ height: number().int().positive(),
25514
+ format: _enum([
25515
+ "rgb",
25516
+ "bgr",
25517
+ "gray"
25518
+ ])
25519
+ }), object({
25520
+ frameId: number(),
25521
+ width: number(),
25522
+ height: number()
25523
+ }), { kind: "mutation" }),
25433
25524
  /**
25434
- * What media an EVENT has, without any of it — the twin `getEventMedia`
25435
- * never had.
25436
- *
25437
- * `listTrackMedia` above got this treatment because a track's media is
25438
- * 5-8 MB. An event's is worse per row, not better: an old-style event owns
25439
- * a `crop` AND a native-resolution `fullFrameBoxed`, and the track DETAIL
25440
- * modal — the one surface that legitimately shows the big kinds — unions
25441
- * both listings to build its filmstrip. It then renders every tile from
25442
- * the `event-media` plane by key and throws the bytes away. Measured on
25443
- * the live hub: one event's `fullFrameBoxed` is 2 824 077 B, base64'd to
25444
- * ~3.8 MB, allocated whole in hub-main's heap, for a list of keys.
25445
- *
25446
- * Same `deviceId` authorization subject as `getEventMedia`, the same
25447
- * REQUIRED `ownerType` (read that method's docblock for the night-time
25448
- * thumbnail this closes — D482), and the same rows: this is a projection
25449
- * of that method, never a different question.
25525
+ * Run inference on a previously cached frame. Sends only 5 bytes
25526
+ * (model_idx + frameId) through the IPC pipe — eliminates the
25527
+ * ~35ms per-call overhead of transferring 1.2MB raw data.
25450
25528
  */
25451
- listEventMedia: method(object({
25452
- ownerType: EventOwnerTypeSchema,
25453
- eventId: number().int(),
25454
- deviceId: number()
25455
- }), array(MediaFileInfoSchema).readonly()),
25529
+ inferCached: method(object({
25530
+ stepId: string(),
25531
+ frameId: number().int()
25532
+ }), record(string(), unknown()), { kind: "mutation" }),
25456
25533
  /**
25457
- * Which of `ownerIds` hold at least ONE media row — an INDEX read, never a
25458
- * blob read, and the LICENCE `videoclips` needs to publish a `thumbnail`.
25459
- *
25460
- * The event-media URL is stamped from a template for every event in the
25461
- * system, so "the plane is up" was being served as "there are bytes": 64 of
25462
- * one camera's 179 clips pointed at a 404 (device 3836, 2026-08-17). This
25463
- * is the question that turns the stamp into a claim.
25464
- *
25465
- * It is on the WIRE because the clip source is registered by the addon that
25466
- * owns the FOOTAGE, not by this one (D560) — the probe used to be an
25467
- * in-process `MediaStore` read. One call per OWNER KIND, never one per
25468
- * owner: that N+1 is what `MediaStore.ownersWithMedia` was written to
25469
- * prevent, and crossing a process boundary makes it worse, not better.
25470
- * `ownerIds` is bounded at the same 5 000 the annotation fetch is bounded
25471
- * at, so one pathological camera-day cannot mint an unbounded request.
25472
- *
25473
- * THROWS rather than answering partially. A probe that quietly
25474
- * under-reports reads as "these owners have nothing" and the caller drops
25475
- * thumbnails that exist — the opposite failure to the one above, and
25476
- * equally invisible.
25477
- *
25478
- * `deviceId` is the authorization subject, exactly as on `getEventMedia`.
25534
+ * Release a cached frame from the Python pool's memory.
25479
25535
  */
25480
- ownersWithMedia: method(object({
25481
- deviceId: number(),
25482
- ownerKind: MediaPresenceOwnerKindSchema,
25483
- ownerIds: array(string()).max(5e3)
25484
- }), array(string()).readonly()),
25536
+ uncacheFrame: method(object({ frameId: number().int() }), _void(), { kind: "mutation" }),
25485
25537
  /**
25486
- * Search object events by text query using CLIP cosine similarity.
25487
- * Encodes `text` via the `embedding-encoder` cap, queries the
25488
- * `ObjectEmbeddingStore` with optional prefilters, ranks all matching
25489
- * embeddings by cosine similarity, and joins winners to their
25490
- * ObjectEvents by trackId. Returns up to `limit` events scored ≥
25491
- * `minScore`, sorted descending by score.
25538
+ * The effective provisioning of ONE pool of this node (operator override →
25539
+ * the pool's own runtime row). `deviceKey` names the device pool; absent is
25540
+ * the node-default pool. It answered only for the node default until
25541
+ * D646, so a benchmark on `openvino:npu` recorded the onnx pool's tuning
25542
+ * beside an NPU measurement.
25492
25543
  */
25493
- searchObjectEvents: method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()),
25494
- wipeObjectEmbeddings: method(object({}), WipeObjectEmbeddingsResultSchema, {
25544
+ getEffectiveTuning: method(object({ deviceKey: string().optional() }), EffectiveTuningSchema),
25545
+ /**
25546
+ * List every EngineFactory currently loaded in this executor's RAM,
25547
+ * with the models resident and a coarse "in use" marker derived from
25548
+ * ongoing inference activity. Used by the Pipeline page Engines tab.
25549
+ */
25550
+ listLoadedEngines: method(_void(), array(object({
25551
+ engineKey: string(),
25552
+ engine: PipelineEngineChoiceSchema,
25553
+ modelsLoaded: array(string()).readonly(),
25554
+ inUseByCameras: array(number()).readonly(),
25555
+ /**
25556
+ * Origin of this resident factory.
25557
+ * - `runtime` — main camera-serving engine (no idle TTL).
25558
+ * - `device-pool` — a concurrent per-device pool (Phase 2
25559
+ * multi-device, keyed by `deviceKey`) resolved
25560
+ * via `resolveDeviceFactory`. Runs alongside the
25561
+ * `runtime` engine on a DIFFERENT accelerator
25562
+ * (NPU / iGPU / Coral) — this is how the
25563
+ * Engines tab shows all pools running at once.
25564
+ */
25565
+ kind: _enum(["runtime", "device-pool"]),
25566
+ /** Native pid of the underlying Python pool (null when no pool). */
25567
+ poolPid: number().nullable(),
25568
+ /** ms since this factory was last used (null when not warm-tracked). */
25569
+ idleMs: number().nullable(),
25570
+ /** Idle TTL after which the factory self-evicts (null when not applicable). */
25571
+ idleTtlMs: number().nullable()
25572
+ })).readonly()),
25573
+ /** Warm up an engine without running a frame. No-op if already loaded. */
25574
+ spinEngine: method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
25495
25575
  kind: "mutation",
25496
25576
  auth: "admin"
25497
25577
  }),
25498
- rebuildObjectEmbeddings: method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
25578
+ /**
25579
+ * Unload an engine from RAM. `force:true` unloads even when cameras
25580
+ * are actively using it (they re-spin on next frame). Default is
25581
+ * gated — returns `{success:false, reason}` when in use.
25582
+ */
25583
+ killEngine: method(object({
25584
+ engine: PipelineEngineChoiceSchema,
25585
+ force: boolean().optional()
25586
+ }), object({
25587
+ success: boolean(),
25588
+ reason: string().optional()
25589
+ }), {
25499
25590
  kind: "mutation",
25500
25591
  auth: "admin"
25501
25592
  }),
25502
- getObjectEmbeddingRebuildStatus: method(object({}), RebuildStatusSchema)
25503
- },
25504
- events: {
25505
- /**
25506
- * Enriched frame emitted after refinement — the live-overlay source of
25507
- * truth (two-plane re-injection). Carries the frame's detections in the
25508
- * `ObjectDetection` wire shape: first-level roots (with track info +
25509
- * enrichment labels) plus synthesized `kind:'detail'` face/plate entries
25510
- * re-projected from per-track detail state, so stream overlays render
25511
- * boxes + recognized names without querying full Track state.
25512
- */
25513
- onFrameTracked: { data: object({
25514
- deviceId: number(),
25515
- timestamp: number(),
25516
- frameWidth: number(),
25517
- frameHeight: number(),
25518
- detections: array(OverlayDetectionSchema).readonly()
25519
- }) },
25520
- /** Track entered active state (first-seen). */
25521
- onTrackStarted: { data: object({
25522
- deviceId: number(),
25523
- trackId: string(),
25524
- className: string()
25525
- }) },
25526
- /** Track expired (TTL reached after last detection). */
25527
- onTrackEnded: { data: object({
25528
- deviceId: number(),
25529
- trackId: string(),
25530
- className: string(),
25531
- durationMs: number()
25532
- }) },
25533
- /** Canonical "something happened at device X" event, per-kind. */
25534
- onDetectionEvent: { data: object({
25535
- deviceId: number(),
25536
- kind: EventKindSchema,
25537
- eventId: string(),
25538
- timestamp: number()
25539
- }) }
25593
+ listReferenceImages: method(_void(), array(ReferenceImageEntrySchema).readonly()),
25594
+ getReferenceImage: method(object({ filename: string() }), ReferenceImageBodySchema.nullable()),
25595
+ getReferenceAudioFiles: method(_void(), array(ReferenceAudioEntrySchema).readonly()),
25596
+ getReferenceAudio: method(object({ filename: string() }), ReferenceAudioBodySchema.nullable()),
25597
+ getAudioCapabilities: method(_void(), AudioCapabilitiesSchema),
25598
+ runAudioTest: method(object({
25599
+ addonId: string(),
25600
+ modelId: string(),
25601
+ filename: string().optional(),
25602
+ settings: record(string(), unknown()).optional()
25603
+ }), AudioTestResultSchema, { kind: "mutation" }),
25604
+ getDetectionConfigSchema: method(_void(), ConfigUISchemaNullableBridge)
25540
25605
  }
25541
25606
  };
25542
25607
  object({
@@ -25564,6 +25629,106 @@ var CameraMetricsSchema = object({
25564
25629
  });
25565
25630
  var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
25566
25631
  /**
25632
+ * Zone — pure geometry + identity. NO filtering behaviour.
25633
+ *
25634
+ * Zones describe **where** in the frame the operator wants to flag
25635
+ * something; consumer-owned {@link ZoneRule} arrays describe **how**
25636
+ * each pipeline stage uses them. Splitting the two means a single
25637
+ * polygon "Driveway" can simultaneously back a motion-exclude rule,
25638
+ * a detection-include rule on `['car']`, and an occupancy aggregate
25639
+ * — without three duplicated polygons.
25640
+ *
25641
+ * Owned by the orchestrator addon (provider) and mirrored into the
25642
+ * `zones` device-state slice on every mutation. Consumers
25643
+ * (motion-wasm, pipeline-executor, analytics, admin UI) read either
25644
+ * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
25645
+ * mirror with `onChanged`).
25646
+ *
25647
+ * Coordinates are normalised fractions of the frame (0–1) so zones
25648
+ * survive resolution changes and stream profile switches.
25649
+ *
25650
+ * `kind` discriminates between full polygons (closed regions used
25651
+ * for intrusion / occupancy filters) and tripwires (open 2-point
25652
+ * line segments used for cross events). Onboard / firmware-reported
25653
+ * zones (Reolink, ONVIF) are out of scope for now — see the deferred
25654
+ * task list.
25655
+ */
25656
+ var ZoneKindEnum = _enum(["polygon", "tripwire"]);
25657
+ /** Polygon vertex in fraction-of-frame coordinates (0–1). */
25658
+ var PolygonPointSchema = object({
25659
+ x: number(),
25660
+ y: number()
25661
+ });
25662
+ /** A camera detection zone — pure geometry/identity. */
25663
+ var ZoneSchema = object({
25664
+ id: string(),
25665
+ name: string(),
25666
+ kind: ZoneKindEnum.default("polygon"),
25667
+ /** Polygon vertices, fraction of frame (0–1). */
25668
+ polygon: array(PolygonPointSchema).readonly(),
25669
+ /** Visual color for UI rendering. */
25670
+ color: string().default("#3b82f6")
25671
+ });
25672
+ /**
25673
+ * Zones capability — per-camera CRUD over polygon detection zones.
25674
+ *
25675
+ * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
25676
+ * to per-device settings and mirrors into the `zones` device-state
25677
+ * slice on every mutation, so downstream consumers can subscribe via
25678
+ * `dev.state.zones.onChanged`.
25679
+ *
25680
+ * The cap surface only handles geometry + identity; filtering
25681
+ * behaviour (per-class, include/exclude, threshold) lives in the
25682
+ * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
25683
+ * `capabilities/schemas/zone-rule.js`.
25684
+ */
25685
+ var zonesCapability = {
25686
+ name: "zones",
25687
+ scope: "device",
25688
+ mode: "singleton",
25689
+ deviceTypes: [DeviceType.Camera],
25690
+ methods: {
25691
+ listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
25692
+ addZone: method(object({
25693
+ deviceId: number(),
25694
+ zone: ZoneSchema
25695
+ }), _void(), {
25696
+ kind: "mutation",
25697
+ auth: "admin"
25698
+ }),
25699
+ removeZone: method(object({
25700
+ deviceId: number(),
25701
+ zoneId: string()
25702
+ }), _void(), {
25703
+ kind: "mutation",
25704
+ auth: "admin"
25705
+ }),
25706
+ updateZone: method(object({
25707
+ deviceId: number(),
25708
+ zone: ZoneSchema
25709
+ }), _void(), {
25710
+ kind: "mutation",
25711
+ auth: "admin"
25712
+ })
25713
+ },
25714
+ /**
25715
+ * Runtime-state slice — the live zone catalogue mirrored by the
25716
+ * orchestrator on every CRUD mutation. Consumers read via
25717
+ * `device.state.zones.value` / `.watch(...)` without round-tripping
25718
+ * the cap, and the codegen DeviceProxy auto-wires the reactive
25719
+ * handle. Slice shape is `{ zones: Zone[] }` so future extensions
25720
+ * (e.g. zone groupings) can sit alongside the polygon list.
25721
+ */
25722
+ runtimeState: object({ zones: array(ZoneSchema).readonly() }),
25723
+ /**
25724
+ * 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.
25725
+ *
25726
+ * See `RuntimeStateDurability`. Enforced by
25727
+ * `scripts/check-runtime-state-durability.ts`.
25728
+ */
25729
+ durability: "restored"
25730
+ };
25731
+ /**
25567
25732
  * A bounding box in NORMALIZED [0,1] frame coordinates for `getNativeCrop`. The
25568
25733
  * decode worker resolves it against the RETAINED native frame's real pixel dims,
25569
25734
  * so the caller supplies only the detection-res bbox divided by the detection
@@ -25750,7 +25915,17 @@ var DetailResultSchema = object({
25750
25915
  /** Face short side (px) measured on the NATIVE crop surface. The `bbox`
25751
25916
  * above is detection-frame px (≈6× smaller on a 4K camera) — min-face-size
25752
25917
  * consumers MUST prefer this when present (2026-07-22 native-gate fix). */
25753
- nativeFaceShortSidePx: number().optional()
25918
+ nativeFaceShortSidePx: number().optional(),
25919
+ /**
25920
+ * The five facial landmarks of a `face` detail, in the SAME frame space as
25921
+ * `bbox` (D644). Additive and optional: post-analysis stores them beside the
25922
+ * face's source frame so a future alignment can be re-derived exactly; a
25923
+ * runner that predates the field sends none and the face is stored without.
25924
+ */
25925
+ landmarks: array(object({
25926
+ x: number(),
25927
+ y: number()
25928
+ })).optional()
25754
25929
  });
25755
25930
  /**
25756
25931
  * Why an executing node REFUSED a stateless step run (`runStatelessStep`).
@@ -27658,7 +27833,11 @@ function buildDescriptor(capName, kind) {
27658
27833
  icon: legacyIcon(t.iconId)
27659
27834
  };
27660
27835
  }
27661
- Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
27836
+ /**
27837
+ * Sensor / control cap name → static event-kind descriptor. A linked device
27838
+ * contributes one entry per bound cap present in this map.
27839
+ */
27840
+ var EVENT_KIND_BY_CAP = Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
27662
27841
  /**
27663
27842
  * server-management — per-NODE singleton capability for a node's ROOT
27664
27843
  * package lifecycle (runtime-updatable node packages).
@@ -32890,12 +33069,20 @@ reset: method(object({
32890
33069
  },
32891
33070
  runtimeState: ConsumablesStatusSchema.extend({ lastFetchedAt: number() }),
32892
33071
  /**
32893
- * Runtime-state durability: **session** — the authority is the appliance; the provider re-reads the whole item array on connect.
33072
+ * Runtime-state durability: **restored** — nothing else holds the value
33073
+ * (D642). A consumable can often be read only in a device's wake window (the
33074
+ * Dreame mower's CMS counters answer only while it charges), so a restart
33075
+ * that wiped the slice left the panel empty and the alerts blind until the
33076
+ * next wake — 2026-09-26, mower 503 idle with `items: []`. A restored item is
33077
+ * the previous observation, not a claim about now; the provider overwrites it
33078
+ * the moment it reads the device again.
32894
33079
  *
32895
33080
  * See `RuntimeStateDurability`. Enforced by
32896
33081
  * `scripts/check-runtime-state-durability.ts`.
32897
33082
  */
32898
- durability: "session"
33083
+ durability: "restored",
33084
+ /** Clocks, not content: a re-read that changed no item costs no commit. */
33085
+ volatileStateFields: ["lastChangedAt", "lastFetchedAt"]
32899
33086
  };
32900
33087
  /**
32901
33088
  * Door / window / opening / garage / valve contact sensor. Boolean
@@ -37768,7 +37955,7 @@ var HardwareInfoSchema = object({
37768
37955
  coral: CoralInfoSchema.nullable().optional()
37769
37956
  });
37770
37957
  var PlatformScoreSchema = object({
37771
- runtime: _enum(["node", "python"]),
37958
+ runtime: literal("python"),
37772
37959
  backend: string(),
37773
37960
  format: _enum([
37774
37961
  "onnx",
@@ -37805,7 +37992,7 @@ var ModelRequirementSchema = object({
37805
37992
  });
37806
37993
  var ResolvedInferenceConfigSchema = object({
37807
37994
  modelId: string(),
37808
- runtime: _enum(["node", "python"]),
37995
+ runtime: literal("python"),
37809
37996
  backend: string(),
37810
37997
  format: ModelFormatSchema,
37811
37998
  reason: string()
@@ -40812,6 +40999,92 @@ var sceneMonitorCapability = {
40812
40999
  durability: "session"
40813
41000
  };
40814
41001
  /**
41002
+ * Per-stage gating mode applied to the zones a rule references.
41003
+ *
41004
+ * - `include`: the rule contributes to a **whitelist** for its stage.
41005
+ * When at least one `include` rule fires for a stage, only entities
41006
+ * inside one of those zones pass that stage.
41007
+ * - `exclude`: the rule contributes to a **blacklist** for its stage.
41008
+ * Entities inside one of those zones are dropped at that stage.
41009
+ *
41010
+ * `monitor`-style observation (count without filtering) is not a rule
41011
+ * mode — zones without any matching rule are observed naturally by
41012
+ * `zone-analytics` (live snapshot + history), so an "I just want to
41013
+ * count, not filter" use case needs no rule at all.
41014
+ */
41015
+ var ZoneRuleModeEnum = _enum(["include", "exclude"]);
41016
+ /**
41017
+ * Per-consumer rule that references existing zones (geometry) and
41018
+ * defines how a specific pipeline stage should treat them. Each
41019
+ * consumer addon owns its own `ZoneRule[]` array in its per-device
41020
+ * settings:
41021
+ *
41022
+ * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
41023
+ * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
41024
+ * - future: notification rules, audio gating, etc.
41025
+ *
41026
+ * One rule applies to N zones (`zoneIds[]`) so the operator can
41027
+ * express "ignore motion in ALL of {garden, street}" with a single
41028
+ * rule. `classFilter` narrows the rule to specific object classes —
41029
+ * "drop person detections in the street, but keep cars" is one
41030
+ * `exclude` rule with `classFilter: ['person']`.
41031
+ *
41032
+ * `enabled` is a soft toggle — the operator can keep the rule
41033
+ * configured but inert without deleting it.
41034
+ */
41035
+ var ZoneRuleSchema = object({
41036
+ /** Stable rule id — survives edits, used by the UI for diffing. */
41037
+ id: string(),
41038
+ /** Optional human-readable label rendered in the rule editor. */
41039
+ name: string().optional(),
41040
+ /** Zones this rule targets. The rule's `mode` applies to ALL
41041
+ * listed zones (OR-set: a detection in any one of them counts).
41042
+ * At least one zone id required — a rule with no targets is a
41043
+ * configuration mistake and the form validator rejects it. */
41044
+ zoneIds: array(string()).min(1).readonly(),
41045
+ mode: ZoneRuleModeEnum,
41046
+ /**
41047
+ * Class names this rule applies to. Empty / undefined ⇒ rule
41048
+ * applies to every class. Class strings match the `macroClass`
41049
+ * field on detections (e.g. `person`, `car`, `dog`).
41050
+ */
41051
+ classFilter: array(string()).readonly().optional(),
41052
+ /**
41053
+ * Minimum bbox/mask overlap (0–1) with any of the rule's zones
41054
+ * required to consider an entity "in the zone". Defaults to the
41055
+ * consumer's stage default when omitted. Kept for back-compat with
41056
+ * existing per-rule overrides; new operators pick the value via
41057
+ * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
41058
+ * set, the lower-level engine reads it as a 0–1 fraction.
41059
+ */
41060
+ overlapThreshold: number().min(0).max(1).optional(),
41061
+ /**
41062
+ * Operator-friendly version of `overlapThreshold` — the percentage
41063
+ * of the detection's bbox that must lie inside the zone for the
41064
+ * rule to match. Documented default is 85%; the engine substitutes
41065
+ * that when the field is omitted (kept optional so existing rules
41066
+ * stored without it stay valid).
41067
+ *
41068
+ * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
41069
+ * rule, the engine prefers `bboxInclusionPct` because it's the
41070
+ * field exposed in the UI. Internally both feed the same gate.
41071
+ */
41072
+ bboxInclusionPct: number().min(0).max(100).optional(),
41073
+ /**
41074
+ * When `true` and a detection has a segmentation mask, use the
41075
+ * mask for overlap instead of the bbox. Detection-stage only;
41076
+ * motion rules ignore this field.
41077
+ */
41078
+ preferMask: boolean().optional(),
41079
+ /**
41080
+ * Soft-toggle: `false` disables the rule without deleting it.
41081
+ * Defaults to `true` so operators creating a rule via the UI
41082
+ * see it active immediately.
41083
+ */
41084
+ enabled: boolean().default(true)
41085
+ });
41086
+ array(ZoneRuleSchema).readonly();
41087
+ /**
40815
41088
  * Script-runner cap. Models HA `script.*` entities on
40816
41089
  * `DeviceType.Script`. A Script is a pre-recorded action sequence
40817
41090
  * that can be invoked imperatively — optionally with a variables
@@ -43019,6 +43292,42 @@ function readDeviceStateFrom(runtimeState) {
43019
43292
  }
43020
43293
  }
43021
43294
  /**
43295
+ * LA tabella "quale booleano di questo tipo di device conta come ALTO", e il
43296
+ * valutatore puro del suo FRONTE.
43297
+ *
43298
+ * Viveva dentro il builtin virtual-doorbell
43299
+ * (`@camstack/system` — `builtins/doorbell/trigger-engine.ts`) e i suoi
43300
+ * predicati erano privati al modulo. Il recorder ne ha bisogno per il trigger
43301
+ * `RecordingTriggers.sensorDeviceIds`: copiarla avrebbe creato la SECONDA
43302
+ * tabella, che diverge alla prima cap aggiunta e il cui sintomo — "il sensore
43303
+ * fa suonare il campanello ma non registra" — è esattamente D62. Quindi si
43304
+ * SPOSTA qui e il doorbell la ri-esporta.
43305
+ *
43306
+ * ⚠ NON è `DEVICE_STATE_READERS` (`catalogs/device-state-vocabulary.ts`), e le
43307
+ * due non vanno unificate: quella risponde a "qual è la PAROLA di stato per una
43308
+ * regola" (e include `presence`, `cover`, `alarm-panel`), questa a "qual è il
43309
+ * booleano il cui FRONTE conta". Vocabolari deliberatamente diversi.
43310
+ */
43311
+ /**
43312
+ * Known binary / switch source caps → the boolean slice field whose
43313
+ * false→true rise counts as ACTIVE. Every entry is "fire on active".
43314
+ * Sensors whose "active" reading is not a plain boolean (presence's string
43315
+ * state, connectivity's connected flag) are deliberately excluded — a
43316
+ * reconnect is not a doorbell press, and it is not a recording either.
43317
+ */
43318
+ var SOURCE_CAP_ACTIVE_FIELD = {
43319
+ contact: "entryOpen",
43320
+ binary: "on",
43321
+ switch: "on",
43322
+ motion: "detected",
43323
+ flood: "flooded",
43324
+ gas: "detected",
43325
+ smoke: "detected",
43326
+ "carbon-monoxide": "detected",
43327
+ vibration: "detected",
43328
+ tamper: "tampered"
43329
+ };
43330
+ /**
43022
43331
  * Accessory device helpers — shared across drivers.
43023
43332
  *
43024
43333
  * Many vendor-specific drivers register accessory child devices on
@@ -48095,6 +48404,12 @@ Object.freeze({
48095
48404
  addonId: null,
48096
48405
  access: "view"
48097
48406
  },
48407
+ "notificationRules.getRuleLastRuns": {
48408
+ capName: "notification-rules",
48409
+ capScope: "system",
48410
+ addonId: null,
48411
+ access: "view"
48412
+ },
48098
48413
  "notificationRules.getTemplateCatalog": {
48099
48414
  capName: "notification-rules",
48100
48415
  capScope: "system",
@@ -48119,6 +48434,12 @@ Object.freeze({
48119
48434
  addonId: null,
48120
48435
  access: "view"
48121
48436
  },
48437
+ "notificationRules.previewStateSummary": {
48438
+ capName: "notification-rules",
48439
+ capScope: "system",
48440
+ addonId: null,
48441
+ access: "view"
48442
+ },
48122
48443
  "notificationRules.previewTemplate": {
48123
48444
  capName: "notification-rules",
48124
48445
  capScope: "system",
@@ -48695,12 +49016,6 @@ Object.freeze({
48695
49016
  addonId: null,
48696
49017
  access: "create"
48697
49018
  },
48698
- "pipelineAnalytics.runReplayFrameProcessor": {
48699
- capName: "pipeline-analytics",
48700
- capScope: "device",
48701
- addonId: null,
48702
- access: "create"
48703
- },
48704
49019
  "pipelineAnalytics.saveRetrainAnnotations": {
48705
49020
  capName: "pipeline-analytics",
48706
49021
  capScope: "device",
@@ -52798,11 +53113,6 @@ Object.freeze({
52798
53113
  form: "single",
52799
53114
  optional: false
52800
53115
  }],
52801
- "pipelineAnalytics.runReplayFrameProcessor": [{
52802
- name: "deviceId",
52803
- form: "single",
52804
- optional: false
52805
- }],
52806
53116
  "pipelineAnalytics.saveRetrainAnnotations": [{
52807
53117
  name: "deviceId",
52808
53118
  form: "single",
@@ -53691,12 +54001,55 @@ var NC_AUDIO_DEFAULTS = {
53691
54001
  samplingSeconds: 10
53692
54002
  };
53693
54003
  new Set(["devices", "classes"]);
53694
- /** Every filter, for the callers that must cover all four (guards, tests). */
54004
+ /**
54005
+ * WHICH narrowing filter speaks about WHICH system-event kind — one predicate,
54006
+ * consumed by the rule ENGINE and by every rule EDITOR.
54007
+ *
54008
+ * ── The failure this file exists for ───────────────────────────────────────
54009
+ * `NcSystemEventConditionSchema` carries four optional narrowing lists
54010
+ * (`deviceIds`, `deviceTypes`, `nodeIds`, `packageNames`) beside a required
54011
+ * `kinds` gate. They are not four filters over one vocabulary: each belongs to
54012
+ * a FAMILY of kinds and is meaningless outside it. A node going away has no
54013
+ * device type; a completed export has no package; `stream-offline` deliberately
54014
+ * carries no device type at all (a stream belongs to a camera by construction).
54015
+ *
54016
+ * The engine applied all four to every kind, so a filter from one family failed
54017
+ * a kind from another family CLOSED. The operator's live rule "Eventi di
54018
+ * sistema" selected eleven kinds and set `deviceTypes: ['camera']` — the only
54019
+ * way to say "only my cameras" about the two liveness kinds — and NINE of the
54020
+ * eleven silently stopped being deliverable. Four days of history contained
54021
+ * `device-online` and `device-offline` and nothing else, across a window in
54022
+ * which agents were restarted and addons were updated.
54023
+ *
54024
+ * Both editors already computed this scoping, to decide which filter boxes to
54025
+ * render; the cap's own docblock already promised it ("Narrow a `device-*` kind
54026
+ * to these device TYPES"). Only the engine disagreed, and it disagreed in the
54027
+ * destructive direction. So the rule is stated ONCE, here, and the engine and
54028
+ * the editors are readers of it rather than three independent authors.
54029
+ *
54030
+ * ── The direction ─────────────────────────────────────────────────────────
54031
+ * Out of family ⇒ the filter is IGNORED, never fail-closed. An editor that
54032
+ * hides a box has already told the operator this filter does not speak about
54033
+ * these kinds, so honouring it as an exclusion contradicts the only
54034
+ * explanation the operator was ever given. Inside its family the filter still
54035
+ * narrows, and still fails CLOSED on a subject that cannot produce the identity
54036
+ * it tests (a device the mirror cannot name is not evidence of a camera).
54037
+ */
54038
+ /**
54039
+ * Every filter, for the callers that must cover all of them (guards, tests).
54040
+ *
54041
+ * `consumableLowPercent` (D642) is not a list but it is a filter in exactly
54042
+ * this sense: it belongs to a family of kinds (the consumable pair) and the
54043
+ * engine consults it only there. It differs in one way the readers must know —
54044
+ * its ABSENCE is not "no narrowing" but the default threshold, because a
54045
+ * consumable episode is always judged at SOME threshold.
54046
+ */
53695
54047
  var NC_SYSTEM_EVENT_FILTER_KEYS = [
53696
54048
  "deviceIds",
53697
54049
  "deviceTypes",
53698
54050
  "nodeIds",
53699
- "packageNames"
54051
+ "packageNames",
54052
+ "consumableLowPercent"
53700
54053
  ];
53701
54054
  new Map(Object.entries({
53702
54055
  "device-online": "device-events",
@@ -53707,6 +54060,9 @@ new Map(Object.entries({
53707
54060
  "device-battery-normal": "device-events",
53708
54061
  "device-consumable-low": "device-events",
53709
54062
  "device-consumable-normal": "device-events",
54063
+ "device-tank-low": "device-events",
54064
+ "device-tank-full": "device-events",
54065
+ "device-tank-normal": "device-events",
53710
54066
  "stream-online": "device-events",
53711
54067
  "stream-offline": "device-events",
53712
54068
  "detection-blind": "device-events",
@@ -53736,6 +54092,98 @@ new Map(Object.entries({
53736
54092
  "camera-enabled": null
53737
54093
  }));
53738
54094
  [...NC_SYSTEM_EVENT_FILTER_KEYS];
54095
+ var NC_SYSTEM_EVENT_KIND_GROUP_SPECS = [
54096
+ {
54097
+ id: "device-state",
54098
+ family: "device-events",
54099
+ label: "Device state",
54100
+ kinds: [
54101
+ "device-offline",
54102
+ "device-online",
54103
+ "device-disabled",
54104
+ "device-enabled"
54105
+ ]
54106
+ },
54107
+ {
54108
+ id: "streams",
54109
+ family: "device-events",
54110
+ label: "Streams",
54111
+ kinds: ["stream-offline", "stream-online"]
54112
+ },
54113
+ {
54114
+ id: "battery",
54115
+ family: "device-events",
54116
+ label: "Battery",
54117
+ kinds: ["device-battery-low", "device-battery-normal"]
54118
+ },
54119
+ {
54120
+ id: "consumables",
54121
+ family: "device-events",
54122
+ label: "Consumables",
54123
+ kinds: ["device-consumable-low", "device-consumable-normal"]
54124
+ },
54125
+ {
54126
+ id: "tanks",
54127
+ family: "device-events",
54128
+ label: "Tanks",
54129
+ kinds: [
54130
+ "device-tank-low",
54131
+ "device-tank-full",
54132
+ "device-tank-normal"
54133
+ ]
54134
+ },
54135
+ {
54136
+ id: "detection-blind",
54137
+ family: "device-events",
54138
+ label: "Detecting nothing",
54139
+ kinds: ["detection-blind"]
54140
+ },
54141
+ {
54142
+ id: "nodes",
54143
+ family: "system",
54144
+ label: "Nodes",
54145
+ kinds: [
54146
+ "node-offline",
54147
+ "node-online",
54148
+ "node-inference-unavailable"
54149
+ ]
54150
+ },
54151
+ {
54152
+ id: "addons",
54153
+ family: "system",
54154
+ label: "Addons",
54155
+ kinds: [
54156
+ "addon-crash-loop",
54157
+ "addon-update-available",
54158
+ "addon-updated"
54159
+ ]
54160
+ },
54161
+ {
54162
+ id: "updates",
54163
+ family: "system",
54164
+ label: "Server & container updates",
54165
+ kinds: [
54166
+ "server-update-available",
54167
+ "server-updated",
54168
+ "wrapper-update-available"
54169
+ ]
54170
+ },
54171
+ {
54172
+ id: "backups-exports",
54173
+ family: "system",
54174
+ label: "Backups & exports",
54175
+ kinds: ["backup-completed", "export-completed"]
54176
+ },
54177
+ {
54178
+ id: "alarm",
54179
+ family: "alarm",
54180
+ label: "Alarm",
54181
+ kinds: NC_ALARM_SYSTEM_EVENT_KINDS
54182
+ }
54183
+ ];
54184
+ function systemEventKindsOfFamily(family) {
54185
+ return NC_SYSTEM_EVENT_KIND_GROUP_SPECS.filter((g) => g.family === family).flatMap((g) => g.kinds);
54186
+ }
53739
54187
  NC_AUDIO_DEFAULTS.hitPercent, NC_AUDIO_DEFAULTS.samplingSeconds;
53740
54188
  var WEEKDAY_TO_DAY = {
53741
54189
  Sun: 0,
@@ -53746,18 +54194,38 @@ var WEEKDAY_TO_DAY = {
53746
54194
  Fri: 5,
53747
54195
  Sat: 6
53748
54196
  };
53749
- /** Resolve (weekday, minute-of-day) of `atMs` in the schedule's timezone.
53750
- * An invalid/unknown IANA name falls back to the host timezone. */
53751
- function localDayMinute(atMs, timezone) {
53752
- const d = new Date(atMs);
53753
- if (timezone !== void 0) try {
53754
- const parts = new Intl.DateTimeFormat("en-US", {
54197
+ /**
54198
+ * One formatter per timezone, built once (D647 review I4). Constructing an
54199
+ * `Intl.DateTimeFormat` is the expensive part of this function, and a caller
54200
+ * that asks about many instants — a window scan — used to build one per
54201
+ * instant. `null` = an invalid IANA name (the host timezone is used).
54202
+ */
54203
+ var FORMATTERS = /* @__PURE__ */ new Map();
54204
+ function formatterFor(timezone) {
54205
+ const held = FORMATTERS.get(timezone);
54206
+ if (held !== void 0) return held;
54207
+ let made;
54208
+ try {
54209
+ made = new Intl.DateTimeFormat("en-US", {
53755
54210
  timeZone: timezone,
53756
54211
  weekday: "short",
53757
54212
  hour: "numeric",
53758
54213
  minute: "numeric",
53759
54214
  hourCycle: "h23"
53760
- }).formatToParts(d);
54215
+ });
54216
+ } catch {
54217
+ made = null;
54218
+ }
54219
+ FORMATTERS.set(timezone, made);
54220
+ return made;
54221
+ }
54222
+ /** Resolve (weekday, minute-of-day) of `atMs` in the schedule's timezone.
54223
+ * An invalid/unknown IANA name falls back to the host timezone. */
54224
+ function localDayMinute(atMs, timezone) {
54225
+ const d = new Date(atMs);
54226
+ const formatter = timezone !== void 0 ? formatterFor(timezone) : null;
54227
+ if (formatter !== null) try {
54228
+ const parts = formatter.formatToParts(d);
53761
54229
  let weekday;
53762
54230
  let hour;
53763
54231
  let minute;
@@ -53797,10 +54265,48 @@ function isScheduleActive(schedule, atMs) {
53797
54265
  }
53798
54266
  return schedule.invert === true ? !inside : inside;
53799
54267
  }
54268
+ /**
54269
+ * WHICH WAY A BOOLEAN SENSOR MOVED — read off the one slice a sensor event
54270
+ * persists (D640 "a sensor rule fires on the raise, the clear, or both").
54271
+ *
54272
+ * A device-event rule over a flood sensor notified on BOTH edges: water
54273
+ * detected, and back to dry. `NcConditions.sensorTransition` lets the rule
54274
+ * name one edge; this file answers, for one `SensorEvent`, which edge it is.
54275
+ *
54276
+ * NOT A SECOND TABLE. The "which boolean of this cap counts as HIGH" question
54277
+ * already has one answer, `SOURCE_CAP_ACTIVE_FIELD`
54278
+ * (`catalogs/sensor-active-state.ts`, the doorbell's and the recorder's edge
54279
+ * table), and a sensor event names its kind, not its cap. So the table here is
54280
+ * DERIVED: event kind → cap (`EVENT_KIND_BY_CAP`) → that cap's active field.
54281
+ * Only kinds whose taxonomy category is `sensor` take part — a switch has an
54282
+ * `on` boolean too, but "it triggers / it clears" is not a sentence about a
54283
+ * light, and offering it there would be a knob with a misleading label.
54284
+ * `presence` is a WORD (`home` / `not_home` / a zone), not a boolean, and is
54285
+ * absent from the source table, so it is absent here.
54286
+ *
54287
+ * `undefined` = never guessed: a kind with no raise (a doorbell press, a
54288
+ * button, a cover), or a slice whose field is missing or not a boolean. The
54289
+ * engine then does NOT filter — a flood alert must not go silent because one
54290
+ * read came back unreadable (the same stance as the alarm's `sensorEdgeOf`).
54291
+ *
54292
+ * Pure, RN-safe: the viewer imports the support rule from here.
54293
+ */
54294
+ /** Event kind → the boolean field of its cap slice that means "raised". */
54295
+ var NC_SENSOR_RAISED_FIELD_BY_KIND = Object.freeze(Object.fromEntries(Object.entries(EVENT_KIND_BY_CAP).flatMap(([capName, descriptor]) => {
54296
+ const field = SOURCE_CAP_ACTIVE_FIELD[capName];
54297
+ if (field === void 0 || descriptor.category !== "sensor") return [];
54298
+ return [[descriptor.kind, field]];
54299
+ })));
54300
+ Object.freeze(Object.keys(NC_SENSOR_RAISED_FIELD_BY_KIND));
53800
54301
  var RULE_BODY_ONLY = ["body"];
53801
54302
  var RULE_TEXT = ["title", "body"];
53802
54303
  var BATTERY = ["device-battery-low", "device-battery-normal"];
53803
54304
  var CONSUMABLE = ["device-consumable-low", "device-consumable-normal"];
54305
+ var TANK = [
54306
+ "device-tank-low",
54307
+ "device-tank-full",
54308
+ "device-tank-normal"
54309
+ ];
53804
54310
  var UPDATES = [
53805
54311
  "addon-update-available",
53806
54312
  "server-update-available",
@@ -53826,12 +54332,189 @@ var DEVICE_EVENTS = [
53826
54332
  "device-enabled",
53827
54333
  ...BATTERY,
53828
54334
  ...CONSUMABLE,
54335
+ ...TANK,
53829
54336
  "stream-online",
53830
54337
  "stream-offline",
53831
54338
  "detection-blind",
53832
54339
  ...ALARM
53833
54340
  ];
53834
- [...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], [...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];
54341
+ /** Every kind a summary may speak about — the two summarisable families. */
54342
+ var SUMMARISABLE = [...systemEventKindsOfFamily("device-events"), ...systemEventKindsOfFamily("system")];
54343
+ /** One per summary SECTION (`NC_STATE_SUMMARY_SECTIONS` in the notification
54344
+ * centre): the section's lines, offered when one of its kinds is selected. */
54345
+ var STATE_SUMMARY_SECTION_VARS = [
54346
+ {
54347
+ name: "summaryDevices",
54348
+ label: "Summary: devices offline / switched off",
54349
+ example: "Garage — offline since 07:12",
54350
+ kinds: [
54351
+ "device-offline",
54352
+ "device-online",
54353
+ "device-disabled",
54354
+ "device-enabled"
54355
+ ]
54356
+ },
54357
+ {
54358
+ name: "summaryStreams",
54359
+ label: "Summary: streams offline",
54360
+ example: "Ingresso (high) — since 06:40",
54361
+ kinds: ["stream-offline", "stream-online"]
54362
+ },
54363
+ {
54364
+ name: "summaryBattery",
54365
+ label: "Summary: low batteries",
54366
+ example: "Sensore porta — 8 %",
54367
+ kinds: BATTERY
54368
+ },
54369
+ {
54370
+ name: "summaryConsumables",
54371
+ label: "Summary: consumables",
54372
+ example: "Robot — filter 10 %",
54373
+ kinds: CONSUMABLE
54374
+ },
54375
+ {
54376
+ name: "summaryTanks",
54377
+ label: "Summary: tanks",
54378
+ example: "Robot — clean water low",
54379
+ kinds: TANK
54380
+ },
54381
+ {
54382
+ name: "summaryDetection",
54383
+ label: "Summary: cameras detecting nothing",
54384
+ example: "Ingresso — since 05:10",
54385
+ kinds: ["detection-blind"]
54386
+ },
54387
+ {
54388
+ name: "summaryNodes",
54389
+ label: "Summary: nodes",
54390
+ example: "little-unraid — offline since 03:00",
54391
+ kinds: [
54392
+ "node-offline",
54393
+ "node-online",
54394
+ "node-inference-unavailable"
54395
+ ]
54396
+ },
54397
+ {
54398
+ name: "summaryAddons",
54399
+ label: "Summary: addons",
54400
+ example: "@camstack/addon-recorder 1.2.3 → 1.2.4",
54401
+ kinds: [
54402
+ "addon-crash-loop",
54403
+ "addon-update-available",
54404
+ "addon-updated"
54405
+ ]
54406
+ },
54407
+ {
54408
+ name: "summaryUpdates",
54409
+ label: "Summary: server & container updates",
54410
+ example: "server 1.2.377 → 1.2.378",
54411
+ kinds: [
54412
+ "server-update-available",
54413
+ "server-updated",
54414
+ "wrapper-update-available"
54415
+ ]
54416
+ }
54417
+ ];
54418
+ var STATE_SUMMARY_VARS = [
54419
+ {
54420
+ name: "summaryText",
54421
+ label: "Summary: every section",
54422
+ description: "One block per section with something to report, one line per item.",
54423
+ example: "Batterie scariche: Sensore porta — 8 %",
54424
+ group: "system",
54425
+ families: ["rule"],
54426
+ fields: [...RULE_TEXT],
54427
+ kinds: ["system"],
54428
+ systemEventKinds: [...SUMMARISABLE],
54429
+ systemEventDeliveries: ["summary"]
54430
+ },
54431
+ {
54432
+ name: "summaryCount",
54433
+ label: "Summary: items reported",
54434
+ example: "3",
54435
+ group: "system",
54436
+ families: ["rule"],
54437
+ fields: [...RULE_TEXT],
54438
+ kinds: ["system"],
54439
+ systemEventKinds: [...SUMMARISABLE],
54440
+ systemEventDeliveries: ["summary"]
54441
+ },
54442
+ ...STATE_SUMMARY_SECTION_VARS.map((v) => ({
54443
+ name: v.name,
54444
+ label: v.label,
54445
+ example: v.example,
54446
+ group: "system",
54447
+ families: ["rule"],
54448
+ fields: [...RULE_TEXT],
54449
+ kinds: ["system"],
54450
+ systemEventKinds: [...v.kinds],
54451
+ systemEventDeliveries: ["summary"]
54452
+ }))
54453
+ ];
54454
+ [
54455
+ [...DEVICE_EVENTS],
54456
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
54457
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
54458
+ [...RULE_TEXT],
54459
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
54460
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
54461
+ [...RULE_TEXT],
54462
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
54463
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
54464
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
54465
+ [...RULE_TEXT],
54466
+ [...RULE_TEXT],
54467
+ [...RULE_TEXT],
54468
+ [...RULE_TEXT],
54469
+ [...RULE_TEXT],
54470
+ [...RULE_TEXT],
54471
+ [...RULE_TEXT],
54472
+ [...RULE_TEXT],
54473
+ [...RULE_BODY_ONLY],
54474
+ [...RULE_TEXT],
54475
+ ([...RULE_TEXT], [...DEVICE_EVENTS]),
54476
+ ([...RULE_TEXT], [...DEVICE_EVENTS]),
54477
+ ([...RULE_TEXT], [...BATTERY, ...CONSUMABLE]),
54478
+ ([...RULE_TEXT], [...CONSUMABLE]),
54479
+ ([...RULE_TEXT], [...TANK]),
54480
+ [...RULE_TEXT],
54481
+ ([...RULE_TEXT], [...UPDATES]),
54482
+ ([...RULE_TEXT], [...UPDATES]),
54483
+ [...RULE_TEXT],
54484
+ [...RULE_TEXT],
54485
+ [...RULE_TEXT],
54486
+ ([...RULE_TEXT], [...UPDATES]),
54487
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
54488
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
54489
+ ([...RULE_TEXT], [...UPDATES]),
54490
+ ([...RULE_TEXT], [...UPDATES]),
54491
+ ([...RULE_TEXT], [...PACKAGE_UPDATES]),
54492
+ [...RULE_TEXT],
54493
+ [...RULE_TEXT],
54494
+ [...RULE_TEXT],
54495
+ [...RULE_TEXT],
54496
+ [...RULE_TEXT],
54497
+ [...RULE_TEXT],
54498
+ [...RULE_TEXT],
54499
+ [...RULE_TEXT],
54500
+ [...RULE_TEXT],
54501
+ [...RULE_TEXT],
54502
+ [...RULE_TEXT],
54503
+ [...RULE_TEXT],
54504
+ [...RULE_TEXT],
54505
+ [...RULE_TEXT],
54506
+ [...RULE_TEXT],
54507
+ [...RULE_TEXT],
54508
+ [...RULE_TEXT],
54509
+ [...RULE_TEXT],
54510
+ [...RULE_TEXT],
54511
+ [...RULE_TEXT],
54512
+ [...RULE_TEXT],
54513
+ [...RULE_TEXT],
54514
+ [...RULE_TEXT],
54515
+ [...RULE_TEXT],
54516
+ ...STATE_SUMMARY_VARS
54517
+ ];
53835
54518
  /**
53836
54519
  * TimelapseRule — the STANDALONE scheduled timelapse producer's rule model.
53837
54520
  *