@camstack/addon-export-hap 1.2.187 → 1.2.188

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.
@@ -39,7 +39,7 @@ var __copyProps = (to, from, except, desc) => {
39
39
  var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod);
40
40
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
41
41
  //#endregion
42
- //#region ../types/dist/event-category-DmZDPDf_.mjs
42
+ //#region ../types/dist/event-category-CaURIwQA.mjs
43
43
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
44
44
  EventCategory["SystemBoot"] = "system.boot";
45
45
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -755,6 +755,10 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
755
755
  EventCategory["NotificationRuleBroken"] = "notification.rule-broken";
756
756
  /** The clear of {@link NotificationRuleBroken}: the rule loads and names nothing deleted. */
757
757
  EventCategory["NotificationRuleRepaired"] = "notification.rule-repaired";
758
+ /** A migration failed or was blocked; the Alert Center re-reads the ledger. */
759
+ EventCategory["MigrationFailed"] = "migration.failed";
760
+ /** A migration applied or a failure cleared; the Alert Center re-reads the ledger. */
761
+ EventCategory["MigrationApplied"] = "migration.applied";
758
762
  EventCategory["DeviceUpdated"] = "device.updated";
759
763
  /**
760
764
  * Transport-level connectivity. Emitted by the device driver when
@@ -817,6 +821,378 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
817
821
  return EventCategory;
818
822
  }({});
819
823
  //#endregion
824
+ //#region ../types/dist/device-type-CEqjmUnR.mjs
825
+ /**
826
+ import { errMsg } from '@camstack/types'
827
+ * Extract a human-readable message from an unknown error value.
828
+ * Replaces the ubiquitous `errMsg(err)` pattern.
829
+ */
830
+ function errMsg$17(err) {
831
+ if (err instanceof Error) return err.message;
832
+ if (typeof err === "string") return err;
833
+ return String(err);
834
+ }
835
+ var DeviceType = /* @__PURE__ */ function(DeviceType) {
836
+ DeviceType["Camera"] = "camera";
837
+ DeviceType["Hub"] = "hub";
838
+ DeviceType["Light"] = "light";
839
+ DeviceType["Siren"] = "siren";
840
+ DeviceType["Switch"] = "switch";
841
+ DeviceType["Sensor"] = "sensor";
842
+ DeviceType["Thermostat"] = "thermostat";
843
+ /** Air-conditioner / heat-pump climate device (HVAC) — shares the
844
+ * `climate-control` cap surface with `Thermostat` but renders a
845
+ * dedicated AC-appropriate control UI (mode chips, fan speed,
846
+ * independent vertical/horizontal swing). Sources: native Gree, and
847
+ * reusable by other AC integrations. */
848
+ DeviceType["Climate"] = "climate";
849
+ DeviceType["Button"] = "button";
850
+ /** Generic stateless event emitter — carries a device's EXACT declared
851
+ * event vocabulary verbatim (no normalization). Installed with the
852
+ * `event-emitter` cap. Sources: HA `event.*` entities (structured) and
853
+ * HA bus events (e.g. `zha_event`, generic). */
854
+ DeviceType["EventEmitter"] = "event-emitter";
855
+ /** Firmware/software update entity — current vs available version,
856
+ * updatable flag, update state, and an install action. Installed with
857
+ * the `update` cap. Sources: Homematic firmware-update channels (and
858
+ * reusable by other providers, e.g. HA `update.*` entities). */
859
+ DeviceType["Update"] = "update";
860
+ DeviceType["Generic"] = "generic";
861
+ /** Generic notification delivery target (HA `notify.<service>`, future
862
+ * Telegram / Discord / ntfy / SMTP, …). One device per delivery
863
+ * endpoint; the `notifier` cap defines the send surface. */
864
+ DeviceType["Notifier"] = "notifier";
865
+ /** Pre-recorded action sequence with optional parameters
866
+ * (HA `script.*`). Runnable via `script-runner` cap. */
867
+ DeviceType["Script"] = "script";
868
+ /** Automation rule (HA `automation.*`) — enable/disable + manual
869
+ * trigger surface exposed via `automation-control` cap. */
870
+ DeviceType["Automation"] = "automation";
871
+ /** Door / smart lock device (HA `lock.*`). `lock-control` cap. */
872
+ DeviceType["Lock"] = "lock";
873
+ /** Window covering, blinds, garage door, valve, etc. (HA `cover.*`,
874
+ * `valve.*`). `cover` cap with sub-roles for variant. */
875
+ DeviceType["Cover"] = "cover";
876
+ /** Pipe / water / gas valve with open/close/stop and optional
877
+ * position (HA `valve.*`). `valve` cap — a cover-sibling actuator
878
+ * modelled on the same open/closed lifecycle. */
879
+ DeviceType["Valve"] = "valve";
880
+ /** Humidifier / dehumidifier with on/off + target humidity + mode
881
+ * (HA `humidifier.*`). `humidifier` cap — a climate-family actuator
882
+ * modelled on the same target / mode lifecycle. */
883
+ DeviceType["Humidifier"] = "humidifier";
884
+ /** Water heater / boiler with target temperature + operation mode +
885
+ * away mode (HA `water_heater.*`). `water-heater` cap — a
886
+ * climate-family actuator. */
887
+ DeviceType["WaterHeater"] = "water-heater";
888
+ /** Ceiling / standing / exhaust fan (HA `fan.*`). `fan-control` cap. */
889
+ DeviceType["Fan"] = "fan";
890
+ /** Audio / video playback endpoint (HA `media_player.*`). Disjoint from
891
+ * the camera surface — those use `Camera`. `media-player` cap. */
892
+ DeviceType["MediaPlayer"] = "media-player";
893
+ /** Security panel / alarm system (HA `alarm_control_panel.*`).
894
+ * `alarm-panel` cap. */
895
+ DeviceType["AlarmPanel"] = "alarm-panel";
896
+ /** Generic user-settable input (HA `number` / `input_number` / `select`
897
+ * / `input_select` / `text` / `input_text` / `input_datetime`).
898
+ * Sub-type via `DeviceRole`: NumericControl / SelectControl /
899
+ * TextControl / DateTimeControl. */
900
+ DeviceType["Control"] = "control";
901
+ /** Person / device-tracker presence (HA `person.*`, `device_tracker.*`).
902
+ * `presence` cap. */
903
+ DeviceType["Presence"] = "presence";
904
+ /** Weather provider (HA `weather.*`). Tier-3, low MVP priority.
905
+ * `weather` cap. */
906
+ DeviceType["Weather"] = "weather";
907
+ /** Robot vacuum (HA `vacuum.*`). Tier-3. `vacuum-control` cap. */
908
+ DeviceType["Vacuum"] = "vacuum";
909
+ /** Robotic lawn mower (HA `lawn_mower.*`). Tier-3.
910
+ * `lawn-mower-control` cap. */
911
+ DeviceType["LawnMower"] = "lawn-mower";
912
+ /** Physical HA device group — parent container for entity-children
913
+ * adopted from a single HA device entry. Not renderable as a
914
+ * standalone device; exists only to anchor child entities. */
915
+ DeviceType["Container"] = "container";
916
+ /** Single still-image entity (HA `image.*`). Read-only display of an
917
+ * `entity_picture` signed URL the browser loads directly. `image` cap. */
918
+ DeviceType["Image"] = "image";
919
+ /** Smart pet feeder — cloud-connected food dispenser with a bowl food
920
+ * level, battery, desiccant life, feeding state and manual-feed /
921
+ * call-pet / maintenance actions. Installed with the `pet-feeder` cap;
922
+ * dual-hopper models (D4S/D4SH) expose per-hopper portions. Sources:
923
+ * native PetKit (`nodepetkit` `FeederDevice`), reusable by other feeder
924
+ * integrations sharing the same food/desiccant/hopper surface. */
925
+ DeviceType["PetFeeder"] = "pet-feeder";
926
+ /** Pet water fountain — tank level, water drunk, pump and its duty cycle.
927
+ * Installed with the `pet-fountain` cap. Reaches CamStack as loose entities
928
+ * of a container and is BUILT as a composed device (D967). */
929
+ DeviceType["PetFountain"] = "pet-fountain";
930
+ /** Built-in dishwasher — program lifecycle, door / remote-start gates,
931
+ * salt and rinse-aid levels. Installed with the `dishwasher` cap.
932
+ * Sources: native Bosch Home Connect, reusable by similar integrations.
933
+ * A plug-built dishwasher carries running-state and power instead. */
934
+ DeviceType["Dishwasher"] = "dishwasher";
935
+ /** Washing machine. A plug-built one is running while its power stays
936
+ * above a threshold. No program cap — that surface is the dishwasher's. */
937
+ DeviceType["Washer"] = "washer";
938
+ /** Tumble dryer. Same plug-built running surface as {@link Washer}. */
939
+ DeviceType["Dryer"] = "dryer";
940
+ /** The physical bridge box of a vendor ecosystem (Velux KLF-200, and later
941
+ * other radio-to-IP bridges). It carries the box's own facts (firmware,
942
+ * address, connection state) and the actions the box really supports
943
+ * (`reboot`, `device-admin-link`). Products are NOT its children — they are
944
+ * adopted beside it — and its connection settings stay on the integration. */
945
+ DeviceType["Gateway"] = "gateway";
946
+ return DeviceType;
947
+ }({});
948
+ var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
949
+ DeviceFeature["BatteryOperated"] = "battery-operated";
950
+ DeviceFeature["Rebootable"] = "rebootable";
951
+ /**
952
+ * Device supports an on-demand re-sync of its derived spec with its
953
+ * upstream source — drives the generic Re-sync button. The owning
954
+ * provider implements the action via the `device-adoption.resync` cap.
955
+ */
956
+ DeviceFeature["Resyncable"] = "resyncable";
957
+ DeviceFeature["NativeSnapshot"] = "native-snapshot";
958
+ DeviceFeature["DoorbellButton"] = "doorbell-button";
959
+ DeviceFeature["TwoWayAudio"] = "two-way-audio";
960
+ DeviceFeature["PanTiltZoom"] = "pan-tilt-zoom";
961
+ /**
962
+ * Camera supports the on-firmware autotrack subsystem (subject-
963
+ * following). Distinct from `PanTiltZoom` because not every PTZ
964
+ * camera ships autotrack — the admin UI uses this flag to gate
965
+ * the autotrack toggle / settings card without re-deriving from
966
+ * the cap registry. Mirrors `ptz-autotrack` cap registration:
967
+ * driver sets this feature when probe confirms the firmware
968
+ * surface, and registers the cap in the same code path.
969
+ */
970
+ DeviceFeature["PtzAutotrack"] = "ptz-autotrack";
971
+ /**
972
+ * Accessory exposes a "trigger on motion" toggle — the parent camera's
973
+ * motion detection automatically activates this device. Mirrors
974
+ * `motion-trigger` cap registration: drivers set this feature in the
975
+ * same code path that calls `ctx.registerNativeCap(motionTriggerCapability, ...)`.
976
+ *
977
+ * Used by admin UI (gate the in-hero `MotionTriggerToggle` against a
978
+ * fast scalar without binding fetch), notifier rules, and `listAll`
979
+ * filters that want "all devices with on-motion behaviour".
980
+ */
981
+ DeviceFeature["MotionTrigger"] = "motion-trigger";
982
+ /** Light supports rgb-triplet color via `color` cap. */
983
+ DeviceFeature["LightColorRgb"] = "light-color-rgb";
984
+ /** Light supports HSV color via `color` cap. */
985
+ DeviceFeature["LightColorHsv"] = "light-color-hsv";
986
+ /** Light supports color-temperature (mired) via `color` cap. */
987
+ DeviceFeature["LightColorMired"] = "light-color-mired";
988
+ /** Thermostat supports a `heat_cool` dual setpoint (targetLow +
989
+ * targetHigh). Gates the range slider UI. */
990
+ DeviceFeature["ClimateDualSetpoint"] = "climate-dual-setpoint";
991
+ /** Thermostat exposes target humidity and/or current humidity
992
+ * readings. Gates the humidity controls. */
993
+ DeviceFeature["ClimateHumidity"] = "climate-humidity";
994
+ /** Thermostat exposes a fan-mode selector. */
995
+ DeviceFeature["ClimateFanMode"] = "climate-fan-mode";
996
+ /** Thermostat exposes preset modes (eco / away / sleep / vendor). */
997
+ DeviceFeature["ClimatePreset"] = "climate-preset";
998
+ /** Thermostat exposes a vertical louver swing toggle. Gates the
999
+ * vertical-swing switch in the climate UI. Independent of horizontal. */
1000
+ DeviceFeature["ClimateSwingVertical"] = "climate-swing-vertical";
1001
+ /** Thermostat exposes a horizontal louver swing toggle. Gates the
1002
+ * horizontal-swing switch in the climate UI. Independent of vertical. */
1003
+ DeviceFeature["ClimateSwingHorizontal"] = "climate-swing-horizontal";
1004
+ /** Cover exposes intermediate position control (0..100). Gates the
1005
+ * position slider UI. */
1006
+ DeviceFeature["CoverPositionable"] = "cover-positionable";
1007
+ /** Cover exposes slat-tilt control. Gates the tilt slider UI. */
1008
+ DeviceFeature["CoverTilt"] = "cover-tilt";
1009
+ /** Valve exposes intermediate position control (0..100). Gates the
1010
+ * position slider / drag surface UI. */
1011
+ DeviceFeature["ValvePositionable"] = "valve-positionable";
1012
+ /** Fan exposes a speed-percentage setter. Gates the speed slider UI. */
1013
+ DeviceFeature["FanSpeed"] = "fan-speed";
1014
+ /** Fan exposes a preset mode selector. */
1015
+ DeviceFeature["FanPreset"] = "fan-preset";
1016
+ /** Fan exposes blade direction (forward/reverse) — typical of
1017
+ * ceiling fans. */
1018
+ DeviceFeature["FanDirection"] = "fan-direction";
1019
+ /** Fan exposes an oscillation toggle. */
1020
+ DeviceFeature["FanOscillating"] = "fan-oscillating";
1021
+ /** Lock requires a PIN code on lock/unlock. Gates the code-entry
1022
+ * field on the UI lock-controls panel. */
1023
+ DeviceFeature["LockPinRequired"] = "lock-pin-required";
1024
+ /** Lock supports a latch-release ("open door") action distinct from
1025
+ * unlock. Mirrors HA `LockEntityFeature.OPEN` (bit 1) in
1026
+ * `supported_features`. Gates the Open Door button in the UI. */
1027
+ DeviceFeature["LockOpen"] = "lock-open";
1028
+ /** Media player exposes a seek-to-position surface. */
1029
+ DeviceFeature["MediaPlayerSeek"] = "media-player-seek";
1030
+ /** Media player exposes a volume-level setter. */
1031
+ DeviceFeature["MediaPlayerVolume"] = "media-player-volume";
1032
+ /** Media player exposes a mute toggle distinct from volume=0. */
1033
+ DeviceFeature["MediaPlayerMute"] = "media-player-mute";
1034
+ /** Media player exposes a shuffle toggle. */
1035
+ DeviceFeature["MediaPlayerShuffle"] = "media-player-shuffle";
1036
+ /** Media player exposes a repeat mode (off / all / one). */
1037
+ DeviceFeature["MediaPlayerRepeat"] = "media-player-repeat";
1038
+ /** Media player exposes a source / input selector. */
1039
+ DeviceFeature["MediaPlayerSelectSource"] = "media-player-select-source";
1040
+ /** Media player exposes a play-arbitrary-media surface (URL / id). */
1041
+ DeviceFeature["MediaPlayerPlayMedia"] = "media-player-play-media";
1042
+ /** Media player exposes next-track. */
1043
+ DeviceFeature["MediaPlayerNext"] = "media-player-next";
1044
+ /** Media player exposes previous-track. */
1045
+ DeviceFeature["MediaPlayerPrevious"] = "media-player-previous";
1046
+ /** Media player exposes stop distinct from pause. */
1047
+ DeviceFeature["MediaPlayerStop"] = "media-player-stop";
1048
+ /** Alarm panel requires a PIN code on arm/disarm. */
1049
+ DeviceFeature["AlarmPinRequired"] = "alarm-pin-required";
1050
+ /** Presence device carries GPS coordinates (lat/lng/accuracy) in
1051
+ * addition to a textual location. */
1052
+ DeviceFeature["PresenceGps"] = "presence-gps";
1053
+ /** Notifier accepts an inline / URL image attachment. */
1054
+ DeviceFeature["NotifierImage"] = "notifier-image";
1055
+ /** Notifier accepts a priority hint (high/normal/low). */
1056
+ DeviceFeature["NotifierPriority"] = "notifier-priority";
1057
+ /** Notifier accepts a free-form `data` payload for platform-specific
1058
+ * fields. */
1059
+ DeviceFeature["NotifierData"] = "notifier-data";
1060
+ /** Notifier supports interactive action buttons / callbacks. */
1061
+ DeviceFeature["NotifierActions"] = "notifier-actions";
1062
+ /** Notifier supports per-call recipient targeting (multi-user). */
1063
+ DeviceFeature["NotifierRecipients"] = "notifier-recipients";
1064
+ /** Script runner accepts a variables map on each run invocation. */
1065
+ DeviceFeature["ScriptVariables"] = "script-variables";
1066
+ /** Automation `trigger` accepts a skipCondition flag — fires the
1067
+ * automation's actions while bypassing its condition block. */
1068
+ DeviceFeature["AutomationSkipCondition"] = "automation-skip-condition";
1069
+ /** Robot vacuum exposes a live cleaning map (image child). Gates the
1070
+ * map tile in the vacuum UI. */
1071
+ DeviceFeature["VacuumHasMap"] = "vacuum-has-map";
1072
+ /** Robot vacuum exposes AI obstacle-detection toggles. Gates the AI
1073
+ * switches group. */
1074
+ DeviceFeature["VacuumHasAi"] = "vacuum-has-ai";
1075
+ /** Robot mower exposes a live mowing map (SVG image child). Gates the
1076
+ * mower map tile. */
1077
+ DeviceFeature["MowerHasMap"] = "mower-has-map";
1078
+ /** Robot mower exposes targeted mowing (all-area / zones / edges /
1079
+ * spots) — gates the Mow action + map selectors. */
1080
+ DeviceFeature["MowerHasTargetedMowing"] = "mower-has-targeted-mowing";
1081
+ return DeviceFeature;
1082
+ }({});
1083
+ /**
1084
+ * Semantic role a device plays within its parent. Populated by driver
1085
+ * addons when creating accessory devices (Reolink siren/floodlight/
1086
+ * PIR/chime/autotrack/doorbell, ONVIF relay outputs, …). Used by the
1087
+ * admin UI to pick icons, labels, and widgets — a `Switch` with
1088
+ * `role: Floodlight` renders as a bulb with a brightness slider,
1089
+ * whereas a `Switch` with `role: Siren` renders as a klaxon.
1090
+ *
1091
+ * Undefined for top-level devices (cameras, NVRs, hubs). Persisted in
1092
+ * sqlite as a nullable TEXT column — old rows keep working unchanged.
1093
+ */
1094
+ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
1095
+ DeviceRole["Siren"] = "siren";
1096
+ DeviceRole["Floodlight"] = "floodlight";
1097
+ DeviceRole["Spotlight"] = "spotlight";
1098
+ DeviceRole["PirSensor"] = "pir-sensor";
1099
+ DeviceRole["Chime"] = "chime";
1100
+ DeviceRole["Autotrack"] = "autotrack";
1101
+ DeviceRole["Nightvision"] = "nightvision";
1102
+ DeviceRole["PrivacyMask"] = "privacy-mask";
1103
+ DeviceRole["Doorbell"] = "doorbell";
1104
+ /** Interior blind / shade / roller blind. HA `device_class: blind|shade`. */
1105
+ DeviceRole["CoverBlind"] = "cover-blind";
1106
+ /** Exterior roller shutter. HA `device_class: shutter`; Homematic BROLL. */
1107
+ DeviceRole["CoverShutter"] = "cover-shutter";
1108
+ /** Exterior awning. HA `device_class: awning`. */
1109
+ DeviceRole["CoverAwning"] = "cover-awning";
1110
+ /** Curtain / drape. HA `device_class: curtain`. */
1111
+ DeviceRole["CoverCurtain"] = "cover-curtain";
1112
+ /** Garage door. HA `device_class: garage`. A security actuator: exports gate it. */
1113
+ DeviceRole["CoverGarage"] = "cover-garage";
1114
+ /** Gate. HA `device_class: gate`. A security actuator: exports gate it. */
1115
+ DeviceRole["CoverGate"] = "cover-gate";
1116
+ /** Door. HA `device_class: door`. A security actuator: exports gate it. */
1117
+ DeviceRole["CoverDoor"] = "cover-door";
1118
+ /** Window. HA `device_class: window`. */
1119
+ DeviceRole["CoverWindow"] = "cover-window";
1120
+ /** Virtual HA toggle (input_boolean.*) — distinguishable from a
1121
+ * real Switch device for UI rendering / export adapters. */
1122
+ DeviceRole["BinaryHelper"] = "binary-helper";
1123
+ /** A smart plug: a `switch` whose source says it is an outlet (HA
1124
+ * `device_class: outlet`). The Alexa export shows it as a SMARTPLUG. */
1125
+ DeviceRole["Outlet"] = "outlet";
1126
+ /** Generic motion / occupancy / moving event source. Distinct from
1127
+ * the camera accessory PirSensor role: that one is a camera child;
1128
+ * this is a standalone HA / 3rd-party motion sensor. */
1129
+ DeviceRole["MotionSensor"] = "motion-sensor";
1130
+ DeviceRole["ContactSensor"] = "contact-sensor";
1131
+ DeviceRole["LeakSensor"] = "leak-sensor";
1132
+ DeviceRole["SmokeSensor"] = "smoke-sensor";
1133
+ DeviceRole["COSensor"] = "co-sensor";
1134
+ DeviceRole["GasSensor"] = "gas-sensor";
1135
+ DeviceRole["TamperSensor"] = "tamper-sensor";
1136
+ DeviceRole["VibrationSensor"] = "vibration-sensor";
1137
+ DeviceRole["ConnectivitySensor"] = "connectivity-sensor";
1138
+ DeviceRole["SoundSensor"] = "sound-sensor";
1139
+ /** Fallback for `binary_sensor` without a known `device_class`. */
1140
+ DeviceRole["BinarySensor"] = "binary-sensor";
1141
+ DeviceRole["TemperatureSensor"] = "temperature-sensor";
1142
+ DeviceRole["HumiditySensor"] = "humidity-sensor";
1143
+ DeviceRole["AmbientLightSensor"] = "ambient-light-sensor";
1144
+ DeviceRole["PressureSensor"] = "pressure-sensor";
1145
+ /** Wind speed or direction (weather-station `wind-sensor` cap). */
1146
+ DeviceRole["WindSensor"] = "wind-sensor";
1147
+ /** Rain accumulation or rate (weather-station `rain-sensor` cap). */
1148
+ DeviceRole["RainSensor"] = "rain-sensor";
1149
+ /** UV index (weather-station `uv-sensor` cap). */
1150
+ DeviceRole["UvSensor"] = "uv-sensor";
1151
+ /** Solar irradiance W/m² (weather-station `solar-radiation-sensor` cap).
1152
+ * Distinct from AmbientLightSensor (lux). */
1153
+ DeviceRole["SolarRadiationSensor"] = "solar-radiation-sensor";
1154
+ /** Soil moisture % (garden/weather `soil-moisture-sensor` cap). */
1155
+ DeviceRole["SoilMoistureSensor"] = "soil-moisture-sensor";
1156
+ DeviceRole["PowerSensor"] = "power-sensor";
1157
+ DeviceRole["EnergySensor"] = "energy-sensor";
1158
+ DeviceRole["VoltageSensor"] = "voltage-sensor";
1159
+ DeviceRole["CurrentSensor"] = "current-sensor";
1160
+ DeviceRole["AirQualitySensor"] = "air-quality-sensor";
1161
+ /** Battery level (numeric % via `sensor` OR low-bool via
1162
+ * `binary_sensor` — the cap distinguishes via the value type). */
1163
+ DeviceRole["BatterySensor"] = "battery-sensor";
1164
+ /** Fallback for `sensor` numeric without a known `device_class`. */
1165
+ DeviceRole["NumericSensor"] = "numeric-sensor";
1166
+ /** String / enum state (HA `sensor` with `state_class: enum` or
1167
+ * `attributes.options`). */
1168
+ DeviceRole["EnumSensor"] = "enum-sensor";
1169
+ /** Date / timestamp state (HA `sensor` with `device_class: timestamp`
1170
+ * or `date`). The slice carries the raw ISO string verbatim (hosted on
1171
+ * the `enum-sensor` cap); the UI renders it locale-formatted. */
1172
+ DeviceRole["DateTimeSensor"] = "datetime-sensor";
1173
+ /** Last-resort fallback when nothing else matches. */
1174
+ DeviceRole["GenericSensor"] = "generic-sensor";
1175
+ DeviceRole["NumericControl"] = "numeric-control";
1176
+ DeviceRole["SelectControl"] = "select-control";
1177
+ DeviceRole["TextControl"] = "text-control";
1178
+ DeviceRole["DateTimeControl"] = "datetime-control";
1179
+ /** Mobile push notifier (HA `notify.mobile_app_*`) — supports
1180
+ * rich features (image, priority, channel routing). */
1181
+ DeviceRole["MobilePushNotifier"] = "mobile-push-notifier";
1182
+ /** Chat / messaging service (HA `notify.telegram_*`,
1183
+ * `notify.discord_*`, etc.). */
1184
+ DeviceRole["MessagingNotifier"] = "messaging-notifier";
1185
+ /** Email-based delivery (HA `notify.smtp`, etc.). */
1186
+ DeviceRole["EmailNotifier"] = "email-notifier";
1187
+ /** Fallback when the notifier service name doesn't match a known
1188
+ * pattern. */
1189
+ DeviceRole["GenericNotifier"] = "generic-notifier";
1190
+ /** Emits a pulse train (infrared or RF) on request — the `ir-transmitter`
1191
+ * cap. A `DeviceType.Generic` device. */
1192
+ DeviceRole["IrTransmitter"] = "ir-transmitter";
1193
+ return DeviceRole;
1194
+ }({});
1195
+ //#endregion
820
1196
  //#region ../../node_modules/zod/v4/core/core.js
821
1197
  var _a$1;
822
1198
  function $constructor(name, initializer, params) {
@@ -5495,7 +5871,7 @@ var ZodIssueCode = {
5495
5871
  var ZodFirstPartyTypeKind;
5496
5872
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5497
5873
  //#endregion
5498
- //#region ../types/dist/sleep-SX9bkW3_.mjs
5874
+ //#region ../types/dist/sleep-CSYuxssh.mjs
5499
5875
  /**
5500
5876
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5501
5877
  * window to float samples (D455).
@@ -6011,6 +6387,102 @@ function emitReadiness(bus, params) {
6011
6387
  ts
6012
6388
  }));
6013
6389
  }
6390
+ var NOT_RUN = {
6391
+ declared: false,
6392
+ snapshot: null,
6393
+ applied: [],
6394
+ failed: [],
6395
+ blocked: [],
6396
+ skipped: [],
6397
+ blockOwner: []
6398
+ };
6399
+ /**
6400
+ * Offer `migrations` to the engine and run what it says to run, in its order. Never
6401
+ * throws: an unreachable or refusing engine is logged and reported `declared: false`,
6402
+ * because the hub (and this addon's boot) must not hang on a migration.
6403
+ */
6404
+ async function runAddonMigrations(host, migrations, logger) {
6405
+ const first = migrations[0];
6406
+ if (first === void 0) return NOT_RUN;
6407
+ const owner = first.meta.owner;
6408
+ const log = logger.withTags({ migrationOwner: owner });
6409
+ const byId = new Map(migrations.map((m) => [m.meta.id, m]));
6410
+ let declaration;
6411
+ try {
6412
+ declaration = await host.declareOwner({
6413
+ owner,
6414
+ metas: migrations.map((m) => m.meta)
6415
+ });
6416
+ } catch (err) {
6417
+ log.error("the migration engine refused or could not take this addon catalogue — none ran", { meta: { error: errMsg$17(err) } });
6418
+ return {
6419
+ ...NOT_RUN,
6420
+ blockOwner: migrations.filter((m) => m.meta.onFailure === "block-owner").map((m) => m.meta.id)
6421
+ };
6422
+ }
6423
+ const applied = [];
6424
+ const failed = [];
6425
+ const blocked = [];
6426
+ const skipped = [];
6427
+ const settle = (id, status) => {
6428
+ if (status === "applied") applied.push(id);
6429
+ else if (status === "failed") failed.push(id);
6430
+ else if (status === "blocked") blocked.push(id);
6431
+ else skipped.push(id);
6432
+ };
6433
+ for (const step of declaration.steps) {
6434
+ const bound = byId.get(step.id);
6435
+ if (bound === void 0 || step.action === "skip") {
6436
+ skipped.push(step.id);
6437
+ continue;
6438
+ }
6439
+ const tags = { migrationId: step.id };
6440
+ try {
6441
+ const gate = await host.startMigration({ id: step.id });
6442
+ if (!gate.proceed) {
6443
+ log.warn("migration not run", {
6444
+ tags,
6445
+ meta: {
6446
+ state: gate.state,
6447
+ reason: gate.reason
6448
+ }
6449
+ });
6450
+ settle(step.id, gate.state === "pending" ? "blocked" : gate.state);
6451
+ continue;
6452
+ }
6453
+ const result = await bound.execute();
6454
+ const outcome = await host.finishMigration({
6455
+ id: step.id,
6456
+ result
6457
+ });
6458
+ if (outcome.status === "applied") log.info("migration applied", {
6459
+ tags,
6460
+ meta: { rowsChanged: outcome.rowsChanged }
6461
+ });
6462
+ else log.error("migration failed", {
6463
+ tags,
6464
+ meta: { error: outcome.error }
6465
+ });
6466
+ settle(step.id, outcome.status);
6467
+ } catch (err) {
6468
+ log.error("migration could not be completed with the engine", {
6469
+ tags,
6470
+ meta: { error: errMsg$17(err) }
6471
+ });
6472
+ failed.push(step.id);
6473
+ }
6474
+ }
6475
+ const blockOwner = [...failed, ...blocked].filter((id) => byId.get(id)?.meta.onFailure === "block-owner");
6476
+ return {
6477
+ declared: true,
6478
+ snapshot: declaration.snapshot,
6479
+ applied,
6480
+ failed,
6481
+ blocked,
6482
+ skipped,
6483
+ blockOwner
6484
+ };
6485
+ }
6014
6486
  /**
6015
6487
  * Build a {@link DurableState} over a single store key. Transport-agnostic:
6016
6488
  * `read`/`write` are the addon-store or device-store accessors. The whole
@@ -7066,6 +7538,28 @@ var BaseAddon = class {
7066
7538
  return normalized;
7067
7539
  }
7068
7540
  /**
7541
+ * Run this addon's migration catalogue (D987 M3) through the hub's `migrations`
7542
+ * engine. Call it at the point of the boot where the data must already have the new
7543
+ * shape — `onInitialize`, or `onRestoreDevices` for a migration that needs the
7544
+ * restored devices — with the catalogue bound to the addon's ports
7545
+ * (`defineAddonMigrations(ADDON_MIGRATIONS, ports)`).
7546
+ *
7547
+ * An engine that cannot be reached or refuses the catalogue is logged and runs
7548
+ * nothing; the boot continues. A migration that FAILED (or was blocked by one)
7549
+ * and declares `onFailure: 'block-owner'` makes this throw, so the addon does not
7550
+ * serve data whose shape it cannot trust; `tolerate` migrations never do.
7551
+ */
7552
+ async runMigrations(migrations) {
7553
+ const api = this.ctx.api.migrations;
7554
+ const report = await runAddonMigrations({
7555
+ declareOwner: (input) => api.declareOwner.mutate(input),
7556
+ startMigration: (input) => api.startMigration.mutate(input),
7557
+ finishMigration: (input) => api.finishMigration.mutate(input)
7558
+ }, migrations, this.ctx.logger);
7559
+ 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`);
7560
+ return report;
7561
+ }
7562
+ /**
7069
7563
  * Called by the isolated-process runner AFTER `broker.start()`.
7070
7564
  * In-process addons never need this because the hub broker is already
7071
7565
  * running when `initialize()` fires. For forked children the broker
@@ -7198,6 +7692,26 @@ var BaseAddon = class {
7198
7692
  * alternative — skip it — turns a rename into a surface that quietly
7199
7693
  * empties, which looks exactly like an addon with nothing to configure.
7200
7694
  */
7695
+ /**
7696
+ * The form schema of ONE integration instance, or `null` to use {@link globalSettingsSchema}.
7697
+ *
7698
+ * Override it only when an `instanceMode: multiple` addon's instances differ: an NVR integration
7699
+ * needs its connection fields, the default integration the addon's own sections. It is the
7700
+ * SHAPE of the form only — the values live in `integrations.getSettings`, and the write path is
7701
+ * unchanged (`integrations.setSettings` for an account integration).
7702
+ */
7703
+ async integrationSettingsSchema(_instance) {
7704
+ return null;
7705
+ }
7706
+ /**
7707
+ * What the create wizard and the integration edit page render for one instance: the addon's
7708
+ * per-instance schema when it declares one, else its global schema (what they always showed).
7709
+ */
7710
+ async getIntegrationFormSchema(instance, nodeId) {
7711
+ const scoped = await this.integrationSettingsSchema(instance);
7712
+ if (scoped === null) return this.getGlobalSettings(void 0, void 0, nodeId);
7713
+ return hydrateSchema(scoped, {}, { inlineSecretsAsViews: true });
7714
+ }
7201
7715
  async getIntegrationSettings(nodeId) {
7202
7716
  const declared = this.integrationSettingSections();
7203
7717
  if (declared.length === 0) return null;
@@ -8088,407 +8602,6 @@ var RecordKindDeclarationSchema = object({
8088
8602
  }).strict();
8089
8603
  /** The kind names: lower-case, dash separated, short enough for an index name. */
8090
8604
  var RecordKindNameSchema = string().regex(/^[a-z][a-z0-9-]{0,47}$/);
8091
- var READING_QUANTITIES = [
8092
- "temperature",
8093
- "pressure",
8094
- "speed",
8095
- "precipitation",
8096
- "precipitation-rate",
8097
- "length",
8098
- "area",
8099
- "illuminance",
8100
- "irradiance",
8101
- "power",
8102
- "energy",
8103
- "voltage",
8104
- "current",
8105
- "apparent-power",
8106
- "humidity",
8107
- "percentage",
8108
- "concentration-volume",
8109
- "concentration-mass",
8110
- "concentration-ppb",
8111
- "volume",
8112
- "duration",
8113
- "duration-ms",
8114
- "information",
8115
- "sound-level",
8116
- "signal-level",
8117
- "colour-temperature",
8118
- "angle",
8119
- "bitrate",
8120
- "rate",
8121
- "mass",
8122
- "index",
8123
- "ratio",
8124
- "count",
8125
- "none",
8126
- "device"
8127
- ];
8128
- var ReadingQuantitySchema = _enum(READING_QUANTITIES);
8129
- new Set(READING_QUANTITIES);
8130
- /**
8131
- * Stored unit symbol for a quantity. `none` means the number is dimensionless
8132
- * (or an index / ratio / count). `device` means the cap has no single unit.
8133
- */
8134
- var QUANTITY_BASE = {
8135
- temperature: "°C",
8136
- pressure: "hPa",
8137
- speed: "m/s",
8138
- precipitation: "mm",
8139
- "precipitation-rate": "mm/h",
8140
- length: "m",
8141
- area: "m²",
8142
- illuminance: "lx",
8143
- irradiance: "W/m²",
8144
- power: "W",
8145
- energy: "kWh",
8146
- voltage: "V",
8147
- current: "A",
8148
- "apparent-power": "VA",
8149
- humidity: "%",
8150
- percentage: "%",
8151
- "concentration-volume": "ppm",
8152
- "concentration-mass": "µg/m³",
8153
- "concentration-ppb": "ppb",
8154
- volume: "L",
8155
- duration: "s",
8156
- "duration-ms": "ms",
8157
- information: "B",
8158
- "sound-level": "dBFS",
8159
- "signal-level": "dBm",
8160
- "colour-temperature": "mired",
8161
- angle: "°",
8162
- bitrate: "kbps",
8163
- rate: "fps",
8164
- mass: "kg",
8165
- index: "none",
8166
- ratio: "none",
8167
- count: "none",
8168
- none: "none",
8169
- device: "device"
8170
- };
8171
- /** The stored unit, or `undefined` when the quantity has no unit symbol. */
8172
- function baseUnitOf(quantity) {
8173
- const symbol = QUANTITY_BASE[quantity];
8174
- if (symbol === "none" || symbol === "device") return void 0;
8175
- return symbol;
8176
- }
8177
- function readingMeta(quantity, extras) {
8178
- return {
8179
- quantity,
8180
- ...extras?.precision !== void 0 ? { precision: extras.precision } : {},
8181
- ...extras?.label !== void 0 ? { label: extras.label } : {}
8182
- };
8183
- }
8184
- /** Shared Zod schemas used across streaming capabilities. */
8185
- var CamProfileSchema = _enum([
8186
- "high",
8187
- "mid",
8188
- "low"
8189
- ]);
8190
- /**
8191
- * Which rung a per-camera consumer listens on: an explicit profile, or `auto`.
8192
- *
8193
- * `auto` is a REAL value, not an absent one — it means "resolve it by the rule
8194
- * that consumer owns". It lives beside `CamProfile` because a rung is the only
8195
- * operator-facing way to name a stream: a cam-stream id is broker-internal and
8196
- * moves when a slot is reassigned, so a stored id silently stops meaning what
8197
- * the operator picked. Today's one user is the audio analyser, whose rule is
8198
- * "the lowest AVAILABLE native rung" (D537).
8199
- */
8200
- var AudioStreamPickSchema = union([CamProfileSchema, literal("auto")]);
8201
- var CamStreamKindSchema = _enum([
8202
- "pull-rtsp",
8203
- "pull-rtmp",
8204
- "pull-http",
8205
- "pull-flv",
8206
- "pull-rfc4571",
8207
- "push-annexb",
8208
- "derived"
8209
- ]);
8210
- var CamStreamResolutionSchema = object({
8211
- width: number().int().positive().meta(readingMeta("none")),
8212
- height: number().int().positive().meta(readingMeta("none"))
8213
- });
8214
- var CameraStreamSchema = object({
8215
- /** Stable, provider-assigned id unique within the (deviceId) scope. */
8216
- camStreamId: string().min(1),
8217
- deviceId: number().int().nonnegative(),
8218
- kind: CamStreamKindSchema,
8219
- /** Required for pull-* kinds. Ignored for push-annexb. */
8220
- url: string().optional(),
8221
- codec: string().optional(),
8222
- resolution: CamStreamResolutionSchema.optional(),
8223
- fps: number().positive().optional(),
8224
- /** Human label surfaced in the Admin UI "Camera Stream" dropdown. */
8225
- label: string().optional(),
8226
- /**
8227
- * Device-level features the publisher advertised (e.g. `battery-operated`).
8228
- * The broker, snapshot orchestrator, and prebuffer manager all consult
8229
- * this list to derive policy — relaxed stall watchdog for battery
8230
- * cams, prebuffer off by default, longer snapshot rate-limit, etc.
8231
- *
8232
- * Single source of truth replacing per-stream flags like the
8233
- * historical `allowStall`: if the publisher knows the camera is
8234
- * battery-powered, every downstream service derives the right policy
8235
- * from this list.
8236
- */
8237
- deviceFeatures: array(string()).optional(),
8238
- /**
8239
- * Whether this stream participates in the broker's automatic profile
8240
- * assignment (`computeInitialAssignment`). Defaults to `true`. Publishers
8241
- * use `false` when they want a stream to be SELECTABLE in the UI but not
8242
- * picked by default — e.g. Reolink publishes its native Baichuan streams
8243
- * as `autoEligible: true` (the recommended path) and its RTSP / RTMP
8244
- * mirrors as `autoEligible: false` (still pickable per slot, just not
8245
- * the auto choice). Manual `assignProfile` calls remain valid for
8246
- * non-eligible streams.
8247
- */
8248
- autoEligible: boolean().optional(),
8249
- /**
8250
- * The profile slot the PUBLISHER says this stream is: `low` for a stream
8251
- * whose only sensible role is the low-bandwidth one, `high` for a main
8252
- * stream. Consulted by the broker's automatic ranking
8253
- * (`rankInitialAssignment`) BEFORE the pixel-count heuristic, and only there:
8254
- * an operator's manual assignment still wins, and an absent hint is the
8255
- * pixel-ranked default every camera had before this field existed.
8256
- *
8257
- * Why it exists: a camera with ONE stream ranked to `mid` — the slot no
8258
- * storage class is written for on its own (`recordings` is high|mid,
8259
- * `recordingsLow` is low) and the one profile scrub does not read. The robot
8260
- * camera's single 720p relay is a `low` in every respect except the slot the
8261
- * heuristic put it in.
8262
- */
8263
- profileHint: CamProfileSchema.optional(),
8264
- /**
8265
- * Transport-specific opaque metadata. The broker passes it through to
8266
- * the source reader without inspecting it. Currently used by
8267
- * `pull-rfc4571` streams to carry the upstream SDP (so the reader can
8268
- * route RTP packets to the right depacketizer without an in-band
8269
- * DESCRIBE phase). Other kinds typically leave it undefined.
8270
- */
8271
- metadata: record(string(), unknown()).optional()
8272
- });
8273
- var ProfileSlotStatusSchema = _enum([
8274
- "unassigned",
8275
- "idle",
8276
- "connecting",
8277
- "streaming",
8278
- "error"
8279
- ]);
8280
- var ProfileSlotSchema = object({
8281
- deviceId: number().int().nonnegative(),
8282
- profile: CamProfileSchema,
8283
- /** Broker id the rest of the system addresses: `${deviceId}/${profile}`. */
8284
- brokerId: string(),
8285
- /** `null` when the profile is unassigned. */
8286
- sourceCamStreamId: string().nullable(),
8287
- status: ProfileSlotStatusSchema,
8288
- resolution: CamStreamResolutionSchema.optional(),
8289
- codec: string().optional(),
8290
- preBufferSec: number().nonnegative().optional(),
8291
- errorMessage: string().optional()
8292
- });
8293
- /**
8294
- * Zod schema for StreamSourceEntry — the canonical stream descriptor
8295
- * exposed by ICameraDevice.getStreamSources() and consumed by the broker.
8296
- */
8297
- var StreamSourceEntrySchema$1 = object({
8298
- id: string(),
8299
- label: string(),
8300
- protocol: _enum([
8301
- "rtsp",
8302
- "rtmp",
8303
- "annexb",
8304
- "http-mjpeg",
8305
- "webrtc",
8306
- "custom"
8307
- ]),
8308
- url: string().optional(),
8309
- resolution: object({
8310
- width: number(),
8311
- height: number()
8312
- }).readonly().optional(),
8313
- fps: number().optional(),
8314
- bitrate: number().optional(),
8315
- codec: string().optional(),
8316
- profileHint: CamProfileSchema.optional()
8317
- });
8318
- object({
8319
- type: string(),
8320
- url: string(),
8321
- videoCodec: string().optional(),
8322
- audioCodec: string().optional(),
8323
- metadata: record(string(), unknown()).readonly().optional()
8324
- });
8325
- /**
8326
- * Wire schema for `FrameHandle` — a zero-pixel, serialisable reference to a
8327
- * frame in a shared-memory ring (Phase 5 / D9). Mirrors the `FrameHandle` TS
8328
- * interface in `interfaces/frame-handle.ts` field-for-field so a cap method
8329
- * (the runner's native-crop and pipeline-executor inputs) can carry handles
8330
- * over tRPC / Moleculer.
8331
- *
8332
- * The `satisfies` assertion below pins this schema to the interface: if a
8333
- * field is added to / removed from `FrameHandle` without a matching schema
8334
- * edit, `z.infer<typeof FrameHandleSchema>` stops being assignable to
8335
- * `FrameHandle` and the build fails — no silent drift.
8336
- */
8337
- var FrameHandleSchema = object({
8338
- shmId: string(),
8339
- slot: number().int().nonnegative(),
8340
- seq: number().int().nonnegative(),
8341
- width: number().int().positive(),
8342
- height: number().int().positive(),
8343
- format: _enum([
8344
- "jpeg",
8345
- "rgb",
8346
- "bgr",
8347
- "yuv420",
8348
- "gray"
8349
- ]),
8350
- pts: number(),
8351
- byteLength: number().int().nonnegative(),
8352
- nodeId: string(),
8353
- slotCount: number().int().positive()
8354
- });
8355
- /**
8356
- * Wire schema for a decoded audio chunk (Phase 5 / D9). Mirrors the
8357
- * `DecodedAudioChunk` TS interface in `interfaces/stream-broker.ts`: PCM
8358
- * sample bytes plus the track parameters a consumer needs to interpret them.
8359
- *
8360
- * Audio chunks are tiny (a ~500ms AudioCodecSession window is a few KB of
8361
- * Float32 PCM), so unlike video frames they ship their bytes INLINE over
8362
- * tRPC / Moleculer — no shared-memory plane. `data` is typed `Uint8Array`
8363
- * (the wire-serialisable supertype of `Buffer`); a `Buffer` is assignable to
8364
- * it.
8365
- */
8366
- var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
8367
- var DecodedAudioChunkSchema = object({
8368
- data: _instanceof(Uint8Array),
8369
- sampleRate: number().int().positive(),
8370
- channels: number().int().positive(),
8371
- timestamp: number(),
8372
- /**
8373
- * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
8374
- * byte, for any peer that never heard of this field. A coded window
8375
- * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
8376
- * subscription that DECLARED it accepts one, so absence can never mean
8377
- * "coded bytes a consumer will read as floats" (D455).
8378
- */
8379
- format: AudioChunkFormatSchema.optional()
8380
- });
8381
- /**
8382
- * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). Audio ships
8383
- * its bytes inline: a consumer asks the broker for the decoded audio-chunk
8384
- * stream of one broker; the broker keeps a per-subscription bounded FIFO queue
8385
- * the consumer drains via `pullAudioChunks`.
8386
- */
8387
- var SubscribeAudioChunksInputSchema = object({
8388
- brokerId: string(),
8389
- /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
8390
- tag: string().optional(),
8391
- /**
8392
- * Byte formats this subscriber can READ, best first. The broker serves the
8393
- * chunk's own format when it is in this list and expands to `f32le`
8394
- * otherwise, so a subscriber is never handed bytes it cannot interpret.
8395
- *
8396
- * Absent (or without the source format) means `f32le` — the behaviour every
8397
- * subscriber had before D455, unchanged. This is the negotiation half of
8398
- * the source-bytes lever: it is what lets the broker and its consumers
8399
- * deploy one at a time across three nodes.
8400
- */
8401
- accept: array(AudioChunkFormatSchema).readonly().optional()
8402
- });
8403
- /** Result of `stream-broker.subscribeAudioChunks`. */
8404
- var SubscribeAudioChunksResultSchema = object({
8405
- /** Opaque id passed to `pullAudioChunks` / `unsubscribeAudioChunks`. */
8406
- subscriptionId: string() });
8407
- var BrokerStatsSchema = object({
8408
- status: _enum([
8409
- "idle",
8410
- "connecting",
8411
- "streaming",
8412
- "error",
8413
- "stopped"
8414
- ]),
8415
- inputFps: number(),
8416
- encodedSubscribers: number(),
8417
- uptimeMs: number(),
8418
- bitrateKbps: number(),
8419
- idrIntervalMs: number(),
8420
- codec: string().optional(),
8421
- totalBytes: number(),
8422
- packetCount: number(),
8423
- rtspClients: number(),
8424
- pipeClients: number(),
8425
- preBufferSec: number(),
8426
- preBufferMs: number(),
8427
- preBufferPackets: number(),
8428
- /**
8429
- * Detected audio track parameters from the RTSP DESCRIBE / SDP. `null`
8430
- * when the stream has no audio track or the broker is in cold start.
8431
- * `supported = false` means the codec was detected but the local
8432
- * decoder pipeline cannot produce PCM chunks (e.g. AAC without the
8433
- * AAC pipeline wired). Surfaced in the UI device-overview so operators
8434
- * can pre-pick the audio-analysis model that matches the codec.
8435
- */
8436
- audio: object({
8437
- codec: string(),
8438
- sampleRate: number(),
8439
- channels: number(),
8440
- supported: boolean()
8441
- }).nullable().optional(),
8442
- /**
8443
- * BROKER-SIDE AUDIO MUTE (D83). `true` = this broker is deliberately
8444
- * distributing none of the device's audio, on live or recording.
8445
- *
8446
- * Present so a silent camera can be told apart from a broken one on the
8447
- * stream panel itself, without cross-referencing the switch group: a
8448
- * broker holding an `audio` track descriptor while `audioMuted` is true is
8449
- * working exactly as asked. `audioMutedDropped` counts the audio units
8450
- * thrown away since the current dial — it is how you confirm from stats
8451
- * alone that the mute is on the packet path and not merely persisted.
8452
- */
8453
- audioMuted: boolean().optional(),
8454
- audioMutedDropped: number().optional()
8455
- });
8456
- /**
8457
- * Exporter-facing "profile restream" entry. Returned by
8458
- * `cameraStreams.getProfileRtspEntries` — one per ASSIGNED profile slot
8459
- * (high/mid/low). `brokerId` is the PROFILE-keyed broker id
8460
- * (`${deviceId}/${profile}`, e.g. `15/high`); its `url` is a broker
8461
- * RTSP restream that aliases the profile's assigned source broker, so
8462
- * every consumer dialling a profile converges on the same single pull.
8463
- * `codec`/`resolution` describe the assigned SOURCE camStream (for the
8464
- * `auto` resolution-closest pick). Distinct from `RtspRestreamEntry`
8465
- * (raw per-camStream, live-view only).
8466
- */
8467
- var ProfileRtspEntrySchema = object({
8468
- profile: CamProfileSchema,
8469
- /** Profile-keyed broker id, format `${deviceId}/${profile}` (e.g. `"15/high"`). */
8470
- brokerId: string(),
8471
- url: string(),
8472
- mutedUrl: string(),
8473
- enabled: boolean(),
8474
- codec: string().optional(),
8475
- resolution: CamStreamResolutionSchema.optional()
8476
- });
8477
- /**
8478
- * The model weight formats a catalog entry can ship. Schema-free on purpose:
8479
- * `types/models.ts` builds Zod schemas from it, but a runner-closure consumer
8480
- * (the model downloader in `@camstack/system`) needs only the list and must
8481
- * reach it through `@camstack/types/addon` without building the cap schema
8482
- * graph (D28).
8483
- */
8484
- var MODEL_FORMATS = [
8485
- "onnx",
8486
- "coreml",
8487
- "openvino",
8488
- "tflite",
8489
- "pt",
8490
- "gguf"
8491
- ];
8492
8605
  object({
8493
8606
  field: string().min(1),
8494
8607
  on: literal("advance")
@@ -8577,6 +8690,407 @@ function optionalMethod(input, output, options) {
8577
8690
  providerOptional: true
8578
8691
  };
8579
8692
  }
8693
+ var READING_QUANTITIES = [
8694
+ "temperature",
8695
+ "pressure",
8696
+ "speed",
8697
+ "precipitation",
8698
+ "precipitation-rate",
8699
+ "length",
8700
+ "area",
8701
+ "illuminance",
8702
+ "irradiance",
8703
+ "power",
8704
+ "energy",
8705
+ "voltage",
8706
+ "current",
8707
+ "apparent-power",
8708
+ "humidity",
8709
+ "percentage",
8710
+ "concentration-volume",
8711
+ "concentration-mass",
8712
+ "concentration-ppb",
8713
+ "volume",
8714
+ "duration",
8715
+ "duration-ms",
8716
+ "information",
8717
+ "sound-level",
8718
+ "signal-level",
8719
+ "colour-temperature",
8720
+ "angle",
8721
+ "bitrate",
8722
+ "rate",
8723
+ "mass",
8724
+ "index",
8725
+ "ratio",
8726
+ "count",
8727
+ "none",
8728
+ "device"
8729
+ ];
8730
+ var ReadingQuantitySchema = _enum(READING_QUANTITIES);
8731
+ new Set(READING_QUANTITIES);
8732
+ /**
8733
+ * Stored unit symbol for a quantity. `none` means the number is dimensionless
8734
+ * (or an index / ratio / count). `device` means the cap has no single unit.
8735
+ */
8736
+ var QUANTITY_BASE = {
8737
+ temperature: "°C",
8738
+ pressure: "hPa",
8739
+ speed: "m/s",
8740
+ precipitation: "mm",
8741
+ "precipitation-rate": "mm/h",
8742
+ length: "m",
8743
+ area: "m²",
8744
+ illuminance: "lx",
8745
+ irradiance: "W/m²",
8746
+ power: "W",
8747
+ energy: "kWh",
8748
+ voltage: "V",
8749
+ current: "A",
8750
+ "apparent-power": "VA",
8751
+ humidity: "%",
8752
+ percentage: "%",
8753
+ "concentration-volume": "ppm",
8754
+ "concentration-mass": "µg/m³",
8755
+ "concentration-ppb": "ppb",
8756
+ volume: "L",
8757
+ duration: "s",
8758
+ "duration-ms": "ms",
8759
+ information: "B",
8760
+ "sound-level": "dBFS",
8761
+ "signal-level": "dBm",
8762
+ "colour-temperature": "mired",
8763
+ angle: "°",
8764
+ bitrate: "kbps",
8765
+ rate: "fps",
8766
+ mass: "kg",
8767
+ index: "none",
8768
+ ratio: "none",
8769
+ count: "none",
8770
+ none: "none",
8771
+ device: "device"
8772
+ };
8773
+ /** The stored unit, or `undefined` when the quantity has no unit symbol. */
8774
+ function baseUnitOf(quantity) {
8775
+ const symbol = QUANTITY_BASE[quantity];
8776
+ if (symbol === "none" || symbol === "device") return void 0;
8777
+ return symbol;
8778
+ }
8779
+ function readingMeta(quantity, extras) {
8780
+ return {
8781
+ quantity,
8782
+ ...extras?.precision !== void 0 ? { precision: extras.precision } : {},
8783
+ ...extras?.label !== void 0 ? { label: extras.label } : {}
8784
+ };
8785
+ }
8786
+ /** Shared Zod schemas used across streaming capabilities. */
8787
+ var CamProfileSchema = _enum([
8788
+ "high",
8789
+ "mid",
8790
+ "low"
8791
+ ]);
8792
+ /**
8793
+ * Which rung a per-camera consumer listens on: an explicit profile, or `auto`.
8794
+ *
8795
+ * `auto` is a REAL value, not an absent one — it means "resolve it by the rule
8796
+ * that consumer owns". It lives beside `CamProfile` because a rung is the only
8797
+ * operator-facing way to name a stream: a cam-stream id is broker-internal and
8798
+ * moves when a slot is reassigned, so a stored id silently stops meaning what
8799
+ * the operator picked. Today's one user is the audio analyser, whose rule is
8800
+ * "the lowest AVAILABLE native rung" (D537).
8801
+ */
8802
+ var AudioStreamPickSchema = union([CamProfileSchema, literal("auto")]);
8803
+ var CamStreamKindSchema = _enum([
8804
+ "pull-rtsp",
8805
+ "pull-rtmp",
8806
+ "pull-http",
8807
+ "pull-flv",
8808
+ "pull-rfc4571",
8809
+ "push-annexb",
8810
+ "derived"
8811
+ ]);
8812
+ var CamStreamResolutionSchema = object({
8813
+ width: number().int().positive().meta(readingMeta("none")),
8814
+ height: number().int().positive().meta(readingMeta("none"))
8815
+ });
8816
+ var CameraStreamSchema = object({
8817
+ /** Stable, provider-assigned id unique within the (deviceId) scope. */
8818
+ camStreamId: string().min(1),
8819
+ deviceId: number().int().nonnegative(),
8820
+ kind: CamStreamKindSchema,
8821
+ /** Required for pull-* kinds. Ignored for push-annexb. */
8822
+ url: string().optional(),
8823
+ codec: string().optional(),
8824
+ resolution: CamStreamResolutionSchema.optional(),
8825
+ fps: number().positive().optional(),
8826
+ /** Human label surfaced in the Admin UI "Camera Stream" dropdown. */
8827
+ label: string().optional(),
8828
+ /**
8829
+ * Device-level features the publisher advertised (e.g. `battery-operated`).
8830
+ * The broker, snapshot orchestrator, and prebuffer manager all consult
8831
+ * this list to derive policy — relaxed stall watchdog for battery
8832
+ * cams, prebuffer off by default, longer snapshot rate-limit, etc.
8833
+ *
8834
+ * Single source of truth replacing per-stream flags like the
8835
+ * historical `allowStall`: if the publisher knows the camera is
8836
+ * battery-powered, every downstream service derives the right policy
8837
+ * from this list.
8838
+ */
8839
+ deviceFeatures: array(string()).optional(),
8840
+ /**
8841
+ * Whether this stream participates in the broker's automatic profile
8842
+ * assignment (`computeInitialAssignment`). Defaults to `true`. Publishers
8843
+ * use `false` when they want a stream to be SELECTABLE in the UI but not
8844
+ * picked by default — e.g. Reolink publishes its native Baichuan streams
8845
+ * as `autoEligible: true` (the recommended path) and its RTSP / RTMP
8846
+ * mirrors as `autoEligible: false` (still pickable per slot, just not
8847
+ * the auto choice). Manual `assignProfile` calls remain valid for
8848
+ * non-eligible streams.
8849
+ */
8850
+ autoEligible: boolean().optional(),
8851
+ /**
8852
+ * The profile slot the PUBLISHER says this stream is: `low` for a stream
8853
+ * whose only sensible role is the low-bandwidth one, `high` for a main
8854
+ * stream. Consulted by the broker's automatic ranking
8855
+ * (`rankInitialAssignment`) BEFORE the pixel-count heuristic, and only there:
8856
+ * an operator's manual assignment still wins, and an absent hint is the
8857
+ * pixel-ranked default every camera had before this field existed.
8858
+ *
8859
+ * Why it exists: a camera with ONE stream ranked to `mid` — the slot no
8860
+ * storage class is written for on its own (`recordings` is high|mid,
8861
+ * `recordingsLow` is low) and the one profile scrub does not read. The robot
8862
+ * camera's single 720p relay is a `low` in every respect except the slot the
8863
+ * heuristic put it in.
8864
+ */
8865
+ profileHint: CamProfileSchema.optional(),
8866
+ /**
8867
+ * Transport-specific opaque metadata. The broker passes it through to
8868
+ * the source reader without inspecting it. Currently used by
8869
+ * `pull-rfc4571` streams to carry the upstream SDP (so the reader can
8870
+ * route RTP packets to the right depacketizer without an in-band
8871
+ * DESCRIBE phase). Other kinds typically leave it undefined.
8872
+ */
8873
+ metadata: record(string(), unknown()).optional()
8874
+ });
8875
+ var ProfileSlotStatusSchema = _enum([
8876
+ "unassigned",
8877
+ "idle",
8878
+ "connecting",
8879
+ "streaming",
8880
+ "error"
8881
+ ]);
8882
+ var ProfileSlotSchema = object({
8883
+ deviceId: number().int().nonnegative(),
8884
+ profile: CamProfileSchema,
8885
+ /** Broker id the rest of the system addresses: `${deviceId}/${profile}`. */
8886
+ brokerId: string(),
8887
+ /** `null` when the profile is unassigned. */
8888
+ sourceCamStreamId: string().nullable(),
8889
+ status: ProfileSlotStatusSchema,
8890
+ resolution: CamStreamResolutionSchema.optional(),
8891
+ codec: string().optional(),
8892
+ preBufferSec: number().nonnegative().optional(),
8893
+ errorMessage: string().optional()
8894
+ });
8895
+ /**
8896
+ * Zod schema for StreamSourceEntry — the canonical stream descriptor
8897
+ * exposed by ICameraDevice.getStreamSources() and consumed by the broker.
8898
+ */
8899
+ var StreamSourceEntrySchema$1 = object({
8900
+ id: string(),
8901
+ label: string(),
8902
+ protocol: _enum([
8903
+ "rtsp",
8904
+ "rtmp",
8905
+ "annexb",
8906
+ "http-mjpeg",
8907
+ "webrtc",
8908
+ "custom"
8909
+ ]),
8910
+ url: string().optional(),
8911
+ resolution: object({
8912
+ width: number(),
8913
+ height: number()
8914
+ }).readonly().optional(),
8915
+ fps: number().optional(),
8916
+ bitrate: number().optional(),
8917
+ codec: string().optional(),
8918
+ profileHint: CamProfileSchema.optional()
8919
+ });
8920
+ object({
8921
+ type: string(),
8922
+ url: string(),
8923
+ videoCodec: string().optional(),
8924
+ audioCodec: string().optional(),
8925
+ metadata: record(string(), unknown()).readonly().optional()
8926
+ });
8927
+ /**
8928
+ * Wire schema for `FrameHandle` — a zero-pixel, serialisable reference to a
8929
+ * frame in a shared-memory ring (Phase 5 / D9). Mirrors the `FrameHandle` TS
8930
+ * interface in `interfaces/frame-handle.ts` field-for-field so a cap method
8931
+ * (the runner's native-crop and pipeline-executor inputs) can carry handles
8932
+ * over tRPC / Moleculer.
8933
+ *
8934
+ * The `satisfies` assertion below pins this schema to the interface: if a
8935
+ * field is added to / removed from `FrameHandle` without a matching schema
8936
+ * edit, `z.infer<typeof FrameHandleSchema>` stops being assignable to
8937
+ * `FrameHandle` and the build fails — no silent drift.
8938
+ */
8939
+ var FrameHandleSchema = object({
8940
+ shmId: string(),
8941
+ slot: number().int().nonnegative(),
8942
+ seq: number().int().nonnegative(),
8943
+ width: number().int().positive(),
8944
+ height: number().int().positive(),
8945
+ format: _enum([
8946
+ "jpeg",
8947
+ "rgb",
8948
+ "bgr",
8949
+ "yuv420",
8950
+ "gray"
8951
+ ]),
8952
+ pts: number(),
8953
+ byteLength: number().int().nonnegative(),
8954
+ nodeId: string(),
8955
+ slotCount: number().int().positive()
8956
+ });
8957
+ /**
8958
+ * Wire schema for a decoded audio chunk (Phase 5 / D9). Mirrors the
8959
+ * `DecodedAudioChunk` TS interface in `interfaces/stream-broker.ts`: PCM
8960
+ * sample bytes plus the track parameters a consumer needs to interpret them.
8961
+ *
8962
+ * Audio chunks are tiny (a ~500ms AudioCodecSession window is a few KB of
8963
+ * Float32 PCM), so unlike video frames they ship their bytes INLINE over
8964
+ * tRPC / Moleculer — no shared-memory plane. `data` is typed `Uint8Array`
8965
+ * (the wire-serialisable supertype of `Buffer`); a `Buffer` is assignable to
8966
+ * it.
8967
+ */
8968
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
8969
+ var DecodedAudioChunkSchema = object({
8970
+ data: _instanceof(Uint8Array),
8971
+ sampleRate: number().int().positive(),
8972
+ channels: number().int().positive(),
8973
+ timestamp: number(),
8974
+ /**
8975
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
8976
+ * byte, for any peer that never heard of this field. A coded window
8977
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
8978
+ * subscription that DECLARED it accepts one, so absence can never mean
8979
+ * "coded bytes a consumer will read as floats" (D455).
8980
+ */
8981
+ format: AudioChunkFormatSchema.optional()
8982
+ });
8983
+ /**
8984
+ * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). Audio ships
8985
+ * its bytes inline: a consumer asks the broker for the decoded audio-chunk
8986
+ * stream of one broker; the broker keeps a per-subscription bounded FIFO queue
8987
+ * the consumer drains via `pullAudioChunks`.
8988
+ */
8989
+ var SubscribeAudioChunksInputSchema = object({
8990
+ brokerId: string(),
8991
+ /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
8992
+ tag: string().optional(),
8993
+ /**
8994
+ * Byte formats this subscriber can READ, best first. The broker serves the
8995
+ * chunk's own format when it is in this list and expands to `f32le`
8996
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
8997
+ *
8998
+ * Absent (or without the source format) means `f32le` — the behaviour every
8999
+ * subscriber had before D455, unchanged. This is the negotiation half of
9000
+ * the source-bytes lever: it is what lets the broker and its consumers
9001
+ * deploy one at a time across three nodes.
9002
+ */
9003
+ accept: array(AudioChunkFormatSchema).readonly().optional()
9004
+ });
9005
+ /** Result of `stream-broker.subscribeAudioChunks`. */
9006
+ var SubscribeAudioChunksResultSchema = object({
9007
+ /** Opaque id passed to `pullAudioChunks` / `unsubscribeAudioChunks`. */
9008
+ subscriptionId: string() });
9009
+ var BrokerStatsSchema = object({
9010
+ status: _enum([
9011
+ "idle",
9012
+ "connecting",
9013
+ "streaming",
9014
+ "error",
9015
+ "stopped"
9016
+ ]),
9017
+ inputFps: number(),
9018
+ encodedSubscribers: number(),
9019
+ uptimeMs: number(),
9020
+ bitrateKbps: number(),
9021
+ idrIntervalMs: number(),
9022
+ codec: string().optional(),
9023
+ totalBytes: number(),
9024
+ packetCount: number(),
9025
+ rtspClients: number(),
9026
+ pipeClients: number(),
9027
+ preBufferSec: number(),
9028
+ preBufferMs: number(),
9029
+ preBufferPackets: number(),
9030
+ /**
9031
+ * Detected audio track parameters from the RTSP DESCRIBE / SDP. `null`
9032
+ * when the stream has no audio track or the broker is in cold start.
9033
+ * `supported = false` means the codec was detected but the local
9034
+ * decoder pipeline cannot produce PCM chunks (e.g. AAC without the
9035
+ * AAC pipeline wired). Surfaced in the UI device-overview so operators
9036
+ * can pre-pick the audio-analysis model that matches the codec.
9037
+ */
9038
+ audio: object({
9039
+ codec: string(),
9040
+ sampleRate: number(),
9041
+ channels: number(),
9042
+ supported: boolean()
9043
+ }).nullable().optional(),
9044
+ /**
9045
+ * BROKER-SIDE AUDIO MUTE (D83). `true` = this broker is deliberately
9046
+ * distributing none of the device's audio, on live or recording.
9047
+ *
9048
+ * Present so a silent camera can be told apart from a broken one on the
9049
+ * stream panel itself, without cross-referencing the switch group: a
9050
+ * broker holding an `audio` track descriptor while `audioMuted` is true is
9051
+ * working exactly as asked. `audioMutedDropped` counts the audio units
9052
+ * thrown away since the current dial — it is how you confirm from stats
9053
+ * alone that the mute is on the packet path and not merely persisted.
9054
+ */
9055
+ audioMuted: boolean().optional(),
9056
+ audioMutedDropped: number().optional()
9057
+ });
9058
+ /**
9059
+ * Exporter-facing "profile restream" entry. Returned by
9060
+ * `cameraStreams.getProfileRtspEntries` — one per ASSIGNED profile slot
9061
+ * (high/mid/low). `brokerId` is the PROFILE-keyed broker id
9062
+ * (`${deviceId}/${profile}`, e.g. `15/high`); its `url` is a broker
9063
+ * RTSP restream that aliases the profile's assigned source broker, so
9064
+ * every consumer dialling a profile converges on the same single pull.
9065
+ * `codec`/`resolution` describe the assigned SOURCE camStream (for the
9066
+ * `auto` resolution-closest pick). Distinct from `RtspRestreamEntry`
9067
+ * (raw per-camStream, live-view only).
9068
+ */
9069
+ var ProfileRtspEntrySchema = object({
9070
+ profile: CamProfileSchema,
9071
+ /** Profile-keyed broker id, format `${deviceId}/${profile}` (e.g. `"15/high"`). */
9072
+ brokerId: string(),
9073
+ url: string(),
9074
+ mutedUrl: string(),
9075
+ enabled: boolean(),
9076
+ codec: string().optional(),
9077
+ resolution: CamStreamResolutionSchema.optional()
9078
+ });
9079
+ /**
9080
+ * The model weight formats a catalog entry can ship. Schema-free on purpose:
9081
+ * `types/models.ts` builds Zod schemas from it, but a runner-closure consumer
9082
+ * (the model downloader in `@camstack/server/system`) needs only the list and must
9083
+ * reach it through `@camstack/types/addon` without building the cap schema
9084
+ * graph (D28).
9085
+ */
9086
+ var MODEL_FORMATS = [
9087
+ "onnx",
9088
+ "coreml",
9089
+ "openvino",
9090
+ "tflite",
9091
+ "pt",
9092
+ "gguf"
9093
+ ];
8580
9094
  /**
8581
9095
  * Per-call node pinning for `ctx.api` capability calls.
8582
9096
  *
@@ -8877,6 +9391,7 @@ var CAP_NAMES = Object.freeze([
8877
9391
  "mesh-network",
8878
9392
  "meter",
8879
9393
  "metrics-provider",
9394
+ "migrations",
8880
9395
  "model-convert",
8881
9396
  "model-distributor",
8882
9397
  "motion",
@@ -8909,6 +9424,7 @@ var CAP_NAMES = Object.freeze([
8909
9424
  "plate-gallery",
8910
9425
  "platform-probe",
8911
9426
  "power-meter",
9427
+ "power-source",
8912
9428
  "presence",
8913
9429
  "pressure-sensor",
8914
9430
  "privacy-mask",
@@ -10260,6 +10776,13 @@ Object.freeze({
10260
10776
  "valueType": "number"
10261
10777
  }
10262
10778
  ],
10779
+ "power-source": [{
10780
+ "path": "switchOn",
10781
+ "valueType": "boolean"
10782
+ }, {
10783
+ "path": "offSeconds",
10784
+ "valueType": "number"
10785
+ }],
10263
10786
  "presence": [
10264
10787
  {
10265
10788
  "path": "state",
@@ -10771,379 +11294,7 @@ object({
10771
11294
  params: record(string(), union([string(), number()])).optional()
10772
11295
  });
10773
11296
  //#endregion
10774
- //#region ../types/dist/err-msg-BD5buxvT.mjs
10775
- var DeviceType = /* @__PURE__ */ function(DeviceType) {
10776
- DeviceType["Camera"] = "camera";
10777
- DeviceType["Hub"] = "hub";
10778
- DeviceType["Light"] = "light";
10779
- DeviceType["Siren"] = "siren";
10780
- DeviceType["Switch"] = "switch";
10781
- DeviceType["Sensor"] = "sensor";
10782
- DeviceType["Thermostat"] = "thermostat";
10783
- /** Air-conditioner / heat-pump climate device (HVAC) — shares the
10784
- * `climate-control` cap surface with `Thermostat` but renders a
10785
- * dedicated AC-appropriate control UI (mode chips, fan speed,
10786
- * independent vertical/horizontal swing). Sources: native Gree, and
10787
- * reusable by other AC integrations. */
10788
- DeviceType["Climate"] = "climate";
10789
- DeviceType["Button"] = "button";
10790
- /** Generic stateless event emitter — carries a device's EXACT declared
10791
- * event vocabulary verbatim (no normalization). Installed with the
10792
- * `event-emitter` cap. Sources: HA `event.*` entities (structured) and
10793
- * HA bus events (e.g. `zha_event`, generic). */
10794
- DeviceType["EventEmitter"] = "event-emitter";
10795
- /** Firmware/software update entity — current vs available version,
10796
- * updatable flag, update state, and an install action. Installed with
10797
- * the `update` cap. Sources: Homematic firmware-update channels (and
10798
- * reusable by other providers, e.g. HA `update.*` entities). */
10799
- DeviceType["Update"] = "update";
10800
- DeviceType["Generic"] = "generic";
10801
- /** Generic notification delivery target (HA `notify.<service>`, future
10802
- * Telegram / Discord / ntfy / SMTP, …). One device per delivery
10803
- * endpoint; the `notifier` cap defines the send surface. */
10804
- DeviceType["Notifier"] = "notifier";
10805
- /** Pre-recorded action sequence with optional parameters
10806
- * (HA `script.*`). Runnable via `script-runner` cap. */
10807
- DeviceType["Script"] = "script";
10808
- /** Automation rule (HA `automation.*`) — enable/disable + manual
10809
- * trigger surface exposed via `automation-control` cap. */
10810
- DeviceType["Automation"] = "automation";
10811
- /** Door / smart lock device (HA `lock.*`). `lock-control` cap. */
10812
- DeviceType["Lock"] = "lock";
10813
- /** Window covering, blinds, garage door, valve, etc. (HA `cover.*`,
10814
- * `valve.*`). `cover` cap with sub-roles for variant. */
10815
- DeviceType["Cover"] = "cover";
10816
- /** Pipe / water / gas valve with open/close/stop and optional
10817
- * position (HA `valve.*`). `valve` cap — a cover-sibling actuator
10818
- * modelled on the same open/closed lifecycle. */
10819
- DeviceType["Valve"] = "valve";
10820
- /** Humidifier / dehumidifier with on/off + target humidity + mode
10821
- * (HA `humidifier.*`). `humidifier` cap — a climate-family actuator
10822
- * modelled on the same target / mode lifecycle. */
10823
- DeviceType["Humidifier"] = "humidifier";
10824
- /** Water heater / boiler with target temperature + operation mode +
10825
- * away mode (HA `water_heater.*`). `water-heater` cap — a
10826
- * climate-family actuator. */
10827
- DeviceType["WaterHeater"] = "water-heater";
10828
- /** Ceiling / standing / exhaust fan (HA `fan.*`). `fan-control` cap. */
10829
- DeviceType["Fan"] = "fan";
10830
- /** Audio / video playback endpoint (HA `media_player.*`). Disjoint from
10831
- * the camera surface — those use `Camera`. `media-player` cap. */
10832
- DeviceType["MediaPlayer"] = "media-player";
10833
- /** Security panel / alarm system (HA `alarm_control_panel.*`).
10834
- * `alarm-panel` cap. */
10835
- DeviceType["AlarmPanel"] = "alarm-panel";
10836
- /** Generic user-settable input (HA `number` / `input_number` / `select`
10837
- * / `input_select` / `text` / `input_text` / `input_datetime`).
10838
- * Sub-type via `DeviceRole`: NumericControl / SelectControl /
10839
- * TextControl / DateTimeControl. */
10840
- DeviceType["Control"] = "control";
10841
- /** Person / device-tracker presence (HA `person.*`, `device_tracker.*`).
10842
- * `presence` cap. */
10843
- DeviceType["Presence"] = "presence";
10844
- /** Weather provider (HA `weather.*`). Tier-3, low MVP priority.
10845
- * `weather` cap. */
10846
- DeviceType["Weather"] = "weather";
10847
- /** Robot vacuum (HA `vacuum.*`). Tier-3. `vacuum-control` cap. */
10848
- DeviceType["Vacuum"] = "vacuum";
10849
- /** Robotic lawn mower (HA `lawn_mower.*`). Tier-3.
10850
- * `lawn-mower-control` cap. */
10851
- DeviceType["LawnMower"] = "lawn-mower";
10852
- /** Physical HA device group — parent container for entity-children
10853
- * adopted from a single HA device entry. Not renderable as a
10854
- * standalone device; exists only to anchor child entities. */
10855
- DeviceType["Container"] = "container";
10856
- /** Single still-image entity (HA `image.*`). Read-only display of an
10857
- * `entity_picture` signed URL the browser loads directly. `image` cap. */
10858
- DeviceType["Image"] = "image";
10859
- /** Smart pet feeder — cloud-connected food dispenser with a bowl food
10860
- * level, battery, desiccant life, feeding state and manual-feed /
10861
- * call-pet / maintenance actions. Installed with the `pet-feeder` cap;
10862
- * dual-hopper models (D4S/D4SH) expose per-hopper portions. Sources:
10863
- * native PetKit (`nodepetkit` `FeederDevice`), reusable by other feeder
10864
- * integrations sharing the same food/desiccant/hopper surface. */
10865
- DeviceType["PetFeeder"] = "pet-feeder";
10866
- /** Pet water fountain — tank level, water drunk, pump and its duty cycle.
10867
- * Installed with the `pet-fountain` cap. Reaches CamStack as loose entities
10868
- * of a container and is BUILT as a composed device (D967). */
10869
- DeviceType["PetFountain"] = "pet-fountain";
10870
- /** Built-in dishwasher — program lifecycle, door / remote-start gates,
10871
- * salt and rinse-aid levels. Installed with the `dishwasher` cap.
10872
- * Sources: native Bosch Home Connect, reusable by similar integrations.
10873
- * A plug-built dishwasher carries running-state and power instead. */
10874
- DeviceType["Dishwasher"] = "dishwasher";
10875
- /** Washing machine. A plug-built one is running while its power stays
10876
- * above a threshold. No program cap — that surface is the dishwasher's. */
10877
- DeviceType["Washer"] = "washer";
10878
- /** Tumble dryer. Same plug-built running surface as {@link Washer}. */
10879
- DeviceType["Dryer"] = "dryer";
10880
- /** The physical bridge box of a vendor ecosystem (Velux KLF-200, and later
10881
- * other radio-to-IP bridges). It carries the box's own facts (firmware,
10882
- * address, connection state) and the actions the box really supports
10883
- * (`reboot`, `device-admin-link`). Products are NOT its children — they are
10884
- * adopted beside it — and its connection settings stay on the integration. */
10885
- DeviceType["Gateway"] = "gateway";
10886
- return DeviceType;
10887
- }({});
10888
- var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
10889
- DeviceFeature["BatteryOperated"] = "battery-operated";
10890
- DeviceFeature["Rebootable"] = "rebootable";
10891
- /**
10892
- * Device supports an on-demand re-sync of its derived spec with its
10893
- * upstream source — drives the generic Re-sync button. The owning
10894
- * provider implements the action via the `device-adoption.resync` cap.
10895
- */
10896
- DeviceFeature["Resyncable"] = "resyncable";
10897
- DeviceFeature["NativeSnapshot"] = "native-snapshot";
10898
- DeviceFeature["DoorbellButton"] = "doorbell-button";
10899
- DeviceFeature["TwoWayAudio"] = "two-way-audio";
10900
- DeviceFeature["PanTiltZoom"] = "pan-tilt-zoom";
10901
- /**
10902
- * Camera supports the on-firmware autotrack subsystem (subject-
10903
- * following). Distinct from `PanTiltZoom` because not every PTZ
10904
- * camera ships autotrack — the admin UI uses this flag to gate
10905
- * the autotrack toggle / settings card without re-deriving from
10906
- * the cap registry. Mirrors `ptz-autotrack` cap registration:
10907
- * driver sets this feature when probe confirms the firmware
10908
- * surface, and registers the cap in the same code path.
10909
- */
10910
- DeviceFeature["PtzAutotrack"] = "ptz-autotrack";
10911
- /**
10912
- * Accessory exposes a "trigger on motion" toggle — the parent camera's
10913
- * motion detection automatically activates this device. Mirrors
10914
- * `motion-trigger` cap registration: drivers set this feature in the
10915
- * same code path that calls `ctx.registerNativeCap(motionTriggerCapability, ...)`.
10916
- *
10917
- * Used by admin UI (gate the in-hero `MotionTriggerToggle` against a
10918
- * fast scalar without binding fetch), notifier rules, and `listAll`
10919
- * filters that want "all devices with on-motion behaviour".
10920
- */
10921
- DeviceFeature["MotionTrigger"] = "motion-trigger";
10922
- /** Light supports rgb-triplet color via `color` cap. */
10923
- DeviceFeature["LightColorRgb"] = "light-color-rgb";
10924
- /** Light supports HSV color via `color` cap. */
10925
- DeviceFeature["LightColorHsv"] = "light-color-hsv";
10926
- /** Light supports color-temperature (mired) via `color` cap. */
10927
- DeviceFeature["LightColorMired"] = "light-color-mired";
10928
- /** Thermostat supports a `heat_cool` dual setpoint (targetLow +
10929
- * targetHigh). Gates the range slider UI. */
10930
- DeviceFeature["ClimateDualSetpoint"] = "climate-dual-setpoint";
10931
- /** Thermostat exposes target humidity and/or current humidity
10932
- * readings. Gates the humidity controls. */
10933
- DeviceFeature["ClimateHumidity"] = "climate-humidity";
10934
- /** Thermostat exposes a fan-mode selector. */
10935
- DeviceFeature["ClimateFanMode"] = "climate-fan-mode";
10936
- /** Thermostat exposes preset modes (eco / away / sleep / vendor). */
10937
- DeviceFeature["ClimatePreset"] = "climate-preset";
10938
- /** Thermostat exposes a vertical louver swing toggle. Gates the
10939
- * vertical-swing switch in the climate UI. Independent of horizontal. */
10940
- DeviceFeature["ClimateSwingVertical"] = "climate-swing-vertical";
10941
- /** Thermostat exposes a horizontal louver swing toggle. Gates the
10942
- * horizontal-swing switch in the climate UI. Independent of vertical. */
10943
- DeviceFeature["ClimateSwingHorizontal"] = "climate-swing-horizontal";
10944
- /** Cover exposes intermediate position control (0..100). Gates the
10945
- * position slider UI. */
10946
- DeviceFeature["CoverPositionable"] = "cover-positionable";
10947
- /** Cover exposes slat-tilt control. Gates the tilt slider UI. */
10948
- DeviceFeature["CoverTilt"] = "cover-tilt";
10949
- /** Valve exposes intermediate position control (0..100). Gates the
10950
- * position slider / drag surface UI. */
10951
- DeviceFeature["ValvePositionable"] = "valve-positionable";
10952
- /** Fan exposes a speed-percentage setter. Gates the speed slider UI. */
10953
- DeviceFeature["FanSpeed"] = "fan-speed";
10954
- /** Fan exposes a preset mode selector. */
10955
- DeviceFeature["FanPreset"] = "fan-preset";
10956
- /** Fan exposes blade direction (forward/reverse) — typical of
10957
- * ceiling fans. */
10958
- DeviceFeature["FanDirection"] = "fan-direction";
10959
- /** Fan exposes an oscillation toggle. */
10960
- DeviceFeature["FanOscillating"] = "fan-oscillating";
10961
- /** Lock requires a PIN code on lock/unlock. Gates the code-entry
10962
- * field on the UI lock-controls panel. */
10963
- DeviceFeature["LockPinRequired"] = "lock-pin-required";
10964
- /** Lock supports a latch-release ("open door") action distinct from
10965
- * unlock. Mirrors HA `LockEntityFeature.OPEN` (bit 1) in
10966
- * `supported_features`. Gates the Open Door button in the UI. */
10967
- DeviceFeature["LockOpen"] = "lock-open";
10968
- /** Media player exposes a seek-to-position surface. */
10969
- DeviceFeature["MediaPlayerSeek"] = "media-player-seek";
10970
- /** Media player exposes a volume-level setter. */
10971
- DeviceFeature["MediaPlayerVolume"] = "media-player-volume";
10972
- /** Media player exposes a mute toggle distinct from volume=0. */
10973
- DeviceFeature["MediaPlayerMute"] = "media-player-mute";
10974
- /** Media player exposes a shuffle toggle. */
10975
- DeviceFeature["MediaPlayerShuffle"] = "media-player-shuffle";
10976
- /** Media player exposes a repeat mode (off / all / one). */
10977
- DeviceFeature["MediaPlayerRepeat"] = "media-player-repeat";
10978
- /** Media player exposes a source / input selector. */
10979
- DeviceFeature["MediaPlayerSelectSource"] = "media-player-select-source";
10980
- /** Media player exposes a play-arbitrary-media surface (URL / id). */
10981
- DeviceFeature["MediaPlayerPlayMedia"] = "media-player-play-media";
10982
- /** Media player exposes next-track. */
10983
- DeviceFeature["MediaPlayerNext"] = "media-player-next";
10984
- /** Media player exposes previous-track. */
10985
- DeviceFeature["MediaPlayerPrevious"] = "media-player-previous";
10986
- /** Media player exposes stop distinct from pause. */
10987
- DeviceFeature["MediaPlayerStop"] = "media-player-stop";
10988
- /** Alarm panel requires a PIN code on arm/disarm. */
10989
- DeviceFeature["AlarmPinRequired"] = "alarm-pin-required";
10990
- /** Presence device carries GPS coordinates (lat/lng/accuracy) in
10991
- * addition to a textual location. */
10992
- DeviceFeature["PresenceGps"] = "presence-gps";
10993
- /** Notifier accepts an inline / URL image attachment. */
10994
- DeviceFeature["NotifierImage"] = "notifier-image";
10995
- /** Notifier accepts a priority hint (high/normal/low). */
10996
- DeviceFeature["NotifierPriority"] = "notifier-priority";
10997
- /** Notifier accepts a free-form `data` payload for platform-specific
10998
- * fields. */
10999
- DeviceFeature["NotifierData"] = "notifier-data";
11000
- /** Notifier supports interactive action buttons / callbacks. */
11001
- DeviceFeature["NotifierActions"] = "notifier-actions";
11002
- /** Notifier supports per-call recipient targeting (multi-user). */
11003
- DeviceFeature["NotifierRecipients"] = "notifier-recipients";
11004
- /** Script runner accepts a variables map on each run invocation. */
11005
- DeviceFeature["ScriptVariables"] = "script-variables";
11006
- /** Automation `trigger` accepts a skipCondition flag — fires the
11007
- * automation's actions while bypassing its condition block. */
11008
- DeviceFeature["AutomationSkipCondition"] = "automation-skip-condition";
11009
- /** Robot vacuum exposes a live cleaning map (image child). Gates the
11010
- * map tile in the vacuum UI. */
11011
- DeviceFeature["VacuumHasMap"] = "vacuum-has-map";
11012
- /** Robot vacuum exposes AI obstacle-detection toggles. Gates the AI
11013
- * switches group. */
11014
- DeviceFeature["VacuumHasAi"] = "vacuum-has-ai";
11015
- /** Robot mower exposes a live mowing map (SVG image child). Gates the
11016
- * mower map tile. */
11017
- DeviceFeature["MowerHasMap"] = "mower-has-map";
11018
- /** Robot mower exposes targeted mowing (all-area / zones / edges /
11019
- * spots) — gates the Mow action + map selectors. */
11020
- DeviceFeature["MowerHasTargetedMowing"] = "mower-has-targeted-mowing";
11021
- return DeviceFeature;
11022
- }({});
11023
- /**
11024
- * Semantic role a device plays within its parent. Populated by driver
11025
- * addons when creating accessory devices (Reolink siren/floodlight/
11026
- * PIR/chime/autotrack/doorbell, ONVIF relay outputs, …). Used by the
11027
- * admin UI to pick icons, labels, and widgets — a `Switch` with
11028
- * `role: Floodlight` renders as a bulb with a brightness slider,
11029
- * whereas a `Switch` with `role: Siren` renders as a klaxon.
11030
- *
11031
- * Undefined for top-level devices (cameras, NVRs, hubs). Persisted in
11032
- * sqlite as a nullable TEXT column — old rows keep working unchanged.
11033
- */
11034
- var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
11035
- DeviceRole["Siren"] = "siren";
11036
- DeviceRole["Floodlight"] = "floodlight";
11037
- DeviceRole["Spotlight"] = "spotlight";
11038
- DeviceRole["PirSensor"] = "pir-sensor";
11039
- DeviceRole["Chime"] = "chime";
11040
- DeviceRole["Autotrack"] = "autotrack";
11041
- DeviceRole["Nightvision"] = "nightvision";
11042
- DeviceRole["PrivacyMask"] = "privacy-mask";
11043
- DeviceRole["Doorbell"] = "doorbell";
11044
- /** Interior blind / shade / roller blind. HA `device_class: blind|shade`. */
11045
- DeviceRole["CoverBlind"] = "cover-blind";
11046
- /** Exterior roller shutter. HA `device_class: shutter`; Homematic BROLL. */
11047
- DeviceRole["CoverShutter"] = "cover-shutter";
11048
- /** Exterior awning. HA `device_class: awning`. */
11049
- DeviceRole["CoverAwning"] = "cover-awning";
11050
- /** Curtain / drape. HA `device_class: curtain`. */
11051
- DeviceRole["CoverCurtain"] = "cover-curtain";
11052
- /** Garage door. HA `device_class: garage`. A security actuator: exports gate it. */
11053
- DeviceRole["CoverGarage"] = "cover-garage";
11054
- /** Gate. HA `device_class: gate`. A security actuator: exports gate it. */
11055
- DeviceRole["CoverGate"] = "cover-gate";
11056
- /** Door. HA `device_class: door`. A security actuator: exports gate it. */
11057
- DeviceRole["CoverDoor"] = "cover-door";
11058
- /** Window. HA `device_class: window`. */
11059
- DeviceRole["CoverWindow"] = "cover-window";
11060
- /** Virtual HA toggle (input_boolean.*) — distinguishable from a
11061
- * real Switch device for UI rendering / export adapters. */
11062
- DeviceRole["BinaryHelper"] = "binary-helper";
11063
- /** A smart plug: a `switch` whose source says it is an outlet (HA
11064
- * `device_class: outlet`). The Alexa export shows it as a SMARTPLUG. */
11065
- DeviceRole["Outlet"] = "outlet";
11066
- /** Generic motion / occupancy / moving event source. Distinct from
11067
- * the camera accessory PirSensor role: that one is a camera child;
11068
- * this is a standalone HA / 3rd-party motion sensor. */
11069
- DeviceRole["MotionSensor"] = "motion-sensor";
11070
- DeviceRole["ContactSensor"] = "contact-sensor";
11071
- DeviceRole["LeakSensor"] = "leak-sensor";
11072
- DeviceRole["SmokeSensor"] = "smoke-sensor";
11073
- DeviceRole["COSensor"] = "co-sensor";
11074
- DeviceRole["GasSensor"] = "gas-sensor";
11075
- DeviceRole["TamperSensor"] = "tamper-sensor";
11076
- DeviceRole["VibrationSensor"] = "vibration-sensor";
11077
- DeviceRole["ConnectivitySensor"] = "connectivity-sensor";
11078
- DeviceRole["SoundSensor"] = "sound-sensor";
11079
- /** Fallback for `binary_sensor` without a known `device_class`. */
11080
- DeviceRole["BinarySensor"] = "binary-sensor";
11081
- DeviceRole["TemperatureSensor"] = "temperature-sensor";
11082
- DeviceRole["HumiditySensor"] = "humidity-sensor";
11083
- DeviceRole["AmbientLightSensor"] = "ambient-light-sensor";
11084
- DeviceRole["PressureSensor"] = "pressure-sensor";
11085
- /** Wind speed or direction (weather-station `wind-sensor` cap). */
11086
- DeviceRole["WindSensor"] = "wind-sensor";
11087
- /** Rain accumulation or rate (weather-station `rain-sensor` cap). */
11088
- DeviceRole["RainSensor"] = "rain-sensor";
11089
- /** UV index (weather-station `uv-sensor` cap). */
11090
- DeviceRole["UvSensor"] = "uv-sensor";
11091
- /** Solar irradiance W/m² (weather-station `solar-radiation-sensor` cap).
11092
- * Distinct from AmbientLightSensor (lux). */
11093
- DeviceRole["SolarRadiationSensor"] = "solar-radiation-sensor";
11094
- /** Soil moisture % (garden/weather `soil-moisture-sensor` cap). */
11095
- DeviceRole["SoilMoistureSensor"] = "soil-moisture-sensor";
11096
- DeviceRole["PowerSensor"] = "power-sensor";
11097
- DeviceRole["EnergySensor"] = "energy-sensor";
11098
- DeviceRole["VoltageSensor"] = "voltage-sensor";
11099
- DeviceRole["CurrentSensor"] = "current-sensor";
11100
- DeviceRole["AirQualitySensor"] = "air-quality-sensor";
11101
- /** Battery level (numeric % via `sensor` OR low-bool via
11102
- * `binary_sensor` — the cap distinguishes via the value type). */
11103
- DeviceRole["BatterySensor"] = "battery-sensor";
11104
- /** Fallback for `sensor` numeric without a known `device_class`. */
11105
- DeviceRole["NumericSensor"] = "numeric-sensor";
11106
- /** String / enum state (HA `sensor` with `state_class: enum` or
11107
- * `attributes.options`). */
11108
- DeviceRole["EnumSensor"] = "enum-sensor";
11109
- /** Date / timestamp state (HA `sensor` with `device_class: timestamp`
11110
- * or `date`). The slice carries the raw ISO string verbatim (hosted on
11111
- * the `enum-sensor` cap); the UI renders it locale-formatted. */
11112
- DeviceRole["DateTimeSensor"] = "datetime-sensor";
11113
- /** Last-resort fallback when nothing else matches. */
11114
- DeviceRole["GenericSensor"] = "generic-sensor";
11115
- DeviceRole["NumericControl"] = "numeric-control";
11116
- DeviceRole["SelectControl"] = "select-control";
11117
- DeviceRole["TextControl"] = "text-control";
11118
- DeviceRole["DateTimeControl"] = "datetime-control";
11119
- /** Mobile push notifier (HA `notify.mobile_app_*`) — supports
11120
- * rich features (image, priority, channel routing). */
11121
- DeviceRole["MobilePushNotifier"] = "mobile-push-notifier";
11122
- /** Chat / messaging service (HA `notify.telegram_*`,
11123
- * `notify.discord_*`, etc.). */
11124
- DeviceRole["MessagingNotifier"] = "messaging-notifier";
11125
- /** Email-based delivery (HA `notify.smtp`, etc.). */
11126
- DeviceRole["EmailNotifier"] = "email-notifier";
11127
- /** Fallback when the notifier service name doesn't match a known
11128
- * pattern. */
11129
- DeviceRole["GenericNotifier"] = "generic-notifier";
11130
- /** Emits a pulse train (infrared or RF) on request — the `ir-transmitter`
11131
- * cap. A `DeviceType.Generic` device. */
11132
- DeviceRole["IrTransmitter"] = "ir-transmitter";
11133
- return DeviceRole;
11134
- }({});
11135
- /**
11136
- import { errMsg } from '@camstack/types'
11137
- * Extract a human-readable message from an unknown error value.
11138
- * Replaces the ubiquitous `errMsg(err)` pattern.
11139
- */
11140
- function errMsg$17(err) {
11141
- if (err instanceof Error) return err.message;
11142
- if (typeof err === "string") return err;
11143
- return String(err);
11144
- }
11145
- //#endregion
11146
- //#region ../types/dist/composition-C7WdThmP.mjs
11297
+ //#region ../types/dist/composition-BBzVf2xd.mjs
11147
11298
  var AUDIO_ENCODER_BY_CODEC = {
11148
11299
  opus: "libopus",
11149
11300
  aac: "aac",
@@ -12956,6 +13107,90 @@ var EventOwnerTypeSchema = _enum(EVENT_OWNER_TYPES);
12956
13107
  /** The same list as a Zod enum, for the cap input that carries it. */
12957
13108
  var MediaPresenceOwnerKindSchema = _enum([...EVENT_OWNER_TYPES, "track"]);
12958
13109
  new Set(EVENT_OWNER_TYPES);
13110
+ /**
13111
+ * What a published package needs from the rest of the install (D989).
13112
+ *
13113
+ * One published framework package (`@camstack/server`) carries the kernel, the
13114
+ * builtins and the capability contracts, so "which addon runs on which
13115
+ * framework" is a question of version, and the answer is DECLARED by the
13116
+ * package that knows it:
13117
+ *
13118
+ * - an addon says the oldest server it runs on (`requires.server: ">=X"`);
13119
+ * - the server says the oldest addon it works with
13120
+ * (`requires.addons: { "@camstack/addon-x": ">=Y" }`) and the oldest shell
13121
+ * around it (`requires.wrapper: { desktop, image }`);
13122
+ * - a wrapper (the desktop app, the container starter) says which server
13123
+ * range it can host, and reports its own kind and version.
13124
+ *
13125
+ * The publish workflow STAMPS these after the version bump
13126
+ * (`scripts/ci/stamp-requires.mjs`); nobody types a number by hand.
13127
+ *
13128
+ * A requirement that cannot be checked is NOT met: a shell that reports no
13129
+ * version counts as below the minimum, and an unreadable running version is
13130
+ * named in the result (a failed read is never a pass).
13131
+ */
13132
+ /** `>=MAJOR.MINOR.PATCH[-prerelease]` — the only range shape a requirement uses. */
13133
+ var MinVersionSchema = string().regex(/^>=\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$/, "a minimum is written \">=X.Y.Z\"");
13134
+ object({
13135
+ /** The oldest `@camstack/server` this package runs on. */
13136
+ server: MinVersionSchema.optional(),
13137
+ /** The oldest installed version of each named addon package. */
13138
+ addons: record(string(), MinVersionSchema).optional(),
13139
+ /** The oldest shell around the server, per shell kind. */
13140
+ wrapper: object({
13141
+ desktop: MinVersionSchema.optional(),
13142
+ image: MinVersionSchema.optional()
13143
+ }).optional()
13144
+ });
13145
+ /** One unmet requirement; each names the versions on both sides. */
13146
+ var UnmetRequirementSchema = discriminatedUnion("kind", [
13147
+ object({
13148
+ kind: literal("server-too-old"),
13149
+ required: string(),
13150
+ /** `null` — the running server version could not be read. */
13151
+ running: string().nullable()
13152
+ }),
13153
+ object({
13154
+ kind: literal("addon-too-old"),
13155
+ packageName: string(),
13156
+ required: string(),
13157
+ /** `null` — the addon is not installed (or its version is unreadable). */
13158
+ running: string().nullable()
13159
+ }),
13160
+ object({
13161
+ kind: literal("wrapper-too-old"),
13162
+ wrapper: _enum(["desktop", "image"]),
13163
+ required: string(),
13164
+ /** `null` — the wrapper reported no version. */
13165
+ running: string().nullable()
13166
+ })
13167
+ ]);
13168
+ var RequiredAddonUpdateSchema = object({
13169
+ packageName: string(),
13170
+ /** The minimum the target server declares. */
13171
+ required: string(),
13172
+ /** What this node has; `null` when the addon is not installed. */
13173
+ installed: string().nullable()
13174
+ });
13175
+ /**
13176
+ * Which integration instance a settings form is for. An addon that serves several instances
13177
+ * (`instanceMode: multiple`) can show a different form per instance — an NVR integration
13178
+ * needs its connection, the default integration needs the addon's own sections.
13179
+ *
13180
+ * - `integrationId` is `null` in the create wizard: nothing exists yet, the operator is
13181
+ * setting up a NEW instance.
13182
+ * - `mode` is the wizard mode of the integration type (`getAvailableTypes`).
13183
+ * - `candidateStableId` is the discovery candidate a wizard was seeded from, if any.
13184
+ */
13185
+ var IntegrationInstanceRefSchema = object({
13186
+ integrationId: string().nullable(),
13187
+ mode: _enum([
13188
+ "standalone",
13189
+ "account",
13190
+ "broker"
13191
+ ]),
13192
+ candidateStableId: string().optional()
13193
+ });
12959
13194
  var EncodeProfileSchema = object({
12960
13195
  video: object({
12961
13196
  codec: _enum([
@@ -13482,6 +13717,613 @@ var CameraSwitchGroupSchema = object({
13482
13717
  fetchedAt: number()
13483
13718
  });
13484
13719
  /**
13720
+ * Query filter for settings-store collections.
13721
+ */
13722
+ var QueryFilterSchema = object({
13723
+ where: record(string(), unknown()).optional(),
13724
+ whereIn: record(string(), array(unknown())).optional(),
13725
+ whereBetween: record(string(), tuple([unknown(), unknown()])).optional(),
13726
+ /** NULL-safe exclusion: matches rows whose field is NULL OR != the value. */
13727
+ whereNot: record(string(), unknown()).optional(),
13728
+ /** NULL-safe exclusion of a SET — `whereNot` for more than one value. An
13729
+ * empty list excludes nothing. See `QueryFilter.whereNotIn`. */
13730
+ whereNotIn: record(string(), array(unknown())).optional(),
13731
+ orderBy: object({
13732
+ field: string(),
13733
+ direction: _enum(["asc", "desc"])
13734
+ }).optional(),
13735
+ limit: number().optional(),
13736
+ offset: number().optional()
13737
+ });
13738
+ /**
13739
+ * The predicate half of a filter, for BULK MUTATIONS.
13740
+ *
13741
+ * Deliberately not `QueryFilterSchema`: `orderBy` / `limit` / `offset` have no
13742
+ * meaning for a statement that rewrites a set, and accepting them would invite
13743
+ * a caller to believe `limit` bounds the damage. Every field is optional here
13744
+ * only so the shape stays composable — the implementation REJECTS a filter
13745
+ * that compiles to no predicate, because that is the whole collection.
13746
+ */
13747
+ var MutationFilterSchema = object({
13748
+ where: record(string(), unknown()).optional(),
13749
+ whereIn: record(string(), array(unknown())).optional(),
13750
+ whereBetween: record(string(), tuple([unknown(), unknown()])).optional(),
13751
+ whereNot: record(string(), unknown()).optional(),
13752
+ whereNotIn: record(string(), array(unknown())).optional()
13753
+ });
13754
+ /**
13755
+ * One scalar an {@link settingsStoreCapability.methods.aggregate} call asks for.
13756
+ *
13757
+ * `as` names the slot in the result, so the SAME column may be asked twice with
13758
+ * two operations (`MIN(startMs)` and `MAX(startMs)` in one round trip) — which
13759
+ * a `Record<column, op>` shape could not express.
13760
+ */
13761
+ var AggregateFieldSchema = object({
13762
+ /** Result key. */
13763
+ as: string().min(1),
13764
+ /** Column to aggregate. Must be a real column of a declared collection. */
13765
+ field: string().min(1),
13766
+ op: _enum([
13767
+ "sum",
13768
+ "min",
13769
+ "max"
13770
+ ])
13771
+ });
13772
+ /**
13773
+ * `COUNT(*)` plus one number per requested field.
13774
+ *
13775
+ * `null` means NO ROW MATCHED, never zero: a `SUM` over an empty set and a sum
13776
+ * that really is 0 are different facts, and an accounting caller that renders
13777
+ * "0 bytes, oldest = 0" for "nothing here" reports a lie about a disk.
13778
+ */
13779
+ var AggregateResultSchema = object({
13780
+ count: number().int(),
13781
+ values: record(string(), number().nullable())
13782
+ });
13783
+ /** A single stored record: `{ id, data }`. */
13784
+ var SettingsRecordSchema = object({
13785
+ id: string(),
13786
+ data: record(string(), unknown())
13787
+ });
13788
+ /**
13789
+ * One record of a BULK insert — {@link SettingsRecordSchema} with the id made
13790
+ * optional.
13791
+ *
13792
+ * A separate schema rather than loosening the shared one: every other method
13793
+ * on this cap addresses a row BY its id, and making that field optional
13794
+ * everywhere would turn a forgotten key into a silently generated one on
13795
+ * `update` and `delete` as well.
13796
+ */
13797
+ var BulkRecordSchema = object({
13798
+ id: string().optional(),
13799
+ data: record(string(), unknown())
13800
+ });
13801
+ /**
13802
+ * The database FILES one `sqlite-settings` engine process owns (D851).
13803
+ * Closed on purpose: a file is a thing the engine opens, backs up and gives a
13804
+ * serving thread, so a new one is a code change, never a string a caller
13805
+ * invents. `settings` is `camstack.db` and the default for every collection
13806
+ * that names no file.
13807
+ */
13808
+ var DataStoreDatabaseSchema = _enum([
13809
+ "settings",
13810
+ "events",
13811
+ "history"
13812
+ ]);
13813
+ DataStoreDatabaseSchema.options;
13814
+ /**
13815
+ * One write inside a {@link settingsStoreCapability.methods.transact} call.
13816
+ * The three that a "replace this set, bump that revision" write needs, plus
13817
+ * the batched upsert a rollup writer needs.
13818
+ */
13819
+ var TransactOpSchema = discriminatedUnion("op", [
13820
+ object({
13821
+ op: literal("deleteWhere"),
13822
+ collection: string(),
13823
+ filter: MutationFilterSchema
13824
+ }),
13825
+ object({
13826
+ op: literal("insertMany"),
13827
+ collection: string(),
13828
+ records: array(BulkRecordSchema).readonly()
13829
+ }),
13830
+ object({
13831
+ op: literal("update"),
13832
+ collection: string(),
13833
+ id: string(),
13834
+ data: record(string(), unknown())
13835
+ }),
13836
+ object({
13837
+ op: literal("upsertMany"),
13838
+ collection: string(),
13839
+ conflict: array(string()).readonly(),
13840
+ records: array(BulkRecordSchema).readonly()
13841
+ })
13842
+ ]);
13843
+ /**
13844
+ * The precondition of a transaction: the row `key` of `collection` must hold
13845
+ * `equals` in `column`, read INSIDE the transaction.
13846
+ */
13847
+ var TransactGuardSchema = object({
13848
+ collection: string(),
13849
+ key: string(),
13850
+ column: string(),
13851
+ equals: unknown()
13852
+ });
13853
+ /**
13854
+ * Column declaration for a structured (SQL-backed) collection.
13855
+ *
13856
+ * Logical types — the backend translates each to the matching SQLite
13857
+ * storage class and handles per-type marshaling:
13858
+ * - `TEXT` / `INTEGER` / `REAL` — native SQLite types, pass-through
13859
+ * - `JSON` — TEXT under the hood; serialised on write, parsed on read
13860
+ * - `BOOLEAN` — INTEGER 0/1 under the hood; coerced both directions
13861
+ */
13862
+ var CollectionColumnSchema = object({
13863
+ name: string(),
13864
+ type: _enum([
13865
+ "TEXT",
13866
+ "INTEGER",
13867
+ "REAL",
13868
+ "JSON",
13869
+ "BOOLEAN"
13870
+ ]),
13871
+ primaryKey: boolean().optional(),
13872
+ notNull: boolean().optional(),
13873
+ unique: boolean().optional(),
13874
+ /**
13875
+ * Column DEFAULT. Required for B2: the four `ensureTable` consumers declare
13876
+ * columns like `enabled INTEGER NOT NULL DEFAULT 1`, and without this the
13877
+ * collection surface simply cannot express their existing tables — which is
13878
+ * why they were still on the uncapped `table*` API.
13879
+ */
13880
+ defaultValue: union([
13881
+ string(),
13882
+ number(),
13883
+ boolean()
13884
+ ]).optional()
13885
+ });
13886
+ var CollectionIndexSchema = object({
13887
+ name: string(),
13888
+ columns: array(string()).readonly(),
13889
+ unique: boolean().optional()
13890
+ });
13891
+ /**
13892
+ * The input of `declareCollection` — ONE schema for the door and for the
13893
+ * engine behind it, so the two surfaces cannot drift (the dispatcher forwards
13894
+ * the payload untouched).
13895
+ *
13896
+ * - `database` — the file the collection lives in (D851). Absent means
13897
+ * `settings`. A declaration naming a file other than the one the table is
13898
+ * already in is REFUSED by the engine, never moved.
13899
+ * - `primaryKey` — a COMPOSITE key, as column names. A single name is the same
13900
+ * as `primaryKey: true` on that column. A composite-keyed collection has no
13901
+ * `id`: it is written with `insertMany` / `upsertMany` / `transact` and read
13902
+ * with `query` / `count` / `aggregate` / `deleteWhere`; the calls that
13903
+ * address one row by id are refused.
13904
+ * - `withoutRowid` — emit `WITHOUT ROWID`. Requires a primary key.
13905
+ */
13906
+ var DeclareCollectionInputSchema = object({
13907
+ namespace: string().optional(),
13908
+ collection: string(),
13909
+ columns: array(CollectionColumnSchema).readonly(),
13910
+ indexes: array(CollectionIndexSchema).readonly().optional(),
13911
+ database: DataStoreDatabaseSchema.optional(),
13912
+ primaryKey: array(string()).readonly().optional(),
13913
+ withoutRowid: boolean().optional()
13914
+ });
13915
+ method(object({
13916
+ namespace: string().optional(),
13917
+ collection: string(),
13918
+ key: string()
13919
+ }), unknown(), { auth: "admin" }), method(object({
13920
+ namespace: string().optional(),
13921
+ collection: string(),
13922
+ key: string(),
13923
+ value: unknown()
13924
+ }), _void(), {
13925
+ kind: "mutation",
13926
+ auth: "admin"
13927
+ }), method(object({
13928
+ namespace: string().optional(),
13929
+ collection: string(),
13930
+ filter: QueryFilterSchema.optional(),
13931
+ columns: array(string()).readonly().optional()
13932
+ }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
13933
+ namespace: string().optional(),
13934
+ collection: string(),
13935
+ /** Declared columns identifying the slot; must be covered by a UNIQUE
13936
+ * index on the collection. Never empty. */
13937
+ conflict: array(string()).readonly(),
13938
+ record: BulkRecordSchema
13939
+ }), object({
13940
+ /** The id the row HAS: assigned by SQLite on an insert, or the existing
13941
+ * row's own id on an update. */
13942
+ id: union([string(), number()]) }), {
13943
+ kind: "mutation",
13944
+ auth: "admin"
13945
+ }), method(object({
13946
+ namespace: string().optional(),
13947
+ collection: string(),
13948
+ conflict: array(string()).readonly(),
13949
+ records: array(BulkRecordSchema).readonly()
13950
+ }), object({ upserted: number().int() }), {
13951
+ kind: "mutation",
13952
+ auth: "admin"
13953
+ }), method(object({
13954
+ namespace: string().optional(),
13955
+ collection: string(),
13956
+ record: object({
13957
+ id: string().optional(),
13958
+ data: record(string(), unknown())
13959
+ })
13960
+ }), object({
13961
+ /**
13962
+ * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
13963
+ * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
13964
+ * primary key — which is the only place an auto key is knowable.
13965
+ */
13966
+ id: union([string(), number()]) }), {
13967
+ kind: "mutation",
13968
+ auth: "admin"
13969
+ }), method(object({
13970
+ namespace: string().optional(),
13971
+ collection: string(),
13972
+ records: array(BulkRecordSchema).readonly()
13973
+ }), object({ inserted: number().int() }), {
13974
+ kind: "mutation",
13975
+ auth: "admin"
13976
+ }), method(object({
13977
+ namespace: string().optional(),
13978
+ guard: TransactGuardSchema.optional(),
13979
+ ops: array(TransactOpSchema).readonly()
13980
+ }), object({
13981
+ applied: boolean(),
13982
+ current: unknown().optional()
13983
+ }), {
13984
+ kind: "mutation",
13985
+ auth: "admin"
13986
+ }), method(object({
13987
+ namespace: string().optional(),
13988
+ collection: string(),
13989
+ id: string(),
13990
+ data: record(string(), unknown())
13991
+ }), _void(), {
13992
+ kind: "mutation",
13993
+ auth: "admin"
13994
+ }), method(object({
13995
+ namespace: string().optional(),
13996
+ collection: string(),
13997
+ key: string()
13998
+ }), _void(), {
13999
+ kind: "mutation",
14000
+ auth: "admin"
14001
+ }), method(object({
14002
+ namespace: string().optional(),
14003
+ collection: string(),
14004
+ filter: MutationFilterSchema
14005
+ }), object({ deleted: number().int() }), {
14006
+ kind: "mutation",
14007
+ auth: "admin"
14008
+ }), method(object({
14009
+ namespace: string().optional(),
14010
+ collection: string(),
14011
+ filter: MutationFilterSchema,
14012
+ data: record(string(), unknown())
14013
+ }), object({ updated: number().int() }), {
14014
+ kind: "mutation",
14015
+ auth: "admin"
14016
+ }), method(object({
14017
+ namespace: string().optional(),
14018
+ collection: string(),
14019
+ filter: QueryFilterSchema.optional()
14020
+ }), number(), { auth: "admin" }), method(object({
14021
+ namespace: string().optional(),
14022
+ collection: string(),
14023
+ fields: array(AggregateFieldSchema).readonly(),
14024
+ filter: QueryFilterSchema.optional()
14025
+ }), AggregateResultSchema, { auth: "admin" }), method(object({
14026
+ namespace: string().optional(),
14027
+ collection: string(),
14028
+ field: string(),
14029
+ bucketSize: number().int().positive(),
14030
+ origin: number().int(),
14031
+ filter: QueryFilterSchema.optional()
14032
+ }), array(object({
14033
+ bucket: number().int(),
14034
+ count: number().int()
14035
+ })).readonly(), { auth: "admin" }), method(object({
14036
+ namespace: string().optional(),
14037
+ collection: string()
14038
+ }), boolean(), { auth: "admin" }), method(DeclareCollectionInputSchema, _void(), {
14039
+ kind: "mutation",
14040
+ auth: "admin"
14041
+ });
14042
+ 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>\"");
14043
+ var MigrationLevelSchema = _enum([
14044
+ "hub-store",
14045
+ "addon-state",
14046
+ "node-config",
14047
+ "viewer",
14048
+ "addon-internal"
14049
+ ]);
14050
+ var MigrationStoreSchema = _enum([
14051
+ "settings",
14052
+ "events",
14053
+ "history",
14054
+ "node-local",
14055
+ "addon-files"
14056
+ ]);
14057
+ var MigrationScopeSchema = _enum(["cluster", "per-node"]);
14058
+ /** What depends on a migration while it is pending: `block-owner` is the default. */
14059
+ var MigrationOnFailureSchema = _enum(["block-owner", "tolerate"]);
14060
+ /**
14061
+ * `sql` is a hub-only body over the owner's connection. `plan` returns edits the
14062
+ * engine applies inside the migration's own transaction (hub-owned: computed in
14063
+ * that transaction; addon-owned: computed by the owner and shipped to the engine).
14064
+ * `procedure` is addon-owned work that is not SQL (keychain, integration registry,
14065
+ * device tombstones); the ledger records its outcome and it must be idempotent.
14066
+ */
14067
+ var MigrationBodyKindSchema = _enum([
14068
+ "sql",
14069
+ "plan",
14070
+ "procedure"
14071
+ ]);
14072
+ var MigrationMetaSchema = object({
14073
+ id: MigrationIdSchema,
14074
+ /** `hub`, an addon id, `node` or `viewer`. */
14075
+ owner: string().regex(/^[a-z0-9-]+$/),
14076
+ level: MigrationLevelSchema,
14077
+ /** Strictly increasing per owner: the order within an owner. */
14078
+ seq: number().int().positive(),
14079
+ /** Ids of any owner: the order across owners. */
14080
+ dependsOn: array(MigrationIdSchema),
14081
+ store: MigrationStoreSchema,
14082
+ scope: MigrationScopeSchema,
14083
+ onFailure: MigrationOnFailureSchema,
14084
+ bodyKind: MigrationBodyKindSchema,
14085
+ description: string().min(1),
14086
+ /** The marked field the migration's spec must assert survived. */
14087
+ fixtureMark: string().min(1)
14088
+ }).refine((m) => m.id.startsWith(`${m.owner}/`), {
14089
+ message: "the id must start with \"<owner>/\"",
14090
+ path: ["id"]
14091
+ });
14092
+ /** A cycle in the dependency graph, named by the ids on it. */
14093
+ var MigrationCycleError = class extends Error {
14094
+ ids;
14095
+ constructor(ids) {
14096
+ super(`migration dependsOn cycle: ${ids.join(" -> ")}`);
14097
+ this.ids = ids;
14098
+ this.name = "MigrationCycleError";
14099
+ }
14100
+ };
14101
+ /**
14102
+ * Topological order over `dependsOn` plus the implicit edge "a lower `seq` of an
14103
+ * owner runs first". Ties are broken by `(owner, seq)`. Throws
14104
+ * {@link MigrationCycleError} on a cycle. A `dependsOn` id that is not in the list
14105
+ * is ignored here — the catalogue schema is what refuses it.
14106
+ */
14107
+ function orderMigrations(items) {
14108
+ const byId = new Map(items.map((item) => [item.id, item]));
14109
+ const deps = /* @__PURE__ */ new Map();
14110
+ const ownerSorted = /* @__PURE__ */ new Map();
14111
+ for (const item of items) {
14112
+ const list = ownerSorted.get(item.owner) ?? [];
14113
+ list.push(item);
14114
+ ownerSorted.set(item.owner, list);
14115
+ }
14116
+ for (const item of items) deps.set(item.id, new Set(item.dependsOn.filter((id) => byId.has(id))));
14117
+ for (const list of ownerSorted.values()) {
14118
+ list.sort((a, b) => a.seq - b.seq);
14119
+ for (let i = 1; i < list.length; i++) {
14120
+ const previous = list[i - 1];
14121
+ const current = list[i];
14122
+ if (previous !== void 0 && current !== void 0) deps.get(current.id)?.add(previous.id);
14123
+ }
14124
+ }
14125
+ const tie = (a, b) => a.owner < b.owner ? -1 : a.owner > b.owner ? 1 : a.seq - b.seq;
14126
+ const done = /* @__PURE__ */ new Set();
14127
+ const ordered = [];
14128
+ let remaining = [...items];
14129
+ while (remaining.length > 0) {
14130
+ const ready = remaining.filter((item) => [...deps.get(item.id) ?? []].every((dep) => done.has(dep)));
14131
+ if (ready.length === 0) throw new MigrationCycleError(remaining.map((item) => item.id).sort());
14132
+ ready.sort(tie);
14133
+ const next = ready[0];
14134
+ if (next === void 0) break;
14135
+ ordered.push(next);
14136
+ done.add(next.id);
14137
+ remaining = remaining.filter((item) => item.id !== next.id);
14138
+ }
14139
+ return ordered;
14140
+ }
14141
+ /** Every way a list of migrations (in declaration order) is not a catalogue. */
14142
+ function catalogueIssues(items) {
14143
+ const issues = [];
14144
+ const seen = /* @__PURE__ */ new Set();
14145
+ const known = new Set(items.map((item) => item.id));
14146
+ const lastSeq = /* @__PURE__ */ new Map();
14147
+ const seqUsed = /* @__PURE__ */ new Map();
14148
+ for (const item of items) {
14149
+ if (seen.has(item.id)) issues.push({
14150
+ code: "duplicate-id",
14151
+ ids: [item.id],
14152
+ message: `duplicate id ${item.id}`
14153
+ });
14154
+ seen.add(item.id);
14155
+ const used = seqUsed.get(item.owner) ?? /* @__PURE__ */ new Set();
14156
+ if (used.has(item.seq)) issues.push({
14157
+ code: "duplicate-seq",
14158
+ ids: [item.id],
14159
+ message: `owner ${item.owner} has two migrations with seq ${item.seq}`
14160
+ });
14161
+ else if (item.seq < (lastSeq.get(item.owner) ?? 0)) issues.push({
14162
+ code: "seq-order",
14163
+ ids: [item.id],
14164
+ message: `seq ${item.seq} of ${item.id} does not increase in declaration order (owner ${item.owner})`
14165
+ });
14166
+ used.add(item.seq);
14167
+ seqUsed.set(item.owner, used);
14168
+ lastSeq.set(item.owner, Math.max(item.seq, lastSeq.get(item.owner) ?? 0));
14169
+ for (const dep of item.dependsOn) if (!known.has(dep)) issues.push({
14170
+ code: "unknown-dependency",
14171
+ ids: [item.id, dep],
14172
+ message: `${item.id} dependsOn unknown id ${dep}`
14173
+ });
14174
+ }
14175
+ try {
14176
+ orderMigrations(items);
14177
+ } catch (err) {
14178
+ if (err instanceof MigrationCycleError) issues.push({
14179
+ code: "cycle",
14180
+ ids: err.ids,
14181
+ message: err.message
14182
+ });
14183
+ else throw err;
14184
+ }
14185
+ return issues;
14186
+ }
14187
+ array(MigrationMetaSchema).superRefine((items, ctx) => {
14188
+ for (const issue of catalogueIssues(items)) ctx.addIssue({
14189
+ code: "custom",
14190
+ message: `${issue.code}: ${issue.message}`
14191
+ });
14192
+ });
14193
+ /**
14194
+ * The canonical JSON (`preconditionOf`) of the value a plan read; the apply step
14195
+ * re-reads, and a plan whose read no longer matches is refused (the migration is
14196
+ * `failed`, nothing it edited is kept).
14197
+ */
14198
+ var PreconditionSchema = string().min(1).optional();
14199
+ var MigrationPlanSchema = object({ edits: array(discriminatedUnion("op", [
14200
+ object({
14201
+ op: literal("setKeys"),
14202
+ scope: string().min(1),
14203
+ values: record(string(), unknown()),
14204
+ precondition: PreconditionSchema
14205
+ }),
14206
+ object({
14207
+ op: literal("deleteKeys"),
14208
+ scope: string().min(1),
14209
+ keys: array(string().min(1)).min(1),
14210
+ precondition: PreconditionSchema
14211
+ }),
14212
+ object({
14213
+ op: literal("putRow"),
14214
+ table: string().min(1),
14215
+ key: record(string(), unknown()),
14216
+ row: record(string(), unknown()),
14217
+ precondition: PreconditionSchema
14218
+ }),
14219
+ object({
14220
+ op: literal("deleteRow"),
14221
+ table: string().min(1),
14222
+ key: record(string(), unknown()),
14223
+ precondition: PreconditionSchema
14224
+ }),
14225
+ object({
14226
+ op: literal("upsertRecord"),
14227
+ kind: string().min(1),
14228
+ recordKey: string().min(1),
14229
+ value: unknown(),
14230
+ precondition: PreconditionSchema
14231
+ }),
14232
+ object({
14233
+ op: literal("deleteRecord"),
14234
+ kind: string().min(1),
14235
+ recordKey: string().min(1),
14236
+ precondition: PreconditionSchema
14237
+ })
14238
+ ])) });
14239
+ /**
14240
+ * What a `procedure` body reports. `already-done` means the rerun observed the
14241
+ * work finished (a crash between the work and the ledger row, or a manual fix)
14242
+ * and did none of it again; the ledger records `applied` either way.
14243
+ */
14244
+ var MigrationProcedureResultSchema = object({
14245
+ outcome: _enum(["done", "already-done"]),
14246
+ summary: record(string(), unknown())
14247
+ });
14248
+ /** What an owner hands the engine when one of its migrations ran. */
14249
+ var MigrationOwnerResultSchema = discriminatedUnion("kind", [
14250
+ object({
14251
+ kind: literal("plan"),
14252
+ plan: MigrationPlanSchema
14253
+ }),
14254
+ object({
14255
+ kind: literal("procedure"),
14256
+ result: MigrationProcedureResultSchema
14257
+ }),
14258
+ object({
14259
+ kind: literal("failed"),
14260
+ error: string().min(1)
14261
+ })
14262
+ ]);
14263
+ /**
14264
+ * `held`: a restore of a pre-migration snapshot undid this id; it does not rerun
14265
+ * until the operator retries or a new code version ships.
14266
+ * `skipped-newer`: the database knows an id this code does not.
14267
+ */
14268
+ var MigrationStatusSchema = _enum([
14269
+ "applied",
14270
+ "failed",
14271
+ "blocked",
14272
+ "running",
14273
+ "held",
14274
+ "skipped-newer"
14275
+ ]);
14276
+ var MigrationLedgerEntrySchema = object({
14277
+ id: string(),
14278
+ database: DataStoreDatabaseSchema,
14279
+ owner: string(),
14280
+ level: MigrationLevelSchema,
14281
+ seq: number().int().nonnegative(),
14282
+ status: MigrationStatusSchema,
14283
+ attempts: number().int().nonnegative(),
14284
+ appliedAt: number().nullable(),
14285
+ codeVersion: string().nullable(),
14286
+ /** What the apply changed: rows per table, as the engine counted them. */
14287
+ planSummary: record(string(), unknown()).nullable(),
14288
+ progress: record(string(), unknown()).nullable(),
14289
+ error: string().nullable(),
14290
+ /** Why it is `blocked` or `held` (`dependency-failed`, `snapshot-refused`, …). */
14291
+ reason: string().nullable(),
14292
+ nodeId: string().nullable(),
14293
+ bootId: string().nullable()
14294
+ });
14295
+ /** A catalogued migration that is not applied, with where it stands. */
14296
+ var MigrationPendingEntrySchema = object({
14297
+ meta: MigrationMetaSchema,
14298
+ database: DataStoreDatabaseSchema,
14299
+ state: _enum([
14300
+ "pending",
14301
+ "failed",
14302
+ "blocked",
14303
+ "held"
14304
+ ]),
14305
+ reason: string().nullable()
14306
+ });
14307
+ /** Rows per table before and after a dry run, and what it would have changed. */
14308
+ var MigrationDryRunResultSchema = object({
14309
+ id: string(),
14310
+ ok: boolean(),
14311
+ error: string().nullable(),
14312
+ rowsChanged: number().int().nonnegative(),
14313
+ tables: array(object({
14314
+ table: string(),
14315
+ before: number().int().nonnegative(),
14316
+ after: number().int().nonnegative()
14317
+ }))
14318
+ });
14319
+ /** One of an owner's migrations, as the engine tells the owner to treat it this boot. */
14320
+ var MigrationOwnerStepSchema = object({
14321
+ id: MigrationIdSchema,
14322
+ action: _enum(["run", "skip"]),
14323
+ /** The ledger state the engine found: `pending` has no row yet. */
14324
+ state: union([literal("pending"), MigrationStatusSchema])
14325
+ });
14326
+ /**
13485
14327
  * The trainer contract — what the hub hands the cloud trainer and what it
13486
14328
  * gets back (cloud training, D805+).
13487
14329
  *
@@ -17038,6 +17880,41 @@ var ACTUATOR_CAP_VOCABULARY = {
17038
17880
  icon: "droplets"
17039
17881
  }]
17040
17882
  },
17883
+ "power-source": {
17884
+ scope: "device",
17885
+ noun: t("Power source", "Alimentazione"),
17886
+ actions: [
17887
+ {
17888
+ id: "powerSource.on",
17889
+ method: "powerOn",
17890
+ label: t("Power on", "Dai corrente"),
17891
+ phrase: t("Power on {device}", "Dai corrente a {device}"),
17892
+ icon: "power"
17893
+ },
17894
+ {
17895
+ id: "powerSource.off",
17896
+ method: "powerOff",
17897
+ label: t("Power off", "Togli corrente"),
17898
+ phrase: t("Cut the power of {device}", "Togli la corrente a {device}"),
17899
+ icon: "power-off"
17900
+ },
17901
+ {
17902
+ id: "powerSource.forceRestart",
17903
+ method: "forceRestart",
17904
+ label: t("Force restart", "Riavvio forzato"),
17905
+ phrase: t("Force restart {device} by cutting its power", "Riavvia {device} togliendo la corrente"),
17906
+ icon: "refresh-cw"
17907
+ }
17908
+ ],
17909
+ state: [{
17910
+ kind: "boolean",
17911
+ field: "switchOn",
17912
+ label: t("Power switch on", "Presa accesa"),
17913
+ whenTrue: t("When the power of {device} comes on", "Quando arriva la corrente a {device}"),
17914
+ whenFalse: t("When the power of {device} is cut", "Quando manca la corrente a {device}"),
17915
+ icon: "power"
17916
+ }]
17917
+ },
17041
17918
  "lock-control": {
17042
17919
  scope: "device",
17043
17920
  noun: t("Lock", "Serratura"),
@@ -17513,7 +18390,7 @@ var ACTUATOR_CAP_VOCABULARY = {
17513
18390
  method: "setDirection",
17514
18391
  label: t("Spin forward", "Rotazione avanti"),
17515
18392
  phrase: t("Spin {device} forward", "Fai girare {device} in avanti"),
17516
- icon: "rotate-cw",
18393
+ icon: "refresh-cw",
17517
18394
  effect: {
17518
18395
  field: "direction",
17519
18396
  value: "forward"
@@ -20591,6 +21468,7 @@ var SYSTEM_CAP_VOCABULARY = {
20591
21468
  "login-method": system(IDENTITY),
20592
21469
  "mesh-network": system(NETWORK),
20593
21470
  "metrics-provider": system(CLUSTER),
21471
+ migrations: system(INTERNAL),
20594
21472
  "model-convert": system(ML),
20595
21473
  "model-distributor": system(ML),
20596
21474
  "mqtt-broker": system(NETWORK),
@@ -42957,7 +43835,7 @@ function pruneDeletedEntities(selection, live, log, exporter) {
42957
43835
  * rebuilds without manual reload.
42958
43836
  *
42959
43837
  * The hub-local builtin `addon-pages-aggregator` (see
42960
- * `@camstack/system/builtins/addon-pages-aggregator`) registers the
43838
+ * `@camstack/server/system/builtins/addon-pages-aggregator`) registers the
42961
43839
  * provider. Splitting the public aggregator from the raw collection
42962
43840
  * keeps both ends in codegen — there's no hand-written
42963
43841
  * `addon-pages.router.ts` wrapper anymore.
@@ -43083,6 +43961,10 @@ method(object({
43083
43961
  }), method(object({
43084
43962
  addonId: string(),
43085
43963
  nodeId: string().optional()
43964
+ }), SettingsSchemaWithValuesSchema.nullable()), method(object({
43965
+ addonId: string(),
43966
+ nodeId: string().optional(),
43967
+ instance: IntegrationInstanceRefSchema
43086
43968
  }), SettingsSchemaWithValuesSchema.nullable()), method(object({
43087
43969
  addonId: string(),
43088
43970
  nodeId: string().optional()
@@ -43253,7 +44135,7 @@ method(_void(), array(WidgetMetadataSchema).readonly(), { auth: "admin" });
43253
44135
  * manual reload — same scheme used by `addon-pages`.
43254
44136
  *
43255
44137
  * The hub-local builtin `addon-widgets-aggregator` (see
43256
- * `@camstack/system/builtins/addon-widgets-aggregator`) registers the
44138
+ * `@camstack/server/system/builtins/addon-widgets-aggregator`) registers the
43257
44139
  * provider. Splitting the public aggregator from the raw collection
43258
44140
  * keeps both ends in codegen — there's no hand-written wrapper.
43259
44141
  */
@@ -43614,329 +44496,6 @@ method(object({
43614
44496
  password: string()
43615
44497
  }), AuthResultSchema.nullable(), { kind: "mutation" }), method(object({ state: string() }), string()), method(record(string(), string()), AuthResultSchema, { kind: "mutation" }), method(object({ token: string() }), AuthResultSchema.nullable());
43616
44498
  /**
43617
- * Query filter for settings-store collections.
43618
- */
43619
- var QueryFilterSchema = object({
43620
- where: record(string(), unknown()).optional(),
43621
- whereIn: record(string(), array(unknown())).optional(),
43622
- whereBetween: record(string(), tuple([unknown(), unknown()])).optional(),
43623
- /** NULL-safe exclusion: matches rows whose field is NULL OR != the value. */
43624
- whereNot: record(string(), unknown()).optional(),
43625
- /** NULL-safe exclusion of a SET — `whereNot` for more than one value. An
43626
- * empty list excludes nothing. See `QueryFilter.whereNotIn`. */
43627
- whereNotIn: record(string(), array(unknown())).optional(),
43628
- orderBy: object({
43629
- field: string(),
43630
- direction: _enum(["asc", "desc"])
43631
- }).optional(),
43632
- limit: number().optional(),
43633
- offset: number().optional()
43634
- });
43635
- /**
43636
- * The predicate half of a filter, for BULK MUTATIONS.
43637
- *
43638
- * Deliberately not `QueryFilterSchema`: `orderBy` / `limit` / `offset` have no
43639
- * meaning for a statement that rewrites a set, and accepting them would invite
43640
- * a caller to believe `limit` bounds the damage. Every field is optional here
43641
- * only so the shape stays composable — the implementation REJECTS a filter
43642
- * that compiles to no predicate, because that is the whole collection.
43643
- */
43644
- var MutationFilterSchema = object({
43645
- where: record(string(), unknown()).optional(),
43646
- whereIn: record(string(), array(unknown())).optional(),
43647
- whereBetween: record(string(), tuple([unknown(), unknown()])).optional(),
43648
- whereNot: record(string(), unknown()).optional(),
43649
- whereNotIn: record(string(), array(unknown())).optional()
43650
- });
43651
- /**
43652
- * One scalar an {@link settingsStoreCapability.methods.aggregate} call asks for.
43653
- *
43654
- * `as` names the slot in the result, so the SAME column may be asked twice with
43655
- * two operations (`MIN(startMs)` and `MAX(startMs)` in one round trip) — which
43656
- * a `Record<column, op>` shape could not express.
43657
- */
43658
- var AggregateFieldSchema = object({
43659
- /** Result key. */
43660
- as: string().min(1),
43661
- /** Column to aggregate. Must be a real column of a declared collection. */
43662
- field: string().min(1),
43663
- op: _enum([
43664
- "sum",
43665
- "min",
43666
- "max"
43667
- ])
43668
- });
43669
- /**
43670
- * `COUNT(*)` plus one number per requested field.
43671
- *
43672
- * `null` means NO ROW MATCHED, never zero: a `SUM` over an empty set and a sum
43673
- * that really is 0 are different facts, and an accounting caller that renders
43674
- * "0 bytes, oldest = 0" for "nothing here" reports a lie about a disk.
43675
- */
43676
- var AggregateResultSchema = object({
43677
- count: number().int(),
43678
- values: record(string(), number().nullable())
43679
- });
43680
- /** A single stored record: `{ id, data }`. */
43681
- var SettingsRecordSchema = object({
43682
- id: string(),
43683
- data: record(string(), unknown())
43684
- });
43685
- /**
43686
- * One record of a BULK insert — {@link SettingsRecordSchema} with the id made
43687
- * optional.
43688
- *
43689
- * A separate schema rather than loosening the shared one: every other method
43690
- * on this cap addresses a row BY its id, and making that field optional
43691
- * everywhere would turn a forgotten key into a silently generated one on
43692
- * `update` and `delete` as well.
43693
- */
43694
- var BulkRecordSchema = object({
43695
- id: string().optional(),
43696
- data: record(string(), unknown())
43697
- });
43698
- /**
43699
- * The database FILES one `sqlite-settings` engine process owns (D851).
43700
- * Closed on purpose: a file is a thing the engine opens, backs up and gives a
43701
- * serving thread, so a new one is a code change, never a string a caller
43702
- * invents. `settings` is `camstack.db` and the default for every collection
43703
- * that names no file.
43704
- */
43705
- var DataStoreDatabaseSchema = _enum([
43706
- "settings",
43707
- "events",
43708
- "history"
43709
- ]);
43710
- DataStoreDatabaseSchema.options;
43711
- /**
43712
- * One write inside a {@link settingsStoreCapability.methods.transact} call.
43713
- * The three that a "replace this set, bump that revision" write needs, plus
43714
- * the batched upsert a rollup writer needs.
43715
- */
43716
- var TransactOpSchema = discriminatedUnion("op", [
43717
- object({
43718
- op: literal("deleteWhere"),
43719
- collection: string(),
43720
- filter: MutationFilterSchema
43721
- }),
43722
- object({
43723
- op: literal("insertMany"),
43724
- collection: string(),
43725
- records: array(BulkRecordSchema).readonly()
43726
- }),
43727
- object({
43728
- op: literal("update"),
43729
- collection: string(),
43730
- id: string(),
43731
- data: record(string(), unknown())
43732
- }),
43733
- object({
43734
- op: literal("upsertMany"),
43735
- collection: string(),
43736
- conflict: array(string()).readonly(),
43737
- records: array(BulkRecordSchema).readonly()
43738
- })
43739
- ]);
43740
- /**
43741
- * The precondition of a transaction: the row `key` of `collection` must hold
43742
- * `equals` in `column`, read INSIDE the transaction.
43743
- */
43744
- var TransactGuardSchema = object({
43745
- collection: string(),
43746
- key: string(),
43747
- column: string(),
43748
- equals: unknown()
43749
- });
43750
- /**
43751
- * Column declaration for a structured (SQL-backed) collection.
43752
- *
43753
- * Logical types — the backend translates each to the matching SQLite
43754
- * storage class and handles per-type marshaling:
43755
- * - `TEXT` / `INTEGER` / `REAL` — native SQLite types, pass-through
43756
- * - `JSON` — TEXT under the hood; serialised on write, parsed on read
43757
- * - `BOOLEAN` — INTEGER 0/1 under the hood; coerced both directions
43758
- */
43759
- var CollectionColumnSchema = object({
43760
- name: string(),
43761
- type: _enum([
43762
- "TEXT",
43763
- "INTEGER",
43764
- "REAL",
43765
- "JSON",
43766
- "BOOLEAN"
43767
- ]),
43768
- primaryKey: boolean().optional(),
43769
- notNull: boolean().optional(),
43770
- unique: boolean().optional(),
43771
- /**
43772
- * Column DEFAULT. Required for B2: the four `ensureTable` consumers declare
43773
- * columns like `enabled INTEGER NOT NULL DEFAULT 1`, and without this the
43774
- * collection surface simply cannot express their existing tables — which is
43775
- * why they were still on the uncapped `table*` API.
43776
- */
43777
- defaultValue: union([
43778
- string(),
43779
- number(),
43780
- boolean()
43781
- ]).optional()
43782
- });
43783
- var CollectionIndexSchema = object({
43784
- name: string(),
43785
- columns: array(string()).readonly(),
43786
- unique: boolean().optional()
43787
- });
43788
- /**
43789
- * The input of `declareCollection` — ONE schema for the door and for the
43790
- * engine behind it, so the two surfaces cannot drift (the dispatcher forwards
43791
- * the payload untouched).
43792
- *
43793
- * - `database` — the file the collection lives in (D851). Absent means
43794
- * `settings`. A declaration naming a file other than the one the table is
43795
- * already in is REFUSED by the engine, never moved.
43796
- * - `primaryKey` — a COMPOSITE key, as column names. A single name is the same
43797
- * as `primaryKey: true` on that column. A composite-keyed collection has no
43798
- * `id`: it is written with `insertMany` / `upsertMany` / `transact` and read
43799
- * with `query` / `count` / `aggregate` / `deleteWhere`; the calls that
43800
- * address one row by id are refused.
43801
- * - `withoutRowid` — emit `WITHOUT ROWID`. Requires a primary key.
43802
- */
43803
- var DeclareCollectionInputSchema = object({
43804
- namespace: string().optional(),
43805
- collection: string(),
43806
- columns: array(CollectionColumnSchema).readonly(),
43807
- indexes: array(CollectionIndexSchema).readonly().optional(),
43808
- database: DataStoreDatabaseSchema.optional(),
43809
- primaryKey: array(string()).readonly().optional(),
43810
- withoutRowid: boolean().optional()
43811
- });
43812
- method(object({
43813
- namespace: string().optional(),
43814
- collection: string(),
43815
- key: string()
43816
- }), unknown(), { auth: "admin" }), method(object({
43817
- namespace: string().optional(),
43818
- collection: string(),
43819
- key: string(),
43820
- value: unknown()
43821
- }), _void(), {
43822
- kind: "mutation",
43823
- auth: "admin"
43824
- }), method(object({
43825
- namespace: string().optional(),
43826
- collection: string(),
43827
- filter: QueryFilterSchema.optional(),
43828
- columns: array(string()).readonly().optional()
43829
- }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
43830
- namespace: string().optional(),
43831
- collection: string(),
43832
- /** Declared columns identifying the slot; must be covered by a UNIQUE
43833
- * index on the collection. Never empty. */
43834
- conflict: array(string()).readonly(),
43835
- record: BulkRecordSchema
43836
- }), object({
43837
- /** The id the row HAS: assigned by SQLite on an insert, or the existing
43838
- * row's own id on an update. */
43839
- id: union([string(), number()]) }), {
43840
- kind: "mutation",
43841
- auth: "admin"
43842
- }), method(object({
43843
- namespace: string().optional(),
43844
- collection: string(),
43845
- conflict: array(string()).readonly(),
43846
- records: array(BulkRecordSchema).readonly()
43847
- }), object({ upserted: number().int() }), {
43848
- kind: "mutation",
43849
- auth: "admin"
43850
- }), method(object({
43851
- namespace: string().optional(),
43852
- collection: string(),
43853
- record: object({
43854
- id: string().optional(),
43855
- data: record(string(), unknown())
43856
- })
43857
- }), object({
43858
- /**
43859
- * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
43860
- * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
43861
- * primary key — which is the only place an auto key is knowable.
43862
- */
43863
- id: union([string(), number()]) }), {
43864
- kind: "mutation",
43865
- auth: "admin"
43866
- }), method(object({
43867
- namespace: string().optional(),
43868
- collection: string(),
43869
- records: array(BulkRecordSchema).readonly()
43870
- }), object({ inserted: number().int() }), {
43871
- kind: "mutation",
43872
- auth: "admin"
43873
- }), method(object({
43874
- namespace: string().optional(),
43875
- guard: TransactGuardSchema.optional(),
43876
- ops: array(TransactOpSchema).readonly()
43877
- }), object({
43878
- applied: boolean(),
43879
- current: unknown().optional()
43880
- }), {
43881
- kind: "mutation",
43882
- auth: "admin"
43883
- }), method(object({
43884
- namespace: string().optional(),
43885
- collection: string(),
43886
- id: string(),
43887
- data: record(string(), unknown())
43888
- }), _void(), {
43889
- kind: "mutation",
43890
- auth: "admin"
43891
- }), method(object({
43892
- namespace: string().optional(),
43893
- collection: string(),
43894
- key: string()
43895
- }), _void(), {
43896
- kind: "mutation",
43897
- auth: "admin"
43898
- }), method(object({
43899
- namespace: string().optional(),
43900
- collection: string(),
43901
- filter: MutationFilterSchema
43902
- }), object({ deleted: number().int() }), {
43903
- kind: "mutation",
43904
- auth: "admin"
43905
- }), method(object({
43906
- namespace: string().optional(),
43907
- collection: string(),
43908
- filter: MutationFilterSchema,
43909
- data: record(string(), unknown())
43910
- }), object({ updated: number().int() }), {
43911
- kind: "mutation",
43912
- auth: "admin"
43913
- }), method(object({
43914
- namespace: string().optional(),
43915
- collection: string(),
43916
- filter: QueryFilterSchema.optional()
43917
- }), number(), { auth: "admin" }), method(object({
43918
- namespace: string().optional(),
43919
- collection: string(),
43920
- fields: array(AggregateFieldSchema).readonly(),
43921
- filter: QueryFilterSchema.optional()
43922
- }), AggregateResultSchema, { auth: "admin" }), method(object({
43923
- namespace: string().optional(),
43924
- collection: string(),
43925
- field: string(),
43926
- bucketSize: number().int().positive(),
43927
- origin: number().int(),
43928
- filter: QueryFilterSchema.optional()
43929
- }), array(object({
43930
- bucket: number().int(),
43931
- count: number().int()
43932
- })).readonly(), { auth: "admin" }), method(object({
43933
- namespace: string().optional(),
43934
- collection: string()
43935
- }), boolean(), { auth: "admin" }), method(DeclareCollectionInputSchema, _void(), {
43936
- kind: "mutation",
43937
- auth: "admin"
43938
- });
43939
- /**
43940
44499
  * How long one snapshot may take end to end: the pinned copy of the whole
43941
44500
  * database plus `PRAGMA integrity_check` over the copy, on the hub's slowest
43942
44501
  * disk. ~800 MB at a pessimistic 10 MB/s is under 3 minutes; the bound is
@@ -45744,7 +46303,7 @@ method(object({
45744
46303
  kind: "mutation",
45745
46304
  auth: "admin"
45746
46305
  }), method(object({ blockIds: array(string()) }), object({ states: array(CompositionBlockStateSchema) }), { auth: "admin" });
45747
- 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;
46306
+ 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;
45748
46307
  var NUMBER = {
45749
46308
  kind: "fixed",
45750
46309
  result: ["number"]
@@ -46755,6 +47314,57 @@ id: union([string(), number()]) }), {
46755
47314
  kind: "mutation",
46756
47315
  auth: "admin"
46757
47316
  });
47317
+ 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({
47318
+ id: string().min(1),
47319
+ error: string().min(1)
47320
+ }), MigrationLedgerEntrySchema, {
47321
+ kind: "mutation",
47322
+ auth: "admin"
47323
+ }), method(object({ id: string().min(1) }), object({ entries: array(MigrationLedgerEntrySchema) }), {
47324
+ kind: "mutation",
47325
+ auth: "admin"
47326
+ }), method(object({
47327
+ database: DataStoreDatabaseSchema,
47328
+ snapshotId: string().min(1)
47329
+ }), object({
47330
+ scheduled: boolean(),
47331
+ held: array(string()),
47332
+ restartRequired: boolean()
47333
+ }), {
47334
+ kind: "mutation",
47335
+ auth: "admin"
47336
+ }), method(object({
47337
+ owner: string().min(1),
47338
+ metas: array(MigrationMetaSchema)
47339
+ }), object({
47340
+ bootId: string(),
47341
+ snapshot: _enum([
47342
+ "none",
47343
+ "written",
47344
+ "refused"
47345
+ ]),
47346
+ steps: array(MigrationOwnerStepSchema)
47347
+ }), {
47348
+ kind: "mutation",
47349
+ auth: "admin"
47350
+ }), method(object({ id: string().min(1) }), object({
47351
+ proceed: boolean(),
47352
+ state: union([literal("pending"), MigrationStatusSchema]),
47353
+ reason: string().nullable()
47354
+ }), {
47355
+ kind: "mutation",
47356
+ auth: "admin"
47357
+ }), method(object({
47358
+ id: string().min(1),
47359
+ result: MigrationOwnerResultSchema
47360
+ }), object({
47361
+ status: MigrationStatusSchema,
47362
+ error: string().nullable(),
47363
+ rowsChanged: number().int().nonnegative()
47364
+ }), {
47365
+ kind: "mutation",
47366
+ auth: "admin"
47367
+ });
46758
47368
  /**
46759
47369
  * records - an addon's own facts and documents (D881): ledgers, audit rows,
46760
47370
  * config documents, mirrors. The third storage API next to `ctx.settings`
@@ -61342,7 +61952,18 @@ var ServerUpdateActionResultSchema = object({
61342
61952
  * store (D877), present when the pre-flight refused the update
61343
61953
  * (`reason: 'addon-would-refuse'`). Optional for version skew.
61344
61954
  */
61345
- blockers: array(UpdateBlockerSchema).optional()
61955
+ blockers: array(UpdateBlockerSchema).optional(),
61956
+ /**
61957
+ * The minimums the target server declares and this node does not meet
61958
+ * (D989), present when the update was refused with
61959
+ * `reason: 'requirements-unmet'`. Each names the versions on both sides.
61960
+ */
61961
+ unmet: array(UnmetRequirementSchema).optional(),
61962
+ /**
61963
+ * The addons this node has below the minimum the staged server declares —
61964
+ * the ones to update WITH the server. Present on an accepted update.
61965
+ */
61966
+ requiredAddonUpdates: array(RequiredAddonUpdateSchema).optional()
61346
61967
  });
61347
61968
  var LaunchOverridesSchema = object({
61348
61969
  /** The persisted heap ceiling in MB, or `null` when none is set. */
@@ -64046,7 +64667,9 @@ var PackageUpdateSchema = object({
64046
64667
  latestVersion: string(),
64047
64668
  category: _enum(["addon", "core"]),
64048
64669
  requiresRestart: boolean(),
64049
- isSystem: boolean()
64670
+ isSystem: boolean(),
64671
+ /** Held: what the newer version needs and this node does not meet (D989). */
64672
+ blockedBy: array(UnmetRequirementSchema).readonly().optional()
64050
64673
  });
64051
64674
  var PackageVersionInfoSchema = object({
64052
64675
  version: string(),
@@ -65094,19 +65717,19 @@ var RemoteSetConfigResultSchema = discriminatedUnion("status", [object({ status:
65094
65717
  reason: _enum(["unknown-template", "not-a-media-player"]),
65095
65718
  detail: string()
65096
65719
  })]);
65097
- var deviceInput = object({ deviceId: number().int().nonnegative() });
65720
+ var deviceInput$1 = object({ deviceId: number().int().nonnegative() });
65098
65721
  DeviceType.MediaPlayer;
65099
- method(deviceInput, RemoteConfigSchema, { auth: "admin" }), method(deviceInput.extend({ config: RemoteConfigSchema }), RemoteSetConfigResultSchema, {
65722
+ method(deviceInput$1, RemoteConfigSchema, { auth: "admin" }), method(deviceInput$1.extend({ config: RemoteConfigSchema }), RemoteSetConfigResultSchema, {
65100
65723
  kind: "mutation",
65101
65724
  auth: "admin"
65102
- }), method(deviceInput, RemoteCommandListSchema, { auth: "protected" }), method(deviceInput.extend({
65725
+ }), method(deviceInput$1, RemoteCommandListSchema, { auth: "protected" }), method(deviceInput$1.extend({
65103
65726
  role: RemoteRoleSchema,
65104
65727
  /** Sends in a row (volume steps). */
65105
65728
  repeat: number().int().min(1).max(50).default(1)
65106
65729
  }), RemoteSendResultSchema, {
65107
65730
  kind: "mutation",
65108
65731
  auth: "protected"
65109
- }), method(deviceInput.extend({
65732
+ }), method(deviceInput$1.extend({
65110
65733
  command: RemoteMediaCommandSchema,
65111
65734
  muted: boolean().optional(),
65112
65735
  source: string().optional(),
@@ -67621,7 +68244,7 @@ DeviceType.LawnMower, method(object({ deviceId: number().int().nonnegative() }),
67621
68244
  * clients — they reverse-connect to the hub. Exposing their interfaces
67622
68245
  * via the same surface would leak internal topology with no upside.
67623
68246
  *
67624
- * Implementation in `@camstack/system/builtins/local-network/`.
68247
+ * Implementation in `@camstack/server/system/builtins/local-network/`.
67625
68248
  */
67626
68249
  /** Coarse classification derived from the interface name + IP range. */
67627
68250
  var InterfaceKindEnum = _enum([
@@ -68050,6 +68673,49 @@ DeviceType.Lock, method(object({
68050
68673
  kind: "mutation",
68051
68674
  auth: "protected"
68052
68675
  });
68676
+ var PowerSourceRefusalReasonSchema = _enum([
68677
+ "no-power-source",
68678
+ "switch-missing",
68679
+ "switch-offline",
68680
+ "switch-unknown",
68681
+ "restart-in-progress",
68682
+ "switch-call-failed"
68683
+ ]);
68684
+ var PowerSourceActionResultSchema = discriminatedUnion("accepted", [object({ accepted: literal(true) }), object({
68685
+ accepted: literal(false),
68686
+ reason: PowerSourceRefusalReasonSchema,
68687
+ /** One line for the operator, naming the switch. */
68688
+ message: string()
68689
+ })]);
68690
+ var PowerSourceInfoSchema = object({
68691
+ /** False when the device has no power source linked; the rest is then empty. */
68692
+ linked: boolean(),
68693
+ switchDeviceId: number().nullable(),
68694
+ switchName: string().nullable(),
68695
+ /** The switch's on/off state, or null when it is unknown. Never false for unknown (D393). */
68696
+ switchOn: boolean().nullable(),
68697
+ switchOnline: boolean().nullable(),
68698
+ restartInProgress: boolean(),
68699
+ offSeconds: number().int()
68700
+ });
68701
+ object({
68702
+ /** Null while the switch has not reported: unknown is never `false` (D393). */
68703
+ switchOn: boolean().nullable(),
68704
+ offSeconds: number().int(),
68705
+ lastFetchedAt: number()
68706
+ });
68707
+ 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;
68708
+ var deviceInput = object({ deviceId: number().int().nonnegative() });
68709
+ systemMethod(deviceInput, PowerSourceInfoSchema, { auth: "admin" }), systemMethod(deviceInput, PowerSourceActionResultSchema, {
68710
+ kind: "mutation",
68711
+ auth: "admin"
68712
+ }), systemMethod(deviceInput, PowerSourceActionResultSchema, {
68713
+ kind: "mutation",
68714
+ auth: "admin"
68715
+ }), systemMethod(deviceInput, PowerSourceActionResultSchema, {
68716
+ kind: "mutation",
68717
+ auth: "admin"
68718
+ });
68053
68719
  object({
68054
68720
  value: number().nullable().meta(readingMeta("device", { label: "Total" })),
68055
68721
  lastFetchedAt: number()
@@ -68858,7 +69524,7 @@ DeviceType.Camera, DeviceType.Sensor, DeviceType.Button, DeviceType.Switch, Devi
68858
69524
  * jitter, and observed/peak bandwidth per device + per client.
68859
69525
  *
68860
69526
  * Implementation lives in the server's `NetworkQualityService` (thin
68861
- * wrapper over the shared `NetworkQualityTracker` from `@camstack/system`).
69527
+ * wrapper over the shared `NetworkQualityTracker` from `@camstack/server/system`).
68862
69528
  * The provider is registered from `trpc.router.ts` against the existing
68863
69529
  * service instance — no addon owns this state.
68864
69530
  *
@@ -74896,6 +75562,13 @@ Object.freeze({
74896
75562
  access: "view",
74897
75563
  role: "admin"
74898
75564
  },
75565
+ "addonSettings.getIntegrationFormSchema": {
75566
+ capName: "addon-settings",
75567
+ capScope: "system",
75568
+ addonId: null,
75569
+ access: "view",
75570
+ role: "admin"
75571
+ },
74899
75572
  "addonSettings.getIntegrationSettings": {
74900
75573
  capName: "addon-settings",
74901
75574
  capScope: "system",
@@ -78984,6 +79657,69 @@ Object.freeze({
78984
79657
  access: "view",
78985
79658
  role: "admin"
78986
79659
  },
79660
+ "migrations.declareOwner": {
79661
+ capName: "migrations",
79662
+ capScope: "system",
79663
+ addonId: null,
79664
+ access: "create",
79665
+ role: "admin"
79666
+ },
79667
+ "migrations.dryRun": {
79668
+ capName: "migrations",
79669
+ capScope: "system",
79670
+ addonId: null,
79671
+ access: "view",
79672
+ role: "admin"
79673
+ },
79674
+ "migrations.finishMigration": {
79675
+ capName: "migrations",
79676
+ capScope: "system",
79677
+ addonId: null,
79678
+ access: "create",
79679
+ role: "admin"
79680
+ },
79681
+ "migrations.listLedger": {
79682
+ capName: "migrations",
79683
+ capScope: "system",
79684
+ addonId: null,
79685
+ access: "view",
79686
+ role: "admin"
79687
+ },
79688
+ "migrations.listPending": {
79689
+ capName: "migrations",
79690
+ capScope: "system",
79691
+ addonId: null,
79692
+ access: "view",
79693
+ role: "admin"
79694
+ },
79695
+ "migrations.markFailed": {
79696
+ capName: "migrations",
79697
+ capScope: "system",
79698
+ addonId: null,
79699
+ access: "create",
79700
+ role: "admin"
79701
+ },
79702
+ "migrations.restorePreMigration": {
79703
+ capName: "migrations",
79704
+ capScope: "system",
79705
+ addonId: null,
79706
+ access: "create",
79707
+ role: "admin"
79708
+ },
79709
+ "migrations.retry": {
79710
+ capName: "migrations",
79711
+ capScope: "system",
79712
+ addonId: null,
79713
+ access: "create",
79714
+ role: "admin"
79715
+ },
79716
+ "migrations.startMigration": {
79717
+ capName: "migrations",
79718
+ capScope: "system",
79719
+ addonId: null,
79720
+ access: "create",
79721
+ role: "admin"
79722
+ },
78987
79723
  "modelConvert.convert": {
78988
79724
  capName: "model-convert",
78989
79725
  capScope: "system",
@@ -81616,6 +82352,34 @@ Object.freeze({
81616
82352
  access: "view",
81617
82353
  role: "viewer"
81618
82354
  },
82355
+ "powerSource.forceRestart": {
82356
+ capName: "power-source",
82357
+ capScope: "device",
82358
+ addonId: null,
82359
+ access: "create",
82360
+ role: "admin"
82361
+ },
82362
+ "powerSource.getStatus": {
82363
+ capName: "power-source",
82364
+ capScope: "device",
82365
+ addonId: null,
82366
+ access: "view",
82367
+ role: "admin"
82368
+ },
82369
+ "powerSource.powerOff": {
82370
+ capName: "power-source",
82371
+ capScope: "device",
82372
+ addonId: null,
82373
+ access: "create",
82374
+ role: "admin"
82375
+ },
82376
+ "powerSource.powerOn": {
82377
+ capName: "power-source",
82378
+ capScope: "device",
82379
+ addonId: null,
82380
+ access: "create",
82381
+ role: "admin"
82382
+ },
81619
82383
  "presence.getStatus": {
81620
82384
  capName: "presence",
81621
82385
  capScope: "device",
@@ -86789,6 +87553,26 @@ Object.freeze({
86789
87553
  form: "single",
86790
87554
  optional: false
86791
87555
  }],
87556
+ "powerSource.forceRestart": [{
87557
+ name: "deviceId",
87558
+ form: "single",
87559
+ optional: false
87560
+ }],
87561
+ "powerSource.getStatus": [{
87562
+ name: "deviceId",
87563
+ form: "single",
87564
+ optional: false
87565
+ }],
87566
+ "powerSource.powerOff": [{
87567
+ name: "deviceId",
87568
+ form: "single",
87569
+ optional: false
87570
+ }],
87571
+ "powerSource.powerOn": [{
87572
+ name: "deviceId",
87573
+ form: "single",
87574
+ optional: false
87575
+ }],
86792
87576
  "presence.getStatus": [{
86793
87577
  name: "deviceId",
86794
87578
  form: "single",