@camstack/server 1.2.752 → 1.2.754

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/api/trpc/generated-cap-routers.js +10 -0
  3. package/dist/core/moleculer/moleculer.service.js +13 -1
  4. package/package.json +8 -8
  5. package/system/dist/addon-utils.mjs +1 -1
  6. package/system/dist/{agent-https-Oc0Go3Gs.js → agent-https-B0bjQVfy.js} +1 -1
  7. package/system/dist/{agent-https-DoGV9jKg.mjs → agent-https-cxghRfum.mjs} +1 -1
  8. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  9. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +4 -4
  10. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  11. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +5 -5
  12. package/system/dist/builtins/alerts/alerts.addon.js +1 -1
  13. package/system/dist/builtins/alerts/alerts.addon.mjs +1 -1
  14. package/system/dist/builtins/autotrack/index.js +1 -1
  15. package/system/dist/builtins/autotrack/index.mjs +1 -1
  16. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
  17. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +5 -5
  18. package/system/dist/builtins/calendars/calendars.addon.js +1 -1
  19. package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
  20. package/system/dist/builtins/camera-grid/index.js +1 -1
  21. package/system/dist/builtins/camera-grid/index.mjs +1 -1
  22. package/system/dist/builtins/composer/composer.addon.js +18 -22
  23. package/system/dist/builtins/composer/composer.addon.mjs +17 -21
  24. package/system/dist/builtins/console-logging/index.js +1 -1
  25. package/system/dist/builtins/console-logging/index.mjs +1 -1
  26. package/system/dist/builtins/core-blocks/composition-api.d.ts +4 -1
  27. package/system/dist/builtins/core-blocks/core-blocks.addon.js +232 -15
  28. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +232 -15
  29. package/system/dist/builtins/core-blocks/running-proposal.d.ts +32 -0
  30. package/system/dist/builtins/device-history/device-history.addon.js +24 -23
  31. package/system/dist/builtins/device-history/device-history.addon.mjs +3 -2
  32. package/system/dist/builtins/device-manager/device-manager.addon.js +1 -1
  33. package/system/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
  34. package/system/dist/builtins/hub-forwarder/index.js +1 -1
  35. package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
  36. package/system/dist/builtins/keychain/index.js +3 -3
  37. package/system/dist/builtins/keychain/index.mjs +3 -3
  38. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  39. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  40. package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
  41. package/system/dist/builtins/local-auth/local-auth.addon.mjs +5 -5
  42. package/system/dist/builtins/local-network/local-network.addon.js +2 -2
  43. package/system/dist/builtins/local-network/local-network.addon.mjs +2 -2
  44. package/system/dist/builtins/loki-logging/index.js +1 -1
  45. package/system/dist/builtins/loki-logging/index.mjs +1 -1
  46. package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  47. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +10 -10
  48. package/system/dist/builtins/platform-probe/index.js +1 -1
  49. package/system/dist/builtins/platform-probe/index.mjs +10 -10
  50. package/system/dist/builtins/record-entries/index.js +1 -1
  51. package/system/dist/builtins/record-entries/index.mjs +1 -1
  52. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  53. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  54. package/system/dist/builtins/snapshot/index.js +5 -1
  55. package/system/dist/builtins/snapshot/index.mjs +5 -1
  56. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  57. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +20 -20
  58. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  59. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  60. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +2 -2
  61. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +2 -2
  62. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  63. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  64. package/system/dist/builtins/system-config/system-config.addon.js +3 -3
  65. package/system/dist/builtins/system-config/system-config.addon.mjs +285 -285
  66. package/system/dist/builtins/winston-logging/index.js +1 -1
  67. package/system/dist/builtins/winston-logging/index.mjs +1 -1
  68. package/system/dist/{retention-C-lijsmN.mjs → capture-engine-CfJdhMTH.mjs} +2 -246
  69. package/system/dist/{retention-WjI-Op7G.js → capture-engine-eRAebXP1.js} +1 -305
  70. package/system/dist/{composition-sources-Bxahhz4f.js → composition-sources-BvDYLpw_.js} +1 -1
  71. package/system/dist/{composition-sources-CzRiSzCV.mjs → composition-sources-ChtkMq1Q.mjs} +1 -1
  72. package/system/dist/{constants-uI6uXyjP.mjs → constants-CYNsr0lM.mjs} +1 -1
  73. package/system/dist/{constants-0rC5QY6i.js → constants-DkC9-VOa.js} +1 -1
  74. package/system/dist/{coral-accelerators-DBlgWB8k.mjs → coral-accelerators-BW3OcrLD.mjs} +6 -6
  75. package/system/dist/{custom-action-registry-oHl1xltx.mjs → custom-action-registry-BIJZBObd.mjs} +37 -37
  76. package/system/dist/{device-ca-CL_Arugd.js → device-ca-BxInMpK2.js} +1 -1
  77. package/system/dist/{device-ca-D7TyMlsS.mjs → device-ca-CQg3PTnE.mjs} +1 -1
  78. package/system/dist/{dist-Iq3vrBOE.mjs → dist-C5eIFTMo.mjs} +752 -554
  79. package/system/dist/{dist-CYnRCUzN.js → dist-DFWnAzAY.js} +775 -553
  80. package/system/dist/file-host-worker.js +1 -1
  81. package/system/dist/file-host-worker.mjs +1 -1
  82. package/system/dist/{hub-mdns-ciao-CNLYSVyJ.js → hub-mdns-ciao-BQDdPkPO.js} +2 -2
  83. package/system/dist/{hub-mdns-ciao-CvMKderb.mjs → hub-mdns-ciao-DW_g42El.mjs} +2 -2
  84. package/system/dist/index.js +9 -8
  85. package/system/dist/index.mjs +220 -219
  86. package/system/dist/kernel/transport/parent-unowned-call.d.ts +10 -0
  87. package/system/dist/{restore-archive-vzWYLf6p.mjs → restore-archive-D8ZIN10X.mjs} +150 -150
  88. package/system/dist/{restore-archive-Dw04PiG5.js → restore-archive-DRjYgh6D.js} +1 -1
  89. package/system/dist/retention-B9l9TnGE.mjs +245 -0
  90. package/system/dist/retention-BNONb5X_.js +304 -0
  91. package/system/dist/{wal-maintenance-DQXiTaph.js → wal-maintenance-D0zSmIwJ.js} +0 -0
  92. package/system/dist/{wal-maintenance-BzTHorT2.mjs → wal-maintenance-xYk-FpJW.mjs} +0 -0
  93. package/system/package.json +1 -1
@@ -1171,7 +1171,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
1171
1171
  return DeviceRole;
1172
1172
  }({});
1173
1173
  //#endregion
1174
- //#region ../types/dist/sleep-DV4qxEyD.mjs
1174
+ //#region ../types/dist/sleep-hK-Dss3z.mjs
1175
1175
  /**
1176
1176
  * The audio chunk plane's byte format, and the ONE expansion from a coded
1177
1177
  * window to float samples (D455).
@@ -8205,7 +8205,7 @@ function sleep(ms) {
8205
8205
  return new Promise((resolve) => setTimeout(resolve, Math.max(0, ms)));
8206
8206
  }
8207
8207
  //#endregion
8208
- //#region ../types/dist/composition-CD1GdFuv.mjs
8208
+ //#region ../types/dist/composition-BSGHhcr8.mjs
8209
8209
  var AUDIO_ENCODER_BY_CODEC = {
8210
8210
  opus: "libopus",
8211
8211
  aac: "aac",
@@ -9777,45 +9777,6 @@ function evaluateExpressionSource(expr, bindingValues, now, opts) {
9777
9777
  }
9778
9778
  }
9779
9779
  /**
9780
- * One power reading becomes a washer, dryer or dishwasher (D944 helper).
9781
- *
9782
- * Standby of the control board is under 5 W; a motor or a heater is far
9783
- * above that, so 5 W is the line. A door lock or a short pump spike is not
9784
- * a cycle, so running starts only after 30 s above the line.
9785
- *
9786
- * A wash, dry or dishwasher pause (soak, heat-wait, heater off between
9787
- * bursts) lasts several minutes. Ending the cycle on the first dip would
9788
- * report "finished" in the middle of the program, so the stop dwell is
9789
- * 10 minutes on every type. The number is stored per type so one machine
9790
- * can move later without moving the others.
9791
- */
9792
- var APPLIANCE_TEMPLATE_ID = "appliance";
9793
- var APPLIANCE_KINDS = [
9794
- "washer",
9795
- "dryer",
9796
- "dishwasher"
9797
- ];
9798
- var DEVICE_TYPE = {
9799
- washer: DeviceType.Washer,
9800
- dryer: DeviceType.Dryer,
9801
- dishwasher: DeviceType.Dishwasher
9802
- };
9803
- function applianceDeviceType(kind) {
9804
- return DEVICE_TYPE[kind];
9805
- }
9806
- /**
9807
- * A dumb plug-in stove or heater, built from a smart plug (a `Heater`).
9808
- *
9809
- * The plug is the actuator: `switch.setState` is a FORWARD to the plug's own
9810
- * (D967), so the heater switches exactly as the plug does. Running is the
9811
- * plug being on; when a power reading is also named, running is the draw
9812
- * staying above the line instead (a plug left on with the stove's own
9813
- * thermostat open is not heating). 50 W is far above any standby and below
9814
- * the smallest radiator.
9815
- */
9816
- var HEATER_TEMPLATE_ID = "heater";
9817
- var HEATER_DEVICE_TYPE = DeviceType.Heater;
9818
- /**
9819
9780
  * Watts integrated over time, in kWh (D944).
9820
9781
  *
9821
9782
  * 1 kWh = 1 000 W × 3 600 000 ms. The history energy series uses the same
@@ -10117,6 +10078,26 @@ var DEFAULT_HISTORY_RETENTION = {
10117
10078
  hourMs: 365 * DAY_MS,
10118
10079
  dayMs: null
10119
10080
  };
10081
+ /**
10082
+ * The retention a device-history settings document states. A missing or
10083
+ * invalid number is the default; a `dayDays` of 0 (or none) keeps the daily
10084
+ * tier forever.
10085
+ */
10086
+ function historyRetentionFromSettings(raw) {
10087
+ return {
10088
+ rawMs: positiveDays(raw["rawDays"], DEFAULT_HISTORY_RETENTION.rawMs),
10089
+ fiveMinuteMs: positiveDays(raw["fiveMinuteDays"], DEFAULT_HISTORY_RETENTION.fiveMinuteMs),
10090
+ hourMs: positiveDays(raw["hourDays"], DEFAULT_HISTORY_RETENTION.hourMs),
10091
+ dayMs: positiveDaysOrForever(raw["dayDays"])
10092
+ };
10093
+ }
10094
+ function positiveDays(value, fallbackMs) {
10095
+ return typeof value === "number" && Number.isFinite(value) && value > 0 ? value * DAY_MS : fallbackMs;
10096
+ }
10097
+ function positiveDaysOrForever(value) {
10098
+ if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) return null;
10099
+ return value * DAY_MS;
10100
+ }
10120
10101
  var rollingWindowObject = z.object({
10121
10102
  kind: z.literal("rolling"),
10122
10103
  span: z.enum(ROLLING_SPANS),
@@ -10454,35 +10435,6 @@ var GroupHelperSpecSchema = z.object({
10454
10435
  /** Actuator groups only. Readings leave this unset. */
10455
10436
  active: ActiveCriterionSchema.optional()
10456
10437
  });
10457
- var ApplianceHelperSpecSchema = z.object({
10458
- kind: z.literal("appliance"),
10459
- templateId: z.literal(APPLIANCE_TEMPLATE_ID),
10460
- appliance: z.enum(APPLIANCE_KINDS),
10461
- thresholdWatts: z.number().positive(),
10462
- startDwellMs: z.number().int().nonnegative(),
10463
- stopDwellMs: z.number().int().nonnegative(),
10464
- member: HelperMemberSchema,
10465
- /**
10466
- * The plug that powers the appliance (`switch.on`). Optional: when set, the
10467
- * composition carries a `power-source` feature, so the hub can cut and restore
10468
- * that plug (power-source link of a NEW-target composition).
10469
- */
10470
- powerSwitch: HelperMemberSchema.optional(),
10471
- /** How long a forced restart keeps the plug off; the cap's default when unset. */
10472
- offSeconds: z.number().optional()
10473
- });
10474
- /** A dumb heater built from a plug: the plug is the actuator, a meter is optional. */
10475
- var HeaterHelperSpecSchema = z.object({
10476
- kind: z.literal("heater"),
10477
- templateId: z.literal(HEATER_TEMPLATE_ID),
10478
- /** The plug, read and commanded at `switch.on`. */
10479
- plug: HelperMemberSchema,
10480
- /** The plug's power reading, when it has one: running is then the draw, not the switch. */
10481
- meter: HelperMemberSchema.optional(),
10482
- thresholdWatts: z.number().positive(),
10483
- startDwellMs: z.number().int().nonnegative(),
10484
- stopDwellMs: z.number().int().nonnegative()
10485
- });
10486
10438
  var statisticHelperObject = z.object({
10487
10439
  kind: z.literal("statistic"),
10488
10440
  stat: z.enum(STATISTIC_STATS),
@@ -10533,8 +10485,6 @@ var derivativeHelperObject = z.object({
10533
10485
  });
10534
10486
  var HelperSpecSchema = z.discriminatedUnion("kind", [
10535
10487
  GroupHelperSpecSchema,
10536
- ApplianceHelperSpecSchema,
10537
- HeaterHelperSpecSchema,
10538
10488
  statisticHelperObject,
10539
10489
  integralHelperObject,
10540
10490
  thresholdHelperObject,
@@ -10549,8 +10499,6 @@ function isHistoryHelper(spec) {
10549
10499
  function helperMembers(spec) {
10550
10500
  switch (spec.kind) {
10551
10501
  case "group": return spec.members;
10552
- case "appliance": return [spec.member];
10553
- case "heater": return spec.meter === void 0 ? [spec.plug] : [spec.plug, spec.meter];
10554
10502
  case "statistic":
10555
10503
  case "integral":
10556
10504
  case "threshold":
@@ -41555,7 +41503,7 @@ var WEEKDAY_BY_INDEX = [
41555
41503
  "fri",
41556
41504
  "sat"
41557
41505
  ];
41558
- var MINUTE_MS$2 = 6e4;
41506
+ var MINUTE_MS$3 = 6e4;
41559
41507
  var DAY_MS$1 = 864e5;
41560
41508
  var formatters = /* @__PURE__ */ new Map();
41561
41509
  function formatterFor$1(timeZone) {
@@ -41637,8 +41585,8 @@ function wallToEpoch(localDate, hh, mm, timeZone) {
41637
41585
  if (valid.length > 0) return Math.min(...valid);
41638
41586
  let lo = wall - DAY_MS$1;
41639
41587
  let hi = wall + DAY_MS$1;
41640
- while (hi - lo > MINUTE_MS$2) {
41641
- const mid = Math.floor((lo + hi) / 2 / MINUTE_MS$2) * MINUTE_MS$2;
41588
+ while (hi - lo > MINUTE_MS$3) {
41589
+ const mid = Math.floor((lo + hi) / 2 / MINUTE_MS$3) * MINUTE_MS$3;
41642
41590
  if (offsetMs(mid, timeZone) === before) lo = mid;
41643
41591
  else hi = mid;
41644
41592
  }
@@ -41663,7 +41611,7 @@ function occurrenceOn(spec, localDate, site) {
41663
41611
  const midday = new Date(wallToEpoch(localDate, 12, 0, site.timeZone));
41664
41612
  const crossings = sunCrossings(site.lat, site.lon, midday, sunEventAltitude(spec.event));
41665
41613
  if (crossings === null) return null;
41666
- return (spec.event === "sunrise" || spec.event === "dawn" ? crossings.rise : crossings.set) + spec.offsetMin * MINUTE_MS$2;
41614
+ return (spec.event === "sunrise" || spec.event === "dawn" ? crossings.rise : crossings.set) + spec.offsetMin * MINUTE_MS$3;
41667
41615
  }
41668
41616
  }
41669
41617
  }
@@ -52825,207 +52773,6 @@ var BY_ID = new Map(GROUP_TEMPLATES.map((template) => [template.id, template]));
52825
52773
  function groupTemplate(id) {
52826
52774
  return BY_ID.get(id) ?? null;
52827
52775
  }
52828
- var PowerSourceRefusalReasonSchema = z.enum([
52829
- "no-power-source",
52830
- "switch-missing",
52831
- "switch-offline",
52832
- "switch-unknown",
52833
- "restart-in-progress",
52834
- "switch-call-failed"
52835
- ]);
52836
- var PowerSourceActionResultSchema = z.discriminatedUnion("accepted", [z.object({ accepted: z.literal(true) }), z.object({
52837
- accepted: z.literal(false),
52838
- reason: PowerSourceRefusalReasonSchema,
52839
- /** One line for the operator, naming the switch. */
52840
- message: z.string()
52841
- })]);
52842
- var PowerSourceInfoSchema = z.object({
52843
- /** False when the device has no power source linked; the rest is then empty. */
52844
- linked: z.boolean(),
52845
- switchDeviceId: z.number().nullable(),
52846
- switchName: z.string().nullable(),
52847
- /** The switch's on/off state, or null when it is unknown. Never false for unknown (D393). */
52848
- switchOn: z.boolean().nullable(),
52849
- switchOnline: z.boolean().nullable(),
52850
- restartInProgress: z.boolean(),
52851
- offSeconds: z.number().int()
52852
- });
52853
- /** The composed slice: the switch state the link mirrors, plus the stored off time. */
52854
- var PowerSourceStateSchema = z.object({
52855
- /** Null while the switch has not reported: unknown is never `false` (D393). */
52856
- switchOn: z.boolean().nullable(),
52857
- offSeconds: z.number().int(),
52858
- lastFetchedAt: z.number()
52859
- });
52860
- var POWER_SOURCE_DEVICE_TYPES = [
52861
- DeviceType.Gateway,
52862
- DeviceType.Hub,
52863
- DeviceType.Camera,
52864
- DeviceType.Sensor,
52865
- DeviceType.MediaPlayer,
52866
- DeviceType.Vacuum,
52867
- DeviceType.Generic,
52868
- DeviceType.Washer,
52869
- DeviceType.Dryer,
52870
- DeviceType.Dishwasher,
52871
- DeviceType.PetFountain,
52872
- DeviceType.Fan,
52873
- DeviceType.Humidifier,
52874
- DeviceType.Climate,
52875
- DeviceType.WaterHeater
52876
- ];
52877
- var powerSourceCustomize = {
52878
- version: 1,
52879
- targets: [{
52880
- id: "switch",
52881
- cardinality: "scalar",
52882
- vocabulary: {
52883
- cap: "power-source",
52884
- stateField: "switchOn"
52885
- },
52886
- deviceTypes: POWER_SOURCE_DEVICE_TYPES,
52887
- apply: "add",
52888
- path: "switchOn",
52889
- sources: [{
52890
- kind: "switch",
52891
- transforms: [{ kind: "identity" }]
52892
- }],
52893
- companions: [{
52894
- kind: "constant",
52895
- path: "offSeconds",
52896
- value: 10,
52897
- when: "add"
52898
- }, {
52899
- kind: "clock",
52900
- path: "lastFetchedAt",
52901
- when: "always"
52902
- }],
52903
- sourceReport: { status: "assignment-status" }
52904
- }]
52905
- };
52906
- var deviceInput$2 = z.object({ deviceId: z.number().int().nonnegative() });
52907
- var powerSourceCapability = {
52908
- name: "power-source",
52909
- scope: "device",
52910
- mode: "singleton",
52911
- deviceTypes: POWER_SOURCE_DEVICE_TYPES,
52912
- methods: {
52913
- getStatus: systemMethod(deviceInput$2, PowerSourceInfoSchema, { auth: "admin" }),
52914
- powerOn: systemMethod(deviceInput$2, PowerSourceActionResultSchema, {
52915
- kind: "mutation",
52916
- auth: "admin"
52917
- }),
52918
- powerOff: systemMethod(deviceInput$2, PowerSourceActionResultSchema, {
52919
- kind: "mutation",
52920
- auth: "admin"
52921
- }),
52922
- forceRestart: systemMethod(deviceInput$2, PowerSourceActionResultSchema, {
52923
- kind: "mutation",
52924
- auth: "admin"
52925
- })
52926
- },
52927
- runtimeState: PowerSourceStateSchema,
52928
- customize: powerSourceCustomize,
52929
- /**
52930
- * Runtime-state durability: **session** — mirrored from the linked switch on
52931
- * its next report; a restored value would outlive the reading it names.
52932
- *
52933
- * See `RuntimeStateDurability`. Enforced by
52934
- * `scripts/check-runtime-state-durability.ts`.
52935
- */
52936
- durability: "session",
52937
- history: "none"
52938
- };
52939
- /**
52940
- * Which smart switch powers a device (the `power-source` Customize extension):
52941
- * the source its stored `power-source.switchOn` field reads, and the off time of
52942
- * a forced restart stored beside it. Read from the STORED composition, never kept
52943
- * as a second copy (D676). Shared by the hub (which acts on the switch) and the
52944
- * admin UI (which shows it).
52945
- */
52946
- /**
52947
- * The stored off time, or the default when none is stored. A stored number out
52948
- * of range is CLAMPED to the bounds (a hand-written value never refuses the
52949
- * link, it just cannot cut power for an absurd time); a non-integer is rounded.
52950
- */
52951
- function normalizeOffSeconds(value) {
52952
- if (typeof value !== "number" || !Number.isFinite(value)) return 10;
52953
- return Math.min(120, Math.max(3, Math.round(value)));
52954
- }
52955
- /** The constant a stored `offSeconds` field carries, or undefined when it is not a literal number. */
52956
- function storedOffSeconds(composition) {
52957
- const feature = composition.features.find((f) => f.cap === "power-source");
52958
- if (feature === void 0 || feature.kind !== "fields") return void 0;
52959
- const field = feature.fields["offSeconds"];
52960
- if (field === void 0 || field.kind !== "expression") return void 0;
52961
- const n = Number(field.expr);
52962
- return field.expr.trim() === "" || !Number.isFinite(n) ? void 0 : n;
52963
- }
52964
- /**
52965
- * The link a composition stores. An `existing` target names its own device; a
52966
- * `new` target (an appliance helper) is the composer's own device, so the caller
52967
- * passes the block id and a new-target composition without one has no link.
52968
- */
52969
- function powerSourceLinkOfComposition(composition, blockId) {
52970
- if (composition === null) return null;
52971
- let device;
52972
- if (composition.target.kind === "existing") device = composition.target.device;
52973
- else if (blockId !== void 0) device = composedDeviceRef(blockId);
52974
- else return null;
52975
- const feature = composition.features.find((f) => f.cap === "power-source");
52976
- if (feature === void 0 || feature.kind !== "fields" || feature.enabled === false) return null;
52977
- const field = feature.fields["switchOn"];
52978
- if (field === void 0) return null;
52979
- const read = fieldReads(field).find((r) => r.cap === "switch");
52980
- if (read === void 0) return null;
52981
- return {
52982
- device,
52983
- switch: read.source,
52984
- offSeconds: normalizeOffSeconds(storedOffSeconds(composition))
52985
- };
52986
- }
52987
- var UNSIGNED = /^\d+(?:\.\d+)?$/;
52988
- var SIGNED = /^-?\d+(?:\.\d+)?$/;
52989
- var IDENT = /^[A-Za-z_][A-Za-z0-9_]*$/;
52990
- function unsignedToken(value) {
52991
- return token(value, UNSIGNED);
52992
- }
52993
- function signedToken(value) {
52994
- return token(value, SIGNED);
52995
- }
52996
- function constantExpr(value) {
52997
- if (typeof value === "string") return JSON.stringify(value);
52998
- if (typeof value === "number") return signedToken(value);
52999
- if (typeof value === "boolean") return value ? "true" : "false";
53000
- return "null";
53001
- }
53002
- /**
53003
- * Canonical text of a replace target's override (D984): the field keeps its
53004
- * NATIVE value (`native`) when that value is one of `unlessNative`, becomes
53005
- * `whenSourceTrue` while the boolean source (`x`) is true, else keeps native.
53006
- * A null source is falsy, so an unknown source leaves the native value.
53007
- */
53008
- function overrideExpr(whenSourceTrue, unlessNative) {
53009
- const guard = unlessNative.map((value) => `native == ${JSON.stringify(value)}`).join(" || ");
53010
- const inner = `(x ? ${JSON.stringify(whenSourceTrue)} : native)`;
53011
- return guard === "" ? inner.slice(1, -1) : `${guard} ? native : ${inner}`;
53012
- }
53013
- function isIdentifier(path) {
53014
- return IDENT.test(path);
53015
- }
53016
- function dwellExpr(comparison, threshold, start, stop) {
53017
- return `dwell(x ${comparison === "gte" ? ">=" : "<="} ${threshold}, ${start}, ${stop})`;
53018
- }
53019
- function linearExpr(inner, scale, offset, clampMin, clampMax) {
53020
- const arithmetic = `${inner} * ${scale} + ${offset}`;
53021
- if (clampMin === null || clampMax === null) return arithmetic;
53022
- return `clamp(${arithmetic}, ${clampMin}, ${clampMax})`;
53023
- }
53024
- function token(value, pattern) {
53025
- if (!Number.isFinite(value)) return null;
53026
- const text = Object.is(value, -0) ? "0" : String(value);
53027
- return pattern.test(text) ? text : null;
53028
- }
53029
52776
  var COLOR_MODE_FEATURES = [
53030
52777
  DeviceFeature.LightColorRgb,
53031
52778
  DeviceFeature.LightColorHsv,
@@ -53628,6 +53375,48 @@ function integralDraft(spec, retention = DEFAULT_HISTORY_RETENTION) {
53628
53375
  })
53629
53376
  };
53630
53377
  }
53378
+ var UNSIGNED = /^\d+(?:\.\d+)?$/;
53379
+ var SIGNED = /^-?\d+(?:\.\d+)?$/;
53380
+ var IDENT = /^[A-Za-z_][A-Za-z0-9_]*$/;
53381
+ function unsignedToken(value) {
53382
+ return token(value, UNSIGNED);
53383
+ }
53384
+ function signedToken(value) {
53385
+ return token(value, SIGNED);
53386
+ }
53387
+ function constantExpr(value) {
53388
+ if (typeof value === "string") return JSON.stringify(value);
53389
+ if (typeof value === "number") return signedToken(value);
53390
+ if (typeof value === "boolean") return value ? "true" : "false";
53391
+ return "null";
53392
+ }
53393
+ /**
53394
+ * Canonical text of a replace target's override (D984): the field keeps its
53395
+ * NATIVE value (`native`) when that value is one of `unlessNative`, becomes
53396
+ * `whenSourceTrue` while the boolean source (`x`) is true, else keeps native.
53397
+ * A null source is falsy, so an unknown source leaves the native value.
53398
+ */
53399
+ function overrideExpr(whenSourceTrue, unlessNative) {
53400
+ const guard = unlessNative.map((value) => `native == ${JSON.stringify(value)}`).join(" || ");
53401
+ const inner = `(x ? ${JSON.stringify(whenSourceTrue)} : native)`;
53402
+ return guard === "" ? inner.slice(1, -1) : `${guard} ? native : ${inner}`;
53403
+ }
53404
+ function isIdentifier(path) {
53405
+ return IDENT.test(path);
53406
+ }
53407
+ function dwellExpr(comparison, threshold, start, stop) {
53408
+ return `dwell(x ${comparison === "gte" ? ">=" : "<="} ${threshold}, ${start}, ${stop})`;
53409
+ }
53410
+ function linearExpr(inner, scale, offset, clampMin, clampMax) {
53411
+ const arithmetic = `${inner} * ${scale} + ${offset}`;
53412
+ if (clampMin === null || clampMax === null) return arithmetic;
53413
+ return `clamp(${arithmetic}, ${clampMin}, ${clampMax})`;
53414
+ }
53415
+ function token(value, pattern) {
53416
+ if (!Number.isFinite(value)) return null;
53417
+ const text = Object.is(value, -0) ? "0" : String(value);
53418
+ return pattern.test(text) ? text : null;
53419
+ }
53631
53420
  /**
53632
53421
  * Math helpers projected onto a new sensor (D944 phase 3). A threshold is the
53633
53422
  * `schmitt` builtin, a difference and a ratio are small expressions, a sum is
@@ -53783,10 +53572,6 @@ function expressionDraft(spec) {
53783
53572
  draft: spec.output === "boolean" ? binarySensor(spec, source) : numericSensor(spec, source)
53784
53573
  };
53785
53574
  }
53786
- /**
53787
- * Project a helper spec onto the composition the composer already runs (D944).
53788
- * Pure: it stores nothing. A group does not compile to `avg(...)` / `any(...)`.
53789
- */
53790
53575
  function sameSource(a, b) {
53791
53576
  return a.addonId === b.addonId && a.stableId === b.stableId;
53792
53577
  }
@@ -53878,162 +53663,10 @@ function expressionSource(expr, bindings = {}) {
53878
53663
  bindings
53879
53664
  };
53880
53665
  }
53881
- function compileAppliance(spec) {
53882
- const member = spec.member;
53883
- if (member.cap !== "power-meter" || member.fieldPath !== "power") return {
53884
- ok: false,
53885
- problems: [problem("member-constraint", "helper.member", "an appliance helper reads power-meter.power")]
53886
- };
53887
- const powerSwitch = spec.powerSwitch;
53888
- if (powerSwitch !== void 0 && (powerSwitch.cap !== "switch" || powerSwitch.fieldPath !== "on")) return {
53889
- ok: false,
53890
- problems: [problem("member-constraint", "helper.powerSwitch", "the power plug of an appliance helper is a switch, read at switch.on")]
53891
- };
53892
- const threshold = unsignedToken(spec.thresholdWatts);
53893
- const start = unsignedToken(spec.startDwellMs);
53894
- const stop = unsignedToken(spec.stopDwellMs);
53895
- if (threshold === null || spec.thresholdWatts <= 0) return {
53896
- ok: false,
53897
- problems: [problem("kind-mismatch", "helper.thresholdWatts", "the threshold is watts above which the appliance is running")]
53898
- };
53899
- if (start === null || stop === null) return {
53900
- ok: false,
53901
- problems: [problem("kind-mismatch", "helper.startDwellMs", "start and stop dwells are a non-negative number of milliseconds")]
53902
- };
53903
- const read = {
53904
- kind: "from",
53905
- source: member.source,
53906
- cap: member.cap,
53907
- fieldPath: member.fieldPath
53908
- };
53909
- const dwell = dwellExpr("gte", threshold, start, stop);
53910
- const clock = expressionSource("now");
53911
- const powerSourceFeatures = powerSwitch === void 0 ? [] : [{
53912
- kind: "fields",
53913
- cap: "power-source",
53914
- fields: {
53915
- switchOn: {
53916
- kind: "from",
53917
- source: powerSwitch.source,
53918
- cap: powerSwitch.cap,
53919
- fieldPath: powerSwitch.fieldPath
53920
- },
53921
- offSeconds: expressionSource(String(normalizeOffSeconds(spec.offSeconds))),
53922
- lastFetchedAt: clock
53923
- }
53924
- }];
53925
- return parseDraft({
53926
- target: {
53927
- kind: "new",
53928
- type: applianceDeviceType(spec.appliance)
53929
- },
53930
- helper: spec,
53931
- features: [
53932
- {
53933
- kind: "fields",
53934
- cap: "running-state",
53935
- fields: {
53936
- running: expressionSource(dwell, { x: read }),
53937
- source: expressionSource("\"assigned\""),
53938
- phase: expressionSource("null"),
53939
- lastFetchedAt: clock,
53940
- since: expressionSource(`latchedAt(${dwell})`, { x: read })
53941
- }
53942
- },
53943
- {
53944
- kind: "fields",
53945
- cap: "power-meter",
53946
- fields: {
53947
- power: read,
53948
- lastFetchedAt: clock
53949
- }
53950
- },
53951
- ...powerSourceFeatures
53952
- ]
53953
- });
53954
- }
53955
- function compileHeater(spec) {
53956
- if (spec.plug.cap !== "switch" || spec.plug.fieldPath !== "on") return {
53957
- ok: false,
53958
- problems: [problem("member-constraint", "helper.plug", "the plug of a heater helper is a switch, read at switch.on")]
53959
- };
53960
- const meter = spec.meter;
53961
- if (meter !== void 0 && (meter.cap !== "power-meter" || meter.fieldPath !== "power")) return {
53962
- ok: false,
53963
- problems: [problem("member-constraint", "helper.meter", "the meter of a heater helper reads power-meter.power")]
53964
- };
53965
- const threshold = unsignedToken(spec.thresholdWatts);
53966
- const start = unsignedToken(spec.startDwellMs);
53967
- const stop = unsignedToken(spec.stopDwellMs);
53968
- if (threshold === null || spec.thresholdWatts <= 0 || start === null || stop === null) return {
53969
- ok: false,
53970
- problems: [problem("kind-mismatch", "helper.thresholdWatts", "the threshold is positive watts; the dwells are a non-negative number of milliseconds")]
53971
- };
53972
- const plugRead = {
53973
- kind: "from",
53974
- source: spec.plug.source,
53975
- cap: spec.plug.cap,
53976
- fieldPath: spec.plug.fieldPath
53977
- };
53978
- const clock = expressionSource("now");
53979
- const meterRead = meter === void 0 ? void 0 : {
53980
- kind: "from",
53981
- source: meter.source,
53982
- cap: meter.cap,
53983
- fieldPath: meter.fieldPath
53984
- };
53985
- const dwell = dwellExpr("gte", threshold, start, stop);
53986
- const running = meterRead === void 0 ? expressionSource("x", { x: plugRead }) : expressionSource(dwell, { x: meterRead });
53987
- const since = meterRead === void 0 ? expressionSource("latchedAt(x)", { x: plugRead }) : expressionSource(`latchedAt(${dwell})`, { x: meterRead });
53988
- return parseDraft({
53989
- target: {
53990
- kind: "new",
53991
- type: HEATER_DEVICE_TYPE
53992
- },
53993
- helper: spec,
53994
- features: [
53995
- {
53996
- kind: "fields",
53997
- cap: "switch",
53998
- fields: {
53999
- on: plugRead,
54000
- lastChangedAt: clock
54001
- },
54002
- commands: { setState: {
54003
- kind: "forward",
54004
- source: spec.plug.source,
54005
- cap: "switch",
54006
- method: "setState"
54007
- } }
54008
- },
54009
- {
54010
- kind: "fields",
54011
- cap: "running-state",
54012
- fields: {
54013
- running,
54014
- source: expressionSource("\"assigned\""),
54015
- phase: expressionSource("null"),
54016
- lastFetchedAt: clock,
54017
- since
54018
- }
54019
- },
54020
- ...meterRead === void 0 ? [] : [{
54021
- kind: "fields",
54022
- cap: "power-meter",
54023
- fields: {
54024
- power: meterRead,
54025
- lastFetchedAt: clock
54026
- }
54027
- }]
54028
- ]
54029
- });
54030
- }
54031
53666
  /** Compile a helper template to a new-device composition. Refusals are named. */
54032
53667
  function compileHelper(spec, retention = DEFAULT_HISTORY_RETENTION) {
54033
53668
  switch (spec.kind) {
54034
53669
  case "group": return compileGroup(spec);
54035
- case "appliance": return compileAppliance(spec);
54036
- case "heater": return compileHeater(spec);
54037
53670
  case "statistic": {
54038
53671
  const built = statisticDraft(spec, retention);
54039
53672
  if (built.problems.length > 0) return {
@@ -54099,10 +53732,6 @@ function compileGroup(spec) {
54099
53732
  function sameHelperBody(stored, compiled) {
54100
53733
  return JSON.stringify(stored.target) === JSON.stringify(compiled.target) && JSON.stringify(stored.features) === JSON.stringify(compiled.features);
54101
53734
  }
54102
- /**
54103
- * Save-time checks a pure compile cannot make: the compiled features must be
54104
- * this spec's, and members that report a quantity must share one (D944 §4).
54105
- */
54106
53735
  function quantityProblems(spec, facts) {
54107
53736
  if (spec.kind !== "group") return [];
54108
53737
  const template = groupTemplate(spec.templateId);
@@ -54139,19 +53768,10 @@ function helperSaveProblems(composition, facts) {
54139
53768
  const compiled = compileHelper(spec);
54140
53769
  if (!compiled.ok) return compiled.problems;
54141
53770
  if (!sameHelperBody(composition, compiled.composition)) return [problem("helper-mismatch", "helper", "the stored features are not this template — the helper spec is the only writer")];
54142
- if (spec.kind === "appliance") return applianceMemberProblems(spec.member, facts);
54143
53771
  if (spec.kind === "arithmetic") return arithmeticQuantityProblems(spec, facts);
54144
53772
  if (spec.kind !== "group") return [];
54145
53773
  return [...quantityProblems(spec, facts), ...deviceTypeProblems(spec, facts)];
54146
53774
  }
54147
- function applianceMemberProblems(member, facts) {
54148
- const fact = facts.get(compositionSourceKey(member.source));
54149
- if (fact === void 0) return [];
54150
- const problems = [];
54151
- if (fact.deviceType !== void 0 && fact.deviceType !== DeviceType.Sensor && fact.deviceType !== DeviceType.Switch) problems.push(problem("member-constraint", "helper.member", `an appliance helper reads a sensor or a switch; this member is a ${fact.deviceType}`));
54152
- if (fact.quantity !== void 0 && fact.quantity !== "power") problems.push(problem("mixed-quantity", "helper.member", `an appliance helper reads power (W); this member is ${fact.quantity}`));
54153
- return problems;
54154
- }
54155
53775
  /**
54156
53776
  * A sum, a difference and a ratio combine readings of ONE quantity. The ratio
54157
53777
  * of two powers is a plain number, but a power over an energy is not a ratio of
@@ -54787,6 +54407,169 @@ function describeComposableCaps(defs, deviceType) {
54787
54407
  }).toSorted((a, b) => a.cap.localeCompare(b.cap));
54788
54408
  }
54789
54409
  /**
54410
+ * A saved Customize assignment (D936). The schema is the type: callers use
54411
+ * `z.infer`, they do not restate the shape.
54412
+ */
54413
+ var OverrideSourceSchema = z.object({
54414
+ addonId: z.string().min(1),
54415
+ stableId: z.string().min(1),
54416
+ cap: z.string().min(1),
54417
+ fieldPath: z.string().min(1)
54418
+ });
54419
+ var IdentityTransformDraftSchema = z.object({ kind: z.literal("identity") });
54420
+ var InvertTransformDraftSchema = z.object({ kind: z.literal("invert") });
54421
+ var ThresholdTransformDraftSchema = z.object({
54422
+ kind: z.literal("threshold"),
54423
+ comparison: z.enum(["gte", "lte"]),
54424
+ threshold: z.number(),
54425
+ startDwellMs: z.number().nonnegative(),
54426
+ stopDwellMs: z.number().nonnegative()
54427
+ });
54428
+ var LinearTransformDraftSchema = z.object({
54429
+ kind: z.literal("linear"),
54430
+ scale: z.number(),
54431
+ offset: z.number(),
54432
+ clampMin: z.number().optional(),
54433
+ clampMax: z.number().optional()
54434
+ });
54435
+ var EnumMapTransformDraftSchema = z.object({
54436
+ kind: z.literal("enum-map"),
54437
+ mapping: z.record(z.string(), z.string().nullable())
54438
+ });
54439
+ var NumberBridgeTransformDraftSchema = z.object({ kind: z.literal("number") });
54440
+ var CustomizeTransformDraftSchema = z.discriminatedUnion("kind", [
54441
+ IdentityTransformDraftSchema,
54442
+ InvertTransformDraftSchema,
54443
+ ThresholdTransformDraftSchema,
54444
+ LinearTransformDraftSchema,
54445
+ EnumMapTransformDraftSchema,
54446
+ NumberBridgeTransformDraftSchema
54447
+ ]);
54448
+ var ScalarOverrideDraftSchema = z.object({
54449
+ kind: z.literal("scalar"),
54450
+ cap: z.string().min(1),
54451
+ targetId: z.string().min(1),
54452
+ source: OverrideSourceSchema,
54453
+ transform: CustomizeTransformDraftSchema
54454
+ });
54455
+ var KeyedArrayOverrideDraftSchema = z.object({
54456
+ kind: z.literal("keyedArray"),
54457
+ cap: z.string().min(1),
54458
+ targetId: z.string().min(1),
54459
+ key: z.string().min(1),
54460
+ label: z.string().min(1),
54461
+ fieldPath: z.string().min(1),
54462
+ source: OverrideSourceSchema,
54463
+ transform: CustomizeTransformDraftSchema
54464
+ });
54465
+ var PulseOverrideDraftSchema = z.object({
54466
+ kind: z.literal("pulse"),
54467
+ cap: z.string().min(1),
54468
+ targetId: z.string().min(1),
54469
+ enabled: z.boolean(),
54470
+ debounceMs: z.number().nonnegative(),
54471
+ edges: z.array(z.enum([
54472
+ "rising",
54473
+ "button",
54474
+ "native-event"
54475
+ ])).min(1).optional(),
54476
+ sources: z.array(OverrideSourceSchema).min(1)
54477
+ });
54478
+ var SpanSourceDraftSchema = OverrideSourceSchema.extend({ mode: z.enum([
54479
+ "in-addition",
54480
+ "confirm",
54481
+ "replace"
54482
+ ]).optional() });
54483
+ var SpanOverrideDraftSchema = z.object({
54484
+ kind: z.literal("span"),
54485
+ cap: z.string().min(1),
54486
+ targetId: z.string().min(1),
54487
+ timeoutMs: z.number().nonnegative(),
54488
+ cooldownMs: z.number().nonnegative().optional(),
54489
+ sources: z.array(SpanSourceDraftSchema)
54490
+ });
54491
+ z.discriminatedUnion("kind", [
54492
+ ScalarOverrideDraftSchema,
54493
+ KeyedArrayOverrideDraftSchema,
54494
+ PulseOverrideDraftSchema,
54495
+ SpanOverrideDraftSchema
54496
+ ]);
54497
+ z.object({
54498
+ targetId: z.string().min(1),
54499
+ configured: z.boolean(),
54500
+ source: z.enum(["native", "assigned"]),
54501
+ state: z.enum([
54502
+ "active",
54503
+ "stale",
54504
+ "released",
54505
+ "unavailable"
54506
+ ]),
54507
+ reason: z.string().nullable()
54508
+ });
54509
+ /**
54510
+ * What a running-threshold proposal says (planning#405). The schema is the
54511
+ * type: the algorithm, the capability method and the UI all read `z.infer`.
54512
+ *
54513
+ * A proposal is read-only advice: it carries the numbers it was derived from
54514
+ * (`evidence`) so the operator can judge it, and an `insufficient` answer names
54515
+ * WHY with a typed reason and the catalog defaults, never an invented number.
54516
+ */
54517
+ var RunningProposalTierSchema = z.enum(["raw", "5m"]);
54518
+ var RunningProposalConfidenceSchema = z.enum([
54519
+ "high",
54520
+ "medium",
54521
+ "low"
54522
+ ]);
54523
+ var RunningProposalInsufficientReasonSchema = z.enum([
54524
+ "no-history",
54525
+ "span-too-short",
54526
+ "truncated",
54527
+ "no-idle-floor",
54528
+ "no-runs",
54529
+ "no-separation"
54530
+ ]);
54531
+ var RunningProposalReplaySchema = z.object({
54532
+ /** Intervals the real dwell expression held true over the window. */
54533
+ intervals: z.number().int().nonnegative(),
54534
+ /** Intervals outside every run, or a second interval inside one. */
54535
+ extra: z.number().int().nonnegative(),
54536
+ /** Runs without an interval of their own (none, or merged into a neighbour). */
54537
+ missed: z.number().int().nonnegative()
54538
+ });
54539
+ var RunningProposalEvidenceSchema = z.object({
54540
+ tier: RunningProposalTierSchema,
54541
+ spanMs: z.number().nonnegative(),
54542
+ from: z.number(),
54543
+ to: z.number(),
54544
+ points: z.number().int().nonnegative(),
54545
+ runsFound: z.number().int().nonnegative(),
54546
+ pausesFound: z.number().int().nonnegative(),
54547
+ longestPauseMs: z.number().nonnegative(),
54548
+ idleFloorW: z.number(),
54549
+ noiseCeilingW: z.number(),
54550
+ plateauW: z.number(),
54551
+ replay: RunningProposalReplaySchema
54552
+ });
54553
+ var RunningProposalInsufficientEvidenceSchema = z.object({
54554
+ spanMs: z.number().nonnegative(),
54555
+ points: z.number().int().nonnegative(),
54556
+ runsFound: z.number().int().nonnegative()
54557
+ });
54558
+ var RunningThresholdProposalSchema = z.discriminatedUnion("state", [z.object({
54559
+ state: z.literal("proposal"),
54560
+ transform: ThresholdTransformDraftSchema,
54561
+ evidence: RunningProposalEvidenceSchema,
54562
+ confidence: RunningProposalConfidenceSchema,
54563
+ /** Why the confidence is not higher; empty when nothing held it back. */
54564
+ notes: z.array(z.string())
54565
+ }), z.object({
54566
+ state: z.literal("insufficient"),
54567
+ reason: RunningProposalInsufficientReasonSchema,
54568
+ evidence: RunningProposalInsufficientEvidenceSchema,
54569
+ /** The catalog defaults, offered as what stands when nothing better is known. */
54570
+ fallback: ThresholdTransformDraftSchema
54571
+ })]);
54572
+ /**
54790
54573
  * The report of a one-shot "move this owner's plaintext secrets into the
54791
54574
  * keychain" run (D878). COUNTS only - never a value, never a ref.
54792
54575
  *
@@ -55283,6 +55066,21 @@ var coreBlocksCapability = {
55283
55066
  access: "view"
55284
55067
  }),
55285
55068
  /**
55069
+ * Propose the running threshold and dwells of a SOURCE device's power
55070
+ * field from its own history (planning#405). Read-only advice: nothing is
55071
+ * stored, the operator applies it through the ordinary save. An answer
55072
+ * with too little history says why, with the catalog defaults.
55073
+ */
55074
+ proposeRunningThreshold: method(z.object({
55075
+ deviceId: z.number().int(),
55076
+ cap: z.string().min(1),
55077
+ fieldPath: z.string().min(1),
55078
+ deviceType: z.enum(DeviceType).optional()
55079
+ }), RunningThresholdProposalSchema, {
55080
+ auth: "admin",
55081
+ access: "view"
55082
+ }),
55083
+ /**
55286
55084
  * An automation block reports one run (or one coalesced skip) to the hub's
55287
55085
  * `runs` ledger. Only the block itself may: the transport stamps
55288
55086
  * `callerAddonId`, and anything but `core-block-<blockId>` is refused.
@@ -61279,7 +61077,7 @@ var FanPresetCaptureResultSchema = z.object({
61279
61077
  items: z.array(FanCaptureItemSchema),
61280
61078
  omitted: z.array(FanCaptureOmissionSchema)
61281
61079
  });
61282
- var deviceInput$1 = z.object({ deviceId: z.number().int().nonnegative() });
61080
+ var deviceInput$2 = z.object({ deviceId: z.number().int().nonnegative() });
61283
61081
  var fanPresetsCustomize = {
61284
61082
  version: 1,
61285
61083
  targets: [{
@@ -61297,12 +61095,12 @@ var fanPresetsCapability = {
61297
61095
  scope: "system",
61298
61096
  mode: "singleton",
61299
61097
  methods: {
61300
- getPresets: method(deviceInput$1, z.array(FanPresetSchema), { auth: "protected" }),
61301
- setPresets: method(deviceInput$1.extend({ presets: z.array(FanPresetSchema).max(12) }), FanPresetsSetResultSchema, {
61098
+ getPresets: method(deviceInput$2, z.array(FanPresetSchema), { auth: "protected" }),
61099
+ setPresets: method(deviceInput$2.extend({ presets: z.array(FanPresetSchema).max(12) }), FanPresetsSetResultSchema, {
61302
61100
  kind: "mutation",
61303
61101
  auth: "admin"
61304
61102
  }),
61305
- applyPreset: method(deviceInput$1.extend({ presetId: z.string().min(1) }), FanPresetApplyResultSchema, {
61103
+ applyPreset: method(deviceInput$2.extend({ presetId: z.string().min(1) }), FanPresetApplyResultSchema, {
61306
61104
  kind: "mutation",
61307
61105
  auth: "protected"
61308
61106
  }),
@@ -61315,7 +61113,7 @@ var fanPresetsCapability = {
61315
61113
  * unknown is left out and named in `omitted`, never captured as 0. Nothing
61316
61114
  * is saved.
61317
61115
  */
61318
- capturePreset: method(deviceInput$1.extend({
61116
+ capturePreset: method(deviceInput$2.extend({
61319
61117
  fields: z.array(FanCaptureFieldSchema).optional(),
61320
61118
  steps: z.array(ActionStepSchema).max(20).default([])
61321
61119
  }), FanPresetCaptureResultSchema, { auth: "protected" })
@@ -80174,6 +79972,117 @@ var powerMeterCapability = {
80174
79972
  volatileStateFields: ["lastFetchedAt"],
80175
79973
  customize: powerMeterCustomize
80176
79974
  };
79975
+ var PowerSourceRefusalReasonSchema = z.enum([
79976
+ "no-power-source",
79977
+ "switch-missing",
79978
+ "switch-offline",
79979
+ "switch-unknown",
79980
+ "restart-in-progress",
79981
+ "switch-call-failed"
79982
+ ]);
79983
+ var PowerSourceActionResultSchema = z.discriminatedUnion("accepted", [z.object({ accepted: z.literal(true) }), z.object({
79984
+ accepted: z.literal(false),
79985
+ reason: PowerSourceRefusalReasonSchema,
79986
+ /** One line for the operator, naming the switch. */
79987
+ message: z.string()
79988
+ })]);
79989
+ var PowerSourceInfoSchema = z.object({
79990
+ /** False when the device has no power source linked; the rest is then empty. */
79991
+ linked: z.boolean(),
79992
+ switchDeviceId: z.number().nullable(),
79993
+ switchName: z.string().nullable(),
79994
+ /** The switch's on/off state, or null when it is unknown. Never false for unknown (D393). */
79995
+ switchOn: z.boolean().nullable(),
79996
+ switchOnline: z.boolean().nullable(),
79997
+ restartInProgress: z.boolean(),
79998
+ offSeconds: z.number().int()
79999
+ });
80000
+ /** The composed slice: the switch state the link mirrors, plus the stored off time. */
80001
+ var PowerSourceStateSchema = z.object({
80002
+ /** Null while the switch has not reported: unknown is never `false` (D393). */
80003
+ switchOn: z.boolean().nullable(),
80004
+ offSeconds: z.number().int(),
80005
+ lastFetchedAt: z.number()
80006
+ });
80007
+ var POWER_SOURCE_DEVICE_TYPES = [
80008
+ DeviceType.Gateway,
80009
+ DeviceType.Hub,
80010
+ DeviceType.Camera,
80011
+ DeviceType.Sensor,
80012
+ DeviceType.MediaPlayer,
80013
+ DeviceType.Vacuum,
80014
+ DeviceType.Generic,
80015
+ DeviceType.Washer,
80016
+ DeviceType.Dryer,
80017
+ DeviceType.Dishwasher,
80018
+ DeviceType.PetFountain,
80019
+ DeviceType.Fan,
80020
+ DeviceType.Humidifier,
80021
+ DeviceType.Climate,
80022
+ DeviceType.WaterHeater
80023
+ ];
80024
+ var powerSourceCustomize = {
80025
+ version: 1,
80026
+ targets: [{
80027
+ id: "switch",
80028
+ cardinality: "scalar",
80029
+ vocabulary: {
80030
+ cap: "power-source",
80031
+ stateField: "switchOn"
80032
+ },
80033
+ deviceTypes: POWER_SOURCE_DEVICE_TYPES,
80034
+ apply: "add",
80035
+ path: "switchOn",
80036
+ sources: [{
80037
+ kind: "switch",
80038
+ transforms: [{ kind: "identity" }]
80039
+ }],
80040
+ companions: [{
80041
+ kind: "constant",
80042
+ path: "offSeconds",
80043
+ value: 10,
80044
+ when: "add"
80045
+ }, {
80046
+ kind: "clock",
80047
+ path: "lastFetchedAt",
80048
+ when: "always"
80049
+ }],
80050
+ sourceReport: { status: "assignment-status" }
80051
+ }]
80052
+ };
80053
+ var deviceInput$1 = z.object({ deviceId: z.number().int().nonnegative() });
80054
+ var powerSourceCapability = {
80055
+ name: "power-source",
80056
+ scope: "device",
80057
+ mode: "singleton",
80058
+ deviceTypes: POWER_SOURCE_DEVICE_TYPES,
80059
+ methods: {
80060
+ getStatus: systemMethod(deviceInput$1, PowerSourceInfoSchema, { auth: "admin" }),
80061
+ powerOn: systemMethod(deviceInput$1, PowerSourceActionResultSchema, {
80062
+ kind: "mutation",
80063
+ auth: "admin"
80064
+ }),
80065
+ powerOff: systemMethod(deviceInput$1, PowerSourceActionResultSchema, {
80066
+ kind: "mutation",
80067
+ auth: "admin"
80068
+ }),
80069
+ forceRestart: systemMethod(deviceInput$1, PowerSourceActionResultSchema, {
80070
+ kind: "mutation",
80071
+ auth: "admin"
80072
+ })
80073
+ },
80074
+ runtimeState: PowerSourceStateSchema,
80075
+ customize: powerSourceCustomize,
80076
+ /**
80077
+ * Runtime-state durability: **session** — mirrored from the linked switch on
80078
+ * its next report; a restored value would outlive the reading it names.
80079
+ *
80080
+ * See `RuntimeStateDurability`. Enforced by
80081
+ * `scripts/check-runtime-state-durability.ts`.
80082
+ */
80083
+ durability: "session",
80084
+ history: "none"
80085
+ };
80177
80086
  /**
80178
80087
  * Presence cap. Models HA `person.*` and `device_tracker.*` entities
80179
80088
  * on `DeviceType.Presence`. Read-only — no setters: presence is
@@ -92559,6 +92468,335 @@ z.discriminatedUnion("kind", [z.object({
92559
92468
  kind: z.literal("pronto"),
92560
92469
  code: z.string()
92561
92470
  })]);
92471
+ /**
92472
+ * Propose a running threshold from a device's own power history (planning#405).
92473
+ *
92474
+ * Pure and deterministic: the same series gives the same answer. The series is
92475
+ * a HELD-VALUE step series — a point's value stands until the next point — which
92476
+ * is how device-history stores a gauge, so "time at a level" is exact, not a
92477
+ * count of samples.
92478
+ *
92479
+ * 1. idle floor F = time-weighted median; noise ceiling N = highest value seen
92480
+ * near F. A device that is not near one level most of the time has no floor.
92481
+ * 2. coarse activity = above max(2N, N + 5 W); consecutive stretches are episodes.
92482
+ * 3. gaps between episodes split in two by the largest log-scale jump (>= 3x):
92483
+ * the short ones are pauses INSIDE a run (a soak), the long ones separate runs.
92484
+ * 4. T = geometric mean of N and the plateau's 10th percentile, snapped to a
92485
+ * grid a person would type; stop dwell covers the longest pause; start dwell
92486
+ * covers the longest standby blip above T.
92487
+ * 5. the numbers are proved by REPLAY through the real `dwell` evaluation: each
92488
+ * run must hold exactly one true interval and nothing may flap outside.
92489
+ */
92490
+ var SECOND_MS = 1e3;
92491
+ var MINUTE_MS$1 = 60 * SECOND_MS;
92492
+ var PROPOSAL_MIN_SPAN_MS = 24 * (60 * MINUTE_MS$1);
92493
+ var MIN_ACTIVE_MS = 10 * MINUTE_MS$1;
92494
+ var IDLE_BAND_FRACTION = .5;
92495
+ var IDLE_BAND_MIN_W = 3;
92496
+ var MIN_IDLE_SHARE = .5;
92497
+ var COARSE_FACTOR = 2;
92498
+ var COARSE_MARGIN_W = 5;
92499
+ var PAUSE_JUMP_FACTOR = 3;
92500
+ var GAP_MARGIN_W = 2;
92501
+ var STOP_FACTOR = 1.5;
92502
+ var STOP_STEP_MS = 30 * SECOND_MS;
92503
+ var STOP_MIN_MS = 60 * SECOND_MS;
92504
+ var STOP_MAX_MS = 20 * MINUTE_MS$1;
92505
+ var START_STEP_MS = 10 * SECOND_MS;
92506
+ var START_MIN_MS = 10 * SECOND_MS;
92507
+ var STOP_WALK_STEPS = 6;
92508
+ var PLATEAU_QUANTILE = .1;
92509
+ var HIGH_CONFIDENCE_RUNS = 5;
92510
+ var MEDIUM_CONFIDENCE_RUNS = 2;
92511
+ /** The thresholds an operator would type, in watts. */
92512
+ var THRESHOLD_GRID_W = [
92513
+ 1,
92514
+ 2,
92515
+ 3,
92516
+ 5,
92517
+ 8,
92518
+ 10,
92519
+ 15,
92520
+ 20,
92521
+ 30,
92522
+ 50,
92523
+ 75,
92524
+ 100,
92525
+ 150,
92526
+ 200,
92527
+ 300,
92528
+ 500
92529
+ ];
92530
+ function proposeRunningThreshold(series) {
92531
+ const segments = toSegments(series);
92532
+ const spanMs = segments.length === 0 ? 0 : series.to - (segments[0]?.start ?? series.to);
92533
+ const insufficient = (reason, runsFound) => ({
92534
+ state: "insufficient",
92535
+ reason,
92536
+ evidence: {
92537
+ spanMs,
92538
+ points: series.points.length,
92539
+ runsFound
92540
+ },
92541
+ fallback: {
92542
+ kind: "threshold",
92543
+ comparison: "gte",
92544
+ threshold: 5,
92545
+ startDwellMs: RUNNING_POWER_START_DELAY_MS,
92546
+ stopDwellMs: RUNNING_POWER_STOP_DELAY_MS
92547
+ }
92548
+ });
92549
+ if (series.truncated) return insufficient("truncated", 0);
92550
+ if (segments.length === 0) return insufficient("no-history", 0);
92551
+ if (spanMs < 864e5) return insufficient("span-too-short", 0);
92552
+ const idleFloor = weightedQuantile(weigh(segments), .5);
92553
+ const band = Math.max(IDLE_BAND_MIN_W, IDLE_BAND_FRACTION * idleFloor);
92554
+ const quiet = segments.filter((s) => Math.abs(s.value - idleFloor) <= band);
92555
+ if (durationOf(quiet) < MIN_IDLE_SHARE * durationOf(segments)) return insufficient("no-idle-floor", 0);
92556
+ const noise = Math.max(idleFloor, ...quiet.map((s) => s.value));
92557
+ const coarse = Math.max(COARSE_FACTOR * noise, noise + COARSE_MARGIN_W);
92558
+ const active = segments.filter((s) => s.value > coarse);
92559
+ const episodes = mergeContiguous(active);
92560
+ if (durationOf(active) < MIN_ACTIVE_MS || episodes.length === 0) return insufficient("no-runs", 0);
92561
+ const { runs, pauses, betweenGaps } = splitRuns(episodes);
92562
+ const plateau = weightedQuantile(weigh(active.filter((s) => runs.some((r) => s.start < r.end && s.end > r.start))), PLATEAU_QUANTILE);
92563
+ const threshold = pickThreshold(noise, plateau);
92564
+ if (threshold === null) return insufficient("no-separation", runs.length);
92565
+ const notes = [];
92566
+ const longestPause = pauses.length === 0 ? 0 : Math.max(...pauses);
92567
+ let stop = clamp(roundUp(STOP_FACTOR * longestPause, STOP_STEP_MS), STOP_MIN_MS, STOP_MAX_MS);
92568
+ const shortestGap = betweenGaps.length === 0 ? null : Math.min(...betweenGaps);
92569
+ if (shortestGap !== null && stop > shortestGap / 2) notes.push("stop-dwell-exceeds-half-of-shortest-gap");
92570
+ const blips = excursionsOutside(segments, threshold, runs);
92571
+ let start = Math.max(START_MIN_MS, roundUp(STOP_FACTOR * maxOf(blips), START_STEP_MS));
92572
+ const shortestRun = Math.min(...runs.map((r) => r.end - r.start));
92573
+ if (start > shortestRun / 2) {
92574
+ notes.push("start-dwell-exceeds-half-of-shortest-run");
92575
+ start = Math.max(START_MIN_MS, Math.floor(shortestRun / 2 / START_STEP_MS) * START_STEP_MS);
92576
+ }
92577
+ let replay = replayDwell(segments, series.to, threshold, start, stop, runs);
92578
+ for (let step = 0; step < STOP_WALK_STEPS && !isClean(replay) && stop < STOP_MAX_MS; step += 1) {
92579
+ stop = Math.min(STOP_MAX_MS, roundUp(stop * STOP_FACTOR, STOP_STEP_MS));
92580
+ replay = replayDwell(segments, series.to, threshold, start, stop, runs);
92581
+ }
92582
+ if (!isClean(replay)) notes.push("replay-not-clean");
92583
+ return {
92584
+ state: "proposal",
92585
+ transform: {
92586
+ kind: "threshold",
92587
+ comparison: "gte",
92588
+ threshold,
92589
+ startDwellMs: start,
92590
+ stopDwellMs: stop
92591
+ },
92592
+ evidence: {
92593
+ tier: series.tier,
92594
+ spanMs,
92595
+ from: series.from,
92596
+ to: series.to,
92597
+ points: series.points.length,
92598
+ runsFound: runs.length,
92599
+ pausesFound: pauses.length,
92600
+ longestPauseMs: longestPause,
92601
+ idleFloorW: idleFloor,
92602
+ noiseCeilingW: noise,
92603
+ plateauW: plateau,
92604
+ replay
92605
+ },
92606
+ confidence: confidenceOf(runs.length, series.tier, notes),
92607
+ notes
92608
+ };
92609
+ }
92610
+ function confidenceOf(runs, tier, notes) {
92611
+ if (notes.length > 0 || runs < MEDIUM_CONFIDENCE_RUNS) return "low";
92612
+ if (runs >= HIGH_CONFIDENCE_RUNS && tier === "raw") return "high";
92613
+ return "medium";
92614
+ }
92615
+ function isClean(replay) {
92616
+ return replay.extra === 0 && replay.missed === 0;
92617
+ }
92618
+ function toSegments(series) {
92619
+ const steps = [];
92620
+ if (series.before !== null) steps.push({
92621
+ t: series.from,
92622
+ value: series.before.value
92623
+ });
92624
+ for (const p of series.points) if (p.t >= series.from && p.t < series.to) steps.push(p);
92625
+ steps.sort((a, b) => a.t - b.t);
92626
+ const out = [];
92627
+ steps.forEach((step, i) => {
92628
+ const end = steps[i + 1]?.t ?? series.to;
92629
+ if (step.value === null || !Number.isFinite(step.value) || end <= step.t) return;
92630
+ out.push({
92631
+ start: step.t,
92632
+ end,
92633
+ value: step.value
92634
+ });
92635
+ });
92636
+ return out;
92637
+ }
92638
+ function durationOf(spans) {
92639
+ return spans.reduce((sum, s) => sum + (s.end - s.start), 0);
92640
+ }
92641
+ function maxOf(values) {
92642
+ return values.length === 0 ? 0 : Math.max(...values);
92643
+ }
92644
+ function clamp(value, min, max) {
92645
+ return Math.min(max, Math.max(min, value));
92646
+ }
92647
+ function roundUp(value, step) {
92648
+ return Math.ceil(value / step) * step;
92649
+ }
92650
+ /** Time-weighted quantile: the first value whose cumulative weight reaches `q`. */
92651
+ function weightedQuantile(items, q) {
92652
+ const rows = [...items].sort((a, b) => a.value - b.value);
92653
+ const total = rows.reduce((sum, r) => sum + r.weight, 0);
92654
+ let seen = 0;
92655
+ for (const row of rows) {
92656
+ seen += row.weight;
92657
+ if (seen >= q * total) return row.value;
92658
+ }
92659
+ return rows[rows.length - 1]?.value ?? 0;
92660
+ }
92661
+ function weigh(segments) {
92662
+ return segments.map((s) => ({
92663
+ value: s.value,
92664
+ weight: s.end - s.start
92665
+ }));
92666
+ }
92667
+ /** Contiguous segments (one ends where the next starts) become one span. */
92668
+ function mergeContiguous(segments) {
92669
+ const out = [];
92670
+ for (const s of segments) {
92671
+ const last = out[out.length - 1];
92672
+ if (last !== void 0 && last.end === s.start) out[out.length - 1] = {
92673
+ start: last.start,
92674
+ end: s.end
92675
+ };
92676
+ else out.push({
92677
+ start: s.start,
92678
+ end: s.end
92679
+ });
92680
+ }
92681
+ return out;
92682
+ }
92683
+ /**
92684
+ * Gaps between episodes: the largest log-scale jump (>= 3x) in the sorted gaps
92685
+ * separates pauses inside a run from the gaps between runs. No jump: every gap
92686
+ * separates runs — a lone pause is indistinguishable from a short standby.
92687
+ */
92688
+ function splitRuns(episodes) {
92689
+ const gaps = episodes.slice(1).map((e, i) => e.start - (episodes[i]?.end ?? e.start));
92690
+ const sorted = [...gaps].sort((a, b) => a - b);
92691
+ let cut = null;
92692
+ let best = PAUSE_JUMP_FACTOR;
92693
+ for (let i = 0; i + 1 < sorted.length; i += 1) {
92694
+ const lo = sorted[i] ?? 0;
92695
+ const hi = sorted[i + 1] ?? 0;
92696
+ const ratio = lo > 0 ? hi / lo : Number.POSITIVE_INFINITY;
92697
+ if (ratio >= best) {
92698
+ best = ratio;
92699
+ cut = lo;
92700
+ }
92701
+ }
92702
+ const isPause = (gap) => cut !== null && gap <= cut;
92703
+ const runs = [];
92704
+ episodes.forEach((e, i) => {
92705
+ const gapBefore = i === 0 ? null : gaps[i - 1] ?? null;
92706
+ const last = runs[runs.length - 1];
92707
+ if (last !== void 0 && gapBefore !== null && isPause(gapBefore)) runs[runs.length - 1] = {
92708
+ start: last.start,
92709
+ end: e.end
92710
+ };
92711
+ else runs.push({
92712
+ start: e.start,
92713
+ end: e.end
92714
+ });
92715
+ });
92716
+ return {
92717
+ runs,
92718
+ pauses: gaps.filter(isPause),
92719
+ betweenGaps: gaps.filter((g) => !isPause(g))
92720
+ };
92721
+ }
92722
+ /** The grid value nearest (in log scale) to the geometric mean that still separates. */
92723
+ function pickThreshold(noise, plateau) {
92724
+ const target = Math.sqrt(Math.max(noise, .5) * plateau);
92725
+ let best = null;
92726
+ let bestDistance = Number.POSITIVE_INFINITY;
92727
+ for (const candidate of THRESHOLD_GRID_W) {
92728
+ if (candidate < noise + GAP_MARGIN_W || candidate > plateau) continue;
92729
+ const distance = Math.abs(Math.log(candidate / target));
92730
+ if (distance < bestDistance) {
92731
+ best = candidate;
92732
+ bestDistance = distance;
92733
+ }
92734
+ }
92735
+ return best;
92736
+ }
92737
+ /** Durations of stretches at or above `threshold` that lie outside every run. */
92738
+ function excursionsOutside(segments, threshold, runs) {
92739
+ return mergeContiguous(segments.filter((s) => s.value >= threshold)).filter((h) => !runs.some((r) => h.start < r.end && h.end > r.start)).map((h) => h.end - h.start);
92740
+ }
92741
+ /** Drive the real `dwell` evaluation over the series, deadlines included. */
92742
+ function replayDwell(segments, to, threshold, startMs, stopMs, runs) {
92743
+ const call = {
92744
+ kind: "dwell",
92745
+ pendingSince: null,
92746
+ latched: null,
92747
+ seenSince: null
92748
+ };
92749
+ let deadline = null;
92750
+ const hooks = { noteDeadline: (at) => {
92751
+ deadline = at;
92752
+ } };
92753
+ const intervals = [];
92754
+ let openAt = null;
92755
+ const evaluate = (active, at) => {
92756
+ deadline = null;
92757
+ const answer = evaluateDwell(active, startMs, stopMs, call, at, hooks);
92758
+ if (answer === true && openAt === null) openAt = at;
92759
+ if (answer !== true && openAt !== null) {
92760
+ intervals.push({
92761
+ start: openAt,
92762
+ end: at
92763
+ });
92764
+ openAt = null;
92765
+ }
92766
+ };
92767
+ segments.forEach((segment, i) => {
92768
+ const active = segment.value >= threshold;
92769
+ evaluate(active, segment.start);
92770
+ const next = segments[i + 1]?.start ?? to;
92771
+ while (deadline !== null && deadline <= next) evaluate(active, deadline);
92772
+ });
92773
+ if (openAt !== null) intervals.push({
92774
+ start: openAt,
92775
+ end: to
92776
+ });
92777
+ return judge(intervals, runs);
92778
+ }
92779
+ function judge(intervals, runs) {
92780
+ const hits = (i, r) => i.start < r.end && i.end > r.start;
92781
+ let extra = 0;
92782
+ let merged = 0;
92783
+ for (const interval of intervals) {
92784
+ const touched = runs.filter((r) => hits(interval, r)).length;
92785
+ if (touched === 0) extra += 1;
92786
+ merged += Math.max(0, touched - 1);
92787
+ }
92788
+ let missed = merged;
92789
+ for (const run of runs) {
92790
+ const mine = intervals.filter((i) => hits(i, run)).length;
92791
+ if (mine === 0) missed += 1;
92792
+ extra += Math.max(0, mine - 1);
92793
+ }
92794
+ return {
92795
+ intervals: intervals.length,
92796
+ extra,
92797
+ missed
92798
+ };
92799
+ }
92562
92800
  function isValueOf(slot, value) {
92563
92801
  return value.slot === slot;
92564
92802
  }
@@ -93030,6 +93268,54 @@ function lockDoorLinkOfComposition(composition) {
93030
93268
  sensor: x.source
93031
93269
  };
93032
93270
  }
93271
+ /**
93272
+ * Which smart switch powers a device (the `power-source` Customize extension):
93273
+ * the source its stored `power-source.switchOn` field reads, and the off time of
93274
+ * a forced restart stored beside it. Read from the STORED composition, never kept
93275
+ * as a second copy (D676). Shared by the hub (which acts on the switch) and the
93276
+ * admin UI (which shows it).
93277
+ */
93278
+ /**
93279
+ * The stored off time, or the default when none is stored. A stored number out
93280
+ * of range is CLAMPED to the bounds (a hand-written value never refuses the
93281
+ * link, it just cannot cut power for an absurd time); a non-integer is rounded.
93282
+ */
93283
+ function normalizeOffSeconds(value) {
93284
+ if (typeof value !== "number" || !Number.isFinite(value)) return 10;
93285
+ return Math.min(120, Math.max(3, Math.round(value)));
93286
+ }
93287
+ /** The constant a stored `offSeconds` field carries, or undefined when it is not a literal number. */
93288
+ function storedOffSeconds(composition) {
93289
+ const feature = composition.features.find((f) => f.cap === "power-source");
93290
+ if (feature === void 0 || feature.kind !== "fields") return void 0;
93291
+ const field = feature.fields["offSeconds"];
93292
+ if (field === void 0 || field.kind !== "expression") return void 0;
93293
+ const n = Number(field.expr);
93294
+ return field.expr.trim() === "" || !Number.isFinite(n) ? void 0 : n;
93295
+ }
93296
+ /**
93297
+ * The link a composition stores. An `existing` target names its own device; a
93298
+ * `new` target (a composed device) is the composer's own device, so the caller
93299
+ * passes the block id and a new-target composition without one has no link.
93300
+ */
93301
+ function powerSourceLinkOfComposition(composition, blockId) {
93302
+ if (composition === null) return null;
93303
+ let device;
93304
+ if (composition.target.kind === "existing") device = composition.target.device;
93305
+ else if (blockId !== void 0) device = composedDeviceRef(blockId);
93306
+ else return null;
93307
+ const feature = composition.features.find((f) => f.cap === "power-source");
93308
+ if (feature === void 0 || feature.kind !== "fields" || feature.enabled === false) return null;
93309
+ const field = feature.fields["switchOn"];
93310
+ if (field === void 0) return null;
93311
+ const read = fieldReads(field).find((r) => r.cap === "switch");
93312
+ if (read === void 0) return null;
93313
+ return {
93314
+ device,
93315
+ switch: read.source,
93316
+ offSeconds: normalizeOffSeconds(storedOffSeconds(composition))
93317
+ };
93318
+ }
93033
93319
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
93034
93320
  function fromRead(source, cap, fieldPath) {
93035
93321
  return {
@@ -96145,6 +96431,13 @@ var METHOD_ACCESS_MAP = Object.freeze({
96145
96431
  access: "create",
96146
96432
  role: "admin"
96147
96433
  },
96434
+ "coreBlocks.proposeRunningThreshold": {
96435
+ capName: "core-blocks",
96436
+ capScope: "system",
96437
+ addonId: null,
96438
+ access: "view",
96439
+ role: "admin"
96440
+ },
96148
96441
  "coreBlocks.reportAutomationRun": {
96149
96442
  capName: "core-blocks",
96150
96443
  capScope: "system",
@@ -105693,6 +105986,11 @@ Object.freeze({
105693
105986
  form: "single",
105694
105987
  optional: false
105695
105988
  }],
105989
+ "coreBlocks.proposeRunningThreshold": [{
105990
+ name: "deviceId",
105991
+ form: "single",
105992
+ optional: false
105993
+ }],
105696
105994
  "cover.close": [{
105697
105995
  name: "deviceId",
105698
105996
  form: "single",
@@ -108704,106 +109002,6 @@ var SESSION_ONLY_POLICY = {
108704
109002
  durability: "session",
108705
109003
  volatileFields: []
108706
109004
  };
108707
- /**
108708
- * A saved Customize assignment (D936). The schema is the type: callers use
108709
- * `z.infer`, they do not restate the shape.
108710
- */
108711
- var OverrideSourceSchema = z.object({
108712
- addonId: z.string().min(1),
108713
- stableId: z.string().min(1),
108714
- cap: z.string().min(1),
108715
- fieldPath: z.string().min(1)
108716
- });
108717
- var IdentityTransformDraftSchema = z.object({ kind: z.literal("identity") });
108718
- var InvertTransformDraftSchema = z.object({ kind: z.literal("invert") });
108719
- var ThresholdTransformDraftSchema = z.object({
108720
- kind: z.literal("threshold"),
108721
- comparison: z.enum(["gte", "lte"]),
108722
- threshold: z.number(),
108723
- startDwellMs: z.number().nonnegative(),
108724
- stopDwellMs: z.number().nonnegative()
108725
- });
108726
- var LinearTransformDraftSchema = z.object({
108727
- kind: z.literal("linear"),
108728
- scale: z.number(),
108729
- offset: z.number(),
108730
- clampMin: z.number().optional(),
108731
- clampMax: z.number().optional()
108732
- });
108733
- var EnumMapTransformDraftSchema = z.object({
108734
- kind: z.literal("enum-map"),
108735
- mapping: z.record(z.string(), z.string().nullable())
108736
- });
108737
- var NumberBridgeTransformDraftSchema = z.object({ kind: z.literal("number") });
108738
- var CustomizeTransformDraftSchema = z.discriminatedUnion("kind", [
108739
- IdentityTransformDraftSchema,
108740
- InvertTransformDraftSchema,
108741
- ThresholdTransformDraftSchema,
108742
- LinearTransformDraftSchema,
108743
- EnumMapTransformDraftSchema,
108744
- NumberBridgeTransformDraftSchema
108745
- ]);
108746
- var ScalarOverrideDraftSchema = z.object({
108747
- kind: z.literal("scalar"),
108748
- cap: z.string().min(1),
108749
- targetId: z.string().min(1),
108750
- source: OverrideSourceSchema,
108751
- transform: CustomizeTransformDraftSchema
108752
- });
108753
- var KeyedArrayOverrideDraftSchema = z.object({
108754
- kind: z.literal("keyedArray"),
108755
- cap: z.string().min(1),
108756
- targetId: z.string().min(1),
108757
- key: z.string().min(1),
108758
- label: z.string().min(1),
108759
- fieldPath: z.string().min(1),
108760
- source: OverrideSourceSchema,
108761
- transform: CustomizeTransformDraftSchema
108762
- });
108763
- var PulseOverrideDraftSchema = z.object({
108764
- kind: z.literal("pulse"),
108765
- cap: z.string().min(1),
108766
- targetId: z.string().min(1),
108767
- enabled: z.boolean(),
108768
- debounceMs: z.number().nonnegative(),
108769
- edges: z.array(z.enum([
108770
- "rising",
108771
- "button",
108772
- "native-event"
108773
- ])).min(1).optional(),
108774
- sources: z.array(OverrideSourceSchema).min(1)
108775
- });
108776
- var SpanSourceDraftSchema = OverrideSourceSchema.extend({ mode: z.enum([
108777
- "in-addition",
108778
- "confirm",
108779
- "replace"
108780
- ]).optional() });
108781
- var SpanOverrideDraftSchema = z.object({
108782
- kind: z.literal("span"),
108783
- cap: z.string().min(1),
108784
- targetId: z.string().min(1),
108785
- timeoutMs: z.number().nonnegative(),
108786
- cooldownMs: z.number().nonnegative().optional(),
108787
- sources: z.array(SpanSourceDraftSchema)
108788
- });
108789
- z.discriminatedUnion("kind", [
108790
- ScalarOverrideDraftSchema,
108791
- KeyedArrayOverrideDraftSchema,
108792
- PulseOverrideDraftSchema,
108793
- SpanOverrideDraftSchema
108794
- ]);
108795
- z.object({
108796
- targetId: z.string().min(1),
108797
- configured: z.boolean(),
108798
- source: z.enum(["native", "assigned"]),
108799
- state: z.enum([
108800
- "active",
108801
- "stale",
108802
- "released",
108803
- "unavailable"
108804
- ]),
108805
- reason: z.string().nullable()
108806
- });
108807
109005
  var G711_SCALE_CORRECTION_DB = {
108808
109006
  PCMU: 20 * Math.log10(4),
108809
109007
  PCMA: 20 * Math.log10(8)
@@ -110575,4 +110773,4 @@ z.object({
110575
110773
  commands: z.record(z.string(), z.unknown())
110576
110774
  });
110577
110775
  //#endregion
110578
- export { EMPTY_REMOTE_CONFIG as $, composedDeviceStableId as $a, resolveRunnerId as $i, defineExtensionSlotProvider as $n, WELL_KNOWN_TAB_MAP as $o, locationIconKey as $r, toSecretFieldView as $s, TemplateKindSchema as $t, CredentialTokenClaimsSchema as A, userManagementCapability as Aa, platformProbeCapability as Ai, checkRoleAddress as An, InvalidRecordError as Ao, integrationInstancesCapability as Ar, isSecretFieldView as As, PreferenceNamespaceSchema as At, DEVICE_ID_FIELD as B, withLocationMode as Ba, remoteCapability as Bi, coreBlockComposition as Bn, RUNTIME_DEFAULTS as Bo, isInternalActionId as Br, parseJsonObject as Bs, RunningStateStatusSchema as Bt, CORE_BLOCK_ADDON_PREFIX as C, streamQualityLabel as Ca, occurrenceOn as Ci, buildDeviceSignatureMessage as Cn, DATAPLANE_SECRET_HEADER as Co, filesystemBrowseCapability as Cr, hydrateSchema as Cs, MediaPlayerStatusSchema as Ct, ConditionMirror as D, timedRunCapability as Da, parseStreamParamsFormPatch as Di, canonicalIconKey as Dn, FilterRequiredError as Do, gbToBytes as Dr, isKeychainStoredField as Ds, PREFERENCES_MAX_VALUE_BYTES as Dt, CatalogFileSchema as E, templateCapability as Ea, parseColorInput as Ei, cameraGridLayoutCapability as En, DeclarationRefusedError as Eo, formatMinutes as Er, isEvent as Es, NetworkTunnelStartedDataSchema as Et, DAY_NAMES as F, vectorDimFromBase64 as Fa, procedureAuthKey as Fi, compileScalarOverride as Fn, RECORD_DELETE_BATCH as Fo, isAppLinkBase as Fr, mapSecretLeaves as Fs, ROOT_BUCKET_KEY as Ft, DataStoreDatabaseSchema as G, DEFAULT_HISTORY_RETENTION as Ga, resolveBucketMs as Gi, createDeviceExtensionProvider as Gn, RecordTooLargeError as Go, kebabToCamel as Gr, resolveCapMount as Gs, ScopedTokenSchema as Gt, DEVICE_SAN_CREDENTIAL_PREFIX as H, COMPOSER_ADDON_ID as Ha, replacedFieldKeys as Hi, coreBlockSourceKind as Hn, ReadinessTimeoutError as Ho, isObjectInput as Hr, parseSecretRef as Hs, STREAM_PROFILE_META as Ht, DEFAULT_HOLD_OVERRIDE as I, vectorIndexDimConflictError as Ia, ptzAutotrackCapability as Ii, composerCapability as In, RECORD_SECRET_COLLECTION_PREFIX as Io, isArrayOutputSchema as Ir, nodeIdOfScopedKey as Is, RecordIntegrationInstances as It, DeviceStatusSchema as J, HOUR_MS as Ja, resolveHubAddressRoles as Ji, dataStoreProviderCapability as Jn, SECRET_CLEAR as Jo, legacyAutoLinkIds as Jr, secretTreeFromPaths as Js, StorageCleanupJobSchema as Jt, DeclaredDevices as K, HISTORY_FAST_MS as Ka, resolveCoreBlockEntry as Ki, customKeyOfRole as Kn, RecordUniqueViolationError as Ko, keychainAdminCapability as Kr, resolveSecretMarkers as Ks, ServerNameSchema as Kt, DERIVED_CAMERA_SILENCED_CAP_NAMES as L, vectorStoreCapability as La, recordEntriesCapability as Li, compositionFieldKey as Ln, RECORD_SWEEP_INTERVAL_MS as Lo, isCollectionArrayMethod as Lr, nodePin as Ls, RecordingStatusSchema as Lt, DATABASE_SNAPSHOT_SUFFIX as M, validateCustomAddress as Ma, powerSourceLinkOfComposition as Mi, climateControlCapability as Mn, PlaintextSecretError as Mo, interpolate as Mr, isSecretMarkerLike as Ms, QuantityUnitError as Mt, DATABASE_SNAPSHOT_TIMEOUT_MS as N, validateSchedulerInput as Na, preconditionOf as Ni, collectWhenMirrorSources as Nn, RECORD_BATCH_MAX as No, isAlertEpisodeOpen as Nr, isSecretRefOwnedBy as Ns, RECORDING_SOURCE_CAMSTACK_ADDON as Nt, ControlStatusSchema as O, timedRunLimitOf as Oa, pickAppLinkHub as Oi, capUnitResolver as On, ForeignSecretMarkerError as Oo, groupCommandsCapability as Or, isReadingQuantity as Os, PowerSourceInfoSchema as Ot, DATA_STORE_DATABASES as P, valveCapability as Pa, problemsBlockSave as Pi, colorCapability as Pn, RECORD_BATCH_MAX_BYTES as Po, isAlertEpisodeSeverity as Pr, makeSecretMarker as Ps, REMOTE_MEDIA_COMMANDS as Pt, EMPTY_REMOTE_ASSUMED_STATE as Q, composedDeviceRef as Qa, resolveNotificationTapAddress as Qi, decodeVectorBase64 as Qn, UnknownRecordKindError as Qo, localNetworkCapability as Qr, toNodeId as Qs, SwitchStatusSchema as Qt, DEVICE_ENROLLMENT_TTL_MS as R, vocabActionIdFor as Ra, recordsCapability as Ri, compositionSourceRefs as Rn, REDACTED_SECRET as Ro, isCredentialTokenPayload as Rr, normalizeNodeId as Rs, RemoteAssumedStateSchema as Rt, CORE_BLOCKS_ADDON_ID as S, streamCatalogCapability as Sa, objectInputDeclaresRequiredDeviceId as Si, buildDeviceEnrollmentLink as Sn, CALLER_STAMPED_CAPABILITIES as So, featureForwards as Sr, historyUnitFor as Ss, MOTION_CLOSE_AFTER_MS as St, CalendarPreferencesSchema as T, switchCapability as Ta, parseAcceleratorFactsJson as Ti, calendarsCapability as Tn, DEVICE_STATUS_METHOD as To, formatDeviceRevoker as Tr, isDeviceConfigCap as Ts, MigrationMetaSchema as Tt, DEVICE_SAN_USER_PREFIX as U, CompositionSchema as Ua, resolveActionVariables as Ui, coreBlocksCapability as Un, RecordKindDeclarationSchema as Uo, isSameAddonId as Ur, readinessKey as Us, SchedulerError as Ut, DEVICE_NONCE_TTL_MS as V, zoneOnlySite as Va, remoteLayoutComponentsCapability as Vi, coreBlockIdFromAddonId as Vn, ReadinessRegistry as Vo, isLocationEnabled as Vr, parseJsonUnknown as Vs, STORAGE_ACCESS_FALLBACK as Vt, DEVICE_TOMBSTONE_RETENTION_MS as W, DAY_MS as Wa, resolveAppConnections as Wi, coverCapability as Wn, RecordNotFoundError as Wo, isVoidInput as Wr, recordSecretRef as Ws, SchedulerSchema as Wt, DiscoveryProposalBodySchema as X, buildFfmpegArgs as Xa, resolveMethodAuth as Xi, declarationOwnerNodeId as Xn, TransactRefusedError as Xo, lifecycleJobSchema as Xr, secretViewsOf as Xs, StorageLocationTypeSchema as Xt, DeviceTombstoneSchema as Y, MINUTE_MS as Ya, resolveLocationMode as Yi, databaseSnapshotCapability as Yn, StoredRecordKindDeclarationSchema as Yo, legacyModeOf as Yr, secretTreeFromSchema as Ys, StorageLocationModeSchema as Yt, EMPTY_AUTOMATION_STATE as Z, cloneStatefulExpressionMemory as Za, resolveMutate as Zi, declaredSeriesKind as Zn, UnindexedFilterError as Zo, localDateOf as Zr, sleep as Zs, StorageMigrationJobSchema as Zt, CAMSTACK_APP_LINK_ORIGIN as _, storageAdminCapability as _a, normalizeCapStep as _i, bareAddonId as _n, statisticCadenceMs as _o, expressionContainsBuiltinCall as _r, emitReadiness as _s, KeychainResetRecordSchema as _t, AGENT_MDNS_TXT_KEYS as a, scopesAllowAddon as aa, DeviceType as ac, mayReadLocation as ai, actionsCapability as an, disarmRoseMemory as ao, deviceManagerCapability as ar, buildSecretRef as as, FieldClaimModeSchema as at, COMPOSED_ITEM_FIXED_FIELDS as b, storageOccupancyCapability as ba, normalizeUnit as bi, buildActionSteps as bn, BaseAddon as bo, fanOutTargets as br, getDebugInterest as bs, METHOD_ACCESS_MAP as bt, ActionStepSchema as c, settingsStoreCapability as ca, mediaPlayerFeaturesOfRoles as ci, addonSettingsCapability as cn, helperMembers as co, deviceStateCapability as cr, collectSecretMarkerRefs as cs, HISTORY_CATALOG as ct, AlertSchema as d, sharedColorModes as da, metricsProviderCapability as di, alertEpisodePayload as dn, isHistoryHelper as do, enumerateItemArrayFields as dr, customAction as ds, HUB_MDNS_TXT_KEYS as dt, resolveStepArgs as ea, transformSecretWrite as ec, lockControlCapability as ei, TokenScopeSchema as en, compositionFeatureEnabled as eo, deriveBatteryPresence as er, asJsonObject as es, FAN_CAPTURE_FIELDS as et, AutomationStateDocSchema as f, shortHostname as fa, migrationsCapability as fi, alertsCapability as fn, nextLocalMidnight as fo, enumerateSchemaFields as fr, defineAddonMigrations as fs, HvacModeSchema as ft, CAMERA_SWITCH_ORDER as g, splitTranslationRef as ga, normalizeActionUnits as gi, backupCapability as gn, planStatisticTier as go, expandContainer as gr, emitDownForOwnedCaps as gs, KeychainAuditEntrySchema as gt, BatteryStatusSchema as h, snapshotCapability as ha, nextOccurrence as hi, authProviderCapability as hn, planResetTier as ho, evictionPolicyOfLocation as hr, defineRecordKinds as hs, KEYCHAIN_RESET_TRIGGER_ACTOR as ht, AGENT_MDNS_SERVICE_TYPE as i, schedulersCapability as ia, DeviceRole as ic, looseSchema as ii, actionSourceCapability as in, createStatefulExpressionMemory as io, deviceHistoryCapability as ir, assertValidDeclaration as is, FanPresetSchema as it, DATABASE_SNAPSHOT_PARTIAL_SUFFIX as j, validateComposition as ja, powerSourceCapability as ji, checkTemplatePayload as jn, NoCallerError as jo, internalActionId as jr, isSecretMarker as js, PreferenceValueSchema as jt, CoreBlockSchema as k, timedRunSeconds as ka, planComposition as ki, catalogueIssues as kn, HISTORY_DEFAULT_MIN_INTERVAL_MS as ko, groupTemplate as kr, isSecretClear as ks, PreferenceDeviceIdSchema as kt, ActionTargetResolver as l, sharedActuatorFeatures as la, memoizePinnedFfmpeg as li, addonWidgetsCapability as ln, integrateReading as lo, deviceStatusCapability as lr, collectZodSecretPaths as ls, HISTORY_ITEM_CATALOG as lt, BaseDevice as m, siteZoneKey as ma, motionCapability as mi, armRemovalReconcile as mn, openStatistic as mo, evaluateWhenTree as mr, defineEntryKind as ms, INTERNAL_ACTION_PREFIX as mt, ACTUATOR_METHODS as n, runSteps as na, withoutCallerStamp as nc, logDestinationCapability as ni, UserRecordSchema as nn, compositionSliceKey as no, deviceCredentialsCapability as nr, asString$1 as ns, FanControlStatusSchema as nt, ALL_CAPABILITY_DEFINITIONS as o, scopesAllowDeviceCap as oa, errMsg as oc, mayWriteToLocation as oi, addonIdOfActionId as on, evaluateDerivative as oo, deviceRemovalHookCapability as or, collectSecretConfigKeys as os, FieldClaimSchema as ot, BUILTIN_REMOTE_COMPONENTS as p, siteFor as pa, modeMayWrite as pi, appendTrace as pn, openReset as po, evaluateCompositionField as pr, defineCustomActions as ps, IDLE_ACTION_STATUS as pt, DeviceRunSchema as q, HISTORY_SLOW_MS as qa, resolveCoreBlockFiles as qi, customRole as qn, RevConflictError as qo, keychainCapability as qr, scopeKey as qs, SsoBridgeClaimsSchema as qt, ACTUATOR_TEMPLATE_IDS as r, runtimeStatePolicyFor as ra, DeviceFeature as rc, logLevelAtMost as ri, actionEffect as rn, compositionSourceKey as ro, deviceExtensionCapability as rr, assertTransactScope as rs, FanDirectionSchema as rt, ActionError as s, scoreRuntimes as sa, EventCategory as sc, mediaPlayerCapability as si, addonPagesCapability as sn, evaluateStatistic as so, deviceRunsCapability as sr, collectSecretLeaves as ss, GroupCommandResultSchema as st, ACTION_TARGET_INVALIDATION_EVENTS as t, runFanOut as ta, userError as tc, lockDoorLinkOfComposition as ti, UNATTRIBUTED_BUCKET_KEY as tn, compositionItemFieldPath as to, describeComposableCaps as tr, asNumber as ts, FIRST_LEVEL_MACRO_CLASSES as tt, ActionVariableSchema as u, sharedActuatorMethods as ua, methodRefusal as ui, alertEpisodeId as un, isForwardInputRef as uo, enumerateInferenceDevices as ur, createEvent as us, HUB_MDNS_SERVICE_TYPE as ut, CAP_NAMES_WITH_STATUS as v, storageCapability as va, normalizeCoreBlockWrite as vi, batteryCapability as vn, toExpressionValue as vo, extractNestedAddonId as vr, expandCapMethods as vs, LOG_LEVEL_RANK as vt, CREDENTIAL_TOKEN_AUDIENCE as w, supportedRuntimes as wa, orderMigrations as wi, buildStreamParamsConfigSchema as wn, DEVICE_SETTINGS_CONTRIBUTION_METHODS as wo, foldSnapshotByFunction as wr, isDebugChannelName as ws, MigrationLedgerEntrySchema as wt, COMPOSER_RUNNER_ID as x, storageProviderCapability as xa, objectInputDeclaresAddonId as xi, buildCapabilityLookup as xn, BatchTooLargeError as xo, fanPresetsCapability as xr, historyItemFieldPath as xs, MINUTES_PER_DAY as xt, CATALOG_LANGS as y, storageMigrationCapability as ya, normalizeStepTargets as yi, brightnessCapability as yn, wattMillisecondsToKwh as yo, fanControlCapability as yr, formatSecretScope as ys, LegacyStorageLocationDefaultSchema as yt, DEVICE_HISTORY_ENERGY_KEY as z, weekdayOfLocalDate as za, reducePoints as zi, coreBlockAddonId as zn, REMOVE_LEAF as zo, isDefaultAppConnectionEndpoint as zr, normalizeSecretOwner as zs, RemoteConfigSchema as zt };
110776
+ export { EMPTY_REMOTE_CONFIG as $, buildFfmpegArgs as $a, resolveMutate as $i, decodeVectorBase64 as $n, StoredRecordKindDeclarationSchema as $o, localNetworkCapability as $r, secretTreeFromSchema as $s, SwitchStatusSchema as $t, CredentialTokenClaimsSchema as A, timedRunLimitOf as Aa, planComposition as Ai, catalogueIssues as An, DeclarationRefusedError as Ao, groupTemplate as Ar, isEvent as As, PreferenceDeviceIdSchema as At, DEVICE_ID_FIELD as B, vocabActionIdFor as Ba, recordsCapability as Bi, coreBlockAddonId as Bn, RECORD_SECRET_COLLECTION_PREFIX as Bo, isDefaultAppConnectionEndpoint as Br, nodeIdOfScopedKey as Bs, RemoteConfigSchema as Bt, CORE_BLOCK_ADDON_PREFIX as C, storageProviderCapability as Ca, objectInputDeclaresRequiredDeviceId as Ci, buildDeviceEnrollmentLink as Cn, wattMillisecondsToKwh as Co, featureForwards as Cr, formatSecretScope as Cs, MediaPlayerStatusSchema as Ct, ConditionMirror as D, switchCapability as Da, parseColorInput as Di, cameraGridLayoutCapability as Dn, DATAPLANE_SECRET_HEADER as Do, formatMinutes as Dr, hydrateSchema as Ds, PREFERENCES_MAX_VALUE_BYTES as Dt, CatalogFileSchema as E, supportedRuntimes as Ea, parseAcceleratorFactsJson as Ei, calendarsCapability as En, CALLER_STAMPED_CAPABILITIES as Eo, formatDeviceRevoker as Er, historyUnitFor as Es, NetworkTunnelStartedDataSchema as Et, DAY_NAMES as F, validateSchedulerInput as Fa, problemsBlockSave as Fi, colorCapability as Fn, NoCallerError as Fo, isAlertEpisodeSeverity as Fr, isSecretMarker as Fs, REMOTE_MEDIA_COMMANDS as Ft, DataStoreDatabaseSchema as G, CompositionSchema as Ga, resolveActionVariables as Gi, coverCapability as Gn, ReadinessRegistry as Go, isVoidInput as Gr, parseJsonUnknown as Gs, SchedulerSchema as Gt, DEVICE_SAN_CREDENTIAL_PREFIX as H, withLocationMode as Ha, remoteCapability as Hi, coreBlockIdFromAddonId as Hn, REDACTED_SECRET as Ho, isLocationEnabled as Hr, normalizeNodeId as Hs, STORAGE_ACCESS_FALLBACK as Ht, DEFAULT_HOLD_OVERRIDE as I, valveCapability as Ia, procedureAuthKey as Ii, compileScalarOverride as In, PlaintextSecretError as Io, isAppLinkBase as Ir, isSecretMarkerLike as Is, ROOT_BUCKET_KEY as It, DeviceStatusSchema as J, HISTORY_FAST_MS as Ja, resolveCoreBlockEntry as Ji, customRole as Jn, RecordNotFoundError as Jo, keychainCapability as Jr, recordSecretRef as Js, SsoBridgeClaimsSchema as Jt, DeclaredDevices as K, DAY_MS as Ka, resolveAppConnections as Ki, createDeviceExtensionProvider as Kn, ReadinessTimeoutError as Ko, kebabToCamel as Kr, parseSecretRef as Ks, ScopedTokenSchema as Kt, DERIVED_CAMERA_SILENCED_CAP_NAMES as L, vectorDimFromBase64 as La, proposeRunningThreshold as Li, composerCapability as Ln, RECORD_BATCH_MAX as Lo, isArrayOutputSchema as Lr, isSecretRefOwnedBy as Ls, RecordIntegrationInstances as Lt, DATABASE_SNAPSHOT_SUFFIX as M, userManagementCapability as Ma, powerSourceCapability as Mi, checkTemplatePayload as Mn, ForeignSecretMarkerError as Mo, internalActionId as Mr, isReadingQuantity as Ms, PreferenceValueSchema as Mt, DATABASE_SNAPSHOT_TIMEOUT_MS as N, validateComposition as Na, powerSourceLinkOfComposition as Ni, climateControlCapability as Nn, HISTORY_DEFAULT_MIN_INTERVAL_MS as No, interpolate as Nr, isSecretClear as Ns, QuantityUnitError as Nt, ControlStatusSchema as O, templateCapability as Oa, parseStreamParamsFormPatch as Oi, canonicalIconKey as On, DEVICE_SETTINGS_CONTRIBUTION_METHODS as Oo, gbToBytes as Or, isDebugChannelName as Os, PROPOSAL_MIN_SPAN_MS as Ot, DATA_STORE_DATABASES as P, validateCustomAddress as Pa, preconditionOf as Pi, collectWhenMirrorSources as Pn, InvalidRecordError as Po, isAlertEpisodeOpen as Pr, isSecretFieldView as Ps, RECORDING_SOURCE_CAMSTACK_ADDON as Pt, EMPTY_REMOTE_ASSUMED_STATE as Q, MINUTE_MS as Qa, resolveMethodAuth as Qi, declaredSeriesKind as Qn, SECRET_CLEAR as Qo, localDateOf as Qr, secretTreeFromPaths as Qs, StorageMigrationJobSchema as Qt, DEVICE_ENROLLMENT_TTL_MS as R, vectorIndexDimConflictError as Ra, ptzAutotrackCapability as Ri, compositionFieldKey as Rn, RECORD_BATCH_MAX_BYTES as Ro, isCollectionArrayMethod as Rr, makeSecretMarker as Rs, RecordingStatusSchema as Rt, CORE_BLOCKS_ADDON_ID as S, storageOccupancyCapability as Sa, objectInputDeclaresAddonId as Si, buildCapabilityLookup as Sn, toExpressionValue as So, fanPresetsCapability as Sr, expandCapMethods as Ss, MOTION_CLOSE_AFTER_MS as St, CalendarPreferencesSchema as T, streamQualityLabel as Ta, orderMigrations as Ti, buildStreamParamsConfigSchema as Tn, BatchTooLargeError as To, foldSnapshotByFunction as Tr, historyItemFieldPath as Ts, MigrationMetaSchema as Tt, DEVICE_SAN_USER_PREFIX as U, zoneOnlySite as Ua, remoteLayoutComponentsCapability as Ui, coreBlockSourceKind as Un, REMOVE_LEAF as Uo, isObjectInput as Ur, normalizeSecretOwner as Us, STREAM_PROFILE_META as Ut, DEVICE_NONCE_TTL_MS as V, weekdayOfLocalDate as Va, reducePoints as Vi, coreBlockComposition as Vn, RECORD_SWEEP_INTERVAL_MS as Vo, isInternalActionId as Vr, nodePin as Vs, RunningStateStatusSchema as Vt, DEVICE_TOMBSTONE_RETENTION_MS as W, COMPOSER_ADDON_ID as Wa, replacedFieldKeys as Wi, coreBlocksCapability as Wn, RUNTIME_DEFAULTS as Wo, isSameAddonId as Wr, parseJsonObject as Ws, SchedulerError as Wt, DiscoveryProposalBodySchema as X, HOUR_MS as Xa, resolveHubAddressRoles as Xi, databaseSnapshotCapability as Xn, RecordUniqueViolationError as Xo, legacyModeOf as Xr, resolveSecretMarkers as Xs, StorageLocationModeSchema as Xt, DeviceTombstoneSchema as Y, HISTORY_SLOW_MS as Ya, resolveCoreBlockFiles as Yi, dataStoreProviderCapability as Yn, RecordTooLargeError as Yo, legacyAutoLinkIds as Yr, resolveCapMount as Ys, StorageCleanupJobSchema as Yt, EMPTY_AUTOMATION_STATE as Z, HelperMemberSchema as Za, resolveLocationMode as Zi, declarationOwnerNodeId as Zn, RevConflictError as Zo, lifecycleJobSchema as Zr, scopeKey as Zs, StorageLocationTypeSchema as Zt, CAMSTACK_APP_LINK_ORIGIN as _, snapshotCapability as _a, normalizeActionUnits as _i, backupCapability as _n, openReset as _o, expandContainer as _r, defineCustomActions as _s, KeychainResetRecordSchema as _t, AGENT_MDNS_TXT_KEYS as a, runtimeStatePolicyFor as aa, userError as ac, looseSchema as ai, actionSourceCapability as an, compositionSliceKey as ao, deviceHistoryCapability as ar, asNumber as as, FieldClaimModeSchema as at, COMPOSED_ITEM_FIXED_FIELDS as b, storageCapability as ba, normalizeStepTargets as bi, brightnessCapability as bn, planStatisticTier as bo, fanControlCapability as br, emitDownForOwnedCaps as bs, METHOD_ACCESS_MAP as bt, ActionStepSchema as c, scopesAllowDeviceCap as ca, DeviceRole as cc, mediaPlayerCapability as ci, addonPagesCapability as cn, disarmRoseMemory as co, deviceRunsCapability as cr, assertValidDeclaration as cs, HISTORY_CATALOG as ct, AlertSchema as d, sharedActuatorFeatures as da, EventCategory as dc, methodRefusal as di, alertEpisodeId as dn, helperMembers as do, enumerateInferenceDevices as dr, collectSecretLeaves as ds, HUB_MDNS_TXT_KEYS as dt, resolveNotificationTapAddress as ea, secretViewsOf as ec, locationIconKey as ei, TemplateKindSchema as en, cloneStatefulExpressionMemory as eo, defineExtensionSlotProvider as er, TransactRefusedError as es, FAN_CAPTURE_FIELDS as et, AutomationStateDocSchema as f, sharedActuatorMethods as fa, metricsProviderCapability as fi, alertEpisodePayload as fn, historyRetentionFromSettings as fo, enumerateItemArrayFields as fr, collectSecretMarkerRefs as fs, HvacModeSchema as ft, CAMERA_SWITCH_ORDER as g, siteZoneKey as ga, nextOccurrence as gi, authProviderCapability as gn, nextLocalMidnight as go, evictionPolicyOfLocation as gr, defineAddonMigrations as gs, KeychainAuditEntrySchema as gt, BatteryStatusSchema as h, siteFor as ha, motionCapability as hi, armRemovalReconcile as hn, isHistoryHelper as ho, evaluateWhenTree as hr, customAction as hs, KEYCHAIN_RESET_TRIGGER_ACTOR as ht, AGENT_MDNS_SERVICE_TYPE as i, runSteps as ia, transformSecretWrite as ic, logLevelAtMost as ii, actionEffect as in, compositionItemFieldPath as io, deviceExtensionCapability as ir, asJsonObject as is, FanPresetSchema as it, DATABASE_SNAPSHOT_PARTIAL_SUFFIX as j, timedRunSeconds as ja, platformProbeCapability as ji, checkRoleAddress as jn, FilterRequiredError as jo, integrationInstancesCapability as jr, isKeychainStoredField as js, PreferenceNamespaceSchema as jt, CoreBlockSchema as k, timedRunCapability as ka, pickAppLinkHub as ki, capUnitResolver as kn, DEVICE_STATUS_METHOD as ko, groupCommandsCapability as kr, isDeviceConfigCap as ks, PowerSourceInfoSchema as kt, ActionTargetResolver as l, scoreRuntimes as la, DeviceType as lc, mediaPlayerFeaturesOfRoles as li, addonSettingsCapability as ln, evaluateDerivative as lo, deviceStateCapability as lr, buildSecretRef as ls, HISTORY_ITEM_CATALOG as lt, BaseDevice as m, shortHostname as ma, modeMayWrite as mi, appendTrace as mn, isForwardInputRef as mo, evaluateCompositionField as mr, createEvent as ms, INTERNAL_ACTION_PREFIX as mt, ACTUATOR_METHODS as n, resolveStepArgs as na, toNodeId as nc, lockDoorLinkOfComposition as ni, UNATTRIBUTED_BUCKET_KEY as nn, composedDeviceStableId as no, describeComposableCaps as nr, UnknownRecordKindError as ns, FanControlStatusSchema as nt, ALL_CAPABILITY_DEFINITIONS as o, schedulersCapability as oa, withoutCallerStamp as oc, mayReadLocation as oi, actionsCapability as on, compositionSourceKey as oo, deviceManagerCapability as or, asString$1 as os, FieldClaimSchema as ot, BUILTIN_REMOTE_COMPONENTS as p, sharedColorModes as pa, migrationsCapability as pi, alertsCapability as pn, integrateReading as po, enumerateSchemaFields as pr, collectZodSecretPaths as ps, IDLE_ACTION_STATUS as pt, DeviceRunSchema as q, DEFAULT_HISTORY_RETENTION as qa, resolveBucketMs as qi, customKeyOfRole as qn, RecordKindDeclarationSchema as qo, keychainAdminCapability as qr, readinessKey as qs, ServerNameSchema as qt, ACTUATOR_TEMPLATE_IDS as r, runFanOut as ra, toSecretFieldView as rc, logDestinationCapability as ri, UserRecordSchema as rn, compositionFeatureEnabled as ro, deviceCredentialsCapability as rr, WELL_KNOWN_TAB_MAP as rs, FanDirectionSchema as rt, ActionError as s, scopesAllowAddon as sa, DeviceFeature as sc, mayWriteToLocation as si, addonIdOfActionId as sn, createStatefulExpressionMemory as so, deviceRemovalHookCapability as sr, assertTransactScope as ss, GroupCommandResultSchema as st, ACTION_TARGET_INVALIDATION_EVENTS as t, resolveRunnerId as ta, sleep as tc, lockControlCapability as ti, TokenScopeSchema as tn, composedDeviceRef as to, deriveBatteryPresence as tr, UnindexedFilterError as ts, FIRST_LEVEL_MACRO_CLASSES as tt, ActionVariableSchema as u, settingsStoreCapability as ua, errMsg as uc, memoizePinnedFfmpeg as ui, addonWidgetsCapability as un, evaluateStatistic as uo, deviceStatusCapability as ur, collectSecretConfigKeys as us, HUB_MDNS_SERVICE_TYPE as ut, CAP_NAMES_WITH_STATUS as v, splitTranslationRef as va, normalizeCapStep as vi, bareAddonId as vn, openStatistic as vo, expressionContainsBuiltinCall as vr, defineEntryKind as vs, LOG_LEVEL_RANK as vt, CREDENTIAL_TOKEN_AUDIENCE as w, streamCatalogCapability as wa, occurrenceOn as wi, buildDeviceSignatureMessage as wn, BaseAddon as wo, filesystemBrowseCapability as wr, getDebugInterest as ws, MigrationLedgerEntrySchema as wt, COMPOSER_RUNNER_ID as x, storageMigrationCapability as xa, normalizeUnit as xi, buildActionSteps as xn, statisticCadenceMs as xo, fanOutTargets as xr, emitReadiness as xs, MINUTES_PER_DAY as xt, CATALOG_LANGS as y, storageAdminCapability as ya, normalizeCoreBlockWrite as yi, batteryCapability as yn, planResetTier as yo, extractNestedAddonId as yr, defineRecordKinds as ys, LegacyStorageLocationDefaultSchema as yt, DEVICE_HISTORY_ENERGY_KEY as z, vectorStoreCapability as za, recordEntriesCapability as zi, compositionSourceRefs as zn, RECORD_DELETE_BATCH as zo, isCredentialTokenPayload as zr, mapSecretLeaves as zs, RemoteAssumedStateSchema as zt };