@camstack/server 1.2.921 → 1.2.923

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 (93) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/api/trpc/generated-cap-routers.js +1843 -1833
  3. package/package.json +9 -10
  4. package/system/dist/addon-utils.mjs +1 -1
  5. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  6. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +4 -4
  7. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  8. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +5 -5
  9. package/system/dist/builtins/alerts/alerts.addon.js +1 -1
  10. package/system/dist/builtins/alerts/alerts.addon.mjs +3 -3
  11. package/system/dist/builtins/autotrack/index.js +1 -1
  12. package/system/dist/builtins/autotrack/index.mjs +1 -1
  13. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
  14. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +5 -5
  15. package/system/dist/builtins/calendars/calendars.addon.js +1 -1
  16. package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
  17. package/system/dist/builtins/camera-grid/index.js +1 -1
  18. package/system/dist/builtins/camera-grid/index.mjs +1 -1
  19. package/system/dist/builtins/composer/composer.addon.js +4 -4
  20. package/system/dist/builtins/composer/composer.addon.mjs +4 -4
  21. package/system/dist/builtins/console-logging/index.js +1 -1
  22. package/system/dist/builtins/console-logging/index.mjs +1 -1
  23. package/system/dist/builtins/core-blocks/core-blocks.addon.js +4 -4
  24. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +4 -4
  25. package/system/dist/builtins/device-history/device-history.addon.js +2 -2
  26. package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
  27. package/system/dist/builtins/device-manager/device-manager.addon.js +3 -3
  28. package/system/dist/builtins/device-manager/device-manager.addon.mjs +3 -3
  29. package/system/dist/builtins/hub-forwarder/index.js +1 -1
  30. package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
  31. package/system/dist/builtins/keychain/index.js +4 -4
  32. package/system/dist/builtins/keychain/index.mjs +4 -4
  33. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  34. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  35. package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
  36. package/system/dist/builtins/local-auth/local-auth.addon.mjs +5 -5
  37. package/system/dist/builtins/local-network/local-network.addon.js +3 -3
  38. package/system/dist/builtins/local-network/local-network.addon.mjs +3 -3
  39. package/system/dist/builtins/loki-logging/index.js +1 -1
  40. package/system/dist/builtins/loki-logging/index.mjs +1 -1
  41. package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  42. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +10 -10
  43. package/system/dist/builtins/platform-probe/index.js +1 -1
  44. package/system/dist/builtins/platform-probe/index.mjs +10 -10
  45. package/system/dist/builtins/record-entries/index.js +1 -1
  46. package/system/dist/builtins/record-entries/index.mjs +1 -1
  47. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  48. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  49. package/system/dist/builtins/snapshot/index.js +1 -1
  50. package/system/dist/builtins/snapshot/index.mjs +1 -1
  51. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  52. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +20 -20
  53. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  54. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  55. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
  56. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
  57. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  58. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  59. package/system/dist/builtins/system-config/system-config.addon.js +3 -3
  60. package/system/dist/builtins/system-config/system-config.addon.mjs +115 -115
  61. package/system/dist/builtins/winston-logging/index.js +1 -1
  62. package/system/dist/builtins/winston-logging/index.mjs +1 -1
  63. package/system/dist/{capture-engine-TdUsuTbA.mjs → capture-engine-Bjuf7szh.mjs} +1 -1
  64. package/system/dist/{capture-engine-B1soT1Ps.js → capture-engine-Cm7ZL3jx.js} +1 -1
  65. package/system/dist/{composition-sources-BzrfJ9EV.mjs → composition-sources-CMa04YwQ.mjs} +1 -1
  66. package/system/dist/{composition-sources-BTM1T_QY.js → composition-sources-DFRtvVCC.js} +1 -1
  67. package/system/dist/{constants-sAtTO2DC.mjs → constants-B_z2KueR.mjs} +1 -1
  68. package/system/dist/{constants-DZEiIvtO.js → constants-ttjAKMDn.js} +1 -1
  69. package/system/dist/{coral-accelerators-BW3OcrLD.mjs → coral-accelerators-DBlgWB8k.mjs} +6 -6
  70. package/system/dist/{custom-action-registry-N7flBDwT.mjs → custom-action-registry-B9zFBNVa.mjs} +37 -37
  71. package/system/dist/{device-ca-B9d9j1AQ.mjs → device-ca-B4U-0_tL.mjs} +1 -1
  72. package/system/dist/{device-ca-Bpsv_9zD.js → device-ca-DLbha6bn.js} +1 -1
  73. package/system/dist/{device-row-store-B4mygtF3.js → device-row-store-BPvPzZXw.js} +1 -1
  74. package/system/dist/{device-row-store-OUq-xOJf.mjs → device-row-store-n7N6WKAJ.mjs} +1 -1
  75. package/system/dist/{dist-aEgseEmg.mjs → dist-D4OoBk4J.mjs} +208 -12
  76. package/system/dist/{dist-B-nGf0cw.js → dist-DyPraj2b.js} +208 -12
  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-identity-DxLcMLXg.mjs → hub-identity-DKSKuA9T.mjs} +10 -10
  80. package/system/dist/{hub-identity-DKH4F5ig.js → hub-identity-DTe2rzm0.js} +1 -1
  81. package/system/dist/{hub-mdns-ciao-BeZydc9f.mjs → hub-mdns-ciao-C3S8zMoF.mjs} +2 -2
  82. package/system/dist/{hub-mdns-ciao-CkP1DWxb.js → hub-mdns-ciao-cwf2mysq.js} +2 -2
  83. package/system/dist/index.js +8 -8
  84. package/system/dist/index.mjs +217 -217
  85. package/system/dist/{legacy-integration-rows-door-B4HDGgxv.js → legacy-integration-rows-door-BVTSfMBP.js} +1 -1
  86. package/system/dist/{legacy-integration-rows-door-DdVk69Sm.mjs → legacy-integration-rows-door-DNXKIchh.mjs} +1 -1
  87. package/system/dist/{rename-composition-block-FvczGAYq.js → rename-composition-block-B0vOvO8o.js} +1 -1
  88. package/system/dist/{rename-composition-block-CscC9L8w.mjs → rename-composition-block-DbDlfizP.mjs} +1 -1
  89. package/system/dist/{restore-archive-JRkEdn_v.mjs → restore-archive-BSMhMFzE.mjs} +94 -94
  90. package/system/dist/{restore-archive-BSv5-bWg.js → restore-archive-DTgUyT_Z.js} +1 -1
  91. package/system/dist/{wal-maintenance-DlOdvy-L.js → wal-maintenance-BrO5LKDF.js} +0 -0
  92. package/system/dist/{wal-maintenance-BTiASQ3_.mjs → wal-maintenance-DTAHv1Ih.mjs} +0 -0
  93. package/system/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  import { i as __require } from "./chunk-CNf5ZN-e.mjs";
2
- import { Ao as resolveMethodAuth, Dc as DATAPLANE_SECRET_HEADER$1, Ec as CALLER_STAMPED_CAPABILITIES$1, El as defineRecordKinds, Ft as LOG_LEVEL_RANK, Gc as RUNTIME_DEFAULTS, Gi as isCollectionArrayMethod, Kc as ReadinessRegistry, La as objectInputDeclaresAddonId, Lt as METHOD_ACCESS_MAP, Ml as expandCapMethods, Oc as DEVICE_SETTINGS_CONTRIBUTION_METHODS, Ol as emitDownForOwnedCaps, Pl as getDebugInterest, Qi as isObjectInput, Ra as objectInputDeclaresRequiredDeviceId, Ri as interpolate, S as CATALOG_LANGS, Ui as isArrayOutputSchema, Uo as scopesAllowAddon, Wo as scopesAllowDeviceCap, Wr as describeUnmet, Yn as bareAddonId, Zt as PackageRequiresSchema, _l as collectSecretMarkerRefs, _u as supportedRuntimes, a as AGENT_MDNS_SERVICE_TYPE, ca as lifecycleJobSchema, cl as asJsonObject$1, cu as resolveCapMount, du as scopeKey, ea as isVoidInput, fi as extractNestedAddonId, ga as looseSchema, ha as logLevelAtMost, ju as EventCategory$1, k as CatalogFileSchema, kc as DEVICE_STATUS_METHOD, ku as errMsg$1, ll as asNumber, na as kebabToCamel$1, nu as parseJsonObject, o as AGENT_MDNS_TXT_KEYS, ou as readinessKey, qc as ReadinessTimeoutError, rs as splitTranslationRef, ru as parseJsonUnknown, s as ALL_CAPABILITY_DEFINITIONS, to as procedureAuthKey, ul as asString$1, ws as unmetRequirements, wu as withoutCallerStamp, xl as createEvent$1, xu as userError, yr as compareVersions, zi as isAddonInstanceId, zl as isDebugChannelName, zn as addonSettingsCapability } from "./dist-aEgseEmg.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-B9d9j1AQ.mjs";
2
+ import { Ao as resolveMethodAuth, Dc as DATAPLANE_SECRET_HEADER$1, Ec as CALLER_STAMPED_CAPABILITIES$1, El as defineRecordKinds, Ft as LOG_LEVEL_RANK, Gc as RUNTIME_DEFAULTS, Gi as isCollectionArrayMethod, Kc as ReadinessRegistry, La as objectInputDeclaresAddonId, Lt as METHOD_ACCESS_MAP, Ml as expandCapMethods, Oc as DEVICE_SETTINGS_CONTRIBUTION_METHODS, Ol as emitDownForOwnedCaps, Pl as getDebugInterest, Qi as isObjectInput, Ra as objectInputDeclaresRequiredDeviceId, Ri as interpolate, S as CATALOG_LANGS, Ui as isArrayOutputSchema, Uo as scopesAllowAddon, Wo as scopesAllowDeviceCap, Wr as describeUnmet, Yn as bareAddonId, Zt as PackageRequiresSchema, _l as collectSecretMarkerRefs, _u as supportedRuntimes, a as AGENT_MDNS_SERVICE_TYPE, ca as lifecycleJobSchema, cl as asJsonObject$1, cu as resolveCapMount, du as scopeKey, ea as isVoidInput, fi as extractNestedAddonId, ga as looseSchema, ha as logLevelAtMost, ju as EventCategory$1, k as CatalogFileSchema, kc as DEVICE_STATUS_METHOD, ku as errMsg$1, ll as asNumber, na as kebabToCamel$1, nu as parseJsonObject, o as AGENT_MDNS_TXT_KEYS, ou as readinessKey, qc as ReadinessTimeoutError, rs as splitTranslationRef, ru as parseJsonUnknown, s as ALL_CAPABILITY_DEFINITIONS, to as procedureAuthKey, ul as asString$1, ws as unmetRequirements, wu as withoutCallerStamp, xl as createEvent$1, xu as userError, yr as compareVersions, zi as isAddonInstanceId, zl as isDebugChannelName, zn as addonSettingsCapability } from "./dist-D4OoBk4J.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-B4U-0_tL.mjs";
4
4
  import { t as require_read_all_rows } from "./read-all-rows-TaPqdWNF.mjs";
5
5
  import { a as redactLogText, i as redactLogMeta, r as redactLogEntry, t as isCredentialKeyName } from "./log-redactor-XLDrPzOi.mjs";
6
6
  import { AlertCenterAddon, n as lastCauseAfterChunk, r as readRunnerDisplayName, t as CRASH_BREAKER_ERROR_PREFIX } from "./builtins/alerts/alerts.addon.mjs";
@@ -27,29 +27,29 @@ import { LokiDestination, LokiLoggingAddon } from "./builtins/loki-logging/index
27
27
  import NativeMetricsAddon, { a as NativeMetricsProvider, i as parseProcStatusRss, n as nodeProcReader, r as parseProcStat } from "./builtins/native-metrics/native-metrics.addon.mjs";
28
28
  import { DeviceHistoryAddon } from "./builtins/device-history/device-history.addon.mjs";
29
29
  import { FilesystemStorageAddon, t as FilesystemStorageProvider } from "./builtins/sqlite-storage/filesystem-storage.addon.mjs";
30
- import { D as RecordsEngine, l as SqliteSettingsBackend } from "./wal-maintenance-BTiASQ3_.mjs";
31
- import { n as clearLegacyIntegrationRows, o as readLegacyIntegrationRows } from "./legacy-integration-rows-door-DdVk69Sm.mjs";
30
+ import { D as RecordsEngine, l as SqliteSettingsBackend } from "./wal-maintenance-DTAHv1Ih.mjs";
31
+ import { n as clearLegacyIntegrationRows, o as readLegacyIntegrationRows } from "./legacy-integration-rows-door-DNXKIchh.mjs";
32
32
  import { SqliteSettingsAddon } from "./builtins/sqlite-storage/sqlite-settings.addon.mjs";
33
33
  import { ConfigStore, DeviceStore } from "./builtins/sqlite-storage/index.mjs";
34
34
  import { StorageOrchestratorAddon, a as createHubCapForwardService, i as HUB_CAP_FWD_SERVICE, o as stripForwardedCaller, r as HUB_CAP_FWD_ACTION, s as buildStorageLocationRegistry, t as StorageOrchestratorService, u as storageOrchestratorRecordKinds } from "./builtins/storage-orchestrator/storage-orchestrator.addon.mjs";
35
35
  import "./builtins/storage-orchestrator/index.mjs";
36
- import { A as evaluateExistingCert, B as AGENT_HTTPS_NAMES_COLLECTION, C as localCaCommonName, D as LEAF_RENEWAL_WINDOW_DAYS, E as CA_VALIDITY_DAYS, F as isConstrainedCa, H as AgentHttpsNames, I as isLocalOnlyHostname, L as permitsIdentity, M as PERMITTED_DNS_SUFFIXES, N as PERMITTED_IP_RANGES, O as MAX_LEAF_VALIDITY_DAYS, P as buildNameConstraintSet, R as permitsName, T as systemHostFacts, U as getProcessAgentHttpsNames, V as AGENT_HTTPS_NAMES_COLUMNS, W as setProcessAgentHttpsNames, _ as pemDigest, a as AgentHttpsInstallError, c as certificateNames, d as describeHttpsLeaf, f as installAgentHttps, g as loadAgentHttps, h as issueAgentHttpsLeaf, i as loadOrCreateHubId, k as SERVER_AUTH_OID, l as collectAgentNames, m as isPrivateAddress, n as HUB_IDENTITY_RELATIVE, o as acceptAgentSans, p as isContainerBridgeAddress, r as isAnnouncedHubId, s as agentHttpsPaths, t as HUB_IDENTITY_FILE, u as createAgentHttpsRequest, v as pinnedHttpsCaFingerprint, w as collectCertIdentity, y as CA_COMMON_NAME, z as readNameConstraints } from "./hub-identity-DxLcMLXg.mjs";
37
- 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-sAtTO2DC.mjs";
36
+ import { A as evaluateExistingCert, B as AGENT_HTTPS_NAMES_COLLECTION, C as localCaCommonName, D as LEAF_RENEWAL_WINDOW_DAYS, E as CA_VALIDITY_DAYS, F as isConstrainedCa, H as AgentHttpsNames, I as isLocalOnlyHostname, L as permitsIdentity, M as PERMITTED_DNS_SUFFIXES, N as PERMITTED_IP_RANGES, O as MAX_LEAF_VALIDITY_DAYS, P as buildNameConstraintSet, R as permitsName, T as systemHostFacts, U as getProcessAgentHttpsNames, V as AGENT_HTTPS_NAMES_COLUMNS, W as setProcessAgentHttpsNames, _ as pemDigest, a as AgentHttpsInstallError, c as certificateNames, d as describeHttpsLeaf, f as installAgentHttps, g as loadAgentHttps, h as issueAgentHttpsLeaf, i as loadOrCreateHubId, k as SERVER_AUTH_OID, l as collectAgentNames, m as isPrivateAddress, n as HUB_IDENTITY_RELATIVE, o as acceptAgentSans, p as isContainerBridgeAddress, r as isAnnouncedHubId, s as agentHttpsPaths, t as HUB_IDENTITY_FILE, u as createAgentHttpsRequest, v as pinnedHttpsCaFingerprint, w as collectCertIdentity, y as CA_COMMON_NAME, z as readNameConstraints } from "./hub-identity-DKSKuA9T.mjs";
37
+ 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-B_z2KueR.mjs";
38
38
  import { $ as getProcessMeshCaState, A as emitProcessNodeRegistered, At as readCidrSetting, B as getProcessMeshTlsListenerState, C as verifyMembershipAnswer, Ct as isInsecureOrigin, D as ServiceBroker, Dt as createCidrMatcher, E as Errors, Et as readOriginSetting, F as onProcessNodeRegistered, G as MeshCertificateRegistry, H as setProcessMeshTlsListenerState, I as setProcessMeshHandshakeReporter, J as getProcessMeshCertificateRegistry, K as RENEWAL_ABANDONED, L as setProcessMeshPeerTransportLookup, M as getProcessNodeMeshTransport, N as getProcessPeerLeaf, O as setProcessMeshTlsEnabler, Ot as normalizeIp, P as isProcessVerifiedMeshPeer, Q as MeshCaKeeper, R as renewMeshCertificate, S as signMembershipProof, St as OPAQUE_ORIGIN, SystemConfigAddon, T as TlsTcpTransporter, Tt as parseOriginList, U as MESH_NODE_CERTIFICATES_COLLECTION, V as openMeshTlsWhenRevocationsLoaded, W as MESH_NODE_CERTIFICATES_COLUMNS, X as MeshCrl, Y as setProcessMeshCertificateRegistry, Z as processMeshCrl, _ as keyFingerprintShort, _t as isAllowedAgentDashboardReturnTo, a as dialableHubHost, at as generateMeshCa, b as MEMBERSHIP_PATHS, bt as verifyAgentUiUnlockTicket, c as PAIRING_MAX_CODE_ATTEMPTS, ct as issueMeshLeafForNode, d as PAIRING_PIN_DIGITS, dt as AGENT_DASHBOARD_ORIGINS_FIELD, et as requireProcessMeshCa, f as PAIRING_PROTOCOL, ft as AGENT_UI_UNLOCK_TTL_MS, g as describeCsr, gt as UnlockTicketJtiStore, h as computePairingSas, ht as AGENT_UI_UNLOCK_VERSION, i as AgentPairing, it as exportMeshPrivateKeyPem, j as getProcessMeshHandshakeReporter, k as dropProcessPeer, kt as parseCidrList, l as PAIRING_MAX_SESSIONS, lt as issueMeshLeafFromCsr, m as computePairingCommitment, mt as AGENT_UI_UNLOCK_USE, n as HubPairing, nt as caFingerprintCompact, o as hubHostFromMeshAddress, ot as generateMeshKeyPair, p as PAIRING_TTL_MS, pt as AGENT_UI_UNLOCK_TYP, q as describeMeshLeaf, r as PairingHttpError, rt as createMeshCsrPem, s as PAIRING_CODE_DIGITS, st as isValidAgentNodeId, tt as caFingerprint, u as PAIRING_PATHS, ut as loadMeshCa, v as signPairingProof, vt as mintAgentUiUnlockTicket, w as MESH_TLS_PORT_HELLO_FIELD, wt as normalizeOrigin, x as MembershipResponder, xt as InvalidCorsOriginError, y as verifyPairingProof, yt as parseAgentDashboardOrigins, z as revokeMeshCertificate } from "./builtins/system-config/system-config.addon.mjs";
39
39
  import "./builtins/system-config/index.mjs";
40
40
  import { WinstonDestination, WinstonLoggingAddon } from "./builtins/winston-logging/index.mjs";
41
- 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-N7flBDwT.mjs";
42
- 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-BeZydc9f.mjs";
41
+ 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-B9zFBNVa.mjs";
42
+ 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-C3S8zMoF.mjs";
43
43
  import { n as getPlatformKeychainKey, r as setPlatformKeychainKey, t as clearPlatformKeychainKey } from "./platform-key-source-BWlq0jjn.mjs";
44
44
  import { n as getSinglePidStats, t as getPidStats } from "./resource-monitor-Di9daRwI.mjs";
45
- 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-JRkEdn_v.mjs";
46
- import { r as nodeCoralFs, t as classifyCoralAccelerator } from "./coral-accelerators-BW3OcrLD.mjs";
45
+ 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-BSMhMFzE.mjs";
46
+ import { r as nodeCoralFs, t as classifyCoralAccelerator } from "./coral-accelerators-DBlgWB8k.mjs";
47
47
  import { z } from "zod";
48
48
  import * as crypto$1 from "node:crypto";
49
49
  import { createHash, randomBytes, randomUUID } from "node:crypto";
50
50
  import { PYTHON_VERSION, buildBinaryPath, declaresEdgetpuDelegate, downloadBinary, ensureBinary, ensureBinary as ensureBinary$1, ensureEdgetpuDelegate, ensureFfmpeg, ensureFfmpeg as ensureFfmpeg$1, ensurePython, ensurePython as ensurePython$1, findInPath, getFfmpegDownloadUrl, getPlatformInfo, getPythonDownloadUrl, implementedMethodsOf, installPythonPackages, installPythonPackages as installPythonPackages$1, installPythonRequirements, installPythonRequirements as installPythonRequirements$1 } from "@camstack/types/node";
51
51
  import { connect, createConnection, createServer } from "node:net";
52
- import * as fs from "node:fs";
52
+ import * as fs$1 from "node:fs";
53
53
  import { accessSync, constants, createReadStream, createWriteStream, existsSync, readFileSync, readdirSync } from "node:fs";
54
54
  import * as path$1 from "node:path";
55
55
  import { basename, dirname, isAbsolute, join, resolve } from "node:path";
@@ -5086,7 +5086,7 @@ var PythonEnvManager = class {
5086
5086
  async ensure(options) {
5087
5087
  const probe = await this.probe();
5088
5088
  if (!probe.available || !probe.path) throw userError("system.python-required", void 0, "Python 3.10+ is required but not found on this system");
5089
- if (!fs.existsSync(path$1.join(this.venvPath, "bin", "python"))) await execFileAsync$7(probe.path, [
5089
+ if (!fs$1.existsSync(path$1.join(this.venvPath, "bin", "python"))) await execFileAsync$7(probe.path, [
5090
5090
  "-m",
5091
5091
  "venv",
5092
5092
  this.venvPath
@@ -5109,7 +5109,7 @@ var PythonEnvManager = class {
5109
5109
  }
5110
5110
  spawn(script, args) {
5111
5111
  const venvPython = path$1.join(this.venvPath, "bin", "python");
5112
- if (!fs.existsSync(venvPython)) throw new Error("Python venv not initialized. Call ensure() first.");
5112
+ if (!fs$1.existsSync(venvPython)) throw new Error("Python venv not initialized. Call ensure() first.");
5113
5113
  return spawn(venvPython, [script, ...args]);
5114
5114
  }
5115
5115
  };
@@ -5461,20 +5461,20 @@ var StorageManager = class {
5461
5461
  const basePath = this.locationManager.getBackend(mappedName).basePath;
5462
5462
  location.files = {
5463
5463
  async readFile(p) {
5464
- return fs.promises.readFile(path$1.join(basePath, p));
5464
+ return fs$1.promises.readFile(path$1.join(basePath, p));
5465
5465
  },
5466
5466
  async writeFile(p, data) {
5467
5467
  const full = path$1.join(basePath, p);
5468
- await fs.promises.mkdir(path$1.dirname(full), { recursive: true });
5469
- await fs.promises.writeFile(full, data);
5468
+ await fs$1.promises.mkdir(path$1.dirname(full), { recursive: true });
5469
+ await fs$1.promises.writeFile(full, data);
5470
5470
  },
5471
5471
  async deleteFile(p) {
5472
- await fs.promises.rm(path$1.join(basePath, p), { force: true });
5472
+ await fs$1.promises.rm(path$1.join(basePath, p), { force: true });
5473
5473
  },
5474
5474
  async listFiles(prefix) {
5475
5475
  const dir = prefix ? path$1.join(basePath, prefix) : basePath;
5476
5476
  try {
5477
- return (await fs.promises.readdir(dir)).map((f) => prefix ? `${prefix}/${f}` : f);
5477
+ return (await fs$1.promises.readdir(dir)).map((f) => prefix ? `${prefix}/${f}` : f);
5478
5478
  } catch {
5479
5479
  return [];
5480
5480
  }
@@ -5484,7 +5484,7 @@ var StorageManager = class {
5484
5484
  },
5485
5485
  async exists(p) {
5486
5486
  try {
5487
- await fs.promises.access(path$1.join(basePath, p));
5487
+ await fs$1.promises.access(path$1.join(basePath, p));
5488
5488
  return true;
5489
5489
  } catch {
5490
5490
  return false;
@@ -5934,7 +5934,7 @@ var TRADITIONAL_NATIVE_PACKAGES = ["better-sqlite3"];
5934
5934
  function hasDotNode(dir, maxDepth) {
5935
5935
  let entries;
5936
5936
  try {
5937
- entries = fs.readdirSync(dir, { withFileTypes: true });
5937
+ entries = fs$1.readdirSync(dir, { withFileTypes: true });
5938
5938
  } catch {
5939
5939
  return false;
5940
5940
  }
@@ -5945,7 +5945,7 @@ function hasDotNode(dir, maxDepth) {
5945
5945
  }
5946
5946
  /** Locate the bundled `prebuild-install` bin.js inside the staged closure. */
5947
5947
  function resolvePrebuildInstallBin(closureDir, moduleDir) {
5948
- 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;
5948
+ 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;
5949
5949
  }
5950
5950
  /**
5951
5951
  * Default fetcher: run the closure's own `prebuild-install` under the CURRENT
@@ -5998,7 +5998,7 @@ async function ensureNativePrebuilds(closureDir, options) {
5998
5998
  const fetched = [];
5999
5999
  for (const pkg of packages) {
6000
6000
  const moduleDir = path$1.join(nm, pkg);
6001
- if (!fs.existsSync(moduleDir)) continue;
6001
+ if (!fs$1.existsSync(moduleDir)) continue;
6002
6002
  if (hasDotNode(moduleDir, 4)) continue;
6003
6003
  options.logger.warn("staged closure native prebuild missing — fetching for running ABI", { meta: {
6004
6004
  pkg,
@@ -6061,12 +6061,12 @@ async function ensureNativePrebuilds(closureDir, options) {
6061
6061
  function replantFromBundled(srcModuleDir, dstModuleDir, hasNative) {
6062
6062
  if (!hasNative(srcModuleDir)) return false;
6063
6063
  try {
6064
- fs.rmSync(dstModuleDir, {
6064
+ fs$1.rmSync(dstModuleDir, {
6065
6065
  recursive: true,
6066
6066
  force: true
6067
6067
  });
6068
- fs.mkdirSync(path$1.dirname(dstModuleDir), { recursive: true });
6069
- fs.cpSync(srcModuleDir, dstModuleDir, {
6068
+ fs$1.mkdirSync(path$1.dirname(dstModuleDir), { recursive: true });
6069
+ fs$1.cpSync(srcModuleDir, dstModuleDir, {
6070
6070
  recursive: true,
6071
6071
  dereference: true
6072
6072
  });
@@ -6095,7 +6095,7 @@ async function ensureAddonNativePrebuilds(addonDir, options) {
6095
6095
  const missing = [];
6096
6096
  for (const pkg of packages) {
6097
6097
  const moduleDir = path$1.join(nm, pkg);
6098
- if (!fs.existsSync(moduleDir)) continue;
6098
+ if (!fs$1.existsSync(moduleDir)) continue;
6099
6099
  if (hasNative(moduleDir)) {
6100
6100
  results.push({
6101
6101
  pkg,
@@ -6194,7 +6194,7 @@ async function defaultDownloadTarball(url, destTgz) {
6194
6194
  const res = await fetch(url);
6195
6195
  if (!res.ok || !res.body) throw new Error(`HTTP ${res.status} downloading ${url}`);
6196
6196
  const bytes = Buffer.from(await res.arrayBuffer());
6197
- await fs.promises.writeFile(destTgz, bytes);
6197
+ await fs$1.promises.writeFile(destTgz, bytes);
6198
6198
  }
6199
6199
  async function defaultExtractTarball(tgzPath, destDir) {
6200
6200
  await execFileAsync$5("tar", [
@@ -6280,7 +6280,7 @@ async function resolveUncached(options) {
6280
6280
  argsPrefix: []
6281
6281
  };
6282
6282
  const cliPath = bootstrappedCliPath(options.cacheDir);
6283
- if (fs.existsSync(cliPath)) {
6283
+ if (fs$1.existsSync(cliPath)) {
6284
6284
  options.logger.info("system npm unavailable — using bootstrapped npm", { meta: { cliPath } });
6285
6285
  return {
6286
6286
  command: process.execPath,
@@ -6292,12 +6292,12 @@ async function resolveUncached(options) {
6292
6292
  const registry = (options.registry ?? DEFAULT_REGISTRY$1).replace(/\/+$/, "");
6293
6293
  const tarballUrl = tarballUrlOf(await (options.fetchJson ?? defaultFetchJson)(`${registry}/npm/latest`));
6294
6294
  if (!tarballUrl) throw new Error(`registry metadata for 'npm' carries no dist.tarball (${registry})`);
6295
- await fs.promises.mkdir(options.cacheDir, { recursive: true });
6295
+ await fs$1.promises.mkdir(options.cacheDir, { recursive: true });
6296
6296
  const tgzPath = path$1.join(options.cacheDir, "npm-bootstrap.tgz");
6297
6297
  await (options.downloadTarball ?? defaultDownloadTarball)(tarballUrl, tgzPath);
6298
6298
  await (options.extractTarball ?? defaultExtractTarball)(tgzPath, options.cacheDir);
6299
- await fs.promises.rm(tgzPath, { force: true });
6300
- if (!fs.existsSync(cliPath)) throw new Error(`extracted npm tarball is missing ${cliPath}`);
6299
+ await fs$1.promises.rm(tgzPath, { force: true });
6300
+ if (!fs$1.existsSync(cliPath)) throw new Error(`extracted npm tarball is missing ${cliPath}`);
6301
6301
  options.logger.info("npm bootstrapped", { meta: { cliPath } });
6302
6302
  return {
6303
6303
  command: process.execPath,
@@ -6363,7 +6363,7 @@ function readOwningPackageVersion(entryPath) {
6363
6363
  let dir = path$1.dirname(entryPath);
6364
6364
  for (let hop = 0; hop < PACKAGE_JSON_LOOKUP_DEPTH; hop++) {
6365
6365
  try {
6366
- const version = asJsonObject$1(parseJsonUnknown(fs.readFileSync(path$1.join(dir, "package.json"), "utf-8")))?.["version"];
6366
+ const version = asJsonObject$1(parseJsonUnknown(fs$1.readFileSync(path$1.join(dir, "package.json"), "utf-8")))?.["version"];
6367
6367
  if (typeof version === "string" && version.length > 0) return version;
6368
6368
  } catch {}
6369
6369
  const parent = path$1.dirname(dir);
@@ -6407,14 +6407,14 @@ function readOwningPackageVersion(entryPath) {
6407
6407
  function addonModuleCacheKey(entryPath) {
6408
6408
  let stat;
6409
6409
  try {
6410
- stat = fs.statSync(entryPath);
6410
+ stat = fs$1.statSync(entryPath);
6411
6411
  } catch {
6412
6412
  return null;
6413
6413
  }
6414
6414
  const version = readOwningPackageVersion(entryPath) ?? `m${stat.mtimeMs}`;
6415
6415
  let content;
6416
6416
  try {
6417
- content = createHash("sha1").update(fs.readFileSync(entryPath)).digest("hex").slice(0, 16);
6417
+ content = createHash("sha1").update(fs$1.readFileSync(entryPath)).digest("hex").slice(0, 16);
6418
6418
  } catch {
6419
6419
  content = `m${stat.mtimeMs}s${stat.size}`;
6420
6420
  }
@@ -6518,14 +6518,14 @@ var AddonLoader = class {
6518
6518
  * BUILTINS from the active closure, not the (now-inert) addons-dir copy, so
6519
6519
  * the addons-dir `@camstack/server/system` must NOT be double-loaded here. */
6520
6520
  async loadFromDirectory(addonsDir, skipPackages = []) {
6521
- if (!fs.existsSync(addonsDir)) return;
6521
+ if (!fs$1.existsSync(addonsDir)) return;
6522
6522
  const skip = new Set(skipPackages);
6523
- const entries = fs.readdirSync(addonsDir, { withFileTypes: true });
6523
+ const entries = fs$1.readdirSync(addonsDir, { withFileTypes: true });
6524
6524
  for (const entry of entries) {
6525
6525
  if (!isDirectoryEntry(entry, addonsDir)) continue;
6526
6526
  if (entry.name.startsWith("@")) {
6527
6527
  const scopeDir = path$1.join(addonsDir, entry.name);
6528
- const scopeEntries = fs.readdirSync(scopeDir, { withFileTypes: true });
6528
+ const scopeEntries = fs$1.readdirSync(scopeDir, { withFileTypes: true });
6529
6529
  for (const scopeEntry of scopeEntries) {
6530
6530
  if (!isDirectoryEntry(scopeEntry, scopeDir)) continue;
6531
6531
  if (skip.has(`${entry.name}/${scopeEntry.name}`)) continue;
@@ -6539,7 +6539,7 @@ var AddonLoader = class {
6539
6539
  }
6540
6540
  async tryLoadAddon(addonDir) {
6541
6541
  const pkgJsonPath = path$1.join(addonDir, "package.json");
6542
- if (!fs.existsSync(pkgJsonPath)) return;
6542
+ if (!fs$1.existsSync(pkgJsonPath)) return;
6543
6543
  try {
6544
6544
  await this.loadFromAddonDir(addonDir);
6545
6545
  } catch (err) {
@@ -6557,7 +6557,7 @@ var AddonLoader = class {
6557
6557
  /** Load addon from a specific directory (package.json + dist/) */
6558
6558
  async loadFromAddonDir(addonDir) {
6559
6559
  const pkgJsonPath = path$1.join(addonDir, "package.json");
6560
- const pkgJson = asJsonObject$1(parseJsonUnknown(fs.readFileSync(pkgJsonPath, "utf-8"))) ?? {};
6560
+ const pkgJson = asJsonObject$1(parseJsonUnknown(fs$1.readFileSync(pkgJsonPath, "utf-8"))) ?? {};
6561
6561
  const packageNameRaw = pkgJson["name"];
6562
6562
  const packageName = typeof packageNameRaw === "string" ? packageNameRaw : "";
6563
6563
  const packageVersionRaw = pkgJson["version"];
@@ -6605,7 +6605,7 @@ var AddonLoader = class {
6605
6605
  }
6606
6606
  const entryFile = declaration.entry.replace(/^\.\//, "").replace(/^src\//, "dist/").replace(/\.ts$/, ".js");
6607
6607
  let entryPath = path$1.resolve(addonDir, entryFile);
6608
- if (!fs.existsSync(entryPath)) {
6608
+ if (!fs$1.existsSync(entryPath)) {
6609
6609
  const base = entryPath.replace(/\.(js|cjs|mjs)$/, "");
6610
6610
  entryPath = [
6611
6611
  `${base}.cjs`,
@@ -6614,9 +6614,9 @@ var AddonLoader = class {
6614
6614
  path$1.resolve(addonDir, "dist", "index.cjs"),
6615
6615
  path$1.resolve(addonDir, "dist", "index.mjs"),
6616
6616
  path$1.resolve(addonDir, declaration.entry)
6617
- ].find((p) => fs.existsSync(p)) ?? entryPath;
6617
+ ].find((p) => fs$1.existsSync(p)) ?? entryPath;
6618
6618
  }
6619
- if (!fs.existsSync(entryPath)) throw new Error(`Entry not found: ${entryPath}`);
6619
+ if (!fs$1.existsSync(entryPath)) throw new Error(`Entry not found: ${entryPath}`);
6620
6620
  const modUnknown = await importAddonModuleFresh(entryPath);
6621
6621
  const mod = isRecord$4(modUnknown) ? modUnknown : {};
6622
6622
  const AddonClass = resolveAddonClass(mod);
@@ -6728,7 +6728,7 @@ function isDirectoryEntry(entry, parentDir) {
6728
6728
  if (entry.name.startsWith(".")) return false;
6729
6729
  if (entry.isDirectory()) return true;
6730
6730
  if (entry.isSymbolicLink()) try {
6731
- return fs.statSync(path$1.join(parentDir, entry.name)).isDirectory();
6731
+ return fs$1.statSync(path$1.join(parentDir, entry.name)).isDirectory();
6732
6732
  } catch {
6733
6733
  return false;
6734
6734
  }
@@ -6822,7 +6822,7 @@ var execFileAsync$4 = promisify(execFile);
6822
6822
  * Single source of truth — replaces scattered mkdirSync calls.
6823
6823
  */
6824
6824
  function ensureDir(dirPath) {
6825
- fs.mkdirSync(dirPath, { recursive: true });
6825
+ fs$1.mkdirSync(dirPath, { recursive: true });
6826
6826
  }
6827
6827
  /**
6828
6828
  * Copy a directory recursively — ASYNC so it never blocks the event loop.
@@ -6835,7 +6835,7 @@ function ensureDir(dirPath) {
6835
6835
  * `fs.promises.cp` keeps the I/O off the event loop. (Node ≥18 stable.)
6836
6836
  */
6837
6837
  async function copyDirRecursive(src, dest) {
6838
- await fs.promises.cp(src, dest, {
6838
+ await fs$1.promises.cp(src, dest, {
6839
6839
  recursive: true,
6840
6840
  force: true
6841
6841
  });
@@ -6940,13 +6940,13 @@ async function copyExtraFileDirs(pkgJson, sourceDir, destDir) {
6940
6940
  if (typeof fileEntry !== "string") continue;
6941
6941
  if (fileEntry === "dist" || fileEntry.includes("*")) continue;
6942
6942
  const srcPath = path$1.join(sourceDir, fileEntry);
6943
- if (!fs.existsSync(srcPath)) continue;
6943
+ if (!fs$1.existsSync(srcPath)) continue;
6944
6944
  const destPath = path$1.join(destDir, fileEntry);
6945
- const stat = await fs.promises.stat(srcPath);
6945
+ const stat = await fs$1.promises.stat(srcPath);
6946
6946
  if (stat.isDirectory()) await copyDirRecursive(srcPath, destPath);
6947
6947
  else if (stat.isFile()) {
6948
6948
  ensureDir(path$1.dirname(destPath));
6949
- await fs.promises.copyFile(srcPath, destPath);
6949
+ await fs$1.promises.copyFile(srcPath, destPath);
6950
6950
  }
6951
6951
  }
6952
6952
  }
@@ -6957,10 +6957,10 @@ async function copyExtraFileDirs(pkgJson, sourceDir, destDir) {
6957
6957
  function isSourceNewer(packageDir) {
6958
6958
  const srcDir = path$1.join(packageDir, "src");
6959
6959
  const distDir = path$1.join(packageDir, "dist");
6960
- if (!fs.existsSync(srcDir) || !fs.existsSync(distDir)) return true;
6960
+ if (!fs$1.existsSync(srcDir) || !fs$1.existsSync(distDir)) return true;
6961
6961
  try {
6962
- const distMtime = fs.statSync(distDir).mtimeMs;
6963
- const entries = fs.readdirSync(srcDir, {
6962
+ const distMtime = fs$1.statSync(distDir).mtimeMs;
6963
+ const entries = fs$1.readdirSync(srcDir, {
6964
6964
  withFileTypes: true,
6965
6965
  recursive: true
6966
6966
  });
@@ -6968,7 +6968,7 @@ function isSourceNewer(packageDir) {
6968
6968
  if (!entry.isFile()) continue;
6969
6969
  const parentDir = entry.parentPath ?? String(Reflect.get(entry, "path") ?? "");
6970
6970
  const filePath = path$1.join(parentDir, entry.name);
6971
- if (fs.statSync(filePath).mtimeMs > distMtime) return true;
6971
+ if (fs$1.statSync(filePath).mtimeMs > distMtime) return true;
6972
6972
  }
6973
6973
  return false;
6974
6974
  } catch {
@@ -6985,7 +6985,7 @@ function isSourceNewer(packageDir) {
6985
6985
  * `copyDirRecursive` for the wedge this prevents.
6986
6986
  */
6987
6987
  async function installPackageFromNpm(packageName, targetDir) {
6988
- const tmpDir = await fs.promises.mkdtemp(path$1.join(os$1.tmpdir(), "camstack-install-"));
6988
+ const tmpDir = await fs$1.promises.mkdtemp(path$1.join(os$1.tmpdir(), "camstack-install-"));
6989
6989
  try {
6990
6990
  const { stdout } = await execFileAsync$4("npm", [
6991
6991
  "pack",
@@ -7008,21 +7008,21 @@ async function installPackageFromNpm(packageName, targetDir) {
7008
7008
  extractDir
7009
7009
  ], { timeout: 3e4 });
7010
7010
  const packageSubDir = path$1.join(extractDir, "package");
7011
- const srcPkgJsonDir = fs.existsSync(path$1.join(packageSubDir, "package.json")) ? packageSubDir : extractDir;
7012
- await fs.promises.rm(targetDir, {
7011
+ const srcPkgJsonDir = fs$1.existsSync(path$1.join(packageSubDir, "package.json")) ? packageSubDir : extractDir;
7012
+ await fs$1.promises.rm(targetDir, {
7013
7013
  recursive: true,
7014
7014
  force: true
7015
7015
  });
7016
7016
  ensureDir(targetDir);
7017
- await fs.promises.copyFile(path$1.join(srcPkgJsonDir, "package.json"), path$1.join(targetDir, "package.json"));
7017
+ await fs$1.promises.copyFile(path$1.join(srcPkgJsonDir, "package.json"), path$1.join(targetDir, "package.json"));
7018
7018
  const distSrc = path$1.join(srcPkgJsonDir, "dist");
7019
- if (fs.existsSync(distSrc)) await copyDirRecursive(distSrc, path$1.join(targetDir, "dist"));
7019
+ if (fs$1.existsSync(distSrc)) await copyDirRecursive(distSrc, path$1.join(targetDir, "dist"));
7020
7020
  try {
7021
- const npmPkg = asJsonObject$1(parseJsonUnknown(await fs.promises.readFile(path$1.join(srcPkgJsonDir, "package.json"), "utf-8")));
7021
+ const npmPkg = asJsonObject$1(parseJsonUnknown(await fs$1.promises.readFile(path$1.join(srcPkgJsonDir, "package.json"), "utf-8")));
7022
7022
  if (npmPkg) await copyExtraFileDirs(npmPkg, srcPkgJsonDir, targetDir);
7023
7023
  } catch {}
7024
7024
  } finally {
7025
- await fs.promises.rm(tmpDir, {
7025
+ await fs$1.promises.rm(tmpDir, {
7026
7026
  recursive: true,
7027
7027
  force: true
7028
7028
  });
@@ -7047,7 +7047,7 @@ function packageDirName$1(declaredName) {
7047
7047
  }
7048
7048
  function isDirLike$1(p) {
7049
7049
  try {
7050
- return fs.statSync(p).isDirectory();
7050
+ return fs$1.statSync(p).isDirectory();
7051
7051
  } catch {
7052
7052
  return false;
7053
7053
  }
@@ -7065,12 +7065,12 @@ var AddonManifest = class {
7065
7065
  */
7066
7066
  read() {
7067
7067
  if (this.cache != null) return this.cache;
7068
- if (!fs.existsSync(this.manifestPath)) {
7068
+ if (!fs$1.existsSync(this.manifestPath)) {
7069
7069
  this.cache = this.empty();
7070
7070
  return this.cache;
7071
7071
  }
7072
7072
  try {
7073
- const raw = fs.readFileSync(this.manifestPath, "utf-8");
7073
+ const raw = fs$1.readFileSync(this.manifestPath, "utf-8");
7074
7074
  const parsed = JSON.parse(raw);
7075
7075
  if (parsed.version !== MANIFEST_VERSION) {
7076
7076
  process.stderr.write(`[AddonManifest] schema mismatch (file=${parsed.version} vs runtime=${MANIFEST_VERSION}); starting empty\n`);
@@ -7091,13 +7091,13 @@ var AddonManifest = class {
7091
7091
  * a half-written file.
7092
7092
  */
7093
7093
  write(manifest) {
7094
- fs.mkdirSync(path$1.dirname(this.manifestPath), { recursive: true });
7094
+ fs$1.mkdirSync(path$1.dirname(this.manifestPath), { recursive: true });
7095
7095
  const tmp = `${this.manifestPath}.tmp.${process.pid}.${Date.now()}`;
7096
- fs.writeFileSync(tmp, JSON.stringify(manifest, null, 2), {
7096
+ fs$1.writeFileSync(tmp, JSON.stringify(manifest, null, 2), {
7097
7097
  encoding: "utf-8",
7098
7098
  mode: 384
7099
7099
  });
7100
- fs.renameSync(tmp, this.manifestPath);
7100
+ fs$1.renameSync(tmp, this.manifestPath);
7101
7101
  this.cache = manifest;
7102
7102
  }
7103
7103
  /** Lookup a single addon's manifest entry, or `null` if not tracked. */
@@ -7172,22 +7172,22 @@ var AddonManifest = class {
7172
7172
  * exactly what moved. Returns the total number of changes.
7173
7173
  */
7174
7174
  reconcileFromDisk(addonsDir, onChange) {
7175
- if (!fs.existsSync(addonsDir)) return 0;
7175
+ if (!fs$1.existsSync(addonsDir)) return 0;
7176
7176
  const m = this.read();
7177
7177
  let changes = 0;
7178
7178
  const now = (/* @__PURE__ */ new Date()).toISOString();
7179
7179
  /** Package name → version, for every ADDON package actually installed. */
7180
7180
  const onDisk = /* @__PURE__ */ new Map();
7181
- for (const scope of fs.readdirSync(addonsDir, { withFileTypes: true })) {
7181
+ for (const scope of fs$1.readdirSync(addonsDir, { withFileTypes: true })) {
7182
7182
  if (!scope.name.startsWith("@") || !isDirLike$1(path$1.join(addonsDir, scope.name))) continue;
7183
7183
  const scopeDir = path$1.join(addonsDir, scope.name);
7184
- for (const pkg of fs.readdirSync(scopeDir, { withFileTypes: true })) {
7184
+ for (const pkg of fs$1.readdirSync(scopeDir, { withFileTypes: true })) {
7185
7185
  if (!isDirLike$1(path$1.join(scopeDir, pkg.name))) continue;
7186
7186
  const pkgJsonPath = path$1.join(scopeDir, pkg.name, "package.json");
7187
- if (!fs.existsSync(pkgJsonPath)) continue;
7187
+ if (!fs$1.existsSync(pkgJsonPath)) continue;
7188
7188
  let pkgJson;
7189
7189
  try {
7190
- const parsed = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"));
7190
+ const parsed = JSON.parse(fs$1.readFileSync(pkgJsonPath, "utf-8"));
7191
7191
  if (typeof parsed !== "object" || parsed == null) continue;
7192
7192
  pkgJson = parsed;
7193
7193
  } catch {
@@ -7258,28 +7258,28 @@ var AddonManifest = class {
7258
7258
  migrateFromInstallSourceMarkers(addonsDir) {
7259
7259
  const m = this.read();
7260
7260
  if (Object.keys(m.addons).length > 0) return 0;
7261
- if (!fs.existsSync(addonsDir)) return 0;
7261
+ if (!fs$1.existsSync(addonsDir)) return 0;
7262
7262
  let migrated = 0;
7263
7263
  const now = (/* @__PURE__ */ new Date()).toISOString();
7264
- for (const scope of fs.readdirSync(addonsDir, { withFileTypes: true })) {
7264
+ for (const scope of fs$1.readdirSync(addonsDir, { withFileTypes: true })) {
7265
7265
  if (!scope.isDirectory() || !scope.name.startsWith("@")) continue;
7266
7266
  const scopeDir = path$1.join(addonsDir, scope.name);
7267
- for (const pkg of fs.readdirSync(scopeDir, { withFileTypes: true })) {
7267
+ for (const pkg of fs$1.readdirSync(scopeDir, { withFileTypes: true })) {
7268
7268
  if (!pkg.isDirectory()) continue;
7269
7269
  const pkgDir = path$1.join(scopeDir, pkg.name);
7270
7270
  const markerPath = path$1.join(pkgDir, ".install-source");
7271
7271
  const pkgJsonPath = path$1.join(pkgDir, "package.json");
7272
- if (!fs.existsSync(pkgJsonPath)) continue;
7272
+ if (!fs$1.existsSync(pkgJsonPath)) continue;
7273
7273
  let pkgJson;
7274
7274
  try {
7275
- const parsed = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"));
7275
+ const parsed = JSON.parse(fs$1.readFileSync(pkgJsonPath, "utf-8"));
7276
7276
  if (typeof parsed !== "object" || parsed == null) continue;
7277
7277
  pkgJson = parsed;
7278
7278
  } catch {
7279
7279
  continue;
7280
7280
  }
7281
7281
  if (!pkgJson.name || !pkgJson.version) continue;
7282
- const source = fs.existsSync(markerPath) ? fs.readFileSync(markerPath, "utf-8").trim() : "bundled";
7282
+ const source = fs$1.existsSync(markerPath) ? fs$1.readFileSync(markerPath, "utf-8").trim() : "bundled";
7283
7283
  m.addons[pkgJson.name] = {
7284
7284
  name: pkgJson.name,
7285
7285
  version: pkgJson.version,
@@ -7483,7 +7483,7 @@ function planClosureDedupe(input) {
7483
7483
  function readTreeManifest(pkgJsonPath) {
7484
7484
  let raw;
7485
7485
  try {
7486
- raw = asJsonObject$1(parseJsonUnknown(fs.readFileSync(pkgJsonPath, "utf-8")));
7486
+ raw = asJsonObject$1(parseJsonUnknown(fs$1.readFileSync(pkgJsonPath, "utf-8")));
7487
7487
  } catch {
7488
7488
  return null;
7489
7489
  }
@@ -7508,7 +7508,7 @@ function readTreeManifest(pkgJsonPath) {
7508
7508
  function listTopLevelEntries(nodeModulesDir) {
7509
7509
  let entries;
7510
7510
  try {
7511
- entries = fs.readdirSync(nodeModulesDir, { withFileTypes: true });
7511
+ entries = fs$1.readdirSync(nodeModulesDir, { withFileTypes: true });
7512
7512
  } catch {
7513
7513
  return [];
7514
7514
  }
@@ -7518,7 +7518,7 @@ function listTopLevelEntries(nodeModulesDir) {
7518
7518
  if (entry.name.startsWith("@")) {
7519
7519
  let inner;
7520
7520
  try {
7521
- inner = fs.readdirSync(path$1.join(nodeModulesDir, entry.name), { withFileTypes: true });
7521
+ inner = fs$1.readdirSync(path$1.join(nodeModulesDir, entry.name), { withFileTypes: true });
7522
7522
  } catch {
7523
7523
  continue;
7524
7524
  }
@@ -7551,14 +7551,14 @@ function collectAddonTreeState(addonDir) {
7551
7551
  const entryDir = path$1.join(nodeModulesDir, name);
7552
7552
  let isLink = false;
7553
7553
  try {
7554
- isLink = fs.lstatSync(entryDir).isSymbolicLink();
7554
+ isLink = fs$1.lstatSync(entryDir).isSymbolicLink();
7555
7555
  } catch {
7556
7556
  continue;
7557
7557
  }
7558
7558
  if (isLink) {
7559
7559
  let target = "";
7560
7560
  try {
7561
- target = fs.readlinkSync(entryDir);
7561
+ target = fs$1.readlinkSync(entryDir);
7562
7562
  } catch {}
7563
7563
  existingLinks.push({
7564
7564
  name,
@@ -7572,7 +7572,7 @@ function collectAddonTreeState(addonDir) {
7572
7572
  version: manifest.version
7573
7573
  });
7574
7574
  for (const [depName, range] of manifest.ranges) {
7575
- if (fs.existsSync(path$1.join(entryDir, "node_modules", depName))) continue;
7575
+ if (fs$1.existsSync(path$1.join(entryDir, "node_modules", depName))) continue;
7576
7576
  addRange(depName, range);
7577
7577
  }
7578
7578
  }
@@ -7602,7 +7602,7 @@ function resolveClosureNodeModulesDir(explicitDir) {
7602
7602
  const frameworkDir = explicitDir ?? process.env["CAMSTACK_FRAMEWORK_DIR"];
7603
7603
  if (frameworkDir === void 0 || frameworkDir.length === 0) return null;
7604
7604
  const nodeModulesDir = explicitDir ?? path$1.join(frameworkDir, "node_modules");
7605
- return fs.existsSync(nodeModulesDir) ? nodeModulesDir : null;
7605
+ return fs$1.existsSync(nodeModulesDir) ? nodeModulesDir : null;
7606
7606
  }
7607
7607
  function symlinkType() {
7608
7608
  return process.platform === "win32" ? "junction" : "dir";
@@ -7621,10 +7621,10 @@ function executeClosureDedupe(addonDir, closureNodeModulesDir, plan, logger) {
7621
7621
  const nodeModulesDir = path$1.join(addonDir, "node_modules");
7622
7622
  const probePath = path$1.join(nodeModulesDir, ".closure-link-probe");
7623
7623
  try {
7624
- fs.mkdirSync(nodeModulesDir, { recursive: true });
7625
- fs.rmSync(probePath, { force: true });
7626
- fs.symlinkSync(closureNodeModulesDir, probePath, symlinkType());
7627
- fs.rmSync(probePath, { force: true });
7624
+ fs$1.mkdirSync(nodeModulesDir, { recursive: true });
7625
+ fs$1.rmSync(probePath, { force: true });
7626
+ fs$1.symlinkSync(closureNodeModulesDir, probePath, symlinkType());
7627
+ fs$1.rmSync(probePath, { force: true });
7628
7628
  } catch (err) {
7629
7629
  logger.warn("closure dedupe skipped — symlinks unavailable on this volume", { meta: {
7630
7630
  addonDir,
@@ -7646,12 +7646,12 @@ function executeClosureDedupe(addonDir, closureNodeModulesDir, plan, logger) {
7646
7646
  }
7647
7647
  const entryDir = path$1.join(nodeModulesDir, link.name);
7648
7648
  try {
7649
- fs.rmSync(entryDir, {
7649
+ fs$1.rmSync(entryDir, {
7650
7650
  recursive: true,
7651
7651
  force: true
7652
7652
  });
7653
- fs.mkdirSync(path$1.dirname(entryDir), { recursive: true });
7654
- fs.symlinkSync(target, entryDir, symlinkType());
7653
+ fs$1.mkdirSync(path$1.dirname(entryDir), { recursive: true });
7654
+ fs$1.symlinkSync(target, entryDir, symlinkType());
7655
7655
  linked.push(link.name);
7656
7656
  } catch (err) {
7657
7657
  logger.warn("closure dedupe — link failed; entry removed copy may need reinstall", { meta: {
@@ -7727,7 +7727,7 @@ async function installManifestNativeDeps(addonDir, pkgRaw, logger, registry, npm
7727
7727
  count: Object.keys(native).length
7728
7728
  } });
7729
7729
  try {
7730
- fs.writeFileSync(markerFile, markerHash);
7730
+ fs$1.writeFileSync(markerFile, markerHash);
7731
7731
  } catch (err) {
7732
7732
  logger.warn("Failed to write native deps marker", { meta: {
7733
7733
  markerFile,
@@ -7765,7 +7765,7 @@ async function installManifestNativeDeps(addonDir, pkgRaw, logger, registry, npm
7765
7765
  }
7766
7766
  await rebuildNativeDeps(addonDir, pending.map(([name]) => name), logger, npmCacheDir ?? defaultNpmCacheDir(), registry);
7767
7767
  try {
7768
- fs.writeFileSync(markerFile, markerHash);
7768
+ fs$1.writeFileSync(markerFile, markerHash);
7769
7769
  } catch (err) {
7770
7770
  logger.warn("Failed to write native deps marker", { meta: {
7771
7771
  markerFile,
@@ -7787,12 +7787,12 @@ function copyPrebuiltNativeDep(name, addonDir, logger) {
7787
7787
  if (source === target) continue;
7788
7788
  if (!hasBuiltBinary(source)) continue;
7789
7789
  try {
7790
- fs.rmSync(target, {
7790
+ fs$1.rmSync(target, {
7791
7791
  recursive: true,
7792
7792
  force: true
7793
7793
  });
7794
- fs.mkdirSync(path$1.dirname(target), { recursive: true });
7795
- fs.cpSync(source, target, {
7794
+ fs$1.mkdirSync(path$1.dirname(target), { recursive: true });
7795
+ fs$1.cpSync(source, target, {
7796
7796
  recursive: true,
7797
7797
  dereference: true
7798
7798
  });
@@ -7828,7 +7828,7 @@ var BUNDLED_NATIVE_SIBLING_SCOPES = {
7828
7828
  function hasAnyDotNode(dir, maxDepth) {
7829
7829
  let entries;
7830
7830
  try {
7831
- entries = fs.readdirSync(dir, { withFileTypes: true });
7831
+ entries = fs$1.readdirSync(dir, { withFileTypes: true });
7832
7832
  } catch {
7833
7833
  return false;
7834
7834
  }
@@ -7842,12 +7842,12 @@ function copyPrebuiltModuleDir(src, dst, label, logger) {
7842
7842
  if (!hasAnyDotNode(src, 5)) return;
7843
7843
  if (hasAnyDotNode(dst, 5)) return;
7844
7844
  try {
7845
- fs.rmSync(dst, {
7845
+ fs$1.rmSync(dst, {
7846
7846
  recursive: true,
7847
7847
  force: true
7848
7848
  });
7849
- fs.mkdirSync(path$1.dirname(dst), { recursive: true });
7850
- fs.cpSync(src, dst, {
7849
+ fs$1.mkdirSync(path$1.dirname(dst), { recursive: true });
7850
+ fs$1.cpSync(src, dst, {
7851
7851
  recursive: true,
7852
7852
  dereference: true
7853
7853
  });
@@ -7882,7 +7882,7 @@ function copyPrebuiltModuleDir(src, dst, label, logger) {
7882
7882
  */
7883
7883
  function copyBundledNativeModules(sourceDir, targetDir, logger) {
7884
7884
  const srcNm = path$1.join(sourceDir, "node_modules");
7885
- if (!fs.existsSync(srcNm)) return;
7885
+ if (!fs$1.existsSync(srcNm)) return;
7886
7886
  const dstNm = path$1.join(targetDir, "node_modules");
7887
7887
  for (const [name, scopes] of Object.entries(BUNDLED_NATIVE_SIBLING_SCOPES)) {
7888
7888
  copyPrebuiltModuleDir(path$1.join(srcNm, name), path$1.join(dstNm, name), name, logger);
@@ -7890,7 +7890,7 @@ function copyBundledNativeModules(sourceDir, targetDir, logger) {
7890
7890
  const scopeSrc = path$1.join(srcNm, scope);
7891
7891
  let siblings;
7892
7892
  try {
7893
- siblings = fs.readdirSync(scopeSrc);
7893
+ siblings = fs$1.readdirSync(scopeSrc);
7894
7894
  } catch {
7895
7895
  continue;
7896
7896
  }
@@ -7900,12 +7900,12 @@ function copyBundledNativeModules(sourceDir, targetDir, logger) {
7900
7900
  }
7901
7901
  /** A package dir is "built" when it carries a compiled `.node` or a prebuilds tree. */
7902
7902
  function hasBuiltBinary(pkgDir) {
7903
- if (!fs.existsSync(path$1.join(pkgDir, "package.json"))) return false;
7903
+ if (!fs$1.existsSync(path$1.join(pkgDir, "package.json"))) return false;
7904
7904
  const releaseDir = path$1.join(pkgDir, "build", "Release");
7905
7905
  try {
7906
- if (fs.existsSync(releaseDir) && fs.readdirSync(releaseDir).some((f) => f.endsWith(".node"))) return true;
7906
+ if (fs$1.existsSync(releaseDir) && fs$1.readdirSync(releaseDir).some((f) => f.endsWith(".node"))) return true;
7907
7907
  } catch {}
7908
- return fs.existsSync(path$1.join(pkgDir, "prebuilds"));
7908
+ return fs$1.existsSync(path$1.join(pkgDir, "prebuilds"));
7909
7909
  }
7910
7910
  /** Candidate hoisted locations for `<name>`: NODE_PATH entries + ancestors of `addonDir`. */
7911
7911
  function candidateHoistedDirs(name, addonDir) {
@@ -7943,7 +7943,7 @@ function hashDeclaration(deps) {
7943
7943
  }
7944
7944
  function markerMatches(markerFile, expected) {
7945
7945
  try {
7946
- return fs.readFileSync(markerFile, "utf-8").trim() === expected;
7946
+ return fs$1.readFileSync(markerFile, "utf-8").trim() === expected;
7947
7947
  } catch {
7948
7948
  return false;
7949
7949
  }
@@ -8154,7 +8154,7 @@ function parseInstallSource(value) {
8154
8154
  function readPackageJson(pkgJsonPath) {
8155
8155
  let raw;
8156
8156
  try {
8157
- raw = asJsonObject$1(parseJsonUnknown(fs.readFileSync(pkgJsonPath, "utf-8")));
8157
+ raw = asJsonObject$1(parseJsonUnknown(fs$1.readFileSync(pkgJsonPath, "utf-8")));
8158
8158
  } catch {
8159
8159
  return null;
8160
8160
  }
@@ -8198,7 +8198,7 @@ var REGISTRY_LATEST_TIMEOUT_MS = 15e3;
8198
8198
  var FALLBACK_VERSION_PROBES = 25;
8199
8199
  function readInstalledPackageVersion(addonDir) {
8200
8200
  try {
8201
- const raw = JSON.parse(fs.readFileSync(path$1.join(addonDir, "package.json"), "utf-8"));
8201
+ const raw = JSON.parse(fs$1.readFileSync(path$1.join(addonDir, "package.json"), "utf-8"));
8202
8202
  if (raw === null || typeof raw !== "object") return null;
8203
8203
  const version = Reflect.get(raw, "version");
8204
8204
  return typeof version === "string" && version.length > 0 ? version : null;
@@ -8346,7 +8346,7 @@ var AddonInstaller = class AddonInstaller {
8346
8346
  } catch {
8347
8347
  return Object.freeze([]);
8348
8348
  }
8349
- const raw = fs.readFileSync(pkgPath, "utf-8");
8349
+ const raw = fs$1.readFileSync(pkgPath, "utf-8");
8350
8350
  const parsed = JSON.parse(raw);
8351
8351
  const deps = Object.keys(parsed.dependencies ?? {});
8352
8352
  const agentOnly = new Set(parsed.camstack?.agentOnlyBootstrapAddons ?? []);
@@ -8391,7 +8391,7 @@ var AddonInstaller = class AddonInstaller {
8391
8391
  } catch {
8392
8392
  return Object.freeze([]);
8393
8393
  }
8394
- const raw = fs.readFileSync(pkgPath, "utf-8");
8394
+ const raw = fs$1.readFileSync(pkgPath, "utf-8");
8395
8395
  const addons = JSON.parse(raw).camstack?.agentBootstrapAddons ?? [];
8396
8396
  return Object.freeze(["@camstack/server", ...addons]);
8397
8397
  }
@@ -8421,7 +8421,7 @@ var AddonInstaller = class AddonInstaller {
8421
8421
  this.logger.info(`Install source: ${isLocal ? `bundle (${this.bundledAddonsDir})` : "npm"}, ${pkgList.length} package(s)`);
8422
8422
  for (const packageName of pkgList) {
8423
8423
  const addonDir = path$1.join(this.addonsDir, packageName);
8424
- if (fs.existsSync(path$1.join(addonDir, "package.json"))) {
8424
+ if (fs$1.existsSync(path$1.join(addonDir, "package.json"))) {
8425
8425
  if (isLocal || shouldSkipClosureProvidedSeed(packageName, this.isResolvableFromClosure(packageName))) {
8426
8426
  this.logger.debug(`${packageName} — already installed, skipping`);
8427
8427
  continue;
@@ -8672,7 +8672,7 @@ var AddonInstaller = class AddonInstaller {
8672
8672
  const installedPackages = this.listInstalled();
8673
8673
  for (const pkg of installedPackages) {
8674
8674
  try {
8675
- if (fs.lstatSync(pkg.dir).isSymbolicLink()) continue;
8675
+ if (fs$1.lstatSync(pkg.dir).isSymbolicLink()) continue;
8676
8676
  } catch {
8677
8677
  continue;
8678
8678
  }
@@ -8712,7 +8712,7 @@ var AddonInstaller = class AddonInstaller {
8712
8712
  if (closureNodeModules !== null) for (const link of state.existingLinks) {
8713
8713
  if (!isClosureLinkTarget(link.target, closureNodeModules)) continue;
8714
8714
  const linkDir = path$1.join(nodeModulesDir, link.name);
8715
- const targetManifest = fs.existsSync(path$1.join(linkDir, "package.json"));
8715
+ const targetManifest = fs$1.existsSync(path$1.join(linkDir, "package.json"));
8716
8716
  const ranges = state.requirements.get(link.name) ?? [];
8717
8717
  let holds = targetManifest;
8718
8718
  if (holds && ranges.length > 0) {
@@ -8721,14 +8721,14 @@ var AddonInstaller = class AddonInstaller {
8721
8721
  }
8722
8722
  if (!holds) {
8723
8723
  this.logger.warn(`${packageName} — closure link for ${link.name} no longer holds; reinstalling this addon's deps`, { meta: { target: link.target } });
8724
- fs.rmSync(linkDir, { force: true });
8724
+ fs$1.rmSync(linkDir, { force: true });
8725
8725
  needsInstall = true;
8726
8726
  }
8727
8727
  }
8728
8728
  const linked = [];
8729
8729
  for (const [depName, range] of declaredEntries) {
8730
8730
  if (typeof range !== "string") continue;
8731
- if (fs.existsSync(path$1.join(nodeModulesDir, depName, "package.json"))) continue;
8731
+ if (fs$1.existsSync(path$1.join(nodeModulesDir, depName, "package.json"))) continue;
8732
8732
  const closureVersion = closureNodeModules === null ? void 0 : readClosureVersions(closureNodeModules, [depName]).get(depName);
8733
8733
  if (closureNodeModules !== null && closureVersion !== void 0 && closureSatisfiesRange(range, closureVersion)) {
8734
8734
  if (executeClosureDedupe(addonDir, closureNodeModules, {
@@ -8761,7 +8761,7 @@ var AddonInstaller = class AddonInstaller {
8761
8761
  const closureNodeModules = resolveClosureNodeModulesDir(this.closureNodeModulesDir);
8762
8762
  if (closureNodeModules !== null) {
8763
8763
  const state = collectAddonTreeState(addonDir);
8764
- for (const link of state.existingLinks) if (isClosureLinkTarget(link.target, closureNodeModules)) fs.rmSync(path$1.join(addonDir, "node_modules", link.name), { force: true });
8764
+ for (const link of state.existingLinks) if (isClosureLinkTarget(link.target, closureNodeModules)) fs$1.rmSync(path$1.join(addonDir, "node_modules", link.name), { force: true });
8765
8765
  }
8766
8766
  this.logger.info(`${packageName} — reinstalling runtime dependencies`, { meta: { addonDir } });
8767
8767
  await runNpm([
@@ -8806,7 +8806,7 @@ var AddonInstaller = class AddonInstaller {
8806
8806
  async realignFromClosure(packageName, closureDir) {
8807
8807
  const targetDir = path$1.join(this.addonsDir, packageName);
8808
8808
  const result = await this.installLocal(packageName, closureDir);
8809
- await fs.promises.writeFile(path$1.join(targetDir, ".install-source"), "closure");
8809
+ await fs$1.promises.writeFile(path$1.join(targetDir, ".install-source"), "closure");
8810
8810
  this.manifest.upsert(result.name, {
8811
8811
  version: result.version,
8812
8812
  source: "closure"
@@ -8822,17 +8822,17 @@ var AddonInstaller = class AddonInstaller {
8822
8822
  async installCopy(packageName, sourceDir, pkgData, targetDir) {
8823
8823
  await this.ensureBuilt(packageName, sourceDir, pkgData);
8824
8824
  const distDir = path$1.join(sourceDir, "dist");
8825
- if (!fs.existsSync(distDir)) throw new Error(`${packageName} has no dist/ after build`);
8826
- await fs.promises.rm(targetDir, {
8825
+ if (!fs$1.existsSync(distDir)) throw new Error(`${packageName} has no dist/ after build`);
8826
+ await fs$1.promises.rm(targetDir, {
8827
8827
  recursive: true,
8828
8828
  force: true
8829
8829
  });
8830
8830
  ensureDir(targetDir);
8831
- await fs.promises.writeFile(path$1.join(targetDir, "package.json"), JSON.stringify(stripBundledDeps(pkgData), null, 2));
8831
+ await fs$1.promises.writeFile(path$1.join(targetDir, "package.json"), JSON.stringify(stripBundledDeps(pkgData), null, 2));
8832
8832
  await copyDirRecursive(distDir, path$1.join(targetDir, "dist"));
8833
8833
  await copyExtraFileDirs(pkgData, sourceDir, targetDir);
8834
8834
  copyBundledNativeModules(sourceDir, targetDir, this.logger);
8835
- await fs.promises.writeFile(path$1.join(targetDir, ".install-source"), "local");
8835
+ await fs$1.promises.writeFile(path$1.join(targetDir, ".install-source"), "local");
8836
8836
  const localPkgVersion = asString$1(pkgData.version, "0.0.0");
8837
8837
  this.manifest.upsert(packageName, {
8838
8838
  version: localPkgVersion,
@@ -8873,7 +8873,7 @@ var AddonInstaller = class AddonInstaller {
8873
8873
  * unusual auth, offline mode, etc).
8874
8874
  */
8875
8875
  async installFromNpm(packageName, version) {
8876
- const tmpDir = fs.mkdtempSync(path$1.join(os$1.tmpdir(), "camstack-addon-npm-"));
8876
+ const tmpDir = fs$1.mkdtempSync(path$1.join(os$1.tmpdir(), "camstack-addon-npm-"));
8877
8877
  const packageSpec = version ? `${packageName}@${version}` : packageName;
8878
8878
  this.logger.info(`${packageName} — installing from npm`);
8879
8879
  try {
@@ -8887,19 +8887,19 @@ var AddonInstaller = class AddonInstaller {
8887
8887
  ];
8888
8888
  if (this.registry) args.push("--registry", this.registry);
8889
8889
  const { stdout } = await runNpm(args, this.npmRunOptions(tmpDir, 12e4));
8890
- const tgzFiles = fs.readdirSync(tmpDir).filter((f) => f.endsWith(".tgz"));
8890
+ const tgzFiles = fs$1.readdirSync(tmpDir).filter((f) => f.endsWith(".tgz"));
8891
8891
  if (tgzFiles.length === 0) throw new Error(`npm pack produced no tgz. stdout: ${stdout.trim()}`);
8892
8892
  return path$1.join(tmpDir, tgzFiles[0]);
8893
8893
  });
8894
8894
  const result = await this.installFromTgz(tgzPath);
8895
- fs.writeFileSync(path$1.join(this.addonsDir, result.name, ".install-source"), "npm");
8895
+ fs$1.writeFileSync(path$1.join(this.addonsDir, result.name, ".install-source"), "npm");
8896
8896
  this.manifest.upsert(result.name, {
8897
8897
  version: result.version,
8898
8898
  source: "npm"
8899
8899
  });
8900
8900
  return result;
8901
8901
  } finally {
8902
- fs.rmSync(tmpDir, {
8902
+ fs$1.rmSync(tmpDir, {
8903
8903
  recursive: true,
8904
8904
  force: true
8905
8905
  });
@@ -8937,7 +8937,7 @@ var AddonInstaller = class AddonInstaller {
8937
8937
  if (!tarRes.ok) throw new Error(`tarball GET ${tarballUrl} → ${tarRes.status}`);
8938
8938
  const tgzPath = path$1.join(tmpDir, `${packageName.replace(/[/@]/g, "-").replace(/^-+/, "")}-${resolvedVersion}.tgz`);
8939
8939
  const buf = Buffer.from(await tarRes.arrayBuffer());
8940
- fs.writeFileSync(tgzPath, buf);
8940
+ fs$1.writeFileSync(tgzPath, buf);
8941
8941
  return tgzPath;
8942
8942
  }
8943
8943
  /**
@@ -8958,7 +8958,7 @@ var AddonInstaller = class AddonInstaller {
8958
8958
  * on the next deploy.
8959
8959
  */
8960
8960
  async evictInstallDir(targetDir) {
8961
- if (!fs.existsSync(targetDir)) return;
8961
+ if (!fs$1.existsSync(targetDir)) return;
8962
8962
  const graveyard = path$1.join(this.addonsDir, ".evicting");
8963
8963
  ensureDir(graveyard);
8964
8964
  await this.sweepGraveyard(graveyard);
@@ -8966,10 +8966,10 @@ var AddonInstaller = class AddonInstaller {
8966
8966
  const flatName = path$1.relative(this.addonsDir, targetDir).replace(/[/\\]/g, "-");
8967
8967
  const asideDir = path$1.join(graveyard, `${flatName}-${ts}`);
8968
8968
  try {
8969
- fs.renameSync(targetDir, asideDir);
8969
+ fs$1.renameSync(targetDir, asideDir);
8970
8970
  } catch (renameErr) {
8971
8971
  if (renameErr.code === "EXDEV") {
8972
- await fs.promises.rm(targetDir, {
8972
+ await fs$1.promises.rm(targetDir, {
8973
8973
  recursive: true,
8974
8974
  force: true
8975
8975
  });
@@ -8977,7 +8977,7 @@ var AddonInstaller = class AddonInstaller {
8977
8977
  }
8978
8978
  throw renameErr;
8979
8979
  }
8980
- await fs.promises.rm(asideDir, {
8980
+ await fs$1.promises.rm(asideDir, {
8981
8981
  recursive: true,
8982
8982
  force: true
8983
8983
  }).catch((cleanupErr) => {
@@ -8998,14 +8998,14 @@ var AddonInstaller = class AddonInstaller {
8998
8998
  async sweepStagingResidue(stagingRoot) {
8999
8999
  let names;
9000
9000
  try {
9001
- names = fs.readdirSync(stagingRoot);
9001
+ names = fs$1.readdirSync(stagingRoot);
9002
9002
  } catch {
9003
9003
  return;
9004
9004
  }
9005
9005
  const now = Date.now();
9006
9006
  const ages = [];
9007
9007
  for (const name of names) try {
9008
- const stat = fs.statSync(path$1.join(stagingRoot, name));
9008
+ const stat = fs$1.statSync(path$1.join(stagingRoot, name));
9009
9009
  ages.push({
9010
9010
  name,
9011
9011
  ageMs: now - stat.mtimeMs
@@ -9016,7 +9016,7 @@ var AddonInstaller = class AddonInstaller {
9016
9016
  stagingRoot,
9017
9017
  entries: sweepable
9018
9018
  } });
9019
- await Promise.all(sweepable.map((name) => fs.promises.rm(path$1.join(stagingRoot, name), {
9019
+ await Promise.all(sweepable.map((name) => fs$1.promises.rm(path$1.join(stagingRoot, name), {
9020
9020
  recursive: true,
9021
9021
  force: true
9022
9022
  }).catch(() => void 0)));
@@ -9025,11 +9025,11 @@ var AddonInstaller = class AddonInstaller {
9025
9025
  async sweepGraveyard(graveyard) {
9026
9026
  let entries;
9027
9027
  try {
9028
- entries = fs.readdirSync(graveyard);
9028
+ entries = fs$1.readdirSync(graveyard);
9029
9029
  } catch {
9030
9030
  return;
9031
9031
  }
9032
- await Promise.all(entries.map((name) => fs.promises.rm(path$1.join(graveyard, name), {
9032
+ await Promise.all(entries.map((name) => fs$1.promises.rm(path$1.join(graveyard, name), {
9033
9033
  recursive: true,
9034
9034
  force: true
9035
9035
  }).catch(() => void 0)));
@@ -9080,7 +9080,7 @@ var AddonInstaller = class AddonInstaller {
9080
9080
  return;
9081
9081
  }
9082
9082
  const strippedManifest = stripBundledDeps(pkgView.raw);
9083
- await fs.promises.writeFile(pkgJsonPath, JSON.stringify(strippedManifest, null, 2));
9083
+ await fs$1.promises.writeFile(pkgJsonPath, JSON.stringify(strippedManifest, null, 2));
9084
9084
  const deps = asJsonObject$1(strippedManifest["dependencies"]);
9085
9085
  const depNames = deps ? Object.keys(deps) : [];
9086
9086
  if (depNames.length === 0) return;
@@ -9212,9 +9212,9 @@ var AddonInstaller = class AddonInstaller {
9212
9212
  "-C",
9213
9213
  stagingDir
9214
9214
  ], { timeout: 12e4 });
9215
- const pkgDir = fs.existsSync(path$1.join(stagingDir, "package", "package.json")) ? path$1.join(stagingDir, "package") : stagingDir;
9215
+ const pkgDir = fs$1.existsSync(path$1.join(stagingDir, "package", "package.json")) ? path$1.join(stagingDir, "package") : stagingDir;
9216
9216
  const pkgJsonPath = path$1.join(pkgDir, "package.json");
9217
- if (!fs.existsSync(pkgJsonPath)) throw new Error("No package.json found in tgz archive");
9217
+ if (!fs$1.existsSync(pkgJsonPath)) throw new Error("No package.json found in tgz archive");
9218
9218
  const pkgView = readPackageJson(pkgJsonPath);
9219
9219
  if (!pkgView) throw new Error(`Invalid package.json at ${pkgJsonPath}`);
9220
9220
  if (!pkgView.camstackAddons) throw new Error(`Package ${pkgView.name} has no camstack.addons manifest`);
@@ -9224,7 +9224,7 @@ var AddonInstaller = class AddonInstaller {
9224
9224
  this.dedupeTreeAgainstClosure(pkgDir, pkgView.name);
9225
9225
  await this.evictInstallDir(targetDir);
9226
9226
  ensureDir(path$1.dirname(targetDir));
9227
- await fs.promises.rename(pkgDir, targetDir);
9227
+ await fs$1.promises.rename(pkgDir, targetDir);
9228
9228
  this.manifest.upsert(pkgView.name, {
9229
9229
  version: pkgView.version,
9230
9230
  source: "bundled"
@@ -9235,7 +9235,7 @@ var AddonInstaller = class AddonInstaller {
9235
9235
  };
9236
9236
  } finally {
9237
9237
  this.inFlightStaging.delete(stagingName);
9238
- await fs.promises.rm(stagingDir, {
9238
+ await fs$1.promises.rm(stagingDir, {
9239
9239
  recursive: true,
9240
9240
  force: true
9241
9241
  }).catch(() => void 0);
@@ -9265,24 +9265,24 @@ var AddonInstaller = class AddonInstaller {
9265
9265
  const current = this.manifest.get(packageName);
9266
9266
  if (current == null) throw new Error(`Cannot update ${packageName}: not currently tracked in manifest`);
9267
9267
  const addonDir = path$1.join(this.addonsDir, packageName);
9268
- if (!fs.existsSync(addonDir)) throw new Error(`Cannot update ${packageName}: install dir ${addonDir} missing`);
9268
+ if (!fs$1.existsSync(addonDir)) throw new Error(`Cannot update ${packageName}: install dir ${addonDir} missing`);
9269
9269
  const ts = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
9270
9270
  const backupRoot = path$1.join(this.addonsDir, ".backups", packageName);
9271
9271
  ensureDir(backupRoot);
9272
9272
  const backupDir = path$1.join(backupRoot, ts);
9273
9273
  this.logger.info(`${packageName} — backing up v${current.version} → ${backupDir}`);
9274
- fs.renameSync(addonDir, backupDir);
9274
+ fs$1.renameSync(addonDir, backupDir);
9275
9275
  let result;
9276
9276
  try {
9277
9277
  result = await this.installFromNpm(packageName, version);
9278
9278
  } catch (installErr) {
9279
9279
  this.logger.error(`${packageName} — install failed, restoring backup`, { meta: { error: errMsg$1(installErr) } });
9280
9280
  try {
9281
- if (fs.existsSync(addonDir)) fs.rmSync(addonDir, {
9281
+ if (fs$1.existsSync(addonDir)) fs$1.rmSync(addonDir, {
9282
9282
  recursive: true,
9283
9283
  force: true
9284
9284
  });
9285
- fs.renameSync(backupDir, addonDir);
9285
+ fs$1.renameSync(backupDir, addonDir);
9286
9286
  this.manifest.upsert(packageName, {
9287
9287
  version: current.version,
9288
9288
  source: current.source,
@@ -9343,7 +9343,7 @@ var AddonInstaller = class AddonInstaller {
9343
9343
  const current = this.manifest.get(packageName);
9344
9344
  if (current == null) throw new Error(`Cannot update ${packageName}: not currently tracked in manifest`);
9345
9345
  const addonDir = path$1.join(this.addonsDir, packageName);
9346
- if (!fs.existsSync(addonDir)) throw new Error(`Cannot update ${packageName}: install dir ${addonDir} missing`);
9346
+ if (!fs$1.existsSync(addonDir)) throw new Error(`Cannot update ${packageName}: install dir ${addonDir} missing`);
9347
9347
  await this.installRuntimeDependencies(stagedPath, packageName);
9348
9348
  await this.installNativeDependencies(stagedPath, packageName);
9349
9349
  this.dedupeTreeAgainstClosure(stagedPath, packageName);
@@ -9352,14 +9352,14 @@ var AddonInstaller = class AddonInstaller {
9352
9352
  ensureDir(backupRoot);
9353
9353
  const backupDir = path$1.join(backupRoot, ts);
9354
9354
  this.logger.info(`${packageName} — backing up v${current.version} → ${backupDir}`);
9355
- fs.renameSync(addonDir, backupDir);
9355
+ fs$1.renameSync(addonDir, backupDir);
9356
9356
  try {
9357
9357
  try {
9358
- fs.renameSync(stagedPath, addonDir);
9358
+ fs$1.renameSync(stagedPath, addonDir);
9359
9359
  } catch (renameErr) {
9360
9360
  if (renameErr.code === "EXDEV") {
9361
- fs.cpSync(stagedPath, addonDir, { recursive: true });
9362
- fs.rmSync(stagedPath, {
9361
+ fs$1.cpSync(stagedPath, addonDir, { recursive: true });
9362
+ fs$1.rmSync(stagedPath, {
9363
9363
  recursive: true,
9364
9364
  force: true
9365
9365
  });
@@ -9368,11 +9368,11 @@ var AddonInstaller = class AddonInstaller {
9368
9368
  } catch (swapErr) {
9369
9369
  this.logger.error(`${packageName} — staged swap failed, restoring backup`, { meta: { error: errMsg$1(swapErr) } });
9370
9370
  try {
9371
- if (fs.existsSync(addonDir)) fs.rmSync(addonDir, {
9371
+ if (fs$1.existsSync(addonDir)) fs$1.rmSync(addonDir, {
9372
9372
  recursive: true,
9373
9373
  force: true
9374
9374
  });
9375
- fs.renameSync(backupDir, addonDir);
9375
+ fs$1.renameSync(backupDir, addonDir);
9376
9376
  this.manifest.upsert(packageName, {
9377
9377
  version: current.version,
9378
9378
  source: current.source,
@@ -9411,20 +9411,20 @@ var AddonInstaller = class AddonInstaller {
9411
9411
  this.logger.warn(`${packageName} — no backup to rollback to`);
9412
9412
  return null;
9413
9413
  }
9414
- if (!fs.existsSync(entry.lastBackupDir)) {
9414
+ if (!fs$1.existsSync(entry.lastBackupDir)) {
9415
9415
  this.logger.warn(`${packageName} — backup dir vanished: ${entry.lastBackupDir}`);
9416
9416
  return null;
9417
9417
  }
9418
9418
  const addonDir = path$1.join(this.addonsDir, packageName);
9419
- if (fs.existsSync(addonDir)) fs.rmSync(addonDir, {
9419
+ if (fs$1.existsSync(addonDir)) fs$1.rmSync(addonDir, {
9420
9420
  recursive: true,
9421
9421
  force: true
9422
9422
  });
9423
- fs.renameSync(entry.lastBackupDir, addonDir);
9423
+ fs$1.renameSync(entry.lastBackupDir, addonDir);
9424
9424
  const pkgJsonPath = path$1.join(addonDir, "package.json");
9425
9425
  let restoredVersion = entry.version;
9426
- if (fs.existsSync(pkgJsonPath)) try {
9427
- const parsed = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"));
9426
+ if (fs$1.existsSync(pkgJsonPath)) try {
9427
+ const parsed = JSON.parse(fs$1.readFileSync(pkgJsonPath, "utf-8"));
9428
9428
  if (typeof parsed === "object" && parsed != null) {
9429
9429
  const v = parsed.version;
9430
9430
  if (typeof v === "string" && v.length > 0) restoredVersion = v;
@@ -9472,7 +9472,7 @@ var AddonInstaller = class AddonInstaller {
9472
9472
  return false;
9473
9473
  }
9474
9474
  try {
9475
- await fs.promises.rm(target, {
9475
+ await fs$1.promises.rm(target, {
9476
9476
  recursive: true,
9477
9477
  force: true
9478
9478
  });
@@ -9490,7 +9490,7 @@ var AddonInstaller = class AddonInstaller {
9490
9490
  listBackupsFor(packageName) {
9491
9491
  const dir = path$1.join(this.backupsRoot, packageName);
9492
9492
  try {
9493
- return fs.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => path$1.join(dir, e.name)).sort();
9493
+ return fs$1.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => path$1.join(dir, e.name)).sort();
9494
9494
  } catch {
9495
9495
  return [];
9496
9496
  }
@@ -9522,7 +9522,7 @@ var AddonInstaller = class AddonInstaller {
9522
9522
  for (const dir of [pkgDir, path$1.dirname(pkgDir)]) {
9523
9523
  if (!this.isInsideBackups(dir)) continue;
9524
9524
  try {
9525
- await fs.promises.rmdir(dir);
9525
+ await fs$1.promises.rmdir(dir);
9526
9526
  } catch {
9527
9527
  return;
9528
9528
  }
@@ -9604,7 +9604,7 @@ var AddonInstaller = class AddonInstaller {
9604
9604
  */
9605
9605
  resolveBackupToKeep(packageName, backups) {
9606
9606
  const liveDir = path$1.join(this.addonsDir, packageName);
9607
- if (!fs.existsSync(liveDir)) {
9607
+ if (!fs$1.existsSync(liveDir)) {
9608
9608
  const newest = backups[backups.length - 1] ?? null;
9609
9609
  if (newest != null) this.logger.warn(`${packageName} — live install dir missing; retaining its newest backup as the only surviving copy`, { meta: {
9610
9610
  liveDir,
@@ -9621,7 +9621,7 @@ var AddonInstaller = class AddonInstaller {
9621
9621
  listBackedUpPackages() {
9622
9622
  let entries;
9623
9623
  try {
9624
- entries = fs.readdirSync(this.backupsRoot, { withFileTypes: true });
9624
+ entries = fs$1.readdirSync(this.backupsRoot, { withFileTypes: true });
9625
9625
  } catch {
9626
9626
  return [];
9627
9627
  }
@@ -9633,14 +9633,14 @@ var AddonInstaller = class AddonInstaller {
9633
9633
  continue;
9634
9634
  }
9635
9635
  const scopeDir = path$1.join(this.backupsRoot, entry.name);
9636
- for (const inner of fs.readdirSync(scopeDir, { withFileTypes: true })) if (inner.isDirectory()) names.push(`${entry.name}/${inner.name}`);
9636
+ for (const inner of fs$1.readdirSync(scopeDir, { withFileTypes: true })) if (inner.isDirectory()) names.push(`${entry.name}/${inner.name}`);
9637
9637
  }
9638
9638
  return names;
9639
9639
  }
9640
9640
  async uninstall(packageName) {
9641
9641
  const addonDir = path$1.join(this.addonsDir, packageName);
9642
- if (fs.existsSync(addonDir)) {
9643
- fs.rmSync(addonDir, {
9642
+ if (fs$1.existsSync(addonDir)) {
9643
+ fs$1.rmSync(addonDir, {
9644
9644
  recursive: true,
9645
9645
  force: true
9646
9646
  });
@@ -9648,8 +9648,8 @@ var AddonInstaller = class AddonInstaller {
9648
9648
  return;
9649
9649
  }
9650
9650
  const legacyDir = path$1.join(this.addonsDir, packageName.replace(/^@[^/]+\//, ""));
9651
- if (fs.existsSync(legacyDir)) {
9652
- fs.rmSync(legacyDir, {
9651
+ if (fs$1.existsSync(legacyDir)) {
9652
+ fs$1.rmSync(legacyDir, {
9653
9653
  recursive: true,
9654
9654
  force: true
9655
9655
  });
@@ -9657,22 +9657,22 @@ var AddonInstaller = class AddonInstaller {
9657
9657
  }
9658
9658
  }
9659
9659
  listInstalled() {
9660
- if (!fs.existsSync(this.addonsDir)) return [];
9660
+ if (!fs$1.existsSync(this.addonsDir)) return [];
9661
9661
  const packageDirs = [];
9662
- for (const entry of fs.readdirSync(this.addonsDir, { withFileTypes: true })) {
9662
+ for (const entry of fs$1.readdirSync(this.addonsDir, { withFileTypes: true })) {
9663
9663
  if (!isDirEntry(entry, this.addonsDir)) continue;
9664
9664
  if (entry.name.startsWith("@")) {
9665
9665
  const scopeDir = path$1.join(this.addonsDir, entry.name);
9666
- for (const inner of fs.readdirSync(scopeDir, { withFileTypes: true })) if (isDirEntry(inner, scopeDir)) packageDirs.push(path$1.join(scopeDir, inner.name));
9666
+ for (const inner of fs$1.readdirSync(scopeDir, { withFileTypes: true })) if (isDirEntry(inner, scopeDir)) packageDirs.push(path$1.join(scopeDir, inner.name));
9667
9667
  } else packageDirs.push(path$1.join(this.addonsDir, entry.name));
9668
9668
  }
9669
9669
  return packageDirs.map((dir) => {
9670
9670
  const pkgPath = path$1.join(dir, "package.json");
9671
- if (!fs.existsSync(pkgPath)) return null;
9671
+ if (!fs$1.existsSync(pkgPath)) return null;
9672
9672
  const pkg = readPackageJson(pkgPath);
9673
9673
  if (!pkg || !pkg.camstackAddons) return null;
9674
9674
  const sourceFile = path$1.join(dir, ".install-source");
9675
- const installSource = fs.existsSync(sourceFile) ? parseInstallSource(fs.readFileSync(sourceFile, "utf-8").trim()) : void 0;
9675
+ const installSource = fs$1.existsSync(sourceFile) ? parseInstallSource(fs$1.readFileSync(sourceFile, "utf-8").trim()) : void 0;
9676
9676
  return {
9677
9677
  name: pkg.name,
9678
9678
  version: pkg.version,
@@ -9682,13 +9682,13 @@ var AddonInstaller = class AddonInstaller {
9682
9682
  }).filter((item) => item !== null);
9683
9683
  }
9684
9684
  isInstalled(packageName) {
9685
- if (fs.existsSync(path$1.join(this.addonsDir, packageName, "package.json"))) return true;
9686
- return fs.existsSync(path$1.join(this.addonsDir, packageName.replace(/^@[^/]+\//, ""), "package.json"));
9685
+ if (fs$1.existsSync(path$1.join(this.addonsDir, packageName, "package.json"))) return true;
9686
+ return fs$1.existsSync(path$1.join(this.addonsDir, packageName.replace(/^@[^/]+\//, ""), "package.json"));
9687
9687
  }
9688
9688
  getInstalledPackage(packageName) {
9689
9689
  let pkgPath = path$1.join(this.addonsDir, packageName, "package.json");
9690
- if (!fs.existsSync(pkgPath)) pkgPath = path$1.join(this.addonsDir, packageName.replace(/^@[^/]+\//, ""), "package.json");
9691
- if (!fs.existsSync(pkgPath)) return null;
9690
+ if (!fs$1.existsSync(pkgPath)) pkgPath = path$1.join(this.addonsDir, packageName.replace(/^@[^/]+\//, ""), "package.json");
9691
+ if (!fs$1.existsSync(pkgPath)) return null;
9692
9692
  const pkg = readPackageJson(pkgPath);
9693
9693
  if (!pkg) return null;
9694
9694
  return {
@@ -9707,7 +9707,7 @@ var AddonInstaller = class AddonInstaller {
9707
9707
  ]) {
9708
9708
  const candidate = path$1.join(this.bundledAddonsDir, dirName);
9709
9709
  try {
9710
- const pkg = asJsonObject$1(parseJsonUnknown(fs.readFileSync(path$1.join(candidate, "package.json"), "utf-8")));
9710
+ const pkg = asJsonObject$1(parseJsonUnknown(fs$1.readFileSync(path$1.join(candidate, "package.json"), "utf-8")));
9711
9711
  if (pkg && asString$1(pkg["name"]) === packageName) return candidate;
9712
9712
  } catch {}
9713
9713
  }
@@ -9716,7 +9716,7 @@ var AddonInstaller = class AddonInstaller {
9716
9716
  /** Ensure a package is built (dist/ exists and page bundles present) */
9717
9717
  async ensureBuilt(packageName, sourceDir, pkgData) {
9718
9718
  const distDir = path$1.join(sourceDir, "dist");
9719
- if (!(!fs.existsSync(distDir) || this.isDistIncomplete(pkgData, sourceDir))) return;
9719
+ if (!(!fs$1.existsSync(distDir) || this.isDistIncomplete(pkgData, sourceDir))) return;
9720
9720
  this.logger.info(`${packageName} — building (dist/ missing or incomplete)`);
9721
9721
  try {
9722
9722
  await runNpm(["run", "build"], this.npmRunOptions(sourceDir, 18e4));
@@ -9731,7 +9731,7 @@ var AddonInstaller = class AddonInstaller {
9731
9731
  if (!camstack?.addons) return false;
9732
9732
  for (const addon of camstack.addons) {
9733
9733
  if (!addon.pages) continue;
9734
- for (const page of addon.pages) if (page.bundle && !fs.existsSync(path$1.join(sourceDir, "dist", page.bundle))) return true;
9734
+ for (const page of addon.pages) if (page.bundle && !fs$1.existsSync(path$1.join(sourceDir, "dist", page.bundle))) return true;
9735
9735
  }
9736
9736
  return false;
9737
9737
  }
@@ -9740,7 +9740,7 @@ var AddonInstaller = class AddonInstaller {
9740
9740
  function isDirEntry(entry, parentDir) {
9741
9741
  if (entry.isDirectory()) return true;
9742
9742
  if (entry.isSymbolicLink()) try {
9743
- return fs.statSync(path$1.join(parentDir, entry.name)).isDirectory();
9743
+ return fs$1.statSync(path$1.join(parentDir, entry.name)).isDirectory();
9744
9744
  } catch {
9745
9745
  return false;
9746
9746
  }
@@ -9839,7 +9839,7 @@ function selectAddonResidue(candidates) {
9839
9839
  }
9840
9840
  function readDeclaredName(dir) {
9841
9841
  try {
9842
- const parsed = JSON.parse(fs.readFileSync(path$1.join(dir, "package.json"), "utf-8"));
9842
+ const parsed = JSON.parse(fs$1.readFileSync(path$1.join(dir, "package.json"), "utf-8"));
9843
9843
  if (typeof parsed !== "object" || parsed === null) return null;
9844
9844
  const name = parsed.name;
9845
9845
  return typeof name === "string" ? name : null;
@@ -9849,7 +9849,7 @@ function readDeclaredName(dir) {
9849
9849
  }
9850
9850
  function readDeclaredVersion(dir) {
9851
9851
  try {
9852
- const parsed = JSON.parse(fs.readFileSync(path$1.join(dir, "package.json"), "utf-8"));
9852
+ const parsed = JSON.parse(fs$1.readFileSync(path$1.join(dir, "package.json"), "utf-8"));
9853
9853
  if (typeof parsed !== "object" || parsed === null) return null;
9854
9854
  const version = parsed.version;
9855
9855
  return typeof version === "string" ? version : null;
@@ -9859,7 +9859,7 @@ function readDeclaredVersion(dir) {
9859
9859
  }
9860
9860
  function isDirLike(p) {
9861
9861
  try {
9862
- return fs.statSync(p).isDirectory();
9862
+ return fs$1.statSync(p).isDirectory();
9863
9863
  } catch {
9864
9864
  return false;
9865
9865
  }
@@ -9869,7 +9869,7 @@ function freeQuarantineTarget(store, scope, dirName) {
9869
9869
  const base = scope === null ? dirName : `${scope.replace("@", "")}__${dirName}`;
9870
9870
  let candidate = path$1.join(store, base);
9871
9871
  let n = 1;
9872
- while (fs.existsSync(candidate)) {
9872
+ while (fs$1.existsSync(candidate)) {
9873
9873
  candidate = path$1.join(store, `${base}-${n}`);
9874
9874
  n += 1;
9875
9875
  }
@@ -9886,7 +9886,7 @@ function freeQuarantineTarget(store, scope, dirName) {
9886
9886
  function quarantineAddonResidue(addonsDir, log) {
9887
9887
  const quarantined = [];
9888
9888
  const failed = [];
9889
- if (!fs.existsSync(addonsDir)) return {
9889
+ if (!fs$1.existsSync(addonsDir)) return {
9890
9890
  quarantined,
9891
9891
  failed
9892
9892
  };
@@ -9894,7 +9894,7 @@ function quarantineAddonResidue(addonsDir, log) {
9894
9894
  const scan = (parent, scope) => {
9895
9895
  let names;
9896
9896
  try {
9897
- names = fs.readdirSync(parent);
9897
+ names = fs$1.readdirSync(parent);
9898
9898
  } catch {
9899
9899
  return;
9900
9900
  }
@@ -9913,8 +9913,8 @@ function quarantineAddonResidue(addonsDir, log) {
9913
9913
  const version = readDeclaredVersion(full);
9914
9914
  const to = freeQuarantineTarget(store, scope, dirName);
9915
9915
  try {
9916
- fs.mkdirSync(store, { recursive: true });
9917
- fs.renameSync(full, to);
9916
+ fs$1.mkdirSync(store, { recursive: true });
9917
+ fs$1.renameSync(full, to);
9918
9918
  } catch (err) {
9919
9919
  const error = err instanceof Error ? err.message : String(err);
9920
9920
  failed.push({
@@ -9972,11 +9972,11 @@ function getRestartMarkerPath(dataDir) {
9972
9972
  * intact or no marker at all (never a half-written file).
9973
9973
  */
9974
9974
  function writePendingRestart(dataDir, marker) {
9975
- fs.mkdirSync(dataDir, { recursive: true });
9975
+ fs$1.mkdirSync(dataDir, { recursive: true });
9976
9976
  const markerPath = getRestartMarkerPath(dataDir);
9977
9977
  const tmpPath = `${markerPath}.tmp`;
9978
- fs.writeFileSync(tmpPath, JSON.stringify(marker, null, 2), "utf-8");
9979
- fs.renameSync(tmpPath, markerPath);
9978
+ fs$1.writeFileSync(tmpPath, JSON.stringify(marker, null, 2), "utf-8");
9979
+ fs$1.renameSync(tmpPath, markerPath);
9980
9980
  }
9981
9981
  /**
9982
9982
  * Read + consume the marker. Returns the parsed payload on success and
@@ -10001,10 +10001,10 @@ function writePendingRestart(dataDir, marker) {
10001
10001
  */
10002
10002
  function readPendingRestart(dataDir) {
10003
10003
  const markerPath = getRestartMarkerPath(dataDir);
10004
- if (!fs.existsSync(markerPath)) return null;
10004
+ if (!fs$1.existsSync(markerPath)) return null;
10005
10005
  let raw;
10006
10006
  try {
10007
- raw = fs.readFileSync(markerPath, "utf-8");
10007
+ raw = fs$1.readFileSync(markerPath, "utf-8");
10008
10008
  } catch (err) {
10009
10009
  console.error("[restart-coordinator] Marker unreadable — leaving in place:", err);
10010
10010
  return null;
@@ -10043,7 +10043,7 @@ function readPendingRestart(dataDir) {
10043
10043
  /** Remove the marker if present. No-op if missing. */
10044
10044
  function clearPendingRestart(dataDir) {
10045
10045
  const markerPath = getRestartMarkerPath(dataDir);
10046
- fs.rmSync(markerPath, { force: true });
10046
+ fs$1.rmSync(markerPath, { force: true });
10047
10047
  }
10048
10048
  function isRestartKind(value) {
10049
10049
  return value === "framework-update" || value === "manual" || value === "system";
@@ -10055,7 +10055,7 @@ function scheduleSelfRestart(options = {}) {
10055
10055
  const touchTarget = process.env["CAMSTACK_RESTART_TOUCH_FILE"];
10056
10056
  if (touchTarget !== void 0 && touchTarget.length > 0) try {
10057
10057
  const now = /* @__PURE__ */ new Date();
10058
- fs.utimesSync(touchTarget, now, now);
10058
+ fs$1.utimesSync(touchTarget, now, now);
10059
10059
  return;
10060
10060
  } catch (err) {
10061
10061
  console.error("[restart-coordinator] dev touch-reload failed; falling through to process exit:", err);
@@ -20817,7 +20817,7 @@ async function probeVaapiInit(renderNode) {
20817
20817
  */
20818
20818
  function safeExistsSync(path) {
20819
20819
  try {
20820
- return fs.existsSync(path);
20820
+ return fs$1.existsSync(path);
20821
20821
  } catch {
20822
20822
  return false;
20823
20823
  }
@@ -20836,11 +20836,11 @@ function probeLinuxGpus() {
20836
20836
  if (safeExistsSync("/dev/nvidia0") || safeExistsSync("/proc/driver/nvidia/version")) signals.hasNvidiaGpu = true;
20837
20837
  try {
20838
20838
  const drmDir = "/sys/class/drm";
20839
- if (fs.existsSync(drmDir)) for (const entry of fs.readdirSync(drmDir)) {
20839
+ if (fs$1.existsSync(drmDir)) for (const entry of fs$1.readdirSync(drmDir)) {
20840
20840
  if (!entry.startsWith("card")) continue;
20841
20841
  const vendorPath = `${drmDir}/${entry}/device/vendor`;
20842
20842
  if (!safeExistsSync(vendorPath)) continue;
20843
- const vendor = fs.readFileSync(vendorPath, "utf8").trim().toLowerCase();
20843
+ const vendor = fs$1.readFileSync(vendorPath, "utf8").trim().toLowerCase();
20844
20844
  if (vendor === "0x10de") signals.hasNvidiaGpu = true;
20845
20845
  else if (vendor === "0x1002") signals.hasAmdGpu = true;
20846
20846
  else if (vendor === "0x8086") signals.hasIntelGpu = true;
@@ -21063,21 +21063,21 @@ function sleep$1(ms) {
21063
21063
  * crashed holder) is stolen.
21064
21064
  */
21065
21065
  async function withFileLock(lockPath, fn) {
21066
- fs.mkdirSync(join(lockPath, ".."), { recursive: true });
21066
+ fs$1.mkdirSync(join(lockPath, ".."), { recursive: true });
21067
21067
  for (;;) try {
21068
- const fd = fs.openSync(lockPath, "wx");
21069
- fs.closeSync(fd);
21068
+ const fd = fs$1.openSync(lockPath, "wx");
21069
+ fs$1.closeSync(fd);
21070
21070
  break;
21071
21071
  } catch {
21072
21072
  try {
21073
- if (Date.now() - fs.statSync(lockPath).mtimeMs > LOCK_STALE_MS) fs.rmSync(lockPath, { force: true });
21073
+ if (Date.now() - fs$1.statSync(lockPath).mtimeMs > LOCK_STALE_MS) fs$1.rmSync(lockPath, { force: true });
21074
21074
  else await sleep$1(LOCK_POLL_MS);
21075
21075
  } catch {}
21076
21076
  }
21077
21077
  try {
21078
21078
  return await fn();
21079
21079
  } finally {
21080
- fs.rmSync(lockPath, { force: true });
21080
+ fs$1.rmSync(lockPath, { force: true });
21081
21081
  }
21082
21082
  }
21083
21083
  /** Coalesce in-process + serialize cross-process for one binary id. */
@@ -21135,7 +21135,7 @@ var AddonDepsManager = class {
21135
21135
  * failed or tampered download throws, and provisioning reports it.
21136
21136
  */
21137
21137
  async stageNativeDepsDeclaredBy(requirementsFile) {
21138
- if (!declaresEdgetpuDelegate(fs.readFileSync(requirementsFile, "utf8"))) return;
21138
+ if (!declaresEdgetpuDelegate(fs$1.readFileSync(requirementsFile, "utf8"))) return;
21139
21139
  await singleFlight(this.depsDir, "edgetpu-delegate", () => ensureEdgetpuDelegate(this.nodeRoot, this.logger));
21140
21140
  }
21141
21141
  getDepsDir() {
@@ -22166,7 +22166,7 @@ async function buildAddonContext(runtime, declaration, dataDir, options) {
22166
22166
  const addonId = declaration.id;
22167
22167
  const nodeDataDir = process.env["CAMSTACK_DATA"] ?? dataDir;
22168
22168
  const addonDataDir = path$1.resolve(nodeDataDir, "addons-data", addonId);
22169
- fs.mkdirSync(addonDataDir, { recursive: true });
22169
+ fs$1.mkdirSync(addonDataDir, { recursive: true });
22170
22170
  if (runtime.mode === "broker") ensureBindingSubscription(runtime.broker);
22171
22171
  const regs = getRegistries(nodeId);
22172
22172
  const workerResolver = {
@@ -24143,7 +24143,7 @@ var FailedRunnerRetryLedger = class {
24143
24143
  function readRunnerPackageVersions(addonDirs) {
24144
24144
  const out = {};
24145
24145
  for (const dir of addonDirs) try {
24146
- const raw = JSON.parse(fs.readFileSync(path$1.join(dir, "package.json"), "utf-8"));
24146
+ const raw = JSON.parse(fs$1.readFileSync(path$1.join(dir, "package.json"), "utf-8"));
24147
24147
  const version = typeof raw === "object" && raw !== null ? Reflect.get(raw, "version") : null;
24148
24148
  out[dir] = typeof version === "string" && version.length > 0 ? version : null;
24149
24149
  } catch {
@@ -24204,7 +24204,7 @@ function readAddonHeapDeclaration(spec) {
24204
24204
  if (cached !== void 0) return cached;
24205
24205
  let declaration = EMPTY_HEAP_DECLARATION;
24206
24206
  for (const manifestPath of [path$1.join(spec.addonDir, "package.json"), path$1.join(path$1.dirname(spec.addonDir), "package.json")]) try {
24207
- const raw = fs.readFileSync(manifestPath, "utf8");
24207
+ const raw = fs$1.readFileSync(manifestPath, "utf8");
24208
24208
  const parsed = JSON.parse(raw);
24209
24209
  const profile = extractHeapProfile(parsed, spec.addonId);
24210
24210
  const maxOldSpaceMb = extractMaxOldSpaceMb(parsed, spec.addonId);
@@ -25437,17 +25437,17 @@ var JobJournal = class {
25437
25437
  return path$1.join(this.jobsDir, `${id}.json`);
25438
25438
  }
25439
25439
  writeAtomic(filePath, data) {
25440
- fs.mkdirSync(path$1.dirname(filePath), { recursive: true });
25440
+ fs$1.mkdirSync(path$1.dirname(filePath), { recursive: true });
25441
25441
  const tmp = `${filePath}.tmp.${process.pid}.${Date.now()}`;
25442
- fs.writeFileSync(tmp, JSON.stringify(data, null, 2), {
25442
+ fs$1.writeFileSync(tmp, JSON.stringify(data, null, 2), {
25443
25443
  encoding: "utf-8",
25444
25444
  mode: 384
25445
25445
  });
25446
- fs.renameSync(tmp, filePath);
25446
+ fs$1.renameSync(tmp, filePath);
25447
25447
  }
25448
25448
  readIndex() {
25449
25449
  try {
25450
- const raw = JSON.parse(fs.readFileSync(this.indexPath, "utf-8"));
25450
+ const raw = JSON.parse(fs$1.readFileSync(this.indexPath, "utf-8"));
25451
25451
  if (raw && Array.isArray(raw.jobIds)) return {
25452
25452
  version: 1,
25453
25453
  jobIds: raw.jobIds
@@ -25472,7 +25472,7 @@ var JobJournal = class {
25472
25472
  }
25473
25473
  getJob(id) {
25474
25474
  try {
25475
- const parsed = lifecycleJobSchema.safeParse(JSON.parse(fs.readFileSync(this.jobPath(id), "utf-8")));
25475
+ const parsed = lifecycleJobSchema.safeParse(JSON.parse(fs$1.readFileSync(this.jobPath(id), "utf-8")));
25476
25476
  return parsed.success ? parsed.data : null;
25477
25477
  } catch {
25478
25478
  return null;
@@ -25537,14 +25537,14 @@ var StagingArea = class {
25537
25537
  }
25538
25538
  async fetchAndStage(input) {
25539
25539
  const destDir = path$1.join(this.stagingDir, input.jobId, safeSegment(input.name));
25540
- fs.rmSync(destDir, {
25540
+ fs$1.rmSync(destDir, {
25541
25541
  recursive: true,
25542
25542
  force: true
25543
25543
  });
25544
25544
  const tgz = await this.deps.fetchTarball(input.name, input.version, input.signal);
25545
25545
  if (input.signal.aborted) throw new Error("staging aborted after fetch");
25546
25546
  await this.deps.extract(tgz, destDir);
25547
- const raw = JSON.parse(fs.readFileSync(path$1.join(destDir, "package.json"), "utf-8"));
25547
+ const raw = JSON.parse(fs$1.readFileSync(path$1.join(destDir, "package.json"), "utf-8"));
25548
25548
  if (typeof raw.version !== "string" || raw.version.length === 0) throw new Error(`staging validation failed: ${input.name} staged a package.json with no version`);
25549
25549
  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}`);
25550
25550
  return {
@@ -25553,7 +25553,7 @@ var StagingArea = class {
25553
25553
  };
25554
25554
  }
25555
25555
  cleanup(jobId) {
25556
- fs.rmSync(path$1.join(this.stagingDir, jobId), {
25556
+ fs$1.rmSync(path$1.join(this.stagingDir, jobId), {
25557
25557
  recursive: true,
25558
25558
  force: true
25559
25559
  });
@@ -25568,13 +25568,13 @@ var StagingArea = class {
25568
25568
  sweepOrphans() {
25569
25569
  let entries;
25570
25570
  try {
25571
- entries = fs.readdirSync(this.stagingDir);
25571
+ entries = fs$1.readdirSync(this.stagingDir);
25572
25572
  } catch {
25573
25573
  return 0;
25574
25574
  }
25575
25575
  let removed = 0;
25576
25576
  for (const name of entries) try {
25577
- fs.rmSync(path$1.join(this.stagingDir, name), {
25577
+ fs$1.rmSync(path$1.join(this.stagingDir, name), {
25578
25578
  recursive: true,
25579
25579
  force: true
25580
25580
  });
@@ -25752,7 +25752,7 @@ var LifecycleJobEngine = class {
25752
25752
  * on failure → `failed`.
25753
25753
  */
25754
25754
  async reconcileJob(job) {
25755
- const exists = this.deps.stagedPathExists ?? ((p) => fs.existsSync(p));
25755
+ const exists = this.deps.stagedPathExists ?? ((p) => fs$1.existsSync(p));
25756
25756
  for (const task of job.tasks) {
25757
25757
  if (task.target === "framework") {
25758
25758
  if (!this.isTerminal(task.phase)) this.skipFrameworkTask(job, task);
@@ -26401,7 +26401,7 @@ var CatalogRegistry = class {
26401
26401
  const file = path$1.join(packageDir, "i18n", `${lang}.json`);
26402
26402
  let text;
26403
26403
  try {
26404
- text = fs.readFileSync(file, "utf8");
26404
+ text = fs$1.readFileSync(file, "utf8");
26405
26405
  } catch {
26406
26406
  continue;
26407
26407
  }