@camstack/addon-export-alexa 1.2.176 → 1.2.177

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.
@@ -34,7 +34,7 @@ let node_path = require("node:path");
34
34
  node_path = __toESM(node_path, 1);
35
35
  require("node:child_process");
36
36
  require("node:zlib");
37
- //#region ../types/dist/event-category-DmZDPDf_.mjs
37
+ //#region ../types/dist/event-category-CaURIwQA.mjs
38
38
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
39
39
  EventCategory["SystemBoot"] = "system.boot";
40
40
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -750,6 +750,10 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
750
750
  EventCategory["NotificationRuleBroken"] = "notification.rule-broken";
751
751
  /** The clear of {@link NotificationRuleBroken}: the rule loads and names nothing deleted. */
752
752
  EventCategory["NotificationRuleRepaired"] = "notification.rule-repaired";
753
+ /** A migration failed or was blocked; the Alert Center re-reads the ledger. */
754
+ EventCategory["MigrationFailed"] = "migration.failed";
755
+ /** A migration applied or a failure cleared; the Alert Center re-reads the ledger. */
756
+ EventCategory["MigrationApplied"] = "migration.applied";
753
757
  EventCategory["DeviceUpdated"] = "device.updated";
754
758
  /**
755
759
  * Transport-level connectivity. Emitted by the device driver when
@@ -812,6 +816,378 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
812
816
  return EventCategory;
813
817
  }({});
814
818
  //#endregion
819
+ //#region ../types/dist/device-type-CEqjmUnR.mjs
820
+ /**
821
+ import { errMsg } from '@camstack/types'
822
+ * Extract a human-readable message from an unknown error value.
823
+ * Replaces the ubiquitous `errMsg(err)` pattern.
824
+ */
825
+ function errMsg$1(err) {
826
+ if (err instanceof Error) return err.message;
827
+ if (typeof err === "string") return err;
828
+ return String(err);
829
+ }
830
+ var DeviceType = /* @__PURE__ */ function(DeviceType) {
831
+ DeviceType["Camera"] = "camera";
832
+ DeviceType["Hub"] = "hub";
833
+ DeviceType["Light"] = "light";
834
+ DeviceType["Siren"] = "siren";
835
+ DeviceType["Switch"] = "switch";
836
+ DeviceType["Sensor"] = "sensor";
837
+ DeviceType["Thermostat"] = "thermostat";
838
+ /** Air-conditioner / heat-pump climate device (HVAC) — shares the
839
+ * `climate-control` cap surface with `Thermostat` but renders a
840
+ * dedicated AC-appropriate control UI (mode chips, fan speed,
841
+ * independent vertical/horizontal swing). Sources: native Gree, and
842
+ * reusable by other AC integrations. */
843
+ DeviceType["Climate"] = "climate";
844
+ DeviceType["Button"] = "button";
845
+ /** Generic stateless event emitter — carries a device's EXACT declared
846
+ * event vocabulary verbatim (no normalization). Installed with the
847
+ * `event-emitter` cap. Sources: HA `event.*` entities (structured) and
848
+ * HA bus events (e.g. `zha_event`, generic). */
849
+ DeviceType["EventEmitter"] = "event-emitter";
850
+ /** Firmware/software update entity — current vs available version,
851
+ * updatable flag, update state, and an install action. Installed with
852
+ * the `update` cap. Sources: Homematic firmware-update channels (and
853
+ * reusable by other providers, e.g. HA `update.*` entities). */
854
+ DeviceType["Update"] = "update";
855
+ DeviceType["Generic"] = "generic";
856
+ /** Generic notification delivery target (HA `notify.<service>`, future
857
+ * Telegram / Discord / ntfy / SMTP, …). One device per delivery
858
+ * endpoint; the `notifier` cap defines the send surface. */
859
+ DeviceType["Notifier"] = "notifier";
860
+ /** Pre-recorded action sequence with optional parameters
861
+ * (HA `script.*`). Runnable via `script-runner` cap. */
862
+ DeviceType["Script"] = "script";
863
+ /** Automation rule (HA `automation.*`) — enable/disable + manual
864
+ * trigger surface exposed via `automation-control` cap. */
865
+ DeviceType["Automation"] = "automation";
866
+ /** Door / smart lock device (HA `lock.*`). `lock-control` cap. */
867
+ DeviceType["Lock"] = "lock";
868
+ /** Window covering, blinds, garage door, valve, etc. (HA `cover.*`,
869
+ * `valve.*`). `cover` cap with sub-roles for variant. */
870
+ DeviceType["Cover"] = "cover";
871
+ /** Pipe / water / gas valve with open/close/stop and optional
872
+ * position (HA `valve.*`). `valve` cap — a cover-sibling actuator
873
+ * modelled on the same open/closed lifecycle. */
874
+ DeviceType["Valve"] = "valve";
875
+ /** Humidifier / dehumidifier with on/off + target humidity + mode
876
+ * (HA `humidifier.*`). `humidifier` cap — a climate-family actuator
877
+ * modelled on the same target / mode lifecycle. */
878
+ DeviceType["Humidifier"] = "humidifier";
879
+ /** Water heater / boiler with target temperature + operation mode +
880
+ * away mode (HA `water_heater.*`). `water-heater` cap — a
881
+ * climate-family actuator. */
882
+ DeviceType["WaterHeater"] = "water-heater";
883
+ /** Ceiling / standing / exhaust fan (HA `fan.*`). `fan-control` cap. */
884
+ DeviceType["Fan"] = "fan";
885
+ /** Audio / video playback endpoint (HA `media_player.*`). Disjoint from
886
+ * the camera surface — those use `Camera`. `media-player` cap. */
887
+ DeviceType["MediaPlayer"] = "media-player";
888
+ /** Security panel / alarm system (HA `alarm_control_panel.*`).
889
+ * `alarm-panel` cap. */
890
+ DeviceType["AlarmPanel"] = "alarm-panel";
891
+ /** Generic user-settable input (HA `number` / `input_number` / `select`
892
+ * / `input_select` / `text` / `input_text` / `input_datetime`).
893
+ * Sub-type via `DeviceRole`: NumericControl / SelectControl /
894
+ * TextControl / DateTimeControl. */
895
+ DeviceType["Control"] = "control";
896
+ /** Person / device-tracker presence (HA `person.*`, `device_tracker.*`).
897
+ * `presence` cap. */
898
+ DeviceType["Presence"] = "presence";
899
+ /** Weather provider (HA `weather.*`). Tier-3, low MVP priority.
900
+ * `weather` cap. */
901
+ DeviceType["Weather"] = "weather";
902
+ /** Robot vacuum (HA `vacuum.*`). Tier-3. `vacuum-control` cap. */
903
+ DeviceType["Vacuum"] = "vacuum";
904
+ /** Robotic lawn mower (HA `lawn_mower.*`). Tier-3.
905
+ * `lawn-mower-control` cap. */
906
+ DeviceType["LawnMower"] = "lawn-mower";
907
+ /** Physical HA device group — parent container for entity-children
908
+ * adopted from a single HA device entry. Not renderable as a
909
+ * standalone device; exists only to anchor child entities. */
910
+ DeviceType["Container"] = "container";
911
+ /** Single still-image entity (HA `image.*`). Read-only display of an
912
+ * `entity_picture` signed URL the browser loads directly. `image` cap. */
913
+ DeviceType["Image"] = "image";
914
+ /** Smart pet feeder — cloud-connected food dispenser with a bowl food
915
+ * level, battery, desiccant life, feeding state and manual-feed /
916
+ * call-pet / maintenance actions. Installed with the `pet-feeder` cap;
917
+ * dual-hopper models (D4S/D4SH) expose per-hopper portions. Sources:
918
+ * native PetKit (`nodepetkit` `FeederDevice`), reusable by other feeder
919
+ * integrations sharing the same food/desiccant/hopper surface. */
920
+ DeviceType["PetFeeder"] = "pet-feeder";
921
+ /** Pet water fountain — tank level, water drunk, pump and its duty cycle.
922
+ * Installed with the `pet-fountain` cap. Reaches CamStack as loose entities
923
+ * of a container and is BUILT as a composed device (D967). */
924
+ DeviceType["PetFountain"] = "pet-fountain";
925
+ /** Built-in dishwasher — program lifecycle, door / remote-start gates,
926
+ * salt and rinse-aid levels. Installed with the `dishwasher` cap.
927
+ * Sources: native Bosch Home Connect, reusable by similar integrations.
928
+ * A plug-built dishwasher carries running-state and power instead. */
929
+ DeviceType["Dishwasher"] = "dishwasher";
930
+ /** Washing machine. A plug-built one is running while its power stays
931
+ * above a threshold. No program cap — that surface is the dishwasher's. */
932
+ DeviceType["Washer"] = "washer";
933
+ /** Tumble dryer. Same plug-built running surface as {@link Washer}. */
934
+ DeviceType["Dryer"] = "dryer";
935
+ /** The physical bridge box of a vendor ecosystem (Velux KLF-200, and later
936
+ * other radio-to-IP bridges). It carries the box's own facts (firmware,
937
+ * address, connection state) and the actions the box really supports
938
+ * (`reboot`, `device-admin-link`). Products are NOT its children — they are
939
+ * adopted beside it — and its connection settings stay on the integration. */
940
+ DeviceType["Gateway"] = "gateway";
941
+ return DeviceType;
942
+ }({});
943
+ var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
944
+ DeviceFeature["BatteryOperated"] = "battery-operated";
945
+ DeviceFeature["Rebootable"] = "rebootable";
946
+ /**
947
+ * Device supports an on-demand re-sync of its derived spec with its
948
+ * upstream source — drives the generic Re-sync button. The owning
949
+ * provider implements the action via the `device-adoption.resync` cap.
950
+ */
951
+ DeviceFeature["Resyncable"] = "resyncable";
952
+ DeviceFeature["NativeSnapshot"] = "native-snapshot";
953
+ DeviceFeature["DoorbellButton"] = "doorbell-button";
954
+ DeviceFeature["TwoWayAudio"] = "two-way-audio";
955
+ DeviceFeature["PanTiltZoom"] = "pan-tilt-zoom";
956
+ /**
957
+ * Camera supports the on-firmware autotrack subsystem (subject-
958
+ * following). Distinct from `PanTiltZoom` because not every PTZ
959
+ * camera ships autotrack — the admin UI uses this flag to gate
960
+ * the autotrack toggle / settings card without re-deriving from
961
+ * the cap registry. Mirrors `ptz-autotrack` cap registration:
962
+ * driver sets this feature when probe confirms the firmware
963
+ * surface, and registers the cap in the same code path.
964
+ */
965
+ DeviceFeature["PtzAutotrack"] = "ptz-autotrack";
966
+ /**
967
+ * Accessory exposes a "trigger on motion" toggle — the parent camera's
968
+ * motion detection automatically activates this device. Mirrors
969
+ * `motion-trigger` cap registration: drivers set this feature in the
970
+ * same code path that calls `ctx.registerNativeCap(motionTriggerCapability, ...)`.
971
+ *
972
+ * Used by admin UI (gate the in-hero `MotionTriggerToggle` against a
973
+ * fast scalar without binding fetch), notifier rules, and `listAll`
974
+ * filters that want "all devices with on-motion behaviour".
975
+ */
976
+ DeviceFeature["MotionTrigger"] = "motion-trigger";
977
+ /** Light supports rgb-triplet color via `color` cap. */
978
+ DeviceFeature["LightColorRgb"] = "light-color-rgb";
979
+ /** Light supports HSV color via `color` cap. */
980
+ DeviceFeature["LightColorHsv"] = "light-color-hsv";
981
+ /** Light supports color-temperature (mired) via `color` cap. */
982
+ DeviceFeature["LightColorMired"] = "light-color-mired";
983
+ /** Thermostat supports a `heat_cool` dual setpoint (targetLow +
984
+ * targetHigh). Gates the range slider UI. */
985
+ DeviceFeature["ClimateDualSetpoint"] = "climate-dual-setpoint";
986
+ /** Thermostat exposes target humidity and/or current humidity
987
+ * readings. Gates the humidity controls. */
988
+ DeviceFeature["ClimateHumidity"] = "climate-humidity";
989
+ /** Thermostat exposes a fan-mode selector. */
990
+ DeviceFeature["ClimateFanMode"] = "climate-fan-mode";
991
+ /** Thermostat exposes preset modes (eco / away / sleep / vendor). */
992
+ DeviceFeature["ClimatePreset"] = "climate-preset";
993
+ /** Thermostat exposes a vertical louver swing toggle. Gates the
994
+ * vertical-swing switch in the climate UI. Independent of horizontal. */
995
+ DeviceFeature["ClimateSwingVertical"] = "climate-swing-vertical";
996
+ /** Thermostat exposes a horizontal louver swing toggle. Gates the
997
+ * horizontal-swing switch in the climate UI. Independent of vertical. */
998
+ DeviceFeature["ClimateSwingHorizontal"] = "climate-swing-horizontal";
999
+ /** Cover exposes intermediate position control (0..100). Gates the
1000
+ * position slider UI. */
1001
+ DeviceFeature["CoverPositionable"] = "cover-positionable";
1002
+ /** Cover exposes slat-tilt control. Gates the tilt slider UI. */
1003
+ DeviceFeature["CoverTilt"] = "cover-tilt";
1004
+ /** Valve exposes intermediate position control (0..100). Gates the
1005
+ * position slider / drag surface UI. */
1006
+ DeviceFeature["ValvePositionable"] = "valve-positionable";
1007
+ /** Fan exposes a speed-percentage setter. Gates the speed slider UI. */
1008
+ DeviceFeature["FanSpeed"] = "fan-speed";
1009
+ /** Fan exposes a preset mode selector. */
1010
+ DeviceFeature["FanPreset"] = "fan-preset";
1011
+ /** Fan exposes blade direction (forward/reverse) — typical of
1012
+ * ceiling fans. */
1013
+ DeviceFeature["FanDirection"] = "fan-direction";
1014
+ /** Fan exposes an oscillation toggle. */
1015
+ DeviceFeature["FanOscillating"] = "fan-oscillating";
1016
+ /** Lock requires a PIN code on lock/unlock. Gates the code-entry
1017
+ * field on the UI lock-controls panel. */
1018
+ DeviceFeature["LockPinRequired"] = "lock-pin-required";
1019
+ /** Lock supports a latch-release ("open door") action distinct from
1020
+ * unlock. Mirrors HA `LockEntityFeature.OPEN` (bit 1) in
1021
+ * `supported_features`. Gates the Open Door button in the UI. */
1022
+ DeviceFeature["LockOpen"] = "lock-open";
1023
+ /** Media player exposes a seek-to-position surface. */
1024
+ DeviceFeature["MediaPlayerSeek"] = "media-player-seek";
1025
+ /** Media player exposes a volume-level setter. */
1026
+ DeviceFeature["MediaPlayerVolume"] = "media-player-volume";
1027
+ /** Media player exposes a mute toggle distinct from volume=0. */
1028
+ DeviceFeature["MediaPlayerMute"] = "media-player-mute";
1029
+ /** Media player exposes a shuffle toggle. */
1030
+ DeviceFeature["MediaPlayerShuffle"] = "media-player-shuffle";
1031
+ /** Media player exposes a repeat mode (off / all / one). */
1032
+ DeviceFeature["MediaPlayerRepeat"] = "media-player-repeat";
1033
+ /** Media player exposes a source / input selector. */
1034
+ DeviceFeature["MediaPlayerSelectSource"] = "media-player-select-source";
1035
+ /** Media player exposes a play-arbitrary-media surface (URL / id). */
1036
+ DeviceFeature["MediaPlayerPlayMedia"] = "media-player-play-media";
1037
+ /** Media player exposes next-track. */
1038
+ DeviceFeature["MediaPlayerNext"] = "media-player-next";
1039
+ /** Media player exposes previous-track. */
1040
+ DeviceFeature["MediaPlayerPrevious"] = "media-player-previous";
1041
+ /** Media player exposes stop distinct from pause. */
1042
+ DeviceFeature["MediaPlayerStop"] = "media-player-stop";
1043
+ /** Alarm panel requires a PIN code on arm/disarm. */
1044
+ DeviceFeature["AlarmPinRequired"] = "alarm-pin-required";
1045
+ /** Presence device carries GPS coordinates (lat/lng/accuracy) in
1046
+ * addition to a textual location. */
1047
+ DeviceFeature["PresenceGps"] = "presence-gps";
1048
+ /** Notifier accepts an inline / URL image attachment. */
1049
+ DeviceFeature["NotifierImage"] = "notifier-image";
1050
+ /** Notifier accepts a priority hint (high/normal/low). */
1051
+ DeviceFeature["NotifierPriority"] = "notifier-priority";
1052
+ /** Notifier accepts a free-form `data` payload for platform-specific
1053
+ * fields. */
1054
+ DeviceFeature["NotifierData"] = "notifier-data";
1055
+ /** Notifier supports interactive action buttons / callbacks. */
1056
+ DeviceFeature["NotifierActions"] = "notifier-actions";
1057
+ /** Notifier supports per-call recipient targeting (multi-user). */
1058
+ DeviceFeature["NotifierRecipients"] = "notifier-recipients";
1059
+ /** Script runner accepts a variables map on each run invocation. */
1060
+ DeviceFeature["ScriptVariables"] = "script-variables";
1061
+ /** Automation `trigger` accepts a skipCondition flag — fires the
1062
+ * automation's actions while bypassing its condition block. */
1063
+ DeviceFeature["AutomationSkipCondition"] = "automation-skip-condition";
1064
+ /** Robot vacuum exposes a live cleaning map (image child). Gates the
1065
+ * map tile in the vacuum UI. */
1066
+ DeviceFeature["VacuumHasMap"] = "vacuum-has-map";
1067
+ /** Robot vacuum exposes AI obstacle-detection toggles. Gates the AI
1068
+ * switches group. */
1069
+ DeviceFeature["VacuumHasAi"] = "vacuum-has-ai";
1070
+ /** Robot mower exposes a live mowing map (SVG image child). Gates the
1071
+ * mower map tile. */
1072
+ DeviceFeature["MowerHasMap"] = "mower-has-map";
1073
+ /** Robot mower exposes targeted mowing (all-area / zones / edges /
1074
+ * spots) — gates the Mow action + map selectors. */
1075
+ DeviceFeature["MowerHasTargetedMowing"] = "mower-has-targeted-mowing";
1076
+ return DeviceFeature;
1077
+ }({});
1078
+ /**
1079
+ * Semantic role a device plays within its parent. Populated by driver
1080
+ * addons when creating accessory devices (Reolink siren/floodlight/
1081
+ * PIR/chime/autotrack/doorbell, ONVIF relay outputs, …). Used by the
1082
+ * admin UI to pick icons, labels, and widgets — a `Switch` with
1083
+ * `role: Floodlight` renders as a bulb with a brightness slider,
1084
+ * whereas a `Switch` with `role: Siren` renders as a klaxon.
1085
+ *
1086
+ * Undefined for top-level devices (cameras, NVRs, hubs). Persisted in
1087
+ * sqlite as a nullable TEXT column — old rows keep working unchanged.
1088
+ */
1089
+ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
1090
+ DeviceRole["Siren"] = "siren";
1091
+ DeviceRole["Floodlight"] = "floodlight";
1092
+ DeviceRole["Spotlight"] = "spotlight";
1093
+ DeviceRole["PirSensor"] = "pir-sensor";
1094
+ DeviceRole["Chime"] = "chime";
1095
+ DeviceRole["Autotrack"] = "autotrack";
1096
+ DeviceRole["Nightvision"] = "nightvision";
1097
+ DeviceRole["PrivacyMask"] = "privacy-mask";
1098
+ DeviceRole["Doorbell"] = "doorbell";
1099
+ /** Interior blind / shade / roller blind. HA `device_class: blind|shade`. */
1100
+ DeviceRole["CoverBlind"] = "cover-blind";
1101
+ /** Exterior roller shutter. HA `device_class: shutter`; Homematic BROLL. */
1102
+ DeviceRole["CoverShutter"] = "cover-shutter";
1103
+ /** Exterior awning. HA `device_class: awning`. */
1104
+ DeviceRole["CoverAwning"] = "cover-awning";
1105
+ /** Curtain / drape. HA `device_class: curtain`. */
1106
+ DeviceRole["CoverCurtain"] = "cover-curtain";
1107
+ /** Garage door. HA `device_class: garage`. A security actuator: exports gate it. */
1108
+ DeviceRole["CoverGarage"] = "cover-garage";
1109
+ /** Gate. HA `device_class: gate`. A security actuator: exports gate it. */
1110
+ DeviceRole["CoverGate"] = "cover-gate";
1111
+ /** Door. HA `device_class: door`. A security actuator: exports gate it. */
1112
+ DeviceRole["CoverDoor"] = "cover-door";
1113
+ /** Window. HA `device_class: window`. */
1114
+ DeviceRole["CoverWindow"] = "cover-window";
1115
+ /** Virtual HA toggle (input_boolean.*) — distinguishable from a
1116
+ * real Switch device for UI rendering / export adapters. */
1117
+ DeviceRole["BinaryHelper"] = "binary-helper";
1118
+ /** A smart plug: a `switch` whose source says it is an outlet (HA
1119
+ * `device_class: outlet`). The Alexa export shows it as a SMARTPLUG. */
1120
+ DeviceRole["Outlet"] = "outlet";
1121
+ /** Generic motion / occupancy / moving event source. Distinct from
1122
+ * the camera accessory PirSensor role: that one is a camera child;
1123
+ * this is a standalone HA / 3rd-party motion sensor. */
1124
+ DeviceRole["MotionSensor"] = "motion-sensor";
1125
+ DeviceRole["ContactSensor"] = "contact-sensor";
1126
+ DeviceRole["LeakSensor"] = "leak-sensor";
1127
+ DeviceRole["SmokeSensor"] = "smoke-sensor";
1128
+ DeviceRole["COSensor"] = "co-sensor";
1129
+ DeviceRole["GasSensor"] = "gas-sensor";
1130
+ DeviceRole["TamperSensor"] = "tamper-sensor";
1131
+ DeviceRole["VibrationSensor"] = "vibration-sensor";
1132
+ DeviceRole["ConnectivitySensor"] = "connectivity-sensor";
1133
+ DeviceRole["SoundSensor"] = "sound-sensor";
1134
+ /** Fallback for `binary_sensor` without a known `device_class`. */
1135
+ DeviceRole["BinarySensor"] = "binary-sensor";
1136
+ DeviceRole["TemperatureSensor"] = "temperature-sensor";
1137
+ DeviceRole["HumiditySensor"] = "humidity-sensor";
1138
+ DeviceRole["AmbientLightSensor"] = "ambient-light-sensor";
1139
+ DeviceRole["PressureSensor"] = "pressure-sensor";
1140
+ /** Wind speed or direction (weather-station `wind-sensor` cap). */
1141
+ DeviceRole["WindSensor"] = "wind-sensor";
1142
+ /** Rain accumulation or rate (weather-station `rain-sensor` cap). */
1143
+ DeviceRole["RainSensor"] = "rain-sensor";
1144
+ /** UV index (weather-station `uv-sensor` cap). */
1145
+ DeviceRole["UvSensor"] = "uv-sensor";
1146
+ /** Solar irradiance W/m² (weather-station `solar-radiation-sensor` cap).
1147
+ * Distinct from AmbientLightSensor (lux). */
1148
+ DeviceRole["SolarRadiationSensor"] = "solar-radiation-sensor";
1149
+ /** Soil moisture % (garden/weather `soil-moisture-sensor` cap). */
1150
+ DeviceRole["SoilMoistureSensor"] = "soil-moisture-sensor";
1151
+ DeviceRole["PowerSensor"] = "power-sensor";
1152
+ DeviceRole["EnergySensor"] = "energy-sensor";
1153
+ DeviceRole["VoltageSensor"] = "voltage-sensor";
1154
+ DeviceRole["CurrentSensor"] = "current-sensor";
1155
+ DeviceRole["AirQualitySensor"] = "air-quality-sensor";
1156
+ /** Battery level (numeric % via `sensor` OR low-bool via
1157
+ * `binary_sensor` — the cap distinguishes via the value type). */
1158
+ DeviceRole["BatterySensor"] = "battery-sensor";
1159
+ /** Fallback for `sensor` numeric without a known `device_class`. */
1160
+ DeviceRole["NumericSensor"] = "numeric-sensor";
1161
+ /** String / enum state (HA `sensor` with `state_class: enum` or
1162
+ * `attributes.options`). */
1163
+ DeviceRole["EnumSensor"] = "enum-sensor";
1164
+ /** Date / timestamp state (HA `sensor` with `device_class: timestamp`
1165
+ * or `date`). The slice carries the raw ISO string verbatim (hosted on
1166
+ * the `enum-sensor` cap); the UI renders it locale-formatted. */
1167
+ DeviceRole["DateTimeSensor"] = "datetime-sensor";
1168
+ /** Last-resort fallback when nothing else matches. */
1169
+ DeviceRole["GenericSensor"] = "generic-sensor";
1170
+ DeviceRole["NumericControl"] = "numeric-control";
1171
+ DeviceRole["SelectControl"] = "select-control";
1172
+ DeviceRole["TextControl"] = "text-control";
1173
+ DeviceRole["DateTimeControl"] = "datetime-control";
1174
+ /** Mobile push notifier (HA `notify.mobile_app_*`) — supports
1175
+ * rich features (image, priority, channel routing). */
1176
+ DeviceRole["MobilePushNotifier"] = "mobile-push-notifier";
1177
+ /** Chat / messaging service (HA `notify.telegram_*`,
1178
+ * `notify.discord_*`, etc.). */
1179
+ DeviceRole["MessagingNotifier"] = "messaging-notifier";
1180
+ /** Email-based delivery (HA `notify.smtp`, etc.). */
1181
+ DeviceRole["EmailNotifier"] = "email-notifier";
1182
+ /** Fallback when the notifier service name doesn't match a known
1183
+ * pattern. */
1184
+ DeviceRole["GenericNotifier"] = "generic-notifier";
1185
+ /** Emits a pulse train (infrared or RF) on request — the `ir-transmitter`
1186
+ * cap. A `DeviceType.Generic` device. */
1187
+ DeviceRole["IrTransmitter"] = "ir-transmitter";
1188
+ return DeviceRole;
1189
+ }({});
1190
+ //#endregion
815
1191
  //#region ../../node_modules/zod/v4/core/core.js
816
1192
  var _a$1;
817
1193
  function $constructor(name, initializer, params) {
@@ -5490,7 +5866,7 @@ var ZodIssueCode = {
5490
5866
  var ZodFirstPartyTypeKind;
5491
5867
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5492
5868
  //#endregion
5493
- //#region ../types/dist/sleep-SX9bkW3_.mjs
5869
+ //#region ../types/dist/sleep-CSYuxssh.mjs
5494
5870
  /**
5495
5871
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5496
5872
  * window to float samples (D455).
@@ -6006,6 +6382,102 @@ function emitReadiness(bus, params) {
6006
6382
  ts
6007
6383
  }));
6008
6384
  }
6385
+ var NOT_RUN = {
6386
+ declared: false,
6387
+ snapshot: null,
6388
+ applied: [],
6389
+ failed: [],
6390
+ blocked: [],
6391
+ skipped: [],
6392
+ blockOwner: []
6393
+ };
6394
+ /**
6395
+ * Offer `migrations` to the engine and run what it says to run, in its order. Never
6396
+ * throws: an unreachable or refusing engine is logged and reported `declared: false`,
6397
+ * because the hub (and this addon's boot) must not hang on a migration.
6398
+ */
6399
+ async function runAddonMigrations(host, migrations, logger) {
6400
+ const first = migrations[0];
6401
+ if (first === void 0) return NOT_RUN;
6402
+ const owner = first.meta.owner;
6403
+ const log = logger.withTags({ migrationOwner: owner });
6404
+ const byId = new Map(migrations.map((m) => [m.meta.id, m]));
6405
+ let declaration;
6406
+ try {
6407
+ declaration = await host.declareOwner({
6408
+ owner,
6409
+ metas: migrations.map((m) => m.meta)
6410
+ });
6411
+ } catch (err) {
6412
+ log.error("the migration engine refused or could not take this addon catalogue — none ran", { meta: { error: errMsg$1(err) } });
6413
+ return {
6414
+ ...NOT_RUN,
6415
+ blockOwner: migrations.filter((m) => m.meta.onFailure === "block-owner").map((m) => m.meta.id)
6416
+ };
6417
+ }
6418
+ const applied = [];
6419
+ const failed = [];
6420
+ const blocked = [];
6421
+ const skipped = [];
6422
+ const settle = (id, status) => {
6423
+ if (status === "applied") applied.push(id);
6424
+ else if (status === "failed") failed.push(id);
6425
+ else if (status === "blocked") blocked.push(id);
6426
+ else skipped.push(id);
6427
+ };
6428
+ for (const step of declaration.steps) {
6429
+ const bound = byId.get(step.id);
6430
+ if (bound === void 0 || step.action === "skip") {
6431
+ skipped.push(step.id);
6432
+ continue;
6433
+ }
6434
+ const tags = { migrationId: step.id };
6435
+ try {
6436
+ const gate = await host.startMigration({ id: step.id });
6437
+ if (!gate.proceed) {
6438
+ log.warn("migration not run", {
6439
+ tags,
6440
+ meta: {
6441
+ state: gate.state,
6442
+ reason: gate.reason
6443
+ }
6444
+ });
6445
+ settle(step.id, gate.state === "pending" ? "blocked" : gate.state);
6446
+ continue;
6447
+ }
6448
+ const result = await bound.execute();
6449
+ const outcome = await host.finishMigration({
6450
+ id: step.id,
6451
+ result
6452
+ });
6453
+ if (outcome.status === "applied") log.info("migration applied", {
6454
+ tags,
6455
+ meta: { rowsChanged: outcome.rowsChanged }
6456
+ });
6457
+ else log.error("migration failed", {
6458
+ tags,
6459
+ meta: { error: outcome.error }
6460
+ });
6461
+ settle(step.id, outcome.status);
6462
+ } catch (err) {
6463
+ log.error("migration could not be completed with the engine", {
6464
+ tags,
6465
+ meta: { error: errMsg$1(err) }
6466
+ });
6467
+ failed.push(step.id);
6468
+ }
6469
+ }
6470
+ const blockOwner = [...failed, ...blocked].filter((id) => byId.get(id)?.meta.onFailure === "block-owner");
6471
+ return {
6472
+ declared: true,
6473
+ snapshot: declaration.snapshot,
6474
+ applied,
6475
+ failed,
6476
+ blocked,
6477
+ skipped,
6478
+ blockOwner
6479
+ };
6480
+ }
6009
6481
  /**
6010
6482
  * Build a {@link DurableState} over a single store key. Transport-agnostic:
6011
6483
  * `read`/`write` are the addon-store or device-store accessors. The whole
@@ -7061,6 +7533,28 @@ var BaseAddon = class {
7061
7533
  return normalized;
7062
7534
  }
7063
7535
  /**
7536
+ * Run this addon's migration catalogue (D987 M3) through the hub's `migrations`
7537
+ * engine. Call it at the point of the boot where the data must already have the new
7538
+ * shape — `onInitialize`, or `onRestoreDevices` for a migration that needs the
7539
+ * restored devices — with the catalogue bound to the addon's ports
7540
+ * (`defineAddonMigrations(ADDON_MIGRATIONS, ports)`).
7541
+ *
7542
+ * An engine that cannot be reached or refuses the catalogue is logged and runs
7543
+ * nothing; the boot continues. A migration that FAILED (or was blocked by one)
7544
+ * and declares `onFailure: 'block-owner'` makes this throw, so the addon does not
7545
+ * serve data whose shape it cannot trust; `tolerate` migrations never do.
7546
+ */
7547
+ async runMigrations(migrations) {
7548
+ const api = this.ctx.api.migrations;
7549
+ const report = await runAddonMigrations({
7550
+ declareOwner: (input) => api.declareOwner.mutate(input),
7551
+ startMigration: (input) => api.startMigration.mutate(input),
7552
+ finishMigration: (input) => api.finishMigration.mutate(input)
7553
+ }, migrations, this.ctx.logger);
7554
+ 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`);
7555
+ return report;
7556
+ }
7557
+ /**
7064
7558
  * Called by the isolated-process runner AFTER `broker.start()`.
7065
7559
  * In-process addons never need this because the hub broker is already
7066
7560
  * running when `initialize()` fires. For forked children the broker
@@ -7193,6 +7687,26 @@ var BaseAddon = class {
7193
7687
  * alternative — skip it — turns a rename into a surface that quietly
7194
7688
  * empties, which looks exactly like an addon with nothing to configure.
7195
7689
  */
7690
+ /**
7691
+ * The form schema of ONE integration instance, or `null` to use {@link globalSettingsSchema}.
7692
+ *
7693
+ * Override it only when an `instanceMode: multiple` addon's instances differ: an NVR integration
7694
+ * needs its connection fields, the default integration the addon's own sections. It is the
7695
+ * SHAPE of the form only — the values live in `integrations.getSettings`, and the write path is
7696
+ * unchanged (`integrations.setSettings` for an account integration).
7697
+ */
7698
+ async integrationSettingsSchema(_instance) {
7699
+ return null;
7700
+ }
7701
+ /**
7702
+ * What the create wizard and the integration edit page render for one instance: the addon's
7703
+ * per-instance schema when it declares one, else its global schema (what they always showed).
7704
+ */
7705
+ async getIntegrationFormSchema(instance, nodeId) {
7706
+ const scoped = await this.integrationSettingsSchema(instance);
7707
+ if (scoped === null) return this.getGlobalSettings(void 0, void 0, nodeId);
7708
+ return hydrateSchema(scoped, {}, { inlineSecretsAsViews: true });
7709
+ }
7196
7710
  async getIntegrationSettings(nodeId) {
7197
7711
  const declared = this.integrationSettingSections();
7198
7712
  if (declared.length === 0) return null;
@@ -8083,407 +8597,6 @@ var RecordKindDeclarationSchema = object({
8083
8597
  }).strict();
8084
8598
  /** The kind names: lower-case, dash separated, short enough for an index name. */
8085
8599
  var RecordKindNameSchema = string().regex(/^[a-z][a-z0-9-]{0,47}$/);
8086
- var READING_QUANTITIES = [
8087
- "temperature",
8088
- "pressure",
8089
- "speed",
8090
- "precipitation",
8091
- "precipitation-rate",
8092
- "length",
8093
- "area",
8094
- "illuminance",
8095
- "irradiance",
8096
- "power",
8097
- "energy",
8098
- "voltage",
8099
- "current",
8100
- "apparent-power",
8101
- "humidity",
8102
- "percentage",
8103
- "concentration-volume",
8104
- "concentration-mass",
8105
- "concentration-ppb",
8106
- "volume",
8107
- "duration",
8108
- "duration-ms",
8109
- "information",
8110
- "sound-level",
8111
- "signal-level",
8112
- "colour-temperature",
8113
- "angle",
8114
- "bitrate",
8115
- "rate",
8116
- "mass",
8117
- "index",
8118
- "ratio",
8119
- "count",
8120
- "none",
8121
- "device"
8122
- ];
8123
- var ReadingQuantitySchema = _enum(READING_QUANTITIES);
8124
- new Set(READING_QUANTITIES);
8125
- /**
8126
- * Stored unit symbol for a quantity. `none` means the number is dimensionless
8127
- * (or an index / ratio / count). `device` means the cap has no single unit.
8128
- */
8129
- var QUANTITY_BASE = {
8130
- temperature: "°C",
8131
- pressure: "hPa",
8132
- speed: "m/s",
8133
- precipitation: "mm",
8134
- "precipitation-rate": "mm/h",
8135
- length: "m",
8136
- area: "m²",
8137
- illuminance: "lx",
8138
- irradiance: "W/m²",
8139
- power: "W",
8140
- energy: "kWh",
8141
- voltage: "V",
8142
- current: "A",
8143
- "apparent-power": "VA",
8144
- humidity: "%",
8145
- percentage: "%",
8146
- "concentration-volume": "ppm",
8147
- "concentration-mass": "µg/m³",
8148
- "concentration-ppb": "ppb",
8149
- volume: "L",
8150
- duration: "s",
8151
- "duration-ms": "ms",
8152
- information: "B",
8153
- "sound-level": "dBFS",
8154
- "signal-level": "dBm",
8155
- "colour-temperature": "mired",
8156
- angle: "°",
8157
- bitrate: "kbps",
8158
- rate: "fps",
8159
- mass: "kg",
8160
- index: "none",
8161
- ratio: "none",
8162
- count: "none",
8163
- none: "none",
8164
- device: "device"
8165
- };
8166
- /** The stored unit, or `undefined` when the quantity has no unit symbol. */
8167
- function baseUnitOf(quantity) {
8168
- const symbol = QUANTITY_BASE[quantity];
8169
- if (symbol === "none" || symbol === "device") return void 0;
8170
- return symbol;
8171
- }
8172
- function readingMeta(quantity, extras) {
8173
- return {
8174
- quantity,
8175
- ...extras?.precision !== void 0 ? { precision: extras.precision } : {},
8176
- ...extras?.label !== void 0 ? { label: extras.label } : {}
8177
- };
8178
- }
8179
- /** Shared Zod schemas used across streaming capabilities. */
8180
- var CamProfileSchema = _enum([
8181
- "high",
8182
- "mid",
8183
- "low"
8184
- ]);
8185
- /**
8186
- * Which rung a per-camera consumer listens on: an explicit profile, or `auto`.
8187
- *
8188
- * `auto` is a REAL value, not an absent one — it means "resolve it by the rule
8189
- * that consumer owns". It lives beside `CamProfile` because a rung is the only
8190
- * operator-facing way to name a stream: a cam-stream id is broker-internal and
8191
- * moves when a slot is reassigned, so a stored id silently stops meaning what
8192
- * the operator picked. Today's one user is the audio analyser, whose rule is
8193
- * "the lowest AVAILABLE native rung" (D537).
8194
- */
8195
- var AudioStreamPickSchema = union([CamProfileSchema, literal("auto")]);
8196
- var CamStreamKindSchema = _enum([
8197
- "pull-rtsp",
8198
- "pull-rtmp",
8199
- "pull-http",
8200
- "pull-flv",
8201
- "pull-rfc4571",
8202
- "push-annexb",
8203
- "derived"
8204
- ]);
8205
- var CamStreamResolutionSchema = object({
8206
- width: number().int().positive().meta(readingMeta("none")),
8207
- height: number().int().positive().meta(readingMeta("none"))
8208
- });
8209
- var CameraStreamSchema = object({
8210
- /** Stable, provider-assigned id unique within the (deviceId) scope. */
8211
- camStreamId: string().min(1),
8212
- deviceId: number().int().nonnegative(),
8213
- kind: CamStreamKindSchema,
8214
- /** Required for pull-* kinds. Ignored for push-annexb. */
8215
- url: string().optional(),
8216
- codec: string().optional(),
8217
- resolution: CamStreamResolutionSchema.optional(),
8218
- fps: number().positive().optional(),
8219
- /** Human label surfaced in the Admin UI "Camera Stream" dropdown. */
8220
- label: string().optional(),
8221
- /**
8222
- * Device-level features the publisher advertised (e.g. `battery-operated`).
8223
- * The broker, snapshot orchestrator, and prebuffer manager all consult
8224
- * this list to derive policy — relaxed stall watchdog for battery
8225
- * cams, prebuffer off by default, longer snapshot rate-limit, etc.
8226
- *
8227
- * Single source of truth replacing per-stream flags like the
8228
- * historical `allowStall`: if the publisher knows the camera is
8229
- * battery-powered, every downstream service derives the right policy
8230
- * from this list.
8231
- */
8232
- deviceFeatures: array(string()).optional(),
8233
- /**
8234
- * Whether this stream participates in the broker's automatic profile
8235
- * assignment (`computeInitialAssignment`). Defaults to `true`. Publishers
8236
- * use `false` when they want a stream to be SELECTABLE in the UI but not
8237
- * picked by default — e.g. Reolink publishes its native Baichuan streams
8238
- * as `autoEligible: true` (the recommended path) and its RTSP / RTMP
8239
- * mirrors as `autoEligible: false` (still pickable per slot, just not
8240
- * the auto choice). Manual `assignProfile` calls remain valid for
8241
- * non-eligible streams.
8242
- */
8243
- autoEligible: boolean().optional(),
8244
- /**
8245
- * The profile slot the PUBLISHER says this stream is: `low` for a stream
8246
- * whose only sensible role is the low-bandwidth one, `high` for a main
8247
- * stream. Consulted by the broker's automatic ranking
8248
- * (`rankInitialAssignment`) BEFORE the pixel-count heuristic, and only there:
8249
- * an operator's manual assignment still wins, and an absent hint is the
8250
- * pixel-ranked default every camera had before this field existed.
8251
- *
8252
- * Why it exists: a camera with ONE stream ranked to `mid` — the slot no
8253
- * storage class is written for on its own (`recordings` is high|mid,
8254
- * `recordingsLow` is low) and the one profile scrub does not read. The robot
8255
- * camera's single 720p relay is a `low` in every respect except the slot the
8256
- * heuristic put it in.
8257
- */
8258
- profileHint: CamProfileSchema.optional(),
8259
- /**
8260
- * Transport-specific opaque metadata. The broker passes it through to
8261
- * the source reader without inspecting it. Currently used by
8262
- * `pull-rfc4571` streams to carry the upstream SDP (so the reader can
8263
- * route RTP packets to the right depacketizer without an in-band
8264
- * DESCRIBE phase). Other kinds typically leave it undefined.
8265
- */
8266
- metadata: record(string(), unknown()).optional()
8267
- });
8268
- var ProfileSlotStatusSchema = _enum([
8269
- "unassigned",
8270
- "idle",
8271
- "connecting",
8272
- "streaming",
8273
- "error"
8274
- ]);
8275
- var ProfileSlotSchema = object({
8276
- deviceId: number().int().nonnegative(),
8277
- profile: CamProfileSchema,
8278
- /** Broker id the rest of the system addresses: `${deviceId}/${profile}`. */
8279
- brokerId: string(),
8280
- /** `null` when the profile is unassigned. */
8281
- sourceCamStreamId: string().nullable(),
8282
- status: ProfileSlotStatusSchema,
8283
- resolution: CamStreamResolutionSchema.optional(),
8284
- codec: string().optional(),
8285
- preBufferSec: number().nonnegative().optional(),
8286
- errorMessage: string().optional()
8287
- });
8288
- /**
8289
- * Zod schema for StreamSourceEntry — the canonical stream descriptor
8290
- * exposed by ICameraDevice.getStreamSources() and consumed by the broker.
8291
- */
8292
- var StreamSourceEntrySchema$1 = object({
8293
- id: string(),
8294
- label: string(),
8295
- protocol: _enum([
8296
- "rtsp",
8297
- "rtmp",
8298
- "annexb",
8299
- "http-mjpeg",
8300
- "webrtc",
8301
- "custom"
8302
- ]),
8303
- url: string().optional(),
8304
- resolution: object({
8305
- width: number(),
8306
- height: number()
8307
- }).readonly().optional(),
8308
- fps: number().optional(),
8309
- bitrate: number().optional(),
8310
- codec: string().optional(),
8311
- profileHint: CamProfileSchema.optional()
8312
- });
8313
- object({
8314
- type: string(),
8315
- url: string(),
8316
- videoCodec: string().optional(),
8317
- audioCodec: string().optional(),
8318
- metadata: record(string(), unknown()).readonly().optional()
8319
- });
8320
- /**
8321
- * Wire schema for `FrameHandle` — a zero-pixel, serialisable reference to a
8322
- * frame in a shared-memory ring (Phase 5 / D9). Mirrors the `FrameHandle` TS
8323
- * interface in `interfaces/frame-handle.ts` field-for-field so a cap method
8324
- * (the runner's native-crop and pipeline-executor inputs) can carry handles
8325
- * over tRPC / Moleculer.
8326
- *
8327
- * The `satisfies` assertion below pins this schema to the interface: if a
8328
- * field is added to / removed from `FrameHandle` without a matching schema
8329
- * edit, `z.infer<typeof FrameHandleSchema>` stops being assignable to
8330
- * `FrameHandle` and the build fails — no silent drift.
8331
- */
8332
- var FrameHandleSchema = object({
8333
- shmId: string(),
8334
- slot: number().int().nonnegative(),
8335
- seq: number().int().nonnegative(),
8336
- width: number().int().positive(),
8337
- height: number().int().positive(),
8338
- format: _enum([
8339
- "jpeg",
8340
- "rgb",
8341
- "bgr",
8342
- "yuv420",
8343
- "gray"
8344
- ]),
8345
- pts: number(),
8346
- byteLength: number().int().nonnegative(),
8347
- nodeId: string(),
8348
- slotCount: number().int().positive()
8349
- });
8350
- /**
8351
- * Wire schema for a decoded audio chunk (Phase 5 / D9). Mirrors the
8352
- * `DecodedAudioChunk` TS interface in `interfaces/stream-broker.ts`: PCM
8353
- * sample bytes plus the track parameters a consumer needs to interpret them.
8354
- *
8355
- * Audio chunks are tiny (a ~500ms AudioCodecSession window is a few KB of
8356
- * Float32 PCM), so unlike video frames they ship their bytes INLINE over
8357
- * tRPC / Moleculer — no shared-memory plane. `data` is typed `Uint8Array`
8358
- * (the wire-serialisable supertype of `Buffer`); a `Buffer` is assignable to
8359
- * it.
8360
- */
8361
- var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
8362
- var DecodedAudioChunkSchema = object({
8363
- data: _instanceof(Uint8Array),
8364
- sampleRate: number().int().positive(),
8365
- channels: number().int().positive(),
8366
- timestamp: number(),
8367
- /**
8368
- * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
8369
- * byte, for any peer that never heard of this field. A coded window
8370
- * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
8371
- * subscription that DECLARED it accepts one, so absence can never mean
8372
- * "coded bytes a consumer will read as floats" (D455).
8373
- */
8374
- format: AudioChunkFormatSchema.optional()
8375
- });
8376
- /**
8377
- * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). Audio ships
8378
- * its bytes inline: a consumer asks the broker for the decoded audio-chunk
8379
- * stream of one broker; the broker keeps a per-subscription bounded FIFO queue
8380
- * the consumer drains via `pullAudioChunks`.
8381
- */
8382
- var SubscribeAudioChunksInputSchema = object({
8383
- brokerId: string(),
8384
- /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
8385
- tag: string().optional(),
8386
- /**
8387
- * Byte formats this subscriber can READ, best first. The broker serves the
8388
- * chunk's own format when it is in this list and expands to `f32le`
8389
- * otherwise, so a subscriber is never handed bytes it cannot interpret.
8390
- *
8391
- * Absent (or without the source format) means `f32le` — the behaviour every
8392
- * subscriber had before D455, unchanged. This is the negotiation half of
8393
- * the source-bytes lever: it is what lets the broker and its consumers
8394
- * deploy one at a time across three nodes.
8395
- */
8396
- accept: array(AudioChunkFormatSchema).readonly().optional()
8397
- });
8398
- /** Result of `stream-broker.subscribeAudioChunks`. */
8399
- var SubscribeAudioChunksResultSchema = object({
8400
- /** Opaque id passed to `pullAudioChunks` / `unsubscribeAudioChunks`. */
8401
- subscriptionId: string() });
8402
- var BrokerStatsSchema = object({
8403
- status: _enum([
8404
- "idle",
8405
- "connecting",
8406
- "streaming",
8407
- "error",
8408
- "stopped"
8409
- ]),
8410
- inputFps: number(),
8411
- encodedSubscribers: number(),
8412
- uptimeMs: number(),
8413
- bitrateKbps: number(),
8414
- idrIntervalMs: number(),
8415
- codec: string().optional(),
8416
- totalBytes: number(),
8417
- packetCount: number(),
8418
- rtspClients: number(),
8419
- pipeClients: number(),
8420
- preBufferSec: number(),
8421
- preBufferMs: number(),
8422
- preBufferPackets: number(),
8423
- /**
8424
- * Detected audio track parameters from the RTSP DESCRIBE / SDP. `null`
8425
- * when the stream has no audio track or the broker is in cold start.
8426
- * `supported = false` means the codec was detected but the local
8427
- * decoder pipeline cannot produce PCM chunks (e.g. AAC without the
8428
- * AAC pipeline wired). Surfaced in the UI device-overview so operators
8429
- * can pre-pick the audio-analysis model that matches the codec.
8430
- */
8431
- audio: object({
8432
- codec: string(),
8433
- sampleRate: number(),
8434
- channels: number(),
8435
- supported: boolean()
8436
- }).nullable().optional(),
8437
- /**
8438
- * BROKER-SIDE AUDIO MUTE (D83). `true` = this broker is deliberately
8439
- * distributing none of the device's audio, on live or recording.
8440
- *
8441
- * Present so a silent camera can be told apart from a broken one on the
8442
- * stream panel itself, without cross-referencing the switch group: a
8443
- * broker holding an `audio` track descriptor while `audioMuted` is true is
8444
- * working exactly as asked. `audioMutedDropped` counts the audio units
8445
- * thrown away since the current dial — it is how you confirm from stats
8446
- * alone that the mute is on the packet path and not merely persisted.
8447
- */
8448
- audioMuted: boolean().optional(),
8449
- audioMutedDropped: number().optional()
8450
- });
8451
- /**
8452
- * Exporter-facing "profile restream" entry. Returned by
8453
- * `cameraStreams.getProfileRtspEntries` — one per ASSIGNED profile slot
8454
- * (high/mid/low). `brokerId` is the PROFILE-keyed broker id
8455
- * (`${deviceId}/${profile}`, e.g. `15/high`); its `url` is a broker
8456
- * RTSP restream that aliases the profile's assigned source broker, so
8457
- * every consumer dialling a profile converges on the same single pull.
8458
- * `codec`/`resolution` describe the assigned SOURCE camStream (for the
8459
- * `auto` resolution-closest pick). Distinct from `RtspRestreamEntry`
8460
- * (raw per-camStream, live-view only).
8461
- */
8462
- var ProfileRtspEntrySchema = object({
8463
- profile: CamProfileSchema,
8464
- /** Profile-keyed broker id, format `${deviceId}/${profile}` (e.g. `"15/high"`). */
8465
- brokerId: string(),
8466
- url: string(),
8467
- mutedUrl: string(),
8468
- enabled: boolean(),
8469
- codec: string().optional(),
8470
- resolution: CamStreamResolutionSchema.optional()
8471
- });
8472
- /**
8473
- * The model weight formats a catalog entry can ship. Schema-free on purpose:
8474
- * `types/models.ts` builds Zod schemas from it, but a runner-closure consumer
8475
- * (the model downloader in `@camstack/system`) needs only the list and must
8476
- * reach it through `@camstack/types/addon` without building the cap schema
8477
- * graph (D28).
8478
- */
8479
- var MODEL_FORMATS = [
8480
- "onnx",
8481
- "coreml",
8482
- "openvino",
8483
- "tflite",
8484
- "pt",
8485
- "gguf"
8486
- ];
8487
8600
  object({
8488
8601
  field: string().min(1),
8489
8602
  on: literal("advance")
@@ -8572,6 +8685,407 @@ function optionalMethod(input, output, options) {
8572
8685
  providerOptional: true
8573
8686
  };
8574
8687
  }
8688
+ var READING_QUANTITIES = [
8689
+ "temperature",
8690
+ "pressure",
8691
+ "speed",
8692
+ "precipitation",
8693
+ "precipitation-rate",
8694
+ "length",
8695
+ "area",
8696
+ "illuminance",
8697
+ "irradiance",
8698
+ "power",
8699
+ "energy",
8700
+ "voltage",
8701
+ "current",
8702
+ "apparent-power",
8703
+ "humidity",
8704
+ "percentage",
8705
+ "concentration-volume",
8706
+ "concentration-mass",
8707
+ "concentration-ppb",
8708
+ "volume",
8709
+ "duration",
8710
+ "duration-ms",
8711
+ "information",
8712
+ "sound-level",
8713
+ "signal-level",
8714
+ "colour-temperature",
8715
+ "angle",
8716
+ "bitrate",
8717
+ "rate",
8718
+ "mass",
8719
+ "index",
8720
+ "ratio",
8721
+ "count",
8722
+ "none",
8723
+ "device"
8724
+ ];
8725
+ var ReadingQuantitySchema = _enum(READING_QUANTITIES);
8726
+ new Set(READING_QUANTITIES);
8727
+ /**
8728
+ * Stored unit symbol for a quantity. `none` means the number is dimensionless
8729
+ * (or an index / ratio / count). `device` means the cap has no single unit.
8730
+ */
8731
+ var QUANTITY_BASE = {
8732
+ temperature: "°C",
8733
+ pressure: "hPa",
8734
+ speed: "m/s",
8735
+ precipitation: "mm",
8736
+ "precipitation-rate": "mm/h",
8737
+ length: "m",
8738
+ area: "m²",
8739
+ illuminance: "lx",
8740
+ irradiance: "W/m²",
8741
+ power: "W",
8742
+ energy: "kWh",
8743
+ voltage: "V",
8744
+ current: "A",
8745
+ "apparent-power": "VA",
8746
+ humidity: "%",
8747
+ percentage: "%",
8748
+ "concentration-volume": "ppm",
8749
+ "concentration-mass": "µg/m³",
8750
+ "concentration-ppb": "ppb",
8751
+ volume: "L",
8752
+ duration: "s",
8753
+ "duration-ms": "ms",
8754
+ information: "B",
8755
+ "sound-level": "dBFS",
8756
+ "signal-level": "dBm",
8757
+ "colour-temperature": "mired",
8758
+ angle: "°",
8759
+ bitrate: "kbps",
8760
+ rate: "fps",
8761
+ mass: "kg",
8762
+ index: "none",
8763
+ ratio: "none",
8764
+ count: "none",
8765
+ none: "none",
8766
+ device: "device"
8767
+ };
8768
+ /** The stored unit, or `undefined` when the quantity has no unit symbol. */
8769
+ function baseUnitOf(quantity) {
8770
+ const symbol = QUANTITY_BASE[quantity];
8771
+ if (symbol === "none" || symbol === "device") return void 0;
8772
+ return symbol;
8773
+ }
8774
+ function readingMeta(quantity, extras) {
8775
+ return {
8776
+ quantity,
8777
+ ...extras?.precision !== void 0 ? { precision: extras.precision } : {},
8778
+ ...extras?.label !== void 0 ? { label: extras.label } : {}
8779
+ };
8780
+ }
8781
+ /** Shared Zod schemas used across streaming capabilities. */
8782
+ var CamProfileSchema = _enum([
8783
+ "high",
8784
+ "mid",
8785
+ "low"
8786
+ ]);
8787
+ /**
8788
+ * Which rung a per-camera consumer listens on: an explicit profile, or `auto`.
8789
+ *
8790
+ * `auto` is a REAL value, not an absent one — it means "resolve it by the rule
8791
+ * that consumer owns". It lives beside `CamProfile` because a rung is the only
8792
+ * operator-facing way to name a stream: a cam-stream id is broker-internal and
8793
+ * moves when a slot is reassigned, so a stored id silently stops meaning what
8794
+ * the operator picked. Today's one user is the audio analyser, whose rule is
8795
+ * "the lowest AVAILABLE native rung" (D537).
8796
+ */
8797
+ var AudioStreamPickSchema = union([CamProfileSchema, literal("auto")]);
8798
+ var CamStreamKindSchema = _enum([
8799
+ "pull-rtsp",
8800
+ "pull-rtmp",
8801
+ "pull-http",
8802
+ "pull-flv",
8803
+ "pull-rfc4571",
8804
+ "push-annexb",
8805
+ "derived"
8806
+ ]);
8807
+ var CamStreamResolutionSchema = object({
8808
+ width: number().int().positive().meta(readingMeta("none")),
8809
+ height: number().int().positive().meta(readingMeta("none"))
8810
+ });
8811
+ var CameraStreamSchema = object({
8812
+ /** Stable, provider-assigned id unique within the (deviceId) scope. */
8813
+ camStreamId: string().min(1),
8814
+ deviceId: number().int().nonnegative(),
8815
+ kind: CamStreamKindSchema,
8816
+ /** Required for pull-* kinds. Ignored for push-annexb. */
8817
+ url: string().optional(),
8818
+ codec: string().optional(),
8819
+ resolution: CamStreamResolutionSchema.optional(),
8820
+ fps: number().positive().optional(),
8821
+ /** Human label surfaced in the Admin UI "Camera Stream" dropdown. */
8822
+ label: string().optional(),
8823
+ /**
8824
+ * Device-level features the publisher advertised (e.g. `battery-operated`).
8825
+ * The broker, snapshot orchestrator, and prebuffer manager all consult
8826
+ * this list to derive policy — relaxed stall watchdog for battery
8827
+ * cams, prebuffer off by default, longer snapshot rate-limit, etc.
8828
+ *
8829
+ * Single source of truth replacing per-stream flags like the
8830
+ * historical `allowStall`: if the publisher knows the camera is
8831
+ * battery-powered, every downstream service derives the right policy
8832
+ * from this list.
8833
+ */
8834
+ deviceFeatures: array(string()).optional(),
8835
+ /**
8836
+ * Whether this stream participates in the broker's automatic profile
8837
+ * assignment (`computeInitialAssignment`). Defaults to `true`. Publishers
8838
+ * use `false` when they want a stream to be SELECTABLE in the UI but not
8839
+ * picked by default — e.g. Reolink publishes its native Baichuan streams
8840
+ * as `autoEligible: true` (the recommended path) and its RTSP / RTMP
8841
+ * mirrors as `autoEligible: false` (still pickable per slot, just not
8842
+ * the auto choice). Manual `assignProfile` calls remain valid for
8843
+ * non-eligible streams.
8844
+ */
8845
+ autoEligible: boolean().optional(),
8846
+ /**
8847
+ * The profile slot the PUBLISHER says this stream is: `low` for a stream
8848
+ * whose only sensible role is the low-bandwidth one, `high` for a main
8849
+ * stream. Consulted by the broker's automatic ranking
8850
+ * (`rankInitialAssignment`) BEFORE the pixel-count heuristic, and only there:
8851
+ * an operator's manual assignment still wins, and an absent hint is the
8852
+ * pixel-ranked default every camera had before this field existed.
8853
+ *
8854
+ * Why it exists: a camera with ONE stream ranked to `mid` — the slot no
8855
+ * storage class is written for on its own (`recordings` is high|mid,
8856
+ * `recordingsLow` is low) and the one profile scrub does not read. The robot
8857
+ * camera's single 720p relay is a `low` in every respect except the slot the
8858
+ * heuristic put it in.
8859
+ */
8860
+ profileHint: CamProfileSchema.optional(),
8861
+ /**
8862
+ * Transport-specific opaque metadata. The broker passes it through to
8863
+ * the source reader without inspecting it. Currently used by
8864
+ * `pull-rfc4571` streams to carry the upstream SDP (so the reader can
8865
+ * route RTP packets to the right depacketizer without an in-band
8866
+ * DESCRIBE phase). Other kinds typically leave it undefined.
8867
+ */
8868
+ metadata: record(string(), unknown()).optional()
8869
+ });
8870
+ var ProfileSlotStatusSchema = _enum([
8871
+ "unassigned",
8872
+ "idle",
8873
+ "connecting",
8874
+ "streaming",
8875
+ "error"
8876
+ ]);
8877
+ var ProfileSlotSchema = object({
8878
+ deviceId: number().int().nonnegative(),
8879
+ profile: CamProfileSchema,
8880
+ /** Broker id the rest of the system addresses: `${deviceId}/${profile}`. */
8881
+ brokerId: string(),
8882
+ /** `null` when the profile is unassigned. */
8883
+ sourceCamStreamId: string().nullable(),
8884
+ status: ProfileSlotStatusSchema,
8885
+ resolution: CamStreamResolutionSchema.optional(),
8886
+ codec: string().optional(),
8887
+ preBufferSec: number().nonnegative().optional(),
8888
+ errorMessage: string().optional()
8889
+ });
8890
+ /**
8891
+ * Zod schema for StreamSourceEntry — the canonical stream descriptor
8892
+ * exposed by ICameraDevice.getStreamSources() and consumed by the broker.
8893
+ */
8894
+ var StreamSourceEntrySchema$1 = object({
8895
+ id: string(),
8896
+ label: string(),
8897
+ protocol: _enum([
8898
+ "rtsp",
8899
+ "rtmp",
8900
+ "annexb",
8901
+ "http-mjpeg",
8902
+ "webrtc",
8903
+ "custom"
8904
+ ]),
8905
+ url: string().optional(),
8906
+ resolution: object({
8907
+ width: number(),
8908
+ height: number()
8909
+ }).readonly().optional(),
8910
+ fps: number().optional(),
8911
+ bitrate: number().optional(),
8912
+ codec: string().optional(),
8913
+ profileHint: CamProfileSchema.optional()
8914
+ });
8915
+ object({
8916
+ type: string(),
8917
+ url: string(),
8918
+ videoCodec: string().optional(),
8919
+ audioCodec: string().optional(),
8920
+ metadata: record(string(), unknown()).readonly().optional()
8921
+ });
8922
+ /**
8923
+ * Wire schema for `FrameHandle` — a zero-pixel, serialisable reference to a
8924
+ * frame in a shared-memory ring (Phase 5 / D9). Mirrors the `FrameHandle` TS
8925
+ * interface in `interfaces/frame-handle.ts` field-for-field so a cap method
8926
+ * (the runner's native-crop and pipeline-executor inputs) can carry handles
8927
+ * over tRPC / Moleculer.
8928
+ *
8929
+ * The `satisfies` assertion below pins this schema to the interface: if a
8930
+ * field is added to / removed from `FrameHandle` without a matching schema
8931
+ * edit, `z.infer<typeof FrameHandleSchema>` stops being assignable to
8932
+ * `FrameHandle` and the build fails — no silent drift.
8933
+ */
8934
+ var FrameHandleSchema = object({
8935
+ shmId: string(),
8936
+ slot: number().int().nonnegative(),
8937
+ seq: number().int().nonnegative(),
8938
+ width: number().int().positive(),
8939
+ height: number().int().positive(),
8940
+ format: _enum([
8941
+ "jpeg",
8942
+ "rgb",
8943
+ "bgr",
8944
+ "yuv420",
8945
+ "gray"
8946
+ ]),
8947
+ pts: number(),
8948
+ byteLength: number().int().nonnegative(),
8949
+ nodeId: string(),
8950
+ slotCount: number().int().positive()
8951
+ });
8952
+ /**
8953
+ * Wire schema for a decoded audio chunk (Phase 5 / D9). Mirrors the
8954
+ * `DecodedAudioChunk` TS interface in `interfaces/stream-broker.ts`: PCM
8955
+ * sample bytes plus the track parameters a consumer needs to interpret them.
8956
+ *
8957
+ * Audio chunks are tiny (a ~500ms AudioCodecSession window is a few KB of
8958
+ * Float32 PCM), so unlike video frames they ship their bytes INLINE over
8959
+ * tRPC / Moleculer — no shared-memory plane. `data` is typed `Uint8Array`
8960
+ * (the wire-serialisable supertype of `Buffer`); a `Buffer` is assignable to
8961
+ * it.
8962
+ */
8963
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
8964
+ var DecodedAudioChunkSchema = object({
8965
+ data: _instanceof(Uint8Array),
8966
+ sampleRate: number().int().positive(),
8967
+ channels: number().int().positive(),
8968
+ timestamp: number(),
8969
+ /**
8970
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
8971
+ * byte, for any peer that never heard of this field. A coded window
8972
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
8973
+ * subscription that DECLARED it accepts one, so absence can never mean
8974
+ * "coded bytes a consumer will read as floats" (D455).
8975
+ */
8976
+ format: AudioChunkFormatSchema.optional()
8977
+ });
8978
+ /**
8979
+ * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). Audio ships
8980
+ * its bytes inline: a consumer asks the broker for the decoded audio-chunk
8981
+ * stream of one broker; the broker keeps a per-subscription bounded FIFO queue
8982
+ * the consumer drains via `pullAudioChunks`.
8983
+ */
8984
+ var SubscribeAudioChunksInputSchema = object({
8985
+ brokerId: string(),
8986
+ /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
8987
+ tag: string().optional(),
8988
+ /**
8989
+ * Byte formats this subscriber can READ, best first. The broker serves the
8990
+ * chunk's own format when it is in this list and expands to `f32le`
8991
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
8992
+ *
8993
+ * Absent (or without the source format) means `f32le` — the behaviour every
8994
+ * subscriber had before D455, unchanged. This is the negotiation half of
8995
+ * the source-bytes lever: it is what lets the broker and its consumers
8996
+ * deploy one at a time across three nodes.
8997
+ */
8998
+ accept: array(AudioChunkFormatSchema).readonly().optional()
8999
+ });
9000
+ /** Result of `stream-broker.subscribeAudioChunks`. */
9001
+ var SubscribeAudioChunksResultSchema = object({
9002
+ /** Opaque id passed to `pullAudioChunks` / `unsubscribeAudioChunks`. */
9003
+ subscriptionId: string() });
9004
+ var BrokerStatsSchema = object({
9005
+ status: _enum([
9006
+ "idle",
9007
+ "connecting",
9008
+ "streaming",
9009
+ "error",
9010
+ "stopped"
9011
+ ]),
9012
+ inputFps: number(),
9013
+ encodedSubscribers: number(),
9014
+ uptimeMs: number(),
9015
+ bitrateKbps: number(),
9016
+ idrIntervalMs: number(),
9017
+ codec: string().optional(),
9018
+ totalBytes: number(),
9019
+ packetCount: number(),
9020
+ rtspClients: number(),
9021
+ pipeClients: number(),
9022
+ preBufferSec: number(),
9023
+ preBufferMs: number(),
9024
+ preBufferPackets: number(),
9025
+ /**
9026
+ * Detected audio track parameters from the RTSP DESCRIBE / SDP. `null`
9027
+ * when the stream has no audio track or the broker is in cold start.
9028
+ * `supported = false` means the codec was detected but the local
9029
+ * decoder pipeline cannot produce PCM chunks (e.g. AAC without the
9030
+ * AAC pipeline wired). Surfaced in the UI device-overview so operators
9031
+ * can pre-pick the audio-analysis model that matches the codec.
9032
+ */
9033
+ audio: object({
9034
+ codec: string(),
9035
+ sampleRate: number(),
9036
+ channels: number(),
9037
+ supported: boolean()
9038
+ }).nullable().optional(),
9039
+ /**
9040
+ * BROKER-SIDE AUDIO MUTE (D83). `true` = this broker is deliberately
9041
+ * distributing none of the device's audio, on live or recording.
9042
+ *
9043
+ * Present so a silent camera can be told apart from a broken one on the
9044
+ * stream panel itself, without cross-referencing the switch group: a
9045
+ * broker holding an `audio` track descriptor while `audioMuted` is true is
9046
+ * working exactly as asked. `audioMutedDropped` counts the audio units
9047
+ * thrown away since the current dial — it is how you confirm from stats
9048
+ * alone that the mute is on the packet path and not merely persisted.
9049
+ */
9050
+ audioMuted: boolean().optional(),
9051
+ audioMutedDropped: number().optional()
9052
+ });
9053
+ /**
9054
+ * Exporter-facing "profile restream" entry. Returned by
9055
+ * `cameraStreams.getProfileRtspEntries` — one per ASSIGNED profile slot
9056
+ * (high/mid/low). `brokerId` is the PROFILE-keyed broker id
9057
+ * (`${deviceId}/${profile}`, e.g. `15/high`); its `url` is a broker
9058
+ * RTSP restream that aliases the profile's assigned source broker, so
9059
+ * every consumer dialling a profile converges on the same single pull.
9060
+ * `codec`/`resolution` describe the assigned SOURCE camStream (for the
9061
+ * `auto` resolution-closest pick). Distinct from `RtspRestreamEntry`
9062
+ * (raw per-camStream, live-view only).
9063
+ */
9064
+ var ProfileRtspEntrySchema = object({
9065
+ profile: CamProfileSchema,
9066
+ /** Profile-keyed broker id, format `${deviceId}/${profile}` (e.g. `"15/high"`). */
9067
+ brokerId: string(),
9068
+ url: string(),
9069
+ mutedUrl: string(),
9070
+ enabled: boolean(),
9071
+ codec: string().optional(),
9072
+ resolution: CamStreamResolutionSchema.optional()
9073
+ });
9074
+ /**
9075
+ * The model weight formats a catalog entry can ship. Schema-free on purpose:
9076
+ * `types/models.ts` builds Zod schemas from it, but a runner-closure consumer
9077
+ * (the model downloader in `@camstack/server/system`) needs only the list and must
9078
+ * reach it through `@camstack/types/addon` without building the cap schema
9079
+ * graph (D28).
9080
+ */
9081
+ var MODEL_FORMATS = [
9082
+ "onnx",
9083
+ "coreml",
9084
+ "openvino",
9085
+ "tflite",
9086
+ "pt",
9087
+ "gguf"
9088
+ ];
8575
9089
  /**
8576
9090
  * `addon-pages-source` — collection cap exposing per-provider raw page
8577
9091
  * declarations. Every addon that contributes a UI page registers a
@@ -8835,6 +9349,7 @@ var CAP_NAMES = Object.freeze([
8835
9349
  "mesh-network",
8836
9350
  "meter",
8837
9351
  "metrics-provider",
9352
+ "migrations",
8838
9353
  "model-convert",
8839
9354
  "model-distributor",
8840
9355
  "motion",
@@ -8867,6 +9382,7 @@ var CAP_NAMES = Object.freeze([
8867
9382
  "plate-gallery",
8868
9383
  "platform-probe",
8869
9384
  "power-meter",
9385
+ "power-source",
8870
9386
  "presence",
8871
9387
  "pressure-sensor",
8872
9388
  "privacy-mask",
@@ -10218,6 +10734,13 @@ Object.freeze({
10218
10734
  "valueType": "number"
10219
10735
  }
10220
10736
  ],
10737
+ "power-source": [{
10738
+ "path": "switchOn",
10739
+ "valueType": "boolean"
10740
+ }, {
10741
+ "path": "offSeconds",
10742
+ "valueType": "number"
10743
+ }],
10221
10744
  "presence": [
10222
10745
  {
10223
10746
  "path": "state",
@@ -10729,379 +11252,7 @@ object({
10729
11252
  params: record(string(), union([string(), number()])).optional()
10730
11253
  });
10731
11254
  //#endregion
10732
- //#region ../types/dist/err-msg-BD5buxvT.mjs
10733
- var DeviceType = /* @__PURE__ */ function(DeviceType) {
10734
- DeviceType["Camera"] = "camera";
10735
- DeviceType["Hub"] = "hub";
10736
- DeviceType["Light"] = "light";
10737
- DeviceType["Siren"] = "siren";
10738
- DeviceType["Switch"] = "switch";
10739
- DeviceType["Sensor"] = "sensor";
10740
- DeviceType["Thermostat"] = "thermostat";
10741
- /** Air-conditioner / heat-pump climate device (HVAC) — shares the
10742
- * `climate-control` cap surface with `Thermostat` but renders a
10743
- * dedicated AC-appropriate control UI (mode chips, fan speed,
10744
- * independent vertical/horizontal swing). Sources: native Gree, and
10745
- * reusable by other AC integrations. */
10746
- DeviceType["Climate"] = "climate";
10747
- DeviceType["Button"] = "button";
10748
- /** Generic stateless event emitter — carries a device's EXACT declared
10749
- * event vocabulary verbatim (no normalization). Installed with the
10750
- * `event-emitter` cap. Sources: HA `event.*` entities (structured) and
10751
- * HA bus events (e.g. `zha_event`, generic). */
10752
- DeviceType["EventEmitter"] = "event-emitter";
10753
- /** Firmware/software update entity — current vs available version,
10754
- * updatable flag, update state, and an install action. Installed with
10755
- * the `update` cap. Sources: Homematic firmware-update channels (and
10756
- * reusable by other providers, e.g. HA `update.*` entities). */
10757
- DeviceType["Update"] = "update";
10758
- DeviceType["Generic"] = "generic";
10759
- /** Generic notification delivery target (HA `notify.<service>`, future
10760
- * Telegram / Discord / ntfy / SMTP, …). One device per delivery
10761
- * endpoint; the `notifier` cap defines the send surface. */
10762
- DeviceType["Notifier"] = "notifier";
10763
- /** Pre-recorded action sequence with optional parameters
10764
- * (HA `script.*`). Runnable via `script-runner` cap. */
10765
- DeviceType["Script"] = "script";
10766
- /** Automation rule (HA `automation.*`) — enable/disable + manual
10767
- * trigger surface exposed via `automation-control` cap. */
10768
- DeviceType["Automation"] = "automation";
10769
- /** Door / smart lock device (HA `lock.*`). `lock-control` cap. */
10770
- DeviceType["Lock"] = "lock";
10771
- /** Window covering, blinds, garage door, valve, etc. (HA `cover.*`,
10772
- * `valve.*`). `cover` cap with sub-roles for variant. */
10773
- DeviceType["Cover"] = "cover";
10774
- /** Pipe / water / gas valve with open/close/stop and optional
10775
- * position (HA `valve.*`). `valve` cap — a cover-sibling actuator
10776
- * modelled on the same open/closed lifecycle. */
10777
- DeviceType["Valve"] = "valve";
10778
- /** Humidifier / dehumidifier with on/off + target humidity + mode
10779
- * (HA `humidifier.*`). `humidifier` cap — a climate-family actuator
10780
- * modelled on the same target / mode lifecycle. */
10781
- DeviceType["Humidifier"] = "humidifier";
10782
- /** Water heater / boiler with target temperature + operation mode +
10783
- * away mode (HA `water_heater.*`). `water-heater` cap — a
10784
- * climate-family actuator. */
10785
- DeviceType["WaterHeater"] = "water-heater";
10786
- /** Ceiling / standing / exhaust fan (HA `fan.*`). `fan-control` cap. */
10787
- DeviceType["Fan"] = "fan";
10788
- /** Audio / video playback endpoint (HA `media_player.*`). Disjoint from
10789
- * the camera surface — those use `Camera`. `media-player` cap. */
10790
- DeviceType["MediaPlayer"] = "media-player";
10791
- /** Security panel / alarm system (HA `alarm_control_panel.*`).
10792
- * `alarm-panel` cap. */
10793
- DeviceType["AlarmPanel"] = "alarm-panel";
10794
- /** Generic user-settable input (HA `number` / `input_number` / `select`
10795
- * / `input_select` / `text` / `input_text` / `input_datetime`).
10796
- * Sub-type via `DeviceRole`: NumericControl / SelectControl /
10797
- * TextControl / DateTimeControl. */
10798
- DeviceType["Control"] = "control";
10799
- /** Person / device-tracker presence (HA `person.*`, `device_tracker.*`).
10800
- * `presence` cap. */
10801
- DeviceType["Presence"] = "presence";
10802
- /** Weather provider (HA `weather.*`). Tier-3, low MVP priority.
10803
- * `weather` cap. */
10804
- DeviceType["Weather"] = "weather";
10805
- /** Robot vacuum (HA `vacuum.*`). Tier-3. `vacuum-control` cap. */
10806
- DeviceType["Vacuum"] = "vacuum";
10807
- /** Robotic lawn mower (HA `lawn_mower.*`). Tier-3.
10808
- * `lawn-mower-control` cap. */
10809
- DeviceType["LawnMower"] = "lawn-mower";
10810
- /** Physical HA device group — parent container for entity-children
10811
- * adopted from a single HA device entry. Not renderable as a
10812
- * standalone device; exists only to anchor child entities. */
10813
- DeviceType["Container"] = "container";
10814
- /** Single still-image entity (HA `image.*`). Read-only display of an
10815
- * `entity_picture` signed URL the browser loads directly. `image` cap. */
10816
- DeviceType["Image"] = "image";
10817
- /** Smart pet feeder — cloud-connected food dispenser with a bowl food
10818
- * level, battery, desiccant life, feeding state and manual-feed /
10819
- * call-pet / maintenance actions. Installed with the `pet-feeder` cap;
10820
- * dual-hopper models (D4S/D4SH) expose per-hopper portions. Sources:
10821
- * native PetKit (`nodepetkit` `FeederDevice`), reusable by other feeder
10822
- * integrations sharing the same food/desiccant/hopper surface. */
10823
- DeviceType["PetFeeder"] = "pet-feeder";
10824
- /** Pet water fountain — tank level, water drunk, pump and its duty cycle.
10825
- * Installed with the `pet-fountain` cap. Reaches CamStack as loose entities
10826
- * of a container and is BUILT as a composed device (D967). */
10827
- DeviceType["PetFountain"] = "pet-fountain";
10828
- /** Built-in dishwasher — program lifecycle, door / remote-start gates,
10829
- * salt and rinse-aid levels. Installed with the `dishwasher` cap.
10830
- * Sources: native Bosch Home Connect, reusable by similar integrations.
10831
- * A plug-built dishwasher carries running-state and power instead. */
10832
- DeviceType["Dishwasher"] = "dishwasher";
10833
- /** Washing machine. A plug-built one is running while its power stays
10834
- * above a threshold. No program cap — that surface is the dishwasher's. */
10835
- DeviceType["Washer"] = "washer";
10836
- /** Tumble dryer. Same plug-built running surface as {@link Washer}. */
10837
- DeviceType["Dryer"] = "dryer";
10838
- /** The physical bridge box of a vendor ecosystem (Velux KLF-200, and later
10839
- * other radio-to-IP bridges). It carries the box's own facts (firmware,
10840
- * address, connection state) and the actions the box really supports
10841
- * (`reboot`, `device-admin-link`). Products are NOT its children — they are
10842
- * adopted beside it — and its connection settings stay on the integration. */
10843
- DeviceType["Gateway"] = "gateway";
10844
- return DeviceType;
10845
- }({});
10846
- var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
10847
- DeviceFeature["BatteryOperated"] = "battery-operated";
10848
- DeviceFeature["Rebootable"] = "rebootable";
10849
- /**
10850
- * Device supports an on-demand re-sync of its derived spec with its
10851
- * upstream source — drives the generic Re-sync button. The owning
10852
- * provider implements the action via the `device-adoption.resync` cap.
10853
- */
10854
- DeviceFeature["Resyncable"] = "resyncable";
10855
- DeviceFeature["NativeSnapshot"] = "native-snapshot";
10856
- DeviceFeature["DoorbellButton"] = "doorbell-button";
10857
- DeviceFeature["TwoWayAudio"] = "two-way-audio";
10858
- DeviceFeature["PanTiltZoom"] = "pan-tilt-zoom";
10859
- /**
10860
- * Camera supports the on-firmware autotrack subsystem (subject-
10861
- * following). Distinct from `PanTiltZoom` because not every PTZ
10862
- * camera ships autotrack — the admin UI uses this flag to gate
10863
- * the autotrack toggle / settings card without re-deriving from
10864
- * the cap registry. Mirrors `ptz-autotrack` cap registration:
10865
- * driver sets this feature when probe confirms the firmware
10866
- * surface, and registers the cap in the same code path.
10867
- */
10868
- DeviceFeature["PtzAutotrack"] = "ptz-autotrack";
10869
- /**
10870
- * Accessory exposes a "trigger on motion" toggle — the parent camera's
10871
- * motion detection automatically activates this device. Mirrors
10872
- * `motion-trigger` cap registration: drivers set this feature in the
10873
- * same code path that calls `ctx.registerNativeCap(motionTriggerCapability, ...)`.
10874
- *
10875
- * Used by admin UI (gate the in-hero `MotionTriggerToggle` against a
10876
- * fast scalar without binding fetch), notifier rules, and `listAll`
10877
- * filters that want "all devices with on-motion behaviour".
10878
- */
10879
- DeviceFeature["MotionTrigger"] = "motion-trigger";
10880
- /** Light supports rgb-triplet color via `color` cap. */
10881
- DeviceFeature["LightColorRgb"] = "light-color-rgb";
10882
- /** Light supports HSV color via `color` cap. */
10883
- DeviceFeature["LightColorHsv"] = "light-color-hsv";
10884
- /** Light supports color-temperature (mired) via `color` cap. */
10885
- DeviceFeature["LightColorMired"] = "light-color-mired";
10886
- /** Thermostat supports a `heat_cool` dual setpoint (targetLow +
10887
- * targetHigh). Gates the range slider UI. */
10888
- DeviceFeature["ClimateDualSetpoint"] = "climate-dual-setpoint";
10889
- /** Thermostat exposes target humidity and/or current humidity
10890
- * readings. Gates the humidity controls. */
10891
- DeviceFeature["ClimateHumidity"] = "climate-humidity";
10892
- /** Thermostat exposes a fan-mode selector. */
10893
- DeviceFeature["ClimateFanMode"] = "climate-fan-mode";
10894
- /** Thermostat exposes preset modes (eco / away / sleep / vendor). */
10895
- DeviceFeature["ClimatePreset"] = "climate-preset";
10896
- /** Thermostat exposes a vertical louver swing toggle. Gates the
10897
- * vertical-swing switch in the climate UI. Independent of horizontal. */
10898
- DeviceFeature["ClimateSwingVertical"] = "climate-swing-vertical";
10899
- /** Thermostat exposes a horizontal louver swing toggle. Gates the
10900
- * horizontal-swing switch in the climate UI. Independent of vertical. */
10901
- DeviceFeature["ClimateSwingHorizontal"] = "climate-swing-horizontal";
10902
- /** Cover exposes intermediate position control (0..100). Gates the
10903
- * position slider UI. */
10904
- DeviceFeature["CoverPositionable"] = "cover-positionable";
10905
- /** Cover exposes slat-tilt control. Gates the tilt slider UI. */
10906
- DeviceFeature["CoverTilt"] = "cover-tilt";
10907
- /** Valve exposes intermediate position control (0..100). Gates the
10908
- * position slider / drag surface UI. */
10909
- DeviceFeature["ValvePositionable"] = "valve-positionable";
10910
- /** Fan exposes a speed-percentage setter. Gates the speed slider UI. */
10911
- DeviceFeature["FanSpeed"] = "fan-speed";
10912
- /** Fan exposes a preset mode selector. */
10913
- DeviceFeature["FanPreset"] = "fan-preset";
10914
- /** Fan exposes blade direction (forward/reverse) — typical of
10915
- * ceiling fans. */
10916
- DeviceFeature["FanDirection"] = "fan-direction";
10917
- /** Fan exposes an oscillation toggle. */
10918
- DeviceFeature["FanOscillating"] = "fan-oscillating";
10919
- /** Lock requires a PIN code on lock/unlock. Gates the code-entry
10920
- * field on the UI lock-controls panel. */
10921
- DeviceFeature["LockPinRequired"] = "lock-pin-required";
10922
- /** Lock supports a latch-release ("open door") action distinct from
10923
- * unlock. Mirrors HA `LockEntityFeature.OPEN` (bit 1) in
10924
- * `supported_features`. Gates the Open Door button in the UI. */
10925
- DeviceFeature["LockOpen"] = "lock-open";
10926
- /** Media player exposes a seek-to-position surface. */
10927
- DeviceFeature["MediaPlayerSeek"] = "media-player-seek";
10928
- /** Media player exposes a volume-level setter. */
10929
- DeviceFeature["MediaPlayerVolume"] = "media-player-volume";
10930
- /** Media player exposes a mute toggle distinct from volume=0. */
10931
- DeviceFeature["MediaPlayerMute"] = "media-player-mute";
10932
- /** Media player exposes a shuffle toggle. */
10933
- DeviceFeature["MediaPlayerShuffle"] = "media-player-shuffle";
10934
- /** Media player exposes a repeat mode (off / all / one). */
10935
- DeviceFeature["MediaPlayerRepeat"] = "media-player-repeat";
10936
- /** Media player exposes a source / input selector. */
10937
- DeviceFeature["MediaPlayerSelectSource"] = "media-player-select-source";
10938
- /** Media player exposes a play-arbitrary-media surface (URL / id). */
10939
- DeviceFeature["MediaPlayerPlayMedia"] = "media-player-play-media";
10940
- /** Media player exposes next-track. */
10941
- DeviceFeature["MediaPlayerNext"] = "media-player-next";
10942
- /** Media player exposes previous-track. */
10943
- DeviceFeature["MediaPlayerPrevious"] = "media-player-previous";
10944
- /** Media player exposes stop distinct from pause. */
10945
- DeviceFeature["MediaPlayerStop"] = "media-player-stop";
10946
- /** Alarm panel requires a PIN code on arm/disarm. */
10947
- DeviceFeature["AlarmPinRequired"] = "alarm-pin-required";
10948
- /** Presence device carries GPS coordinates (lat/lng/accuracy) in
10949
- * addition to a textual location. */
10950
- DeviceFeature["PresenceGps"] = "presence-gps";
10951
- /** Notifier accepts an inline / URL image attachment. */
10952
- DeviceFeature["NotifierImage"] = "notifier-image";
10953
- /** Notifier accepts a priority hint (high/normal/low). */
10954
- DeviceFeature["NotifierPriority"] = "notifier-priority";
10955
- /** Notifier accepts a free-form `data` payload for platform-specific
10956
- * fields. */
10957
- DeviceFeature["NotifierData"] = "notifier-data";
10958
- /** Notifier supports interactive action buttons / callbacks. */
10959
- DeviceFeature["NotifierActions"] = "notifier-actions";
10960
- /** Notifier supports per-call recipient targeting (multi-user). */
10961
- DeviceFeature["NotifierRecipients"] = "notifier-recipients";
10962
- /** Script runner accepts a variables map on each run invocation. */
10963
- DeviceFeature["ScriptVariables"] = "script-variables";
10964
- /** Automation `trigger` accepts a skipCondition flag — fires the
10965
- * automation's actions while bypassing its condition block. */
10966
- DeviceFeature["AutomationSkipCondition"] = "automation-skip-condition";
10967
- /** Robot vacuum exposes a live cleaning map (image child). Gates the
10968
- * map tile in the vacuum UI. */
10969
- DeviceFeature["VacuumHasMap"] = "vacuum-has-map";
10970
- /** Robot vacuum exposes AI obstacle-detection toggles. Gates the AI
10971
- * switches group. */
10972
- DeviceFeature["VacuumHasAi"] = "vacuum-has-ai";
10973
- /** Robot mower exposes a live mowing map (SVG image child). Gates the
10974
- * mower map tile. */
10975
- DeviceFeature["MowerHasMap"] = "mower-has-map";
10976
- /** Robot mower exposes targeted mowing (all-area / zones / edges /
10977
- * spots) — gates the Mow action + map selectors. */
10978
- DeviceFeature["MowerHasTargetedMowing"] = "mower-has-targeted-mowing";
10979
- return DeviceFeature;
10980
- }({});
10981
- /**
10982
- * Semantic role a device plays within its parent. Populated by driver
10983
- * addons when creating accessory devices (Reolink siren/floodlight/
10984
- * PIR/chime/autotrack/doorbell, ONVIF relay outputs, …). Used by the
10985
- * admin UI to pick icons, labels, and widgets — a `Switch` with
10986
- * `role: Floodlight` renders as a bulb with a brightness slider,
10987
- * whereas a `Switch` with `role: Siren` renders as a klaxon.
10988
- *
10989
- * Undefined for top-level devices (cameras, NVRs, hubs). Persisted in
10990
- * sqlite as a nullable TEXT column — old rows keep working unchanged.
10991
- */
10992
- var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
10993
- DeviceRole["Siren"] = "siren";
10994
- DeviceRole["Floodlight"] = "floodlight";
10995
- DeviceRole["Spotlight"] = "spotlight";
10996
- DeviceRole["PirSensor"] = "pir-sensor";
10997
- DeviceRole["Chime"] = "chime";
10998
- DeviceRole["Autotrack"] = "autotrack";
10999
- DeviceRole["Nightvision"] = "nightvision";
11000
- DeviceRole["PrivacyMask"] = "privacy-mask";
11001
- DeviceRole["Doorbell"] = "doorbell";
11002
- /** Interior blind / shade / roller blind. HA `device_class: blind|shade`. */
11003
- DeviceRole["CoverBlind"] = "cover-blind";
11004
- /** Exterior roller shutter. HA `device_class: shutter`; Homematic BROLL. */
11005
- DeviceRole["CoverShutter"] = "cover-shutter";
11006
- /** Exterior awning. HA `device_class: awning`. */
11007
- DeviceRole["CoverAwning"] = "cover-awning";
11008
- /** Curtain / drape. HA `device_class: curtain`. */
11009
- DeviceRole["CoverCurtain"] = "cover-curtain";
11010
- /** Garage door. HA `device_class: garage`. A security actuator: exports gate it. */
11011
- DeviceRole["CoverGarage"] = "cover-garage";
11012
- /** Gate. HA `device_class: gate`. A security actuator: exports gate it. */
11013
- DeviceRole["CoverGate"] = "cover-gate";
11014
- /** Door. HA `device_class: door`. A security actuator: exports gate it. */
11015
- DeviceRole["CoverDoor"] = "cover-door";
11016
- /** Window. HA `device_class: window`. */
11017
- DeviceRole["CoverWindow"] = "cover-window";
11018
- /** Virtual HA toggle (input_boolean.*) — distinguishable from a
11019
- * real Switch device for UI rendering / export adapters. */
11020
- DeviceRole["BinaryHelper"] = "binary-helper";
11021
- /** A smart plug: a `switch` whose source says it is an outlet (HA
11022
- * `device_class: outlet`). The Alexa export shows it as a SMARTPLUG. */
11023
- DeviceRole["Outlet"] = "outlet";
11024
- /** Generic motion / occupancy / moving event source. Distinct from
11025
- * the camera accessory PirSensor role: that one is a camera child;
11026
- * this is a standalone HA / 3rd-party motion sensor. */
11027
- DeviceRole["MotionSensor"] = "motion-sensor";
11028
- DeviceRole["ContactSensor"] = "contact-sensor";
11029
- DeviceRole["LeakSensor"] = "leak-sensor";
11030
- DeviceRole["SmokeSensor"] = "smoke-sensor";
11031
- DeviceRole["COSensor"] = "co-sensor";
11032
- DeviceRole["GasSensor"] = "gas-sensor";
11033
- DeviceRole["TamperSensor"] = "tamper-sensor";
11034
- DeviceRole["VibrationSensor"] = "vibration-sensor";
11035
- DeviceRole["ConnectivitySensor"] = "connectivity-sensor";
11036
- DeviceRole["SoundSensor"] = "sound-sensor";
11037
- /** Fallback for `binary_sensor` without a known `device_class`. */
11038
- DeviceRole["BinarySensor"] = "binary-sensor";
11039
- DeviceRole["TemperatureSensor"] = "temperature-sensor";
11040
- DeviceRole["HumiditySensor"] = "humidity-sensor";
11041
- DeviceRole["AmbientLightSensor"] = "ambient-light-sensor";
11042
- DeviceRole["PressureSensor"] = "pressure-sensor";
11043
- /** Wind speed or direction (weather-station `wind-sensor` cap). */
11044
- DeviceRole["WindSensor"] = "wind-sensor";
11045
- /** Rain accumulation or rate (weather-station `rain-sensor` cap). */
11046
- DeviceRole["RainSensor"] = "rain-sensor";
11047
- /** UV index (weather-station `uv-sensor` cap). */
11048
- DeviceRole["UvSensor"] = "uv-sensor";
11049
- /** Solar irradiance W/m² (weather-station `solar-radiation-sensor` cap).
11050
- * Distinct from AmbientLightSensor (lux). */
11051
- DeviceRole["SolarRadiationSensor"] = "solar-radiation-sensor";
11052
- /** Soil moisture % (garden/weather `soil-moisture-sensor` cap). */
11053
- DeviceRole["SoilMoistureSensor"] = "soil-moisture-sensor";
11054
- DeviceRole["PowerSensor"] = "power-sensor";
11055
- DeviceRole["EnergySensor"] = "energy-sensor";
11056
- DeviceRole["VoltageSensor"] = "voltage-sensor";
11057
- DeviceRole["CurrentSensor"] = "current-sensor";
11058
- DeviceRole["AirQualitySensor"] = "air-quality-sensor";
11059
- /** Battery level (numeric % via `sensor` OR low-bool via
11060
- * `binary_sensor` — the cap distinguishes via the value type). */
11061
- DeviceRole["BatterySensor"] = "battery-sensor";
11062
- /** Fallback for `sensor` numeric without a known `device_class`. */
11063
- DeviceRole["NumericSensor"] = "numeric-sensor";
11064
- /** String / enum state (HA `sensor` with `state_class: enum` or
11065
- * `attributes.options`). */
11066
- DeviceRole["EnumSensor"] = "enum-sensor";
11067
- /** Date / timestamp state (HA `sensor` with `device_class: timestamp`
11068
- * or `date`). The slice carries the raw ISO string verbatim (hosted on
11069
- * the `enum-sensor` cap); the UI renders it locale-formatted. */
11070
- DeviceRole["DateTimeSensor"] = "datetime-sensor";
11071
- /** Last-resort fallback when nothing else matches. */
11072
- DeviceRole["GenericSensor"] = "generic-sensor";
11073
- DeviceRole["NumericControl"] = "numeric-control";
11074
- DeviceRole["SelectControl"] = "select-control";
11075
- DeviceRole["TextControl"] = "text-control";
11076
- DeviceRole["DateTimeControl"] = "datetime-control";
11077
- /** Mobile push notifier (HA `notify.mobile_app_*`) — supports
11078
- * rich features (image, priority, channel routing). */
11079
- DeviceRole["MobilePushNotifier"] = "mobile-push-notifier";
11080
- /** Chat / messaging service (HA `notify.telegram_*`,
11081
- * `notify.discord_*`, etc.). */
11082
- DeviceRole["MessagingNotifier"] = "messaging-notifier";
11083
- /** Email-based delivery (HA `notify.smtp`, etc.). */
11084
- DeviceRole["EmailNotifier"] = "email-notifier";
11085
- /** Fallback when the notifier service name doesn't match a known
11086
- * pattern. */
11087
- DeviceRole["GenericNotifier"] = "generic-notifier";
11088
- /** Emits a pulse train (infrared or RF) on request — the `ir-transmitter`
11089
- * cap. A `DeviceType.Generic` device. */
11090
- DeviceRole["IrTransmitter"] = "ir-transmitter";
11091
- return DeviceRole;
11092
- }({});
11093
- /**
11094
- import { errMsg } from '@camstack/types'
11095
- * Extract a human-readable message from an unknown error value.
11096
- * Replaces the ubiquitous `errMsg(err)` pattern.
11097
- */
11098
- function errMsg$1(err) {
11099
- if (err instanceof Error) return err.message;
11100
- if (typeof err === "string") return err;
11101
- return String(err);
11102
- }
11103
- //#endregion
11104
- //#region ../types/dist/composition-C7WdThmP.mjs
11255
+ //#region ../types/dist/composition-BBzVf2xd.mjs
11105
11256
  /**
11106
11257
  * The ffmpeg build every CamStack node downloads, per platform and arch.
11107
11258
  *
@@ -12320,6 +12471,90 @@ var EventOwnerTypeSchema = _enum(EVENT_OWNER_TYPES);
12320
12471
  var MediaPresenceOwnerKindSchema = _enum([...EVENT_OWNER_TYPES, "track"]);
12321
12472
  new Set(EVENT_OWNER_TYPES);
12322
12473
  /**
12474
+ * What a published package needs from the rest of the install (D989).
12475
+ *
12476
+ * One published framework package (`@camstack/server`) carries the kernel, the
12477
+ * builtins and the capability contracts, so "which addon runs on which
12478
+ * framework" is a question of version, and the answer is DECLARED by the
12479
+ * package that knows it:
12480
+ *
12481
+ * - an addon says the oldest server it runs on (`requires.server: ">=X"`);
12482
+ * - the server says the oldest addon it works with
12483
+ * (`requires.addons: { "@camstack/addon-x": ">=Y" }`) and the oldest shell
12484
+ * around it (`requires.wrapper: { desktop, image }`);
12485
+ * - a wrapper (the desktop app, the container starter) says which server
12486
+ * range it can host, and reports its own kind and version.
12487
+ *
12488
+ * The publish workflow STAMPS these after the version bump
12489
+ * (`scripts/ci/stamp-requires.mjs`); nobody types a number by hand.
12490
+ *
12491
+ * A requirement that cannot be checked is NOT met: a shell that reports no
12492
+ * version counts as below the minimum, and an unreadable running version is
12493
+ * named in the result (a failed read is never a pass).
12494
+ */
12495
+ /** `>=MAJOR.MINOR.PATCH[-prerelease]` — the only range shape a requirement uses. */
12496
+ var MinVersionSchema = string().regex(/^>=\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$/, "a minimum is written \">=X.Y.Z\"");
12497
+ object({
12498
+ /** The oldest `@camstack/server` this package runs on. */
12499
+ server: MinVersionSchema.optional(),
12500
+ /** The oldest installed version of each named addon package. */
12501
+ addons: record(string(), MinVersionSchema).optional(),
12502
+ /** The oldest shell around the server, per shell kind. */
12503
+ wrapper: object({
12504
+ desktop: MinVersionSchema.optional(),
12505
+ image: MinVersionSchema.optional()
12506
+ }).optional()
12507
+ });
12508
+ /** One unmet requirement; each names the versions on both sides. */
12509
+ var UnmetRequirementSchema = discriminatedUnion("kind", [
12510
+ object({
12511
+ kind: literal("server-too-old"),
12512
+ required: string(),
12513
+ /** `null` — the running server version could not be read. */
12514
+ running: string().nullable()
12515
+ }),
12516
+ object({
12517
+ kind: literal("addon-too-old"),
12518
+ packageName: string(),
12519
+ required: string(),
12520
+ /** `null` — the addon is not installed (or its version is unreadable). */
12521
+ running: string().nullable()
12522
+ }),
12523
+ object({
12524
+ kind: literal("wrapper-too-old"),
12525
+ wrapper: _enum(["desktop", "image"]),
12526
+ required: string(),
12527
+ /** `null` — the wrapper reported no version. */
12528
+ running: string().nullable()
12529
+ })
12530
+ ]);
12531
+ var RequiredAddonUpdateSchema = object({
12532
+ packageName: string(),
12533
+ /** The minimum the target server declares. */
12534
+ required: string(),
12535
+ /** What this node has; `null` when the addon is not installed. */
12536
+ installed: string().nullable()
12537
+ });
12538
+ /**
12539
+ * Which integration instance a settings form is for. An addon that serves several instances
12540
+ * (`instanceMode: multiple`) can show a different form per instance — an NVR integration
12541
+ * needs its connection, the default integration needs the addon's own sections.
12542
+ *
12543
+ * - `integrationId` is `null` in the create wizard: nothing exists yet, the operator is
12544
+ * setting up a NEW instance.
12545
+ * - `mode` is the wizard mode of the integration type (`getAvailableTypes`).
12546
+ * - `candidateStableId` is the discovery candidate a wizard was seeded from, if any.
12547
+ */
12548
+ var IntegrationInstanceRefSchema = object({
12549
+ integrationId: string().nullable(),
12550
+ mode: _enum([
12551
+ "standalone",
12552
+ "account",
12553
+ "broker"
12554
+ ]),
12555
+ candidateStableId: string().optional()
12556
+ });
12557
+ /**
12323
12558
  * Build an `IAddonRouteProvider` from a list of routes. Implements
12324
12559
  * both the operator-facing `getRoutes` (returning route descriptors
12325
12560
  * minus the handlers, which can't cross JSON) and the framework-
@@ -12944,6 +13179,613 @@ var CameraSwitchGroupSchema = object({
12944
13179
  fetchedAt: number()
12945
13180
  });
12946
13181
  /**
13182
+ * Query filter for settings-store collections.
13183
+ */
13184
+ var QueryFilterSchema = object({
13185
+ where: record(string(), unknown()).optional(),
13186
+ whereIn: record(string(), array(unknown())).optional(),
13187
+ whereBetween: record(string(), tuple([unknown(), unknown()])).optional(),
13188
+ /** NULL-safe exclusion: matches rows whose field is NULL OR != the value. */
13189
+ whereNot: record(string(), unknown()).optional(),
13190
+ /** NULL-safe exclusion of a SET — `whereNot` for more than one value. An
13191
+ * empty list excludes nothing. See `QueryFilter.whereNotIn`. */
13192
+ whereNotIn: record(string(), array(unknown())).optional(),
13193
+ orderBy: object({
13194
+ field: string(),
13195
+ direction: _enum(["asc", "desc"])
13196
+ }).optional(),
13197
+ limit: number().optional(),
13198
+ offset: number().optional()
13199
+ });
13200
+ /**
13201
+ * The predicate half of a filter, for BULK MUTATIONS.
13202
+ *
13203
+ * Deliberately not `QueryFilterSchema`: `orderBy` / `limit` / `offset` have no
13204
+ * meaning for a statement that rewrites a set, and accepting them would invite
13205
+ * a caller to believe `limit` bounds the damage. Every field is optional here
13206
+ * only so the shape stays composable — the implementation REJECTS a filter
13207
+ * that compiles to no predicate, because that is the whole collection.
13208
+ */
13209
+ var MutationFilterSchema = object({
13210
+ where: record(string(), unknown()).optional(),
13211
+ whereIn: record(string(), array(unknown())).optional(),
13212
+ whereBetween: record(string(), tuple([unknown(), unknown()])).optional(),
13213
+ whereNot: record(string(), unknown()).optional(),
13214
+ whereNotIn: record(string(), array(unknown())).optional()
13215
+ });
13216
+ /**
13217
+ * One scalar an {@link settingsStoreCapability.methods.aggregate} call asks for.
13218
+ *
13219
+ * `as` names the slot in the result, so the SAME column may be asked twice with
13220
+ * two operations (`MIN(startMs)` and `MAX(startMs)` in one round trip) — which
13221
+ * a `Record<column, op>` shape could not express.
13222
+ */
13223
+ var AggregateFieldSchema = object({
13224
+ /** Result key. */
13225
+ as: string().min(1),
13226
+ /** Column to aggregate. Must be a real column of a declared collection. */
13227
+ field: string().min(1),
13228
+ op: _enum([
13229
+ "sum",
13230
+ "min",
13231
+ "max"
13232
+ ])
13233
+ });
13234
+ /**
13235
+ * `COUNT(*)` plus one number per requested field.
13236
+ *
13237
+ * `null` means NO ROW MATCHED, never zero: a `SUM` over an empty set and a sum
13238
+ * that really is 0 are different facts, and an accounting caller that renders
13239
+ * "0 bytes, oldest = 0" for "nothing here" reports a lie about a disk.
13240
+ */
13241
+ var AggregateResultSchema = object({
13242
+ count: number().int(),
13243
+ values: record(string(), number().nullable())
13244
+ });
13245
+ /** A single stored record: `{ id, data }`. */
13246
+ var SettingsRecordSchema = object({
13247
+ id: string(),
13248
+ data: record(string(), unknown())
13249
+ });
13250
+ /**
13251
+ * One record of a BULK insert — {@link SettingsRecordSchema} with the id made
13252
+ * optional.
13253
+ *
13254
+ * A separate schema rather than loosening the shared one: every other method
13255
+ * on this cap addresses a row BY its id, and making that field optional
13256
+ * everywhere would turn a forgotten key into a silently generated one on
13257
+ * `update` and `delete` as well.
13258
+ */
13259
+ var BulkRecordSchema = object({
13260
+ id: string().optional(),
13261
+ data: record(string(), unknown())
13262
+ });
13263
+ /**
13264
+ * The database FILES one `sqlite-settings` engine process owns (D851).
13265
+ * Closed on purpose: a file is a thing the engine opens, backs up and gives a
13266
+ * serving thread, so a new one is a code change, never a string a caller
13267
+ * invents. `settings` is `camstack.db` and the default for every collection
13268
+ * that names no file.
13269
+ */
13270
+ var DataStoreDatabaseSchema = _enum([
13271
+ "settings",
13272
+ "events",
13273
+ "history"
13274
+ ]);
13275
+ DataStoreDatabaseSchema.options;
13276
+ /**
13277
+ * One write inside a {@link settingsStoreCapability.methods.transact} call.
13278
+ * The three that a "replace this set, bump that revision" write needs, plus
13279
+ * the batched upsert a rollup writer needs.
13280
+ */
13281
+ var TransactOpSchema = discriminatedUnion("op", [
13282
+ object({
13283
+ op: literal("deleteWhere"),
13284
+ collection: string(),
13285
+ filter: MutationFilterSchema
13286
+ }),
13287
+ object({
13288
+ op: literal("insertMany"),
13289
+ collection: string(),
13290
+ records: array(BulkRecordSchema).readonly()
13291
+ }),
13292
+ object({
13293
+ op: literal("update"),
13294
+ collection: string(),
13295
+ id: string(),
13296
+ data: record(string(), unknown())
13297
+ }),
13298
+ object({
13299
+ op: literal("upsertMany"),
13300
+ collection: string(),
13301
+ conflict: array(string()).readonly(),
13302
+ records: array(BulkRecordSchema).readonly()
13303
+ })
13304
+ ]);
13305
+ /**
13306
+ * The precondition of a transaction: the row `key` of `collection` must hold
13307
+ * `equals` in `column`, read INSIDE the transaction.
13308
+ */
13309
+ var TransactGuardSchema = object({
13310
+ collection: string(),
13311
+ key: string(),
13312
+ column: string(),
13313
+ equals: unknown()
13314
+ });
13315
+ /**
13316
+ * Column declaration for a structured (SQL-backed) collection.
13317
+ *
13318
+ * Logical types — the backend translates each to the matching SQLite
13319
+ * storage class and handles per-type marshaling:
13320
+ * - `TEXT` / `INTEGER` / `REAL` — native SQLite types, pass-through
13321
+ * - `JSON` — TEXT under the hood; serialised on write, parsed on read
13322
+ * - `BOOLEAN` — INTEGER 0/1 under the hood; coerced both directions
13323
+ */
13324
+ var CollectionColumnSchema = object({
13325
+ name: string(),
13326
+ type: _enum([
13327
+ "TEXT",
13328
+ "INTEGER",
13329
+ "REAL",
13330
+ "JSON",
13331
+ "BOOLEAN"
13332
+ ]),
13333
+ primaryKey: boolean().optional(),
13334
+ notNull: boolean().optional(),
13335
+ unique: boolean().optional(),
13336
+ /**
13337
+ * Column DEFAULT. Required for B2: the four `ensureTable` consumers declare
13338
+ * columns like `enabled INTEGER NOT NULL DEFAULT 1`, and without this the
13339
+ * collection surface simply cannot express their existing tables — which is
13340
+ * why they were still on the uncapped `table*` API.
13341
+ */
13342
+ defaultValue: union([
13343
+ string(),
13344
+ number(),
13345
+ boolean()
13346
+ ]).optional()
13347
+ });
13348
+ var CollectionIndexSchema = object({
13349
+ name: string(),
13350
+ columns: array(string()).readonly(),
13351
+ unique: boolean().optional()
13352
+ });
13353
+ /**
13354
+ * The input of `declareCollection` — ONE schema for the door and for the
13355
+ * engine behind it, so the two surfaces cannot drift (the dispatcher forwards
13356
+ * the payload untouched).
13357
+ *
13358
+ * - `database` — the file the collection lives in (D851). Absent means
13359
+ * `settings`. A declaration naming a file other than the one the table is
13360
+ * already in is REFUSED by the engine, never moved.
13361
+ * - `primaryKey` — a COMPOSITE key, as column names. A single name is the same
13362
+ * as `primaryKey: true` on that column. A composite-keyed collection has no
13363
+ * `id`: it is written with `insertMany` / `upsertMany` / `transact` and read
13364
+ * with `query` / `count` / `aggregate` / `deleteWhere`; the calls that
13365
+ * address one row by id are refused.
13366
+ * - `withoutRowid` — emit `WITHOUT ROWID`. Requires a primary key.
13367
+ */
13368
+ var DeclareCollectionInputSchema = object({
13369
+ namespace: string().optional(),
13370
+ collection: string(),
13371
+ columns: array(CollectionColumnSchema).readonly(),
13372
+ indexes: array(CollectionIndexSchema).readonly().optional(),
13373
+ database: DataStoreDatabaseSchema.optional(),
13374
+ primaryKey: array(string()).readonly().optional(),
13375
+ withoutRowid: boolean().optional()
13376
+ });
13377
+ method(object({
13378
+ namespace: string().optional(),
13379
+ collection: string(),
13380
+ key: string()
13381
+ }), unknown(), { auth: "admin" }), method(object({
13382
+ namespace: string().optional(),
13383
+ collection: string(),
13384
+ key: string(),
13385
+ value: unknown()
13386
+ }), _void(), {
13387
+ kind: "mutation",
13388
+ auth: "admin"
13389
+ }), method(object({
13390
+ namespace: string().optional(),
13391
+ collection: string(),
13392
+ filter: QueryFilterSchema.optional(),
13393
+ columns: array(string()).readonly().optional()
13394
+ }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
13395
+ namespace: string().optional(),
13396
+ collection: string(),
13397
+ /** Declared columns identifying the slot; must be covered by a UNIQUE
13398
+ * index on the collection. Never empty. */
13399
+ conflict: array(string()).readonly(),
13400
+ record: BulkRecordSchema
13401
+ }), object({
13402
+ /** The id the row HAS: assigned by SQLite on an insert, or the existing
13403
+ * row's own id on an update. */
13404
+ id: union([string(), number()]) }), {
13405
+ kind: "mutation",
13406
+ auth: "admin"
13407
+ }), method(object({
13408
+ namespace: string().optional(),
13409
+ collection: string(),
13410
+ conflict: array(string()).readonly(),
13411
+ records: array(BulkRecordSchema).readonly()
13412
+ }), object({ upserted: number().int() }), {
13413
+ kind: "mutation",
13414
+ auth: "admin"
13415
+ }), method(object({
13416
+ namespace: string().optional(),
13417
+ collection: string(),
13418
+ record: object({
13419
+ id: string().optional(),
13420
+ data: record(string(), unknown())
13421
+ })
13422
+ }), object({
13423
+ /**
13424
+ * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
13425
+ * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
13426
+ * primary key — which is the only place an auto key is knowable.
13427
+ */
13428
+ id: union([string(), number()]) }), {
13429
+ kind: "mutation",
13430
+ auth: "admin"
13431
+ }), method(object({
13432
+ namespace: string().optional(),
13433
+ collection: string(),
13434
+ records: array(BulkRecordSchema).readonly()
13435
+ }), object({ inserted: number().int() }), {
13436
+ kind: "mutation",
13437
+ auth: "admin"
13438
+ }), method(object({
13439
+ namespace: string().optional(),
13440
+ guard: TransactGuardSchema.optional(),
13441
+ ops: array(TransactOpSchema).readonly()
13442
+ }), object({
13443
+ applied: boolean(),
13444
+ current: unknown().optional()
13445
+ }), {
13446
+ kind: "mutation",
13447
+ auth: "admin"
13448
+ }), method(object({
13449
+ namespace: string().optional(),
13450
+ collection: string(),
13451
+ id: string(),
13452
+ data: record(string(), unknown())
13453
+ }), _void(), {
13454
+ kind: "mutation",
13455
+ auth: "admin"
13456
+ }), method(object({
13457
+ namespace: string().optional(),
13458
+ collection: string(),
13459
+ key: string()
13460
+ }), _void(), {
13461
+ kind: "mutation",
13462
+ auth: "admin"
13463
+ }), method(object({
13464
+ namespace: string().optional(),
13465
+ collection: string(),
13466
+ filter: MutationFilterSchema
13467
+ }), object({ deleted: number().int() }), {
13468
+ kind: "mutation",
13469
+ auth: "admin"
13470
+ }), method(object({
13471
+ namespace: string().optional(),
13472
+ collection: string(),
13473
+ filter: MutationFilterSchema,
13474
+ data: record(string(), unknown())
13475
+ }), object({ updated: number().int() }), {
13476
+ kind: "mutation",
13477
+ auth: "admin"
13478
+ }), method(object({
13479
+ namespace: string().optional(),
13480
+ collection: string(),
13481
+ filter: QueryFilterSchema.optional()
13482
+ }), number(), { auth: "admin" }), method(object({
13483
+ namespace: string().optional(),
13484
+ collection: string(),
13485
+ fields: array(AggregateFieldSchema).readonly(),
13486
+ filter: QueryFilterSchema.optional()
13487
+ }), AggregateResultSchema, { auth: "admin" }), method(object({
13488
+ namespace: string().optional(),
13489
+ collection: string(),
13490
+ field: string(),
13491
+ bucketSize: number().int().positive(),
13492
+ origin: number().int(),
13493
+ filter: QueryFilterSchema.optional()
13494
+ }), array(object({
13495
+ bucket: number().int(),
13496
+ count: number().int()
13497
+ })).readonly(), { auth: "admin" }), method(object({
13498
+ namespace: string().optional(),
13499
+ collection: string()
13500
+ }), boolean(), { auth: "admin" }), method(DeclareCollectionInputSchema, _void(), {
13501
+ kind: "mutation",
13502
+ auth: "admin"
13503
+ });
13504
+ 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>\"");
13505
+ var MigrationLevelSchema = _enum([
13506
+ "hub-store",
13507
+ "addon-state",
13508
+ "node-config",
13509
+ "viewer",
13510
+ "addon-internal"
13511
+ ]);
13512
+ var MigrationStoreSchema = _enum([
13513
+ "settings",
13514
+ "events",
13515
+ "history",
13516
+ "node-local",
13517
+ "addon-files"
13518
+ ]);
13519
+ var MigrationScopeSchema = _enum(["cluster", "per-node"]);
13520
+ /** What depends on a migration while it is pending: `block-owner` is the default. */
13521
+ var MigrationOnFailureSchema = _enum(["block-owner", "tolerate"]);
13522
+ /**
13523
+ * `sql` is a hub-only body over the owner's connection. `plan` returns edits the
13524
+ * engine applies inside the migration's own transaction (hub-owned: computed in
13525
+ * that transaction; addon-owned: computed by the owner and shipped to the engine).
13526
+ * `procedure` is addon-owned work that is not SQL (keychain, integration registry,
13527
+ * device tombstones); the ledger records its outcome and it must be idempotent.
13528
+ */
13529
+ var MigrationBodyKindSchema = _enum([
13530
+ "sql",
13531
+ "plan",
13532
+ "procedure"
13533
+ ]);
13534
+ var MigrationMetaSchema = object({
13535
+ id: MigrationIdSchema,
13536
+ /** `hub`, an addon id, `node` or `viewer`. */
13537
+ owner: string().regex(/^[a-z0-9-]+$/),
13538
+ level: MigrationLevelSchema,
13539
+ /** Strictly increasing per owner: the order within an owner. */
13540
+ seq: number().int().positive(),
13541
+ /** Ids of any owner: the order across owners. */
13542
+ dependsOn: array(MigrationIdSchema),
13543
+ store: MigrationStoreSchema,
13544
+ scope: MigrationScopeSchema,
13545
+ onFailure: MigrationOnFailureSchema,
13546
+ bodyKind: MigrationBodyKindSchema,
13547
+ description: string().min(1),
13548
+ /** The marked field the migration's spec must assert survived. */
13549
+ fixtureMark: string().min(1)
13550
+ }).refine((m) => m.id.startsWith(`${m.owner}/`), {
13551
+ message: "the id must start with \"<owner>/\"",
13552
+ path: ["id"]
13553
+ });
13554
+ /** A cycle in the dependency graph, named by the ids on it. */
13555
+ var MigrationCycleError = class extends Error {
13556
+ ids;
13557
+ constructor(ids) {
13558
+ super(`migration dependsOn cycle: ${ids.join(" -> ")}`);
13559
+ this.ids = ids;
13560
+ this.name = "MigrationCycleError";
13561
+ }
13562
+ };
13563
+ /**
13564
+ * Topological order over `dependsOn` plus the implicit edge "a lower `seq` of an
13565
+ * owner runs first". Ties are broken by `(owner, seq)`. Throws
13566
+ * {@link MigrationCycleError} on a cycle. A `dependsOn` id that is not in the list
13567
+ * is ignored here — the catalogue schema is what refuses it.
13568
+ */
13569
+ function orderMigrations(items) {
13570
+ const byId = new Map(items.map((item) => [item.id, item]));
13571
+ const deps = /* @__PURE__ */ new Map();
13572
+ const ownerSorted = /* @__PURE__ */ new Map();
13573
+ for (const item of items) {
13574
+ const list = ownerSorted.get(item.owner) ?? [];
13575
+ list.push(item);
13576
+ ownerSorted.set(item.owner, list);
13577
+ }
13578
+ for (const item of items) deps.set(item.id, new Set(item.dependsOn.filter((id) => byId.has(id))));
13579
+ for (const list of ownerSorted.values()) {
13580
+ list.sort((a, b) => a.seq - b.seq);
13581
+ for (let i = 1; i < list.length; i++) {
13582
+ const previous = list[i - 1];
13583
+ const current = list[i];
13584
+ if (previous !== void 0 && current !== void 0) deps.get(current.id)?.add(previous.id);
13585
+ }
13586
+ }
13587
+ const tie = (a, b) => a.owner < b.owner ? -1 : a.owner > b.owner ? 1 : a.seq - b.seq;
13588
+ const done = /* @__PURE__ */ new Set();
13589
+ const ordered = [];
13590
+ let remaining = [...items];
13591
+ while (remaining.length > 0) {
13592
+ const ready = remaining.filter((item) => [...deps.get(item.id) ?? []].every((dep) => done.has(dep)));
13593
+ if (ready.length === 0) throw new MigrationCycleError(remaining.map((item) => item.id).sort());
13594
+ ready.sort(tie);
13595
+ const next = ready[0];
13596
+ if (next === void 0) break;
13597
+ ordered.push(next);
13598
+ done.add(next.id);
13599
+ remaining = remaining.filter((item) => item.id !== next.id);
13600
+ }
13601
+ return ordered;
13602
+ }
13603
+ /** Every way a list of migrations (in declaration order) is not a catalogue. */
13604
+ function catalogueIssues(items) {
13605
+ const issues = [];
13606
+ const seen = /* @__PURE__ */ new Set();
13607
+ const known = new Set(items.map((item) => item.id));
13608
+ const lastSeq = /* @__PURE__ */ new Map();
13609
+ const seqUsed = /* @__PURE__ */ new Map();
13610
+ for (const item of items) {
13611
+ if (seen.has(item.id)) issues.push({
13612
+ code: "duplicate-id",
13613
+ ids: [item.id],
13614
+ message: `duplicate id ${item.id}`
13615
+ });
13616
+ seen.add(item.id);
13617
+ const used = seqUsed.get(item.owner) ?? /* @__PURE__ */ new Set();
13618
+ if (used.has(item.seq)) issues.push({
13619
+ code: "duplicate-seq",
13620
+ ids: [item.id],
13621
+ message: `owner ${item.owner} has two migrations with seq ${item.seq}`
13622
+ });
13623
+ else if (item.seq < (lastSeq.get(item.owner) ?? 0)) issues.push({
13624
+ code: "seq-order",
13625
+ ids: [item.id],
13626
+ message: `seq ${item.seq} of ${item.id} does not increase in declaration order (owner ${item.owner})`
13627
+ });
13628
+ used.add(item.seq);
13629
+ seqUsed.set(item.owner, used);
13630
+ lastSeq.set(item.owner, Math.max(item.seq, lastSeq.get(item.owner) ?? 0));
13631
+ for (const dep of item.dependsOn) if (!known.has(dep)) issues.push({
13632
+ code: "unknown-dependency",
13633
+ ids: [item.id, dep],
13634
+ message: `${item.id} dependsOn unknown id ${dep}`
13635
+ });
13636
+ }
13637
+ try {
13638
+ orderMigrations(items);
13639
+ } catch (err) {
13640
+ if (err instanceof MigrationCycleError) issues.push({
13641
+ code: "cycle",
13642
+ ids: err.ids,
13643
+ message: err.message
13644
+ });
13645
+ else throw err;
13646
+ }
13647
+ return issues;
13648
+ }
13649
+ array(MigrationMetaSchema).superRefine((items, ctx) => {
13650
+ for (const issue of catalogueIssues(items)) ctx.addIssue({
13651
+ code: "custom",
13652
+ message: `${issue.code}: ${issue.message}`
13653
+ });
13654
+ });
13655
+ /**
13656
+ * The canonical JSON (`preconditionOf`) of the value a plan read; the apply step
13657
+ * re-reads, and a plan whose read no longer matches is refused (the migration is
13658
+ * `failed`, nothing it edited is kept).
13659
+ */
13660
+ var PreconditionSchema = string().min(1).optional();
13661
+ var MigrationPlanSchema = object({ edits: array(discriminatedUnion("op", [
13662
+ object({
13663
+ op: literal("setKeys"),
13664
+ scope: string().min(1),
13665
+ values: record(string(), unknown()),
13666
+ precondition: PreconditionSchema
13667
+ }),
13668
+ object({
13669
+ op: literal("deleteKeys"),
13670
+ scope: string().min(1),
13671
+ keys: array(string().min(1)).min(1),
13672
+ precondition: PreconditionSchema
13673
+ }),
13674
+ object({
13675
+ op: literal("putRow"),
13676
+ table: string().min(1),
13677
+ key: record(string(), unknown()),
13678
+ row: record(string(), unknown()),
13679
+ precondition: PreconditionSchema
13680
+ }),
13681
+ object({
13682
+ op: literal("deleteRow"),
13683
+ table: string().min(1),
13684
+ key: record(string(), unknown()),
13685
+ precondition: PreconditionSchema
13686
+ }),
13687
+ object({
13688
+ op: literal("upsertRecord"),
13689
+ kind: string().min(1),
13690
+ recordKey: string().min(1),
13691
+ value: unknown(),
13692
+ precondition: PreconditionSchema
13693
+ }),
13694
+ object({
13695
+ op: literal("deleteRecord"),
13696
+ kind: string().min(1),
13697
+ recordKey: string().min(1),
13698
+ precondition: PreconditionSchema
13699
+ })
13700
+ ])) });
13701
+ /**
13702
+ * What a `procedure` body reports. `already-done` means the rerun observed the
13703
+ * work finished (a crash between the work and the ledger row, or a manual fix)
13704
+ * and did none of it again; the ledger records `applied` either way.
13705
+ */
13706
+ var MigrationProcedureResultSchema = object({
13707
+ outcome: _enum(["done", "already-done"]),
13708
+ summary: record(string(), unknown())
13709
+ });
13710
+ /** What an owner hands the engine when one of its migrations ran. */
13711
+ var MigrationOwnerResultSchema = discriminatedUnion("kind", [
13712
+ object({
13713
+ kind: literal("plan"),
13714
+ plan: MigrationPlanSchema
13715
+ }),
13716
+ object({
13717
+ kind: literal("procedure"),
13718
+ result: MigrationProcedureResultSchema
13719
+ }),
13720
+ object({
13721
+ kind: literal("failed"),
13722
+ error: string().min(1)
13723
+ })
13724
+ ]);
13725
+ /**
13726
+ * `held`: a restore of a pre-migration snapshot undid this id; it does not rerun
13727
+ * until the operator retries or a new code version ships.
13728
+ * `skipped-newer`: the database knows an id this code does not.
13729
+ */
13730
+ var MigrationStatusSchema = _enum([
13731
+ "applied",
13732
+ "failed",
13733
+ "blocked",
13734
+ "running",
13735
+ "held",
13736
+ "skipped-newer"
13737
+ ]);
13738
+ var MigrationLedgerEntrySchema = object({
13739
+ id: string(),
13740
+ database: DataStoreDatabaseSchema,
13741
+ owner: string(),
13742
+ level: MigrationLevelSchema,
13743
+ seq: number().int().nonnegative(),
13744
+ status: MigrationStatusSchema,
13745
+ attempts: number().int().nonnegative(),
13746
+ appliedAt: number().nullable(),
13747
+ codeVersion: string().nullable(),
13748
+ /** What the apply changed: rows per table, as the engine counted them. */
13749
+ planSummary: record(string(), unknown()).nullable(),
13750
+ progress: record(string(), unknown()).nullable(),
13751
+ error: string().nullable(),
13752
+ /** Why it is `blocked` or `held` (`dependency-failed`, `snapshot-refused`, …). */
13753
+ reason: string().nullable(),
13754
+ nodeId: string().nullable(),
13755
+ bootId: string().nullable()
13756
+ });
13757
+ /** A catalogued migration that is not applied, with where it stands. */
13758
+ var MigrationPendingEntrySchema = object({
13759
+ meta: MigrationMetaSchema,
13760
+ database: DataStoreDatabaseSchema,
13761
+ state: _enum([
13762
+ "pending",
13763
+ "failed",
13764
+ "blocked",
13765
+ "held"
13766
+ ]),
13767
+ reason: string().nullable()
13768
+ });
13769
+ /** Rows per table before and after a dry run, and what it would have changed. */
13770
+ var MigrationDryRunResultSchema = object({
13771
+ id: string(),
13772
+ ok: boolean(),
13773
+ error: string().nullable(),
13774
+ rowsChanged: number().int().nonnegative(),
13775
+ tables: array(object({
13776
+ table: string(),
13777
+ before: number().int().nonnegative(),
13778
+ after: number().int().nonnegative()
13779
+ }))
13780
+ });
13781
+ /** One of an owner's migrations, as the engine tells the owner to treat it this boot. */
13782
+ var MigrationOwnerStepSchema = object({
13783
+ id: MigrationIdSchema,
13784
+ action: _enum(["run", "skip"]),
13785
+ /** The ledger state the engine found: `pending` has no row yet. */
13786
+ state: union([literal("pending"), MigrationStatusSchema])
13787
+ });
13788
+ /**
12947
13789
  * The trainer contract — what the hub hands the cloud trainer and what it
12948
13790
  * gets back (cloud training, D805+).
12949
13791
  *
@@ -16464,6 +17306,41 @@ var ACTUATOR_CAP_VOCABULARY = {
16464
17306
  icon: "droplets"
16465
17307
  }]
16466
17308
  },
17309
+ "power-source": {
17310
+ scope: "device",
17311
+ noun: t("Power source", "Alimentazione"),
17312
+ actions: [
17313
+ {
17314
+ id: "powerSource.on",
17315
+ method: "powerOn",
17316
+ label: t("Power on", "Dai corrente"),
17317
+ phrase: t("Power on {device}", "Dai corrente a {device}"),
17318
+ icon: "power"
17319
+ },
17320
+ {
17321
+ id: "powerSource.off",
17322
+ method: "powerOff",
17323
+ label: t("Power off", "Togli corrente"),
17324
+ phrase: t("Cut the power of {device}", "Togli la corrente a {device}"),
17325
+ icon: "power-off"
17326
+ },
17327
+ {
17328
+ id: "powerSource.forceRestart",
17329
+ method: "forceRestart",
17330
+ label: t("Force restart", "Riavvio forzato"),
17331
+ phrase: t("Force restart {device} by cutting its power", "Riavvia {device} togliendo la corrente"),
17332
+ icon: "refresh-cw"
17333
+ }
17334
+ ],
17335
+ state: [{
17336
+ kind: "boolean",
17337
+ field: "switchOn",
17338
+ label: t("Power switch on", "Presa accesa"),
17339
+ whenTrue: t("When the power of {device} comes on", "Quando arriva la corrente a {device}"),
17340
+ whenFalse: t("When the power of {device} is cut", "Quando manca la corrente a {device}"),
17341
+ icon: "power"
17342
+ }]
17343
+ },
16467
17344
  "lock-control": {
16468
17345
  scope: "device",
16469
17346
  noun: t("Lock", "Serratura"),
@@ -16939,7 +17816,7 @@ var ACTUATOR_CAP_VOCABULARY = {
16939
17816
  method: "setDirection",
16940
17817
  label: t("Spin forward", "Rotazione avanti"),
16941
17818
  phrase: t("Spin {device} forward", "Fai girare {device} in avanti"),
16942
- icon: "rotate-cw",
17819
+ icon: "refresh-cw",
16943
17820
  effect: {
16944
17821
  field: "direction",
16945
17822
  value: "forward"
@@ -20017,6 +20894,7 @@ var SYSTEM_CAP_VOCABULARY = {
20017
20894
  "login-method": system(IDENTITY),
20018
20895
  "mesh-network": system(NETWORK),
20019
20896
  "metrics-provider": system(CLUSTER),
20897
+ migrations: system(INTERNAL),
20020
20898
  "model-convert": system(ML),
20021
20899
  "model-distributor": system(ML),
20022
20900
  "mqtt-broker": system(NETWORK),
@@ -42383,7 +43261,7 @@ function pruneDeletedEntities(selection, live, log, exporter) {
42383
43261
  * rebuilds without manual reload.
42384
43262
  *
42385
43263
  * The hub-local builtin `addon-pages-aggregator` (see
42386
- * `@camstack/system/builtins/addon-pages-aggregator`) registers the
43264
+ * `@camstack/server/system/builtins/addon-pages-aggregator`) registers the
42387
43265
  * provider. Splitting the public aggregator from the raw collection
42388
43266
  * keeps both ends in codegen — there's no hand-written
42389
43267
  * `addon-pages.router.ts` wrapper anymore.
@@ -42473,7 +43351,7 @@ var addonRoutesCapability = {
42473
43351
  */
42474
43352
  invoke: method(InvokeRequestSchema, InvokeReplyEnvelopeSchema, { kind: "mutation" })
42475
43353
  },
42476
- /** BIG PLAN 2: declarative mount hint — read by `@camstack/system` `buildCapRouters`. */
43354
+ /** BIG PLAN 2: declarative mount hint — read by `@camstack/server/system` `buildCapRouters`. */
42477
43355
  mount: { kind: "skip" }
42478
43356
  };
42479
43357
  var ConfigTabDeclarationSchema = object({
@@ -42528,6 +43406,10 @@ method(object({
42528
43406
  }), method(object({
42529
43407
  addonId: string(),
42530
43408
  nodeId: string().optional()
43409
+ }), SettingsSchemaWithValuesSchema.nullable()), method(object({
43410
+ addonId: string(),
43411
+ nodeId: string().optional(),
43412
+ instance: IntegrationInstanceRefSchema
42531
43413
  }), SettingsSchemaWithValuesSchema.nullable()), method(object({
42532
43414
  addonId: string(),
42533
43415
  nodeId: string().optional()
@@ -42698,7 +43580,7 @@ method(_void(), array(WidgetMetadataSchema).readonly(), { auth: "admin" });
42698
43580
  * manual reload — same scheme used by `addon-pages`.
42699
43581
  *
42700
43582
  * The hub-local builtin `addon-widgets-aggregator` (see
42701
- * `@camstack/system/builtins/addon-widgets-aggregator`) registers the
43583
+ * `@camstack/server/system/builtins/addon-widgets-aggregator`) registers the
42702
43584
  * provider. Splitting the public aggregator from the raw collection
42703
43585
  * keeps both ends in codegen — there's no hand-written wrapper.
42704
43586
  */
@@ -43059,329 +43941,6 @@ method(object({
43059
43941
  password: string()
43060
43942
  }), AuthResultSchema.nullable(), { kind: "mutation" }), method(object({ state: string() }), string()), method(record(string(), string()), AuthResultSchema, { kind: "mutation" }), method(object({ token: string() }), AuthResultSchema.nullable());
43061
43943
  /**
43062
- * Query filter for settings-store collections.
43063
- */
43064
- var QueryFilterSchema = object({
43065
- where: record(string(), unknown()).optional(),
43066
- whereIn: record(string(), array(unknown())).optional(),
43067
- whereBetween: record(string(), tuple([unknown(), unknown()])).optional(),
43068
- /** NULL-safe exclusion: matches rows whose field is NULL OR != the value. */
43069
- whereNot: record(string(), unknown()).optional(),
43070
- /** NULL-safe exclusion of a SET — `whereNot` for more than one value. An
43071
- * empty list excludes nothing. See `QueryFilter.whereNotIn`. */
43072
- whereNotIn: record(string(), array(unknown())).optional(),
43073
- orderBy: object({
43074
- field: string(),
43075
- direction: _enum(["asc", "desc"])
43076
- }).optional(),
43077
- limit: number().optional(),
43078
- offset: number().optional()
43079
- });
43080
- /**
43081
- * The predicate half of a filter, for BULK MUTATIONS.
43082
- *
43083
- * Deliberately not `QueryFilterSchema`: `orderBy` / `limit` / `offset` have no
43084
- * meaning for a statement that rewrites a set, and accepting them would invite
43085
- * a caller to believe `limit` bounds the damage. Every field is optional here
43086
- * only so the shape stays composable — the implementation REJECTS a filter
43087
- * that compiles to no predicate, because that is the whole collection.
43088
- */
43089
- var MutationFilterSchema = object({
43090
- where: record(string(), unknown()).optional(),
43091
- whereIn: record(string(), array(unknown())).optional(),
43092
- whereBetween: record(string(), tuple([unknown(), unknown()])).optional(),
43093
- whereNot: record(string(), unknown()).optional(),
43094
- whereNotIn: record(string(), array(unknown())).optional()
43095
- });
43096
- /**
43097
- * One scalar an {@link settingsStoreCapability.methods.aggregate} call asks for.
43098
- *
43099
- * `as` names the slot in the result, so the SAME column may be asked twice with
43100
- * two operations (`MIN(startMs)` and `MAX(startMs)` in one round trip) — which
43101
- * a `Record<column, op>` shape could not express.
43102
- */
43103
- var AggregateFieldSchema = object({
43104
- /** Result key. */
43105
- as: string().min(1),
43106
- /** Column to aggregate. Must be a real column of a declared collection. */
43107
- field: string().min(1),
43108
- op: _enum([
43109
- "sum",
43110
- "min",
43111
- "max"
43112
- ])
43113
- });
43114
- /**
43115
- * `COUNT(*)` plus one number per requested field.
43116
- *
43117
- * `null` means NO ROW MATCHED, never zero: a `SUM` over an empty set and a sum
43118
- * that really is 0 are different facts, and an accounting caller that renders
43119
- * "0 bytes, oldest = 0" for "nothing here" reports a lie about a disk.
43120
- */
43121
- var AggregateResultSchema = object({
43122
- count: number().int(),
43123
- values: record(string(), number().nullable())
43124
- });
43125
- /** A single stored record: `{ id, data }`. */
43126
- var SettingsRecordSchema = object({
43127
- id: string(),
43128
- data: record(string(), unknown())
43129
- });
43130
- /**
43131
- * One record of a BULK insert — {@link SettingsRecordSchema} with the id made
43132
- * optional.
43133
- *
43134
- * A separate schema rather than loosening the shared one: every other method
43135
- * on this cap addresses a row BY its id, and making that field optional
43136
- * everywhere would turn a forgotten key into a silently generated one on
43137
- * `update` and `delete` as well.
43138
- */
43139
- var BulkRecordSchema = object({
43140
- id: string().optional(),
43141
- data: record(string(), unknown())
43142
- });
43143
- /**
43144
- * The database FILES one `sqlite-settings` engine process owns (D851).
43145
- * Closed on purpose: a file is a thing the engine opens, backs up and gives a
43146
- * serving thread, so a new one is a code change, never a string a caller
43147
- * invents. `settings` is `camstack.db` and the default for every collection
43148
- * that names no file.
43149
- */
43150
- var DataStoreDatabaseSchema = _enum([
43151
- "settings",
43152
- "events",
43153
- "history"
43154
- ]);
43155
- DataStoreDatabaseSchema.options;
43156
- /**
43157
- * One write inside a {@link settingsStoreCapability.methods.transact} call.
43158
- * The three that a "replace this set, bump that revision" write needs, plus
43159
- * the batched upsert a rollup writer needs.
43160
- */
43161
- var TransactOpSchema = discriminatedUnion("op", [
43162
- object({
43163
- op: literal("deleteWhere"),
43164
- collection: string(),
43165
- filter: MutationFilterSchema
43166
- }),
43167
- object({
43168
- op: literal("insertMany"),
43169
- collection: string(),
43170
- records: array(BulkRecordSchema).readonly()
43171
- }),
43172
- object({
43173
- op: literal("update"),
43174
- collection: string(),
43175
- id: string(),
43176
- data: record(string(), unknown())
43177
- }),
43178
- object({
43179
- op: literal("upsertMany"),
43180
- collection: string(),
43181
- conflict: array(string()).readonly(),
43182
- records: array(BulkRecordSchema).readonly()
43183
- })
43184
- ]);
43185
- /**
43186
- * The precondition of a transaction: the row `key` of `collection` must hold
43187
- * `equals` in `column`, read INSIDE the transaction.
43188
- */
43189
- var TransactGuardSchema = object({
43190
- collection: string(),
43191
- key: string(),
43192
- column: string(),
43193
- equals: unknown()
43194
- });
43195
- /**
43196
- * Column declaration for a structured (SQL-backed) collection.
43197
- *
43198
- * Logical types — the backend translates each to the matching SQLite
43199
- * storage class and handles per-type marshaling:
43200
- * - `TEXT` / `INTEGER` / `REAL` — native SQLite types, pass-through
43201
- * - `JSON` — TEXT under the hood; serialised on write, parsed on read
43202
- * - `BOOLEAN` — INTEGER 0/1 under the hood; coerced both directions
43203
- */
43204
- var CollectionColumnSchema = object({
43205
- name: string(),
43206
- type: _enum([
43207
- "TEXT",
43208
- "INTEGER",
43209
- "REAL",
43210
- "JSON",
43211
- "BOOLEAN"
43212
- ]),
43213
- primaryKey: boolean().optional(),
43214
- notNull: boolean().optional(),
43215
- unique: boolean().optional(),
43216
- /**
43217
- * Column DEFAULT. Required for B2: the four `ensureTable` consumers declare
43218
- * columns like `enabled INTEGER NOT NULL DEFAULT 1`, and without this the
43219
- * collection surface simply cannot express their existing tables — which is
43220
- * why they were still on the uncapped `table*` API.
43221
- */
43222
- defaultValue: union([
43223
- string(),
43224
- number(),
43225
- boolean()
43226
- ]).optional()
43227
- });
43228
- var CollectionIndexSchema = object({
43229
- name: string(),
43230
- columns: array(string()).readonly(),
43231
- unique: boolean().optional()
43232
- });
43233
- /**
43234
- * The input of `declareCollection` — ONE schema for the door and for the
43235
- * engine behind it, so the two surfaces cannot drift (the dispatcher forwards
43236
- * the payload untouched).
43237
- *
43238
- * - `database` — the file the collection lives in (D851). Absent means
43239
- * `settings`. A declaration naming a file other than the one the table is
43240
- * already in is REFUSED by the engine, never moved.
43241
- * - `primaryKey` — a COMPOSITE key, as column names. A single name is the same
43242
- * as `primaryKey: true` on that column. A composite-keyed collection has no
43243
- * `id`: it is written with `insertMany` / `upsertMany` / `transact` and read
43244
- * with `query` / `count` / `aggregate` / `deleteWhere`; the calls that
43245
- * address one row by id are refused.
43246
- * - `withoutRowid` — emit `WITHOUT ROWID`. Requires a primary key.
43247
- */
43248
- var DeclareCollectionInputSchema = object({
43249
- namespace: string().optional(),
43250
- collection: string(),
43251
- columns: array(CollectionColumnSchema).readonly(),
43252
- indexes: array(CollectionIndexSchema).readonly().optional(),
43253
- database: DataStoreDatabaseSchema.optional(),
43254
- primaryKey: array(string()).readonly().optional(),
43255
- withoutRowid: boolean().optional()
43256
- });
43257
- method(object({
43258
- namespace: string().optional(),
43259
- collection: string(),
43260
- key: string()
43261
- }), unknown(), { auth: "admin" }), method(object({
43262
- namespace: string().optional(),
43263
- collection: string(),
43264
- key: string(),
43265
- value: unknown()
43266
- }), _void(), {
43267
- kind: "mutation",
43268
- auth: "admin"
43269
- }), method(object({
43270
- namespace: string().optional(),
43271
- collection: string(),
43272
- filter: QueryFilterSchema.optional(),
43273
- columns: array(string()).readonly().optional()
43274
- }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
43275
- namespace: string().optional(),
43276
- collection: string(),
43277
- /** Declared columns identifying the slot; must be covered by a UNIQUE
43278
- * index on the collection. Never empty. */
43279
- conflict: array(string()).readonly(),
43280
- record: BulkRecordSchema
43281
- }), object({
43282
- /** The id the row HAS: assigned by SQLite on an insert, or the existing
43283
- * row's own id on an update. */
43284
- id: union([string(), number()]) }), {
43285
- kind: "mutation",
43286
- auth: "admin"
43287
- }), method(object({
43288
- namespace: string().optional(),
43289
- collection: string(),
43290
- conflict: array(string()).readonly(),
43291
- records: array(BulkRecordSchema).readonly()
43292
- }), object({ upserted: number().int() }), {
43293
- kind: "mutation",
43294
- auth: "admin"
43295
- }), method(object({
43296
- namespace: string().optional(),
43297
- collection: string(),
43298
- record: object({
43299
- id: string().optional(),
43300
- data: record(string(), unknown())
43301
- })
43302
- }), object({
43303
- /**
43304
- * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
43305
- * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
43306
- * primary key — which is the only place an auto key is knowable.
43307
- */
43308
- id: union([string(), number()]) }), {
43309
- kind: "mutation",
43310
- auth: "admin"
43311
- }), method(object({
43312
- namespace: string().optional(),
43313
- collection: string(),
43314
- records: array(BulkRecordSchema).readonly()
43315
- }), object({ inserted: number().int() }), {
43316
- kind: "mutation",
43317
- auth: "admin"
43318
- }), method(object({
43319
- namespace: string().optional(),
43320
- guard: TransactGuardSchema.optional(),
43321
- ops: array(TransactOpSchema).readonly()
43322
- }), object({
43323
- applied: boolean(),
43324
- current: unknown().optional()
43325
- }), {
43326
- kind: "mutation",
43327
- auth: "admin"
43328
- }), method(object({
43329
- namespace: string().optional(),
43330
- collection: string(),
43331
- id: string(),
43332
- data: record(string(), unknown())
43333
- }), _void(), {
43334
- kind: "mutation",
43335
- auth: "admin"
43336
- }), method(object({
43337
- namespace: string().optional(),
43338
- collection: string(),
43339
- key: string()
43340
- }), _void(), {
43341
- kind: "mutation",
43342
- auth: "admin"
43343
- }), method(object({
43344
- namespace: string().optional(),
43345
- collection: string(),
43346
- filter: MutationFilterSchema
43347
- }), object({ deleted: number().int() }), {
43348
- kind: "mutation",
43349
- auth: "admin"
43350
- }), method(object({
43351
- namespace: string().optional(),
43352
- collection: string(),
43353
- filter: MutationFilterSchema,
43354
- data: record(string(), unknown())
43355
- }), object({ updated: number().int() }), {
43356
- kind: "mutation",
43357
- auth: "admin"
43358
- }), method(object({
43359
- namespace: string().optional(),
43360
- collection: string(),
43361
- filter: QueryFilterSchema.optional()
43362
- }), number(), { auth: "admin" }), method(object({
43363
- namespace: string().optional(),
43364
- collection: string(),
43365
- fields: array(AggregateFieldSchema).readonly(),
43366
- filter: QueryFilterSchema.optional()
43367
- }), AggregateResultSchema, { auth: "admin" }), method(object({
43368
- namespace: string().optional(),
43369
- collection: string(),
43370
- field: string(),
43371
- bucketSize: number().int().positive(),
43372
- origin: number().int(),
43373
- filter: QueryFilterSchema.optional()
43374
- }), array(object({
43375
- bucket: number().int(),
43376
- count: number().int()
43377
- })).readonly(), { auth: "admin" }), method(object({
43378
- namespace: string().optional(),
43379
- collection: string()
43380
- }), boolean(), { auth: "admin" }), method(DeclareCollectionInputSchema, _void(), {
43381
- kind: "mutation",
43382
- auth: "admin"
43383
- });
43384
- /**
43385
43944
  * How long one snapshot may take end to end: the pinned copy of the whole
43386
43945
  * database plus `PRAGMA integrity_check` over the copy, on the hub's slowest
43387
43946
  * disk. ~800 MB at a pessimistic 10 MB/s is under 3 minutes; the bound is
@@ -45189,7 +45748,7 @@ method(object({
45189
45748
  kind: "mutation",
45190
45749
  auth: "admin"
45191
45750
  }), method(object({ blockIds: array(string()) }), object({ states: array(CompositionBlockStateSchema) }), { auth: "admin" });
45192
- 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;
45751
+ 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;
45193
45752
  var NUMBER = {
45194
45753
  kind: "fixed",
45195
45754
  result: ["number"]
@@ -46200,6 +46759,57 @@ id: union([string(), number()]) }), {
46200
46759
  kind: "mutation",
46201
46760
  auth: "admin"
46202
46761
  });
46762
+ 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({
46763
+ id: string().min(1),
46764
+ error: string().min(1)
46765
+ }), MigrationLedgerEntrySchema, {
46766
+ kind: "mutation",
46767
+ auth: "admin"
46768
+ }), method(object({ id: string().min(1) }), object({ entries: array(MigrationLedgerEntrySchema) }), {
46769
+ kind: "mutation",
46770
+ auth: "admin"
46771
+ }), method(object({
46772
+ database: DataStoreDatabaseSchema,
46773
+ snapshotId: string().min(1)
46774
+ }), object({
46775
+ scheduled: boolean(),
46776
+ held: array(string()),
46777
+ restartRequired: boolean()
46778
+ }), {
46779
+ kind: "mutation",
46780
+ auth: "admin"
46781
+ }), method(object({
46782
+ owner: string().min(1),
46783
+ metas: array(MigrationMetaSchema)
46784
+ }), object({
46785
+ bootId: string(),
46786
+ snapshot: _enum([
46787
+ "none",
46788
+ "written",
46789
+ "refused"
46790
+ ]),
46791
+ steps: array(MigrationOwnerStepSchema)
46792
+ }), {
46793
+ kind: "mutation",
46794
+ auth: "admin"
46795
+ }), method(object({ id: string().min(1) }), object({
46796
+ proceed: boolean(),
46797
+ state: union([literal("pending"), MigrationStatusSchema]),
46798
+ reason: string().nullable()
46799
+ }), {
46800
+ kind: "mutation",
46801
+ auth: "admin"
46802
+ }), method(object({
46803
+ id: string().min(1),
46804
+ result: MigrationOwnerResultSchema
46805
+ }), object({
46806
+ status: MigrationStatusSchema,
46807
+ error: string().nullable(),
46808
+ rowsChanged: number().int().nonnegative()
46809
+ }), {
46810
+ kind: "mutation",
46811
+ auth: "admin"
46812
+ });
46203
46813
  /**
46204
46814
  * records - an addon's own facts and documents (D881): ledgers, audit rows,
46205
46815
  * config documents, mirrors. The third storage API next to `ctx.settings`
@@ -60747,7 +61357,18 @@ var ServerUpdateActionResultSchema = object({
60747
61357
  * store (D877), present when the pre-flight refused the update
60748
61358
  * (`reason: 'addon-would-refuse'`). Optional for version skew.
60749
61359
  */
60750
- blockers: array(UpdateBlockerSchema).optional()
61360
+ blockers: array(UpdateBlockerSchema).optional(),
61361
+ /**
61362
+ * The minimums the target server declares and this node does not meet
61363
+ * (D989), present when the update was refused with
61364
+ * `reason: 'requirements-unmet'`. Each names the versions on both sides.
61365
+ */
61366
+ unmet: array(UnmetRequirementSchema).optional(),
61367
+ /**
61368
+ * The addons this node has below the minimum the staged server declares —
61369
+ * the ones to update WITH the server. Present on an accepted update.
61370
+ */
61371
+ requiredAddonUpdates: array(RequiredAddonUpdateSchema).optional()
60751
61372
  });
60752
61373
  var LaunchOverridesSchema = object({
60753
61374
  /** The persisted heap ceiling in MB, or `null` when none is set. */
@@ -63258,7 +63879,9 @@ var PackageUpdateSchema = object({
63258
63879
  latestVersion: string(),
63259
63880
  category: _enum(["addon", "core"]),
63260
63881
  requiresRestart: boolean(),
63261
- isSystem: boolean()
63882
+ isSystem: boolean(),
63883
+ /** Held: what the newer version needs and this node does not meet (D989). */
63884
+ blockedBy: array(UnmetRequirementSchema).readonly().optional()
63262
63885
  });
63263
63886
  var PackageVersionInfoSchema = object({
63264
63887
  version: string(),
@@ -64314,19 +64937,19 @@ var RemoteSetConfigResultSchema = discriminatedUnion("status", [object({ status:
64314
64937
  reason: _enum(["unknown-template", "not-a-media-player"]),
64315
64938
  detail: string()
64316
64939
  })]);
64317
- var deviceInput = object({ deviceId: number().int().nonnegative() });
64940
+ var deviceInput$1 = object({ deviceId: number().int().nonnegative() });
64318
64941
  DeviceType.MediaPlayer;
64319
- method(deviceInput, RemoteConfigSchema, { auth: "admin" }), method(deviceInput.extend({ config: RemoteConfigSchema }), RemoteSetConfigResultSchema, {
64942
+ method(deviceInput$1, RemoteConfigSchema, { auth: "admin" }), method(deviceInput$1.extend({ config: RemoteConfigSchema }), RemoteSetConfigResultSchema, {
64320
64943
  kind: "mutation",
64321
64944
  auth: "admin"
64322
- }), method(deviceInput, RemoteCommandListSchema, { auth: "protected" }), method(deviceInput.extend({
64945
+ }), method(deviceInput$1, RemoteCommandListSchema, { auth: "protected" }), method(deviceInput$1.extend({
64323
64946
  role: RemoteRoleSchema,
64324
64947
  /** Sends in a row (volume steps). */
64325
64948
  repeat: number().int().min(1).max(50).default(1)
64326
64949
  }), RemoteSendResultSchema, {
64327
64950
  kind: "mutation",
64328
64951
  auth: "protected"
64329
- }), method(deviceInput.extend({
64952
+ }), method(deviceInput$1.extend({
64330
64953
  command: RemoteMediaCommandSchema,
64331
64954
  muted: boolean().optional(),
64332
64955
  source: string().optional(),
@@ -66829,7 +67452,7 @@ DeviceType.LawnMower, method(object({ deviceId: number().int().nonnegative() }),
66829
67452
  * clients — they reverse-connect to the hub. Exposing their interfaces
66830
67453
  * via the same surface would leak internal topology with no upside.
66831
67454
  *
66832
- * Implementation in `@camstack/system/builtins/local-network/`.
67455
+ * Implementation in `@camstack/server/system/builtins/local-network/`.
66833
67456
  */
66834
67457
  /** Coarse classification derived from the interface name + IP range. */
66835
67458
  var InterfaceKindEnum = _enum([
@@ -67258,6 +67881,49 @@ DeviceType.Lock, method(object({
67258
67881
  kind: "mutation",
67259
67882
  auth: "protected"
67260
67883
  });
67884
+ var PowerSourceRefusalReasonSchema = _enum([
67885
+ "no-power-source",
67886
+ "switch-missing",
67887
+ "switch-offline",
67888
+ "switch-unknown",
67889
+ "restart-in-progress",
67890
+ "switch-call-failed"
67891
+ ]);
67892
+ var PowerSourceActionResultSchema = discriminatedUnion("accepted", [object({ accepted: literal(true) }), object({
67893
+ accepted: literal(false),
67894
+ reason: PowerSourceRefusalReasonSchema,
67895
+ /** One line for the operator, naming the switch. */
67896
+ message: string()
67897
+ })]);
67898
+ var PowerSourceInfoSchema = object({
67899
+ /** False when the device has no power source linked; the rest is then empty. */
67900
+ linked: boolean(),
67901
+ switchDeviceId: number().nullable(),
67902
+ switchName: string().nullable(),
67903
+ /** The switch's on/off state, or null when it is unknown. Never false for unknown (D393). */
67904
+ switchOn: boolean().nullable(),
67905
+ switchOnline: boolean().nullable(),
67906
+ restartInProgress: boolean(),
67907
+ offSeconds: number().int()
67908
+ });
67909
+ object({
67910
+ /** Null while the switch has not reported: unknown is never `false` (D393). */
67911
+ switchOn: boolean().nullable(),
67912
+ offSeconds: number().int(),
67913
+ lastFetchedAt: number()
67914
+ });
67915
+ 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;
67916
+ var deviceInput = object({ deviceId: number().int().nonnegative() });
67917
+ systemMethod(deviceInput, PowerSourceInfoSchema, { auth: "admin" }), systemMethod(deviceInput, PowerSourceActionResultSchema, {
67918
+ kind: "mutation",
67919
+ auth: "admin"
67920
+ }), systemMethod(deviceInput, PowerSourceActionResultSchema, {
67921
+ kind: "mutation",
67922
+ auth: "admin"
67923
+ }), systemMethod(deviceInput, PowerSourceActionResultSchema, {
67924
+ kind: "mutation",
67925
+ auth: "admin"
67926
+ });
67261
67927
  object({
67262
67928
  value: number().nullable().meta(readingMeta("device", { label: "Total" })),
67263
67929
  lastFetchedAt: number()
@@ -68066,7 +68732,7 @@ DeviceType.Camera, DeviceType.Sensor, DeviceType.Button, DeviceType.Switch, Devi
68066
68732
  * jitter, and observed/peak bandwidth per device + per client.
68067
68733
  *
68068
68734
  * Implementation lives in the server's `NetworkQualityService` (thin
68069
- * wrapper over the shared `NetworkQualityTracker` from `@camstack/system`).
68735
+ * wrapper over the shared `NetworkQualityTracker` from `@camstack/server/system`).
68070
68736
  * The provider is registered from `trpc.router.ts` against the existing
68071
68737
  * service instance — no addon owns this state.
68072
68738
  *
@@ -74102,6 +74768,13 @@ Object.freeze({
74102
74768
  access: "view",
74103
74769
  role: "admin"
74104
74770
  },
74771
+ "addonSettings.getIntegrationFormSchema": {
74772
+ capName: "addon-settings",
74773
+ capScope: "system",
74774
+ addonId: null,
74775
+ access: "view",
74776
+ role: "admin"
74777
+ },
74105
74778
  "addonSettings.getIntegrationSettings": {
74106
74779
  capName: "addon-settings",
74107
74780
  capScope: "system",
@@ -78190,6 +78863,69 @@ Object.freeze({
78190
78863
  access: "view",
78191
78864
  role: "admin"
78192
78865
  },
78866
+ "migrations.declareOwner": {
78867
+ capName: "migrations",
78868
+ capScope: "system",
78869
+ addonId: null,
78870
+ access: "create",
78871
+ role: "admin"
78872
+ },
78873
+ "migrations.dryRun": {
78874
+ capName: "migrations",
78875
+ capScope: "system",
78876
+ addonId: null,
78877
+ access: "view",
78878
+ role: "admin"
78879
+ },
78880
+ "migrations.finishMigration": {
78881
+ capName: "migrations",
78882
+ capScope: "system",
78883
+ addonId: null,
78884
+ access: "create",
78885
+ role: "admin"
78886
+ },
78887
+ "migrations.listLedger": {
78888
+ capName: "migrations",
78889
+ capScope: "system",
78890
+ addonId: null,
78891
+ access: "view",
78892
+ role: "admin"
78893
+ },
78894
+ "migrations.listPending": {
78895
+ capName: "migrations",
78896
+ capScope: "system",
78897
+ addonId: null,
78898
+ access: "view",
78899
+ role: "admin"
78900
+ },
78901
+ "migrations.markFailed": {
78902
+ capName: "migrations",
78903
+ capScope: "system",
78904
+ addonId: null,
78905
+ access: "create",
78906
+ role: "admin"
78907
+ },
78908
+ "migrations.restorePreMigration": {
78909
+ capName: "migrations",
78910
+ capScope: "system",
78911
+ addonId: null,
78912
+ access: "create",
78913
+ role: "admin"
78914
+ },
78915
+ "migrations.retry": {
78916
+ capName: "migrations",
78917
+ capScope: "system",
78918
+ addonId: null,
78919
+ access: "create",
78920
+ role: "admin"
78921
+ },
78922
+ "migrations.startMigration": {
78923
+ capName: "migrations",
78924
+ capScope: "system",
78925
+ addonId: null,
78926
+ access: "create",
78927
+ role: "admin"
78928
+ },
78193
78929
  "modelConvert.convert": {
78194
78930
  capName: "model-convert",
78195
78931
  capScope: "system",
@@ -80822,6 +81558,34 @@ Object.freeze({
80822
81558
  access: "view",
80823
81559
  role: "viewer"
80824
81560
  },
81561
+ "powerSource.forceRestart": {
81562
+ capName: "power-source",
81563
+ capScope: "device",
81564
+ addonId: null,
81565
+ access: "create",
81566
+ role: "admin"
81567
+ },
81568
+ "powerSource.getStatus": {
81569
+ capName: "power-source",
81570
+ capScope: "device",
81571
+ addonId: null,
81572
+ access: "view",
81573
+ role: "admin"
81574
+ },
81575
+ "powerSource.powerOff": {
81576
+ capName: "power-source",
81577
+ capScope: "device",
81578
+ addonId: null,
81579
+ access: "create",
81580
+ role: "admin"
81581
+ },
81582
+ "powerSource.powerOn": {
81583
+ capName: "power-source",
81584
+ capScope: "device",
81585
+ addonId: null,
81586
+ access: "create",
81587
+ role: "admin"
81588
+ },
80825
81589
  "presence.getStatus": {
80826
81590
  capName: "presence",
80827
81591
  capScope: "device",
@@ -85995,6 +86759,26 @@ Object.freeze({
85995
86759
  form: "single",
85996
86760
  optional: false
85997
86761
  }],
86762
+ "powerSource.forceRestart": [{
86763
+ name: "deviceId",
86764
+ form: "single",
86765
+ optional: false
86766
+ }],
86767
+ "powerSource.getStatus": [{
86768
+ name: "deviceId",
86769
+ form: "single",
86770
+ optional: false
86771
+ }],
86772
+ "powerSource.powerOff": [{
86773
+ name: "deviceId",
86774
+ form: "single",
86775
+ optional: false
86776
+ }],
86777
+ "powerSource.powerOn": [{
86778
+ name: "deviceId",
86779
+ form: "single",
86780
+ optional: false
86781
+ }],
85998
86782
  "presence.getStatus": [{
85999
86783
  name: "deviceId",
86000
86784
  form: "single",
@@ -95216,7 +96000,7 @@ async function handleBrokerLinkCallback(request, reply, deps) {
95216
96000
  * Lambda once, regenerating invalidates the old value).
95217
96001
  *
95218
96002
  * Could be unified with the stream-broker primitives into a shared
95219
- * `@camstack/system` util — kept local for now to avoid a system-package rebuild
96003
+ * `@camstack/server/system` util — kept local for now to avoid a system-package rebuild
95220
96004
  * during this batch (see the completion spec).
95221
96005
  */
95222
96006
  /** Generate a fresh high-entropy opaque ingress token (256-bit, base64url). */