@camstack/server 1.2.724 → 1.2.726

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 (89) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/package.json +10 -6
  3. package/system/dist/addon-runner.js +69 -57
  4. package/system/dist/addon-runner.mjs +69 -57
  5. package/system/dist/addon-utils.mjs +1 -1
  6. package/system/dist/{agent-https-DslXCDRW.js → agent-https-BnvFHfIE.js} +1 -1
  7. package/system/dist/{agent-https-BMbnmX5u.mjs → agent-https-D0cOTQNv.mjs} +1 -1
  8. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  9. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +4 -4
  10. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  11. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +5 -5
  12. package/system/dist/builtins/alerts/alerts.addon.js +1 -1
  13. package/system/dist/builtins/alerts/alerts.addon.mjs +1 -1
  14. package/system/dist/builtins/autotrack/index.js +1 -1
  15. package/system/dist/builtins/autotrack/index.mjs +1 -1
  16. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
  17. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +5 -5
  18. package/system/dist/builtins/calendars/calendars.addon.js +1 -1
  19. package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
  20. package/system/dist/builtins/camera-grid/index.js +1 -1
  21. package/system/dist/builtins/camera-grid/index.mjs +1 -1
  22. package/system/dist/builtins/composer/composer.addon.js +3 -3
  23. package/system/dist/builtins/composer/composer.addon.mjs +3 -3
  24. package/system/dist/builtins/console-logging/index.js +1 -1
  25. package/system/dist/builtins/console-logging/index.mjs +1 -1
  26. package/system/dist/builtins/core-blocks/core-blocks.addon.js +3 -3
  27. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +3 -3
  28. package/system/dist/builtins/core-blocks/power-source-service.d.ts +1 -1
  29. package/system/dist/builtins/device-history/device-history.addon.js +2 -2
  30. package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
  31. package/system/dist/builtins/device-manager/device-manager.addon.js +1 -1
  32. package/system/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
  33. package/system/dist/builtins/hub-forwarder/index.js +1 -1
  34. package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
  35. package/system/dist/builtins/keychain/index.js +3 -3
  36. package/system/dist/builtins/keychain/index.mjs +3 -3
  37. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  38. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  39. package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
  40. package/system/dist/builtins/local-auth/local-auth.addon.mjs +5 -5
  41. package/system/dist/builtins/local-network/local-network.addon.js +2 -2
  42. package/system/dist/builtins/local-network/local-network.addon.mjs +2 -2
  43. package/system/dist/builtins/loki-logging/index.js +1 -1
  44. package/system/dist/builtins/loki-logging/index.mjs +1 -1
  45. package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  46. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +10 -10
  47. package/system/dist/builtins/platform-probe/index.js +1 -1
  48. package/system/dist/builtins/platform-probe/index.mjs +10 -10
  49. package/system/dist/builtins/record-entries/index.js +1 -1
  50. package/system/dist/builtins/record-entries/index.mjs +1 -1
  51. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  52. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  53. package/system/dist/builtins/snapshot/index.js +1 -1
  54. package/system/dist/builtins/snapshot/index.mjs +1 -1
  55. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  56. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +20 -20
  57. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  58. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  59. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +2 -2
  60. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +2 -2
  61. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  62. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  63. package/system/dist/builtins/system-config/system-config.addon.js +3 -3
  64. package/system/dist/builtins/system-config/system-config.addon.mjs +115 -115
  65. package/system/dist/builtins/winston-logging/index.js +1 -1
  66. package/system/dist/builtins/winston-logging/index.mjs +1 -1
  67. package/system/dist/{composition-sources-EXNuxmGQ.mjs → composition-sources-9gWI1PaJ.mjs} +1 -1
  68. package/system/dist/{composition-sources-C14epb_m.js → composition-sources-Csn9vigy.js} +1 -1
  69. package/system/dist/{constants-M7NtSiRo.js → constants-BUBTFwBx.js} +1 -1
  70. package/system/dist/{constants-DIGWBiNC.mjs → constants-DXemqoYD.mjs} +1 -1
  71. package/system/dist/{coral-accelerators-DBlgWB8k.mjs → coral-accelerators-BW3OcrLD.mjs} +6 -6
  72. package/system/dist/{custom-action-registry-oHl1xltx.mjs → custom-action-registry-BIJZBObd.mjs} +37 -37
  73. package/system/dist/{device-ca-3vmBP1i0.js → device-ca-BBWsIjrt.js} +1 -1
  74. package/system/dist/{device-ca-DZlvNBWU.mjs → device-ca-mHcd1YH_.mjs} +1 -1
  75. package/system/dist/{dist-DcMqHB_N.mjs → dist-AYmnm-Kz.mjs} +256 -184
  76. package/system/dist/{dist-M9yHiIY7.js → dist-D4jIqIYT.js} +256 -184
  77. package/system/dist/file-host-worker.js +1 -1
  78. package/system/dist/file-host-worker.mjs +1 -1
  79. package/system/dist/{hub-mdns-ciao-CpCKuQnK.js → hub-mdns-ciao-Cl258gjr.js} +2 -2
  80. package/system/dist/{hub-mdns-ciao-Czz2ssit.mjs → hub-mdns-ciao-Cx91p2V7.mjs} +2 -2
  81. package/system/dist/index.js +76 -64
  82. package/system/dist/index.mjs +293 -281
  83. package/system/dist/{restore-archive-Cy7jGqiD.js → restore-archive-DIU_NCSx.js} +1 -1
  84. package/system/dist/{restore-archive-DS4nvQ43.mjs → restore-archive-DebhY_Mj.mjs} +94 -94
  85. package/system/dist/{retention-Dqm_EiVq.mjs → retention-CI5_Tvdn.mjs} +1 -1
  86. package/system/dist/{retention-Ufa2fci-.js → retention-D0GH1QcS.js} +1 -1
  87. package/system/dist/{wal-maintenance-BmugbgS7.js → wal-maintenance-BA0MvGtU.js} +0 -0
  88. package/system/dist/{wal-maintenance-Bnb2QzYG.mjs → wal-maintenance-CJKZ2zXS.mjs} +0 -0
  89. package/system/package.json +1 -1
@@ -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-AYmnm-Kz.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-mHcd1YH_.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,22 +25,22 @@ 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-CJKZ2zXS.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-D0cOTQNv.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-DXemqoYD.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
- 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";
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-BIJZBObd.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-Cx91p2V7.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";
43
- import { r as nodeCoralFs, t as classifyCoralAccelerator } from "./coral-accelerators-DBlgWB8k.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-DebhY_Mj.mjs";
43
+ import { r as nodeCoralFs, t as classifyCoralAccelerator } from "./coral-accelerators-BW3OcrLD.mjs";
44
44
  import { z } from "zod";
45
45
  import * as crypto$1 from "node:crypto";
46
46
  import { createHash, randomBytes, randomUUID } from "node:crypto";
@@ -55,7 +55,7 @@ import * as os$1 from "node:os";
55
55
  import { tmpdir } from "node:os";
56
56
  import { pathToFileURL } from "node:url";
57
57
  import { BOOT_RECOVERY_BACKOFF_MS, CALLER_STAMPED_CAPABILITIES, DATAPLANE_SECRET_HEADER, DEVICE_CHILDREN_BATCH_MAX, DeviceType, DisposerChain, ErrorI18nPayloadSchema, EventCategory, PEER_BYTES_CHUNK_BYTES, PEER_BYTES_MAX_OUTSTANDING, PEER_BYTES_STALL_MS, PEER_BYTES_TICKET_TTL_MS, ReadinessRegistry as ReadinessRegistry$1, addonSliceHandleApi, asJsonObject, asString, collectZodSecretPaths, createDeviceProxy, createEvent, createEventBusSliceSource, createRecordsAccess, createSecretsAccess, deviceOpsCapability, emitReadiness, errMsg, expandCapMethods as expandCapMethods$1, maskUrlCredentials, readErrorI18n, readNodePin, scopeKey as scopeKey$1, scrubKnownSecrets, sleep, withCapInputDefaults } from "@camstack/types/addon";
58
- import * as fs$1 from "node:fs";
58
+ import * as fs from "node:fs";
59
59
  import { accessSync, constants, createReadStream, createWriteStream, existsSync, readFileSync, readdirSync } from "node:fs";
60
60
  import { execFile, spawn } from "node:child_process";
61
61
  import { once } from "node:events";
@@ -5092,7 +5092,7 @@ var PythonEnvManager = class {
5092
5092
  async ensure(options) {
5093
5093
  const probe = await this.probe();
5094
5094
  if (!probe.available || !probe.path) throw userError("system.python-required", void 0, "Python 3.10+ is required but not found on this system");
5095
- if (!fs$1.existsSync(path$1.join(this.venvPath, "bin", "python"))) await execFileAsync$7(probe.path, [
5095
+ if (!fs.existsSync(path$1.join(this.venvPath, "bin", "python"))) await execFileAsync$7(probe.path, [
5096
5096
  "-m",
5097
5097
  "venv",
5098
5098
  this.venvPath
@@ -5115,7 +5115,7 @@ var PythonEnvManager = class {
5115
5115
  }
5116
5116
  spawn(script, args) {
5117
5117
  const venvPython = path$1.join(this.venvPath, "bin", "python");
5118
- if (!fs$1.existsSync(venvPython)) throw new Error("Python venv not initialized. Call ensure() first.");
5118
+ if (!fs.existsSync(venvPython)) throw new Error("Python venv not initialized. Call ensure() first.");
5119
5119
  return spawn(venvPython, [script, ...args]);
5120
5120
  }
5121
5121
  };
@@ -5467,20 +5467,20 @@ var StorageManager = class {
5467
5467
  const basePath = this.locationManager.getBackend(mappedName).basePath;
5468
5468
  location.files = {
5469
5469
  async readFile(p) {
5470
- return fs$1.promises.readFile(path$1.join(basePath, p));
5470
+ return fs.promises.readFile(path$1.join(basePath, p));
5471
5471
  },
5472
5472
  async writeFile(p, data) {
5473
5473
  const full = path$1.join(basePath, p);
5474
- await fs$1.promises.mkdir(path$1.dirname(full), { recursive: true });
5475
- await fs$1.promises.writeFile(full, data);
5474
+ await fs.promises.mkdir(path$1.dirname(full), { recursive: true });
5475
+ await fs.promises.writeFile(full, data);
5476
5476
  },
5477
5477
  async deleteFile(p) {
5478
- await fs$1.promises.rm(path$1.join(basePath, p), { force: true });
5478
+ await fs.promises.rm(path$1.join(basePath, p), { force: true });
5479
5479
  },
5480
5480
  async listFiles(prefix) {
5481
5481
  const dir = prefix ? path$1.join(basePath, prefix) : basePath;
5482
5482
  try {
5483
- return (await fs$1.promises.readdir(dir)).map((f) => prefix ? `${prefix}/${f}` : f);
5483
+ return (await fs.promises.readdir(dir)).map((f) => prefix ? `${prefix}/${f}` : f);
5484
5484
  } catch {
5485
5485
  return [];
5486
5486
  }
@@ -5490,7 +5490,7 @@ var StorageManager = class {
5490
5490
  },
5491
5491
  async exists(p) {
5492
5492
  try {
5493
- await fs$1.promises.access(path$1.join(basePath, p));
5493
+ await fs.promises.access(path$1.join(basePath, p));
5494
5494
  return true;
5495
5495
  } catch {
5496
5496
  return false;
@@ -6261,7 +6261,7 @@ var TRADITIONAL_NATIVE_PACKAGES = ["better-sqlite3"];
6261
6261
  function hasDotNode(dir, maxDepth) {
6262
6262
  let entries;
6263
6263
  try {
6264
- entries = fs$1.readdirSync(dir, { withFileTypes: true });
6264
+ entries = fs.readdirSync(dir, { withFileTypes: true });
6265
6265
  } catch {
6266
6266
  return false;
6267
6267
  }
@@ -6272,7 +6272,7 @@ function hasDotNode(dir, maxDepth) {
6272
6272
  }
6273
6273
  /** Locate the bundled `prebuild-install` bin.js inside the staged closure. */
6274
6274
  function resolvePrebuildInstallBin(closureDir, moduleDir) {
6275
- return [path$1.join(moduleDir, "node_modules", "prebuild-install", "bin.js"), path$1.join(closureDir, "node_modules", "prebuild-install", "bin.js")].find((c) => fs$1.existsSync(c)) ?? null;
6275
+ return [path$1.join(moduleDir, "node_modules", "prebuild-install", "bin.js"), path$1.join(closureDir, "node_modules", "prebuild-install", "bin.js")].find((c) => fs.existsSync(c)) ?? null;
6276
6276
  }
6277
6277
  /**
6278
6278
  * Default fetcher: run the closure's own `prebuild-install` under the CURRENT
@@ -6325,7 +6325,7 @@ async function ensureNativePrebuilds(closureDir, options) {
6325
6325
  const fetched = [];
6326
6326
  for (const pkg of packages) {
6327
6327
  const moduleDir = path$1.join(nm, pkg);
6328
- if (!fs$1.existsSync(moduleDir)) continue;
6328
+ if (!fs.existsSync(moduleDir)) continue;
6329
6329
  if (hasDotNode(moduleDir, 4)) continue;
6330
6330
  options.logger.warn("staged closure native prebuild missing — fetching for running ABI", { meta: {
6331
6331
  pkg,
@@ -6388,12 +6388,12 @@ async function ensureNativePrebuilds(closureDir, options) {
6388
6388
  function replantFromBundled(srcModuleDir, dstModuleDir, hasNative) {
6389
6389
  if (!hasNative(srcModuleDir)) return false;
6390
6390
  try {
6391
- fs$1.rmSync(dstModuleDir, {
6391
+ fs.rmSync(dstModuleDir, {
6392
6392
  recursive: true,
6393
6393
  force: true
6394
6394
  });
6395
- fs$1.mkdirSync(path$1.dirname(dstModuleDir), { recursive: true });
6396
- fs$1.cpSync(srcModuleDir, dstModuleDir, {
6395
+ fs.mkdirSync(path$1.dirname(dstModuleDir), { recursive: true });
6396
+ fs.cpSync(srcModuleDir, dstModuleDir, {
6397
6397
  recursive: true,
6398
6398
  dereference: true
6399
6399
  });
@@ -6422,7 +6422,7 @@ async function ensureAddonNativePrebuilds(addonDir, options) {
6422
6422
  const missing = [];
6423
6423
  for (const pkg of packages) {
6424
6424
  const moduleDir = path$1.join(nm, pkg);
6425
- if (!fs$1.existsSync(moduleDir)) continue;
6425
+ if (!fs.existsSync(moduleDir)) continue;
6426
6426
  if (hasNative(moduleDir)) {
6427
6427
  results.push({
6428
6428
  pkg,
@@ -6521,7 +6521,7 @@ async function defaultDownloadTarball(url, destTgz) {
6521
6521
  const res = await fetch(url);
6522
6522
  if (!res.ok || !res.body) throw new Error(`HTTP ${res.status} downloading ${url}`);
6523
6523
  const bytes = Buffer.from(await res.arrayBuffer());
6524
- await fs$1.promises.writeFile(destTgz, bytes);
6524
+ await fs.promises.writeFile(destTgz, bytes);
6525
6525
  }
6526
6526
  async function defaultExtractTarball(tgzPath, destDir) {
6527
6527
  await execFileAsync$5("tar", [
@@ -6607,7 +6607,7 @@ async function resolveUncached(options) {
6607
6607
  argsPrefix: []
6608
6608
  };
6609
6609
  const cliPath = bootstrappedCliPath(options.cacheDir);
6610
- if (fs$1.existsSync(cliPath)) {
6610
+ if (fs.existsSync(cliPath)) {
6611
6611
  options.logger.info("system npm unavailable — using bootstrapped npm", { meta: { cliPath } });
6612
6612
  return {
6613
6613
  command: process.execPath,
@@ -6619,12 +6619,12 @@ async function resolveUncached(options) {
6619
6619
  const registry = (options.registry ?? DEFAULT_REGISTRY).replace(/\/+$/, "");
6620
6620
  const tarballUrl = tarballUrlOf(await (options.fetchJson ?? defaultFetchJson)(`${registry}/npm/latest`));
6621
6621
  if (!tarballUrl) throw new Error(`registry metadata for 'npm' carries no dist.tarball (${registry})`);
6622
- await fs$1.promises.mkdir(options.cacheDir, { recursive: true });
6622
+ await fs.promises.mkdir(options.cacheDir, { recursive: true });
6623
6623
  const tgzPath = path$1.join(options.cacheDir, "npm-bootstrap.tgz");
6624
6624
  await (options.downloadTarball ?? defaultDownloadTarball)(tarballUrl, tgzPath);
6625
6625
  await (options.extractTarball ?? defaultExtractTarball)(tgzPath, options.cacheDir);
6626
- await fs$1.promises.rm(tgzPath, { force: true });
6627
- if (!fs$1.existsSync(cliPath)) throw new Error(`extracted npm tarball is missing ${cliPath}`);
6626
+ await fs.promises.rm(tgzPath, { force: true });
6627
+ if (!fs.existsSync(cliPath)) throw new Error(`extracted npm tarball is missing ${cliPath}`);
6628
6628
  options.logger.info("npm bootstrapped", { meta: { cliPath } });
6629
6629
  return {
6630
6630
  command: process.execPath,
@@ -6690,7 +6690,7 @@ function readOwningPackageVersion(entryPath) {
6690
6690
  let dir = path$1.dirname(entryPath);
6691
6691
  for (let hop = 0; hop < PACKAGE_JSON_LOOKUP_DEPTH; hop++) {
6692
6692
  try {
6693
- const version = asJsonObject$1(parseJsonUnknown(fs$1.readFileSync(path$1.join(dir, "package.json"), "utf-8")))?.["version"];
6693
+ const version = asJsonObject$1(parseJsonUnknown(fs.readFileSync(path$1.join(dir, "package.json"), "utf-8")))?.["version"];
6694
6694
  if (typeof version === "string" && version.length > 0) return version;
6695
6695
  } catch {}
6696
6696
  const parent = path$1.dirname(dir);
@@ -6734,14 +6734,14 @@ function readOwningPackageVersion(entryPath) {
6734
6734
  function addonModuleCacheKey(entryPath) {
6735
6735
  let stat;
6736
6736
  try {
6737
- stat = fs$1.statSync(entryPath);
6737
+ stat = fs.statSync(entryPath);
6738
6738
  } catch {
6739
6739
  return null;
6740
6740
  }
6741
6741
  const version = readOwningPackageVersion(entryPath) ?? `m${stat.mtimeMs}`;
6742
6742
  let content;
6743
6743
  try {
6744
- content = createHash("sha1").update(fs$1.readFileSync(entryPath)).digest("hex").slice(0, 16);
6744
+ content = createHash("sha1").update(fs.readFileSync(entryPath)).digest("hex").slice(0, 16);
6745
6745
  } catch {
6746
6746
  content = `m${stat.mtimeMs}s${stat.size}`;
6747
6747
  }
@@ -6845,14 +6845,14 @@ var AddonLoader = class {
6845
6845
  * BUILTINS from the active closure, not the (now-inert) addons-dir copy, so
6846
6846
  * the addons-dir `@camstack/server/system` must NOT be double-loaded here. */
6847
6847
  async loadFromDirectory(addonsDir, skipPackages = []) {
6848
- if (!fs$1.existsSync(addonsDir)) return;
6848
+ if (!fs.existsSync(addonsDir)) return;
6849
6849
  const skip = new Set(skipPackages);
6850
- const entries = fs$1.readdirSync(addonsDir, { withFileTypes: true });
6850
+ const entries = fs.readdirSync(addonsDir, { withFileTypes: true });
6851
6851
  for (const entry of entries) {
6852
6852
  if (!isDirectoryEntry(entry, addonsDir)) continue;
6853
6853
  if (entry.name.startsWith("@")) {
6854
6854
  const scopeDir = path$1.join(addonsDir, entry.name);
6855
- const scopeEntries = fs$1.readdirSync(scopeDir, { withFileTypes: true });
6855
+ const scopeEntries = fs.readdirSync(scopeDir, { withFileTypes: true });
6856
6856
  for (const scopeEntry of scopeEntries) {
6857
6857
  if (!isDirectoryEntry(scopeEntry, scopeDir)) continue;
6858
6858
  if (skip.has(`${entry.name}/${scopeEntry.name}`)) continue;
@@ -6866,7 +6866,7 @@ var AddonLoader = class {
6866
6866
  }
6867
6867
  async tryLoadAddon(addonDir) {
6868
6868
  const pkgJsonPath = path$1.join(addonDir, "package.json");
6869
- if (!fs$1.existsSync(pkgJsonPath)) return;
6869
+ if (!fs.existsSync(pkgJsonPath)) return;
6870
6870
  try {
6871
6871
  await this.loadFromAddonDir(addonDir);
6872
6872
  } catch (err) {
@@ -6884,7 +6884,7 @@ var AddonLoader = class {
6884
6884
  /** Load addon from a specific directory (package.json + dist/) */
6885
6885
  async loadFromAddonDir(addonDir) {
6886
6886
  const pkgJsonPath = path$1.join(addonDir, "package.json");
6887
- const pkgJson = asJsonObject$1(parseJsonUnknown(fs$1.readFileSync(pkgJsonPath, "utf-8"))) ?? {};
6887
+ const pkgJson = asJsonObject$1(parseJsonUnknown(fs.readFileSync(pkgJsonPath, "utf-8"))) ?? {};
6888
6888
  const packageNameRaw = pkgJson["name"];
6889
6889
  const packageName = typeof packageNameRaw === "string" ? packageNameRaw : "";
6890
6890
  const packageVersionRaw = pkgJson["version"];
@@ -6931,7 +6931,7 @@ var AddonLoader = class {
6931
6931
  }
6932
6932
  const entryFile = declaration.entry.replace(/^\.\//, "").replace(/^src\//, "dist/").replace(/\.ts$/, ".js");
6933
6933
  let entryPath = path$1.resolve(addonDir, entryFile);
6934
- if (!fs$1.existsSync(entryPath)) {
6934
+ if (!fs.existsSync(entryPath)) {
6935
6935
  const base = entryPath.replace(/\.(js|cjs|mjs)$/, "");
6936
6936
  entryPath = [
6937
6937
  `${base}.cjs`,
@@ -6940,9 +6940,9 @@ var AddonLoader = class {
6940
6940
  path$1.resolve(addonDir, "dist", "index.cjs"),
6941
6941
  path$1.resolve(addonDir, "dist", "index.mjs"),
6942
6942
  path$1.resolve(addonDir, declaration.entry)
6943
- ].find((p) => fs$1.existsSync(p)) ?? entryPath;
6943
+ ].find((p) => fs.existsSync(p)) ?? entryPath;
6944
6944
  }
6945
- if (!fs$1.existsSync(entryPath)) throw new Error(`Entry not found: ${entryPath}`);
6945
+ if (!fs.existsSync(entryPath)) throw new Error(`Entry not found: ${entryPath}`);
6946
6946
  const modUnknown = await importAddonModuleFresh(entryPath);
6947
6947
  const mod = isRecord$4(modUnknown) ? modUnknown : {};
6948
6948
  const AddonClass = resolveAddonClass(mod);
@@ -7027,7 +7027,7 @@ function isDirectoryEntry(entry, parentDir) {
7027
7027
  if (entry.name.startsWith(".")) return false;
7028
7028
  if (entry.isDirectory()) return true;
7029
7029
  if (entry.isSymbolicLink()) try {
7030
- return fs$1.statSync(path$1.join(parentDir, entry.name)).isDirectory();
7030
+ return fs.statSync(path$1.join(parentDir, entry.name)).isDirectory();
7031
7031
  } catch {
7032
7032
  return false;
7033
7033
  }
@@ -7121,7 +7121,7 @@ var execFileAsync$4 = promisify(execFile);
7121
7121
  * Single source of truth — replaces scattered mkdirSync calls.
7122
7122
  */
7123
7123
  function ensureDir(dirPath) {
7124
- fs$1.mkdirSync(dirPath, { recursive: true });
7124
+ fs.mkdirSync(dirPath, { recursive: true });
7125
7125
  }
7126
7126
  /**
7127
7127
  * Copy a directory recursively — ASYNC so it never blocks the event loop.
@@ -7134,7 +7134,7 @@ function ensureDir(dirPath) {
7134
7134
  * `fs.promises.cp` keeps the I/O off the event loop. (Node ≥18 stable.)
7135
7135
  */
7136
7136
  async function copyDirRecursive(src, dest) {
7137
- await fs$1.promises.cp(src, dest, {
7137
+ await fs.promises.cp(src, dest, {
7138
7138
  recursive: true,
7139
7139
  force: true
7140
7140
  });
@@ -7239,13 +7239,13 @@ async function copyExtraFileDirs(pkgJson, sourceDir, destDir) {
7239
7239
  if (typeof fileEntry !== "string") continue;
7240
7240
  if (fileEntry === "dist" || fileEntry.includes("*")) continue;
7241
7241
  const srcPath = path$1.join(sourceDir, fileEntry);
7242
- if (!fs$1.existsSync(srcPath)) continue;
7242
+ if (!fs.existsSync(srcPath)) continue;
7243
7243
  const destPath = path$1.join(destDir, fileEntry);
7244
- const stat = await fs$1.promises.stat(srcPath);
7244
+ const stat = await fs.promises.stat(srcPath);
7245
7245
  if (stat.isDirectory()) await copyDirRecursive(srcPath, destPath);
7246
7246
  else if (stat.isFile()) {
7247
7247
  ensureDir(path$1.dirname(destPath));
7248
- await fs$1.promises.copyFile(srcPath, destPath);
7248
+ await fs.promises.copyFile(srcPath, destPath);
7249
7249
  }
7250
7250
  }
7251
7251
  }
@@ -7256,10 +7256,10 @@ async function copyExtraFileDirs(pkgJson, sourceDir, destDir) {
7256
7256
  function isSourceNewer(packageDir) {
7257
7257
  const srcDir = path$1.join(packageDir, "src");
7258
7258
  const distDir = path$1.join(packageDir, "dist");
7259
- if (!fs$1.existsSync(srcDir) || !fs$1.existsSync(distDir)) return true;
7259
+ if (!fs.existsSync(srcDir) || !fs.existsSync(distDir)) return true;
7260
7260
  try {
7261
- const distMtime = fs$1.statSync(distDir).mtimeMs;
7262
- const entries = fs$1.readdirSync(srcDir, {
7261
+ const distMtime = fs.statSync(distDir).mtimeMs;
7262
+ const entries = fs.readdirSync(srcDir, {
7263
7263
  withFileTypes: true,
7264
7264
  recursive: true
7265
7265
  });
@@ -7267,7 +7267,7 @@ function isSourceNewer(packageDir) {
7267
7267
  if (!entry.isFile()) continue;
7268
7268
  const parentDir = entry.parentPath ?? String(Reflect.get(entry, "path") ?? "");
7269
7269
  const filePath = path$1.join(parentDir, entry.name);
7270
- if (fs$1.statSync(filePath).mtimeMs > distMtime) return true;
7270
+ if (fs.statSync(filePath).mtimeMs > distMtime) return true;
7271
7271
  }
7272
7272
  return false;
7273
7273
  } catch {
@@ -7282,9 +7282,9 @@ function isSourceNewer(packageDir) {
7282
7282
  function ensureLibraryBuilt(packageName, packagesDir) {
7283
7283
  const dirName = packageName.replace("@camstack/", "");
7284
7284
  const sourceDir = path$1.join(packagesDir, dirName);
7285
- if (!fs$1.existsSync(sourceDir)) return;
7285
+ if (!fs.existsSync(sourceDir)) return;
7286
7286
  const distDir = path$1.join(sourceDir, "dist");
7287
- if (fs$1.existsSync(path$1.join(distDir, "index.js")) || fs$1.existsSync(path$1.join(distDir, "index.mjs"))) return;
7287
+ if (fs.existsSync(path$1.join(distDir, "index.js")) || fs.existsSync(path$1.join(distDir, "index.mjs"))) return;
7288
7288
  console.warn(`[ensureLibraryBuilt] ${packageName} has no dist/ — run 'npm run build' first`);
7289
7289
  }
7290
7290
  /**
@@ -7297,7 +7297,7 @@ function ensureLibraryBuilt(packageName, packagesDir) {
7297
7297
  * `copyDirRecursive` for the wedge this prevents.
7298
7298
  */
7299
7299
  async function installPackageFromNpm(packageName, targetDir) {
7300
- const tmpDir = await fs$1.promises.mkdtemp(path$1.join(os$1.tmpdir(), "camstack-install-"));
7300
+ const tmpDir = await fs.promises.mkdtemp(path$1.join(os$1.tmpdir(), "camstack-install-"));
7301
7301
  try {
7302
7302
  const { stdout } = await execFileAsync$4("npm", [
7303
7303
  "pack",
@@ -7320,21 +7320,21 @@ async function installPackageFromNpm(packageName, targetDir) {
7320
7320
  extractDir
7321
7321
  ], { timeout: 3e4 });
7322
7322
  const packageSubDir = path$1.join(extractDir, "package");
7323
- const srcPkgJsonDir = fs$1.existsSync(path$1.join(packageSubDir, "package.json")) ? packageSubDir : extractDir;
7324
- await fs$1.promises.rm(targetDir, {
7323
+ const srcPkgJsonDir = fs.existsSync(path$1.join(packageSubDir, "package.json")) ? packageSubDir : extractDir;
7324
+ await fs.promises.rm(targetDir, {
7325
7325
  recursive: true,
7326
7326
  force: true
7327
7327
  });
7328
7328
  ensureDir(targetDir);
7329
- await fs$1.promises.copyFile(path$1.join(srcPkgJsonDir, "package.json"), path$1.join(targetDir, "package.json"));
7329
+ await fs.promises.copyFile(path$1.join(srcPkgJsonDir, "package.json"), path$1.join(targetDir, "package.json"));
7330
7330
  const distSrc = path$1.join(srcPkgJsonDir, "dist");
7331
- if (fs$1.existsSync(distSrc)) await copyDirRecursive(distSrc, path$1.join(targetDir, "dist"));
7331
+ if (fs.existsSync(distSrc)) await copyDirRecursive(distSrc, path$1.join(targetDir, "dist"));
7332
7332
  try {
7333
- const npmPkg = asJsonObject$1(parseJsonUnknown(await fs$1.promises.readFile(path$1.join(srcPkgJsonDir, "package.json"), "utf-8")));
7333
+ const npmPkg = asJsonObject$1(parseJsonUnknown(await fs.promises.readFile(path$1.join(srcPkgJsonDir, "package.json"), "utf-8")));
7334
7334
  if (npmPkg) await copyExtraFileDirs(npmPkg, srcPkgJsonDir, targetDir);
7335
7335
  } catch {}
7336
7336
  } finally {
7337
- await fs$1.promises.rm(tmpDir, {
7337
+ await fs.promises.rm(tmpDir, {
7338
7338
  recursive: true,
7339
7339
  force: true
7340
7340
  });
@@ -7359,7 +7359,7 @@ function packageDirName$1(declaredName) {
7359
7359
  }
7360
7360
  function isDirLike$1(p) {
7361
7361
  try {
7362
- return fs$1.statSync(p).isDirectory();
7362
+ return fs.statSync(p).isDirectory();
7363
7363
  } catch {
7364
7364
  return false;
7365
7365
  }
@@ -7377,12 +7377,12 @@ var AddonManifest = class {
7377
7377
  */
7378
7378
  read() {
7379
7379
  if (this.cache != null) return this.cache;
7380
- if (!fs$1.existsSync(this.manifestPath)) {
7380
+ if (!fs.existsSync(this.manifestPath)) {
7381
7381
  this.cache = this.empty();
7382
7382
  return this.cache;
7383
7383
  }
7384
7384
  try {
7385
- const raw = fs$1.readFileSync(this.manifestPath, "utf-8");
7385
+ const raw = fs.readFileSync(this.manifestPath, "utf-8");
7386
7386
  const parsed = JSON.parse(raw);
7387
7387
  if (parsed.version !== MANIFEST_VERSION) {
7388
7388
  process.stderr.write(`[AddonManifest] schema mismatch (file=${parsed.version} vs runtime=${MANIFEST_VERSION}); starting empty\n`);
@@ -7403,13 +7403,13 @@ var AddonManifest = class {
7403
7403
  * a half-written file.
7404
7404
  */
7405
7405
  write(manifest) {
7406
- fs$1.mkdirSync(path$1.dirname(this.manifestPath), { recursive: true });
7406
+ fs.mkdirSync(path$1.dirname(this.manifestPath), { recursive: true });
7407
7407
  const tmp = `${this.manifestPath}.tmp.${process.pid}.${Date.now()}`;
7408
- fs$1.writeFileSync(tmp, JSON.stringify(manifest, null, 2), {
7408
+ fs.writeFileSync(tmp, JSON.stringify(manifest, null, 2), {
7409
7409
  encoding: "utf-8",
7410
7410
  mode: 384
7411
7411
  });
7412
- fs$1.renameSync(tmp, this.manifestPath);
7412
+ fs.renameSync(tmp, this.manifestPath);
7413
7413
  this.cache = manifest;
7414
7414
  }
7415
7415
  /** Lookup a single addon's manifest entry, or `null` if not tracked. */
@@ -7484,22 +7484,22 @@ var AddonManifest = class {
7484
7484
  * exactly what moved. Returns the total number of changes.
7485
7485
  */
7486
7486
  reconcileFromDisk(addonsDir, onChange) {
7487
- if (!fs$1.existsSync(addonsDir)) return 0;
7487
+ if (!fs.existsSync(addonsDir)) return 0;
7488
7488
  const m = this.read();
7489
7489
  let changes = 0;
7490
7490
  const now = (/* @__PURE__ */ new Date()).toISOString();
7491
7491
  /** Package name → version, for every ADDON package actually installed. */
7492
7492
  const onDisk = /* @__PURE__ */ new Map();
7493
- for (const scope of fs$1.readdirSync(addonsDir, { withFileTypes: true })) {
7493
+ for (const scope of fs.readdirSync(addonsDir, { withFileTypes: true })) {
7494
7494
  if (!scope.name.startsWith("@") || !isDirLike$1(path$1.join(addonsDir, scope.name))) continue;
7495
7495
  const scopeDir = path$1.join(addonsDir, scope.name);
7496
- for (const pkg of fs$1.readdirSync(scopeDir, { withFileTypes: true })) {
7496
+ for (const pkg of fs.readdirSync(scopeDir, { withFileTypes: true })) {
7497
7497
  if (!isDirLike$1(path$1.join(scopeDir, pkg.name))) continue;
7498
7498
  const pkgJsonPath = path$1.join(scopeDir, pkg.name, "package.json");
7499
- if (!fs$1.existsSync(pkgJsonPath)) continue;
7499
+ if (!fs.existsSync(pkgJsonPath)) continue;
7500
7500
  let pkgJson;
7501
7501
  try {
7502
- const parsed = JSON.parse(fs$1.readFileSync(pkgJsonPath, "utf-8"));
7502
+ const parsed = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"));
7503
7503
  if (typeof parsed !== "object" || parsed == null) continue;
7504
7504
  pkgJson = parsed;
7505
7505
  } catch {
@@ -7570,28 +7570,28 @@ var AddonManifest = class {
7570
7570
  migrateFromInstallSourceMarkers(addonsDir) {
7571
7571
  const m = this.read();
7572
7572
  if (Object.keys(m.addons).length > 0) return 0;
7573
- if (!fs$1.existsSync(addonsDir)) return 0;
7573
+ if (!fs.existsSync(addonsDir)) return 0;
7574
7574
  let migrated = 0;
7575
7575
  const now = (/* @__PURE__ */ new Date()).toISOString();
7576
- for (const scope of fs$1.readdirSync(addonsDir, { withFileTypes: true })) {
7576
+ for (const scope of fs.readdirSync(addonsDir, { withFileTypes: true })) {
7577
7577
  if (!scope.isDirectory() || !scope.name.startsWith("@")) continue;
7578
7578
  const scopeDir = path$1.join(addonsDir, scope.name);
7579
- for (const pkg of fs$1.readdirSync(scopeDir, { withFileTypes: true })) {
7579
+ for (const pkg of fs.readdirSync(scopeDir, { withFileTypes: true })) {
7580
7580
  if (!pkg.isDirectory()) continue;
7581
7581
  const pkgDir = path$1.join(scopeDir, pkg.name);
7582
7582
  const markerPath = path$1.join(pkgDir, ".install-source");
7583
7583
  const pkgJsonPath = path$1.join(pkgDir, "package.json");
7584
- if (!fs$1.existsSync(pkgJsonPath)) continue;
7584
+ if (!fs.existsSync(pkgJsonPath)) continue;
7585
7585
  let pkgJson;
7586
7586
  try {
7587
- const parsed = JSON.parse(fs$1.readFileSync(pkgJsonPath, "utf-8"));
7587
+ const parsed = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"));
7588
7588
  if (typeof parsed !== "object" || parsed == null) continue;
7589
7589
  pkgJson = parsed;
7590
7590
  } catch {
7591
7591
  continue;
7592
7592
  }
7593
7593
  if (!pkgJson.name || !pkgJson.version) continue;
7594
- const source = fs$1.existsSync(markerPath) ? fs$1.readFileSync(markerPath, "utf-8").trim() : "bundled";
7594
+ const source = fs.existsSync(markerPath) ? fs.readFileSync(markerPath, "utf-8").trim() : "bundled";
7595
7595
  m.addons[pkgJson.name] = {
7596
7596
  name: pkgJson.name,
7597
7597
  version: pkgJson.version,
@@ -7795,7 +7795,7 @@ function planClosureDedupe(input) {
7795
7795
  function readTreeManifest(pkgJsonPath) {
7796
7796
  let raw;
7797
7797
  try {
7798
- raw = asJsonObject$1(parseJsonUnknown(fs$1.readFileSync(pkgJsonPath, "utf-8")));
7798
+ raw = asJsonObject$1(parseJsonUnknown(fs.readFileSync(pkgJsonPath, "utf-8")));
7799
7799
  } catch {
7800
7800
  return null;
7801
7801
  }
@@ -7820,7 +7820,7 @@ function readTreeManifest(pkgJsonPath) {
7820
7820
  function listTopLevelEntries(nodeModulesDir) {
7821
7821
  let entries;
7822
7822
  try {
7823
- entries = fs$1.readdirSync(nodeModulesDir, { withFileTypes: true });
7823
+ entries = fs.readdirSync(nodeModulesDir, { withFileTypes: true });
7824
7824
  } catch {
7825
7825
  return [];
7826
7826
  }
@@ -7830,7 +7830,7 @@ function listTopLevelEntries(nodeModulesDir) {
7830
7830
  if (entry.name.startsWith("@")) {
7831
7831
  let inner;
7832
7832
  try {
7833
- inner = fs$1.readdirSync(path$1.join(nodeModulesDir, entry.name), { withFileTypes: true });
7833
+ inner = fs.readdirSync(path$1.join(nodeModulesDir, entry.name), { withFileTypes: true });
7834
7834
  } catch {
7835
7835
  continue;
7836
7836
  }
@@ -7863,14 +7863,14 @@ function collectAddonTreeState(addonDir) {
7863
7863
  const entryDir = path$1.join(nodeModulesDir, name);
7864
7864
  let isLink = false;
7865
7865
  try {
7866
- isLink = fs$1.lstatSync(entryDir).isSymbolicLink();
7866
+ isLink = fs.lstatSync(entryDir).isSymbolicLink();
7867
7867
  } catch {
7868
7868
  continue;
7869
7869
  }
7870
7870
  if (isLink) {
7871
7871
  let target = "";
7872
7872
  try {
7873
- target = fs$1.readlinkSync(entryDir);
7873
+ target = fs.readlinkSync(entryDir);
7874
7874
  } catch {}
7875
7875
  existingLinks.push({
7876
7876
  name,
@@ -7884,7 +7884,7 @@ function collectAddonTreeState(addonDir) {
7884
7884
  version: manifest.version
7885
7885
  });
7886
7886
  for (const [depName, range] of manifest.ranges) {
7887
- if (fs$1.existsSync(path$1.join(entryDir, "node_modules", depName))) continue;
7887
+ if (fs.existsSync(path$1.join(entryDir, "node_modules", depName))) continue;
7888
7888
  addRange(depName, range);
7889
7889
  }
7890
7890
  }
@@ -7914,7 +7914,7 @@ function resolveClosureNodeModulesDir(explicitDir) {
7914
7914
  const frameworkDir = explicitDir ?? process.env["CAMSTACK_FRAMEWORK_DIR"];
7915
7915
  if (frameworkDir === void 0 || frameworkDir.length === 0) return null;
7916
7916
  const nodeModulesDir = explicitDir ?? path$1.join(frameworkDir, "node_modules");
7917
- return fs$1.existsSync(nodeModulesDir) ? nodeModulesDir : null;
7917
+ return fs.existsSync(nodeModulesDir) ? nodeModulesDir : null;
7918
7918
  }
7919
7919
  function symlinkType() {
7920
7920
  return process.platform === "win32" ? "junction" : "dir";
@@ -7933,10 +7933,10 @@ function executeClosureDedupe(addonDir, closureNodeModulesDir, plan, logger) {
7933
7933
  const nodeModulesDir = path$1.join(addonDir, "node_modules");
7934
7934
  const probePath = path$1.join(nodeModulesDir, ".closure-link-probe");
7935
7935
  try {
7936
- fs$1.mkdirSync(nodeModulesDir, { recursive: true });
7937
- fs$1.rmSync(probePath, { force: true });
7938
- fs$1.symlinkSync(closureNodeModulesDir, probePath, symlinkType());
7939
- fs$1.rmSync(probePath, { force: true });
7936
+ fs.mkdirSync(nodeModulesDir, { recursive: true });
7937
+ fs.rmSync(probePath, { force: true });
7938
+ fs.symlinkSync(closureNodeModulesDir, probePath, symlinkType());
7939
+ fs.rmSync(probePath, { force: true });
7940
7940
  } catch (err) {
7941
7941
  logger.warn("closure dedupe skipped — symlinks unavailable on this volume", { meta: {
7942
7942
  addonDir,
@@ -7958,12 +7958,12 @@ function executeClosureDedupe(addonDir, closureNodeModulesDir, plan, logger) {
7958
7958
  }
7959
7959
  const entryDir = path$1.join(nodeModulesDir, link.name);
7960
7960
  try {
7961
- fs$1.rmSync(entryDir, {
7961
+ fs.rmSync(entryDir, {
7962
7962
  recursive: true,
7963
7963
  force: true
7964
7964
  });
7965
- fs$1.mkdirSync(path$1.dirname(entryDir), { recursive: true });
7966
- fs$1.symlinkSync(target, entryDir, symlinkType());
7965
+ fs.mkdirSync(path$1.dirname(entryDir), { recursive: true });
7966
+ fs.symlinkSync(target, entryDir, symlinkType());
7967
7967
  linked.push(link.name);
7968
7968
  } catch (err) {
7969
7969
  logger.warn("closure dedupe — link failed; entry removed copy may need reinstall", { meta: {
@@ -8039,7 +8039,7 @@ async function installManifestNativeDeps(addonDir, pkgRaw, logger, registry, npm
8039
8039
  count: Object.keys(native).length
8040
8040
  } });
8041
8041
  try {
8042
- fs$1.writeFileSync(markerFile, markerHash);
8042
+ fs.writeFileSync(markerFile, markerHash);
8043
8043
  } catch (err) {
8044
8044
  logger.warn("Failed to write native deps marker", { meta: {
8045
8045
  markerFile,
@@ -8077,7 +8077,7 @@ async function installManifestNativeDeps(addonDir, pkgRaw, logger, registry, npm
8077
8077
  }
8078
8078
  await rebuildNativeDeps(addonDir, pending.map(([name]) => name), logger, npmCacheDir ?? defaultNpmCacheDir(), registry);
8079
8079
  try {
8080
- fs$1.writeFileSync(markerFile, markerHash);
8080
+ fs.writeFileSync(markerFile, markerHash);
8081
8081
  } catch (err) {
8082
8082
  logger.warn("Failed to write native deps marker", { meta: {
8083
8083
  markerFile,
@@ -8099,12 +8099,12 @@ function copyPrebuiltNativeDep(name, addonDir, logger) {
8099
8099
  if (source === target) continue;
8100
8100
  if (!hasBuiltBinary(source)) continue;
8101
8101
  try {
8102
- fs$1.rmSync(target, {
8102
+ fs.rmSync(target, {
8103
8103
  recursive: true,
8104
8104
  force: true
8105
8105
  });
8106
- fs$1.mkdirSync(path$1.dirname(target), { recursive: true });
8107
- fs$1.cpSync(source, target, {
8106
+ fs.mkdirSync(path$1.dirname(target), { recursive: true });
8107
+ fs.cpSync(source, target, {
8108
8108
  recursive: true,
8109
8109
  dereference: true
8110
8110
  });
@@ -8140,7 +8140,7 @@ var BUNDLED_NATIVE_SIBLING_SCOPES = {
8140
8140
  function hasAnyDotNode(dir, maxDepth) {
8141
8141
  let entries;
8142
8142
  try {
8143
- entries = fs$1.readdirSync(dir, { withFileTypes: true });
8143
+ entries = fs.readdirSync(dir, { withFileTypes: true });
8144
8144
  } catch {
8145
8145
  return false;
8146
8146
  }
@@ -8154,12 +8154,12 @@ function copyPrebuiltModuleDir(src, dst, label, logger) {
8154
8154
  if (!hasAnyDotNode(src, 5)) return;
8155
8155
  if (hasAnyDotNode(dst, 5)) return;
8156
8156
  try {
8157
- fs$1.rmSync(dst, {
8157
+ fs.rmSync(dst, {
8158
8158
  recursive: true,
8159
8159
  force: true
8160
8160
  });
8161
- fs$1.mkdirSync(path$1.dirname(dst), { recursive: true });
8162
- fs$1.cpSync(src, dst, {
8161
+ fs.mkdirSync(path$1.dirname(dst), { recursive: true });
8162
+ fs.cpSync(src, dst, {
8163
8163
  recursive: true,
8164
8164
  dereference: true
8165
8165
  });
@@ -8194,7 +8194,7 @@ function copyPrebuiltModuleDir(src, dst, label, logger) {
8194
8194
  */
8195
8195
  function copyBundledNativeModules(sourceDir, targetDir, logger) {
8196
8196
  const srcNm = path$1.join(sourceDir, "node_modules");
8197
- if (!fs$1.existsSync(srcNm)) return;
8197
+ if (!fs.existsSync(srcNm)) return;
8198
8198
  const dstNm = path$1.join(targetDir, "node_modules");
8199
8199
  for (const [name, scopes] of Object.entries(BUNDLED_NATIVE_SIBLING_SCOPES)) {
8200
8200
  copyPrebuiltModuleDir(path$1.join(srcNm, name), path$1.join(dstNm, name), name, logger);
@@ -8202,7 +8202,7 @@ function copyBundledNativeModules(sourceDir, targetDir, logger) {
8202
8202
  const scopeSrc = path$1.join(srcNm, scope);
8203
8203
  let siblings;
8204
8204
  try {
8205
- siblings = fs$1.readdirSync(scopeSrc);
8205
+ siblings = fs.readdirSync(scopeSrc);
8206
8206
  } catch {
8207
8207
  continue;
8208
8208
  }
@@ -8212,12 +8212,12 @@ function copyBundledNativeModules(sourceDir, targetDir, logger) {
8212
8212
  }
8213
8213
  /** A package dir is "built" when it carries a compiled `.node` or a prebuilds tree. */
8214
8214
  function hasBuiltBinary(pkgDir) {
8215
- if (!fs$1.existsSync(path$1.join(pkgDir, "package.json"))) return false;
8215
+ if (!fs.existsSync(path$1.join(pkgDir, "package.json"))) return false;
8216
8216
  const releaseDir = path$1.join(pkgDir, "build", "Release");
8217
8217
  try {
8218
- if (fs$1.existsSync(releaseDir) && fs$1.readdirSync(releaseDir).some((f) => f.endsWith(".node"))) return true;
8218
+ if (fs.existsSync(releaseDir) && fs.readdirSync(releaseDir).some((f) => f.endsWith(".node"))) return true;
8219
8219
  } catch {}
8220
- return fs$1.existsSync(path$1.join(pkgDir, "prebuilds"));
8220
+ return fs.existsSync(path$1.join(pkgDir, "prebuilds"));
8221
8221
  }
8222
8222
  /** Candidate hoisted locations for `<name>`: NODE_PATH entries + ancestors of `addonDir`. */
8223
8223
  function candidateHoistedDirs(name, addonDir) {
@@ -8255,7 +8255,7 @@ function hashDeclaration(deps) {
8255
8255
  }
8256
8256
  function markerMatches(markerFile, expected) {
8257
8257
  try {
8258
- return fs$1.readFileSync(markerFile, "utf-8").trim() === expected;
8258
+ return fs.readFileSync(markerFile, "utf-8").trim() === expected;
8259
8259
  } catch {
8260
8260
  return false;
8261
8261
  }
@@ -8362,7 +8362,7 @@ function parseInstallSource(value) {
8362
8362
  function readPackageJson(pkgJsonPath) {
8363
8363
  let raw;
8364
8364
  try {
8365
- raw = asJsonObject$1(parseJsonUnknown(fs$1.readFileSync(pkgJsonPath, "utf-8")));
8365
+ raw = asJsonObject$1(parseJsonUnknown(fs.readFileSync(pkgJsonPath, "utf-8")));
8366
8366
  } catch {
8367
8367
  return null;
8368
8368
  }
@@ -8404,7 +8404,7 @@ function shouldSkipClosureProvidedSeed(packageName, isResolvable) {
8404
8404
  var REGISTRY_LATEST_TIMEOUT_MS = 15e3;
8405
8405
  function readInstalledPackageVersion(addonDir) {
8406
8406
  try {
8407
- const raw = JSON.parse(fs$1.readFileSync(path$1.join(addonDir, "package.json"), "utf-8"));
8407
+ const raw = JSON.parse(fs.readFileSync(path$1.join(addonDir, "package.json"), "utf-8"));
8408
8408
  if (raw === null || typeof raw !== "object") return null;
8409
8409
  const version = Reflect.get(raw, "version");
8410
8410
  return typeof version === "string" && version.length > 0 ? version : null;
@@ -8548,7 +8548,7 @@ var AddonInstaller = class AddonInstaller {
8548
8548
  } catch {
8549
8549
  return Object.freeze([]);
8550
8550
  }
8551
- const raw = fs$1.readFileSync(pkgPath, "utf-8");
8551
+ const raw = fs.readFileSync(pkgPath, "utf-8");
8552
8552
  const parsed = JSON.parse(raw);
8553
8553
  const deps = Object.keys(parsed.dependencies ?? {});
8554
8554
  const agentOnly = new Set(parsed.camstack?.agentOnlyBootstrapAddons ?? []);
@@ -8593,7 +8593,7 @@ var AddonInstaller = class AddonInstaller {
8593
8593
  } catch {
8594
8594
  return Object.freeze([]);
8595
8595
  }
8596
- const raw = fs$1.readFileSync(pkgPath, "utf-8");
8596
+ const raw = fs.readFileSync(pkgPath, "utf-8");
8597
8597
  const addons = JSON.parse(raw).camstack?.agentBootstrapAddons ?? [];
8598
8598
  return Object.freeze(["@camstack/server", ...addons]);
8599
8599
  }
@@ -8627,7 +8627,7 @@ var AddonInstaller = class AddonInstaller {
8627
8627
  }
8628
8628
  for (const packageName of pkgList) {
8629
8629
  const addonDir = path$1.join(this.addonsDir, packageName);
8630
- if (fs$1.existsSync(path$1.join(addonDir, "package.json"))) {
8630
+ if (fs.existsSync(path$1.join(addonDir, "package.json"))) {
8631
8631
  if (this.installSource !== "npm" || shouldSkipClosureProvidedSeed(packageName, this.isResolvableFromClosure(packageName))) {
8632
8632
  this.logger.debug(`${packageName} — already installed, skipping`);
8633
8633
  continue;
@@ -8771,7 +8771,7 @@ var AddonInstaller = class AddonInstaller {
8771
8771
  const installedPackages = this.listInstalled();
8772
8772
  for (const pkg of installedPackages) {
8773
8773
  try {
8774
- if (fs$1.lstatSync(pkg.dir).isSymbolicLink()) continue;
8774
+ if (fs.lstatSync(pkg.dir).isSymbolicLink()) continue;
8775
8775
  } catch {
8776
8776
  continue;
8777
8777
  }
@@ -8811,7 +8811,7 @@ var AddonInstaller = class AddonInstaller {
8811
8811
  if (closureNodeModules !== null) for (const link of state.existingLinks) {
8812
8812
  if (!isClosureLinkTarget(link.target, closureNodeModules)) continue;
8813
8813
  const linkDir = path$1.join(nodeModulesDir, link.name);
8814
- const targetManifest = fs$1.existsSync(path$1.join(linkDir, "package.json"));
8814
+ const targetManifest = fs.existsSync(path$1.join(linkDir, "package.json"));
8815
8815
  const ranges = state.requirements.get(link.name) ?? [];
8816
8816
  let holds = targetManifest;
8817
8817
  if (holds && ranges.length > 0) {
@@ -8820,14 +8820,14 @@ var AddonInstaller = class AddonInstaller {
8820
8820
  }
8821
8821
  if (!holds) {
8822
8822
  this.logger.warn(`${packageName} — closure link for ${link.name} no longer holds; reinstalling this addon's deps`, { meta: { target: link.target } });
8823
- fs$1.rmSync(linkDir, { force: true });
8823
+ fs.rmSync(linkDir, { force: true });
8824
8824
  needsInstall = true;
8825
8825
  }
8826
8826
  }
8827
8827
  const linked = [];
8828
8828
  for (const [depName, range] of declaredEntries) {
8829
8829
  if (typeof range !== "string") continue;
8830
- if (fs$1.existsSync(path$1.join(nodeModulesDir, depName, "package.json"))) continue;
8830
+ if (fs.existsSync(path$1.join(nodeModulesDir, depName, "package.json"))) continue;
8831
8831
  const closureVersion = closureNodeModules === null ? void 0 : readClosureVersions(closureNodeModules, [depName]).get(depName);
8832
8832
  if (closureNodeModules !== null && closureVersion !== void 0 && closureSatisfiesRange(range, closureVersion)) {
8833
8833
  if (executeClosureDedupe(addonDir, closureNodeModules, {
@@ -8860,7 +8860,7 @@ var AddonInstaller = class AddonInstaller {
8860
8860
  const closureNodeModules = resolveClosureNodeModulesDir(this.closureNodeModulesDir);
8861
8861
  if (closureNodeModules !== null) {
8862
8862
  const state = collectAddonTreeState(addonDir);
8863
- for (const link of state.existingLinks) if (isClosureLinkTarget(link.target, closureNodeModules)) fs$1.rmSync(path$1.join(addonDir, "node_modules", link.name), { force: true });
8863
+ for (const link of state.existingLinks) if (isClosureLinkTarget(link.target, closureNodeModules)) fs.rmSync(path$1.join(addonDir, "node_modules", link.name), { force: true });
8864
8864
  }
8865
8865
  this.logger.info(`${packageName} — reinstalling runtime dependencies`, { meta: { addonDir } });
8866
8866
  await runNpm([
@@ -8919,7 +8919,7 @@ var AddonInstaller = class AddonInstaller {
8919
8919
  async realignFromClosure(packageName, closureDir) {
8920
8920
  const targetDir = path$1.join(this.addonsDir, packageName);
8921
8921
  const result = await this.installLocal(packageName, closureDir);
8922
- await fs$1.promises.writeFile(path$1.join(targetDir, ".install-source"), "closure");
8922
+ await fs.promises.writeFile(path$1.join(targetDir, ".install-source"), "closure");
8923
8923
  this.manifest.upsert(result.name, {
8924
8924
  version: result.version,
8925
8925
  source: "closure"
@@ -8954,12 +8954,12 @@ var AddonInstaller = class AddonInstaller {
8954
8954
  */
8955
8955
  async installSymlink(packageName, sourceDir, pkgData, targetDir) {
8956
8956
  await this.ensureBuilt(packageName, sourceDir, pkgData);
8957
- fs$1.rmSync(targetDir, {
8957
+ fs.rmSync(targetDir, {
8958
8958
  recursive: true,
8959
8959
  force: true
8960
8960
  });
8961
8961
  ensureDir(path$1.dirname(targetDir));
8962
- fs$1.symlinkSync(sourceDir, targetDir, "dir");
8962
+ fs.symlinkSync(sourceDir, targetDir, "dir");
8963
8963
  this.manifest.upsert(packageName, {
8964
8964
  version: asString$1(pkgData.version, "0.0.0"),
8965
8965
  source: "local"
@@ -8973,17 +8973,17 @@ var AddonInstaller = class AddonInstaller {
8973
8973
  async installCopy(packageName, sourceDir, pkgData, targetDir) {
8974
8974
  await this.ensureBuilt(packageName, sourceDir, pkgData);
8975
8975
  const distDir = path$1.join(sourceDir, "dist");
8976
- if (!fs$1.existsSync(distDir)) throw new Error(`${packageName} has no dist/ after build`);
8977
- await fs$1.promises.rm(targetDir, {
8976
+ if (!fs.existsSync(distDir)) throw new Error(`${packageName} has no dist/ after build`);
8977
+ await fs.promises.rm(targetDir, {
8978
8978
  recursive: true,
8979
8979
  force: true
8980
8980
  });
8981
8981
  ensureDir(targetDir);
8982
- await fs$1.promises.writeFile(path$1.join(targetDir, "package.json"), JSON.stringify(stripBundledDeps(pkgData), null, 2));
8982
+ await fs.promises.writeFile(path$1.join(targetDir, "package.json"), JSON.stringify(stripBundledDeps(pkgData), null, 2));
8983
8983
  await copyDirRecursive(distDir, path$1.join(targetDir, "dist"));
8984
8984
  await copyExtraFileDirs(pkgData, sourceDir, targetDir);
8985
8985
  copyBundledNativeModules(sourceDir, targetDir, this.logger);
8986
- await fs$1.promises.writeFile(path$1.join(targetDir, ".install-source"), "local");
8986
+ await fs.promises.writeFile(path$1.join(targetDir, ".install-source"), "local");
8987
8987
  const localPkgVersion = asString$1(pkgData.version, "0.0.0");
8988
8988
  this.manifest.upsert(packageName, {
8989
8989
  version: localPkgVersion,
@@ -9024,7 +9024,7 @@ var AddonInstaller = class AddonInstaller {
9024
9024
  * unusual auth, offline mode, etc).
9025
9025
  */
9026
9026
  async installFromNpm(packageName, version) {
9027
- const tmpDir = fs$1.mkdtempSync(path$1.join(os$1.tmpdir(), "camstack-addon-npm-"));
9027
+ const tmpDir = fs.mkdtempSync(path$1.join(os$1.tmpdir(), "camstack-addon-npm-"));
9028
9028
  const packageSpec = version ? `${packageName}@${version}` : packageName;
9029
9029
  this.logger.info(`${packageName} — installing from npm`);
9030
9030
  try {
@@ -9038,19 +9038,19 @@ var AddonInstaller = class AddonInstaller {
9038
9038
  ];
9039
9039
  if (this.registry) args.push("--registry", this.registry);
9040
9040
  const { stdout } = await runNpm(args, this.npmRunOptions(tmpDir, 12e4));
9041
- const tgzFiles = fs$1.readdirSync(tmpDir).filter((f) => f.endsWith(".tgz"));
9041
+ const tgzFiles = fs.readdirSync(tmpDir).filter((f) => f.endsWith(".tgz"));
9042
9042
  if (tgzFiles.length === 0) throw new Error(`npm pack produced no tgz. stdout: ${stdout.trim()}`);
9043
9043
  return path$1.join(tmpDir, tgzFiles[0]);
9044
9044
  });
9045
9045
  const result = await this.installFromTgz(tgzPath);
9046
- fs$1.writeFileSync(path$1.join(this.addonsDir, result.name, ".install-source"), "npm");
9046
+ fs.writeFileSync(path$1.join(this.addonsDir, result.name, ".install-source"), "npm");
9047
9047
  this.manifest.upsert(result.name, {
9048
9048
  version: result.version,
9049
9049
  source: "npm"
9050
9050
  });
9051
9051
  return result;
9052
9052
  } finally {
9053
- fs$1.rmSync(tmpDir, {
9053
+ fs.rmSync(tmpDir, {
9054
9054
  recursive: true,
9055
9055
  force: true
9056
9056
  });
@@ -9088,7 +9088,7 @@ var AddonInstaller = class AddonInstaller {
9088
9088
  if (!tarRes.ok) throw new Error(`tarball GET ${tarballUrl} → ${tarRes.status}`);
9089
9089
  const tgzPath = path$1.join(tmpDir, `${packageName.replace(/[/@]/g, "-").replace(/^-+/, "")}-${resolvedVersion}.tgz`);
9090
9090
  const buf = Buffer.from(await tarRes.arrayBuffer());
9091
- fs$1.writeFileSync(tgzPath, buf);
9091
+ fs.writeFileSync(tgzPath, buf);
9092
9092
  return tgzPath;
9093
9093
  }
9094
9094
  /**
@@ -9109,7 +9109,7 @@ var AddonInstaller = class AddonInstaller {
9109
9109
  * on the next deploy.
9110
9110
  */
9111
9111
  async evictInstallDir(targetDir) {
9112
- if (!fs$1.existsSync(targetDir)) return;
9112
+ if (!fs.existsSync(targetDir)) return;
9113
9113
  const graveyard = path$1.join(this.addonsDir, ".evicting");
9114
9114
  ensureDir(graveyard);
9115
9115
  await this.sweepGraveyard(graveyard);
@@ -9117,10 +9117,10 @@ var AddonInstaller = class AddonInstaller {
9117
9117
  const flatName = path$1.relative(this.addonsDir, targetDir).replace(/[/\\]/g, "-");
9118
9118
  const asideDir = path$1.join(graveyard, `${flatName}-${ts}`);
9119
9119
  try {
9120
- fs$1.renameSync(targetDir, asideDir);
9120
+ fs.renameSync(targetDir, asideDir);
9121
9121
  } catch (renameErr) {
9122
9122
  if (renameErr.code === "EXDEV") {
9123
- await fs$1.promises.rm(targetDir, {
9123
+ await fs.promises.rm(targetDir, {
9124
9124
  recursive: true,
9125
9125
  force: true
9126
9126
  });
@@ -9128,7 +9128,7 @@ var AddonInstaller = class AddonInstaller {
9128
9128
  }
9129
9129
  throw renameErr;
9130
9130
  }
9131
- await fs$1.promises.rm(asideDir, {
9131
+ await fs.promises.rm(asideDir, {
9132
9132
  recursive: true,
9133
9133
  force: true
9134
9134
  }).catch((cleanupErr) => {
@@ -9149,14 +9149,14 @@ var AddonInstaller = class AddonInstaller {
9149
9149
  async sweepStagingResidue(stagingRoot) {
9150
9150
  let names;
9151
9151
  try {
9152
- names = fs$1.readdirSync(stagingRoot);
9152
+ names = fs.readdirSync(stagingRoot);
9153
9153
  } catch {
9154
9154
  return;
9155
9155
  }
9156
9156
  const now = Date.now();
9157
9157
  const ages = [];
9158
9158
  for (const name of names) try {
9159
- const stat = fs$1.statSync(path$1.join(stagingRoot, name));
9159
+ const stat = fs.statSync(path$1.join(stagingRoot, name));
9160
9160
  ages.push({
9161
9161
  name,
9162
9162
  ageMs: now - stat.mtimeMs
@@ -9167,7 +9167,7 @@ var AddonInstaller = class AddonInstaller {
9167
9167
  stagingRoot,
9168
9168
  entries: sweepable
9169
9169
  } });
9170
- await Promise.all(sweepable.map((name) => fs$1.promises.rm(path$1.join(stagingRoot, name), {
9170
+ await Promise.all(sweepable.map((name) => fs.promises.rm(path$1.join(stagingRoot, name), {
9171
9171
  recursive: true,
9172
9172
  force: true
9173
9173
  }).catch(() => void 0)));
@@ -9176,11 +9176,11 @@ var AddonInstaller = class AddonInstaller {
9176
9176
  async sweepGraveyard(graveyard) {
9177
9177
  let entries;
9178
9178
  try {
9179
- entries = fs$1.readdirSync(graveyard);
9179
+ entries = fs.readdirSync(graveyard);
9180
9180
  } catch {
9181
9181
  return;
9182
9182
  }
9183
- await Promise.all(entries.map((name) => fs$1.promises.rm(path$1.join(graveyard, name), {
9183
+ await Promise.all(entries.map((name) => fs.promises.rm(path$1.join(graveyard, name), {
9184
9184
  recursive: true,
9185
9185
  force: true
9186
9186
  }).catch(() => void 0)));
@@ -9231,7 +9231,7 @@ var AddonInstaller = class AddonInstaller {
9231
9231
  return;
9232
9232
  }
9233
9233
  const strippedManifest = stripBundledDeps(pkgView.raw);
9234
- await fs$1.promises.writeFile(pkgJsonPath, JSON.stringify(strippedManifest, null, 2));
9234
+ await fs.promises.writeFile(pkgJsonPath, JSON.stringify(strippedManifest, null, 2));
9235
9235
  const deps = asJsonObject$1(strippedManifest["dependencies"]);
9236
9236
  const depNames = deps ? Object.keys(deps) : [];
9237
9237
  if (depNames.length === 0) return;
@@ -9363,9 +9363,9 @@ var AddonInstaller = class AddonInstaller {
9363
9363
  "-C",
9364
9364
  stagingDir
9365
9365
  ], { timeout: 12e4 });
9366
- const pkgDir = fs$1.existsSync(path$1.join(stagingDir, "package", "package.json")) ? path$1.join(stagingDir, "package") : stagingDir;
9366
+ const pkgDir = fs.existsSync(path$1.join(stagingDir, "package", "package.json")) ? path$1.join(stagingDir, "package") : stagingDir;
9367
9367
  const pkgJsonPath = path$1.join(pkgDir, "package.json");
9368
- if (!fs$1.existsSync(pkgJsonPath)) throw new Error("No package.json found in tgz archive");
9368
+ if (!fs.existsSync(pkgJsonPath)) throw new Error("No package.json found in tgz archive");
9369
9369
  const pkgView = readPackageJson(pkgJsonPath);
9370
9370
  if (!pkgView) throw new Error(`Invalid package.json at ${pkgJsonPath}`);
9371
9371
  if (!pkgView.camstackAddons) throw new Error(`Package ${pkgView.name} has no camstack.addons manifest`);
@@ -9375,7 +9375,7 @@ var AddonInstaller = class AddonInstaller {
9375
9375
  this.dedupeTreeAgainstClosure(pkgDir, pkgView.name);
9376
9376
  await this.evictInstallDir(targetDir);
9377
9377
  ensureDir(path$1.dirname(targetDir));
9378
- await fs$1.promises.rename(pkgDir, targetDir);
9378
+ await fs.promises.rename(pkgDir, targetDir);
9379
9379
  this.manifest.upsert(pkgView.name, {
9380
9380
  version: pkgView.version,
9381
9381
  source: "bundled"
@@ -9386,7 +9386,7 @@ var AddonInstaller = class AddonInstaller {
9386
9386
  };
9387
9387
  } finally {
9388
9388
  this.inFlightStaging.delete(stagingName);
9389
- await fs$1.promises.rm(stagingDir, {
9389
+ await fs.promises.rm(stagingDir, {
9390
9390
  recursive: true,
9391
9391
  force: true
9392
9392
  }).catch(() => void 0);
@@ -9416,13 +9416,13 @@ var AddonInstaller = class AddonInstaller {
9416
9416
  const current = this.manifest.get(packageName);
9417
9417
  if (current == null) throw new Error(`Cannot update ${packageName}: not currently tracked in manifest`);
9418
9418
  const addonDir = path$1.join(this.addonsDir, packageName);
9419
- if (!fs$1.existsSync(addonDir)) throw new Error(`Cannot update ${packageName}: install dir ${addonDir} missing`);
9419
+ if (!fs.existsSync(addonDir)) throw new Error(`Cannot update ${packageName}: install dir ${addonDir} missing`);
9420
9420
  const ts = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
9421
9421
  const backupRoot = path$1.join(this.addonsDir, ".backups", packageName);
9422
9422
  ensureDir(backupRoot);
9423
9423
  const backupDir = path$1.join(backupRoot, ts);
9424
9424
  this.logger.info(`${packageName} — backing up v${current.version} → ${backupDir}`);
9425
- fs$1.renameSync(addonDir, backupDir);
9425
+ fs.renameSync(addonDir, backupDir);
9426
9426
  let result;
9427
9427
  try {
9428
9428
  if (this.installSource === "local" || this.installSource === "symlink") {
@@ -9437,11 +9437,11 @@ var AddonInstaller = class AddonInstaller {
9437
9437
  } catch (installErr) {
9438
9438
  this.logger.error(`${packageName} — install failed, restoring backup`, { meta: { error: errMsg$1(installErr) } });
9439
9439
  try {
9440
- if (fs$1.existsSync(addonDir)) fs$1.rmSync(addonDir, {
9440
+ if (fs.existsSync(addonDir)) fs.rmSync(addonDir, {
9441
9441
  recursive: true,
9442
9442
  force: true
9443
9443
  });
9444
- fs$1.renameSync(backupDir, addonDir);
9444
+ fs.renameSync(backupDir, addonDir);
9445
9445
  this.manifest.upsert(packageName, {
9446
9446
  version: current.version,
9447
9447
  source: current.source,
@@ -9502,7 +9502,7 @@ var AddonInstaller = class AddonInstaller {
9502
9502
  const current = this.manifest.get(packageName);
9503
9503
  if (current == null) throw new Error(`Cannot update ${packageName}: not currently tracked in manifest`);
9504
9504
  const addonDir = path$1.join(this.addonsDir, packageName);
9505
- if (!fs$1.existsSync(addonDir)) throw new Error(`Cannot update ${packageName}: install dir ${addonDir} missing`);
9505
+ if (!fs.existsSync(addonDir)) throw new Error(`Cannot update ${packageName}: install dir ${addonDir} missing`);
9506
9506
  await this.installRuntimeDependencies(stagedPath, packageName);
9507
9507
  await this.installNativeDependencies(stagedPath, packageName);
9508
9508
  this.dedupeTreeAgainstClosure(stagedPath, packageName);
@@ -9511,14 +9511,14 @@ var AddonInstaller = class AddonInstaller {
9511
9511
  ensureDir(backupRoot);
9512
9512
  const backupDir = path$1.join(backupRoot, ts);
9513
9513
  this.logger.info(`${packageName} — backing up v${current.version} → ${backupDir}`);
9514
- fs$1.renameSync(addonDir, backupDir);
9514
+ fs.renameSync(addonDir, backupDir);
9515
9515
  try {
9516
9516
  try {
9517
- fs$1.renameSync(stagedPath, addonDir);
9517
+ fs.renameSync(stagedPath, addonDir);
9518
9518
  } catch (renameErr) {
9519
9519
  if (renameErr.code === "EXDEV") {
9520
- fs$1.cpSync(stagedPath, addonDir, { recursive: true });
9521
- fs$1.rmSync(stagedPath, {
9520
+ fs.cpSync(stagedPath, addonDir, { recursive: true });
9521
+ fs.rmSync(stagedPath, {
9522
9522
  recursive: true,
9523
9523
  force: true
9524
9524
  });
@@ -9527,11 +9527,11 @@ var AddonInstaller = class AddonInstaller {
9527
9527
  } catch (swapErr) {
9528
9528
  this.logger.error(`${packageName} — staged swap failed, restoring backup`, { meta: { error: errMsg$1(swapErr) } });
9529
9529
  try {
9530
- if (fs$1.existsSync(addonDir)) fs$1.rmSync(addonDir, {
9530
+ if (fs.existsSync(addonDir)) fs.rmSync(addonDir, {
9531
9531
  recursive: true,
9532
9532
  force: true
9533
9533
  });
9534
- fs$1.renameSync(backupDir, addonDir);
9534
+ fs.renameSync(backupDir, addonDir);
9535
9535
  this.manifest.upsert(packageName, {
9536
9536
  version: current.version,
9537
9537
  source: current.source,
@@ -9570,20 +9570,20 @@ var AddonInstaller = class AddonInstaller {
9570
9570
  this.logger.warn(`${packageName} — no backup to rollback to`);
9571
9571
  return null;
9572
9572
  }
9573
- if (!fs$1.existsSync(entry.lastBackupDir)) {
9573
+ if (!fs.existsSync(entry.lastBackupDir)) {
9574
9574
  this.logger.warn(`${packageName} — backup dir vanished: ${entry.lastBackupDir}`);
9575
9575
  return null;
9576
9576
  }
9577
9577
  const addonDir = path$1.join(this.addonsDir, packageName);
9578
- if (fs$1.existsSync(addonDir)) fs$1.rmSync(addonDir, {
9578
+ if (fs.existsSync(addonDir)) fs.rmSync(addonDir, {
9579
9579
  recursive: true,
9580
9580
  force: true
9581
9581
  });
9582
- fs$1.renameSync(entry.lastBackupDir, addonDir);
9582
+ fs.renameSync(entry.lastBackupDir, addonDir);
9583
9583
  const pkgJsonPath = path$1.join(addonDir, "package.json");
9584
9584
  let restoredVersion = entry.version;
9585
- if (fs$1.existsSync(pkgJsonPath)) try {
9586
- const parsed = JSON.parse(fs$1.readFileSync(pkgJsonPath, "utf-8"));
9585
+ if (fs.existsSync(pkgJsonPath)) try {
9586
+ const parsed = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"));
9587
9587
  if (typeof parsed === "object" && parsed != null) {
9588
9588
  const v = parsed.version;
9589
9589
  if (typeof v === "string" && v.length > 0) restoredVersion = v;
@@ -9631,7 +9631,7 @@ var AddonInstaller = class AddonInstaller {
9631
9631
  return false;
9632
9632
  }
9633
9633
  try {
9634
- await fs$1.promises.rm(target, {
9634
+ await fs.promises.rm(target, {
9635
9635
  recursive: true,
9636
9636
  force: true
9637
9637
  });
@@ -9649,7 +9649,7 @@ var AddonInstaller = class AddonInstaller {
9649
9649
  listBackupsFor(packageName) {
9650
9650
  const dir = path$1.join(this.backupsRoot, packageName);
9651
9651
  try {
9652
- return fs$1.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => path$1.join(dir, e.name)).sort();
9652
+ return fs.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => path$1.join(dir, e.name)).sort();
9653
9653
  } catch {
9654
9654
  return [];
9655
9655
  }
@@ -9681,7 +9681,7 @@ var AddonInstaller = class AddonInstaller {
9681
9681
  for (const dir of [pkgDir, path$1.dirname(pkgDir)]) {
9682
9682
  if (!this.isInsideBackups(dir)) continue;
9683
9683
  try {
9684
- await fs$1.promises.rmdir(dir);
9684
+ await fs.promises.rmdir(dir);
9685
9685
  } catch {
9686
9686
  return;
9687
9687
  }
@@ -9763,7 +9763,7 @@ var AddonInstaller = class AddonInstaller {
9763
9763
  */
9764
9764
  resolveBackupToKeep(packageName, backups) {
9765
9765
  const liveDir = path$1.join(this.addonsDir, packageName);
9766
- if (!fs$1.existsSync(liveDir)) {
9766
+ if (!fs.existsSync(liveDir)) {
9767
9767
  const newest = backups[backups.length - 1] ?? null;
9768
9768
  if (newest != null) this.logger.warn(`${packageName} — live install dir missing; retaining its newest backup as the only surviving copy`, { meta: {
9769
9769
  liveDir,
@@ -9780,7 +9780,7 @@ var AddonInstaller = class AddonInstaller {
9780
9780
  listBackedUpPackages() {
9781
9781
  let entries;
9782
9782
  try {
9783
- entries = fs$1.readdirSync(this.backupsRoot, { withFileTypes: true });
9783
+ entries = fs.readdirSync(this.backupsRoot, { withFileTypes: true });
9784
9784
  } catch {
9785
9785
  return [];
9786
9786
  }
@@ -9792,14 +9792,14 @@ var AddonInstaller = class AddonInstaller {
9792
9792
  continue;
9793
9793
  }
9794
9794
  const scopeDir = path$1.join(this.backupsRoot, entry.name);
9795
- for (const inner of fs$1.readdirSync(scopeDir, { withFileTypes: true })) if (inner.isDirectory()) names.push(`${entry.name}/${inner.name}`);
9795
+ for (const inner of fs.readdirSync(scopeDir, { withFileTypes: true })) if (inner.isDirectory()) names.push(`${entry.name}/${inner.name}`);
9796
9796
  }
9797
9797
  return names;
9798
9798
  }
9799
9799
  async uninstall(packageName) {
9800
9800
  const addonDir = path$1.join(this.addonsDir, packageName);
9801
- if (fs$1.existsSync(addonDir)) {
9802
- fs$1.rmSync(addonDir, {
9801
+ if (fs.existsSync(addonDir)) {
9802
+ fs.rmSync(addonDir, {
9803
9803
  recursive: true,
9804
9804
  force: true
9805
9805
  });
@@ -9807,8 +9807,8 @@ var AddonInstaller = class AddonInstaller {
9807
9807
  return;
9808
9808
  }
9809
9809
  const legacyDir = path$1.join(this.addonsDir, packageName.replace(/^@[^/]+\//, ""));
9810
- if (fs$1.existsSync(legacyDir)) {
9811
- fs$1.rmSync(legacyDir, {
9810
+ if (fs.existsSync(legacyDir)) {
9811
+ fs.rmSync(legacyDir, {
9812
9812
  recursive: true,
9813
9813
  force: true
9814
9814
  });
@@ -9816,22 +9816,22 @@ var AddonInstaller = class AddonInstaller {
9816
9816
  }
9817
9817
  }
9818
9818
  listInstalled() {
9819
- if (!fs$1.existsSync(this.addonsDir)) return [];
9819
+ if (!fs.existsSync(this.addonsDir)) return [];
9820
9820
  const packageDirs = [];
9821
- for (const entry of fs$1.readdirSync(this.addonsDir, { withFileTypes: true })) {
9821
+ for (const entry of fs.readdirSync(this.addonsDir, { withFileTypes: true })) {
9822
9822
  if (!isDirEntry(entry, this.addonsDir)) continue;
9823
9823
  if (entry.name.startsWith("@")) {
9824
9824
  const scopeDir = path$1.join(this.addonsDir, entry.name);
9825
- for (const inner of fs$1.readdirSync(scopeDir, { withFileTypes: true })) if (isDirEntry(inner, scopeDir)) packageDirs.push(path$1.join(scopeDir, inner.name));
9825
+ for (const inner of fs.readdirSync(scopeDir, { withFileTypes: true })) if (isDirEntry(inner, scopeDir)) packageDirs.push(path$1.join(scopeDir, inner.name));
9826
9826
  } else packageDirs.push(path$1.join(this.addonsDir, entry.name));
9827
9827
  }
9828
9828
  return packageDirs.map((dir) => {
9829
9829
  const pkgPath = path$1.join(dir, "package.json");
9830
- if (!fs$1.existsSync(pkgPath)) return null;
9830
+ if (!fs.existsSync(pkgPath)) return null;
9831
9831
  const pkg = readPackageJson(pkgPath);
9832
9832
  if (!pkg || !pkg.camstackAddons) return null;
9833
9833
  const sourceFile = path$1.join(dir, ".install-source");
9834
- const installSource = fs$1.existsSync(sourceFile) ? parseInstallSource(fs$1.readFileSync(sourceFile, "utf-8").trim()) : void 0;
9834
+ const installSource = fs.existsSync(sourceFile) ? parseInstallSource(fs.readFileSync(sourceFile, "utf-8").trim()) : void 0;
9835
9835
  return {
9836
9836
  name: pkg.name,
9837
9837
  version: pkg.version,
@@ -9841,13 +9841,13 @@ var AddonInstaller = class AddonInstaller {
9841
9841
  }).filter((item) => item !== null);
9842
9842
  }
9843
9843
  isInstalled(packageName) {
9844
- if (fs$1.existsSync(path$1.join(this.addonsDir, packageName, "package.json"))) return true;
9845
- return fs$1.existsSync(path$1.join(this.addonsDir, packageName.replace(/^@[^/]+\//, ""), "package.json"));
9844
+ if (fs.existsSync(path$1.join(this.addonsDir, packageName, "package.json"))) return true;
9845
+ return fs.existsSync(path$1.join(this.addonsDir, packageName.replace(/^@[^/]+\//, ""), "package.json"));
9846
9846
  }
9847
9847
  getInstalledPackage(packageName) {
9848
9848
  let pkgPath = path$1.join(this.addonsDir, packageName, "package.json");
9849
- if (!fs$1.existsSync(pkgPath)) pkgPath = path$1.join(this.addonsDir, packageName.replace(/^@[^/]+\//, ""), "package.json");
9850
- if (!fs$1.existsSync(pkgPath)) return null;
9849
+ if (!fs.existsSync(pkgPath)) pkgPath = path$1.join(this.addonsDir, packageName.replace(/^@[^/]+\//, ""), "package.json");
9850
+ if (!fs.existsSync(pkgPath)) return null;
9851
9851
  const pkg = readPackageJson(pkgPath);
9852
9852
  if (!pkg) return null;
9853
9853
  return {
@@ -9866,7 +9866,7 @@ var AddonInstaller = class AddonInstaller {
9866
9866
  ]) {
9867
9867
  const candidate = path$1.join(this.workspaceDir, dirName);
9868
9868
  try {
9869
- const pkg = asJsonObject$1(parseJsonUnknown(fs$1.readFileSync(path$1.join(candidate, "package.json"), "utf-8")));
9869
+ const pkg = asJsonObject$1(parseJsonUnknown(fs.readFileSync(path$1.join(candidate, "package.json"), "utf-8")));
9870
9870
  if (pkg && asString$1(pkg["name"]) === packageName) return candidate;
9871
9871
  } catch {}
9872
9872
  }
@@ -9875,7 +9875,7 @@ var AddonInstaller = class AddonInstaller {
9875
9875
  /** Ensure a package is built (dist/ exists and page bundles present) */
9876
9876
  async ensureBuilt(packageName, sourceDir, pkgData) {
9877
9877
  const distDir = path$1.join(sourceDir, "dist");
9878
- if (!(!fs$1.existsSync(distDir) || this.isDistIncomplete(pkgData, sourceDir))) return;
9878
+ if (!(!fs.existsSync(distDir) || this.isDistIncomplete(pkgData, sourceDir))) return;
9879
9879
  this.logger.info(`${packageName} — building (dist/ missing or incomplete)`);
9880
9880
  try {
9881
9881
  await runNpm(["run", "build"], this.npmRunOptions(sourceDir, 18e4));
@@ -9890,7 +9890,7 @@ var AddonInstaller = class AddonInstaller {
9890
9890
  if (!camstack?.addons) return false;
9891
9891
  for (const addon of camstack.addons) {
9892
9892
  if (!addon.pages) continue;
9893
- for (const page of addon.pages) if (page.bundle && !fs$1.existsSync(path$1.join(sourceDir, "dist", page.bundle))) return true;
9893
+ for (const page of addon.pages) if (page.bundle && !fs.existsSync(path$1.join(sourceDir, "dist", page.bundle))) return true;
9894
9894
  }
9895
9895
  return false;
9896
9896
  }
@@ -9899,7 +9899,7 @@ var AddonInstaller = class AddonInstaller {
9899
9899
  function isDirEntry(entry, parentDir) {
9900
9900
  if (entry.isDirectory()) return true;
9901
9901
  if (entry.isSymbolicLink()) try {
9902
- return fs$1.statSync(path$1.join(parentDir, entry.name)).isDirectory();
9902
+ return fs.statSync(path$1.join(parentDir, entry.name)).isDirectory();
9903
9903
  } catch {
9904
9904
  return false;
9905
9905
  }
@@ -9998,7 +9998,7 @@ function selectAddonResidue(candidates) {
9998
9998
  }
9999
9999
  function readDeclaredName(dir) {
10000
10000
  try {
10001
- const parsed = JSON.parse(fs$1.readFileSync(path$1.join(dir, "package.json"), "utf-8"));
10001
+ const parsed = JSON.parse(fs.readFileSync(path$1.join(dir, "package.json"), "utf-8"));
10002
10002
  if (typeof parsed !== "object" || parsed === null) return null;
10003
10003
  const name = parsed.name;
10004
10004
  return typeof name === "string" ? name : null;
@@ -10008,7 +10008,7 @@ function readDeclaredName(dir) {
10008
10008
  }
10009
10009
  function readDeclaredVersion(dir) {
10010
10010
  try {
10011
- const parsed = JSON.parse(fs$1.readFileSync(path$1.join(dir, "package.json"), "utf-8"));
10011
+ const parsed = JSON.parse(fs.readFileSync(path$1.join(dir, "package.json"), "utf-8"));
10012
10012
  if (typeof parsed !== "object" || parsed === null) return null;
10013
10013
  const version = parsed.version;
10014
10014
  return typeof version === "string" ? version : null;
@@ -10018,7 +10018,7 @@ function readDeclaredVersion(dir) {
10018
10018
  }
10019
10019
  function isDirLike(p) {
10020
10020
  try {
10021
- return fs$1.statSync(p).isDirectory();
10021
+ return fs.statSync(p).isDirectory();
10022
10022
  } catch {
10023
10023
  return false;
10024
10024
  }
@@ -10028,7 +10028,7 @@ function freeQuarantineTarget(store, scope, dirName) {
10028
10028
  const base = scope === null ? dirName : `${scope.replace("@", "")}__${dirName}`;
10029
10029
  let candidate = path$1.join(store, base);
10030
10030
  let n = 1;
10031
- while (fs$1.existsSync(candidate)) {
10031
+ while (fs.existsSync(candidate)) {
10032
10032
  candidate = path$1.join(store, `${base}-${n}`);
10033
10033
  n += 1;
10034
10034
  }
@@ -10045,7 +10045,7 @@ function freeQuarantineTarget(store, scope, dirName) {
10045
10045
  function quarantineAddonResidue(addonsDir, log) {
10046
10046
  const quarantined = [];
10047
10047
  const failed = [];
10048
- if (!fs$1.existsSync(addonsDir)) return {
10048
+ if (!fs.existsSync(addonsDir)) return {
10049
10049
  quarantined,
10050
10050
  failed
10051
10051
  };
@@ -10053,7 +10053,7 @@ function quarantineAddonResidue(addonsDir, log) {
10053
10053
  const scan = (parent, scope) => {
10054
10054
  let names;
10055
10055
  try {
10056
- names = fs$1.readdirSync(parent);
10056
+ names = fs.readdirSync(parent);
10057
10057
  } catch {
10058
10058
  return;
10059
10059
  }
@@ -10072,8 +10072,8 @@ function quarantineAddonResidue(addonsDir, log) {
10072
10072
  const version = readDeclaredVersion(full);
10073
10073
  const to = freeQuarantineTarget(store, scope, dirName);
10074
10074
  try {
10075
- fs$1.mkdirSync(store, { recursive: true });
10076
- fs$1.renameSync(full, to);
10075
+ fs.mkdirSync(store, { recursive: true });
10076
+ fs.renameSync(full, to);
10077
10077
  } catch (err) {
10078
10078
  const error = err instanceof Error ? err.message : String(err);
10079
10079
  failed.push({
@@ -10114,8 +10114,8 @@ function detectWorkspacePackagesDir(startDir) {
10114
10114
  current = path$1.dirname(current);
10115
10115
  const packagesDir = path$1.join(current, "packages");
10116
10116
  const rootPkgJson = path$1.join(current, "package.json");
10117
- if (fs$1.existsSync(packagesDir) && fs$1.existsSync(rootPkgJson)) try {
10118
- const rootPkg = JSON.parse(fs$1.readFileSync(rootPkgJson, "utf-8"));
10117
+ if (fs.existsSync(packagesDir) && fs.existsSync(rootPkgJson)) try {
10118
+ const rootPkg = JSON.parse(fs.readFileSync(rootPkgJson, "utf-8"));
10119
10119
  if (rootPkg.workspaces || rootPkg.name === "camstack-server" || rootPkg.name === "camstack") return packagesDir;
10120
10120
  } catch {}
10121
10121
  }
@@ -10154,11 +10154,11 @@ function getRestartMarkerPath(dataDir) {
10154
10154
  * intact or no marker at all (never a half-written file).
10155
10155
  */
10156
10156
  function writePendingRestart(dataDir, marker) {
10157
- fs$1.mkdirSync(dataDir, { recursive: true });
10157
+ fs.mkdirSync(dataDir, { recursive: true });
10158
10158
  const markerPath = getRestartMarkerPath(dataDir);
10159
10159
  const tmpPath = `${markerPath}.tmp`;
10160
- fs$1.writeFileSync(tmpPath, JSON.stringify(marker, null, 2), "utf-8");
10161
- fs$1.renameSync(tmpPath, markerPath);
10160
+ fs.writeFileSync(tmpPath, JSON.stringify(marker, null, 2), "utf-8");
10161
+ fs.renameSync(tmpPath, markerPath);
10162
10162
  }
10163
10163
  /**
10164
10164
  * Read + consume the marker. Returns the parsed payload on success and
@@ -10183,10 +10183,10 @@ function writePendingRestart(dataDir, marker) {
10183
10183
  */
10184
10184
  function readPendingRestart(dataDir) {
10185
10185
  const markerPath = getRestartMarkerPath(dataDir);
10186
- if (!fs$1.existsSync(markerPath)) return null;
10186
+ if (!fs.existsSync(markerPath)) return null;
10187
10187
  let raw;
10188
10188
  try {
10189
- raw = fs$1.readFileSync(markerPath, "utf-8");
10189
+ raw = fs.readFileSync(markerPath, "utf-8");
10190
10190
  } catch (err) {
10191
10191
  console.error("[restart-coordinator] Marker unreadable — leaving in place:", err);
10192
10192
  return null;
@@ -10225,7 +10225,7 @@ function readPendingRestart(dataDir) {
10225
10225
  /** Remove the marker if present. No-op if missing. */
10226
10226
  function clearPendingRestart(dataDir) {
10227
10227
  const markerPath = getRestartMarkerPath(dataDir);
10228
- fs$1.rmSync(markerPath, { force: true });
10228
+ fs.rmSync(markerPath, { force: true });
10229
10229
  }
10230
10230
  function isRestartKind(value) {
10231
10231
  return value === "framework-update" || value === "manual" || value === "system";
@@ -10237,7 +10237,7 @@ function scheduleSelfRestart(options = {}) {
10237
10237
  const touchTarget = process.env["CAMSTACK_RESTART_TOUCH_FILE"];
10238
10238
  if (touchTarget !== void 0 && touchTarget.length > 0) try {
10239
10239
  const now = /* @__PURE__ */ new Date();
10240
- fs$1.utimesSync(touchTarget, now, now);
10240
+ fs.utimesSync(touchTarget, now, now);
10241
10241
  return;
10242
10242
  } catch (err) {
10243
10243
  console.error("[restart-coordinator] dev touch-reload failed; falling through to process exit:", err);
@@ -14610,11 +14610,11 @@ function applyEnvOverrides(raw) {
14610
14610
  return result;
14611
14611
  }
14612
14612
  function loadYaml(configPath) {
14613
- if (!fs$1.existsSync(configPath)) {
14613
+ if (!fs.existsSync(configPath)) {
14614
14614
  console.warn(`[ConfigManager] Config file not found at: ${configPath}\n → Using built-in defaults. Set CONFIG_PATH env var or create the file.\n → Example path from project root: ./server/backend/data/config.yaml`);
14615
14615
  return {};
14616
14616
  }
14617
- const parsed = load(fs$1.readFileSync(configPath, "utf-8")) ?? {};
14617
+ const parsed = load(fs.readFileSync(configPath, "utf-8")) ?? {};
14618
14618
  console.log(`[ConfigManager] Loaded config from: ${configPath}`);
14619
14619
  return parsed;
14620
14620
  }
@@ -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);
@@ -22699,7 +22711,7 @@ async function probeVaapiInit(renderNode) {
22699
22711
  */
22700
22712
  function safeExistsSync(path) {
22701
22713
  try {
22702
- return fs$1.existsSync(path);
22714
+ return fs.existsSync(path);
22703
22715
  } catch {
22704
22716
  return false;
22705
22717
  }
@@ -22718,11 +22730,11 @@ function probeLinuxGpus() {
22718
22730
  if (safeExistsSync("/dev/nvidia0") || safeExistsSync("/proc/driver/nvidia/version")) signals.hasNvidiaGpu = true;
22719
22731
  try {
22720
22732
  const drmDir = "/sys/class/drm";
22721
- if (fs$1.existsSync(drmDir)) for (const entry of fs$1.readdirSync(drmDir)) {
22733
+ if (fs.existsSync(drmDir)) for (const entry of fs.readdirSync(drmDir)) {
22722
22734
  if (!entry.startsWith("card")) continue;
22723
22735
  const vendorPath = `${drmDir}/${entry}/device/vendor`;
22724
22736
  if (!safeExistsSync(vendorPath)) continue;
22725
- const vendor = fs$1.readFileSync(vendorPath, "utf8").trim().toLowerCase();
22737
+ const vendor = fs.readFileSync(vendorPath, "utf8").trim().toLowerCase();
22726
22738
  if (vendor === "0x10de") signals.hasNvidiaGpu = true;
22727
22739
  else if (vendor === "0x1002") signals.hasAmdGpu = true;
22728
22740
  else if (vendor === "0x8086") signals.hasIntelGpu = true;
@@ -22940,21 +22952,21 @@ function sleep$1(ms) {
22940
22952
  * crashed holder) is stolen.
22941
22953
  */
22942
22954
  async function withFileLock(lockPath, fn) {
22943
- fs$1.mkdirSync(join(lockPath, ".."), { recursive: true });
22955
+ fs.mkdirSync(join(lockPath, ".."), { recursive: true });
22944
22956
  for (;;) try {
22945
- const fd = fs$1.openSync(lockPath, "wx");
22946
- fs$1.closeSync(fd);
22957
+ const fd = fs.openSync(lockPath, "wx");
22958
+ fs.closeSync(fd);
22947
22959
  break;
22948
22960
  } catch {
22949
22961
  try {
22950
- if (Date.now() - fs$1.statSync(lockPath).mtimeMs > LOCK_STALE_MS) fs$1.rmSync(lockPath, { force: true });
22962
+ if (Date.now() - fs.statSync(lockPath).mtimeMs > LOCK_STALE_MS) fs.rmSync(lockPath, { force: true });
22951
22963
  else await sleep$1(LOCK_POLL_MS);
22952
22964
  } catch {}
22953
22965
  }
22954
22966
  try {
22955
22967
  return await fn();
22956
22968
  } finally {
22957
- fs$1.rmSync(lockPath, { force: true });
22969
+ fs.rmSync(lockPath, { force: true });
22958
22970
  }
22959
22971
  }
22960
22972
  /** Coalesce in-process + serialize cross-process for one binary id. */
@@ -23012,7 +23024,7 @@ var AddonDepsManager = class {
23012
23024
  * failed or tampered download throws, and provisioning reports it.
23013
23025
  */
23014
23026
  async stageNativeDepsDeclaredBy(requirementsFile) {
23015
- if (!declaresEdgetpuDelegate(fs$1.readFileSync(requirementsFile, "utf8"))) return;
23027
+ if (!declaresEdgetpuDelegate(fs.readFileSync(requirementsFile, "utf8"))) return;
23016
23028
  await singleFlight(this.depsDir, "edgetpu-delegate", () => ensureEdgetpuDelegate(this.nodeRoot, this.logger));
23017
23029
  }
23018
23030
  getDepsDir() {
@@ -24049,7 +24061,7 @@ async function buildAddonContext(runtime, declaration, dataDir, options) {
24049
24061
  const addonId = declaration.id;
24050
24062
  const nodeDataDir = process.env["CAMSTACK_DATA"] ?? dataDir;
24051
24063
  const addonDataDir = path$1.resolve(nodeDataDir, "addons-data", addonId);
24052
- fs$1.mkdirSync(addonDataDir, { recursive: true });
24064
+ fs.mkdirSync(addonDataDir, { recursive: true });
24053
24065
  if (runtime.mode === "broker") ensureBindingSubscription(runtime.broker);
24054
24066
  const regs = getRegistries(nodeId);
24055
24067
  const workerResolver = {
@@ -25850,7 +25862,7 @@ var FailedRunnerRetryLedger = class {
25850
25862
  function readRunnerPackageVersions(addonDirs) {
25851
25863
  const out = {};
25852
25864
  for (const dir of addonDirs) try {
25853
- const raw = JSON.parse(fs$1.readFileSync(path$1.join(dir, "package.json"), "utf-8"));
25865
+ const raw = JSON.parse(fs.readFileSync(path$1.join(dir, "package.json"), "utf-8"));
25854
25866
  const version = typeof raw === "object" && raw !== null ? Reflect.get(raw, "version") : null;
25855
25867
  out[dir] = typeof version === "string" && version.length > 0 ? version : null;
25856
25868
  } catch {
@@ -25911,7 +25923,7 @@ function readAddonHeapDeclaration(spec) {
25911
25923
  if (cached !== void 0) return cached;
25912
25924
  let declaration = EMPTY_HEAP_DECLARATION;
25913
25925
  for (const manifestPath of [path$1.join(spec.addonDir, "package.json"), path$1.join(path$1.dirname(spec.addonDir), "package.json")]) try {
25914
- const raw = fs$1.readFileSync(manifestPath, "utf8");
25926
+ const raw = fs.readFileSync(manifestPath, "utf8");
25915
25927
  const parsed = JSON.parse(raw);
25916
25928
  const profile = extractHeapProfile(parsed, spec.addonId);
25917
25929
  const maxOldSpaceMb = extractMaxOldSpaceMb(parsed, spec.addonId);
@@ -27133,17 +27145,17 @@ var JobJournal = class {
27133
27145
  return path$1.join(this.jobsDir, `${id}.json`);
27134
27146
  }
27135
27147
  writeAtomic(filePath, data) {
27136
- fs$1.mkdirSync(path$1.dirname(filePath), { recursive: true });
27148
+ fs.mkdirSync(path$1.dirname(filePath), { recursive: true });
27137
27149
  const tmp = `${filePath}.tmp.${process.pid}.${Date.now()}`;
27138
- fs$1.writeFileSync(tmp, JSON.stringify(data, null, 2), {
27150
+ fs.writeFileSync(tmp, JSON.stringify(data, null, 2), {
27139
27151
  encoding: "utf-8",
27140
27152
  mode: 384
27141
27153
  });
27142
- fs$1.renameSync(tmp, filePath);
27154
+ fs.renameSync(tmp, filePath);
27143
27155
  }
27144
27156
  readIndex() {
27145
27157
  try {
27146
- const raw = JSON.parse(fs$1.readFileSync(this.indexPath, "utf-8"));
27158
+ const raw = JSON.parse(fs.readFileSync(this.indexPath, "utf-8"));
27147
27159
  if (raw && Array.isArray(raw.jobIds)) return {
27148
27160
  version: 1,
27149
27161
  jobIds: raw.jobIds
@@ -27168,7 +27180,7 @@ var JobJournal = class {
27168
27180
  }
27169
27181
  getJob(id) {
27170
27182
  try {
27171
- const parsed = lifecycleJobSchema.safeParse(JSON.parse(fs$1.readFileSync(this.jobPath(id), "utf-8")));
27183
+ const parsed = lifecycleJobSchema.safeParse(JSON.parse(fs.readFileSync(this.jobPath(id), "utf-8")));
27172
27184
  return parsed.success ? parsed.data : null;
27173
27185
  } catch {
27174
27186
  return null;
@@ -27233,14 +27245,14 @@ var StagingArea = class {
27233
27245
  }
27234
27246
  async fetchAndStage(input) {
27235
27247
  const destDir = path$1.join(this.stagingDir, input.jobId, safeSegment(input.name));
27236
- fs$1.rmSync(destDir, {
27248
+ fs.rmSync(destDir, {
27237
27249
  recursive: true,
27238
27250
  force: true
27239
27251
  });
27240
27252
  const tgz = await this.deps.fetchTarball(input.name, input.version, input.signal);
27241
27253
  if (input.signal.aborted) throw new Error("staging aborted after fetch");
27242
27254
  await this.deps.extract(tgz, destDir);
27243
- const raw = JSON.parse(fs$1.readFileSync(path$1.join(destDir, "package.json"), "utf-8"));
27255
+ const raw = JSON.parse(fs.readFileSync(path$1.join(destDir, "package.json"), "utf-8"));
27244
27256
  if (typeof raw.version !== "string" || raw.version.length === 0) throw new Error(`staging validation failed: ${input.name} staged a package.json with no version`);
27245
27257
  if (EXACT_SEMVER.test(input.version) && raw.version !== input.version) throw new Error(`staging validation failed: ${input.name} expected version ${input.version}, got ${raw.version}`);
27246
27258
  return {
@@ -27249,7 +27261,7 @@ var StagingArea = class {
27249
27261
  };
27250
27262
  }
27251
27263
  cleanup(jobId) {
27252
- fs$1.rmSync(path$1.join(this.stagingDir, jobId), {
27264
+ fs.rmSync(path$1.join(this.stagingDir, jobId), {
27253
27265
  recursive: true,
27254
27266
  force: true
27255
27267
  });
@@ -27264,13 +27276,13 @@ var StagingArea = class {
27264
27276
  sweepOrphans() {
27265
27277
  let entries;
27266
27278
  try {
27267
- entries = fs$1.readdirSync(this.stagingDir);
27279
+ entries = fs.readdirSync(this.stagingDir);
27268
27280
  } catch {
27269
27281
  return 0;
27270
27282
  }
27271
27283
  let removed = 0;
27272
27284
  for (const name of entries) try {
27273
- fs$1.rmSync(path$1.join(this.stagingDir, name), {
27285
+ fs.rmSync(path$1.join(this.stagingDir, name), {
27274
27286
  recursive: true,
27275
27287
  force: true
27276
27288
  });
@@ -27448,7 +27460,7 @@ var LifecycleJobEngine = class {
27448
27460
  * on failure → `failed`.
27449
27461
  */
27450
27462
  async reconcileJob(job) {
27451
- const exists = this.deps.stagedPathExists ?? ((p) => fs$1.existsSync(p));
27463
+ const exists = this.deps.stagedPathExists ?? ((p) => fs.existsSync(p));
27452
27464
  for (const task of job.tasks) {
27453
27465
  if (task.target === "framework") {
27454
27466
  if (!this.isTerminal(task.phase)) this.skipFrameworkTask(job, task);
@@ -28085,7 +28097,7 @@ var CatalogRegistry = class {
28085
28097
  const file = path$1.join(packageDir, "i18n", `${lang}.json`);
28086
28098
  let text;
28087
28099
  try {
28088
- text = fs$1.readFileSync(file, "utf8");
28100
+ text = fs.readFileSync(file, "utf8");
28089
28101
  } catch {
28090
28102
  continue;
28091
28103
  }