@camstack/server 1.2.724 → 1.2.725

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 (86) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/package.json +7 -4
  3. package/system/dist/addon-runner.js +69 -57
  4. package/system/dist/addon-runner.mjs +69 -57
  5. package/system/dist/{agent-https-DslXCDRW.js → agent-https-CzkxjkB5.js} +1 -1
  6. package/system/dist/{agent-https-BMbnmX5u.mjs → agent-https-DuZMpe3P.mjs} +1 -1
  7. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  8. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  9. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  10. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  11. package/system/dist/builtins/alerts/alerts.addon.js +1 -1
  12. package/system/dist/builtins/alerts/alerts.addon.mjs +1 -1
  13. package/system/dist/builtins/autotrack/index.js +1 -1
  14. package/system/dist/builtins/autotrack/index.mjs +1 -1
  15. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
  16. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
  17. package/system/dist/builtins/calendars/calendars.addon.js +1 -1
  18. package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
  19. package/system/dist/builtins/camera-grid/index.js +1 -1
  20. package/system/dist/builtins/camera-grid/index.mjs +1 -1
  21. package/system/dist/builtins/composer/composer.addon.js +3 -3
  22. package/system/dist/builtins/composer/composer.addon.mjs +3 -3
  23. package/system/dist/builtins/console-logging/index.js +1 -1
  24. package/system/dist/builtins/console-logging/index.mjs +1 -1
  25. package/system/dist/builtins/core-blocks/core-blocks.addon.js +3 -3
  26. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +3 -3
  27. package/system/dist/builtins/core-blocks/power-source-service.d.ts +1 -1
  28. package/system/dist/builtins/device-history/device-history.addon.js +2 -2
  29. package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
  30. package/system/dist/builtins/device-manager/device-manager.addon.js +1 -1
  31. package/system/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
  32. package/system/dist/builtins/hub-forwarder/index.js +1 -1
  33. package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
  34. package/system/dist/builtins/keychain/index.js +3 -3
  35. package/system/dist/builtins/keychain/index.mjs +3 -3
  36. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  37. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  38. package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
  39. package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
  40. package/system/dist/builtins/local-network/local-network.addon.js +2 -2
  41. package/system/dist/builtins/local-network/local-network.addon.mjs +2 -2
  42. package/system/dist/builtins/loki-logging/index.js +1 -1
  43. package/system/dist/builtins/loki-logging/index.mjs +1 -1
  44. package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  45. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  46. package/system/dist/builtins/platform-probe/index.js +1 -1
  47. package/system/dist/builtins/platform-probe/index.mjs +1 -1
  48. package/system/dist/builtins/record-entries/index.js +1 -1
  49. package/system/dist/builtins/record-entries/index.mjs +1 -1
  50. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  51. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  52. package/system/dist/builtins/snapshot/index.js +1 -1
  53. package/system/dist/builtins/snapshot/index.mjs +1 -1
  54. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  55. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  56. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  57. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  58. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +2 -2
  59. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +2 -2
  60. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  61. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  62. package/system/dist/builtins/system-config/system-config.addon.js +3 -3
  63. package/system/dist/builtins/system-config/system-config.addon.mjs +3 -3
  64. package/system/dist/builtins/winston-logging/index.js +1 -1
  65. package/system/dist/builtins/winston-logging/index.mjs +1 -1
  66. package/system/dist/{composition-sources-C14epb_m.js → composition-sources-B5uJfQqd.js} +1 -1
  67. package/system/dist/{composition-sources-EXNuxmGQ.mjs → composition-sources-DKx0-ndC.mjs} +1 -1
  68. package/system/dist/{constants-DIGWBiNC.mjs → constants-HoyXps3n.mjs} +1 -1
  69. package/system/dist/{constants-M7NtSiRo.js → constants-n9Ip2uKi.js} +1 -1
  70. package/system/dist/{device-ca-DZlvNBWU.mjs → device-ca-BiQeJXfU.mjs} +1 -1
  71. package/system/dist/{device-ca-3vmBP1i0.js → device-ca-Cw3JZPXq.js} +1 -1
  72. package/system/dist/{dist-DcMqHB_N.mjs → dist-D35rKdpn.mjs} +220 -176
  73. package/system/dist/{dist-M9yHiIY7.js → dist-DngPUHs2.js} +220 -176
  74. package/system/dist/file-host-worker.js +1 -1
  75. package/system/dist/file-host-worker.mjs +1 -1
  76. package/system/dist/{hub-mdns-ciao-Czz2ssit.mjs → hub-mdns-ciao-C4upkgCX.mjs} +2 -2
  77. package/system/dist/{hub-mdns-ciao-CpCKuQnK.js → hub-mdns-ciao-CChO-G09.js} +2 -2
  78. package/system/dist/index.js +76 -64
  79. package/system/dist/index.mjs +76 -64
  80. package/system/dist/{restore-archive-DS4nvQ43.mjs → restore-archive-Dr_FY9P0.mjs} +1 -1
  81. package/system/dist/{restore-archive-Cy7jGqiD.js → restore-archive-Lb1DCZll.js} +1 -1
  82. package/system/dist/{retention-Dqm_EiVq.mjs → retention-CwKSqRi5.mjs} +1 -1
  83. package/system/dist/{retention-Ufa2fci-.js → retention-IAzprg-c.js} +1 -1
  84. package/system/dist/{wal-maintenance-Bnb2QzYG.mjs → wal-maintenance-D49HVxcB.mjs} +0 -0
  85. package/system/dist/{wal-maintenance-BmugbgS7.js → wal-maintenance-DMP7fhqn.js} +0 -0
  86. package/system/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_chunk = require("./chunk-Cek0wNdY.js");
3
- const require_dist = require("./dist-M9yHiIY7.js");
4
- const require_device_ca = require("./device-ca-3vmBP1i0.js");
3
+ const require_dist = require("./dist-DngPUHs2.js");
4
+ const require_device_ca = require("./device-ca-Cw3JZPXq.js");
5
5
  const require_read_all_rows$1 = require("./read-all-rows-CVoO1ONM.js");
6
6
  const require_builtins_alerts_alerts_addon = require("./builtins/alerts/alerts.addon.js");
7
7
  require("./builtins/alerts/index.js");
@@ -26,21 +26,21 @@ const require_builtins_loki_logging_index = require("./builtins/loki-logging/ind
26
26
  const require_builtins_native_metrics_native_metrics_addon = require("./builtins/native-metrics/native-metrics.addon.js");
27
27
  const require_builtins_device_history_device_history_addon = require("./builtins/device-history/device-history.addon.js");
28
28
  const require_builtins_sqlite_storage_filesystem_storage_addon = require("./builtins/sqlite-storage/filesystem-storage.addon.js");
29
- const require_wal_maintenance = require("./wal-maintenance-BmugbgS7.js");
29
+ const require_wal_maintenance = require("./wal-maintenance-DMP7fhqn.js");
30
30
  const require_builtins_sqlite_storage_sqlite_settings_addon = require("./builtins/sqlite-storage/sqlite-settings.addon.js");
31
31
  const require_builtins_sqlite_storage_index = require("./builtins/sqlite-storage/index.js");
32
32
  const require_builtins_storage_orchestrator_storage_orchestrator_addon = require("./builtins/storage-orchestrator/storage-orchestrator.addon.js");
33
33
  require("./builtins/storage-orchestrator/index.js");
34
- const require_agent_https = require("./agent-https-DslXCDRW.js");
35
- const require_constants = require("./constants-M7NtSiRo.js");
34
+ const require_agent_https = require("./agent-https-CzkxjkB5.js");
35
+ const require_constants = require("./constants-n9Ip2uKi.js");
36
36
  const require_builtins_system_config_system_config_addon = require("./builtins/system-config/system-config.addon.js");
37
37
  require("./builtins/system-config/index.js");
38
38
  const require_builtins_winston_logging_index = require("./builtins/winston-logging/index.js");
39
39
  const require_custom_action_registry = require("./custom-action-registry-JuMHGKEc.js");
40
- const require_hub_mdns_ciao = require("./hub-mdns-ciao-CpCKuQnK.js");
40
+ const require_hub_mdns_ciao = require("./hub-mdns-ciao-CChO-G09.js");
41
41
  const require_platform_key_source = require("./platform-key-source-Di7HrlGR.js");
42
42
  const require_resource_monitor = require("./resource-monitor-mio9dSCT.js");
43
- const require_restore_archive = require("./restore-archive-Cy7jGqiD.js");
43
+ const require_restore_archive = require("./restore-archive-Lb1DCZll.js");
44
44
  const require_coral_accelerators = require("./coral-accelerators-BSVsBVzt.js");
45
45
  let zod = require("zod");
46
46
  let node_crypto = require("node:crypto");
@@ -16798,6 +16798,62 @@ function createBrokerDeviceManagerApi(opts) {
16798
16798
  probeRetryTimers.delete(deviceId);
16799
16799
  }
16800
16800
  };
16801
+ /**
16802
+ * The in-memory half of a teardown, children first. `runLifecycle` is false
16803
+ * when the hub already ran each device's `removeDevice()` through its
16804
+ * `device-ops` provider (the cascading remove): only the local registry,
16805
+ * native caps and rebuild factories are left to drop, never a second
16806
+ * lifecycle call.
16807
+ */
16808
+ const teardownLocal = async (deviceId, runLifecycle) => {
16809
+ const device = registry.getById(deviceId);
16810
+ cancelProbeRetry(deviceId);
16811
+ if (!device) return;
16812
+ const children = registry.getChildren(deviceId);
16813
+ for (const child of children) await teardownLocal(child.id, runLifecycle);
16814
+ const capsToUnregister = opts.capabilityRegistry ? [...opts.capabilityRegistry.getNativeCapsForDevice(deviceId)] : [...getWorkerNativeCapsForDevice(deviceId)];
16815
+ opts.capabilityRegistry?.unregisterAllNativeForDevice(deviceId);
16816
+ if (!opts.capabilityRegistry) clearWorkerNativeCapsForDevice(deviceId);
16817
+ for (const capName of capsToUnregister) {
16818
+ eventBus.emit({
16819
+ id: (0, node_crypto.randomUUID)(),
16820
+ timestamp: /* @__PURE__ */ new Date(),
16821
+ source: {
16822
+ type: "device",
16823
+ id: deviceId
16824
+ },
16825
+ category: _camstack_types_addon.EventCategory.DeviceBindingsChanged,
16826
+ data: {
16827
+ deviceId,
16828
+ capName,
16829
+ reason: "native-unregistered",
16830
+ addonId,
16831
+ nodeId
16832
+ }
16833
+ });
16834
+ (0, _camstack_types_addon.emitReadiness)(eventBus, {
16835
+ capName,
16836
+ scope: {
16837
+ type: "device",
16838
+ deviceId
16839
+ },
16840
+ state: "down",
16841
+ generation: nativeCapReadinessGeneration,
16842
+ sourceNodeId: nodeId
16843
+ });
16844
+ }
16845
+ if (runLifecycle) await device.removeDevice().catch((err) => {
16846
+ opts.logger.warn("removeDevice() lifecycle threw during decommission", {
16847
+ tags: {
16848
+ deviceId,
16849
+ addonId
16850
+ },
16851
+ meta: { error: err instanceof Error ? err.message : String(err) }
16852
+ });
16853
+ });
16854
+ if (!runLifecycle) deviceRebuildFactories.delete(deviceId);
16855
+ registry.remove(deviceId);
16856
+ };
16801
16857
  const deviceApi = {
16802
16858
  allocateDeviceId: async (stableId) => {
16803
16859
  return (await callDeviceManager(api, "allocateDeviceId", {
@@ -17239,58 +17295,11 @@ function createBrokerDeviceManagerApi(opts) {
17239
17295
  /**
17240
17296
  * In-memory teardown — fires `removeDevice()` lifecycle, drops
17241
17297
  * native caps, removes from registry. Cascades through children.
17242
- * Does NOT touch persisted state. Used both by `remove()` (which
17243
- * follows up with the device-manager call) and by addon shutdown
17298
+ * Does NOT touch persisted state. Used by `remove()` (after the hub
17299
+ * cascade) and by addon shutdown
17244
17300
  * paths that want the next boot to rehydrate the same devices.
17245
17301
  */
17246
- decommission: async (deviceId) => {
17247
- const device = registry.getById(deviceId);
17248
- cancelProbeRetry(deviceId);
17249
- if (!device) return;
17250
- const children = registry.getChildren(deviceId);
17251
- for (const child of children) await deviceApi.decommission(child.id);
17252
- const capsToUnregister = opts.capabilityRegistry ? [...opts.capabilityRegistry.getNativeCapsForDevice(deviceId)] : [...getWorkerNativeCapsForDevice(deviceId)];
17253
- opts.capabilityRegistry?.unregisterAllNativeForDevice(deviceId);
17254
- if (!opts.capabilityRegistry) clearWorkerNativeCapsForDevice(deviceId);
17255
- for (const capName of capsToUnregister) {
17256
- eventBus.emit({
17257
- id: (0, node_crypto.randomUUID)(),
17258
- timestamp: /* @__PURE__ */ new Date(),
17259
- source: {
17260
- type: "device",
17261
- id: deviceId
17262
- },
17263
- category: _camstack_types_addon.EventCategory.DeviceBindingsChanged,
17264
- data: {
17265
- deviceId,
17266
- capName,
17267
- reason: "native-unregistered",
17268
- addonId,
17269
- nodeId
17270
- }
17271
- });
17272
- (0, _camstack_types_addon.emitReadiness)(eventBus, {
17273
- capName,
17274
- scope: {
17275
- type: "device",
17276
- deviceId
17277
- },
17278
- state: "down",
17279
- generation: nativeCapReadinessGeneration,
17280
- sourceNodeId: nodeId
17281
- });
17282
- }
17283
- await device.removeDevice().catch((err) => {
17284
- opts.logger.warn("removeDevice() lifecycle threw during decommission", {
17285
- tags: {
17286
- deviceId,
17287
- addonId
17288
- },
17289
- meta: { error: err instanceof Error ? err.message : String(err) }
17290
- });
17291
- });
17292
- registry.remove(deviceId);
17293
- },
17302
+ decommission: (deviceId) => teardownLocal(deviceId, true),
17294
17303
  applyDerivedSpec: async (deviceId, derived) => {
17295
17304
  if (derived.type !== void 0) await callDeviceManager(api, "setType", {
17296
17305
  deviceId,
@@ -17333,14 +17342,17 @@ function createBrokerDeviceManagerApi(opts) {
17333
17342
  await deviceApi.decommission(deviceId);
17334
17343
  await deviceApi.register(construct());
17335
17344
  },
17345
+ /**
17346
+ * Remove a device AND its whole subtree, once. The hub's public `remove`
17347
+ * is the one cascade (children, live teardown through each device's
17348
+ * `device-ops`, rows, tombstones, removal hooks, events); this worker then
17349
+ * drops what only it holds — the registry entries and native caps — without
17350
+ * a second `removeDevice()` lifecycle. A persisted-only orphan is the same
17351
+ * call: the hub clears its rows and there is nothing local to drop.
17352
+ */
17336
17353
  remove: async (deviceId) => {
17337
- deviceRebuildFactories.delete(deviceId);
17338
- if (!registry.getById(deviceId)) {
17339
- await callDeviceManager(api, "removeDevice", { deviceId });
17340
- return;
17341
- }
17342
- await deviceApi.decommission(deviceId);
17343
- await callDeviceManager(api, "removeDevice", { deviceId });
17354
+ await callDeviceManager(api, "remove", { deviceId });
17355
+ await teardownLocal(deviceId, false);
17344
17356
  },
17345
17357
  getAll: async () => {
17346
17358
  return registry.getAllForAddon(addonId);
@@ -1,6 +1,6 @@
1
1
  import { i as __require } from "./chunk-CNf5ZN-e.mjs";
2
- import { Dr as isObjectInput, Ds as withoutCallerStamp, E as CatalogFileSchema, Es as userError, Go as defineRecordKinds, Hi as scopesAllowDeviceCap, Ho as createEvent$1, Hr as looseSchema, Jo as expandCapMethods, Ko as emitDownForOwnedCaps, Mo as asJsonObject$1, Ms as EventCategory$1, Ni as resolveMethodAuth, No as asNumber, Or as isVoidInput, Po as asString$1, Pr as lifecycleJobSchema, Qi as splitTranslationRef, Sr as isCollectionArrayMethod, Vi as scopesAllowAddon, Vr as logLevelAtMost, Zt as addonSettingsCapability, _r as interpolate, _s as resolveCapMount, a as AGENT_MDNS_TXT_KEYS, ai as objectInputDeclaresRequiredDeviceId, ar as extractNestedAddonId, bo as ReadinessTimeoutError, eo as CALLER_STAMPED_CAPABILITIES$1, fs as parseJsonObject, ft as LOG_LEVEL_RANK, hs as readinessKey, i as AGENT_MDNS_SERVICE_TYPE, ii as objectInputDeclaresAddonId, js as errMsg$1, kr as kebabToCamel$1, mt as METHOD_ACCESS_MAP, no as DEVICE_SETTINGS_CONTRIBUTION_METHODS, o as ALL_CAPABILITY_DEFINITIONS, oa as supportedRuntimes, ps as parseJsonUnknown, ro as DEVICE_STATUS_METHOD, to as DATAPLANE_SECRET_HEADER$1, vi as procedureAuthKey, vo as RUNTIME_DEFAULTS, xr as isArrayOutputSchema, y as CATALOG_LANGS, yo as ReadinessRegistry, ys as scopeKey } from "./dist-DcMqHB_N.mjs";
3
- import { d as JWT_SIGNING_KEY_REF, f as JwtSigningKeyUnavailableError, g as processJwtSigningKey, i as generateDeviceCa, l as verifyDeviceLeaf, m as getProcessJwtSigningKeyState, n as DEVICE_CA_KEY_REF, o as issueDeviceLeaf, p as SYSTEM_SECRET_OWNER, s as loadDeviceCa, u as verifyDeviceSignature, v as staticJwtSigningKey } from "./device-ca-DZlvNBWU.mjs";
2
+ import { Dr as isObjectInput, Ds as withoutCallerStamp, E as CatalogFileSchema, Es as userError, Go as defineRecordKinds, Hi as scopesAllowDeviceCap, Ho as createEvent$1, Hr as looseSchema, Jo as expandCapMethods, Ko as emitDownForOwnedCaps, Mo as asJsonObject$1, Ms as EventCategory$1, Ni as resolveMethodAuth, No as asNumber, Or as isVoidInput, Po as asString$1, Pr as lifecycleJobSchema, Qi as splitTranslationRef, Sr as isCollectionArrayMethod, Vi as scopesAllowAddon, Vr as logLevelAtMost, Zt as addonSettingsCapability, _r as interpolate, _s as resolveCapMount, a as AGENT_MDNS_TXT_KEYS, ai as objectInputDeclaresRequiredDeviceId, ar as extractNestedAddonId, bo as ReadinessTimeoutError, eo as CALLER_STAMPED_CAPABILITIES$1, fs as parseJsonObject, ft as LOG_LEVEL_RANK, hs as readinessKey, i as AGENT_MDNS_SERVICE_TYPE, ii as objectInputDeclaresAddonId, js as errMsg$1, kr as kebabToCamel$1, mt as METHOD_ACCESS_MAP, no as DEVICE_SETTINGS_CONTRIBUTION_METHODS, o as ALL_CAPABILITY_DEFINITIONS, oa as supportedRuntimes, ps as parseJsonUnknown, ro as DEVICE_STATUS_METHOD, to as DATAPLANE_SECRET_HEADER$1, vi as procedureAuthKey, vo as RUNTIME_DEFAULTS, xr as isArrayOutputSchema, y as CATALOG_LANGS, yo as ReadinessRegistry, ys as scopeKey } from "./dist-D35rKdpn.mjs";
3
+ import { d as JWT_SIGNING_KEY_REF, f as JwtSigningKeyUnavailableError, g as processJwtSigningKey, i as generateDeviceCa, l as verifyDeviceLeaf, m as getProcessJwtSigningKeyState, n as DEVICE_CA_KEY_REF, o as issueDeviceLeaf, p as SYSTEM_SECRET_OWNER, s as loadDeviceCa, u as verifyDeviceSignature, v as staticJwtSigningKey } from "./device-ca-BiQeJXfU.mjs";
4
4
  import { t as require_read_all_rows } from "./read-all-rows-TaPqdWNF.mjs";
5
5
  import { AlertCenterAddon } from "./builtins/alerts/alerts.addon.mjs";
6
6
  import "./builtins/alerts/index.mjs";
@@ -25,21 +25,21 @@ import { LokiDestination, LokiLoggingAddon } from "./builtins/loki-logging/index
25
25
  import NativeMetricsAddon, { a as NativeMetricsProvider, i as parseProcStatusRss, n as nodeProcReader, r as parseProcStat } from "./builtins/native-metrics/native-metrics.addon.mjs";
26
26
  import { DeviceHistoryAddon } from "./builtins/device-history/device-history.addon.mjs";
27
27
  import { FilesystemStorageAddon, t as FilesystemStorageProvider } from "./builtins/sqlite-storage/filesystem-storage.addon.mjs";
28
- import { D as RecordsEngine, l as SqliteSettingsBackend } from "./wal-maintenance-Bnb2QzYG.mjs";
28
+ import { D as RecordsEngine, l as SqliteSettingsBackend } from "./wal-maintenance-D49HVxcB.mjs";
29
29
  import { SqliteSettingsAddon } from "./builtins/sqlite-storage/sqlite-settings.addon.mjs";
30
30
  import { ConfigStore, DeviceStore } from "./builtins/sqlite-storage/index.mjs";
31
31
  import { StorageOrchestratorAddon, a as stripForwardedCaller, i as createHubCapForwardService, l as STORAGE_DRAIN_STATE_LEGACY, n as HUB_CAP_FWD_ACTION, o as buildStorageLocationRegistry, r as HUB_CAP_FWD_SERVICE, t as StorageOrchestratorService, u as storageOrchestratorRecordKinds } from "./builtins/storage-orchestrator/storage-orchestrator.addon.mjs";
32
32
  import "./builtins/storage-orchestrator/index.mjs";
33
- import { A as buildNameConstraintSet, B as setProcessAgentHttpsNames, C as LEAF_RENEWAL_WINDOW_DAYS, E as evaluateExistingCert, F as readNameConstraints, I as AGENT_HTTPS_NAMES_COLLECTION, L as AGENT_HTTPS_NAMES_COLUMNS, M as isLocalOnlyHostname, N as permitsIdentity, O as PERMITTED_DNS_SUFFIXES, P as permitsName, R as AgentHttpsNames, S as CA_VALIDITY_DAYS, T as SERVER_AUTH_OID, a as collectAgentNames, b as collectCertIdentity, c as installAgentHttps, d as issueAgentHttpsLeaf, f as loadAgentHttps, h as CA_COMMON_NAME, i as certificateNames, j as isConstrainedCa, k as PERMITTED_IP_RANGES, l as isContainerBridgeAddress, m as pinnedHttpsCaFingerprint, n as acceptAgentSans, o as createAgentHttpsRequest, p as pemDigest, r as agentHttpsPaths, s as describeHttpsLeaf, t as AgentHttpsInstallError, u as isPrivateAddress, w as MAX_LEAF_VALIDITY_DAYS, x as systemHostFacts, y as localCaCommonName, z as getProcessAgentHttpsNames } from "./agent-https-BMbnmX5u.mjs";
34
- import { a as MESH_CA_KEY_REF, i as MESH_CA_FIELD, n as DEFAULT_HUB_TLS_TCP_PORT, o as MESH_CA_SETTINGS_KEY } from "./constants-DIGWBiNC.mjs";
33
+ import { A as buildNameConstraintSet, B as setProcessAgentHttpsNames, C as LEAF_RENEWAL_WINDOW_DAYS, E as evaluateExistingCert, F as readNameConstraints, I as AGENT_HTTPS_NAMES_COLLECTION, L as AGENT_HTTPS_NAMES_COLUMNS, M as isLocalOnlyHostname, N as permitsIdentity, O as PERMITTED_DNS_SUFFIXES, P as permitsName, R as AgentHttpsNames, S as CA_VALIDITY_DAYS, T as SERVER_AUTH_OID, a as collectAgentNames, b as collectCertIdentity, c as installAgentHttps, d as issueAgentHttpsLeaf, f as loadAgentHttps, h as CA_COMMON_NAME, i as certificateNames, j as isConstrainedCa, k as PERMITTED_IP_RANGES, l as isContainerBridgeAddress, m as pinnedHttpsCaFingerprint, n as acceptAgentSans, o as createAgentHttpsRequest, p as pemDigest, r as agentHttpsPaths, s as describeHttpsLeaf, t as AgentHttpsInstallError, u as isPrivateAddress, w as MAX_LEAF_VALIDITY_DAYS, x as systemHostFacts, y as localCaCommonName, z as getProcessAgentHttpsNames } from "./agent-https-DuZMpe3P.mjs";
34
+ import { a as MESH_CA_KEY_REF, i as MESH_CA_FIELD, n as DEFAULT_HUB_TLS_TCP_PORT, o as MESH_CA_SETTINGS_KEY } from "./constants-HoyXps3n.mjs";
35
35
  import { $ as caFingerprintCompact, A as getProcessNodeMeshTransport, B as MESH_NODE_CERTIFICATES_COLLECTION, C as MESH_TLS_PORT_HELLO_FIELD, Ct as readOriginSetting, D as setProcessMeshTlsEnabler, Dt as readCidrSetting, E as ServiceBroker, Et as parseCidrList, F as renewMeshCertificate, G as getProcessMeshCertificateRegistry, H as MeshCertificateRegistry, I as revokeMeshCertificate, J as processMeshCrl, K as setProcessMeshCertificateRegistry, L as getProcessMeshTlsListenerState, M as isProcessVerifiedMeshPeer, N as onProcessNodeRegistered, O as dropProcessPeer, P as setProcessMeshPeerTransportLookup, Q as caFingerprint, R as openMeshTlsWhenRevocationsLoaded, S as verifyMembershipAnswer, St as parseOriginList, SystemConfigAddon, T as Errors, Tt as normalizeIp, U as RENEWAL_ABANDONED, V as MESH_NODE_CERTIFICATES_COLUMNS, W as describeMeshLeaf, X as getProcessMeshCaState, Y as MeshCaKeeper, Z as requireProcessMeshCa, _ as signPairingProof, _t as verifyAgentUiUnlockTicket, a as hubHostFromMeshAddress, at as issueMeshLeafForNode, b as MembershipResponder, bt as isInsecureOrigin, c as PAIRING_MAX_SESSIONS, ct as AGENT_DASHBOARD_ORIGINS_FIELD, d as PAIRING_PROTOCOL, dt as AGENT_UI_UNLOCK_USE, et as createMeshCsrPem, f as PAIRING_TTL_MS, ft as AGENT_UI_UNLOCK_VERSION, g as keyFingerprintShort, gt as parseAgentDashboardOrigins, h as describeCsr, ht as mintAgentUiUnlockTicket, i as AgentPairing, it as isValidAgentNodeId, j as getProcessPeerLeaf, k as emitProcessNodeRegistered, l as PAIRING_PATHS, lt as AGENT_UI_UNLOCK_TTL_MS, m as computePairingSas, mt as isAllowedAgentDashboardReturnTo, n as HubPairing, nt as generateMeshCa, o as PAIRING_CODE_DIGITS, ot as issueMeshLeafFromCsr, p as computePairingCommitment, pt as UnlockTicketJtiStore, q as MeshCrl, r as PairingHttpError, rt as generateMeshKeyPair, s as PAIRING_MAX_CODE_ATTEMPTS, st as loadMeshCa, tt as exportMeshPrivateKeyPem, u as PAIRING_PIN_DIGITS, ut as AGENT_UI_UNLOCK_TYP, v as verifyPairingProof, vt as InvalidCorsOriginError, w as TlsTcpTransporter, wt as createCidrMatcher, x as signMembershipProof, xt as normalizeOrigin, y as MEMBERSHIP_PATHS, yt as OPAQUE_ORIGIN, z as setProcessMeshTlsListenerState } from "./builtins/system-config/system-config.addon.mjs";
36
36
  import "./builtins/system-config/index.mjs";
37
37
  import { WinstonDestination, WinstonLoggingAddon } from "./builtins/winston-logging/index.mjs";
38
38
  import { C as isModelDownloaded, E as setHuggingFaceReachabilityObserver, T as revisionWeightUrl, _ as downloadFile, a as startEventLoopStallMonitor, b as fetchJson, c as createAuthenticatedFileServer, d as resolveFilePath, f as ModelDownloadService, g as deleteModelFromDisk, h as collectModelFiles, i as attributeStall, l as parseRangeHeader, m as adoptModelRevisions, n as STALL_REPORT_MS, o as createFileDataPlaneHandler, r as STALL_TICK_MS, s as contentTypeFor, t as CustomActionRegistry, u as parseTokenizedUrl, v as downloadModel, w as resolveFormatRevision, x as getModelFilePath, y as ensureModel } from "./custom-action-registry-oHl1xltx.mjs";
39
- import { A as retirePreviousLocalCa, C as checkUploadedCa, D as loadTlsCert, E as ensureTlsCert, F as closeLanHttp, I as readLanHttpState, L as registerLanHttpHandler, M as allFamiliesListenHost, N as applyLanHttp, O as reissueTlsLeaf, P as bindPendingLanHttp, S as chainsToPublicRoot, T as caReplacementMarkerFile, _ as readTlsMode, a as storeUploadedCertificate, b as writeTlsEnabled, c as leafFingerprintOf, d as servedHttpsLeafFingerprint, f as prepareBootTls, g as readTlsEnabled, h as readTlsAccessStatus, i as revertToGeneratedCertificate, j as DEFAULT_LAN_HTTP_PORT, k as replaceUnconstrainedLocalCa, l as registerHttpsListener, m as readExtraSans, n as applyCertificateToListener, o as useStoredUploadedCertificate, p as UPLOADED_CA_FILE, r as regenerateCertificate, s as clearHttpsListener, t as createCiaoPublisher, u as reloadHttpsListener, v as splitPemCertificates, w as validateUploadedTls, x as writeTlsMode, y as writeExtraSans } from "./hub-mdns-ciao-Czz2ssit.mjs";
39
+ import { A as retirePreviousLocalCa, C as checkUploadedCa, D as loadTlsCert, E as ensureTlsCert, F as closeLanHttp, I as readLanHttpState, L as registerLanHttpHandler, M as allFamiliesListenHost, N as applyLanHttp, O as reissueTlsLeaf, P as bindPendingLanHttp, S as chainsToPublicRoot, T as caReplacementMarkerFile, _ as readTlsMode, a as storeUploadedCertificate, b as writeTlsEnabled, c as leafFingerprintOf, d as servedHttpsLeafFingerprint, f as prepareBootTls, g as readTlsEnabled, h as readTlsAccessStatus, i as revertToGeneratedCertificate, j as DEFAULT_LAN_HTTP_PORT, k as replaceUnconstrainedLocalCa, l as registerHttpsListener, m as readExtraSans, n as applyCertificateToListener, o as useStoredUploadedCertificate, p as UPLOADED_CA_FILE, r as regenerateCertificate, s as clearHttpsListener, t as createCiaoPublisher, u as reloadHttpsListener, v as splitPemCertificates, w as validateUploadedTls, x as writeTlsMode, y as writeExtraSans } from "./hub-mdns-ciao-C4upkgCX.mjs";
40
40
  import { n as getPlatformKeychainKey, r as setPlatformKeychainKey, t as clearPlatformKeychainKey } from "./platform-key-source-BWlq0jjn.mjs";
41
41
  import { n as getSinglePidStats, t as getPidStats } from "./resource-monitor-Di9daRwI.mjs";
42
- import { _ as backupRecordStoresOf, c as BackupDecryptError, f as generateBackupKeyPair, g as backupOrchestratorRecordKinds, h as readBackupEncryptionHeader, l as BackupKeyFormatError, r as prepareRestoreArchive, s as SystemBackupService, t as BackupKeyRequiredError, u as BackupKeyMismatchError } from "./restore-archive-DS4nvQ43.mjs";
42
+ import { _ as backupRecordStoresOf, c as BackupDecryptError, f as generateBackupKeyPair, g as backupOrchestratorRecordKinds, h as readBackupEncryptionHeader, l as BackupKeyFormatError, r as prepareRestoreArchive, s as SystemBackupService, t as BackupKeyRequiredError, u as BackupKeyMismatchError } from "./restore-archive-Dr_FY9P0.mjs";
43
43
  import { r as nodeCoralFs, t as classifyCoralAccelerator } from "./coral-accelerators-DBlgWB8k.mjs";
44
44
  import { z } from "zod";
45
45
  import * as crypto$1 from "node:crypto";
@@ -16795,6 +16795,62 @@ function createBrokerDeviceManagerApi(opts) {
16795
16795
  probeRetryTimers.delete(deviceId);
16796
16796
  }
16797
16797
  };
16798
+ /**
16799
+ * The in-memory half of a teardown, children first. `runLifecycle` is false
16800
+ * when the hub already ran each device's `removeDevice()` through its
16801
+ * `device-ops` provider (the cascading remove): only the local registry,
16802
+ * native caps and rebuild factories are left to drop, never a second
16803
+ * lifecycle call.
16804
+ */
16805
+ const teardownLocal = async (deviceId, runLifecycle) => {
16806
+ const device = registry.getById(deviceId);
16807
+ cancelProbeRetry(deviceId);
16808
+ if (!device) return;
16809
+ const children = registry.getChildren(deviceId);
16810
+ for (const child of children) await teardownLocal(child.id, runLifecycle);
16811
+ const capsToUnregister = opts.capabilityRegistry ? [...opts.capabilityRegistry.getNativeCapsForDevice(deviceId)] : [...getWorkerNativeCapsForDevice(deviceId)];
16812
+ opts.capabilityRegistry?.unregisterAllNativeForDevice(deviceId);
16813
+ if (!opts.capabilityRegistry) clearWorkerNativeCapsForDevice(deviceId);
16814
+ for (const capName of capsToUnregister) {
16815
+ eventBus.emit({
16816
+ id: randomUUID(),
16817
+ timestamp: /* @__PURE__ */ new Date(),
16818
+ source: {
16819
+ type: "device",
16820
+ id: deviceId
16821
+ },
16822
+ category: EventCategory.DeviceBindingsChanged,
16823
+ data: {
16824
+ deviceId,
16825
+ capName,
16826
+ reason: "native-unregistered",
16827
+ addonId,
16828
+ nodeId
16829
+ }
16830
+ });
16831
+ emitReadiness(eventBus, {
16832
+ capName,
16833
+ scope: {
16834
+ type: "device",
16835
+ deviceId
16836
+ },
16837
+ state: "down",
16838
+ generation: nativeCapReadinessGeneration,
16839
+ sourceNodeId: nodeId
16840
+ });
16841
+ }
16842
+ if (runLifecycle) await device.removeDevice().catch((err) => {
16843
+ opts.logger.warn("removeDevice() lifecycle threw during decommission", {
16844
+ tags: {
16845
+ deviceId,
16846
+ addonId
16847
+ },
16848
+ meta: { error: err instanceof Error ? err.message : String(err) }
16849
+ });
16850
+ });
16851
+ if (!runLifecycle) deviceRebuildFactories.delete(deviceId);
16852
+ registry.remove(deviceId);
16853
+ };
16798
16854
  const deviceApi = {
16799
16855
  allocateDeviceId: async (stableId) => {
16800
16856
  return (await callDeviceManager(api, "allocateDeviceId", {
@@ -17236,58 +17292,11 @@ function createBrokerDeviceManagerApi(opts) {
17236
17292
  /**
17237
17293
  * In-memory teardown — fires `removeDevice()` lifecycle, drops
17238
17294
  * native caps, removes from registry. Cascades through children.
17239
- * Does NOT touch persisted state. Used both by `remove()` (which
17240
- * follows up with the device-manager call) and by addon shutdown
17295
+ * Does NOT touch persisted state. Used by `remove()` (after the hub
17296
+ * cascade) and by addon shutdown
17241
17297
  * paths that want the next boot to rehydrate the same devices.
17242
17298
  */
17243
- decommission: async (deviceId) => {
17244
- const device = registry.getById(deviceId);
17245
- cancelProbeRetry(deviceId);
17246
- if (!device) return;
17247
- const children = registry.getChildren(deviceId);
17248
- for (const child of children) await deviceApi.decommission(child.id);
17249
- const capsToUnregister = opts.capabilityRegistry ? [...opts.capabilityRegistry.getNativeCapsForDevice(deviceId)] : [...getWorkerNativeCapsForDevice(deviceId)];
17250
- opts.capabilityRegistry?.unregisterAllNativeForDevice(deviceId);
17251
- if (!opts.capabilityRegistry) clearWorkerNativeCapsForDevice(deviceId);
17252
- for (const capName of capsToUnregister) {
17253
- eventBus.emit({
17254
- id: randomUUID(),
17255
- timestamp: /* @__PURE__ */ new Date(),
17256
- source: {
17257
- type: "device",
17258
- id: deviceId
17259
- },
17260
- category: EventCategory.DeviceBindingsChanged,
17261
- data: {
17262
- deviceId,
17263
- capName,
17264
- reason: "native-unregistered",
17265
- addonId,
17266
- nodeId
17267
- }
17268
- });
17269
- emitReadiness(eventBus, {
17270
- capName,
17271
- scope: {
17272
- type: "device",
17273
- deviceId
17274
- },
17275
- state: "down",
17276
- generation: nativeCapReadinessGeneration,
17277
- sourceNodeId: nodeId
17278
- });
17279
- }
17280
- await device.removeDevice().catch((err) => {
17281
- opts.logger.warn("removeDevice() lifecycle threw during decommission", {
17282
- tags: {
17283
- deviceId,
17284
- addonId
17285
- },
17286
- meta: { error: err instanceof Error ? err.message : String(err) }
17287
- });
17288
- });
17289
- registry.remove(deviceId);
17290
- },
17299
+ decommission: (deviceId) => teardownLocal(deviceId, true),
17291
17300
  applyDerivedSpec: async (deviceId, derived) => {
17292
17301
  if (derived.type !== void 0) await callDeviceManager(api, "setType", {
17293
17302
  deviceId,
@@ -17330,14 +17339,17 @@ function createBrokerDeviceManagerApi(opts) {
17330
17339
  await deviceApi.decommission(deviceId);
17331
17340
  await deviceApi.register(construct());
17332
17341
  },
17342
+ /**
17343
+ * Remove a device AND its whole subtree, once. The hub's public `remove`
17344
+ * is the one cascade (children, live teardown through each device's
17345
+ * `device-ops`, rows, tombstones, removal hooks, events); this worker then
17346
+ * drops what only it holds — the registry entries and native caps — without
17347
+ * a second `removeDevice()` lifecycle. A persisted-only orphan is the same
17348
+ * call: the hub clears its rows and there is nothing local to drop.
17349
+ */
17333
17350
  remove: async (deviceId) => {
17334
- deviceRebuildFactories.delete(deviceId);
17335
- if (!registry.getById(deviceId)) {
17336
- await callDeviceManager(api, "removeDevice", { deviceId });
17337
- return;
17338
- }
17339
- await deviceApi.decommission(deviceId);
17340
- await callDeviceManager(api, "removeDevice", { deviceId });
17351
+ await callDeviceManager(api, "remove", { deviceId });
17352
+ await teardownLocal(deviceId, false);
17341
17353
  },
17342
17354
  getAll: async () => {
17343
17355
  return registry.getAllForAddon(addonId);
@@ -1,4 +1,4 @@
1
- import { Go as defineRecordKinds, W as DataStoreDatabaseSchema, j as DATABASE_SNAPSHOT_SUFFIX } from "./dist-DcMqHB_N.mjs";
1
+ import { Go as defineRecordKinds, W as DataStoreDatabaseSchema, j as DATABASE_SNAPSHOT_SUFFIX } from "./dist-D35rKdpn.mjs";
2
2
  import { z } from "zod";
3
3
  import { createCipheriv, createDecipheriv, createHash, createPrivateKey, createPublicKey, diffieHellman, generateKeyPairSync, hkdfSync, randomBytes } from "node:crypto";
4
4
  import { Buffer as Buffer$1 } from "buffer";
@@ -1,5 +1,5 @@
1
1
  const require_chunk = require("./chunk-Cek0wNdY.js");
2
- const require_dist = require("./dist-M9yHiIY7.js");
2
+ const require_dist = require("./dist-DngPUHs2.js");
3
3
  let zod = require("zod");
4
4
  let node_crypto = require("node:crypto");
5
5
  let buffer = require("buffer");
@@ -1,4 +1,4 @@
1
- import { As as DeviceType, Xo as historyItemFieldPath, so as HISTORY_DEFAULT_MIN_INTERVAL_MS } from "./dist-DcMqHB_N.mjs";
1
+ import { As as DeviceType, Xo as historyItemFieldPath, so as HISTORY_DEFAULT_MIN_INTERVAL_MS } from "./dist-D35rKdpn.mjs";
2
2
  //#region src/builtins/device-history/store/series-registry.ts
3
3
  function subjectIdOf(subject) {
4
4
  return subject.kind === "device" ? `d:${subject.deviceId}` : `n:${subject.nodeId}`;
@@ -1,4 +1,4 @@
1
- const require_dist = require("./dist-M9yHiIY7.js");
1
+ const require_dist = require("./dist-DngPUHs2.js");
2
2
  //#region src/builtins/device-history/store/series-registry.ts
3
3
  function subjectIdOf(subject) {
4
4
  return subject.kind === "device" ? `d:${subject.deviceId}` : `n:${subject.nodeId}`;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/server",
3
- "version": "1.2.724",
3
+ "version": "1.2.725",
4
4
  "description": "CamStack builtins — shipped inside @camstack/server (generated, do not edit)",
5
5
  "license": "MIT",
6
6
  "camstack": {