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