@camstack/server 1.2.932 → 1.2.934

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 (45) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/api/trpc/generated-cap-routers.js +20 -0
  3. package/package.json +8 -7
  4. package/system/dist/addon-utils.mjs +1 -1
  5. package/system/dist/{base-device-IuM1AwXZ.mjs → base-device-Bwiblqmn.mjs} +1 -1
  6. package/system/dist/{base-device-2sL1DMm1.js → base-device-C1z4zYGR.js} +1 -1
  7. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +3 -3
  8. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +4 -4
  9. package/system/dist/builtins/alerts/alerts.addon.js +2 -2
  10. package/system/dist/builtins/alerts/alerts.addon.mjs +4 -4
  11. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +4 -4
  12. package/system/dist/builtins/camera-grid/index.js +2 -2
  13. package/system/dist/builtins/camera-grid/index.mjs +2 -2
  14. package/system/dist/builtins/composer/composer.addon.js +5 -5
  15. package/system/dist/builtins/composer/composer.addon.mjs +5 -5
  16. package/system/dist/builtins/core-blocks/cap-links.d.ts +34 -0
  17. package/system/dist/builtins/core-blocks/core-blocks.addon.d.ts +4 -0
  18. package/system/dist/builtins/core-blocks/core-blocks.addon.js +282 -8
  19. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +282 -8
  20. package/system/dist/builtins/device-manager/device-manager.addon.js +18 -4
  21. package/system/dist/builtins/device-manager/device-manager.addon.mjs +18 -4
  22. package/system/dist/builtins/local-auth/local-auth.addon.mjs +3 -3
  23. package/system/dist/builtins/local-network/local-network.addon.mjs +2 -2
  24. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +9 -9
  25. package/system/dist/builtins/platform-probe/index.mjs +9 -9
  26. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +19 -19
  27. package/system/dist/builtins/system-config/system-config.addon.mjs +113 -113
  28. package/system/dist/{composition-sources-BEUWn2s_.mjs → composition-sources-B0QW4g86.mjs} +2 -2
  29. package/system/dist/{composition-sources-acfR4hDq.js → composition-sources-BtUx1MfU.js} +2 -2
  30. package/system/dist/{coral-accelerators-zTMTEd-8.mjs → coral-accelerators-BKcXP59c.mjs} +6 -6
  31. package/system/dist/{core-blocks.cap-BRPsLAij.mjs → core-blocks.cap-CnwBuf7E.mjs} +1524 -1267
  32. package/system/dist/{core-blocks.cap-BMeMCBrx.js → core-blocks.cap-DlEuHq-S.js} +1555 -1268
  33. package/system/dist/{custom-action-registry-N7flBDwT.mjs → custom-action-registry-B9zFBNVa.mjs} +37 -37
  34. package/system/dist/{error.cap-CSM_SRfR.mjs → error.cap-5zNPAgU2.mjs} +19 -2
  35. package/system/dist/{error.cap-DBhgPeWK.js → error.cap-BCqzFlo2.js} +24 -1
  36. package/system/dist/{hub-identity-_IOgPJ00.mjs → hub-identity-DjMN9Ac2.mjs} +9 -9
  37. package/system/dist/{hub-mdns-ciao-Dk7ts_Uk.mjs → hub-mdns-ciao-DBrtHOcc.mjs} +1 -1
  38. package/system/dist/index.js +2 -2
  39. package/system/dist/index.mjs +214 -214
  40. package/system/dist/{prefix-walk-ifwg_ukx.mjs → prefix-walk-CRnbYJcC.mjs} +2 -2
  41. package/system/dist/{prefix-walk-BkMxoXpL.js → prefix-walk-DD1BM923.js} +2 -2
  42. package/system/dist/{rename-composition-block-BJsL58Ih.js → rename-composition-block-BRgyBO25.js} +20 -2
  43. package/system/dist/{rename-composition-block-OAtErZgq.mjs → rename-composition-block-BYRBlx-V.mjs} +20 -2
  44. package/system/dist/{restore-archive-kSFNjkWY.mjs → restore-archive-CjAyKpgX.mjs} +93 -93
  45. package/system/package.json +1 -1
@@ -1,18 +1,18 @@
1
1
  import { i as __require } from "./chunk-CNf5ZN-e.mjs";
2
2
  import { b as EventCategory$1, i as collectSecretMarkerRefs, p as createEvent$1 } from "./base-addon-Md14i7pe.mjs";
3
3
  import { Z as errMsg$1 } from "./scoped-settings-DVWUIP7Z.mjs";
4
- import { Un as lifecycleJobSchema, a as isCollectionArrayMethod, c as kebabToCamel$1, d as objectInputDeclaresRequiredDeviceId, dr as compareVersions, f as procedureAuthKey, fr as describeUnmet, i as isArrayOutputSchema, l as looseSchema, m as ALL_CAPABILITY_DEFINITIONS, o as isObjectInput, p as resolveMethodAuth, pr as unmetRequirements, r as extractNestedAddonId, s as isVoidInput, u as objectInputDeclaresAddonId, ur as PackageRequiresSchema } from "./rename-composition-block-OAtErZgq.mjs";
4
+ import { Un as lifecycleJobSchema, a as isCollectionArrayMethod, c as kebabToCamel$1, d as objectInputDeclaresRequiredDeviceId, dr as compareVersions, f as procedureAuthKey, fr as describeUnmet, i as isArrayOutputSchema, l as looseSchema, m as ALL_CAPABILITY_DEFINITIONS, o as isObjectInput, p as resolveMethodAuth, pr as unmetRequirements, r as extractNestedAddonId, s as isVoidInput, u as objectInputDeclaresAddonId, ur as PackageRequiresSchema } from "./rename-composition-block-BYRBlx-V.mjs";
5
5
  import { t as userError } from "./camstack-error-viZYfcj9.mjs";
6
6
  import { a as expandCapMethods, n as DEVICE_STATUS_METHOD, t as DEVICE_SETTINGS_CONTRIBUTION_METHODS, u as resolveCapMount } from "./capability-definition-C2rJdVeX.mjs";
7
7
  import { s as defineRecordKinds } from "./record-kind-ub6NXqfh.mjs";
8
8
  import { D as RecordsEngine, J as asNumber, X as parseJsonObject, Y as asString$1, Z as parseJsonUnknown, l as SqliteSettingsBackend, q as asJsonObject$1 } from "./wal-maintenance-BG01rOn9.mjs";
9
9
  import { f as AppPageLangSchema } from "./device-certificate-Cddm4Idn.mjs";
10
10
  import { i as addonSettingsCapability } from "./addon-settings.cap-3-TIIMq_.mjs";
11
- import { t as loadPrefixed } from "./prefix-walk-ifwg_ukx.mjs";
11
+ import { t as loadPrefixed } from "./prefix-walk-CRnbYJcC.mjs";
12
12
  import { a as AGENT_MDNS_TXT_KEYS, i as AGENT_MDNS_SERVICE_TYPE } from "./network-access.cap-BJnGbE6n.mjs";
13
13
  import { t as RUNTIME_DEFAULTS } from "./constants-DCLpoF4L.mjs";
14
14
  import { t as bareAddonId } from "./addon-id-CVg1_r5E.mjs";
15
- import { r as nodeCoralFs, s as supportedRuntimes, t as classifyCoralAccelerator } from "./coral-accelerators-zTMTEd-8.mjs";
15
+ import { r as nodeCoralFs, s as supportedRuntimes, t as classifyCoralAccelerator } from "./coral-accelerators-BKcXP59c.mjs";
16
16
  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-BLM6fccc.mjs";
17
17
  import { t as require_read_all_rows } from "./read-all-rows-TaPqdWNF.mjs";
18
18
  import { a as redactLogText, i as redactLogMeta, r as redactLogEntry, t as isCredentialKeyName } from "./log-redactor-XLDrPzOi.mjs";
@@ -46,22 +46,22 @@ import { SqliteSettingsAddon } from "./builtins/sqlite-storage/sqlite-settings.a
46
46
  import { ConfigStore, DeviceStore } from "./builtins/sqlite-storage/index.mjs";
47
47
  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";
48
48
  import "./builtins/storage-orchestrator/index.mjs";
49
- 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-_IOgPJ00.mjs";
49
+ 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-DjMN9Ac2.mjs";
50
50
  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-DB4piTD5.mjs";
51
51
  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";
52
52
  import "./builtins/system-config/index.mjs";
53
53
  import { WinstonDestination, WinstonLoggingAddon } from "./builtins/winston-logging/index.mjs";
54
- 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";
55
- 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-Dk7ts_Uk.mjs";
54
+ 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";
55
+ 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-DBrtHOcc.mjs";
56
56
  import { n as getPlatformKeychainKey, r as setPlatformKeychainKey, t as clearPlatformKeychainKey } from "./platform-key-source-BWlq0jjn.mjs";
57
57
  import { n as getSinglePidStats, t as getPidStats } from "./resource-monitor-Di9daRwI.mjs";
58
- 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-kSFNjkWY.mjs";
58
+ 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-CjAyKpgX.mjs";
59
59
  import { z } from "zod";
60
60
  import * as crypto$1 from "node:crypto";
61
61
  import { createHash, randomBytes, randomUUID } from "node:crypto";
62
62
  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";
63
63
  import { connect, createConnection, createServer } from "node:net";
64
- import * as fs from "node:fs";
64
+ import * as fs$1 from "node:fs";
65
65
  import { accessSync, constants, createReadStream, createWriteStream, existsSync, readFileSync, readdirSync } from "node:fs";
66
66
  import * as path$1 from "node:path";
67
67
  import { basename, dirname, isAbsolute, join, resolve } from "node:path";
@@ -5700,7 +5700,7 @@ var PythonEnvManager = class {
5700
5700
  async ensure(options) {
5701
5701
  const probe = await this.probe();
5702
5702
  if (!probe.available || !probe.path) throw userError("system.python-required", void 0, "Python 3.10+ is required but not found on this system");
5703
- if (!fs.existsSync(path$1.join(this.venvPath, "bin", "python"))) await execFileAsync$7(probe.path, [
5703
+ if (!fs$1.existsSync(path$1.join(this.venvPath, "bin", "python"))) await execFileAsync$7(probe.path, [
5704
5704
  "-m",
5705
5705
  "venv",
5706
5706
  this.venvPath
@@ -5723,7 +5723,7 @@ var PythonEnvManager = class {
5723
5723
  }
5724
5724
  spawn(script, args) {
5725
5725
  const venvPython = path$1.join(this.venvPath, "bin", "python");
5726
- if (!fs.existsSync(venvPython)) throw new Error("Python venv not initialized. Call ensure() first.");
5726
+ if (!fs$1.existsSync(venvPython)) throw new Error("Python venv not initialized. Call ensure() first.");
5727
5727
  return spawn(venvPython, [script, ...args]);
5728
5728
  }
5729
5729
  };
@@ -6075,20 +6075,20 @@ var StorageManager = class {
6075
6075
  const basePath = this.locationManager.getBackend(mappedName).basePath;
6076
6076
  location.files = {
6077
6077
  async readFile(p) {
6078
- return fs.promises.readFile(path$1.join(basePath, p));
6078
+ return fs$1.promises.readFile(path$1.join(basePath, p));
6079
6079
  },
6080
6080
  async writeFile(p, data) {
6081
6081
  const full = path$1.join(basePath, p);
6082
- await fs.promises.mkdir(path$1.dirname(full), { recursive: true });
6083
- await fs.promises.writeFile(full, data);
6082
+ await fs$1.promises.mkdir(path$1.dirname(full), { recursive: true });
6083
+ await fs$1.promises.writeFile(full, data);
6084
6084
  },
6085
6085
  async deleteFile(p) {
6086
- await fs.promises.rm(path$1.join(basePath, p), { force: true });
6086
+ await fs$1.promises.rm(path$1.join(basePath, p), { force: true });
6087
6087
  },
6088
6088
  async listFiles(prefix) {
6089
6089
  const dir = prefix ? path$1.join(basePath, prefix) : basePath;
6090
6090
  try {
6091
- return (await fs.promises.readdir(dir)).map((f) => prefix ? `${prefix}/${f}` : f);
6091
+ return (await fs$1.promises.readdir(dir)).map((f) => prefix ? `${prefix}/${f}` : f);
6092
6092
  } catch {
6093
6093
  return [];
6094
6094
  }
@@ -6098,7 +6098,7 @@ var StorageManager = class {
6098
6098
  },
6099
6099
  async exists(p) {
6100
6100
  try {
6101
- await fs.promises.access(path$1.join(basePath, p));
6101
+ await fs$1.promises.access(path$1.join(basePath, p));
6102
6102
  return true;
6103
6103
  } catch {
6104
6104
  return false;
@@ -6548,7 +6548,7 @@ var TRADITIONAL_NATIVE_PACKAGES = ["better-sqlite3"];
6548
6548
  function hasDotNode(dir, maxDepth) {
6549
6549
  let entries;
6550
6550
  try {
6551
- entries = fs.readdirSync(dir, { withFileTypes: true });
6551
+ entries = fs$1.readdirSync(dir, { withFileTypes: true });
6552
6552
  } catch {
6553
6553
  return false;
6554
6554
  }
@@ -6559,7 +6559,7 @@ function hasDotNode(dir, maxDepth) {
6559
6559
  }
6560
6560
  /** Locate the bundled `prebuild-install` bin.js inside the staged closure. */
6561
6561
  function resolvePrebuildInstallBin(closureDir, moduleDir) {
6562
- 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;
6562
+ 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;
6563
6563
  }
6564
6564
  /**
6565
6565
  * Default fetcher: run the closure's own `prebuild-install` under the CURRENT
@@ -6612,7 +6612,7 @@ async function ensureNativePrebuilds(closureDir, options) {
6612
6612
  const fetched = [];
6613
6613
  for (const pkg of packages) {
6614
6614
  const moduleDir = path$1.join(nm, pkg);
6615
- if (!fs.existsSync(moduleDir)) continue;
6615
+ if (!fs$1.existsSync(moduleDir)) continue;
6616
6616
  if (hasDotNode(moduleDir, 4)) continue;
6617
6617
  options.logger.warn("staged closure native prebuild missing — fetching for running ABI", { meta: {
6618
6618
  pkg,
@@ -6675,12 +6675,12 @@ async function ensureNativePrebuilds(closureDir, options) {
6675
6675
  function replantFromBundled(srcModuleDir, dstModuleDir, hasNative) {
6676
6676
  if (!hasNative(srcModuleDir)) return false;
6677
6677
  try {
6678
- fs.rmSync(dstModuleDir, {
6678
+ fs$1.rmSync(dstModuleDir, {
6679
6679
  recursive: true,
6680
6680
  force: true
6681
6681
  });
6682
- fs.mkdirSync(path$1.dirname(dstModuleDir), { recursive: true });
6683
- fs.cpSync(srcModuleDir, dstModuleDir, {
6682
+ fs$1.mkdirSync(path$1.dirname(dstModuleDir), { recursive: true });
6683
+ fs$1.cpSync(srcModuleDir, dstModuleDir, {
6684
6684
  recursive: true,
6685
6685
  dereference: true
6686
6686
  });
@@ -6709,7 +6709,7 @@ async function ensureAddonNativePrebuilds(addonDir, options) {
6709
6709
  const missing = [];
6710
6710
  for (const pkg of packages) {
6711
6711
  const moduleDir = path$1.join(nm, pkg);
6712
- if (!fs.existsSync(moduleDir)) continue;
6712
+ if (!fs$1.existsSync(moduleDir)) continue;
6713
6713
  if (hasNative(moduleDir)) {
6714
6714
  results.push({
6715
6715
  pkg,
@@ -6808,7 +6808,7 @@ async function defaultDownloadTarball(url, destTgz) {
6808
6808
  const res = await fetch(url);
6809
6809
  if (!res.ok || !res.body) throw new Error(`HTTP ${res.status} downloading ${url}`);
6810
6810
  const bytes = Buffer.from(await res.arrayBuffer());
6811
- await fs.promises.writeFile(destTgz, bytes);
6811
+ await fs$1.promises.writeFile(destTgz, bytes);
6812
6812
  }
6813
6813
  async function defaultExtractTarball(tgzPath, destDir) {
6814
6814
  await execFileAsync$5("tar", [
@@ -6894,7 +6894,7 @@ async function resolveUncached(options) {
6894
6894
  argsPrefix: []
6895
6895
  };
6896
6896
  const cliPath = bootstrappedCliPath(options.cacheDir);
6897
- if (fs.existsSync(cliPath)) {
6897
+ if (fs$1.existsSync(cliPath)) {
6898
6898
  options.logger.info("system npm unavailable — using bootstrapped npm", { meta: { cliPath } });
6899
6899
  return {
6900
6900
  command: process.execPath,
@@ -6906,12 +6906,12 @@ async function resolveUncached(options) {
6906
6906
  const registry = (options.registry ?? DEFAULT_REGISTRY$1).replace(/\/+$/, "");
6907
6907
  const tarballUrl = tarballUrlOf(await (options.fetchJson ?? defaultFetchJson)(`${registry}/npm/latest`));
6908
6908
  if (!tarballUrl) throw new Error(`registry metadata for 'npm' carries no dist.tarball (${registry})`);
6909
- await fs.promises.mkdir(options.cacheDir, { recursive: true });
6909
+ await fs$1.promises.mkdir(options.cacheDir, { recursive: true });
6910
6910
  const tgzPath = path$1.join(options.cacheDir, "npm-bootstrap.tgz");
6911
6911
  await (options.downloadTarball ?? defaultDownloadTarball)(tarballUrl, tgzPath);
6912
6912
  await (options.extractTarball ?? defaultExtractTarball)(tgzPath, options.cacheDir);
6913
- await fs.promises.rm(tgzPath, { force: true });
6914
- if (!fs.existsSync(cliPath)) throw new Error(`extracted npm tarball is missing ${cliPath}`);
6913
+ await fs$1.promises.rm(tgzPath, { force: true });
6914
+ if (!fs$1.existsSync(cliPath)) throw new Error(`extracted npm tarball is missing ${cliPath}`);
6915
6915
  options.logger.info("npm bootstrapped", { meta: { cliPath } });
6916
6916
  return {
6917
6917
  command: process.execPath,
@@ -6977,7 +6977,7 @@ function readOwningPackageVersion(entryPath) {
6977
6977
  let dir = path$1.dirname(entryPath);
6978
6978
  for (let hop = 0; hop < PACKAGE_JSON_LOOKUP_DEPTH; hop++) {
6979
6979
  try {
6980
- const version = asJsonObject$1(parseJsonUnknown(fs.readFileSync(path$1.join(dir, "package.json"), "utf-8")))?.["version"];
6980
+ const version = asJsonObject$1(parseJsonUnknown(fs$1.readFileSync(path$1.join(dir, "package.json"), "utf-8")))?.["version"];
6981
6981
  if (typeof version === "string" && version.length > 0) return version;
6982
6982
  } catch {}
6983
6983
  const parent = path$1.dirname(dir);
@@ -7021,14 +7021,14 @@ function readOwningPackageVersion(entryPath) {
7021
7021
  function addonModuleCacheKey(entryPath) {
7022
7022
  let stat;
7023
7023
  try {
7024
- stat = fs.statSync(entryPath);
7024
+ stat = fs$1.statSync(entryPath);
7025
7025
  } catch {
7026
7026
  return null;
7027
7027
  }
7028
7028
  const version = readOwningPackageVersion(entryPath) ?? `m${stat.mtimeMs}`;
7029
7029
  let content;
7030
7030
  try {
7031
- content = createHash("sha1").update(fs.readFileSync(entryPath)).digest("hex").slice(0, 16);
7031
+ content = createHash("sha1").update(fs$1.readFileSync(entryPath)).digest("hex").slice(0, 16);
7032
7032
  } catch {
7033
7033
  content = `m${stat.mtimeMs}s${stat.size}`;
7034
7034
  }
@@ -7132,14 +7132,14 @@ var AddonLoader = class {
7132
7132
  * BUILTINS from the active closure, not the (now-inert) addons-dir copy, so
7133
7133
  * the addons-dir `@camstack/server/system` must NOT be double-loaded here. */
7134
7134
  async loadFromDirectory(addonsDir, skipPackages = []) {
7135
- if (!fs.existsSync(addonsDir)) return;
7135
+ if (!fs$1.existsSync(addonsDir)) return;
7136
7136
  const skip = new Set(skipPackages);
7137
- const entries = fs.readdirSync(addonsDir, { withFileTypes: true });
7137
+ const entries = fs$1.readdirSync(addonsDir, { withFileTypes: true });
7138
7138
  for (const entry of entries) {
7139
7139
  if (!isDirectoryEntry(entry, addonsDir)) continue;
7140
7140
  if (entry.name.startsWith("@")) {
7141
7141
  const scopeDir = path$1.join(addonsDir, entry.name);
7142
- const scopeEntries = fs.readdirSync(scopeDir, { withFileTypes: true });
7142
+ const scopeEntries = fs$1.readdirSync(scopeDir, { withFileTypes: true });
7143
7143
  for (const scopeEntry of scopeEntries) {
7144
7144
  if (!isDirectoryEntry(scopeEntry, scopeDir)) continue;
7145
7145
  if (skip.has(`${entry.name}/${scopeEntry.name}`)) continue;
@@ -7153,7 +7153,7 @@ var AddonLoader = class {
7153
7153
  }
7154
7154
  async tryLoadAddon(addonDir) {
7155
7155
  const pkgJsonPath = path$1.join(addonDir, "package.json");
7156
- if (!fs.existsSync(pkgJsonPath)) return;
7156
+ if (!fs$1.existsSync(pkgJsonPath)) return;
7157
7157
  try {
7158
7158
  await this.loadFromAddonDir(addonDir);
7159
7159
  } catch (err) {
@@ -7171,7 +7171,7 @@ var AddonLoader = class {
7171
7171
  /** Load addon from a specific directory (package.json + dist/) */
7172
7172
  async loadFromAddonDir(addonDir) {
7173
7173
  const pkgJsonPath = path$1.join(addonDir, "package.json");
7174
- const pkgJson = asJsonObject$1(parseJsonUnknown(fs.readFileSync(pkgJsonPath, "utf-8"))) ?? {};
7174
+ const pkgJson = asJsonObject$1(parseJsonUnknown(fs$1.readFileSync(pkgJsonPath, "utf-8"))) ?? {};
7175
7175
  const packageNameRaw = pkgJson["name"];
7176
7176
  const packageName = typeof packageNameRaw === "string" ? packageNameRaw : "";
7177
7177
  const packageVersionRaw = pkgJson["version"];
@@ -7219,7 +7219,7 @@ var AddonLoader = class {
7219
7219
  }
7220
7220
  const entryFile = declaration.entry.replace(/^\.\//, "").replace(/^src\//, "dist/").replace(/\.ts$/, ".js");
7221
7221
  let entryPath = path$1.resolve(addonDir, entryFile);
7222
- if (!fs.existsSync(entryPath)) {
7222
+ if (!fs$1.existsSync(entryPath)) {
7223
7223
  const base = entryPath.replace(/\.(js|cjs|mjs)$/, "");
7224
7224
  entryPath = [
7225
7225
  `${base}.cjs`,
@@ -7228,9 +7228,9 @@ var AddonLoader = class {
7228
7228
  path$1.resolve(addonDir, "dist", "index.cjs"),
7229
7229
  path$1.resolve(addonDir, "dist", "index.mjs"),
7230
7230
  path$1.resolve(addonDir, declaration.entry)
7231
- ].find((p) => fs.existsSync(p)) ?? entryPath;
7231
+ ].find((p) => fs$1.existsSync(p)) ?? entryPath;
7232
7232
  }
7233
- if (!fs.existsSync(entryPath)) throw new Error(`Entry not found: ${entryPath}`);
7233
+ if (!fs$1.existsSync(entryPath)) throw new Error(`Entry not found: ${entryPath}`);
7234
7234
  const modUnknown = await importAddonModuleFresh(entryPath);
7235
7235
  const mod = isRecord$4(modUnknown) ? modUnknown : {};
7236
7236
  const AddonClass = resolveAddonClass(mod);
@@ -7342,7 +7342,7 @@ function isDirectoryEntry(entry, parentDir) {
7342
7342
  if (entry.name.startsWith(".")) return false;
7343
7343
  if (entry.isDirectory()) return true;
7344
7344
  if (entry.isSymbolicLink()) try {
7345
- return fs.statSync(path$1.join(parentDir, entry.name)).isDirectory();
7345
+ return fs$1.statSync(path$1.join(parentDir, entry.name)).isDirectory();
7346
7346
  } catch {
7347
7347
  return false;
7348
7348
  }
@@ -7436,7 +7436,7 @@ var execFileAsync$4 = promisify(execFile);
7436
7436
  * Single source of truth — replaces scattered mkdirSync calls.
7437
7437
  */
7438
7438
  function ensureDir(dirPath) {
7439
- fs.mkdirSync(dirPath, { recursive: true });
7439
+ fs$1.mkdirSync(dirPath, { recursive: true });
7440
7440
  }
7441
7441
  /**
7442
7442
  * Copy a directory recursively — ASYNC so it never blocks the event loop.
@@ -7449,7 +7449,7 @@ function ensureDir(dirPath) {
7449
7449
  * `fs.promises.cp` keeps the I/O off the event loop. (Node ≥18 stable.)
7450
7450
  */
7451
7451
  async function copyDirRecursive(src, dest) {
7452
- await fs.promises.cp(src, dest, {
7452
+ await fs$1.promises.cp(src, dest, {
7453
7453
  recursive: true,
7454
7454
  force: true
7455
7455
  });
@@ -7554,13 +7554,13 @@ async function copyExtraFileDirs(pkgJson, sourceDir, destDir) {
7554
7554
  if (typeof fileEntry !== "string") continue;
7555
7555
  if (fileEntry === "dist" || fileEntry.includes("*")) continue;
7556
7556
  const srcPath = path$1.join(sourceDir, fileEntry);
7557
- if (!fs.existsSync(srcPath)) continue;
7557
+ if (!fs$1.existsSync(srcPath)) continue;
7558
7558
  const destPath = path$1.join(destDir, fileEntry);
7559
- const stat = await fs.promises.stat(srcPath);
7559
+ const stat = await fs$1.promises.stat(srcPath);
7560
7560
  if (stat.isDirectory()) await copyDirRecursive(srcPath, destPath);
7561
7561
  else if (stat.isFile()) {
7562
7562
  ensureDir(path$1.dirname(destPath));
7563
- await fs.promises.copyFile(srcPath, destPath);
7563
+ await fs$1.promises.copyFile(srcPath, destPath);
7564
7564
  }
7565
7565
  }
7566
7566
  }
@@ -7571,10 +7571,10 @@ async function copyExtraFileDirs(pkgJson, sourceDir, destDir) {
7571
7571
  function isSourceNewer(packageDir) {
7572
7572
  const srcDir = path$1.join(packageDir, "src");
7573
7573
  const distDir = path$1.join(packageDir, "dist");
7574
- if (!fs.existsSync(srcDir) || !fs.existsSync(distDir)) return true;
7574
+ if (!fs$1.existsSync(srcDir) || !fs$1.existsSync(distDir)) return true;
7575
7575
  try {
7576
- const distMtime = fs.statSync(distDir).mtimeMs;
7577
- const entries = fs.readdirSync(srcDir, {
7576
+ const distMtime = fs$1.statSync(distDir).mtimeMs;
7577
+ const entries = fs$1.readdirSync(srcDir, {
7578
7578
  withFileTypes: true,
7579
7579
  recursive: true
7580
7580
  });
@@ -7582,7 +7582,7 @@ function isSourceNewer(packageDir) {
7582
7582
  if (!entry.isFile()) continue;
7583
7583
  const parentDir = entry.parentPath ?? String(Reflect.get(entry, "path") ?? "");
7584
7584
  const filePath = path$1.join(parentDir, entry.name);
7585
- if (fs.statSync(filePath).mtimeMs > distMtime) return true;
7585
+ if (fs$1.statSync(filePath).mtimeMs > distMtime) return true;
7586
7586
  }
7587
7587
  return false;
7588
7588
  } catch {
@@ -7599,7 +7599,7 @@ function isSourceNewer(packageDir) {
7599
7599
  * `copyDirRecursive` for the wedge this prevents.
7600
7600
  */
7601
7601
  async function installPackageFromNpm(packageName, targetDir) {
7602
- const tmpDir = await fs.promises.mkdtemp(path$1.join(os$1.tmpdir(), "camstack-install-"));
7602
+ const tmpDir = await fs$1.promises.mkdtemp(path$1.join(os$1.tmpdir(), "camstack-install-"));
7603
7603
  try {
7604
7604
  const { stdout } = await execFileAsync$4("npm", [
7605
7605
  "pack",
@@ -7622,21 +7622,21 @@ async function installPackageFromNpm(packageName, targetDir) {
7622
7622
  extractDir
7623
7623
  ], { timeout: 3e4 });
7624
7624
  const packageSubDir = path$1.join(extractDir, "package");
7625
- const srcPkgJsonDir = fs.existsSync(path$1.join(packageSubDir, "package.json")) ? packageSubDir : extractDir;
7626
- await fs.promises.rm(targetDir, {
7625
+ const srcPkgJsonDir = fs$1.existsSync(path$1.join(packageSubDir, "package.json")) ? packageSubDir : extractDir;
7626
+ await fs$1.promises.rm(targetDir, {
7627
7627
  recursive: true,
7628
7628
  force: true
7629
7629
  });
7630
7630
  ensureDir(targetDir);
7631
- await fs.promises.copyFile(path$1.join(srcPkgJsonDir, "package.json"), path$1.join(targetDir, "package.json"));
7631
+ await fs$1.promises.copyFile(path$1.join(srcPkgJsonDir, "package.json"), path$1.join(targetDir, "package.json"));
7632
7632
  const distSrc = path$1.join(srcPkgJsonDir, "dist");
7633
- if (fs.existsSync(distSrc)) await copyDirRecursive(distSrc, path$1.join(targetDir, "dist"));
7633
+ if (fs$1.existsSync(distSrc)) await copyDirRecursive(distSrc, path$1.join(targetDir, "dist"));
7634
7634
  try {
7635
- const npmPkg = asJsonObject$1(parseJsonUnknown(await fs.promises.readFile(path$1.join(srcPkgJsonDir, "package.json"), "utf-8")));
7635
+ const npmPkg = asJsonObject$1(parseJsonUnknown(await fs$1.promises.readFile(path$1.join(srcPkgJsonDir, "package.json"), "utf-8")));
7636
7636
  if (npmPkg) await copyExtraFileDirs(npmPkg, srcPkgJsonDir, targetDir);
7637
7637
  } catch {}
7638
7638
  } finally {
7639
- await fs.promises.rm(tmpDir, {
7639
+ await fs$1.promises.rm(tmpDir, {
7640
7640
  recursive: true,
7641
7641
  force: true
7642
7642
  });
@@ -7661,7 +7661,7 @@ function packageDirName$1(declaredName) {
7661
7661
  }
7662
7662
  function isDirLike$1(p) {
7663
7663
  try {
7664
- return fs.statSync(p).isDirectory();
7664
+ return fs$1.statSync(p).isDirectory();
7665
7665
  } catch {
7666
7666
  return false;
7667
7667
  }
@@ -7679,12 +7679,12 @@ var AddonManifest = class {
7679
7679
  */
7680
7680
  read() {
7681
7681
  if (this.cache != null) return this.cache;
7682
- if (!fs.existsSync(this.manifestPath)) {
7682
+ if (!fs$1.existsSync(this.manifestPath)) {
7683
7683
  this.cache = this.empty();
7684
7684
  return this.cache;
7685
7685
  }
7686
7686
  try {
7687
- const raw = fs.readFileSync(this.manifestPath, "utf-8");
7687
+ const raw = fs$1.readFileSync(this.manifestPath, "utf-8");
7688
7688
  const parsed = JSON.parse(raw);
7689
7689
  if (parsed.version !== MANIFEST_VERSION) {
7690
7690
  process.stderr.write(`[AddonManifest] schema mismatch (file=${parsed.version} vs runtime=${MANIFEST_VERSION}); starting empty\n`);
@@ -7705,13 +7705,13 @@ var AddonManifest = class {
7705
7705
  * a half-written file.
7706
7706
  */
7707
7707
  write(manifest) {
7708
- fs.mkdirSync(path$1.dirname(this.manifestPath), { recursive: true });
7708
+ fs$1.mkdirSync(path$1.dirname(this.manifestPath), { recursive: true });
7709
7709
  const tmp = `${this.manifestPath}.tmp.${process.pid}.${Date.now()}`;
7710
- fs.writeFileSync(tmp, JSON.stringify(manifest, null, 2), {
7710
+ fs$1.writeFileSync(tmp, JSON.stringify(manifest, null, 2), {
7711
7711
  encoding: "utf-8",
7712
7712
  mode: 384
7713
7713
  });
7714
- fs.renameSync(tmp, this.manifestPath);
7714
+ fs$1.renameSync(tmp, this.manifestPath);
7715
7715
  this.cache = manifest;
7716
7716
  }
7717
7717
  /** Lookup a single addon's manifest entry, or `null` if not tracked. */
@@ -7786,22 +7786,22 @@ var AddonManifest = class {
7786
7786
  * exactly what moved. Returns the total number of changes.
7787
7787
  */
7788
7788
  reconcileFromDisk(addonsDir, onChange) {
7789
- if (!fs.existsSync(addonsDir)) return 0;
7789
+ if (!fs$1.existsSync(addonsDir)) return 0;
7790
7790
  const m = this.read();
7791
7791
  let changes = 0;
7792
7792
  const now = (/* @__PURE__ */ new Date()).toISOString();
7793
7793
  /** Package name → version, for every ADDON package actually installed. */
7794
7794
  const onDisk = /* @__PURE__ */ new Map();
7795
- for (const scope of fs.readdirSync(addonsDir, { withFileTypes: true })) {
7795
+ for (const scope of fs$1.readdirSync(addonsDir, { withFileTypes: true })) {
7796
7796
  if (!scope.name.startsWith("@") || !isDirLike$1(path$1.join(addonsDir, scope.name))) continue;
7797
7797
  const scopeDir = path$1.join(addonsDir, scope.name);
7798
- for (const pkg of fs.readdirSync(scopeDir, { withFileTypes: true })) {
7798
+ for (const pkg of fs$1.readdirSync(scopeDir, { withFileTypes: true })) {
7799
7799
  if (!isDirLike$1(path$1.join(scopeDir, pkg.name))) continue;
7800
7800
  const pkgJsonPath = path$1.join(scopeDir, pkg.name, "package.json");
7801
- if (!fs.existsSync(pkgJsonPath)) continue;
7801
+ if (!fs$1.existsSync(pkgJsonPath)) continue;
7802
7802
  let pkgJson;
7803
7803
  try {
7804
- const parsed = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"));
7804
+ const parsed = JSON.parse(fs$1.readFileSync(pkgJsonPath, "utf-8"));
7805
7805
  if (typeof parsed !== "object" || parsed == null) continue;
7806
7806
  pkgJson = parsed;
7807
7807
  } catch {
@@ -7872,28 +7872,28 @@ var AddonManifest = class {
7872
7872
  migrateFromInstallSourceMarkers(addonsDir) {
7873
7873
  const m = this.read();
7874
7874
  if (Object.keys(m.addons).length > 0) return 0;
7875
- if (!fs.existsSync(addonsDir)) return 0;
7875
+ if (!fs$1.existsSync(addonsDir)) return 0;
7876
7876
  let migrated = 0;
7877
7877
  const now = (/* @__PURE__ */ new Date()).toISOString();
7878
- for (const scope of fs.readdirSync(addonsDir, { withFileTypes: true })) {
7878
+ for (const scope of fs$1.readdirSync(addonsDir, { withFileTypes: true })) {
7879
7879
  if (!scope.isDirectory() || !scope.name.startsWith("@")) continue;
7880
7880
  const scopeDir = path$1.join(addonsDir, scope.name);
7881
- for (const pkg of fs.readdirSync(scopeDir, { withFileTypes: true })) {
7881
+ for (const pkg of fs$1.readdirSync(scopeDir, { withFileTypes: true })) {
7882
7882
  if (!pkg.isDirectory()) continue;
7883
7883
  const pkgDir = path$1.join(scopeDir, pkg.name);
7884
7884
  const markerPath = path$1.join(pkgDir, ".install-source");
7885
7885
  const pkgJsonPath = path$1.join(pkgDir, "package.json");
7886
- if (!fs.existsSync(pkgJsonPath)) continue;
7886
+ if (!fs$1.existsSync(pkgJsonPath)) continue;
7887
7887
  let pkgJson;
7888
7888
  try {
7889
- const parsed = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"));
7889
+ const parsed = JSON.parse(fs$1.readFileSync(pkgJsonPath, "utf-8"));
7890
7890
  if (typeof parsed !== "object" || parsed == null) continue;
7891
7891
  pkgJson = parsed;
7892
7892
  } catch {
7893
7893
  continue;
7894
7894
  }
7895
7895
  if (!pkgJson.name || !pkgJson.version) continue;
7896
- const source = fs.existsSync(markerPath) ? fs.readFileSync(markerPath, "utf-8").trim() : "bundled";
7896
+ const source = fs$1.existsSync(markerPath) ? fs$1.readFileSync(markerPath, "utf-8").trim() : "bundled";
7897
7897
  m.addons[pkgJson.name] = {
7898
7898
  name: pkgJson.name,
7899
7899
  version: pkgJson.version,
@@ -8097,7 +8097,7 @@ function planClosureDedupe(input) {
8097
8097
  function readTreeManifest(pkgJsonPath) {
8098
8098
  let raw;
8099
8099
  try {
8100
- raw = asJsonObject$1(parseJsonUnknown(fs.readFileSync(pkgJsonPath, "utf-8")));
8100
+ raw = asJsonObject$1(parseJsonUnknown(fs$1.readFileSync(pkgJsonPath, "utf-8")));
8101
8101
  } catch {
8102
8102
  return null;
8103
8103
  }
@@ -8122,7 +8122,7 @@ function readTreeManifest(pkgJsonPath) {
8122
8122
  function listTopLevelEntries(nodeModulesDir) {
8123
8123
  let entries;
8124
8124
  try {
8125
- entries = fs.readdirSync(nodeModulesDir, { withFileTypes: true });
8125
+ entries = fs$1.readdirSync(nodeModulesDir, { withFileTypes: true });
8126
8126
  } catch {
8127
8127
  return [];
8128
8128
  }
@@ -8132,7 +8132,7 @@ function listTopLevelEntries(nodeModulesDir) {
8132
8132
  if (entry.name.startsWith("@")) {
8133
8133
  let inner;
8134
8134
  try {
8135
- inner = fs.readdirSync(path$1.join(nodeModulesDir, entry.name), { withFileTypes: true });
8135
+ inner = fs$1.readdirSync(path$1.join(nodeModulesDir, entry.name), { withFileTypes: true });
8136
8136
  } catch {
8137
8137
  continue;
8138
8138
  }
@@ -8165,14 +8165,14 @@ function collectAddonTreeState(addonDir) {
8165
8165
  const entryDir = path$1.join(nodeModulesDir, name);
8166
8166
  let isLink = false;
8167
8167
  try {
8168
- isLink = fs.lstatSync(entryDir).isSymbolicLink();
8168
+ isLink = fs$1.lstatSync(entryDir).isSymbolicLink();
8169
8169
  } catch {
8170
8170
  continue;
8171
8171
  }
8172
8172
  if (isLink) {
8173
8173
  let target = "";
8174
8174
  try {
8175
- target = fs.readlinkSync(entryDir);
8175
+ target = fs$1.readlinkSync(entryDir);
8176
8176
  } catch {}
8177
8177
  existingLinks.push({
8178
8178
  name,
@@ -8186,7 +8186,7 @@ function collectAddonTreeState(addonDir) {
8186
8186
  version: manifest.version
8187
8187
  });
8188
8188
  for (const [depName, range] of manifest.ranges) {
8189
- if (fs.existsSync(path$1.join(entryDir, "node_modules", depName))) continue;
8189
+ if (fs$1.existsSync(path$1.join(entryDir, "node_modules", depName))) continue;
8190
8190
  addRange(depName, range);
8191
8191
  }
8192
8192
  }
@@ -8216,7 +8216,7 @@ function resolveClosureNodeModulesDir(explicitDir) {
8216
8216
  const frameworkDir = explicitDir ?? process.env["CAMSTACK_FRAMEWORK_DIR"];
8217
8217
  if (frameworkDir === void 0 || frameworkDir.length === 0) return null;
8218
8218
  const nodeModulesDir = explicitDir ?? path$1.join(frameworkDir, "node_modules");
8219
- return fs.existsSync(nodeModulesDir) ? nodeModulesDir : null;
8219
+ return fs$1.existsSync(nodeModulesDir) ? nodeModulesDir : null;
8220
8220
  }
8221
8221
  function symlinkType() {
8222
8222
  return process.platform === "win32" ? "junction" : "dir";
@@ -8235,10 +8235,10 @@ function executeClosureDedupe(addonDir, closureNodeModulesDir, plan, logger) {
8235
8235
  const nodeModulesDir = path$1.join(addonDir, "node_modules");
8236
8236
  const probePath = path$1.join(nodeModulesDir, ".closure-link-probe");
8237
8237
  try {
8238
- fs.mkdirSync(nodeModulesDir, { recursive: true });
8239
- fs.rmSync(probePath, { force: true });
8240
- fs.symlinkSync(closureNodeModulesDir, probePath, symlinkType());
8241
- fs.rmSync(probePath, { force: true });
8238
+ fs$1.mkdirSync(nodeModulesDir, { recursive: true });
8239
+ fs$1.rmSync(probePath, { force: true });
8240
+ fs$1.symlinkSync(closureNodeModulesDir, probePath, symlinkType());
8241
+ fs$1.rmSync(probePath, { force: true });
8242
8242
  } catch (err) {
8243
8243
  logger.warn("closure dedupe skipped — symlinks unavailable on this volume", { meta: {
8244
8244
  addonDir,
@@ -8260,12 +8260,12 @@ function executeClosureDedupe(addonDir, closureNodeModulesDir, plan, logger) {
8260
8260
  }
8261
8261
  const entryDir = path$1.join(nodeModulesDir, link.name);
8262
8262
  try {
8263
- fs.rmSync(entryDir, {
8263
+ fs$1.rmSync(entryDir, {
8264
8264
  recursive: true,
8265
8265
  force: true
8266
8266
  });
8267
- fs.mkdirSync(path$1.dirname(entryDir), { recursive: true });
8268
- fs.symlinkSync(target, entryDir, symlinkType());
8267
+ fs$1.mkdirSync(path$1.dirname(entryDir), { recursive: true });
8268
+ fs$1.symlinkSync(target, entryDir, symlinkType());
8269
8269
  linked.push(link.name);
8270
8270
  } catch (err) {
8271
8271
  logger.warn("closure dedupe — link failed; entry removed copy may need reinstall", { meta: {
@@ -8341,7 +8341,7 @@ async function installManifestNativeDeps(addonDir, pkgRaw, logger, registry, npm
8341
8341
  count: Object.keys(native).length
8342
8342
  } });
8343
8343
  try {
8344
- fs.writeFileSync(markerFile, markerHash);
8344
+ fs$1.writeFileSync(markerFile, markerHash);
8345
8345
  } catch (err) {
8346
8346
  logger.warn("Failed to write native deps marker", { meta: {
8347
8347
  markerFile,
@@ -8379,7 +8379,7 @@ async function installManifestNativeDeps(addonDir, pkgRaw, logger, registry, npm
8379
8379
  }
8380
8380
  await rebuildNativeDeps(addonDir, pending.map(([name]) => name), logger, npmCacheDir ?? defaultNpmCacheDir(), registry);
8381
8381
  try {
8382
- fs.writeFileSync(markerFile, markerHash);
8382
+ fs$1.writeFileSync(markerFile, markerHash);
8383
8383
  } catch (err) {
8384
8384
  logger.warn("Failed to write native deps marker", { meta: {
8385
8385
  markerFile,
@@ -8401,12 +8401,12 @@ function copyPrebuiltNativeDep(name, addonDir, logger) {
8401
8401
  if (source === target) continue;
8402
8402
  if (!hasBuiltBinary(source)) continue;
8403
8403
  try {
8404
- fs.rmSync(target, {
8404
+ fs$1.rmSync(target, {
8405
8405
  recursive: true,
8406
8406
  force: true
8407
8407
  });
8408
- fs.mkdirSync(path$1.dirname(target), { recursive: true });
8409
- fs.cpSync(source, target, {
8408
+ fs$1.mkdirSync(path$1.dirname(target), { recursive: true });
8409
+ fs$1.cpSync(source, target, {
8410
8410
  recursive: true,
8411
8411
  dereference: true
8412
8412
  });
@@ -8442,7 +8442,7 @@ var BUNDLED_NATIVE_SIBLING_SCOPES = {
8442
8442
  function hasAnyDotNode(dir, maxDepth) {
8443
8443
  let entries;
8444
8444
  try {
8445
- entries = fs.readdirSync(dir, { withFileTypes: true });
8445
+ entries = fs$1.readdirSync(dir, { withFileTypes: true });
8446
8446
  } catch {
8447
8447
  return false;
8448
8448
  }
@@ -8456,12 +8456,12 @@ function copyPrebuiltModuleDir(src, dst, label, logger) {
8456
8456
  if (!hasAnyDotNode(src, 5)) return;
8457
8457
  if (hasAnyDotNode(dst, 5)) return;
8458
8458
  try {
8459
- fs.rmSync(dst, {
8459
+ fs$1.rmSync(dst, {
8460
8460
  recursive: true,
8461
8461
  force: true
8462
8462
  });
8463
- fs.mkdirSync(path$1.dirname(dst), { recursive: true });
8464
- fs.cpSync(src, dst, {
8463
+ fs$1.mkdirSync(path$1.dirname(dst), { recursive: true });
8464
+ fs$1.cpSync(src, dst, {
8465
8465
  recursive: true,
8466
8466
  dereference: true
8467
8467
  });
@@ -8496,7 +8496,7 @@ function copyPrebuiltModuleDir(src, dst, label, logger) {
8496
8496
  */
8497
8497
  function copyBundledNativeModules(sourceDir, targetDir, logger) {
8498
8498
  const srcNm = path$1.join(sourceDir, "node_modules");
8499
- if (!fs.existsSync(srcNm)) return;
8499
+ if (!fs$1.existsSync(srcNm)) return;
8500
8500
  const dstNm = path$1.join(targetDir, "node_modules");
8501
8501
  for (const [name, scopes] of Object.entries(BUNDLED_NATIVE_SIBLING_SCOPES)) {
8502
8502
  copyPrebuiltModuleDir(path$1.join(srcNm, name), path$1.join(dstNm, name), name, logger);
@@ -8504,7 +8504,7 @@ function copyBundledNativeModules(sourceDir, targetDir, logger) {
8504
8504
  const scopeSrc = path$1.join(srcNm, scope);
8505
8505
  let siblings;
8506
8506
  try {
8507
- siblings = fs.readdirSync(scopeSrc);
8507
+ siblings = fs$1.readdirSync(scopeSrc);
8508
8508
  } catch {
8509
8509
  continue;
8510
8510
  }
@@ -8514,12 +8514,12 @@ function copyBundledNativeModules(sourceDir, targetDir, logger) {
8514
8514
  }
8515
8515
  /** A package dir is "built" when it carries a compiled `.node` or a prebuilds tree. */
8516
8516
  function hasBuiltBinary(pkgDir) {
8517
- if (!fs.existsSync(path$1.join(pkgDir, "package.json"))) return false;
8517
+ if (!fs$1.existsSync(path$1.join(pkgDir, "package.json"))) return false;
8518
8518
  const releaseDir = path$1.join(pkgDir, "build", "Release");
8519
8519
  try {
8520
- if (fs.existsSync(releaseDir) && fs.readdirSync(releaseDir).some((f) => f.endsWith(".node"))) return true;
8520
+ if (fs$1.existsSync(releaseDir) && fs$1.readdirSync(releaseDir).some((f) => f.endsWith(".node"))) return true;
8521
8521
  } catch {}
8522
- return fs.existsSync(path$1.join(pkgDir, "prebuilds"));
8522
+ return fs$1.existsSync(path$1.join(pkgDir, "prebuilds"));
8523
8523
  }
8524
8524
  /** Candidate hoisted locations for `<name>`: NODE_PATH entries + ancestors of `addonDir`. */
8525
8525
  function candidateHoistedDirs(name, addonDir) {
@@ -8557,7 +8557,7 @@ function hashDeclaration(deps) {
8557
8557
  }
8558
8558
  function markerMatches(markerFile, expected) {
8559
8559
  try {
8560
- return fs.readFileSync(markerFile, "utf-8").trim() === expected;
8560
+ return fs$1.readFileSync(markerFile, "utf-8").trim() === expected;
8561
8561
  } catch {
8562
8562
  return false;
8563
8563
  }
@@ -8768,7 +8768,7 @@ function parseInstallSource(value) {
8768
8768
  function readPackageJson(pkgJsonPath) {
8769
8769
  let raw;
8770
8770
  try {
8771
- raw = asJsonObject$1(parseJsonUnknown(fs.readFileSync(pkgJsonPath, "utf-8")));
8771
+ raw = asJsonObject$1(parseJsonUnknown(fs$1.readFileSync(pkgJsonPath, "utf-8")));
8772
8772
  } catch {
8773
8773
  return null;
8774
8774
  }
@@ -8812,7 +8812,7 @@ var REGISTRY_LATEST_TIMEOUT_MS = 15e3;
8812
8812
  var FALLBACK_VERSION_PROBES = 25;
8813
8813
  function readInstalledPackageVersion(addonDir) {
8814
8814
  try {
8815
- const raw = JSON.parse(fs.readFileSync(path$1.join(addonDir, "package.json"), "utf-8"));
8815
+ const raw = JSON.parse(fs$1.readFileSync(path$1.join(addonDir, "package.json"), "utf-8"));
8816
8816
  if (raw === null || typeof raw !== "object") return null;
8817
8817
  const version = Reflect.get(raw, "version");
8818
8818
  return typeof version === "string" && version.length > 0 ? version : null;
@@ -8960,7 +8960,7 @@ var AddonInstaller = class AddonInstaller {
8960
8960
  } catch {
8961
8961
  return Object.freeze([]);
8962
8962
  }
8963
- const raw = fs.readFileSync(pkgPath, "utf-8");
8963
+ const raw = fs$1.readFileSync(pkgPath, "utf-8");
8964
8964
  const parsed = JSON.parse(raw);
8965
8965
  const deps = Object.keys(parsed.dependencies ?? {});
8966
8966
  const agentOnly = new Set(parsed.camstack?.agentOnlyBootstrapAddons ?? []);
@@ -9005,7 +9005,7 @@ var AddonInstaller = class AddonInstaller {
9005
9005
  } catch {
9006
9006
  return Object.freeze([]);
9007
9007
  }
9008
- const raw = fs.readFileSync(pkgPath, "utf-8");
9008
+ const raw = fs$1.readFileSync(pkgPath, "utf-8");
9009
9009
  const addons = JSON.parse(raw).camstack?.agentBootstrapAddons ?? [];
9010
9010
  return Object.freeze(["@camstack/server", ...addons]);
9011
9011
  }
@@ -9035,7 +9035,7 @@ var AddonInstaller = class AddonInstaller {
9035
9035
  this.logger.info(`Install source: ${isLocal ? `bundle (${this.bundledAddonsDir})` : "npm"}, ${pkgList.length} package(s)`);
9036
9036
  for (const packageName of pkgList) {
9037
9037
  const addonDir = path$1.join(this.addonsDir, packageName);
9038
- if (fs.existsSync(path$1.join(addonDir, "package.json"))) {
9038
+ if (fs$1.existsSync(path$1.join(addonDir, "package.json"))) {
9039
9039
  if (isLocal || shouldSkipClosureProvidedSeed(packageName, this.isResolvableFromClosure(packageName))) {
9040
9040
  this.logger.debug(`${packageName} — already installed, skipping`);
9041
9041
  continue;
@@ -9286,7 +9286,7 @@ var AddonInstaller = class AddonInstaller {
9286
9286
  const installedPackages = this.listInstalled();
9287
9287
  for (const pkg of installedPackages) {
9288
9288
  try {
9289
- if (fs.lstatSync(pkg.dir).isSymbolicLink()) continue;
9289
+ if (fs$1.lstatSync(pkg.dir).isSymbolicLink()) continue;
9290
9290
  } catch {
9291
9291
  continue;
9292
9292
  }
@@ -9326,7 +9326,7 @@ var AddonInstaller = class AddonInstaller {
9326
9326
  if (closureNodeModules !== null) for (const link of state.existingLinks) {
9327
9327
  if (!isClosureLinkTarget(link.target, closureNodeModules)) continue;
9328
9328
  const linkDir = path$1.join(nodeModulesDir, link.name);
9329
- const targetManifest = fs.existsSync(path$1.join(linkDir, "package.json"));
9329
+ const targetManifest = fs$1.existsSync(path$1.join(linkDir, "package.json"));
9330
9330
  const ranges = state.requirements.get(link.name) ?? [];
9331
9331
  let holds = targetManifest;
9332
9332
  if (holds && ranges.length > 0) {
@@ -9335,14 +9335,14 @@ var AddonInstaller = class AddonInstaller {
9335
9335
  }
9336
9336
  if (!holds) {
9337
9337
  this.logger.warn(`${packageName} — closure link for ${link.name} no longer holds; reinstalling this addon's deps`, { meta: { target: link.target } });
9338
- fs.rmSync(linkDir, { force: true });
9338
+ fs$1.rmSync(linkDir, { force: true });
9339
9339
  needsInstall = true;
9340
9340
  }
9341
9341
  }
9342
9342
  const linked = [];
9343
9343
  for (const [depName, range] of declaredEntries) {
9344
9344
  if (typeof range !== "string") continue;
9345
- if (fs.existsSync(path$1.join(nodeModulesDir, depName, "package.json"))) continue;
9345
+ if (fs$1.existsSync(path$1.join(nodeModulesDir, depName, "package.json"))) continue;
9346
9346
  const closureVersion = closureNodeModules === null ? void 0 : readClosureVersions(closureNodeModules, [depName]).get(depName);
9347
9347
  if (closureNodeModules !== null && closureVersion !== void 0 && closureSatisfiesRange(range, closureVersion)) {
9348
9348
  if (executeClosureDedupe(addonDir, closureNodeModules, {
@@ -9375,7 +9375,7 @@ var AddonInstaller = class AddonInstaller {
9375
9375
  const closureNodeModules = resolveClosureNodeModulesDir(this.closureNodeModulesDir);
9376
9376
  if (closureNodeModules !== null) {
9377
9377
  const state = collectAddonTreeState(addonDir);
9378
- for (const link of state.existingLinks) if (isClosureLinkTarget(link.target, closureNodeModules)) fs.rmSync(path$1.join(addonDir, "node_modules", link.name), { force: true });
9378
+ for (const link of state.existingLinks) if (isClosureLinkTarget(link.target, closureNodeModules)) fs$1.rmSync(path$1.join(addonDir, "node_modules", link.name), { force: true });
9379
9379
  }
9380
9380
  this.logger.info(`${packageName} — reinstalling runtime dependencies`, { meta: { addonDir } });
9381
9381
  await runNpm([
@@ -9420,7 +9420,7 @@ var AddonInstaller = class AddonInstaller {
9420
9420
  async realignFromClosure(packageName, closureDir) {
9421
9421
  const targetDir = path$1.join(this.addonsDir, packageName);
9422
9422
  const result = await this.installLocal(packageName, closureDir);
9423
- await fs.promises.writeFile(path$1.join(targetDir, ".install-source"), "closure");
9423
+ await fs$1.promises.writeFile(path$1.join(targetDir, ".install-source"), "closure");
9424
9424
  this.manifest.upsert(result.name, {
9425
9425
  version: result.version,
9426
9426
  source: "closure"
@@ -9436,17 +9436,17 @@ var AddonInstaller = class AddonInstaller {
9436
9436
  async installCopy(packageName, sourceDir, pkgData, targetDir) {
9437
9437
  await this.ensureBuilt(packageName, sourceDir, pkgData);
9438
9438
  const distDir = path$1.join(sourceDir, "dist");
9439
- if (!fs.existsSync(distDir)) throw new Error(`${packageName} has no dist/ after build`);
9440
- await fs.promises.rm(targetDir, {
9439
+ if (!fs$1.existsSync(distDir)) throw new Error(`${packageName} has no dist/ after build`);
9440
+ await fs$1.promises.rm(targetDir, {
9441
9441
  recursive: true,
9442
9442
  force: true
9443
9443
  });
9444
9444
  ensureDir(targetDir);
9445
- await fs.promises.writeFile(path$1.join(targetDir, "package.json"), JSON.stringify(stripBundledDeps(pkgData), null, 2));
9445
+ await fs$1.promises.writeFile(path$1.join(targetDir, "package.json"), JSON.stringify(stripBundledDeps(pkgData), null, 2));
9446
9446
  await copyDirRecursive(distDir, path$1.join(targetDir, "dist"));
9447
9447
  await copyExtraFileDirs(pkgData, sourceDir, targetDir);
9448
9448
  copyBundledNativeModules(sourceDir, targetDir, this.logger);
9449
- await fs.promises.writeFile(path$1.join(targetDir, ".install-source"), "local");
9449
+ await fs$1.promises.writeFile(path$1.join(targetDir, ".install-source"), "local");
9450
9450
  const localPkgVersion = asString$1(pkgData.version, "0.0.0");
9451
9451
  this.manifest.upsert(packageName, {
9452
9452
  version: localPkgVersion,
@@ -9487,7 +9487,7 @@ var AddonInstaller = class AddonInstaller {
9487
9487
  * unusual auth, offline mode, etc).
9488
9488
  */
9489
9489
  async installFromNpm(packageName, version) {
9490
- const tmpDir = fs.mkdtempSync(path$1.join(os$1.tmpdir(), "camstack-addon-npm-"));
9490
+ const tmpDir = fs$1.mkdtempSync(path$1.join(os$1.tmpdir(), "camstack-addon-npm-"));
9491
9491
  const packageSpec = version ? `${packageName}@${version}` : packageName;
9492
9492
  this.logger.info(`${packageName} — installing from npm`);
9493
9493
  try {
@@ -9501,19 +9501,19 @@ var AddonInstaller = class AddonInstaller {
9501
9501
  ];
9502
9502
  if (this.registry) args.push("--registry", this.registry);
9503
9503
  const { stdout } = await runNpm(args, this.npmRunOptions(tmpDir, 12e4));
9504
- const tgzFiles = fs.readdirSync(tmpDir).filter((f) => f.endsWith(".tgz"));
9504
+ const tgzFiles = fs$1.readdirSync(tmpDir).filter((f) => f.endsWith(".tgz"));
9505
9505
  if (tgzFiles.length === 0) throw new Error(`npm pack produced no tgz. stdout: ${stdout.trim()}`);
9506
9506
  return path$1.join(tmpDir, tgzFiles[0]);
9507
9507
  });
9508
9508
  const result = await this.installFromTgz(tgzPath);
9509
- fs.writeFileSync(path$1.join(this.addonsDir, result.name, ".install-source"), "npm");
9509
+ fs$1.writeFileSync(path$1.join(this.addonsDir, result.name, ".install-source"), "npm");
9510
9510
  this.manifest.upsert(result.name, {
9511
9511
  version: result.version,
9512
9512
  source: "npm"
9513
9513
  });
9514
9514
  return result;
9515
9515
  } finally {
9516
- fs.rmSync(tmpDir, {
9516
+ fs$1.rmSync(tmpDir, {
9517
9517
  recursive: true,
9518
9518
  force: true
9519
9519
  });
@@ -9551,7 +9551,7 @@ var AddonInstaller = class AddonInstaller {
9551
9551
  if (!tarRes.ok) throw new Error(`tarball GET ${tarballUrl} → ${tarRes.status}`);
9552
9552
  const tgzPath = path$1.join(tmpDir, `${packageName.replace(/[/@]/g, "-").replace(/^-+/, "")}-${resolvedVersion}.tgz`);
9553
9553
  const buf = Buffer.from(await tarRes.arrayBuffer());
9554
- fs.writeFileSync(tgzPath, buf);
9554
+ fs$1.writeFileSync(tgzPath, buf);
9555
9555
  return tgzPath;
9556
9556
  }
9557
9557
  /**
@@ -9572,7 +9572,7 @@ var AddonInstaller = class AddonInstaller {
9572
9572
  * on the next deploy.
9573
9573
  */
9574
9574
  async evictInstallDir(targetDir) {
9575
- if (!fs.existsSync(targetDir)) return;
9575
+ if (!fs$1.existsSync(targetDir)) return;
9576
9576
  const graveyard = path$1.join(this.addonsDir, ".evicting");
9577
9577
  ensureDir(graveyard);
9578
9578
  await this.sweepGraveyard(graveyard);
@@ -9580,10 +9580,10 @@ var AddonInstaller = class AddonInstaller {
9580
9580
  const flatName = path$1.relative(this.addonsDir, targetDir).replace(/[/\\]/g, "-");
9581
9581
  const asideDir = path$1.join(graveyard, `${flatName}-${ts}`);
9582
9582
  try {
9583
- fs.renameSync(targetDir, asideDir);
9583
+ fs$1.renameSync(targetDir, asideDir);
9584
9584
  } catch (renameErr) {
9585
9585
  if (renameErr.code === "EXDEV") {
9586
- await fs.promises.rm(targetDir, {
9586
+ await fs$1.promises.rm(targetDir, {
9587
9587
  recursive: true,
9588
9588
  force: true
9589
9589
  });
@@ -9591,7 +9591,7 @@ var AddonInstaller = class AddonInstaller {
9591
9591
  }
9592
9592
  throw renameErr;
9593
9593
  }
9594
- await fs.promises.rm(asideDir, {
9594
+ await fs$1.promises.rm(asideDir, {
9595
9595
  recursive: true,
9596
9596
  force: true
9597
9597
  }).catch((cleanupErr) => {
@@ -9612,14 +9612,14 @@ var AddonInstaller = class AddonInstaller {
9612
9612
  async sweepStagingResidue(stagingRoot) {
9613
9613
  let names;
9614
9614
  try {
9615
- names = fs.readdirSync(stagingRoot);
9615
+ names = fs$1.readdirSync(stagingRoot);
9616
9616
  } catch {
9617
9617
  return;
9618
9618
  }
9619
9619
  const now = Date.now();
9620
9620
  const ages = [];
9621
9621
  for (const name of names) try {
9622
- const stat = fs.statSync(path$1.join(stagingRoot, name));
9622
+ const stat = fs$1.statSync(path$1.join(stagingRoot, name));
9623
9623
  ages.push({
9624
9624
  name,
9625
9625
  ageMs: now - stat.mtimeMs
@@ -9630,7 +9630,7 @@ var AddonInstaller = class AddonInstaller {
9630
9630
  stagingRoot,
9631
9631
  entries: sweepable
9632
9632
  } });
9633
- await Promise.all(sweepable.map((name) => fs.promises.rm(path$1.join(stagingRoot, name), {
9633
+ await Promise.all(sweepable.map((name) => fs$1.promises.rm(path$1.join(stagingRoot, name), {
9634
9634
  recursive: true,
9635
9635
  force: true
9636
9636
  }).catch(() => void 0)));
@@ -9639,11 +9639,11 @@ var AddonInstaller = class AddonInstaller {
9639
9639
  async sweepGraveyard(graveyard) {
9640
9640
  let entries;
9641
9641
  try {
9642
- entries = fs.readdirSync(graveyard);
9642
+ entries = fs$1.readdirSync(graveyard);
9643
9643
  } catch {
9644
9644
  return;
9645
9645
  }
9646
- await Promise.all(entries.map((name) => fs.promises.rm(path$1.join(graveyard, name), {
9646
+ await Promise.all(entries.map((name) => fs$1.promises.rm(path$1.join(graveyard, name), {
9647
9647
  recursive: true,
9648
9648
  force: true
9649
9649
  }).catch(() => void 0)));
@@ -9694,7 +9694,7 @@ var AddonInstaller = class AddonInstaller {
9694
9694
  return;
9695
9695
  }
9696
9696
  const strippedManifest = stripBundledDeps(pkgView.raw);
9697
- await fs.promises.writeFile(pkgJsonPath, JSON.stringify(strippedManifest, null, 2));
9697
+ await fs$1.promises.writeFile(pkgJsonPath, JSON.stringify(strippedManifest, null, 2));
9698
9698
  const deps = asJsonObject$1(strippedManifest["dependencies"]);
9699
9699
  const depNames = deps ? Object.keys(deps) : [];
9700
9700
  if (depNames.length === 0) return;
@@ -9826,9 +9826,9 @@ var AddonInstaller = class AddonInstaller {
9826
9826
  "-C",
9827
9827
  stagingDir
9828
9828
  ], { timeout: 12e4 });
9829
- const pkgDir = fs.existsSync(path$1.join(stagingDir, "package", "package.json")) ? path$1.join(stagingDir, "package") : stagingDir;
9829
+ const pkgDir = fs$1.existsSync(path$1.join(stagingDir, "package", "package.json")) ? path$1.join(stagingDir, "package") : stagingDir;
9830
9830
  const pkgJsonPath = path$1.join(pkgDir, "package.json");
9831
- if (!fs.existsSync(pkgJsonPath)) throw new Error("No package.json found in tgz archive");
9831
+ if (!fs$1.existsSync(pkgJsonPath)) throw new Error("No package.json found in tgz archive");
9832
9832
  const pkgView = readPackageJson(pkgJsonPath);
9833
9833
  if (!pkgView) throw new Error(`Invalid package.json at ${pkgJsonPath}`);
9834
9834
  if (!pkgView.camstackAddons) throw new Error(`Package ${pkgView.name} has no camstack.addons manifest`);
@@ -9838,7 +9838,7 @@ var AddonInstaller = class AddonInstaller {
9838
9838
  this.dedupeTreeAgainstClosure(pkgDir, pkgView.name);
9839
9839
  await this.evictInstallDir(targetDir);
9840
9840
  ensureDir(path$1.dirname(targetDir));
9841
- await fs.promises.rename(pkgDir, targetDir);
9841
+ await fs$1.promises.rename(pkgDir, targetDir);
9842
9842
  this.manifest.upsert(pkgView.name, {
9843
9843
  version: pkgView.version,
9844
9844
  source: "bundled"
@@ -9849,7 +9849,7 @@ var AddonInstaller = class AddonInstaller {
9849
9849
  };
9850
9850
  } finally {
9851
9851
  this.inFlightStaging.delete(stagingName);
9852
- await fs.promises.rm(stagingDir, {
9852
+ await fs$1.promises.rm(stagingDir, {
9853
9853
  recursive: true,
9854
9854
  force: true
9855
9855
  }).catch(() => void 0);
@@ -9879,24 +9879,24 @@ var AddonInstaller = class AddonInstaller {
9879
9879
  const current = this.manifest.get(packageName);
9880
9880
  if (current == null) throw new Error(`Cannot update ${packageName}: not currently tracked in manifest`);
9881
9881
  const addonDir = path$1.join(this.addonsDir, packageName);
9882
- if (!fs.existsSync(addonDir)) throw new Error(`Cannot update ${packageName}: install dir ${addonDir} missing`);
9882
+ if (!fs$1.existsSync(addonDir)) throw new Error(`Cannot update ${packageName}: install dir ${addonDir} missing`);
9883
9883
  const ts = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
9884
9884
  const backupRoot = path$1.join(this.addonsDir, ".backups", packageName);
9885
9885
  ensureDir(backupRoot);
9886
9886
  const backupDir = path$1.join(backupRoot, ts);
9887
9887
  this.logger.info(`${packageName} — backing up v${current.version} → ${backupDir}`);
9888
- fs.renameSync(addonDir, backupDir);
9888
+ fs$1.renameSync(addonDir, backupDir);
9889
9889
  let result;
9890
9890
  try {
9891
9891
  result = await this.installFromNpm(packageName, version);
9892
9892
  } catch (installErr) {
9893
9893
  this.logger.error(`${packageName} — install failed, restoring backup`, { meta: { error: errMsg$1(installErr) } });
9894
9894
  try {
9895
- if (fs.existsSync(addonDir)) fs.rmSync(addonDir, {
9895
+ if (fs$1.existsSync(addonDir)) fs$1.rmSync(addonDir, {
9896
9896
  recursive: true,
9897
9897
  force: true
9898
9898
  });
9899
- fs.renameSync(backupDir, addonDir);
9899
+ fs$1.renameSync(backupDir, addonDir);
9900
9900
  this.manifest.upsert(packageName, {
9901
9901
  version: current.version,
9902
9902
  source: current.source,
@@ -9957,7 +9957,7 @@ var AddonInstaller = class AddonInstaller {
9957
9957
  const current = this.manifest.get(packageName);
9958
9958
  if (current == null) throw new Error(`Cannot update ${packageName}: not currently tracked in manifest`);
9959
9959
  const addonDir = path$1.join(this.addonsDir, packageName);
9960
- if (!fs.existsSync(addonDir)) throw new Error(`Cannot update ${packageName}: install dir ${addonDir} missing`);
9960
+ if (!fs$1.existsSync(addonDir)) throw new Error(`Cannot update ${packageName}: install dir ${addonDir} missing`);
9961
9961
  await this.installRuntimeDependencies(stagedPath, packageName);
9962
9962
  await this.installNativeDependencies(stagedPath, packageName);
9963
9963
  this.dedupeTreeAgainstClosure(stagedPath, packageName);
@@ -9966,14 +9966,14 @@ var AddonInstaller = class AddonInstaller {
9966
9966
  ensureDir(backupRoot);
9967
9967
  const backupDir = path$1.join(backupRoot, ts);
9968
9968
  this.logger.info(`${packageName} — backing up v${current.version} → ${backupDir}`);
9969
- fs.renameSync(addonDir, backupDir);
9969
+ fs$1.renameSync(addonDir, backupDir);
9970
9970
  try {
9971
9971
  try {
9972
- fs.renameSync(stagedPath, addonDir);
9972
+ fs$1.renameSync(stagedPath, addonDir);
9973
9973
  } catch (renameErr) {
9974
9974
  if (renameErr.code === "EXDEV") {
9975
- fs.cpSync(stagedPath, addonDir, { recursive: true });
9976
- fs.rmSync(stagedPath, {
9975
+ fs$1.cpSync(stagedPath, addonDir, { recursive: true });
9976
+ fs$1.rmSync(stagedPath, {
9977
9977
  recursive: true,
9978
9978
  force: true
9979
9979
  });
@@ -9982,11 +9982,11 @@ var AddonInstaller = class AddonInstaller {
9982
9982
  } catch (swapErr) {
9983
9983
  this.logger.error(`${packageName} — staged swap failed, restoring backup`, { meta: { error: errMsg$1(swapErr) } });
9984
9984
  try {
9985
- if (fs.existsSync(addonDir)) fs.rmSync(addonDir, {
9985
+ if (fs$1.existsSync(addonDir)) fs$1.rmSync(addonDir, {
9986
9986
  recursive: true,
9987
9987
  force: true
9988
9988
  });
9989
- fs.renameSync(backupDir, addonDir);
9989
+ fs$1.renameSync(backupDir, addonDir);
9990
9990
  this.manifest.upsert(packageName, {
9991
9991
  version: current.version,
9992
9992
  source: current.source,
@@ -10025,20 +10025,20 @@ var AddonInstaller = class AddonInstaller {
10025
10025
  this.logger.warn(`${packageName} — no backup to rollback to`);
10026
10026
  return null;
10027
10027
  }
10028
- if (!fs.existsSync(entry.lastBackupDir)) {
10028
+ if (!fs$1.existsSync(entry.lastBackupDir)) {
10029
10029
  this.logger.warn(`${packageName} — backup dir vanished: ${entry.lastBackupDir}`);
10030
10030
  return null;
10031
10031
  }
10032
10032
  const addonDir = path$1.join(this.addonsDir, packageName);
10033
- if (fs.existsSync(addonDir)) fs.rmSync(addonDir, {
10033
+ if (fs$1.existsSync(addonDir)) fs$1.rmSync(addonDir, {
10034
10034
  recursive: true,
10035
10035
  force: true
10036
10036
  });
10037
- fs.renameSync(entry.lastBackupDir, addonDir);
10037
+ fs$1.renameSync(entry.lastBackupDir, addonDir);
10038
10038
  const pkgJsonPath = path$1.join(addonDir, "package.json");
10039
10039
  let restoredVersion = entry.version;
10040
- if (fs.existsSync(pkgJsonPath)) try {
10041
- const parsed = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"));
10040
+ if (fs$1.existsSync(pkgJsonPath)) try {
10041
+ const parsed = JSON.parse(fs$1.readFileSync(pkgJsonPath, "utf-8"));
10042
10042
  if (typeof parsed === "object" && parsed != null) {
10043
10043
  const v = parsed.version;
10044
10044
  if (typeof v === "string" && v.length > 0) restoredVersion = v;
@@ -10086,7 +10086,7 @@ var AddonInstaller = class AddonInstaller {
10086
10086
  return false;
10087
10087
  }
10088
10088
  try {
10089
- await fs.promises.rm(target, {
10089
+ await fs$1.promises.rm(target, {
10090
10090
  recursive: true,
10091
10091
  force: true
10092
10092
  });
@@ -10104,7 +10104,7 @@ var AddonInstaller = class AddonInstaller {
10104
10104
  listBackupsFor(packageName) {
10105
10105
  const dir = path$1.join(this.backupsRoot, packageName);
10106
10106
  try {
10107
- return fs.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => path$1.join(dir, e.name)).sort();
10107
+ return fs$1.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => path$1.join(dir, e.name)).sort();
10108
10108
  } catch {
10109
10109
  return [];
10110
10110
  }
@@ -10136,7 +10136,7 @@ var AddonInstaller = class AddonInstaller {
10136
10136
  for (const dir of [pkgDir, path$1.dirname(pkgDir)]) {
10137
10137
  if (!this.isInsideBackups(dir)) continue;
10138
10138
  try {
10139
- await fs.promises.rmdir(dir);
10139
+ await fs$1.promises.rmdir(dir);
10140
10140
  } catch {
10141
10141
  return;
10142
10142
  }
@@ -10218,7 +10218,7 @@ var AddonInstaller = class AddonInstaller {
10218
10218
  */
10219
10219
  resolveBackupToKeep(packageName, backups) {
10220
10220
  const liveDir = path$1.join(this.addonsDir, packageName);
10221
- if (!fs.existsSync(liveDir)) {
10221
+ if (!fs$1.existsSync(liveDir)) {
10222
10222
  const newest = backups[backups.length - 1] ?? null;
10223
10223
  if (newest != null) this.logger.warn(`${packageName} — live install dir missing; retaining its newest backup as the only surviving copy`, { meta: {
10224
10224
  liveDir,
@@ -10235,7 +10235,7 @@ var AddonInstaller = class AddonInstaller {
10235
10235
  listBackedUpPackages() {
10236
10236
  let entries;
10237
10237
  try {
10238
- entries = fs.readdirSync(this.backupsRoot, { withFileTypes: true });
10238
+ entries = fs$1.readdirSync(this.backupsRoot, { withFileTypes: true });
10239
10239
  } catch {
10240
10240
  return [];
10241
10241
  }
@@ -10247,14 +10247,14 @@ var AddonInstaller = class AddonInstaller {
10247
10247
  continue;
10248
10248
  }
10249
10249
  const scopeDir = path$1.join(this.backupsRoot, entry.name);
10250
- for (const inner of fs.readdirSync(scopeDir, { withFileTypes: true })) if (inner.isDirectory()) names.push(`${entry.name}/${inner.name}`);
10250
+ for (const inner of fs$1.readdirSync(scopeDir, { withFileTypes: true })) if (inner.isDirectory()) names.push(`${entry.name}/${inner.name}`);
10251
10251
  }
10252
10252
  return names;
10253
10253
  }
10254
10254
  async uninstall(packageName) {
10255
10255
  const addonDir = path$1.join(this.addonsDir, packageName);
10256
- if (fs.existsSync(addonDir)) {
10257
- fs.rmSync(addonDir, {
10256
+ if (fs$1.existsSync(addonDir)) {
10257
+ fs$1.rmSync(addonDir, {
10258
10258
  recursive: true,
10259
10259
  force: true
10260
10260
  });
@@ -10262,8 +10262,8 @@ var AddonInstaller = class AddonInstaller {
10262
10262
  return;
10263
10263
  }
10264
10264
  const legacyDir = path$1.join(this.addonsDir, packageName.replace(/^@[^/]+\//, ""));
10265
- if (fs.existsSync(legacyDir)) {
10266
- fs.rmSync(legacyDir, {
10265
+ if (fs$1.existsSync(legacyDir)) {
10266
+ fs$1.rmSync(legacyDir, {
10267
10267
  recursive: true,
10268
10268
  force: true
10269
10269
  });
@@ -10271,22 +10271,22 @@ var AddonInstaller = class AddonInstaller {
10271
10271
  }
10272
10272
  }
10273
10273
  listInstalled() {
10274
- if (!fs.existsSync(this.addonsDir)) return [];
10274
+ if (!fs$1.existsSync(this.addonsDir)) return [];
10275
10275
  const packageDirs = [];
10276
- for (const entry of fs.readdirSync(this.addonsDir, { withFileTypes: true })) {
10276
+ for (const entry of fs$1.readdirSync(this.addonsDir, { withFileTypes: true })) {
10277
10277
  if (!isDirEntry(entry, this.addonsDir)) continue;
10278
10278
  if (entry.name.startsWith("@")) {
10279
10279
  const scopeDir = path$1.join(this.addonsDir, entry.name);
10280
- for (const inner of fs.readdirSync(scopeDir, { withFileTypes: true })) if (isDirEntry(inner, scopeDir)) packageDirs.push(path$1.join(scopeDir, inner.name));
10280
+ for (const inner of fs$1.readdirSync(scopeDir, { withFileTypes: true })) if (isDirEntry(inner, scopeDir)) packageDirs.push(path$1.join(scopeDir, inner.name));
10281
10281
  } else packageDirs.push(path$1.join(this.addonsDir, entry.name));
10282
10282
  }
10283
10283
  return packageDirs.map((dir) => {
10284
10284
  const pkgPath = path$1.join(dir, "package.json");
10285
- if (!fs.existsSync(pkgPath)) return null;
10285
+ if (!fs$1.existsSync(pkgPath)) return null;
10286
10286
  const pkg = readPackageJson(pkgPath);
10287
10287
  if (!pkg || !pkg.camstackAddons) return null;
10288
10288
  const sourceFile = path$1.join(dir, ".install-source");
10289
- const installSource = fs.existsSync(sourceFile) ? parseInstallSource(fs.readFileSync(sourceFile, "utf-8").trim()) : void 0;
10289
+ const installSource = fs$1.existsSync(sourceFile) ? parseInstallSource(fs$1.readFileSync(sourceFile, "utf-8").trim()) : void 0;
10290
10290
  return {
10291
10291
  name: pkg.name,
10292
10292
  version: pkg.version,
@@ -10296,13 +10296,13 @@ var AddonInstaller = class AddonInstaller {
10296
10296
  }).filter((item) => item !== null);
10297
10297
  }
10298
10298
  isInstalled(packageName) {
10299
- if (fs.existsSync(path$1.join(this.addonsDir, packageName, "package.json"))) return true;
10300
- return fs.existsSync(path$1.join(this.addonsDir, packageName.replace(/^@[^/]+\//, ""), "package.json"));
10299
+ if (fs$1.existsSync(path$1.join(this.addonsDir, packageName, "package.json"))) return true;
10300
+ return fs$1.existsSync(path$1.join(this.addonsDir, packageName.replace(/^@[^/]+\//, ""), "package.json"));
10301
10301
  }
10302
10302
  getInstalledPackage(packageName) {
10303
10303
  let pkgPath = path$1.join(this.addonsDir, packageName, "package.json");
10304
- if (!fs.existsSync(pkgPath)) pkgPath = path$1.join(this.addonsDir, packageName.replace(/^@[^/]+\//, ""), "package.json");
10305
- if (!fs.existsSync(pkgPath)) return null;
10304
+ if (!fs$1.existsSync(pkgPath)) pkgPath = path$1.join(this.addonsDir, packageName.replace(/^@[^/]+\//, ""), "package.json");
10305
+ if (!fs$1.existsSync(pkgPath)) return null;
10306
10306
  const pkg = readPackageJson(pkgPath);
10307
10307
  if (!pkg) return null;
10308
10308
  return {
@@ -10321,7 +10321,7 @@ var AddonInstaller = class AddonInstaller {
10321
10321
  ]) {
10322
10322
  const candidate = path$1.join(this.bundledAddonsDir, dirName);
10323
10323
  try {
10324
- const pkg = asJsonObject$1(parseJsonUnknown(fs.readFileSync(path$1.join(candidate, "package.json"), "utf-8")));
10324
+ const pkg = asJsonObject$1(parseJsonUnknown(fs$1.readFileSync(path$1.join(candidate, "package.json"), "utf-8")));
10325
10325
  if (pkg && asString$1(pkg["name"]) === packageName) return candidate;
10326
10326
  } catch {}
10327
10327
  }
@@ -10330,7 +10330,7 @@ var AddonInstaller = class AddonInstaller {
10330
10330
  /** Ensure a package is built (dist/ exists and page bundles present) */
10331
10331
  async ensureBuilt(packageName, sourceDir, pkgData) {
10332
10332
  const distDir = path$1.join(sourceDir, "dist");
10333
- if (!(!fs.existsSync(distDir) || this.isDistIncomplete(pkgData, sourceDir))) return;
10333
+ if (!(!fs$1.existsSync(distDir) || this.isDistIncomplete(pkgData, sourceDir))) return;
10334
10334
  this.logger.info(`${packageName} — building (dist/ missing or incomplete)`);
10335
10335
  try {
10336
10336
  await runNpm(["run", "build"], this.npmRunOptions(sourceDir, 18e4));
@@ -10345,7 +10345,7 @@ var AddonInstaller = class AddonInstaller {
10345
10345
  if (!camstack?.addons) return false;
10346
10346
  for (const addon of camstack.addons) {
10347
10347
  if (!addon.pages) continue;
10348
- for (const page of addon.pages) if (page.bundle && !fs.existsSync(path$1.join(sourceDir, "dist", page.bundle))) return true;
10348
+ for (const page of addon.pages) if (page.bundle && !fs$1.existsSync(path$1.join(sourceDir, "dist", page.bundle))) return true;
10349
10349
  }
10350
10350
  return false;
10351
10351
  }
@@ -10354,7 +10354,7 @@ var AddonInstaller = class AddonInstaller {
10354
10354
  function isDirEntry(entry, parentDir) {
10355
10355
  if (entry.isDirectory()) return true;
10356
10356
  if (entry.isSymbolicLink()) try {
10357
- return fs.statSync(path$1.join(parentDir, entry.name)).isDirectory();
10357
+ return fs$1.statSync(path$1.join(parentDir, entry.name)).isDirectory();
10358
10358
  } catch {
10359
10359
  return false;
10360
10360
  }
@@ -10453,7 +10453,7 @@ function selectAddonResidue(candidates) {
10453
10453
  }
10454
10454
  function readDeclaredName(dir) {
10455
10455
  try {
10456
- const parsed = JSON.parse(fs.readFileSync(path$1.join(dir, "package.json"), "utf-8"));
10456
+ const parsed = JSON.parse(fs$1.readFileSync(path$1.join(dir, "package.json"), "utf-8"));
10457
10457
  if (typeof parsed !== "object" || parsed === null) return null;
10458
10458
  const name = parsed.name;
10459
10459
  return typeof name === "string" ? name : null;
@@ -10463,7 +10463,7 @@ function readDeclaredName(dir) {
10463
10463
  }
10464
10464
  function readDeclaredVersion(dir) {
10465
10465
  try {
10466
- const parsed = JSON.parse(fs.readFileSync(path$1.join(dir, "package.json"), "utf-8"));
10466
+ const parsed = JSON.parse(fs$1.readFileSync(path$1.join(dir, "package.json"), "utf-8"));
10467
10467
  if (typeof parsed !== "object" || parsed === null) return null;
10468
10468
  const version = parsed.version;
10469
10469
  return typeof version === "string" ? version : null;
@@ -10473,7 +10473,7 @@ function readDeclaredVersion(dir) {
10473
10473
  }
10474
10474
  function isDirLike(p) {
10475
10475
  try {
10476
- return fs.statSync(p).isDirectory();
10476
+ return fs$1.statSync(p).isDirectory();
10477
10477
  } catch {
10478
10478
  return false;
10479
10479
  }
@@ -10483,7 +10483,7 @@ function freeQuarantineTarget(store, scope, dirName) {
10483
10483
  const base = scope === null ? dirName : `${scope.replace("@", "")}__${dirName}`;
10484
10484
  let candidate = path$1.join(store, base);
10485
10485
  let n = 1;
10486
- while (fs.existsSync(candidate)) {
10486
+ while (fs$1.existsSync(candidate)) {
10487
10487
  candidate = path$1.join(store, `${base}-${n}`);
10488
10488
  n += 1;
10489
10489
  }
@@ -10500,7 +10500,7 @@ function freeQuarantineTarget(store, scope, dirName) {
10500
10500
  function quarantineAddonResidue(addonsDir, log) {
10501
10501
  const quarantined = [];
10502
10502
  const failed = [];
10503
- if (!fs.existsSync(addonsDir)) return {
10503
+ if (!fs$1.existsSync(addonsDir)) return {
10504
10504
  quarantined,
10505
10505
  failed
10506
10506
  };
@@ -10508,7 +10508,7 @@ function quarantineAddonResidue(addonsDir, log) {
10508
10508
  const scan = (parent, scope) => {
10509
10509
  let names;
10510
10510
  try {
10511
- names = fs.readdirSync(parent);
10511
+ names = fs$1.readdirSync(parent);
10512
10512
  } catch {
10513
10513
  return;
10514
10514
  }
@@ -10527,8 +10527,8 @@ function quarantineAddonResidue(addonsDir, log) {
10527
10527
  const version = readDeclaredVersion(full);
10528
10528
  const to = freeQuarantineTarget(store, scope, dirName);
10529
10529
  try {
10530
- fs.mkdirSync(store, { recursive: true });
10531
- fs.renameSync(full, to);
10530
+ fs$1.mkdirSync(store, { recursive: true });
10531
+ fs$1.renameSync(full, to);
10532
10532
  } catch (err) {
10533
10533
  const error = err instanceof Error ? err.message : String(err);
10534
10534
  failed.push({
@@ -10586,11 +10586,11 @@ function getRestartMarkerPath(dataDir) {
10586
10586
  * intact or no marker at all (never a half-written file).
10587
10587
  */
10588
10588
  function writePendingRestart(dataDir, marker) {
10589
- fs.mkdirSync(dataDir, { recursive: true });
10589
+ fs$1.mkdirSync(dataDir, { recursive: true });
10590
10590
  const markerPath = getRestartMarkerPath(dataDir);
10591
10591
  const tmpPath = `${markerPath}.tmp`;
10592
- fs.writeFileSync(tmpPath, JSON.stringify(marker, null, 2), "utf-8");
10593
- fs.renameSync(tmpPath, markerPath);
10592
+ fs$1.writeFileSync(tmpPath, JSON.stringify(marker, null, 2), "utf-8");
10593
+ fs$1.renameSync(tmpPath, markerPath);
10594
10594
  }
10595
10595
  /**
10596
10596
  * Read + consume the marker. Returns the parsed payload on success and
@@ -10615,10 +10615,10 @@ function writePendingRestart(dataDir, marker) {
10615
10615
  */
10616
10616
  function readPendingRestart(dataDir) {
10617
10617
  const markerPath = getRestartMarkerPath(dataDir);
10618
- if (!fs.existsSync(markerPath)) return null;
10618
+ if (!fs$1.existsSync(markerPath)) return null;
10619
10619
  let raw;
10620
10620
  try {
10621
- raw = fs.readFileSync(markerPath, "utf-8");
10621
+ raw = fs$1.readFileSync(markerPath, "utf-8");
10622
10622
  } catch (err) {
10623
10623
  console.error("[restart-coordinator] Marker unreadable — leaving in place:", err);
10624
10624
  return null;
@@ -10657,7 +10657,7 @@ function readPendingRestart(dataDir) {
10657
10657
  /** Remove the marker if present. No-op if missing. */
10658
10658
  function clearPendingRestart(dataDir) {
10659
10659
  const markerPath = getRestartMarkerPath(dataDir);
10660
- fs.rmSync(markerPath, { force: true });
10660
+ fs$1.rmSync(markerPath, { force: true });
10661
10661
  }
10662
10662
  function isRestartKind(value) {
10663
10663
  return value === "framework-update" || value === "manual" || value === "system";
@@ -10669,7 +10669,7 @@ function scheduleSelfRestart(options = {}) {
10669
10669
  const touchTarget = process.env["CAMSTACK_RESTART_TOUCH_FILE"];
10670
10670
  if (touchTarget !== void 0 && touchTarget.length > 0) try {
10671
10671
  const now = /* @__PURE__ */ new Date();
10672
- fs.utimesSync(touchTarget, now, now);
10672
+ fs$1.utimesSync(touchTarget, now, now);
10673
10673
  return;
10674
10674
  } catch (err) {
10675
10675
  console.error("[restart-coordinator] dev touch-reload failed; falling through to process exit:", err);
@@ -21431,7 +21431,7 @@ async function probeVaapiInit(renderNode) {
21431
21431
  */
21432
21432
  function safeExistsSync(path) {
21433
21433
  try {
21434
- return fs.existsSync(path);
21434
+ return fs$1.existsSync(path);
21435
21435
  } catch {
21436
21436
  return false;
21437
21437
  }
@@ -21450,11 +21450,11 @@ function probeLinuxGpus() {
21450
21450
  if (safeExistsSync("/dev/nvidia0") || safeExistsSync("/proc/driver/nvidia/version")) signals.hasNvidiaGpu = true;
21451
21451
  try {
21452
21452
  const drmDir = "/sys/class/drm";
21453
- if (fs.existsSync(drmDir)) for (const entry of fs.readdirSync(drmDir)) {
21453
+ if (fs$1.existsSync(drmDir)) for (const entry of fs$1.readdirSync(drmDir)) {
21454
21454
  if (!entry.startsWith("card")) continue;
21455
21455
  const vendorPath = `${drmDir}/${entry}/device/vendor`;
21456
21456
  if (!safeExistsSync(vendorPath)) continue;
21457
- const vendor = fs.readFileSync(vendorPath, "utf8").trim().toLowerCase();
21457
+ const vendor = fs$1.readFileSync(vendorPath, "utf8").trim().toLowerCase();
21458
21458
  if (vendor === "0x10de") signals.hasNvidiaGpu = true;
21459
21459
  else if (vendor === "0x1002") signals.hasAmdGpu = true;
21460
21460
  else if (vendor === "0x8086") signals.hasIntelGpu = true;
@@ -21677,21 +21677,21 @@ function sleep$1(ms) {
21677
21677
  * crashed holder) is stolen.
21678
21678
  */
21679
21679
  async function withFileLock(lockPath, fn) {
21680
- fs.mkdirSync(join(lockPath, ".."), { recursive: true });
21680
+ fs$1.mkdirSync(join(lockPath, ".."), { recursive: true });
21681
21681
  for (;;) try {
21682
- const fd = fs.openSync(lockPath, "wx");
21683
- fs.closeSync(fd);
21682
+ const fd = fs$1.openSync(lockPath, "wx");
21683
+ fs$1.closeSync(fd);
21684
21684
  break;
21685
21685
  } catch {
21686
21686
  try {
21687
- if (Date.now() - fs.statSync(lockPath).mtimeMs > LOCK_STALE_MS) fs.rmSync(lockPath, { force: true });
21687
+ if (Date.now() - fs$1.statSync(lockPath).mtimeMs > LOCK_STALE_MS) fs$1.rmSync(lockPath, { force: true });
21688
21688
  else await sleep$1(LOCK_POLL_MS);
21689
21689
  } catch {}
21690
21690
  }
21691
21691
  try {
21692
21692
  return await fn();
21693
21693
  } finally {
21694
- fs.rmSync(lockPath, { force: true });
21694
+ fs$1.rmSync(lockPath, { force: true });
21695
21695
  }
21696
21696
  }
21697
21697
  /** Coalesce in-process + serialize cross-process for one binary id. */
@@ -21749,7 +21749,7 @@ var AddonDepsManager = class {
21749
21749
  * failed or tampered download throws, and provisioning reports it.
21750
21750
  */
21751
21751
  async stageNativeDepsDeclaredBy(requirementsFile) {
21752
- if (!declaresEdgetpuDelegate(fs.readFileSync(requirementsFile, "utf8"))) return;
21752
+ if (!declaresEdgetpuDelegate(fs$1.readFileSync(requirementsFile, "utf8"))) return;
21753
21753
  await singleFlight(this.depsDir, "edgetpu-delegate", () => ensureEdgetpuDelegate(this.nodeRoot, this.logger));
21754
21754
  }
21755
21755
  getDepsDir() {
@@ -22780,7 +22780,7 @@ async function buildAddonContext(runtime, declaration, dataDir, options) {
22780
22780
  const addonId = declaration.id;
22781
22781
  const nodeDataDir = process.env["CAMSTACK_DATA"] ?? dataDir;
22782
22782
  const addonDataDir = path$1.resolve(nodeDataDir, "addons-data", addonId);
22783
- fs.mkdirSync(addonDataDir, { recursive: true });
22783
+ fs$1.mkdirSync(addonDataDir, { recursive: true });
22784
22784
  if (runtime.mode === "broker") ensureBindingSubscription(runtime.broker);
22785
22785
  const regs = getRegistries(nodeId);
22786
22786
  const workerResolver = {
@@ -24757,7 +24757,7 @@ var FailedRunnerRetryLedger = class {
24757
24757
  function readRunnerPackageVersions(addonDirs) {
24758
24758
  const out = {};
24759
24759
  for (const dir of addonDirs) try {
24760
- const raw = JSON.parse(fs.readFileSync(path$1.join(dir, "package.json"), "utf-8"));
24760
+ const raw = JSON.parse(fs$1.readFileSync(path$1.join(dir, "package.json"), "utf-8"));
24761
24761
  const version = typeof raw === "object" && raw !== null ? Reflect.get(raw, "version") : null;
24762
24762
  out[dir] = typeof version === "string" && version.length > 0 ? version : null;
24763
24763
  } catch {
@@ -24818,7 +24818,7 @@ function readAddonHeapDeclaration(spec) {
24818
24818
  if (cached !== void 0) return cached;
24819
24819
  let declaration = EMPTY_HEAP_DECLARATION;
24820
24820
  for (const manifestPath of [path$1.join(spec.addonDir, "package.json"), path$1.join(path$1.dirname(spec.addonDir), "package.json")]) try {
24821
- const raw = fs.readFileSync(manifestPath, "utf8");
24821
+ const raw = fs$1.readFileSync(manifestPath, "utf8");
24822
24822
  const parsed = JSON.parse(raw);
24823
24823
  const profile = extractHeapProfile(parsed, spec.addonId);
24824
24824
  const maxOldSpaceMb = extractMaxOldSpaceMb(parsed, spec.addonId);
@@ -26051,17 +26051,17 @@ var JobJournal = class {
26051
26051
  return path$1.join(this.jobsDir, `${id}.json`);
26052
26052
  }
26053
26053
  writeAtomic(filePath, data) {
26054
- fs.mkdirSync(path$1.dirname(filePath), { recursive: true });
26054
+ fs$1.mkdirSync(path$1.dirname(filePath), { recursive: true });
26055
26055
  const tmp = `${filePath}.tmp.${process.pid}.${Date.now()}`;
26056
- fs.writeFileSync(tmp, JSON.stringify(data, null, 2), {
26056
+ fs$1.writeFileSync(tmp, JSON.stringify(data, null, 2), {
26057
26057
  encoding: "utf-8",
26058
26058
  mode: 384
26059
26059
  });
26060
- fs.renameSync(tmp, filePath);
26060
+ fs$1.renameSync(tmp, filePath);
26061
26061
  }
26062
26062
  readIndex() {
26063
26063
  try {
26064
- const raw = JSON.parse(fs.readFileSync(this.indexPath, "utf-8"));
26064
+ const raw = JSON.parse(fs$1.readFileSync(this.indexPath, "utf-8"));
26065
26065
  if (raw && Array.isArray(raw.jobIds)) return {
26066
26066
  version: 1,
26067
26067
  jobIds: raw.jobIds
@@ -26086,7 +26086,7 @@ var JobJournal = class {
26086
26086
  }
26087
26087
  getJob(id) {
26088
26088
  try {
26089
- const parsed = lifecycleJobSchema.safeParse(JSON.parse(fs.readFileSync(this.jobPath(id), "utf-8")));
26089
+ const parsed = lifecycleJobSchema.safeParse(JSON.parse(fs$1.readFileSync(this.jobPath(id), "utf-8")));
26090
26090
  return parsed.success ? parsed.data : null;
26091
26091
  } catch {
26092
26092
  return null;
@@ -26151,14 +26151,14 @@ var StagingArea = class {
26151
26151
  }
26152
26152
  async fetchAndStage(input) {
26153
26153
  const destDir = path$1.join(this.stagingDir, input.jobId, safeSegment(input.name));
26154
- fs.rmSync(destDir, {
26154
+ fs$1.rmSync(destDir, {
26155
26155
  recursive: true,
26156
26156
  force: true
26157
26157
  });
26158
26158
  const tgz = await this.deps.fetchTarball(input.name, input.version, input.signal);
26159
26159
  if (input.signal.aborted) throw new Error("staging aborted after fetch");
26160
26160
  await this.deps.extract(tgz, destDir);
26161
- const raw = JSON.parse(fs.readFileSync(path$1.join(destDir, "package.json"), "utf-8"));
26161
+ const raw = JSON.parse(fs$1.readFileSync(path$1.join(destDir, "package.json"), "utf-8"));
26162
26162
  if (typeof raw.version !== "string" || raw.version.length === 0) throw new Error(`staging validation failed: ${input.name} staged a package.json with no version`);
26163
26163
  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}`);
26164
26164
  return {
@@ -26167,7 +26167,7 @@ var StagingArea = class {
26167
26167
  };
26168
26168
  }
26169
26169
  cleanup(jobId) {
26170
- fs.rmSync(path$1.join(this.stagingDir, jobId), {
26170
+ fs$1.rmSync(path$1.join(this.stagingDir, jobId), {
26171
26171
  recursive: true,
26172
26172
  force: true
26173
26173
  });
@@ -26182,13 +26182,13 @@ var StagingArea = class {
26182
26182
  sweepOrphans() {
26183
26183
  let entries;
26184
26184
  try {
26185
- entries = fs.readdirSync(this.stagingDir);
26185
+ entries = fs$1.readdirSync(this.stagingDir);
26186
26186
  } catch {
26187
26187
  return 0;
26188
26188
  }
26189
26189
  let removed = 0;
26190
26190
  for (const name of entries) try {
26191
- fs.rmSync(path$1.join(this.stagingDir, name), {
26191
+ fs$1.rmSync(path$1.join(this.stagingDir, name), {
26192
26192
  recursive: true,
26193
26193
  force: true
26194
26194
  });
@@ -26366,7 +26366,7 @@ var LifecycleJobEngine = class {
26366
26366
  * on failure → `failed`.
26367
26367
  */
26368
26368
  async reconcileJob(job) {
26369
- const exists = this.deps.stagedPathExists ?? ((p) => fs.existsSync(p));
26369
+ const exists = this.deps.stagedPathExists ?? ((p) => fs$1.existsSync(p));
26370
26370
  for (const task of job.tasks) {
26371
26371
  if (task.target === "framework") {
26372
26372
  if (!this.isTerminal(task.phase)) this.skipFrameworkTask(job, task);
@@ -27015,7 +27015,7 @@ var CatalogRegistry = class {
27015
27015
  const file = path$1.join(packageDir, "i18n", `${lang}.json`);
27016
27016
  let text;
27017
27017
  try {
27018
- text = fs.readFileSync(file, "utf8");
27018
+ text = fs$1.readFileSync(file, "utf8");
27019
27019
  } catch {
27020
27020
  continue;
27021
27021
  }