@camstack/system 1.2.94 → 1.2.96

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 (50) hide show
  1. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  2. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  3. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  4. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  5. package/dist/builtins/alerts/alerts.addon.js +1 -1
  6. package/dist/builtins/alerts/alerts.addon.mjs +1 -1
  7. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +1 -1
  8. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +1 -1
  9. package/dist/builtins/console-logging/index.js +1 -1
  10. package/dist/builtins/console-logging/index.mjs +1 -1
  11. package/dist/builtins/core-blocks/core-blocks.addon.js +1 -1
  12. package/dist/builtins/core-blocks/core-blocks.addon.mjs +1 -1
  13. package/dist/builtins/device-manager/device-manager.addon.js +1 -1
  14. package/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
  15. package/dist/builtins/doorbell/virtual-doorbell.addon.js +1 -1
  16. package/dist/builtins/doorbell/virtual-doorbell.addon.mjs +1 -1
  17. package/dist/builtins/hub-forwarder/index.js +1 -1
  18. package/dist/builtins/hub-forwarder/index.mjs +1 -1
  19. package/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  20. package/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  21. package/dist/builtins/local-auth/local-auth.addon.js +1 -1
  22. package/dist/builtins/local-auth/local-auth.addon.mjs +1 -1
  23. package/dist/builtins/local-network/local-network.addon.js +1 -1
  24. package/dist/builtins/local-network/local-network.addon.mjs +1 -1
  25. package/dist/builtins/loki-logging/index.js +1 -1
  26. package/dist/builtins/loki-logging/index.mjs +1 -1
  27. package/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  28. package/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  29. package/dist/builtins/platform-probe/index.js +1 -1
  30. package/dist/builtins/platform-probe/index.mjs +1 -1
  31. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  32. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  33. package/dist/builtins/snapshot/index.js +92 -23
  34. package/dist/builtins/snapshot/index.mjs +92 -23
  35. package/dist/builtins/snapshot/snapshot.addon.d.ts +27 -8
  36. package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  37. package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  38. package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +1 -1
  39. package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +1 -1
  40. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  41. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  42. package/dist/builtins/system-config/system-config.addon.js +1 -1
  43. package/dist/builtins/system-config/system-config.addon.mjs +1 -1
  44. package/dist/builtins/winston-logging/index.js +1 -1
  45. package/dist/builtins/winston-logging/index.mjs +1 -1
  46. package/dist/{dist-BspfS8Q7.js → dist-BQoU9nGS.js} +10 -1
  47. package/dist/{dist-COd223t-.mjs → dist-hKJyHgFg.mjs} +10 -1
  48. package/dist/index.js +1 -1
  49. package/dist/index.mjs +1 -1
  50. package/package.json +1 -1
@@ -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-BspfS8Q7.js");
6
+ const require_dist = require("../../dist-BQoU9nGS.js");
7
7
  const require_settle_sources = require("../../settle-sources-Bhsy57y-.js");
8
8
  let node_crypto = require("node:crypto");
9
9
  let node_path = require("node:path");
@@ -1,4 +1,4 @@
1
- import { Gt as EventCategory, v as addonPagesCapability, vt as errMsg, yt as BaseAddon } from "../../dist-COd223t-.mjs";
1
+ import { Gt as EventCategory, v as addonPagesCapability, vt as errMsg, yt as BaseAddon } from "../../dist-hKJyHgFg.mjs";
2
2
  import { t as settleSourcesWithTimeout } from "../../settle-sources-CDtNC8ub.mjs";
3
3
  import { createHash, randomUUID } from "node:crypto";
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-BspfS8Q7.js");
6
+ const require_dist = require("../../dist-BQoU9nGS.js");
7
7
  const require_settle_sources = require("../../settle-sources-Bhsy57y-.js");
8
8
  let node_crypto = require("node:crypto");
9
9
  let node_path = require("node:path");
@@ -1,4 +1,4 @@
1
- import { Gt as EventCategory, b as addonWidgetsCapability, vt as errMsg, yt as BaseAddon } from "../../dist-COd223t-.mjs";
1
+ import { Gt as EventCategory, b as addonWidgetsCapability, vt as errMsg, yt as BaseAddon } from "../../dist-hKJyHgFg.mjs";
2
2
  import { t as settleSourcesWithTimeout } from "../../settle-sources-CDtNC8ub.mjs";
3
3
  import { createHash, randomUUID } from "node:crypto";
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
  require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-BspfS8Q7.js");
6
+ const require_dist = require("../../dist-BQoU9nGS.js");
7
7
  //#region src/builtins/alerts/prune-policy.ts
8
8
  /**
9
9
  * Ids older than `cutoffMs`, oldest first.
@@ -1,4 +1,4 @@
1
- import { Gt as EventCategory, Mt as createEvent, n as AlertSchema, vt as errMsg, x as alertsCapability, yt as BaseAddon } from "../../dist-COd223t-.mjs";
1
+ import { Gt as EventCategory, Mt as createEvent, n as AlertSchema, vt as errMsg, x as alertsCapability, yt as BaseAddon } from "../../dist-hKJyHgFg.mjs";
2
2
  //#region src/builtins/alerts/prune-policy.ts
3
3
  /**
4
4
  * Ids older than `cutoffMs`, oldest first.
@@ -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-BspfS8Q7.js");
6
+ const require_dist = require("../../dist-BQoU9nGS.js");
7
7
  let node_crypto = require("node:crypto");
8
8
  let buffer = require("buffer");
9
9
  let node_fs_promises = require("node:fs/promises");
@@ -1,4 +1,4 @@
1
- import { C as backupCapability, Gt as EventCategory, yt as BaseAddon } from "../../dist-COd223t-.mjs";
1
+ import { C as backupCapability, Gt as EventCategory, yt as BaseAddon } from "../../dist-hKJyHgFg.mjs";
2
2
  import { randomBytes, randomUUID } from "node:crypto";
3
3
  import { Buffer as Buffer$1 } from "buffer";
4
4
  import * as fsp from "node:fs/promises";
@@ -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-BspfS8Q7.js");
6
+ const require_dist = require("../../dist-BQoU9nGS.js");
7
7
  const require_formatter = require("../../formatter-DqAKDlvN.js");
8
8
  //#region src/builtins/console-logging/console-destination.ts
9
9
  var LEVEL_RANK = {
@@ -1,4 +1,4 @@
1
- import { X as logDestinationCapability, yt as BaseAddon } from "../../dist-COd223t-.mjs";
1
+ import { X as logDestinationCapability, yt as BaseAddon } from "../../dist-hKJyHgFg.mjs";
2
2
  import { t as formatLogLine } from "../../formatter-B7qW8bPJ.mjs";
3
3
  //#region src/builtins/console-logging/console-destination.ts
4
4
  var LEVEL_RANK = {
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_chunk = require("../../chunk-Cek0wNdY.js");
3
- const require_dist = require("../../dist-BspfS8Q7.js");
3
+ const require_dist = require("../../dist-BQoU9nGS.js");
4
4
  let node_crypto = require("node:crypto");
5
5
  let node_fs_promises = require("node:fs/promises");
6
6
  node_fs_promises = require_chunk.__toESM(node_fs_promises);
@@ -1,4 +1,4 @@
1
- import { D as coreBlockAddonId, O as coreBlockIdFromAddonId, c as CoreBlockSchema, k as coreBlocksCapability, l as DeclaredDevices, o as CORE_BLOCKS_ADDON_ID, s as CORE_BLOCK_ADDON_PREFIX, vt as errMsg, yt as BaseAddon } from "../../dist-COd223t-.mjs";
1
+ import { D as coreBlockAddonId, O as coreBlockIdFromAddonId, c as CoreBlockSchema, k as coreBlocksCapability, l as DeclaredDevices, o as CORE_BLOCKS_ADDON_ID, s as CORE_BLOCK_ADDON_PREFIX, vt as errMsg, yt as BaseAddon } from "../../dist-hKJyHgFg.mjs";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import * as fs 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
  require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-BspfS8Q7.js");
6
+ const require_dist = require("../../dist-BQoU9nGS.js");
7
7
  let node_crypto = require("node:crypto");
8
8
  let _camstack_types_node = require("@camstack/types/node");
9
9
  //#region src/builtins/device-manager/adoption-job-engine.ts
@@ -1,4 +1,4 @@
1
- import { Ct as DeviceFeature, E as buildStreamParamsConfigSchema, F as deviceStatusCapability, Gt as EventCategory, Lt as isDeviceConfigCap, N as deviceManagerCapability, Ot as WELL_KNOWN_TAB_MAP, P as deviceStateCapability, R as enumerateItemArrayFields, Tt as DeviceType, Wt as sleep, a as CAP_NAMES_WITH_STATUS, at as runtimeStatePolicyFor, et as normalizeUnit, nt as parseStreamParamsFormPatch, p as STREAM_PROFILE_META, t as ALL_CAPABILITY_DEFINITIONS, u as DeviceStatusSchema, vt as errMsg, wt as DeviceRole, yt as BaseAddon, z as enumerateSchemaFields } from "../../dist-COd223t-.mjs";
1
+ import { Ct as DeviceFeature, E as buildStreamParamsConfigSchema, F as deviceStatusCapability, Gt as EventCategory, Lt as isDeviceConfigCap, N as deviceManagerCapability, Ot as WELL_KNOWN_TAB_MAP, P as deviceStateCapability, R as enumerateItemArrayFields, Tt as DeviceType, Wt as sleep, a as CAP_NAMES_WITH_STATUS, at as runtimeStatePolicyFor, et as normalizeUnit, nt as parseStreamParamsFormPatch, p as STREAM_PROFILE_META, t as ALL_CAPABILITY_DEFINITIONS, u as DeviceStatusSchema, vt as errMsg, wt as DeviceRole, yt as BaseAddon, z as enumerateSchemaFields } from "../../dist-hKJyHgFg.mjs";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import { canonicalDeviceFingerprint } from "@camstack/types/node";
4
4
  //#region src/builtins/device-manager/adoption-job-engine.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-BspfS8Q7.js");
6
+ const require_dist = require("../../dist-BQoU9nGS.js");
7
7
  //#region src/builtins/doorbell/trigger-engine.ts
8
8
  /**
9
9
  * Pure trigger logic for the virtual-doorbell builtin — edge detection over
@@ -1,4 +1,4 @@
1
- import { G as isSameAddonId, Gt as EventCategory, I as doorbellCapability, Mt as createEvent, Tt as DeviceType, vt as errMsg, w as bareAddonId, yt as BaseAddon } from "../../dist-COd223t-.mjs";
1
+ import { G as isSameAddonId, Gt as EventCategory, I as doorbellCapability, Mt as createEvent, Tt as DeviceType, vt as errMsg, w as bareAddonId, yt as BaseAddon } from "../../dist-hKJyHgFg.mjs";
2
2
  //#region src/builtins/doorbell/trigger-engine.ts
3
3
  /**
4
4
  * Pure trigger logic for the virtual-doorbell builtin — edge detection over
@@ -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-BspfS8Q7.js");
6
+ const require_dist = require("../../dist-BQoU9nGS.js");
7
7
  const require_formatter = require("../../formatter-DqAKDlvN.js");
8
8
  //#region src/builtins/hub-forwarder/hub-forwarder-destination.ts
9
9
  var DEFAULT_OUTBOUND_BUFFER_SIZE = 500;
@@ -1,4 +1,4 @@
1
- import { X as logDestinationCapability, yt as BaseAddon } from "../../dist-COd223t-.mjs";
1
+ import { X as logDestinationCapability, yt as BaseAddon } from "../../dist-hKJyHgFg.mjs";
2
2
  import { t as formatLogLine } from "../../formatter-B7qW8bPJ.mjs";
3
3
  //#region src/builtins/hub-forwarder/hub-forwarder-destination.ts
4
4
  var DEFAULT_OUTBOUND_BUFFER_SIZE = 500;
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  require("../../chunk-Cek0wNdY.js");
3
- const require_dist = require("../../dist-BspfS8Q7.js");
3
+ const require_dist = require("../../dist-BQoU9nGS.js");
4
4
  //#region src/builtins/liveness-monitor/liveness-checks.ts
5
5
  var NO_DEVICES = "liveness:no-devices";
6
6
  var ALL_OFFLINE = "liveness:all-devices-offline";
@@ -1,4 +1,4 @@
1
- import { Gt as EventCategory, Mt as createEvent, vt as errMsg, yt as BaseAddon } from "../../dist-COd223t-.mjs";
1
+ import { Gt as EventCategory, Mt as createEvent, vt as errMsg, yt as BaseAddon } from "../../dist-hKJyHgFg.mjs";
2
2
  //#region src/builtins/liveness-monitor/liveness-checks.ts
3
3
  var NO_DEVICES = "liveness:no-devices";
4
4
  var ALL_OFFLINE = "liveness:all-devices-offline";
@@ -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-BspfS8Q7.js");
6
+ const require_dist = require("../../dist-BQoU9nGS.js");
7
7
  let node_crypto = require("node:crypto");
8
8
  node_crypto = require_chunk.__toESM(node_crypto);
9
9
  let crypto$1 = require("crypto");
@@ -1,5 +1,5 @@
1
1
  import { i as __require, o as __toESM, t as __commonJSMin } from "../../chunk-CNf5ZN-e.mjs";
2
- import { S as authProviderCapability, _ as UserRecordSchema, ht as userManagementCapability, m as ScopedTokenSchema, r as ApiKeyRecordSchema, yt as BaseAddon } from "../../dist-COd223t-.mjs";
2
+ import { S as authProviderCapability, _ as UserRecordSchema, ht as userManagementCapability, m as ScopedTokenSchema, r as ApiKeyRecordSchema, yt as BaseAddon } from "../../dist-hKJyHgFg.mjs";
3
3
  import * as crypto$2 from "node:crypto";
4
4
  import { createHash, randomUUID, timingSafeEqual } from "node:crypto";
5
5
  import nodeCrypto from "crypto";
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_chunk = require("../../chunk-Cek0wNdY.js");
3
- const require_dist = require("../../dist-BspfS8Q7.js");
3
+ const require_dist = require("../../dist-BQoU9nGS.js");
4
4
  let node_os = require("node:os");
5
5
  node_os = require_chunk.__toESM(node_os);
6
6
  //#region src/builtins/local-network/local-network.addon.ts
@@ -1,4 +1,4 @@
1
- import { Gt as EventCategory, Y as localNetworkCapability, yt as BaseAddon } from "../../dist-COd223t-.mjs";
1
+ import { Gt as EventCategory, Y as localNetworkCapability, yt as BaseAddon } from "../../dist-hKJyHgFg.mjs";
2
2
  import * as os from "node:os";
3
3
  //#region src/builtins/local-network/local-network.addon.ts
4
4
  /**
@@ -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-BspfS8Q7.js");
6
+ const require_dist = require("../../dist-BQoU9nGS.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 { X as logDestinationCapability, yt as BaseAddon } from "../../dist-COd223t-.mjs";
1
+ import { X as logDestinationCapability, yt as BaseAddon } from "../../dist-hKJyHgFg.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-BspfS8Q7.js");
6
+ const require_dist = require("../../dist-BQoU9nGS.js");
7
7
  let node_child_process = require("node:child_process");
8
8
  let node_util = require("node:util");
9
9
  let node_os = require("node:os");
@@ -1,4 +1,4 @@
1
- import { $ as metricsProviderCapability, Gt as EventCategory, Mt as createEvent, yt as BaseAddon } from "../../dist-COd223t-.mjs";
1
+ import { $ as metricsProviderCapability, Gt as EventCategory, Mt as createEvent, yt as BaseAddon } from "../../dist-hKJyHgFg.mjs";
2
2
  import { execFile, execFileSync } from "node:child_process";
3
3
  import { promisify } from "node:util";
4
4
  import * as os from "node:os";
@@ -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-BspfS8Q7.js");
6
+ const require_dist = require("../../dist-BQoU9nGS.js");
7
7
  let node_child_process = require("node:child_process");
8
8
  let node_util = require("node:util");
9
9
  let node_os = require("node:os");
@@ -1,5 +1,5 @@
1
1
  import { o as __toESM } from "../../chunk-CNf5ZN-e.mjs";
2
- import { Gt as EventCategory, L as enumerateInferenceDevices, Pt as emitReadiness, ct as scoreRuntimes, rt as platformProbeCapability, vt as errMsg, yt as BaseAddon } from "../../dist-COd223t-.mjs";
2
+ import { Gt as EventCategory, L as enumerateInferenceDevices, Pt as emitReadiness, ct as scoreRuntimes, rt as platformProbeCapability, vt as errMsg, yt as BaseAddon } from "../../dist-hKJyHgFg.mjs";
3
3
  import { execFile } from "node:child_process";
4
4
  import { promisify } from "node:util";
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-BspfS8Q7.js");
6
+ const require_dist = require("../../dist-BQoU9nGS.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 { Gt as EventCategory, yt as BaseAddon } from "../../dist-COd223t-.mjs";
1
+ import { Gt as EventCategory, yt as BaseAddon } from "../../dist-hKJyHgFg.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-BspfS8Q7.js");
6
+ const require_dist = require("../../dist-BQoU9nGS.js");
7
7
  let zod = require("zod");
8
8
  let node_crypto = require("node:crypto");
9
9
  let _camstack_types_node = require("@camstack/types/node");
@@ -823,11 +823,34 @@ var LINK_MINT_DEADLINE_MS = 2500;
823
823
  var LINK_BATCH_WAIT_MS = 750;
824
824
  /** Frames older than this are never represented as current by the Viewer. */
825
825
  var LINK_CURRENT_MAX_AGE_MS = 15e3;
826
+ /**
827
+ * Memo TTL for the per-device `deviceManager.getDevice` lookup.
828
+ *
829
+ * Every serve decision — each `getSnapshotLinks` target, each media-plane GET,
830
+ * each conditional-GET peek — used to pay this cross-process round trip (plus
831
+ * the battery-slice one) before it could even look at the cache: 21-target
832
+ * grids paid 42 UDS calls per 5 s poll, on top of the captures themselves
833
+ * (live hub, 2026-08-15). Registry facts (name/type/disabled/online/features)
834
+ * change on operator action or provider reconnect, not mid-second, so ten
835
+ * seconds of staleness is invisible next to the poll cadence — and every
836
+ * lifecycle event that changes one of those fields evicts the entry
837
+ * immediately (see the `device.*` subscriptions in `onInitialize`).
838
+ *
839
+ * The BATTERY SLICE is deliberately NOT memoized: sleep/wake transitions must
840
+ * be reactive (a camera that just fell asleep must not be dialed — the
841
+ * Baichuan wake-on-login incident), and `waking` is already live from the
842
+ * in-memory `wakingDevices` map.
843
+ */
844
+ var DEVICE_META_MEMO_MS = 1e4;
826
845
  /** Wake-on-play's 8 s firmware wait + 20 s broker settle, with scheduling
827
846
  * slack. A lost completion event must not leave a camera "Waking" forever. */
828
847
  var SNAPSHOT_WAKING_TTL_MS = 35e3;
829
- /** Default cache window for non-battery cams (seconds). 10s feels live. */
830
- var NON_BATTERY_DEFAULT_MAX_AGE_S = 10;
848
+ /** Default cache window for non-battery cams (seconds). Matches the Viewer's
849
+ * 15 s currency contract (`LINK_CURRENT_MAX_AGE_MS`): a frame younger than
850
+ * that is presented as current, so re-capturing INSIDE the window bought
851
+ * nothing the client would show — under the 5 s links poll it made every
852
+ * other poll recapture the whole fleet through the 6-permit grab pools. */
853
+ var NON_BATTERY_DEFAULT_MAX_AGE_S = 15;
831
854
  /** Default cache window for battery cams (seconds). 1h ≈ "don't wake the cam unless asked". */
832
855
  var BATTERY_DEFAULT_MAX_AGE_S = 3600;
833
856
  /**
@@ -879,6 +902,15 @@ var SnapshotAddon = class SnapshotAddon extends require_dist.BaseAddon {
879
902
  /** Devices inside the explicit battery wake-in-progress window. */
880
903
  wakingDevices = /* @__PURE__ */ new Map();
881
904
  /**
905
+ * Short-TTL memo for `lookupDeviceMeta` (see {@link DEVICE_META_MEMO_MS}).
906
+ * The PROMISE is stored (not the resolved value), so a burst of concurrent
907
+ * callers — a links batch plus the image fetches it mints — joins one
908
+ * in-flight lookup instead of stampeding `deviceManager.getDevice`.
909
+ * `fetchDeviceMeta` never rejects (failure → null), so a settled rejection
910
+ * can never be served from the memo.
911
+ */
912
+ deviceMetaMemo = /* @__PURE__ */ new Map();
913
+ /**
882
914
  * De-dupes concurrent captures per `${deviceId}:${streamId}` and holds a
883
915
  * settled SUCCESS for COALESCE_MS so a grid-mount burst (and a row of refresh
884
916
  * buttons) collapses into one capture instead of one dial per tile.
@@ -949,6 +981,17 @@ var SnapshotAddon = class SnapshotAddon extends require_dist.BaseAddon {
949
981
  const deviceId = event.data.deviceId;
950
982
  if (typeof deviceId === "number") this.evictRemovedDevice(deviceId, "device-unregistered");
951
983
  });
984
+ const dropMetaMemo = (data) => {
985
+ const deviceId = data?.deviceId;
986
+ if (typeof deviceId === "number") this.deviceMetaMemo.delete(deviceId);
987
+ };
988
+ this.subscribe({ category: require_dist.EventCategory.DeviceRegistered }, (event) => dropMetaMemo(event.data));
989
+ this.subscribe({ category: require_dist.EventCategory.DeviceEnabled }, (event) => dropMetaMemo(event.data));
990
+ this.subscribe({ category: require_dist.EventCategory.DeviceDisabled }, (event) => dropMetaMemo(event.data));
991
+ this.subscribe({ category: require_dist.EventCategory.DeviceMetaChanged }, (event) => dropMetaMemo(event.data));
992
+ this.subscribe({ category: require_dist.EventCategory.DeviceOnline }, (event) => dropMetaMemo(event.data));
993
+ this.subscribe({ category: require_dist.EventCategory.DeviceOffline }, (event) => dropMetaMemo(event.data));
994
+ this.subscribe({ category: require_dist.EventCategory.DeviceBindingsChanged }, (event) => dropMetaMemo(event.data));
952
995
  this.subscribe({ category: require_dist.EventCategory.BatteryOnWakeStarted }, (event) => {
953
996
  this.wakingDevices.set(event.data.deviceId, Date.now());
954
997
  });
@@ -1155,11 +1198,11 @@ var SnapshotAddon = class SnapshotAddon extends require_dist.BaseAddon {
1155
1198
  const expMs = snapshotLinkExpiry(Date.now(), SNAPSHOT_LINK_TTL_MS);
1156
1199
  const served = this.linkDataPlane !== null && secret !== null;
1157
1200
  const prefix = this.linkRoutePrefix();
1158
- const sleepingByDevice = /* @__PURE__ */ new Map();
1201
+ const stateByDevice = /* @__PURE__ */ new Map();
1159
1202
  const refreshes = input.targets.map(async (target) => {
1160
- const sleeping = await this.isSleepingBatteryDevice(target.deviceId);
1161
- sleepingByDevice.set(target.deviceId, sleeping);
1162
- if (!sleeping) await this.awaitFreshEnough(target.deviceId);
1203
+ const state = await this.snapshotStateForLink(target.deviceId);
1204
+ stateByDevice.set(target.deviceId, state);
1205
+ if (state.reason === void 0) await this.awaitFreshEnough(target.deviceId);
1163
1206
  });
1164
1207
  await raceForResult(Promise.allSettled(refreshes), LINK_BATCH_WAIT_MS);
1165
1208
  const rows = input.targets.map((target) => {
@@ -1182,7 +1225,8 @@ var SnapshotAddon = class SnapshotAddon extends require_dist.BaseAddon {
1182
1225
  expiresAt: served ? expMs : null,
1183
1226
  width: width ?? null,
1184
1227
  neverCaptured: capturedAt === null,
1185
- sleeping: sleepingByDevice.get(deviceId) ?? false
1228
+ sleeping: stateByDevice.get(deviceId)?.reason === "sleeping",
1229
+ stateReason: stateByDevice.get(deviceId)?.reason ?? null
1186
1230
  };
1187
1231
  });
1188
1232
  this.ctx.logger.debug("snapshot: minted links", { meta: {
@@ -1216,14 +1260,18 @@ var SnapshotAddon = class SnapshotAddon extends require_dist.BaseAddon {
1216
1260
  }
1217
1261
  });
1218
1262
  }
1219
- /** True only for a battery device that must not be snapshot-refreshed. */
1220
- async isSleepingBatteryDevice(deviceId) {
1263
+ /** Resolve the state advertised by a minted link before deciding whether a
1264
+ * background capture is allowed. */
1265
+ async snapshotStateForLink(deviceId) {
1221
1266
  try {
1222
1267
  const meta = await this.lookupDeviceMeta(deviceId);
1223
- const state = await this.resolveSnapshotState(deviceId, meta);
1224
- return state.reason === "sleeping" || state.reason === "unreachable" || state.reason === "waking";
1225
- } catch {
1226
- return false;
1268
+ return await this.resolveSnapshotState(deviceId, meta);
1269
+ } catch (err) {
1270
+ this.ctx.logger.debug("snapshot: link state resolution failed", {
1271
+ tags: { deviceId },
1272
+ meta: { error: require_dist.errMsg(err) }
1273
+ });
1274
+ return { isBattery: false };
1227
1275
  }
1228
1276
  }
1229
1277
  /**
@@ -1240,7 +1288,7 @@ var SnapshotAddon = class SnapshotAddon extends require_dist.BaseAddon {
1240
1288
  deviceId,
1241
1289
  ...streamId !== void 0 ? { streamId } : {},
1242
1290
  force
1243
- }, 0, Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY, resolutionMeta);
1291
+ }, 0, Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY, resolutionMeta, 0);
1244
1292
  if (!image) return null;
1245
1293
  const capturedAt = this.cache.get(deviceId, streamId)?.ts ?? Date.now();
1246
1294
  const prefs = await this.readDeviceSettings(deviceId).catch(() => ({}));
@@ -1345,6 +1393,7 @@ var SnapshotAddon = class SnapshotAddon extends require_dist.BaseAddon {
1345
1393
  this.variants.clear();
1346
1394
  this.stateFrames.clear();
1347
1395
  this.wakingDevices.clear();
1396
+ this.deviceMetaMemo.clear();
1348
1397
  this.captureFlight.clear();
1349
1398
  this.ownerCache = null;
1350
1399
  }
@@ -1377,7 +1426,7 @@ var SnapshotAddon = class SnapshotAddon extends require_dist.BaseAddon {
1377
1426
  })]
1378
1427
  }] });
1379
1428
  }
1380
- async getSnapshot(input, minimumCaptureWaitMs = 0, maximumCacheAgeMs = Number.POSITIVE_INFINITY, maximumCaptureWaitMs = Number.POSITIVE_INFINITY, resolutionMeta) {
1429
+ async getSnapshot(input, minimumCaptureWaitMs = 0, maximumCacheAgeMs = Number.POSITIVE_INFINITY, maximumCaptureWaitMs = Number.POSITIVE_INFINITY, resolutionMeta, staleWaitCapMs = Number.POSITIVE_INFINITY) {
1381
1430
  const { deviceId } = input;
1382
1431
  const force = input.force === true;
1383
1432
  const meta = await this.lookupDeviceMeta(deviceId);
@@ -1440,7 +1489,8 @@ var SnapshotAddon = class SnapshotAddon extends require_dist.BaseAddon {
1440
1489
  log
1441
1490
  }));
1442
1491
  flight.catch(() => void 0);
1443
- const raced = await raceForResult(flight, Math.min(Math.max(decision.waitMs, minimumCaptureWaitMs), maximumCaptureWaitMs));
1492
+ const waitMs = !force && decision.staleFallback && hit !== void 0 ? Math.min(decision.waitMs, staleWaitCapMs) : decision.waitMs;
1493
+ const raced = await raceForResult(flight, Math.min(Math.max(waitMs, minimumCaptureWaitMs), maximumCaptureWaitMs));
1444
1494
  if (raced.settled) try {
1445
1495
  const resolved = await this.resolveOutcome(raced.value, deviceId, hit, log);
1446
1496
  if (resolved !== null) return resolved;
@@ -1740,6 +1790,7 @@ var SnapshotAddon = class SnapshotAddon extends require_dist.BaseAddon {
1740
1790
  this.variants.deleteDevice(deviceId);
1741
1791
  this.stateFrames.delete(deviceId);
1742
1792
  this.wakingDevices.delete(deviceId);
1793
+ this.deviceMetaMemo.delete(deviceId);
1743
1794
  this.captureFlight.invalidatePrefix(`${deviceId}:`);
1744
1795
  }
1745
1796
  /**
@@ -2047,17 +2098,35 @@ var SnapshotAddon = class SnapshotAddon extends require_dist.BaseAddon {
2047
2098
  }
2048
2099
  }
2049
2100
  /**
2050
- * Single-trip device lookup against device-manager. Returns the
2051
- * stable registry fields the wrapper consults. Battery classification is
2052
- * completed by `resolveSnapshotState` from this feature flag PLUS the
2053
- * canonical runtime-state mirror, so a stale persisted feature projection
2054
- * cannot authorize a snapshot dial against a known sleeping battery camera.
2101
+ * Single-trip device lookup against device-manager memoized for
2102
+ * {@link DEVICE_META_MEMO_MS} (promise-keyed, so bursts single-flight).
2103
+ * Registry facts only; nothing battery-runtime lives here, so the TTL never
2104
+ * masks a sleep/wake transition. Announced changes evict immediately (the
2105
+ * `device.*` subscriptions in `onInitialize`); the TTL bounds silent drift.
2106
+ */
2107
+ lookupDeviceMeta(deviceId) {
2108
+ const hit = this.deviceMetaMemo.get(deviceId);
2109
+ if (hit !== void 0 && Date.now() - hit.ts < DEVICE_META_MEMO_MS) return hit.promise;
2110
+ const promise = this.fetchDeviceMeta(deviceId);
2111
+ this.deviceMetaMemo.set(deviceId, {
2112
+ ts: Date.now(),
2113
+ promise
2114
+ });
2115
+ return promise;
2116
+ }
2117
+ /**
2118
+ * The actual `deviceManager.getDevice` round trip behind
2119
+ * {@link lookupDeviceMeta}. Returns the stable registry fields the wrapper
2120
+ * consults. Battery classification is completed by `resolveSnapshotState`
2121
+ * from this feature flag PLUS the canonical runtime-state mirror, so a stale
2122
+ * persisted feature projection cannot authorize a snapshot dial against a
2123
+ * known sleeping battery camera.
2055
2124
  *
2056
2125
  * Logged at debug + null return on failure: every call site already
2057
2126
  * has a sensible fallback path (cache hit, conservative default, …),
2058
2127
  * so we don't want a transient device-manager hiccup to throw.
2059
2128
  */
2060
- async lookupDeviceMeta(deviceId) {
2129
+ async fetchDeviceMeta(deviceId) {
2061
2130
  const api = this.ctx.api;
2062
2131
  if (!api) return null;
2063
2132
  try {
@@ -1,4 +1,4 @@
1
- import { Ct as DeviceFeature, Gt as EventCategory, M as deriveBatteryPresence, Rt as nodePin, T as batteryCapability, Tt as DeviceType, i as BatteryStatusSchema, mt as streamQualityLabel, ut as snapshotCapability, vt as errMsg, w as bareAddonId, yt as BaseAddon } from "../../dist-COd223t-.mjs";
1
+ import { Ct as DeviceFeature, Gt as EventCategory, M as deriveBatteryPresence, Rt as nodePin, T as batteryCapability, Tt as DeviceType, i as BatteryStatusSchema, mt as streamQualityLabel, ut as snapshotCapability, vt as errMsg, w as bareAddonId, yt as BaseAddon } from "../../dist-hKJyHgFg.mjs";
2
2
  import { z } from "zod";
3
3
  import { randomUUID } from "node:crypto";
4
4
  import { signExpiringUrl, verifyExpiringUrl } from "@camstack/types/node";
@@ -817,11 +817,34 @@ var LINK_MINT_DEADLINE_MS = 2500;
817
817
  var LINK_BATCH_WAIT_MS = 750;
818
818
  /** Frames older than this are never represented as current by the Viewer. */
819
819
  var LINK_CURRENT_MAX_AGE_MS = 15e3;
820
+ /**
821
+ * Memo TTL for the per-device `deviceManager.getDevice` lookup.
822
+ *
823
+ * Every serve decision — each `getSnapshotLinks` target, each media-plane GET,
824
+ * each conditional-GET peek — used to pay this cross-process round trip (plus
825
+ * the battery-slice one) before it could even look at the cache: 21-target
826
+ * grids paid 42 UDS calls per 5 s poll, on top of the captures themselves
827
+ * (live hub, 2026-08-15). Registry facts (name/type/disabled/online/features)
828
+ * change on operator action or provider reconnect, not mid-second, so ten
829
+ * seconds of staleness is invisible next to the poll cadence — and every
830
+ * lifecycle event that changes one of those fields evicts the entry
831
+ * immediately (see the `device.*` subscriptions in `onInitialize`).
832
+ *
833
+ * The BATTERY SLICE is deliberately NOT memoized: sleep/wake transitions must
834
+ * be reactive (a camera that just fell asleep must not be dialed — the
835
+ * Baichuan wake-on-login incident), and `waking` is already live from the
836
+ * in-memory `wakingDevices` map.
837
+ */
838
+ var DEVICE_META_MEMO_MS = 1e4;
820
839
  /** Wake-on-play's 8 s firmware wait + 20 s broker settle, with scheduling
821
840
  * slack. A lost completion event must not leave a camera "Waking" forever. */
822
841
  var SNAPSHOT_WAKING_TTL_MS = 35e3;
823
- /** Default cache window for non-battery cams (seconds). 10s feels live. */
824
- var NON_BATTERY_DEFAULT_MAX_AGE_S = 10;
842
+ /** Default cache window for non-battery cams (seconds). Matches the Viewer's
843
+ * 15 s currency contract (`LINK_CURRENT_MAX_AGE_MS`): a frame younger than
844
+ * that is presented as current, so re-capturing INSIDE the window bought
845
+ * nothing the client would show — under the 5 s links poll it made every
846
+ * other poll recapture the whole fleet through the 6-permit grab pools. */
847
+ var NON_BATTERY_DEFAULT_MAX_AGE_S = 15;
825
848
  /** Default cache window for battery cams (seconds). 1h ≈ "don't wake the cam unless asked". */
826
849
  var BATTERY_DEFAULT_MAX_AGE_S = 3600;
827
850
  /**
@@ -873,6 +896,15 @@ var SnapshotAddon = class SnapshotAddon extends BaseAddon {
873
896
  /** Devices inside the explicit battery wake-in-progress window. */
874
897
  wakingDevices = /* @__PURE__ */ new Map();
875
898
  /**
899
+ * Short-TTL memo for `lookupDeviceMeta` (see {@link DEVICE_META_MEMO_MS}).
900
+ * The PROMISE is stored (not the resolved value), so a burst of concurrent
901
+ * callers — a links batch plus the image fetches it mints — joins one
902
+ * in-flight lookup instead of stampeding `deviceManager.getDevice`.
903
+ * `fetchDeviceMeta` never rejects (failure → null), so a settled rejection
904
+ * can never be served from the memo.
905
+ */
906
+ deviceMetaMemo = /* @__PURE__ */ new Map();
907
+ /**
876
908
  * De-dupes concurrent captures per `${deviceId}:${streamId}` and holds a
877
909
  * settled SUCCESS for COALESCE_MS so a grid-mount burst (and a row of refresh
878
910
  * buttons) collapses into one capture instead of one dial per tile.
@@ -943,6 +975,17 @@ var SnapshotAddon = class SnapshotAddon extends BaseAddon {
943
975
  const deviceId = event.data.deviceId;
944
976
  if (typeof deviceId === "number") this.evictRemovedDevice(deviceId, "device-unregistered");
945
977
  });
978
+ const dropMetaMemo = (data) => {
979
+ const deviceId = data?.deviceId;
980
+ if (typeof deviceId === "number") this.deviceMetaMemo.delete(deviceId);
981
+ };
982
+ this.subscribe({ category: EventCategory.DeviceRegistered }, (event) => dropMetaMemo(event.data));
983
+ this.subscribe({ category: EventCategory.DeviceEnabled }, (event) => dropMetaMemo(event.data));
984
+ this.subscribe({ category: EventCategory.DeviceDisabled }, (event) => dropMetaMemo(event.data));
985
+ this.subscribe({ category: EventCategory.DeviceMetaChanged }, (event) => dropMetaMemo(event.data));
986
+ this.subscribe({ category: EventCategory.DeviceOnline }, (event) => dropMetaMemo(event.data));
987
+ this.subscribe({ category: EventCategory.DeviceOffline }, (event) => dropMetaMemo(event.data));
988
+ this.subscribe({ category: EventCategory.DeviceBindingsChanged }, (event) => dropMetaMemo(event.data));
946
989
  this.subscribe({ category: EventCategory.BatteryOnWakeStarted }, (event) => {
947
990
  this.wakingDevices.set(event.data.deviceId, Date.now());
948
991
  });
@@ -1149,11 +1192,11 @@ var SnapshotAddon = class SnapshotAddon extends BaseAddon {
1149
1192
  const expMs = snapshotLinkExpiry(Date.now(), SNAPSHOT_LINK_TTL_MS);
1150
1193
  const served = this.linkDataPlane !== null && secret !== null;
1151
1194
  const prefix = this.linkRoutePrefix();
1152
- const sleepingByDevice = /* @__PURE__ */ new Map();
1195
+ const stateByDevice = /* @__PURE__ */ new Map();
1153
1196
  const refreshes = input.targets.map(async (target) => {
1154
- const sleeping = await this.isSleepingBatteryDevice(target.deviceId);
1155
- sleepingByDevice.set(target.deviceId, sleeping);
1156
- if (!sleeping) await this.awaitFreshEnough(target.deviceId);
1197
+ const state = await this.snapshotStateForLink(target.deviceId);
1198
+ stateByDevice.set(target.deviceId, state);
1199
+ if (state.reason === void 0) await this.awaitFreshEnough(target.deviceId);
1157
1200
  });
1158
1201
  await raceForResult(Promise.allSettled(refreshes), LINK_BATCH_WAIT_MS);
1159
1202
  const rows = input.targets.map((target) => {
@@ -1176,7 +1219,8 @@ var SnapshotAddon = class SnapshotAddon extends BaseAddon {
1176
1219
  expiresAt: served ? expMs : null,
1177
1220
  width: width ?? null,
1178
1221
  neverCaptured: capturedAt === null,
1179
- sleeping: sleepingByDevice.get(deviceId) ?? false
1222
+ sleeping: stateByDevice.get(deviceId)?.reason === "sleeping",
1223
+ stateReason: stateByDevice.get(deviceId)?.reason ?? null
1180
1224
  };
1181
1225
  });
1182
1226
  this.ctx.logger.debug("snapshot: minted links", { meta: {
@@ -1210,14 +1254,18 @@ var SnapshotAddon = class SnapshotAddon extends BaseAddon {
1210
1254
  }
1211
1255
  });
1212
1256
  }
1213
- /** True only for a battery device that must not be snapshot-refreshed. */
1214
- async isSleepingBatteryDevice(deviceId) {
1257
+ /** Resolve the state advertised by a minted link before deciding whether a
1258
+ * background capture is allowed. */
1259
+ async snapshotStateForLink(deviceId) {
1215
1260
  try {
1216
1261
  const meta = await this.lookupDeviceMeta(deviceId);
1217
- const state = await this.resolveSnapshotState(deviceId, meta);
1218
- return state.reason === "sleeping" || state.reason === "unreachable" || state.reason === "waking";
1219
- } catch {
1220
- return false;
1262
+ return await this.resolveSnapshotState(deviceId, meta);
1263
+ } catch (err) {
1264
+ this.ctx.logger.debug("snapshot: link state resolution failed", {
1265
+ tags: { deviceId },
1266
+ meta: { error: errMsg(err) }
1267
+ });
1268
+ return { isBattery: false };
1221
1269
  }
1222
1270
  }
1223
1271
  /**
@@ -1234,7 +1282,7 @@ var SnapshotAddon = class SnapshotAddon extends BaseAddon {
1234
1282
  deviceId,
1235
1283
  ...streamId !== void 0 ? { streamId } : {},
1236
1284
  force
1237
- }, 0, Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY, resolutionMeta);
1285
+ }, 0, Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY, resolutionMeta, 0);
1238
1286
  if (!image) return null;
1239
1287
  const capturedAt = this.cache.get(deviceId, streamId)?.ts ?? Date.now();
1240
1288
  const prefs = await this.readDeviceSettings(deviceId).catch(() => ({}));
@@ -1339,6 +1387,7 @@ var SnapshotAddon = class SnapshotAddon extends BaseAddon {
1339
1387
  this.variants.clear();
1340
1388
  this.stateFrames.clear();
1341
1389
  this.wakingDevices.clear();
1390
+ this.deviceMetaMemo.clear();
1342
1391
  this.captureFlight.clear();
1343
1392
  this.ownerCache = null;
1344
1393
  }
@@ -1371,7 +1420,7 @@ var SnapshotAddon = class SnapshotAddon extends BaseAddon {
1371
1420
  })]
1372
1421
  }] });
1373
1422
  }
1374
- async getSnapshot(input, minimumCaptureWaitMs = 0, maximumCacheAgeMs = Number.POSITIVE_INFINITY, maximumCaptureWaitMs = Number.POSITIVE_INFINITY, resolutionMeta) {
1423
+ async getSnapshot(input, minimumCaptureWaitMs = 0, maximumCacheAgeMs = Number.POSITIVE_INFINITY, maximumCaptureWaitMs = Number.POSITIVE_INFINITY, resolutionMeta, staleWaitCapMs = Number.POSITIVE_INFINITY) {
1375
1424
  const { deviceId } = input;
1376
1425
  const force = input.force === true;
1377
1426
  const meta = await this.lookupDeviceMeta(deviceId);
@@ -1434,7 +1483,8 @@ var SnapshotAddon = class SnapshotAddon extends BaseAddon {
1434
1483
  log
1435
1484
  }));
1436
1485
  flight.catch(() => void 0);
1437
- const raced = await raceForResult(flight, Math.min(Math.max(decision.waitMs, minimumCaptureWaitMs), maximumCaptureWaitMs));
1486
+ const waitMs = !force && decision.staleFallback && hit !== void 0 ? Math.min(decision.waitMs, staleWaitCapMs) : decision.waitMs;
1487
+ const raced = await raceForResult(flight, Math.min(Math.max(waitMs, minimumCaptureWaitMs), maximumCaptureWaitMs));
1438
1488
  if (raced.settled) try {
1439
1489
  const resolved = await this.resolveOutcome(raced.value, deviceId, hit, log);
1440
1490
  if (resolved !== null) return resolved;
@@ -1734,6 +1784,7 @@ var SnapshotAddon = class SnapshotAddon extends BaseAddon {
1734
1784
  this.variants.deleteDevice(deviceId);
1735
1785
  this.stateFrames.delete(deviceId);
1736
1786
  this.wakingDevices.delete(deviceId);
1787
+ this.deviceMetaMemo.delete(deviceId);
1737
1788
  this.captureFlight.invalidatePrefix(`${deviceId}:`);
1738
1789
  }
1739
1790
  /**
@@ -2041,17 +2092,35 @@ var SnapshotAddon = class SnapshotAddon extends BaseAddon {
2041
2092
  }
2042
2093
  }
2043
2094
  /**
2044
- * Single-trip device lookup against device-manager. Returns the
2045
- * stable registry fields the wrapper consults. Battery classification is
2046
- * completed by `resolveSnapshotState` from this feature flag PLUS the
2047
- * canonical runtime-state mirror, so a stale persisted feature projection
2048
- * cannot authorize a snapshot dial against a known sleeping battery camera.
2095
+ * Single-trip device lookup against device-manager memoized for
2096
+ * {@link DEVICE_META_MEMO_MS} (promise-keyed, so bursts single-flight).
2097
+ * Registry facts only; nothing battery-runtime lives here, so the TTL never
2098
+ * masks a sleep/wake transition. Announced changes evict immediately (the
2099
+ * `device.*` subscriptions in `onInitialize`); the TTL bounds silent drift.
2100
+ */
2101
+ lookupDeviceMeta(deviceId) {
2102
+ const hit = this.deviceMetaMemo.get(deviceId);
2103
+ if (hit !== void 0 && Date.now() - hit.ts < DEVICE_META_MEMO_MS) return hit.promise;
2104
+ const promise = this.fetchDeviceMeta(deviceId);
2105
+ this.deviceMetaMemo.set(deviceId, {
2106
+ ts: Date.now(),
2107
+ promise
2108
+ });
2109
+ return promise;
2110
+ }
2111
+ /**
2112
+ * The actual `deviceManager.getDevice` round trip behind
2113
+ * {@link lookupDeviceMeta}. Returns the stable registry fields the wrapper
2114
+ * consults. Battery classification is completed by `resolveSnapshotState`
2115
+ * from this feature flag PLUS the canonical runtime-state mirror, so a stale
2116
+ * persisted feature projection cannot authorize a snapshot dial against a
2117
+ * known sleeping battery camera.
2049
2118
  *
2050
2119
  * Logged at debug + null return on failure: every call site already
2051
2120
  * has a sensible fallback path (cache hit, conservative default, …),
2052
2121
  * so we don't want a transient device-manager hiccup to throw.
2053
2122
  */
2054
- async lookupDeviceMeta(deviceId) {
2123
+ async fetchDeviceMeta(deviceId) {
2055
2124
  const api = this.ctx.api;
2056
2125
  if (!api) return null;
2057
2126
  try {
@@ -48,6 +48,15 @@ export declare class SnapshotAddon extends BaseAddon<SnapshotAddonConfig> {
48
48
  private readonly stateFrames;
49
49
  /** Devices inside the explicit battery wake-in-progress window. */
50
50
  private readonly wakingDevices;
51
+ /**
52
+ * Short-TTL memo for `lookupDeviceMeta` (see {@link DEVICE_META_MEMO_MS}).
53
+ * The PROMISE is stored (not the resolved value), so a burst of concurrent
54
+ * callers — a links batch plus the image fetches it mints — joins one
55
+ * in-flight lookup instead of stampeding `deviceManager.getDevice`.
56
+ * `fetchDeviceMeta` never rejects (failure → null), so a settled rejection
57
+ * can never be served from the memo.
58
+ */
59
+ private readonly deviceMetaMemo;
51
60
  /**
52
61
  * De-dupes concurrent captures per `${deviceId}:${streamId}` and holds a
53
62
  * settled SUCCESS for COALESCE_MS so a grid-mount burst (and a row of refresh
@@ -206,8 +215,9 @@ export declare class SnapshotAddon extends BaseAddon<SnapshotAddonConfig> {
206
215
  * the Viewer's 15-second currency contract and the link-mint wait bound.
207
216
  */
208
217
  private awaitFreshEnough;
209
- /** True only for a battery device that must not be snapshot-refreshed. */
210
- private isSleepingBatteryDevice;
218
+ /** Resolve the state advertised by a minted link before deciding whether a
219
+ * background capture is allowed. */
220
+ private snapshotStateForLink;
211
221
  /**
212
222
  * Resolve a device (+ optional stream, + force) to renderable JPEG bytes for
213
223
  * the HTTP endpoint. Runs the same coalesced capture ladder as the tRPC
@@ -432,17 +442,26 @@ export declare class SnapshotAddon extends BaseAddon<SnapshotAddonConfig> {
432
442
  */
433
443
  private stateImage;
434
444
  /**
435
- * Single-trip device lookup against device-manager. Returns the
436
- * stable registry fields the wrapper consults. Battery classification is
437
- * completed by `resolveSnapshotState` from this feature flag PLUS the
438
- * canonical runtime-state mirror, so a stale persisted feature projection
439
- * cannot authorize a snapshot dial against a known sleeping battery camera.
445
+ * Single-trip device lookup against device-manager memoized for
446
+ * {@link DEVICE_META_MEMO_MS} (promise-keyed, so bursts single-flight).
447
+ * Registry facts only; nothing battery-runtime lives here, so the TTL never
448
+ * masks a sleep/wake transition. Announced changes evict immediately (the
449
+ * `device.*` subscriptions in `onInitialize`); the TTL bounds silent drift.
450
+ */
451
+ private lookupDeviceMeta;
452
+ /**
453
+ * The actual `deviceManager.getDevice` round trip behind
454
+ * {@link lookupDeviceMeta}. Returns the stable registry fields the wrapper
455
+ * consults. Battery classification is completed by `resolveSnapshotState`
456
+ * from this feature flag PLUS the canonical runtime-state mirror, so a stale
457
+ * persisted feature projection cannot authorize a snapshot dial against a
458
+ * known sleeping battery camera.
440
459
  *
441
460
  * Logged at debug + null return on failure: every call site already
442
461
  * has a sensible fallback path (cache hit, conservative default, …),
443
462
  * so we don't want a transient device-manager hiccup to throw.
444
463
  */
445
- private lookupDeviceMeta;
464
+ private fetchDeviceMeta;
446
465
  /** Settings-UI helper — battery flag drives the default max-age in the field description. */
447
466
  private isDeviceBattery;
448
467
  /**
@@ -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-BspfS8Q7.js");
6
+ const require_dist = require("../../dist-BQoU9nGS.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 { V as filesystemBrowseCapability, pt as storageProviderCapability, yt as BaseAddon } from "../../dist-COd223t-.mjs";
1
+ import { V as filesystemBrowseCapability, pt as storageProviderCapability, yt as BaseAddon } from "../../dist-hKJyHgFg.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-BspfS8Q7.js");
6
+ const require_dist = require("../../dist-BQoU9nGS.js");
7
7
  let node_crypto = require("node:crypto");
8
8
  let node_fs = require("node:fs");
9
9
  let node_module = require("node:module");
@@ -1,4 +1,4 @@
1
- import { A as dataStoreProviderCapability, Bt as parseJsonUnknown, _t as vectorStoreCapability, f as RUNTIME_DEFAULTS, gt as vectorDimFromBase64, j as decodeVectorBase64, kt as asJsonObject, vt as errMsg, w as bareAddonId, yt as BaseAddon } from "../../dist-COd223t-.mjs";
1
+ import { A as dataStoreProviderCapability, Bt as parseJsonUnknown, _t as vectorStoreCapability, f as RUNTIME_DEFAULTS, gt as vectorDimFromBase64, j as decodeVectorBase64, kt as asJsonObject, vt as errMsg, w as bareAddonId, yt as BaseAddon } from "../../dist-hKJyHgFg.mjs";
2
2
  import { createRequire } from "node:module";
3
3
  import { randomUUID } from "node:crypto";
4
4
  import { statSync } 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-BspfS8Q7.js");
6
+ const require_dist = require("../../dist-BQoU9nGS.js");
7
7
  let node_crypto = require("node:crypto");
8
8
  let node_fs_promises = require("node:fs/promises");
9
9
  node_fs_promises = require_chunk.__toESM(node_fs_promises);
@@ -1,4 +1,4 @@
1
- import { dt as storageCapability, ft as storageMigrationCapability, g as StorageMigrationJobSchema, h as StorageLocationTypeSchema, lt as settingsStoreCapability, yt as BaseAddon, zt as parseJsonObject } from "../../dist-COd223t-.mjs";
1
+ import { dt as storageCapability, ft as storageMigrationCapability, g as StorageMigrationJobSchema, h as StorageLocationTypeSchema, lt as settingsStoreCapability, yt as BaseAddon, zt as parseJsonObject } from "../../dist-hKJyHgFg.mjs";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import * as fs 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
  require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-BspfS8Q7.js");
6
+ const require_dist = require("../../dist-BQoU9nGS.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.
@@ -1,4 +1,4 @@
1
- import { It as hydrateSchema, vt as errMsg, yt as BaseAddon } from "../../dist-COd223t-.mjs";
1
+ import { It as hydrateSchema, vt as errMsg, yt as BaseAddon } from "../../dist-hKJyHgFg.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.
@@ -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-BspfS8Q7.js");
6
+ const require_dist = require("../../dist-BQoU9nGS.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 { X as logDestinationCapability, yt as BaseAddon } from "../../dist-COd223t-.mjs";
1
+ import { X as logDestinationCapability, yt as BaseAddon } from "../../dist-hKJyHgFg.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";
@@ -18597,7 +18597,16 @@ targets: zod.z.array(zod.z.object({
18597
18597
  /** A sleeping battery camera: the frame is deliberately stale and will
18598
18598
  * NOT refresh in the background. A surface should say so rather than
18599
18599
  * present it as current. */
18600
- sleeping: zod.z.boolean()
18600
+ sleeping: zod.z.boolean(),
18601
+ /** Current device state rendered over the cached frame. State images
18602
+ * remain authoritative even when their photographic background is
18603
+ * old; null means the link must carry a current camera frame. */
18604
+ stateReason: zod.z.enum([
18605
+ "disabled",
18606
+ "sleeping",
18607
+ "unreachable",
18608
+ "waking"
18609
+ ]).nullable()
18601
18610
  })))
18602
18611
  },
18603
18612
  status: {
@@ -18597,7 +18597,16 @@ targets: z.array(z.object({
18597
18597
  /** A sleeping battery camera: the frame is deliberately stale and will
18598
18598
  * NOT refresh in the background. A surface should say so rather than
18599
18599
  * present it as current. */
18600
- sleeping: z.boolean()
18600
+ sleeping: z.boolean(),
18601
+ /** Current device state rendered over the cached frame. State images
18602
+ * remain authoritative even when their photographic background is
18603
+ * old; null means the link must carry a current camera frame. */
18604
+ stateReason: z.enum([
18605
+ "disabled",
18606
+ "sleeping",
18607
+ "unreachable",
18608
+ "waking"
18609
+ ]).nullable()
18601
18610
  })))
18602
18611
  },
18603
18612
  status: {
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_chunk = require("./chunk-Cek0wNdY.js");
3
- const require_dist = require("./dist-BspfS8Q7.js");
3
+ const require_dist = require("./dist-BQoU9nGS.js");
4
4
  const require_builtins_alerts_alerts_addon = require("./builtins/alerts/alerts.addon.js");
5
5
  require("./builtins/alerts/index.js");
6
6
  const require_formatter = require("./formatter-DqAKDlvN.js");
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { a as __toCommonJS, i as __require, n as __esmMin, o as __toESM$1, r as __exportAll, t as __commonJSMin$1 } from "./chunk-CNf5ZN-e.mjs";
2
- import { At as asNumber, B as extractNestedAddonId, Bt as parseJsonUnknown$1, Dt as ReadinessTimeoutError, Et as ReadinessRegistry, Ft as expandCapMethods, Gt as EventCategory$1, H as isArrayOutputSchema, Ht as resolveCapMount, J as lifecycleJobSchema, K as isVoidInput, Mt as createEvent, Nt as emitDownForOwnedCaps, Q as looseSchema, St as DEVICE_STATUS_METHOD, U as isCollectionArrayMethod, Ut as scopeKey, Vt as readinessKey, W as isObjectInput, Z as logLevelAtMost, bt as DATAPLANE_SECRET_HEADER$1, d as METHOD_ACCESS_MAP, f as RUNTIME_DEFAULTS, it as procedureAuthKey, jt as asString$1, kt as asJsonObject$1, ot as scopesAllowAddon, q as kebabToCamel, st as scopesAllowDeviceCap, t as ALL_CAPABILITY_DEFINITIONS, tt as objectInputDeclaresAddonId, vt as errMsg$1, xt as DEVICE_SETTINGS_CONTRIBUTION_METHODS, y as addonSettingsCapability, zt as parseJsonObject } from "./dist-COd223t-.mjs";
2
+ import { At as asNumber, B as extractNestedAddonId, Bt as parseJsonUnknown$1, Dt as ReadinessTimeoutError, Et as ReadinessRegistry, Ft as expandCapMethods, Gt as EventCategory$1, H as isArrayOutputSchema, Ht as resolveCapMount, J as lifecycleJobSchema, K as isVoidInput, Mt as createEvent, Nt as emitDownForOwnedCaps, Q as looseSchema, St as DEVICE_STATUS_METHOD, U as isCollectionArrayMethod, Ut as scopeKey, Vt as readinessKey, W as isObjectInput, Z as logLevelAtMost, bt as DATAPLANE_SECRET_HEADER$1, d as METHOD_ACCESS_MAP, f as RUNTIME_DEFAULTS, it as procedureAuthKey, jt as asString$1, kt as asJsonObject$1, ot as scopesAllowAddon, q as kebabToCamel, st as scopesAllowDeviceCap, t as ALL_CAPABILITY_DEFINITIONS, tt as objectInputDeclaresAddonId, vt as errMsg$1, xt as DEVICE_SETTINGS_CONTRIBUTION_METHODS, y as addonSettingsCapability, zt as parseJsonObject } from "./dist-hKJyHgFg.mjs";
3
3
  import { AlertCenterAddon } from "./builtins/alerts/alerts.addon.mjs";
4
4
  import "./builtins/alerts/index.mjs";
5
5
  import { t as formatLogLine } from "./formatter-B7qW8bPJ.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/system",
3
- "version": "1.2.94",
3
+ "version": "1.2.96",
4
4
  "description": "Core addon for CamStack — builtins, pipeline, process management, auth, logging, events",
5
5
  "keywords": [
6
6
  "camstack",