@camstack/server 1.2.847 → 1.2.849

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 (97) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/api/trpc/generated-cap-routers.js +9 -0
  3. package/dist/core/addon/instance-lifecycle.js +10 -6
  4. package/package.json +13 -9
  5. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  6. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  7. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  8. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  9. package/system/dist/builtins/alerts/alerts.addon.js +1 -1
  10. package/system/dist/builtins/alerts/alerts.addon.mjs +1 -1
  11. package/system/dist/builtins/autotrack/index.js +1 -1
  12. package/system/dist/builtins/autotrack/index.mjs +1 -1
  13. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
  14. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
  15. package/system/dist/builtins/calendars/calendars.addon.js +1 -1
  16. package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
  17. package/system/dist/builtins/camera-grid/index.js +1 -1
  18. package/system/dist/builtins/camera-grid/index.mjs +1 -1
  19. package/system/dist/builtins/composer/composer.addon.js +4 -4
  20. package/system/dist/builtins/composer/composer.addon.mjs +4 -4
  21. package/system/dist/builtins/console-logging/index.js +1 -1
  22. package/system/dist/builtins/console-logging/index.mjs +1 -1
  23. package/system/dist/builtins/core-blocks/core-blocks.addon.js +36 -8
  24. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +36 -8
  25. package/system/dist/builtins/core-blocks/remote-service.d.ts +5 -1
  26. package/system/dist/builtins/core-blocks/remote-wiring.d.ts +3 -1
  27. package/system/dist/builtins/device-history/device-history.addon.js +2 -2
  28. package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
  29. package/system/dist/builtins/device-manager/device-manager.addon.d.ts +0 -25
  30. package/system/dist/builtins/device-manager/device-manager.addon.js +62 -4
  31. package/system/dist/builtins/device-manager/device-manager.addon.mjs +62 -4
  32. package/system/dist/builtins/device-manager/transitions/transitions-wiring.d.ts +6 -1
  33. package/system/dist/builtins/hub-forwarder/index.js +1 -1
  34. package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
  35. package/system/dist/builtins/keychain/index.js +4 -4
  36. package/system/dist/builtins/keychain/index.mjs +4 -4
  37. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  38. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  39. package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
  40. package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
  41. package/system/dist/builtins/local-network/local-network.addon.js +3 -3
  42. package/system/dist/builtins/local-network/local-network.addon.mjs +3 -3
  43. package/system/dist/builtins/loki-logging/index.js +1 -1
  44. package/system/dist/builtins/loki-logging/index.mjs +1 -1
  45. package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  46. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  47. package/system/dist/builtins/platform-probe/index.js +1 -1
  48. package/system/dist/builtins/platform-probe/index.mjs +1 -1
  49. package/system/dist/builtins/record-entries/index.js +1 -1
  50. package/system/dist/builtins/record-entries/index.mjs +1 -1
  51. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  52. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  53. package/system/dist/builtins/snapshot/index.js +1 -1
  54. package/system/dist/builtins/snapshot/index.mjs +1 -1
  55. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  56. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  57. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  58. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  59. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
  60. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
  61. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  62. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  63. package/system/dist/builtins/system-config/system-config.addon.js +3 -3
  64. package/system/dist/builtins/system-config/system-config.addon.mjs +3 -3
  65. package/system/dist/builtins/winston-logging/index.js +1 -1
  66. package/system/dist/builtins/winston-logging/index.mjs +1 -1
  67. package/system/dist/{capture-engine-BSDgRisG.mjs → capture-engine-CgCljSbM.mjs} +1 -1
  68. package/system/dist/{capture-engine-B0oRy06v.js → capture-engine-QQtJ9iXs.js} +1 -1
  69. package/system/dist/{composition-sources-SR0LOiwV.js → composition-sources-DxDmYFCD.js} +1 -1
  70. package/system/dist/{composition-sources-ujH0OBVn.mjs → composition-sources-pEPr0Ucn.mjs} +1 -1
  71. package/system/dist/{constants-B7eUjmLy.mjs → constants-CNZ_oxrp.mjs} +1 -1
  72. package/system/dist/{constants-Bu2PpZxT.js → constants-Df49f3b4.js} +1 -1
  73. package/system/dist/{device-ca-Ddx0w66k.mjs → device-ca-Bl-6F9mv.mjs} +1 -1
  74. package/system/dist/{device-ca-DQVQodun.js → device-ca-BzUtH2U5.js} +1 -1
  75. package/system/dist/{dist-C2g-bkW3.js → dist-DKsFOzpr.js} +329 -29
  76. package/system/dist/{dist-Btw-kJec.mjs → dist-zkNb0bBi.mjs} +329 -29
  77. package/system/dist/file-host-worker.js +1 -1
  78. package/system/dist/file-host-worker.mjs +1 -1
  79. package/system/dist/{hub-identity-BGQRouDQ.mjs → hub-identity-BrGlipuh.mjs} +1 -1
  80. package/system/dist/{hub-identity-DiXO_HL1.js → hub-identity-Dv4V44gP.js} +1 -1
  81. package/system/dist/{hub-mdns-ciao-BR2Zdm6h.js → hub-mdns-ciao-DcWSdIki.js} +2 -2
  82. package/system/dist/{hub-mdns-ciao-DGGKuLGZ.mjs → hub-mdns-ciao-Dzht7PBY.mjs} +2 -2
  83. package/system/dist/index.js +50 -2507
  84. package/system/dist/index.mjs +50 -2507
  85. package/system/dist/kernel/bootstrap-config.d.ts +1 -2
  86. package/system/dist/kernel/capability-registry.d.ts +6 -2
  87. package/system/dist/{legacy-integration-rows-door-OnrCmUJI.js → legacy-integration-rows-door-CISh8s7H.js} +1 -1
  88. package/system/dist/{legacy-integration-rows-door-50Uc78LM.mjs → legacy-integration-rows-door-CL6R8xaY.mjs} +1 -1
  89. package/system/dist/migrations/hub/2026-11-12-drop-retired-storage-leftovers.d.ts +16 -0
  90. package/system/dist/{rename-composition-block-CjVxHVX1.js → rename-composition-block-DFi7GTKn.js} +1 -1
  91. package/system/dist/{rename-composition-block-kGqHAdUc.mjs → rename-composition-block-DM_koTq7.mjs} +1 -1
  92. package/system/dist/{restore-archive-Cxhhx7mC.mjs → restore-archive-D_3y4vj-.mjs} +1 -1
  93. package/system/dist/{restore-archive-DQZdAca-.js → restore-archive-Daw2fB9X.js} +1 -1
  94. package/system/dist/{wal-maintenance-DoZE1qG9.mjs → wal-maintenance-BPohUtyD.mjs} +0 -0
  95. package/system/dist/{wal-maintenance-C4WfHqw5.js → wal-maintenance-GyMlkYI_.js} +0 -0
  96. package/system/package.json +1 -1
  97. package/system/dist/kernel/legacy-config-yaml.d.ts +0 -37
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import "node:crypto";
3
- //#region ../types/dist/event-category-78tcBemo.mjs
3
+ //#region ../types/dist/event-category-Dv-Gcv1f.mjs
4
4
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
5
5
  EventCategory["SystemBoot"] = "system.boot";
6
6
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -441,6 +441,15 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
441
441
  */
442
442
  EventCategory["DeviceStateChanged"] = "device.state-changed";
443
443
  /**
444
+ * A device COMMAND (a vocabulary action, D920/D983) settled in the hub's
445
+ * transition audit (D1022): confirmed, already in place, unconfirmed or
446
+ * failed. Never a device's own change. Payload: `DeviceCommandSettledEvent`
447
+ * (`{deviceId, action, outcome, actor, at}`, no arguments). It feeds
448
+ * the Notification Center `device-command` kind. Telemetry (D8): losing one
449
+ * costs a notification, never state; the audit row is the record.
450
+ */
451
+ EventCategory["DeviceCommandSettled"] = "device.command-settled";
452
+ /**
444
453
  * The NATIVE shadow of a cap a composition has claimed fields of moved
445
454
  * (D663). Payload: `{ deviceId, capName, native }` — what the provider
446
455
  * wrote, BEFORE the owned fields are overlaid. Owner-only (D224): it is for
@@ -1243,7 +1252,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
1243
1252
  */
1244
1253
  var COMPOSED_DEVICE_STABLE_ID_PREFIX = "composed-";
1245
1254
  //#endregion
1246
- //#region ../types/dist/sleep-D0roI_CZ.mjs
1255
+ //#region ../types/dist/sleep-Czv-4wFH.mjs
1247
1256
  /**
1248
1257
  * The audio chunk plane's byte format, and the ONE expansion from a coded
1249
1258
  * window to float samples (D455).
@@ -1990,6 +1999,13 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
1990
1999
  else skipped.push(id);
1991
2000
  };
1992
2001
  const selected = options.only === void 0 ? null : new Set(options.only);
2002
+ const deferred = /* @__PURE__ */ new Set();
2003
+ const deferredBy = (reason) => {
2004
+ if (selected === null || reason === null) return null;
2005
+ const dep = /^dependency-(?:pending|blocked):(.+)$/.exec(reason)?.[1];
2006
+ if (dep === void 0 || !byId.has(dep)) return null;
2007
+ return !selected.has(dep) || deferred.has(dep) ? dep : null;
2008
+ };
1993
2009
  for (const step of declaration.steps) {
1994
2010
  if (selected !== null && !selected.has(step.id)) continue;
1995
2011
  const bound = byId.get(step.id);
@@ -2001,6 +2017,19 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
2001
2017
  try {
2002
2018
  const gate = await host.startMigration({ id: step.id });
2003
2019
  if (!gate.proceed) {
2020
+ const waitsFor = deferredBy(gate.reason);
2021
+ if (waitsFor !== null) {
2022
+ log.info("migration deferred: its predecessor runs in another phase of this owner", {
2023
+ tags,
2024
+ meta: {
2025
+ waitsFor,
2026
+ reason: gate.reason
2027
+ }
2028
+ });
2029
+ deferred.add(step.id);
2030
+ skipped.push(step.id);
2031
+ continue;
2032
+ }
2004
2033
  log.warn("migration not run", {
2005
2034
  tags,
2006
2035
  meta: {
@@ -5739,6 +5768,13 @@ var DeviceTransitionSchema = z.object({
5739
5768
  actor: TransitionActorSchema,
5740
5769
  command: TransitionCommandSchema.optional()
5741
5770
  });
5771
+ z.object({
5772
+ deviceId: z.number().int(),
5773
+ action: z.string(),
5774
+ outcome: TransitionOutcomeSchema,
5775
+ actor: TransitionActorSchema,
5776
+ at: z.number()
5777
+ });
5742
5778
  var READING_QUANTITIES = [
5743
5779
  "temperature",
5744
5780
  "pressure",
@@ -8266,7 +8302,10 @@ var ACTUATOR_CAP_VOCABULARY = {
8266
8302
  "ir-transmitter": {
8267
8303
  scope: "device",
8268
8304
  noun: t("IR / RF transmitter", "Trasmettitore IR / RF"),
8269
- notOperatorFacing: { send: "a raw pulse train is not something an operator composes in an automation; the remote that owns the command table sends it" }
8305
+ notOperatorFacing: {
8306
+ send: "a raw pulse train is not something an operator composes in an automation; the remote that owns the command table sends it",
8307
+ learn: "an interactive capture the operator starts from the source dialog and answers by pressing a physical remote; no automation can supply the signal"
8308
+ }
8270
8309
  },
8271
8310
  control: {
8272
8311
  scope: "device",
@@ -53685,11 +53724,13 @@ var IrCodecError = class extends Error {
53685
53724
  this.code = code;
53686
53725
  }
53687
53726
  };
53727
+ /** Maximum number of mark/space entries one pulse train may carry. */
53728
+ var IR_TIMINGS_MAX = 1024;
53688
53729
  /**
53689
53730
  * A pulse train in signed microseconds: mark (+) first, then space (-), strictly
53690
53731
  * alternating, no zeros, 2..1024 entries.
53691
53732
  */
53692
- var IrTimingsSchema = z.array(z.number().int()).min(2).max(1024).superRefine((timings, ctx) => {
53733
+ var IrTimingsSchema = z.array(z.number().int()).min(2).max(IR_TIMINGS_MAX).superRefine((timings, ctx) => {
53693
53734
  timings.forEach((value, index) => {
53694
53735
  const expectMark = index % 2 === 0;
53695
53736
  if (value === 0 || value > 0 !== expectMark) ctx.addIssue({
@@ -53736,15 +53777,186 @@ function decodePronto(code) {
53736
53777
  carrierHz: Math.round(1e6 / unitUs)
53737
53778
  };
53738
53779
  }
53739
- /** What a remote command stores: a raw pulse train, or a learned Pronto code. */
53740
- var IrPayloadSchema = z.discriminatedUnion("kind", [z.object({
53741
- kind: z.literal("raw"),
53742
- timings: z.array(z.number().int()),
53743
- settings: TransmitSettingsSchema.optional()
53744
- }), z.object({
53745
- kind: z.literal("pronto"),
53746
- code: z.string()
53747
- })]);
53780
+ /**
53781
+ * FastLZ level 1: a byte-oriented LZ77 stream. A control byte below 32 starts a
53782
+ * literal run of `ctrl + 1` bytes; otherwise it is a back-reference whose length
53783
+ * is `ctrl >> 5` (extended by one byte when 7) and whose distance is split
53784
+ * between the low 5 bits and the next byte.
53785
+ */
53786
+ var MAX_DISTANCE = 8192;
53787
+ var MAX_LITERAL_RUN = 32;
53788
+ var MIN_MATCH = 3;
53789
+ var MAX_MATCH = 264;
53790
+ /**
53791
+ * Most bytes a decoded IR code may hold: two bytes per timing. A level-1 stream
53792
+ * can expand ~130x, so the decoder checks this bound before every write.
53793
+ */
53794
+ var IR_DECOMPRESSED_MAX = IR_TIMINGS_MAX * 2;
53795
+ function fastlzDecompress(input) {
53796
+ const out = [];
53797
+ let ip = 0;
53798
+ const room = (count) => {
53799
+ if (out.length + count > IR_DECOMPRESSED_MAX) throw new IrCodecError("tuya-malformed", "decompressed code is larger than any IR train");
53800
+ };
53801
+ const next = () => {
53802
+ const byte = input[ip++];
53803
+ if (byte === void 0) throw new IrCodecError("tuya-malformed", "compressed stream is truncated");
53804
+ return byte;
53805
+ };
53806
+ while (ip < input.length) {
53807
+ const ctrl = next();
53808
+ if (ctrl < 32) {
53809
+ room(ctrl + 1);
53810
+ for (let i = 0; i <= ctrl; i++) out.push(next());
53811
+ continue;
53812
+ }
53813
+ let len = (ctrl >> 5) - 1;
53814
+ if (len === 6) len += next();
53815
+ const distance = ((ctrl & 31) << 8) + next() + 1;
53816
+ const start = out.length - distance;
53817
+ if (start < 0) throw new IrCodecError("tuya-malformed", "back-reference points before the stream");
53818
+ room(len + 3);
53819
+ for (let i = 0; i < len + 3; i++) {
53820
+ const byte = out[start + i];
53821
+ if (byte === void 0) throw new IrCodecError("tuya-malformed", "back-reference is invalid");
53822
+ out.push(byte);
53823
+ }
53824
+ }
53825
+ return Uint8Array.from(out);
53826
+ }
53827
+ function fastlzCompress(input) {
53828
+ const out = [];
53829
+ const lastSeen = /* @__PURE__ */ new Map();
53830
+ let literalStart = 0;
53831
+ const flushLiterals = (end) => {
53832
+ for (let from = literalStart; from < end; from += MAX_LITERAL_RUN) {
53833
+ const to = Math.min(from + MAX_LITERAL_RUN, end);
53834
+ out.push(to - from - 1);
53835
+ for (let i = from; i < to; i++) out.push(input[i] ?? 0);
53836
+ }
53837
+ };
53838
+ let pos = 0;
53839
+ while (pos < input.length) {
53840
+ let matchLen = 0;
53841
+ let matchDistance = 0;
53842
+ if (pos + MIN_MATCH <= input.length) {
53843
+ const key = (input[pos] ?? 0) << 16 | (input[pos + 1] ?? 0) << 8 | (input[pos + 2] ?? 0);
53844
+ const candidate = lastSeen.get(key);
53845
+ lastSeen.set(key, pos);
53846
+ if (candidate !== void 0 && pos - candidate <= MAX_DISTANCE) {
53847
+ let len = 0;
53848
+ while (pos + len < input.length && len < MAX_MATCH && input[candidate + len] === input[pos + len]) len++;
53849
+ if (len >= MIN_MATCH) {
53850
+ matchLen = len;
53851
+ matchDistance = pos - candidate - 1;
53852
+ }
53853
+ }
53854
+ }
53855
+ if (matchLen === 0) {
53856
+ pos++;
53857
+ continue;
53858
+ }
53859
+ flushLiterals(pos);
53860
+ const enc = matchLen - 2;
53861
+ if (enc < 7) out.push(enc << 5 | matchDistance >> 8);
53862
+ else out.push(224 | matchDistance >> 8, enc - 7);
53863
+ out.push(matchDistance & 255);
53864
+ pos += matchLen;
53865
+ literalStart = pos;
53866
+ }
53867
+ flushLiterals(input.length);
53868
+ return Uint8Array.from(out);
53869
+ }
53870
+ var ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
53871
+ var MAX_DURATION_US = 65535;
53872
+ function toBase64(bytes) {
53873
+ let out = "";
53874
+ for (let i = 0; i < bytes.length; i += 3) {
53875
+ const a = bytes[i] ?? 0;
53876
+ const b = bytes[i + 1] ?? 0;
53877
+ const c = bytes[i + 2] ?? 0;
53878
+ const word = a << 16 | b << 8 | c;
53879
+ out += ALPHABET[word >> 18 & 63];
53880
+ out += ALPHABET[word >> 12 & 63];
53881
+ out += i + 1 < bytes.length ? ALPHABET[word >> 6 & 63] : "=";
53882
+ out += i + 2 < bytes.length ? ALPHABET[word & 63] : "=";
53883
+ }
53884
+ return out;
53885
+ }
53886
+ function fromBase64(text) {
53887
+ const clean = text.trim().replace(/=+$/, "");
53888
+ if (clean.length === 0 || clean.length % 4 === 1) throw new IrCodecError("tuya-malformed", "not a base64 string");
53889
+ const out = [];
53890
+ let bits = 0;
53891
+ let acc = 0;
53892
+ for (const ch of clean) {
53893
+ const value = ALPHABET.indexOf(ch);
53894
+ if (value < 0) throw new IrCodecError("tuya-malformed", "not a base64 string");
53895
+ acc = acc << 6 | value;
53896
+ bits += 6;
53897
+ if (bits >= 8) {
53898
+ bits -= 8;
53899
+ out.push(acc >> bits & 255);
53900
+ }
53901
+ }
53902
+ return Uint8Array.from(out);
53903
+ }
53904
+ /** Signed pulse train to a Tuya IR code: base64(FastLZ(uint16 LE durations)). */
53905
+ function encodeTuya(timings) {
53906
+ const bytes = new Uint8Array(timings.length * 2);
53907
+ timings.forEach((value, index) => {
53908
+ const duration = Math.abs(value);
53909
+ if (duration === 0 || duration > MAX_DURATION_US) throw new IrCodecError("invalid-timings", `timing ${index} does not fit 16 bits`);
53910
+ bytes[index * 2] = duration & 255;
53911
+ bytes[index * 2 + 1] = duration >> 8;
53912
+ });
53913
+ return toBase64(fastlzCompress(bytes));
53914
+ }
53915
+ /** A Tuya IR code to a signed pulse train (mark first). Throws `IrCodecError`. */
53916
+ function decodeTuya(code) {
53917
+ const bytes = fastlzDecompress(fromBase64(code));
53918
+ if (bytes.length === 0 || bytes.length % 2 !== 0) throw new IrCodecError("tuya-malformed", "payload is not a list of 16-bit durations");
53919
+ const timings = [];
53920
+ for (let i = 0; i < bytes.length; i += 2) {
53921
+ const duration = (bytes[i] ?? 0) | (bytes[i + 1] ?? 0) << 8;
53922
+ timings.push(i / 2 % 2 === 0 ? duration : -duration);
53923
+ }
53924
+ const checked = IrTimingsSchema.safeParse(timings);
53925
+ if (!checked.success) throw new IrCodecError("tuya-malformed", checked.error.message);
53926
+ return checked.data;
53927
+ }
53928
+ /** Device-native IR code formats a transmitter can replay verbatim. */
53929
+ var IrNativeFormatSchema = z.enum(["tuya"]);
53930
+ /**
53931
+ * Longest native code accepted: base64 of the worst-case compressed stream
53932
+ * (every decoded byte as a literal, plus one control byte per 32), with margin.
53933
+ */
53934
+ var IR_NATIVE_CODE_MAX_CHARS = Math.ceil((IR_DECOMPRESSED_MAX + Math.ceil(IR_DECOMPRESSED_MAX / 32)) / 3) * 4 + 256;
53935
+ var IrNativeCodeSchema = z.object({
53936
+ format: IrNativeFormatSchema,
53937
+ code: z.string().min(1).max(IR_NATIVE_CODE_MAX_CHARS)
53938
+ });
53939
+ var IR_NATIVE_CODECS = { tuya: {
53940
+ encode: encodeTuya,
53941
+ decode: decodeTuya
53942
+ } };
53943
+ /** What a remote command stores: a raw pulse train, a learned Pronto code, or a device-native code. */
53944
+ var IrPayloadSchema = z.discriminatedUnion("kind", [
53945
+ z.object({
53946
+ kind: z.literal("raw"),
53947
+ timings: z.array(z.number().int()),
53948
+ settings: TransmitSettingsSchema.optional()
53949
+ }),
53950
+ z.object({
53951
+ kind: z.literal("pronto"),
53952
+ code: z.string()
53953
+ }),
53954
+ z.object({
53955
+ kind: z.literal("native"),
53956
+ format: IrNativeFormatSchema,
53957
+ code: z.string()
53958
+ })
53959
+ ]);
53748
53960
  /** Resolve a payload to what `ir-transmitter.send` takes. Throws `IrCodecError`. */
53749
53961
  function toTimings(payload) {
53750
53962
  if (payload.kind === "pronto") {
@@ -53754,6 +53966,10 @@ function toTimings(payload) {
53754
53966
  settings: { carrierHz: decoded.carrierHz }
53755
53967
  };
53756
53968
  }
53969
+ if (payload.kind === "native") return {
53970
+ timings: IR_NATIVE_CODECS[payload.format].decode(payload.code),
53971
+ settings: {}
53972
+ };
53757
53973
  const checked = IrTimingsSchema.safeParse(payload.timings);
53758
53974
  if (!checked.success) throw new IrCodecError("invalid-timings", checked.error.message);
53759
53975
  return {
@@ -66881,18 +67097,32 @@ var HeroRowModelSchema = z.object({
66881
67097
  extras: z.array(HeroControlSchema).max(2).optional(),
66882
67098
  trailing: HeroFactSchema.nullable()
66883
67099
  });
66884
- /** The trailing fact, in order of preference. */
67100
+ /**
67101
+ * A measurement that IS the headline. The row trails it so a client that paints only
67102
+ * `trailing` still shows the reading. Power, battery and consumables stay ahead of these.
67103
+ */
67104
+ var ROW_READING_FACT_IDS = [
67105
+ "temperature",
67106
+ "humidity",
67107
+ "pressure",
67108
+ "illuminance",
67109
+ "reading",
67110
+ "air-quality",
67111
+ "valve"
67112
+ ];
67113
+ /** The trailing fact, in order of preference. A reading joins only when it repeats the headline. */
66885
67114
  var TRAILING_ORDER = [
66886
67115
  "power",
66887
67116
  "battery",
66888
67117
  "consumables"
66889
67118
  ];
66890
- function trailingOf(facts) {
67119
+ var READING_FACT_IDS = new Set(ROW_READING_FACT_IDS);
67120
+ function trailingOf(model) {
66891
67121
  for (const id of TRAILING_ORDER) {
66892
- const found = facts.find((f) => f.id === id);
67122
+ const found = model.facts.find((f) => f.id === id);
66893
67123
  if (found !== void 0) return found;
66894
67124
  }
66895
- return null;
67125
+ return model.facts.find((f) => READING_FACT_IDS.has(f.id) && f.text.en === model.title.en) ?? null;
66896
67126
  }
66897
67127
  /**
66898
67128
  * A type whose primary is a named control, not its power: a climate row is the mode
@@ -66987,7 +67217,7 @@ function timedRunOf(model) {
66987
67217
  };
66988
67218
  }
66989
67219
  function projectDeviceRow(model) {
66990
- const trailing = trailingOf(model.facts);
67220
+ const trailing = trailingOf(model);
66991
67221
  const primary = primaryOf(model);
66992
67222
  return {
66993
67223
  deviceId: model.deviceId,
@@ -68128,7 +68358,19 @@ var IrSendResultSchema = z.object({
68128
68358
  var IrTransmitterInfoSchema = z.object({
68129
68359
  media: z.array(IrMediumSchema),
68130
68360
  settable: z.array(TransmitSettingKeySchema),
68131
- maxTimings: z.number().int().positive()
68361
+ maxTimings: z.number().int().positive(),
68362
+ /** The transmitter can learn a code (`learn`). */
68363
+ learn: z.boolean().default(false),
68364
+ /** Native code formats the transmitter replays verbatim (`send.native`). */
68365
+ formats: z.array(IrNativeFormatSchema).default([])
68366
+ });
68367
+ var IR_LEARN_TIMEOUT_DEFAULT_MS = 2e4;
68368
+ var IR_LEARN_TIMEOUT_MAX_MS = 6e4;
68369
+ var IrLearnResultSchema = z.object({
68370
+ /** The code in the device's own format, when it reports one. */
68371
+ native: IrNativeCodeSchema.nullable(),
68372
+ timings: IrTimingsSchema,
68373
+ carrierHz: z.number().int().positive().nullable()
68132
68374
  });
68133
68375
  /**
68134
68376
  * ir-transmitter — emit a pulse train (infrared or RF) with settings. One cap
@@ -68139,7 +68381,12 @@ var IrTransmitterInfoSchema = z.object({
68139
68381
  * transmitter cannot be reached) and `ir-transmitter.too-long` (more pulses
68140
68382
  * than the transmitter's `maxTimings`). A setting the transmitter cannot apply
68141
68383
  * is NOT a refusal: the train is sent and the key comes back in
68142
- * `ignoredSettings`.
68384
+ * `ignoredSettings`. `send` takes exactly one of `timings` or `native` (a code
68385
+ * in a format listed in `getInfo.formats`).
68386
+ *
68387
+ * `learn` waits for the user to point a remote at the transmitter and refuses
68388
+ * with `ir-transmitter.learn-unsupported`, `ir-transmitter.learn-timeout` or
68389
+ * `ir-transmitter.learn-undecodable`.
68143
68390
  */
68144
68391
  var irTransmitterCapability = {
68145
68392
  name: "ir-transmitter",
@@ -68150,9 +68397,17 @@ var irTransmitterCapability = {
68150
68397
  methods: {
68151
68398
  send: method(z.object({
68152
68399
  deviceId: z.number().int().nonnegative(),
68153
- timings: IrTimingsSchema,
68400
+ timings: IrTimingsSchema.optional(),
68401
+ native: IrNativeCodeSchema.optional(),
68154
68402
  settings: TransmitSettingsSchema.optional()
68155
- }), IrSendResultSchema, {
68403
+ }).refine((input) => input.timings === void 0 !== (input.native === void 0), { message: "send takes exactly one of timings or native" }), IrSendResultSchema, {
68404
+ kind: "mutation",
68405
+ auth: "protected"
68406
+ }),
68407
+ learn: method(z.object({
68408
+ deviceId: z.number().int().nonnegative(),
68409
+ timeoutMs: z.number().int().positive().max(IR_LEARN_TIMEOUT_MAX_MS).default(IR_LEARN_TIMEOUT_DEFAULT_MS)
68410
+ }), IrLearnResultSchema, {
68156
68411
  kind: "mutation",
68157
68412
  auth: "protected"
68158
68413
  }),
@@ -80555,6 +80810,7 @@ var NcSystemEventKindSchema = z.enum([
80555
80810
  "recording-degraded",
80556
80811
  "device-attention-required",
80557
80812
  "device-attention-resolved",
80813
+ "device-command",
80558
80814
  "storage-location-low",
80559
80815
  "storage-location-critical",
80560
80816
  "storage-location-ok",
@@ -80617,11 +80873,6 @@ var NC_ALARM_SYSTEM_EVENT_KINDS = [
80617
80873
  "alarm-sensor-bypass",
80618
80874
  "alarm-disarmed"
80619
80875
  ];
80620
- /**
80621
- * One coherent system-event condition. `kinds` is the required opt-in safety
80622
- * gate; the remaining lists are optional narrowing filters relevant to the
80623
- * selected kinds.
80624
- */
80625
80876
  var NcSystemEventConditionSchema = z.object({
80626
80877
  kinds: z.array(NcSystemEventKindSchema).min(1),
80627
80878
  deviceIds: z.array(z.number().int()).min(1).optional(),
@@ -80653,6 +80904,28 @@ var NcSystemEventConditionSchema = z.object({
80653
80904
  nodeIds: z.array(z.string().min(1)).min(1).optional(),
80654
80905
  packageNames: z.array(z.string().min(1)).min(1).optional(),
80655
80906
  /**
80907
+ * `device-command` only: the vocabulary ACTION IDS (D983, `powerSource.forceRestart`)
80908
+ * this rule speaks about - the same dictionary the automation action blocks
80909
+ * pick from. The hub refuses an id the action index does not know.
80910
+ */
80911
+ commandActions: z.array(z.string().min(1)).min(1).optional(),
80912
+ /** `device-command` only: how the command settled. A device's own change is not a command. */
80913
+ commandOutcomes: z.array(z.enum([
80914
+ "confirmed",
80915
+ "already",
80916
+ "unconfirmed",
80917
+ "failed"
80918
+ ])).min(1).optional(),
80919
+ /** `device-command` only: who asked (`user`, `addon`, `action`, `scheduler`, `composition`, `node`). */
80920
+ commandActorKinds: z.array(z.enum([
80921
+ "user",
80922
+ "addon",
80923
+ "action",
80924
+ "scheduler",
80925
+ "composition",
80926
+ "node"
80927
+ ])).min(1).optional(),
80928
+ /**
80656
80929
  * At or below this remaining-life %, a consumable is LOW for THIS rule
80657
80930
  * (D642). Absent = {@link NC_CONSUMABLE_LOW_PERCENT_DEFAULT}; at most
80658
80931
  * {@link NC_CONSUMABLE_LOW_PERCENT_MAX}, so every episode can recover. Scoped to the
@@ -104763,7 +105036,8 @@ function buildHeroModel(input) {
104763
105036
  label: t(integration, integration)
104764
105037
  }], ...fragments.flatMap((f) => f.badges ?? [])];
104765
105038
  const headline = state === "offline" || state === "unknown" ? void 0 : fragments.find((f) => f.title !== void 0)?.title;
104766
- const facts = fragments.flatMap((f) => f.facts ?? []).filter((f) => headline === void 0 || f.text.en !== headline.en);
105039
+ const readingIds = new Set(ROW_READING_FACT_IDS);
105040
+ const facts = fragments.flatMap((f) => f.facts ?? []).filter((f) => headline === void 0 || f.text.en !== headline.en || readingIds.has(f.id));
104767
105041
  const sideTiles = {
104768
105042
  left: tilesOf(fragments, "left"),
104769
105043
  right: tilesOf(fragments, "right")
@@ -108669,6 +108943,13 @@ var METHOD_ACCESS_MAP = Object.freeze({
108669
108943
  access: "view",
108670
108944
  role: "viewer"
108671
108945
  },
108946
+ "irTransmitter.learn": {
108947
+ capName: "ir-transmitter",
108948
+ capScope: "device",
108949
+ addonId: null,
108950
+ access: "create",
108951
+ role: "viewer"
108952
+ },
108672
108953
  "irTransmitter.send": {
108673
108954
  capName: "ir-transmitter",
108674
108955
  capScope: "device",
@@ -116766,6 +117047,11 @@ Object.freeze({
116766
117047
  form: "single",
116767
117048
  optional: false
116768
117049
  }],
117050
+ "irTransmitter.learn": [{
117051
+ name: "deviceId",
117052
+ form: "single",
117053
+ optional: false
117054
+ }],
116769
117055
  "irTransmitter.send": [{
116770
117056
  name: "deviceId",
116771
117057
  form: "single",
@@ -119061,7 +119347,10 @@ var NC_SYSTEM_EVENT_FILTER_KEYS = [
119061
119347
  "deviceTypes",
119062
119348
  "nodeIds",
119063
119349
  "packageNames",
119064
- "consumableLowPercent"
119350
+ "consumableLowPercent",
119351
+ "commandActions",
119352
+ "commandOutcomes",
119353
+ "commandActorKinds"
119065
119354
  ];
119066
119355
  new Map(Object.entries({
119067
119356
  "device-online": "device-events",
@@ -119084,6 +119373,7 @@ new Map(Object.entries({
119084
119373
  "recording-degraded": "device-events",
119085
119374
  "device-attention-required": "device-events",
119086
119375
  "device-attention-resolved": "device-events",
119376
+ "device-command": "device-events",
119087
119377
  "node-online": "system",
119088
119378
  "node-offline": "system",
119089
119379
  "node-restarting": "system",
@@ -119184,6 +119474,12 @@ var NC_SYSTEM_EVENT_KIND_GROUP_SPECS = [
119184
119474
  label: "Needs attention",
119185
119475
  kinds: ["device-attention-required", "device-attention-resolved"]
119186
119476
  },
119477
+ {
119478
+ id: "device-command",
119479
+ family: "device-events",
119480
+ label: "Commands given to devices",
119481
+ kinds: ["device-command"]
119482
+ },
119187
119483
  {
119188
119484
  id: "nodes",
119189
119485
  family: "system",
@@ -119498,6 +119794,7 @@ var DEVICE_EVENTS = [
119498
119794
  "recording-healthy",
119499
119795
  "recording-degraded",
119500
119796
  ...DEVICE_ATTENTION,
119797
+ "device-command",
119501
119798
  ...ALARM
119502
119799
  ];
119503
119800
  /** Every kind a summary may speak about — the two summarisable families. */
@@ -119651,6 +119948,9 @@ var STATE_SUMMARY_VARS = [
119651
119948
  [...RULE_BODY_ONLY],
119652
119949
  [...RULE_TEXT],
119653
119950
  ([...RULE_TEXT], [...DEVICE_EVENTS]),
119951
+ [...RULE_TEXT],
119952
+ [...RULE_TEXT],
119953
+ ([...RULE_TEXT], [...DEVICE_EVENTS]),
119654
119954
  ([...RULE_TEXT], [...COMBINED_ALARM]),
119655
119955
  ([...RULE_TEXT], [...COMBINED_ALARM]),
119656
119956
  ([...RULE_TEXT], [...DEVICE_EVENTS]),
@@ -1,5 +1,5 @@
1
1
  require("./chunk-Cek0wNdY.js");
2
- const require_wal_maintenance = require("./wal-maintenance-C4WfHqw5.js");
2
+ const require_wal_maintenance = require("./wal-maintenance-GyMlkYI_.js");
3
3
  let node_worker_threads = require("node:worker_threads");
4
4
  //#region src/builtins/sqlite-storage/file-host-worker.ts
5
5
  /**
@@ -1,4 +1,4 @@
1
- import { A as callRecords, C as isFileHostWorkerData, D as RecordsEngine, M as controlTargetOf, O as callControl, S as isFileHostRequest, a as WalMaintenance, b as collectTransferables, d as callMigrate, f as migrateTargetOf, j as callVector, k as callData, l as SqliteSettingsBackend, o as createVectorIndex, s as vectorProviderOf, u as HUB_MIGRATIONS, v as serializeError, w as trustInput } from "./wal-maintenance-DoZE1qG9.mjs";
1
+ import { A as callRecords, C as isFileHostWorkerData, D as RecordsEngine, M as controlTargetOf, O as callControl, S as isFileHostRequest, a as WalMaintenance, b as collectTransferables, d as callMigrate, f as migrateTargetOf, j as callVector, k as callData, l as SqliteSettingsBackend, o as createVectorIndex, s as vectorProviderOf, u as HUB_MIGRATIONS, v as serializeError, w as trustInput } from "./wal-maintenance-BPohUtyD.mjs";
2
2
  import { parentPort, threadId, workerData } from "node:worker_threads";
3
3
  //#region src/builtins/sqlite-storage/file-host-worker.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { Cc as defineRecordKinds } from "./dist-Btw-kJec.mjs";
1
+ import { Cc as defineRecordKinds } from "./dist-zkNb0bBi.mjs";
2
2
  import { C as backdatedNotBefore, S as withUtcTimeEncoding, _ as NameConstraints, a as KeyUsageFlags, c as Pkcs10CertificateRequest, d as SubjectKeyIdentifierExtension, f as X509Certificate$1, g as GeneralSubtrees, h as GeneralSubtree, i as Extension, l as Pkcs10CertificateRequestGenerator, m as cryptoProvider, n as BasicConstraintsExtension, o as KeyUsagesExtension, p as X509CertificateGenerator, r as ExtendedKeyUsageExtension, s as PemConverter, t as AuthorityKeyIdentifierExtension, u as SubjectAlternativeNameExtension, v as GeneralName, x as AsnConvert } from "./x509.es-BRiJgOvu.mjs";
3
3
  import { z } from "zod";
4
4
  import { X509Certificate, createHash, createPrivateKey, randomBytes, webcrypto } from "node:crypto";
@@ -1,5 +1,5 @@
1
1
  const require_chunk = require("./chunk-Cek0wNdY.js");
2
- const require_dist = require("./dist-C2g-bkW3.js");
2
+ const require_dist = require("./dist-DKsFOzpr.js");
3
3
  const require_x509_es = require("./x509.es-WtnRNyYS.js");
4
4
  let zod = require("zod");
5
5
  let node_crypto = require("node:crypto");
@@ -1,7 +1,7 @@
1
1
  const require_chunk = require("./chunk-Cek0wNdY.js");
2
- const require_dist = require("./dist-C2g-bkW3.js");
2
+ const require_dist = require("./dist-DKsFOzpr.js");
3
3
  const require_x509_es = require("./x509.es-WtnRNyYS.js");
4
- const require_hub_identity = require("./hub-identity-DiXO_HL1.js");
4
+ const require_hub_identity = require("./hub-identity-Dv4V44gP.js");
5
5
  let node_crypto = require("node:crypto");
6
6
  let _camstack_types_node = require("@camstack/types/node");
7
7
  let node_fs = require("node:fs");
@@ -1,7 +1,7 @@
1
1
  import { o as __toESM } from "./chunk-CNf5ZN-e.mjs";
2
- import { pl as userError } from "./dist-Btw-kJec.mjs";
2
+ import { pl as userError } from "./dist-zkNb0bBi.mjs";
3
3
  import { f as X509Certificate$1 } from "./x509.es-BRiJgOvu.mjs";
4
- import { A as evaluateExistingCert, C as localCaCommonName, F as isConstrainedCa, L as permitsIdentity, S as loadCa, b as generateCa, j as reasonRequiresNewCa, w as collectCertIdentity, x as issueLeaf, z as readNameConstraints } from "./hub-identity-BGQRouDQ.mjs";
4
+ import { A as evaluateExistingCert, C as localCaCommonName, F as isConstrainedCa, L as permitsIdentity, S as loadCa, b as generateCa, j as reasonRequiresNewCa, w as collectCertIdentity, x as issueLeaf, z as readNameConstraints } from "./hub-identity-BrGlipuh.mjs";
5
5
  import { X509Certificate, createPrivateKey } from "node:crypto";
6
6
  import { writeOwnerOnlyFileSync } from "@camstack/types/node";
7
7
  import { copyFileSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";