@camstack/addon-provider-homematic 1.2.173 → 1.2.174

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 (19) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/{MotionZonesSettings-CqnDpyqc.mjs → MotionZonesSettings-C72DhAtZ.mjs} +2 -2
  3. package/dist/{PrivacyMaskSettings-6tkdoeER.mjs → PrivacyMaskSettings-DKrvx6p_.mjs} +4 -4
  4. package/dist/{SceneMonitorEditor-BmdszbmG.mjs → SceneMonitorEditor-DfEwUp9i.mjs} +3 -3
  5. package/dist/_stub.js +162 -162
  6. package/dist/{_virtual_mf-localSharedImportMap___mfe_internal__addon_provider_homematic_page-Bn2cfWur.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_provider_homematic_page-pjgfYJxV.mjs} +4 -4
  7. package/dist/_virtual_mf___mfe_internal__addon_provider_homematic_page__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-C1EsOqg_.mjs +26 -0
  8. package/dist/addon.js +2005 -1144
  9. package/dist/addon.mjs +2005 -1144
  10. package/dist/{hostInit-CTd-Vj1N.mjs → hostInit-DCQb2Pfb.mjs} +3 -3
  11. package/dist/{player-overlays-DjlHnIwB.mjs → player-overlays-oe35nJ8t.mjs} +1 -1
  12. package/dist/remoteEntry.js +1 -1
  13. package/dist/{responsive-cQr14mMl.mjs → responsive-tHO3JeA_.mjs} +1 -1
  14. package/dist/{scene-monitor-copy-CJJ7MbTH.mjs → scene-monitor-copy-5nIMkqXt.mjs} +1 -1
  15. package/dist/{square-Co7N2v2G.mjs → square-Dnvvt33F.mjs} +1 -1
  16. package/dist/{trash-2-DJnz9xs3.mjs → trash-2-BNqBavvJ.mjs} +1 -1
  17. package/dist/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_provider_homematic_page__remoteEntry_js-Db3ekXR3.mjs → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_provider_homematic_page__remoteEntry_js-CpRCYtlj.mjs} +1 -1
  18. package/package.json +5 -2
  19. package/dist/_virtual_mf___mfe_internal__addon_provider_homematic_page__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-BhTBBkpt.mjs +0 -26
package/dist/addon.mjs CHANGED
@@ -9,7 +9,7 @@ import { networkInterfaces } from "node:os";
9
9
  var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
10
10
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
11
11
  //#endregion
12
- //#region ../types/dist/event-category-DmZDPDf_.mjs
12
+ //#region ../types/dist/event-category-CaURIwQA.mjs
13
13
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
14
14
  EventCategory["SystemBoot"] = "system.boot";
15
15
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -725,6 +725,10 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
725
725
  EventCategory["NotificationRuleBroken"] = "notification.rule-broken";
726
726
  /** The clear of {@link NotificationRuleBroken}: the rule loads and names nothing deleted. */
727
727
  EventCategory["NotificationRuleRepaired"] = "notification.rule-repaired";
728
+ /** A migration failed or was blocked; the Alert Center re-reads the ledger. */
729
+ EventCategory["MigrationFailed"] = "migration.failed";
730
+ /** A migration applied or a failure cleared; the Alert Center re-reads the ledger. */
731
+ EventCategory["MigrationApplied"] = "migration.applied";
728
732
  EventCategory["DeviceUpdated"] = "device.updated";
729
733
  /**
730
734
  * Transport-level connectivity. Emitted by the device driver when
@@ -787,6 +791,378 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
787
791
  return EventCategory;
788
792
  }({});
789
793
  //#endregion
794
+ //#region ../types/dist/device-type-CEqjmUnR.mjs
795
+ /**
796
+ import { errMsg } from '@camstack/types'
797
+ * Extract a human-readable message from an unknown error value.
798
+ * Replaces the ubiquitous `errMsg(err)` pattern.
799
+ */
800
+ function errMsg(err) {
801
+ if (err instanceof Error) return err.message;
802
+ if (typeof err === "string") return err;
803
+ return String(err);
804
+ }
805
+ var DeviceType = /* @__PURE__ */ function(DeviceType) {
806
+ DeviceType["Camera"] = "camera";
807
+ DeviceType["Hub"] = "hub";
808
+ DeviceType["Light"] = "light";
809
+ DeviceType["Siren"] = "siren";
810
+ DeviceType["Switch"] = "switch";
811
+ DeviceType["Sensor"] = "sensor";
812
+ DeviceType["Thermostat"] = "thermostat";
813
+ /** Air-conditioner / heat-pump climate device (HVAC) — shares the
814
+ * `climate-control` cap surface with `Thermostat` but renders a
815
+ * dedicated AC-appropriate control UI (mode chips, fan speed,
816
+ * independent vertical/horizontal swing). Sources: native Gree, and
817
+ * reusable by other AC integrations. */
818
+ DeviceType["Climate"] = "climate";
819
+ DeviceType["Button"] = "button";
820
+ /** Generic stateless event emitter — carries a device's EXACT declared
821
+ * event vocabulary verbatim (no normalization). Installed with the
822
+ * `event-emitter` cap. Sources: HA `event.*` entities (structured) and
823
+ * HA bus events (e.g. `zha_event`, generic). */
824
+ DeviceType["EventEmitter"] = "event-emitter";
825
+ /** Firmware/software update entity — current vs available version,
826
+ * updatable flag, update state, and an install action. Installed with
827
+ * the `update` cap. Sources: Homematic firmware-update channels (and
828
+ * reusable by other providers, e.g. HA `update.*` entities). */
829
+ DeviceType["Update"] = "update";
830
+ DeviceType["Generic"] = "generic";
831
+ /** Generic notification delivery target (HA `notify.<service>`, future
832
+ * Telegram / Discord / ntfy / SMTP, …). One device per delivery
833
+ * endpoint; the `notifier` cap defines the send surface. */
834
+ DeviceType["Notifier"] = "notifier";
835
+ /** Pre-recorded action sequence with optional parameters
836
+ * (HA `script.*`). Runnable via `script-runner` cap. */
837
+ DeviceType["Script"] = "script";
838
+ /** Automation rule (HA `automation.*`) — enable/disable + manual
839
+ * trigger surface exposed via `automation-control` cap. */
840
+ DeviceType["Automation"] = "automation";
841
+ /** Door / smart lock device (HA `lock.*`). `lock-control` cap. */
842
+ DeviceType["Lock"] = "lock";
843
+ /** Window covering, blinds, garage door, valve, etc. (HA `cover.*`,
844
+ * `valve.*`). `cover` cap with sub-roles for variant. */
845
+ DeviceType["Cover"] = "cover";
846
+ /** Pipe / water / gas valve with open/close/stop and optional
847
+ * position (HA `valve.*`). `valve` cap — a cover-sibling actuator
848
+ * modelled on the same open/closed lifecycle. */
849
+ DeviceType["Valve"] = "valve";
850
+ /** Humidifier / dehumidifier with on/off + target humidity + mode
851
+ * (HA `humidifier.*`). `humidifier` cap — a climate-family actuator
852
+ * modelled on the same target / mode lifecycle. */
853
+ DeviceType["Humidifier"] = "humidifier";
854
+ /** Water heater / boiler with target temperature + operation mode +
855
+ * away mode (HA `water_heater.*`). `water-heater` cap — a
856
+ * climate-family actuator. */
857
+ DeviceType["WaterHeater"] = "water-heater";
858
+ /** Ceiling / standing / exhaust fan (HA `fan.*`). `fan-control` cap. */
859
+ DeviceType["Fan"] = "fan";
860
+ /** Audio / video playback endpoint (HA `media_player.*`). Disjoint from
861
+ * the camera surface — those use `Camera`. `media-player` cap. */
862
+ DeviceType["MediaPlayer"] = "media-player";
863
+ /** Security panel / alarm system (HA `alarm_control_panel.*`).
864
+ * `alarm-panel` cap. */
865
+ DeviceType["AlarmPanel"] = "alarm-panel";
866
+ /** Generic user-settable input (HA `number` / `input_number` / `select`
867
+ * / `input_select` / `text` / `input_text` / `input_datetime`).
868
+ * Sub-type via `DeviceRole`: NumericControl / SelectControl /
869
+ * TextControl / DateTimeControl. */
870
+ DeviceType["Control"] = "control";
871
+ /** Person / device-tracker presence (HA `person.*`, `device_tracker.*`).
872
+ * `presence` cap. */
873
+ DeviceType["Presence"] = "presence";
874
+ /** Weather provider (HA `weather.*`). Tier-3, low MVP priority.
875
+ * `weather` cap. */
876
+ DeviceType["Weather"] = "weather";
877
+ /** Robot vacuum (HA `vacuum.*`). Tier-3. `vacuum-control` cap. */
878
+ DeviceType["Vacuum"] = "vacuum";
879
+ /** Robotic lawn mower (HA `lawn_mower.*`). Tier-3.
880
+ * `lawn-mower-control` cap. */
881
+ DeviceType["LawnMower"] = "lawn-mower";
882
+ /** Physical HA device group — parent container for entity-children
883
+ * adopted from a single HA device entry. Not renderable as a
884
+ * standalone device; exists only to anchor child entities. */
885
+ DeviceType["Container"] = "container";
886
+ /** Single still-image entity (HA `image.*`). Read-only display of an
887
+ * `entity_picture` signed URL the browser loads directly. `image` cap. */
888
+ DeviceType["Image"] = "image";
889
+ /** Smart pet feeder — cloud-connected food dispenser with a bowl food
890
+ * level, battery, desiccant life, feeding state and manual-feed /
891
+ * call-pet / maintenance actions. Installed with the `pet-feeder` cap;
892
+ * dual-hopper models (D4S/D4SH) expose per-hopper portions. Sources:
893
+ * native PetKit (`nodepetkit` `FeederDevice`), reusable by other feeder
894
+ * integrations sharing the same food/desiccant/hopper surface. */
895
+ DeviceType["PetFeeder"] = "pet-feeder";
896
+ /** Pet water fountain — tank level, water drunk, pump and its duty cycle.
897
+ * Installed with the `pet-fountain` cap. Reaches CamStack as loose entities
898
+ * of a container and is BUILT as a composed device (D967). */
899
+ DeviceType["PetFountain"] = "pet-fountain";
900
+ /** Built-in dishwasher — program lifecycle, door / remote-start gates,
901
+ * salt and rinse-aid levels. Installed with the `dishwasher` cap.
902
+ * Sources: native Bosch Home Connect, reusable by similar integrations.
903
+ * A plug-built dishwasher carries running-state and power instead. */
904
+ DeviceType["Dishwasher"] = "dishwasher";
905
+ /** Washing machine. A plug-built one is running while its power stays
906
+ * above a threshold. No program cap — that surface is the dishwasher's. */
907
+ DeviceType["Washer"] = "washer";
908
+ /** Tumble dryer. Same plug-built running surface as {@link Washer}. */
909
+ DeviceType["Dryer"] = "dryer";
910
+ /** The physical bridge box of a vendor ecosystem (Velux KLF-200, and later
911
+ * other radio-to-IP bridges). It carries the box's own facts (firmware,
912
+ * address, connection state) and the actions the box really supports
913
+ * (`reboot`, `device-admin-link`). Products are NOT its children — they are
914
+ * adopted beside it — and its connection settings stay on the integration. */
915
+ DeviceType["Gateway"] = "gateway";
916
+ return DeviceType;
917
+ }({});
918
+ var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
919
+ DeviceFeature["BatteryOperated"] = "battery-operated";
920
+ DeviceFeature["Rebootable"] = "rebootable";
921
+ /**
922
+ * Device supports an on-demand re-sync of its derived spec with its
923
+ * upstream source — drives the generic Re-sync button. The owning
924
+ * provider implements the action via the `device-adoption.resync` cap.
925
+ */
926
+ DeviceFeature["Resyncable"] = "resyncable";
927
+ DeviceFeature["NativeSnapshot"] = "native-snapshot";
928
+ DeviceFeature["DoorbellButton"] = "doorbell-button";
929
+ DeviceFeature["TwoWayAudio"] = "two-way-audio";
930
+ DeviceFeature["PanTiltZoom"] = "pan-tilt-zoom";
931
+ /**
932
+ * Camera supports the on-firmware autotrack subsystem (subject-
933
+ * following). Distinct from `PanTiltZoom` because not every PTZ
934
+ * camera ships autotrack — the admin UI uses this flag to gate
935
+ * the autotrack toggle / settings card without re-deriving from
936
+ * the cap registry. Mirrors `ptz-autotrack` cap registration:
937
+ * driver sets this feature when probe confirms the firmware
938
+ * surface, and registers the cap in the same code path.
939
+ */
940
+ DeviceFeature["PtzAutotrack"] = "ptz-autotrack";
941
+ /**
942
+ * Accessory exposes a "trigger on motion" toggle — the parent camera's
943
+ * motion detection automatically activates this device. Mirrors
944
+ * `motion-trigger` cap registration: drivers set this feature in the
945
+ * same code path that calls `ctx.registerNativeCap(motionTriggerCapability, ...)`.
946
+ *
947
+ * Used by admin UI (gate the in-hero `MotionTriggerToggle` against a
948
+ * fast scalar without binding fetch), notifier rules, and `listAll`
949
+ * filters that want "all devices with on-motion behaviour".
950
+ */
951
+ DeviceFeature["MotionTrigger"] = "motion-trigger";
952
+ /** Light supports rgb-triplet color via `color` cap. */
953
+ DeviceFeature["LightColorRgb"] = "light-color-rgb";
954
+ /** Light supports HSV color via `color` cap. */
955
+ DeviceFeature["LightColorHsv"] = "light-color-hsv";
956
+ /** Light supports color-temperature (mired) via `color` cap. */
957
+ DeviceFeature["LightColorMired"] = "light-color-mired";
958
+ /** Thermostat supports a `heat_cool` dual setpoint (targetLow +
959
+ * targetHigh). Gates the range slider UI. */
960
+ DeviceFeature["ClimateDualSetpoint"] = "climate-dual-setpoint";
961
+ /** Thermostat exposes target humidity and/or current humidity
962
+ * readings. Gates the humidity controls. */
963
+ DeviceFeature["ClimateHumidity"] = "climate-humidity";
964
+ /** Thermostat exposes a fan-mode selector. */
965
+ DeviceFeature["ClimateFanMode"] = "climate-fan-mode";
966
+ /** Thermostat exposes preset modes (eco / away / sleep / vendor). */
967
+ DeviceFeature["ClimatePreset"] = "climate-preset";
968
+ /** Thermostat exposes a vertical louver swing toggle. Gates the
969
+ * vertical-swing switch in the climate UI. Independent of horizontal. */
970
+ DeviceFeature["ClimateSwingVertical"] = "climate-swing-vertical";
971
+ /** Thermostat exposes a horizontal louver swing toggle. Gates the
972
+ * horizontal-swing switch in the climate UI. Independent of vertical. */
973
+ DeviceFeature["ClimateSwingHorizontal"] = "climate-swing-horizontal";
974
+ /** Cover exposes intermediate position control (0..100). Gates the
975
+ * position slider UI. */
976
+ DeviceFeature["CoverPositionable"] = "cover-positionable";
977
+ /** Cover exposes slat-tilt control. Gates the tilt slider UI. */
978
+ DeviceFeature["CoverTilt"] = "cover-tilt";
979
+ /** Valve exposes intermediate position control (0..100). Gates the
980
+ * position slider / drag surface UI. */
981
+ DeviceFeature["ValvePositionable"] = "valve-positionable";
982
+ /** Fan exposes a speed-percentage setter. Gates the speed slider UI. */
983
+ DeviceFeature["FanSpeed"] = "fan-speed";
984
+ /** Fan exposes a preset mode selector. */
985
+ DeviceFeature["FanPreset"] = "fan-preset";
986
+ /** Fan exposes blade direction (forward/reverse) — typical of
987
+ * ceiling fans. */
988
+ DeviceFeature["FanDirection"] = "fan-direction";
989
+ /** Fan exposes an oscillation toggle. */
990
+ DeviceFeature["FanOscillating"] = "fan-oscillating";
991
+ /** Lock requires a PIN code on lock/unlock. Gates the code-entry
992
+ * field on the UI lock-controls panel. */
993
+ DeviceFeature["LockPinRequired"] = "lock-pin-required";
994
+ /** Lock supports a latch-release ("open door") action distinct from
995
+ * unlock. Mirrors HA `LockEntityFeature.OPEN` (bit 1) in
996
+ * `supported_features`. Gates the Open Door button in the UI. */
997
+ DeviceFeature["LockOpen"] = "lock-open";
998
+ /** Media player exposes a seek-to-position surface. */
999
+ DeviceFeature["MediaPlayerSeek"] = "media-player-seek";
1000
+ /** Media player exposes a volume-level setter. */
1001
+ DeviceFeature["MediaPlayerVolume"] = "media-player-volume";
1002
+ /** Media player exposes a mute toggle distinct from volume=0. */
1003
+ DeviceFeature["MediaPlayerMute"] = "media-player-mute";
1004
+ /** Media player exposes a shuffle toggle. */
1005
+ DeviceFeature["MediaPlayerShuffle"] = "media-player-shuffle";
1006
+ /** Media player exposes a repeat mode (off / all / one). */
1007
+ DeviceFeature["MediaPlayerRepeat"] = "media-player-repeat";
1008
+ /** Media player exposes a source / input selector. */
1009
+ DeviceFeature["MediaPlayerSelectSource"] = "media-player-select-source";
1010
+ /** Media player exposes a play-arbitrary-media surface (URL / id). */
1011
+ DeviceFeature["MediaPlayerPlayMedia"] = "media-player-play-media";
1012
+ /** Media player exposes next-track. */
1013
+ DeviceFeature["MediaPlayerNext"] = "media-player-next";
1014
+ /** Media player exposes previous-track. */
1015
+ DeviceFeature["MediaPlayerPrevious"] = "media-player-previous";
1016
+ /** Media player exposes stop distinct from pause. */
1017
+ DeviceFeature["MediaPlayerStop"] = "media-player-stop";
1018
+ /** Alarm panel requires a PIN code on arm/disarm. */
1019
+ DeviceFeature["AlarmPinRequired"] = "alarm-pin-required";
1020
+ /** Presence device carries GPS coordinates (lat/lng/accuracy) in
1021
+ * addition to a textual location. */
1022
+ DeviceFeature["PresenceGps"] = "presence-gps";
1023
+ /** Notifier accepts an inline / URL image attachment. */
1024
+ DeviceFeature["NotifierImage"] = "notifier-image";
1025
+ /** Notifier accepts a priority hint (high/normal/low). */
1026
+ DeviceFeature["NotifierPriority"] = "notifier-priority";
1027
+ /** Notifier accepts a free-form `data` payload for platform-specific
1028
+ * fields. */
1029
+ DeviceFeature["NotifierData"] = "notifier-data";
1030
+ /** Notifier supports interactive action buttons / callbacks. */
1031
+ DeviceFeature["NotifierActions"] = "notifier-actions";
1032
+ /** Notifier supports per-call recipient targeting (multi-user). */
1033
+ DeviceFeature["NotifierRecipients"] = "notifier-recipients";
1034
+ /** Script runner accepts a variables map on each run invocation. */
1035
+ DeviceFeature["ScriptVariables"] = "script-variables";
1036
+ /** Automation `trigger` accepts a skipCondition flag — fires the
1037
+ * automation's actions while bypassing its condition block. */
1038
+ DeviceFeature["AutomationSkipCondition"] = "automation-skip-condition";
1039
+ /** Robot vacuum exposes a live cleaning map (image child). Gates the
1040
+ * map tile in the vacuum UI. */
1041
+ DeviceFeature["VacuumHasMap"] = "vacuum-has-map";
1042
+ /** Robot vacuum exposes AI obstacle-detection toggles. Gates the AI
1043
+ * switches group. */
1044
+ DeviceFeature["VacuumHasAi"] = "vacuum-has-ai";
1045
+ /** Robot mower exposes a live mowing map (SVG image child). Gates the
1046
+ * mower map tile. */
1047
+ DeviceFeature["MowerHasMap"] = "mower-has-map";
1048
+ /** Robot mower exposes targeted mowing (all-area / zones / edges /
1049
+ * spots) — gates the Mow action + map selectors. */
1050
+ DeviceFeature["MowerHasTargetedMowing"] = "mower-has-targeted-mowing";
1051
+ return DeviceFeature;
1052
+ }({});
1053
+ /**
1054
+ * Semantic role a device plays within its parent. Populated by driver
1055
+ * addons when creating accessory devices (Reolink siren/floodlight/
1056
+ * PIR/chime/autotrack/doorbell, ONVIF relay outputs, …). Used by the
1057
+ * admin UI to pick icons, labels, and widgets — a `Switch` with
1058
+ * `role: Floodlight` renders as a bulb with a brightness slider,
1059
+ * whereas a `Switch` with `role: Siren` renders as a klaxon.
1060
+ *
1061
+ * Undefined for top-level devices (cameras, NVRs, hubs). Persisted in
1062
+ * sqlite as a nullable TEXT column — old rows keep working unchanged.
1063
+ */
1064
+ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
1065
+ DeviceRole["Siren"] = "siren";
1066
+ DeviceRole["Floodlight"] = "floodlight";
1067
+ DeviceRole["Spotlight"] = "spotlight";
1068
+ DeviceRole["PirSensor"] = "pir-sensor";
1069
+ DeviceRole["Chime"] = "chime";
1070
+ DeviceRole["Autotrack"] = "autotrack";
1071
+ DeviceRole["Nightvision"] = "nightvision";
1072
+ DeviceRole["PrivacyMask"] = "privacy-mask";
1073
+ DeviceRole["Doorbell"] = "doorbell";
1074
+ /** Interior blind / shade / roller blind. HA `device_class: blind|shade`. */
1075
+ DeviceRole["CoverBlind"] = "cover-blind";
1076
+ /** Exterior roller shutter. HA `device_class: shutter`; Homematic BROLL. */
1077
+ DeviceRole["CoverShutter"] = "cover-shutter";
1078
+ /** Exterior awning. HA `device_class: awning`. */
1079
+ DeviceRole["CoverAwning"] = "cover-awning";
1080
+ /** Curtain / drape. HA `device_class: curtain`. */
1081
+ DeviceRole["CoverCurtain"] = "cover-curtain";
1082
+ /** Garage door. HA `device_class: garage`. A security actuator: exports gate it. */
1083
+ DeviceRole["CoverGarage"] = "cover-garage";
1084
+ /** Gate. HA `device_class: gate`. A security actuator: exports gate it. */
1085
+ DeviceRole["CoverGate"] = "cover-gate";
1086
+ /** Door. HA `device_class: door`. A security actuator: exports gate it. */
1087
+ DeviceRole["CoverDoor"] = "cover-door";
1088
+ /** Window. HA `device_class: window`. */
1089
+ DeviceRole["CoverWindow"] = "cover-window";
1090
+ /** Virtual HA toggle (input_boolean.*) — distinguishable from a
1091
+ * real Switch device for UI rendering / export adapters. */
1092
+ DeviceRole["BinaryHelper"] = "binary-helper";
1093
+ /** A smart plug: a `switch` whose source says it is an outlet (HA
1094
+ * `device_class: outlet`). The Alexa export shows it as a SMARTPLUG. */
1095
+ DeviceRole["Outlet"] = "outlet";
1096
+ /** Generic motion / occupancy / moving event source. Distinct from
1097
+ * the camera accessory PirSensor role: that one is a camera child;
1098
+ * this is a standalone HA / 3rd-party motion sensor. */
1099
+ DeviceRole["MotionSensor"] = "motion-sensor";
1100
+ DeviceRole["ContactSensor"] = "contact-sensor";
1101
+ DeviceRole["LeakSensor"] = "leak-sensor";
1102
+ DeviceRole["SmokeSensor"] = "smoke-sensor";
1103
+ DeviceRole["COSensor"] = "co-sensor";
1104
+ DeviceRole["GasSensor"] = "gas-sensor";
1105
+ DeviceRole["TamperSensor"] = "tamper-sensor";
1106
+ DeviceRole["VibrationSensor"] = "vibration-sensor";
1107
+ DeviceRole["ConnectivitySensor"] = "connectivity-sensor";
1108
+ DeviceRole["SoundSensor"] = "sound-sensor";
1109
+ /** Fallback for `binary_sensor` without a known `device_class`. */
1110
+ DeviceRole["BinarySensor"] = "binary-sensor";
1111
+ DeviceRole["TemperatureSensor"] = "temperature-sensor";
1112
+ DeviceRole["HumiditySensor"] = "humidity-sensor";
1113
+ DeviceRole["AmbientLightSensor"] = "ambient-light-sensor";
1114
+ DeviceRole["PressureSensor"] = "pressure-sensor";
1115
+ /** Wind speed or direction (weather-station `wind-sensor` cap). */
1116
+ DeviceRole["WindSensor"] = "wind-sensor";
1117
+ /** Rain accumulation or rate (weather-station `rain-sensor` cap). */
1118
+ DeviceRole["RainSensor"] = "rain-sensor";
1119
+ /** UV index (weather-station `uv-sensor` cap). */
1120
+ DeviceRole["UvSensor"] = "uv-sensor";
1121
+ /** Solar irradiance W/m² (weather-station `solar-radiation-sensor` cap).
1122
+ * Distinct from AmbientLightSensor (lux). */
1123
+ DeviceRole["SolarRadiationSensor"] = "solar-radiation-sensor";
1124
+ /** Soil moisture % (garden/weather `soil-moisture-sensor` cap). */
1125
+ DeviceRole["SoilMoistureSensor"] = "soil-moisture-sensor";
1126
+ DeviceRole["PowerSensor"] = "power-sensor";
1127
+ DeviceRole["EnergySensor"] = "energy-sensor";
1128
+ DeviceRole["VoltageSensor"] = "voltage-sensor";
1129
+ DeviceRole["CurrentSensor"] = "current-sensor";
1130
+ DeviceRole["AirQualitySensor"] = "air-quality-sensor";
1131
+ /** Battery level (numeric % via `sensor` OR low-bool via
1132
+ * `binary_sensor` — the cap distinguishes via the value type). */
1133
+ DeviceRole["BatterySensor"] = "battery-sensor";
1134
+ /** Fallback for `sensor` numeric without a known `device_class`. */
1135
+ DeviceRole["NumericSensor"] = "numeric-sensor";
1136
+ /** String / enum state (HA `sensor` with `state_class: enum` or
1137
+ * `attributes.options`). */
1138
+ DeviceRole["EnumSensor"] = "enum-sensor";
1139
+ /** Date / timestamp state (HA `sensor` with `device_class: timestamp`
1140
+ * or `date`). The slice carries the raw ISO string verbatim (hosted on
1141
+ * the `enum-sensor` cap); the UI renders it locale-formatted. */
1142
+ DeviceRole["DateTimeSensor"] = "datetime-sensor";
1143
+ /** Last-resort fallback when nothing else matches. */
1144
+ DeviceRole["GenericSensor"] = "generic-sensor";
1145
+ DeviceRole["NumericControl"] = "numeric-control";
1146
+ DeviceRole["SelectControl"] = "select-control";
1147
+ DeviceRole["TextControl"] = "text-control";
1148
+ DeviceRole["DateTimeControl"] = "datetime-control";
1149
+ /** Mobile push notifier (HA `notify.mobile_app_*`) — supports
1150
+ * rich features (image, priority, channel routing). */
1151
+ DeviceRole["MobilePushNotifier"] = "mobile-push-notifier";
1152
+ /** Chat / messaging service (HA `notify.telegram_*`,
1153
+ * `notify.discord_*`, etc.). */
1154
+ DeviceRole["MessagingNotifier"] = "messaging-notifier";
1155
+ /** Email-based delivery (HA `notify.smtp`, etc.). */
1156
+ DeviceRole["EmailNotifier"] = "email-notifier";
1157
+ /** Fallback when the notifier service name doesn't match a known
1158
+ * pattern. */
1159
+ DeviceRole["GenericNotifier"] = "generic-notifier";
1160
+ /** Emits a pulse train (infrared or RF) on request — the `ir-transmitter`
1161
+ * cap. A `DeviceType.Generic` device. */
1162
+ DeviceRole["IrTransmitter"] = "ir-transmitter";
1163
+ return DeviceRole;
1164
+ }({});
1165
+ //#endregion
790
1166
  //#region ../../node_modules/zod/v4/core/core.js
791
1167
  var _a$1;
792
1168
  function $constructor(name, initializer, params) {
@@ -5465,7 +5841,7 @@ var ZodIssueCode = {
5465
5841
  var ZodFirstPartyTypeKind;
5466
5842
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5467
5843
  //#endregion
5468
- //#region ../types/dist/sleep-DSVWZfJC.mjs
5844
+ //#region ../types/dist/sleep-CSYuxssh.mjs
5469
5845
  /**
5470
5846
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5471
5847
  * window to float samples (D455).
@@ -5981,6 +6357,102 @@ function emitReadiness(bus, params) {
5981
6357
  ts
5982
6358
  }));
5983
6359
  }
6360
+ var NOT_RUN = {
6361
+ declared: false,
6362
+ snapshot: null,
6363
+ applied: [],
6364
+ failed: [],
6365
+ blocked: [],
6366
+ skipped: [],
6367
+ blockOwner: []
6368
+ };
6369
+ /**
6370
+ * Offer `migrations` to the engine and run what it says to run, in its order. Never
6371
+ * throws: an unreachable or refusing engine is logged and reported `declared: false`,
6372
+ * because the hub (and this addon's boot) must not hang on a migration.
6373
+ */
6374
+ async function runAddonMigrations(host, migrations, logger) {
6375
+ const first = migrations[0];
6376
+ if (first === void 0) return NOT_RUN;
6377
+ const owner = first.meta.owner;
6378
+ const log = logger.withTags({ migrationOwner: owner });
6379
+ const byId = new Map(migrations.map((m) => [m.meta.id, m]));
6380
+ let declaration;
6381
+ try {
6382
+ declaration = await host.declareOwner({
6383
+ owner,
6384
+ metas: migrations.map((m) => m.meta)
6385
+ });
6386
+ } catch (err) {
6387
+ log.error("the migration engine refused or could not take this addon catalogue — none ran", { meta: { error: errMsg(err) } });
6388
+ return {
6389
+ ...NOT_RUN,
6390
+ blockOwner: migrations.filter((m) => m.meta.onFailure === "block-owner").map((m) => m.meta.id)
6391
+ };
6392
+ }
6393
+ const applied = [];
6394
+ const failed = [];
6395
+ const blocked = [];
6396
+ const skipped = [];
6397
+ const settle = (id, status) => {
6398
+ if (status === "applied") applied.push(id);
6399
+ else if (status === "failed") failed.push(id);
6400
+ else if (status === "blocked") blocked.push(id);
6401
+ else skipped.push(id);
6402
+ };
6403
+ for (const step of declaration.steps) {
6404
+ const bound = byId.get(step.id);
6405
+ if (bound === void 0 || step.action === "skip") {
6406
+ skipped.push(step.id);
6407
+ continue;
6408
+ }
6409
+ const tags = { migrationId: step.id };
6410
+ try {
6411
+ const gate = await host.startMigration({ id: step.id });
6412
+ if (!gate.proceed) {
6413
+ log.warn("migration not run", {
6414
+ tags,
6415
+ meta: {
6416
+ state: gate.state,
6417
+ reason: gate.reason
6418
+ }
6419
+ });
6420
+ settle(step.id, gate.state === "pending" ? "blocked" : gate.state);
6421
+ continue;
6422
+ }
6423
+ const result = await bound.execute();
6424
+ const outcome = await host.finishMigration({
6425
+ id: step.id,
6426
+ result
6427
+ });
6428
+ if (outcome.status === "applied") log.info("migration applied", {
6429
+ tags,
6430
+ meta: { rowsChanged: outcome.rowsChanged }
6431
+ });
6432
+ else log.error("migration failed", {
6433
+ tags,
6434
+ meta: { error: outcome.error }
6435
+ });
6436
+ settle(step.id, outcome.status);
6437
+ } catch (err) {
6438
+ log.error("migration could not be completed with the engine", {
6439
+ tags,
6440
+ meta: { error: errMsg(err) }
6441
+ });
6442
+ failed.push(step.id);
6443
+ }
6444
+ }
6445
+ const blockOwner = [...failed, ...blocked].filter((id) => byId.get(id)?.meta.onFailure === "block-owner");
6446
+ return {
6447
+ declared: true,
6448
+ snapshot: declaration.snapshot,
6449
+ applied,
6450
+ failed,
6451
+ blocked,
6452
+ skipped,
6453
+ blockOwner
6454
+ };
6455
+ }
5984
6456
  /**
5985
6457
  * Build a {@link DurableState} over a single store key. Transport-agnostic:
5986
6458
  * `read`/`write` are the addon-store or device-store accessors. The whole
@@ -7036,6 +7508,28 @@ var BaseAddon = class {
7036
7508
  return normalized;
7037
7509
  }
7038
7510
  /**
7511
+ * Run this addon's migration catalogue (D987 M3) through the hub's `migrations`
7512
+ * engine. Call it at the point of the boot where the data must already have the new
7513
+ * shape — `onInitialize`, or `onRestoreDevices` for a migration that needs the
7514
+ * restored devices — with the catalogue bound to the addon's ports
7515
+ * (`defineAddonMigrations(ADDON_MIGRATIONS, ports)`).
7516
+ *
7517
+ * An engine that cannot be reached or refuses the catalogue is logged and runs
7518
+ * nothing; the boot continues. A migration that FAILED (or was blocked by one)
7519
+ * and declares `onFailure: 'block-owner'` makes this throw, so the addon does not
7520
+ * serve data whose shape it cannot trust; `tolerate` migrations never do.
7521
+ */
7522
+ async runMigrations(migrations) {
7523
+ const api = this.ctx.api.migrations;
7524
+ const report = await runAddonMigrations({
7525
+ declareOwner: (input) => api.declareOwner.mutate(input),
7526
+ startMigration: (input) => api.startMigration.mutate(input),
7527
+ finishMigration: (input) => api.finishMigration.mutate(input)
7528
+ }, migrations, this.ctx.logger);
7529
+ if (report.blockOwner.length > 0) throw new Error(`migration(s) ${report.blockOwner.join(", ")} did not apply and block this addon — fix or retry them (migrations.retry), then restart it`);
7530
+ return report;
7531
+ }
7532
+ /**
7039
7533
  * Called by the isolated-process runner AFTER `broker.start()`.
7040
7534
  * In-process addons never need this because the hub broker is already
7041
7535
  * running when `initialize()` fires. For forked children the broker
@@ -8145,407 +8639,6 @@ var RecordKindDeclarationSchema = object({
8145
8639
  }).strict();
8146
8640
  /** The kind names: lower-case, dash separated, short enough for an index name. */
8147
8641
  var RecordKindNameSchema = string().regex(/^[a-z][a-z0-9-]{0,47}$/);
8148
- var READING_QUANTITIES = [
8149
- "temperature",
8150
- "pressure",
8151
- "speed",
8152
- "precipitation",
8153
- "precipitation-rate",
8154
- "length",
8155
- "area",
8156
- "illuminance",
8157
- "irradiance",
8158
- "power",
8159
- "energy",
8160
- "voltage",
8161
- "current",
8162
- "apparent-power",
8163
- "humidity",
8164
- "percentage",
8165
- "concentration-volume",
8166
- "concentration-mass",
8167
- "concentration-ppb",
8168
- "volume",
8169
- "duration",
8170
- "duration-ms",
8171
- "information",
8172
- "sound-level",
8173
- "signal-level",
8174
- "colour-temperature",
8175
- "angle",
8176
- "bitrate",
8177
- "rate",
8178
- "mass",
8179
- "index",
8180
- "ratio",
8181
- "count",
8182
- "none",
8183
- "device"
8184
- ];
8185
- var ReadingQuantitySchema = _enum(READING_QUANTITIES);
8186
- new Set(READING_QUANTITIES);
8187
- /**
8188
- * Stored unit symbol for a quantity. `none` means the number is dimensionless
8189
- * (or an index / ratio / count). `device` means the cap has no single unit.
8190
- */
8191
- var QUANTITY_BASE = {
8192
- temperature: "°C",
8193
- pressure: "hPa",
8194
- speed: "m/s",
8195
- precipitation: "mm",
8196
- "precipitation-rate": "mm/h",
8197
- length: "m",
8198
- area: "m²",
8199
- illuminance: "lx",
8200
- irradiance: "W/m²",
8201
- power: "W",
8202
- energy: "kWh",
8203
- voltage: "V",
8204
- current: "A",
8205
- "apparent-power": "VA",
8206
- humidity: "%",
8207
- percentage: "%",
8208
- "concentration-volume": "ppm",
8209
- "concentration-mass": "µg/m³",
8210
- "concentration-ppb": "ppb",
8211
- volume: "L",
8212
- duration: "s",
8213
- "duration-ms": "ms",
8214
- information: "B",
8215
- "sound-level": "dBFS",
8216
- "signal-level": "dBm",
8217
- "colour-temperature": "mired",
8218
- angle: "°",
8219
- bitrate: "kbps",
8220
- rate: "fps",
8221
- mass: "kg",
8222
- index: "none",
8223
- ratio: "none",
8224
- count: "none",
8225
- none: "none",
8226
- device: "device"
8227
- };
8228
- /** The stored unit, or `undefined` when the quantity has no unit symbol. */
8229
- function baseUnitOf(quantity) {
8230
- const symbol = QUANTITY_BASE[quantity];
8231
- if (symbol === "none" || symbol === "device") return void 0;
8232
- return symbol;
8233
- }
8234
- function readingMeta(quantity, extras) {
8235
- return {
8236
- quantity,
8237
- ...extras?.precision !== void 0 ? { precision: extras.precision } : {},
8238
- ...extras?.label !== void 0 ? { label: extras.label } : {}
8239
- };
8240
- }
8241
- /** Shared Zod schemas used across streaming capabilities. */
8242
- var CamProfileSchema = _enum([
8243
- "high",
8244
- "mid",
8245
- "low"
8246
- ]);
8247
- /**
8248
- * Which rung a per-camera consumer listens on: an explicit profile, or `auto`.
8249
- *
8250
- * `auto` is a REAL value, not an absent one — it means "resolve it by the rule
8251
- * that consumer owns". It lives beside `CamProfile` because a rung is the only
8252
- * operator-facing way to name a stream: a cam-stream id is broker-internal and
8253
- * moves when a slot is reassigned, so a stored id silently stops meaning what
8254
- * the operator picked. Today's one user is the audio analyser, whose rule is
8255
- * "the lowest AVAILABLE native rung" (D537).
8256
- */
8257
- var AudioStreamPickSchema = union([CamProfileSchema, literal("auto")]);
8258
- var CamStreamKindSchema = _enum([
8259
- "pull-rtsp",
8260
- "pull-rtmp",
8261
- "pull-http",
8262
- "pull-flv",
8263
- "pull-rfc4571",
8264
- "push-annexb",
8265
- "derived"
8266
- ]);
8267
- var CamStreamResolutionSchema = object({
8268
- width: number().int().positive().meta(readingMeta("none")),
8269
- height: number().int().positive().meta(readingMeta("none"))
8270
- });
8271
- var CameraStreamSchema = object({
8272
- /** Stable, provider-assigned id unique within the (deviceId) scope. */
8273
- camStreamId: string().min(1),
8274
- deviceId: number().int().nonnegative(),
8275
- kind: CamStreamKindSchema,
8276
- /** Required for pull-* kinds. Ignored for push-annexb. */
8277
- url: string().optional(),
8278
- codec: string().optional(),
8279
- resolution: CamStreamResolutionSchema.optional(),
8280
- fps: number().positive().optional(),
8281
- /** Human label surfaced in the Admin UI "Camera Stream" dropdown. */
8282
- label: string().optional(),
8283
- /**
8284
- * Device-level features the publisher advertised (e.g. `battery-operated`).
8285
- * The broker, snapshot orchestrator, and prebuffer manager all consult
8286
- * this list to derive policy — relaxed stall watchdog for battery
8287
- * cams, prebuffer off by default, longer snapshot rate-limit, etc.
8288
- *
8289
- * Single source of truth replacing per-stream flags like the
8290
- * historical `allowStall`: if the publisher knows the camera is
8291
- * battery-powered, every downstream service derives the right policy
8292
- * from this list.
8293
- */
8294
- deviceFeatures: array(string()).optional(),
8295
- /**
8296
- * Whether this stream participates in the broker's automatic profile
8297
- * assignment (`computeInitialAssignment`). Defaults to `true`. Publishers
8298
- * use `false` when they want a stream to be SELECTABLE in the UI but not
8299
- * picked by default — e.g. Reolink publishes its native Baichuan streams
8300
- * as `autoEligible: true` (the recommended path) and its RTSP / RTMP
8301
- * mirrors as `autoEligible: false` (still pickable per slot, just not
8302
- * the auto choice). Manual `assignProfile` calls remain valid for
8303
- * non-eligible streams.
8304
- */
8305
- autoEligible: boolean().optional(),
8306
- /**
8307
- * The profile slot the PUBLISHER says this stream is: `low` for a stream
8308
- * whose only sensible role is the low-bandwidth one, `high` for a main
8309
- * stream. Consulted by the broker's automatic ranking
8310
- * (`rankInitialAssignment`) BEFORE the pixel-count heuristic, and only there:
8311
- * an operator's manual assignment still wins, and an absent hint is the
8312
- * pixel-ranked default every camera had before this field existed.
8313
- *
8314
- * Why it exists: a camera with ONE stream ranked to `mid` — the slot no
8315
- * storage class is written for on its own (`recordings` is high|mid,
8316
- * `recordingsLow` is low) and the one profile scrub does not read. The robot
8317
- * camera's single 720p relay is a `low` in every respect except the slot the
8318
- * heuristic put it in.
8319
- */
8320
- profileHint: CamProfileSchema.optional(),
8321
- /**
8322
- * Transport-specific opaque metadata. The broker passes it through to
8323
- * the source reader without inspecting it. Currently used by
8324
- * `pull-rfc4571` streams to carry the upstream SDP (so the reader can
8325
- * route RTP packets to the right depacketizer without an in-band
8326
- * DESCRIBE phase). Other kinds typically leave it undefined.
8327
- */
8328
- metadata: record(string(), unknown()).optional()
8329
- });
8330
- var ProfileSlotStatusSchema = _enum([
8331
- "unassigned",
8332
- "idle",
8333
- "connecting",
8334
- "streaming",
8335
- "error"
8336
- ]);
8337
- var ProfileSlotSchema = object({
8338
- deviceId: number().int().nonnegative(),
8339
- profile: CamProfileSchema,
8340
- /** Broker id the rest of the system addresses: `${deviceId}/${profile}`. */
8341
- brokerId: string(),
8342
- /** `null` when the profile is unassigned. */
8343
- sourceCamStreamId: string().nullable(),
8344
- status: ProfileSlotStatusSchema,
8345
- resolution: CamStreamResolutionSchema.optional(),
8346
- codec: string().optional(),
8347
- preBufferSec: number().nonnegative().optional(),
8348
- errorMessage: string().optional()
8349
- });
8350
- /**
8351
- * Zod schema for StreamSourceEntry — the canonical stream descriptor
8352
- * exposed by ICameraDevice.getStreamSources() and consumed by the broker.
8353
- */
8354
- var StreamSourceEntrySchema$1 = object({
8355
- id: string(),
8356
- label: string(),
8357
- protocol: _enum([
8358
- "rtsp",
8359
- "rtmp",
8360
- "annexb",
8361
- "http-mjpeg",
8362
- "webrtc",
8363
- "custom"
8364
- ]),
8365
- url: string().optional(),
8366
- resolution: object({
8367
- width: number(),
8368
- height: number()
8369
- }).readonly().optional(),
8370
- fps: number().optional(),
8371
- bitrate: number().optional(),
8372
- codec: string().optional(),
8373
- profileHint: CamProfileSchema.optional()
8374
- });
8375
- object({
8376
- type: string(),
8377
- url: string(),
8378
- videoCodec: string().optional(),
8379
- audioCodec: string().optional(),
8380
- metadata: record(string(), unknown()).readonly().optional()
8381
- });
8382
- /**
8383
- * Wire schema for `FrameHandle` — a zero-pixel, serialisable reference to a
8384
- * frame in a shared-memory ring (Phase 5 / D9). Mirrors the `FrameHandle` TS
8385
- * interface in `interfaces/frame-handle.ts` field-for-field so a cap method
8386
- * (the runner's native-crop and pipeline-executor inputs) can carry handles
8387
- * over tRPC / Moleculer.
8388
- *
8389
- * The `satisfies` assertion below pins this schema to the interface: if a
8390
- * field is added to / removed from `FrameHandle` without a matching schema
8391
- * edit, `z.infer<typeof FrameHandleSchema>` stops being assignable to
8392
- * `FrameHandle` and the build fails — no silent drift.
8393
- */
8394
- var FrameHandleSchema = object({
8395
- shmId: string(),
8396
- slot: number().int().nonnegative(),
8397
- seq: number().int().nonnegative(),
8398
- width: number().int().positive(),
8399
- height: number().int().positive(),
8400
- format: _enum([
8401
- "jpeg",
8402
- "rgb",
8403
- "bgr",
8404
- "yuv420",
8405
- "gray"
8406
- ]),
8407
- pts: number(),
8408
- byteLength: number().int().nonnegative(),
8409
- nodeId: string(),
8410
- slotCount: number().int().positive()
8411
- });
8412
- /**
8413
- * Wire schema for a decoded audio chunk (Phase 5 / D9). Mirrors the
8414
- * `DecodedAudioChunk` TS interface in `interfaces/stream-broker.ts`: PCM
8415
- * sample bytes plus the track parameters a consumer needs to interpret them.
8416
- *
8417
- * Audio chunks are tiny (a ~500ms AudioCodecSession window is a few KB of
8418
- * Float32 PCM), so unlike video frames they ship their bytes INLINE over
8419
- * tRPC / Moleculer — no shared-memory plane. `data` is typed `Uint8Array`
8420
- * (the wire-serialisable supertype of `Buffer`); a `Buffer` is assignable to
8421
- * it.
8422
- */
8423
- var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
8424
- var DecodedAudioChunkSchema = object({
8425
- data: _instanceof(Uint8Array),
8426
- sampleRate: number().int().positive(),
8427
- channels: number().int().positive(),
8428
- timestamp: number(),
8429
- /**
8430
- * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
8431
- * byte, for any peer that never heard of this field. A coded window
8432
- * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
8433
- * subscription that DECLARED it accepts one, so absence can never mean
8434
- * "coded bytes a consumer will read as floats" (D455).
8435
- */
8436
- format: AudioChunkFormatSchema.optional()
8437
- });
8438
- /**
8439
- * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). Audio ships
8440
- * its bytes inline: a consumer asks the broker for the decoded audio-chunk
8441
- * stream of one broker; the broker keeps a per-subscription bounded FIFO queue
8442
- * the consumer drains via `pullAudioChunks`.
8443
- */
8444
- var SubscribeAudioChunksInputSchema = object({
8445
- brokerId: string(),
8446
- /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
8447
- tag: string().optional(),
8448
- /**
8449
- * Byte formats this subscriber can READ, best first. The broker serves the
8450
- * chunk's own format when it is in this list and expands to `f32le`
8451
- * otherwise, so a subscriber is never handed bytes it cannot interpret.
8452
- *
8453
- * Absent (or without the source format) means `f32le` — the behaviour every
8454
- * subscriber had before D455, unchanged. This is the negotiation half of
8455
- * the source-bytes lever: it is what lets the broker and its consumers
8456
- * deploy one at a time across three nodes.
8457
- */
8458
- accept: array(AudioChunkFormatSchema).readonly().optional()
8459
- });
8460
- /** Result of `stream-broker.subscribeAudioChunks`. */
8461
- var SubscribeAudioChunksResultSchema = object({
8462
- /** Opaque id passed to `pullAudioChunks` / `unsubscribeAudioChunks`. */
8463
- subscriptionId: string() });
8464
- var BrokerStatsSchema = object({
8465
- status: _enum([
8466
- "idle",
8467
- "connecting",
8468
- "streaming",
8469
- "error",
8470
- "stopped"
8471
- ]),
8472
- inputFps: number(),
8473
- encodedSubscribers: number(),
8474
- uptimeMs: number(),
8475
- bitrateKbps: number(),
8476
- idrIntervalMs: number(),
8477
- codec: string().optional(),
8478
- totalBytes: number(),
8479
- packetCount: number(),
8480
- rtspClients: number(),
8481
- pipeClients: number(),
8482
- preBufferSec: number(),
8483
- preBufferMs: number(),
8484
- preBufferPackets: number(),
8485
- /**
8486
- * Detected audio track parameters from the RTSP DESCRIBE / SDP. `null`
8487
- * when the stream has no audio track or the broker is in cold start.
8488
- * `supported = false` means the codec was detected but the local
8489
- * decoder pipeline cannot produce PCM chunks (e.g. AAC without the
8490
- * AAC pipeline wired). Surfaced in the UI device-overview so operators
8491
- * can pre-pick the audio-analysis model that matches the codec.
8492
- */
8493
- audio: object({
8494
- codec: string(),
8495
- sampleRate: number(),
8496
- channels: number(),
8497
- supported: boolean()
8498
- }).nullable().optional(),
8499
- /**
8500
- * BROKER-SIDE AUDIO MUTE (D83). `true` = this broker is deliberately
8501
- * distributing none of the device's audio, on live or recording.
8502
- *
8503
- * Present so a silent camera can be told apart from a broken one on the
8504
- * stream panel itself, without cross-referencing the switch group: a
8505
- * broker holding an `audio` track descriptor while `audioMuted` is true is
8506
- * working exactly as asked. `audioMutedDropped` counts the audio units
8507
- * thrown away since the current dial — it is how you confirm from stats
8508
- * alone that the mute is on the packet path and not merely persisted.
8509
- */
8510
- audioMuted: boolean().optional(),
8511
- audioMutedDropped: number().optional()
8512
- });
8513
- /**
8514
- * Exporter-facing "profile restream" entry. Returned by
8515
- * `cameraStreams.getProfileRtspEntries` — one per ASSIGNED profile slot
8516
- * (high/mid/low). `brokerId` is the PROFILE-keyed broker id
8517
- * (`${deviceId}/${profile}`, e.g. `15/high`); its `url` is a broker
8518
- * RTSP restream that aliases the profile's assigned source broker, so
8519
- * every consumer dialling a profile converges on the same single pull.
8520
- * `codec`/`resolution` describe the assigned SOURCE camStream (for the
8521
- * `auto` resolution-closest pick). Distinct from `RtspRestreamEntry`
8522
- * (raw per-camStream, live-view only).
8523
- */
8524
- var ProfileRtspEntrySchema = object({
8525
- profile: CamProfileSchema,
8526
- /** Profile-keyed broker id, format `${deviceId}/${profile}` (e.g. `"15/high"`). */
8527
- brokerId: string(),
8528
- url: string(),
8529
- mutedUrl: string(),
8530
- enabled: boolean(),
8531
- codec: string().optional(),
8532
- resolution: CamStreamResolutionSchema.optional()
8533
- });
8534
- /**
8535
- * The model weight formats a catalog entry can ship. Schema-free on purpose:
8536
- * `types/models.ts` builds Zod schemas from it, but a runner-closure consumer
8537
- * (the model downloader in `@camstack/system`) needs only the list and must
8538
- * reach it through `@camstack/types/addon` without building the cap schema
8539
- * graph (D28).
8540
- */
8541
- var MODEL_FORMATS = [
8542
- "onnx",
8543
- "coreml",
8544
- "openvino",
8545
- "tflite",
8546
- "pt",
8547
- "gguf"
8548
- ];
8549
8642
  object({
8550
8643
  field: string().min(1),
8551
8644
  on: literal("advance")
@@ -8638,6 +8731,407 @@ function optionalMethod(input, output, options) {
8638
8731
  function event(data) {
8639
8732
  return { data };
8640
8733
  }
8734
+ var READING_QUANTITIES = [
8735
+ "temperature",
8736
+ "pressure",
8737
+ "speed",
8738
+ "precipitation",
8739
+ "precipitation-rate",
8740
+ "length",
8741
+ "area",
8742
+ "illuminance",
8743
+ "irradiance",
8744
+ "power",
8745
+ "energy",
8746
+ "voltage",
8747
+ "current",
8748
+ "apparent-power",
8749
+ "humidity",
8750
+ "percentage",
8751
+ "concentration-volume",
8752
+ "concentration-mass",
8753
+ "concentration-ppb",
8754
+ "volume",
8755
+ "duration",
8756
+ "duration-ms",
8757
+ "information",
8758
+ "sound-level",
8759
+ "signal-level",
8760
+ "colour-temperature",
8761
+ "angle",
8762
+ "bitrate",
8763
+ "rate",
8764
+ "mass",
8765
+ "index",
8766
+ "ratio",
8767
+ "count",
8768
+ "none",
8769
+ "device"
8770
+ ];
8771
+ var ReadingQuantitySchema = _enum(READING_QUANTITIES);
8772
+ new Set(READING_QUANTITIES);
8773
+ /**
8774
+ * Stored unit symbol for a quantity. `none` means the number is dimensionless
8775
+ * (or an index / ratio / count). `device` means the cap has no single unit.
8776
+ */
8777
+ var QUANTITY_BASE = {
8778
+ temperature: "°C",
8779
+ pressure: "hPa",
8780
+ speed: "m/s",
8781
+ precipitation: "mm",
8782
+ "precipitation-rate": "mm/h",
8783
+ length: "m",
8784
+ area: "m²",
8785
+ illuminance: "lx",
8786
+ irradiance: "W/m²",
8787
+ power: "W",
8788
+ energy: "kWh",
8789
+ voltage: "V",
8790
+ current: "A",
8791
+ "apparent-power": "VA",
8792
+ humidity: "%",
8793
+ percentage: "%",
8794
+ "concentration-volume": "ppm",
8795
+ "concentration-mass": "µg/m³",
8796
+ "concentration-ppb": "ppb",
8797
+ volume: "L",
8798
+ duration: "s",
8799
+ "duration-ms": "ms",
8800
+ information: "B",
8801
+ "sound-level": "dBFS",
8802
+ "signal-level": "dBm",
8803
+ "colour-temperature": "mired",
8804
+ angle: "°",
8805
+ bitrate: "kbps",
8806
+ rate: "fps",
8807
+ mass: "kg",
8808
+ index: "none",
8809
+ ratio: "none",
8810
+ count: "none",
8811
+ none: "none",
8812
+ device: "device"
8813
+ };
8814
+ /** The stored unit, or `undefined` when the quantity has no unit symbol. */
8815
+ function baseUnitOf(quantity) {
8816
+ const symbol = QUANTITY_BASE[quantity];
8817
+ if (symbol === "none" || symbol === "device") return void 0;
8818
+ return symbol;
8819
+ }
8820
+ function readingMeta(quantity, extras) {
8821
+ return {
8822
+ quantity,
8823
+ ...extras?.precision !== void 0 ? { precision: extras.precision } : {},
8824
+ ...extras?.label !== void 0 ? { label: extras.label } : {}
8825
+ };
8826
+ }
8827
+ /** Shared Zod schemas used across streaming capabilities. */
8828
+ var CamProfileSchema = _enum([
8829
+ "high",
8830
+ "mid",
8831
+ "low"
8832
+ ]);
8833
+ /**
8834
+ * Which rung a per-camera consumer listens on: an explicit profile, or `auto`.
8835
+ *
8836
+ * `auto` is a REAL value, not an absent one — it means "resolve it by the rule
8837
+ * that consumer owns". It lives beside `CamProfile` because a rung is the only
8838
+ * operator-facing way to name a stream: a cam-stream id is broker-internal and
8839
+ * moves when a slot is reassigned, so a stored id silently stops meaning what
8840
+ * the operator picked. Today's one user is the audio analyser, whose rule is
8841
+ * "the lowest AVAILABLE native rung" (D537).
8842
+ */
8843
+ var AudioStreamPickSchema = union([CamProfileSchema, literal("auto")]);
8844
+ var CamStreamKindSchema = _enum([
8845
+ "pull-rtsp",
8846
+ "pull-rtmp",
8847
+ "pull-http",
8848
+ "pull-flv",
8849
+ "pull-rfc4571",
8850
+ "push-annexb",
8851
+ "derived"
8852
+ ]);
8853
+ var CamStreamResolutionSchema = object({
8854
+ width: number().int().positive().meta(readingMeta("none")),
8855
+ height: number().int().positive().meta(readingMeta("none"))
8856
+ });
8857
+ var CameraStreamSchema = object({
8858
+ /** Stable, provider-assigned id unique within the (deviceId) scope. */
8859
+ camStreamId: string().min(1),
8860
+ deviceId: number().int().nonnegative(),
8861
+ kind: CamStreamKindSchema,
8862
+ /** Required for pull-* kinds. Ignored for push-annexb. */
8863
+ url: string().optional(),
8864
+ codec: string().optional(),
8865
+ resolution: CamStreamResolutionSchema.optional(),
8866
+ fps: number().positive().optional(),
8867
+ /** Human label surfaced in the Admin UI "Camera Stream" dropdown. */
8868
+ label: string().optional(),
8869
+ /**
8870
+ * Device-level features the publisher advertised (e.g. `battery-operated`).
8871
+ * The broker, snapshot orchestrator, and prebuffer manager all consult
8872
+ * this list to derive policy — relaxed stall watchdog for battery
8873
+ * cams, prebuffer off by default, longer snapshot rate-limit, etc.
8874
+ *
8875
+ * Single source of truth replacing per-stream flags like the
8876
+ * historical `allowStall`: if the publisher knows the camera is
8877
+ * battery-powered, every downstream service derives the right policy
8878
+ * from this list.
8879
+ */
8880
+ deviceFeatures: array(string()).optional(),
8881
+ /**
8882
+ * Whether this stream participates in the broker's automatic profile
8883
+ * assignment (`computeInitialAssignment`). Defaults to `true`. Publishers
8884
+ * use `false` when they want a stream to be SELECTABLE in the UI but not
8885
+ * picked by default — e.g. Reolink publishes its native Baichuan streams
8886
+ * as `autoEligible: true` (the recommended path) and its RTSP / RTMP
8887
+ * mirrors as `autoEligible: false` (still pickable per slot, just not
8888
+ * the auto choice). Manual `assignProfile` calls remain valid for
8889
+ * non-eligible streams.
8890
+ */
8891
+ autoEligible: boolean().optional(),
8892
+ /**
8893
+ * The profile slot the PUBLISHER says this stream is: `low` for a stream
8894
+ * whose only sensible role is the low-bandwidth one, `high` for a main
8895
+ * stream. Consulted by the broker's automatic ranking
8896
+ * (`rankInitialAssignment`) BEFORE the pixel-count heuristic, and only there:
8897
+ * an operator's manual assignment still wins, and an absent hint is the
8898
+ * pixel-ranked default every camera had before this field existed.
8899
+ *
8900
+ * Why it exists: a camera with ONE stream ranked to `mid` — the slot no
8901
+ * storage class is written for on its own (`recordings` is high|mid,
8902
+ * `recordingsLow` is low) and the one profile scrub does not read. The robot
8903
+ * camera's single 720p relay is a `low` in every respect except the slot the
8904
+ * heuristic put it in.
8905
+ */
8906
+ profileHint: CamProfileSchema.optional(),
8907
+ /**
8908
+ * Transport-specific opaque metadata. The broker passes it through to
8909
+ * the source reader without inspecting it. Currently used by
8910
+ * `pull-rfc4571` streams to carry the upstream SDP (so the reader can
8911
+ * route RTP packets to the right depacketizer without an in-band
8912
+ * DESCRIBE phase). Other kinds typically leave it undefined.
8913
+ */
8914
+ metadata: record(string(), unknown()).optional()
8915
+ });
8916
+ var ProfileSlotStatusSchema = _enum([
8917
+ "unassigned",
8918
+ "idle",
8919
+ "connecting",
8920
+ "streaming",
8921
+ "error"
8922
+ ]);
8923
+ var ProfileSlotSchema = object({
8924
+ deviceId: number().int().nonnegative(),
8925
+ profile: CamProfileSchema,
8926
+ /** Broker id the rest of the system addresses: `${deviceId}/${profile}`. */
8927
+ brokerId: string(),
8928
+ /** `null` when the profile is unassigned. */
8929
+ sourceCamStreamId: string().nullable(),
8930
+ status: ProfileSlotStatusSchema,
8931
+ resolution: CamStreamResolutionSchema.optional(),
8932
+ codec: string().optional(),
8933
+ preBufferSec: number().nonnegative().optional(),
8934
+ errorMessage: string().optional()
8935
+ });
8936
+ /**
8937
+ * Zod schema for StreamSourceEntry — the canonical stream descriptor
8938
+ * exposed by ICameraDevice.getStreamSources() and consumed by the broker.
8939
+ */
8940
+ var StreamSourceEntrySchema$1 = object({
8941
+ id: string(),
8942
+ label: string(),
8943
+ protocol: _enum([
8944
+ "rtsp",
8945
+ "rtmp",
8946
+ "annexb",
8947
+ "http-mjpeg",
8948
+ "webrtc",
8949
+ "custom"
8950
+ ]),
8951
+ url: string().optional(),
8952
+ resolution: object({
8953
+ width: number(),
8954
+ height: number()
8955
+ }).readonly().optional(),
8956
+ fps: number().optional(),
8957
+ bitrate: number().optional(),
8958
+ codec: string().optional(),
8959
+ profileHint: CamProfileSchema.optional()
8960
+ });
8961
+ object({
8962
+ type: string(),
8963
+ url: string(),
8964
+ videoCodec: string().optional(),
8965
+ audioCodec: string().optional(),
8966
+ metadata: record(string(), unknown()).readonly().optional()
8967
+ });
8968
+ /**
8969
+ * Wire schema for `FrameHandle` — a zero-pixel, serialisable reference to a
8970
+ * frame in a shared-memory ring (Phase 5 / D9). Mirrors the `FrameHandle` TS
8971
+ * interface in `interfaces/frame-handle.ts` field-for-field so a cap method
8972
+ * (the runner's native-crop and pipeline-executor inputs) can carry handles
8973
+ * over tRPC / Moleculer.
8974
+ *
8975
+ * The `satisfies` assertion below pins this schema to the interface: if a
8976
+ * field is added to / removed from `FrameHandle` without a matching schema
8977
+ * edit, `z.infer<typeof FrameHandleSchema>` stops being assignable to
8978
+ * `FrameHandle` and the build fails — no silent drift.
8979
+ */
8980
+ var FrameHandleSchema = object({
8981
+ shmId: string(),
8982
+ slot: number().int().nonnegative(),
8983
+ seq: number().int().nonnegative(),
8984
+ width: number().int().positive(),
8985
+ height: number().int().positive(),
8986
+ format: _enum([
8987
+ "jpeg",
8988
+ "rgb",
8989
+ "bgr",
8990
+ "yuv420",
8991
+ "gray"
8992
+ ]),
8993
+ pts: number(),
8994
+ byteLength: number().int().nonnegative(),
8995
+ nodeId: string(),
8996
+ slotCount: number().int().positive()
8997
+ });
8998
+ /**
8999
+ * Wire schema for a decoded audio chunk (Phase 5 / D9). Mirrors the
9000
+ * `DecodedAudioChunk` TS interface in `interfaces/stream-broker.ts`: PCM
9001
+ * sample bytes plus the track parameters a consumer needs to interpret them.
9002
+ *
9003
+ * Audio chunks are tiny (a ~500ms AudioCodecSession window is a few KB of
9004
+ * Float32 PCM), so unlike video frames they ship their bytes INLINE over
9005
+ * tRPC / Moleculer — no shared-memory plane. `data` is typed `Uint8Array`
9006
+ * (the wire-serialisable supertype of `Buffer`); a `Buffer` is assignable to
9007
+ * it.
9008
+ */
9009
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
9010
+ var DecodedAudioChunkSchema = object({
9011
+ data: _instanceof(Uint8Array),
9012
+ sampleRate: number().int().positive(),
9013
+ channels: number().int().positive(),
9014
+ timestamp: number(),
9015
+ /**
9016
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
9017
+ * byte, for any peer that never heard of this field. A coded window
9018
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
9019
+ * subscription that DECLARED it accepts one, so absence can never mean
9020
+ * "coded bytes a consumer will read as floats" (D455).
9021
+ */
9022
+ format: AudioChunkFormatSchema.optional()
9023
+ });
9024
+ /**
9025
+ * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). Audio ships
9026
+ * its bytes inline: a consumer asks the broker for the decoded audio-chunk
9027
+ * stream of one broker; the broker keeps a per-subscription bounded FIFO queue
9028
+ * the consumer drains via `pullAudioChunks`.
9029
+ */
9030
+ var SubscribeAudioChunksInputSchema = object({
9031
+ brokerId: string(),
9032
+ /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
9033
+ tag: string().optional(),
9034
+ /**
9035
+ * Byte formats this subscriber can READ, best first. The broker serves the
9036
+ * chunk's own format when it is in this list and expands to `f32le`
9037
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
9038
+ *
9039
+ * Absent (or without the source format) means `f32le` — the behaviour every
9040
+ * subscriber had before D455, unchanged. This is the negotiation half of
9041
+ * the source-bytes lever: it is what lets the broker and its consumers
9042
+ * deploy one at a time across three nodes.
9043
+ */
9044
+ accept: array(AudioChunkFormatSchema).readonly().optional()
9045
+ });
9046
+ /** Result of `stream-broker.subscribeAudioChunks`. */
9047
+ var SubscribeAudioChunksResultSchema = object({
9048
+ /** Opaque id passed to `pullAudioChunks` / `unsubscribeAudioChunks`. */
9049
+ subscriptionId: string() });
9050
+ var BrokerStatsSchema = object({
9051
+ status: _enum([
9052
+ "idle",
9053
+ "connecting",
9054
+ "streaming",
9055
+ "error",
9056
+ "stopped"
9057
+ ]),
9058
+ inputFps: number(),
9059
+ encodedSubscribers: number(),
9060
+ uptimeMs: number(),
9061
+ bitrateKbps: number(),
9062
+ idrIntervalMs: number(),
9063
+ codec: string().optional(),
9064
+ totalBytes: number(),
9065
+ packetCount: number(),
9066
+ rtspClients: number(),
9067
+ pipeClients: number(),
9068
+ preBufferSec: number(),
9069
+ preBufferMs: number(),
9070
+ preBufferPackets: number(),
9071
+ /**
9072
+ * Detected audio track parameters from the RTSP DESCRIBE / SDP. `null`
9073
+ * when the stream has no audio track or the broker is in cold start.
9074
+ * `supported = false` means the codec was detected but the local
9075
+ * decoder pipeline cannot produce PCM chunks (e.g. AAC without the
9076
+ * AAC pipeline wired). Surfaced in the UI device-overview so operators
9077
+ * can pre-pick the audio-analysis model that matches the codec.
9078
+ */
9079
+ audio: object({
9080
+ codec: string(),
9081
+ sampleRate: number(),
9082
+ channels: number(),
9083
+ supported: boolean()
9084
+ }).nullable().optional(),
9085
+ /**
9086
+ * BROKER-SIDE AUDIO MUTE (D83). `true` = this broker is deliberately
9087
+ * distributing none of the device's audio, on live or recording.
9088
+ *
9089
+ * Present so a silent camera can be told apart from a broken one on the
9090
+ * stream panel itself, without cross-referencing the switch group: a
9091
+ * broker holding an `audio` track descriptor while `audioMuted` is true is
9092
+ * working exactly as asked. `audioMutedDropped` counts the audio units
9093
+ * thrown away since the current dial — it is how you confirm from stats
9094
+ * alone that the mute is on the packet path and not merely persisted.
9095
+ */
9096
+ audioMuted: boolean().optional(),
9097
+ audioMutedDropped: number().optional()
9098
+ });
9099
+ /**
9100
+ * Exporter-facing "profile restream" entry. Returned by
9101
+ * `cameraStreams.getProfileRtspEntries` — one per ASSIGNED profile slot
9102
+ * (high/mid/low). `brokerId` is the PROFILE-keyed broker id
9103
+ * (`${deviceId}/${profile}`, e.g. `15/high`); its `url` is a broker
9104
+ * RTSP restream that aliases the profile's assigned source broker, so
9105
+ * every consumer dialling a profile converges on the same single pull.
9106
+ * `codec`/`resolution` describe the assigned SOURCE camStream (for the
9107
+ * `auto` resolution-closest pick). Distinct from `RtspRestreamEntry`
9108
+ * (raw per-camStream, live-view only).
9109
+ */
9110
+ var ProfileRtspEntrySchema = object({
9111
+ profile: CamProfileSchema,
9112
+ /** Profile-keyed broker id, format `${deviceId}/${profile}` (e.g. `"15/high"`). */
9113
+ brokerId: string(),
9114
+ url: string(),
9115
+ mutedUrl: string(),
9116
+ enabled: boolean(),
9117
+ codec: string().optional(),
9118
+ resolution: CamStreamResolutionSchema.optional()
9119
+ });
9120
+ /**
9121
+ * The model weight formats a catalog entry can ship. Schema-free on purpose:
9122
+ * `types/models.ts` builds Zod schemas from it, but a runner-closure consumer
9123
+ * (the model downloader in `@camstack/server/system`) needs only the list and must
9124
+ * reach it through `@camstack/types/addon` without building the cap schema
9125
+ * graph (D28).
9126
+ */
9127
+ var MODEL_FORMATS = [
9128
+ "onnx",
9129
+ "coreml",
9130
+ "openvino",
9131
+ "tflite",
9132
+ "pt",
9133
+ "gguf"
9134
+ ];
8641
9135
  /**
8642
9136
  * `addon-pages-source` — collection cap exposing per-provider raw page
8643
9137
  * declarations. Every addon that contributes a UI page registers a
@@ -8918,6 +9412,7 @@ var CAP_NAMES = Object.freeze([
8918
9412
  "mesh-network",
8919
9413
  "meter",
8920
9414
  "metrics-provider",
9415
+ "migrations",
8921
9416
  "model-convert",
8922
9417
  "model-distributor",
8923
9418
  "motion",
@@ -8950,6 +9445,7 @@ var CAP_NAMES = Object.freeze([
8950
9445
  "plate-gallery",
8951
9446
  "platform-probe",
8952
9447
  "power-meter",
9448
+ "power-source",
8953
9449
  "presence",
8954
9450
  "pressure-sensor",
8955
9451
  "privacy-mask",
@@ -10301,6 +10797,13 @@ Object.freeze({
10301
10797
  "valueType": "number"
10302
10798
  }
10303
10799
  ],
10800
+ "power-source": [{
10801
+ "path": "switchOn",
10802
+ "valueType": "boolean"
10803
+ }, {
10804
+ "path": "offSeconds",
10805
+ "valueType": "number"
10806
+ }],
10304
10807
  "presence": [
10305
10808
  {
10306
10809
  "path": "state",
@@ -10812,379 +11315,7 @@ object({
10812
11315
  params: record(string(), union([string(), number()])).optional()
10813
11316
  });
10814
11317
  //#endregion
10815
- //#region ../types/dist/err-msg-BD5buxvT.mjs
10816
- var DeviceType = /* @__PURE__ */ function(DeviceType) {
10817
- DeviceType["Camera"] = "camera";
10818
- DeviceType["Hub"] = "hub";
10819
- DeviceType["Light"] = "light";
10820
- DeviceType["Siren"] = "siren";
10821
- DeviceType["Switch"] = "switch";
10822
- DeviceType["Sensor"] = "sensor";
10823
- DeviceType["Thermostat"] = "thermostat";
10824
- /** Air-conditioner / heat-pump climate device (HVAC) — shares the
10825
- * `climate-control` cap surface with `Thermostat` but renders a
10826
- * dedicated AC-appropriate control UI (mode chips, fan speed,
10827
- * independent vertical/horizontal swing). Sources: native Gree, and
10828
- * reusable by other AC integrations. */
10829
- DeviceType["Climate"] = "climate";
10830
- DeviceType["Button"] = "button";
10831
- /** Generic stateless event emitter — carries a device's EXACT declared
10832
- * event vocabulary verbatim (no normalization). Installed with the
10833
- * `event-emitter` cap. Sources: HA `event.*` entities (structured) and
10834
- * HA bus events (e.g. `zha_event`, generic). */
10835
- DeviceType["EventEmitter"] = "event-emitter";
10836
- /** Firmware/software update entity — current vs available version,
10837
- * updatable flag, update state, and an install action. Installed with
10838
- * the `update` cap. Sources: Homematic firmware-update channels (and
10839
- * reusable by other providers, e.g. HA `update.*` entities). */
10840
- DeviceType["Update"] = "update";
10841
- DeviceType["Generic"] = "generic";
10842
- /** Generic notification delivery target (HA `notify.<service>`, future
10843
- * Telegram / Discord / ntfy / SMTP, …). One device per delivery
10844
- * endpoint; the `notifier` cap defines the send surface. */
10845
- DeviceType["Notifier"] = "notifier";
10846
- /** Pre-recorded action sequence with optional parameters
10847
- * (HA `script.*`). Runnable via `script-runner` cap. */
10848
- DeviceType["Script"] = "script";
10849
- /** Automation rule (HA `automation.*`) — enable/disable + manual
10850
- * trigger surface exposed via `automation-control` cap. */
10851
- DeviceType["Automation"] = "automation";
10852
- /** Door / smart lock device (HA `lock.*`). `lock-control` cap. */
10853
- DeviceType["Lock"] = "lock";
10854
- /** Window covering, blinds, garage door, valve, etc. (HA `cover.*`,
10855
- * `valve.*`). `cover` cap with sub-roles for variant. */
10856
- DeviceType["Cover"] = "cover";
10857
- /** Pipe / water / gas valve with open/close/stop and optional
10858
- * position (HA `valve.*`). `valve` cap — a cover-sibling actuator
10859
- * modelled on the same open/closed lifecycle. */
10860
- DeviceType["Valve"] = "valve";
10861
- /** Humidifier / dehumidifier with on/off + target humidity + mode
10862
- * (HA `humidifier.*`). `humidifier` cap — a climate-family actuator
10863
- * modelled on the same target / mode lifecycle. */
10864
- DeviceType["Humidifier"] = "humidifier";
10865
- /** Water heater / boiler with target temperature + operation mode +
10866
- * away mode (HA `water_heater.*`). `water-heater` cap — a
10867
- * climate-family actuator. */
10868
- DeviceType["WaterHeater"] = "water-heater";
10869
- /** Ceiling / standing / exhaust fan (HA `fan.*`). `fan-control` cap. */
10870
- DeviceType["Fan"] = "fan";
10871
- /** Audio / video playback endpoint (HA `media_player.*`). Disjoint from
10872
- * the camera surface — those use `Camera`. `media-player` cap. */
10873
- DeviceType["MediaPlayer"] = "media-player";
10874
- /** Security panel / alarm system (HA `alarm_control_panel.*`).
10875
- * `alarm-panel` cap. */
10876
- DeviceType["AlarmPanel"] = "alarm-panel";
10877
- /** Generic user-settable input (HA `number` / `input_number` / `select`
10878
- * / `input_select` / `text` / `input_text` / `input_datetime`).
10879
- * Sub-type via `DeviceRole`: NumericControl / SelectControl /
10880
- * TextControl / DateTimeControl. */
10881
- DeviceType["Control"] = "control";
10882
- /** Person / device-tracker presence (HA `person.*`, `device_tracker.*`).
10883
- * `presence` cap. */
10884
- DeviceType["Presence"] = "presence";
10885
- /** Weather provider (HA `weather.*`). Tier-3, low MVP priority.
10886
- * `weather` cap. */
10887
- DeviceType["Weather"] = "weather";
10888
- /** Robot vacuum (HA `vacuum.*`). Tier-3. `vacuum-control` cap. */
10889
- DeviceType["Vacuum"] = "vacuum";
10890
- /** Robotic lawn mower (HA `lawn_mower.*`). Tier-3.
10891
- * `lawn-mower-control` cap. */
10892
- DeviceType["LawnMower"] = "lawn-mower";
10893
- /** Physical HA device group — parent container for entity-children
10894
- * adopted from a single HA device entry. Not renderable as a
10895
- * standalone device; exists only to anchor child entities. */
10896
- DeviceType["Container"] = "container";
10897
- /** Single still-image entity (HA `image.*`). Read-only display of an
10898
- * `entity_picture` signed URL the browser loads directly. `image` cap. */
10899
- DeviceType["Image"] = "image";
10900
- /** Smart pet feeder — cloud-connected food dispenser with a bowl food
10901
- * level, battery, desiccant life, feeding state and manual-feed /
10902
- * call-pet / maintenance actions. Installed with the `pet-feeder` cap;
10903
- * dual-hopper models (D4S/D4SH) expose per-hopper portions. Sources:
10904
- * native PetKit (`nodepetkit` `FeederDevice`), reusable by other feeder
10905
- * integrations sharing the same food/desiccant/hopper surface. */
10906
- DeviceType["PetFeeder"] = "pet-feeder";
10907
- /** Pet water fountain — tank level, water drunk, pump and its duty cycle.
10908
- * Installed with the `pet-fountain` cap. Reaches CamStack as loose entities
10909
- * of a container and is BUILT as a composed device (D967). */
10910
- DeviceType["PetFountain"] = "pet-fountain";
10911
- /** Built-in dishwasher — program lifecycle, door / remote-start gates,
10912
- * salt and rinse-aid levels. Installed with the `dishwasher` cap.
10913
- * Sources: native Bosch Home Connect, reusable by similar integrations.
10914
- * A plug-built dishwasher carries running-state and power instead. */
10915
- DeviceType["Dishwasher"] = "dishwasher";
10916
- /** Washing machine. A plug-built one is running while its power stays
10917
- * above a threshold. No program cap — that surface is the dishwasher's. */
10918
- DeviceType["Washer"] = "washer";
10919
- /** Tumble dryer. Same plug-built running surface as {@link Washer}. */
10920
- DeviceType["Dryer"] = "dryer";
10921
- /** The physical bridge box of a vendor ecosystem (Velux KLF-200, and later
10922
- * other radio-to-IP bridges). It carries the box's own facts (firmware,
10923
- * address, connection state) and the actions the box really supports
10924
- * (`reboot`, `device-admin-link`). Products are NOT its children — they are
10925
- * adopted beside it — and its connection settings stay on the integration. */
10926
- DeviceType["Gateway"] = "gateway";
10927
- return DeviceType;
10928
- }({});
10929
- var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
10930
- DeviceFeature["BatteryOperated"] = "battery-operated";
10931
- DeviceFeature["Rebootable"] = "rebootable";
10932
- /**
10933
- * Device supports an on-demand re-sync of its derived spec with its
10934
- * upstream source — drives the generic Re-sync button. The owning
10935
- * provider implements the action via the `device-adoption.resync` cap.
10936
- */
10937
- DeviceFeature["Resyncable"] = "resyncable";
10938
- DeviceFeature["NativeSnapshot"] = "native-snapshot";
10939
- DeviceFeature["DoorbellButton"] = "doorbell-button";
10940
- DeviceFeature["TwoWayAudio"] = "two-way-audio";
10941
- DeviceFeature["PanTiltZoom"] = "pan-tilt-zoom";
10942
- /**
10943
- * Camera supports the on-firmware autotrack subsystem (subject-
10944
- * following). Distinct from `PanTiltZoom` because not every PTZ
10945
- * camera ships autotrack — the admin UI uses this flag to gate
10946
- * the autotrack toggle / settings card without re-deriving from
10947
- * the cap registry. Mirrors `ptz-autotrack` cap registration:
10948
- * driver sets this feature when probe confirms the firmware
10949
- * surface, and registers the cap in the same code path.
10950
- */
10951
- DeviceFeature["PtzAutotrack"] = "ptz-autotrack";
10952
- /**
10953
- * Accessory exposes a "trigger on motion" toggle — the parent camera's
10954
- * motion detection automatically activates this device. Mirrors
10955
- * `motion-trigger` cap registration: drivers set this feature in the
10956
- * same code path that calls `ctx.registerNativeCap(motionTriggerCapability, ...)`.
10957
- *
10958
- * Used by admin UI (gate the in-hero `MotionTriggerToggle` against a
10959
- * fast scalar without binding fetch), notifier rules, and `listAll`
10960
- * filters that want "all devices with on-motion behaviour".
10961
- */
10962
- DeviceFeature["MotionTrigger"] = "motion-trigger";
10963
- /** Light supports rgb-triplet color via `color` cap. */
10964
- DeviceFeature["LightColorRgb"] = "light-color-rgb";
10965
- /** Light supports HSV color via `color` cap. */
10966
- DeviceFeature["LightColorHsv"] = "light-color-hsv";
10967
- /** Light supports color-temperature (mired) via `color` cap. */
10968
- DeviceFeature["LightColorMired"] = "light-color-mired";
10969
- /** Thermostat supports a `heat_cool` dual setpoint (targetLow +
10970
- * targetHigh). Gates the range slider UI. */
10971
- DeviceFeature["ClimateDualSetpoint"] = "climate-dual-setpoint";
10972
- /** Thermostat exposes target humidity and/or current humidity
10973
- * readings. Gates the humidity controls. */
10974
- DeviceFeature["ClimateHumidity"] = "climate-humidity";
10975
- /** Thermostat exposes a fan-mode selector. */
10976
- DeviceFeature["ClimateFanMode"] = "climate-fan-mode";
10977
- /** Thermostat exposes preset modes (eco / away / sleep / vendor). */
10978
- DeviceFeature["ClimatePreset"] = "climate-preset";
10979
- /** Thermostat exposes a vertical louver swing toggle. Gates the
10980
- * vertical-swing switch in the climate UI. Independent of horizontal. */
10981
- DeviceFeature["ClimateSwingVertical"] = "climate-swing-vertical";
10982
- /** Thermostat exposes a horizontal louver swing toggle. Gates the
10983
- * horizontal-swing switch in the climate UI. Independent of vertical. */
10984
- DeviceFeature["ClimateSwingHorizontal"] = "climate-swing-horizontal";
10985
- /** Cover exposes intermediate position control (0..100). Gates the
10986
- * position slider UI. */
10987
- DeviceFeature["CoverPositionable"] = "cover-positionable";
10988
- /** Cover exposes slat-tilt control. Gates the tilt slider UI. */
10989
- DeviceFeature["CoverTilt"] = "cover-tilt";
10990
- /** Valve exposes intermediate position control (0..100). Gates the
10991
- * position slider / drag surface UI. */
10992
- DeviceFeature["ValvePositionable"] = "valve-positionable";
10993
- /** Fan exposes a speed-percentage setter. Gates the speed slider UI. */
10994
- DeviceFeature["FanSpeed"] = "fan-speed";
10995
- /** Fan exposes a preset mode selector. */
10996
- DeviceFeature["FanPreset"] = "fan-preset";
10997
- /** Fan exposes blade direction (forward/reverse) — typical of
10998
- * ceiling fans. */
10999
- DeviceFeature["FanDirection"] = "fan-direction";
11000
- /** Fan exposes an oscillation toggle. */
11001
- DeviceFeature["FanOscillating"] = "fan-oscillating";
11002
- /** Lock requires a PIN code on lock/unlock. Gates the code-entry
11003
- * field on the UI lock-controls panel. */
11004
- DeviceFeature["LockPinRequired"] = "lock-pin-required";
11005
- /** Lock supports a latch-release ("open door") action distinct from
11006
- * unlock. Mirrors HA `LockEntityFeature.OPEN` (bit 1) in
11007
- * `supported_features`. Gates the Open Door button in the UI. */
11008
- DeviceFeature["LockOpen"] = "lock-open";
11009
- /** Media player exposes a seek-to-position surface. */
11010
- DeviceFeature["MediaPlayerSeek"] = "media-player-seek";
11011
- /** Media player exposes a volume-level setter. */
11012
- DeviceFeature["MediaPlayerVolume"] = "media-player-volume";
11013
- /** Media player exposes a mute toggle distinct from volume=0. */
11014
- DeviceFeature["MediaPlayerMute"] = "media-player-mute";
11015
- /** Media player exposes a shuffle toggle. */
11016
- DeviceFeature["MediaPlayerShuffle"] = "media-player-shuffle";
11017
- /** Media player exposes a repeat mode (off / all / one). */
11018
- DeviceFeature["MediaPlayerRepeat"] = "media-player-repeat";
11019
- /** Media player exposes a source / input selector. */
11020
- DeviceFeature["MediaPlayerSelectSource"] = "media-player-select-source";
11021
- /** Media player exposes a play-arbitrary-media surface (URL / id). */
11022
- DeviceFeature["MediaPlayerPlayMedia"] = "media-player-play-media";
11023
- /** Media player exposes next-track. */
11024
- DeviceFeature["MediaPlayerNext"] = "media-player-next";
11025
- /** Media player exposes previous-track. */
11026
- DeviceFeature["MediaPlayerPrevious"] = "media-player-previous";
11027
- /** Media player exposes stop distinct from pause. */
11028
- DeviceFeature["MediaPlayerStop"] = "media-player-stop";
11029
- /** Alarm panel requires a PIN code on arm/disarm. */
11030
- DeviceFeature["AlarmPinRequired"] = "alarm-pin-required";
11031
- /** Presence device carries GPS coordinates (lat/lng/accuracy) in
11032
- * addition to a textual location. */
11033
- DeviceFeature["PresenceGps"] = "presence-gps";
11034
- /** Notifier accepts an inline / URL image attachment. */
11035
- DeviceFeature["NotifierImage"] = "notifier-image";
11036
- /** Notifier accepts a priority hint (high/normal/low). */
11037
- DeviceFeature["NotifierPriority"] = "notifier-priority";
11038
- /** Notifier accepts a free-form `data` payload for platform-specific
11039
- * fields. */
11040
- DeviceFeature["NotifierData"] = "notifier-data";
11041
- /** Notifier supports interactive action buttons / callbacks. */
11042
- DeviceFeature["NotifierActions"] = "notifier-actions";
11043
- /** Notifier supports per-call recipient targeting (multi-user). */
11044
- DeviceFeature["NotifierRecipients"] = "notifier-recipients";
11045
- /** Script runner accepts a variables map on each run invocation. */
11046
- DeviceFeature["ScriptVariables"] = "script-variables";
11047
- /** Automation `trigger` accepts a skipCondition flag — fires the
11048
- * automation's actions while bypassing its condition block. */
11049
- DeviceFeature["AutomationSkipCondition"] = "automation-skip-condition";
11050
- /** Robot vacuum exposes a live cleaning map (image child). Gates the
11051
- * map tile in the vacuum UI. */
11052
- DeviceFeature["VacuumHasMap"] = "vacuum-has-map";
11053
- /** Robot vacuum exposes AI obstacle-detection toggles. Gates the AI
11054
- * switches group. */
11055
- DeviceFeature["VacuumHasAi"] = "vacuum-has-ai";
11056
- /** Robot mower exposes a live mowing map (SVG image child). Gates the
11057
- * mower map tile. */
11058
- DeviceFeature["MowerHasMap"] = "mower-has-map";
11059
- /** Robot mower exposes targeted mowing (all-area / zones / edges /
11060
- * spots) — gates the Mow action + map selectors. */
11061
- DeviceFeature["MowerHasTargetedMowing"] = "mower-has-targeted-mowing";
11062
- return DeviceFeature;
11063
- }({});
11064
- /**
11065
- * Semantic role a device plays within its parent. Populated by driver
11066
- * addons when creating accessory devices (Reolink siren/floodlight/
11067
- * PIR/chime/autotrack/doorbell, ONVIF relay outputs, …). Used by the
11068
- * admin UI to pick icons, labels, and widgets — a `Switch` with
11069
- * `role: Floodlight` renders as a bulb with a brightness slider,
11070
- * whereas a `Switch` with `role: Siren` renders as a klaxon.
11071
- *
11072
- * Undefined for top-level devices (cameras, NVRs, hubs). Persisted in
11073
- * sqlite as a nullable TEXT column — old rows keep working unchanged.
11074
- */
11075
- var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
11076
- DeviceRole["Siren"] = "siren";
11077
- DeviceRole["Floodlight"] = "floodlight";
11078
- DeviceRole["Spotlight"] = "spotlight";
11079
- DeviceRole["PirSensor"] = "pir-sensor";
11080
- DeviceRole["Chime"] = "chime";
11081
- DeviceRole["Autotrack"] = "autotrack";
11082
- DeviceRole["Nightvision"] = "nightvision";
11083
- DeviceRole["PrivacyMask"] = "privacy-mask";
11084
- DeviceRole["Doorbell"] = "doorbell";
11085
- /** Interior blind / shade / roller blind. HA `device_class: blind|shade`. */
11086
- DeviceRole["CoverBlind"] = "cover-blind";
11087
- /** Exterior roller shutter. HA `device_class: shutter`; Homematic BROLL. */
11088
- DeviceRole["CoverShutter"] = "cover-shutter";
11089
- /** Exterior awning. HA `device_class: awning`. */
11090
- DeviceRole["CoverAwning"] = "cover-awning";
11091
- /** Curtain / drape. HA `device_class: curtain`. */
11092
- DeviceRole["CoverCurtain"] = "cover-curtain";
11093
- /** Garage door. HA `device_class: garage`. A security actuator: exports gate it. */
11094
- DeviceRole["CoverGarage"] = "cover-garage";
11095
- /** Gate. HA `device_class: gate`. A security actuator: exports gate it. */
11096
- DeviceRole["CoverGate"] = "cover-gate";
11097
- /** Door. HA `device_class: door`. A security actuator: exports gate it. */
11098
- DeviceRole["CoverDoor"] = "cover-door";
11099
- /** Window. HA `device_class: window`. */
11100
- DeviceRole["CoverWindow"] = "cover-window";
11101
- /** Virtual HA toggle (input_boolean.*) — distinguishable from a
11102
- * real Switch device for UI rendering / export adapters. */
11103
- DeviceRole["BinaryHelper"] = "binary-helper";
11104
- /** A smart plug: a `switch` whose source says it is an outlet (HA
11105
- * `device_class: outlet`). The Alexa export shows it as a SMARTPLUG. */
11106
- DeviceRole["Outlet"] = "outlet";
11107
- /** Generic motion / occupancy / moving event source. Distinct from
11108
- * the camera accessory PirSensor role: that one is a camera child;
11109
- * this is a standalone HA / 3rd-party motion sensor. */
11110
- DeviceRole["MotionSensor"] = "motion-sensor";
11111
- DeviceRole["ContactSensor"] = "contact-sensor";
11112
- DeviceRole["LeakSensor"] = "leak-sensor";
11113
- DeviceRole["SmokeSensor"] = "smoke-sensor";
11114
- DeviceRole["COSensor"] = "co-sensor";
11115
- DeviceRole["GasSensor"] = "gas-sensor";
11116
- DeviceRole["TamperSensor"] = "tamper-sensor";
11117
- DeviceRole["VibrationSensor"] = "vibration-sensor";
11118
- DeviceRole["ConnectivitySensor"] = "connectivity-sensor";
11119
- DeviceRole["SoundSensor"] = "sound-sensor";
11120
- /** Fallback for `binary_sensor` without a known `device_class`. */
11121
- DeviceRole["BinarySensor"] = "binary-sensor";
11122
- DeviceRole["TemperatureSensor"] = "temperature-sensor";
11123
- DeviceRole["HumiditySensor"] = "humidity-sensor";
11124
- DeviceRole["AmbientLightSensor"] = "ambient-light-sensor";
11125
- DeviceRole["PressureSensor"] = "pressure-sensor";
11126
- /** Wind speed or direction (weather-station `wind-sensor` cap). */
11127
- DeviceRole["WindSensor"] = "wind-sensor";
11128
- /** Rain accumulation or rate (weather-station `rain-sensor` cap). */
11129
- DeviceRole["RainSensor"] = "rain-sensor";
11130
- /** UV index (weather-station `uv-sensor` cap). */
11131
- DeviceRole["UvSensor"] = "uv-sensor";
11132
- /** Solar irradiance W/m² (weather-station `solar-radiation-sensor` cap).
11133
- * Distinct from AmbientLightSensor (lux). */
11134
- DeviceRole["SolarRadiationSensor"] = "solar-radiation-sensor";
11135
- /** Soil moisture % (garden/weather `soil-moisture-sensor` cap). */
11136
- DeviceRole["SoilMoistureSensor"] = "soil-moisture-sensor";
11137
- DeviceRole["PowerSensor"] = "power-sensor";
11138
- DeviceRole["EnergySensor"] = "energy-sensor";
11139
- DeviceRole["VoltageSensor"] = "voltage-sensor";
11140
- DeviceRole["CurrentSensor"] = "current-sensor";
11141
- DeviceRole["AirQualitySensor"] = "air-quality-sensor";
11142
- /** Battery level (numeric % via `sensor` OR low-bool via
11143
- * `binary_sensor` — the cap distinguishes via the value type). */
11144
- DeviceRole["BatterySensor"] = "battery-sensor";
11145
- /** Fallback for `sensor` numeric without a known `device_class`. */
11146
- DeviceRole["NumericSensor"] = "numeric-sensor";
11147
- /** String / enum state (HA `sensor` with `state_class: enum` or
11148
- * `attributes.options`). */
11149
- DeviceRole["EnumSensor"] = "enum-sensor";
11150
- /** Date / timestamp state (HA `sensor` with `device_class: timestamp`
11151
- * or `date`). The slice carries the raw ISO string verbatim (hosted on
11152
- * the `enum-sensor` cap); the UI renders it locale-formatted. */
11153
- DeviceRole["DateTimeSensor"] = "datetime-sensor";
11154
- /** Last-resort fallback when nothing else matches. */
11155
- DeviceRole["GenericSensor"] = "generic-sensor";
11156
- DeviceRole["NumericControl"] = "numeric-control";
11157
- DeviceRole["SelectControl"] = "select-control";
11158
- DeviceRole["TextControl"] = "text-control";
11159
- DeviceRole["DateTimeControl"] = "datetime-control";
11160
- /** Mobile push notifier (HA `notify.mobile_app_*`) — supports
11161
- * rich features (image, priority, channel routing). */
11162
- DeviceRole["MobilePushNotifier"] = "mobile-push-notifier";
11163
- /** Chat / messaging service (HA `notify.telegram_*`,
11164
- * `notify.discord_*`, etc.). */
11165
- DeviceRole["MessagingNotifier"] = "messaging-notifier";
11166
- /** Email-based delivery (HA `notify.smtp`, etc.). */
11167
- DeviceRole["EmailNotifier"] = "email-notifier";
11168
- /** Fallback when the notifier service name doesn't match a known
11169
- * pattern. */
11170
- DeviceRole["GenericNotifier"] = "generic-notifier";
11171
- /** Emits a pulse train (infrared or RF) on request — the `ir-transmitter`
11172
- * cap. A `DeviceType.Generic` device. */
11173
- DeviceRole["IrTransmitter"] = "ir-transmitter";
11174
- return DeviceRole;
11175
- }({});
11176
- /**
11177
- import { errMsg } from '@camstack/types'
11178
- * Extract a human-readable message from an unknown error value.
11179
- * Replaces the ubiquitous `errMsg(err)` pattern.
11180
- */
11181
- function errMsg(err) {
11182
- if (err instanceof Error) return err.message;
11183
- if (typeof err === "string") return err;
11184
- return String(err);
11185
- }
11186
- //#endregion
11187
- //#region ../types/dist/composition-C7WdThmP.mjs
11318
+ //#region ../types/dist/composition-BBzVf2xd.mjs
11188
11319
  /**
11189
11320
  * The ffmpeg build every CamStack node downloads, per platform and arch.
11190
11321
  *
@@ -12403,6 +12534,71 @@ var EventOwnerTypeSchema = _enum(EVENT_OWNER_TYPES);
12403
12534
  var MediaPresenceOwnerKindSchema = _enum([...EVENT_OWNER_TYPES, "track"]);
12404
12535
  new Set(EVENT_OWNER_TYPES);
12405
12536
  /**
12537
+ * What a published package needs from the rest of the install (D989).
12538
+ *
12539
+ * One published framework package (`@camstack/server`) carries the kernel, the
12540
+ * builtins and the capability contracts, so "which addon runs on which
12541
+ * framework" is a question of version, and the answer is DECLARED by the
12542
+ * package that knows it:
12543
+ *
12544
+ * - an addon says the oldest server it runs on (`requires.server: ">=X"`);
12545
+ * - the server says the oldest addon it works with
12546
+ * (`requires.addons: { "@camstack/addon-x": ">=Y" }`) and the oldest shell
12547
+ * around it (`requires.wrapper: { desktop, image }`);
12548
+ * - a wrapper (the desktop app, the container starter) says which server
12549
+ * range it can host, and reports its own kind and version.
12550
+ *
12551
+ * The publish workflow STAMPS these after the version bump
12552
+ * (`scripts/ci/stamp-requires.mjs`); nobody types a number by hand.
12553
+ *
12554
+ * A requirement that cannot be checked is NOT met: a shell that reports no
12555
+ * version counts as below the minimum, and an unreadable running version is
12556
+ * named in the result (a failed read is never a pass).
12557
+ */
12558
+ /** `>=MAJOR.MINOR.PATCH[-prerelease]` — the only range shape a requirement uses. */
12559
+ var MinVersionSchema = string().regex(/^>=\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$/, "a minimum is written \">=X.Y.Z\"");
12560
+ object({
12561
+ /** The oldest `@camstack/server` this package runs on. */
12562
+ server: MinVersionSchema.optional(),
12563
+ /** The oldest installed version of each named addon package. */
12564
+ addons: record(string(), MinVersionSchema).optional(),
12565
+ /** The oldest shell around the server, per shell kind. */
12566
+ wrapper: object({
12567
+ desktop: MinVersionSchema.optional(),
12568
+ image: MinVersionSchema.optional()
12569
+ }).optional()
12570
+ });
12571
+ /** One unmet requirement; each names the versions on both sides. */
12572
+ var UnmetRequirementSchema = discriminatedUnion("kind", [
12573
+ object({
12574
+ kind: literal("server-too-old"),
12575
+ required: string(),
12576
+ /** `null` — the running server version could not be read. */
12577
+ running: string().nullable()
12578
+ }),
12579
+ object({
12580
+ kind: literal("addon-too-old"),
12581
+ packageName: string(),
12582
+ required: string(),
12583
+ /** `null` — the addon is not installed (or its version is unreadable). */
12584
+ running: string().nullable()
12585
+ }),
12586
+ object({
12587
+ kind: literal("wrapper-too-old"),
12588
+ wrapper: _enum(["desktop", "image"]),
12589
+ required: string(),
12590
+ /** `null` — the wrapper reported no version. */
12591
+ running: string().nullable()
12592
+ })
12593
+ ]);
12594
+ var RequiredAddonUpdateSchema = object({
12595
+ packageName: string(),
12596
+ /** The minimum the target server declares. */
12597
+ required: string(),
12598
+ /** What this node has; `null` when the addon is not installed. */
12599
+ installed: string().nullable()
12600
+ });
12601
+ /**
12406
12602
  * Which integration instance a settings form is for. An addon that serves several instances
12407
12603
  * (`instanceMode: multiple`) can show a different form per instance — an NVR integration
12408
12604
  * needs its connection, the default integration needs the addon's own sections.
@@ -12877,6 +13073,613 @@ var CameraSwitchGroupSchema = object({
12877
13073
  fetchedAt: number()
12878
13074
  });
12879
13075
  /**
13076
+ * Query filter for settings-store collections.
13077
+ */
13078
+ var QueryFilterSchema = object({
13079
+ where: record(string(), unknown()).optional(),
13080
+ whereIn: record(string(), array(unknown())).optional(),
13081
+ whereBetween: record(string(), tuple([unknown(), unknown()])).optional(),
13082
+ /** NULL-safe exclusion: matches rows whose field is NULL OR != the value. */
13083
+ whereNot: record(string(), unknown()).optional(),
13084
+ /** NULL-safe exclusion of a SET — `whereNot` for more than one value. An
13085
+ * empty list excludes nothing. See `QueryFilter.whereNotIn`. */
13086
+ whereNotIn: record(string(), array(unknown())).optional(),
13087
+ orderBy: object({
13088
+ field: string(),
13089
+ direction: _enum(["asc", "desc"])
13090
+ }).optional(),
13091
+ limit: number().optional(),
13092
+ offset: number().optional()
13093
+ });
13094
+ /**
13095
+ * The predicate half of a filter, for BULK MUTATIONS.
13096
+ *
13097
+ * Deliberately not `QueryFilterSchema`: `orderBy` / `limit` / `offset` have no
13098
+ * meaning for a statement that rewrites a set, and accepting them would invite
13099
+ * a caller to believe `limit` bounds the damage. Every field is optional here
13100
+ * only so the shape stays composable — the implementation REJECTS a filter
13101
+ * that compiles to no predicate, because that is the whole collection.
13102
+ */
13103
+ var MutationFilterSchema = object({
13104
+ where: record(string(), unknown()).optional(),
13105
+ whereIn: record(string(), array(unknown())).optional(),
13106
+ whereBetween: record(string(), tuple([unknown(), unknown()])).optional(),
13107
+ whereNot: record(string(), unknown()).optional(),
13108
+ whereNotIn: record(string(), array(unknown())).optional()
13109
+ });
13110
+ /**
13111
+ * One scalar an {@link settingsStoreCapability.methods.aggregate} call asks for.
13112
+ *
13113
+ * `as` names the slot in the result, so the SAME column may be asked twice with
13114
+ * two operations (`MIN(startMs)` and `MAX(startMs)` in one round trip) — which
13115
+ * a `Record<column, op>` shape could not express.
13116
+ */
13117
+ var AggregateFieldSchema = object({
13118
+ /** Result key. */
13119
+ as: string().min(1),
13120
+ /** Column to aggregate. Must be a real column of a declared collection. */
13121
+ field: string().min(1),
13122
+ op: _enum([
13123
+ "sum",
13124
+ "min",
13125
+ "max"
13126
+ ])
13127
+ });
13128
+ /**
13129
+ * `COUNT(*)` plus one number per requested field.
13130
+ *
13131
+ * `null` means NO ROW MATCHED, never zero: a `SUM` over an empty set and a sum
13132
+ * that really is 0 are different facts, and an accounting caller that renders
13133
+ * "0 bytes, oldest = 0" for "nothing here" reports a lie about a disk.
13134
+ */
13135
+ var AggregateResultSchema = object({
13136
+ count: number().int(),
13137
+ values: record(string(), number().nullable())
13138
+ });
13139
+ /** A single stored record: `{ id, data }`. */
13140
+ var SettingsRecordSchema = object({
13141
+ id: string(),
13142
+ data: record(string(), unknown())
13143
+ });
13144
+ /**
13145
+ * One record of a BULK insert — {@link SettingsRecordSchema} with the id made
13146
+ * optional.
13147
+ *
13148
+ * A separate schema rather than loosening the shared one: every other method
13149
+ * on this cap addresses a row BY its id, and making that field optional
13150
+ * everywhere would turn a forgotten key into a silently generated one on
13151
+ * `update` and `delete` as well.
13152
+ */
13153
+ var BulkRecordSchema = object({
13154
+ id: string().optional(),
13155
+ data: record(string(), unknown())
13156
+ });
13157
+ /**
13158
+ * The database FILES one `sqlite-settings` engine process owns (D851).
13159
+ * Closed on purpose: a file is a thing the engine opens, backs up and gives a
13160
+ * serving thread, so a new one is a code change, never a string a caller
13161
+ * invents. `settings` is `camstack.db` and the default for every collection
13162
+ * that names no file.
13163
+ */
13164
+ var DataStoreDatabaseSchema = _enum([
13165
+ "settings",
13166
+ "events",
13167
+ "history"
13168
+ ]);
13169
+ DataStoreDatabaseSchema.options;
13170
+ /**
13171
+ * One write inside a {@link settingsStoreCapability.methods.transact} call.
13172
+ * The three that a "replace this set, bump that revision" write needs, plus
13173
+ * the batched upsert a rollup writer needs.
13174
+ */
13175
+ var TransactOpSchema = discriminatedUnion("op", [
13176
+ object({
13177
+ op: literal("deleteWhere"),
13178
+ collection: string(),
13179
+ filter: MutationFilterSchema
13180
+ }),
13181
+ object({
13182
+ op: literal("insertMany"),
13183
+ collection: string(),
13184
+ records: array(BulkRecordSchema).readonly()
13185
+ }),
13186
+ object({
13187
+ op: literal("update"),
13188
+ collection: string(),
13189
+ id: string(),
13190
+ data: record(string(), unknown())
13191
+ }),
13192
+ object({
13193
+ op: literal("upsertMany"),
13194
+ collection: string(),
13195
+ conflict: array(string()).readonly(),
13196
+ records: array(BulkRecordSchema).readonly()
13197
+ })
13198
+ ]);
13199
+ /**
13200
+ * The precondition of a transaction: the row `key` of `collection` must hold
13201
+ * `equals` in `column`, read INSIDE the transaction.
13202
+ */
13203
+ var TransactGuardSchema = object({
13204
+ collection: string(),
13205
+ key: string(),
13206
+ column: string(),
13207
+ equals: unknown()
13208
+ });
13209
+ /**
13210
+ * Column declaration for a structured (SQL-backed) collection.
13211
+ *
13212
+ * Logical types — the backend translates each to the matching SQLite
13213
+ * storage class and handles per-type marshaling:
13214
+ * - `TEXT` / `INTEGER` / `REAL` — native SQLite types, pass-through
13215
+ * - `JSON` — TEXT under the hood; serialised on write, parsed on read
13216
+ * - `BOOLEAN` — INTEGER 0/1 under the hood; coerced both directions
13217
+ */
13218
+ var CollectionColumnSchema = object({
13219
+ name: string(),
13220
+ type: _enum([
13221
+ "TEXT",
13222
+ "INTEGER",
13223
+ "REAL",
13224
+ "JSON",
13225
+ "BOOLEAN"
13226
+ ]),
13227
+ primaryKey: boolean().optional(),
13228
+ notNull: boolean().optional(),
13229
+ unique: boolean().optional(),
13230
+ /**
13231
+ * Column DEFAULT. Required for B2: the four `ensureTable` consumers declare
13232
+ * columns like `enabled INTEGER NOT NULL DEFAULT 1`, and without this the
13233
+ * collection surface simply cannot express their existing tables — which is
13234
+ * why they were still on the uncapped `table*` API.
13235
+ */
13236
+ defaultValue: union([
13237
+ string(),
13238
+ number(),
13239
+ boolean()
13240
+ ]).optional()
13241
+ });
13242
+ var CollectionIndexSchema = object({
13243
+ name: string(),
13244
+ columns: array(string()).readonly(),
13245
+ unique: boolean().optional()
13246
+ });
13247
+ /**
13248
+ * The input of `declareCollection` — ONE schema for the door and for the
13249
+ * engine behind it, so the two surfaces cannot drift (the dispatcher forwards
13250
+ * the payload untouched).
13251
+ *
13252
+ * - `database` — the file the collection lives in (D851). Absent means
13253
+ * `settings`. A declaration naming a file other than the one the table is
13254
+ * already in is REFUSED by the engine, never moved.
13255
+ * - `primaryKey` — a COMPOSITE key, as column names. A single name is the same
13256
+ * as `primaryKey: true` on that column. A composite-keyed collection has no
13257
+ * `id`: it is written with `insertMany` / `upsertMany` / `transact` and read
13258
+ * with `query` / `count` / `aggregate` / `deleteWhere`; the calls that
13259
+ * address one row by id are refused.
13260
+ * - `withoutRowid` — emit `WITHOUT ROWID`. Requires a primary key.
13261
+ */
13262
+ var DeclareCollectionInputSchema = object({
13263
+ namespace: string().optional(),
13264
+ collection: string(),
13265
+ columns: array(CollectionColumnSchema).readonly(),
13266
+ indexes: array(CollectionIndexSchema).readonly().optional(),
13267
+ database: DataStoreDatabaseSchema.optional(),
13268
+ primaryKey: array(string()).readonly().optional(),
13269
+ withoutRowid: boolean().optional()
13270
+ });
13271
+ method(object({
13272
+ namespace: string().optional(),
13273
+ collection: string(),
13274
+ key: string()
13275
+ }), unknown(), { auth: "admin" }), method(object({
13276
+ namespace: string().optional(),
13277
+ collection: string(),
13278
+ key: string(),
13279
+ value: unknown()
13280
+ }), _void(), {
13281
+ kind: "mutation",
13282
+ auth: "admin"
13283
+ }), method(object({
13284
+ namespace: string().optional(),
13285
+ collection: string(),
13286
+ filter: QueryFilterSchema.optional(),
13287
+ columns: array(string()).readonly().optional()
13288
+ }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
13289
+ namespace: string().optional(),
13290
+ collection: string(),
13291
+ /** Declared columns identifying the slot; must be covered by a UNIQUE
13292
+ * index on the collection. Never empty. */
13293
+ conflict: array(string()).readonly(),
13294
+ record: BulkRecordSchema
13295
+ }), object({
13296
+ /** The id the row HAS: assigned by SQLite on an insert, or the existing
13297
+ * row's own id on an update. */
13298
+ id: union([string(), number()]) }), {
13299
+ kind: "mutation",
13300
+ auth: "admin"
13301
+ }), method(object({
13302
+ namespace: string().optional(),
13303
+ collection: string(),
13304
+ conflict: array(string()).readonly(),
13305
+ records: array(BulkRecordSchema).readonly()
13306
+ }), object({ upserted: number().int() }), {
13307
+ kind: "mutation",
13308
+ auth: "admin"
13309
+ }), method(object({
13310
+ namespace: string().optional(),
13311
+ collection: string(),
13312
+ record: object({
13313
+ id: string().optional(),
13314
+ data: record(string(), unknown())
13315
+ })
13316
+ }), object({
13317
+ /**
13318
+ * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
13319
+ * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
13320
+ * primary key — which is the only place an auto key is knowable.
13321
+ */
13322
+ id: union([string(), number()]) }), {
13323
+ kind: "mutation",
13324
+ auth: "admin"
13325
+ }), method(object({
13326
+ namespace: string().optional(),
13327
+ collection: string(),
13328
+ records: array(BulkRecordSchema).readonly()
13329
+ }), object({ inserted: number().int() }), {
13330
+ kind: "mutation",
13331
+ auth: "admin"
13332
+ }), method(object({
13333
+ namespace: string().optional(),
13334
+ guard: TransactGuardSchema.optional(),
13335
+ ops: array(TransactOpSchema).readonly()
13336
+ }), object({
13337
+ applied: boolean(),
13338
+ current: unknown().optional()
13339
+ }), {
13340
+ kind: "mutation",
13341
+ auth: "admin"
13342
+ }), method(object({
13343
+ namespace: string().optional(),
13344
+ collection: string(),
13345
+ id: string(),
13346
+ data: record(string(), unknown())
13347
+ }), _void(), {
13348
+ kind: "mutation",
13349
+ auth: "admin"
13350
+ }), method(object({
13351
+ namespace: string().optional(),
13352
+ collection: string(),
13353
+ key: string()
13354
+ }), _void(), {
13355
+ kind: "mutation",
13356
+ auth: "admin"
13357
+ }), method(object({
13358
+ namespace: string().optional(),
13359
+ collection: string(),
13360
+ filter: MutationFilterSchema
13361
+ }), object({ deleted: number().int() }), {
13362
+ kind: "mutation",
13363
+ auth: "admin"
13364
+ }), method(object({
13365
+ namespace: string().optional(),
13366
+ collection: string(),
13367
+ filter: MutationFilterSchema,
13368
+ data: record(string(), unknown())
13369
+ }), object({ updated: number().int() }), {
13370
+ kind: "mutation",
13371
+ auth: "admin"
13372
+ }), method(object({
13373
+ namespace: string().optional(),
13374
+ collection: string(),
13375
+ filter: QueryFilterSchema.optional()
13376
+ }), number(), { auth: "admin" }), method(object({
13377
+ namespace: string().optional(),
13378
+ collection: string(),
13379
+ fields: array(AggregateFieldSchema).readonly(),
13380
+ filter: QueryFilterSchema.optional()
13381
+ }), AggregateResultSchema, { auth: "admin" }), method(object({
13382
+ namespace: string().optional(),
13383
+ collection: string(),
13384
+ field: string(),
13385
+ bucketSize: number().int().positive(),
13386
+ origin: number().int(),
13387
+ filter: QueryFilterSchema.optional()
13388
+ }), array(object({
13389
+ bucket: number().int(),
13390
+ count: number().int()
13391
+ })).readonly(), { auth: "admin" }), method(object({
13392
+ namespace: string().optional(),
13393
+ collection: string()
13394
+ }), boolean(), { auth: "admin" }), method(DeclareCollectionInputSchema, _void(), {
13395
+ kind: "mutation",
13396
+ auth: "admin"
13397
+ });
13398
+ var MigrationIdSchema = string().regex(/^[a-z0-9-]+\/\d{4}-\d{2}-\d{2}-[a-z0-9-]+$/, "a migration id is \"<owner>/<yyyy-mm-dd>-<slug>\"");
13399
+ var MigrationLevelSchema = _enum([
13400
+ "hub-store",
13401
+ "addon-state",
13402
+ "node-config",
13403
+ "viewer",
13404
+ "addon-internal"
13405
+ ]);
13406
+ var MigrationStoreSchema = _enum([
13407
+ "settings",
13408
+ "events",
13409
+ "history",
13410
+ "node-local",
13411
+ "addon-files"
13412
+ ]);
13413
+ var MigrationScopeSchema = _enum(["cluster", "per-node"]);
13414
+ /** What depends on a migration while it is pending: `block-owner` is the default. */
13415
+ var MigrationOnFailureSchema = _enum(["block-owner", "tolerate"]);
13416
+ /**
13417
+ * `sql` is a hub-only body over the owner's connection. `plan` returns edits the
13418
+ * engine applies inside the migration's own transaction (hub-owned: computed in
13419
+ * that transaction; addon-owned: computed by the owner and shipped to the engine).
13420
+ * `procedure` is addon-owned work that is not SQL (keychain, integration registry,
13421
+ * device tombstones); the ledger records its outcome and it must be idempotent.
13422
+ */
13423
+ var MigrationBodyKindSchema = _enum([
13424
+ "sql",
13425
+ "plan",
13426
+ "procedure"
13427
+ ]);
13428
+ var MigrationMetaSchema = object({
13429
+ id: MigrationIdSchema,
13430
+ /** `hub`, an addon id, `node` or `viewer`. */
13431
+ owner: string().regex(/^[a-z0-9-]+$/),
13432
+ level: MigrationLevelSchema,
13433
+ /** Strictly increasing per owner: the order within an owner. */
13434
+ seq: number().int().positive(),
13435
+ /** Ids of any owner: the order across owners. */
13436
+ dependsOn: array(MigrationIdSchema),
13437
+ store: MigrationStoreSchema,
13438
+ scope: MigrationScopeSchema,
13439
+ onFailure: MigrationOnFailureSchema,
13440
+ bodyKind: MigrationBodyKindSchema,
13441
+ description: string().min(1),
13442
+ /** The marked field the migration's spec must assert survived. */
13443
+ fixtureMark: string().min(1)
13444
+ }).refine((m) => m.id.startsWith(`${m.owner}/`), {
13445
+ message: "the id must start with \"<owner>/\"",
13446
+ path: ["id"]
13447
+ });
13448
+ /** A cycle in the dependency graph, named by the ids on it. */
13449
+ var MigrationCycleError = class extends Error {
13450
+ ids;
13451
+ constructor(ids) {
13452
+ super(`migration dependsOn cycle: ${ids.join(" -> ")}`);
13453
+ this.ids = ids;
13454
+ this.name = "MigrationCycleError";
13455
+ }
13456
+ };
13457
+ /**
13458
+ * Topological order over `dependsOn` plus the implicit edge "a lower `seq` of an
13459
+ * owner runs first". Ties are broken by `(owner, seq)`. Throws
13460
+ * {@link MigrationCycleError} on a cycle. A `dependsOn` id that is not in the list
13461
+ * is ignored here — the catalogue schema is what refuses it.
13462
+ */
13463
+ function orderMigrations(items) {
13464
+ const byId = new Map(items.map((item) => [item.id, item]));
13465
+ const deps = /* @__PURE__ */ new Map();
13466
+ const ownerSorted = /* @__PURE__ */ new Map();
13467
+ for (const item of items) {
13468
+ const list = ownerSorted.get(item.owner) ?? [];
13469
+ list.push(item);
13470
+ ownerSorted.set(item.owner, list);
13471
+ }
13472
+ for (const item of items) deps.set(item.id, new Set(item.dependsOn.filter((id) => byId.has(id))));
13473
+ for (const list of ownerSorted.values()) {
13474
+ list.sort((a, b) => a.seq - b.seq);
13475
+ for (let i = 1; i < list.length; i++) {
13476
+ const previous = list[i - 1];
13477
+ const current = list[i];
13478
+ if (previous !== void 0 && current !== void 0) deps.get(current.id)?.add(previous.id);
13479
+ }
13480
+ }
13481
+ const tie = (a, b) => a.owner < b.owner ? -1 : a.owner > b.owner ? 1 : a.seq - b.seq;
13482
+ const done = /* @__PURE__ */ new Set();
13483
+ const ordered = [];
13484
+ let remaining = [...items];
13485
+ while (remaining.length > 0) {
13486
+ const ready = remaining.filter((item) => [...deps.get(item.id) ?? []].every((dep) => done.has(dep)));
13487
+ if (ready.length === 0) throw new MigrationCycleError(remaining.map((item) => item.id).sort());
13488
+ ready.sort(tie);
13489
+ const next = ready[0];
13490
+ if (next === void 0) break;
13491
+ ordered.push(next);
13492
+ done.add(next.id);
13493
+ remaining = remaining.filter((item) => item.id !== next.id);
13494
+ }
13495
+ return ordered;
13496
+ }
13497
+ /** Every way a list of migrations (in declaration order) is not a catalogue. */
13498
+ function catalogueIssues(items) {
13499
+ const issues = [];
13500
+ const seen = /* @__PURE__ */ new Set();
13501
+ const known = new Set(items.map((item) => item.id));
13502
+ const lastSeq = /* @__PURE__ */ new Map();
13503
+ const seqUsed = /* @__PURE__ */ new Map();
13504
+ for (const item of items) {
13505
+ if (seen.has(item.id)) issues.push({
13506
+ code: "duplicate-id",
13507
+ ids: [item.id],
13508
+ message: `duplicate id ${item.id}`
13509
+ });
13510
+ seen.add(item.id);
13511
+ const used = seqUsed.get(item.owner) ?? /* @__PURE__ */ new Set();
13512
+ if (used.has(item.seq)) issues.push({
13513
+ code: "duplicate-seq",
13514
+ ids: [item.id],
13515
+ message: `owner ${item.owner} has two migrations with seq ${item.seq}`
13516
+ });
13517
+ else if (item.seq < (lastSeq.get(item.owner) ?? 0)) issues.push({
13518
+ code: "seq-order",
13519
+ ids: [item.id],
13520
+ message: `seq ${item.seq} of ${item.id} does not increase in declaration order (owner ${item.owner})`
13521
+ });
13522
+ used.add(item.seq);
13523
+ seqUsed.set(item.owner, used);
13524
+ lastSeq.set(item.owner, Math.max(item.seq, lastSeq.get(item.owner) ?? 0));
13525
+ for (const dep of item.dependsOn) if (!known.has(dep)) issues.push({
13526
+ code: "unknown-dependency",
13527
+ ids: [item.id, dep],
13528
+ message: `${item.id} dependsOn unknown id ${dep}`
13529
+ });
13530
+ }
13531
+ try {
13532
+ orderMigrations(items);
13533
+ } catch (err) {
13534
+ if (err instanceof MigrationCycleError) issues.push({
13535
+ code: "cycle",
13536
+ ids: err.ids,
13537
+ message: err.message
13538
+ });
13539
+ else throw err;
13540
+ }
13541
+ return issues;
13542
+ }
13543
+ array(MigrationMetaSchema).superRefine((items, ctx) => {
13544
+ for (const issue of catalogueIssues(items)) ctx.addIssue({
13545
+ code: "custom",
13546
+ message: `${issue.code}: ${issue.message}`
13547
+ });
13548
+ });
13549
+ /**
13550
+ * The canonical JSON (`preconditionOf`) of the value a plan read; the apply step
13551
+ * re-reads, and a plan whose read no longer matches is refused (the migration is
13552
+ * `failed`, nothing it edited is kept).
13553
+ */
13554
+ var PreconditionSchema = string().min(1).optional();
13555
+ var MigrationPlanSchema = object({ edits: array(discriminatedUnion("op", [
13556
+ object({
13557
+ op: literal("setKeys"),
13558
+ scope: string().min(1),
13559
+ values: record(string(), unknown()),
13560
+ precondition: PreconditionSchema
13561
+ }),
13562
+ object({
13563
+ op: literal("deleteKeys"),
13564
+ scope: string().min(1),
13565
+ keys: array(string().min(1)).min(1),
13566
+ precondition: PreconditionSchema
13567
+ }),
13568
+ object({
13569
+ op: literal("putRow"),
13570
+ table: string().min(1),
13571
+ key: record(string(), unknown()),
13572
+ row: record(string(), unknown()),
13573
+ precondition: PreconditionSchema
13574
+ }),
13575
+ object({
13576
+ op: literal("deleteRow"),
13577
+ table: string().min(1),
13578
+ key: record(string(), unknown()),
13579
+ precondition: PreconditionSchema
13580
+ }),
13581
+ object({
13582
+ op: literal("upsertRecord"),
13583
+ kind: string().min(1),
13584
+ recordKey: string().min(1),
13585
+ value: unknown(),
13586
+ precondition: PreconditionSchema
13587
+ }),
13588
+ object({
13589
+ op: literal("deleteRecord"),
13590
+ kind: string().min(1),
13591
+ recordKey: string().min(1),
13592
+ precondition: PreconditionSchema
13593
+ })
13594
+ ])) });
13595
+ /**
13596
+ * What a `procedure` body reports. `already-done` means the rerun observed the
13597
+ * work finished (a crash between the work and the ledger row, or a manual fix)
13598
+ * and did none of it again; the ledger records `applied` either way.
13599
+ */
13600
+ var MigrationProcedureResultSchema = object({
13601
+ outcome: _enum(["done", "already-done"]),
13602
+ summary: record(string(), unknown())
13603
+ });
13604
+ /** What an owner hands the engine when one of its migrations ran. */
13605
+ var MigrationOwnerResultSchema = discriminatedUnion("kind", [
13606
+ object({
13607
+ kind: literal("plan"),
13608
+ plan: MigrationPlanSchema
13609
+ }),
13610
+ object({
13611
+ kind: literal("procedure"),
13612
+ result: MigrationProcedureResultSchema
13613
+ }),
13614
+ object({
13615
+ kind: literal("failed"),
13616
+ error: string().min(1)
13617
+ })
13618
+ ]);
13619
+ /**
13620
+ * `held`: a restore of a pre-migration snapshot undid this id; it does not rerun
13621
+ * until the operator retries or a new code version ships.
13622
+ * `skipped-newer`: the database knows an id this code does not.
13623
+ */
13624
+ var MigrationStatusSchema = _enum([
13625
+ "applied",
13626
+ "failed",
13627
+ "blocked",
13628
+ "running",
13629
+ "held",
13630
+ "skipped-newer"
13631
+ ]);
13632
+ var MigrationLedgerEntrySchema = object({
13633
+ id: string(),
13634
+ database: DataStoreDatabaseSchema,
13635
+ owner: string(),
13636
+ level: MigrationLevelSchema,
13637
+ seq: number().int().nonnegative(),
13638
+ status: MigrationStatusSchema,
13639
+ attempts: number().int().nonnegative(),
13640
+ appliedAt: number().nullable(),
13641
+ codeVersion: string().nullable(),
13642
+ /** What the apply changed: rows per table, as the engine counted them. */
13643
+ planSummary: record(string(), unknown()).nullable(),
13644
+ progress: record(string(), unknown()).nullable(),
13645
+ error: string().nullable(),
13646
+ /** Why it is `blocked` or `held` (`dependency-failed`, `snapshot-refused`, …). */
13647
+ reason: string().nullable(),
13648
+ nodeId: string().nullable(),
13649
+ bootId: string().nullable()
13650
+ });
13651
+ /** A catalogued migration that is not applied, with where it stands. */
13652
+ var MigrationPendingEntrySchema = object({
13653
+ meta: MigrationMetaSchema,
13654
+ database: DataStoreDatabaseSchema,
13655
+ state: _enum([
13656
+ "pending",
13657
+ "failed",
13658
+ "blocked",
13659
+ "held"
13660
+ ]),
13661
+ reason: string().nullable()
13662
+ });
13663
+ /** Rows per table before and after a dry run, and what it would have changed. */
13664
+ var MigrationDryRunResultSchema = object({
13665
+ id: string(),
13666
+ ok: boolean(),
13667
+ error: string().nullable(),
13668
+ rowsChanged: number().int().nonnegative(),
13669
+ tables: array(object({
13670
+ table: string(),
13671
+ before: number().int().nonnegative(),
13672
+ after: number().int().nonnegative()
13673
+ }))
13674
+ });
13675
+ /** One of an owner's migrations, as the engine tells the owner to treat it this boot. */
13676
+ var MigrationOwnerStepSchema = object({
13677
+ id: MigrationIdSchema,
13678
+ action: _enum(["run", "skip"]),
13679
+ /** The ledger state the engine found: `pending` has no row yet. */
13680
+ state: union([literal("pending"), MigrationStatusSchema])
13681
+ });
13682
+ /**
12880
13683
  * The trainer contract — what the hub hands the cloud trainer and what it
12881
13684
  * gets back (cloud training, D805+).
12882
13685
  *
@@ -16279,6 +17082,41 @@ var ACTUATOR_CAP_VOCABULARY = {
16279
17082
  icon: "droplets"
16280
17083
  }]
16281
17084
  },
17085
+ "power-source": {
17086
+ scope: "device",
17087
+ noun: t("Power source", "Alimentazione"),
17088
+ actions: [
17089
+ {
17090
+ id: "powerSource.on",
17091
+ method: "powerOn",
17092
+ label: t("Power on", "Dai corrente"),
17093
+ phrase: t("Power on {device}", "Dai corrente a {device}"),
17094
+ icon: "power"
17095
+ },
17096
+ {
17097
+ id: "powerSource.off",
17098
+ method: "powerOff",
17099
+ label: t("Power off", "Togli corrente"),
17100
+ phrase: t("Cut the power of {device}", "Togli la corrente a {device}"),
17101
+ icon: "power-off"
17102
+ },
17103
+ {
17104
+ id: "powerSource.forceRestart",
17105
+ method: "forceRestart",
17106
+ label: t("Force restart", "Riavvio forzato"),
17107
+ phrase: t("Force restart {device} by cutting its power", "Riavvia {device} togliendo la corrente"),
17108
+ icon: "refresh-cw"
17109
+ }
17110
+ ],
17111
+ state: [{
17112
+ kind: "boolean",
17113
+ field: "switchOn",
17114
+ label: t("Power switch on", "Presa accesa"),
17115
+ whenTrue: t("When the power of {device} comes on", "Quando arriva la corrente a {device}"),
17116
+ whenFalse: t("When the power of {device} is cut", "Quando manca la corrente a {device}"),
17117
+ icon: "power"
17118
+ }]
17119
+ },
16282
17120
  "lock-control": {
16283
17121
  scope: "device",
16284
17122
  noun: t("Lock", "Serratura"),
@@ -16754,7 +17592,7 @@ var ACTUATOR_CAP_VOCABULARY = {
16754
17592
  method: "setDirection",
16755
17593
  label: t("Spin forward", "Rotazione avanti"),
16756
17594
  phrase: t("Spin {device} forward", "Fai girare {device} in avanti"),
16757
- icon: "rotate-cw",
17595
+ icon: "refresh-cw",
16758
17596
  effect: {
16759
17597
  field: "direction",
16760
17598
  value: "forward"
@@ -19832,6 +20670,7 @@ var SYSTEM_CAP_VOCABULARY = {
19832
20670
  "login-method": system(IDENTITY),
19833
20671
  "mesh-network": system(NETWORK),
19834
20672
  "metrics-provider": system(CLUSTER),
20673
+ migrations: system(INTERNAL),
19835
20674
  "model-convert": system(ML),
19836
20675
  "model-distributor": system(ML),
19837
20676
  "mqtt-broker": system(NETWORK),
@@ -40034,7 +40873,8 @@ function normalizeUnit(raw) {
40034
40873
  if (lower === "dbm") return "dBm";
40035
40874
  if (lower === "dbfs") return "dBFS";
40036
40875
  if (lower === "inhg") return "inHg";
40037
- if (lower === "mm/h") return "mm/h";
40876
+ if (lower === "mm/h" || lower === "mm/hr") return "mm/h";
40877
+ if (lower === "in/h" || lower === "in/hr") return "in/h";
40038
40878
  if (lower === "w/m²" || lower === "w/m2") return "W/m²";
40039
40879
  if (lower === "°" || lower === "deg" || lower === "degree" || lower === "degrees") return "°";
40040
40880
  if (lower === "kbps") return "kbps";
@@ -42253,7 +43093,7 @@ method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSche
42253
43093
  * rebuilds without manual reload.
42254
43094
  *
42255
43095
  * The hub-local builtin `addon-pages-aggregator` (see
42256
- * `@camstack/system/builtins/addon-pages-aggregator`) registers the
43096
+ * `@camstack/server/system/builtins/addon-pages-aggregator`) registers the
42257
43097
  * provider. Splitting the public aggregator from the raw collection
42258
43098
  * keeps both ends in codegen — there's no hand-written
42259
43099
  * `addon-pages.router.ts` wrapper anymore.
@@ -42553,7 +43393,7 @@ method(_void(), array(WidgetMetadataSchema).readonly(), { auth: "admin" });
42553
43393
  * manual reload — same scheme used by `addon-pages`.
42554
43394
  *
42555
43395
  * The hub-local builtin `addon-widgets-aggregator` (see
42556
- * `@camstack/system/builtins/addon-widgets-aggregator`) registers the
43396
+ * `@camstack/server/system/builtins/addon-widgets-aggregator`) registers the
42557
43397
  * provider. Splitting the public aggregator from the raw collection
42558
43398
  * keeps both ends in codegen — there's no hand-written wrapper.
42559
43399
  */
@@ -42914,329 +43754,6 @@ method(object({
42914
43754
  password: string()
42915
43755
  }), AuthResultSchema.nullable(), { kind: "mutation" }), method(object({ state: string() }), string()), method(record(string(), string()), AuthResultSchema, { kind: "mutation" }), method(object({ token: string() }), AuthResultSchema.nullable());
42916
43756
  /**
42917
- * Query filter for settings-store collections.
42918
- */
42919
- var QueryFilterSchema = object({
42920
- where: record(string(), unknown()).optional(),
42921
- whereIn: record(string(), array(unknown())).optional(),
42922
- whereBetween: record(string(), tuple([unknown(), unknown()])).optional(),
42923
- /** NULL-safe exclusion: matches rows whose field is NULL OR != the value. */
42924
- whereNot: record(string(), unknown()).optional(),
42925
- /** NULL-safe exclusion of a SET — `whereNot` for more than one value. An
42926
- * empty list excludes nothing. See `QueryFilter.whereNotIn`. */
42927
- whereNotIn: record(string(), array(unknown())).optional(),
42928
- orderBy: object({
42929
- field: string(),
42930
- direction: _enum(["asc", "desc"])
42931
- }).optional(),
42932
- limit: number().optional(),
42933
- offset: number().optional()
42934
- });
42935
- /**
42936
- * The predicate half of a filter, for BULK MUTATIONS.
42937
- *
42938
- * Deliberately not `QueryFilterSchema`: `orderBy` / `limit` / `offset` have no
42939
- * meaning for a statement that rewrites a set, and accepting them would invite
42940
- * a caller to believe `limit` bounds the damage. Every field is optional here
42941
- * only so the shape stays composable — the implementation REJECTS a filter
42942
- * that compiles to no predicate, because that is the whole collection.
42943
- */
42944
- var MutationFilterSchema = object({
42945
- where: record(string(), unknown()).optional(),
42946
- whereIn: record(string(), array(unknown())).optional(),
42947
- whereBetween: record(string(), tuple([unknown(), unknown()])).optional(),
42948
- whereNot: record(string(), unknown()).optional(),
42949
- whereNotIn: record(string(), array(unknown())).optional()
42950
- });
42951
- /**
42952
- * One scalar an {@link settingsStoreCapability.methods.aggregate} call asks for.
42953
- *
42954
- * `as` names the slot in the result, so the SAME column may be asked twice with
42955
- * two operations (`MIN(startMs)` and `MAX(startMs)` in one round trip) — which
42956
- * a `Record<column, op>` shape could not express.
42957
- */
42958
- var AggregateFieldSchema = object({
42959
- /** Result key. */
42960
- as: string().min(1),
42961
- /** Column to aggregate. Must be a real column of a declared collection. */
42962
- field: string().min(1),
42963
- op: _enum([
42964
- "sum",
42965
- "min",
42966
- "max"
42967
- ])
42968
- });
42969
- /**
42970
- * `COUNT(*)` plus one number per requested field.
42971
- *
42972
- * `null` means NO ROW MATCHED, never zero: a `SUM` over an empty set and a sum
42973
- * that really is 0 are different facts, and an accounting caller that renders
42974
- * "0 bytes, oldest = 0" for "nothing here" reports a lie about a disk.
42975
- */
42976
- var AggregateResultSchema = object({
42977
- count: number().int(),
42978
- values: record(string(), number().nullable())
42979
- });
42980
- /** A single stored record: `{ id, data }`. */
42981
- var SettingsRecordSchema = object({
42982
- id: string(),
42983
- data: record(string(), unknown())
42984
- });
42985
- /**
42986
- * One record of a BULK insert — {@link SettingsRecordSchema} with the id made
42987
- * optional.
42988
- *
42989
- * A separate schema rather than loosening the shared one: every other method
42990
- * on this cap addresses a row BY its id, and making that field optional
42991
- * everywhere would turn a forgotten key into a silently generated one on
42992
- * `update` and `delete` as well.
42993
- */
42994
- var BulkRecordSchema = object({
42995
- id: string().optional(),
42996
- data: record(string(), unknown())
42997
- });
42998
- /**
42999
- * The database FILES one `sqlite-settings` engine process owns (D851).
43000
- * Closed on purpose: a file is a thing the engine opens, backs up and gives a
43001
- * serving thread, so a new one is a code change, never a string a caller
43002
- * invents. `settings` is `camstack.db` and the default for every collection
43003
- * that names no file.
43004
- */
43005
- var DataStoreDatabaseSchema = _enum([
43006
- "settings",
43007
- "events",
43008
- "history"
43009
- ]);
43010
- DataStoreDatabaseSchema.options;
43011
- /**
43012
- * One write inside a {@link settingsStoreCapability.methods.transact} call.
43013
- * The three that a "replace this set, bump that revision" write needs, plus
43014
- * the batched upsert a rollup writer needs.
43015
- */
43016
- var TransactOpSchema = discriminatedUnion("op", [
43017
- object({
43018
- op: literal("deleteWhere"),
43019
- collection: string(),
43020
- filter: MutationFilterSchema
43021
- }),
43022
- object({
43023
- op: literal("insertMany"),
43024
- collection: string(),
43025
- records: array(BulkRecordSchema).readonly()
43026
- }),
43027
- object({
43028
- op: literal("update"),
43029
- collection: string(),
43030
- id: string(),
43031
- data: record(string(), unknown())
43032
- }),
43033
- object({
43034
- op: literal("upsertMany"),
43035
- collection: string(),
43036
- conflict: array(string()).readonly(),
43037
- records: array(BulkRecordSchema).readonly()
43038
- })
43039
- ]);
43040
- /**
43041
- * The precondition of a transaction: the row `key` of `collection` must hold
43042
- * `equals` in `column`, read INSIDE the transaction.
43043
- */
43044
- var TransactGuardSchema = object({
43045
- collection: string(),
43046
- key: string(),
43047
- column: string(),
43048
- equals: unknown()
43049
- });
43050
- /**
43051
- * Column declaration for a structured (SQL-backed) collection.
43052
- *
43053
- * Logical types — the backend translates each to the matching SQLite
43054
- * storage class and handles per-type marshaling:
43055
- * - `TEXT` / `INTEGER` / `REAL` — native SQLite types, pass-through
43056
- * - `JSON` — TEXT under the hood; serialised on write, parsed on read
43057
- * - `BOOLEAN` — INTEGER 0/1 under the hood; coerced both directions
43058
- */
43059
- var CollectionColumnSchema = object({
43060
- name: string(),
43061
- type: _enum([
43062
- "TEXT",
43063
- "INTEGER",
43064
- "REAL",
43065
- "JSON",
43066
- "BOOLEAN"
43067
- ]),
43068
- primaryKey: boolean().optional(),
43069
- notNull: boolean().optional(),
43070
- unique: boolean().optional(),
43071
- /**
43072
- * Column DEFAULT. Required for B2: the four `ensureTable` consumers declare
43073
- * columns like `enabled INTEGER NOT NULL DEFAULT 1`, and without this the
43074
- * collection surface simply cannot express their existing tables — which is
43075
- * why they were still on the uncapped `table*` API.
43076
- */
43077
- defaultValue: union([
43078
- string(),
43079
- number(),
43080
- boolean()
43081
- ]).optional()
43082
- });
43083
- var CollectionIndexSchema = object({
43084
- name: string(),
43085
- columns: array(string()).readonly(),
43086
- unique: boolean().optional()
43087
- });
43088
- /**
43089
- * The input of `declareCollection` — ONE schema for the door and for the
43090
- * engine behind it, so the two surfaces cannot drift (the dispatcher forwards
43091
- * the payload untouched).
43092
- *
43093
- * - `database` — the file the collection lives in (D851). Absent means
43094
- * `settings`. A declaration naming a file other than the one the table is
43095
- * already in is REFUSED by the engine, never moved.
43096
- * - `primaryKey` — a COMPOSITE key, as column names. A single name is the same
43097
- * as `primaryKey: true` on that column. A composite-keyed collection has no
43098
- * `id`: it is written with `insertMany` / `upsertMany` / `transact` and read
43099
- * with `query` / `count` / `aggregate` / `deleteWhere`; the calls that
43100
- * address one row by id are refused.
43101
- * - `withoutRowid` — emit `WITHOUT ROWID`. Requires a primary key.
43102
- */
43103
- var DeclareCollectionInputSchema = object({
43104
- namespace: string().optional(),
43105
- collection: string(),
43106
- columns: array(CollectionColumnSchema).readonly(),
43107
- indexes: array(CollectionIndexSchema).readonly().optional(),
43108
- database: DataStoreDatabaseSchema.optional(),
43109
- primaryKey: array(string()).readonly().optional(),
43110
- withoutRowid: boolean().optional()
43111
- });
43112
- method(object({
43113
- namespace: string().optional(),
43114
- collection: string(),
43115
- key: string()
43116
- }), unknown(), { auth: "admin" }), method(object({
43117
- namespace: string().optional(),
43118
- collection: string(),
43119
- key: string(),
43120
- value: unknown()
43121
- }), _void(), {
43122
- kind: "mutation",
43123
- auth: "admin"
43124
- }), method(object({
43125
- namespace: string().optional(),
43126
- collection: string(),
43127
- filter: QueryFilterSchema.optional(),
43128
- columns: array(string()).readonly().optional()
43129
- }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
43130
- namespace: string().optional(),
43131
- collection: string(),
43132
- /** Declared columns identifying the slot; must be covered by a UNIQUE
43133
- * index on the collection. Never empty. */
43134
- conflict: array(string()).readonly(),
43135
- record: BulkRecordSchema
43136
- }), object({
43137
- /** The id the row HAS: assigned by SQLite on an insert, or the existing
43138
- * row's own id on an update. */
43139
- id: union([string(), number()]) }), {
43140
- kind: "mutation",
43141
- auth: "admin"
43142
- }), method(object({
43143
- namespace: string().optional(),
43144
- collection: string(),
43145
- conflict: array(string()).readonly(),
43146
- records: array(BulkRecordSchema).readonly()
43147
- }), object({ upserted: number().int() }), {
43148
- kind: "mutation",
43149
- auth: "admin"
43150
- }), method(object({
43151
- namespace: string().optional(),
43152
- collection: string(),
43153
- record: object({
43154
- id: string().optional(),
43155
- data: record(string(), unknown())
43156
- })
43157
- }), object({
43158
- /**
43159
- * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
43160
- * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
43161
- * primary key — which is the only place an auto key is knowable.
43162
- */
43163
- id: union([string(), number()]) }), {
43164
- kind: "mutation",
43165
- auth: "admin"
43166
- }), method(object({
43167
- namespace: string().optional(),
43168
- collection: string(),
43169
- records: array(BulkRecordSchema).readonly()
43170
- }), object({ inserted: number().int() }), {
43171
- kind: "mutation",
43172
- auth: "admin"
43173
- }), method(object({
43174
- namespace: string().optional(),
43175
- guard: TransactGuardSchema.optional(),
43176
- ops: array(TransactOpSchema).readonly()
43177
- }), object({
43178
- applied: boolean(),
43179
- current: unknown().optional()
43180
- }), {
43181
- kind: "mutation",
43182
- auth: "admin"
43183
- }), method(object({
43184
- namespace: string().optional(),
43185
- collection: string(),
43186
- id: string(),
43187
- data: record(string(), unknown())
43188
- }), _void(), {
43189
- kind: "mutation",
43190
- auth: "admin"
43191
- }), method(object({
43192
- namespace: string().optional(),
43193
- collection: string(),
43194
- key: string()
43195
- }), _void(), {
43196
- kind: "mutation",
43197
- auth: "admin"
43198
- }), method(object({
43199
- namespace: string().optional(),
43200
- collection: string(),
43201
- filter: MutationFilterSchema
43202
- }), object({ deleted: number().int() }), {
43203
- kind: "mutation",
43204
- auth: "admin"
43205
- }), method(object({
43206
- namespace: string().optional(),
43207
- collection: string(),
43208
- filter: MutationFilterSchema,
43209
- data: record(string(), unknown())
43210
- }), object({ updated: number().int() }), {
43211
- kind: "mutation",
43212
- auth: "admin"
43213
- }), method(object({
43214
- namespace: string().optional(),
43215
- collection: string(),
43216
- filter: QueryFilterSchema.optional()
43217
- }), number(), { auth: "admin" }), method(object({
43218
- namespace: string().optional(),
43219
- collection: string(),
43220
- fields: array(AggregateFieldSchema).readonly(),
43221
- filter: QueryFilterSchema.optional()
43222
- }), AggregateResultSchema, { auth: "admin" }), method(object({
43223
- namespace: string().optional(),
43224
- collection: string(),
43225
- field: string(),
43226
- bucketSize: number().int().positive(),
43227
- origin: number().int(),
43228
- filter: QueryFilterSchema.optional()
43229
- }), array(object({
43230
- bucket: number().int(),
43231
- count: number().int()
43232
- })).readonly(), { auth: "admin" }), method(object({
43233
- namespace: string().optional(),
43234
- collection: string()
43235
- }), boolean(), { auth: "admin" }), method(DeclareCollectionInputSchema, _void(), {
43236
- kind: "mutation",
43237
- auth: "admin"
43238
- });
43239
- /**
43240
43757
  * How long one snapshot may take end to end: the pinned copy of the whole
43241
43758
  * database plus `PRAGMA integrity_check` over the copy, on the hub's slowest
43242
43759
  * disk. ~800 MB at a pessimistic 10 MB/s is under 3 minutes; the bound is
@@ -45150,7 +45667,7 @@ method(object({
45150
45667
  kind: "mutation",
45151
45668
  auth: "admin"
45152
45669
  }), method(object({ blockIds: array(string()) }), object({ states: array(CompositionBlockStateSchema) }), { auth: "admin" });
45153
- DeviceType.Camera, DeviceType.Sensor, DeviceType.Button, DeviceType.Switch, DeviceType.PetFeeder, DeviceType.Container, DeviceType.Thermostat, DeviceType.EventEmitter, DeviceType.Camera, DeviceType.Hub, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Thermostat, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Gateway, DeviceType.Camera, DeviceType.Lock, DeviceType.Camera, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.MediaPlayer, DeviceType.WaterHeater, DeviceType.Humidifier, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.PetFeeder;
45670
+ DeviceType.Camera, DeviceType.Sensor, DeviceType.Button, DeviceType.Switch, DeviceType.PetFeeder, DeviceType.Container, DeviceType.Thermostat, DeviceType.EventEmitter, DeviceType.Camera, DeviceType.Hub, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Thermostat, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Gateway, DeviceType.Camera, DeviceType.Lock, DeviceType.Camera, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Gateway, DeviceType.Hub, DeviceType.Camera, DeviceType.Sensor, DeviceType.MediaPlayer, DeviceType.Vacuum, DeviceType.Generic, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.PetFountain, DeviceType.Fan, DeviceType.Humidifier, DeviceType.Climate, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.MediaPlayer, DeviceType.WaterHeater, DeviceType.Humidifier, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.PetFeeder;
45154
45671
  var NUMBER = {
45155
45672
  kind: "fixed",
45156
45673
  result: ["number"]
@@ -46161,6 +46678,57 @@ id: union([string(), number()]) }), {
46161
46678
  kind: "mutation",
46162
46679
  auth: "admin"
46163
46680
  });
46681
+ method(object({}), object({ entries: array(MigrationLedgerEntrySchema) }), { auth: "admin" }), method(object({ owner: string().optional() }), object({ pending: array(MigrationPendingEntrySchema) }), { auth: "admin" }), method(object({ id: string().min(1) }), MigrationDryRunResultSchema, { auth: "admin" }), method(object({
46682
+ id: string().min(1),
46683
+ error: string().min(1)
46684
+ }), MigrationLedgerEntrySchema, {
46685
+ kind: "mutation",
46686
+ auth: "admin"
46687
+ }), method(object({ id: string().min(1) }), object({ entries: array(MigrationLedgerEntrySchema) }), {
46688
+ kind: "mutation",
46689
+ auth: "admin"
46690
+ }), method(object({
46691
+ database: DataStoreDatabaseSchema,
46692
+ snapshotId: string().min(1)
46693
+ }), object({
46694
+ scheduled: boolean(),
46695
+ held: array(string()),
46696
+ restartRequired: boolean()
46697
+ }), {
46698
+ kind: "mutation",
46699
+ auth: "admin"
46700
+ }), method(object({
46701
+ owner: string().min(1),
46702
+ metas: array(MigrationMetaSchema)
46703
+ }), object({
46704
+ bootId: string(),
46705
+ snapshot: _enum([
46706
+ "none",
46707
+ "written",
46708
+ "refused"
46709
+ ]),
46710
+ steps: array(MigrationOwnerStepSchema)
46711
+ }), {
46712
+ kind: "mutation",
46713
+ auth: "admin"
46714
+ }), method(object({ id: string().min(1) }), object({
46715
+ proceed: boolean(),
46716
+ state: union([literal("pending"), MigrationStatusSchema]),
46717
+ reason: string().nullable()
46718
+ }), {
46719
+ kind: "mutation",
46720
+ auth: "admin"
46721
+ }), method(object({
46722
+ id: string().min(1),
46723
+ result: MigrationOwnerResultSchema
46724
+ }), object({
46725
+ status: MigrationStatusSchema,
46726
+ error: string().nullable(),
46727
+ rowsChanged: number().int().nonnegative()
46728
+ }), {
46729
+ kind: "mutation",
46730
+ auth: "admin"
46731
+ });
46164
46732
  /**
46165
46733
  * records - an addon's own facts and documents (D881): ledgers, audit rows,
46166
46734
  * config documents, mirrors. The third storage API next to `ctx.settings`
@@ -61025,7 +61593,18 @@ var ServerUpdateActionResultSchema = object({
61025
61593
  * store (D877), present when the pre-flight refused the update
61026
61594
  * (`reason: 'addon-would-refuse'`). Optional for version skew.
61027
61595
  */
61028
- blockers: array(UpdateBlockerSchema).optional()
61596
+ blockers: array(UpdateBlockerSchema).optional(),
61597
+ /**
61598
+ * The minimums the target server declares and this node does not meet
61599
+ * (D989), present when the update was refused with
61600
+ * `reason: 'requirements-unmet'`. Each names the versions on both sides.
61601
+ */
61602
+ unmet: array(UnmetRequirementSchema).optional(),
61603
+ /**
61604
+ * The addons this node has below the minimum the staged server declares —
61605
+ * the ones to update WITH the server. Present on an accepted update.
61606
+ */
61607
+ requiredAddonUpdates: array(RequiredAddonUpdateSchema).optional()
61029
61608
  });
61030
61609
  var LaunchOverridesSchema = object({
61031
61610
  /** The persisted heap ceiling in MB, or `null` when none is set. */
@@ -63569,7 +64148,9 @@ var PackageUpdateSchema = object({
63569
64148
  latestVersion: string(),
63570
64149
  category: _enum(["addon", "core"]),
63571
64150
  requiresRestart: boolean(),
63572
- isSystem: boolean()
64151
+ isSystem: boolean(),
64152
+ /** Held: what the newer version needs and this node does not meet (D989). */
64153
+ blockedBy: array(UnmetRequirementSchema).readonly().optional()
63573
64154
  });
63574
64155
  var PackageVersionInfoSchema = object({
63575
64156
  version: string(),
@@ -65025,19 +65606,19 @@ var RemoteSetConfigResultSchema = discriminatedUnion("status", [object({ status:
65025
65606
  reason: _enum(["unknown-template", "not-a-media-player"]),
65026
65607
  detail: string()
65027
65608
  })]);
65028
- var deviceInput = object({ deviceId: number().int().nonnegative() });
65609
+ var deviceInput$1 = object({ deviceId: number().int().nonnegative() });
65029
65610
  DeviceType.MediaPlayer;
65030
- method(deviceInput, RemoteConfigSchema, { auth: "admin" }), method(deviceInput.extend({ config: RemoteConfigSchema }), RemoteSetConfigResultSchema, {
65611
+ method(deviceInput$1, RemoteConfigSchema, { auth: "admin" }), method(deviceInput$1.extend({ config: RemoteConfigSchema }), RemoteSetConfigResultSchema, {
65031
65612
  kind: "mutation",
65032
65613
  auth: "admin"
65033
- }), method(deviceInput, RemoteCommandListSchema, { auth: "protected" }), method(deviceInput.extend({
65614
+ }), method(deviceInput$1, RemoteCommandListSchema, { auth: "protected" }), method(deviceInput$1.extend({
65034
65615
  role: RemoteRoleSchema,
65035
65616
  /** Sends in a row (volume steps). */
65036
65617
  repeat: number().int().min(1).max(50).default(1)
65037
65618
  }), RemoteSendResultSchema, {
65038
65619
  kind: "mutation",
65039
65620
  auth: "protected"
65040
- }), method(deviceInput.extend({
65621
+ }), method(deviceInput$1.extend({
65041
65622
  command: RemoteMediaCommandSchema,
65042
65623
  muted: boolean().optional(),
65043
65624
  source: string().optional(),
@@ -68860,7 +69441,7 @@ var lawnMowerControlCapability = {
68860
69441
  * clients — they reverse-connect to the hub. Exposing their interfaces
68861
69442
  * via the same surface would leak internal topology with no upside.
68862
69443
  *
68863
- * Implementation in `@camstack/system/builtins/local-network/`.
69444
+ * Implementation in `@camstack/server/system/builtins/local-network/`.
68864
69445
  */
68865
69446
  /** Coarse classification derived from the interface name + IP range. */
68866
69447
  var InterfaceKindEnum = _enum([
@@ -69357,6 +69938,117 @@ var lockControlCapability = {
69357
69938
  * whether persisting is worth a SQLite commit. */
69358
69939
  volatileStateFields: ["lastChangedAt"]
69359
69940
  };
69941
+ var PowerSourceRefusalReasonSchema = _enum([
69942
+ "no-power-source",
69943
+ "switch-missing",
69944
+ "switch-offline",
69945
+ "switch-unknown",
69946
+ "restart-in-progress",
69947
+ "switch-call-failed"
69948
+ ]);
69949
+ var PowerSourceActionResultSchema = discriminatedUnion("accepted", [object({ accepted: literal(true) }), object({
69950
+ accepted: literal(false),
69951
+ reason: PowerSourceRefusalReasonSchema,
69952
+ /** One line for the operator, naming the switch. */
69953
+ message: string()
69954
+ })]);
69955
+ var PowerSourceInfoSchema = object({
69956
+ /** False when the device has no power source linked; the rest is then empty. */
69957
+ linked: boolean(),
69958
+ switchDeviceId: number().nullable(),
69959
+ switchName: string().nullable(),
69960
+ /** The switch's on/off state, or null when it is unknown. Never false for unknown (D393). */
69961
+ switchOn: boolean().nullable(),
69962
+ switchOnline: boolean().nullable(),
69963
+ restartInProgress: boolean(),
69964
+ offSeconds: number().int()
69965
+ });
69966
+ /** The composed slice: the switch state the link mirrors, plus the stored off time. */
69967
+ var PowerSourceStateSchema = object({
69968
+ /** Null while the switch has not reported: unknown is never `false` (D393). */
69969
+ switchOn: boolean().nullable(),
69970
+ offSeconds: number().int(),
69971
+ lastFetchedAt: number()
69972
+ });
69973
+ var POWER_SOURCE_DEVICE_TYPES = [
69974
+ DeviceType.Gateway,
69975
+ DeviceType.Hub,
69976
+ DeviceType.Camera,
69977
+ DeviceType.Sensor,
69978
+ DeviceType.MediaPlayer,
69979
+ DeviceType.Vacuum,
69980
+ DeviceType.Generic,
69981
+ DeviceType.Washer,
69982
+ DeviceType.Dryer,
69983
+ DeviceType.Dishwasher,
69984
+ DeviceType.PetFountain,
69985
+ DeviceType.Fan,
69986
+ DeviceType.Humidifier,
69987
+ DeviceType.Climate,
69988
+ DeviceType.WaterHeater
69989
+ ];
69990
+ var powerSourceCustomize = {
69991
+ version: 1,
69992
+ targets: [{
69993
+ id: "switch",
69994
+ cardinality: "scalar",
69995
+ vocabulary: {
69996
+ cap: "power-source",
69997
+ stateField: "switchOn"
69998
+ },
69999
+ deviceTypes: POWER_SOURCE_DEVICE_TYPES,
70000
+ apply: "add",
70001
+ path: "switchOn",
70002
+ sources: [{
70003
+ kind: "switch",
70004
+ transforms: [{ kind: "identity" }]
70005
+ }],
70006
+ companions: [{
70007
+ kind: "constant",
70008
+ path: "offSeconds",
70009
+ value: 10,
70010
+ when: "add"
70011
+ }, {
70012
+ kind: "clock",
70013
+ path: "lastFetchedAt",
70014
+ when: "always"
70015
+ }],
70016
+ sourceReport: { status: "assignment-status" }
70017
+ }]
70018
+ };
70019
+ var deviceInput = object({ deviceId: number().int().nonnegative() });
70020
+ var powerSourceCapability = {
70021
+ name: "power-source",
70022
+ scope: "device",
70023
+ mode: "singleton",
70024
+ deviceTypes: POWER_SOURCE_DEVICE_TYPES,
70025
+ methods: {
70026
+ getStatus: systemMethod(deviceInput, PowerSourceInfoSchema, { auth: "admin" }),
70027
+ powerOn: systemMethod(deviceInput, PowerSourceActionResultSchema, {
70028
+ kind: "mutation",
70029
+ auth: "admin"
70030
+ }),
70031
+ powerOff: systemMethod(deviceInput, PowerSourceActionResultSchema, {
70032
+ kind: "mutation",
70033
+ auth: "admin"
70034
+ }),
70035
+ forceRestart: systemMethod(deviceInput, PowerSourceActionResultSchema, {
70036
+ kind: "mutation",
70037
+ auth: "admin"
70038
+ })
70039
+ },
70040
+ runtimeState: PowerSourceStateSchema,
70041
+ customize: powerSourceCustomize,
70042
+ /**
70043
+ * Runtime-state durability: **session** — mirrored from the linked switch on
70044
+ * its next report; a restored value would outlive the reading it names.
70045
+ *
70046
+ * See `RuntimeStateDurability`. Enforced by
70047
+ * `scripts/check-runtime-state-durability.ts`.
70048
+ */
70049
+ durability: "session",
70050
+ history: "none"
70051
+ };
69360
70052
  /**
69361
70053
  * A monotonic total between resets (D944). Energy uses `power-meter.energy`
69362
70054
  * so dashboards keep one series; every other instantaneous reading lands here.
@@ -70637,7 +71329,7 @@ onStatusChanged: { data: object({
70637
71329
  * jitter, and observed/peak bandwidth per device + per client.
70638
71330
  *
70639
71331
  * Implementation lives in the server's `NetworkQualityService` (thin
70640
- * wrapper over the shared `NetworkQualityTracker` from `@camstack/system`).
71332
+ * wrapper over the shared `NetworkQualityTracker` from `@camstack/server/system`).
70641
71333
  * The provider is registered from `trpc.router.ts` against the existing
70642
71334
  * service instance — no addon owns this state.
70643
71335
  *
@@ -72788,7 +73480,7 @@ var ptzAutotrackCapability = {
72788
73480
  * - **Native**: the camera's own firmware autotrack, registered per device by
72789
73481
  * the driver when the probe says it exists (Reolink: yes; Hikvision:
72790
73482
  * model-dependent).
72791
- * - **Wrapper**: the emulated implementation (`@camstack/system`'s `autotrack` builtin),
73483
+ * - **Wrapper**: the emulated implementation (`@camstack/server/system`'s `autotrack` builtin),
72792
73484
  * which follows a subject with `ptz.move` pulses driven by the detection
72793
73485
  * pipeline. `defaultActive: false` — the operator binds it per camera in
72794
73486
  * the bindings UI.
@@ -78097,6 +78789,7 @@ var DEVICE_LOCAL_STATE_CAPS = {
78097
78789
  petFeeder: petFeederCapability,
78098
78790
  petFountain: petFountainCapability,
78099
78791
  powerMeter: powerMeterCapability,
78792
+ powerSource: powerSourceCapability,
78100
78793
  presence: presenceCapability,
78101
78794
  pressureSensor: pressureSensorCapability,
78102
78795
  privacyMask: privacyMaskCapability,
@@ -83861,6 +84554,69 @@ Object.freeze({
83861
84554
  access: "view",
83862
84555
  role: "admin"
83863
84556
  },
84557
+ "migrations.declareOwner": {
84558
+ capName: "migrations",
84559
+ capScope: "system",
84560
+ addonId: null,
84561
+ access: "create",
84562
+ role: "admin"
84563
+ },
84564
+ "migrations.dryRun": {
84565
+ capName: "migrations",
84566
+ capScope: "system",
84567
+ addonId: null,
84568
+ access: "view",
84569
+ role: "admin"
84570
+ },
84571
+ "migrations.finishMigration": {
84572
+ capName: "migrations",
84573
+ capScope: "system",
84574
+ addonId: null,
84575
+ access: "create",
84576
+ role: "admin"
84577
+ },
84578
+ "migrations.listLedger": {
84579
+ capName: "migrations",
84580
+ capScope: "system",
84581
+ addonId: null,
84582
+ access: "view",
84583
+ role: "admin"
84584
+ },
84585
+ "migrations.listPending": {
84586
+ capName: "migrations",
84587
+ capScope: "system",
84588
+ addonId: null,
84589
+ access: "view",
84590
+ role: "admin"
84591
+ },
84592
+ "migrations.markFailed": {
84593
+ capName: "migrations",
84594
+ capScope: "system",
84595
+ addonId: null,
84596
+ access: "create",
84597
+ role: "admin"
84598
+ },
84599
+ "migrations.restorePreMigration": {
84600
+ capName: "migrations",
84601
+ capScope: "system",
84602
+ addonId: null,
84603
+ access: "create",
84604
+ role: "admin"
84605
+ },
84606
+ "migrations.retry": {
84607
+ capName: "migrations",
84608
+ capScope: "system",
84609
+ addonId: null,
84610
+ access: "create",
84611
+ role: "admin"
84612
+ },
84613
+ "migrations.startMigration": {
84614
+ capName: "migrations",
84615
+ capScope: "system",
84616
+ addonId: null,
84617
+ access: "create",
84618
+ role: "admin"
84619
+ },
83864
84620
  "modelConvert.convert": {
83865
84621
  capName: "model-convert",
83866
84622
  capScope: "system",
@@ -86493,6 +87249,34 @@ Object.freeze({
86493
87249
  access: "view",
86494
87250
  role: "viewer"
86495
87251
  },
87252
+ "powerSource.forceRestart": {
87253
+ capName: "power-source",
87254
+ capScope: "device",
87255
+ addonId: null,
87256
+ access: "create",
87257
+ role: "admin"
87258
+ },
87259
+ "powerSource.getStatus": {
87260
+ capName: "power-source",
87261
+ capScope: "device",
87262
+ addonId: null,
87263
+ access: "view",
87264
+ role: "admin"
87265
+ },
87266
+ "powerSource.powerOff": {
87267
+ capName: "power-source",
87268
+ capScope: "device",
87269
+ addonId: null,
87270
+ access: "create",
87271
+ role: "admin"
87272
+ },
87273
+ "powerSource.powerOn": {
87274
+ capName: "power-source",
87275
+ capScope: "device",
87276
+ addonId: null,
87277
+ access: "create",
87278
+ role: "admin"
87279
+ },
86496
87280
  "presence.getStatus": {
86497
87281
  capName: "presence",
86498
87282
  capScope: "device",
@@ -91641,6 +92425,26 @@ Object.freeze({
91641
92425
  form: "single",
91642
92426
  optional: false
91643
92427
  }],
92428
+ "powerSource.forceRestart": [{
92429
+ name: "deviceId",
92430
+ form: "single",
92431
+ optional: false
92432
+ }],
92433
+ "powerSource.getStatus": [{
92434
+ name: "deviceId",
92435
+ form: "single",
92436
+ optional: false
92437
+ }],
92438
+ "powerSource.powerOff": [{
92439
+ name: "deviceId",
92440
+ form: "single",
92441
+ optional: false
92442
+ }],
92443
+ "powerSource.powerOn": [{
92444
+ name: "deviceId",
92445
+ form: "single",
92446
+ optional: false
92447
+ }],
91644
92448
  "presence.getStatus": [{
91645
92449
  name: "deviceId",
91646
92450
  form: "single",
@@ -93962,6 +94766,60 @@ object({
93962
94766
  commands: record(string(), unknown())
93963
94767
  });
93964
94768
  //#endregion
94769
+ //#region src/homematic-reconciler.ts
94770
+ /**
94771
+ * Keeps one live client per enabled integration. Devices are removed ONLY on an explicit
94772
+ * lifecycle event naming the integration (D49): a list that failed, an empty list or an
94773
+ * unreadable connection changes nothing about devices and is logged, never read as "gone".
94774
+ */
94775
+ var HomematicReconciler = class {
94776
+ #deps;
94777
+ constructor(deps) {
94778
+ this.#deps = deps;
94779
+ }
94780
+ /** Upsert a client per usable enabled integration; drop the CLIENT (never devices) of one the list answered is gone. */
94781
+ async reconcile() {
94782
+ const { logger, clients } = this.#deps;
94783
+ let all;
94784
+ try {
94785
+ all = await this.#deps.listIntegrations();
94786
+ } catch (err) {
94787
+ logger.warn("Homematic integration reconcile skipped — the integration list did not answer", { meta: { error: errMsg(err) } });
94788
+ return;
94789
+ }
94790
+ const enabled = all.filter((i) => i.addonId === this.#deps.addonId && i.enabled);
94791
+ for (const integration of enabled) try {
94792
+ if (!await this.#deps.applySettings(integration)) logger.warn("Homematic integration has no usable connection — left as it is", { meta: { integrationId: integration.id } });
94793
+ } catch (err) {
94794
+ logger.warn("Homematic reconcile failed for integration — left as it is", { meta: {
94795
+ integrationId: integration.id,
94796
+ error: errMsg(err)
94797
+ } });
94798
+ }
94799
+ const enabledIds = new Set(enabled.map((i) => i.id));
94800
+ for (const id of clients.list()) if (!enabledIds.has(id)) await clients.remove(id);
94801
+ }
94802
+ /** An explicit lifecycle event: only `deleted` / `disabled` of a named integration remove devices. */
94803
+ async onLifecycle(kind, integrationId) {
94804
+ await this.reconcile();
94805
+ if (kind === "enabled" || integrationId === null) return;
94806
+ try {
94807
+ const removed = await this.#deps.removeDevices(integrationId);
94808
+ this.#deps.logger.info("Homematic integration devices removed", { meta: {
94809
+ integrationId,
94810
+ kind,
94811
+ removed
94812
+ } });
94813
+ } catch (err) {
94814
+ this.#deps.logger.warn("Homematic integration device removal failed", { meta: {
94815
+ integrationId,
94816
+ kind,
94817
+ error: errMsg(err)
94818
+ } });
94819
+ }
94820
+ }
94821
+ };
94822
+ //#endregion
93965
94823
  //#region src/ccu/ccu-facade.ts
93966
94824
  function errorText(err) {
93967
94825
  return err instanceof Error ? err.message : String(err);
@@ -121697,6 +122555,7 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
121697
122555
  [DeviceType.Container]: HmContainerDevice
121698
122556
  };
121699
122557
  /** Live per-integration CCU sessions, or null before init / after shutdown. */
122558
+ integrationReconciler = null;
121700
122559
  clients = null;
121701
122560
  constructor() {
121702
122561
  super({});
@@ -121786,6 +122645,7 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
121786
122645
  this.ctx.logger.warn("Homematic: provider shutdown error", { meta: { error: errMsg(err) } });
121787
122646
  }
121788
122647
  this.clients = null;
122648
+ this.integrationReconciler = null;
121789
122649
  homematicFacades.clear();
121790
122650
  await super.onShutdown();
121791
122651
  }
@@ -121893,47 +122753,48 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
121893
122753
  * devices. Idempotent; runs on boot and on every integration lifecycle event.
121894
122754
  * Guarded: a failing read warns and returns, `onInitialize` must not fail.
121895
122755
  */
121896
- async reconcileIntegrations() {
121897
- const reg = this.requireClients();
121898
- try {
121899
- const mine = (await this.ctx.api.integrations.list.query()).filter((i) => i.addonId === this.ctx.id && i.enabled);
121900
- const surviving = /* @__PURE__ */ new Set();
121901
- for (const integration of mine) try {
121902
- const connection = connectionFromSettings(await this.ctx.api.integrations.getSettings.query({ id: integration.id }));
121903
- if (!connection) {
121904
- this.ctx.logger.warn("Homematic reconcile: host missing or invalid, no session opened", { tags: { integrationId: integration.id } });
121905
- continue;
122756
+ reconciler() {
122757
+ this.integrationReconciler ??= new HomematicReconciler({
122758
+ addonId: this.ctx.id,
122759
+ logger: this.ctx.logger,
122760
+ clients: {
122761
+ list: () => this.requireClients().list(),
122762
+ remove: async (id) => {
122763
+ await this.requireClients().remove(id);
121906
122764
  }
121907
- await reg.upsert(integration.id, integration.name, connection);
121908
- surviving.add(integration.id);
121909
- } catch (err) {
121910
- this.ctx.logger.warn("Homematic reconcile: settings read failed", {
121911
- tags: { integrationId: integration.id },
121912
- meta: { error: errMsg(err) }
121913
- });
121914
- }
121915
- const vanished = reg.list().filter((id) => !surviving.has(id));
121916
- await reg.retain(surviving);
121917
- for (const integrationId of vanished) await this.cascadeRemoveDevicesForIntegration(integrationId);
121918
- } catch (err) {
121919
- this.ctx.logger.warn("Homematic integration reconcile failed", { meta: { error: errMsg(err) } });
121920
- }
122765
+ },
122766
+ listIntegrations: () => this.ctx.api.integrations.list.query(),
122767
+ applySettings: async (integration) => {
122768
+ const connection = connectionFromSettings(await this.ctx.api.integrations.getSettings.query({ id: integration.id }));
122769
+ if (!connection) return false;
122770
+ await this.requireClients().upsert(integration.id, integration.name, connection);
122771
+ return true;
122772
+ },
122773
+ removeDevices: (integrationId) => this.cascadeRemoveDevicesForIntegration(integrationId)
122774
+ });
122775
+ return this.integrationReconciler;
122776
+ }
122777
+ /** Upsert one client per enabled integration; never removes a device (D49). */
122778
+ async reconcileIntegrations() {
122779
+ await this.reconciler().reconcile();
121921
122780
  }
122781
+ /** Lifecycle events: only an explicit Deleted/Disabled naming an integration removes devices. */
121922
122782
  subscribeIntegrationLifecycle() {
121923
- const handler = (event) => {
122783
+ const on = (kind) => (event) => {
121924
122784
  const addonId = event.data["addonId"];
121925
122785
  if (typeof addonId === "string" && addonId !== this.ctx.id) return;
121926
- this.reconcileIntegrations();
122786
+ const integrationId = event.data["integrationId"];
122787
+ this.reconciler().onLifecycle(kind, typeof integrationId === "string" ? integrationId : null);
121927
122788
  };
121928
- this.ctx.eventBus.subscribe({ category: EventCategory.IntegrationEnabled }, handler);
121929
- this.ctx.eventBus.subscribe({ category: EventCategory.IntegrationDisabled }, handler);
121930
- this.ctx.eventBus.subscribe({ category: EventCategory.IntegrationDeleted }, handler);
122789
+ this.ctx.eventBus.subscribe({ category: EventCategory.IntegrationEnabled }, on("enabled"));
122790
+ this.ctx.eventBus.subscribe({ category: EventCategory.IntegrationDisabled }, on("disabled"));
122791
+ this.ctx.eventBus.subscribe({ category: EventCategory.IntegrationDeleted }, on("deleted"));
121931
122792
  }
121932
122793
  async cascadeRemoveDevicesForIntegration(integrationId) {
121933
122794
  const reg = this.ctx.kernel.deviceRegistry;
121934
122795
  const devices = this.ctx.kernel.devices;
121935
- if (!reg || !devices) return;
121936
- await cascadeRemoveDevicesForIntegration({
122796
+ if (!reg || !devices) return 0;
122797
+ return await cascadeRemoveDevicesForIntegration({
121937
122798
  reg,
121938
122799
  devices,
121939
122800
  addonId: this.addonId,