@camstack/system 1.2.316 → 1.2.318

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 (87) hide show
  1. package/dist/addon-runner.js +1 -1
  2. package/dist/addon-runner.mjs +1 -1
  3. package/dist/auth/auth-manager.d.ts +11 -0
  4. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  5. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  6. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  7. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  8. package/dist/builtins/alerts/alerts.addon.js +1 -1
  9. package/dist/builtins/alerts/alerts.addon.mjs +1 -1
  10. package/dist/builtins/autotrack/index.js +1 -1
  11. package/dist/builtins/autotrack/index.mjs +1 -1
  12. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +1 -1
  13. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +1 -1
  14. package/dist/builtins/camera-grid/index.js +1 -1
  15. package/dist/builtins/camera-grid/index.mjs +1 -1
  16. package/dist/builtins/composer/composer.addon.js +347 -181
  17. package/dist/builtins/composer/composer.addon.mjs +347 -181
  18. package/dist/builtins/composer/composition-evaluation.d.ts +37 -0
  19. package/dist/builtins/composer/composition-runtime.d.ts +11 -52
  20. package/dist/builtins/composer/composition-target.d.ts +50 -0
  21. package/dist/builtins/composer/existing-target.d.ts +19 -1
  22. package/dist/builtins/composer/own-field-reads.d.ts +19 -0
  23. package/dist/builtins/console-logging/index.js +1 -1
  24. package/dist/builtins/console-logging/index.mjs +1 -1
  25. package/dist/builtins/core-blocks/core-blocks.addon.js +2 -2
  26. package/dist/builtins/core-blocks/core-blocks.addon.mjs +2 -2
  27. package/dist/builtins/device-manager/device-manager.addon.js +265 -29
  28. package/dist/builtins/device-manager/device-manager.addon.mjs +265 -29
  29. package/dist/builtins/device-manager/device-provider-context.d.ts +6 -0
  30. package/dist/builtins/device-manager/device-source-activation.d.ts +26 -1
  31. package/dist/builtins/device-manager/device-state-mirror.d.ts +41 -9
  32. package/dist/builtins/device-manager/mirror-row-writer.d.ts +59 -1
  33. package/dist/builtins/doorbell/binding-mirror.d.ts +45 -81
  34. package/dist/builtins/doorbell/doorbell-extension-slot.d.ts +4 -3
  35. package/dist/builtins/doorbell/virtual-doorbell.addon.d.ts +53 -11
  36. package/dist/builtins/doorbell/virtual-doorbell.addon.js +207 -82
  37. package/dist/builtins/doorbell/virtual-doorbell.addon.mjs +207 -82
  38. package/dist/builtins/hub-forwarder/index.js +1 -1
  39. package/dist/builtins/hub-forwarder/index.mjs +1 -1
  40. package/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  41. package/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  42. package/dist/builtins/local-auth/local-auth.addon.js +47 -3
  43. package/dist/builtins/local-auth/local-auth.addon.mjs +46 -4
  44. package/dist/builtins/local-network/local-network.addon.js +1 -1
  45. package/dist/builtins/local-network/local-network.addon.mjs +1 -1
  46. package/dist/builtins/loki-logging/index.js +1 -1
  47. package/dist/builtins/loki-logging/index.mjs +1 -1
  48. package/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  49. package/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  50. package/dist/builtins/platform-probe/index.js +1 -1
  51. package/dist/builtins/platform-probe/index.mjs +1 -1
  52. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  53. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  54. package/dist/builtins/snapshot/index.js +1 -1
  55. package/dist/builtins/snapshot/index.mjs +1 -1
  56. package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  57. package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  58. package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +0 -0
  59. package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +0 -0
  60. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  61. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  62. package/dist/builtins/system-config/system-config.addon.js +4 -4
  63. package/dist/builtins/system-config/system-config.addon.mjs +4 -4
  64. package/dist/builtins/winston-logging/index.js +1 -1
  65. package/dist/builtins/winston-logging/index.mjs +1 -1
  66. package/dist/{child-cap-dispatch-AAltfBUH.mjs → child-cap-dispatch-C2VINHu1.mjs} +70 -18
  67. package/dist/{child-cap-dispatch-DzcUd_ct.js → child-cap-dispatch-C8uts1P4.js} +70 -18
  68. package/dist/{composition-sources-BwE1POnF.js → composition-sources-BjRPhWtU.js} +1 -1
  69. package/dist/{composition-sources-fUyF4z39.mjs → composition-sources-Cg2MP-qf.mjs} +1 -1
  70. package/dist/{dist-BPvku43i.mjs → dist-CQ9vXSUh.mjs} +220 -8
  71. package/dist/{dist-RAl10EfG.js → dist-Dcy0gVHu.js} +220 -8
  72. package/dist/index.js +739 -350
  73. package/dist/index.mjs +737 -352
  74. package/dist/kernel/bootstrap-config.d.ts +8 -0
  75. package/dist/kernel/capability-registry.d.ts +30 -0
  76. package/dist/kernel/config-manager.d.ts +75 -129
  77. package/dist/kernel/index.d.ts +5 -2
  78. package/dist/kernel/moleculer/runtime-state-load.d.ts +19 -0
  79. package/dist/kernel/settings-door-view.d.ts +24 -1
  80. package/dist/kernel/settings-read-error.d.ts +37 -0
  81. package/dist/kernel/settings-view-types.d.ts +105 -0
  82. package/dist/kernel/store-settings-view.d.ts +17 -0
  83. package/dist/kernel/system-settings-mirror.d.ts +34 -0
  84. package/dist/kernel/system-settings-policy.d.ts +47 -0
  85. package/dist/{retired-settings-keys-DqVWSrVw.mjs → retired-settings-keys-DNIbyfTR.mjs} +1 -1
  86. package/dist/{retired-settings-keys-D3rGTGq5.js → retired-settings-keys-pzlrLUbA.js} +1 -1
  87. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { Gn as BaseAddon, It as localNetworkCapability, hr as EventCategory } from "../../dist-BPvku43i.mjs";
1
+ import { Gn as BaseAddon, It as localNetworkCapability, hr as EventCategory } from "../../dist-CQ9vXSUh.mjs";
2
2
  import { S as readLanHttpState, _ as DEFAULT_LAN_HTTP_PORT, a as writeTlsMode, i as writeExtraSans, l as reissueTlsLeaf, n as readTlsAccessStatus, o as validateUploadedTls, r as readTlsMode, s as ensureTlsCert, t as readExtraSans, y as applyLanHttp } from "../../tls-IM-v7JV4.mjs";
3
3
  import { mkdir, writeFile } from "node:fs/promises";
4
4
  import { join } from "node:path";
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-RAl10EfG.js");
6
+ const require_dist = require("../../dist-Dcy0gVHu.js");
7
7
  //#region src/builtins/loki-logging/loki-payload.ts
8
8
  /**
9
9
  * Loki rejects a label name that is not a valid Prometheus label
@@ -1,4 +1,4 @@
1
- import { Gn as BaseAddon, Rt as logDestinationCapability } from "../../dist-BPvku43i.mjs";
1
+ import { Gn as BaseAddon, Rt as logDestinationCapability } from "../../dist-CQ9vXSUh.mjs";
2
2
  //#region src/builtins/loki-logging/loki-payload.ts
3
3
  /**
4
4
  * Loki rejects a label name that is not a valid Prometheus label
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-RAl10EfG.js");
6
+ const require_dist = require("../../dist-Dcy0gVHu.js");
7
7
  const require_proc_stat = require("../../proc-stat-DL-WUOhl.js");
8
8
  let node_fs_promises = require("node:fs/promises");
9
9
  let node_fs = require("node:fs");
@@ -1,4 +1,4 @@
1
- import { Ct as foldSnapshotByFunction, Gn as BaseAddon, Ut as metricsProviderCapability, Wn as errMsg, en as reducePoints, hr as EventCategory, nn as resolveBucketMs, tr as createEvent } from "../../dist-BPvku43i.mjs";
1
+ import { Ct as foldSnapshotByFunction, Gn as BaseAddon, Ut as metricsProviderCapability, Wn as errMsg, en as reducePoints, hr as EventCategory, nn as resolveBucketMs, tr as createEvent } from "../../dist-CQ9vXSUh.mjs";
2
2
  import { a as parseProcStat, i as nodeProcReader, n as elapsedSecSince, o as parseProcStatusRss, r as lifetimeCpuPercent, t as commandFromCmdline } from "../../proc-stat-CbC55Kqi.mjs";
3
3
  import { access, readFile, readdir } from "node:fs/promises";
4
4
  import * as fs from "node:fs";
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-RAl10EfG.js");
6
+ const require_dist = require("../../dist-Dcy0gVHu.js");
7
7
  let node_fs = require("node:fs");
8
8
  node_fs = require_chunk.__toESM(node_fs);
9
9
  let node_child_process = require("node:child_process");
@@ -1,5 +1,5 @@
1
1
  import { o as __toESM } from "../../chunk-CNf5ZN-e.mjs";
2
- import { Gn as BaseAddon, Wn as errMsg, Zt as platformProbeCapability, cn as scoreRuntimes, hr as EventCategory, ht as enumerateInferenceDevices, rr as emitReadiness } from "../../dist-BPvku43i.mjs";
2
+ import { Gn as BaseAddon, Wn as errMsg, Zt as platformProbeCapability, cn as scoreRuntimes, hr as EventCategory, ht as enumerateInferenceDevices, rr as emitReadiness } from "../../dist-CQ9vXSUh.mjs";
3
3
  import * as fs from "node:fs";
4
4
  import { execFile } from "node:child_process";
5
5
  import * as os from "node:os";
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-RAl10EfG.js");
6
+ const require_dist = require("../../dist-Dcy0gVHu.js");
7
7
  //#region src/builtins/remote-access-orchestrator/enabled-providers-reconcile.ts
8
8
  /**
9
9
  * Reconcile the durable `enabledProviders` set against authoritative
@@ -1,4 +1,4 @@
1
- import { Gn as BaseAddon, hr as EventCategory } from "../../dist-BPvku43i.mjs";
1
+ import { Gn as BaseAddon, hr as EventCategory } from "../../dist-CQ9vXSUh.mjs";
2
2
  //#region src/builtins/remote-access-orchestrator/enabled-providers-reconcile.ts
3
3
  /**
4
4
  * Reconcile the durable `enabledProviders` set against authoritative
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-RAl10EfG.js");
6
+ const require_dist = require("../../dist-Dcy0gVHu.js");
7
7
  const require_snapshot_courtesy = require("../../snapshot-courtesy-Cqs7GkOV.js");
8
8
  let zod = require("zod");
9
9
  let node_crypto = require("node:crypto");
@@ -1,4 +1,4 @@
1
- import { G as batteryCapability, Gn as BaseAddon, Un as DeviceType, Vn as DeviceFeature, W as bareAddonId, Wn as errMsg, _n as streamQualityLabel, a as BatteryStatusSchema, cr as nodePin, dn as snapshotCapability, hr as EventCategory, lt as deriveBatteryPresence } from "../../dist-BPvku43i.mjs";
1
+ import { G as batteryCapability, Gn as BaseAddon, Un as DeviceType, Vn as DeviceFeature, W as bareAddonId, Wn as errMsg, _n as streamQualityLabel, a as BatteryStatusSchema, cr as nodePin, dn as snapshotCapability, hr as EventCategory, lt as deriveBatteryPresence } from "../../dist-CQ9vXSUh.mjs";
2
2
  import { i as renderCourtesyOverlayJpeg, n as courtesyCacheKey, r as renderCourtesyJpeg } from "../../snapshot-courtesy-CZPvteq2.mjs";
3
3
  import { z } from "zod";
4
4
  import { randomUUID } from "node:crypto";
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-RAl10EfG.js");
6
+ const require_dist = require("../../dist-Dcy0gVHu.js");
7
7
  let node_crypto = require("node:crypto");
8
8
  let node_fs_promises = require("node:fs/promises");
9
9
  let node_path = require("node:path");
@@ -1,4 +1,4 @@
1
- import { Gn as BaseAddon, St as filesystemBrowseCapability, hn as storageProviderCapability } from "../../dist-BPvku43i.mjs";
1
+ import { Gn as BaseAddon, St as filesystemBrowseCapability, hn as storageProviderCapability } from "../../dist-CQ9vXSUh.mjs";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import { mkdir, readdir, realpath, statfs } from "node:fs/promises";
4
4
  import * as path$1 from "node:path";
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-RAl10EfG.js");
6
+ const require_dist = require("../../dist-Dcy0gVHu.js");
7
7
  const require_hub_cap_forward = require("../../hub-cap-forward-DmHNjbB0.js");
8
8
  let zod = require("zod");
9
9
  let node_crypto = require("node:crypto");
@@ -1,4 +1,4 @@
1
- import { Cn as withLocationMode, D as REDACTED_SECRET, F as StorageLocationTypeSchema, Gn as BaseAddon, Ht as mayWriteToLocation, I as StorageMigrationJobSchema, N as StorageCleanupJobSchema, Ot as isLocationEnabled, P as StorageLocationModeSchema, Pt as legacyModeOf, Tt as gbToBytes, Vt as mayReadLocation, Wt as modeMayWrite, Y as collectSecretConfigKeys, fn as storageCapability, hr as EventCategory, ln as settingsStoreCapability, lr as parseJsonObject, pn as storageMigrationCapability, rn as resolveLocationMode, x as LegacyStorageLocationDefaultSchema, yt as evictionPolicyOfLocation } from "../../dist-BPvku43i.mjs";
1
+ import { Cn as withLocationMode, D as REDACTED_SECRET, F as StorageLocationTypeSchema, Gn as BaseAddon, Ht as mayWriteToLocation, I as StorageMigrationJobSchema, N as StorageCleanupJobSchema, Ot as isLocationEnabled, P as StorageLocationModeSchema, Pt as legacyModeOf, Tt as gbToBytes, Vt as mayReadLocation, Wt as modeMayWrite, Y as collectSecretConfigKeys, fn as storageCapability, hr as EventCategory, ln as settingsStoreCapability, lr as parseJsonObject, pn as storageMigrationCapability, rn as resolveLocationMode, x as LegacyStorageLocationDefaultSchema, yt as evictionPolicyOfLocation } from "../../dist-CQ9vXSUh.mjs";
2
2
  import { t as HUB_CAP_FWD_ACTION } from "../../hub-cap-forward-BdT320dq.mjs";
3
3
  import { z } from "zod";
4
4
  import { randomUUID } from "node:crypto";
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-RAl10EfG.js");
6
+ const require_dist = require("../../dist-Dcy0gVHu.js");
7
7
  //#region src/builtins/system-config/system-config.addon.ts
8
8
  /**
9
9
  * Built-in `system-config` addon — Phase 4 of the settings redesign.
@@ -124,11 +124,11 @@ var SystemConfigAddon = class extends require_dist.BaseAddon {
124
124
  const values = await this.ctx.settings.getSection(section);
125
125
  Object.assign(merged, values);
126
126
  } catch (err) {
127
- const msg = require_dist.errMsg(err);
128
- this.ctx.logger.debug("Failed to read section", { meta: {
127
+ this.ctx.logger.warn("system-config: a settings section could not be read", { meta: {
129
128
  section,
130
- error: msg
129
+ error: require_dist.errMsg(err)
131
130
  } });
131
+ throw err;
132
132
  }
133
133
  return require_dist.hydrateSchema(schema, merged);
134
134
  }
@@ -1,4 +1,4 @@
1
- import { Gn as BaseAddon, Wn as errMsg, ar as hydrateSchema } from "../../dist-BPvku43i.mjs";
1
+ import { Gn as BaseAddon, Wn as errMsg, ar as hydrateSchema } from "../../dist-CQ9vXSUh.mjs";
2
2
  //#region src/builtins/system-config/system-config.addon.ts
3
3
  /**
4
4
  * Built-in `system-config` addon — Phase 4 of the settings redesign.
@@ -119,11 +119,11 @@ var SystemConfigAddon = class extends BaseAddon {
119
119
  const values = await this.ctx.settings.getSection(section);
120
120
  Object.assign(merged, values);
121
121
  } catch (err) {
122
- const msg = errMsg(err);
123
- this.ctx.logger.debug("Failed to read section", { meta: {
122
+ this.ctx.logger.warn("system-config: a settings section could not be read", { meta: {
124
123
  section,
125
- error: msg
124
+ error: errMsg(err)
126
125
  } });
126
+ throw err;
127
127
  }
128
128
  return hydrateSchema(schema, merged);
129
129
  }
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-RAl10EfG.js");
6
+ const require_dist = require("../../dist-Dcy0gVHu.js");
7
7
  const require_formatter = require("../../formatter-DqAKDlvN.js");
8
8
  let node_path = require("node:path");
9
9
  node_path = require_chunk.__toESM(node_path);
@@ -1,4 +1,4 @@
1
- import { Gn as BaseAddon, Rt as logDestinationCapability } from "../../dist-BPvku43i.mjs";
1
+ import { Gn as BaseAddon, Rt as logDestinationCapability } from "../../dist-CQ9vXSUh.mjs";
2
2
  import { t as formatLogLine } from "../../formatter-B7qW8bPJ.mjs";
3
3
  import * as path$1 from "node:path";
4
4
  import path from "node:path";
@@ -719,23 +719,23 @@ function formatSocketPlane(window) {
719
719
  }
720
720
  //#endregion
721
721
  //#region src/kernel/moleculer/mesh-queue-report.ts
722
- function isRecord$1(value) {
722
+ function isRecord$2(value) {
723
723
  return typeof value === "object" && value !== null;
724
724
  }
725
725
  /** The shape `TcpWriter` keeps its sockets in. Anything else is not a mesh. */
726
726
  function writerSocketsOf(broker) {
727
- if (!isRecord$1(broker)) return void 0;
727
+ if (!isRecord$2(broker)) return void 0;
728
728
  const transit = broker["transit"];
729
- if (!isRecord$1(transit)) return void 0;
729
+ if (!isRecord$2(transit)) return void 0;
730
730
  const transporter = transit["tx"];
731
- if (!isRecord$1(transporter)) return void 0;
731
+ if (!isRecord$2(transporter)) return void 0;
732
732
  const writer = transporter["writer"];
733
- if (!isRecord$1(writer)) return void 0;
733
+ if (!isRecord$2(writer)) return void 0;
734
734
  const sockets = writer["sockets"];
735
735
  return sockets instanceof Map ? sockets : void 0;
736
736
  }
737
737
  function readSocket(nodeId, socket) {
738
- if (typeof nodeId !== "string" || !isRecord$1(socket)) return void 0;
738
+ if (typeof nodeId !== "string" || !isRecord$2(socket)) return void 0;
739
739
  const queuedBytes = socket["writableLength"];
740
740
  const bytesWritten = socket["bytesWritten"];
741
741
  if (typeof queuedBytes !== "number" || typeof bytesWritten !== "number") return void 0;
@@ -3346,7 +3346,7 @@ async function resolveUncached(options) {
3346
3346
  }
3347
3347
  //#endregion
3348
3348
  //#region src/kernel/addon-class-resolver.ts
3349
- function isRecord(value) {
3349
+ function isRecord$1(value) {
3350
3350
  return typeof value === "object" && value !== null && !Array.isArray(value);
3351
3351
  }
3352
3352
  /**
@@ -3370,14 +3370,14 @@ function isRecord(value) {
3370
3370
  function isAddonConstructor(fn) {
3371
3371
  if (typeof fn !== "function") return false;
3372
3372
  const proto = fn.prototype;
3373
- if (!isRecord(proto)) return false;
3373
+ if (!isRecord$1(proto)) return false;
3374
3374
  return typeof proto["initialize"] === "function";
3375
3375
  }
3376
3376
  function resolveAddonClass(mod) {
3377
3377
  let candidate = mod["default"];
3378
- if (isRecord(candidate) && "default" in candidate) candidate = candidate["default"];
3378
+ if (isRecord$1(candidate) && "default" in candidate) candidate = candidate["default"];
3379
3379
  if (isAddonConstructor(candidate)) return candidate;
3380
- if (isRecord(candidate)) {
3380
+ if (isRecord$1(candidate)) {
3381
3381
  const fn = Object.values(candidate).find(isAddonConstructor);
3382
3382
  if (fn) return fn;
3383
3383
  }
@@ -4418,6 +4418,51 @@ function createChildrenBatchLoader(opts) {
4418
4418
  } };
4419
4419
  }
4420
4420
  //#endregion
4421
+ //#region src/kernel/moleculer/runtime-state-load.ts
4422
+ /** A device build refused because its runtime state could not be loaded. */
4423
+ var RuntimeStateLoadError = class extends Error {
4424
+ deviceId;
4425
+ constructor(deviceId, reason, options) {
4426
+ super(`runtime state of device ${deviceId} could not be loaded (${reason}) — the device is not built from an empty state (D677)`, options);
4427
+ this.deviceId = deviceId;
4428
+ this.name = "RuntimeStateLoadError";
4429
+ }
4430
+ };
4431
+ function isRecord(value) {
4432
+ return typeof value === "object" && value !== null && !Array.isArray(value);
4433
+ }
4434
+ function errorMessage(err) {
4435
+ return err instanceof Error ? err.message : String(err);
4436
+ }
4437
+ /**
4438
+ * Load the device's runtime state, or throw {@link RuntimeStateLoadError}
4439
+ * after one warn naming the device. An answer that is not an object is a
4440
+ * failed load too — it would hydrate as nothing.
4441
+ */
4442
+ async function loadRuntimeStateOrRefuse(load, logger, target) {
4443
+ const refuse = (reason, cause) => {
4444
+ logger.warn("loadRuntimeState failed — device build refused, never hydrated from an empty state (D677)", {
4445
+ tags: {
4446
+ deviceId: target.deviceId,
4447
+ stableId: target.stableId
4448
+ },
4449
+ meta: {
4450
+ phase: target.phase,
4451
+ error: reason
4452
+ }
4453
+ });
4454
+ throw new RuntimeStateLoadError(target.deviceId, reason, cause === void 0 ? void 0 : { cause });
4455
+ };
4456
+ let answer;
4457
+ try {
4458
+ answer = await load();
4459
+ } catch (err) {
4460
+ return refuse(errorMessage(err), err);
4461
+ }
4462
+ if (!isRecord(answer)) return refuse(`answered ${answer === null ? "null" : typeof answer}`);
4463
+ return answer;
4464
+ }
4465
+ //#endregion
4421
4466
  //#region src/kernel/moleculer/device-cap-proxy.ts
4422
4467
  /**
4423
4468
  * Max number of accessory children spawned concurrently during a single
@@ -4697,6 +4742,12 @@ function createBrokerDeviceManagerApi(opts) {
4697
4742
  }
4698
4743
  });
4699
4744
  const deviceRebuildFactories = /* @__PURE__ */ new Map();
4745
+ /** `loadRuntimeState` that refuses the build instead of answering `{}` (D677). */
4746
+ const loadRuntimeStateFor = (deviceId, stableId, phase) => loadRuntimeStateOrRefuse(() => callDeviceManager(api, "loadRuntimeState", { deviceId }), opts.logger, {
4747
+ deviceId,
4748
+ stableId,
4749
+ phase
4750
+ });
4700
4751
  const buildContext = (stableId, id, parentDeviceId = null, initialRuntimeState = {}, persistedConfig = {}, deviceMeta = null) => {
4701
4752
  let runtimeStateRef = null;
4702
4753
  return {
@@ -4913,7 +4964,7 @@ function createBrokerDeviceManagerApi(opts) {
4913
4964
  data: spec.config
4914
4965
  }).catch(() => {});
4915
4966
  const [initialRuntimeState, loadedConfig, deviceMeta] = await Promise.all([
4916
- callDeviceManager(api, "loadRuntimeState", { deviceId: id }).catch(() => empty),
4967
+ loadRuntimeStateFor(id, childStableId, "accessory-child"),
4917
4968
  callDeviceManager(api, "loadConfig", { deviceId: id }).catch(() => empty),
4918
4969
  callDeviceManager(api, "loadMeta", { deviceId: id }).catch(() => null)
4919
4970
  ]);
@@ -4929,8 +4980,8 @@ function createBrokerDeviceManagerApi(opts) {
4929
4980
  const child = spec.factory(childCtx);
4930
4981
  await deviceApi.register(child);
4931
4982
  deviceRebuildFactories.set(id, async (mergedConfig) => {
4932
- const [rt, meta] = await Promise.all([callDeviceManager(api, "loadRuntimeState", { deviceId: id }).catch(() => ({})), callDeviceManager(api, "loadMeta", { deviceId: id }).catch(() => null)]);
4933
- return spec.factory(buildContext(childStableId, id, parent.id, rt, mergedConfig, meta));
4983
+ const [rt, meta] = await Promise.all([loadRuntimeStateFor(id, childStableId, "rebuild"), callDeviceManager(api, "loadMeta", { deviceId: id }).catch(() => null)]);
4984
+ return () => spec.factory(buildContext(childStableId, id, parent.id, rt, mergedConfig, meta));
4934
4985
  });
4935
4986
  return child;
4936
4987
  };
@@ -5056,19 +5107,20 @@ function createBrokerDeviceManagerApi(opts) {
5056
5107
  });
5057
5108
  const empty = {};
5058
5109
  const [initialRuntimeState, persistedConfig, deviceMeta] = await Promise.all([
5059
- callDeviceManager(api, "loadRuntimeState", { deviceId: id }).catch(() => empty),
5110
+ loadRuntimeStateFor(id, stableId, "create"),
5060
5111
  callDeviceManager(api, "loadConfig", { deviceId: id }).catch(() => empty),
5061
5112
  callDeviceManager(api, "loadMeta", { deviceId: id }).catch(() => null)
5062
5113
  ]);
5063
5114
  const device = new DeviceClass(buildContext(stableId, id, parentDeviceId, initialRuntimeState, persistedConfig, deviceMeta));
5064
5115
  await deviceApi.register(device);
5065
5116
  deviceRebuildFactories.set(id, async (mergedConfig) => {
5066
- const [rt, meta] = await Promise.all([callDeviceManager(api, "loadRuntimeState", { deviceId: id }).catch(() => ({})), callDeviceManager(api, "loadMeta", { deviceId: id }).catch(() => null)]);
5067
- return new DeviceClass(buildContext(stableId, id, parentDeviceId, rt, mergedConfig, meta));
5117
+ const [rt, meta] = await Promise.all([loadRuntimeStateFor(id, stableId, "rebuild"), callDeviceManager(api, "loadMeta", { deviceId: id }).catch(() => null)]);
5118
+ return () => new DeviceClass(buildContext(stableId, id, parentDeviceId, rt, mergedConfig, meta));
5068
5119
  });
5069
5120
  return device;
5070
5121
  },
5071
5122
  createContext: (stableId, id, parentDeviceId = null, persistedConfig = {}) => buildContext(stableId, id, parentDeviceId, {}, persistedConfig),
5123
+ loadContext: async (stableId, id, parentDeviceId = null, persistedConfig = {}) => buildContext(stableId, id, parentDeviceId, await loadRuntimeStateFor(id, stableId, "context"), persistedConfig),
5072
5124
  loadConfig: async (deviceId) => {
5073
5125
  const empty = {};
5074
5126
  return callDeviceManager(api, "loadConfig", { deviceId }).catch(() => empty);
@@ -5446,9 +5498,9 @@ function createBrokerDeviceManagerApi(opts) {
5446
5498
  });
5447
5499
  const rebuild = deviceRebuildFactories.get(deviceId);
5448
5500
  if (!rebuild) return;
5501
+ const construct = await rebuild(merged);
5449
5502
  await deviceApi.decommission(deviceId);
5450
- const fresh = await rebuild(merged);
5451
- await deviceApi.register(fresh);
5503
+ await deviceApi.register(construct());
5452
5504
  },
5453
5505
  remove: async (deviceId) => {
5454
5506
  deviceRebuildFactories.delete(deviceId);
@@ -722,23 +722,23 @@ function formatSocketPlane(window) {
722
722
  }
723
723
  //#endregion
724
724
  //#region src/kernel/moleculer/mesh-queue-report.ts
725
- function isRecord$1(value) {
725
+ function isRecord$2(value) {
726
726
  return typeof value === "object" && value !== null;
727
727
  }
728
728
  /** The shape `TcpWriter` keeps its sockets in. Anything else is not a mesh. */
729
729
  function writerSocketsOf(broker) {
730
- if (!isRecord$1(broker)) return void 0;
730
+ if (!isRecord$2(broker)) return void 0;
731
731
  const transit = broker["transit"];
732
- if (!isRecord$1(transit)) return void 0;
732
+ if (!isRecord$2(transit)) return void 0;
733
733
  const transporter = transit["tx"];
734
- if (!isRecord$1(transporter)) return void 0;
734
+ if (!isRecord$2(transporter)) return void 0;
735
735
  const writer = transporter["writer"];
736
- if (!isRecord$1(writer)) return void 0;
736
+ if (!isRecord$2(writer)) return void 0;
737
737
  const sockets = writer["sockets"];
738
738
  return sockets instanceof Map ? sockets : void 0;
739
739
  }
740
740
  function readSocket(nodeId, socket) {
741
- if (typeof nodeId !== "string" || !isRecord$1(socket)) return void 0;
741
+ if (typeof nodeId !== "string" || !isRecord$2(socket)) return void 0;
742
742
  const queuedBytes = socket["writableLength"];
743
743
  const bytesWritten = socket["bytesWritten"];
744
744
  if (typeof queuedBytes !== "number" || typeof bytesWritten !== "number") return void 0;
@@ -3349,7 +3349,7 @@ async function resolveUncached(options) {
3349
3349
  }
3350
3350
  //#endregion
3351
3351
  //#region src/kernel/addon-class-resolver.ts
3352
- function isRecord(value) {
3352
+ function isRecord$1(value) {
3353
3353
  return typeof value === "object" && value !== null && !Array.isArray(value);
3354
3354
  }
3355
3355
  /**
@@ -3373,14 +3373,14 @@ function isRecord(value) {
3373
3373
  function isAddonConstructor(fn) {
3374
3374
  if (typeof fn !== "function") return false;
3375
3375
  const proto = fn.prototype;
3376
- if (!isRecord(proto)) return false;
3376
+ if (!isRecord$1(proto)) return false;
3377
3377
  return typeof proto["initialize"] === "function";
3378
3378
  }
3379
3379
  function resolveAddonClass(mod) {
3380
3380
  let candidate = mod["default"];
3381
- if (isRecord(candidate) && "default" in candidate) candidate = candidate["default"];
3381
+ if (isRecord$1(candidate) && "default" in candidate) candidate = candidate["default"];
3382
3382
  if (isAddonConstructor(candidate)) return candidate;
3383
- if (isRecord(candidate)) {
3383
+ if (isRecord$1(candidate)) {
3384
3384
  const fn = Object.values(candidate).find(isAddonConstructor);
3385
3385
  if (fn) return fn;
3386
3386
  }
@@ -4421,6 +4421,51 @@ function createChildrenBatchLoader(opts) {
4421
4421
  } };
4422
4422
  }
4423
4423
  //#endregion
4424
+ //#region src/kernel/moleculer/runtime-state-load.ts
4425
+ /** A device build refused because its runtime state could not be loaded. */
4426
+ var RuntimeStateLoadError = class extends Error {
4427
+ deviceId;
4428
+ constructor(deviceId, reason, options) {
4429
+ super(`runtime state of device ${deviceId} could not be loaded (${reason}) — the device is not built from an empty state (D677)`, options);
4430
+ this.deviceId = deviceId;
4431
+ this.name = "RuntimeStateLoadError";
4432
+ }
4433
+ };
4434
+ function isRecord(value) {
4435
+ return typeof value === "object" && value !== null && !Array.isArray(value);
4436
+ }
4437
+ function errorMessage(err) {
4438
+ return err instanceof Error ? err.message : String(err);
4439
+ }
4440
+ /**
4441
+ * Load the device's runtime state, or throw {@link RuntimeStateLoadError}
4442
+ * after one warn naming the device. An answer that is not an object is a
4443
+ * failed load too — it would hydrate as nothing.
4444
+ */
4445
+ async function loadRuntimeStateOrRefuse(load, logger, target) {
4446
+ const refuse = (reason, cause) => {
4447
+ logger.warn("loadRuntimeState failed — device build refused, never hydrated from an empty state (D677)", {
4448
+ tags: {
4449
+ deviceId: target.deviceId,
4450
+ stableId: target.stableId
4451
+ },
4452
+ meta: {
4453
+ phase: target.phase,
4454
+ error: reason
4455
+ }
4456
+ });
4457
+ throw new RuntimeStateLoadError(target.deviceId, reason, cause === void 0 ? void 0 : { cause });
4458
+ };
4459
+ let answer;
4460
+ try {
4461
+ answer = await load();
4462
+ } catch (err) {
4463
+ return refuse(errorMessage(err), err);
4464
+ }
4465
+ if (!isRecord(answer)) return refuse(`answered ${answer === null ? "null" : typeof answer}`);
4466
+ return answer;
4467
+ }
4468
+ //#endregion
4424
4469
  //#region src/kernel/moleculer/device-cap-proxy.ts
4425
4470
  /**
4426
4471
  * Max number of accessory children spawned concurrently during a single
@@ -4700,6 +4745,12 @@ function createBrokerDeviceManagerApi(opts) {
4700
4745
  }
4701
4746
  });
4702
4747
  const deviceRebuildFactories = /* @__PURE__ */ new Map();
4748
+ /** `loadRuntimeState` that refuses the build instead of answering `{}` (D677). */
4749
+ const loadRuntimeStateFor = (deviceId, stableId, phase) => loadRuntimeStateOrRefuse(() => callDeviceManager(api, "loadRuntimeState", { deviceId }), opts.logger, {
4750
+ deviceId,
4751
+ stableId,
4752
+ phase
4753
+ });
4703
4754
  const buildContext = (stableId, id, parentDeviceId = null, initialRuntimeState = {}, persistedConfig = {}, deviceMeta = null) => {
4704
4755
  let runtimeStateRef = null;
4705
4756
  return {
@@ -4916,7 +4967,7 @@ function createBrokerDeviceManagerApi(opts) {
4916
4967
  data: spec.config
4917
4968
  }).catch(() => {});
4918
4969
  const [initialRuntimeState, loadedConfig, deviceMeta] = await Promise.all([
4919
- callDeviceManager(api, "loadRuntimeState", { deviceId: id }).catch(() => empty),
4970
+ loadRuntimeStateFor(id, childStableId, "accessory-child"),
4920
4971
  callDeviceManager(api, "loadConfig", { deviceId: id }).catch(() => empty),
4921
4972
  callDeviceManager(api, "loadMeta", { deviceId: id }).catch(() => null)
4922
4973
  ]);
@@ -4932,8 +4983,8 @@ function createBrokerDeviceManagerApi(opts) {
4932
4983
  const child = spec.factory(childCtx);
4933
4984
  await deviceApi.register(child);
4934
4985
  deviceRebuildFactories.set(id, async (mergedConfig) => {
4935
- const [rt, meta] = await Promise.all([callDeviceManager(api, "loadRuntimeState", { deviceId: id }).catch(() => ({})), callDeviceManager(api, "loadMeta", { deviceId: id }).catch(() => null)]);
4936
- return spec.factory(buildContext(childStableId, id, parent.id, rt, mergedConfig, meta));
4986
+ const [rt, meta] = await Promise.all([loadRuntimeStateFor(id, childStableId, "rebuild"), callDeviceManager(api, "loadMeta", { deviceId: id }).catch(() => null)]);
4987
+ return () => spec.factory(buildContext(childStableId, id, parent.id, rt, mergedConfig, meta));
4937
4988
  });
4938
4989
  return child;
4939
4990
  };
@@ -5059,19 +5110,20 @@ function createBrokerDeviceManagerApi(opts) {
5059
5110
  });
5060
5111
  const empty = {};
5061
5112
  const [initialRuntimeState, persistedConfig, deviceMeta] = await Promise.all([
5062
- callDeviceManager(api, "loadRuntimeState", { deviceId: id }).catch(() => empty),
5113
+ loadRuntimeStateFor(id, stableId, "create"),
5063
5114
  callDeviceManager(api, "loadConfig", { deviceId: id }).catch(() => empty),
5064
5115
  callDeviceManager(api, "loadMeta", { deviceId: id }).catch(() => null)
5065
5116
  ]);
5066
5117
  const device = new DeviceClass(buildContext(stableId, id, parentDeviceId, initialRuntimeState, persistedConfig, deviceMeta));
5067
5118
  await deviceApi.register(device);
5068
5119
  deviceRebuildFactories.set(id, async (mergedConfig) => {
5069
- const [rt, meta] = await Promise.all([callDeviceManager(api, "loadRuntimeState", { deviceId: id }).catch(() => ({})), callDeviceManager(api, "loadMeta", { deviceId: id }).catch(() => null)]);
5070
- return new DeviceClass(buildContext(stableId, id, parentDeviceId, rt, mergedConfig, meta));
5120
+ const [rt, meta] = await Promise.all([loadRuntimeStateFor(id, stableId, "rebuild"), callDeviceManager(api, "loadMeta", { deviceId: id }).catch(() => null)]);
5121
+ return () => new DeviceClass(buildContext(stableId, id, parentDeviceId, rt, mergedConfig, meta));
5071
5122
  });
5072
5123
  return device;
5073
5124
  },
5074
5125
  createContext: (stableId, id, parentDeviceId = null, persistedConfig = {}) => buildContext(stableId, id, parentDeviceId, {}, persistedConfig),
5126
+ loadContext: async (stableId, id, parentDeviceId = null, persistedConfig = {}) => buildContext(stableId, id, parentDeviceId, await loadRuntimeStateFor(id, stableId, "context"), persistedConfig),
5075
5127
  loadConfig: async (deviceId) => {
5076
5128
  const empty = {};
5077
5129
  return callDeviceManager(api, "loadConfig", { deviceId }).catch(() => empty);
@@ -5449,9 +5501,9 @@ function createBrokerDeviceManagerApi(opts) {
5449
5501
  });
5450
5502
  const rebuild = deviceRebuildFactories.get(deviceId);
5451
5503
  if (!rebuild) return;
5504
+ const construct = await rebuild(merged);
5452
5505
  await deviceApi.decommission(deviceId);
5453
- const fresh = await rebuild(merged);
5454
- await deviceApi.register(fresh);
5506
+ await deviceApi.register(construct());
5455
5507
  },
5456
5508
  remove: async (deviceId) => {
5457
5509
  deviceRebuildFactories.delete(deviceId);
@@ -1,4 +1,4 @@
1
- const require_dist = require("./dist-RAl10EfG.js");
1
+ const require_dist = require("./dist-Dcy0gVHu.js");
2
2
  //#region src/builtins/core-blocks/composition-sources.ts
3
3
  /**
4
4
  * Describe what a composition reads and writes for SAVE-time validation
@@ -1,4 +1,4 @@
1
- import { In as compositionSourceKey, Wn as errMsg } from "./dist-BPvku43i.mjs";
1
+ import { In as compositionSourceKey, Wn as errMsg } from "./dist-CQ9vXSUh.mjs";
2
2
  //#region src/builtins/core-blocks/composition-sources.ts
3
3
  /**
4
4
  * Describe what a composition reads and writes for SAVE-time validation