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