@camstack/server 1.2.909 → 1.2.911

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 (101) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/agent/main.js +21 -8
  3. package/dist/api/core/cap-providers.js +81 -78
  4. package/dist/api/trpc/device-config-secret-redaction.js +42 -2
  5. package/dist/api/trpc/generated-cap-routers.js +20 -0
  6. package/dist/api/trpc/trpc.middleware.js +10 -2
  7. package/dist/core/addon/addon-registry.service.js +25 -1
  8. package/dist/core/addon/instance-lifecycle.js +106 -33
  9. package/package.json +29 -12
  10. package/system/dist/addon-runner.js +229 -21
  11. package/system/dist/addon-runner.mjs +230 -22
  12. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  13. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  14. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  15. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  16. package/system/dist/builtins/alerts/alerts.addon.js +1 -1
  17. package/system/dist/builtins/alerts/alerts.addon.mjs +1 -1
  18. package/system/dist/builtins/autotrack/index.js +1 -1
  19. package/system/dist/builtins/autotrack/index.mjs +1 -1
  20. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
  21. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
  22. package/system/dist/builtins/calendars/calendars.addon.js +1 -1
  23. package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
  24. package/system/dist/builtins/camera-grid/index.js +1 -1
  25. package/system/dist/builtins/camera-grid/index.mjs +1 -1
  26. package/system/dist/builtins/composer/composer.addon.js +4 -4
  27. package/system/dist/builtins/composer/composer.addon.mjs +4 -4
  28. package/system/dist/builtins/console-logging/index.js +1 -1
  29. package/system/dist/builtins/console-logging/index.mjs +1 -1
  30. package/system/dist/builtins/core-blocks/core-blocks.addon.js +6 -5
  31. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +6 -5
  32. package/system/dist/builtins/device-history/device-history.addon.js +2 -2
  33. package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
  34. package/system/dist/builtins/device-manager/device-manager.addon.js +2 -2
  35. package/system/dist/builtins/device-manager/device-manager.addon.mjs +2 -2
  36. package/system/dist/builtins/hub-forwarder/index.js +1 -1
  37. package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
  38. package/system/dist/builtins/keychain/index.js +4 -4
  39. package/system/dist/builtins/keychain/index.mjs +4 -4
  40. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  41. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  42. package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
  43. package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
  44. package/system/dist/builtins/local-network/local-network.addon.js +3 -3
  45. package/system/dist/builtins/local-network/local-network.addon.mjs +3 -3
  46. package/system/dist/builtins/loki-logging/index.js +15 -9
  47. package/system/dist/builtins/loki-logging/index.mjs +15 -9
  48. package/system/dist/builtins/loki-logging/loki-logging.addon.d.ts +6 -0
  49. package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  50. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  51. package/system/dist/builtins/platform-probe/index.js +1 -1
  52. package/system/dist/builtins/platform-probe/index.mjs +1 -1
  53. package/system/dist/builtins/record-entries/index.js +1 -1
  54. package/system/dist/builtins/record-entries/index.mjs +1 -1
  55. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  56. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  57. package/system/dist/builtins/snapshot/index.js +1 -1
  58. package/system/dist/builtins/snapshot/index.mjs +1 -1
  59. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  60. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  61. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  62. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  63. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
  64. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
  65. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  66. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  67. package/system/dist/builtins/system-config/system-config.addon.js +3 -3
  68. package/system/dist/builtins/system-config/system-config.addon.mjs +3 -3
  69. package/system/dist/builtins/winston-logging/index.js +1 -1
  70. package/system/dist/builtins/winston-logging/index.mjs +1 -1
  71. package/system/dist/{capture-engine-C6IjgNU4.js → capture-engine-CRXUcNzg.js} +1 -1
  72. package/system/dist/{capture-engine-CE9QyWYX.mjs → capture-engine-erwNulcY.mjs} +1 -1
  73. package/system/dist/{composition-sources-YIJB6QG7.js → composition-sources-CmJRQLAB.js} +1 -1
  74. package/system/dist/{composition-sources-CsPiXLpf.mjs → composition-sources-DrQFzsQU.mjs} +1 -1
  75. package/system/dist/{constants-D6sXdBUu.js → constants-BuRweEmb.js} +1 -1
  76. package/system/dist/{constants-D1n14R3Y.mjs → constants-D9ZICjoN.mjs} +1 -1
  77. package/system/dist/{device-ca-BTbsR2J2.js → device-ca-DGwzbKB7.js} +1 -1
  78. package/system/dist/{device-ca-DahOgcXb.mjs → device-ca-XXMVM6Lu.mjs} +1 -1
  79. package/system/dist/{dist-_gUzcZPn.js → dist-CZx3IYRz.js} +523 -42
  80. package/system/dist/{dist-DxW5ebV-.mjs → dist-DUYpvNfO.mjs} +522 -41
  81. package/system/dist/file-host-worker.js +1 -1
  82. package/system/dist/file-host-worker.mjs +1 -1
  83. package/system/dist/{hub-identity-DpzA5fuQ.mjs → hub-identity-Dc-SOwBk.mjs} +1 -1
  84. package/system/dist/{hub-identity-CDhT1yT0.js → hub-identity-vVRXZi0z.js} +1 -1
  85. package/system/dist/{hub-mdns-ciao-C6nswov4.mjs → hub-mdns-ciao-DpRGDUEE.mjs} +2 -2
  86. package/system/dist/{hub-mdns-ciao-BWDuSepO.js → hub-mdns-ciao-uCdDDwE4.js} +2 -2
  87. package/system/dist/index.d.ts +1 -0
  88. package/system/dist/index.js +218 -26
  89. package/system/dist/index.mjs +219 -28
  90. package/system/dist/kernel/moleculer/accessory-spawn-retry.d.ts +67 -0
  91. package/system/dist/kernel/moleculer/device-cap-proxy.d.ts +2 -0
  92. package/system/dist/kernel/moleculer/hub-connect-switches.d.ts +23 -0
  93. package/system/dist/{legacy-integration-rows-door-vKSv01GH.js → legacy-integration-rows-door-CtObsXaU.js} +1 -1
  94. package/system/dist/{legacy-integration-rows-door-lCNawQ-w.mjs → legacy-integration-rows-door-DvbF3IY8.mjs} +1 -1
  95. package/system/dist/{rename-composition-block-ONfuFbfd.mjs → rename-composition-block-CowZDV1m.mjs} +1 -1
  96. package/system/dist/{rename-composition-block-ozGMTnI_.js → rename-composition-block-rKmnICiK.js} +1 -1
  97. package/system/dist/{restore-archive-CUVoxsCu.js → restore-archive-BvvAR6Ww.js} +1 -1
  98. package/system/dist/{restore-archive-DWTsdq1K.mjs → restore-archive-DH-lFUT0.mjs} +1 -1
  99. package/system/dist/{wal-maintenance-B6pvtESa.mjs → wal-maintenance-B0uiPZUs.mjs} +0 -0
  100. package/system/dist/{wal-maintenance-Cgpar8TL.js → wal-maintenance-CB9zUxb-.js} +0 -0
  101. package/system/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  import { register } from "node:module";
2
- import { BOOT_RECOVERY_BACKOFF_MS, CALLER_STAMPED_CAPABILITIES, CAP_METHOD_NOT_IMPLEMENTED, CAP_METHOD_TIMEOUTS_MS, COLLECTION_ARRAY_METHODS, COMPOSED_DEVICE_STABLE_ID_PREFIX, DATAPLANE_SECRET_HEADER, DEVICE_CHILDREN_BATCH_MAX, DeviceType, DisposerChain, ErrorI18nPayloadSchema, EventCategory, MIGRATION_API_VERSION, PEER_BYTES_CHUNK_BYTES, PEER_BYTES_MAX_OUTSTANDING, PEER_BYTES_STALL_MS, PEER_BYTES_TICKET_TTL_MS, ReadinessRegistry, ReadinessTimeoutError, addonSliceHandleApi, asJsonObject, asString, collectZodSecretPaths, commandOrigin, createDebugEmitter, createDeviceProxy, createEventBusSliceSource, createRecordsAccess, createSecretsAccess, describeCustomActions, describeNvidia, deviceOpsCapability, emitReadiness, errMsg, expandCapMethods, findMigrationsBlocked, isCollectionArrayMethodName, isProviderOptionalMethodName, maskUrlCredentials, nodeIdOfScopedKey, normalizeAddonInitResult, readCommandOrigin, readErrorI18n, readNodePin, resolveDeviceSettings, resolveSecretViewsIn, scopeKey, scrubKnownSecrets, switchRefusesSetState, withCapInputDefaults } from "@camstack/types/addon";
2
+ import { BOOT_RECOVERY_BACKOFF_MS, CALLER_STAMPED_CAPABILITIES, CAP_METHOD_NOT_IMPLEMENTED, CAP_METHOD_TIMEOUTS_MS, COLLECTION_ARRAY_METHODS, COMPOSED_DEVICE_STABLE_ID_PREFIX, DATAPLANE_SECRET_HEADER, DEVICE_CHILDREN_BATCH_MAX, DEVICE_RESTORE_RETRY_DELAYS_MS, DeviceType, DisposerChain, ErrorI18nPayloadSchema, EventCategory, MIGRATION_API_VERSION, PEER_BYTES_CHUNK_BYTES, PEER_BYTES_MAX_OUTSTANDING, PEER_BYTES_STALL_MS, PEER_BYTES_TICKET_TTL_MS, ReadinessRegistry, ReadinessTimeoutError, addonSliceHandleApi, asJsonObject, asString, collectZodSecretPaths, commandOrigin, createDebugEmitter, createDeviceProxy, createEventBusSliceSource, createRecordsAccess, createSecretsAccess, describeCustomActions, describeNvidia, deviceOpsCapability, emitReadiness, errMsg, expandCapMethods, findMigrationsBlocked, isCollectionArrayMethodName, isInstanceSwitchesUnreadError, isProviderOptionalMethodName, maskUrlCredentials, nodeIdOfScopedKey, normalizeAddonInitResult, readCommandOrigin, readErrorI18n, readNodePin, resolveDeviceSettings, resolveSecretViewsIn, scopeKey, scrubKnownSecrets, switchRefusesSetState, withCapInputDefaults } from "@camstack/types/addon";
3
3
  import * as fs$1 from "node:fs";
4
4
  import fs, { createReadStream, createWriteStream, existsSync, readFileSync, readdirSync } from "node:fs";
5
5
  import * as path from "node:path";
@@ -125,6 +125,25 @@ function refusalReportOf(addonId, err) {
125
125
  };
126
126
  }
127
127
  //#endregion
128
+ //#region src/kernel/moleculer/hub-connect-switches.ts
129
+ /**
130
+ * On a hub connect, every addon with instance kinds reads its switches from the registry again
131
+ * (D1066). Event-driven, no timer (D3): the next connect retries. A forked runner's FIRST connect
132
+ * is its boot, so a registry that still does not answer ends the process and the supervisor
133
+ * respawns it, bounded and marked terminally failed (D6), instead of leaving instances off.
134
+ */
135
+ async function rehydrateSwitchesOnHubConnect(entries, deps) {
136
+ for (const entry of entries) {
137
+ if (entry.addon.rehydrateSwitches === void 0) continue;
138
+ try {
139
+ await entry.addon.rehydrateSwitches();
140
+ } catch (err) {
141
+ if (deps.fatalOnUnread && isInstanceSwitchesUnreadError(err)) deps.exit(entry.addonId, err);
142
+ else deps.onUnread(entry.addonId, err);
143
+ }
144
+ }
145
+ }
146
+ //#endregion
128
147
  //#region src/kernel/addon-class-resolver.ts
129
148
  function isRecord$4(value) {
130
149
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -6054,6 +6073,156 @@ var AccessoryShrinkGate = class {
6054
6073
  }
6055
6074
  };
6056
6075
  //#endregion
6076
+ //#region src/kernel/moleculer/accessory-spawn-retry.ts
6077
+ /** A spawn failure that knows which step threw. */
6078
+ var AccessorySpawnStepError = class extends Error {
6079
+ step;
6080
+ /** The child's numeric id once allocated; null when allocation itself failed. */
6081
+ deviceId;
6082
+ constructor(step, deviceId, cause) {
6083
+ const reason = cause instanceof Error ? cause.message : String(cause);
6084
+ super(`${step}: ${reason}`, { cause });
6085
+ this.name = "AccessorySpawnStepError";
6086
+ this.step = step;
6087
+ this.deviceId = deviceId;
6088
+ }
6089
+ };
6090
+ function describeError(error) {
6091
+ if (error instanceof AccessorySpawnStepError) return {
6092
+ step: error.step,
6093
+ reason: error.message.slice(error.step.length + 2)
6094
+ };
6095
+ return {
6096
+ step: "unknown",
6097
+ reason: error instanceof Error ? error.message : String(error)
6098
+ };
6099
+ }
6100
+ var AccessorySpawnRetry = class AccessorySpawnRetry {
6101
+ #logger;
6102
+ #delaysMs;
6103
+ /** Pending spawns, by `<parent>:<child stableId>`. */
6104
+ #pending = /* @__PURE__ */ new Map();
6105
+ /** Gave up — sticks until the parent is registered again. */
6106
+ #gaveUp = /* @__PURE__ */ new Set();
6107
+ constructor(options) {
6108
+ this.#logger = options.logger;
6109
+ this.#delaysMs = options.delaysMs ?? DEVICE_RESTORE_RETRY_DELAYS_MS;
6110
+ }
6111
+ static #key(parentDeviceId, stableId) {
6112
+ return `${parentDeviceId}:${stableId}`;
6113
+ }
6114
+ /** The parent went away (teardown / shutdown): drop its pending rounds and its give-ups. */
6115
+ cancelParent(parentDeviceId) {
6116
+ for (const [key, entry] of this.#pending) {
6117
+ if (entry.parentDeviceId !== parentDeviceId) continue;
6118
+ entry.cancelled = true;
6119
+ if (entry.timer !== null) clearTimeout(entry.timer);
6120
+ this.#pending.delete(key);
6121
+ }
6122
+ this.#forgetGiveUps(parentDeviceId);
6123
+ }
6124
+ /** The parent registered again: a fresh chance for children that gave up. */
6125
+ resetParent(parentDeviceId) {
6126
+ this.#forgetGiveUps(parentDeviceId);
6127
+ }
6128
+ #forgetGiveUps(parentDeviceId) {
6129
+ const prefix = `${parentDeviceId}:`;
6130
+ for (const key of this.#gaveUp) if (key.startsWith(prefix)) this.#gaveUp.delete(key);
6131
+ }
6132
+ /** Record the initial failure and run the bounded rounds in the background. */
6133
+ schedule(request) {
6134
+ const key = AccessorySpawnRetry.#key(request.parentDeviceId, request.stableId);
6135
+ if (this.#pending.has(key)) return;
6136
+ if (this.#gaveUp.has(key)) {
6137
+ this.#logger.debug("Accessory child spawn skipped — gave up earlier, parent not re-registered", {
6138
+ tags: { parentDeviceId: request.parentDeviceId },
6139
+ meta: { stableId: request.stableId }
6140
+ });
6141
+ return;
6142
+ }
6143
+ const entry = {
6144
+ parentDeviceId: request.parentDeviceId,
6145
+ cancelled: false,
6146
+ timer: null
6147
+ };
6148
+ this.#pending.set(key, entry);
6149
+ this.#record(request, request.deviceId, request.error, 0, false);
6150
+ this.#run(key, entry, request);
6151
+ }
6152
+ #record(request, deviceId, error, retry, terminal) {
6153
+ const { step, reason } = describeError(error);
6154
+ this.#logger.error(terminal ? "Accessory child spawn gave up after the bounded retries" : "Accessory child spawn failed", {
6155
+ tags: {
6156
+ ...deviceId === null ? {} : { deviceId },
6157
+ parentDeviceId: request.parentDeviceId
6158
+ },
6159
+ meta: {
6160
+ stableId: request.stableId,
6161
+ step,
6162
+ error: reason,
6163
+ retry,
6164
+ max: this.#delaysMs.length
6165
+ }
6166
+ });
6167
+ }
6168
+ async #run(key, entry, request) {
6169
+ let lastError = request.error;
6170
+ let deviceId = request.deviceId;
6171
+ for (let round = 1; round <= this.#delaysMs.length; round += 1) {
6172
+ await this.#sleep(entry, this.#delaysMs[round - 1] ?? 0);
6173
+ if (entry.cancelled) return;
6174
+ if (!request.isParentRegistered()) {
6175
+ this.#pending.delete(key);
6176
+ this.#logger.info("Accessory child spawn retry skipped — parent no longer registered", {
6177
+ tags: {
6178
+ ...deviceId === null ? {} : { deviceId },
6179
+ parentDeviceId: request.parentDeviceId
6180
+ },
6181
+ meta: {
6182
+ stableId: request.stableId,
6183
+ retry: round
6184
+ }
6185
+ });
6186
+ return;
6187
+ }
6188
+ try {
6189
+ await request.attempt({ final: round === this.#delaysMs.length });
6190
+ if (entry.cancelled) return;
6191
+ this.#pending.delete(key);
6192
+ this.#logger.info("Accessory child spawned on retry", {
6193
+ tags: {
6194
+ ...deviceId === null ? {} : { deviceId },
6195
+ parentDeviceId: request.parentDeviceId
6196
+ },
6197
+ meta: {
6198
+ stableId: request.stableId,
6199
+ retry: round
6200
+ }
6201
+ });
6202
+ return;
6203
+ } catch (err) {
6204
+ if (entry.cancelled) return;
6205
+ lastError = err;
6206
+ if (err instanceof AccessorySpawnStepError && err.deviceId !== null) deviceId = err.deviceId;
6207
+ if (round < this.#delaysMs.length) this.#record(request, deviceId, err, round, false);
6208
+ }
6209
+ }
6210
+ this.#record(request, deviceId, lastError, this.#delaysMs.length, true);
6211
+ this.#pending.delete(key);
6212
+ this.#gaveUp.add(key);
6213
+ }
6214
+ #sleep(entry, ms) {
6215
+ return new Promise((resolve) => {
6216
+ const timer = setTimeout(() => {
6217
+ entry.timer = null;
6218
+ resolve();
6219
+ }, ms);
6220
+ timer.unref?.();
6221
+ entry.timer = timer;
6222
+ });
6223
+ }
6224
+ };
6225
+ //#endregion
6057
6226
  //#region src/kernel/moleculer/runtime-state-load.ts
6058
6227
  /** A device build refused because its runtime state could not be loaded. */
6059
6228
  var RuntimeStateLoadError = class extends Error {
@@ -6634,6 +6803,10 @@ function createBrokerDeviceManagerApi(opts) {
6634
6803
  const resolveParentIntegrationId = async (parentId) => {
6635
6804
  return (await callDeviceManager(api, "loadMeta", { deviceId: parentId }).catch(() => null))?.integrationId ?? void 0;
6636
6805
  };
6806
+ const accessorySpawnRetry = new AccessorySpawnRetry({
6807
+ logger: opts.logger,
6808
+ ...opts.accessorySpawnRetryDelaysMs !== void 0 ? { delaysMs: opts.accessorySpawnRetryDelaysMs } : {}
6809
+ });
6637
6810
  /**
6638
6811
  * Spawn one accessory child device declared by a parent's
6639
6812
  * `getAccessoryChildren()`. Mirrors the standard `create()` flow
@@ -6643,9 +6816,20 @@ function createBrokerDeviceManagerApi(opts) {
6643
6816
  * row already exists, `persistInitialConfig` is skipped (config
6644
6817
  * arg empty) and the child self-hydrates from `loadConfig`.
6645
6818
  */
6646
- const spawnAccessoryChild = async (parent, spec) => {
6819
+ const spawnAccessoryChild = async (parent, spec, spawnOptions = { final: false }) => {
6647
6820
  const childStableId = `${parent.stableId}-${spec.stableIdSuffix}`;
6648
- const id = await deviceApi.allocateDeviceId(childStableId);
6821
+ let allocatedId = null;
6822
+ try {
6823
+ return await spawnAccessoryChildSteps(parent, spec, childStableId, (id) => {
6824
+ allocatedId = id;
6825
+ }, spawnOptions);
6826
+ } catch (err) {
6827
+ throw err instanceof AccessorySpawnStepError ? err : new AccessorySpawnStepError("register", allocatedId, err);
6828
+ }
6829
+ };
6830
+ const spawnAccessoryChildSteps = async (parent, spec, childStableId, onAllocated, spawnOptions) => {
6831
+ const id = await deviceApi.allocateDeviceId(childStableId).catch((err) => Promise.reject(new AccessorySpawnStepError("allocateDeviceId", null, err)));
6832
+ onAllocated(id);
6649
6833
  const existing = registry.getById(id);
6650
6834
  if (existing && existing.stableId === childStableId) return existing;
6651
6835
  const empty = {};
@@ -6662,12 +6846,17 @@ function createBrokerDeviceManagerApi(opts) {
6662
6846
  ...spec.meta.type !== void 0 ? { type: spec.meta.type } : {},
6663
6847
  ...integrationId !== void 0 ? { integrationId } : {}
6664
6848
  }).catch((err) => {
6665
- opts.logger.warn("spawnAccessoryChild: applyInitialMeta pre-seed failed", {
6849
+ if (!spawnOptions.final) return Promise.reject(new AccessorySpawnStepError("applyInitialMeta", id, err));
6850
+ opts.logger.error("Accessory child spawned WITHOUT its meta pre-seed after the last retry", {
6666
6851
  tags: {
6667
- stableId: childStableId,
6668
- deviceId: id
6852
+ deviceId: id,
6853
+ parentDeviceId: parent.id
6669
6854
  },
6670
- meta: { error: err instanceof Error ? err.message : String(err) }
6855
+ meta: {
6856
+ step: "applyInitialMeta",
6857
+ stableId: childStableId,
6858
+ error: err instanceof Error ? err.message : String(err)
6859
+ }
6671
6860
  });
6672
6861
  });
6673
6862
  if (isFirstSpawn && Object.keys(spec.config).length > 0) await callDeviceManager(api, "persistConfig", {
@@ -6675,7 +6864,7 @@ function createBrokerDeviceManagerApi(opts) {
6675
6864
  data: spec.config
6676
6865
  }).catch(() => {});
6677
6866
  const [initialRuntimeState, loadedConfig, deviceMeta] = await Promise.all([
6678
- loadRuntimeStateFor(id, childStableId, "accessory-child"),
6867
+ loadRuntimeStateFor(id, childStableId, "accessory-child").catch((err) => Promise.reject(new AccessorySpawnStepError("loadRuntimeState", id, err))),
6679
6868
  callDeviceManager(api, "loadConfig", { deviceId: id }).catch(() => empty),
6680
6869
  callDeviceManager(api, "loadMeta", { deviceId: id }).catch(() => null)
6681
6870
  ]);
@@ -6714,6 +6903,7 @@ function createBrokerDeviceManagerApi(opts) {
6714
6903
  */
6715
6904
  const teardownLocal = async (deviceId, runLifecycle) => {
6716
6905
  const device = registry.getById(deviceId);
6906
+ accessorySpawnRetry.cancelParent(deviceId);
6717
6907
  cancelProbeRetry(deviceId);
6718
6908
  if (!device) return;
6719
6909
  const children = registry.getChildren(deviceId);
@@ -6958,6 +7148,7 @@ function createBrokerDeviceManagerApi(opts) {
6958
7148
  if (!opts.capabilityRegistry) workerNativeCaps.get("device-ops")?.delete(device.id);
6959
7149
  throw err;
6960
7150
  }
7151
+ accessorySpawnRetry.resetParent(device.id);
6961
7152
  const lifecycleHost = device;
6962
7153
  const shrinkGate = new AccessoryShrinkGate();
6963
7154
  const runReconcileNow = async () => {
@@ -6995,14 +7186,14 @@ function createBrokerDeviceManagerApi(opts) {
6995
7186
  try {
6996
7187
  await spawnAccessoryChild(device, spec);
6997
7188
  } catch (err) {
6998
- opts.logger.warn("Failed to spawn accessory child", {
6999
- tags: {
7000
- parentDeviceId: device.id,
7001
- parentStableId: device.stableId
7002
- },
7003
- meta: {
7004
- stableIdSuffix: spec.stableIdSuffix,
7005
- error: err instanceof Error ? err.message : String(err)
7189
+ accessorySpawnRetry.schedule({
7190
+ deviceId: err instanceof AccessorySpawnStepError ? err.deviceId : null,
7191
+ stableId: `${device.stableId}-${spec.stableIdSuffix}`,
7192
+ parentDeviceId: device.id,
7193
+ error: err,
7194
+ isParentRegistered: () => registry.getById(device.id) !== null,
7195
+ attempt: async (attemptOptions) => {
7196
+ await spawnAccessoryChild(device, spec, attemptOptions);
7006
7197
  }
7007
7198
  });
7008
7199
  }
@@ -12504,18 +12695,35 @@ async function main() {
12504
12695
  if (deviceRestorePromises.length > 0 && !shuttingDown) await Promise.allSettled(deviceRestorePromises);
12505
12696
  refreshChildCaps("post-init", customActionRegistry.describeAll(specs.map((spec) => spec.addonId)));
12506
12697
  let hubReachableFired = false;
12507
- const fireHubReachableOnce = () => {
12698
+ const rehydrateSwitches = (first) => rehydrateSwitchesOnHubConnect(loaded, {
12699
+ fatalOnUnread: first,
12700
+ onUnread: (addonId, err) => {
12701
+ runnerLog.error(`"${addonId}" instance switches not read from the registry`, { meta: { error: errMsg(err) } });
12702
+ },
12703
+ exit: (addonId, err) => {
12704
+ console.error(`[addon-runner] "${addonId}" cannot read its instance switches: ${errMsg(err)}`);
12705
+ process.exit(1);
12706
+ }
12707
+ });
12708
+ const fireHubReachableOnce = async () => {
12508
12709
  if (hubReachableFired) return;
12509
12710
  hubReachableFired = true;
12510
- for (const entry of loaded) if (typeof entry.addon.onHubReachable === "function") Promise.resolve(entry.addon.onHubReachable()).catch((err) => {
12511
- runnerLog.error(`"${entry.addonId}" onHubReachable() threw`, { meta: { error: errMsg(err) } });
12512
- });
12711
+ await rehydrateSwitches(true);
12712
+ for (const entry of loaded) {
12713
+ if (typeof entry.addon.onHubReachable !== "function") continue;
12714
+ Promise.resolve(entry.addon.onHubReachable()).catch((err) => {
12715
+ runnerLog.error(`"${entry.addonId}" onHubReachable() threw`, { meta: { error: errMsg(err) } });
12716
+ });
12717
+ }
12513
12718
  };
12514
12719
  udsChildClient.onConnected(() => {
12515
- if (hubReachableFired) refreshChildCaps("on reconnect");
12720
+ if (hubReachableFired) {
12721
+ refreshChildCaps("on reconnect");
12722
+ rehydrateSwitches(false);
12723
+ }
12516
12724
  fireHubReachableOnce();
12517
12725
  });
12518
- fireHubReachableOnce();
12726
+ await fireHubReachableOnce();
12519
12727
  runnerLog.info(`"${nodeId}" started — ${loaded.length} addon(s) ready (UDS connected)`);
12520
12728
  process.stdout.write(`READY:${nodeId}\n`);
12521
12729
  const stopHeapWatch = startRunnerHeapWatch({
@@ -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-_gUzcZPn.js");
6
+ const require_dist = require("../../dist-CZx3IYRz.js");
7
7
  const require_settle_sources = require("../../settle-sources-Bhsy57y-.js");
8
8
  let node_crypto = require("node:crypto");
9
9
  let node_fs = require("node:fs");
@@ -1,4 +1,4 @@
1
- import { Cc as BaseAddon, Du as errMsg, Rn as addonPagesCapability, ku as EventCategory } from "../../dist-DxW5ebV-.mjs";
1
+ import { Cc as BaseAddon, Du as errMsg, Rn as addonPagesCapability, ku as EventCategory } from "../../dist-DUYpvNfO.mjs";
2
2
  import { t as settleSourcesWithTimeout } from "../../settle-sources-CDtNC8ub.mjs";
3
3
  import { createHash, randomUUID } from "node:crypto";
4
4
  import * as fs$1 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-_gUzcZPn.js");
6
+ const require_dist = require("../../dist-CZx3IYRz.js");
7
7
  const require_settle_sources = require("../../settle-sources-Bhsy57y-.js");
8
8
  let node_crypto = require("node:crypto");
9
9
  let node_fs = require("node:fs");
@@ -1,4 +1,4 @@
1
- import { Bn as addonWidgetsCapability, Cc as BaseAddon, Du as errMsg, ku as EventCategory } from "../../dist-DxW5ebV-.mjs";
1
+ import { Bn as addonWidgetsCapability, Cc as BaseAddon, Du as errMsg, ku as EventCategory } from "../../dist-DUYpvNfO.mjs";
2
2
  import { t as settleSourcesWithTimeout } from "../../settle-sources-CDtNC8ub.mjs";
3
3
  import { createHash, randomUUID } from "node:crypto";
4
4
  import * as fs$1 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-_gUzcZPn.js");
6
+ const require_dist = require("../../dist-CZx3IYRz.js");
7
7
  const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
8
8
  const require_log_redactor = require("../../log-redactor-BhIEMaG9.js");
9
9
  let node_fs = require("node:fs");
@@ -1,4 +1,4 @@
1
- import { Bi as isAlertEpisodeSeverity, Cc as BaseAddon, Du as errMsg, E as CORE_BLOCK_ADDON_PREFIX, Hn as alertEpisodePayload, Tl as defineRecordKinds, Un as alertsCapability, Vn as alertEpisodeId, bl as createEvent, ku as EventCategory, p as AlertSchema, zi as isAlertEpisodeOpen } from "../../dist-DxW5ebV-.mjs";
1
+ import { Bi as isAlertEpisodeSeverity, Cc as BaseAddon, Du as errMsg, E as CORE_BLOCK_ADDON_PREFIX, Hn as alertEpisodePayload, Tl as defineRecordKinds, Un as alertsCapability, Vn as alertEpisodeId, bl as createEvent, ku as EventCategory, p as AlertSchema, zi as isAlertEpisodeOpen } from "../../dist-DUYpvNfO.mjs";
2
2
  import { t as require_read_all_rows } from "../../read-all-rows-TaPqdWNF.mjs";
3
3
  import { a as redactLogText } from "../../log-redactor-XLDrPzOi.mjs";
4
4
  import * as fs$1 from "node:fs";
@@ -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-_gUzcZPn.js");
6
+ const require_dist = require("../../dist-CZx3IYRz.js");
7
7
  let zod = require("zod");
8
8
  //#region src/builtins/autotrack/autotrack-config.ts
9
9
  var DEFAULT_AUTOTRACK_LOOP_CONFIG = {
@@ -1,4 +1,4 @@
1
- import { Bl as isEvent, Cc as BaseAddon, Du as errMsg, Yn as bareAddonId, ht as FIRST_LEVEL_MACRO_CLASSES, io as ptzAutotrackCapability, ku as EventCategory } from "../../dist-DxW5ebV-.mjs";
1
+ import { Bl as isEvent, Cc as BaseAddon, Du as errMsg, Yn as bareAddonId, ht as FIRST_LEVEL_MACRO_CLASSES, io as ptzAutotrackCapability, ku as EventCategory } from "../../dist-DUYpvNfO.mjs";
2
2
  import { z } from "zod";
3
3
  //#region src/builtins/autotrack/autotrack-config.ts
4
4
  var DEFAULT_AUTOTRACK_LOOP_CONFIG = {
@@ -3,9 +3,9 @@ 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-_gUzcZPn.js");
6
+ const require_dist = require("../../dist-CZx3IYRz.js");
7
7
  const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
8
- const require_restore_archive = require("../../restore-archive-CUVoxsCu.js");
8
+ const require_restore_archive = require("../../restore-archive-BvvAR6Ww.js");
9
9
  let node_crypto = require("node:crypto");
10
10
  let node_fs = require("node:fs");
11
11
  node_fs = require_chunk.__toESM(node_fs);
@@ -1,6 +1,6 @@
1
- import { Cc as BaseAddon, Jn as backupCapability, Ql as nodePin, gu as toNodeId, ku as EventCategory, ss as storageOccupancyCapability, va as mayWriteToLocation } from "../../dist-DxW5ebV-.mjs";
1
+ import { Cc as BaseAddon, Jn as backupCapability, Ql as nodePin, gu as toNodeId, ku as EventCategory, ss as storageOccupancyCapability, va as mayWriteToLocation } from "../../dist-DUYpvNfO.mjs";
2
2
  import { t as require_read_all_rows } from "../../read-all-rows-TaPqdWNF.mjs";
3
- import { _ as backupRecordStoresOf, a as BackupSnapshotRefusedError, d as ENCRYPTED_BACKUP_SUFFIX, f as generateBackupKeyPair, g as backupOrchestratorRecordKinds, i as BackupCancelledError, l as BackupKeyFormatError, m as parseBackupSecretKey, n as precheckRestoreKey, o as DEFAULT_BACKUP_DATABASES, p as parseBackupPublicKey, r as prepareRestoreArchive, s as SystemBackupService } from "../../restore-archive-DWTsdq1K.mjs";
3
+ import { _ as backupRecordStoresOf, a as BackupSnapshotRefusedError, d as ENCRYPTED_BACKUP_SUFFIX, f as generateBackupKeyPair, g as backupOrchestratorRecordKinds, i as BackupCancelledError, l as BackupKeyFormatError, m as parseBackupSecretKey, n as precheckRestoreKey, o as DEFAULT_BACKUP_DATABASES, p as parseBackupPublicKey, r as prepareRestoreArchive, s as SystemBackupService } from "../../restore-archive-DH-lFUT0.mjs";
4
4
  import { randomUUID } from "node:crypto";
5
5
  import * as fs$1 from "node:fs";
6
6
  import * as path$1 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-_gUzcZPn.js");
6
+ const require_dist = require("../../dist-CZx3IYRz.js");
7
7
  const require_settle_sources = require("../../settle-sources-Bhsy57y-.js");
8
8
  let zod = require("zod");
9
9
  //#region src/builtins/calendars/calendar-color.ts
@@ -1,4 +1,4 @@
1
- import { Cc as BaseAddon, O as CalendarPreferencesSchema, Tl as defineRecordKinds, ir as calendarsCapability } from "../../dist-DxW5ebV-.mjs";
1
+ import { Cc as BaseAddon, O as CalendarPreferencesSchema, Tl as defineRecordKinds, ir as calendarsCapability } from "../../dist-DUYpvNfO.mjs";
2
2
  import { t as settleSourcesWithTimeout } from "../../settle-sources-CDtNC8ub.mjs";
3
3
  import { z } from "zod";
4
4
  //#region src/builtins/calendars/calendar-color.ts
@@ -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-_gUzcZPn.js");
6
+ const require_dist = require("../../dist-CZx3IYRz.js");
7
7
  let zod = require("zod");
8
8
  let _camstack_types_node = require("@camstack/types/node");
9
9
  let node_fs = require("node:fs");
@@ -1,4 +1,4 @@
1
- import { Ai as hostEngineDevice, B as DERIVED_CAMERA_SILENCED_CAP_NAMES, Bt as MOTION_CLOSE_AFTER_MS, Cc as BaseAddon, Du as errMsg, Et as HostedWithdrawalGate, Il as hydrateSchema, Ko as selectEngineHostedBlocks, Lr as declarationOwnerNodeId, Rs as COMPOSER_ADDON_ID, Yn as bareAddonId, ar as cameraGridLayoutCapability, bl as createEvent, br as compileHelper, ds as sweepLegacyEngineRows, ka as motionCapability, ku as EventCategory, ls as streamCatalogCapability, oa as legacySweepDone, qs as buildFfmpegArgs, ts as snapshotCapability, v as BaseDevice, wu as DeviceFeature, xa as memoizePinnedFfmpeg } from "../../dist-DxW5ebV-.mjs";
1
+ import { Ai as hostEngineDevice, B as DERIVED_CAMERA_SILENCED_CAP_NAMES, Bt as MOTION_CLOSE_AFTER_MS, Cc as BaseAddon, Du as errMsg, Et as HostedWithdrawalGate, Il as hydrateSchema, Ko as selectEngineHostedBlocks, Lr as declarationOwnerNodeId, Rs as COMPOSER_ADDON_ID, Yn as bareAddonId, ar as cameraGridLayoutCapability, bl as createEvent, br as compileHelper, ds as sweepLegacyEngineRows, ka as motionCapability, ku as EventCategory, ls as streamCatalogCapability, oa as legacySweepDone, qs as buildFfmpegArgs, ts as snapshotCapability, v as BaseDevice, wu as DeviceFeature, xa as memoizePinnedFfmpeg } from "../../dist-DUYpvNfO.mjs";
2
2
  import { z } from "zod";
3
3
  import { FfmpegProcess } from "@camstack/types/node";
4
4
  import { promises } from "node:fs";
@@ -3,11 +3,11 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-_gUzcZPn.js");
7
- const require_capture_engine = require("../../capture-engine-C6IjgNU4.js");
8
- const require_composition_sources = require("../../composition-sources-YIJB6QG7.js");
6
+ const require_dist = require("../../dist-CZx3IYRz.js");
7
+ const require_capture_engine = require("../../capture-engine-CRXUcNzg.js");
8
+ const require_composition_sources = require("../../composition-sources-CmJRQLAB.js");
9
9
  const require_retention = require("../../retention-BcOSL6b9.js");
10
- const require_rename_composition_block = require("../../rename-composition-block-ozGMTnI_.js");
10
+ const require_rename_composition_block = require("../../rename-composition-block-rKmnICiK.js");
11
11
  let zod = require("zod");
12
12
  //#region src/builtins/composer/actuator-invoke.ts
13
13
  /**
@@ -1,8 +1,8 @@
1
- import { $s as composedDeviceStableId, Ao as resolveMutate, C as COMPOSED_ITEM_FIXED_FIELDS, Cc as BaseAddon, Cr as compositionFieldKey, Di as groupTemplate, Dt as HvacModeSchema, Du as errMsg, Ei as groupCommandsCapability, Er as consumablesCapability, Eu as DeviceType, Hs as HISTORY_FAST_MS, Io as runFanOut, Ka as planComposition, Ks as MINUTE_MS, Mr as coverCapability, Ns as withDefaultRunning, Os as valveCapability, Ou as featuresOfBoundCaps, Qn as buildCapabilityLookup, Qs as composedDeviceRef, Qt as PetFountainStatusSchema, Rr as declaredSeriesKind, Rs as COMPOSER_ADDON_ID, Sr as composerCapability, Ua as petFountainCapability, Ul as isReadingQuantity, Us as HISTORY_SLOW_MS, Va as parseColorInput, Vs as DEFAULT_HISTORY_RETENTION, Wa as petFountainWaterItem, Ws as HOUR_MS, Xn as brightnessCapability, Xo as sharedActuatorMethods, Yo as sharedActuatorFeatures, Zo as sharedColorModes, Zs as cloneStatefulExpressionMemory, _c as openStatistic, _i as featureForwards, _t as FanDirectionSchema, ac as disarmRoseMemory, ai as evaluateCompositionField, ba as mediaPlayerFeaturesOfRoles, bc as statisticCadenceMs, bl as createEvent, da as lockControlCapability, dc as integrateReading, ec as compositionFeatureEnabled, fc as isEngineHostedHelper, fs as switchCapability, gc as openReset, gr as colorCapability, hc as nextLocalMidnight, hi as fanOutTargets, i as ACTUATOR_TEMPLATE_IDS, ic as createStatefulExpressionMemory, j as ConsumableItemSchema, ka as motionCapability, ku as EventCategory, lc as historyRetentionFromSettings, mc as isHistoryHelper, mi as fanControlCapability, nc as compositionSliceKey, oc as evaluateDerivative, pc as isForwardInputRef, pr as climateControlCapability, r as ACTUATOR_METHODS, rc as compositionSourceKey, s as ALL_CAPABILITY_DEFINITIONS, sc as evaluateStatistic, ta as kebabToCamel, tc as compositionItemFieldPath, to as processTimeZoneOr, tt as DeclaredDevices, ui as expressionContainsBuiltinCall, v as BaseDevice, vc as planResetTier, vr as commandedMethods, wa as methodRefusal, xc as toExpressionValue, xt as GroupCommandResultSchema, ya as mediaPlayerCapability, yc as planStatisticTier } from "../../dist-DxW5ebV-.mjs";
2
- import { i as capSeriesKey, m as parseConfirmedStateChanged, p as isRecord$4 } from "../../capture-engine-CE9QyWYX.mjs";
3
- import { n as normalizedNativeOwner } from "../../composition-sources-CsPiXLpf.mjs";
1
+ import { $s as composedDeviceStableId, Ao as resolveMutate, C as COMPOSED_ITEM_FIXED_FIELDS, Cc as BaseAddon, Cr as compositionFieldKey, Di as groupTemplate, Dt as HvacModeSchema, Du as errMsg, Ei as groupCommandsCapability, Er as consumablesCapability, Eu as DeviceType, Hs as HISTORY_FAST_MS, Io as runFanOut, Ka as planComposition, Ks as MINUTE_MS, Mr as coverCapability, Ns as withDefaultRunning, Os as valveCapability, Ou as featuresOfBoundCaps, Qn as buildCapabilityLookup, Qs as composedDeviceRef, Qt as PetFountainStatusSchema, Rr as declaredSeriesKind, Rs as COMPOSER_ADDON_ID, Sr as composerCapability, Ua as petFountainCapability, Ul as isReadingQuantity, Us as HISTORY_SLOW_MS, Va as parseColorInput, Vs as DEFAULT_HISTORY_RETENTION, Wa as petFountainWaterItem, Ws as HOUR_MS, Xn as brightnessCapability, Xo as sharedActuatorMethods, Yo as sharedActuatorFeatures, Zo as sharedColorModes, Zs as cloneStatefulExpressionMemory, _c as openStatistic, _i as featureForwards, _t as FanDirectionSchema, ac as disarmRoseMemory, ai as evaluateCompositionField, ba as mediaPlayerFeaturesOfRoles, bc as statisticCadenceMs, bl as createEvent, da as lockControlCapability, dc as integrateReading, ec as compositionFeatureEnabled, fc as isEngineHostedHelper, fs as switchCapability, gc as openReset, gr as colorCapability, hc as nextLocalMidnight, hi as fanOutTargets, i as ACTUATOR_TEMPLATE_IDS, ic as createStatefulExpressionMemory, j as ConsumableItemSchema, ka as motionCapability, ku as EventCategory, lc as historyRetentionFromSettings, mc as isHistoryHelper, mi as fanControlCapability, nc as compositionSliceKey, oc as evaluateDerivative, pc as isForwardInputRef, pr as climateControlCapability, r as ACTUATOR_METHODS, rc as compositionSourceKey, s as ALL_CAPABILITY_DEFINITIONS, sc as evaluateStatistic, ta as kebabToCamel, tc as compositionItemFieldPath, to as processTimeZoneOr, tt as DeclaredDevices, ui as expressionContainsBuiltinCall, v as BaseDevice, vc as planResetTier, vr as commandedMethods, wa as methodRefusal, xc as toExpressionValue, xt as GroupCommandResultSchema, ya as mediaPlayerCapability, yc as planStatisticTier } from "../../dist-DUYpvNfO.mjs";
2
+ import { i as capSeriesKey, m as parseConfirmedStateChanged, p as isRecord$4 } from "../../capture-engine-erwNulcY.mjs";
3
+ import { n as normalizedNativeOwner } from "../../composition-sources-DrQFzsQU.mjs";
4
4
  import { i as DAY_MS, t as DEFAULT_RETENTION } from "../../retention-CUOVI1p7.mjs";
5
- import { n as renameCompositionBlock } from "../../rename-composition-block-ONfuFbfd.mjs";
5
+ import { n as renameCompositionBlock } from "../../rename-composition-block-CowZDV1m.mjs";
6
6
  import { z } from "zod";
7
7
  //#region src/builtins/composer/actuator-invoke.ts
8
8
  /**
@@ -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-_gUzcZPn.js");
6
+ const require_dist = require("../../dist-CZx3IYRz.js");
7
7
  const require_formatter = require("../../formatter-xbxeV4GD.js");
8
8
  //#region src/builtins/console-logging/console-destination.ts
9
9
  var LEVEL_RANK = {
@@ -1,4 +1,4 @@
1
- import { Cc as BaseAddon, pa as logDestinationCapability } from "../../dist-DxW5ebV-.mjs";
1
+ import { Cc as BaseAddon, pa as logDestinationCapability } from "../../dist-DUYpvNfO.mjs";
2
2
  import { t as formatLogLine } from "../../formatter-DkYZ4LXp.mjs";
3
3
  //#region src/builtins/console-logging/console-destination.ts
4
4
  var LEVEL_RANK = {
@@ -1,10 +1,10 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_chunk = require("../../chunk-Cek0wNdY.js");
3
- const require_dist = require("../../dist-_gUzcZPn.js");
3
+ const require_dist = require("../../dist-CZx3IYRz.js");
4
4
  const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
5
- const require_capture_engine = require("../../capture-engine-C6IjgNU4.js");
6
- const require_composition_sources = require("../../composition-sources-YIJB6QG7.js");
7
- const require_rename_composition_block = require("../../rename-composition-block-ozGMTnI_.js");
5
+ const require_capture_engine = require("../../capture-engine-CRXUcNzg.js");
6
+ const require_composition_sources = require("../../composition-sources-CmJRQLAB.js");
7
+ const require_rename_composition_block = require("../../rename-composition-block-rKmnICiK.js");
8
8
  const require_prefix_range = require("../../prefix-range-D_KueXbQ.js");
9
9
  const require_prefix_walk = require("../../prefix-walk-Dv6MLZlM.js");
10
10
  const require_cap_call_scope = require("../../cap-call-scope-8eiugfLl.js");
@@ -3113,7 +3113,7 @@ var EMPTY_RUNS_VIEW = {
3113
3113
  /** The failure a trace stands for, or null when it did not fail. */
3114
3114
  function failureOf(trace) {
3115
3115
  if (trace.outcome !== "failed") return null;
3116
- return trace.steps.find((s) => s.outcome === "error")?.message ?? "the run failed";
3116
+ return trace.steps.find((s) => s.outcome === "error")?.message ?? trace.error ?? "the run failed";
3117
3117
  }
3118
3118
  var RunsLedger = class {
3119
3119
  runs;
@@ -3578,6 +3578,7 @@ var ActionsService = class {
3578
3578
  conditions: [],
3579
3579
  steps: [...steps],
3580
3580
  outcome,
3581
+ ...message !== void 0 && !steps.some((s) => s.message === message) ? { error: message } : {},
3581
3582
  repeat: 1,
3582
3583
  lastAt: endedAt
3583
3584
  };
@@ -1,8 +1,8 @@
1
- import { $a as problemsBlockSave, $o as siteFor, $s as composedDeviceStableId, $t as PowerSourceInfoSchema, A as ConditionMirror, Aa as nextOccurrence, Ar as coreBlockSourceKind, At as INTERNAL_ACTION_PREFIX, Br as defaultTagColorId, Bs as DAY_MS, Ca as mergeScalarTarget, Cc as BaseAddon, Dn as TagsFieldSchema, Dr as coreBlockAddonId, Ds as validateSchedulerInput, Du as errMsg$1, E as CORE_BLOCK_ADDON_PREFIX, En as TagStyleSchema, Eo as resolveHeroLayout, Eu as DeviceType$1, Fi as integrationInstancesCapability, Fn as actionWaitTotalMs, Go as seedInstanceOnce, Gs as HelperMemberSchema, Ii as internalActionId, Il as hydrateSchema, In as actionsCapability, Ja as powerSourceActuatorConflicts, Ji as isInternalActionId, Jl as isSecretRefOwnedBy, Js as canonicalStoredBlockTarget, Ka as planComposition, Kl as isSecretMarker, Kn as assertStepsOffered, Ln as addonIdOfActionId, Lo as runSteps, Ls as zoneOnlySite, M as CoreBlockSchema, Ma as normalizeActionUnits, Mo as resolveRemoteSource, Ms as weekdayOfLocalDate, Na as normalizeCoreBlockWrite, Oi as hasTimeLeaves, On as TemplateKindSchema, Or as coreBlockComposition, Ot as IDENTITY_LINK_KINDS, Pa as normalizeTags, Pi as instanceCodeHash, Pn as actionSourceCapability, Po as resolveStepArgs, Pr as customKeyOfRole, Qa as prepareRecipeUnits, Qn as buildCapabilityLookup, Qs as composedDeviceRef, Ra as occurrenceOn, Rs as COMPOSER_ADDON_ID, Sl as defineAddonMigrations, Ss as toTimings, T as CORE_BLOCKS_ADDON_ID, Tl as defineRecordKinds, Tn as TagNameSchema, To as resolveCoreBlockFiles, Tr as compositionUnionReads, Ts as validateComposition, Tu as DeviceRole, Ui as isBuiltinTemplateId, Ur as describeComposableCaps, Vo as schedulersCapability, Vt as MediaPlayerStatusSchema, Wn as appendTrace, Wt as NcTaggedRuleKindSchema, Xa as powerSourceLinkOfComposition, Ya as powerSourceCapability, Zn as buildActionSteps, _ as BUILTIN_REMOTE_COMPONENTS, _o as renameInTags, _s as timedRunCapability, an as REMOTE_MEDIA_COMMANDS, ao as readRecipeLiteral, bo as resolveActionVariables, bs as timedRunQuickRun, bu as vocabActionIdFor, c as ActionError, ca as localDateOf, cc as helperMembers, cn as RemoteAssumedStateSchema, cr as capUnitResolver, ct as EMPTY_AUTOMATION_STATE, cu as ruleFireOfClaim, d as ActionTargetResolver, do as reexpandAutomationInstance, ec as compositionFeatureEnabled, f as ActionVariableSchema, fa as lockDoorLinkOfComposition, fo as remoteCapability, fr as checkTemplatePayload, ft as FAN_CAPTURE_FIELDS, fu as secretTreeFromSchema, g as BUILTIN_AUTOMATION_TEMPLATES, gi as fanPresetsCapability, gl as collectSecretMarkerRefs, gn as SchedulerSchema, go as removeScalarTarget, gs as templateCapability, gt as FanControlStatusSchema, h as AutomationTemplatePayloadSchema, hn as SchedulerError, ho as removeFromTags, hr as collectWhenMirrorSources, hs as tagsCapability, il as VocabActionError, ja as nextTimeBoundaryInMs, jr as coreBlocksCapability, ki as heroLayoutCapability, kl as entryBody, kr as coreBlockIdFromAddonId, kt as IDLE_ACTION_STATUS, ku as EventCategory$1, l as ActionMinDelaySecSchema, lc as historyRetentionFromSettings, ln as RemoteLayoutPayloadSchema, lt as EMPTY_REMOTE_ASSUMED_STATE, m as AutomationStateDocSchema, mn as SWITCH_DEFAULT_OPTIONS, mo as remoteSourceSteps, mr as collectDeviceTemplates, ms as tagKey, mt as FAN_OSCILLATION_AXIS_SETTABLE, n as ACTION_TARGET_INVALIDATION_EVENTS, no as projectDeviceRow, oi as evaluateStepCondition, ol as actionEffect, oo as readStoredRemoteConfig, pi as fanAxisPath, po as remoteLayoutComponentsCapability, pt as FAN_OSCILLATION_AXES, qc as RecordIntegrationInstances, rc as compositionSourceKey, rn as QuantityUnitError, ro as proposeRunningThreshold, rr as builtinAutomationTemplate, rs as stableIdMapOf, s as ALL_CAPABILITY_DEFINITIONS, si as evaluateWhenTree, sr as canonicalStoredStepTargets, su as resolveSecretMarkers, ta as kebabToCamel, tr as buildHeroModel, tt as DeclaredDevices, u as ActionStepSchema, un as RunningStateStatusSchema, ut as EMPTY_REMOTE_CONFIG, vo as replaceRecipeLiteral, vs as timedRunLimitOf, vt as FanPresetSchema, vu as transformSecretWrite, w as COMPOSER_RUNNER_ID, wi as generateAutomationBlock, wl as defineEntryKind, wo as resolveCoreBlockEntry, wr as compositionSourceRefs, xr as compileScalarOverride, xs as timedRunSeconds, xu as vocabCall, yi as findChannelSource, yl as commandOrigin$1, yn as SetOscillationAxisInputSchema, yo as replacedFieldKeys, ys as timedRunMaxIn, z as DEFAULT_HOLD_OVERRIDE, zs as CompositionSchema } from "../../dist-DxW5ebV-.mjs";
1
+ import { $a as problemsBlockSave, $o as siteFor, $s as composedDeviceStableId, $t as PowerSourceInfoSchema, A as ConditionMirror, Aa as nextOccurrence, Ar as coreBlockSourceKind, At as INTERNAL_ACTION_PREFIX, Br as defaultTagColorId, Bs as DAY_MS, Ca as mergeScalarTarget, Cc as BaseAddon, Dn as TagsFieldSchema, Dr as coreBlockAddonId, Ds as validateSchedulerInput, Du as errMsg$1, E as CORE_BLOCK_ADDON_PREFIX, En as TagStyleSchema, Eo as resolveHeroLayout, Eu as DeviceType$1, Fi as integrationInstancesCapability, Fn as actionWaitTotalMs, Go as seedInstanceOnce, Gs as HelperMemberSchema, Ii as internalActionId, Il as hydrateSchema, In as actionsCapability, Ja as powerSourceActuatorConflicts, Ji as isInternalActionId, Jl as isSecretRefOwnedBy, Js as canonicalStoredBlockTarget, Ka as planComposition, Kl as isSecretMarker, Kn as assertStepsOffered, Ln as addonIdOfActionId, Lo as runSteps, Ls as zoneOnlySite, M as CoreBlockSchema, Ma as normalizeActionUnits, Mo as resolveRemoteSource, Ms as weekdayOfLocalDate, Na as normalizeCoreBlockWrite, Oi as hasTimeLeaves, On as TemplateKindSchema, Or as coreBlockComposition, Ot as IDENTITY_LINK_KINDS, Pa as normalizeTags, Pi as instanceCodeHash, Pn as actionSourceCapability, Po as resolveStepArgs, Pr as customKeyOfRole, Qa as prepareRecipeUnits, Qn as buildCapabilityLookup, Qs as composedDeviceRef, Ra as occurrenceOn, Rs as COMPOSER_ADDON_ID, Sl as defineAddonMigrations, Ss as toTimings, T as CORE_BLOCKS_ADDON_ID, Tl as defineRecordKinds, Tn as TagNameSchema, To as resolveCoreBlockFiles, Tr as compositionUnionReads, Ts as validateComposition, Tu as DeviceRole, Ui as isBuiltinTemplateId, Ur as describeComposableCaps, Vo as schedulersCapability, Vt as MediaPlayerStatusSchema, Wn as appendTrace, Wt as NcTaggedRuleKindSchema, Xa as powerSourceLinkOfComposition, Ya as powerSourceCapability, Zn as buildActionSteps, _ as BUILTIN_REMOTE_COMPONENTS, _o as renameInTags, _s as timedRunCapability, an as REMOTE_MEDIA_COMMANDS, ao as readRecipeLiteral, bo as resolveActionVariables, bs as timedRunQuickRun, bu as vocabActionIdFor, c as ActionError, ca as localDateOf, cc as helperMembers, cn as RemoteAssumedStateSchema, cr as capUnitResolver, ct as EMPTY_AUTOMATION_STATE, cu as ruleFireOfClaim, d as ActionTargetResolver, do as reexpandAutomationInstance, ec as compositionFeatureEnabled, f as ActionVariableSchema, fa as lockDoorLinkOfComposition, fo as remoteCapability, fr as checkTemplatePayload, ft as FAN_CAPTURE_FIELDS, fu as secretTreeFromSchema, g as BUILTIN_AUTOMATION_TEMPLATES, gi as fanPresetsCapability, gl as collectSecretMarkerRefs, gn as SchedulerSchema, go as removeScalarTarget, gs as templateCapability, gt as FanControlStatusSchema, h as AutomationTemplatePayloadSchema, hn as SchedulerError, ho as removeFromTags, hr as collectWhenMirrorSources, hs as tagsCapability, il as VocabActionError, ja as nextTimeBoundaryInMs, jr as coreBlocksCapability, ki as heroLayoutCapability, kl as entryBody, kr as coreBlockIdFromAddonId, kt as IDLE_ACTION_STATUS, ku as EventCategory$1, l as ActionMinDelaySecSchema, lc as historyRetentionFromSettings, ln as RemoteLayoutPayloadSchema, lt as EMPTY_REMOTE_ASSUMED_STATE, m as AutomationStateDocSchema, mn as SWITCH_DEFAULT_OPTIONS, mo as remoteSourceSteps, mr as collectDeviceTemplates, ms as tagKey, mt as FAN_OSCILLATION_AXIS_SETTABLE, n as ACTION_TARGET_INVALIDATION_EVENTS, no as projectDeviceRow, oi as evaluateStepCondition, ol as actionEffect, oo as readStoredRemoteConfig, pi as fanAxisPath, po as remoteLayoutComponentsCapability, pt as FAN_OSCILLATION_AXES, qc as RecordIntegrationInstances, rc as compositionSourceKey, rn as QuantityUnitError, ro as proposeRunningThreshold, rr as builtinAutomationTemplate, rs as stableIdMapOf, s as ALL_CAPABILITY_DEFINITIONS, si as evaluateWhenTree, sr as canonicalStoredStepTargets, su as resolveSecretMarkers, ta as kebabToCamel, tr as buildHeroModel, tt as DeclaredDevices, u as ActionStepSchema, un as RunningStateStatusSchema, ut as EMPTY_REMOTE_CONFIG, vo as replaceRecipeLiteral, vs as timedRunLimitOf, vt as FanPresetSchema, vu as transformSecretWrite, w as COMPOSER_RUNNER_ID, wi as generateAutomationBlock, wl as defineEntryKind, wo as resolveCoreBlockEntry, wr as compositionSourceRefs, xr as compileScalarOverride, xs as timedRunSeconds, xu as vocabCall, yi as findChannelSource, yl as commandOrigin$1, yn as SetOscillationAxisInputSchema, yo as replacedFieldKeys, ys as timedRunMaxIn, z as DEFAULT_HOLD_OVERRIDE, zs as CompositionSchema } from "../../dist-DUYpvNfO.mjs";
2
2
  import { t as require_read_all_rows } from "../../read-all-rows-TaPqdWNF.mjs";
3
- import { i as capSeriesKey, m as parseConfirmedStateChanged, p as isRecord$1 } from "../../capture-engine-CE9QyWYX.mjs";
4
- import { t as describeCompositionSources } from "../../composition-sources-CsPiXLpf.mjs";
5
- import { t as composedBlockIdOf } from "../../rename-composition-block-ONfuFbfd.mjs";
3
+ import { i as capSeriesKey, m as parseConfirmedStateChanged, p as isRecord$1 } from "../../capture-engine-erwNulcY.mjs";
4
+ import { t as describeCompositionSources } from "../../composition-sources-DrQFzsQU.mjs";
5
+ import { t as composedBlockIdOf } from "../../rename-composition-block-CowZDV1m.mjs";
6
6
  import { t as prefixRange } from "../../prefix-range-Dl0znowN.mjs";
7
7
  import { n as unwrapStoredValue, t as loadPrefixed } from "../../prefix-walk-DAOBSyH1.mjs";
8
8
  import { n as readCurrentCommandOrigin } from "../../cap-call-scope-Bic6Ekfw.mjs";
@@ -3107,7 +3107,7 @@ var EMPTY_RUNS_VIEW = {
3107
3107
  /** The failure a trace stands for, or null when it did not fail. */
3108
3108
  function failureOf(trace) {
3109
3109
  if (trace.outcome !== "failed") return null;
3110
- return trace.steps.find((s) => s.outcome === "error")?.message ?? "the run failed";
3110
+ return trace.steps.find((s) => s.outcome === "error")?.message ?? trace.error ?? "the run failed";
3111
3111
  }
3112
3112
  var RunsLedger = class {
3113
3113
  runs;
@@ -3572,6 +3572,7 @@ var ActionsService = class {
3572
3572
  conditions: [],
3573
3573
  steps: [...steps],
3574
3574
  outcome,
3575
+ ...message !== void 0 && !steps.some((s) => s.message === message) ? { error: message } : {},
3575
3576
  repeat: 1,
3576
3577
  lastAt: endedAt
3577
3578
  };
@@ -3,8 +3,8 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-_gUzcZPn.js");
7
- const require_capture_engine = require("../../capture-engine-C6IjgNU4.js");
6
+ const require_dist = require("../../dist-CZx3IYRz.js");
7
+ const require_capture_engine = require("../../capture-engine-CRXUcNzg.js");
8
8
  const require_retention = require("../../retention-BcOSL6b9.js");
9
9
  let node_crypto = require("node:crypto");
10
10
  //#region src/builtins/device-history/capture/point-writer.ts
@@ -1,5 +1,5 @@
1
- import { Ac as DeviceTransitionSchema, Cc as BaseAddon, Ct as HISTORY_ITEM_CATALOG, Eu as DeviceType, Fl as historyUnitFor, Gn as armRemovalReconcile, H as DEVICE_HISTORY_ENERGY_KEY, Ol as emitReadiness, Pc as InvalidRecordError, Sc as wattMillisecondsToKwh, St as HISTORY_CATALOG, Tl as defineRecordKinds, Ul as isReadingQuantity, Xc as RecordTooLargeError, Xr as deviceRemovalHookCapability, Zr as deviceRunsCapability, it as DeviceRunSchema, ku as EventCategory, qr as deviceHistoryCapability, ti as deviceTransitionsCapability } from "../../dist-DxW5ebV-.mjs";
2
- import { a as catalogMetrics, c as DeviceDirectory, d as identityOf, f as subjectIdOf, i as capSeriesKey, l as isRealDeviceType, m as parseConfirmedStateChanged, n as CaptureEngine, o as readPath, r as capItemSeriesKey, s as readUnit, t as CAP_KEY_PREFIX, u as SeriesRegistry } from "../../capture-engine-CE9QyWYX.mjs";
1
+ import { Ac as DeviceTransitionSchema, Cc as BaseAddon, Ct as HISTORY_ITEM_CATALOG, Eu as DeviceType, Fl as historyUnitFor, Gn as armRemovalReconcile, H as DEVICE_HISTORY_ENERGY_KEY, Ol as emitReadiness, Pc as InvalidRecordError, Sc as wattMillisecondsToKwh, St as HISTORY_CATALOG, Tl as defineRecordKinds, Ul as isReadingQuantity, Xc as RecordTooLargeError, Xr as deviceRemovalHookCapability, Zr as deviceRunsCapability, it as DeviceRunSchema, ku as EventCategory, qr as deviceHistoryCapability, ti as deviceTransitionsCapability } from "../../dist-DUYpvNfO.mjs";
2
+ import { a as catalogMetrics, c as DeviceDirectory, d as identityOf, f as subjectIdOf, i as capSeriesKey, l as isRealDeviceType, m as parseConfirmedStateChanged, n as CaptureEngine, o as readPath, r as capItemSeriesKey, s as readUnit, t as CAP_KEY_PREFIX, u as SeriesRegistry } from "../../capture-engine-erwNulcY.mjs";
3
3
  import { a as FIVE_MINUTES_MS, c as bucketEndOf, i as DAY_MS, l as bucketStartOf, n as RetentionJob, o as HOUR_MS, r as DepartureTracker, s as ROLLUP_GRACE_MS, t as DEFAULT_RETENTION, u as floorTo } from "../../retention-CUOVI1p7.mjs";
4
4
  import { randomUUID } from "node:crypto";
5
5
  //#region src/builtins/device-history/capture/point-writer.ts