@camstack/addon-provider-rademacher 0.2.154 → 0.2.156

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.
package/dist/addon.js CHANGED
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  let crypto$1 = require("crypto");
3
3
  let events = require("events");
4
4
  let os = require("os");
5
- //#region ../types/dist/event-category-DmZDPDf_.mjs
5
+ //#region ../types/dist/event-category-CaURIwQA.mjs
6
6
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
7
7
  EventCategory["SystemBoot"] = "system.boot";
8
8
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -718,6 +718,10 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
718
718
  EventCategory["NotificationRuleBroken"] = "notification.rule-broken";
719
719
  /** The clear of {@link NotificationRuleBroken}: the rule loads and names nothing deleted. */
720
720
  EventCategory["NotificationRuleRepaired"] = "notification.rule-repaired";
721
+ /** A migration failed or was blocked; the Alert Center re-reads the ledger. */
722
+ EventCategory["MigrationFailed"] = "migration.failed";
723
+ /** A migration applied or a failure cleared; the Alert Center re-reads the ledger. */
724
+ EventCategory["MigrationApplied"] = "migration.applied";
721
725
  EventCategory["DeviceUpdated"] = "device.updated";
722
726
  /**
723
727
  * Transport-level connectivity. Emitted by the device driver when
@@ -780,6 +784,378 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
780
784
  return EventCategory;
781
785
  }({});
782
786
  //#endregion
787
+ //#region ../types/dist/device-type-CEqjmUnR.mjs
788
+ /**
789
+ import { errMsg } from '@camstack/types'
790
+ * Extract a human-readable message from an unknown error value.
791
+ * Replaces the ubiquitous `errMsg(err)` pattern.
792
+ */
793
+ function errMsg(err) {
794
+ if (err instanceof Error) return err.message;
795
+ if (typeof err === "string") return err;
796
+ return String(err);
797
+ }
798
+ var DeviceType = /* @__PURE__ */ function(DeviceType) {
799
+ DeviceType["Camera"] = "camera";
800
+ DeviceType["Hub"] = "hub";
801
+ DeviceType["Light"] = "light";
802
+ DeviceType["Siren"] = "siren";
803
+ DeviceType["Switch"] = "switch";
804
+ DeviceType["Sensor"] = "sensor";
805
+ DeviceType["Thermostat"] = "thermostat";
806
+ /** Air-conditioner / heat-pump climate device (HVAC) — shares the
807
+ * `climate-control` cap surface with `Thermostat` but renders a
808
+ * dedicated AC-appropriate control UI (mode chips, fan speed,
809
+ * independent vertical/horizontal swing). Sources: native Gree, and
810
+ * reusable by other AC integrations. */
811
+ DeviceType["Climate"] = "climate";
812
+ DeviceType["Button"] = "button";
813
+ /** Generic stateless event emitter — carries a device's EXACT declared
814
+ * event vocabulary verbatim (no normalization). Installed with the
815
+ * `event-emitter` cap. Sources: HA `event.*` entities (structured) and
816
+ * HA bus events (e.g. `zha_event`, generic). */
817
+ DeviceType["EventEmitter"] = "event-emitter";
818
+ /** Firmware/software update entity — current vs available version,
819
+ * updatable flag, update state, and an install action. Installed with
820
+ * the `update` cap. Sources: Homematic firmware-update channels (and
821
+ * reusable by other providers, e.g. HA `update.*` entities). */
822
+ DeviceType["Update"] = "update";
823
+ DeviceType["Generic"] = "generic";
824
+ /** Generic notification delivery target (HA `notify.<service>`, future
825
+ * Telegram / Discord / ntfy / SMTP, …). One device per delivery
826
+ * endpoint; the `notifier` cap defines the send surface. */
827
+ DeviceType["Notifier"] = "notifier";
828
+ /** Pre-recorded action sequence with optional parameters
829
+ * (HA `script.*`). Runnable via `script-runner` cap. */
830
+ DeviceType["Script"] = "script";
831
+ /** Automation rule (HA `automation.*`) — enable/disable + manual
832
+ * trigger surface exposed via `automation-control` cap. */
833
+ DeviceType["Automation"] = "automation";
834
+ /** Door / smart lock device (HA `lock.*`). `lock-control` cap. */
835
+ DeviceType["Lock"] = "lock";
836
+ /** Window covering, blinds, garage door, valve, etc. (HA `cover.*`,
837
+ * `valve.*`). `cover` cap with sub-roles for variant. */
838
+ DeviceType["Cover"] = "cover";
839
+ /** Pipe / water / gas valve with open/close/stop and optional
840
+ * position (HA `valve.*`). `valve` cap — a cover-sibling actuator
841
+ * modelled on the same open/closed lifecycle. */
842
+ DeviceType["Valve"] = "valve";
843
+ /** Humidifier / dehumidifier with on/off + target humidity + mode
844
+ * (HA `humidifier.*`). `humidifier` cap — a climate-family actuator
845
+ * modelled on the same target / mode lifecycle. */
846
+ DeviceType["Humidifier"] = "humidifier";
847
+ /** Water heater / boiler with target temperature + operation mode +
848
+ * away mode (HA `water_heater.*`). `water-heater` cap — a
849
+ * climate-family actuator. */
850
+ DeviceType["WaterHeater"] = "water-heater";
851
+ /** Ceiling / standing / exhaust fan (HA `fan.*`). `fan-control` cap. */
852
+ DeviceType["Fan"] = "fan";
853
+ /** Audio / video playback endpoint (HA `media_player.*`). Disjoint from
854
+ * the camera surface — those use `Camera`. `media-player` cap. */
855
+ DeviceType["MediaPlayer"] = "media-player";
856
+ /** Security panel / alarm system (HA `alarm_control_panel.*`).
857
+ * `alarm-panel` cap. */
858
+ DeviceType["AlarmPanel"] = "alarm-panel";
859
+ /** Generic user-settable input (HA `number` / `input_number` / `select`
860
+ * / `input_select` / `text` / `input_text` / `input_datetime`).
861
+ * Sub-type via `DeviceRole`: NumericControl / SelectControl /
862
+ * TextControl / DateTimeControl. */
863
+ DeviceType["Control"] = "control";
864
+ /** Person / device-tracker presence (HA `person.*`, `device_tracker.*`).
865
+ * `presence` cap. */
866
+ DeviceType["Presence"] = "presence";
867
+ /** Weather provider (HA `weather.*`). Tier-3, low MVP priority.
868
+ * `weather` cap. */
869
+ DeviceType["Weather"] = "weather";
870
+ /** Robot vacuum (HA `vacuum.*`). Tier-3. `vacuum-control` cap. */
871
+ DeviceType["Vacuum"] = "vacuum";
872
+ /** Robotic lawn mower (HA `lawn_mower.*`). Tier-3.
873
+ * `lawn-mower-control` cap. */
874
+ DeviceType["LawnMower"] = "lawn-mower";
875
+ /** Physical HA device group — parent container for entity-children
876
+ * adopted from a single HA device entry. Not renderable as a
877
+ * standalone device; exists only to anchor child entities. */
878
+ DeviceType["Container"] = "container";
879
+ /** Single still-image entity (HA `image.*`). Read-only display of an
880
+ * `entity_picture` signed URL the browser loads directly. `image` cap. */
881
+ DeviceType["Image"] = "image";
882
+ /** Smart pet feeder — cloud-connected food dispenser with a bowl food
883
+ * level, battery, desiccant life, feeding state and manual-feed /
884
+ * call-pet / maintenance actions. Installed with the `pet-feeder` cap;
885
+ * dual-hopper models (D4S/D4SH) expose per-hopper portions. Sources:
886
+ * native PetKit (`nodepetkit` `FeederDevice`), reusable by other feeder
887
+ * integrations sharing the same food/desiccant/hopper surface. */
888
+ DeviceType["PetFeeder"] = "pet-feeder";
889
+ /** Pet water fountain — tank level, water drunk, pump and its duty cycle.
890
+ * Installed with the `pet-fountain` cap. Reaches CamStack as loose entities
891
+ * of a container and is BUILT as a composed device (D967). */
892
+ DeviceType["PetFountain"] = "pet-fountain";
893
+ /** Built-in dishwasher — program lifecycle, door / remote-start gates,
894
+ * salt and rinse-aid levels. Installed with the `dishwasher` cap.
895
+ * Sources: native Bosch Home Connect, reusable by similar integrations.
896
+ * A plug-built dishwasher carries running-state and power instead. */
897
+ DeviceType["Dishwasher"] = "dishwasher";
898
+ /** Washing machine. A plug-built one is running while its power stays
899
+ * above a threshold. No program cap — that surface is the dishwasher's. */
900
+ DeviceType["Washer"] = "washer";
901
+ /** Tumble dryer. Same plug-built running surface as {@link Washer}. */
902
+ DeviceType["Dryer"] = "dryer";
903
+ /** The physical bridge box of a vendor ecosystem (Velux KLF-200, and later
904
+ * other radio-to-IP bridges). It carries the box's own facts (firmware,
905
+ * address, connection state) and the actions the box really supports
906
+ * (`reboot`, `device-admin-link`). Products are NOT its children — they are
907
+ * adopted beside it — and its connection settings stay on the integration. */
908
+ DeviceType["Gateway"] = "gateway";
909
+ return DeviceType;
910
+ }({});
911
+ var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
912
+ DeviceFeature["BatteryOperated"] = "battery-operated";
913
+ DeviceFeature["Rebootable"] = "rebootable";
914
+ /**
915
+ * Device supports an on-demand re-sync of its derived spec with its
916
+ * upstream source — drives the generic Re-sync button. The owning
917
+ * provider implements the action via the `device-adoption.resync` cap.
918
+ */
919
+ DeviceFeature["Resyncable"] = "resyncable";
920
+ DeviceFeature["NativeSnapshot"] = "native-snapshot";
921
+ DeviceFeature["DoorbellButton"] = "doorbell-button";
922
+ DeviceFeature["TwoWayAudio"] = "two-way-audio";
923
+ DeviceFeature["PanTiltZoom"] = "pan-tilt-zoom";
924
+ /**
925
+ * Camera supports the on-firmware autotrack subsystem (subject-
926
+ * following). Distinct from `PanTiltZoom` because not every PTZ
927
+ * camera ships autotrack — the admin UI uses this flag to gate
928
+ * the autotrack toggle / settings card without re-deriving from
929
+ * the cap registry. Mirrors `ptz-autotrack` cap registration:
930
+ * driver sets this feature when probe confirms the firmware
931
+ * surface, and registers the cap in the same code path.
932
+ */
933
+ DeviceFeature["PtzAutotrack"] = "ptz-autotrack";
934
+ /**
935
+ * Accessory exposes a "trigger on motion" toggle — the parent camera's
936
+ * motion detection automatically activates this device. Mirrors
937
+ * `motion-trigger` cap registration: drivers set this feature in the
938
+ * same code path that calls `ctx.registerNativeCap(motionTriggerCapability, ...)`.
939
+ *
940
+ * Used by admin UI (gate the in-hero `MotionTriggerToggle` against a
941
+ * fast scalar without binding fetch), notifier rules, and `listAll`
942
+ * filters that want "all devices with on-motion behaviour".
943
+ */
944
+ DeviceFeature["MotionTrigger"] = "motion-trigger";
945
+ /** Light supports rgb-triplet color via `color` cap. */
946
+ DeviceFeature["LightColorRgb"] = "light-color-rgb";
947
+ /** Light supports HSV color via `color` cap. */
948
+ DeviceFeature["LightColorHsv"] = "light-color-hsv";
949
+ /** Light supports color-temperature (mired) via `color` cap. */
950
+ DeviceFeature["LightColorMired"] = "light-color-mired";
951
+ /** Thermostat supports a `heat_cool` dual setpoint (targetLow +
952
+ * targetHigh). Gates the range slider UI. */
953
+ DeviceFeature["ClimateDualSetpoint"] = "climate-dual-setpoint";
954
+ /** Thermostat exposes target humidity and/or current humidity
955
+ * readings. Gates the humidity controls. */
956
+ DeviceFeature["ClimateHumidity"] = "climate-humidity";
957
+ /** Thermostat exposes a fan-mode selector. */
958
+ DeviceFeature["ClimateFanMode"] = "climate-fan-mode";
959
+ /** Thermostat exposes preset modes (eco / away / sleep / vendor). */
960
+ DeviceFeature["ClimatePreset"] = "climate-preset";
961
+ /** Thermostat exposes a vertical louver swing toggle. Gates the
962
+ * vertical-swing switch in the climate UI. Independent of horizontal. */
963
+ DeviceFeature["ClimateSwingVertical"] = "climate-swing-vertical";
964
+ /** Thermostat exposes a horizontal louver swing toggle. Gates the
965
+ * horizontal-swing switch in the climate UI. Independent of vertical. */
966
+ DeviceFeature["ClimateSwingHorizontal"] = "climate-swing-horizontal";
967
+ /** Cover exposes intermediate position control (0..100). Gates the
968
+ * position slider UI. */
969
+ DeviceFeature["CoverPositionable"] = "cover-positionable";
970
+ /** Cover exposes slat-tilt control. Gates the tilt slider UI. */
971
+ DeviceFeature["CoverTilt"] = "cover-tilt";
972
+ /** Valve exposes intermediate position control (0..100). Gates the
973
+ * position slider / drag surface UI. */
974
+ DeviceFeature["ValvePositionable"] = "valve-positionable";
975
+ /** Fan exposes a speed-percentage setter. Gates the speed slider UI. */
976
+ DeviceFeature["FanSpeed"] = "fan-speed";
977
+ /** Fan exposes a preset mode selector. */
978
+ DeviceFeature["FanPreset"] = "fan-preset";
979
+ /** Fan exposes blade direction (forward/reverse) — typical of
980
+ * ceiling fans. */
981
+ DeviceFeature["FanDirection"] = "fan-direction";
982
+ /** Fan exposes an oscillation toggle. */
983
+ DeviceFeature["FanOscillating"] = "fan-oscillating";
984
+ /** Lock requires a PIN code on lock/unlock. Gates the code-entry
985
+ * field on the UI lock-controls panel. */
986
+ DeviceFeature["LockPinRequired"] = "lock-pin-required";
987
+ /** Lock supports a latch-release ("open door") action distinct from
988
+ * unlock. Mirrors HA `LockEntityFeature.OPEN` (bit 1) in
989
+ * `supported_features`. Gates the Open Door button in the UI. */
990
+ DeviceFeature["LockOpen"] = "lock-open";
991
+ /** Media player exposes a seek-to-position surface. */
992
+ DeviceFeature["MediaPlayerSeek"] = "media-player-seek";
993
+ /** Media player exposes a volume-level setter. */
994
+ DeviceFeature["MediaPlayerVolume"] = "media-player-volume";
995
+ /** Media player exposes a mute toggle distinct from volume=0. */
996
+ DeviceFeature["MediaPlayerMute"] = "media-player-mute";
997
+ /** Media player exposes a shuffle toggle. */
998
+ DeviceFeature["MediaPlayerShuffle"] = "media-player-shuffle";
999
+ /** Media player exposes a repeat mode (off / all / one). */
1000
+ DeviceFeature["MediaPlayerRepeat"] = "media-player-repeat";
1001
+ /** Media player exposes a source / input selector. */
1002
+ DeviceFeature["MediaPlayerSelectSource"] = "media-player-select-source";
1003
+ /** Media player exposes a play-arbitrary-media surface (URL / id). */
1004
+ DeviceFeature["MediaPlayerPlayMedia"] = "media-player-play-media";
1005
+ /** Media player exposes next-track. */
1006
+ DeviceFeature["MediaPlayerNext"] = "media-player-next";
1007
+ /** Media player exposes previous-track. */
1008
+ DeviceFeature["MediaPlayerPrevious"] = "media-player-previous";
1009
+ /** Media player exposes stop distinct from pause. */
1010
+ DeviceFeature["MediaPlayerStop"] = "media-player-stop";
1011
+ /** Alarm panel requires a PIN code on arm/disarm. */
1012
+ DeviceFeature["AlarmPinRequired"] = "alarm-pin-required";
1013
+ /** Presence device carries GPS coordinates (lat/lng/accuracy) in
1014
+ * addition to a textual location. */
1015
+ DeviceFeature["PresenceGps"] = "presence-gps";
1016
+ /** Notifier accepts an inline / URL image attachment. */
1017
+ DeviceFeature["NotifierImage"] = "notifier-image";
1018
+ /** Notifier accepts a priority hint (high/normal/low). */
1019
+ DeviceFeature["NotifierPriority"] = "notifier-priority";
1020
+ /** Notifier accepts a free-form `data` payload for platform-specific
1021
+ * fields. */
1022
+ DeviceFeature["NotifierData"] = "notifier-data";
1023
+ /** Notifier supports interactive action buttons / callbacks. */
1024
+ DeviceFeature["NotifierActions"] = "notifier-actions";
1025
+ /** Notifier supports per-call recipient targeting (multi-user). */
1026
+ DeviceFeature["NotifierRecipients"] = "notifier-recipients";
1027
+ /** Script runner accepts a variables map on each run invocation. */
1028
+ DeviceFeature["ScriptVariables"] = "script-variables";
1029
+ /** Automation `trigger` accepts a skipCondition flag — fires the
1030
+ * automation's actions while bypassing its condition block. */
1031
+ DeviceFeature["AutomationSkipCondition"] = "automation-skip-condition";
1032
+ /** Robot vacuum exposes a live cleaning map (image child). Gates the
1033
+ * map tile in the vacuum UI. */
1034
+ DeviceFeature["VacuumHasMap"] = "vacuum-has-map";
1035
+ /** Robot vacuum exposes AI obstacle-detection toggles. Gates the AI
1036
+ * switches group. */
1037
+ DeviceFeature["VacuumHasAi"] = "vacuum-has-ai";
1038
+ /** Robot mower exposes a live mowing map (SVG image child). Gates the
1039
+ * mower map tile. */
1040
+ DeviceFeature["MowerHasMap"] = "mower-has-map";
1041
+ /** Robot mower exposes targeted mowing (all-area / zones / edges /
1042
+ * spots) — gates the Mow action + map selectors. */
1043
+ DeviceFeature["MowerHasTargetedMowing"] = "mower-has-targeted-mowing";
1044
+ return DeviceFeature;
1045
+ }({});
1046
+ /**
1047
+ * Semantic role a device plays within its parent. Populated by driver
1048
+ * addons when creating accessory devices (Reolink siren/floodlight/
1049
+ * PIR/chime/autotrack/doorbell, ONVIF relay outputs, …). Used by the
1050
+ * admin UI to pick icons, labels, and widgets — a `Switch` with
1051
+ * `role: Floodlight` renders as a bulb with a brightness slider,
1052
+ * whereas a `Switch` with `role: Siren` renders as a klaxon.
1053
+ *
1054
+ * Undefined for top-level devices (cameras, NVRs, hubs). Persisted in
1055
+ * sqlite as a nullable TEXT column — old rows keep working unchanged.
1056
+ */
1057
+ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
1058
+ DeviceRole["Siren"] = "siren";
1059
+ DeviceRole["Floodlight"] = "floodlight";
1060
+ DeviceRole["Spotlight"] = "spotlight";
1061
+ DeviceRole["PirSensor"] = "pir-sensor";
1062
+ DeviceRole["Chime"] = "chime";
1063
+ DeviceRole["Autotrack"] = "autotrack";
1064
+ DeviceRole["Nightvision"] = "nightvision";
1065
+ DeviceRole["PrivacyMask"] = "privacy-mask";
1066
+ DeviceRole["Doorbell"] = "doorbell";
1067
+ /** Interior blind / shade / roller blind. HA `device_class: blind|shade`. */
1068
+ DeviceRole["CoverBlind"] = "cover-blind";
1069
+ /** Exterior roller shutter. HA `device_class: shutter`; Homematic BROLL. */
1070
+ DeviceRole["CoverShutter"] = "cover-shutter";
1071
+ /** Exterior awning. HA `device_class: awning`. */
1072
+ DeviceRole["CoverAwning"] = "cover-awning";
1073
+ /** Curtain / drape. HA `device_class: curtain`. */
1074
+ DeviceRole["CoverCurtain"] = "cover-curtain";
1075
+ /** Garage door. HA `device_class: garage`. A security actuator: exports gate it. */
1076
+ DeviceRole["CoverGarage"] = "cover-garage";
1077
+ /** Gate. HA `device_class: gate`. A security actuator: exports gate it. */
1078
+ DeviceRole["CoverGate"] = "cover-gate";
1079
+ /** Door. HA `device_class: door`. A security actuator: exports gate it. */
1080
+ DeviceRole["CoverDoor"] = "cover-door";
1081
+ /** Window. HA `device_class: window`. */
1082
+ DeviceRole["CoverWindow"] = "cover-window";
1083
+ /** Virtual HA toggle (input_boolean.*) — distinguishable from a
1084
+ * real Switch device for UI rendering / export adapters. */
1085
+ DeviceRole["BinaryHelper"] = "binary-helper";
1086
+ /** A smart plug: a `switch` whose source says it is an outlet (HA
1087
+ * `device_class: outlet`). The Alexa export shows it as a SMARTPLUG. */
1088
+ DeviceRole["Outlet"] = "outlet";
1089
+ /** Generic motion / occupancy / moving event source. Distinct from
1090
+ * the camera accessory PirSensor role: that one is a camera child;
1091
+ * this is a standalone HA / 3rd-party motion sensor. */
1092
+ DeviceRole["MotionSensor"] = "motion-sensor";
1093
+ DeviceRole["ContactSensor"] = "contact-sensor";
1094
+ DeviceRole["LeakSensor"] = "leak-sensor";
1095
+ DeviceRole["SmokeSensor"] = "smoke-sensor";
1096
+ DeviceRole["COSensor"] = "co-sensor";
1097
+ DeviceRole["GasSensor"] = "gas-sensor";
1098
+ DeviceRole["TamperSensor"] = "tamper-sensor";
1099
+ DeviceRole["VibrationSensor"] = "vibration-sensor";
1100
+ DeviceRole["ConnectivitySensor"] = "connectivity-sensor";
1101
+ DeviceRole["SoundSensor"] = "sound-sensor";
1102
+ /** Fallback for `binary_sensor` without a known `device_class`. */
1103
+ DeviceRole["BinarySensor"] = "binary-sensor";
1104
+ DeviceRole["TemperatureSensor"] = "temperature-sensor";
1105
+ DeviceRole["HumiditySensor"] = "humidity-sensor";
1106
+ DeviceRole["AmbientLightSensor"] = "ambient-light-sensor";
1107
+ DeviceRole["PressureSensor"] = "pressure-sensor";
1108
+ /** Wind speed or direction (weather-station `wind-sensor` cap). */
1109
+ DeviceRole["WindSensor"] = "wind-sensor";
1110
+ /** Rain accumulation or rate (weather-station `rain-sensor` cap). */
1111
+ DeviceRole["RainSensor"] = "rain-sensor";
1112
+ /** UV index (weather-station `uv-sensor` cap). */
1113
+ DeviceRole["UvSensor"] = "uv-sensor";
1114
+ /** Solar irradiance W/m² (weather-station `solar-radiation-sensor` cap).
1115
+ * Distinct from AmbientLightSensor (lux). */
1116
+ DeviceRole["SolarRadiationSensor"] = "solar-radiation-sensor";
1117
+ /** Soil moisture % (garden/weather `soil-moisture-sensor` cap). */
1118
+ DeviceRole["SoilMoistureSensor"] = "soil-moisture-sensor";
1119
+ DeviceRole["PowerSensor"] = "power-sensor";
1120
+ DeviceRole["EnergySensor"] = "energy-sensor";
1121
+ DeviceRole["VoltageSensor"] = "voltage-sensor";
1122
+ DeviceRole["CurrentSensor"] = "current-sensor";
1123
+ DeviceRole["AirQualitySensor"] = "air-quality-sensor";
1124
+ /** Battery level (numeric % via `sensor` OR low-bool via
1125
+ * `binary_sensor` — the cap distinguishes via the value type). */
1126
+ DeviceRole["BatterySensor"] = "battery-sensor";
1127
+ /** Fallback for `sensor` numeric without a known `device_class`. */
1128
+ DeviceRole["NumericSensor"] = "numeric-sensor";
1129
+ /** String / enum state (HA `sensor` with `state_class: enum` or
1130
+ * `attributes.options`). */
1131
+ DeviceRole["EnumSensor"] = "enum-sensor";
1132
+ /** Date / timestamp state (HA `sensor` with `device_class: timestamp`
1133
+ * or `date`). The slice carries the raw ISO string verbatim (hosted on
1134
+ * the `enum-sensor` cap); the UI renders it locale-formatted. */
1135
+ DeviceRole["DateTimeSensor"] = "datetime-sensor";
1136
+ /** Last-resort fallback when nothing else matches. */
1137
+ DeviceRole["GenericSensor"] = "generic-sensor";
1138
+ DeviceRole["NumericControl"] = "numeric-control";
1139
+ DeviceRole["SelectControl"] = "select-control";
1140
+ DeviceRole["TextControl"] = "text-control";
1141
+ DeviceRole["DateTimeControl"] = "datetime-control";
1142
+ /** Mobile push notifier (HA `notify.mobile_app_*`) — supports
1143
+ * rich features (image, priority, channel routing). */
1144
+ DeviceRole["MobilePushNotifier"] = "mobile-push-notifier";
1145
+ /** Chat / messaging service (HA `notify.telegram_*`,
1146
+ * `notify.discord_*`, etc.). */
1147
+ DeviceRole["MessagingNotifier"] = "messaging-notifier";
1148
+ /** Email-based delivery (HA `notify.smtp`, etc.). */
1149
+ DeviceRole["EmailNotifier"] = "email-notifier";
1150
+ /** Fallback when the notifier service name doesn't match a known
1151
+ * pattern. */
1152
+ DeviceRole["GenericNotifier"] = "generic-notifier";
1153
+ /** Emits a pulse train (infrared or RF) on request — the `ir-transmitter`
1154
+ * cap. A `DeviceType.Generic` device. */
1155
+ DeviceRole["IrTransmitter"] = "ir-transmitter";
1156
+ return DeviceRole;
1157
+ }({});
1158
+ //#endregion
783
1159
  //#region ../../node_modules/zod/v4/core/core.js
784
1160
  var _a$1;
785
1161
  function $constructor(name, initializer, params) {
@@ -5458,7 +5834,7 @@ var ZodIssueCode = {
5458
5834
  var ZodFirstPartyTypeKind;
5459
5835
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5460
5836
  //#endregion
5461
- //#region ../types/dist/sleep-DSVWZfJC.mjs
5837
+ //#region ../types/dist/sleep-CSYuxssh.mjs
5462
5838
  /**
5463
5839
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5464
5840
  * window to float samples (D455).
@@ -5974,6 +6350,102 @@ function emitReadiness(bus, params) {
5974
6350
  ts
5975
6351
  }));
5976
6352
  }
6353
+ var NOT_RUN = {
6354
+ declared: false,
6355
+ snapshot: null,
6356
+ applied: [],
6357
+ failed: [],
6358
+ blocked: [],
6359
+ skipped: [],
6360
+ blockOwner: []
6361
+ };
6362
+ /**
6363
+ * Offer `migrations` to the engine and run what it says to run, in its order. Never
6364
+ * throws: an unreachable or refusing engine is logged and reported `declared: false`,
6365
+ * because the hub (and this addon's boot) must not hang on a migration.
6366
+ */
6367
+ async function runAddonMigrations(host, migrations, logger) {
6368
+ const first = migrations[0];
6369
+ if (first === void 0) return NOT_RUN;
6370
+ const owner = first.meta.owner;
6371
+ const log = logger.withTags({ migrationOwner: owner });
6372
+ const byId = new Map(migrations.map((m) => [m.meta.id, m]));
6373
+ let declaration;
6374
+ try {
6375
+ declaration = await host.declareOwner({
6376
+ owner,
6377
+ metas: migrations.map((m) => m.meta)
6378
+ });
6379
+ } catch (err) {
6380
+ log.error("the migration engine refused or could not take this addon catalogue — none ran", { meta: { error: errMsg(err) } });
6381
+ return {
6382
+ ...NOT_RUN,
6383
+ blockOwner: migrations.filter((m) => m.meta.onFailure === "block-owner").map((m) => m.meta.id)
6384
+ };
6385
+ }
6386
+ const applied = [];
6387
+ const failed = [];
6388
+ const blocked = [];
6389
+ const skipped = [];
6390
+ const settle = (id, status) => {
6391
+ if (status === "applied") applied.push(id);
6392
+ else if (status === "failed") failed.push(id);
6393
+ else if (status === "blocked") blocked.push(id);
6394
+ else skipped.push(id);
6395
+ };
6396
+ for (const step of declaration.steps) {
6397
+ const bound = byId.get(step.id);
6398
+ if (bound === void 0 || step.action === "skip") {
6399
+ skipped.push(step.id);
6400
+ continue;
6401
+ }
6402
+ const tags = { migrationId: step.id };
6403
+ try {
6404
+ const gate = await host.startMigration({ id: step.id });
6405
+ if (!gate.proceed) {
6406
+ log.warn("migration not run", {
6407
+ tags,
6408
+ meta: {
6409
+ state: gate.state,
6410
+ reason: gate.reason
6411
+ }
6412
+ });
6413
+ settle(step.id, gate.state === "pending" ? "blocked" : gate.state);
6414
+ continue;
6415
+ }
6416
+ const result = await bound.execute();
6417
+ const outcome = await host.finishMigration({
6418
+ id: step.id,
6419
+ result
6420
+ });
6421
+ if (outcome.status === "applied") log.info("migration applied", {
6422
+ tags,
6423
+ meta: { rowsChanged: outcome.rowsChanged }
6424
+ });
6425
+ else log.error("migration failed", {
6426
+ tags,
6427
+ meta: { error: outcome.error }
6428
+ });
6429
+ settle(step.id, outcome.status);
6430
+ } catch (err) {
6431
+ log.error("migration could not be completed with the engine", {
6432
+ tags,
6433
+ meta: { error: errMsg(err) }
6434
+ });
6435
+ failed.push(step.id);
6436
+ }
6437
+ }
6438
+ const blockOwner = [...failed, ...blocked].filter((id) => byId.get(id)?.meta.onFailure === "block-owner");
6439
+ return {
6440
+ declared: true,
6441
+ snapshot: declaration.snapshot,
6442
+ applied,
6443
+ failed,
6444
+ blocked,
6445
+ skipped,
6446
+ blockOwner
6447
+ };
6448
+ }
5977
6449
  /**
5978
6450
  * Build a {@link DurableState} over a single store key. Transport-agnostic:
5979
6451
  * `read`/`write` are the addon-store or device-store accessors. The whole
@@ -7029,6 +7501,28 @@ var BaseAddon = class {
7029
7501
  return normalized;
7030
7502
  }
7031
7503
  /**
7504
+ * Run this addon's migration catalogue (D987 M3) through the hub's `migrations`
7505
+ * engine. Call it at the point of the boot where the data must already have the new
7506
+ * shape — `onInitialize`, or `onRestoreDevices` for a migration that needs the
7507
+ * restored devices — with the catalogue bound to the addon's ports
7508
+ * (`defineAddonMigrations(ADDON_MIGRATIONS, ports)`).
7509
+ *
7510
+ * An engine that cannot be reached or refuses the catalogue is logged and runs
7511
+ * nothing; the boot continues. A migration that FAILED (or was blocked by one)
7512
+ * and declares `onFailure: 'block-owner'` makes this throw, so the addon does not
7513
+ * serve data whose shape it cannot trust; `tolerate` migrations never do.
7514
+ */
7515
+ async runMigrations(migrations) {
7516
+ const api = this.ctx.api.migrations;
7517
+ const report = await runAddonMigrations({
7518
+ declareOwner: (input) => api.declareOwner.mutate(input),
7519
+ startMigration: (input) => api.startMigration.mutate(input),
7520
+ finishMigration: (input) => api.finishMigration.mutate(input)
7521
+ }, migrations, this.ctx.logger);
7522
+ 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`);
7523
+ return report;
7524
+ }
7525
+ /**
7032
7526
  * Called by the isolated-process runner AFTER `broker.start()`.
7033
7527
  * In-process addons never need this because the hub broker is already
7034
7528
  * running when `initialize()` fires. For forked children the broker
@@ -8138,6 +8632,98 @@ var RecordKindDeclarationSchema = object({
8138
8632
  }).strict();
8139
8633
  /** The kind names: lower-case, dash separated, short enough for an index name. */
8140
8634
  var RecordKindNameSchema = string().regex(/^[a-z][a-z0-9-]{0,47}$/);
8635
+ object({
8636
+ field: string().min(1),
8637
+ on: literal("advance")
8638
+ });
8639
+ /**
8640
+ * Output schema shared by the contribution + live methods.
8641
+ *
8642
+ * Mirrors the `ConfigUISchemaWithValues` shape (sections[] + optional
8643
+ * tabs[]) without importing from `../interfaces/config-ui.js` — a
8644
+ * concrete-but-lenient Zod object keeps tRPC output inference happy
8645
+ * (using `z.unknown()` here collapses unrelated router branches to
8646
+ * `unknown` when the generator re-inlines the huge AppRouter type).
8647
+ *
8648
+ * `.passthrough()` on sections/fields accepts whatever FormBuilder
8649
+ * extensions the caller adds (showWhen, displayScale, …) without
8650
+ * rebuilding every time a new field kind is introduced.
8651
+ */
8652
+ var ContributionSectionSchema = object({
8653
+ id: string(),
8654
+ title: string(),
8655
+ description: string().optional(),
8656
+ style: _enum(["card", "accordion"]).optional(),
8657
+ defaultCollapsed: boolean().optional(),
8658
+ columns: union([
8659
+ literal(1),
8660
+ literal(2),
8661
+ literal(3),
8662
+ literal(4)
8663
+ ]).optional(),
8664
+ tab: string().optional(),
8665
+ location: _enum([
8666
+ "settings",
8667
+ "top-tab",
8668
+ "hero"
8669
+ ]).optional(),
8670
+ order: number().optional(),
8671
+ fields: array(any())
8672
+ });
8673
+ object({
8674
+ tabs: array(object({
8675
+ id: string(),
8676
+ label: string(),
8677
+ icon: string(),
8678
+ order: number().optional()
8679
+ })).optional(),
8680
+ sections: array(ContributionSectionSchema)
8681
+ }).nullable();
8682
+ object({ deviceId: number() }), object({ deviceId: number() }), object({
8683
+ deviceId: number(),
8684
+ patch: record(string(), unknown())
8685
+ }), object({ success: literal(true) });
8686
+ object({ deviceId: number() }), unknown().nullable();
8687
+ function method(input, output, options) {
8688
+ return {
8689
+ input,
8690
+ output,
8691
+ kind: options?.kind ?? "query",
8692
+ ...options?.auth !== void 0 ? { auth: options.auth } : {},
8693
+ ...options?.access !== void 0 ? { access: options.access } : {},
8694
+ ...options?.role !== void 0 ? { role: options.role } : {},
8695
+ ...options?.caller !== void 0 ? { caller: options.caller } : {},
8696
+ timeoutMs: options?.timeoutMs
8697
+ };
8698
+ }
8699
+ /**
8700
+ * A wrapper/system-only method: served exclusively by the cap's system-level
8701
+ * provider (`InferProvider`), and OPTIONAL on `InferNativeProvider` so per-device
8702
+ * driver natives don't stub out a wrapper concern (e.g. a cross-device cache
8703
+ * overview). The `systemOnly: true` literal is what `InferNativeProvider` keys on.
8704
+ */
8705
+ function systemMethod(input, output, options) {
8706
+ return {
8707
+ ...method(input, output, options),
8708
+ systemOnly: true
8709
+ };
8710
+ }
8711
+ /**
8712
+ * A method a SOURCE of a collection cap may legitimately not serve — OPTIONAL
8713
+ * on `InferProvider`. The `providerOptional: true` literal is what
8714
+ * `InferProvider` keys on; see {@link CapabilityMethodSchema.providerOptional}
8715
+ * for when this is the honest answer and when it is a soft stub.
8716
+ */
8717
+ function optionalMethod(input, output, options) {
8718
+ return {
8719
+ ...method(input, output, options),
8720
+ providerOptional: true
8721
+ };
8722
+ }
8723
+ /** Shorthand to define an event schema */
8724
+ function event(data) {
8725
+ return { data };
8726
+ }
8141
8727
  var READING_QUANTITIES = [
8142
8728
  "temperature",
8143
8729
  "pressure",
@@ -8527,7 +9113,7 @@ var ProfileRtspEntrySchema = object({
8527
9113
  /**
8528
9114
  * The model weight formats a catalog entry can ship. Schema-free on purpose:
8529
9115
  * `types/models.ts` builds Zod schemas from it, but a runner-closure consumer
8530
- * (the model downloader in `@camstack/system`) needs only the list and must
9116
+ * (the model downloader in `@camstack/server/system`) needs only the list and must
8531
9117
  * reach it through `@camstack/types/addon` without building the cap schema
8532
9118
  * graph (D28).
8533
9119
  */
@@ -8539,98 +9125,6 @@ var MODEL_FORMATS = [
8539
9125
  "pt",
8540
9126
  "gguf"
8541
9127
  ];
8542
- object({
8543
- field: string().min(1),
8544
- on: literal("advance")
8545
- });
8546
- /**
8547
- * Output schema shared by the contribution + live methods.
8548
- *
8549
- * Mirrors the `ConfigUISchemaWithValues` shape (sections[] + optional
8550
- * tabs[]) without importing from `../interfaces/config-ui.js` — a
8551
- * concrete-but-lenient Zod object keeps tRPC output inference happy
8552
- * (using `z.unknown()` here collapses unrelated router branches to
8553
- * `unknown` when the generator re-inlines the huge AppRouter type).
8554
- *
8555
- * `.passthrough()` on sections/fields accepts whatever FormBuilder
8556
- * extensions the caller adds (showWhen, displayScale, …) without
8557
- * rebuilding every time a new field kind is introduced.
8558
- */
8559
- var ContributionSectionSchema = object({
8560
- id: string(),
8561
- title: string(),
8562
- description: string().optional(),
8563
- style: _enum(["card", "accordion"]).optional(),
8564
- defaultCollapsed: boolean().optional(),
8565
- columns: union([
8566
- literal(1),
8567
- literal(2),
8568
- literal(3),
8569
- literal(4)
8570
- ]).optional(),
8571
- tab: string().optional(),
8572
- location: _enum([
8573
- "settings",
8574
- "top-tab",
8575
- "hero"
8576
- ]).optional(),
8577
- order: number().optional(),
8578
- fields: array(any())
8579
- });
8580
- object({
8581
- tabs: array(object({
8582
- id: string(),
8583
- label: string(),
8584
- icon: string(),
8585
- order: number().optional()
8586
- })).optional(),
8587
- sections: array(ContributionSectionSchema)
8588
- }).nullable();
8589
- object({ deviceId: number() }), object({ deviceId: number() }), object({
8590
- deviceId: number(),
8591
- patch: record(string(), unknown())
8592
- }), object({ success: literal(true) });
8593
- object({ deviceId: number() }), unknown().nullable();
8594
- function method(input, output, options) {
8595
- return {
8596
- input,
8597
- output,
8598
- kind: options?.kind ?? "query",
8599
- ...options?.auth !== void 0 ? { auth: options.auth } : {},
8600
- ...options?.access !== void 0 ? { access: options.access } : {},
8601
- ...options?.role !== void 0 ? { role: options.role } : {},
8602
- ...options?.caller !== void 0 ? { caller: options.caller } : {},
8603
- timeoutMs: options?.timeoutMs
8604
- };
8605
- }
8606
- /**
8607
- * A wrapper/system-only method: served exclusively by the cap's system-level
8608
- * provider (`InferProvider`), and OPTIONAL on `InferNativeProvider` so per-device
8609
- * driver natives don't stub out a wrapper concern (e.g. a cross-device cache
8610
- * overview). The `systemOnly: true` literal is what `InferNativeProvider` keys on.
8611
- */
8612
- function systemMethod(input, output, options) {
8613
- return {
8614
- ...method(input, output, options),
8615
- systemOnly: true
8616
- };
8617
- }
8618
- /**
8619
- * A method a SOURCE of a collection cap may legitimately not serve — OPTIONAL
8620
- * on `InferProvider`. The `providerOptional: true` literal is what
8621
- * `InferProvider` keys on; see {@link CapabilityMethodSchema.providerOptional}
8622
- * for when this is the honest answer and when it is a soft stub.
8623
- */
8624
- function optionalMethod(input, output, options) {
8625
- return {
8626
- ...method(input, output, options),
8627
- providerOptional: true
8628
- };
8629
- }
8630
- /** Shorthand to define an event schema */
8631
- function event(data) {
8632
- return { data };
8633
- }
8634
9128
  /**
8635
9129
  * `addon-pages-source` — collection cap exposing per-provider raw page
8636
9130
  * declarations. Every addon that contributes a UI page registers a
@@ -8872,6 +9366,7 @@ var CAP_NAMES = Object.freeze([
8872
9366
  "mesh-network",
8873
9367
  "meter",
8874
9368
  "metrics-provider",
9369
+ "migrations",
8875
9370
  "model-convert",
8876
9371
  "model-distributor",
8877
9372
  "motion",
@@ -8904,6 +9399,7 @@ var CAP_NAMES = Object.freeze([
8904
9399
  "plate-gallery",
8905
9400
  "platform-probe",
8906
9401
  "power-meter",
9402
+ "power-source",
8907
9403
  "presence",
8908
9404
  "pressure-sensor",
8909
9405
  "privacy-mask",
@@ -10255,6 +10751,13 @@ Object.freeze({
10255
10751
  "valueType": "number"
10256
10752
  }
10257
10753
  ],
10754
+ "power-source": [{
10755
+ "path": "switchOn",
10756
+ "valueType": "boolean"
10757
+ }, {
10758
+ "path": "offSeconds",
10759
+ "valueType": "number"
10760
+ }],
10258
10761
  "presence": [
10259
10762
  {
10260
10763
  "path": "state",
@@ -10766,379 +11269,7 @@ object({
10766
11269
  params: record(string(), union([string(), number()])).optional()
10767
11270
  });
10768
11271
  //#endregion
10769
- //#region ../types/dist/err-msg-BD5buxvT.mjs
10770
- var DeviceType = /* @__PURE__ */ function(DeviceType) {
10771
- DeviceType["Camera"] = "camera";
10772
- DeviceType["Hub"] = "hub";
10773
- DeviceType["Light"] = "light";
10774
- DeviceType["Siren"] = "siren";
10775
- DeviceType["Switch"] = "switch";
10776
- DeviceType["Sensor"] = "sensor";
10777
- DeviceType["Thermostat"] = "thermostat";
10778
- /** Air-conditioner / heat-pump climate device (HVAC) — shares the
10779
- * `climate-control` cap surface with `Thermostat` but renders a
10780
- * dedicated AC-appropriate control UI (mode chips, fan speed,
10781
- * independent vertical/horizontal swing). Sources: native Gree, and
10782
- * reusable by other AC integrations. */
10783
- DeviceType["Climate"] = "climate";
10784
- DeviceType["Button"] = "button";
10785
- /** Generic stateless event emitter — carries a device's EXACT declared
10786
- * event vocabulary verbatim (no normalization). Installed with the
10787
- * `event-emitter` cap. Sources: HA `event.*` entities (structured) and
10788
- * HA bus events (e.g. `zha_event`, generic). */
10789
- DeviceType["EventEmitter"] = "event-emitter";
10790
- /** Firmware/software update entity — current vs available version,
10791
- * updatable flag, update state, and an install action. Installed with
10792
- * the `update` cap. Sources: Homematic firmware-update channels (and
10793
- * reusable by other providers, e.g. HA `update.*` entities). */
10794
- DeviceType["Update"] = "update";
10795
- DeviceType["Generic"] = "generic";
10796
- /** Generic notification delivery target (HA `notify.<service>`, future
10797
- * Telegram / Discord / ntfy / SMTP, …). One device per delivery
10798
- * endpoint; the `notifier` cap defines the send surface. */
10799
- DeviceType["Notifier"] = "notifier";
10800
- /** Pre-recorded action sequence with optional parameters
10801
- * (HA `script.*`). Runnable via `script-runner` cap. */
10802
- DeviceType["Script"] = "script";
10803
- /** Automation rule (HA `automation.*`) — enable/disable + manual
10804
- * trigger surface exposed via `automation-control` cap. */
10805
- DeviceType["Automation"] = "automation";
10806
- /** Door / smart lock device (HA `lock.*`). `lock-control` cap. */
10807
- DeviceType["Lock"] = "lock";
10808
- /** Window covering, blinds, garage door, valve, etc. (HA `cover.*`,
10809
- * `valve.*`). `cover` cap with sub-roles for variant. */
10810
- DeviceType["Cover"] = "cover";
10811
- /** Pipe / water / gas valve with open/close/stop and optional
10812
- * position (HA `valve.*`). `valve` cap — a cover-sibling actuator
10813
- * modelled on the same open/closed lifecycle. */
10814
- DeviceType["Valve"] = "valve";
10815
- /** Humidifier / dehumidifier with on/off + target humidity + mode
10816
- * (HA `humidifier.*`). `humidifier` cap — a climate-family actuator
10817
- * modelled on the same target / mode lifecycle. */
10818
- DeviceType["Humidifier"] = "humidifier";
10819
- /** Water heater / boiler with target temperature + operation mode +
10820
- * away mode (HA `water_heater.*`). `water-heater` cap — a
10821
- * climate-family actuator. */
10822
- DeviceType["WaterHeater"] = "water-heater";
10823
- /** Ceiling / standing / exhaust fan (HA `fan.*`). `fan-control` cap. */
10824
- DeviceType["Fan"] = "fan";
10825
- /** Audio / video playback endpoint (HA `media_player.*`). Disjoint from
10826
- * the camera surface — those use `Camera`. `media-player` cap. */
10827
- DeviceType["MediaPlayer"] = "media-player";
10828
- /** Security panel / alarm system (HA `alarm_control_panel.*`).
10829
- * `alarm-panel` cap. */
10830
- DeviceType["AlarmPanel"] = "alarm-panel";
10831
- /** Generic user-settable input (HA `number` / `input_number` / `select`
10832
- * / `input_select` / `text` / `input_text` / `input_datetime`).
10833
- * Sub-type via `DeviceRole`: NumericControl / SelectControl /
10834
- * TextControl / DateTimeControl. */
10835
- DeviceType["Control"] = "control";
10836
- /** Person / device-tracker presence (HA `person.*`, `device_tracker.*`).
10837
- * `presence` cap. */
10838
- DeviceType["Presence"] = "presence";
10839
- /** Weather provider (HA `weather.*`). Tier-3, low MVP priority.
10840
- * `weather` cap. */
10841
- DeviceType["Weather"] = "weather";
10842
- /** Robot vacuum (HA `vacuum.*`). Tier-3. `vacuum-control` cap. */
10843
- DeviceType["Vacuum"] = "vacuum";
10844
- /** Robotic lawn mower (HA `lawn_mower.*`). Tier-3.
10845
- * `lawn-mower-control` cap. */
10846
- DeviceType["LawnMower"] = "lawn-mower";
10847
- /** Physical HA device group — parent container for entity-children
10848
- * adopted from a single HA device entry. Not renderable as a
10849
- * standalone device; exists only to anchor child entities. */
10850
- DeviceType["Container"] = "container";
10851
- /** Single still-image entity (HA `image.*`). Read-only display of an
10852
- * `entity_picture` signed URL the browser loads directly. `image` cap. */
10853
- DeviceType["Image"] = "image";
10854
- /** Smart pet feeder — cloud-connected food dispenser with a bowl food
10855
- * level, battery, desiccant life, feeding state and manual-feed /
10856
- * call-pet / maintenance actions. Installed with the `pet-feeder` cap;
10857
- * dual-hopper models (D4S/D4SH) expose per-hopper portions. Sources:
10858
- * native PetKit (`nodepetkit` `FeederDevice`), reusable by other feeder
10859
- * integrations sharing the same food/desiccant/hopper surface. */
10860
- DeviceType["PetFeeder"] = "pet-feeder";
10861
- /** Pet water fountain — tank level, water drunk, pump and its duty cycle.
10862
- * Installed with the `pet-fountain` cap. Reaches CamStack as loose entities
10863
- * of a container and is BUILT as a composed device (D967). */
10864
- DeviceType["PetFountain"] = "pet-fountain";
10865
- /** Built-in dishwasher — program lifecycle, door / remote-start gates,
10866
- * salt and rinse-aid levels. Installed with the `dishwasher` cap.
10867
- * Sources: native Bosch Home Connect, reusable by similar integrations.
10868
- * A plug-built dishwasher carries running-state and power instead. */
10869
- DeviceType["Dishwasher"] = "dishwasher";
10870
- /** Washing machine. A plug-built one is running while its power stays
10871
- * above a threshold. No program cap — that surface is the dishwasher's. */
10872
- DeviceType["Washer"] = "washer";
10873
- /** Tumble dryer. Same plug-built running surface as {@link Washer}. */
10874
- DeviceType["Dryer"] = "dryer";
10875
- /** The physical bridge box of a vendor ecosystem (Velux KLF-200, and later
10876
- * other radio-to-IP bridges). It carries the box's own facts (firmware,
10877
- * address, connection state) and the actions the box really supports
10878
- * (`reboot`, `device-admin-link`). Products are NOT its children — they are
10879
- * adopted beside it — and its connection settings stay on the integration. */
10880
- DeviceType["Gateway"] = "gateway";
10881
- return DeviceType;
10882
- }({});
10883
- var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
10884
- DeviceFeature["BatteryOperated"] = "battery-operated";
10885
- DeviceFeature["Rebootable"] = "rebootable";
10886
- /**
10887
- * Device supports an on-demand re-sync of its derived spec with its
10888
- * upstream source — drives the generic Re-sync button. The owning
10889
- * provider implements the action via the `device-adoption.resync` cap.
10890
- */
10891
- DeviceFeature["Resyncable"] = "resyncable";
10892
- DeviceFeature["NativeSnapshot"] = "native-snapshot";
10893
- DeviceFeature["DoorbellButton"] = "doorbell-button";
10894
- DeviceFeature["TwoWayAudio"] = "two-way-audio";
10895
- DeviceFeature["PanTiltZoom"] = "pan-tilt-zoom";
10896
- /**
10897
- * Camera supports the on-firmware autotrack subsystem (subject-
10898
- * following). Distinct from `PanTiltZoom` because not every PTZ
10899
- * camera ships autotrack — the admin UI uses this flag to gate
10900
- * the autotrack toggle / settings card without re-deriving from
10901
- * the cap registry. Mirrors `ptz-autotrack` cap registration:
10902
- * driver sets this feature when probe confirms the firmware
10903
- * surface, and registers the cap in the same code path.
10904
- */
10905
- DeviceFeature["PtzAutotrack"] = "ptz-autotrack";
10906
- /**
10907
- * Accessory exposes a "trigger on motion" toggle — the parent camera's
10908
- * motion detection automatically activates this device. Mirrors
10909
- * `motion-trigger` cap registration: drivers set this feature in the
10910
- * same code path that calls `ctx.registerNativeCap(motionTriggerCapability, ...)`.
10911
- *
10912
- * Used by admin UI (gate the in-hero `MotionTriggerToggle` against a
10913
- * fast scalar without binding fetch), notifier rules, and `listAll`
10914
- * filters that want "all devices with on-motion behaviour".
10915
- */
10916
- DeviceFeature["MotionTrigger"] = "motion-trigger";
10917
- /** Light supports rgb-triplet color via `color` cap. */
10918
- DeviceFeature["LightColorRgb"] = "light-color-rgb";
10919
- /** Light supports HSV color via `color` cap. */
10920
- DeviceFeature["LightColorHsv"] = "light-color-hsv";
10921
- /** Light supports color-temperature (mired) via `color` cap. */
10922
- DeviceFeature["LightColorMired"] = "light-color-mired";
10923
- /** Thermostat supports a `heat_cool` dual setpoint (targetLow +
10924
- * targetHigh). Gates the range slider UI. */
10925
- DeviceFeature["ClimateDualSetpoint"] = "climate-dual-setpoint";
10926
- /** Thermostat exposes target humidity and/or current humidity
10927
- * readings. Gates the humidity controls. */
10928
- DeviceFeature["ClimateHumidity"] = "climate-humidity";
10929
- /** Thermostat exposes a fan-mode selector. */
10930
- DeviceFeature["ClimateFanMode"] = "climate-fan-mode";
10931
- /** Thermostat exposes preset modes (eco / away / sleep / vendor). */
10932
- DeviceFeature["ClimatePreset"] = "climate-preset";
10933
- /** Thermostat exposes a vertical louver swing toggle. Gates the
10934
- * vertical-swing switch in the climate UI. Independent of horizontal. */
10935
- DeviceFeature["ClimateSwingVertical"] = "climate-swing-vertical";
10936
- /** Thermostat exposes a horizontal louver swing toggle. Gates the
10937
- * horizontal-swing switch in the climate UI. Independent of vertical. */
10938
- DeviceFeature["ClimateSwingHorizontal"] = "climate-swing-horizontal";
10939
- /** Cover exposes intermediate position control (0..100). Gates the
10940
- * position slider UI. */
10941
- DeviceFeature["CoverPositionable"] = "cover-positionable";
10942
- /** Cover exposes slat-tilt control. Gates the tilt slider UI. */
10943
- DeviceFeature["CoverTilt"] = "cover-tilt";
10944
- /** Valve exposes intermediate position control (0..100). Gates the
10945
- * position slider / drag surface UI. */
10946
- DeviceFeature["ValvePositionable"] = "valve-positionable";
10947
- /** Fan exposes a speed-percentage setter. Gates the speed slider UI. */
10948
- DeviceFeature["FanSpeed"] = "fan-speed";
10949
- /** Fan exposes a preset mode selector. */
10950
- DeviceFeature["FanPreset"] = "fan-preset";
10951
- /** Fan exposes blade direction (forward/reverse) — typical of
10952
- * ceiling fans. */
10953
- DeviceFeature["FanDirection"] = "fan-direction";
10954
- /** Fan exposes an oscillation toggle. */
10955
- DeviceFeature["FanOscillating"] = "fan-oscillating";
10956
- /** Lock requires a PIN code on lock/unlock. Gates the code-entry
10957
- * field on the UI lock-controls panel. */
10958
- DeviceFeature["LockPinRequired"] = "lock-pin-required";
10959
- /** Lock supports a latch-release ("open door") action distinct from
10960
- * unlock. Mirrors HA `LockEntityFeature.OPEN` (bit 1) in
10961
- * `supported_features`. Gates the Open Door button in the UI. */
10962
- DeviceFeature["LockOpen"] = "lock-open";
10963
- /** Media player exposes a seek-to-position surface. */
10964
- DeviceFeature["MediaPlayerSeek"] = "media-player-seek";
10965
- /** Media player exposes a volume-level setter. */
10966
- DeviceFeature["MediaPlayerVolume"] = "media-player-volume";
10967
- /** Media player exposes a mute toggle distinct from volume=0. */
10968
- DeviceFeature["MediaPlayerMute"] = "media-player-mute";
10969
- /** Media player exposes a shuffle toggle. */
10970
- DeviceFeature["MediaPlayerShuffle"] = "media-player-shuffle";
10971
- /** Media player exposes a repeat mode (off / all / one). */
10972
- DeviceFeature["MediaPlayerRepeat"] = "media-player-repeat";
10973
- /** Media player exposes a source / input selector. */
10974
- DeviceFeature["MediaPlayerSelectSource"] = "media-player-select-source";
10975
- /** Media player exposes a play-arbitrary-media surface (URL / id). */
10976
- DeviceFeature["MediaPlayerPlayMedia"] = "media-player-play-media";
10977
- /** Media player exposes next-track. */
10978
- DeviceFeature["MediaPlayerNext"] = "media-player-next";
10979
- /** Media player exposes previous-track. */
10980
- DeviceFeature["MediaPlayerPrevious"] = "media-player-previous";
10981
- /** Media player exposes stop distinct from pause. */
10982
- DeviceFeature["MediaPlayerStop"] = "media-player-stop";
10983
- /** Alarm panel requires a PIN code on arm/disarm. */
10984
- DeviceFeature["AlarmPinRequired"] = "alarm-pin-required";
10985
- /** Presence device carries GPS coordinates (lat/lng/accuracy) in
10986
- * addition to a textual location. */
10987
- DeviceFeature["PresenceGps"] = "presence-gps";
10988
- /** Notifier accepts an inline / URL image attachment. */
10989
- DeviceFeature["NotifierImage"] = "notifier-image";
10990
- /** Notifier accepts a priority hint (high/normal/low). */
10991
- DeviceFeature["NotifierPriority"] = "notifier-priority";
10992
- /** Notifier accepts a free-form `data` payload for platform-specific
10993
- * fields. */
10994
- DeviceFeature["NotifierData"] = "notifier-data";
10995
- /** Notifier supports interactive action buttons / callbacks. */
10996
- DeviceFeature["NotifierActions"] = "notifier-actions";
10997
- /** Notifier supports per-call recipient targeting (multi-user). */
10998
- DeviceFeature["NotifierRecipients"] = "notifier-recipients";
10999
- /** Script runner accepts a variables map on each run invocation. */
11000
- DeviceFeature["ScriptVariables"] = "script-variables";
11001
- /** Automation `trigger` accepts a skipCondition flag — fires the
11002
- * automation's actions while bypassing its condition block. */
11003
- DeviceFeature["AutomationSkipCondition"] = "automation-skip-condition";
11004
- /** Robot vacuum exposes a live cleaning map (image child). Gates the
11005
- * map tile in the vacuum UI. */
11006
- DeviceFeature["VacuumHasMap"] = "vacuum-has-map";
11007
- /** Robot vacuum exposes AI obstacle-detection toggles. Gates the AI
11008
- * switches group. */
11009
- DeviceFeature["VacuumHasAi"] = "vacuum-has-ai";
11010
- /** Robot mower exposes a live mowing map (SVG image child). Gates the
11011
- * mower map tile. */
11012
- DeviceFeature["MowerHasMap"] = "mower-has-map";
11013
- /** Robot mower exposes targeted mowing (all-area / zones / edges /
11014
- * spots) — gates the Mow action + map selectors. */
11015
- DeviceFeature["MowerHasTargetedMowing"] = "mower-has-targeted-mowing";
11016
- return DeviceFeature;
11017
- }({});
11018
- /**
11019
- * Semantic role a device plays within its parent. Populated by driver
11020
- * addons when creating accessory devices (Reolink siren/floodlight/
11021
- * PIR/chime/autotrack/doorbell, ONVIF relay outputs, …). Used by the
11022
- * admin UI to pick icons, labels, and widgets — a `Switch` with
11023
- * `role: Floodlight` renders as a bulb with a brightness slider,
11024
- * whereas a `Switch` with `role: Siren` renders as a klaxon.
11025
- *
11026
- * Undefined for top-level devices (cameras, NVRs, hubs). Persisted in
11027
- * sqlite as a nullable TEXT column — old rows keep working unchanged.
11028
- */
11029
- var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
11030
- DeviceRole["Siren"] = "siren";
11031
- DeviceRole["Floodlight"] = "floodlight";
11032
- DeviceRole["Spotlight"] = "spotlight";
11033
- DeviceRole["PirSensor"] = "pir-sensor";
11034
- DeviceRole["Chime"] = "chime";
11035
- DeviceRole["Autotrack"] = "autotrack";
11036
- DeviceRole["Nightvision"] = "nightvision";
11037
- DeviceRole["PrivacyMask"] = "privacy-mask";
11038
- DeviceRole["Doorbell"] = "doorbell";
11039
- /** Interior blind / shade / roller blind. HA `device_class: blind|shade`. */
11040
- DeviceRole["CoverBlind"] = "cover-blind";
11041
- /** Exterior roller shutter. HA `device_class: shutter`; Homematic BROLL. */
11042
- DeviceRole["CoverShutter"] = "cover-shutter";
11043
- /** Exterior awning. HA `device_class: awning`. */
11044
- DeviceRole["CoverAwning"] = "cover-awning";
11045
- /** Curtain / drape. HA `device_class: curtain`. */
11046
- DeviceRole["CoverCurtain"] = "cover-curtain";
11047
- /** Garage door. HA `device_class: garage`. A security actuator: exports gate it. */
11048
- DeviceRole["CoverGarage"] = "cover-garage";
11049
- /** Gate. HA `device_class: gate`. A security actuator: exports gate it. */
11050
- DeviceRole["CoverGate"] = "cover-gate";
11051
- /** Door. HA `device_class: door`. A security actuator: exports gate it. */
11052
- DeviceRole["CoverDoor"] = "cover-door";
11053
- /** Window. HA `device_class: window`. */
11054
- DeviceRole["CoverWindow"] = "cover-window";
11055
- /** Virtual HA toggle (input_boolean.*) — distinguishable from a
11056
- * real Switch device for UI rendering / export adapters. */
11057
- DeviceRole["BinaryHelper"] = "binary-helper";
11058
- /** A smart plug: a `switch` whose source says it is an outlet (HA
11059
- * `device_class: outlet`). The Alexa export shows it as a SMARTPLUG. */
11060
- DeviceRole["Outlet"] = "outlet";
11061
- /** Generic motion / occupancy / moving event source. Distinct from
11062
- * the camera accessory PirSensor role: that one is a camera child;
11063
- * this is a standalone HA / 3rd-party motion sensor. */
11064
- DeviceRole["MotionSensor"] = "motion-sensor";
11065
- DeviceRole["ContactSensor"] = "contact-sensor";
11066
- DeviceRole["LeakSensor"] = "leak-sensor";
11067
- DeviceRole["SmokeSensor"] = "smoke-sensor";
11068
- DeviceRole["COSensor"] = "co-sensor";
11069
- DeviceRole["GasSensor"] = "gas-sensor";
11070
- DeviceRole["TamperSensor"] = "tamper-sensor";
11071
- DeviceRole["VibrationSensor"] = "vibration-sensor";
11072
- DeviceRole["ConnectivitySensor"] = "connectivity-sensor";
11073
- DeviceRole["SoundSensor"] = "sound-sensor";
11074
- /** Fallback for `binary_sensor` without a known `device_class`. */
11075
- DeviceRole["BinarySensor"] = "binary-sensor";
11076
- DeviceRole["TemperatureSensor"] = "temperature-sensor";
11077
- DeviceRole["HumiditySensor"] = "humidity-sensor";
11078
- DeviceRole["AmbientLightSensor"] = "ambient-light-sensor";
11079
- DeviceRole["PressureSensor"] = "pressure-sensor";
11080
- /** Wind speed or direction (weather-station `wind-sensor` cap). */
11081
- DeviceRole["WindSensor"] = "wind-sensor";
11082
- /** Rain accumulation or rate (weather-station `rain-sensor` cap). */
11083
- DeviceRole["RainSensor"] = "rain-sensor";
11084
- /** UV index (weather-station `uv-sensor` cap). */
11085
- DeviceRole["UvSensor"] = "uv-sensor";
11086
- /** Solar irradiance W/m² (weather-station `solar-radiation-sensor` cap).
11087
- * Distinct from AmbientLightSensor (lux). */
11088
- DeviceRole["SolarRadiationSensor"] = "solar-radiation-sensor";
11089
- /** Soil moisture % (garden/weather `soil-moisture-sensor` cap). */
11090
- DeviceRole["SoilMoistureSensor"] = "soil-moisture-sensor";
11091
- DeviceRole["PowerSensor"] = "power-sensor";
11092
- DeviceRole["EnergySensor"] = "energy-sensor";
11093
- DeviceRole["VoltageSensor"] = "voltage-sensor";
11094
- DeviceRole["CurrentSensor"] = "current-sensor";
11095
- DeviceRole["AirQualitySensor"] = "air-quality-sensor";
11096
- /** Battery level (numeric % via `sensor` OR low-bool via
11097
- * `binary_sensor` — the cap distinguishes via the value type). */
11098
- DeviceRole["BatterySensor"] = "battery-sensor";
11099
- /** Fallback for `sensor` numeric without a known `device_class`. */
11100
- DeviceRole["NumericSensor"] = "numeric-sensor";
11101
- /** String / enum state (HA `sensor` with `state_class: enum` or
11102
- * `attributes.options`). */
11103
- DeviceRole["EnumSensor"] = "enum-sensor";
11104
- /** Date / timestamp state (HA `sensor` with `device_class: timestamp`
11105
- * or `date`). The slice carries the raw ISO string verbatim (hosted on
11106
- * the `enum-sensor` cap); the UI renders it locale-formatted. */
11107
- DeviceRole["DateTimeSensor"] = "datetime-sensor";
11108
- /** Last-resort fallback when nothing else matches. */
11109
- DeviceRole["GenericSensor"] = "generic-sensor";
11110
- DeviceRole["NumericControl"] = "numeric-control";
11111
- DeviceRole["SelectControl"] = "select-control";
11112
- DeviceRole["TextControl"] = "text-control";
11113
- DeviceRole["DateTimeControl"] = "datetime-control";
11114
- /** Mobile push notifier (HA `notify.mobile_app_*`) — supports
11115
- * rich features (image, priority, channel routing). */
11116
- DeviceRole["MobilePushNotifier"] = "mobile-push-notifier";
11117
- /** Chat / messaging service (HA `notify.telegram_*`,
11118
- * `notify.discord_*`, etc.). */
11119
- DeviceRole["MessagingNotifier"] = "messaging-notifier";
11120
- /** Email-based delivery (HA `notify.smtp`, etc.). */
11121
- DeviceRole["EmailNotifier"] = "email-notifier";
11122
- /** Fallback when the notifier service name doesn't match a known
11123
- * pattern. */
11124
- DeviceRole["GenericNotifier"] = "generic-notifier";
11125
- /** Emits a pulse train (infrared or RF) on request — the `ir-transmitter`
11126
- * cap. A `DeviceType.Generic` device. */
11127
- DeviceRole["IrTransmitter"] = "ir-transmitter";
11128
- return DeviceRole;
11129
- }({});
11130
- /**
11131
- import { errMsg } from '@camstack/types'
11132
- * Extract a human-readable message from an unknown error value.
11133
- * Replaces the ubiquitous `errMsg(err)` pattern.
11134
- */
11135
- function errMsg(err) {
11136
- if (err instanceof Error) return err.message;
11137
- if (typeof err === "string") return err;
11138
- return String(err);
11139
- }
11140
- //#endregion
11141
- //#region ../types/dist/composition-C7WdThmP.mjs
11272
+ //#region ../types/dist/composition-BBzVf2xd.mjs
11142
11273
  /**
11143
11274
  * The ffmpeg build every CamStack node downloads, per platform and arch.
11144
11275
  *
@@ -12357,6 +12488,71 @@ var EventOwnerTypeSchema = _enum(EVENT_OWNER_TYPES);
12357
12488
  var MediaPresenceOwnerKindSchema = _enum([...EVENT_OWNER_TYPES, "track"]);
12358
12489
  new Set(EVENT_OWNER_TYPES);
12359
12490
  /**
12491
+ * What a published package needs from the rest of the install (D989).
12492
+ *
12493
+ * One published framework package (`@camstack/server`) carries the kernel, the
12494
+ * builtins and the capability contracts, so "which addon runs on which
12495
+ * framework" is a question of version, and the answer is DECLARED by the
12496
+ * package that knows it:
12497
+ *
12498
+ * - an addon says the oldest server it runs on (`requires.server: ">=X"`);
12499
+ * - the server says the oldest addon it works with
12500
+ * (`requires.addons: { "@camstack/addon-x": ">=Y" }`) and the oldest shell
12501
+ * around it (`requires.wrapper: { desktop, image }`);
12502
+ * - a wrapper (the desktop app, the container starter) says which server
12503
+ * range it can host, and reports its own kind and version.
12504
+ *
12505
+ * The publish workflow STAMPS these after the version bump
12506
+ * (`scripts/ci/stamp-requires.mjs`); nobody types a number by hand.
12507
+ *
12508
+ * A requirement that cannot be checked is NOT met: a shell that reports no
12509
+ * version counts as below the minimum, and an unreadable running version is
12510
+ * named in the result (a failed read is never a pass).
12511
+ */
12512
+ /** `>=MAJOR.MINOR.PATCH[-prerelease]` — the only range shape a requirement uses. */
12513
+ var MinVersionSchema = string().regex(/^>=\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$/, "a minimum is written \">=X.Y.Z\"");
12514
+ object({
12515
+ /** The oldest `@camstack/server` this package runs on. */
12516
+ server: MinVersionSchema.optional(),
12517
+ /** The oldest installed version of each named addon package. */
12518
+ addons: record(string(), MinVersionSchema).optional(),
12519
+ /** The oldest shell around the server, per shell kind. */
12520
+ wrapper: object({
12521
+ desktop: MinVersionSchema.optional(),
12522
+ image: MinVersionSchema.optional()
12523
+ }).optional()
12524
+ });
12525
+ /** One unmet requirement; each names the versions on both sides. */
12526
+ var UnmetRequirementSchema = discriminatedUnion("kind", [
12527
+ object({
12528
+ kind: literal("server-too-old"),
12529
+ required: string(),
12530
+ /** `null` — the running server version could not be read. */
12531
+ running: string().nullable()
12532
+ }),
12533
+ object({
12534
+ kind: literal("addon-too-old"),
12535
+ packageName: string(),
12536
+ required: string(),
12537
+ /** `null` — the addon is not installed (or its version is unreadable). */
12538
+ running: string().nullable()
12539
+ }),
12540
+ object({
12541
+ kind: literal("wrapper-too-old"),
12542
+ wrapper: _enum(["desktop", "image"]),
12543
+ required: string(),
12544
+ /** `null` — the wrapper reported no version. */
12545
+ running: string().nullable()
12546
+ })
12547
+ ]);
12548
+ var RequiredAddonUpdateSchema = object({
12549
+ packageName: string(),
12550
+ /** The minimum the target server declares. */
12551
+ required: string(),
12552
+ /** What this node has; `null` when the addon is not installed. */
12553
+ installed: string().nullable()
12554
+ });
12555
+ /**
12360
12556
  * Which integration instance a settings form is for. An addon that serves several instances
12361
12557
  * (`instanceMode: multiple`) can show a different form per instance — an NVR integration
12362
12558
  * needs its connection, the default integration needs the addon's own sections.
@@ -12831,6 +13027,613 @@ var CameraSwitchGroupSchema = object({
12831
13027
  fetchedAt: number()
12832
13028
  });
12833
13029
  /**
13030
+ * Query filter for settings-store collections.
13031
+ */
13032
+ var QueryFilterSchema = object({
13033
+ where: record(string(), unknown()).optional(),
13034
+ whereIn: record(string(), array(unknown())).optional(),
13035
+ whereBetween: record(string(), tuple([unknown(), unknown()])).optional(),
13036
+ /** NULL-safe exclusion: matches rows whose field is NULL OR != the value. */
13037
+ whereNot: record(string(), unknown()).optional(),
13038
+ /** NULL-safe exclusion of a SET — `whereNot` for more than one value. An
13039
+ * empty list excludes nothing. See `QueryFilter.whereNotIn`. */
13040
+ whereNotIn: record(string(), array(unknown())).optional(),
13041
+ orderBy: object({
13042
+ field: string(),
13043
+ direction: _enum(["asc", "desc"])
13044
+ }).optional(),
13045
+ limit: number().optional(),
13046
+ offset: number().optional()
13047
+ });
13048
+ /**
13049
+ * The predicate half of a filter, for BULK MUTATIONS.
13050
+ *
13051
+ * Deliberately not `QueryFilterSchema`: `orderBy` / `limit` / `offset` have no
13052
+ * meaning for a statement that rewrites a set, and accepting them would invite
13053
+ * a caller to believe `limit` bounds the damage. Every field is optional here
13054
+ * only so the shape stays composable — the implementation REJECTS a filter
13055
+ * that compiles to no predicate, because that is the whole collection.
13056
+ */
13057
+ var MutationFilterSchema = object({
13058
+ where: record(string(), unknown()).optional(),
13059
+ whereIn: record(string(), array(unknown())).optional(),
13060
+ whereBetween: record(string(), tuple([unknown(), unknown()])).optional(),
13061
+ whereNot: record(string(), unknown()).optional(),
13062
+ whereNotIn: record(string(), array(unknown())).optional()
13063
+ });
13064
+ /**
13065
+ * One scalar an {@link settingsStoreCapability.methods.aggregate} call asks for.
13066
+ *
13067
+ * `as` names the slot in the result, so the SAME column may be asked twice with
13068
+ * two operations (`MIN(startMs)` and `MAX(startMs)` in one round trip) — which
13069
+ * a `Record<column, op>` shape could not express.
13070
+ */
13071
+ var AggregateFieldSchema = object({
13072
+ /** Result key. */
13073
+ as: string().min(1),
13074
+ /** Column to aggregate. Must be a real column of a declared collection. */
13075
+ field: string().min(1),
13076
+ op: _enum([
13077
+ "sum",
13078
+ "min",
13079
+ "max"
13080
+ ])
13081
+ });
13082
+ /**
13083
+ * `COUNT(*)` plus one number per requested field.
13084
+ *
13085
+ * `null` means NO ROW MATCHED, never zero: a `SUM` over an empty set and a sum
13086
+ * that really is 0 are different facts, and an accounting caller that renders
13087
+ * "0 bytes, oldest = 0" for "nothing here" reports a lie about a disk.
13088
+ */
13089
+ var AggregateResultSchema = object({
13090
+ count: number().int(),
13091
+ values: record(string(), number().nullable())
13092
+ });
13093
+ /** A single stored record: `{ id, data }`. */
13094
+ var SettingsRecordSchema = object({
13095
+ id: string(),
13096
+ data: record(string(), unknown())
13097
+ });
13098
+ /**
13099
+ * One record of a BULK insert — {@link SettingsRecordSchema} with the id made
13100
+ * optional.
13101
+ *
13102
+ * A separate schema rather than loosening the shared one: every other method
13103
+ * on this cap addresses a row BY its id, and making that field optional
13104
+ * everywhere would turn a forgotten key into a silently generated one on
13105
+ * `update` and `delete` as well.
13106
+ */
13107
+ var BulkRecordSchema = object({
13108
+ id: string().optional(),
13109
+ data: record(string(), unknown())
13110
+ });
13111
+ /**
13112
+ * The database FILES one `sqlite-settings` engine process owns (D851).
13113
+ * Closed on purpose: a file is a thing the engine opens, backs up and gives a
13114
+ * serving thread, so a new one is a code change, never a string a caller
13115
+ * invents. `settings` is `camstack.db` and the default for every collection
13116
+ * that names no file.
13117
+ */
13118
+ var DataStoreDatabaseSchema = _enum([
13119
+ "settings",
13120
+ "events",
13121
+ "history"
13122
+ ]);
13123
+ DataStoreDatabaseSchema.options;
13124
+ /**
13125
+ * One write inside a {@link settingsStoreCapability.methods.transact} call.
13126
+ * The three that a "replace this set, bump that revision" write needs, plus
13127
+ * the batched upsert a rollup writer needs.
13128
+ */
13129
+ var TransactOpSchema = discriminatedUnion("op", [
13130
+ object({
13131
+ op: literal("deleteWhere"),
13132
+ collection: string(),
13133
+ filter: MutationFilterSchema
13134
+ }),
13135
+ object({
13136
+ op: literal("insertMany"),
13137
+ collection: string(),
13138
+ records: array(BulkRecordSchema).readonly()
13139
+ }),
13140
+ object({
13141
+ op: literal("update"),
13142
+ collection: string(),
13143
+ id: string(),
13144
+ data: record(string(), unknown())
13145
+ }),
13146
+ object({
13147
+ op: literal("upsertMany"),
13148
+ collection: string(),
13149
+ conflict: array(string()).readonly(),
13150
+ records: array(BulkRecordSchema).readonly()
13151
+ })
13152
+ ]);
13153
+ /**
13154
+ * The precondition of a transaction: the row `key` of `collection` must hold
13155
+ * `equals` in `column`, read INSIDE the transaction.
13156
+ */
13157
+ var TransactGuardSchema = object({
13158
+ collection: string(),
13159
+ key: string(),
13160
+ column: string(),
13161
+ equals: unknown()
13162
+ });
13163
+ /**
13164
+ * Column declaration for a structured (SQL-backed) collection.
13165
+ *
13166
+ * Logical types — the backend translates each to the matching SQLite
13167
+ * storage class and handles per-type marshaling:
13168
+ * - `TEXT` / `INTEGER` / `REAL` — native SQLite types, pass-through
13169
+ * - `JSON` — TEXT under the hood; serialised on write, parsed on read
13170
+ * - `BOOLEAN` — INTEGER 0/1 under the hood; coerced both directions
13171
+ */
13172
+ var CollectionColumnSchema = object({
13173
+ name: string(),
13174
+ type: _enum([
13175
+ "TEXT",
13176
+ "INTEGER",
13177
+ "REAL",
13178
+ "JSON",
13179
+ "BOOLEAN"
13180
+ ]),
13181
+ primaryKey: boolean().optional(),
13182
+ notNull: boolean().optional(),
13183
+ unique: boolean().optional(),
13184
+ /**
13185
+ * Column DEFAULT. Required for B2: the four `ensureTable` consumers declare
13186
+ * columns like `enabled INTEGER NOT NULL DEFAULT 1`, and without this the
13187
+ * collection surface simply cannot express their existing tables — which is
13188
+ * why they were still on the uncapped `table*` API.
13189
+ */
13190
+ defaultValue: union([
13191
+ string(),
13192
+ number(),
13193
+ boolean()
13194
+ ]).optional()
13195
+ });
13196
+ var CollectionIndexSchema = object({
13197
+ name: string(),
13198
+ columns: array(string()).readonly(),
13199
+ unique: boolean().optional()
13200
+ });
13201
+ /**
13202
+ * The input of `declareCollection` — ONE schema for the door and for the
13203
+ * engine behind it, so the two surfaces cannot drift (the dispatcher forwards
13204
+ * the payload untouched).
13205
+ *
13206
+ * - `database` — the file the collection lives in (D851). Absent means
13207
+ * `settings`. A declaration naming a file other than the one the table is
13208
+ * already in is REFUSED by the engine, never moved.
13209
+ * - `primaryKey` — a COMPOSITE key, as column names. A single name is the same
13210
+ * as `primaryKey: true` on that column. A composite-keyed collection has no
13211
+ * `id`: it is written with `insertMany` / `upsertMany` / `transact` and read
13212
+ * with `query` / `count` / `aggregate` / `deleteWhere`; the calls that
13213
+ * address one row by id are refused.
13214
+ * - `withoutRowid` — emit `WITHOUT ROWID`. Requires a primary key.
13215
+ */
13216
+ var DeclareCollectionInputSchema = object({
13217
+ namespace: string().optional(),
13218
+ collection: string(),
13219
+ columns: array(CollectionColumnSchema).readonly(),
13220
+ indexes: array(CollectionIndexSchema).readonly().optional(),
13221
+ database: DataStoreDatabaseSchema.optional(),
13222
+ primaryKey: array(string()).readonly().optional(),
13223
+ withoutRowid: boolean().optional()
13224
+ });
13225
+ method(object({
13226
+ namespace: string().optional(),
13227
+ collection: string(),
13228
+ key: string()
13229
+ }), unknown(), { auth: "admin" }), method(object({
13230
+ namespace: string().optional(),
13231
+ collection: string(),
13232
+ key: string(),
13233
+ value: unknown()
13234
+ }), _void(), {
13235
+ kind: "mutation",
13236
+ auth: "admin"
13237
+ }), method(object({
13238
+ namespace: string().optional(),
13239
+ collection: string(),
13240
+ filter: QueryFilterSchema.optional(),
13241
+ columns: array(string()).readonly().optional()
13242
+ }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
13243
+ namespace: string().optional(),
13244
+ collection: string(),
13245
+ /** Declared columns identifying the slot; must be covered by a UNIQUE
13246
+ * index on the collection. Never empty. */
13247
+ conflict: array(string()).readonly(),
13248
+ record: BulkRecordSchema
13249
+ }), object({
13250
+ /** The id the row HAS: assigned by SQLite on an insert, or the existing
13251
+ * row's own id on an update. */
13252
+ id: union([string(), number()]) }), {
13253
+ kind: "mutation",
13254
+ auth: "admin"
13255
+ }), method(object({
13256
+ namespace: string().optional(),
13257
+ collection: string(),
13258
+ conflict: array(string()).readonly(),
13259
+ records: array(BulkRecordSchema).readonly()
13260
+ }), object({ upserted: number().int() }), {
13261
+ kind: "mutation",
13262
+ auth: "admin"
13263
+ }), method(object({
13264
+ namespace: string().optional(),
13265
+ collection: string(),
13266
+ record: object({
13267
+ id: string().optional(),
13268
+ data: record(string(), unknown())
13269
+ })
13270
+ }), object({
13271
+ /**
13272
+ * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
13273
+ * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
13274
+ * primary key — which is the only place an auto key is knowable.
13275
+ */
13276
+ id: union([string(), number()]) }), {
13277
+ kind: "mutation",
13278
+ auth: "admin"
13279
+ }), method(object({
13280
+ namespace: string().optional(),
13281
+ collection: string(),
13282
+ records: array(BulkRecordSchema).readonly()
13283
+ }), object({ inserted: number().int() }), {
13284
+ kind: "mutation",
13285
+ auth: "admin"
13286
+ }), method(object({
13287
+ namespace: string().optional(),
13288
+ guard: TransactGuardSchema.optional(),
13289
+ ops: array(TransactOpSchema).readonly()
13290
+ }), object({
13291
+ applied: boolean(),
13292
+ current: unknown().optional()
13293
+ }), {
13294
+ kind: "mutation",
13295
+ auth: "admin"
13296
+ }), method(object({
13297
+ namespace: string().optional(),
13298
+ collection: string(),
13299
+ id: string(),
13300
+ data: record(string(), unknown())
13301
+ }), _void(), {
13302
+ kind: "mutation",
13303
+ auth: "admin"
13304
+ }), method(object({
13305
+ namespace: string().optional(),
13306
+ collection: string(),
13307
+ key: string()
13308
+ }), _void(), {
13309
+ kind: "mutation",
13310
+ auth: "admin"
13311
+ }), method(object({
13312
+ namespace: string().optional(),
13313
+ collection: string(),
13314
+ filter: MutationFilterSchema
13315
+ }), object({ deleted: number().int() }), {
13316
+ kind: "mutation",
13317
+ auth: "admin"
13318
+ }), method(object({
13319
+ namespace: string().optional(),
13320
+ collection: string(),
13321
+ filter: MutationFilterSchema,
13322
+ data: record(string(), unknown())
13323
+ }), object({ updated: number().int() }), {
13324
+ kind: "mutation",
13325
+ auth: "admin"
13326
+ }), method(object({
13327
+ namespace: string().optional(),
13328
+ collection: string(),
13329
+ filter: QueryFilterSchema.optional()
13330
+ }), number(), { auth: "admin" }), method(object({
13331
+ namespace: string().optional(),
13332
+ collection: string(),
13333
+ fields: array(AggregateFieldSchema).readonly(),
13334
+ filter: QueryFilterSchema.optional()
13335
+ }), AggregateResultSchema, { auth: "admin" }), method(object({
13336
+ namespace: string().optional(),
13337
+ collection: string(),
13338
+ field: string(),
13339
+ bucketSize: number().int().positive(),
13340
+ origin: number().int(),
13341
+ filter: QueryFilterSchema.optional()
13342
+ }), array(object({
13343
+ bucket: number().int(),
13344
+ count: number().int()
13345
+ })).readonly(), { auth: "admin" }), method(object({
13346
+ namespace: string().optional(),
13347
+ collection: string()
13348
+ }), boolean(), { auth: "admin" }), method(DeclareCollectionInputSchema, _void(), {
13349
+ kind: "mutation",
13350
+ auth: "admin"
13351
+ });
13352
+ 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>\"");
13353
+ var MigrationLevelSchema = _enum([
13354
+ "hub-store",
13355
+ "addon-state",
13356
+ "node-config",
13357
+ "viewer",
13358
+ "addon-internal"
13359
+ ]);
13360
+ var MigrationStoreSchema = _enum([
13361
+ "settings",
13362
+ "events",
13363
+ "history",
13364
+ "node-local",
13365
+ "addon-files"
13366
+ ]);
13367
+ var MigrationScopeSchema = _enum(["cluster", "per-node"]);
13368
+ /** What depends on a migration while it is pending: `block-owner` is the default. */
13369
+ var MigrationOnFailureSchema = _enum(["block-owner", "tolerate"]);
13370
+ /**
13371
+ * `sql` is a hub-only body over the owner's connection. `plan` returns edits the
13372
+ * engine applies inside the migration's own transaction (hub-owned: computed in
13373
+ * that transaction; addon-owned: computed by the owner and shipped to the engine).
13374
+ * `procedure` is addon-owned work that is not SQL (keychain, integration registry,
13375
+ * device tombstones); the ledger records its outcome and it must be idempotent.
13376
+ */
13377
+ var MigrationBodyKindSchema = _enum([
13378
+ "sql",
13379
+ "plan",
13380
+ "procedure"
13381
+ ]);
13382
+ var MigrationMetaSchema = object({
13383
+ id: MigrationIdSchema,
13384
+ /** `hub`, an addon id, `node` or `viewer`. */
13385
+ owner: string().regex(/^[a-z0-9-]+$/),
13386
+ level: MigrationLevelSchema,
13387
+ /** Strictly increasing per owner: the order within an owner. */
13388
+ seq: number().int().positive(),
13389
+ /** Ids of any owner: the order across owners. */
13390
+ dependsOn: array(MigrationIdSchema),
13391
+ store: MigrationStoreSchema,
13392
+ scope: MigrationScopeSchema,
13393
+ onFailure: MigrationOnFailureSchema,
13394
+ bodyKind: MigrationBodyKindSchema,
13395
+ description: string().min(1),
13396
+ /** The marked field the migration's spec must assert survived. */
13397
+ fixtureMark: string().min(1)
13398
+ }).refine((m) => m.id.startsWith(`${m.owner}/`), {
13399
+ message: "the id must start with \"<owner>/\"",
13400
+ path: ["id"]
13401
+ });
13402
+ /** A cycle in the dependency graph, named by the ids on it. */
13403
+ var MigrationCycleError = class extends Error {
13404
+ ids;
13405
+ constructor(ids) {
13406
+ super(`migration dependsOn cycle: ${ids.join(" -> ")}`);
13407
+ this.ids = ids;
13408
+ this.name = "MigrationCycleError";
13409
+ }
13410
+ };
13411
+ /**
13412
+ * Topological order over `dependsOn` plus the implicit edge "a lower `seq` of an
13413
+ * owner runs first". Ties are broken by `(owner, seq)`. Throws
13414
+ * {@link MigrationCycleError} on a cycle. A `dependsOn` id that is not in the list
13415
+ * is ignored here — the catalogue schema is what refuses it.
13416
+ */
13417
+ function orderMigrations(items) {
13418
+ const byId = new Map(items.map((item) => [item.id, item]));
13419
+ const deps = /* @__PURE__ */ new Map();
13420
+ const ownerSorted = /* @__PURE__ */ new Map();
13421
+ for (const item of items) {
13422
+ const list = ownerSorted.get(item.owner) ?? [];
13423
+ list.push(item);
13424
+ ownerSorted.set(item.owner, list);
13425
+ }
13426
+ for (const item of items) deps.set(item.id, new Set(item.dependsOn.filter((id) => byId.has(id))));
13427
+ for (const list of ownerSorted.values()) {
13428
+ list.sort((a, b) => a.seq - b.seq);
13429
+ for (let i = 1; i < list.length; i++) {
13430
+ const previous = list[i - 1];
13431
+ const current = list[i];
13432
+ if (previous !== void 0 && current !== void 0) deps.get(current.id)?.add(previous.id);
13433
+ }
13434
+ }
13435
+ const tie = (a, b) => a.owner < b.owner ? -1 : a.owner > b.owner ? 1 : a.seq - b.seq;
13436
+ const done = /* @__PURE__ */ new Set();
13437
+ const ordered = [];
13438
+ let remaining = [...items];
13439
+ while (remaining.length > 0) {
13440
+ const ready = remaining.filter((item) => [...deps.get(item.id) ?? []].every((dep) => done.has(dep)));
13441
+ if (ready.length === 0) throw new MigrationCycleError(remaining.map((item) => item.id).sort());
13442
+ ready.sort(tie);
13443
+ const next = ready[0];
13444
+ if (next === void 0) break;
13445
+ ordered.push(next);
13446
+ done.add(next.id);
13447
+ remaining = remaining.filter((item) => item.id !== next.id);
13448
+ }
13449
+ return ordered;
13450
+ }
13451
+ /** Every way a list of migrations (in declaration order) is not a catalogue. */
13452
+ function catalogueIssues(items) {
13453
+ const issues = [];
13454
+ const seen = /* @__PURE__ */ new Set();
13455
+ const known = new Set(items.map((item) => item.id));
13456
+ const lastSeq = /* @__PURE__ */ new Map();
13457
+ const seqUsed = /* @__PURE__ */ new Map();
13458
+ for (const item of items) {
13459
+ if (seen.has(item.id)) issues.push({
13460
+ code: "duplicate-id",
13461
+ ids: [item.id],
13462
+ message: `duplicate id ${item.id}`
13463
+ });
13464
+ seen.add(item.id);
13465
+ const used = seqUsed.get(item.owner) ?? /* @__PURE__ */ new Set();
13466
+ if (used.has(item.seq)) issues.push({
13467
+ code: "duplicate-seq",
13468
+ ids: [item.id],
13469
+ message: `owner ${item.owner} has two migrations with seq ${item.seq}`
13470
+ });
13471
+ else if (item.seq < (lastSeq.get(item.owner) ?? 0)) issues.push({
13472
+ code: "seq-order",
13473
+ ids: [item.id],
13474
+ message: `seq ${item.seq} of ${item.id} does not increase in declaration order (owner ${item.owner})`
13475
+ });
13476
+ used.add(item.seq);
13477
+ seqUsed.set(item.owner, used);
13478
+ lastSeq.set(item.owner, Math.max(item.seq, lastSeq.get(item.owner) ?? 0));
13479
+ for (const dep of item.dependsOn) if (!known.has(dep)) issues.push({
13480
+ code: "unknown-dependency",
13481
+ ids: [item.id, dep],
13482
+ message: `${item.id} dependsOn unknown id ${dep}`
13483
+ });
13484
+ }
13485
+ try {
13486
+ orderMigrations(items);
13487
+ } catch (err) {
13488
+ if (err instanceof MigrationCycleError) issues.push({
13489
+ code: "cycle",
13490
+ ids: err.ids,
13491
+ message: err.message
13492
+ });
13493
+ else throw err;
13494
+ }
13495
+ return issues;
13496
+ }
13497
+ array(MigrationMetaSchema).superRefine((items, ctx) => {
13498
+ for (const issue of catalogueIssues(items)) ctx.addIssue({
13499
+ code: "custom",
13500
+ message: `${issue.code}: ${issue.message}`
13501
+ });
13502
+ });
13503
+ /**
13504
+ * The canonical JSON (`preconditionOf`) of the value a plan read; the apply step
13505
+ * re-reads, and a plan whose read no longer matches is refused (the migration is
13506
+ * `failed`, nothing it edited is kept).
13507
+ */
13508
+ var PreconditionSchema = string().min(1).optional();
13509
+ var MigrationPlanSchema = object({ edits: array(discriminatedUnion("op", [
13510
+ object({
13511
+ op: literal("setKeys"),
13512
+ scope: string().min(1),
13513
+ values: record(string(), unknown()),
13514
+ precondition: PreconditionSchema
13515
+ }),
13516
+ object({
13517
+ op: literal("deleteKeys"),
13518
+ scope: string().min(1),
13519
+ keys: array(string().min(1)).min(1),
13520
+ precondition: PreconditionSchema
13521
+ }),
13522
+ object({
13523
+ op: literal("putRow"),
13524
+ table: string().min(1),
13525
+ key: record(string(), unknown()),
13526
+ row: record(string(), unknown()),
13527
+ precondition: PreconditionSchema
13528
+ }),
13529
+ object({
13530
+ op: literal("deleteRow"),
13531
+ table: string().min(1),
13532
+ key: record(string(), unknown()),
13533
+ precondition: PreconditionSchema
13534
+ }),
13535
+ object({
13536
+ op: literal("upsertRecord"),
13537
+ kind: string().min(1),
13538
+ recordKey: string().min(1),
13539
+ value: unknown(),
13540
+ precondition: PreconditionSchema
13541
+ }),
13542
+ object({
13543
+ op: literal("deleteRecord"),
13544
+ kind: string().min(1),
13545
+ recordKey: string().min(1),
13546
+ precondition: PreconditionSchema
13547
+ })
13548
+ ])) });
13549
+ /**
13550
+ * What a `procedure` body reports. `already-done` means the rerun observed the
13551
+ * work finished (a crash between the work and the ledger row, or a manual fix)
13552
+ * and did none of it again; the ledger records `applied` either way.
13553
+ */
13554
+ var MigrationProcedureResultSchema = object({
13555
+ outcome: _enum(["done", "already-done"]),
13556
+ summary: record(string(), unknown())
13557
+ });
13558
+ /** What an owner hands the engine when one of its migrations ran. */
13559
+ var MigrationOwnerResultSchema = discriminatedUnion("kind", [
13560
+ object({
13561
+ kind: literal("plan"),
13562
+ plan: MigrationPlanSchema
13563
+ }),
13564
+ object({
13565
+ kind: literal("procedure"),
13566
+ result: MigrationProcedureResultSchema
13567
+ }),
13568
+ object({
13569
+ kind: literal("failed"),
13570
+ error: string().min(1)
13571
+ })
13572
+ ]);
13573
+ /**
13574
+ * `held`: a restore of a pre-migration snapshot undid this id; it does not rerun
13575
+ * until the operator retries or a new code version ships.
13576
+ * `skipped-newer`: the database knows an id this code does not.
13577
+ */
13578
+ var MigrationStatusSchema = _enum([
13579
+ "applied",
13580
+ "failed",
13581
+ "blocked",
13582
+ "running",
13583
+ "held",
13584
+ "skipped-newer"
13585
+ ]);
13586
+ var MigrationLedgerEntrySchema = object({
13587
+ id: string(),
13588
+ database: DataStoreDatabaseSchema,
13589
+ owner: string(),
13590
+ level: MigrationLevelSchema,
13591
+ seq: number().int().nonnegative(),
13592
+ status: MigrationStatusSchema,
13593
+ attempts: number().int().nonnegative(),
13594
+ appliedAt: number().nullable(),
13595
+ codeVersion: string().nullable(),
13596
+ /** What the apply changed: rows per table, as the engine counted them. */
13597
+ planSummary: record(string(), unknown()).nullable(),
13598
+ progress: record(string(), unknown()).nullable(),
13599
+ error: string().nullable(),
13600
+ /** Why it is `blocked` or `held` (`dependency-failed`, `snapshot-refused`, …). */
13601
+ reason: string().nullable(),
13602
+ nodeId: string().nullable(),
13603
+ bootId: string().nullable()
13604
+ });
13605
+ /** A catalogued migration that is not applied, with where it stands. */
13606
+ var MigrationPendingEntrySchema = object({
13607
+ meta: MigrationMetaSchema,
13608
+ database: DataStoreDatabaseSchema,
13609
+ state: _enum([
13610
+ "pending",
13611
+ "failed",
13612
+ "blocked",
13613
+ "held"
13614
+ ]),
13615
+ reason: string().nullable()
13616
+ });
13617
+ /** Rows per table before and after a dry run, and what it would have changed. */
13618
+ var MigrationDryRunResultSchema = object({
13619
+ id: string(),
13620
+ ok: boolean(),
13621
+ error: string().nullable(),
13622
+ rowsChanged: number().int().nonnegative(),
13623
+ tables: array(object({
13624
+ table: string(),
13625
+ before: number().int().nonnegative(),
13626
+ after: number().int().nonnegative()
13627
+ }))
13628
+ });
13629
+ /** One of an owner's migrations, as the engine tells the owner to treat it this boot. */
13630
+ var MigrationOwnerStepSchema = object({
13631
+ id: MigrationIdSchema,
13632
+ action: _enum(["run", "skip"]),
13633
+ /** The ledger state the engine found: `pending` has no row yet. */
13634
+ state: union([literal("pending"), MigrationStatusSchema])
13635
+ });
13636
+ /**
12834
13637
  * The trainer contract — what the hub hands the cloud trainer and what it
12835
13638
  * gets back (cloud training, D805+).
12836
13639
  *
@@ -16233,6 +17036,41 @@ var ACTUATOR_CAP_VOCABULARY = {
16233
17036
  icon: "droplets"
16234
17037
  }]
16235
17038
  },
17039
+ "power-source": {
17040
+ scope: "device",
17041
+ noun: t("Power source", "Alimentazione"),
17042
+ actions: [
17043
+ {
17044
+ id: "powerSource.on",
17045
+ method: "powerOn",
17046
+ label: t("Power on", "Dai corrente"),
17047
+ phrase: t("Power on {device}", "Dai corrente a {device}"),
17048
+ icon: "power"
17049
+ },
17050
+ {
17051
+ id: "powerSource.off",
17052
+ method: "powerOff",
17053
+ label: t("Power off", "Togli corrente"),
17054
+ phrase: t("Cut the power of {device}", "Togli la corrente a {device}"),
17055
+ icon: "power-off"
17056
+ },
17057
+ {
17058
+ id: "powerSource.forceRestart",
17059
+ method: "forceRestart",
17060
+ label: t("Force restart", "Riavvio forzato"),
17061
+ phrase: t("Force restart {device} by cutting its power", "Riavvia {device} togliendo la corrente"),
17062
+ icon: "refresh-cw"
17063
+ }
17064
+ ],
17065
+ state: [{
17066
+ kind: "boolean",
17067
+ field: "switchOn",
17068
+ label: t("Power switch on", "Presa accesa"),
17069
+ whenTrue: t("When the power of {device} comes on", "Quando arriva la corrente a {device}"),
17070
+ whenFalse: t("When the power of {device} is cut", "Quando manca la corrente a {device}"),
17071
+ icon: "power"
17072
+ }]
17073
+ },
16236
17074
  "lock-control": {
16237
17075
  scope: "device",
16238
17076
  noun: t("Lock", "Serratura"),
@@ -16708,7 +17546,7 @@ var ACTUATOR_CAP_VOCABULARY = {
16708
17546
  method: "setDirection",
16709
17547
  label: t("Spin forward", "Rotazione avanti"),
16710
17548
  phrase: t("Spin {device} forward", "Fai girare {device} in avanti"),
16711
- icon: "rotate-cw",
17549
+ icon: "refresh-cw",
16712
17550
  effect: {
16713
17551
  field: "direction",
16714
17552
  value: "forward"
@@ -19786,6 +20624,7 @@ var SYSTEM_CAP_VOCABULARY = {
19786
20624
  "login-method": system(IDENTITY),
19787
20625
  "mesh-network": system(NETWORK),
19788
20626
  "metrics-provider": system(CLUSTER),
20627
+ migrations: system(INTERNAL),
19789
20628
  "model-convert": system(ML),
19790
20629
  "model-distributor": system(ML),
19791
20630
  "mqtt-broker": system(NETWORK),
@@ -42129,7 +42968,7 @@ method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSche
42129
42968
  * rebuilds without manual reload.
42130
42969
  *
42131
42970
  * The hub-local builtin `addon-pages-aggregator` (see
42132
- * `@camstack/system/builtins/addon-pages-aggregator`) registers the
42971
+ * `@camstack/server/system/builtins/addon-pages-aggregator`) registers the
42133
42972
  * provider. Splitting the public aggregator from the raw collection
42134
42973
  * keeps both ends in codegen — there's no hand-written
42135
42974
  * `addon-pages.router.ts` wrapper anymore.
@@ -42429,7 +43268,7 @@ method(_void(), array(WidgetMetadataSchema).readonly(), { auth: "admin" });
42429
43268
  * manual reload — same scheme used by `addon-pages`.
42430
43269
  *
42431
43270
  * The hub-local builtin `addon-widgets-aggregator` (see
42432
- * `@camstack/system/builtins/addon-widgets-aggregator`) registers the
43271
+ * `@camstack/server/system/builtins/addon-widgets-aggregator`) registers the
42433
43272
  * provider. Splitting the public aggregator from the raw collection
42434
43273
  * keeps both ends in codegen — there's no hand-written wrapper.
42435
43274
  */
@@ -42790,329 +43629,6 @@ method(object({
42790
43629
  password: string()
42791
43630
  }), AuthResultSchema.nullable(), { kind: "mutation" }), method(object({ state: string() }), string()), method(record(string(), string()), AuthResultSchema, { kind: "mutation" }), method(object({ token: string() }), AuthResultSchema.nullable());
42792
43631
  /**
42793
- * Query filter for settings-store collections.
42794
- */
42795
- var QueryFilterSchema = object({
42796
- where: record(string(), unknown()).optional(),
42797
- whereIn: record(string(), array(unknown())).optional(),
42798
- whereBetween: record(string(), tuple([unknown(), unknown()])).optional(),
42799
- /** NULL-safe exclusion: matches rows whose field is NULL OR != the value. */
42800
- whereNot: record(string(), unknown()).optional(),
42801
- /** NULL-safe exclusion of a SET — `whereNot` for more than one value. An
42802
- * empty list excludes nothing. See `QueryFilter.whereNotIn`. */
42803
- whereNotIn: record(string(), array(unknown())).optional(),
42804
- orderBy: object({
42805
- field: string(),
42806
- direction: _enum(["asc", "desc"])
42807
- }).optional(),
42808
- limit: number().optional(),
42809
- offset: number().optional()
42810
- });
42811
- /**
42812
- * The predicate half of a filter, for BULK MUTATIONS.
42813
- *
42814
- * Deliberately not `QueryFilterSchema`: `orderBy` / `limit` / `offset` have no
42815
- * meaning for a statement that rewrites a set, and accepting them would invite
42816
- * a caller to believe `limit` bounds the damage. Every field is optional here
42817
- * only so the shape stays composable — the implementation REJECTS a filter
42818
- * that compiles to no predicate, because that is the whole collection.
42819
- */
42820
- var MutationFilterSchema = object({
42821
- where: record(string(), unknown()).optional(),
42822
- whereIn: record(string(), array(unknown())).optional(),
42823
- whereBetween: record(string(), tuple([unknown(), unknown()])).optional(),
42824
- whereNot: record(string(), unknown()).optional(),
42825
- whereNotIn: record(string(), array(unknown())).optional()
42826
- });
42827
- /**
42828
- * One scalar an {@link settingsStoreCapability.methods.aggregate} call asks for.
42829
- *
42830
- * `as` names the slot in the result, so the SAME column may be asked twice with
42831
- * two operations (`MIN(startMs)` and `MAX(startMs)` in one round trip) — which
42832
- * a `Record<column, op>` shape could not express.
42833
- */
42834
- var AggregateFieldSchema = object({
42835
- /** Result key. */
42836
- as: string().min(1),
42837
- /** Column to aggregate. Must be a real column of a declared collection. */
42838
- field: string().min(1),
42839
- op: _enum([
42840
- "sum",
42841
- "min",
42842
- "max"
42843
- ])
42844
- });
42845
- /**
42846
- * `COUNT(*)` plus one number per requested field.
42847
- *
42848
- * `null` means NO ROW MATCHED, never zero: a `SUM` over an empty set and a sum
42849
- * that really is 0 are different facts, and an accounting caller that renders
42850
- * "0 bytes, oldest = 0" for "nothing here" reports a lie about a disk.
42851
- */
42852
- var AggregateResultSchema = object({
42853
- count: number().int(),
42854
- values: record(string(), number().nullable())
42855
- });
42856
- /** A single stored record: `{ id, data }`. */
42857
- var SettingsRecordSchema = object({
42858
- id: string(),
42859
- data: record(string(), unknown())
42860
- });
42861
- /**
42862
- * One record of a BULK insert — {@link SettingsRecordSchema} with the id made
42863
- * optional.
42864
- *
42865
- * A separate schema rather than loosening the shared one: every other method
42866
- * on this cap addresses a row BY its id, and making that field optional
42867
- * everywhere would turn a forgotten key into a silently generated one on
42868
- * `update` and `delete` as well.
42869
- */
42870
- var BulkRecordSchema = object({
42871
- id: string().optional(),
42872
- data: record(string(), unknown())
42873
- });
42874
- /**
42875
- * The database FILES one `sqlite-settings` engine process owns (D851).
42876
- * Closed on purpose: a file is a thing the engine opens, backs up and gives a
42877
- * serving thread, so a new one is a code change, never a string a caller
42878
- * invents. `settings` is `camstack.db` and the default for every collection
42879
- * that names no file.
42880
- */
42881
- var DataStoreDatabaseSchema = _enum([
42882
- "settings",
42883
- "events",
42884
- "history"
42885
- ]);
42886
- DataStoreDatabaseSchema.options;
42887
- /**
42888
- * One write inside a {@link settingsStoreCapability.methods.transact} call.
42889
- * The three that a "replace this set, bump that revision" write needs, plus
42890
- * the batched upsert a rollup writer needs.
42891
- */
42892
- var TransactOpSchema = discriminatedUnion("op", [
42893
- object({
42894
- op: literal("deleteWhere"),
42895
- collection: string(),
42896
- filter: MutationFilterSchema
42897
- }),
42898
- object({
42899
- op: literal("insertMany"),
42900
- collection: string(),
42901
- records: array(BulkRecordSchema).readonly()
42902
- }),
42903
- object({
42904
- op: literal("update"),
42905
- collection: string(),
42906
- id: string(),
42907
- data: record(string(), unknown())
42908
- }),
42909
- object({
42910
- op: literal("upsertMany"),
42911
- collection: string(),
42912
- conflict: array(string()).readonly(),
42913
- records: array(BulkRecordSchema).readonly()
42914
- })
42915
- ]);
42916
- /**
42917
- * The precondition of a transaction: the row `key` of `collection` must hold
42918
- * `equals` in `column`, read INSIDE the transaction.
42919
- */
42920
- var TransactGuardSchema = object({
42921
- collection: string(),
42922
- key: string(),
42923
- column: string(),
42924
- equals: unknown()
42925
- });
42926
- /**
42927
- * Column declaration for a structured (SQL-backed) collection.
42928
- *
42929
- * Logical types — the backend translates each to the matching SQLite
42930
- * storage class and handles per-type marshaling:
42931
- * - `TEXT` / `INTEGER` / `REAL` — native SQLite types, pass-through
42932
- * - `JSON` — TEXT under the hood; serialised on write, parsed on read
42933
- * - `BOOLEAN` — INTEGER 0/1 under the hood; coerced both directions
42934
- */
42935
- var CollectionColumnSchema = object({
42936
- name: string(),
42937
- type: _enum([
42938
- "TEXT",
42939
- "INTEGER",
42940
- "REAL",
42941
- "JSON",
42942
- "BOOLEAN"
42943
- ]),
42944
- primaryKey: boolean().optional(),
42945
- notNull: boolean().optional(),
42946
- unique: boolean().optional(),
42947
- /**
42948
- * Column DEFAULT. Required for B2: the four `ensureTable` consumers declare
42949
- * columns like `enabled INTEGER NOT NULL DEFAULT 1`, and without this the
42950
- * collection surface simply cannot express their existing tables — which is
42951
- * why they were still on the uncapped `table*` API.
42952
- */
42953
- defaultValue: union([
42954
- string(),
42955
- number(),
42956
- boolean()
42957
- ]).optional()
42958
- });
42959
- var CollectionIndexSchema = object({
42960
- name: string(),
42961
- columns: array(string()).readonly(),
42962
- unique: boolean().optional()
42963
- });
42964
- /**
42965
- * The input of `declareCollection` — ONE schema for the door and for the
42966
- * engine behind it, so the two surfaces cannot drift (the dispatcher forwards
42967
- * the payload untouched).
42968
- *
42969
- * - `database` — the file the collection lives in (D851). Absent means
42970
- * `settings`. A declaration naming a file other than the one the table is
42971
- * already in is REFUSED by the engine, never moved.
42972
- * - `primaryKey` — a COMPOSITE key, as column names. A single name is the same
42973
- * as `primaryKey: true` on that column. A composite-keyed collection has no
42974
- * `id`: it is written with `insertMany` / `upsertMany` / `transact` and read
42975
- * with `query` / `count` / `aggregate` / `deleteWhere`; the calls that
42976
- * address one row by id are refused.
42977
- * - `withoutRowid` — emit `WITHOUT ROWID`. Requires a primary key.
42978
- */
42979
- var DeclareCollectionInputSchema = object({
42980
- namespace: string().optional(),
42981
- collection: string(),
42982
- columns: array(CollectionColumnSchema).readonly(),
42983
- indexes: array(CollectionIndexSchema).readonly().optional(),
42984
- database: DataStoreDatabaseSchema.optional(),
42985
- primaryKey: array(string()).readonly().optional(),
42986
- withoutRowid: boolean().optional()
42987
- });
42988
- method(object({
42989
- namespace: string().optional(),
42990
- collection: string(),
42991
- key: string()
42992
- }), unknown(), { auth: "admin" }), method(object({
42993
- namespace: string().optional(),
42994
- collection: string(),
42995
- key: string(),
42996
- value: unknown()
42997
- }), _void(), {
42998
- kind: "mutation",
42999
- auth: "admin"
43000
- }), method(object({
43001
- namespace: string().optional(),
43002
- collection: string(),
43003
- filter: QueryFilterSchema.optional(),
43004
- columns: array(string()).readonly().optional()
43005
- }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
43006
- namespace: string().optional(),
43007
- collection: string(),
43008
- /** Declared columns identifying the slot; must be covered by a UNIQUE
43009
- * index on the collection. Never empty. */
43010
- conflict: array(string()).readonly(),
43011
- record: BulkRecordSchema
43012
- }), object({
43013
- /** The id the row HAS: assigned by SQLite on an insert, or the existing
43014
- * row's own id on an update. */
43015
- id: union([string(), number()]) }), {
43016
- kind: "mutation",
43017
- auth: "admin"
43018
- }), method(object({
43019
- namespace: string().optional(),
43020
- collection: string(),
43021
- conflict: array(string()).readonly(),
43022
- records: array(BulkRecordSchema).readonly()
43023
- }), object({ upserted: number().int() }), {
43024
- kind: "mutation",
43025
- auth: "admin"
43026
- }), method(object({
43027
- namespace: string().optional(),
43028
- collection: string(),
43029
- record: object({
43030
- id: string().optional(),
43031
- data: record(string(), unknown())
43032
- })
43033
- }), object({
43034
- /**
43035
- * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
43036
- * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
43037
- * primary key — which is the only place an auto key is knowable.
43038
- */
43039
- id: union([string(), number()]) }), {
43040
- kind: "mutation",
43041
- auth: "admin"
43042
- }), method(object({
43043
- namespace: string().optional(),
43044
- collection: string(),
43045
- records: array(BulkRecordSchema).readonly()
43046
- }), object({ inserted: number().int() }), {
43047
- kind: "mutation",
43048
- auth: "admin"
43049
- }), method(object({
43050
- namespace: string().optional(),
43051
- guard: TransactGuardSchema.optional(),
43052
- ops: array(TransactOpSchema).readonly()
43053
- }), object({
43054
- applied: boolean(),
43055
- current: unknown().optional()
43056
- }), {
43057
- kind: "mutation",
43058
- auth: "admin"
43059
- }), method(object({
43060
- namespace: string().optional(),
43061
- collection: string(),
43062
- id: string(),
43063
- data: record(string(), unknown())
43064
- }), _void(), {
43065
- kind: "mutation",
43066
- auth: "admin"
43067
- }), method(object({
43068
- namespace: string().optional(),
43069
- collection: string(),
43070
- key: string()
43071
- }), _void(), {
43072
- kind: "mutation",
43073
- auth: "admin"
43074
- }), method(object({
43075
- namespace: string().optional(),
43076
- collection: string(),
43077
- filter: MutationFilterSchema
43078
- }), object({ deleted: number().int() }), {
43079
- kind: "mutation",
43080
- auth: "admin"
43081
- }), method(object({
43082
- namespace: string().optional(),
43083
- collection: string(),
43084
- filter: MutationFilterSchema,
43085
- data: record(string(), unknown())
43086
- }), object({ updated: number().int() }), {
43087
- kind: "mutation",
43088
- auth: "admin"
43089
- }), method(object({
43090
- namespace: string().optional(),
43091
- collection: string(),
43092
- filter: QueryFilterSchema.optional()
43093
- }), number(), { auth: "admin" }), method(object({
43094
- namespace: string().optional(),
43095
- collection: string(),
43096
- fields: array(AggregateFieldSchema).readonly(),
43097
- filter: QueryFilterSchema.optional()
43098
- }), AggregateResultSchema, { auth: "admin" }), method(object({
43099
- namespace: string().optional(),
43100
- collection: string(),
43101
- field: string(),
43102
- bucketSize: number().int().positive(),
43103
- origin: number().int(),
43104
- filter: QueryFilterSchema.optional()
43105
- }), array(object({
43106
- bucket: number().int(),
43107
- count: number().int()
43108
- })).readonly(), { auth: "admin" }), method(object({
43109
- namespace: string().optional(),
43110
- collection: string()
43111
- }), boolean(), { auth: "admin" }), method(DeclareCollectionInputSchema, _void(), {
43112
- kind: "mutation",
43113
- auth: "admin"
43114
- });
43115
- /**
43116
43632
  * How long one snapshot may take end to end: the pinned copy of the whole
43117
43633
  * database plus `PRAGMA integrity_check` over the copy, on the hub's slowest
43118
43634
  * disk. ~800 MB at a pessimistic 10 MB/s is under 3 minutes; the bound is
@@ -45026,7 +45542,7 @@ method(object({
45026
45542
  kind: "mutation",
45027
45543
  auth: "admin"
45028
45544
  }), method(object({ blockIds: array(string()) }), object({ states: array(CompositionBlockStateSchema) }), { auth: "admin" });
45029
- 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;
45545
+ 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;
45030
45546
  var NUMBER = {
45031
45547
  kind: "fixed",
45032
45548
  result: ["number"]
@@ -46037,6 +46553,57 @@ id: union([string(), number()]) }), {
46037
46553
  kind: "mutation",
46038
46554
  auth: "admin"
46039
46555
  });
46556
+ 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({
46557
+ id: string().min(1),
46558
+ error: string().min(1)
46559
+ }), MigrationLedgerEntrySchema, {
46560
+ kind: "mutation",
46561
+ auth: "admin"
46562
+ }), method(object({ id: string().min(1) }), object({ entries: array(MigrationLedgerEntrySchema) }), {
46563
+ kind: "mutation",
46564
+ auth: "admin"
46565
+ }), method(object({
46566
+ database: DataStoreDatabaseSchema,
46567
+ snapshotId: string().min(1)
46568
+ }), object({
46569
+ scheduled: boolean(),
46570
+ held: array(string()),
46571
+ restartRequired: boolean()
46572
+ }), {
46573
+ kind: "mutation",
46574
+ auth: "admin"
46575
+ }), method(object({
46576
+ owner: string().min(1),
46577
+ metas: array(MigrationMetaSchema)
46578
+ }), object({
46579
+ bootId: string(),
46580
+ snapshot: _enum([
46581
+ "none",
46582
+ "written",
46583
+ "refused"
46584
+ ]),
46585
+ steps: array(MigrationOwnerStepSchema)
46586
+ }), {
46587
+ kind: "mutation",
46588
+ auth: "admin"
46589
+ }), method(object({ id: string().min(1) }), object({
46590
+ proceed: boolean(),
46591
+ state: union([literal("pending"), MigrationStatusSchema]),
46592
+ reason: string().nullable()
46593
+ }), {
46594
+ kind: "mutation",
46595
+ auth: "admin"
46596
+ }), method(object({
46597
+ id: string().min(1),
46598
+ result: MigrationOwnerResultSchema
46599
+ }), object({
46600
+ status: MigrationStatusSchema,
46601
+ error: string().nullable(),
46602
+ rowsChanged: number().int().nonnegative()
46603
+ }), {
46604
+ kind: "mutation",
46605
+ auth: "admin"
46606
+ });
46040
46607
  /**
46041
46608
  * records - an addon's own facts and documents (D881): ledgers, audit rows,
46042
46609
  * config documents, mirrors. The third storage API next to `ctx.settings`
@@ -60901,7 +61468,18 @@ var ServerUpdateActionResultSchema = object({
60901
61468
  * store (D877), present when the pre-flight refused the update
60902
61469
  * (`reason: 'addon-would-refuse'`). Optional for version skew.
60903
61470
  */
60904
- blockers: array(UpdateBlockerSchema).optional()
61471
+ blockers: array(UpdateBlockerSchema).optional(),
61472
+ /**
61473
+ * The minimums the target server declares and this node does not meet
61474
+ * (D989), present when the update was refused with
61475
+ * `reason: 'requirements-unmet'`. Each names the versions on both sides.
61476
+ */
61477
+ unmet: array(UnmetRequirementSchema).optional(),
61478
+ /**
61479
+ * The addons this node has below the minimum the staged server declares —
61480
+ * the ones to update WITH the server. Present on an accepted update.
61481
+ */
61482
+ requiredAddonUpdates: array(RequiredAddonUpdateSchema).optional()
60905
61483
  });
60906
61484
  var LaunchOverridesSchema = object({
60907
61485
  /** The persisted heap ceiling in MB, or `null` when none is set. */
@@ -63445,7 +64023,9 @@ var PackageUpdateSchema = object({
63445
64023
  latestVersion: string(),
63446
64024
  category: _enum(["addon", "core"]),
63447
64025
  requiresRestart: boolean(),
63448
- isSystem: boolean()
64026
+ isSystem: boolean(),
64027
+ /** Held: what the newer version needs and this node does not meet (D989). */
64028
+ blockedBy: array(UnmetRequirementSchema).readonly().optional()
63449
64029
  });
63450
64030
  var PackageVersionInfoSchema = object({
63451
64031
  version: string(),
@@ -64901,19 +65481,19 @@ var RemoteSetConfigResultSchema = discriminatedUnion("status", [object({ status:
64901
65481
  reason: _enum(["unknown-template", "not-a-media-player"]),
64902
65482
  detail: string()
64903
65483
  })]);
64904
- var deviceInput = object({ deviceId: number().int().nonnegative() });
65484
+ var deviceInput$1 = object({ deviceId: number().int().nonnegative() });
64905
65485
  DeviceType.MediaPlayer;
64906
- method(deviceInput, RemoteConfigSchema, { auth: "admin" }), method(deviceInput.extend({ config: RemoteConfigSchema }), RemoteSetConfigResultSchema, {
65486
+ method(deviceInput$1, RemoteConfigSchema, { auth: "admin" }), method(deviceInput$1.extend({ config: RemoteConfigSchema }), RemoteSetConfigResultSchema, {
64907
65487
  kind: "mutation",
64908
65488
  auth: "admin"
64909
- }), method(deviceInput, RemoteCommandListSchema, { auth: "protected" }), method(deviceInput.extend({
65489
+ }), method(deviceInput$1, RemoteCommandListSchema, { auth: "protected" }), method(deviceInput$1.extend({
64910
65490
  role: RemoteRoleSchema,
64911
65491
  /** Sends in a row (volume steps). */
64912
65492
  repeat: number().int().min(1).max(50).default(1)
64913
65493
  }), RemoteSendResultSchema, {
64914
65494
  kind: "mutation",
64915
65495
  auth: "protected"
64916
- }), method(deviceInput.extend({
65496
+ }), method(deviceInput$1.extend({
64917
65497
  command: RemoteMediaCommandSchema,
64918
65498
  muted: boolean().optional(),
64919
65499
  source: string().optional(),
@@ -68736,7 +69316,7 @@ var lawnMowerControlCapability = {
68736
69316
  * clients — they reverse-connect to the hub. Exposing their interfaces
68737
69317
  * via the same surface would leak internal topology with no upside.
68738
69318
  *
68739
- * Implementation in `@camstack/system/builtins/local-network/`.
69319
+ * Implementation in `@camstack/server/system/builtins/local-network/`.
68740
69320
  */
68741
69321
  /** Coarse classification derived from the interface name + IP range. */
68742
69322
  var InterfaceKindEnum = _enum([
@@ -69233,6 +69813,117 @@ var lockControlCapability = {
69233
69813
  * whether persisting is worth a SQLite commit. */
69234
69814
  volatileStateFields: ["lastChangedAt"]
69235
69815
  };
69816
+ var PowerSourceRefusalReasonSchema = _enum([
69817
+ "no-power-source",
69818
+ "switch-missing",
69819
+ "switch-offline",
69820
+ "switch-unknown",
69821
+ "restart-in-progress",
69822
+ "switch-call-failed"
69823
+ ]);
69824
+ var PowerSourceActionResultSchema = discriminatedUnion("accepted", [object({ accepted: literal(true) }), object({
69825
+ accepted: literal(false),
69826
+ reason: PowerSourceRefusalReasonSchema,
69827
+ /** One line for the operator, naming the switch. */
69828
+ message: string()
69829
+ })]);
69830
+ var PowerSourceInfoSchema = object({
69831
+ /** False when the device has no power source linked; the rest is then empty. */
69832
+ linked: boolean(),
69833
+ switchDeviceId: number().nullable(),
69834
+ switchName: string().nullable(),
69835
+ /** The switch's on/off state, or null when it is unknown. Never false for unknown (D393). */
69836
+ switchOn: boolean().nullable(),
69837
+ switchOnline: boolean().nullable(),
69838
+ restartInProgress: boolean(),
69839
+ offSeconds: number().int()
69840
+ });
69841
+ /** The composed slice: the switch state the link mirrors, plus the stored off time. */
69842
+ var PowerSourceStateSchema = object({
69843
+ /** Null while the switch has not reported: unknown is never `false` (D393). */
69844
+ switchOn: boolean().nullable(),
69845
+ offSeconds: number().int(),
69846
+ lastFetchedAt: number()
69847
+ });
69848
+ var POWER_SOURCE_DEVICE_TYPES = [
69849
+ DeviceType.Gateway,
69850
+ DeviceType.Hub,
69851
+ DeviceType.Camera,
69852
+ DeviceType.Sensor,
69853
+ DeviceType.MediaPlayer,
69854
+ DeviceType.Vacuum,
69855
+ DeviceType.Generic,
69856
+ DeviceType.Washer,
69857
+ DeviceType.Dryer,
69858
+ DeviceType.Dishwasher,
69859
+ DeviceType.PetFountain,
69860
+ DeviceType.Fan,
69861
+ DeviceType.Humidifier,
69862
+ DeviceType.Climate,
69863
+ DeviceType.WaterHeater
69864
+ ];
69865
+ var powerSourceCustomize = {
69866
+ version: 1,
69867
+ targets: [{
69868
+ id: "switch",
69869
+ cardinality: "scalar",
69870
+ vocabulary: {
69871
+ cap: "power-source",
69872
+ stateField: "switchOn"
69873
+ },
69874
+ deviceTypes: POWER_SOURCE_DEVICE_TYPES,
69875
+ apply: "add",
69876
+ path: "switchOn",
69877
+ sources: [{
69878
+ kind: "switch",
69879
+ transforms: [{ kind: "identity" }]
69880
+ }],
69881
+ companions: [{
69882
+ kind: "constant",
69883
+ path: "offSeconds",
69884
+ value: 10,
69885
+ when: "add"
69886
+ }, {
69887
+ kind: "clock",
69888
+ path: "lastFetchedAt",
69889
+ when: "always"
69890
+ }],
69891
+ sourceReport: { status: "assignment-status" }
69892
+ }]
69893
+ };
69894
+ var deviceInput = object({ deviceId: number().int().nonnegative() });
69895
+ var powerSourceCapability = {
69896
+ name: "power-source",
69897
+ scope: "device",
69898
+ mode: "singleton",
69899
+ deviceTypes: POWER_SOURCE_DEVICE_TYPES,
69900
+ methods: {
69901
+ getStatus: systemMethod(deviceInput, PowerSourceInfoSchema, { auth: "admin" }),
69902
+ powerOn: systemMethod(deviceInput, PowerSourceActionResultSchema, {
69903
+ kind: "mutation",
69904
+ auth: "admin"
69905
+ }),
69906
+ powerOff: systemMethod(deviceInput, PowerSourceActionResultSchema, {
69907
+ kind: "mutation",
69908
+ auth: "admin"
69909
+ }),
69910
+ forceRestart: systemMethod(deviceInput, PowerSourceActionResultSchema, {
69911
+ kind: "mutation",
69912
+ auth: "admin"
69913
+ })
69914
+ },
69915
+ runtimeState: PowerSourceStateSchema,
69916
+ customize: powerSourceCustomize,
69917
+ /**
69918
+ * Runtime-state durability: **session** — mirrored from the linked switch on
69919
+ * its next report; a restored value would outlive the reading it names.
69920
+ *
69921
+ * See `RuntimeStateDurability`. Enforced by
69922
+ * `scripts/check-runtime-state-durability.ts`.
69923
+ */
69924
+ durability: "session",
69925
+ history: "none"
69926
+ };
69236
69927
  /**
69237
69928
  * A monotonic total between resets (D944). Energy uses `power-meter.energy`
69238
69929
  * so dashboards keep one series; every other instantaneous reading lands here.
@@ -70513,7 +71204,7 @@ onStatusChanged: { data: object({
70513
71204
  * jitter, and observed/peak bandwidth per device + per client.
70514
71205
  *
70515
71206
  * Implementation lives in the server's `NetworkQualityService` (thin
70516
- * wrapper over the shared `NetworkQualityTracker` from `@camstack/system`).
71207
+ * wrapper over the shared `NetworkQualityTracker` from `@camstack/server/system`).
70517
71208
  * The provider is registered from `trpc.router.ts` against the existing
70518
71209
  * service instance — no addon owns this state.
70519
71210
  *
@@ -72664,7 +73355,7 @@ var ptzAutotrackCapability = {
72664
73355
  * - **Native**: the camera's own firmware autotrack, registered per device by
72665
73356
  * the driver when the probe says it exists (Reolink: yes; Hikvision:
72666
73357
  * model-dependent).
72667
- * - **Wrapper**: the emulated implementation (`@camstack/system`'s `autotrack` builtin),
73358
+ * - **Wrapper**: the emulated implementation (`@camstack/server/system`'s `autotrack` builtin),
72668
73359
  * which follows a subject with `ptz.move` pulses driven by the detection
72669
73360
  * pipeline. `defaultActive: false` — the operator binds it per camera in
72670
73361
  * the bindings UI.
@@ -77973,6 +78664,7 @@ var DEVICE_LOCAL_STATE_CAPS = {
77973
78664
  petFeeder: petFeederCapability,
77974
78665
  petFountain: petFountainCapability,
77975
78666
  powerMeter: powerMeterCapability,
78667
+ powerSource: powerSourceCapability,
77976
78668
  presence: presenceCapability,
77977
78669
  pressureSensor: pressureSensorCapability,
77978
78670
  privacyMask: privacyMaskCapability,
@@ -83737,6 +84429,69 @@ Object.freeze({
83737
84429
  access: "view",
83738
84430
  role: "admin"
83739
84431
  },
84432
+ "migrations.declareOwner": {
84433
+ capName: "migrations",
84434
+ capScope: "system",
84435
+ addonId: null,
84436
+ access: "create",
84437
+ role: "admin"
84438
+ },
84439
+ "migrations.dryRun": {
84440
+ capName: "migrations",
84441
+ capScope: "system",
84442
+ addonId: null,
84443
+ access: "view",
84444
+ role: "admin"
84445
+ },
84446
+ "migrations.finishMigration": {
84447
+ capName: "migrations",
84448
+ capScope: "system",
84449
+ addonId: null,
84450
+ access: "create",
84451
+ role: "admin"
84452
+ },
84453
+ "migrations.listLedger": {
84454
+ capName: "migrations",
84455
+ capScope: "system",
84456
+ addonId: null,
84457
+ access: "view",
84458
+ role: "admin"
84459
+ },
84460
+ "migrations.listPending": {
84461
+ capName: "migrations",
84462
+ capScope: "system",
84463
+ addonId: null,
84464
+ access: "view",
84465
+ role: "admin"
84466
+ },
84467
+ "migrations.markFailed": {
84468
+ capName: "migrations",
84469
+ capScope: "system",
84470
+ addonId: null,
84471
+ access: "create",
84472
+ role: "admin"
84473
+ },
84474
+ "migrations.restorePreMigration": {
84475
+ capName: "migrations",
84476
+ capScope: "system",
84477
+ addonId: null,
84478
+ access: "create",
84479
+ role: "admin"
84480
+ },
84481
+ "migrations.retry": {
84482
+ capName: "migrations",
84483
+ capScope: "system",
84484
+ addonId: null,
84485
+ access: "create",
84486
+ role: "admin"
84487
+ },
84488
+ "migrations.startMigration": {
84489
+ capName: "migrations",
84490
+ capScope: "system",
84491
+ addonId: null,
84492
+ access: "create",
84493
+ role: "admin"
84494
+ },
83740
84495
  "modelConvert.convert": {
83741
84496
  capName: "model-convert",
83742
84497
  capScope: "system",
@@ -86369,6 +87124,34 @@ Object.freeze({
86369
87124
  access: "view",
86370
87125
  role: "viewer"
86371
87126
  },
87127
+ "powerSource.forceRestart": {
87128
+ capName: "power-source",
87129
+ capScope: "device",
87130
+ addonId: null,
87131
+ access: "create",
87132
+ role: "admin"
87133
+ },
87134
+ "powerSource.getStatus": {
87135
+ capName: "power-source",
87136
+ capScope: "device",
87137
+ addonId: null,
87138
+ access: "view",
87139
+ role: "admin"
87140
+ },
87141
+ "powerSource.powerOff": {
87142
+ capName: "power-source",
87143
+ capScope: "device",
87144
+ addonId: null,
87145
+ access: "create",
87146
+ role: "admin"
87147
+ },
87148
+ "powerSource.powerOn": {
87149
+ capName: "power-source",
87150
+ capScope: "device",
87151
+ addonId: null,
87152
+ access: "create",
87153
+ role: "admin"
87154
+ },
86372
87155
  "presence.getStatus": {
86373
87156
  capName: "presence",
86374
87157
  capScope: "device",
@@ -91517,6 +92300,26 @@ Object.freeze({
91517
92300
  form: "single",
91518
92301
  optional: false
91519
92302
  }],
92303
+ "powerSource.forceRestart": [{
92304
+ name: "deviceId",
92305
+ form: "single",
92306
+ optional: false
92307
+ }],
92308
+ "powerSource.getStatus": [{
92309
+ name: "deviceId",
92310
+ form: "single",
92311
+ optional: false
92312
+ }],
92313
+ "powerSource.powerOff": [{
92314
+ name: "deviceId",
92315
+ form: "single",
92316
+ optional: false
92317
+ }],
92318
+ "powerSource.powerOn": [{
92319
+ name: "deviceId",
92320
+ form: "single",
92321
+ optional: false
92322
+ }],
91520
92323
  "presence.getStatus": [{
91521
92324
  name: "deviceId",
91522
92325
  form: "single",
@@ -93684,6 +94487,88 @@ DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
93684
94487
  DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
93685
94488
  DEFAULT_NATIVE_LEASE_SETTINGS.sceneBudgetMb;
93686
94489
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
94490
+ /**
94491
+ * Closes the gap D49 leaves: an integration deleted while its provider was down never emits an
94492
+ * event the provider sees. An integration id absent from an ANSWERED list is only a suspect; its
94493
+ * devices go (through the provider's own removeDevices) when a SECOND answered read, at least
94494
+ * `minIntervalMs` later, still lacks it. A read that threw changes nothing; reappearing clears.
94495
+ */
94496
+ var OrphanIntegrationSweep = class {
94497
+ #logger;
94498
+ #minIntervalMs;
94499
+ #now;
94500
+ #suspects = /* @__PURE__ */ new Map();
94501
+ constructor(options) {
94502
+ this.#logger = options.logger;
94503
+ this.#minIntervalMs = options.minIntervalMs ?? 6e4;
94504
+ this.#now = options.now ?? Date.now;
94505
+ }
94506
+ get minIntervalMs() {
94507
+ return this.#minIntervalMs;
94508
+ }
94509
+ async sweep(input) {
94510
+ if (input.listedIds === null) return {
94511
+ newSuspects: 0,
94512
+ removed: []
94513
+ };
94514
+ const listed = new Set(input.listedIds);
94515
+ const owners = new Set(input.ownerIds);
94516
+ const now = this.#now();
94517
+ let newSuspects = 0;
94518
+ const removed = [];
94519
+ for (const id of [...this.#suspects.keys()]) if (listed.has(id) || !owners.has(id)) {
94520
+ this.#suspects.delete(id);
94521
+ this.#logger.info("Orphan integration suspect cleared", { meta: {
94522
+ integrationId: id,
94523
+ reason: listed.has(id) ? "listed again" : "owns no devices"
94524
+ } });
94525
+ }
94526
+ for (const id of owners) {
94527
+ if (listed.has(id)) continue;
94528
+ const since = this.#suspects.get(id);
94529
+ if (since === void 0) {
94530
+ this.#suspects.set(id, now);
94531
+ newSuspects += 1;
94532
+ this.#logger.info("Integration owns devices but is absent from the list — suspect", { meta: {
94533
+ integrationId: id,
94534
+ minIntervalMs: this.#minIntervalMs
94535
+ } });
94536
+ continue;
94537
+ }
94538
+ if (now - since < this.#minIntervalMs) continue;
94539
+ try {
94540
+ const count = await input.removeDevices(id);
94541
+ this.#suspects.delete(id);
94542
+ removed.push(id);
94543
+ this.#logger.warn("Orphan integration devices removed — absent from two answered lists", { meta: {
94544
+ integrationId: id,
94545
+ removed: count,
94546
+ firstMissingAt: since
94547
+ } });
94548
+ } catch (err) {
94549
+ this.#logger.warn("Orphan integration device removal failed — kept as suspect", { meta: {
94550
+ integrationId: id,
94551
+ error: errMsg(err)
94552
+ } });
94553
+ }
94554
+ }
94555
+ return {
94556
+ newSuspects,
94557
+ removed
94558
+ };
94559
+ }
94560
+ };
94561
+ /** The integration ids that own top-level devices of one provider (a config that cannot be read is skipped). */
94562
+ async function collectOwnerIntegrationIds(input) {
94563
+ const ids = /* @__PURE__ */ new Set();
94564
+ for (const d of input.reg.getAllForAddon(input.addonId)) {
94565
+ if (d.parentDeviceId !== null) continue;
94566
+ const cfg = await input.devices.loadConfig(d.id).catch(() => ({}));
94567
+ const owner = input.ownerOf(cfg);
94568
+ if (owner !== null) ids.add(owner);
94569
+ }
94570
+ return [...ids];
94571
+ }
93687
94572
  String.raw`(?<=^|["'(\s>,\[{])`;
93688
94573
  var MB = 1024 * 1024;
93689
94574
  1024 * MB, 3072 * MB;
@@ -93696,6 +94581,97 @@ object({
93696
94581
  commands: record(string(), unknown())
93697
94582
  });
93698
94583
  //#endregion
94584
+ //#region src/rademacher-reconciler.ts
94585
+ /**
94586
+ * Keeps one live client per enabled integration. Devices are removed ONLY on an explicit
94587
+ * lifecycle event naming the integration (D49): a list that failed, an empty list or an
94588
+ * unreadable connection changes nothing about devices and is logged, never read as "gone".
94589
+ */
94590
+ var RademacherReconciler = class {
94591
+ #deps;
94592
+ #sweep;
94593
+ #rerun = null;
94594
+ constructor(deps) {
94595
+ this.#deps = deps;
94596
+ this.#sweep = new OrphanIntegrationSweep({
94597
+ logger: deps.logger,
94598
+ ...deps.sweepOptions
94599
+ });
94600
+ }
94601
+ /** Upsert a client per usable enabled integration; drop the CLIENT (never devices) of one the list answered is gone. */
94602
+ async reconcile() {
94603
+ const { logger, clients } = this.#deps;
94604
+ let all;
94605
+ try {
94606
+ all = await this.#deps.listIntegrations();
94607
+ } catch (err) {
94608
+ logger.warn("Rademacher integration reconcile skipped — the integration list did not answer", { meta: { error: errMsg(err) } });
94609
+ return;
94610
+ }
94611
+ const enabled = all.filter((i) => i.addonId === this.#deps.addonId && i.enabled);
94612
+ for (const integration of enabled) try {
94613
+ if (!await this.#deps.applySettings(integration)) logger.warn("Rademacher integration has no usable connection — left as it is", { meta: { integrationId: integration.id } });
94614
+ } catch (err) {
94615
+ logger.warn("Rademacher reconcile failed for integration — left as it is", { meta: {
94616
+ integrationId: integration.id,
94617
+ error: errMsg(err)
94618
+ } });
94619
+ }
94620
+ const enabledIds = new Set(enabled.map((i) => i.id));
94621
+ for (const id of clients.list()) if (!enabledIds.has(id)) await clients.remove(id);
94622
+ await this.#sweepOrphans(all.map((i) => i.id));
94623
+ }
94624
+ /** Stop the scheduled second read (addon stop). */
94625
+ dispose() {
94626
+ if (this.#rerun !== null) clearTimeout(this.#rerun);
94627
+ this.#rerun = null;
94628
+ }
94629
+ /**
94630
+ * An integration deleted while this addon was down emits nothing it sees: its id owns devices
94631
+ * yet is absent from the ANSWERED list. Removal needs a second answered read later, so one
94632
+ * re-run is scheduled when a suspect appears (bounded: one timer, no retry loop).
94633
+ */
94634
+ async #sweepOrphans(listedIds) {
94635
+ const { ownerIntegrationIds, removeDevices, logger } = this.#deps;
94636
+ if (ownerIntegrationIds === void 0) return;
94637
+ try {
94638
+ const ownerIds = await ownerIntegrationIds();
94639
+ if ((await this.#sweep.sweep({
94640
+ ownerIds,
94641
+ listedIds,
94642
+ removeDevices
94643
+ })).newSuspects > 0 && this.#rerun === null) {
94644
+ this.#rerun = setTimeout(() => {
94645
+ this.#rerun = null;
94646
+ this.reconcile();
94647
+ }, this.#sweep.minIntervalMs + 1e3);
94648
+ this.#rerun.unref();
94649
+ }
94650
+ } catch (err) {
94651
+ logger.warn("Orphan integration sweep failed — devices left as they are", { meta: { error: errMsg(err) } });
94652
+ }
94653
+ }
94654
+ /** An explicit lifecycle event: only `deleted` / `disabled` of a named integration remove devices. */
94655
+ async onLifecycle(kind, integrationId) {
94656
+ await this.reconcile();
94657
+ if (kind === "enabled" || integrationId === null) return;
94658
+ try {
94659
+ const removed = await this.#deps.removeDevices(integrationId);
94660
+ this.#deps.logger.info("Rademacher integration devices removed", { meta: {
94661
+ integrationId,
94662
+ kind,
94663
+ removed
94664
+ } });
94665
+ } catch (err) {
94666
+ this.#deps.logger.warn("Rademacher integration device removal failed", { meta: {
94667
+ integrationId,
94668
+ kind,
94669
+ error: errMsg(err)
94670
+ } });
94671
+ }
94672
+ }
94673
+ };
94674
+ //#endregion
93699
94675
  //#region src/config.ts
93700
94676
  /**
93701
94677
  * Operator-supplied connection to ONE Rademacher HomePilot / Start2Smart hub on
@@ -95847,6 +96823,7 @@ var RademacherProviderAddon = class extends BaseDeviceProvider {
95847
96823
  [DeviceType.Gateway]: RademacherGatewayDevice,
95848
96824
  [DeviceType.Cover]: RademacherCoverDevice
95849
96825
  };
96826
+ integrationReconciler = null;
95850
96827
  clients = null;
95851
96828
  constructor() {
95852
96829
  super({});
@@ -95881,6 +96858,8 @@ var RademacherProviderAddon = class extends BaseDeviceProvider {
95881
96858
  this.ctx.logger.warn("Rademacher: shutdown error", { meta: { error: errMsg(err) } });
95882
96859
  }
95883
96860
  this.clients = null;
96861
+ this.integrationReconciler?.dispose();
96862
+ this.integrationReconciler = null;
95884
96863
  await super.onShutdown();
95885
96864
  }
95886
96865
  globalSettingsSchema() {
@@ -95905,47 +96884,64 @@ var RademacherProviderAddon = class extends BaseDeviceProvider {
95905
96884
  if (!this.clients) throw new Error("Rademacher provider not initialised");
95906
96885
  return this.clients;
95907
96886
  }
95908
- async reconcileIntegrations() {
95909
- const reg = this.requireClients();
95910
- try {
95911
- const mine = (await this.ctx.api.integrations.list.query()).filter((i) => i.addonId === this.ctx.id && i.enabled);
95912
- const surviving = /* @__PURE__ */ new Set();
95913
- for (const integration of mine) try {
95914
- const connection = connectionFromSettings(await this.ctx.api.integrations.getSettings.query({ id: integration.id }));
95915
- if (!connection) {
95916
- this.ctx.logger.warn("Rademacher reconcile: host missing or invalid, no session opened", { tags: { integrationId: integration.id } });
95917
- continue;
96887
+ reconciler() {
96888
+ this.integrationReconciler ??= new RademacherReconciler({
96889
+ addonId: this.ctx.id,
96890
+ logger: this.ctx.logger,
96891
+ clients: {
96892
+ list: () => this.requireClients().list(),
96893
+ remove: async (id) => {
96894
+ await this.requireClients().remove(id);
95918
96895
  }
95919
- await reg.upsert(integration.id, integration.name, connection);
95920
- surviving.add(integration.id);
95921
- } catch (err) {
95922
- this.ctx.logger.warn("Rademacher reconcile: settings read failed", {
95923
- tags: { integrationId: integration.id },
95924
- meta: { error: errMsg(err) }
95925
- });
95926
- }
95927
- const vanished = reg.list().filter((id) => !surviving.has(id));
95928
- await reg.retain(surviving);
95929
- for (const integrationId of vanished) await this.cascadeRemoveDevicesForIntegration(integrationId);
95930
- } catch (err) {
95931
- this.ctx.logger.warn("Rademacher integration reconcile failed", { meta: { error: errMsg(err) } });
95932
- }
96896
+ },
96897
+ listIntegrations: () => this.ctx.api.integrations.list.query(),
96898
+ applySettings: async (integration) => {
96899
+ const connection = connectionFromSettings(await this.ctx.api.integrations.getSettings.query({ id: integration.id }));
96900
+ if (!connection) return false;
96901
+ await this.requireClients().upsert(integration.id, integration.name, connection);
96902
+ return true;
96903
+ },
96904
+ removeDevices: (integrationId) => this.cascadeRemoveDevicesForIntegration(integrationId),
96905
+ ownerIntegrationIds: () => this.ownerIntegrationIds()
96906
+ });
96907
+ return this.integrationReconciler;
96908
+ }
96909
+ /** Upsert one client per enabled integration; never removes a device (D49). */
96910
+ async reconcileIntegrations() {
96911
+ await this.reconciler().reconcile();
95933
96912
  }
96913
+ /** Lifecycle events: only an explicit Deleted/Disabled naming an integration removes devices. */
95934
96914
  subscribeIntegrationLifecycle() {
95935
- const handler = (event) => {
96915
+ const on = (kind) => (event) => {
95936
96916
  const addonId = event.data["addonId"];
95937
96917
  if (typeof addonId === "string" && addonId !== this.ctx.id) return;
95938
- this.reconcileIntegrations();
96918
+ const integrationId = event.data["integrationId"];
96919
+ this.reconciler().onLifecycle(kind, typeof integrationId === "string" ? integrationId : null);
95939
96920
  };
95940
- this.ctx.eventBus.subscribe({ category: EventCategory.IntegrationEnabled }, handler);
95941
- this.ctx.eventBus.subscribe({ category: EventCategory.IntegrationDisabled }, handler);
95942
- this.ctx.eventBus.subscribe({ category: EventCategory.IntegrationDeleted }, handler);
96921
+ this.ctx.eventBus.subscribe({ category: EventCategory.IntegrationEnabled }, on("enabled"));
96922
+ this.ctx.eventBus.subscribe({ category: EventCategory.IntegrationDisabled }, on("disabled"));
96923
+ this.ctx.eventBus.subscribe({ category: EventCategory.IntegrationDeleted }, on("deleted"));
96924
+ }
96925
+ /** The integrations that own devices here, for the orphan sweep. */
96926
+ async ownerIntegrationIds() {
96927
+ const reg = this.ctx.kernel.deviceRegistry;
96928
+ const devices = this.ctx.kernel.devices;
96929
+ if (!reg || !devices) return [];
96930
+ return await collectOwnerIntegrationIds({
96931
+ reg,
96932
+ devices,
96933
+ addonId: this.addonId,
96934
+ ownerOf: (cfg) => {
96935
+ const owner = cfg["integrationId"];
96936
+ return cfg["system"] === "rademacher" && typeof owner === "string" ? owner : null;
96937
+ }
96938
+ });
95943
96939
  }
95944
96940
  async cascadeRemoveDevicesForIntegration(integrationId) {
95945
96941
  const reg = this.ctx.kernel.deviceRegistry;
95946
96942
  const devices = this.ctx.kernel.devices;
95947
- if (!reg || !devices) return;
95948
- await cascadeRemoveDevicesForIntegration({
96943
+ if (!reg || !devices) return 0;
96944
+ return await cascadeRemoveDevicesForIntegration({
95949
96945
  reg,
95950
96946
  devices,
95951
96947
  addonId: this.addonId,